minidump_dump: dump stack memory like hexdump

The current stack output is one line byte string which is not easy for
humans to parse.  Extend the print mode to support a hexdump-like view
and switch to that by default.  Now we get something like:
Stack
00000000  20 67 7b 53 94 7f 00 00  01 00 00 00 00 00 00 00  | g{S...........|
00000010  00 70 c4 44 9a 25 00 00  08 65 7a 53 94 7f 00 00  |.p.D.%...ezS...|

BUG=chromium:598947

Change-Id: I868e1cf4faa435a14c5f1c35f94a5db4a49b6a6d
Reviewed-on: https://chromium-review.googlesource.com/404008
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Mike Frysinger 2016-10-25 20:12:09 -04:00
parent 117aa25107
commit e1b3620ec7
3 changed files with 97 additions and 14 deletions

View file

@ -236,6 +236,7 @@ class MinidumpMemoryRegion : public MinidumpObject,
// Print a human-readable representation of the object to stdout.
void Print() const;
void SetPrintMode(bool hexdump, unsigned int width);
protected:
explicit MinidumpMemoryRegion(Minidump* minidump);
@ -252,6 +253,10 @@ class MinidumpMemoryRegion : public MinidumpObject,
template<typename T> bool GetMemoryAtAddressInternal(uint64_t address,
T* value) const;
// Knobs for controlling display of memory printing.
bool hexdump_;
unsigned int hexdump_width_;
// The largest memory region that will be read from a minidump. The
// default is 1MB.
static uint32_t max_bytes_;
@ -1104,7 +1109,9 @@ class MinidumpLinuxMapsList : public MinidumpStream {
class Minidump {
public:
// path is the pathname of a file containing the minidump.
explicit Minidump(const string& path);
explicit Minidump(const string& path,
bool hexdump=false,
unsigned int hexdump_width=16);
// input is an istream wrapping minidump data. Minidump holds a
// weak pointer to input, and the caller must ensure that the stream
// is valid as long as the Minidump object is.
@ -1214,6 +1221,9 @@ class Minidump {
// Is the OS Android.
bool IsAndroid();
// Get current hexdump display settings.
unsigned int HexdumpMode() const { return hexdump_ ? hexdump_width_ : 0; }
private:
// MinidumpStreamInfo is used in the MinidumpStreamMap. It lets
// the Minidump object locate interesting streams quickly, and
@ -1275,6 +1285,10 @@ class Minidump {
// Read().
bool valid_;
// Knobs for controlling display of memory printing.
bool hexdump_;
unsigned int hexdump_width_;
DISALLOW_COPY_AND_ASSIGN(Minidump);
};