diff options
author | ted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-09-17 14:01:10 +0000 |
---|---|---|
committer | ted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-09-17 14:01:10 +0000 |
commit | 54ede03227a7c90f4d9911b6f247c530e04e4ce9 (patch) | |
tree | 93281d8a64fa1a08c723bbdbf1a20f8294eaab95 /src/client/linux | |
parent | Fix compilation of crash_generation_server.cc, and add it to the client libra... (diff) | |
download | breakpad-54ede03227a7c90f4d9911b6f247c530e04e4ce9.tar.xz |
Allow setting a new MinidumpDescriptor on ExceptionHandler, also expose directory from MinidumpDescriptor
R=digit at https://breakpad.appspot.com/452003/
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1037 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/linux')
-rw-r--r-- | src/client/linux/handler/exception_handler.h | 4 | ||||
-rw-r--r-- | src/client/linux/handler/exception_handler_unittest.cc | 4 | ||||
-rw-r--r-- | src/client/linux/handler/minidump_descriptor.cc | 15 | ||||
-rw-r--r-- | src/client/linux/handler/minidump_descriptor.h | 9 |
4 files changed, 29 insertions, 3 deletions
diff --git a/src/client/linux/handler/exception_handler.h b/src/client/linux/handler/exception_handler.h index cde5ee8a..95817424 100644 --- a/src/client/linux/handler/exception_handler.h +++ b/src/client/linux/handler/exception_handler.h @@ -138,6 +138,10 @@ class ExceptionHandler { return minidump_descriptor_; } + void set_minidump_descriptor(const MinidumpDescriptor& descriptor) { + minidump_descriptor_ = descriptor; + } + void set_crash_handler(HandlerCallback callback) { crash_handler_ = callback; } diff --git a/src/client/linux/handler/exception_handler_unittest.cc b/src/client/linux/handler/exception_handler_unittest.cc index 991c85a6..83af35d5 100644 --- a/src/client/linux/handler/exception_handler_unittest.cc +++ b/src/client/linux/handler/exception_handler_unittest.cc @@ -125,6 +125,10 @@ TEST(ExceptionHandlerTest, SimpleWithPath) { AutoTempDir temp_dir; ExceptionHandler handler( MinidumpDescriptor(temp_dir.path()), NULL, NULL, NULL, true, -1); + EXPECT_EQ(temp_dir.path(), handler.minidump_descriptor().directory()); + string temp_subdir = temp_dir.path() + "/subdir"; + handler.set_minidump_descriptor(MinidumpDescriptor(temp_subdir)); + EXPECT_EQ(temp_subdir, handler.minidump_descriptor().directory()); } TEST(ExceptionHandlerTest, SimpleWithFD) { diff --git a/src/client/linux/handler/minidump_descriptor.cc b/src/client/linux/handler/minidump_descriptor.cc index 130764af..af314a94 100644 --- a/src/client/linux/handler/minidump_descriptor.cc +++ b/src/client/linux/handler/minidump_descriptor.cc @@ -45,6 +45,21 @@ MinidumpDescriptor::MinidumpDescriptor(const MinidumpDescriptor& descriptor) assert(descriptor.path_.empty()); } +MinidumpDescriptor& MinidumpDescriptor::operator=( + const MinidumpDescriptor& descriptor) { + assert(descriptor.path_.empty()); + + fd_ = descriptor.fd_; + directory_ = descriptor.directory_; + path_.clear(); + if (c_path_) { + // This descriptor already had a path set, so generate a new one. + c_path_ = NULL; + UpdatePath(); + } + return *this; +} + void MinidumpDescriptor::UpdatePath() { assert(fd_ == -1 && !directory_.empty()); diff --git a/src/client/linux/handler/minidump_descriptor.h b/src/client/linux/handler/minidump_descriptor.h index 5d331a3e..dc2719ac 100644 --- a/src/client/linux/handler/minidump_descriptor.h +++ b/src/client/linux/handler/minidump_descriptor.h @@ -45,7 +45,7 @@ class MinidumpDescriptor { public: MinidumpDescriptor() : fd_(-1) {} - explicit MinidumpDescriptor(const std::string& directory) + explicit MinidumpDescriptor(const string& directory) : fd_(-1), directory_(directory), c_path_(NULL) { @@ -57,11 +57,14 @@ class MinidumpDescriptor { } explicit MinidumpDescriptor(const MinidumpDescriptor& descriptor); + MinidumpDescriptor& operator=(const MinidumpDescriptor& descriptor); bool IsFD() const { return fd_ != -1; } int fd() const { return fd_; } + string directory() const { return directory_; } + const char* path() const { return c_path_; } // Updates the path so it is unique. @@ -70,10 +73,10 @@ class MinidumpDescriptor { private: // The file descriptor where the minidump is generated. - const int fd_; + int fd_; // The directory where the minidump should be generated. - const string directory_; + string directory_; // The full path to the generated minidump. string path_; // The C string of |path_|. Precomputed so it can be access from a compromised |