From 43c933d7f8e490d9dbf3f939f3b2f095a170dc84 Mon Sep 17 00:00:00 2001 From: "jcivelli@chromium.org" Date: Thu, 9 Aug 2012 22:59:58 +0000 Subject: 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 --- src/client/minidump_file_writer.h | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/client/minidump_file_writer.h') 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 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 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_; -- cgit v1.2.1