diff options
Diffstat (limited to 'src/google_breakpad/processor/minidump.h')
-rw-r--r-- | src/google_breakpad/processor/minidump.h | 103 |
1 files changed, 101 insertions, 2 deletions
diff --git a/src/google_breakpad/processor/minidump.h b/src/google_breakpad/processor/minidump.h index 51f15025..9c8448a3 100644 --- a/src/google_breakpad/processor/minidump.h +++ b/src/google_breakpad/processor/minidump.h @@ -88,12 +88,14 @@ #include <string> #include <vector> +#include "common/basictypes.h" #include "common/using_std_string.h" #include "google_breakpad/processor/code_module.h" #include "google_breakpad/processor/code_modules.h" #include "google_breakpad/processor/dump_context.h" #include "google_breakpad/processor/dump_object.h" #include "google_breakpad/processor/memory_region.h" +#include "google_breakpad/processor/proc_maps_linux.h" namespace google_breakpad { @@ -808,7 +810,7 @@ class MinidumpMemoryInfo : public MinidumpObject { // These objects are managed by MinidumpMemoryInfoList. friend class MinidumpMemoryInfoList; - explicit MinidumpMemoryInfo(Minidump* minidump); + explicit MinidumpMemoryInfo(Minidump* minidump_); // This works like MinidumpStream::Read, but is driven by // MinidumpMemoryInfoList. No size checking is done, because @@ -841,7 +843,7 @@ class MinidumpMemoryInfoList : public MinidumpStream { static const uint32_t kStreamType = MD_MEMORY_INFO_LIST_STREAM; - explicit MinidumpMemoryInfoList(Minidump* minidump); + explicit MinidumpMemoryInfoList(Minidump* minidump_); bool Read(uint32_t expected_size); @@ -852,6 +854,100 @@ class MinidumpMemoryInfoList : public MinidumpStream { uint32_t info_count_; }; +// MinidumpLinuxMaps wraps information about a single mapped memory region +// from /proc/self/maps. +class MinidumpLinuxMaps : public MinidumpObject { + public: + // The memory address of the base of the mapped region. + uint64_t GetBase() const { return valid_ ? region_.start : 0; } + // The size of the mapped region. + uint64_t GetSize() const { return valid_ ? region_.end - region_.start : 0; } + + // The permissions of the mapped region. + bool IsReadable() const { + return valid_ ? region_.permissions & MappedMemoryRegion::READ : false; + } + bool IsWriteable() const { + return valid_ ? region_.permissions & MappedMemoryRegion::WRITE : false; + } + bool IsExecutable() const { + return valid_ ? region_.permissions & MappedMemoryRegion::EXECUTE : false; + } + bool IsPrivate() const { + return valid_ ? region_.permissions & MappedMemoryRegion::PRIVATE : false; + } + + // The offset of the mapped region. + uint64_t GetOffset() const { return valid_ ? region_.offset : 0; } + + // The major device number. + uint8_t GetMajorDevice() const { return valid_ ? region_.major_device : 0; } + // The minor device number. + uint8_t GetMinorDevice() const { return valid_ ? region_.minor_device : 0; } + + // The inode of the mapped region. + uint64_t GetInode() const { return valid_ ? region_.inode : 0; } + + // The pathname of the mapped region. + const string GetPathname() const { return valid_ ? region_.path : ""; } + + // Print the contents of this mapping. + void Print(); + + private: + // These objects are managed by MinidumpLinuxMapsList. + friend class MinidumpLinuxMapsList; + + // This caller owns the pointer. + explicit MinidumpLinuxMaps(Minidump *minidump); + + // Read data about a single mapping from /proc/self/maps and load the data + // into this object. The input vector is in the same format as a line from + // /proc/self/maps. + + // The memory region struct that this class wraps. + MappedMemoryRegion region_; + + DISALLOW_COPY_AND_ASSIGN(MinidumpLinuxMaps); +}; + +// MinidumpLinuxMapsList corresponds to the Linux-exclusive MD_LINUX_MAPS +// stream, which contains the contents of /prod/self/maps, which contains +// the mapped memory regions and their access permissions. +class MinidumpLinuxMapsList : public MinidumpStream { + public: + virtual ~MinidumpLinuxMapsList(); + + // Get mapping at the given memory address. The caller owns the pointer. + const MinidumpLinuxMaps *GetLinuxMapsForAddress(uint64_t address) const; + // Get mapping at the given index. The caller owns the pointer. + const MinidumpLinuxMaps *GetLinuxMapsAtIndex(unsigned int index) const; + + // Print the contents of /proc/self/maps to stdout. + void Print(); + + private: + friend class Minidump; + + typedef vector<MinidumpLinuxMaps *> MinidumpLinuxMappings; + + static const uint32_t kStreamType = MD_LINUX_MAPS; + + // The caller owns the pointer. + explicit MinidumpLinuxMapsList(Minidump *minidump); + + // Read and load the contents of the process mapping data. + // The stream should have data in the form of /proc/self/maps. + // This method returns whether the stream was read successfully. + bool Read(uint32_t expected_size); + + // The list of individual mappings. + MinidumpLinuxMappings *maps_; + // The number of mappings. + uint32_t maps_count_; + + DISALLOW_COPY_AND_ASSIGN(MinidumpLinuxMapsList); +}; // Minidump is the user's interface to a minidump file. It wraps MDRawHeader // and provides access to the minidump's top-level stream directory. @@ -912,6 +1008,9 @@ class Minidump { virtual MinidumpBreakpadInfo* GetBreakpadInfo(); virtual MinidumpMemoryInfoList* GetMemoryInfoList(); + // The next method also calls GetStream, but is exclusive for Linux dumps. + virtual MinidumpLinuxMapsList *GetLinuxMapsList(); + // The next set of methods are provided for users who wish to access // data in minidump files directly, while leveraging the rest of // this class and related classes to handle the basic minidump |