Chromium Code Reviews| Index: src/google_breakpad/processor/minidump.h |
| =================================================================== |
| --- src/google_breakpad/processor/minidump.h (revision 1474) |
| +++ src/google_breakpad/processor/minidump.h (working copy) |
| @@ -94,6 +94,7 @@ |
| #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 { |
| @@ -123,7 +124,7 @@ |
| // for access to data about the minidump file itself, such as whether |
| // it should be byte-swapped. |
| Minidump* minidump_; |
| -}; |
| +}; |
|
ivanpe
2015/07/27 18:12:42
please, remove the whitespace after the ;
liuandrew
2015/07/27 23:09:26
Done.
|
| // This class exists primarily to provide a virtual destructor in a base |
| @@ -808,7 +809,7 @@ |
| // 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 +842,7 @@ |
| 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,7 +853,97 @@ |
| 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. |
| + long 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. |
| + struct MappedMemoryRegion region_; |
| +}; |
| + |
| +// 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_; |
| +}; |
| + |
| // Minidump is the user's interface to a minidump file. It wraps MDRawHeader |
| // and provides access to the minidump's top-level stream directory. |
| class Minidump { |
| @@ -912,6 +1003,9 @@ |
| 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 |