aboutsummaryrefslogtreecommitdiff
path: root/src/client/minidump_file_writer.h
diff options
context:
space:
mode:
authorjcivelli@chromium.org <jcivelli@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>2012-08-09 22:59:58 +0000
committerjcivelli@chromium.org <jcivelli@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>2012-08-09 22:59:58 +0000
commit43c933d7f8e490d9dbf3f939f3b2f095a170dc84 (patch)
tree153b8e0393f5e9f9f7edcf7f1d905cfd58571bad /src/client/minidump_file_writer.h
parentClean up warnings about narrowing conversion (diff)
downloadbreakpad-43c933d7f8e490d9dbf3f939f3b2f095a170dc84.tar.xz
Adding a way to create an ExceptionHandler that takes in a file descriptor
where the minidump should be created, without the need of opening any other file. BUG=None TEST=Run unit-tests. git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1007 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/minidump_file_writer.h')
-rw-r--r--src/client/minidump_file_writer.h29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/client/minidump_file_writer.h b/src/client/minidump_file_writer.h
index 21d4ce68..313b250b 100644
--- a/src/client/minidump_file_writer.h
+++ b/src/client/minidump_file_writer.h
@@ -55,6 +55,16 @@ template<typename MDType> class TypedMDRVA;
// header->get()->signature = MD_HEADER_SIGNATURE;
// :
// writer.Close();
+//
+// An alternative is to use SetFile and provide a file descriptor:
+// MinidumpFileWriter writer;
+// writer.SetFile(minidump_fd);
+// TypedMDRVA<MDRawHeader> header(&writer_);
+// header.Allocate();
+// header->get()->signature = MD_HEADER_SIGNATURE;
+// :
+// writer.Close();
+
class MinidumpFileWriter {
public:
// Invalid MDRVA (Minidump Relative Virtual Address)
@@ -66,11 +76,19 @@ public:
// Open |path| as the destination of the minidump data. Any existing file
// will be overwritten.
- // Return true on success, or false on failure
+ // Return true on success, or false on failure.
bool Open(const char *path);
- // Close the current file
- // Return true on success, or false on failure
+ // Sets the file descriptor |file| as the destination of the minidump data.
+ // Can be used as an alternative to Open() when a file descriptor is
+ // available.
+ // Note that |fd| is not closed when the instance of MinidumpFileWriter is
+ // destroyed.
+ void SetFile(const int file);
+
+ // Close the current file (that was either created when Open was called, or
+ // specified with SetFile).
+ // Return true on success, or false on failure.
bool Close();
// Copy the contents of |str| to a MDString and write it to the file.
@@ -106,9 +124,12 @@ public:
// unable to allocate the bytes.
MDRVA Allocate(size_t size);
- // The file descriptor for the output file
+ // The file descriptor for the output file.
int file_;
+ // Whether |file_| should be closed when the instance is destroyed.
+ bool close_file_when_destroyed_;
+
// Current position in buffer
MDRVA position_;