diff --git a/src/google_breakpad/processor/memory_region.h b/src/google_breakpad/processor/memory_region.h index 1ac3fe8d..6e01cddf 100644 --- a/src/google_breakpad/processor/memory_region.h +++ b/src/google_breakpad/processor/memory_region.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006, Google Inc. +// Copyright (c) 2010, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -50,10 +50,10 @@ class MemoryRegion { virtual ~MemoryRegion() {} // The base address of this memory region. - virtual u_int64_t GetBase() = 0; + virtual u_int64_t GetBase() const = 0; // The size of this memory region. - virtual u_int32_t GetSize() = 0; + virtual u_int32_t GetSize() const = 0; // Access to data of various sizes within the memory region. address // is a pointer to read, and it must lie within the memory region as @@ -63,10 +63,10 @@ class MemoryRegion { // program. Returns true on success. Fails and returns false if address // is out of the region's bounds (after considering the width of value), // or for other types of errors. - virtual bool GetMemoryAtAddress(u_int64_t address, u_int8_t* value) = 0; - virtual bool GetMemoryAtAddress(u_int64_t address, u_int16_t* value) = 0; - virtual bool GetMemoryAtAddress(u_int64_t address, u_int32_t* value) = 0; - virtual bool GetMemoryAtAddress(u_int64_t address, u_int64_t* value) = 0; + virtual bool GetMemoryAtAddress(u_int64_t address, u_int8_t* value) const =0; + virtual bool GetMemoryAtAddress(u_int64_t address, u_int16_t* value) const =0; + virtual bool GetMemoryAtAddress(u_int64_t address, u_int32_t* value) const =0; + virtual bool GetMemoryAtAddress(u_int64_t address, u_int64_t* value) const =0; }; diff --git a/src/google_breakpad/processor/minidump.h b/src/google_breakpad/processor/minidump.h index 2a83c3f0..4575fca3 100644 --- a/src/google_breakpad/processor/minidump.h +++ b/src/google_breakpad/processor/minidump.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006, Google Inc. +// Copyright (c) 2010, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -242,22 +242,22 @@ class MinidumpMemoryRegion : public MinidumpObject, // Returns a pointer to the base of the memory region. Returns the // cached value if available, otherwise, reads the minidump file and // caches the memory region. - const u_int8_t* GetMemory(); + const u_int8_t* GetMemory() const; // The address of the base of the memory region. - u_int64_t GetBase(); + u_int64_t GetBase() const; // The size, in bytes, of the memory region. - u_int32_t GetSize(); + u_int32_t GetSize() const; // Frees the cached memory region, if cached. void FreeMemory(); // Obtains the value of memory at the pointer specified by address. - bool GetMemoryAtAddress(u_int64_t address, u_int8_t* value); - bool GetMemoryAtAddress(u_int64_t address, u_int16_t* value); - bool GetMemoryAtAddress(u_int64_t address, u_int32_t* value); - bool GetMemoryAtAddress(u_int64_t address, u_int64_t* value); + bool GetMemoryAtAddress(u_int64_t address, u_int8_t* value) const; + bool GetMemoryAtAddress(u_int64_t address, u_int16_t* value) const; + bool GetMemoryAtAddress(u_int64_t address, u_int32_t* value) const; + bool GetMemoryAtAddress(u_int64_t address, u_int64_t* value) const; // Print a human-readable representation of the object to stdout. void Print(); @@ -274,7 +274,7 @@ class MinidumpMemoryRegion : public MinidumpObject, // Implementation for GetMemoryAtAddress template bool GetMemoryAtAddressInternal(u_int64_t address, - T* value); + T* value) const; // The largest memory region that will be read from a minidump. The // default is 1MB. @@ -285,7 +285,7 @@ class MinidumpMemoryRegion : public MinidumpObject, MDMemoryDescriptor* descriptor_; // Cached memory. - vector* memory_; + mutable vector* memory_; }; diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc index f82c9a7e..f2b82392 100644 --- a/src/processor/minidump.cc +++ b/src/processor/minidump.cc @@ -1106,7 +1106,7 @@ void MinidumpMemoryRegion::SetDescriptor(MDMemoryDescriptor* descriptor) { } -const u_int8_t* MinidumpMemoryRegion::GetMemory() { +const u_int8_t* MinidumpMemoryRegion::GetMemory() const { if (!valid_) { BPLOG(ERROR) << "Invalid MinidumpMemoryRegion for GetMemory"; return NULL; @@ -1145,7 +1145,7 @@ const u_int8_t* MinidumpMemoryRegion::GetMemory() { } -u_int64_t MinidumpMemoryRegion::GetBase() { +u_int64_t MinidumpMemoryRegion::GetBase() const { if (!valid_) { BPLOG(ERROR) << "Invalid MinidumpMemoryRegion for GetBase"; return static_cast(-1); @@ -1155,7 +1155,7 @@ u_int64_t MinidumpMemoryRegion::GetBase() { } -u_int32_t MinidumpMemoryRegion::GetSize() { +u_int32_t MinidumpMemoryRegion::GetSize() const { if (!valid_) { BPLOG(ERROR) << "Invalid MinidumpMemoryRegion for GetSize"; return 0; @@ -1173,7 +1173,7 @@ void MinidumpMemoryRegion::FreeMemory() { template bool MinidumpMemoryRegion::GetMemoryAtAddressInternal(u_int64_t address, - T* value) { + T* value) const { BPLOG_IF(ERROR, !value) << "MinidumpMemoryRegion::GetMemoryAtAddressInternal " "requires |value|"; assert(value); @@ -1215,25 +1215,25 @@ bool MinidumpMemoryRegion::GetMemoryAtAddressInternal(u_int64_t address, bool MinidumpMemoryRegion::GetMemoryAtAddress(u_int64_t address, - u_int8_t* value) { + u_int8_t* value) const { return GetMemoryAtAddressInternal(address, value); } bool MinidumpMemoryRegion::GetMemoryAtAddress(u_int64_t address, - u_int16_t* value) { + u_int16_t* value) const { return GetMemoryAtAddressInternal(address, value); } bool MinidumpMemoryRegion::GetMemoryAtAddress(u_int64_t address, - u_int32_t* value) { + u_int32_t* value) const { return GetMemoryAtAddressInternal(address, value); } bool MinidumpMemoryRegion::GetMemoryAtAddress(u_int64_t address, - u_int64_t* value) { + u_int64_t* value) const { return GetMemoryAtAddressInternal(address, value); } diff --git a/src/processor/postfix_evaluator.h b/src/processor/postfix_evaluator.h index 552ed159..d70bcaa0 100644 --- a/src/processor/postfix_evaluator.h +++ b/src/processor/postfix_evaluator.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006, Google Inc. +// Copyright (c) 2010, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -90,7 +90,7 @@ class PostfixEvaluator { // (^) will not be supported. |dictionary| may be NULL, but evaluation // will fail in that case unless set_dictionary is used before calling // Evaluate. - PostfixEvaluator(DictionaryType *dictionary, MemoryRegion *memory) + PostfixEvaluator(DictionaryType *dictionary, const MemoryRegion *memory) : dictionary_(dictionary), memory_(memory), stack_() {} // Evaluate the expression. The results of execution will be stored @@ -144,7 +144,7 @@ class PostfixEvaluator { // If non-NULL, the MemoryRegion used for dereference (^) operations. // If NULL, dereferencing is unsupported and will fail. Weak pointer. - MemoryRegion *memory_; + const MemoryRegion *memory_; // The stack contains state information as execution progresses. Values // are pushed on to it as the expression string is read and as operations diff --git a/src/processor/postfix_evaluator_unittest.cc b/src/processor/postfix_evaluator_unittest.cc index d687cc83..73aec468 100644 --- a/src/processor/postfix_evaluator_unittest.cc +++ b/src/processor/postfix_evaluator_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006, Google Inc. +// Copyright (c) 2010, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -56,21 +56,21 @@ using google_breakpad::PostfixEvaluator; // the value. class FakeMemoryRegion : public MemoryRegion { public: - virtual u_int64_t GetBase() { return 0; } - virtual u_int32_t GetSize() { return 0; } - virtual bool GetMemoryAtAddress(u_int64_t address, u_int8_t *value) { + virtual u_int64_t GetBase() const { return 0; } + virtual u_int32_t GetSize() const { return 0; } + virtual bool GetMemoryAtAddress(u_int64_t address, u_int8_t *value) const { *value = address + 1; return true; } - virtual bool GetMemoryAtAddress(u_int64_t address, u_int16_t *value) { + virtual bool GetMemoryAtAddress(u_int64_t address, u_int16_t *value) const { *value = address + 1; return true; } - virtual bool GetMemoryAtAddress(u_int64_t address, u_int32_t *value) { + virtual bool GetMemoryAtAddress(u_int64_t address, u_int32_t *value) const { *value = address + 1; return true; } - virtual bool GetMemoryAtAddress(u_int64_t address, u_int64_t *value) { + virtual bool GetMemoryAtAddress(u_int64_t address, u_int64_t *value) const { *value = address + 1; return true; }