mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-03-11 17:06:31 +00:00
Use stdint types everywhere
R=mark at https://breakpad.appspot.com/535002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1121 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
@@ -63,7 +63,7 @@ class BasicCodeModule : public CodeModule {
|
||||
debug_identifier_(that->debug_identifier()),
|
||||
version_(that->version()) {}
|
||||
|
||||
BasicCodeModule(u_int64_t base_address, u_int64_t size,
|
||||
BasicCodeModule(uint64_t base_address, uint64_t size,
|
||||
const string &code_file,
|
||||
const string &code_identifier,
|
||||
const string &debug_file,
|
||||
@@ -81,8 +81,8 @@ class BasicCodeModule : public CodeModule {
|
||||
|
||||
// See code_module.h for descriptions of these methods and the associated
|
||||
// members.
|
||||
virtual u_int64_t base_address() const { return base_address_; }
|
||||
virtual u_int64_t size() const { return size_; }
|
||||
virtual uint64_t base_address() const { return base_address_; }
|
||||
virtual uint64_t size() const { return size_; }
|
||||
virtual string code_file() const { return code_file_; }
|
||||
virtual string code_identifier() const { return code_identifier_; }
|
||||
virtual string debug_file() const { return debug_file_; }
|
||||
@@ -91,8 +91,8 @@ class BasicCodeModule : public CodeModule {
|
||||
virtual const CodeModule* Copy() const { return new BasicCodeModule(this); }
|
||||
|
||||
private:
|
||||
u_int64_t base_address_;
|
||||
u_int64_t size_;
|
||||
uint64_t base_address_;
|
||||
uint64_t size_;
|
||||
string code_file_;
|
||||
string code_identifier_;
|
||||
string debug_file_;
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace google_breakpad {
|
||||
|
||||
BasicCodeModules::BasicCodeModules(const CodeModules *that)
|
||||
: main_address_(0),
|
||||
map_(new RangeMap<u_int64_t, linked_ptr<const CodeModule> >()) {
|
||||
map_(new RangeMap<uint64_t, linked_ptr<const CodeModule> >()) {
|
||||
BPLOG_IF(ERROR, !that) << "BasicCodeModules::BasicCodeModules requires "
|
||||
"|that|";
|
||||
assert(that);
|
||||
@@ -82,7 +82,7 @@ unsigned int BasicCodeModules::module_count() const {
|
||||
}
|
||||
|
||||
const CodeModule* BasicCodeModules::GetModuleForAddress(
|
||||
u_int64_t address) const {
|
||||
uint64_t address) const {
|
||||
linked_ptr<const CodeModule> module;
|
||||
if (!map_->RetrieveRange(address, &module, NULL, NULL)) {
|
||||
BPLOG(INFO) << "No module at " << HexString(address);
|
||||
|
||||
@@ -61,7 +61,7 @@ class BasicCodeModules : public CodeModules {
|
||||
|
||||
// See code_modules.h for descriptions of these methods.
|
||||
virtual unsigned int module_count() const;
|
||||
virtual const CodeModule* GetModuleForAddress(u_int64_t address) const;
|
||||
virtual const CodeModule* GetModuleForAddress(uint64_t address) const;
|
||||
virtual const CodeModule* GetMainModule() const;
|
||||
virtual const CodeModule* GetModuleAtSequence(unsigned int sequence) const;
|
||||
virtual const CodeModule* GetModuleAtIndex(unsigned int index) const;
|
||||
@@ -69,11 +69,11 @@ class BasicCodeModules : public CodeModules {
|
||||
|
||||
private:
|
||||
// The base address of the main module.
|
||||
u_int64_t main_address_;
|
||||
uint64_t main_address_;
|
||||
|
||||
// The map used to contain each CodeModule, keyed by each CodeModule's
|
||||
// address range.
|
||||
RangeMap<u_int64_t, linked_ptr<const CodeModule> > *map_;
|
||||
RangeMap<uint64_t, linked_ptr<const CodeModule> > *map_;
|
||||
|
||||
// Disallow copy constructor and assignment operator.
|
||||
BasicCodeModules(const BasicCodeModules &that);
|
||||
|
||||
@@ -299,8 +299,8 @@ BasicSourceLineResolver::Module::ParseFunction(char *function_line) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_int64_t address = strtoull(tokens[0], NULL, 16);
|
||||
u_int64_t size = strtoull(tokens[1], NULL, 16);
|
||||
uint64_t address = strtoull(tokens[0], NULL, 16);
|
||||
uint64_t size = strtoull(tokens[1], NULL, 16);
|
||||
int stack_param_size = strtoull(tokens[2], NULL, 16);
|
||||
char *name = tokens[3];
|
||||
|
||||
@@ -315,8 +315,8 @@ BasicSourceLineResolver::Line* BasicSourceLineResolver::Module::ParseLine(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_int64_t address = strtoull(tokens[0], NULL, 16);
|
||||
u_int64_t size = strtoull(tokens[1], NULL, 16);
|
||||
uint64_t address = strtoull(tokens[0], NULL, 16);
|
||||
uint64_t size = strtoull(tokens[1], NULL, 16);
|
||||
int line_number = atoi(tokens[2]);
|
||||
int source_file = atoi(tokens[3]);
|
||||
if (line_number <= 0) {
|
||||
@@ -337,7 +337,7 @@ bool BasicSourceLineResolver::Module::ParsePublicSymbol(char *public_line) {
|
||||
return false;
|
||||
}
|
||||
|
||||
u_int64_t address = strtoull(tokens[0], NULL, 16);
|
||||
uint64_t address = strtoull(tokens[0], NULL, 16);
|
||||
int stack_param_size = strtoull(tokens[1], NULL, 16);
|
||||
char *name = tokens[2];
|
||||
|
||||
@@ -372,7 +372,7 @@ bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) {
|
||||
// MSVC stack frame info.
|
||||
if (strcmp(platform, "WIN") == 0) {
|
||||
int type = 0;
|
||||
u_int64_t rva, code_size;
|
||||
uint64_t rva, code_size;
|
||||
linked_ptr<WindowsFrameInfo>
|
||||
stack_frame_info(WindowsFrameInfo::ParseFromString(stack_info_line,
|
||||
type,
|
||||
|
||||
@@ -59,8 +59,8 @@ class TestCodeModule : public CodeModule {
|
||||
TestCodeModule(string code_file) : code_file_(code_file) {}
|
||||
virtual ~TestCodeModule() {}
|
||||
|
||||
virtual u_int64_t base_address() const { return 0; }
|
||||
virtual u_int64_t size() const { return 0xb000; }
|
||||
virtual uint64_t base_address() const { return 0; }
|
||||
virtual uint64_t size() const { return 0xb000; }
|
||||
virtual string code_file() const { return code_file_; }
|
||||
virtual string code_identifier() const { return ""; }
|
||||
virtual string debug_file() const { return ""; }
|
||||
@@ -76,17 +76,17 @@ class TestCodeModule : public CodeModule {
|
||||
|
||||
// A mock memory region object, for use by the STACK CFI tests.
|
||||
class MockMemoryRegion: public MemoryRegion {
|
||||
u_int64_t GetBase() const { return 0x10000; }
|
||||
u_int32_t GetSize() const { return 0x01000; }
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int8_t *value) const {
|
||||
uint64_t GetBase() const { return 0x10000; }
|
||||
uint32_t GetSize() const { return 0x01000; }
|
||||
bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const {
|
||||
*value = address & 0xff;
|
||||
return true;
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int16_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const {
|
||||
*value = address & 0xffff;
|
||||
return true;
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int32_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const {
|
||||
switch (address) {
|
||||
case 0x10008: *value = 0x98ecadc3; break; // saved %ebx
|
||||
case 0x1000c: *value = 0x878f7524; break; // saved %esi
|
||||
@@ -97,7 +97,7 @@ class MockMemoryRegion: public MemoryRegion {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int64_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const {
|
||||
*value = address;
|
||||
return true;
|
||||
}
|
||||
@@ -109,9 +109,9 @@ class MockMemoryRegion: public MemoryRegion {
|
||||
// ".cfa".
|
||||
static bool VerifyRegisters(
|
||||
const char *file, int line,
|
||||
const CFIFrameInfo::RegisterValueMap<u_int32_t> &expected,
|
||||
const CFIFrameInfo::RegisterValueMap<u_int32_t> &actual) {
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t>::const_iterator a;
|
||||
const CFIFrameInfo::RegisterValueMap<uint32_t> &expected,
|
||||
const CFIFrameInfo::RegisterValueMap<uint32_t> &actual) {
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t>::const_iterator a;
|
||||
a = actual.find(".cfa");
|
||||
if (a == actual.end())
|
||||
return false;
|
||||
@@ -119,7 +119,7 @@ static bool VerifyRegisters(
|
||||
if (a == actual.end())
|
||||
return false;
|
||||
for (a = actual.begin(); a != actual.end(); a++) {
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t>::const_iterator e =
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t>::const_iterator e =
|
||||
expected.find(a->first);
|
||||
if (e == expected.end()) {
|
||||
fprintf(stderr, "%s:%d: unexpected register '%s' recovered, value 0x%x\n",
|
||||
@@ -252,9 +252,9 @@ TEST_F(TestBasicSourceLineResolver, TestLoadAndResolve)
|
||||
cfi_frame_info.reset(resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_FALSE(cfi_frame_info.get());
|
||||
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t> current_registers;
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t> caller_registers;
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t> expected_caller_registers;
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t> current_registers;
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t> caller_registers;
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t> expected_caller_registers;
|
||||
MockMemoryRegion memory;
|
||||
|
||||
// Regardless of which instruction evaluation takes place at, it
|
||||
@@ -277,7 +277,7 @@ TEST_F(TestBasicSourceLineResolver, TestLoadAndResolve)
|
||||
cfi_frame_info.reset(resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_TRUE(VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers));
|
||||
@@ -287,7 +287,7 @@ TEST_F(TestBasicSourceLineResolver, TestLoadAndResolve)
|
||||
cfi_frame_info.reset(resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_TRUE(VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers));
|
||||
@@ -297,7 +297,7 @@ TEST_F(TestBasicSourceLineResolver, TestLoadAndResolve)
|
||||
cfi_frame_info.reset(resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers);
|
||||
@@ -307,7 +307,7 @@ TEST_F(TestBasicSourceLineResolver, TestLoadAndResolve)
|
||||
cfi_frame_info.reset(resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers);
|
||||
@@ -317,7 +317,7 @@ TEST_F(TestBasicSourceLineResolver, TestLoadAndResolve)
|
||||
cfi_frame_info.reset(resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers);
|
||||
@@ -327,7 +327,7 @@ TEST_F(TestBasicSourceLineResolver, TestLoadAndResolve)
|
||||
cfi_frame_info.reset(resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace google_breakpad {
|
||||
using std::vector;
|
||||
|
||||
binarystream &binarystream::operator>>(string &str) {
|
||||
u_int16_t length;
|
||||
uint16_t length;
|
||||
*this >> length;
|
||||
if (eof())
|
||||
return *this;
|
||||
@@ -55,68 +55,68 @@ binarystream &binarystream::operator>>(string &str) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
binarystream &binarystream::operator>>(u_int8_t &u8) {
|
||||
binarystream &binarystream::operator>>(uint8_t &u8) {
|
||||
stream_.read((char *)&u8, 1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
binarystream &binarystream::operator>>(u_int16_t &u16) {
|
||||
u_int16_t temp;
|
||||
binarystream &binarystream::operator>>(uint16_t &u16) {
|
||||
uint16_t temp;
|
||||
stream_.read((char *)&temp, 2);
|
||||
if (!eof())
|
||||
u16 = ntohs(temp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
binarystream &binarystream::operator>>(u_int32_t &u32) {
|
||||
u_int32_t temp;
|
||||
binarystream &binarystream::operator>>(uint32_t &u32) {
|
||||
uint32_t temp;
|
||||
stream_.read((char *)&temp, 4);
|
||||
if (!eof())
|
||||
u32 = ntohl(temp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
binarystream &binarystream::operator>>(u_int64_t &u64) {
|
||||
u_int32_t lower, upper;
|
||||
binarystream &binarystream::operator>>(uint64_t &u64) {
|
||||
uint32_t lower, upper;
|
||||
*this >> lower >> upper;
|
||||
if (!eof())
|
||||
u64 = static_cast<u_int64_t>(lower) | (static_cast<u_int64_t>(upper) << 32);
|
||||
u64 = static_cast<uint64_t>(lower) | (static_cast<uint64_t>(upper) << 32);
|
||||
return *this;
|
||||
}
|
||||
|
||||
binarystream &binarystream::operator<<(const string &str) {
|
||||
if (str.length() > USHRT_MAX) {
|
||||
// truncate to 16-bit length
|
||||
*this << static_cast<u_int16_t>(USHRT_MAX);
|
||||
*this << static_cast<uint16_t>(USHRT_MAX);
|
||||
stream_.write(str.c_str(), USHRT_MAX);
|
||||
} else {
|
||||
*this << (u_int16_t)(str.length() & 0xFFFF);
|
||||
*this << (uint16_t)(str.length() & 0xFFFF);
|
||||
stream_.write(str.c_str(), str.length());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
binarystream &binarystream::operator<<(u_int8_t u8) {
|
||||
binarystream &binarystream::operator<<(uint8_t u8) {
|
||||
stream_.write((const char*)&u8, 1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
binarystream &binarystream::operator<<(u_int16_t u16) {
|
||||
binarystream &binarystream::operator<<(uint16_t u16) {
|
||||
u16 = htons(u16);
|
||||
stream_.write((const char*)&u16, 2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
binarystream &binarystream::operator<<(u_int32_t u32) {
|
||||
binarystream &binarystream::operator<<(uint32_t u32) {
|
||||
u32 = htonl(u32);
|
||||
stream_.write((const char*)&u32, 4);
|
||||
return *this;
|
||||
}
|
||||
|
||||
binarystream &binarystream::operator<<(u_int64_t u64) {
|
||||
binarystream &binarystream::operator<<(uint64_t u64) {
|
||||
// write 64-bit ints as two 32-bit ints, so we can byte-swap them easily
|
||||
u_int32_t lower = static_cast<u_int32_t>(u64 & 0xFFFFFFFF);
|
||||
u_int32_t upper = static_cast<u_int32_t>(u64 >> 32);
|
||||
uint32_t lower = static_cast<uint32_t>(u64 & 0xFFFFFFFF);
|
||||
uint32_t upper = static_cast<uint32_t>(u64 >> 32);
|
||||
*this << lower << upper;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -56,17 +56,17 @@ class binarystream {
|
||||
: stream_(string(str, size), which) {}
|
||||
|
||||
binarystream &operator>>(string &str);
|
||||
binarystream &operator>>(u_int8_t &u8);
|
||||
binarystream &operator>>(u_int16_t &u16);
|
||||
binarystream &operator>>(u_int32_t &u32);
|
||||
binarystream &operator>>(u_int64_t &u64);
|
||||
binarystream &operator>>(uint8_t &u8);
|
||||
binarystream &operator>>(uint16_t &u16);
|
||||
binarystream &operator>>(uint32_t &u32);
|
||||
binarystream &operator>>(uint64_t &u64);
|
||||
|
||||
// Note: strings are truncated at 65535 characters
|
||||
binarystream &operator<<(const string &str);
|
||||
binarystream &operator<<(u_int8_t u8);
|
||||
binarystream &operator<<(u_int16_t u16);
|
||||
binarystream &operator<<(u_int32_t u32);
|
||||
binarystream &operator<<(u_int64_t u64);
|
||||
binarystream &operator<<(uint8_t u8);
|
||||
binarystream &operator<<(uint16_t u16);
|
||||
binarystream &operator<<(uint32_t u32);
|
||||
binarystream &operator<<(uint64_t u64);
|
||||
|
||||
// Forward a few methods directly from the stream object
|
||||
bool eof() const { return stream_.eof(); }
|
||||
|
||||
@@ -47,14 +47,14 @@ protected:
|
||||
};
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadU8) {
|
||||
u_int8_t u8 = 0;
|
||||
uint8_t u8 = 0;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u8;
|
||||
ASSERT_TRUE(stream.eof());
|
||||
EXPECT_EQ(0U, u8);
|
||||
stream.rewind();
|
||||
stream.clear();
|
||||
stream << (u_int8_t)1;
|
||||
stream << (uint8_t)1;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u8;
|
||||
EXPECT_EQ(1, u8);
|
||||
@@ -62,14 +62,14 @@ TEST_F(BinaryStreamBasicTest, ReadU8) {
|
||||
}
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadU16) {
|
||||
u_int16_t u16 = 0;
|
||||
uint16_t u16 = 0;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u16;
|
||||
ASSERT_TRUE(stream.eof());
|
||||
EXPECT_EQ(0U, u16);
|
||||
stream.rewind();
|
||||
stream.clear();
|
||||
stream << (u_int16_t)1;
|
||||
stream << (uint16_t)1;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u16;
|
||||
EXPECT_EQ(1, u16);
|
||||
@@ -77,14 +77,14 @@ TEST_F(BinaryStreamBasicTest, ReadU16) {
|
||||
}
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadU32) {
|
||||
u_int32_t u32 = 0;
|
||||
uint32_t u32 = 0;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u32;
|
||||
ASSERT_TRUE(stream.eof());
|
||||
EXPECT_EQ(0U, u32);
|
||||
stream.rewind();
|
||||
stream.clear();
|
||||
stream << (u_int32_t)1;
|
||||
stream << (uint32_t)1;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u32;
|
||||
EXPECT_EQ(1U, u32);
|
||||
@@ -92,14 +92,14 @@ TEST_F(BinaryStreamBasicTest, ReadU32) {
|
||||
}
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadU64) {
|
||||
u_int64_t u64 = 0;
|
||||
uint64_t u64 = 0;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u64;
|
||||
ASSERT_TRUE(stream.eof());
|
||||
EXPECT_EQ(0U, u64);
|
||||
stream.rewind();
|
||||
stream.clear();
|
||||
stream << (u_int64_t)1;
|
||||
stream << (uint64_t)1;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u64;
|
||||
EXPECT_EQ(1U, u64);
|
||||
@@ -137,8 +137,8 @@ TEST_F(BinaryStreamBasicTest, ReadEmptyString) {
|
||||
}
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadMultiU8) {
|
||||
const u_int8_t ea = 0, eb = 100, ec = 200, ed = 0xFF;
|
||||
u_int8_t a, b, c, d, e;
|
||||
const uint8_t ea = 0, eb = 100, ec = 200, ed = 0xFF;
|
||||
uint8_t a, b, c, d, e;
|
||||
stream << ea << eb << ec << ed;
|
||||
stream >> a >> b >> c >> d;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
@@ -167,8 +167,8 @@ TEST_F(BinaryStreamBasicTest, ReadMultiU8) {
|
||||
}
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadMultiU16) {
|
||||
const u_int16_t ea = 0, eb = 0x100, ec = 0x8000, ed = 0xFFFF;
|
||||
u_int16_t a, b, c, d, e;
|
||||
const uint16_t ea = 0, eb = 0x100, ec = 0x8000, ed = 0xFFFF;
|
||||
uint16_t a, b, c, d, e;
|
||||
stream << ea << eb << ec << ed;
|
||||
stream >> a >> b >> c >> d;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
@@ -197,8 +197,8 @@ TEST_F(BinaryStreamBasicTest, ReadMultiU16) {
|
||||
}
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadMultiU32) {
|
||||
const u_int32_t ea = 0, eb = 0x10000, ec = 0x8000000, ed = 0xFFFFFFFF;
|
||||
u_int32_t a, b, c, d, e;
|
||||
const uint32_t ea = 0, eb = 0x10000, ec = 0x8000000, ed = 0xFFFFFFFF;
|
||||
uint32_t a, b, c, d, e;
|
||||
stream << ea << eb << ec << ed;
|
||||
stream >> a >> b >> c >> d;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
@@ -227,9 +227,9 @@ TEST_F(BinaryStreamBasicTest, ReadMultiU32) {
|
||||
}
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadMultiU64) {
|
||||
const u_int64_t ea = 0, eb = 0x10000, ec = 0x100000000ULL,
|
||||
const uint64_t ea = 0, eb = 0x10000, ec = 0x100000000ULL,
|
||||
ed = 0xFFFFFFFFFFFFFFFFULL;
|
||||
u_int64_t a, b, c, d, e;
|
||||
uint64_t a, b, c, d, e;
|
||||
stream << ea << eb << ec << ed;
|
||||
stream >> a >> b >> c >> d;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
@@ -258,15 +258,15 @@ TEST_F(BinaryStreamBasicTest, ReadMultiU64) {
|
||||
}
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadMixed) {
|
||||
const u_int8_t e8 = 0x10;
|
||||
const u_int16_t e16 = 0x2020;
|
||||
const u_int32_t e32 = 0x30303030;
|
||||
const u_int64_t e64 = 0x4040404040404040ULL;
|
||||
const uint8_t e8 = 0x10;
|
||||
const uint16_t e16 = 0x2020;
|
||||
const uint32_t e32 = 0x30303030;
|
||||
const uint64_t e64 = 0x4040404040404040ULL;
|
||||
const string es = "test";
|
||||
u_int8_t u8 = 0;
|
||||
u_int16_t u16 = 0;
|
||||
u_int32_t u32 = 0;
|
||||
u_int64_t u64 = 0;
|
||||
uint8_t u8 = 0;
|
||||
uint16_t u16 = 0;
|
||||
uint32_t u32 = 0;
|
||||
uint64_t u64 = 0;
|
||||
string s("test");
|
||||
stream << e8 << e16 << e32 << e64 << es;
|
||||
stream >> u8 >> u16 >> u32 >> u64 >> s;
|
||||
@@ -280,7 +280,7 @@ TEST_F(BinaryStreamBasicTest, ReadMixed) {
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadStringMissing) {
|
||||
// ensure that reading a string where only the length is present fails
|
||||
u_int16_t u16 = 8;
|
||||
uint16_t u16 = 8;
|
||||
stream << u16;
|
||||
stream.rewind();
|
||||
string s("");
|
||||
@@ -291,9 +291,9 @@ TEST_F(BinaryStreamBasicTest, ReadStringMissing) {
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, ReadStringTruncated) {
|
||||
// ensure that reading a string where not all the data is present fails
|
||||
u_int16_t u16 = 8;
|
||||
uint16_t u16 = 8;
|
||||
stream << u16;
|
||||
stream << (u_int8_t)'t' << (u_int8_t)'e' << (u_int8_t)'s' << (u_int8_t)'t';
|
||||
stream << (uint8_t)'t' << (uint8_t)'e' << (uint8_t)'s' << (uint8_t)'t';
|
||||
stream.rewind();
|
||||
string s("");
|
||||
stream >> s;
|
||||
@@ -303,7 +303,7 @@ TEST_F(BinaryStreamBasicTest, ReadStringTruncated) {
|
||||
|
||||
TEST_F(BinaryStreamBasicTest, StreamByteLength) {
|
||||
// Test that the stream buffer contains the right amount of data
|
||||
stream << (u_int8_t)0 << (u_int16_t)1 << (u_int32_t)2 << (u_int64_t)3
|
||||
stream << (uint8_t)0 << (uint16_t)1 << (uint32_t)2 << (uint64_t)3
|
||||
<< string("test");
|
||||
string s = stream.str();
|
||||
EXPECT_EQ(21U, s.length());
|
||||
@@ -313,8 +313,8 @@ TEST_F(BinaryStreamBasicTest, AppendStreamResultsByteLength) {
|
||||
// Test that appending the str() results from two streams
|
||||
// gives the right byte length
|
||||
binarystream stream2;
|
||||
stream << (u_int8_t)0 << (u_int16_t)1;
|
||||
stream2 << (u_int32_t)0 << (u_int64_t)2
|
||||
stream << (uint8_t)0 << (uint16_t)1;
|
||||
stream2 << (uint32_t)0 << (uint64_t)2
|
||||
<< string("test");
|
||||
string s = stream.str();
|
||||
string s2 = stream2.str();
|
||||
@@ -344,12 +344,12 @@ protected:
|
||||
binarystream stream;
|
||||
|
||||
void SetUp() {
|
||||
stream << (u_int8_t)1;
|
||||
stream << (uint8_t)1;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(BinaryStreamU8Test, ReadU16) {
|
||||
u_int16_t u16 = 0;
|
||||
uint16_t u16 = 0;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u16;
|
||||
ASSERT_TRUE(stream.eof());
|
||||
@@ -357,7 +357,7 @@ TEST_F(BinaryStreamU8Test, ReadU16) {
|
||||
}
|
||||
|
||||
TEST_F(BinaryStreamU8Test, ReadU32) {
|
||||
u_int32_t u32 = 0;
|
||||
uint32_t u32 = 0;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u32;
|
||||
ASSERT_TRUE(stream.eof());
|
||||
@@ -365,7 +365,7 @@ TEST_F(BinaryStreamU8Test, ReadU32) {
|
||||
}
|
||||
|
||||
TEST_F(BinaryStreamU8Test, ReadU64) {
|
||||
u_int64_t u64 = 0;
|
||||
uint64_t u64 = 0;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
stream >> u64;
|
||||
ASSERT_TRUE(stream.eof());
|
||||
@@ -384,7 +384,7 @@ TEST_F(BinaryStreamU8Test, ReadString) {
|
||||
TEST(BinaryStreamTest, InitWithData) {
|
||||
const char *data = "abcd";
|
||||
binarystream stream(data);
|
||||
u_int8_t a, b, c, d;
|
||||
uint8_t a, b, c, d;
|
||||
stream >> a >> b >> c >> d;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
EXPECT_EQ('a', a);
|
||||
@@ -396,7 +396,7 @@ TEST(BinaryStreamTest, InitWithData) {
|
||||
TEST(BinaryStreamTest, InitWithDataLeadingNull) {
|
||||
const char *data = "\0abcd";
|
||||
binarystream stream(data, 5);
|
||||
u_int8_t z, a, b, c, d;
|
||||
uint8_t z, a, b, c, d;
|
||||
stream >> z >> a >> b >> c >> d;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
EXPECT_EQ(0U, z);
|
||||
@@ -415,7 +415,7 @@ TEST(BinaryStreamTest, InitWithDataVector) {
|
||||
data.push_back('e');
|
||||
data.resize(4);
|
||||
binarystream stream(&data[0], data.size());
|
||||
u_int8_t a, b, c, d;
|
||||
uint8_t a, b, c, d;
|
||||
stream >> a >> b >> c >> d;
|
||||
ASSERT_FALSE(stream.eof());
|
||||
EXPECT_EQ('a', a);
|
||||
|
||||
@@ -88,14 +88,14 @@ bool CFIFrameInfo::FindCallerRegs(const RegisterValueMap<V> ®isters,
|
||||
}
|
||||
|
||||
// Explicit instantiations for 32-bit and 64-bit architectures.
|
||||
template bool CFIFrameInfo::FindCallerRegs<u_int32_t>(
|
||||
const RegisterValueMap<u_int32_t> ®isters,
|
||||
template bool CFIFrameInfo::FindCallerRegs<uint32_t>(
|
||||
const RegisterValueMap<uint32_t> ®isters,
|
||||
const MemoryRegion &memory,
|
||||
RegisterValueMap<u_int32_t> *caller_registers) const;
|
||||
template bool CFIFrameInfo::FindCallerRegs<u_int64_t>(
|
||||
const RegisterValueMap<u_int64_t> ®isters,
|
||||
RegisterValueMap<uint32_t> *caller_registers) const;
|
||||
template bool CFIFrameInfo::FindCallerRegs<uint64_t>(
|
||||
const RegisterValueMap<uint64_t> ®isters,
|
||||
const MemoryRegion &memory,
|
||||
RegisterValueMap<u_int64_t> *caller_registers) const;
|
||||
RegisterValueMap<uint64_t> *caller_registers) const;
|
||||
|
||||
string CFIFrameInfo::Serialize() const {
|
||||
std::ostringstream stream;
|
||||
|
||||
@@ -80,8 +80,8 @@ class CFIFrameInfo {
|
||||
|
||||
// Compute the values of the calling frame's registers, according to
|
||||
// this rule set. Use ValueType in expression evaluation; this
|
||||
// should be u_int32_t on machines with 32-bit addresses, or
|
||||
// u_int64_t on machines with 64-bit addresses.
|
||||
// should be uint32_t on machines with 32-bit addresses, or
|
||||
// uint64_t on machines with 64-bit addresses.
|
||||
//
|
||||
// Return true on success, false otherwise.
|
||||
//
|
||||
@@ -204,7 +204,7 @@ class CFIFrameInfoParseHandler: public CFIRuleParser::Handler {
|
||||
// up in a class should allow the walkers to share code.
|
||||
//
|
||||
// RegisterType should be the type of this architecture's registers, either
|
||||
// u_int32_t or u_int64_t. RawContextType should be the raw context
|
||||
// uint32_t or uint64_t. RawContextType should be the raw context
|
||||
// structure type for this architecture.
|
||||
template <typename RegisterType, class RawContextType>
|
||||
class SimpleCFIWalker {
|
||||
|
||||
@@ -54,12 +54,12 @@ using testing::Test;
|
||||
|
||||
class MockMemoryRegion: public MemoryRegion {
|
||||
public:
|
||||
MOCK_CONST_METHOD0(GetBase, u_int64_t());
|
||||
MOCK_CONST_METHOD0(GetSize, u_int32_t());
|
||||
MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(u_int64_t, u_int8_t *));
|
||||
MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(u_int64_t, u_int16_t *));
|
||||
MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(u_int64_t, u_int32_t *));
|
||||
MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(u_int64_t, u_int64_t *));
|
||||
MOCK_CONST_METHOD0(GetBase, uint64_t());
|
||||
MOCK_CONST_METHOD0(GetSize, uint32_t());
|
||||
MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint8_t *));
|
||||
MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint16_t *));
|
||||
MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint32_t *));
|
||||
MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint64_t *));
|
||||
};
|
||||
|
||||
// Handy definitions for all tests.
|
||||
@@ -69,15 +69,15 @@ struct CFIFixture {
|
||||
void ExpectNoMemoryReferences() {
|
||||
EXPECT_CALL(memory, GetBase()).Times(0);
|
||||
EXPECT_CALL(memory, GetSize()).Times(0);
|
||||
EXPECT_CALL(memory, GetMemoryAtAddress(_, A<u_int8_t *>())).Times(0);
|
||||
EXPECT_CALL(memory, GetMemoryAtAddress(_, A<u_int16_t *>())).Times(0);
|
||||
EXPECT_CALL(memory, GetMemoryAtAddress(_, A<u_int32_t *>())).Times(0);
|
||||
EXPECT_CALL(memory, GetMemoryAtAddress(_, A<u_int64_t *>())).Times(0);
|
||||
EXPECT_CALL(memory, GetMemoryAtAddress(_, A<uint8_t *>())).Times(0);
|
||||
EXPECT_CALL(memory, GetMemoryAtAddress(_, A<uint16_t *>())).Times(0);
|
||||
EXPECT_CALL(memory, GetMemoryAtAddress(_, A<uint32_t *>())).Times(0);
|
||||
EXPECT_CALL(memory, GetMemoryAtAddress(_, A<uint64_t *>())).Times(0);
|
||||
}
|
||||
|
||||
CFIFrameInfo cfi;
|
||||
MockMemoryRegion memory;
|
||||
CFIFrameInfo::RegisterValueMap<u_int64_t> registers, caller_registers;
|
||||
CFIFrameInfo::RegisterValueMap<uint64_t> registers, caller_registers;
|
||||
};
|
||||
|
||||
class Simple: public CFIFixture, public Test { };
|
||||
@@ -87,7 +87,7 @@ TEST_F(Simple, NoCFA) {
|
||||
ExpectNoMemoryReferences();
|
||||
|
||||
cfi.SetRARule("0");
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(".ra: 0", cfi.Serialize());
|
||||
}
|
||||
@@ -97,7 +97,7 @@ TEST_F(Simple, NoRA) {
|
||||
ExpectNoMemoryReferences();
|
||||
|
||||
cfi.SetCFARule("0");
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(".cfa: 0", cfi.Serialize());
|
||||
}
|
||||
@@ -107,7 +107,7 @@ TEST_F(Simple, SetCFAAndRARule) {
|
||||
|
||||
cfi.SetCFARule("330903416631436410");
|
||||
cfi.SetRARule("5870666104170902211");
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(2U, caller_registers.size());
|
||||
ASSERT_EQ(330903416631436410ULL, caller_registers[".cfa"]);
|
||||
@@ -126,7 +126,7 @@ TEST_F(Simple, SetManyRules) {
|
||||
cfi.SetRegisterRule("vodkathumbscrewingly", "24076308 .cfa +");
|
||||
cfi.SetRegisterRule("pubvexingfjordschmaltzy", ".cfa 29801007 -");
|
||||
cfi.SetRegisterRule("uncopyrightables", "92642917 .cfa /");
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(6U, caller_registers.size());
|
||||
ASSERT_EQ(7664691U, caller_registers[".cfa"]);
|
||||
@@ -150,7 +150,7 @@ TEST_F(Simple, RulesOverride) {
|
||||
cfi.SetCFARule("330903416631436410");
|
||||
cfi.SetRARule("5870666104170902211");
|
||||
cfi.SetCFARule("2828089117179001");
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(2U, caller_registers.size());
|
||||
ASSERT_EQ(2828089117179001ULL, caller_registers[".cfa"]);
|
||||
@@ -167,7 +167,7 @@ TEST_F(Scope, CFALacksCFA) {
|
||||
|
||||
cfi.SetCFARule(".cfa");
|
||||
cfi.SetRARule("0");
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ TEST_F(Scope, CFALacksRA) {
|
||||
|
||||
cfi.SetCFARule(".ra");
|
||||
cfi.SetRARule("0");
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ TEST_F(Scope, CFASeesCurrentRegs) {
|
||||
registers[".ornithorhynchus"] = 0x5e0bf850bafce9d2ULL;
|
||||
cfi.SetCFARule(".baraminology .ornithorhynchus +");
|
||||
cfi.SetRARule("0");
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(2U, caller_registers.size());
|
||||
ASSERT_EQ(0x06a7bc63e4f13893ULL + 0x5e0bf850bafce9d2ULL,
|
||||
@@ -203,7 +203,7 @@ TEST_F(Scope, RASeesCFA) {
|
||||
|
||||
cfi.SetCFARule("48364076");
|
||||
cfi.SetRARule(".cfa");
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(2U, caller_registers.size());
|
||||
ASSERT_EQ(48364076U, caller_registers[".ra"]);
|
||||
@@ -215,7 +215,7 @@ TEST_F(Scope, RALacksRA) {
|
||||
|
||||
cfi.SetCFARule("0");
|
||||
cfi.SetRARule(".ra");
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ TEST_F(Scope, RASeesCurrentRegs) {
|
||||
registers["noachian"] = 0x54dc4a5d8e5eb503ULL;
|
||||
cfi.SetCFARule("10359370");
|
||||
cfi.SetRARule("noachian");
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(2U, caller_registers.size());
|
||||
ASSERT_EQ(0x54dc4a5d8e5eb503ULL, caller_registers[".ra"]);
|
||||
@@ -240,7 +240,7 @@ TEST_F(Scope, RegistersSeeCFA) {
|
||||
cfi.SetCFARule("6515179");
|
||||
cfi.SetRARule(".cfa");
|
||||
cfi.SetRegisterRule("rogerian", ".cfa");
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(3U, caller_registers.size());
|
||||
ASSERT_EQ(6515179U, caller_registers["rogerian"]);
|
||||
@@ -253,7 +253,7 @@ TEST_F(Scope, RegsLackRA) {
|
||||
cfi.SetCFARule("42740329");
|
||||
cfi.SetRARule("27045204");
|
||||
cfi.SetRegisterRule("$r1", ".ra");
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ TEST_F(Scope, RegsSeeRegs) {
|
||||
cfi.SetRARule("30503835");
|
||||
cfi.SetRegisterRule("$r1", "$r1 42175211 = $r2");
|
||||
cfi.SetRegisterRule("$r2", "$r2 21357221 = $r1");
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(4U, caller_registers.size());
|
||||
ASSERT_EQ(0xd27d9e742b8df6d0ULL, caller_registers["$r1"]);
|
||||
@@ -280,12 +280,12 @@ TEST_F(Scope, SeparateTempsRA) {
|
||||
|
||||
cfi.SetCFARule("$temp1 76569129 = $temp1");
|
||||
cfi.SetRARule("0");
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
|
||||
cfi.SetCFARule("$temp1 76569129 = $temp1");
|
||||
cfi.SetRARule("$temp1");
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_FALSE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ TEST_F(ParseHandler, CFARARule) {
|
||||
handler.RARule("reg-for-ra");
|
||||
registers["reg-for-cfa"] = 0x268a9a4a3821a797ULL;
|
||||
registers["reg-for-ra"] = 0x6301b475b8b91c02ULL;
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(0x268a9a4a3821a797ULL, caller_registers[".cfa"]);
|
||||
ASSERT_EQ(0x6301b475b8b91c02ULL, caller_registers[".ra"]);
|
||||
@@ -442,7 +442,7 @@ TEST_F(ParseHandler, RegisterRules) {
|
||||
registers["reg-for-ra"] = 0x6301b475b8b91c02ULL;
|
||||
registers["reg-for-reg1"] = 0x06cde8e2ff062481ULL;
|
||||
registers["reg-for-reg2"] = 0xff0c4f76403173e2ULL;
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<u_int64_t>(registers, memory,
|
||||
ASSERT_TRUE(cfi.FindCallerRegs<uint64_t>(registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_EQ(0x268a9a4a3821a797ULL, caller_registers[".cfa"]);
|
||||
ASSERT_EQ(0x6301b475b8b91c02ULL, caller_registers[".ra"]);
|
||||
@@ -452,7 +452,7 @@ TEST_F(ParseHandler, RegisterRules) {
|
||||
|
||||
struct SimpleCFIWalkerFixture {
|
||||
struct RawContext {
|
||||
u_int64_t r0, r1, r2, r3, r4, sp, pc;
|
||||
uint64_t r0, r1, r2, r3, r4, sp, pc;
|
||||
};
|
||||
enum Validity {
|
||||
R0_VALID = 0x01,
|
||||
@@ -463,7 +463,7 @@ struct SimpleCFIWalkerFixture {
|
||||
SP_VALID = 0x20,
|
||||
PC_VALID = 0x40
|
||||
};
|
||||
typedef SimpleCFIWalker<u_int64_t, RawContext> CFIWalker;
|
||||
typedef SimpleCFIWalker<uint64_t, RawContext> CFIWalker;
|
||||
|
||||
SimpleCFIWalkerFixture()
|
||||
: walker(register_map,
|
||||
@@ -504,16 +504,16 @@ TEST_F(SimpleWalker, Walk) {
|
||||
// r4 is not recoverable, even though it is a callee-saves register.
|
||||
// Some earlier frame's unwinder must have failed to recover it.
|
||||
|
||||
u_int64_t stack_top = 0x83254944b20d5512ULL;
|
||||
uint64_t stack_top = 0x83254944b20d5512ULL;
|
||||
|
||||
// Saved r0.
|
||||
EXPECT_CALL(memory,
|
||||
GetMemoryAtAddress(stack_top, A<u_int64_t *>()))
|
||||
GetMemoryAtAddress(stack_top, A<uint64_t *>()))
|
||||
.WillRepeatedly(DoAll(SetArgumentPointee<1>(0xdc1975eba8602302ULL),
|
||||
Return(true)));
|
||||
// Saved return address.
|
||||
EXPECT_CALL(memory,
|
||||
GetMemoryAtAddress(stack_top + 16, A<u_int64_t *>()))
|
||||
GetMemoryAtAddress(stack_top + 16, A<uint64_t *>()))
|
||||
.WillRepeatedly(DoAll(SetArgumentPointee<1>(0xba5ad6d9acce28deULL),
|
||||
Return(true)));
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
|
||||
namespace google_breakpad {
|
||||
|
||||
DisassemblerX86::DisassemblerX86(const u_int8_t *bytecode,
|
||||
u_int32_t size,
|
||||
u_int32_t virtual_address) :
|
||||
DisassemblerX86::DisassemblerX86(const uint8_t *bytecode,
|
||||
uint32_t size,
|
||||
uint32_t virtual_address) :
|
||||
bytecode_(bytecode),
|
||||
size_(size),
|
||||
virtual_address_(virtual_address),
|
||||
@@ -54,7 +54,7 @@ DisassemblerX86::~DisassemblerX86() {
|
||||
libdis::x86_cleanup();
|
||||
}
|
||||
|
||||
u_int32_t DisassemblerX86::NextInstruction() {
|
||||
uint32_t DisassemblerX86::NextInstruction() {
|
||||
if (instr_valid_)
|
||||
libdis::x86_oplist_free(¤t_instr_);
|
||||
|
||||
@@ -62,7 +62,7 @@ u_int32_t DisassemblerX86::NextInstruction() {
|
||||
instr_valid_ = false;
|
||||
return 0;
|
||||
}
|
||||
u_int32_t instr_size = 0;
|
||||
uint32_t instr_size = 0;
|
||||
instr_size = libdis::x86_disasm((unsigned char *)bytecode_, size_,
|
||||
virtual_address_, current_byte_offset_,
|
||||
¤t_instr_);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#define GOOGLE_BREAKPAD_PROCESSOR_DISASSEMBLER_X86_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "google_breakpad/common/breakpad_types.h"
|
||||
|
||||
@@ -62,7 +63,7 @@ class DisassemblerX86 {
|
||||
// TODO(cdn): Modify this class to take a MemoryRegion instead of just
|
||||
// a raw buffer. This will make it easier to use this on arbitrary
|
||||
// minidumps without first copying out the code segment.
|
||||
DisassemblerX86(const u_int8_t *bytecode, u_int32_t, u_int32_t);
|
||||
DisassemblerX86(const uint8_t *bytecode, uint32_t, uint32_t);
|
||||
~DisassemblerX86();
|
||||
|
||||
// This walks to the next instruction in the memory region and
|
||||
@@ -70,7 +71,7 @@ class DisassemblerX86 {
|
||||
// including any registers marked as bad through setBadRead()
|
||||
// or setBadWrite(). This method can be called in a loop to
|
||||
// disassemble until the end of a region.
|
||||
u_int32_t NextInstruction();
|
||||
uint32_t NextInstruction();
|
||||
|
||||
// Indicates whether the current disassembled instruction was valid.
|
||||
bool currentInstructionValid() { return instr_valid_; }
|
||||
@@ -90,7 +91,7 @@ class DisassemblerX86 {
|
||||
bool endOfBlock() { return end_of_block_; }
|
||||
|
||||
// The flags set so far for the disassembly.
|
||||
u_int16_t flags() { return flags_; }
|
||||
uint16_t flags() { return flags_; }
|
||||
|
||||
// This sets an indicator that the register used to determine
|
||||
// src or dest for the current instruction is tainted. These can
|
||||
@@ -101,11 +102,11 @@ class DisassemblerX86 {
|
||||
bool setBadWrite();
|
||||
|
||||
protected:
|
||||
const u_int8_t *bytecode_;
|
||||
u_int32_t size_;
|
||||
u_int32_t virtual_address_;
|
||||
u_int32_t current_byte_offset_;
|
||||
u_int32_t current_inst_offset_;
|
||||
const uint8_t *bytecode_;
|
||||
uint32_t size_;
|
||||
uint32_t virtual_address_;
|
||||
uint32_t current_byte_offset_;
|
||||
uint32_t current_inst_offset_;
|
||||
|
||||
bool instr_valid_;
|
||||
libdis::x86_insn_t current_instr_;
|
||||
@@ -118,7 +119,7 @@ class DisassemblerX86 {
|
||||
bool pushed_bad_value_;
|
||||
bool end_of_block_;
|
||||
|
||||
u_int16_t flags_;
|
||||
uint16_t flags_;
|
||||
};
|
||||
|
||||
} // namespace google_breakpad
|
||||
|
||||
@@ -92,9 +92,9 @@ Exploitability *Exploitability::ExploitabilityForPlatform(
|
||||
return platform_exploitability;
|
||||
}
|
||||
|
||||
bool Exploitability::AddressIsAscii(u_int64_t address) {
|
||||
bool Exploitability::AddressIsAscii(uint64_t address) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
u_int8_t byte = (address >> (8*i)) & 0xff;
|
||||
uint8_t byte = (address >> (8*i)) & 0xff;
|
||||
if ((byte >= ' ' && byte <= '~') || byte == 0)
|
||||
continue;
|
||||
return false;
|
||||
|
||||
@@ -50,8 +50,8 @@ namespace google_breakpad {
|
||||
|
||||
// The cutoff that we use to judge if and address is likely an offset
|
||||
// from various interesting addresses.
|
||||
static const u_int64_t kProbableNullOffset = 4096;
|
||||
static const u_int64_t kProbableStackOffset = 8192;
|
||||
static const uint64_t kProbableNullOffset = 4096;
|
||||
static const uint64_t kProbableStackOffset = 8192;
|
||||
|
||||
// The various cutoffs for the different ratings.
|
||||
static const size_t kHighCutoff = 100;
|
||||
@@ -98,14 +98,14 @@ ExploitabilityRating ExploitabilityWin::CheckPlatformExploitability() {
|
||||
BPLOG(INFO) << "Minidump memory segments not available.";
|
||||
memory_available = false;
|
||||
}
|
||||
u_int64_t address = process_state_->crash_address();
|
||||
u_int32_t exception_code = raw_exception->exception_record.exception_code;
|
||||
uint64_t address = process_state_->crash_address();
|
||||
uint32_t exception_code = raw_exception->exception_record.exception_code;
|
||||
|
||||
u_int32_t exploitability_weight = 0;
|
||||
uint32_t exploitability_weight = 0;
|
||||
|
||||
u_int64_t stack_ptr = 0;
|
||||
u_int64_t instruction_ptr = 0;
|
||||
u_int64_t this_ptr = 0;
|
||||
uint64_t stack_ptr = 0;
|
||||
uint64_t instruction_ptr = 0;
|
||||
uint64_t this_ptr = 0;
|
||||
|
||||
switch (context->GetContextCPU()) {
|
||||
case MD_CONTEXT_X86:
|
||||
@@ -211,14 +211,14 @@ ExploitabilityRating ExploitabilityWin::CheckPlatformExploitability() {
|
||||
context->GetContextCPU() == MD_CONTEXT_X86 &&
|
||||
(bad_read || bad_write)) {
|
||||
// Perform checks related to memory around instruction pointer.
|
||||
u_int32_t memory_offset =
|
||||
uint32_t memory_offset =
|
||||
instruction_ptr - instruction_region->GetBase();
|
||||
u_int32_t available_memory =
|
||||
uint32_t available_memory =
|
||||
instruction_region->GetSize() - memory_offset;
|
||||
available_memory = available_memory > kDisassembleBytesBeyondPC ?
|
||||
kDisassembleBytesBeyondPC : available_memory;
|
||||
if (available_memory) {
|
||||
const u_int8_t *raw_memory =
|
||||
const uint8_t *raw_memory =
|
||||
instruction_region->GetMemory() + memory_offset;
|
||||
DisassemblerX86 disassembler(raw_memory,
|
||||
available_memory,
|
||||
|
||||
@@ -116,15 +116,15 @@ WindowsFrameInfo FastSourceLineResolver::CopyWFI(const char *raw) {
|
||||
// The first 8 bytes of int data are unused.
|
||||
// They correspond to "StackInfoTypes type_;" and "int valid;"
|
||||
// data member of WFI.
|
||||
const u_int32_t *para_uint32 = reinterpret_cast<const u_int32_t*>(
|
||||
const uint32_t *para_uint32 = reinterpret_cast<const uint32_t*>(
|
||||
raw + 2 * sizeof(int32_t));
|
||||
|
||||
u_int32_t prolog_size = para_uint32[0];;
|
||||
u_int32_t epilog_size = para_uint32[1];
|
||||
u_int32_t parameter_size = para_uint32[2];
|
||||
u_int32_t saved_register_size = para_uint32[3];
|
||||
u_int32_t local_size = para_uint32[4];
|
||||
u_int32_t max_stack_size = para_uint32[5];
|
||||
uint32_t prolog_size = para_uint32[0];;
|
||||
uint32_t epilog_size = para_uint32[1];
|
||||
uint32_t parameter_size = para_uint32[2];
|
||||
uint32_t saved_register_size = para_uint32[3];
|
||||
uint32_t local_size = para_uint32[4];
|
||||
uint32_t max_stack_size = para_uint32[5];
|
||||
const char *boolean = reinterpret_cast<const char*>(para_uint32 + 6);
|
||||
bool allocates_base_pointer = (*boolean != 0);
|
||||
string program_string = boolean + 1;
|
||||
@@ -146,7 +146,7 @@ WindowsFrameInfo FastSourceLineResolver::CopyWFI(const char *raw) {
|
||||
bool FastSourceLineResolver::Module::LoadMapFromMemory(char *mem_buffer) {
|
||||
if (!mem_buffer) return false;
|
||||
|
||||
const u_int32_t *map_sizes = reinterpret_cast<const u_int32_t*>(mem_buffer);
|
||||
const uint32_t *map_sizes = reinterpret_cast<const uint32_t*>(mem_buffer);
|
||||
|
||||
unsigned int header_size = kNumberMaps_ * sizeof(unsigned int);
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ class TestCodeModule : public CodeModule {
|
||||
explicit TestCodeModule(string code_file) : code_file_(code_file) {}
|
||||
virtual ~TestCodeModule() {}
|
||||
|
||||
virtual u_int64_t base_address() const { return 0; }
|
||||
virtual u_int64_t size() const { return 0xb000; }
|
||||
virtual uint64_t base_address() const { return 0; }
|
||||
virtual uint64_t size() const { return 0xb000; }
|
||||
virtual string code_file() const { return code_file_; }
|
||||
virtual string code_identifier() const { return ""; }
|
||||
virtual string debug_file() const { return ""; }
|
||||
@@ -88,17 +88,17 @@ class TestCodeModule : public CodeModule {
|
||||
|
||||
// A mock memory region object, for use by the STACK CFI tests.
|
||||
class MockMemoryRegion: public MemoryRegion {
|
||||
u_int64_t GetBase() const { return 0x10000; }
|
||||
u_int32_t GetSize() const { return 0x01000; }
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int8_t *value) const {
|
||||
uint64_t GetBase() const { return 0x10000; }
|
||||
uint32_t GetSize() const { return 0x01000; }
|
||||
bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const {
|
||||
*value = address & 0xff;
|
||||
return true;
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int16_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const {
|
||||
*value = address & 0xffff;
|
||||
return true;
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int32_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const {
|
||||
switch (address) {
|
||||
case 0x10008: *value = 0x98ecadc3; break; // saved %ebx
|
||||
case 0x1000c: *value = 0x878f7524; break; // saved %esi
|
||||
@@ -109,7 +109,7 @@ class MockMemoryRegion: public MemoryRegion {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int64_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const {
|
||||
*value = address;
|
||||
return true;
|
||||
}
|
||||
@@ -121,9 +121,9 @@ class MockMemoryRegion: public MemoryRegion {
|
||||
// ".cfa".
|
||||
static bool VerifyRegisters(
|
||||
const char *file, int line,
|
||||
const CFIFrameInfo::RegisterValueMap<u_int32_t> &expected,
|
||||
const CFIFrameInfo::RegisterValueMap<u_int32_t> &actual) {
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t>::const_iterator a;
|
||||
const CFIFrameInfo::RegisterValueMap<uint32_t> &expected,
|
||||
const CFIFrameInfo::RegisterValueMap<uint32_t> &actual) {
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t>::const_iterator a;
|
||||
a = actual.find(".cfa");
|
||||
if (a == actual.end())
|
||||
return false;
|
||||
@@ -131,7 +131,7 @@ static bool VerifyRegisters(
|
||||
if (a == actual.end())
|
||||
return false;
|
||||
for (a = actual.begin(); a != actual.end(); a++) {
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t>::const_iterator e =
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t>::const_iterator e =
|
||||
expected.find(a->first);
|
||||
if (e == expected.end()) {
|
||||
fprintf(stderr, "%s:%d: unexpected register '%s' recovered, value 0x%x\n",
|
||||
@@ -280,9 +280,9 @@ TEST_F(TestFastSourceLineResolver, TestLoadAndResolve) {
|
||||
cfi_frame_info.reset(fast_resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_FALSE(cfi_frame_info.get());
|
||||
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t> current_registers;
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t> caller_registers;
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t> expected_caller_registers;
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t> current_registers;
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t> caller_registers;
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t> expected_caller_registers;
|
||||
MockMemoryRegion memory;
|
||||
|
||||
// Regardless of which instruction evaluation takes place at, it
|
||||
@@ -305,7 +305,7 @@ TEST_F(TestFastSourceLineResolver, TestLoadAndResolve) {
|
||||
cfi_frame_info.reset(fast_resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_TRUE(VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers));
|
||||
@@ -315,7 +315,7 @@ TEST_F(TestFastSourceLineResolver, TestLoadAndResolve) {
|
||||
cfi_frame_info.reset(fast_resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
ASSERT_TRUE(VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers));
|
||||
@@ -325,7 +325,7 @@ TEST_F(TestFastSourceLineResolver, TestLoadAndResolve) {
|
||||
cfi_frame_info.reset(fast_resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers);
|
||||
@@ -335,7 +335,7 @@ TEST_F(TestFastSourceLineResolver, TestLoadAndResolve) {
|
||||
cfi_frame_info.reset(fast_resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers);
|
||||
@@ -345,7 +345,7 @@ TEST_F(TestFastSourceLineResolver, TestLoadAndResolve) {
|
||||
cfi_frame_info.reset(fast_resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers);
|
||||
@@ -355,7 +355,7 @@ TEST_F(TestFastSourceLineResolver, TestLoadAndResolve) {
|
||||
cfi_frame_info.reset(fast_resolver.FindCFIFrameInfo(&frame));
|
||||
ASSERT_TRUE(cfi_frame_info.get());
|
||||
ASSERT_TRUE(cfi_frame_info.get()
|
||||
->FindCallerRegs<u_int32_t>(current_registers, memory,
|
||||
->FindCallerRegs<uint32_t>(current_registers, memory,
|
||||
&caller_registers));
|
||||
VerifyRegisters(__FILE__, __LINE__,
|
||||
expected_caller_registers, caller_registers);
|
||||
|
||||
@@ -83,13 +83,13 @@ LogStream::~LogStream() {
|
||||
stream_ << std::endl;
|
||||
}
|
||||
|
||||
string HexString(u_int32_t number) {
|
||||
string HexString(uint32_t number) {
|
||||
char buffer[11];
|
||||
snprintf(buffer, sizeof(buffer), "0x%x", number);
|
||||
return string(buffer);
|
||||
}
|
||||
|
||||
string HexString(u_int64_t number) {
|
||||
string HexString(uint64_t number) {
|
||||
char buffer[19];
|
||||
snprintf(buffer, sizeof(buffer), "0x%" PRIx64, number);
|
||||
return string(buffer);
|
||||
|
||||
@@ -119,8 +119,8 @@ class LogMessageVoidify {
|
||||
};
|
||||
|
||||
// Returns number formatted as a hexadecimal string, such as "0x7b".
|
||||
string HexString(u_int32_t number);
|
||||
string HexString(u_int64_t number);
|
||||
string HexString(uint32_t number);
|
||||
string HexString(uint64_t number);
|
||||
string HexString(int number);
|
||||
|
||||
// Returns the error code as set in the global errno variable, and sets
|
||||
|
||||
@@ -55,7 +55,7 @@ template<typename Key, typename Value>
|
||||
size_t StdMapSerializer<Key, Value>::SizeOf(
|
||||
const std::map<Key, Value> &m) const {
|
||||
size_t size = 0;
|
||||
size_t header_size = (1 + m.size()) * sizeof(u_int32_t);
|
||||
size_t header_size = (1 + m.size()) * sizeof(uint32_t);
|
||||
size += header_size;
|
||||
|
||||
typename std::map<Key, Value>::const_iterator iter;
|
||||
@@ -77,10 +77,10 @@ char *StdMapSerializer<Key, Value>::Write(const std::map<Key, Value> &m,
|
||||
|
||||
// Write header:
|
||||
// Number of nodes.
|
||||
dest = SimpleSerializer<u_int32_t>::Write(m.size(), dest);
|
||||
dest = SimpleSerializer<uint32_t>::Write(m.size(), dest);
|
||||
// Nodes offsets.
|
||||
u_int32_t *offsets = reinterpret_cast<u_int32_t*>(dest);
|
||||
dest += sizeof(u_int32_t) * m.size();
|
||||
uint32_t *offsets = reinterpret_cast<uint32_t*>(dest);
|
||||
dest += sizeof(uint32_t) * m.size();
|
||||
|
||||
char *key_address = dest;
|
||||
dest += sizeof(Key) * m.size();
|
||||
@@ -89,7 +89,7 @@ char *StdMapSerializer<Key, Value>::Write(const std::map<Key, Value> &m,
|
||||
typename std::map<Key, Value>::const_iterator iter;
|
||||
int index = 0;
|
||||
for (iter = m.begin(); iter != m.end(); ++iter, ++index) {
|
||||
offsets[index] = static_cast<u_int32_t>(dest - start_address);
|
||||
offsets[index] = static_cast<uint32_t>(dest - start_address);
|
||||
key_address = key_serializer_.Write(iter->first, key_address);
|
||||
dest = value_serializer_.Write(iter->second, dest);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ template<typename Address, typename Entry>
|
||||
size_t RangeMapSerializer<Address, Entry>::SizeOf(
|
||||
const RangeMap<Address, Entry> &m) const {
|
||||
size_t size = 0;
|
||||
size_t header_size = (1 + m.map_.size()) * sizeof(u_int32_t);
|
||||
size_t header_size = (1 + m.map_.size()) * sizeof(uint32_t);
|
||||
size += header_size;
|
||||
|
||||
typename std::map<Address, Range>::const_iterator iter;
|
||||
@@ -145,10 +145,10 @@ char *RangeMapSerializer<Address, Entry>::Write(
|
||||
|
||||
// Write header:
|
||||
// Number of nodes.
|
||||
dest = SimpleSerializer<u_int32_t>::Write(m.map_.size(), dest);
|
||||
dest = SimpleSerializer<uint32_t>::Write(m.map_.size(), dest);
|
||||
// Nodes offsets.
|
||||
u_int32_t *offsets = reinterpret_cast<u_int32_t*>(dest);
|
||||
dest += sizeof(u_int32_t) * m.map_.size();
|
||||
uint32_t *offsets = reinterpret_cast<uint32_t*>(dest);
|
||||
dest += sizeof(uint32_t) * m.map_.size();
|
||||
|
||||
char *key_address = dest;
|
||||
dest += sizeof(Address) * m.map_.size();
|
||||
@@ -157,7 +157,7 @@ char *RangeMapSerializer<Address, Entry>::Write(
|
||||
typename std::map<Address, Range>::const_iterator iter;
|
||||
int index = 0;
|
||||
for (iter = m.map_.begin(); iter != m.map_.end(); ++iter, ++index) {
|
||||
offsets[index] = static_cast<u_int32_t>(dest - start_address);
|
||||
offsets[index] = static_cast<uint32_t>(dest - start_address);
|
||||
key_address = address_serializer_.Write(iter->first, key_address);
|
||||
dest = address_serializer_.Write(iter->second.base(), dest);
|
||||
dest = entry_serializer_.Write(iter->second.entry(), dest);
|
||||
@@ -192,12 +192,12 @@ size_t ContainedRangeMapSerializer<AddrType, EntryType>::SizeOf(
|
||||
size_t size = 0;
|
||||
size_t header_size = addr_serializer_.SizeOf(m->base_)
|
||||
+ entry_serializer_.SizeOf(m->entry_)
|
||||
+ sizeof(u_int32_t);
|
||||
+ sizeof(uint32_t);
|
||||
size += header_size;
|
||||
// In case m.map_ == NULL, we treat it as an empty map:
|
||||
size += sizeof(u_int32_t);
|
||||
size += sizeof(uint32_t);
|
||||
if (m->map_) {
|
||||
size += m->map_->size() * sizeof(u_int32_t);
|
||||
size += m->map_->size() * sizeof(uint32_t);
|
||||
typename Map::const_iterator iter;
|
||||
for (iter = m->map_->begin(); iter != m->map_->end(); ++iter) {
|
||||
size += addr_serializer_.SizeOf(iter->first);
|
||||
@@ -216,18 +216,18 @@ char *ContainedRangeMapSerializer<AddrType, EntryType>::Write(
|
||||
return NULL;
|
||||
}
|
||||
dest = addr_serializer_.Write(m->base_, dest);
|
||||
dest = SimpleSerializer<u_int32_t>::Write(entry_serializer_.SizeOf(m->entry_),
|
||||
dest = SimpleSerializer<uint32_t>::Write(entry_serializer_.SizeOf(m->entry_),
|
||||
dest);
|
||||
dest = entry_serializer_.Write(m->entry_, dest);
|
||||
|
||||
// Write map<<AddrType, ContainedRangeMap*>:
|
||||
char *map_address = dest;
|
||||
if (m->map_ == NULL) {
|
||||
dest = SimpleSerializer<u_int32_t>::Write(0, dest);
|
||||
dest = SimpleSerializer<uint32_t>::Write(0, dest);
|
||||
} else {
|
||||
dest = SimpleSerializer<u_int32_t>::Write(m->map_->size(), dest);
|
||||
u_int32_t *offsets = reinterpret_cast<u_int32_t*>(dest);
|
||||
dest += sizeof(u_int32_t) * m->map_->size();
|
||||
dest = SimpleSerializer<uint32_t>::Write(m->map_->size(), dest);
|
||||
uint32_t *offsets = reinterpret_cast<uint32_t*>(dest);
|
||||
dest += sizeof(uint32_t) * m->map_->size();
|
||||
|
||||
char *key_address = dest;
|
||||
dest += sizeof(AddrType) * m->map_->size();
|
||||
@@ -236,7 +236,7 @@ char *ContainedRangeMapSerializer<AddrType, EntryType>::Write(
|
||||
typename Map::const_iterator iter;
|
||||
int index = 0;
|
||||
for (iter = m->map_->begin(); iter != m->map_->end(); ++iter, ++index) {
|
||||
offsets[index] = static_cast<u_int32_t>(dest - map_address);
|
||||
offsets[index] = static_cast<uint32_t>(dest - map_address);
|
||||
key_address = addr_serializer_.Write(iter->first, key_address);
|
||||
// Recursively write.
|
||||
dest = Write(iter->second, dest);
|
||||
|
||||
@@ -64,13 +64,13 @@ class TestStdMapSerializer : public ::testing::Test {
|
||||
|
||||
std::map<AddrType, EntryType> std_map_;
|
||||
google_breakpad::StdMapSerializer<AddrType, EntryType> serializer_;
|
||||
u_int32_t serialized_size_;
|
||||
uint32_t serialized_size_;
|
||||
char *serialized_data_;
|
||||
};
|
||||
|
||||
TEST_F(TestStdMapSerializer, EmptyMapTestCase) {
|
||||
const int32_t correct_data[] = { 0 };
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
// std_map_ is empty.
|
||||
serialized_data_ = serializer_.Serialize(std_map_, &serialized_size_);
|
||||
@@ -90,7 +90,7 @@ TEST_F(TestStdMapSerializer, MapWithTwoElementsTestCase) {
|
||||
// Values
|
||||
2, 6
|
||||
};
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
std_map_.insert(std::make_pair(1, 2));
|
||||
std_map_.insert(std::make_pair(3, 6));
|
||||
@@ -112,7 +112,7 @@ TEST_F(TestStdMapSerializer, MapWithFiveElementsTestCase) {
|
||||
// Values
|
||||
11, 12, 13, 14, 15
|
||||
};
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
for (int i = 1; i < 6; ++i)
|
||||
std_map_.insert(std::make_pair(i, 10 + i));
|
||||
@@ -136,13 +136,13 @@ class TestAddressMapSerializer : public ::testing::Test {
|
||||
|
||||
google_breakpad::AddressMap<AddrType, EntryType> address_map_;
|
||||
google_breakpad::AddressMapSerializer<AddrType, EntryType> serializer_;
|
||||
u_int32_t serialized_size_;
|
||||
uint32_t serialized_size_;
|
||||
char *serialized_data_;
|
||||
};
|
||||
|
||||
TEST_F(TestAddressMapSerializer, EmptyMapTestCase) {
|
||||
const int32_t correct_data[] = { 0 };
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
// std_map_ is empty.
|
||||
serialized_data_ = serializer_.Serialize(address_map_, &serialized_size_);
|
||||
@@ -162,7 +162,7 @@ TEST_F(TestAddressMapSerializer, MapWithTwoElementsTestCase) {
|
||||
// Values
|
||||
2, 6
|
||||
};
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
address_map_.Store(1, 2);
|
||||
address_map_.Store(3, 6);
|
||||
@@ -184,7 +184,7 @@ TEST_F(TestAddressMapSerializer, MapWithFourElementsTestCase) {
|
||||
// Values
|
||||
2, 3, 5, 8
|
||||
};
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
address_map_.Store(-6, 2);
|
||||
address_map_.Store(-4, 3);
|
||||
@@ -211,13 +211,13 @@ class TestRangeMapSerializer : public ::testing::Test {
|
||||
|
||||
google_breakpad::RangeMap<AddrType, EntryType> range_map_;
|
||||
google_breakpad::RangeMapSerializer<AddrType, EntryType> serializer_;
|
||||
u_int32_t serialized_size_;
|
||||
uint32_t serialized_size_;
|
||||
char *serialized_data_;
|
||||
};
|
||||
|
||||
TEST_F(TestRangeMapSerializer, EmptyMapTestCase) {
|
||||
const int32_t correct_data[] = { 0 };
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
// range_map_ is empty.
|
||||
serialized_data_ = serializer_.Serialize(range_map_, &serialized_size_);
|
||||
@@ -237,7 +237,7 @@ TEST_F(TestRangeMapSerializer, MapWithOneRangeTestCase) {
|
||||
// Values: (low address, entry) pairs
|
||||
1, 6
|
||||
};
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
range_map_.StoreRange(1, 10, 6);
|
||||
|
||||
@@ -258,7 +258,7 @@ TEST_F(TestRangeMapSerializer, MapWithThreeRangesTestCase) {
|
||||
// Values: (low address, entry) pairs
|
||||
2, 1, 6, 2, 10, 3
|
||||
};
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
ASSERT_TRUE(range_map_.StoreRange(2, 4, 1));
|
||||
ASSERT_TRUE(range_map_.StoreRange(6, 4, 2));
|
||||
@@ -284,7 +284,7 @@ class TestContainedRangeMapSerializer : public ::testing::Test {
|
||||
|
||||
google_breakpad::ContainedRangeMap<AddrType, EntryType> crm_map_;
|
||||
google_breakpad::ContainedRangeMapSerializer<AddrType, EntryType> serializer_;
|
||||
u_int32_t serialized_size_;
|
||||
uint32_t serialized_size_;
|
||||
char *serialized_data_;
|
||||
};
|
||||
|
||||
@@ -295,7 +295,7 @@ TEST_F(TestContainedRangeMapSerializer, EmptyMapTestCase) {
|
||||
0, // entry stored at root
|
||||
0 // empty map stored at root
|
||||
};
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
// crm_map_ is empty.
|
||||
serialized_data_ = serializer_.Serialize(&crm_map_, &serialized_size_);
|
||||
@@ -319,7 +319,7 @@ TEST_F(TestContainedRangeMapSerializer, MapWithOneRangeTestCase) {
|
||||
-1, // entry stored in child CRM
|
||||
0 // empty sub-map stored in child CRM
|
||||
};
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
crm_map_.StoreRange(3, 7, -1);
|
||||
|
||||
@@ -361,7 +361,7 @@ TEST_F(TestContainedRangeMapSerializer, MapWithTwoLevelsTestCase) {
|
||||
// grandchild3: base, entry_size, entry, empty_map
|
||||
16, 4, -1, 0
|
||||
};
|
||||
u_int32_t correct_size = sizeof(correct_data);
|
||||
uint32_t correct_size = sizeof(correct_data);
|
||||
|
||||
// Store child1.
|
||||
ASSERT_TRUE(crm_map_.StoreRange(2, 7, -1));
|
||||
|
||||
266
src/processor/minidump.cc
Normal file → Executable file
266
src/processor/minidump.cc
Normal file → Executable file
@@ -43,7 +43,9 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#if _MSC_VER < 1600
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif
|
||||
#define PRIx64 "llx"
|
||||
#define PRIx32 "lx"
|
||||
#define snprintf _snprintf
|
||||
@@ -86,9 +88,9 @@ using std::vector;
|
||||
|
||||
// Swapping an 8-bit quantity is a no-op. This function is only provided
|
||||
// to account for certain templatized operations that require swapping for
|
||||
// wider types but handle u_int8_t too
|
||||
// wider types but handle uint8_t too
|
||||
// (MinidumpMemoryRegion::GetMemoryAtAddressInternal).
|
||||
static inline void Swap(u_int8_t* value) {
|
||||
static inline void Swap(uint8_t* value) {
|
||||
}
|
||||
|
||||
|
||||
@@ -99,13 +101,13 @@ static inline void Swap(u_int8_t* value) {
|
||||
// The furthest left shift never needs to be ANDed bitmask.
|
||||
|
||||
|
||||
static inline void Swap(u_int16_t* value) {
|
||||
static inline void Swap(uint16_t* value) {
|
||||
*value = (*value >> 8) |
|
||||
(*value << 8);
|
||||
}
|
||||
|
||||
|
||||
static inline void Swap(u_int32_t* value) {
|
||||
static inline void Swap(uint32_t* value) {
|
||||
*value = (*value >> 24) |
|
||||
((*value >> 8) & 0x0000ff00) |
|
||||
((*value << 8) & 0x00ff0000) |
|
||||
@@ -113,11 +115,11 @@ static inline void Swap(u_int32_t* value) {
|
||||
}
|
||||
|
||||
|
||||
static inline void Swap(u_int64_t* value) {
|
||||
u_int32_t* value32 = reinterpret_cast<u_int32_t*>(value);
|
||||
static inline void Swap(uint64_t* value) {
|
||||
uint32_t* value32 = reinterpret_cast<uint32_t*>(value);
|
||||
Swap(&value32[0]);
|
||||
Swap(&value32[1]);
|
||||
u_int32_t temp = value32[0];
|
||||
uint32_t temp = value32[0];
|
||||
value32[0] = value32[1];
|
||||
value32[1] = temp;
|
||||
}
|
||||
@@ -125,11 +127,11 @@ static inline void Swap(u_int64_t* value) {
|
||||
|
||||
// Given a pointer to a 128-bit int in the minidump data, set the "low"
|
||||
// and "high" fields appropriately.
|
||||
static void Normalize128(u_int128_t* value, bool is_big_endian) {
|
||||
static void Normalize128(uint128_struct* value, bool is_big_endian) {
|
||||
// The struct format is [high, low], so if the format is big-endian,
|
||||
// the most significant bytes will already be in the high field.
|
||||
if (!is_big_endian) {
|
||||
u_int64_t temp = value->low;
|
||||
uint64_t temp = value->low;
|
||||
value->low = value->high;
|
||||
value->high = temp;
|
||||
}
|
||||
@@ -137,7 +139,7 @@ static void Normalize128(u_int128_t* value, bool is_big_endian) {
|
||||
|
||||
// This just swaps each int64 half of the 128-bit value.
|
||||
// The value should also be normalized by calling Normalize128().
|
||||
static void Swap(u_int128_t* value) {
|
||||
static void Swap(uint128_struct* value) {
|
||||
Swap(&value->low);
|
||||
Swap(&value->high);
|
||||
}
|
||||
@@ -177,7 +179,7 @@ static inline void Swap(MDGUID* guid) {
|
||||
// parameter, a converter that uses iconv would also need to take the host
|
||||
// CPU's endianness into consideration. It doesn't seems worth the trouble
|
||||
// of making it a dependency when we don't care about anything but UTF-16.
|
||||
static string* UTF16ToUTF8(const vector<u_int16_t>& in,
|
||||
static string* UTF16ToUTF8(const vector<uint16_t>& in,
|
||||
bool swap) {
|
||||
scoped_ptr<string> out(new string());
|
||||
|
||||
@@ -186,16 +188,16 @@ static string* UTF16ToUTF8(const vector<u_int16_t>& in,
|
||||
// If the UTF-8 representation is longer, the string will grow dynamically.
|
||||
out->reserve(in.size());
|
||||
|
||||
for (vector<u_int16_t>::const_iterator iterator = in.begin();
|
||||
for (vector<uint16_t>::const_iterator iterator = in.begin();
|
||||
iterator != in.end();
|
||||
++iterator) {
|
||||
// Get a 16-bit value from the input
|
||||
u_int16_t in_word = *iterator;
|
||||
uint16_t in_word = *iterator;
|
||||
if (swap)
|
||||
Swap(&in_word);
|
||||
|
||||
// Convert the input value (in_word) into a Unicode code point (unichar).
|
||||
u_int32_t unichar;
|
||||
uint32_t unichar;
|
||||
if (in_word >= 0xdc00 && in_word <= 0xdcff) {
|
||||
BPLOG(ERROR) << "UTF16ToUTF8 found low surrogate " <<
|
||||
HexString(in_word) << " without high";
|
||||
@@ -208,7 +210,7 @@ static string* UTF16ToUTF8(const vector<u_int16_t>& in,
|
||||
HexString(in_word) << " at end of string";
|
||||
return NULL;
|
||||
}
|
||||
u_int32_t high_word = in_word;
|
||||
uint32_t high_word = in_word;
|
||||
in_word = *iterator;
|
||||
if (in_word < 0xdc00 || in_word > 0xdcff) {
|
||||
BPLOG(ERROR) << "UTF16ToUTF8 found high surrogate " <<
|
||||
@@ -251,7 +253,7 @@ static string* UTF16ToUTF8(const vector<u_int16_t>& in,
|
||||
|
||||
// Return the smaller of the number of code units in the UTF-16 string,
|
||||
// not including the terminating null word, or maxlen.
|
||||
static size_t UTF16codeunits(const u_int16_t *string, size_t maxlen) {
|
||||
static size_t UTF16codeunits(const uint16_t *string, size_t maxlen) {
|
||||
size_t count = 0;
|
||||
while (count < maxlen && string[count] != 0)
|
||||
count++;
|
||||
@@ -297,7 +299,7 @@ MinidumpContext::~MinidumpContext() {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpContext::Read(u_int32_t expected_size) {
|
||||
bool MinidumpContext::Read(uint32_t expected_size) {
|
||||
valid_ = false;
|
||||
|
||||
FreeContext();
|
||||
@@ -318,7 +320,7 @@ bool MinidumpContext::Read(u_int32_t expected_size) {
|
||||
if (minidump_->swap())
|
||||
Swap(&context_amd64->context_flags);
|
||||
|
||||
u_int32_t cpu_type = context_amd64->context_flags & MD_CONTEXT_CPU_MASK;
|
||||
uint32_t cpu_type = context_amd64->context_flags & MD_CONTEXT_CPU_MASK;
|
||||
if (cpu_type == 0) {
|
||||
if (minidump_->GetContextCPUFlagsFromSystemInfo(&cpu_type)) {
|
||||
context_amd64->context_flags |= cpu_type;
|
||||
@@ -410,7 +412,7 @@ bool MinidumpContext::Read(u_int32_t expected_size) {
|
||||
context_.amd64 = context_amd64.release();
|
||||
}
|
||||
else {
|
||||
u_int32_t context_flags;
|
||||
uint32_t context_flags;
|
||||
if (!minidump_->ReadBytes(&context_flags, sizeof(context_flags))) {
|
||||
BPLOG(ERROR) << "MinidumpContext could not read context flags";
|
||||
return false;
|
||||
@@ -418,7 +420,7 @@ bool MinidumpContext::Read(u_int32_t expected_size) {
|
||||
if (minidump_->swap())
|
||||
Swap(&context_flags);
|
||||
|
||||
u_int32_t cpu_type = context_flags & MD_CONTEXT_CPU_MASK;
|
||||
uint32_t cpu_type = context_flags & MD_CONTEXT_CPU_MASK;
|
||||
if (cpu_type == 0) {
|
||||
// Unfortunately the flag for MD_CONTEXT_ARM that was taken
|
||||
// from a Windows CE SDK header conflicts in practice with
|
||||
@@ -460,8 +462,8 @@ bool MinidumpContext::Read(u_int32_t expected_size) {
|
||||
context_x86->context_flags = context_flags;
|
||||
|
||||
size_t flags_size = sizeof(context_x86->context_flags);
|
||||
u_int8_t* context_after_flags =
|
||||
reinterpret_cast<u_int8_t*>(context_x86.get()) + flags_size;
|
||||
uint8_t* context_after_flags =
|
||||
reinterpret_cast<uint8_t*>(context_x86.get()) + flags_size;
|
||||
if (!minidump_->ReadBytes(context_after_flags,
|
||||
sizeof(MDRawContextX86) - flags_size)) {
|
||||
BPLOG(ERROR) << "MinidumpContext could not read x86 context";
|
||||
@@ -533,8 +535,8 @@ bool MinidumpContext::Read(u_int32_t expected_size) {
|
||||
context_ppc->context_flags = context_flags;
|
||||
|
||||
size_t flags_size = sizeof(context_ppc->context_flags);
|
||||
u_int8_t* context_after_flags =
|
||||
reinterpret_cast<u_int8_t*>(context_ppc.get()) + flags_size;
|
||||
uint8_t* context_after_flags =
|
||||
reinterpret_cast<uint8_t*>(context_ppc.get()) + flags_size;
|
||||
if (!minidump_->ReadBytes(context_after_flags,
|
||||
sizeof(MDRawContextPPC) - flags_size)) {
|
||||
BPLOG(ERROR) << "MinidumpContext could not read ppc context";
|
||||
@@ -609,8 +611,8 @@ bool MinidumpContext::Read(u_int32_t expected_size) {
|
||||
context_sparc->context_flags = context_flags;
|
||||
|
||||
size_t flags_size = sizeof(context_sparc->context_flags);
|
||||
u_int8_t* context_after_flags =
|
||||
reinterpret_cast<u_int8_t*>(context_sparc.get()) + flags_size;
|
||||
uint8_t* context_after_flags =
|
||||
reinterpret_cast<uint8_t*>(context_sparc.get()) + flags_size;
|
||||
if (!minidump_->ReadBytes(context_after_flags,
|
||||
sizeof(MDRawContextSPARC) - flags_size)) {
|
||||
BPLOG(ERROR) << "MinidumpContext could not read sparc context";
|
||||
@@ -665,8 +667,8 @@ bool MinidumpContext::Read(u_int32_t expected_size) {
|
||||
context_arm->context_flags = context_flags;
|
||||
|
||||
size_t flags_size = sizeof(context_arm->context_flags);
|
||||
u_int8_t* context_after_flags =
|
||||
reinterpret_cast<u_int8_t*>(context_arm.get()) + flags_size;
|
||||
uint8_t* context_after_flags =
|
||||
reinterpret_cast<uint8_t*>(context_arm.get()) + flags_size;
|
||||
if (!minidump_->ReadBytes(context_after_flags,
|
||||
sizeof(MDRawContextARM) - flags_size)) {
|
||||
BPLOG(ERROR) << "MinidumpContext could not read arm context";
|
||||
@@ -722,7 +724,7 @@ bool MinidumpContext::Read(u_int32_t expected_size) {
|
||||
}
|
||||
|
||||
|
||||
u_int32_t MinidumpContext::GetContextCPU() const {
|
||||
uint32_t MinidumpContext::GetContextCPU() const {
|
||||
if (!valid_) {
|
||||
// Don't log a message, GetContextCPU can be legitimately called with
|
||||
// valid_ false by FreeContext, which is called by Read.
|
||||
@@ -732,7 +734,7 @@ u_int32_t MinidumpContext::GetContextCPU() const {
|
||||
return context_flags_ & MD_CONTEXT_CPU_MASK;
|
||||
}
|
||||
|
||||
bool MinidumpContext::GetInstructionPointer(u_int64_t* ip) const {
|
||||
bool MinidumpContext::GetInstructionPointer(uint64_t* ip) const {
|
||||
BPLOG_IF(ERROR, !ip) << "MinidumpContext::GetInstructionPointer "
|
||||
"requires |ip|";
|
||||
assert(ip);
|
||||
@@ -848,7 +850,7 @@ void MinidumpContext::FreeContext() {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpContext::CheckAgainstSystemInfo(u_int32_t context_cpu_type) {
|
||||
bool MinidumpContext::CheckAgainstSystemInfo(uint32_t context_cpu_type) {
|
||||
// It's OK if the minidump doesn't contain an MD_SYSTEM_INFO_STREAM,
|
||||
// as this function just implements a sanity check.
|
||||
MinidumpSystemInfo* system_info = minidump_->GetSystemInfo();
|
||||
@@ -1147,7 +1149,7 @@ void MinidumpContext::Print() {
|
||||
//
|
||||
|
||||
|
||||
u_int32_t MinidumpMemoryRegion::max_bytes_ = 1024 * 1024; // 1MB
|
||||
uint32_t MinidumpMemoryRegion::max_bytes_ = 1024 * 1024; // 1MB
|
||||
|
||||
|
||||
MinidumpMemoryRegion::MinidumpMemoryRegion(Minidump* minidump)
|
||||
@@ -1166,12 +1168,12 @@ void MinidumpMemoryRegion::SetDescriptor(MDMemoryDescriptor* descriptor) {
|
||||
descriptor_ = descriptor;
|
||||
valid_ = descriptor &&
|
||||
descriptor_->memory.data_size <=
|
||||
numeric_limits<u_int64_t>::max() -
|
||||
numeric_limits<uint64_t>::max() -
|
||||
descriptor_->start_of_memory_range;
|
||||
}
|
||||
|
||||
|
||||
const u_int8_t* MinidumpMemoryRegion::GetMemory() const {
|
||||
const uint8_t* MinidumpMemoryRegion::GetMemory() const {
|
||||
if (!valid_) {
|
||||
BPLOG(ERROR) << "Invalid MinidumpMemoryRegion for GetMemory";
|
||||
return NULL;
|
||||
@@ -1195,8 +1197,8 @@ const u_int8_t* MinidumpMemoryRegion::GetMemory() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
scoped_ptr< vector<u_int8_t> > memory(
|
||||
new vector<u_int8_t>(descriptor_->memory.data_size));
|
||||
scoped_ptr< vector<uint8_t> > memory(
|
||||
new vector<uint8_t>(descriptor_->memory.data_size));
|
||||
|
||||
if (!minidump_->ReadBytes(&(*memory)[0], descriptor_->memory.data_size)) {
|
||||
BPLOG(ERROR) << "MinidumpMemoryRegion could not read memory region";
|
||||
@@ -1210,17 +1212,17 @@ const u_int8_t* MinidumpMemoryRegion::GetMemory() const {
|
||||
}
|
||||
|
||||
|
||||
u_int64_t MinidumpMemoryRegion::GetBase() const {
|
||||
uint64_t MinidumpMemoryRegion::GetBase() const {
|
||||
if (!valid_) {
|
||||
BPLOG(ERROR) << "Invalid MinidumpMemoryRegion for GetBase";
|
||||
return static_cast<u_int64_t>(-1);
|
||||
return static_cast<uint64_t>(-1);
|
||||
}
|
||||
|
||||
return descriptor_->start_of_memory_range;
|
||||
}
|
||||
|
||||
|
||||
u_int32_t MinidumpMemoryRegion::GetSize() const {
|
||||
uint32_t MinidumpMemoryRegion::GetSize() const {
|
||||
if (!valid_) {
|
||||
BPLOG(ERROR) << "Invalid MinidumpMemoryRegion for GetSize";
|
||||
return 0;
|
||||
@@ -1237,7 +1239,7 @@ void MinidumpMemoryRegion::FreeMemory() {
|
||||
|
||||
|
||||
template<typename T>
|
||||
bool MinidumpMemoryRegion::GetMemoryAtAddressInternal(u_int64_t address,
|
||||
bool MinidumpMemoryRegion::GetMemoryAtAddressInternal(uint64_t address,
|
||||
T* value) const {
|
||||
BPLOG_IF(ERROR, !value) << "MinidumpMemoryRegion::GetMemoryAtAddressInternal "
|
||||
"requires |value|";
|
||||
@@ -1252,7 +1254,7 @@ bool MinidumpMemoryRegion::GetMemoryAtAddressInternal(u_int64_t address,
|
||||
|
||||
// Common failure case
|
||||
if (address < descriptor_->start_of_memory_range ||
|
||||
sizeof(T) > numeric_limits<u_int64_t>::max() - address ||
|
||||
sizeof(T) > numeric_limits<uint64_t>::max() - address ||
|
||||
address + sizeof(T) > descriptor_->start_of_memory_range +
|
||||
descriptor_->memory.data_size) {
|
||||
BPLOG(INFO) << "MinidumpMemoryRegion request out of range: " <<
|
||||
@@ -1262,7 +1264,7 @@ bool MinidumpMemoryRegion::GetMemoryAtAddressInternal(u_int64_t address,
|
||||
return false;
|
||||
}
|
||||
|
||||
const u_int8_t* memory = GetMemory();
|
||||
const uint8_t* memory = GetMemory();
|
||||
if (!memory) {
|
||||
// GetMemory already logged a perfectly good message.
|
||||
return false;
|
||||
@@ -1280,26 +1282,26 @@ bool MinidumpMemoryRegion::GetMemoryAtAddressInternal(u_int64_t address,
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpMemoryRegion::GetMemoryAtAddress(u_int64_t address,
|
||||
u_int8_t* value) const {
|
||||
bool MinidumpMemoryRegion::GetMemoryAtAddress(uint64_t address,
|
||||
uint8_t* value) const {
|
||||
return GetMemoryAtAddressInternal(address, value);
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpMemoryRegion::GetMemoryAtAddress(u_int64_t address,
|
||||
u_int16_t* value) const {
|
||||
bool MinidumpMemoryRegion::GetMemoryAtAddress(uint64_t address,
|
||||
uint16_t* value) const {
|
||||
return GetMemoryAtAddressInternal(address, value);
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpMemoryRegion::GetMemoryAtAddress(u_int64_t address,
|
||||
u_int32_t* value) const {
|
||||
bool MinidumpMemoryRegion::GetMemoryAtAddress(uint64_t address,
|
||||
uint32_t* value) const {
|
||||
return GetMemoryAtAddressInternal(address, value);
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpMemoryRegion::GetMemoryAtAddress(u_int64_t address,
|
||||
u_int64_t* value) const {
|
||||
bool MinidumpMemoryRegion::GetMemoryAtAddress(uint64_t address,
|
||||
uint64_t* value) const {
|
||||
return GetMemoryAtAddressInternal(address, value);
|
||||
}
|
||||
|
||||
@@ -1310,7 +1312,7 @@ void MinidumpMemoryRegion::Print() {
|
||||
return;
|
||||
}
|
||||
|
||||
const u_int8_t* memory = GetMemory();
|
||||
const uint8_t* memory = GetMemory();
|
||||
if (memory) {
|
||||
printf("0x");
|
||||
for (unsigned int byte_index = 0;
|
||||
@@ -1370,7 +1372,7 @@ bool MinidumpThread::Read() {
|
||||
|
||||
// Check for base + size overflow or undersize.
|
||||
if (thread_.stack.memory.data_size == 0 ||
|
||||
thread_.stack.memory.data_size > numeric_limits<u_int64_t>::max() -
|
||||
thread_.stack.memory.data_size > numeric_limits<uint64_t>::max() -
|
||||
thread_.stack.start_of_memory_range) {
|
||||
// This is ok, but log an error anyway.
|
||||
BPLOG(ERROR) << "MinidumpThread has a memory region problem, " <<
|
||||
@@ -1422,7 +1424,7 @@ MinidumpContext* MinidumpThread::GetContext() {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpThread::GetThreadID(u_int32_t *thread_id) const {
|
||||
bool MinidumpThread::GetThreadID(uint32_t *thread_id) const {
|
||||
BPLOG_IF(ERROR, !thread_id) << "MinidumpThread::GetThreadID requires "
|
||||
"|thread_id|";
|
||||
assert(thread_id);
|
||||
@@ -1485,7 +1487,7 @@ void MinidumpThread::Print() {
|
||||
//
|
||||
|
||||
|
||||
u_int32_t MinidumpThreadList::max_threads_ = 4096;
|
||||
uint32_t MinidumpThreadList::max_threads_ = 4096;
|
||||
|
||||
|
||||
MinidumpThreadList::MinidumpThreadList(Minidump* minidump)
|
||||
@@ -1501,7 +1503,7 @@ MinidumpThreadList::~MinidumpThreadList() {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpThreadList::Read(u_int32_t expected_size) {
|
||||
bool MinidumpThreadList::Read(uint32_t expected_size) {
|
||||
// Invalidate cached data.
|
||||
id_to_thread_map_.clear();
|
||||
delete threads_;
|
||||
@@ -1510,7 +1512,7 @@ bool MinidumpThreadList::Read(u_int32_t expected_size) {
|
||||
|
||||
valid_ = false;
|
||||
|
||||
u_int32_t thread_count;
|
||||
uint32_t thread_count;
|
||||
if (expected_size < sizeof(thread_count)) {
|
||||
BPLOG(ERROR) << "MinidumpThreadList count size mismatch, " <<
|
||||
expected_size << " < " << sizeof(thread_count);
|
||||
@@ -1524,7 +1526,7 @@ bool MinidumpThreadList::Read(u_int32_t expected_size) {
|
||||
if (minidump_->swap())
|
||||
Swap(&thread_count);
|
||||
|
||||
if (thread_count > numeric_limits<u_int32_t>::max() / sizeof(MDRawThread)) {
|
||||
if (thread_count > numeric_limits<uint32_t>::max() / sizeof(MDRawThread)) {
|
||||
BPLOG(ERROR) << "MinidumpThreadList thread count " << thread_count <<
|
||||
" would cause multiplication overflow";
|
||||
return false;
|
||||
@@ -1535,7 +1537,7 @@ bool MinidumpThreadList::Read(u_int32_t expected_size) {
|
||||
// may be padded with 4 bytes on 64bit ABIs for alignment
|
||||
if (expected_size == sizeof(thread_count) + 4 +
|
||||
thread_count * sizeof(MDRawThread)) {
|
||||
u_int32_t useless;
|
||||
uint32_t useless;
|
||||
if (!minidump_->ReadBytes(&useless, 4)) {
|
||||
BPLOG(ERROR) << "MinidumpThreadList cannot read threadlist padded bytes";
|
||||
return false;
|
||||
@@ -1571,7 +1573,7 @@ bool MinidumpThreadList::Read(u_int32_t expected_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
if (!thread->GetThreadID(&thread_id)) {
|
||||
BPLOG(ERROR) << "MinidumpThreadList cannot get thread ID for thread " <<
|
||||
thread_index << "/" << thread_count;
|
||||
@@ -1615,7 +1617,7 @@ MinidumpThread* MinidumpThreadList::GetThreadAtIndex(unsigned int index)
|
||||
}
|
||||
|
||||
|
||||
MinidumpThread* MinidumpThreadList::GetThreadByID(u_int32_t thread_id) {
|
||||
MinidumpThread* MinidumpThreadList::GetThreadByID(uint32_t thread_id) {
|
||||
// Don't check valid_. Read calls this method before everything is
|
||||
// validated. It is safe to not check valid_ here.
|
||||
return id_to_thread_map_[thread_id];
|
||||
@@ -1647,8 +1649,8 @@ void MinidumpThreadList::Print() {
|
||||
//
|
||||
|
||||
|
||||
u_int32_t MinidumpModule::max_cv_bytes_ = 32768;
|
||||
u_int32_t MinidumpModule::max_misc_bytes_ = 32768;
|
||||
uint32_t MinidumpModule::max_cv_bytes_ = 32768;
|
||||
uint32_t MinidumpModule::max_misc_bytes_ = 32768;
|
||||
|
||||
|
||||
MinidumpModule::MinidumpModule(Minidump* minidump)
|
||||
@@ -1717,7 +1719,7 @@ bool MinidumpModule::Read() {
|
||||
// Check for base + size overflow or undersize.
|
||||
if (module_.size_of_image == 0 ||
|
||||
module_.size_of_image >
|
||||
numeric_limits<u_int64_t>::max() - module_.base_of_image) {
|
||||
numeric_limits<uint64_t>::max() - module_.base_of_image) {
|
||||
BPLOG(ERROR) << "MinidumpModule has a module problem, " <<
|
||||
HexString(module_.base_of_image) << "+" <<
|
||||
HexString(module_.size_of_image);
|
||||
@@ -1892,9 +1894,9 @@ string MinidumpModule::debug_file() const {
|
||||
if (bytes % 2 == 0) {
|
||||
unsigned int utf16_words = bytes / 2;
|
||||
|
||||
// UTF16ToUTF8 expects a vector<u_int16_t>, so create a temporary one
|
||||
// UTF16ToUTF8 expects a vector<uint16_t>, so create a temporary one
|
||||
// and copy the UTF-16 data into it.
|
||||
vector<u_int16_t> string_utf16(utf16_words);
|
||||
vector<uint16_t> string_utf16(utf16_words);
|
||||
if (utf16_words)
|
||||
memcpy(&string_utf16[0], &misc_record->data, bytes);
|
||||
|
||||
@@ -2021,7 +2023,7 @@ const CodeModule* MinidumpModule::Copy() const {
|
||||
}
|
||||
|
||||
|
||||
const u_int8_t* MinidumpModule::GetCVRecord(u_int32_t* size) {
|
||||
const uint8_t* MinidumpModule::GetCVRecord(uint32_t* size) {
|
||||
if (!module_valid_) {
|
||||
BPLOG(ERROR) << "Invalid MinidumpModule for GetCVRecord";
|
||||
return NULL;
|
||||
@@ -2047,21 +2049,21 @@ const u_int8_t* MinidumpModule::GetCVRecord(u_int32_t* size) {
|
||||
}
|
||||
|
||||
// Allocating something that will be accessed as MDCVInfoPDB70 or
|
||||
// MDCVInfoPDB20 but is allocated as u_int8_t[] can cause alignment
|
||||
// MDCVInfoPDB20 but is allocated as uint8_t[] can cause alignment
|
||||
// problems. x86 and ppc are able to cope, though. This allocation
|
||||
// style is needed because the MDCVInfoPDB70 or MDCVInfoPDB20 are
|
||||
// variable-sized due to their pdb_file_name fields; these structures
|
||||
// are not MDCVInfoPDB70_minsize or MDCVInfoPDB20_minsize and treating
|
||||
// them as such would result in incomplete structures or overruns.
|
||||
scoped_ptr< vector<u_int8_t> > cv_record(
|
||||
new vector<u_int8_t>(module_.cv_record.data_size));
|
||||
scoped_ptr< vector<uint8_t> > cv_record(
|
||||
new vector<uint8_t>(module_.cv_record.data_size));
|
||||
|
||||
if (!minidump_->ReadBytes(&(*cv_record)[0], module_.cv_record.data_size)) {
|
||||
BPLOG(ERROR) << "MinidumpModule could not read CodeView record";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_int32_t signature = MD_CVINFOUNKNOWN_SIGNATURE;
|
||||
uint32_t signature = MD_CVINFOUNKNOWN_SIGNATURE;
|
||||
if (module_.cv_record.data_size > sizeof(signature)) {
|
||||
MDCVInfoPDB70* cv_record_signature =
|
||||
reinterpret_cast<MDCVInfoPDB70*>(&(*cv_record)[0]);
|
||||
@@ -2131,7 +2133,7 @@ const u_int8_t* MinidumpModule::GetCVRecord(u_int32_t* size) {
|
||||
// although byte-swapping can't be done.
|
||||
|
||||
// Store the vector type because that's how storage was allocated, but
|
||||
// return it casted to u_int8_t*.
|
||||
// return it casted to uint8_t*.
|
||||
cv_record_ = cv_record.release();
|
||||
cv_record_signature_ = signature;
|
||||
}
|
||||
@@ -2143,7 +2145,7 @@ const u_int8_t* MinidumpModule::GetCVRecord(u_int32_t* size) {
|
||||
}
|
||||
|
||||
|
||||
const MDImageDebugMisc* MinidumpModule::GetMiscRecord(u_int32_t* size) {
|
||||
const MDImageDebugMisc* MinidumpModule::GetMiscRecord(uint32_t* size) {
|
||||
if (!module_valid_) {
|
||||
BPLOG(ERROR) << "Invalid MinidumpModule for GetMiscRecord";
|
||||
return NULL;
|
||||
@@ -2175,13 +2177,13 @@ const MDImageDebugMisc* MinidumpModule::GetMiscRecord(u_int32_t* size) {
|
||||
}
|
||||
|
||||
// Allocating something that will be accessed as MDImageDebugMisc but
|
||||
// is allocated as u_int8_t[] can cause alignment problems. x86 and
|
||||
// is allocated as uint8_t[] can cause alignment problems. x86 and
|
||||
// ppc are able to cope, though. This allocation style is needed
|
||||
// because the MDImageDebugMisc is variable-sized due to its data field;
|
||||
// this structure is not MDImageDebugMisc_minsize and treating it as such
|
||||
// would result in an incomplete structure or an overrun.
|
||||
scoped_ptr< vector<u_int8_t> > misc_record_mem(
|
||||
new vector<u_int8_t>(module_.misc_record.data_size));
|
||||
scoped_ptr< vector<uint8_t> > misc_record_mem(
|
||||
new vector<uint8_t>(module_.misc_record.data_size));
|
||||
MDImageDebugMisc* misc_record =
|
||||
reinterpret_cast<MDImageDebugMisc*>(&(*misc_record_mem)[0]);
|
||||
|
||||
@@ -2200,7 +2202,7 @@ const MDImageDebugMisc* MinidumpModule::GetMiscRecord(u_int32_t* size) {
|
||||
if (misc_record->unicode) {
|
||||
// There is a potential alignment problem, but shouldn't be a problem
|
||||
// in practice due to the layout of MDImageDebugMisc.
|
||||
u_int16_t* data16 = reinterpret_cast<u_int16_t*>(&(misc_record->data));
|
||||
uint16_t* data16 = reinterpret_cast<uint16_t*>(&(misc_record->data));
|
||||
unsigned int dataBytes = module_.misc_record.data_size -
|
||||
MDImageDebugMisc_minsize;
|
||||
unsigned int dataLength = dataBytes / 2;
|
||||
@@ -2284,8 +2286,8 @@ void MinidumpModule::Print() {
|
||||
printf(" (code_identifier) = \"%s\"\n",
|
||||
code_identifier().c_str());
|
||||
|
||||
u_int32_t cv_record_size;
|
||||
const u_int8_t *cv_record = GetCVRecord(&cv_record_size);
|
||||
uint32_t cv_record_size;
|
||||
const uint8_t *cv_record = GetCVRecord(&cv_record_size);
|
||||
if (cv_record) {
|
||||
if (cv_record_signature_ == MD_CVINFOPDB70_SIGNATURE) {
|
||||
const MDCVInfoPDB70* cv_record_70 =
|
||||
@@ -2370,12 +2372,12 @@ void MinidumpModule::Print() {
|
||||
//
|
||||
|
||||
|
||||
u_int32_t MinidumpModuleList::max_modules_ = 1024;
|
||||
uint32_t MinidumpModuleList::max_modules_ = 1024;
|
||||
|
||||
|
||||
MinidumpModuleList::MinidumpModuleList(Minidump* minidump)
|
||||
: MinidumpStream(minidump),
|
||||
range_map_(new RangeMap<u_int64_t, unsigned int>()),
|
||||
range_map_(new RangeMap<uint64_t, unsigned int>()),
|
||||
modules_(NULL),
|
||||
module_count_(0) {
|
||||
}
|
||||
@@ -2387,7 +2389,7 @@ MinidumpModuleList::~MinidumpModuleList() {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpModuleList::Read(u_int32_t expected_size) {
|
||||
bool MinidumpModuleList::Read(uint32_t expected_size) {
|
||||
// Invalidate cached data.
|
||||
range_map_->Clear();
|
||||
delete modules_;
|
||||
@@ -2396,7 +2398,7 @@ bool MinidumpModuleList::Read(u_int32_t expected_size) {
|
||||
|
||||
valid_ = false;
|
||||
|
||||
u_int32_t module_count;
|
||||
uint32_t module_count;
|
||||
if (expected_size < sizeof(module_count)) {
|
||||
BPLOG(ERROR) << "MinidumpModuleList count size mismatch, " <<
|
||||
expected_size << " < " << sizeof(module_count);
|
||||
@@ -2410,7 +2412,7 @@ bool MinidumpModuleList::Read(u_int32_t expected_size) {
|
||||
if (minidump_->swap())
|
||||
Swap(&module_count);
|
||||
|
||||
if (module_count > numeric_limits<u_int32_t>::max() / MD_MODULE_SIZE) {
|
||||
if (module_count > numeric_limits<uint32_t>::max() / MD_MODULE_SIZE) {
|
||||
BPLOG(ERROR) << "MinidumpModuleList module count " << module_count <<
|
||||
" would cause multiplication overflow";
|
||||
return false;
|
||||
@@ -2421,7 +2423,7 @@ bool MinidumpModuleList::Read(u_int32_t expected_size) {
|
||||
// may be padded with 4 bytes on 64bit ABIs for alignment
|
||||
if (expected_size == sizeof(module_count) + 4 +
|
||||
module_count * MD_MODULE_SIZE) {
|
||||
u_int32_t useless;
|
||||
uint32_t useless;
|
||||
if (!minidump_->ReadBytes(&useless, 4)) {
|
||||
BPLOG(ERROR) << "MinidumpModuleList cannot read modulelist padded bytes";
|
||||
return false;
|
||||
@@ -2482,9 +2484,9 @@ bool MinidumpModuleList::Read(u_int32_t expected_size) {
|
||||
// It is safe to use module->code_file() after successfully calling
|
||||
// module->ReadAuxiliaryData or noting that the module is valid.
|
||||
|
||||
u_int64_t base_address = module->base_address();
|
||||
u_int64_t module_size = module->size();
|
||||
if (base_address == static_cast<u_int64_t>(-1)) {
|
||||
uint64_t base_address = module->base_address();
|
||||
uint64_t module_size = module->size();
|
||||
if (base_address == static_cast<uint64_t>(-1)) {
|
||||
BPLOG(ERROR) << "MinidumpModuleList found bad base address "
|
||||
"for module " << module_index << "/" << module_count <<
|
||||
", " << module->code_file();
|
||||
@@ -2512,7 +2514,7 @@ bool MinidumpModuleList::Read(u_int32_t expected_size) {
|
||||
|
||||
|
||||
const MinidumpModule* MinidumpModuleList::GetModuleForAddress(
|
||||
u_int64_t address) const {
|
||||
uint64_t address) const {
|
||||
if (!valid_) {
|
||||
BPLOG(ERROR) << "Invalid MinidumpModuleList for GetModuleForAddress";
|
||||
return NULL;
|
||||
@@ -2611,12 +2613,12 @@ void MinidumpModuleList::Print() {
|
||||
//
|
||||
|
||||
|
||||
u_int32_t MinidumpMemoryList::max_regions_ = 4096;
|
||||
uint32_t MinidumpMemoryList::max_regions_ = 4096;
|
||||
|
||||
|
||||
MinidumpMemoryList::MinidumpMemoryList(Minidump* minidump)
|
||||
: MinidumpStream(minidump),
|
||||
range_map_(new RangeMap<u_int64_t, unsigned int>()),
|
||||
range_map_(new RangeMap<uint64_t, unsigned int>()),
|
||||
descriptors_(NULL),
|
||||
regions_(NULL),
|
||||
region_count_(0) {
|
||||
@@ -2630,7 +2632,7 @@ MinidumpMemoryList::~MinidumpMemoryList() {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpMemoryList::Read(u_int32_t expected_size) {
|
||||
bool MinidumpMemoryList::Read(uint32_t expected_size) {
|
||||
// Invalidate cached data.
|
||||
delete descriptors_;
|
||||
descriptors_ = NULL;
|
||||
@@ -2641,7 +2643,7 @@ bool MinidumpMemoryList::Read(u_int32_t expected_size) {
|
||||
|
||||
valid_ = false;
|
||||
|
||||
u_int32_t region_count;
|
||||
uint32_t region_count;
|
||||
if (expected_size < sizeof(region_count)) {
|
||||
BPLOG(ERROR) << "MinidumpMemoryList count size mismatch, " <<
|
||||
expected_size << " < " << sizeof(region_count);
|
||||
@@ -2656,7 +2658,7 @@ bool MinidumpMemoryList::Read(u_int32_t expected_size) {
|
||||
Swap(®ion_count);
|
||||
|
||||
if (region_count >
|
||||
numeric_limits<u_int32_t>::max() / sizeof(MDMemoryDescriptor)) {
|
||||
numeric_limits<uint32_t>::max() / sizeof(MDMemoryDescriptor)) {
|
||||
BPLOG(ERROR) << "MinidumpMemoryList region count " << region_count <<
|
||||
" would cause multiplication overflow";
|
||||
return false;
|
||||
@@ -2667,7 +2669,7 @@ bool MinidumpMemoryList::Read(u_int32_t expected_size) {
|
||||
// may be padded with 4 bytes on 64bit ABIs for alignment
|
||||
if (expected_size == sizeof(region_count) + 4 +
|
||||
region_count * sizeof(MDMemoryDescriptor)) {
|
||||
u_int32_t useless;
|
||||
uint32_t useless;
|
||||
if (!minidump_->ReadBytes(&useless, 4)) {
|
||||
BPLOG(ERROR) << "MinidumpMemoryList cannot read memorylist padded bytes";
|
||||
return false;
|
||||
@@ -2709,12 +2711,12 @@ bool MinidumpMemoryList::Read(u_int32_t expected_size) {
|
||||
if (minidump_->swap())
|
||||
Swap(descriptor);
|
||||
|
||||
u_int64_t base_address = descriptor->start_of_memory_range;
|
||||
u_int32_t region_size = descriptor->memory.data_size;
|
||||
uint64_t base_address = descriptor->start_of_memory_range;
|
||||
uint32_t region_size = descriptor->memory.data_size;
|
||||
|
||||
// Check for base + size overflow or undersize.
|
||||
if (region_size == 0 ||
|
||||
region_size > numeric_limits<u_int64_t>::max() - base_address) {
|
||||
region_size > numeric_limits<uint64_t>::max() - base_address) {
|
||||
BPLOG(ERROR) << "MinidumpMemoryList has a memory region problem, " <<
|
||||
" region " << region_index << "/" << region_count <<
|
||||
", " << HexString(base_address) << "+" <<
|
||||
@@ -2762,7 +2764,7 @@ MinidumpMemoryRegion* MinidumpMemoryList::GetMemoryRegionAtIndex(
|
||||
|
||||
|
||||
MinidumpMemoryRegion* MinidumpMemoryList::GetMemoryRegionForAddress(
|
||||
u_int64_t address) {
|
||||
uint64_t address) {
|
||||
if (!valid_) {
|
||||
BPLOG(ERROR) << "Invalid MinidumpMemoryList for GetMemoryRegionForAddress";
|
||||
return NULL;
|
||||
@@ -2828,7 +2830,7 @@ MinidumpException::~MinidumpException() {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpException::Read(u_int32_t expected_size) {
|
||||
bool MinidumpException::Read(uint32_t expected_size) {
|
||||
// Invalidate cached data.
|
||||
delete context_;
|
||||
context_ = NULL;
|
||||
@@ -2870,7 +2872,7 @@ bool MinidumpException::Read(u_int32_t expected_size) {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpException::GetThreadID(u_int32_t *thread_id) const {
|
||||
bool MinidumpException::GetThreadID(uint32_t *thread_id) const {
|
||||
BPLOG_IF(ERROR, !thread_id) << "MinidumpException::GetThreadID requires "
|
||||
"|thread_id|";
|
||||
assert(thread_id);
|
||||
@@ -2972,7 +2974,7 @@ MinidumpAssertion::~MinidumpAssertion() {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpAssertion::Read(u_int32_t expected_size) {
|
||||
bool MinidumpAssertion::Read(uint32_t expected_size) {
|
||||
// Invalidate cached data.
|
||||
valid_ = false;
|
||||
|
||||
@@ -2993,11 +2995,11 @@ bool MinidumpAssertion::Read(u_int32_t expected_size) {
|
||||
// Since we don't have an explicit byte length for each string,
|
||||
// we use UTF16codeunits to calculate word length, then derive byte
|
||||
// length from that.
|
||||
u_int32_t word_length = UTF16codeunits(assertion_.expression,
|
||||
uint32_t word_length = UTF16codeunits(assertion_.expression,
|
||||
sizeof(assertion_.expression));
|
||||
if (word_length > 0) {
|
||||
u_int32_t byte_length = word_length * 2;
|
||||
vector<u_int16_t> expression_utf16(word_length);
|
||||
uint32_t byte_length = word_length * 2;
|
||||
vector<uint16_t> expression_utf16(word_length);
|
||||
memcpy(&expression_utf16[0], &assertion_.expression[0], byte_length);
|
||||
|
||||
scoped_ptr<string> new_expression(UTF16ToUTF8(expression_utf16,
|
||||
@@ -3010,8 +3012,8 @@ bool MinidumpAssertion::Read(u_int32_t expected_size) {
|
||||
word_length = UTF16codeunits(assertion_.function,
|
||||
sizeof(assertion_.function));
|
||||
if (word_length) {
|
||||
u_int32_t byte_length = word_length * 2;
|
||||
vector<u_int16_t> function_utf16(word_length);
|
||||
uint32_t byte_length = word_length * 2;
|
||||
vector<uint16_t> function_utf16(word_length);
|
||||
memcpy(&function_utf16[0], &assertion_.function[0], byte_length);
|
||||
scoped_ptr<string> new_function(UTF16ToUTF8(function_utf16,
|
||||
minidump_->swap()));
|
||||
@@ -3023,8 +3025,8 @@ bool MinidumpAssertion::Read(u_int32_t expected_size) {
|
||||
word_length = UTF16codeunits(assertion_.file,
|
||||
sizeof(assertion_.file));
|
||||
if (word_length > 0) {
|
||||
u_int32_t byte_length = word_length * 2;
|
||||
vector<u_int16_t> file_utf16(word_length);
|
||||
uint32_t byte_length = word_length * 2;
|
||||
vector<uint16_t> file_utf16(word_length);
|
||||
memcpy(&file_utf16[0], &assertion_.file[0], byte_length);
|
||||
scoped_ptr<string> new_file(UTF16ToUTF8(file_utf16,
|
||||
minidump_->swap()));
|
||||
@@ -3080,7 +3082,7 @@ MinidumpSystemInfo::~MinidumpSystemInfo() {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpSystemInfo::Read(u_int32_t expected_size) {
|
||||
bool MinidumpSystemInfo::Read(uint32_t expected_size) {
|
||||
// Invalidate cached data.
|
||||
delete csd_version_;
|
||||
csd_version_ = NULL;
|
||||
@@ -3332,7 +3334,7 @@ MinidumpMiscInfo::MinidumpMiscInfo(Minidump* minidump)
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpMiscInfo::Read(u_int32_t expected_size) {
|
||||
bool MinidumpMiscInfo::Read(uint32_t expected_size) {
|
||||
valid_ = false;
|
||||
|
||||
if (expected_size != MD_MISCINFO_SIZE &&
|
||||
@@ -3418,7 +3420,7 @@ MinidumpBreakpadInfo::MinidumpBreakpadInfo(Minidump* minidump)
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpBreakpadInfo::Read(u_int32_t expected_size) {
|
||||
bool MinidumpBreakpadInfo::Read(uint32_t expected_size) {
|
||||
valid_ = false;
|
||||
|
||||
if (expected_size != sizeof(breakpad_info_)) {
|
||||
@@ -3443,7 +3445,7 @@ bool MinidumpBreakpadInfo::Read(u_int32_t expected_size) {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpBreakpadInfo::GetDumpThreadID(u_int32_t *thread_id) const {
|
||||
bool MinidumpBreakpadInfo::GetDumpThreadID(uint32_t *thread_id) const {
|
||||
BPLOG_IF(ERROR, !thread_id) << "MinidumpBreakpadInfo::GetDumpThreadID "
|
||||
"requires |thread_id|";
|
||||
assert(thread_id);
|
||||
@@ -3464,7 +3466,7 @@ bool MinidumpBreakpadInfo::GetDumpThreadID(u_int32_t *thread_id) const {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpBreakpadInfo::GetRequestingThreadID(u_int32_t *thread_id)
|
||||
bool MinidumpBreakpadInfo::GetRequestingThreadID(uint32_t *thread_id)
|
||||
const {
|
||||
BPLOG_IF(ERROR, !thread_id) << "MinidumpBreakpadInfo::GetRequestingThreadID "
|
||||
"requires |thread_id|";
|
||||
@@ -3525,7 +3527,7 @@ MinidumpMemoryInfo::MinidumpMemoryInfo(Minidump* minidump)
|
||||
|
||||
|
||||
bool MinidumpMemoryInfo::IsExecutable() const {
|
||||
u_int32_t protection =
|
||||
uint32_t protection =
|
||||
memory_info_.protection & MD_MEMORY_PROTECTION_ACCESS_MASK;
|
||||
return protection == MD_MEMORY_PROTECT_EXECUTE ||
|
||||
protection == MD_MEMORY_PROTECT_EXECUTE_READ ||
|
||||
@@ -3534,7 +3536,7 @@ bool MinidumpMemoryInfo::IsExecutable() const {
|
||||
|
||||
|
||||
bool MinidumpMemoryInfo::IsWritable() const {
|
||||
u_int32_t protection =
|
||||
uint32_t protection =
|
||||
memory_info_.protection & MD_MEMORY_PROTECTION_ACCESS_MASK;
|
||||
return protection == MD_MEMORY_PROTECT_READWRITE ||
|
||||
protection == MD_MEMORY_PROTECT_WRITECOPY ||
|
||||
@@ -3563,7 +3565,7 @@ bool MinidumpMemoryInfo::Read() {
|
||||
|
||||
// Check for base + size overflow or undersize.
|
||||
if (memory_info_.region_size == 0 ||
|
||||
memory_info_.region_size > numeric_limits<u_int64_t>::max() -
|
||||
memory_info_.region_size > numeric_limits<uint64_t>::max() -
|
||||
memory_info_.base_address) {
|
||||
BPLOG(ERROR) << "MinidumpMemoryInfo has a memory region problem, " <<
|
||||
HexString(memory_info_.base_address) << "+" <<
|
||||
@@ -3603,7 +3605,7 @@ void MinidumpMemoryInfo::Print() {
|
||||
|
||||
MinidumpMemoryInfoList::MinidumpMemoryInfoList(Minidump* minidump)
|
||||
: MinidumpStream(minidump),
|
||||
range_map_(new RangeMap<u_int64_t, unsigned int>()),
|
||||
range_map_(new RangeMap<uint64_t, unsigned int>()),
|
||||
infos_(NULL),
|
||||
info_count_(0) {
|
||||
}
|
||||
@@ -3615,7 +3617,7 @@ MinidumpMemoryInfoList::~MinidumpMemoryInfoList() {
|
||||
}
|
||||
|
||||
|
||||
bool MinidumpMemoryInfoList::Read(u_int32_t expected_size) {
|
||||
bool MinidumpMemoryInfoList::Read(uint32_t expected_size) {
|
||||
// Invalidate cached data.
|
||||
delete infos_;
|
||||
infos_ = NULL;
|
||||
@@ -3660,7 +3662,7 @@ bool MinidumpMemoryInfoList::Read(u_int32_t expected_size) {
|
||||
}
|
||||
|
||||
if (header.number_of_entries >
|
||||
numeric_limits<u_int32_t>::max() / sizeof(MDRawMemoryInfo)) {
|
||||
numeric_limits<uint32_t>::max() / sizeof(MDRawMemoryInfo)) {
|
||||
BPLOG(ERROR) << "MinidumpMemoryInfoList info count " <<
|
||||
header.number_of_entries <<
|
||||
" would cause multiplication overflow";
|
||||
@@ -3692,8 +3694,8 @@ bool MinidumpMemoryInfoList::Read(u_int32_t expected_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
u_int64_t base_address = info->GetBase();
|
||||
u_int32_t region_size = info->GetSize();
|
||||
uint64_t base_address = info->GetBase();
|
||||
uint32_t region_size = info->GetSize();
|
||||
|
||||
if (!range_map_->StoreRange(base_address, region_size, index)) {
|
||||
BPLOG(ERROR) << "MinidumpMemoryInfoList could not store"
|
||||
@@ -3733,7 +3735,7 @@ const MinidumpMemoryInfo* MinidumpMemoryInfoList::GetMemoryInfoAtIndex(
|
||||
|
||||
|
||||
const MinidumpMemoryInfo* MinidumpMemoryInfoList::GetMemoryInfoForAddress(
|
||||
u_int64_t address) const {
|
||||
uint64_t address) const {
|
||||
if (!valid_) {
|
||||
BPLOG(ERROR) << "Invalid MinidumpMemoryInfoList for"
|
||||
" GetMemoryInfoForAddress";
|
||||
@@ -3776,7 +3778,7 @@ void MinidumpMemoryInfoList::Print() {
|
||||
//
|
||||
|
||||
|
||||
u_int32_t Minidump::max_streams_ = 128;
|
||||
uint32_t Minidump::max_streams_ = 128;
|
||||
unsigned int Minidump::max_string_length_ = 1024;
|
||||
|
||||
|
||||
@@ -3834,7 +3836,7 @@ bool Minidump::Open() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Minidump::GetContextCPUFlagsFromSystemInfo(u_int32_t *context_cpu_flags) {
|
||||
bool Minidump::GetContextCPUFlagsFromSystemInfo(uint32_t *context_cpu_flags) {
|
||||
// Initialize output parameters
|
||||
*context_cpu_flags = 0;
|
||||
|
||||
@@ -3924,7 +3926,7 @@ bool Minidump::Read() {
|
||||
// classes don't know or need to know what CPU (or endianness) the
|
||||
// minidump was produced on in order to parse it. Use the signature as
|
||||
// a byte order marker.
|
||||
u_int32_t signature_swapped = header_.signature;
|
||||
uint32_t signature_swapped = header_.signature;
|
||||
Swap(&signature_swapped);
|
||||
if (signature_swapped != MD_HEADER_SIGNATURE) {
|
||||
// This isn't a minidump or a byte-swapped minidump.
|
||||
@@ -4128,7 +4130,7 @@ void Minidump::Print() {
|
||||
for (MinidumpStreamMap::const_iterator iterator = stream_map_->begin();
|
||||
iterator != stream_map_->end();
|
||||
++iterator) {
|
||||
u_int32_t stream_type = iterator->first;
|
||||
uint32_t stream_type = iterator->first;
|
||||
MinidumpStreamInfo info = iterator->second;
|
||||
printf(" stream type 0x%x at index %d\n", stream_type, info.stream_index);
|
||||
}
|
||||
@@ -4210,7 +4212,7 @@ string* Minidump::ReadString(off_t offset) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_int32_t bytes;
|
||||
uint32_t bytes;
|
||||
if (!ReadBytes(&bytes, sizeof(bytes))) {
|
||||
BPLOG(ERROR) << "ReadString could not read string size at offset " <<
|
||||
offset;
|
||||
@@ -4233,7 +4235,7 @@ string* Minidump::ReadString(off_t offset) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vector<u_int16_t> string_utf16(utf16_words);
|
||||
vector<uint16_t> string_utf16(utf16_words);
|
||||
|
||||
if (utf16_words) {
|
||||
if (!ReadBytes(&string_utf16[0], bytes)) {
|
||||
@@ -4247,8 +4249,8 @@ string* Minidump::ReadString(off_t offset) {
|
||||
}
|
||||
|
||||
|
||||
bool Minidump::SeekToStreamType(u_int32_t stream_type,
|
||||
u_int32_t* stream_length) {
|
||||
bool Minidump::SeekToStreamType(uint32_t stream_type,
|
||||
uint32_t* stream_length) {
|
||||
BPLOG_IF(ERROR, !stream_length) << "Minidump::SeekToStreamType requires "
|
||||
"|stream_length|";
|
||||
assert(stream_length);
|
||||
@@ -4292,7 +4294,7 @@ T* Minidump::GetStream(T** stream) {
|
||||
// stream is a garbage parameter that's present only to account for C++'s
|
||||
// inability to overload a method based solely on its return type.
|
||||
|
||||
const u_int32_t stream_type = T::kStreamType;
|
||||
const uint32_t stream_type = T::kStreamType;
|
||||
|
||||
BPLOG_IF(ERROR, !stream) << "Minidump::GetStream type " << stream_type <<
|
||||
" requires |stream|";
|
||||
@@ -4321,7 +4323,7 @@ T* Minidump::GetStream(T** stream) {
|
||||
return *stream;
|
||||
}
|
||||
|
||||
u_int32_t stream_length;
|
||||
uint32_t stream_length;
|
||||
if (!SeekToStreamType(stream_type, &stream_length)) {
|
||||
BPLOG(ERROR) << "GetStream could not seek to stream type " << stream_type;
|
||||
return NULL;
|
||||
|
||||
@@ -53,10 +53,10 @@ using google_breakpad::MinidumpMiscInfo;
|
||||
using google_breakpad::MinidumpBreakpadInfo;
|
||||
|
||||
static void DumpRawStream(Minidump *minidump,
|
||||
u_int32_t stream_type,
|
||||
uint32_t stream_type,
|
||||
const char *stream_name,
|
||||
int *errors) {
|
||||
u_int32_t length = 0;
|
||||
uint32_t length = 0;
|
||||
if (!minidump->SeekToStreamType(stream_type, &length)) {
|
||||
return;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ static void DumpRawStream(Minidump *minidump,
|
||||
size_t remaining = length - current_offset;
|
||||
// Printf requires an int and direct casting from size_t results
|
||||
// in compatibility warnings.
|
||||
u_int32_t int_remaining = remaining;
|
||||
uint32_t int_remaining = remaining;
|
||||
printf("%.*s", int_remaining, &contents[current_offset]);
|
||||
char *next_null = reinterpret_cast<char *>(
|
||||
memchr(&contents[current_offset], 0, remaining));
|
||||
|
||||
@@ -87,9 +87,9 @@ ProcessResult MinidumpProcessor::Process(
|
||||
bool has_cpu_info = GetCPUInfo(dump, &process_state->system_info_);
|
||||
bool has_os_info = GetOSInfo(dump, &process_state->system_info_);
|
||||
|
||||
u_int32_t dump_thread_id = 0;
|
||||
uint32_t dump_thread_id = 0;
|
||||
bool has_dump_thread = false;
|
||||
u_int32_t requesting_thread_id = 0;
|
||||
uint32_t requesting_thread_id = 0;
|
||||
bool has_requesting_thread = false;
|
||||
|
||||
MinidumpBreakpadInfo *breakpad_info = dump->GetBreakpadInfo();
|
||||
@@ -156,7 +156,7 @@ ProcessResult MinidumpProcessor::Process(
|
||||
return PROCESS_ERROR_GETTING_THREAD;
|
||||
}
|
||||
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
if (!thread->GetThreadID(&thread_id)) {
|
||||
BPLOG(ERROR) << "Could not get thread ID for " << thread_string;
|
||||
return PROCESS_ERROR_GETTING_THREAD_ID;
|
||||
@@ -450,7 +450,7 @@ bool MinidumpProcessor::GetOSInfo(Minidump *dump, SystemInfo *info) {
|
||||
}
|
||||
|
||||
// static
|
||||
string MinidumpProcessor::GetCrashReason(Minidump *dump, u_int64_t *address) {
|
||||
string MinidumpProcessor::GetCrashReason(Minidump *dump, uint64_t *address) {
|
||||
MinidumpException *exception = dump->GetException();
|
||||
if (!exception)
|
||||
return "";
|
||||
@@ -467,8 +467,8 @@ string MinidumpProcessor::GetCrashReason(Minidump *dump, u_int64_t *address) {
|
||||
// map the codes to a string (because there's no system info, or because
|
||||
// it's an unrecognized platform, or because it's an unrecognized code.)
|
||||
char reason_string[24];
|
||||
u_int32_t exception_code = raw_exception->exception_record.exception_code;
|
||||
u_int32_t exception_flags = raw_exception->exception_record.exception_flags;
|
||||
uint32_t exception_code = raw_exception->exception_record.exception_code;
|
||||
uint32_t exception_flags = raw_exception->exception_record.exception_flags;
|
||||
snprintf(reason_string, sizeof(reason_string), "0x%08x / 0x%08x",
|
||||
exception_code, exception_flags);
|
||||
string reason = reason_string;
|
||||
|
||||
@@ -84,7 +84,7 @@ class MockMinidumpThread : public MinidumpThread {
|
||||
public:
|
||||
MockMinidumpThread() : MinidumpThread(NULL) {}
|
||||
|
||||
MOCK_CONST_METHOD1(GetThreadID, bool(u_int32_t*));
|
||||
MOCK_CONST_METHOD1(GetThreadID, bool(uint32_t*));
|
||||
MOCK_METHOD0(GetContext, MinidumpContext*());
|
||||
MOCK_METHOD0(GetMemory, MinidumpMemoryRegion*());
|
||||
};
|
||||
@@ -93,24 +93,24 @@ class MockMinidumpThread : public MinidumpThread {
|
||||
// MinidumpMemoryRegion.
|
||||
class MockMinidumpMemoryRegion : public MinidumpMemoryRegion {
|
||||
public:
|
||||
MockMinidumpMemoryRegion(u_int64_t base, const string& contents) :
|
||||
MockMinidumpMemoryRegion(uint64_t base, const string& contents) :
|
||||
MinidumpMemoryRegion(NULL) {
|
||||
region_.Init(base, contents);
|
||||
}
|
||||
|
||||
u_int64_t GetBase() const { return region_.GetBase(); }
|
||||
u_int32_t GetSize() const { return region_.GetSize(); }
|
||||
uint64_t GetBase() const { return region_.GetBase(); }
|
||||
uint32_t GetSize() const { return region_.GetSize(); }
|
||||
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int8_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const {
|
||||
return region_.GetMemoryAtAddress(address, value);
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int16_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const {
|
||||
return region_.GetMemoryAtAddress(address, value);
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int32_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const {
|
||||
return region_.GetMemoryAtAddress(address, value);
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int64_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const {
|
||||
return region_.GetMemoryAtAddress(address, value);
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ TEST_F(MinidumpProcessorTest, TestThreadMissingMemory) {
|
||||
memset(&no_memory_thread_raw_context, 0,
|
||||
sizeof(no_memory_thread_raw_context));
|
||||
no_memory_thread_raw_context.context_flags = MD_CONTEXT_X86_FULL;
|
||||
const u_int32_t kExpectedEIP = 0xabcd1234;
|
||||
const uint32_t kExpectedEIP = 0xabcd1234;
|
||||
no_memory_thread_raw_context.eip = kExpectedEIP;
|
||||
TestMinidumpContext no_memory_thread_context(no_memory_thread_raw_context);
|
||||
EXPECT_CALL(no_memory_thread, GetContext()).
|
||||
|
||||
@@ -84,7 +84,7 @@ static const char kOutputSeparator = '|';
|
||||
// of registers is completely printed, regardless of the number of calls
|
||||
// to PrintRegister.
|
||||
static const int kMaxWidth = 80; // optimize for an 80-column terminal
|
||||
static int PrintRegister(const char *name, u_int32_t value, int start_col) {
|
||||
static int PrintRegister(const char *name, uint32_t value, int start_col) {
|
||||
char buffer[64];
|
||||
snprintf(buffer, sizeof(buffer), " %5s = 0x%08x", name, value);
|
||||
|
||||
@@ -98,7 +98,7 @@ static int PrintRegister(const char *name, u_int32_t value, int start_col) {
|
||||
}
|
||||
|
||||
// PrintRegister64 does the same thing, but for 64-bit registers.
|
||||
static int PrintRegister64(const char *name, u_int64_t value, int start_col) {
|
||||
static int PrintRegister64(const char *name, uint64_t value, int start_col) {
|
||||
char buffer[64];
|
||||
snprintf(buffer, sizeof(buffer), " %5s = 0x%016" PRIx64 , name, value);
|
||||
|
||||
@@ -144,7 +144,7 @@ static void PrintStack(const CallStack *stack, const string &cpu) {
|
||||
const StackFrame *frame = stack->frames()->at(frame_index);
|
||||
printf("%2d ", frame_index);
|
||||
|
||||
u_int64_t instruction_address = frame->ReturnAddress();
|
||||
uint64_t instruction_address = frame->ReturnAddress();
|
||||
|
||||
if (frame->module) {
|
||||
printf("%s", PathnameStripper::File(frame->module->code_file()).c_str());
|
||||
@@ -288,7 +288,7 @@ static void PrintStackMachineReadable(int thread_num, const CallStack *stack) {
|
||||
printf("%d%c%d%c", thread_num, kOutputSeparator, frame_index,
|
||||
kOutputSeparator);
|
||||
|
||||
u_int64_t instruction_address = frame->ReturnAddress();
|
||||
uint64_t instruction_address = frame->ReturnAddress();
|
||||
|
||||
if (frame->module) {
|
||||
assert(!frame->module->code_file().empty());
|
||||
@@ -340,7 +340,7 @@ static void PrintModules(const CodeModules *modules) {
|
||||
printf("\n");
|
||||
printf("Loaded modules:\n");
|
||||
|
||||
u_int64_t main_address = 0;
|
||||
uint64_t main_address = 0;
|
||||
const CodeModule *main_module = modules->GetMainModule();
|
||||
if (main_module) {
|
||||
main_address = main_module->base_address();
|
||||
@@ -351,7 +351,7 @@ static void PrintModules(const CodeModules *modules) {
|
||||
module_sequence < module_count;
|
||||
++module_sequence) {
|
||||
const CodeModule *module = modules->GetModuleAtSequence(module_sequence);
|
||||
u_int64_t base_address = module->base_address();
|
||||
uint64_t base_address = module->base_address();
|
||||
printf("0x%08" PRIx64 " - 0x%08" PRIx64 " %s %s%s\n",
|
||||
base_address, base_address + module->size() - 1,
|
||||
PathnameStripper::File(module->code_file()).c_str(),
|
||||
@@ -370,7 +370,7 @@ static void PrintModulesMachineReadable(const CodeModules *modules) {
|
||||
if (!modules)
|
||||
return;
|
||||
|
||||
u_int64_t main_address = 0;
|
||||
uint64_t main_address = 0;
|
||||
const CodeModule *main_module = modules->GetMainModule();
|
||||
if (main_module) {
|
||||
main_address = main_module->base_address();
|
||||
@@ -381,7 +381,7 @@ static void PrintModulesMachineReadable(const CodeModules *modules) {
|
||||
module_sequence < module_count;
|
||||
++module_sequence) {
|
||||
const CodeModule *module = modules->GetModuleAtSequence(module_sequence);
|
||||
u_int64_t base_address = module->base_address();
|
||||
uint64_t base_address = module->base_address();
|
||||
printf("Module%c%s%c%s%c%s%c%s%c0x%08" PRIx64 "%c0x%08" PRIx64 "%c%d\n",
|
||||
kOutputSeparator,
|
||||
StripSeparator(PathnameStripper::File(module->code_file())).c_str(),
|
||||
|
||||
@@ -89,7 +89,7 @@ TEST_F(MinidumpTest, TestMinidumpFromFile) {
|
||||
ASSERT_TRUE(minidump.Read());
|
||||
const MDRawHeader* header = minidump.header();
|
||||
ASSERT_NE(header, (MDRawHeader*)NULL);
|
||||
ASSERT_EQ(header->signature, u_int32_t(MD_HEADER_SIGNATURE));
|
||||
ASSERT_EQ(header->signature, uint32_t(MD_HEADER_SIGNATURE));
|
||||
//TODO: add more checks here
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ TEST_F(MinidumpTest, TestMinidumpFromStream) {
|
||||
ASSERT_TRUE(minidump.Read());
|
||||
const MDRawHeader* header = minidump.header();
|
||||
ASSERT_NE(header, (MDRawHeader*)NULL);
|
||||
ASSERT_EQ(header->signature, u_int32_t(MD_HEADER_SIGNATURE));
|
||||
ASSERT_EQ(header->signature, uint32_t(MD_HEADER_SIGNATURE));
|
||||
//TODO: add more checks here
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ TEST(Dump, OneStream) {
|
||||
ASSERT_TRUE(dir != NULL);
|
||||
EXPECT_EQ(0xfbb7fa2bU, dir->stream_type);
|
||||
|
||||
u_int32_t stream_length;
|
||||
uint32_t stream_length;
|
||||
ASSERT_TRUE(minidump.SeekToStreamType(0xfbb7fa2bU, &stream_length));
|
||||
ASSERT_EQ(15U, stream_length);
|
||||
char stream_contents[15];
|
||||
@@ -193,7 +193,7 @@ TEST(Dump, OneMemory) {
|
||||
|
||||
const MDRawDirectory *dir = minidump.GetDirectoryEntryAtIndex(0);
|
||||
ASSERT_TRUE(dir != NULL);
|
||||
EXPECT_EQ((u_int32_t) MD_MEMORY_LIST_STREAM, dir->stream_type);
|
||||
EXPECT_EQ((uint32_t) MD_MEMORY_LIST_STREAM, dir->stream_type);
|
||||
|
||||
MinidumpMemoryList *memory_list = minidump.GetMemoryList();
|
||||
ASSERT_TRUE(memory_list != NULL);
|
||||
@@ -202,7 +202,7 @@ TEST(Dump, OneMemory) {
|
||||
MinidumpMemoryRegion *region1 = memory_list->GetMemoryRegionAtIndex(0);
|
||||
ASSERT_EQ(0x309d68010bd21b2cULL, region1->GetBase());
|
||||
ASSERT_EQ(15U, region1->GetSize());
|
||||
const u_int8_t *region1_bytes = region1->GetMemory();
|
||||
const uint8_t *region1_bytes = region1->GetMemory();
|
||||
ASSERT_TRUE(memcmp("memory contents", region1_bytes, 15) == 0);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ TEST(Dump, OneThread) {
|
||||
stack.Append("stack for thread");
|
||||
|
||||
MDRawContextX86 raw_context;
|
||||
const u_int32_t kExpectedEIP = 0x6913f540;
|
||||
const uint32_t kExpectedEIP = 0x6913f540;
|
||||
raw_context.context_flags = MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL;
|
||||
raw_context.edi = 0x3ecba80d;
|
||||
raw_context.esi = 0x382583b9;
|
||||
@@ -252,7 +252,7 @@ TEST(Dump, OneThread) {
|
||||
MinidumpMemoryRegion *md_region = md_memory_list->GetMemoryRegionAtIndex(0);
|
||||
ASSERT_EQ(0x2326a0faU, md_region->GetBase());
|
||||
ASSERT_EQ(16U, md_region->GetSize());
|
||||
const u_int8_t *region_bytes = md_region->GetMemory();
|
||||
const uint8_t *region_bytes = md_region->GetMemory();
|
||||
ASSERT_TRUE(memcmp("stack for thread", region_bytes, 16) == 0);
|
||||
|
||||
MinidumpThreadList *thread_list = minidump.GetThreadList();
|
||||
@@ -261,27 +261,27 @@ TEST(Dump, OneThread) {
|
||||
|
||||
MinidumpThread *md_thread = thread_list->GetThreadAtIndex(0);
|
||||
ASSERT_TRUE(md_thread != NULL);
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
ASSERT_TRUE(md_thread->GetThreadID(&thread_id));
|
||||
ASSERT_EQ(0xa898f11bU, thread_id);
|
||||
MinidumpMemoryRegion *md_stack = md_thread->GetMemory();
|
||||
ASSERT_TRUE(md_stack != NULL);
|
||||
ASSERT_EQ(0x2326a0faU, md_stack->GetBase());
|
||||
ASSERT_EQ(16U, md_stack->GetSize());
|
||||
const u_int8_t *md_stack_bytes = md_stack->GetMemory();
|
||||
const uint8_t *md_stack_bytes = md_stack->GetMemory();
|
||||
ASSERT_TRUE(memcmp("stack for thread", md_stack_bytes, 16) == 0);
|
||||
|
||||
MinidumpContext *md_context = md_thread->GetContext();
|
||||
ASSERT_TRUE(md_context != NULL);
|
||||
ASSERT_EQ((u_int32_t) MD_CONTEXT_X86, md_context->GetContextCPU());
|
||||
ASSERT_EQ((uint32_t) MD_CONTEXT_X86, md_context->GetContextCPU());
|
||||
|
||||
u_int64_t eip;
|
||||
uint64_t eip;
|
||||
ASSERT_TRUE(md_context->GetInstructionPointer(&eip));
|
||||
EXPECT_EQ(kExpectedEIP, eip);
|
||||
|
||||
const MDRawContextX86 *md_raw_context = md_context->GetContextX86();
|
||||
ASSERT_TRUE(md_raw_context != NULL);
|
||||
ASSERT_EQ((u_int32_t) (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL),
|
||||
ASSERT_EQ((uint32_t) (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL),
|
||||
(md_raw_context->context_flags
|
||||
& (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL)));
|
||||
EXPECT_EQ(0x3ecba80dU, raw_context.edi);
|
||||
@@ -332,7 +332,7 @@ TEST(Dump, ThreadMissingMemory) {
|
||||
MinidumpThread* md_thread = thread_list->GetThreadAtIndex(0);
|
||||
ASSERT_TRUE(md_thread != NULL);
|
||||
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
ASSERT_TRUE(md_thread->GetThreadID(&thread_id));
|
||||
ASSERT_EQ(0xa898f11bU, thread_id);
|
||||
|
||||
@@ -375,7 +375,7 @@ TEST(Dump, ThreadMissingContext) {
|
||||
MinidumpThread* md_thread = thread_list->GetThreadAtIndex(0);
|
||||
ASSERT_TRUE(md_thread != NULL);
|
||||
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
ASSERT_TRUE(md_thread->GetThreadID(&thread_id));
|
||||
ASSERT_EQ(0xa898f11bU, thread_id);
|
||||
MinidumpMemoryRegion* md_stack = md_thread->GetMemory();
|
||||
@@ -424,7 +424,7 @@ TEST(Dump, OneModule) {
|
||||
|
||||
const MDRawDirectory *dir = minidump.GetDirectoryEntryAtIndex(0);
|
||||
ASSERT_TRUE(dir != NULL);
|
||||
EXPECT_EQ((u_int32_t) MD_MODULE_LIST_STREAM, dir->stream_type);
|
||||
EXPECT_EQ((uint32_t) MD_MODULE_LIST_STREAM, dir->stream_type);
|
||||
|
||||
MinidumpModuleList *md_module_list = minidump.GetModuleList();
|
||||
ASSERT_TRUE(md_module_list != NULL);
|
||||
@@ -462,7 +462,7 @@ TEST(Dump, OneSystemInfo) {
|
||||
|
||||
const MDRawDirectory *dir = minidump.GetDirectoryEntryAtIndex(0);
|
||||
ASSERT_TRUE(dir != NULL);
|
||||
EXPECT_EQ((u_int32_t) MD_SYSTEM_INFO_STREAM, dir->stream_type);
|
||||
EXPECT_EQ((uint32_t) MD_SYSTEM_INFO_STREAM, dir->stream_type);
|
||||
|
||||
MinidumpSystemInfo *md_system_info = minidump.GetSystemInfo();
|
||||
ASSERT_TRUE(md_system_info != NULL);
|
||||
@@ -576,7 +576,7 @@ TEST(Dump, BigDump) {
|
||||
MinidumpThreadList *thread_list = minidump.GetThreadList();
|
||||
ASSERT_TRUE(thread_list != NULL);
|
||||
ASSERT_EQ(5U, thread_list->thread_count());
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
ASSERT_TRUE(thread_list->GetThreadAtIndex(0)->GetThreadID(&thread_id));
|
||||
ASSERT_EQ(0xbbef4432U, thread_id);
|
||||
ASSERT_EQ(0x70b9ebfcU,
|
||||
@@ -634,15 +634,15 @@ TEST(Dump, OneMemoryInfo) {
|
||||
Stream stream(dump, MD_MEMORY_INFO_LIST_STREAM);
|
||||
|
||||
// Add the MDRawMemoryInfoList header.
|
||||
const u_int64_t kNumberOfEntries = 1;
|
||||
const uint64_t kNumberOfEntries = 1;
|
||||
stream.D32(sizeof(MDRawMemoryInfoList)) // size_of_header
|
||||
.D32(sizeof(MDRawMemoryInfo)) // size_of_entry
|
||||
.D64(kNumberOfEntries); // number_of_entries
|
||||
|
||||
|
||||
// Now add a MDRawMemoryInfo entry.
|
||||
const u_int64_t kBaseAddress = 0x1000;
|
||||
const u_int64_t kRegionSize = 0x2000;
|
||||
const uint64_t kBaseAddress = 0x1000;
|
||||
const uint64_t kRegionSize = 0x2000;
|
||||
stream.D64(kBaseAddress) // base_address
|
||||
.D64(kBaseAddress) // allocation_base
|
||||
.D32(MD_MEMORY_PROTECT_EXECUTE_READWRITE) // allocation_protection
|
||||
@@ -665,7 +665,7 @@ TEST(Dump, OneMemoryInfo) {
|
||||
|
||||
const MDRawDirectory *dir = minidump.GetDirectoryEntryAtIndex(0);
|
||||
ASSERT_TRUE(dir != NULL);
|
||||
EXPECT_EQ((u_int32_t) MD_MEMORY_INFO_LIST_STREAM, dir->stream_type);
|
||||
EXPECT_EQ((uint32_t) MD_MEMORY_INFO_LIST_STREAM, dir->stream_type);
|
||||
|
||||
MinidumpMemoryInfoList *info_list = minidump.GetMemoryInfoList();
|
||||
ASSERT_TRUE(info_list != NULL);
|
||||
@@ -724,7 +724,7 @@ TEST(Dump, OneExceptionX86) {
|
||||
MinidumpException *md_exception = minidump.GetException();
|
||||
ASSERT_TRUE(md_exception != NULL);
|
||||
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
ASSERT_TRUE(md_exception->GetThreadID(&thread_id));
|
||||
ASSERT_EQ(0x1234abcdU, thread_id);
|
||||
|
||||
@@ -737,10 +737,10 @@ TEST(Dump, OneExceptionX86) {
|
||||
|
||||
MinidumpContext *md_context = md_exception->GetContext();
|
||||
ASSERT_TRUE(md_context != NULL);
|
||||
ASSERT_EQ((u_int32_t) MD_CONTEXT_X86, md_context->GetContextCPU());
|
||||
ASSERT_EQ((uint32_t) MD_CONTEXT_X86, md_context->GetContextCPU());
|
||||
const MDRawContextX86 *md_raw_context = md_context->GetContextX86();
|
||||
ASSERT_TRUE(md_raw_context != NULL);
|
||||
ASSERT_EQ((u_int32_t) (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL),
|
||||
ASSERT_EQ((uint32_t) (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL),
|
||||
(md_raw_context->context_flags
|
||||
& (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL)));
|
||||
EXPECT_EQ(0x3ecba80dU, raw_context.edi);
|
||||
@@ -798,7 +798,7 @@ TEST(Dump, OneExceptionX86XState) {
|
||||
MinidumpException *md_exception = minidump.GetException();
|
||||
ASSERT_TRUE(md_exception != NULL);
|
||||
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
ASSERT_TRUE(md_exception->GetThreadID(&thread_id));
|
||||
ASSERT_EQ(0x1234abcdU, thread_id);
|
||||
|
||||
@@ -811,10 +811,10 @@ TEST(Dump, OneExceptionX86XState) {
|
||||
|
||||
MinidumpContext *md_context = md_exception->GetContext();
|
||||
ASSERT_TRUE(md_context != NULL);
|
||||
ASSERT_EQ((u_int32_t) MD_CONTEXT_X86, md_context->GetContextCPU());
|
||||
ASSERT_EQ((uint32_t) MD_CONTEXT_X86, md_context->GetContextCPU());
|
||||
const MDRawContextX86 *md_raw_context = md_context->GetContextX86();
|
||||
ASSERT_TRUE(md_raw_context != NULL);
|
||||
ASSERT_EQ((u_int32_t) (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL),
|
||||
ASSERT_EQ((uint32_t) (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL),
|
||||
(md_raw_context->context_flags
|
||||
& (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL)));
|
||||
EXPECT_EQ(0x3ecba80dU, raw_context.edi);
|
||||
@@ -883,7 +883,7 @@ TEST(Dump, OneExceptionX86NoCPUFlags) {
|
||||
MinidumpException *md_exception = minidump.GetException();
|
||||
ASSERT_TRUE(md_exception != NULL);
|
||||
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
ASSERT_TRUE(md_exception->GetThreadID(&thread_id));
|
||||
ASSERT_EQ(0x1234abcdU, thread_id);
|
||||
|
||||
@@ -897,14 +897,14 @@ TEST(Dump, OneExceptionX86NoCPUFlags) {
|
||||
MinidumpContext *md_context = md_exception->GetContext();
|
||||
ASSERT_TRUE(md_context != NULL);
|
||||
|
||||
ASSERT_EQ((u_int32_t) MD_CONTEXT_X86, md_context->GetContextCPU());
|
||||
ASSERT_EQ((uint32_t) MD_CONTEXT_X86, md_context->GetContextCPU());
|
||||
const MDRawContextX86 *md_raw_context = md_context->GetContextX86();
|
||||
ASSERT_TRUE(md_raw_context != NULL);
|
||||
|
||||
// Even though the CPU flags were missing from the context_flags, the
|
||||
// GetContext call above is expected to load the missing CPU flags from the
|
||||
// system info stream and set the CPU type bits in context_flags.
|
||||
ASSERT_EQ((u_int32_t) (MD_CONTEXT_X86), md_raw_context->context_flags);
|
||||
ASSERT_EQ((uint32_t) (MD_CONTEXT_X86), md_raw_context->context_flags);
|
||||
|
||||
EXPECT_EQ(0x3ecba80dU, raw_context.edi);
|
||||
EXPECT_EQ(0x382583b9U, raw_context.esi);
|
||||
@@ -965,7 +965,7 @@ TEST(Dump, OneExceptionX86NoCPUFlagsNoSystemInfo) {
|
||||
MinidumpException *md_exception = minidump.GetException();
|
||||
ASSERT_TRUE(md_exception != NULL);
|
||||
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
ASSERT_TRUE(md_exception->GetThreadID(&thread_id));
|
||||
ASSERT_EQ(0x1234abcdU, thread_id);
|
||||
|
||||
@@ -1028,7 +1028,7 @@ TEST(Dump, OneExceptionARM) {
|
||||
MinidumpException *md_exception = minidump.GetException();
|
||||
ASSERT_TRUE(md_exception != NULL);
|
||||
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
ASSERT_TRUE(md_exception->GetThreadID(&thread_id));
|
||||
ASSERT_EQ(0x1234abcdU, thread_id);
|
||||
|
||||
@@ -1041,10 +1041,10 @@ TEST(Dump, OneExceptionARM) {
|
||||
|
||||
MinidumpContext *md_context = md_exception->GetContext();
|
||||
ASSERT_TRUE(md_context != NULL);
|
||||
ASSERT_EQ((u_int32_t) MD_CONTEXT_ARM, md_context->GetContextCPU());
|
||||
ASSERT_EQ((uint32_t) MD_CONTEXT_ARM, md_context->GetContextCPU());
|
||||
const MDRawContextARM *md_raw_context = md_context->GetContextARM();
|
||||
ASSERT_TRUE(md_raw_context != NULL);
|
||||
ASSERT_EQ((u_int32_t) MD_CONTEXT_ARM_INTEGER,
|
||||
ASSERT_EQ((uint32_t) MD_CONTEXT_ARM_INTEGER,
|
||||
(md_raw_context->context_flags
|
||||
& MD_CONTEXT_ARM_INTEGER));
|
||||
EXPECT_EQ(0x3ecba80dU, raw_context.iregs[0]);
|
||||
@@ -1112,7 +1112,7 @@ TEST(Dump, OneExceptionARMOldFlags) {
|
||||
MinidumpException *md_exception = minidump.GetException();
|
||||
ASSERT_TRUE(md_exception != NULL);
|
||||
|
||||
u_int32_t thread_id;
|
||||
uint32_t thread_id;
|
||||
ASSERT_TRUE(md_exception->GetThreadID(&thread_id));
|
||||
ASSERT_EQ(0x1234abcdU, thread_id);
|
||||
|
||||
@@ -1125,10 +1125,10 @@ TEST(Dump, OneExceptionARMOldFlags) {
|
||||
|
||||
MinidumpContext *md_context = md_exception->GetContext();
|
||||
ASSERT_TRUE(md_context != NULL);
|
||||
ASSERT_EQ((u_int32_t) MD_CONTEXT_ARM, md_context->GetContextCPU());
|
||||
ASSERT_EQ((uint32_t) MD_CONTEXT_ARM, md_context->GetContextCPU());
|
||||
const MDRawContextARM *md_raw_context = md_context->GetContextARM();
|
||||
ASSERT_TRUE(md_raw_context != NULL);
|
||||
ASSERT_EQ((u_int32_t) MD_CONTEXT_ARM_INTEGER,
|
||||
ASSERT_EQ((uint32_t) MD_CONTEXT_ARM_INTEGER,
|
||||
(md_raw_context->context_flags
|
||||
& MD_CONTEXT_ARM_INTEGER));
|
||||
EXPECT_EQ(0x3ecba80dU, raw_context.iregs[0]);
|
||||
|
||||
@@ -65,7 +65,7 @@ size_t ModuleSerializer::SizeOf(const BasicSourceLineResolver::Module &module) {
|
||||
module.cfi_delta_rules_);
|
||||
|
||||
// Header size.
|
||||
total_size_alloc_ = kNumberMaps_ * sizeof(u_int32_t);
|
||||
total_size_alloc_ = kNumberMaps_ * sizeof(uint32_t);
|
||||
|
||||
for (int i = 0; i < kNumberMaps_; ++i)
|
||||
total_size_alloc_ += map_sizes_[i];
|
||||
@@ -79,8 +79,8 @@ size_t ModuleSerializer::SizeOf(const BasicSourceLineResolver::Module &module) {
|
||||
char *ModuleSerializer::Write(const BasicSourceLineResolver::Module &module,
|
||||
char *dest) {
|
||||
// Write header.
|
||||
memcpy(dest, map_sizes_, kNumberMaps_ * sizeof(u_int32_t));
|
||||
dest += kNumberMaps_ * sizeof(u_int32_t);
|
||||
memcpy(dest, map_sizes_, kNumberMaps_ * sizeof(uint32_t));
|
||||
dest += kNumberMaps_ * sizeof(uint32_t);
|
||||
// Write each map.
|
||||
dest = files_serializer_.Write(module.files_, dest);
|
||||
dest = functions_serializer_.Write(module.functions_, dest);
|
||||
|
||||
@@ -110,7 +110,7 @@ class ModuleSerializer {
|
||||
FastSourceLineResolver::Module::kNumberMaps_;
|
||||
|
||||
// Memory sizes required to serialize map components in Module.
|
||||
u_int32_t map_sizes_[kNumberMaps_];
|
||||
uint32_t map_sizes_[kNumberMaps_];
|
||||
|
||||
// Serializers for each individual map component in Module class.
|
||||
StdMapSerializer<int, string> files_serializer_;
|
||||
|
||||
@@ -57,21 +57,21 @@ using google_breakpad::PostfixEvaluator;
|
||||
// the value.
|
||||
class FakeMemoryRegion : public MemoryRegion {
|
||||
public:
|
||||
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 {
|
||||
virtual uint64_t GetBase() const { return 0; }
|
||||
virtual uint32_t GetSize() const { return 0; }
|
||||
virtual bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const {
|
||||
*value = address + 1;
|
||||
return true;
|
||||
}
|
||||
virtual bool GetMemoryAtAddress(u_int64_t address, u_int16_t *value) const {
|
||||
virtual bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const {
|
||||
*value = address + 1;
|
||||
return true;
|
||||
}
|
||||
virtual bool GetMemoryAtAddress(u_int64_t address, u_int32_t *value) const {
|
||||
virtual bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const {
|
||||
*value = address + 1;
|
||||
return true;
|
||||
}
|
||||
virtual bool GetMemoryAtAddress(u_int64_t address, u_int64_t *value) const {
|
||||
virtual bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const {
|
||||
*value = address + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -134,12 +134,12 @@ class SimpleSerializer<WindowsFrameInfo> {
|
||||
unsigned int size = 0;
|
||||
size += sizeof(int32_t); // wfi.type_
|
||||
size += SimpleSerializer<int32_t>::SizeOf(wfi.valid);
|
||||
size += SimpleSerializer<u_int32_t>::SizeOf(wfi.prolog_size);
|
||||
size += SimpleSerializer<u_int32_t>::SizeOf(wfi.epilog_size);
|
||||
size += SimpleSerializer<u_int32_t>::SizeOf(wfi.parameter_size);
|
||||
size += SimpleSerializer<u_int32_t>::SizeOf(wfi.saved_register_size);
|
||||
size += SimpleSerializer<u_int32_t>::SizeOf(wfi.local_size);
|
||||
size += SimpleSerializer<u_int32_t>::SizeOf(wfi.max_stack_size);
|
||||
size += SimpleSerializer<uint32_t>::SizeOf(wfi.prolog_size);
|
||||
size += SimpleSerializer<uint32_t>::SizeOf(wfi.epilog_size);
|
||||
size += SimpleSerializer<uint32_t>::SizeOf(wfi.parameter_size);
|
||||
size += SimpleSerializer<uint32_t>::SizeOf(wfi.saved_register_size);
|
||||
size += SimpleSerializer<uint32_t>::SizeOf(wfi.local_size);
|
||||
size += SimpleSerializer<uint32_t>::SizeOf(wfi.max_stack_size);
|
||||
size += SimpleSerializer<bool>::SizeOf(wfi.allocates_base_pointer);
|
||||
size += SimpleSerializer<string>::SizeOf(wfi.program_string);
|
||||
return size;
|
||||
@@ -148,12 +148,12 @@ class SimpleSerializer<WindowsFrameInfo> {
|
||||
dest = SimpleSerializer<int32_t>::Write(
|
||||
static_cast<const int32_t>(wfi.type_), dest);
|
||||
dest = SimpleSerializer<int32_t>::Write(wfi.valid, dest);
|
||||
dest = SimpleSerializer<u_int32_t>::Write(wfi.prolog_size, dest);
|
||||
dest = SimpleSerializer<u_int32_t>::Write(wfi.epilog_size, dest);
|
||||
dest = SimpleSerializer<u_int32_t>::Write(wfi.parameter_size, dest);
|
||||
dest = SimpleSerializer<u_int32_t>::Write(wfi.saved_register_size, dest);
|
||||
dest = SimpleSerializer<u_int32_t>::Write(wfi.local_size, dest);
|
||||
dest = SimpleSerializer<u_int32_t>::Write(wfi.max_stack_size, dest);
|
||||
dest = SimpleSerializer<uint32_t>::Write(wfi.prolog_size, dest);
|
||||
dest = SimpleSerializer<uint32_t>::Write(wfi.epilog_size, dest);
|
||||
dest = SimpleSerializer<uint32_t>::Write(wfi.parameter_size, dest);
|
||||
dest = SimpleSerializer<uint32_t>::Write(wfi.saved_register_size, dest);
|
||||
dest = SimpleSerializer<uint32_t>::Write(wfi.local_size, dest);
|
||||
dest = SimpleSerializer<uint32_t>::Write(wfi.max_stack_size, dest);
|
||||
dest = SimpleSerializer<bool>::Write(wfi.allocates_base_pointer, dest);
|
||||
return SimpleSerializer<string>::Write(wfi.program_string, dest);
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@
|
||||
#ifndef PROCESSOR_SIMPLE_SERIALIZER_H__
|
||||
#define PROCESSOR_SIMPLE_SERIALIZER_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "google_breakpad/common/breakpad_types.h"
|
||||
|
||||
namespace google_breakpad {
|
||||
|
||||
typedef u_int64_t MemAddr;
|
||||
typedef uint64_t MemAddr;
|
||||
|
||||
// Default implementation of SimpleSerializer template.
|
||||
// Specializations are defined in "simple_serializer-inl.h".
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
namespace google_breakpad {
|
||||
|
||||
const int Stackwalker::kRASearchWords = 30;
|
||||
u_int32_t Stackwalker::max_frames_ = 1024;
|
||||
uint32_t Stackwalker::max_frames_ = 1024;
|
||||
|
||||
Stackwalker::Stackwalker(const SystemInfo* system_info,
|
||||
MemoryRegion* memory,
|
||||
@@ -125,7 +125,7 @@ Stackwalker* Stackwalker::StackwalkerForCPU(
|
||||
|
||||
Stackwalker* cpu_stackwalker = NULL;
|
||||
|
||||
u_int32_t cpu = context->GetContextCPU();
|
||||
uint32_t cpu = context->GetContextCPU();
|
||||
switch (cpu) {
|
||||
case MD_CONTEXT_X86:
|
||||
cpu_stackwalker = new StackwalkerX86(system_info,
|
||||
@@ -168,7 +168,7 @@ Stackwalker* Stackwalker::StackwalkerForCPU(
|
||||
return cpu_stackwalker;
|
||||
}
|
||||
|
||||
bool Stackwalker::InstructionAddressSeemsValid(u_int64_t address) {
|
||||
bool Stackwalker::InstructionAddressSeemsValid(uint64_t address) {
|
||||
StackFrame frame;
|
||||
frame.instruction = address;
|
||||
StackFrameSymbolizer::SymbolizerResult symbolizer_result =
|
||||
|
||||
@@ -101,7 +101,7 @@ StackwalkerAMD64::StackwalkerAMD64(const SystemInfo* system_info,
|
||||
(sizeof(cfi_register_map_) / sizeof(cfi_register_map_[0]))) {
|
||||
}
|
||||
|
||||
u_int64_t StackFrameAMD64::ReturnAddress() const
|
||||
uint64_t StackFrameAMD64::ReturnAddress() const
|
||||
{
|
||||
assert(context_validity & StackFrameAMD64::CONTEXT_VALID_RIP);
|
||||
return context.rip;
|
||||
@@ -150,8 +150,8 @@ StackFrameAMD64* StackwalkerAMD64::GetCallerByCFIFrameInfo(
|
||||
StackFrameAMD64* StackwalkerAMD64::GetCallerByStackScan(
|
||||
const vector<StackFrame*> &frames) {
|
||||
StackFrameAMD64* last_frame = static_cast<StackFrameAMD64*>(frames.back());
|
||||
u_int64_t last_rsp = last_frame->context.rsp;
|
||||
u_int64_t caller_rip_address, caller_rip;
|
||||
uint64_t last_rsp = last_frame->context.rsp;
|
||||
uint64_t caller_rip_address, caller_rip;
|
||||
|
||||
if (!ScanForReturnAddress(last_rsp, &caller_rip_address, &caller_rip)) {
|
||||
// No plausible return address was found.
|
||||
@@ -179,7 +179,7 @@ StackFrameAMD64* StackwalkerAMD64::GetCallerByStackScan(
|
||||
// pointing to the first word below the alleged return address, presume
|
||||
// that the caller's %rbp is saved there.
|
||||
if (caller_rip_address - 8 == last_frame->context.rbp) {
|
||||
u_int64_t caller_rbp = 0;
|
||||
uint64_t caller_rbp = 0;
|
||||
if (memory_->GetMemoryAtAddress(last_frame->context.rbp, &caller_rbp) &&
|
||||
caller_rbp > caller_rip_address) {
|
||||
frame->context.rbp = caller_rbp;
|
||||
|
||||
@@ -64,7 +64,7 @@ class StackwalkerAMD64 : public Stackwalker {
|
||||
|
||||
private:
|
||||
// A STACK CFI-driven frame walker for the AMD64
|
||||
typedef SimpleCFIWalker<u_int64_t, MDRawContextAMD64> CFIWalker;
|
||||
typedef SimpleCFIWalker<uint64_t, MDRawContextAMD64> CFIWalker;
|
||||
|
||||
// Implementation of Stackwalker, using amd64 context (stack pointer in %rsp,
|
||||
// stack base in %rbp) and stack conventions (saved stack pointer at 0(%rbp))
|
||||
|
||||
@@ -109,9 +109,9 @@ class StackwalkerAMD64Fixture {
|
||||
|
||||
// Fill RAW_CONTEXT with pseudo-random data, for round-trip checking.
|
||||
void BrandContext(MDRawContextAMD64 *raw_context) {
|
||||
u_int8_t x = 173;
|
||||
uint8_t x = 173;
|
||||
for (size_t i = 0; i < sizeof(*raw_context); i++)
|
||||
reinterpret_cast<u_int8_t *>(raw_context)[i] = (x += 17);
|
||||
reinterpret_cast<uint8_t *>(raw_context)[i] = (x += 17);
|
||||
}
|
||||
|
||||
SystemInfo system_info;
|
||||
@@ -199,8 +199,8 @@ TEST_F(GetCallerFrame, ScanWithoutSymbols) {
|
||||
// Force scanning through three frames to ensure that the
|
||||
// stack pointer is set properly in scan-recovered frames.
|
||||
stack_section.start() = 0x8000000080000000ULL;
|
||||
u_int64_t return_address1 = 0x50000000b0000100ULL;
|
||||
u_int64_t return_address2 = 0x50000000b0000900ULL;
|
||||
uint64_t return_address1 = 0x50000000b0000100ULL;
|
||||
uint64_t return_address2 = 0x50000000b0000900ULL;
|
||||
Label frame1_sp, frame2_sp, frame1_rbp;
|
||||
stack_section
|
||||
// frame 0
|
||||
@@ -270,7 +270,7 @@ TEST_F(GetCallerFrame, ScanWithFunctionSymbols) {
|
||||
// it is only considered a valid return address if it
|
||||
// lies within a function's bounds.
|
||||
stack_section.start() = 0x8000000080000000ULL;
|
||||
u_int64_t return_address = 0x50000000b0000110ULL;
|
||||
uint64_t return_address = 0x50000000b0000110ULL;
|
||||
Label frame1_sp, frame1_rbp;
|
||||
|
||||
stack_section
|
||||
@@ -333,7 +333,7 @@ TEST_F(GetCallerFrame, CallerPushedRBP) {
|
||||
// %rbp directly below the return address, assume that it is indeed the
|
||||
// next frame's %rbp.
|
||||
stack_section.start() = 0x8000000080000000ULL;
|
||||
u_int64_t return_address = 0x50000000b0000110ULL;
|
||||
uint64_t return_address = 0x50000000b0000110ULL;
|
||||
Label frame0_rbp, frame1_sp, frame1_rbp;
|
||||
|
||||
stack_section
|
||||
|
||||
@@ -90,13 +90,13 @@ StackFrameARM* StackwalkerARM::GetCallerByCFIFrameInfo(
|
||||
};
|
||||
|
||||
// Populate a dictionary with the valid register values in last_frame.
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t> callee_registers;
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t> callee_registers;
|
||||
for (int i = 0; register_names[i]; i++)
|
||||
if (last_frame->context_validity & StackFrameARM::RegisterValidFlag(i))
|
||||
callee_registers[register_names[i]] = last_frame->context.iregs[i];
|
||||
|
||||
// Use the STACK CFI data to recover the caller's register values.
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t> caller_registers;
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t> caller_registers;
|
||||
if (!cfi_frame_info->FindCallerRegs(callee_registers, *memory_,
|
||||
&caller_registers))
|
||||
return NULL;
|
||||
@@ -104,7 +104,7 @@ StackFrameARM* StackwalkerARM::GetCallerByCFIFrameInfo(
|
||||
// Construct a new stack frame given the values the CFI recovered.
|
||||
scoped_ptr<StackFrameARM> frame(new StackFrameARM());
|
||||
for (int i = 0; register_names[i]; i++) {
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t>::iterator entry =
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t>::iterator entry =
|
||||
caller_registers.find(register_names[i]);
|
||||
if (entry != caller_registers.end()) {
|
||||
// We recovered the value of this register; fill the context with the
|
||||
@@ -123,7 +123,7 @@ StackFrameARM* StackwalkerARM::GetCallerByCFIFrameInfo(
|
||||
}
|
||||
// If the CFI doesn't recover the PC explicitly, then use .ra.
|
||||
if (!(frame->context_validity & StackFrameARM::CONTEXT_VALID_PC)) {
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t>::iterator entry =
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t>::iterator entry =
|
||||
caller_registers.find(".ra");
|
||||
if (entry != caller_registers.end()) {
|
||||
if (fp_register_ == -1) {
|
||||
@@ -142,7 +142,7 @@ StackFrameARM* StackwalkerARM::GetCallerByCFIFrameInfo(
|
||||
}
|
||||
// If the CFI doesn't recover the SP explicitly, then use .cfa.
|
||||
if (!(frame->context_validity & StackFrameARM::CONTEXT_VALID_SP)) {
|
||||
CFIFrameInfo::RegisterValueMap<u_int32_t>::iterator entry =
|
||||
CFIFrameInfo::RegisterValueMap<uint32_t>::iterator entry =
|
||||
caller_registers.find(".cfa");
|
||||
if (entry != caller_registers.end()) {
|
||||
frame->context_validity |= StackFrameARM::CONTEXT_VALID_SP;
|
||||
@@ -163,8 +163,8 @@ StackFrameARM* StackwalkerARM::GetCallerByCFIFrameInfo(
|
||||
StackFrameARM* StackwalkerARM::GetCallerByStackScan(
|
||||
const vector<StackFrame*> &frames) {
|
||||
StackFrameARM* last_frame = static_cast<StackFrameARM*>(frames.back());
|
||||
u_int32_t last_sp = last_frame->context.iregs[MD_CONTEXT_ARM_REG_SP];
|
||||
u_int32_t caller_sp, caller_pc;
|
||||
uint32_t last_sp = last_frame->context.iregs[MD_CONTEXT_ARM_REG_SP];
|
||||
uint32_t caller_sp, caller_pc;
|
||||
|
||||
// When searching for the caller of the context frame,
|
||||
// allow the scanner to look farther down the stack.
|
||||
@@ -206,23 +206,23 @@ StackFrameARM* StackwalkerARM::GetCallerByFramePointer(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_int32_t last_fp = last_frame->context.iregs[fp_register_];
|
||||
uint32_t last_fp = last_frame->context.iregs[fp_register_];
|
||||
|
||||
u_int32_t caller_fp = 0;
|
||||
uint32_t caller_fp = 0;
|
||||
if (last_fp && !memory_->GetMemoryAtAddress(last_fp, &caller_fp)) {
|
||||
BPLOG(ERROR) << "Unable to read caller_fp from last_fp: 0x"
|
||||
<< std::hex << last_fp;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_int32_t caller_lr = 0;
|
||||
uint32_t caller_lr = 0;
|
||||
if (last_fp && !memory_->GetMemoryAtAddress(last_fp + 4, &caller_lr)) {
|
||||
BPLOG(ERROR) << "Unable to read caller_lr from last_fp + 4: 0x"
|
||||
<< std::hex << (last_fp + 4);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_int32_t caller_sp = last_fp ? last_fp + 8 :
|
||||
uint32_t caller_sp = last_fp ? last_fp + 8 :
|
||||
last_frame->context.iregs[MD_CONTEXT_ARM_REG_SP];
|
||||
|
||||
// Create a new stack frame (ownership will be transferred to the caller)
|
||||
|
||||
@@ -111,9 +111,9 @@ class StackwalkerARMFixture {
|
||||
|
||||
// Fill RAW_CONTEXT with pseudo-random data, for round-trip checking.
|
||||
void BrandContext(MDRawContextARM *raw_context) {
|
||||
u_int8_t x = 173;
|
||||
uint8_t x = 173;
|
||||
for (size_t i = 0; i < sizeof(*raw_context); i++)
|
||||
reinterpret_cast<u_int8_t *>(raw_context)[i] = (x += 17);
|
||||
reinterpret_cast<uint8_t *>(raw_context)[i] = (x += 17);
|
||||
}
|
||||
|
||||
SystemInfo system_info;
|
||||
@@ -190,8 +190,8 @@ TEST_F(GetCallerFrame, ScanWithoutSymbols) {
|
||||
// Force scanning through three frames to ensure that the
|
||||
// stack pointer is set properly in scan-recovered frames.
|
||||
stack_section.start() = 0x80000000;
|
||||
u_int32_t return_address1 = 0x50000100;
|
||||
u_int32_t return_address2 = 0x50000900;
|
||||
uint32_t return_address1 = 0x50000100;
|
||||
uint32_t return_address2 = 0x50000900;
|
||||
Label frame1_sp, frame2_sp;
|
||||
stack_section
|
||||
// frame 0
|
||||
@@ -252,7 +252,7 @@ TEST_F(GetCallerFrame, ScanWithFunctionSymbols) {
|
||||
// it is only considered a valid return address if it
|
||||
// lies within a function's bounds.
|
||||
stack_section.start() = 0x80000000;
|
||||
u_int32_t return_address = 0x50000200;
|
||||
uint32_t return_address = 0x50000200;
|
||||
Label frame1_sp;
|
||||
|
||||
stack_section
|
||||
@@ -310,8 +310,8 @@ TEST_F(GetCallerFrame, ScanFirstFrame) {
|
||||
// If the stackwalker resorts to stack scanning, it will scan much
|
||||
// farther to find the caller of the context frame.
|
||||
stack_section.start() = 0x80000000;
|
||||
u_int32_t return_address1 = 0x50000100;
|
||||
u_int32_t return_address2 = 0x50000900;
|
||||
uint32_t return_address1 = 0x50000100;
|
||||
uint32_t return_address2 = 0x50000900;
|
||||
Label frame1_sp, frame2_sp;
|
||||
stack_section
|
||||
// frame 0
|
||||
@@ -674,8 +674,8 @@ class GetFramesByFramePointer: public StackwalkerARMFixtureIOS, public Test { };
|
||||
|
||||
TEST_F(GetFramesByFramePointer, OnlyFramePointer) {
|
||||
stack_section.start() = 0x80000000;
|
||||
u_int32_t return_address1 = 0x50000100;
|
||||
u_int32_t return_address2 = 0x50000900;
|
||||
uint32_t return_address1 = 0x50000100;
|
||||
uint32_t return_address2 = 0x50000900;
|
||||
Label frame1_sp, frame2_sp;
|
||||
Label frame1_fp, frame2_fp;
|
||||
stack_section
|
||||
@@ -764,8 +764,8 @@ TEST_F(GetFramesByFramePointer, FramePointerAndCFI) {
|
||||
);
|
||||
|
||||
stack_section.start() = 0x80000000;
|
||||
u_int32_t return_address1 = 0x40004010;
|
||||
u_int32_t return_address2 = 0x50000900;
|
||||
uint32_t return_address1 = 0x40004010;
|
||||
uint32_t return_address2 = 0x50000900;
|
||||
Label frame1_sp, frame2_sp;
|
||||
Label frame1_fp, frame2_fp;
|
||||
stack_section
|
||||
|
||||
@@ -102,7 +102,7 @@ StackFrame* StackwalkerPPC::GetCallerFrame(const CallStack* stack) {
|
||||
// A caller frame must reside higher in memory than its callee frames.
|
||||
// Anything else is an error, or an indication that we've reached the
|
||||
// end of the stack.
|
||||
u_int32_t stack_pointer;
|
||||
uint32_t stack_pointer;
|
||||
if (!memory_->GetMemoryAtAddress(last_frame->context.gpr[1],
|
||||
&stack_pointer) ||
|
||||
stack_pointer <= last_frame->context.gpr[1]) {
|
||||
@@ -114,7 +114,7 @@ StackFrame* StackwalkerPPC::GetCallerFrame(const CallStack* stack) {
|
||||
// documentation on this, but 0 or 1 would be bogus return addresses,
|
||||
// so check for them here and return false (end of stack) when they're
|
||||
// hit to avoid having a phantom frame.
|
||||
u_int32_t instruction;
|
||||
uint32_t instruction;
|
||||
if (!memory_->GetMemoryAtAddress(stack_pointer + 8, &instruction) ||
|
||||
instruction <= 1) {
|
||||
return NULL;
|
||||
|
||||
@@ -100,20 +100,20 @@ using google_breakpad::StackwalkerSPARC;
|
||||
// process' memory space by pointer.
|
||||
class SelfMemoryRegion : public MemoryRegion {
|
||||
public:
|
||||
virtual u_int64_t GetBase() { return 0; }
|
||||
virtual u_int32_t GetSize() { return 0xffffffff; }
|
||||
virtual uint64_t GetBase() { return 0; }
|
||||
virtual uint32_t GetSize() { return 0xffffffff; }
|
||||
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int8_t* value) {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint8_t* value) {
|
||||
return GetMemoryAtAddressInternal(address, value); }
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int16_t* value) {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint16_t* value) {
|
||||
return GetMemoryAtAddressInternal(address, value); }
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int32_t* value) {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint32_t* value) {
|
||||
return GetMemoryAtAddressInternal(address, value); }
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int64_t* value) {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint64_t* value) {
|
||||
return GetMemoryAtAddressInternal(address, value); }
|
||||
|
||||
private:
|
||||
template<typename T> bool GetMemoryAtAddressInternal(u_int64_t address,
|
||||
template<typename T> bool GetMemoryAtAddressInternal(uint64_t address,
|
||||
T* value) {
|
||||
// Without knowing what addresses are actually mapped, just assume that
|
||||
// everything low is not mapped. This helps the stackwalker catch the
|
||||
@@ -123,7 +123,7 @@ class SelfMemoryRegion : public MemoryRegion {
|
||||
if (address < 0x100)
|
||||
return false;
|
||||
|
||||
u_int8_t* memory = 0;
|
||||
uint8_t* memory = 0;
|
||||
*value = *reinterpret_cast<const T*>(&memory[address]);
|
||||
return true;
|
||||
}
|
||||
@@ -142,9 +142,9 @@ class SelfMemoryRegion : public MemoryRegion {
|
||||
// on the stack (provided frame pointers are not being omitted.) Because
|
||||
// this function depends on the compiler-generated preamble, inlining is
|
||||
// disabled.
|
||||
static u_int32_t GetEBP() __attribute__((noinline));
|
||||
static u_int32_t GetEBP() {
|
||||
u_int32_t ebp;
|
||||
static uint32_t GetEBP() __attribute__((noinline));
|
||||
static uint32_t GetEBP() {
|
||||
uint32_t ebp;
|
||||
__asm__ __volatile__(
|
||||
"movl (%%ebp), %0"
|
||||
: "=a" (ebp)
|
||||
@@ -158,9 +158,9 @@ static u_int32_t GetEBP() {
|
||||
// The CALL instruction places a 4-byte return address on the stack above
|
||||
// the caller's %esp, and this function's prolog will save the caller's %ebp
|
||||
// on the stack as well, for another 4 bytes, before storing %esp in %ebp.
|
||||
static u_int32_t GetESP() __attribute__((noinline));
|
||||
static u_int32_t GetESP() {
|
||||
u_int32_t ebp;
|
||||
static uint32_t GetESP() __attribute__((noinline));
|
||||
static uint32_t GetESP() {
|
||||
uint32_t ebp;
|
||||
__asm__ __volatile__(
|
||||
"movl %%ebp, %0"
|
||||
: "=a" (ebp)
|
||||
@@ -179,9 +179,9 @@ static u_int32_t GetESP() {
|
||||
// because GetEBP and stackwalking necessarily depends on access to frame
|
||||
// pointers. Because this function depends on a call instruction and the
|
||||
// compiler-generated preamble, inlining is disabled.
|
||||
static u_int32_t GetEIP() __attribute__((noinline));
|
||||
static u_int32_t GetEIP() {
|
||||
u_int32_t eip;
|
||||
static uint32_t GetEIP() __attribute__((noinline));
|
||||
static uint32_t GetEIP() {
|
||||
uint32_t eip;
|
||||
__asm__ __volatile__(
|
||||
"movl 4(%%ebp), %0"
|
||||
: "=a" (eip)
|
||||
@@ -199,9 +199,9 @@ static u_int32_t GetEIP() {
|
||||
// pointer. Dereference %r1 to obtain the caller's stack pointer, which the
|
||||
// compiler-generated prolog stored on the stack. Because this function
|
||||
// depends on the compiler-generated prolog, inlining is disabled.
|
||||
static u_int32_t GetSP() __attribute__((noinline));
|
||||
static u_int32_t GetSP() {
|
||||
u_int32_t sp;
|
||||
static uint32_t GetSP() __attribute__((noinline));
|
||||
static uint32_t GetSP() {
|
||||
uint32_t sp;
|
||||
__asm__ __volatile__(
|
||||
"lwz %0, 0(r1)"
|
||||
: "=r" (sp)
|
||||
@@ -215,9 +215,9 @@ static u_int32_t GetSP() {
|
||||
// link register, where it was placed by the branch instruction that called
|
||||
// GetPC. Because this function depends on the caller's use of a branch
|
||||
// instruction, inlining is disabled.
|
||||
static u_int32_t GetPC() __attribute__((noinline));
|
||||
static u_int32_t GetPC() {
|
||||
u_int32_t lr;
|
||||
static uint32_t GetPC() __attribute__((noinline));
|
||||
static uint32_t GetPC() {
|
||||
uint32_t lr;
|
||||
__asm__ __volatile__(
|
||||
"mflr %0"
|
||||
: "=r" (lr)
|
||||
@@ -236,9 +236,9 @@ static u_int32_t GetPC() {
|
||||
// pointer, which the compiler-generated prolog stored on the stack.
|
||||
// Because this function depends on the compiler-generated prolog, inlining
|
||||
// is disabled.
|
||||
static u_int32_t GetSP() __attribute__((noinline));
|
||||
static u_int32_t GetSP() {
|
||||
u_int32_t sp;
|
||||
static uint32_t GetSP() __attribute__((noinline));
|
||||
static uint32_t GetSP() {
|
||||
uint32_t sp;
|
||||
__asm__ __volatile__(
|
||||
"mov %%fp, %0"
|
||||
: "=r" (sp)
|
||||
@@ -253,9 +253,9 @@ static u_int32_t GetSP() {
|
||||
// on the stack (provided frame pointers are not being omitted.) Because
|
||||
// this function depends on the compiler-generated preamble, inlining is
|
||||
// disabled.
|
||||
static u_int32_t GetFP() __attribute__((noinline));
|
||||
static u_int32_t GetFP() {
|
||||
u_int32_t fp;
|
||||
static uint32_t GetFP() __attribute__((noinline));
|
||||
static uint32_t GetFP() {
|
||||
uint32_t fp;
|
||||
__asm__ __volatile__(
|
||||
"ld [%%fp+56], %0"
|
||||
: "=r" (fp)
|
||||
@@ -268,9 +268,9 @@ static u_int32_t GetFP() {
|
||||
// link register, where it was placed by the branch instruction that called
|
||||
// GetPC. Because this function depends on the caller's use of a branch
|
||||
// instruction, inlining is disabled.
|
||||
static u_int32_t GetPC() __attribute__((noinline));
|
||||
static u_int32_t GetPC() {
|
||||
u_int32_t pc;
|
||||
static uint32_t GetPC() __attribute__((noinline));
|
||||
static uint32_t GetPC() {
|
||||
uint32_t pc;
|
||||
__asm__ __volatile__(
|
||||
"mov %%i7, %0"
|
||||
: "=r" (pc)
|
||||
@@ -284,15 +284,15 @@ static u_int32_t GetPC() {
|
||||
|
||||
#if defined(__i386__)
|
||||
extern "C" {
|
||||
extern u_int32_t GetEIP();
|
||||
extern u_int32_t GetEBP();
|
||||
extern u_int32_t GetESP();
|
||||
extern uint32_t GetEIP();
|
||||
extern uint32_t GetEBP();
|
||||
extern uint32_t GetESP();
|
||||
}
|
||||
#elif defined(__sparc__)
|
||||
extern "C" {
|
||||
extern u_int32_t GetPC();
|
||||
extern u_int32_t GetFP();
|
||||
extern u_int32_t GetSP();
|
||||
extern uint32_t GetPC();
|
||||
extern uint32_t GetFP();
|
||||
extern uint32_t GetSP();
|
||||
}
|
||||
#endif // __i386__ || __sparc__
|
||||
|
||||
|
||||
@@ -93,18 +93,18 @@ StackFrame* StackwalkerSPARC::GetCallerFrame(const CallStack* stack) {
|
||||
// A caller frame must reside higher in memory than its callee frames.
|
||||
// Anything else is an error, or an indication that we've reached the
|
||||
// end of the stack.
|
||||
u_int64_t stack_pointer = last_frame->context.g_r[30];
|
||||
uint64_t stack_pointer = last_frame->context.g_r[30];
|
||||
if (stack_pointer <= last_frame->context.g_r[14]) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_int32_t instruction;
|
||||
uint32_t instruction;
|
||||
if (!memory_->GetMemoryAtAddress(stack_pointer + 60,
|
||||
&instruction) || instruction <= 1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u_int32_t stack_base;
|
||||
uint32_t stack_base;
|
||||
if (!memory_->GetMemoryAtAddress(stack_pointer + 56,
|
||||
&stack_base) || stack_base <= 1) {
|
||||
return NULL;
|
||||
|
||||
@@ -55,24 +55,24 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion {
|
||||
// Set this region's address and contents. If we have placed an
|
||||
// instance of this class in a test fixture class, individual tests
|
||||
// can use this to provide the region's contents.
|
||||
void Init(u_int64_t base_address, const string &contents) {
|
||||
void Init(uint64_t base_address, const string &contents) {
|
||||
base_address_ = base_address;
|
||||
contents_ = contents;
|
||||
}
|
||||
|
||||
u_int64_t GetBase() const { return base_address_; }
|
||||
u_int32_t GetSize() const { return contents_.size(); }
|
||||
uint64_t GetBase() const { return base_address_; }
|
||||
uint32_t GetSize() const { return contents_.size(); }
|
||||
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int8_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const {
|
||||
return GetMemoryLittleEndian(address, value);
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int16_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const {
|
||||
return GetMemoryLittleEndian(address, value);
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int32_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const {
|
||||
return GetMemoryLittleEndian(address, value);
|
||||
}
|
||||
bool GetMemoryAtAddress(u_int64_t address, u_int64_t *value) const {
|
||||
bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const {
|
||||
return GetMemoryLittleEndian(address, value);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion {
|
||||
// Fetch a little-endian value from ADDRESS in contents_ whose size
|
||||
// is BYTES, and store it in *VALUE. Return true on success.
|
||||
template<typename ValueType>
|
||||
bool GetMemoryLittleEndian(u_int64_t address, ValueType *value) const {
|
||||
bool GetMemoryLittleEndian(uint64_t address, ValueType *value) const {
|
||||
if (address < base_address_ ||
|
||||
address - base_address_ + sizeof(ValueType) > contents_.size())
|
||||
return false;
|
||||
@@ -93,18 +93,18 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
u_int64_t base_address_;
|
||||
uint64_t base_address_;
|
||||
string contents_;
|
||||
};
|
||||
|
||||
class MockCodeModule: public google_breakpad::CodeModule {
|
||||
public:
|
||||
MockCodeModule(u_int64_t base_address, u_int64_t size,
|
||||
MockCodeModule(uint64_t base_address, uint64_t size,
|
||||
const string &code_file, const string &version)
|
||||
: base_address_(base_address), size_(size), code_file_(code_file) { }
|
||||
|
||||
u_int64_t base_address() const { return base_address_; }
|
||||
u_int64_t size() const { return size_; }
|
||||
uint64_t base_address() const { return base_address_; }
|
||||
uint64_t size() const { return size_; }
|
||||
string code_file() const { return code_file_; }
|
||||
string code_identifier() const { return code_file_; }
|
||||
string debug_file() const { return code_file_; }
|
||||
@@ -115,8 +115,8 @@ class MockCodeModule: public google_breakpad::CodeModule {
|
||||
}
|
||||
|
||||
private:
|
||||
u_int64_t base_address_;
|
||||
u_int64_t size_;
|
||||
uint64_t base_address_;
|
||||
uint64_t size_;
|
||||
string code_file_;
|
||||
string version_;
|
||||
};
|
||||
@@ -132,7 +132,7 @@ class MockCodeModules: public google_breakpad::CodeModules {
|
||||
|
||||
unsigned int module_count() const { return modules_.size(); }
|
||||
|
||||
const CodeModule *GetModuleForAddress(u_int64_t address) const {
|
||||
const CodeModule *GetModuleForAddress(uint64_t address) const {
|
||||
for (ModuleVector::const_iterator i = modules_.begin();
|
||||
i != modules_.end(); i++) {
|
||||
const MockCodeModule *module = *i;
|
||||
|
||||
@@ -106,7 +106,7 @@ StackFrameX86::~StackFrameX86() {
|
||||
cfi_frame_info = NULL;
|
||||
}
|
||||
|
||||
u_int64_t StackFrameX86::ReturnAddress() const
|
||||
uint64_t StackFrameX86::ReturnAddress() const
|
||||
{
|
||||
assert(context_validity & StackFrameX86::CONTEXT_VALID_EIP);
|
||||
return context.eip;
|
||||
@@ -179,7 +179,7 @@ StackFrameX86* StackwalkerX86::GetCallerByWindowsFrameInfo(
|
||||
// are unknown, 0 is also used in that case. When that happens, it should
|
||||
// be possible to walk to the next frame without reference to %esp.
|
||||
|
||||
u_int32_t last_frame_callee_parameter_size = 0;
|
||||
uint32_t last_frame_callee_parameter_size = 0;
|
||||
int frames_already_walked = frames.size();
|
||||
if (frames_already_walked >= 2) {
|
||||
const StackFrameX86* last_frame_callee
|
||||
@@ -197,7 +197,7 @@ StackFrameX86* StackwalkerX86::GetCallerByWindowsFrameInfo(
|
||||
// Set up the dictionary for the PostfixEvaluator. %ebp and %esp are used
|
||||
// in each program string, and their previous values are known, so set them
|
||||
// here.
|
||||
PostfixEvaluator<u_int32_t>::DictionaryType dictionary;
|
||||
PostfixEvaluator<uint32_t>::DictionaryType dictionary;
|
||||
// Provide the current register values.
|
||||
dictionary["$ebp"] = last_frame->context.ebp;
|
||||
dictionary["$esp"] = last_frame->context.esp;
|
||||
@@ -210,13 +210,13 @@ StackFrameX86* StackwalkerX86::GetCallerByWindowsFrameInfo(
|
||||
dictionary[".cbSavedRegs"] = last_frame_info->saved_register_size;
|
||||
dictionary[".cbLocals"] = last_frame_info->local_size;
|
||||
|
||||
u_int32_t raSearchStart = last_frame->context.esp +
|
||||
uint32_t raSearchStart = last_frame->context.esp +
|
||||
last_frame_callee_parameter_size +
|
||||
last_frame_info->local_size +
|
||||
last_frame_info->saved_register_size;
|
||||
|
||||
u_int32_t raSearchStartOld = raSearchStart;
|
||||
u_int32_t found = 0; // dummy value
|
||||
uint32_t raSearchStartOld = raSearchStart;
|
||||
uint32_t found = 0; // dummy value
|
||||
// Scan up to three words above the calculated search value, in case
|
||||
// the stack was aligned to a quadword boundary.
|
||||
if (ScanForReturnAddress(raSearchStart, &raSearchStart, &found, 3) &&
|
||||
@@ -326,9 +326,9 @@ StackFrameX86* StackwalkerX86::GetCallerByWindowsFrameInfo(
|
||||
|
||||
// Now crank it out, making sure that the program string set at least the
|
||||
// two required variables.
|
||||
PostfixEvaluator<u_int32_t> evaluator =
|
||||
PostfixEvaluator<u_int32_t>(&dictionary, memory_);
|
||||
PostfixEvaluator<u_int32_t>::DictionaryValidityType dictionary_validity;
|
||||
PostfixEvaluator<uint32_t> evaluator =
|
||||
PostfixEvaluator<uint32_t>(&dictionary, memory_);
|
||||
PostfixEvaluator<uint32_t>::DictionaryValidityType dictionary_validity;
|
||||
if (!evaluator.Evaluate(program_string, &dictionary_validity) ||
|
||||
dictionary_validity.find("$eip") == dictionary_validity.end() ||
|
||||
dictionary_validity.find("$esp") == dictionary_validity.end()) {
|
||||
@@ -338,8 +338,8 @@ StackFrameX86* StackwalkerX86::GetCallerByWindowsFrameInfo(
|
||||
// address. This can happen if the stack is in a module for which
|
||||
// we don't have symbols, and that module is compiled without a
|
||||
// frame pointer.
|
||||
u_int32_t location_start = last_frame->context.esp;
|
||||
u_int32_t location, eip;
|
||||
uint32_t location_start = last_frame->context.esp;
|
||||
uint32_t location, eip;
|
||||
if (!ScanForReturnAddress(location_start, &location, &eip)) {
|
||||
// if we can't find an instruction pointer even with stack scanning,
|
||||
// give up.
|
||||
@@ -376,12 +376,12 @@ StackFrameX86* StackwalkerX86::GetCallerByWindowsFrameInfo(
|
||||
// ability, older OSes (pre-XP SP2) and CPUs (pre-P4) don't enforce
|
||||
// an independent execute privilege on memory pages.
|
||||
|
||||
u_int32_t eip = dictionary["$eip"];
|
||||
uint32_t eip = dictionary["$eip"];
|
||||
if (modules_ && !modules_->GetModuleForAddress(eip)) {
|
||||
// The instruction pointer at .raSearchStart was invalid, so start
|
||||
// looking one 32-bit word above that location.
|
||||
u_int32_t location_start = dictionary[".raSearchStart"] + 4;
|
||||
u_int32_t location;
|
||||
uint32_t location_start = dictionary[".raSearchStart"] + 4;
|
||||
uint32_t location;
|
||||
if (ScanForReturnAddress(location_start, &location, &eip)) {
|
||||
// This is a better return address that what program string
|
||||
// evaluation found. Use it, and set %esp to the location above the
|
||||
@@ -401,7 +401,7 @@ StackFrameX86* StackwalkerX86::GetCallerByWindowsFrameInfo(
|
||||
// stack. The scan is performed from the highest possible address to
|
||||
// the lowest, because the expectation is that the function's prolog
|
||||
// would have saved %ebp early.
|
||||
u_int32_t ebp = dictionary["$ebp"];
|
||||
uint32_t ebp = dictionary["$ebp"];
|
||||
|
||||
// When a scan for return address is used, it is possible to skip one or
|
||||
// more frames (when return address is not in a known module). One
|
||||
@@ -410,13 +410,13 @@ StackFrameX86* StackwalkerX86::GetCallerByWindowsFrameInfo(
|
||||
bool has_skipped_frames =
|
||||
(trust != StackFrame::FRAME_TRUST_CFI && ebp <= raSearchStart + offset);
|
||||
|
||||
u_int32_t value; // throwaway variable to check pointer validity
|
||||
uint32_t value; // throwaway variable to check pointer validity
|
||||
if (has_skipped_frames || !memory_->GetMemoryAtAddress(ebp, &value)) {
|
||||
int fp_search_bytes = last_frame_info->saved_register_size + offset;
|
||||
u_int32_t location_end = last_frame->context.esp +
|
||||
uint32_t location_end = last_frame->context.esp +
|
||||
last_frame_callee_parameter_size;
|
||||
|
||||
for (u_int32_t location = location_end + fp_search_bytes;
|
||||
for (uint32_t location = location_end + fp_search_bytes;
|
||||
location >= location_end;
|
||||
location -= 4) {
|
||||
if (!memory_->GetMemoryAtAddress(location, &ebp))
|
||||
@@ -493,8 +493,8 @@ StackFrameX86* StackwalkerX86::GetCallerByEBPAtBase(
|
||||
const vector<StackFrame*> &frames) {
|
||||
StackFrame::FrameTrust trust;
|
||||
StackFrameX86* last_frame = static_cast<StackFrameX86*>(frames.back());
|
||||
u_int32_t last_esp = last_frame->context.esp;
|
||||
u_int32_t last_ebp = last_frame->context.ebp;
|
||||
uint32_t last_esp = last_frame->context.esp;
|
||||
uint32_t last_ebp = last_frame->context.ebp;
|
||||
|
||||
// Assume that the standard %ebp-using x86 calling convention is in
|
||||
// use.
|
||||
@@ -519,7 +519,7 @@ StackFrameX86* StackwalkerX86::GetCallerByEBPAtBase(
|
||||
// %esp_new = %ebp_old + 8
|
||||
// %ebp_new = *(%ebp_old)
|
||||
|
||||
u_int32_t caller_eip, caller_esp, caller_ebp;
|
||||
uint32_t caller_eip, caller_esp, caller_ebp;
|
||||
|
||||
if (memory_->GetMemoryAtAddress(last_ebp + 4, &caller_eip) &&
|
||||
memory_->GetMemoryAtAddress(last_ebp, &caller_ebp)) {
|
||||
|
||||
@@ -67,7 +67,7 @@ class StackwalkerX86 : public Stackwalker {
|
||||
|
||||
private:
|
||||
// A STACK CFI-driven frame walker for the X86.
|
||||
typedef SimpleCFIWalker<u_int32_t, MDRawContextX86> CFIWalker;
|
||||
typedef SimpleCFIWalker<uint32_t, MDRawContextX86> CFIWalker;
|
||||
|
||||
// Implementation of Stackwalker, using x86 context (%ebp, %esp, %eip) and
|
||||
// stack conventions (saved %ebp at [%ebp], saved %eip at 4[%ebp], or
|
||||
|
||||
@@ -118,9 +118,9 @@ class StackwalkerX86Fixture {
|
||||
|
||||
// Fill RAW_CONTEXT with pseudo-random data, for round-trip checking.
|
||||
void BrandContext(MDRawContextX86 *raw_context) {
|
||||
u_int8_t x = 173;
|
||||
uint8_t x = 173;
|
||||
for (size_t i = 0; i < sizeof(*raw_context); i++)
|
||||
reinterpret_cast<u_int8_t *>(raw_context)[i] = (x += 17);
|
||||
reinterpret_cast<uint8_t *>(raw_context)[i] = (x += 17);
|
||||
}
|
||||
|
||||
SystemInfo system_info;
|
||||
|
||||
@@ -46,7 +46,7 @@ template<typename AddressType, typename EntryType>
|
||||
StaticContainedRangeMap<AddressType, EntryType>::StaticContainedRangeMap(
|
||||
const char *base)
|
||||
: base_(*(reinterpret_cast<const AddressType*>(base))),
|
||||
entry_size_(*(reinterpret_cast<const u_int32_t*>(base + sizeof(base_)))),
|
||||
entry_size_(*(reinterpret_cast<const uint32_t*>(base + sizeof(base_)))),
|
||||
entry_ptr_(reinterpret_cast<const EntryType *>(
|
||||
base + sizeof(base_) + sizeof(entry_size_))),
|
||||
map_(base + sizeof(base_) + sizeof(entry_size_) + entry_size_) {
|
||||
|
||||
@@ -81,7 +81,7 @@ class StaticContainedRangeMap {
|
||||
// actually contain an entry, so its entry_ field is meaningless. For
|
||||
// this reason, the entry_ field should only be accessed on child
|
||||
// ContainedRangeMap objects, and never on |this|.
|
||||
u_int32_t entry_size_;
|
||||
uint32_t entry_size_;
|
||||
const EntryType *entry_ptr_;
|
||||
|
||||
// The map containing child ranges, keyed by each child range's high
|
||||
|
||||
@@ -47,13 +47,13 @@ StaticMap<Key, Value, Compare>::StaticMap(const char* raw_data)
|
||||
: raw_data_(raw_data),
|
||||
compare_() {
|
||||
// First 4 Bytes store the number of nodes.
|
||||
num_nodes_ = *(reinterpret_cast<const u_int32_t*>(raw_data_));
|
||||
num_nodes_ = *(reinterpret_cast<const uint32_t*>(raw_data_));
|
||||
|
||||
offsets_ = reinterpret_cast<const u_int32_t*>(
|
||||
offsets_ = reinterpret_cast<const uint32_t*>(
|
||||
raw_data_ + sizeof(num_nodes_));
|
||||
|
||||
keys_ = reinterpret_cast<const Key*>(
|
||||
raw_data_ + (1 + num_nodes_) * sizeof(u_int32_t));
|
||||
raw_data_ + (1 + num_nodes_) * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
// find(), lower_bound() and upper_bound() implement binary search algorithm.
|
||||
@@ -132,14 +132,14 @@ bool StaticMap<Key, Value, Compare>::ValidateInMemoryStructure() const {
|
||||
|
||||
int node_index = 0;
|
||||
if (num_nodes_) {
|
||||
u_int64_t first_offset = sizeof(int32_t) * (num_nodes_ + 1)
|
||||
uint64_t first_offset = sizeof(int32_t) * (num_nodes_ + 1)
|
||||
+ sizeof(Key) * num_nodes_;
|
||||
// Num_nodes_ is too large.
|
||||
if (first_offset > 0xffffffffUL) {
|
||||
BPLOG(INFO) << "StaticMap check failed: size exceeds limit";
|
||||
return false;
|
||||
}
|
||||
if (offsets_[node_index] != static_cast<u_int32_t>(first_offset)) {
|
||||
if (offsets_[node_index] != static_cast<uint32_t>(first_offset)) {
|
||||
BPLOG(INFO) << "StaticMap check failed: first node offset is incorrect";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class StaticMap {
|
||||
// Array of offset addresses for stored values.
|
||||
// For example:
|
||||
// address_of_i-th_node_value = raw_data_ + offsets_[i]
|
||||
const u_int32_t* offsets_;
|
||||
const uint32_t* offsets_;
|
||||
|
||||
// keys_[i] = key of i_th node
|
||||
const Key* keys_;
|
||||
|
||||
@@ -48,7 +48,7 @@ StaticMapIterator<Key, Value, Compare>::StaticMapIterator(const char* base,
|
||||
// See static_map.h for documentation on
|
||||
// bytes format of serialized StaticMap data.
|
||||
num_nodes_ = *(reinterpret_cast<const int32_t*>(base_));
|
||||
offsets_ = reinterpret_cast<const u_int32_t*>(base_ + sizeof(num_nodes_));
|
||||
offsets_ = reinterpret_cast<const uint32_t*>(base_ + sizeof(num_nodes_));
|
||||
keys_ = reinterpret_cast<const Key*>(
|
||||
base_ + (1 + num_nodes_) * sizeof(num_nodes_));
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#ifndef PROCESSOR_STATIC_MAP_ITERATOR_H__
|
||||
#define PROCESSOR_STATIC_MAP_ITERATOR_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "google_breakpad/common/breakpad_types.h"
|
||||
|
||||
namespace google_breakpad {
|
||||
|
||||
@@ -101,7 +101,7 @@ class StaticMapIterator {
|
||||
// offsets_ is an array of offset addresses of mapped values.
|
||||
// For example:
|
||||
// address_of_i-th_node_value = base_ + offsets_[i]
|
||||
const u_int32_t* offsets_;
|
||||
const uint32_t* offsets_;
|
||||
|
||||
// keys_[i] = key of i_th node.
|
||||
const Key* keys_;
|
||||
|
||||
@@ -49,7 +49,7 @@ class SimpleMapSerializer {
|
||||
static char* Serialize(const std::map<Key, Value> &stdmap,
|
||||
unsigned int* size = NULL) {
|
||||
unsigned int size_per_node =
|
||||
sizeof(u_int32_t) + sizeof(Key) + sizeof(Value);
|
||||
sizeof(uint32_t) + sizeof(Key) + sizeof(Value);
|
||||
unsigned int memsize = sizeof(int32_t) + size_per_node * stdmap.size();
|
||||
if (size) *size = memsize;
|
||||
|
||||
@@ -58,12 +58,12 @@ class SimpleMapSerializer {
|
||||
char* address = mem;
|
||||
|
||||
// Writer the number of nodes:
|
||||
new (address) u_int32_t(static_cast<u_int32_t>(stdmap.size()));
|
||||
address += sizeof(u_int32_t);
|
||||
new (address) uint32_t(static_cast<uint32_t>(stdmap.size()));
|
||||
address += sizeof(uint32_t);
|
||||
|
||||
// Nodes' offset:
|
||||
u_int32_t* offsets = reinterpret_cast<u_int32_t*>(address);
|
||||
address += sizeof(u_int32_t) * stdmap.size();
|
||||
uint32_t* offsets = reinterpret_cast<uint32_t*>(address);
|
||||
address += sizeof(uint32_t) * stdmap.size();
|
||||
|
||||
// Keys:
|
||||
Key* keys = reinterpret_cast<Key*>(address);
|
||||
@@ -95,16 +95,16 @@ class TestInvalidMap : public ::testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(TestInvalidMap, TestNegativeNumberNodes) {
|
||||
memset(data, 0xff, sizeof(u_int32_t)); // Set the number of nodes = -1
|
||||
memset(data, 0xff, sizeof(uint32_t)); // Set the number of nodes = -1
|
||||
test_map = TestMap(data);
|
||||
ASSERT_FALSE(test_map.ValidateInMemoryStructure());
|
||||
}
|
||||
|
||||
TEST_F(TestInvalidMap, TestWrongOffsets) {
|
||||
u_int32_t* header = reinterpret_cast<u_int32_t*>(data);
|
||||
const u_int32_t kNumNodes = 2;
|
||||
const u_int32_t kHeaderOffset =
|
||||
sizeof(u_int32_t) + kNumNodes * (sizeof(u_int32_t) + sizeof(KeyType));
|
||||
uint32_t* header = reinterpret_cast<uint32_t*>(data);
|
||||
const uint32_t kNumNodes = 2;
|
||||
const uint32_t kHeaderOffset =
|
||||
sizeof(uint32_t) + kNumNodes * (sizeof(uint32_t) + sizeof(KeyType));
|
||||
|
||||
header[0] = kNumNodes;
|
||||
header[1] = kHeaderOffset + 3; // Wrong offset for first node
|
||||
@@ -118,16 +118,16 @@ TEST_F(TestInvalidMap, TestWrongOffsets) {
|
||||
}
|
||||
|
||||
TEST_F(TestInvalidMap, TestUnSortedKeys) {
|
||||
u_int32_t* header = reinterpret_cast<u_int32_t*>(data);
|
||||
const u_int32_t kNumNodes = 2;
|
||||
const u_int32_t kHeaderOffset =
|
||||
sizeof(u_int32_t) + kNumNodes * (sizeof(u_int32_t) + sizeof(KeyType));
|
||||
uint32_t* header = reinterpret_cast<uint32_t*>(data);
|
||||
const uint32_t kNumNodes = 2;
|
||||
const uint32_t kHeaderOffset =
|
||||
sizeof(uint32_t) + kNumNodes * (sizeof(uint32_t) + sizeof(KeyType));
|
||||
header[0] = kNumNodes;
|
||||
header[1] = kHeaderOffset;
|
||||
header[2] = kHeaderOffset + sizeof(ValueType);
|
||||
|
||||
KeyType* keys = reinterpret_cast<KeyType*>(
|
||||
data + (kNumNodes + 1) * sizeof(u_int32_t));
|
||||
data + (kNumNodes + 1) * sizeof(uint32_t));
|
||||
// Set keys in non-increasing order.
|
||||
keys[0] = 10;
|
||||
keys[1] = 7;
|
||||
@@ -171,10 +171,10 @@ class TestValidMap : public ::testing::Test {
|
||||
|
||||
// Set correct size of memory allocation for each test case.
|
||||
unsigned int size_per_node =
|
||||
sizeof(u_int32_t) + sizeof(KeyType) + sizeof(ValueType);
|
||||
sizeof(uint32_t) + sizeof(KeyType) + sizeof(ValueType);
|
||||
for (testcase = 0; testcase < kNumberTestCases; ++testcase) {
|
||||
correct_size[testcase] =
|
||||
sizeof(u_int32_t) + std_map[testcase].size() * size_per_node;
|
||||
sizeof(uint32_t) + std_map[testcase].size() * size_per_node;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -193,9 +193,9 @@ Context::Context(const Dump &dump, const MDRawContextARM &context)
|
||||
}
|
||||
|
||||
Thread::Thread(const Dump &dump,
|
||||
u_int32_t thread_id, const Memory &stack, const Context &context,
|
||||
u_int32_t suspend_count, u_int32_t priority_class,
|
||||
u_int32_t priority, u_int64_t teb) : Section(dump) {
|
||||
uint32_t thread_id, const Memory &stack, const Context &context,
|
||||
uint32_t suspend_count, uint32_t priority_class,
|
||||
uint32_t priority, uint64_t teb) : Section(dump) {
|
||||
D32(thread_id);
|
||||
D32(suspend_count);
|
||||
D32(priority_class);
|
||||
@@ -207,11 +207,11 @@ Thread::Thread(const Dump &dump,
|
||||
}
|
||||
|
||||
Module::Module(const Dump &dump,
|
||||
u_int64_t base_of_image,
|
||||
u_int32_t size_of_image,
|
||||
uint64_t base_of_image,
|
||||
uint32_t size_of_image,
|
||||
const String &name,
|
||||
u_int32_t time_date_stamp,
|
||||
u_int32_t checksum,
|
||||
uint32_t time_date_stamp,
|
||||
uint32_t checksum,
|
||||
const MDVSFixedFileInfo &version_info,
|
||||
const Section *cv_record,
|
||||
const Section *misc_record) : Section(dump) {
|
||||
@@ -257,10 +257,10 @@ const MDVSFixedFileInfo Module::stock_version_info = {
|
||||
|
||||
Exception::Exception(const Dump &dump,
|
||||
const Context &context,
|
||||
u_int32_t thread_id,
|
||||
u_int32_t exception_code,
|
||||
u_int32_t exception_flags,
|
||||
u_int64_t exception_address)
|
||||
uint32_t thread_id,
|
||||
uint32_t exception_code,
|
||||
uint32_t exception_flags,
|
||||
uint64_t exception_address)
|
||||
: Stream(dump, MD_EXCEPTION_STREAM) {
|
||||
D32(thread_id);
|
||||
D32(0); // __align
|
||||
@@ -276,10 +276,10 @@ Exception::Exception(const Dump &dump,
|
||||
assert(Size() == sizeof(MDRawExceptionStream));
|
||||
}
|
||||
|
||||
Dump::Dump(u_int64_t flags,
|
||||
Dump::Dump(uint64_t flags,
|
||||
Endianness endianness,
|
||||
u_int32_t version,
|
||||
u_int32_t date_time_stamp)
|
||||
uint32_t version,
|
||||
uint32_t date_time_stamp)
|
||||
: test_assembler::Section(endianness),
|
||||
file_start_(0),
|
||||
stream_directory_(*this),
|
||||
|
||||
@@ -166,14 +166,14 @@ class Stream: public Section {
|
||||
public:
|
||||
// Create a stream of type TYPE. You can append whatever contents
|
||||
// you like to this stream using the test_assembler::Section methods.
|
||||
Stream(const Dump &dump, u_int32_t type) : Section(dump), type_(type) { }
|
||||
Stream(const Dump &dump, uint32_t type) : Section(dump), type_(type) { }
|
||||
|
||||
// Append an MDRawDirectory referring to this stream to SECTION.
|
||||
void CiteStreamIn(test_assembler::Section *section) const;
|
||||
|
||||
private:
|
||||
// The type of this stream.
|
||||
u_int32_t type_;
|
||||
uint32_t type_;
|
||||
};
|
||||
|
||||
class SystemInfo: public Stream {
|
||||
@@ -211,7 +211,7 @@ class String: public Section {
|
||||
// to memory addresses.
|
||||
class Memory: public Section {
|
||||
public:
|
||||
Memory(const Dump &dump, u_int64_t address)
|
||||
Memory(const Dump &dump, uint64_t address)
|
||||
: Section(dump), address_(address) { start() = address; }
|
||||
|
||||
// Append an MDMemoryDescriptor referring to this memory range to SECTION.
|
||||
@@ -220,7 +220,7 @@ class Memory: public Section {
|
||||
private:
|
||||
// The process address from which these memory contents were taken.
|
||||
// Shouldn't this be a Label?
|
||||
u_int64_t address_;
|
||||
uint64_t address_;
|
||||
};
|
||||
|
||||
class Context: public Section {
|
||||
@@ -238,13 +238,13 @@ class Thread: public Section {
|
||||
// Create a thread belonging to DUMP with the given values, citing
|
||||
// STACK and CONTEXT (which you must Add to the dump separately).
|
||||
Thread(const Dump &dump,
|
||||
u_int32_t thread_id,
|
||||
uint32_t thread_id,
|
||||
const Memory &stack,
|
||||
const Context &context,
|
||||
u_int32_t suspend_count = 0,
|
||||
u_int32_t priority_class = 0,
|
||||
u_int32_t priority = 0,
|
||||
u_int64_t teb = 0);
|
||||
uint32_t suspend_count = 0,
|
||||
uint32_t priority_class = 0,
|
||||
uint32_t priority = 0,
|
||||
uint64_t teb = 0);
|
||||
};
|
||||
|
||||
class Module: public Section {
|
||||
@@ -253,11 +253,11 @@ class Module: public Section {
|
||||
// MISC_RECORD can be NULL, in which case the corresponding location
|
||||
// descriptior in the minidump will have a length of zero.
|
||||
Module(const Dump &dump,
|
||||
u_int64_t base_of_image,
|
||||
u_int32_t size_of_image,
|
||||
uint64_t base_of_image,
|
||||
uint32_t size_of_image,
|
||||
const String &name,
|
||||
u_int32_t time_date_stamp = 1262805309,
|
||||
u_int32_t checksum = 0,
|
||||
uint32_t time_date_stamp = 1262805309,
|
||||
uint32_t checksum = 0,
|
||||
const MDVSFixedFileInfo &version_info = Module::stock_version_info,
|
||||
const Section *cv_record = NULL,
|
||||
const Section *misc_record = NULL);
|
||||
@@ -273,10 +273,10 @@ class Exception : public Stream {
|
||||
public:
|
||||
Exception(const Dump &dump,
|
||||
const Context &context,
|
||||
u_int32_t thread_id = 0,
|
||||
u_int32_t exception_code = 0,
|
||||
u_int32_t exception_flags = 0,
|
||||
u_int64_t exception_address = 0);
|
||||
uint32_t thread_id = 0,
|
||||
uint32_t exception_code = 0,
|
||||
uint32_t exception_flags = 0,
|
||||
uint64_t exception_address = 0);
|
||||
};
|
||||
|
||||
// A list of entries starting with a 32-bit count, like a memory list
|
||||
@@ -284,7 +284,7 @@ public:
|
||||
template<typename Element>
|
||||
class List: public Stream {
|
||||
public:
|
||||
List(const Dump &dump, u_int32_t type) : Stream(dump, type), count_(0) {
|
||||
List(const Dump &dump, uint32_t type) : Stream(dump, type), count_(0) {
|
||||
D32(count_label_);
|
||||
}
|
||||
|
||||
@@ -317,10 +317,10 @@ class Dump: public test_assembler::Section {
|
||||
// header uses the given values. ENDIANNESS determines the
|
||||
// endianness of the signature; we set this section's default
|
||||
// endianness by this.
|
||||
Dump(u_int64_t flags,
|
||||
Dump(uint64_t flags,
|
||||
Endianness endianness = kLittleEndian,
|
||||
u_int32_t version = MD_HEADER_VERSION,
|
||||
u_int32_t date_time_stamp = 1262805309);
|
||||
uint32_t version = MD_HEADER_VERSION,
|
||||
uint32_t date_time_stamp = 1262805309);
|
||||
|
||||
// The following functions call OBJECT->Finish(), and append the
|
||||
// contents of OBJECT to this minidump. They also record OBJECT in
|
||||
|
||||
@@ -175,7 +175,7 @@ TEST(Thread, Simple) {
|
||||
0xeb2de4be3f29e3e9ULL); // thread environment block
|
||||
string contents;
|
||||
ASSERT_TRUE(thread.GetContents(&contents));
|
||||
static const u_int8_t expected_bytes[] = {
|
||||
static const uint8_t expected_bytes[] = {
|
||||
0x60, 0xc3, 0x7e, 0x3d, // thread id
|
||||
0x4d, 0xf4, 0x93, 0x35, // suspend count
|
||||
0x82, 0x2b, 0x35, 0xab, // priority class
|
||||
@@ -203,7 +203,7 @@ TEST(Exception, Simple) {
|
||||
0x0919a9b9c9d9e9f9ULL); // exception address
|
||||
string contents;
|
||||
ASSERT_TRUE(exception.GetContents(&contents));
|
||||
static const u_int8_t expected_bytes[] = {
|
||||
static const uint8_t expected_bytes[] = {
|
||||
0xcd, 0xab, 0x34, 0x12, // thread id
|
||||
0x00, 0x00, 0x00, 0x00, // __align
|
||||
0x21, 0x43, 0xba, 0xdc, // exception code
|
||||
|
||||
@@ -130,7 +130,7 @@ static const MDRawContextX86 x86_raw_context = {
|
||||
}
|
||||
};
|
||||
|
||||
static const u_int8_t x86_expected_contents[] = {
|
||||
static const uint8_t x86_expected_contents[] = {
|
||||
0x1b, 0xd7, 0xd5, 0xde,
|
||||
0x2e, 0x43, 0xdb, 0x9f,
|
||||
0x1a, 0xa8, 0xb7, 0x26,
|
||||
@@ -320,7 +320,7 @@ static const MDRawContextARM arm_raw_context = {
|
||||
}
|
||||
};
|
||||
|
||||
static const u_int8_t arm_expected_contents[] = {
|
||||
static const uint8_t arm_expected_contents[] = {
|
||||
0x6a, 0x9e, 0x1b, 0x59,
|
||||
0xde, 0x94, 0x15, 0xa2,
|
||||
0x25, 0x8a, 0x0d, 0x82,
|
||||
|
||||
@@ -85,12 +85,12 @@ struct WindowsFrameInfo {
|
||||
program_string() {}
|
||||
|
||||
WindowsFrameInfo(StackInfoTypes type,
|
||||
u_int32_t set_prolog_size,
|
||||
u_int32_t set_epilog_size,
|
||||
u_int32_t set_parameter_size,
|
||||
u_int32_t set_saved_register_size,
|
||||
u_int32_t set_local_size,
|
||||
u_int32_t set_max_stack_size,
|
||||
uint32_t set_prolog_size,
|
||||
uint32_t set_epilog_size,
|
||||
uint32_t set_parameter_size,
|
||||
uint32_t set_saved_register_size,
|
||||
uint32_t set_local_size,
|
||||
uint32_t set_max_stack_size,
|
||||
int set_allocates_base_pointer,
|
||||
const string set_program_string)
|
||||
: type_(type),
|
||||
@@ -110,9 +110,9 @@ struct WindowsFrameInfo {
|
||||
// but not the StackFrameInfo structure, so return them as outparams.
|
||||
static WindowsFrameInfo *ParseFromString(const string string,
|
||||
int &type,
|
||||
u_int64_t &rva,
|
||||
u_int64_t &code_size) {
|
||||
// The format of a STACK WIN record is documented at:
|
||||
uint64_t &rva,
|
||||
uint64_t &code_size) {
|
||||
// The format of a STACK WIN record is documented at:
|
||||
//
|
||||
// http://code.google.com/p/google-breakpad/wiki/SymbolFiles
|
||||
|
||||
@@ -128,12 +128,12 @@ struct WindowsFrameInfo {
|
||||
|
||||
rva = strtoull(tokens[1], NULL, 16);
|
||||
code_size = strtoull(tokens[2], NULL, 16);
|
||||
u_int32_t prolog_size = strtoul(tokens[3], NULL, 16);
|
||||
u_int32_t epilog_size = strtoul(tokens[4], NULL, 16);
|
||||
u_int32_t parameter_size = strtoul(tokens[5], NULL, 16);
|
||||
u_int32_t saved_register_size = strtoul(tokens[6], NULL, 16);
|
||||
u_int32_t local_size = strtoul(tokens[7], NULL, 16);
|
||||
u_int32_t max_stack_size = strtoul(tokens[8], NULL, 16);
|
||||
uint32_t prolog_size = strtoul(tokens[3], NULL, 16);
|
||||
uint32_t epilog_size = strtoul(tokens[4], NULL, 16);
|
||||
uint32_t parameter_size = strtoul(tokens[5], NULL, 16);
|
||||
uint32_t saved_register_size = strtoul(tokens[6], NULL, 16);
|
||||
uint32_t local_size = strtoul(tokens[7], NULL, 16);
|
||||
uint32_t max_stack_size = strtoul(tokens[8], NULL, 16);
|
||||
int has_program_string = strtoul(tokens[9], NULL, 16);
|
||||
|
||||
const char *program_string = "";
|
||||
@@ -186,12 +186,12 @@ struct WindowsFrameInfo {
|
||||
int valid;
|
||||
|
||||
// These values come from IDiaFrameData.
|
||||
u_int32_t prolog_size;
|
||||
u_int32_t epilog_size;
|
||||
u_int32_t parameter_size;
|
||||
u_int32_t saved_register_size;
|
||||
u_int32_t local_size;
|
||||
u_int32_t max_stack_size;
|
||||
uint32_t prolog_size;
|
||||
uint32_t epilog_size;
|
||||
uint32_t parameter_size;
|
||||
uint32_t saved_register_size;
|
||||
uint32_t local_size;
|
||||
uint32_t max_stack_size;
|
||||
|
||||
// Only one of allocates_base_pointer or program_string will be valid.
|
||||
// If program_string is empty, use allocates_base_pointer.
|
||||
|
||||
Reference in New Issue
Block a user