diff options
Diffstat (limited to 'src/google_breakpad')
6 files changed, 39 insertions, 52 deletions
diff --git a/src/google_breakpad/processor/basic_source_line_resolver.h b/src/google_breakpad/processor/basic_source_line_resolver.h index 6cf99705..f77b3bbb 100644 --- a/src/google_breakpad/processor/basic_source_line_resolver.h +++ b/src/google_breakpad/processor/basic_source_line_resolver.h @@ -55,6 +55,7 @@ class BasicSourceLineResolver : public SourceLineResolverBase { using SourceLineResolverBase::LoadModule; using SourceLineResolverBase::LoadModuleUsingMapBuffer; using SourceLineResolverBase::LoadModuleUsingMemoryBuffer; + using SourceLineResolverBase::ShouldDeleteMemoryBufferAfterLoadModule; using SourceLineResolverBase::UnloadModule; using SourceLineResolverBase::HasModule; using SourceLineResolverBase::FillSourceLineInfo; @@ -73,16 +74,6 @@ class BasicSourceLineResolver : public SourceLineResolverBase { // Module implements SourceLineResolverBase::Module interface. class Module; - // Helper methods to manage C-String format symbol data. - // See "google_breakpad/processor/source_line_resolver_base.h" for more - // comments about these helper methods. - virtual void DeleteDataAfterLoad(char *symbol_data); - // No-op helper methods. - virtual void DeleteDataUnload(const CodeModule *module) { } - virtual void ClearLocalMemory() { } - virtual void StoreDataBeforeLoad(const CodeModule *module, - char *symbol_data) { } - // Disallow unwanted copy ctor and assignment operator BasicSourceLineResolver(const BasicSourceLineResolver&); void operator=(const BasicSourceLineResolver&); diff --git a/src/google_breakpad/processor/fast_source_line_resolver.h b/src/google_breakpad/processor/fast_source_line_resolver.h index 4bb74f1a..60f6dfce 100644 --- a/src/google_breakpad/processor/fast_source_line_resolver.h +++ b/src/google_breakpad/processor/fast_source_line_resolver.h @@ -84,18 +84,10 @@ class FastSourceLineResolver : public SourceLineResolverBase { // Deserialize raw memory data to construct a WindowsFrameInfo object. static WindowsFrameInfo CopyWFI(const char *raw_memory); - // Helper methods to manage C-String format symbol data. - // See "google_breakpad/processor/source_line_resolver_base.h" for more - // comments about these helper methods. - virtual void StoreDataBeforeLoad(const CodeModule *module, char *symbol_data); - virtual void DeleteDataUnload(const CodeModule *module); - virtual void ClearLocalMemory(); - // No-op helper method. - virtual void DeleteDataAfterLoad(char *symbol_data) { } - - // Store memory data allocated in LoadModule and LoadModuleUsingMapBuffer. - typedef std::map<string, char*, CompareString> MemoryMap; - MemoryMap memory_chunks_; + // FastSourceLineResolver requires the memory buffer stays alive during the + // lifetime of a corresponding module, therefore it needs to redefine this + // virtual method. + virtual bool ShouldDeleteMemoryBufferAfterLoadModule(); // Disallow unwanted copy ctor and assignment operator FastSourceLineResolver(const FastSourceLineResolver&); diff --git a/src/google_breakpad/processor/network_source_line_resolver.h b/src/google_breakpad/processor/network_source_line_resolver.h index f60ff701..138b2f56 100644 --- a/src/google_breakpad/processor/network_source_line_resolver.h +++ b/src/google_breakpad/processor/network_source_line_resolver.h @@ -84,6 +84,10 @@ class NetworkSourceLineResolver : public SourceLineResolverInterface, virtual bool LoadModuleUsingMemoryBuffer(const CodeModule *module, char *memory_buffer); + // It doesn't matter whether returns true or false, since no memory buffer + // will be allocated in GetCStringSymbolData(). + virtual bool ShouldDeleteMemoryBufferAfterLoadModule() { return true; } + void UnloadModule(const CodeModule *module); virtual bool HasModule(const CodeModule *module); @@ -112,6 +116,11 @@ class NetworkSourceLineResolver : public SourceLineResolverInterface, string *symbol_file, char **symbol_data); + // Delete the data buffer allocated in GetCStringSymbolData(). + // Since the above GetCStringSymbolData() won't allocate any memory at all, + // this method is no-op. + virtual void FreeSymbolData(const CodeModule *module) { } + private: int wait_milliseconds_; // if false, some part of our network setup failed. diff --git a/src/google_breakpad/processor/source_line_resolver_base.h b/src/google_breakpad/processor/source_line_resolver_base.h index 8113e2ed..d950a736 100644 --- a/src/google_breakpad/processor/source_line_resolver_base.h +++ b/src/google_breakpad/processor/source_line_resolver_base.h @@ -73,35 +73,13 @@ class SourceLineResolverBase : public SourceLineResolverInterface { const string &map_buffer); virtual bool LoadModuleUsingMemoryBuffer(const CodeModule *module, char *memory_buffer); + virtual bool ShouldDeleteMemoryBufferAfterLoadModule(); virtual void UnloadModule(const CodeModule *module); virtual bool HasModule(const CodeModule *module); virtual void FillSourceLineInfo(StackFrame *frame); virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame); virtual CFIFrameInfo *FindCFIFrameInfo(const StackFrame *frame); - // Helper methods to manage C-String format symbol data. - // These methods are defined as no-op by default. - // - // StoreDataBeforeLoad() will be called in LoadModule() and - // LoadModuleUsingMapBuffer() to let subclass decide whether or how to store - // the dynamicly allocated memory data, before passing the data to - // LoadModuleUsingMemoryBuffer() which actually loads the module. - virtual void StoreDataBeforeLoad(const CodeModule *module, char *symbol_data); - - // DeleteDataAfterLoad() will be called at the end of - // LoadModuleUsingMemoryBuffer() to let subclass decide whether to delete the - // allocated memory data or not (which depends on whether the subclass has - // ownership of the data or not). - virtual void DeleteDataAfterLoad(char *symbol_data); - - // DeleteDataUnload() will be called in UnloadModule() to let subclass clean - // up dynamicly allocated data associated with the module, if there is any. - virtual void DeleteDataUnload(const CodeModule *module); - - // ClearLocalMemory() will be called in destructor to let subclass clean up - // all local memory data it owns, if there is any. - virtual void ClearLocalMemory(); - // Nested structs and classes. struct Line; struct Function; @@ -113,10 +91,14 @@ class SourceLineResolverBase : public SourceLineResolverInterface { class Module; class AutoFileCloser; - // All of the modules we've loaded + // All of the modules that are loaded. typedef map<string, Module*, CompareString> ModuleMap; ModuleMap *modules_; + // All of heap-allocated buffers that are owned locally by resolver. + typedef std::map<string, char*, CompareString> MemoryMap; + MemoryMap *memory_buffers_; + // Creates a concrete module at run-time. ModuleFactory *module_factory_; diff --git a/src/google_breakpad/processor/source_line_resolver_interface.h b/src/google_breakpad/processor/source_line_resolver_interface.h index bd6a12d6..103f979e 100644 --- a/src/google_breakpad/processor/source_line_resolver_interface.h +++ b/src/google_breakpad/processor/source_line_resolver_interface.h @@ -67,9 +67,15 @@ class SourceLineResolverInterface { // Add an interface to load symbol using C-String data insteading string. // This is useful in the optimization design for avoiding unnecessary copying // of symbol data, in order to improve memory efficiency. + // LoadModuleUsingMemoryBuffer() does NOT take ownership of memory_buffer. virtual bool LoadModuleUsingMemoryBuffer(const CodeModule *module, char *memory_buffer) = 0; + // Return true if the memory buffer should be deleted immediately after + // LoadModuleUsingMemoryBuffer(). Return false if the memory buffer has to be + // alive during the lifetime of the corresponding Module. + virtual bool ShouldDeleteMemoryBufferAfterLoadModule() = 0; + // Request that the specified module be unloaded from this resolver. // A resolver may choose to ignore such a request. virtual void UnloadModule(const CodeModule *module) = 0; @@ -79,7 +85,7 @@ class SourceLineResolverInterface { // Fills in the function_base, function_name, source_file_name, // and source_line fields of the StackFrame. The instruction and - // module_name fields must already be filled in. + // module_name fields must already be filled in. virtual void FillSourceLineInfo(StackFrame *frame) = 0; // If Windows stack walking information is available covering @@ -87,7 +93,7 @@ class SourceLineResolverInterface { // describing it. If the information is not available, returns NULL. // A NULL return value does not indicate an error. The caller takes // ownership of any returned WindowsFrameInfo object. - virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame) = 0; + virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame) = 0; // If CFI stack walking information is available covering ADDRESS, // return a CFIFrameInfo structure describing it. If the information diff --git a/src/google_breakpad/processor/symbol_supplier.h b/src/google_breakpad/processor/symbol_supplier.h index 4a41688e..26f5d7fa 100644 --- a/src/google_breakpad/processor/symbol_supplier.h +++ b/src/google_breakpad/processor/symbol_supplier.h @@ -76,14 +76,21 @@ class SymbolSupplier { string *symbol_file, string *symbol_data) = 0; - // Same as above, except places symbol data into symbol_data as C-string in - // dynamically allocated memory. Using C-string as type of symbol data enables - // passing data by pointer, and thus avoids unncessary copying of data (to - // improve memory efficiency). + // Same as above, except allocates data buffer on heap and then places the + // symbol data into the buffer as C-string. + // SymbolSupplier is responsible for deleting the data buffer. After the call + // to GetCStringSymbolData(), the caller should call FreeSymbolData(const + // Module *module) once the data buffer is no longer needed. + // If symbol_data is not NULL, symbol supplier won't return FOUND unless it + // returns a valid buffer in symbol_data, e.g., returns INTERRUPT on memory + // allocation failure. virtual SymbolResult GetCStringSymbolData(const CodeModule *module, const SystemInfo *system_info, string *symbol_file, char **symbol_data) = 0; + + // Frees the data buffer allocated for the module in GetCStringSymbolData. + virtual void FreeSymbolData(const CodeModule *module) = 0; }; } // namespace google_breakpad |