aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-01-28 22:59:15 +0000
committerjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-01-28 22:59:15 +0000
commit3e60d65111607f401461ff15981a463cde8f744a (patch)
treec2bce078d87b7a6789a22d1d69792989fd2566de
parentBreakpad DWARF parser: Add method to read DWARF "Initial length". (diff)
downloadbreakpad-3e60d65111607f401461ff15981a463cde8f744a.tar.xz
Breakpad Linux Dumper: Rename structure members to follow the Google C++ Style Guide.
The Google C++ Style Guide says that members of structures needn't have names ending in underscores. The structure types in google_breakpad::Module don't follow this rule. a=jimblandy, r=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@505 4c0a9323-5329-0410-9bdc-e9ce6186880e
-rw-r--r--src/common/linux/dump_stabs.cc40
-rw-r--r--src/common/linux/dump_stabs_unittest.cc66
-rw-r--r--src/common/linux/dwarf_cu_to_module.cc70
-rw-r--r--src/common/linux/dwarf_cu_to_module_unittest.cc32
-rw-r--r--src/common/linux/dwarf_line_to_module.cc8
-rw-r--r--src/common/linux/dwarf_line_to_module_unittest.cc88
-rw-r--r--src/common/linux/module.cc44
-rw-r--r--src/common/linux/module.h22
-rw-r--r--src/common/linux/module_unittest.cc64
9 files changed, 217 insertions, 217 deletions
diff --git a/src/common/linux/dump_stabs.cc b/src/common/linux/dump_stabs.cc
index e61b274e..23e41aeb 100644
--- a/src/common/linux/dump_stabs.cc
+++ b/src/common/linux/dump_stabs.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009, Google Inc.
+// Copyright (c) 2010, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -78,10 +78,10 @@ bool DumpStabsHandler::StartFunction(const string &name,
uint64_t address) {
assert(!current_function_);
Module::Function *f = new Module::Function;
- f->name_ = Demangle(name);
- f->address_ = address;
- f->size_ = 0; // We compute this in DumpStabsHandler::Finalize().
- f->parameter_size_ = 0; // We don't provide this information.
+ f->name = Demangle(name);
+ f->address = address;
+ f->size = 0; // We compute this in DumpStabsHandler::Finalize().
+ f->parameter_size = 0; // We don't provide this information.
current_function_ = f;
boundaries_.push_back(static_cast<Module::Address>(address));
return true;
@@ -97,7 +97,7 @@ bool DumpStabsHandler::EndFunction(uint64_t address) {
// (I don't really understand the above comment; just bringing it
// along from the previous code, and leaving the behaivor unchanged.
// If you know the whole story, please patch this comment. --jimb)
- if (current_function_->address_ >= comp_unit_base_address_)
+ if (current_function_->address >= comp_unit_base_address_)
functions_.push_back(current_function_);
else
delete current_function_;
@@ -115,11 +115,11 @@ bool DumpStabsHandler::Line(uint64_t address, const char *name, int number) {
current_source_file_name_ = name;
}
Module::Line line;
- line.address_ = address;
- line.size_ = 0; // We compute this in DumpStabsHandler::Finalize().
- line.file_ = current_source_file_;
- line.number_ = number;
- current_function_->lines_.push_back(line);
+ line.address = address;
+ line.size = 0; // We compute this in DumpStabsHandler::Finalize().
+ line.file = current_source_file_;
+ line.number = number;
+ current_function_->lines.push_back(line);
return true;
}
@@ -142,27 +142,27 @@ void DumpStabsHandler::Finalize() {
Module::Function *f = *func_it;
// Compute the function f's size.
vector<Module::Address>::iterator boundary
- = std::upper_bound(boundaries_.begin(), boundaries_.end(), f->address_);
+ = std::upper_bound(boundaries_.begin(), boundaries_.end(), f->address);
if (boundary != boundaries_.end())
- f->size_ = *boundary - f->address_;
+ f->size = *boundary - f->address;
else
// If this is the last function in the module, and the STABS
// reader was unable to give us its ending address, then assign
// it a bogus, very large value. This will happen at most once
// per module: since we've added all functions' addresses to the
// boundary table, only one can be the last.
- f->size_ = kFallbackSize;
+ f->size = kFallbackSize;
// Compute sizes for each of the function f's lines --- if it has any.
- if (!f->lines_.empty()) {
- stable_sort(f->lines_.begin(), f->lines_.end(),
+ if (!f->lines.empty()) {
+ stable_sort(f->lines.begin(), f->lines.end(),
Module::Line::CompareByAddress);
- vector<Module::Line>::iterator last_line = f->lines_.end() - 1;
- for (vector<Module::Line>::iterator line_it = f->lines_.begin();
+ vector<Module::Line>::iterator last_line = f->lines.end() - 1;
+ for (vector<Module::Line>::iterator line_it = f->lines.begin();
line_it != last_line; line_it++)
- line_it[0].size_ = line_it[1].address_ - line_it[0].address_;
+ line_it[0].size = line_it[1].address - line_it[0].address;
// Compute the size of the last line from f's end address.
- last_line->size_ = (f->address_ + f->size_) - last_line->address_;
+ last_line->size = (f->address + f->size) - last_line->address;
}
}
// Now that everything has a size, add our functions to the module, and
diff --git a/src/common/linux/dump_stabs_unittest.cc b/src/common/linux/dump_stabs_unittest.cc
index ca09f43c..764b187f 100644
--- a/src/common/linux/dump_stabs_unittest.cc
+++ b/src/common/linux/dump_stabs_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009, Google Inc.
+// Copyright (c) 2010, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -60,16 +60,16 @@ TEST(DumpStabsHandler, SimpleCU) {
m.GetFunctions(&functions, functions.end());
ASSERT_EQ((size_t) 1, functions.size());
Module::Function *function = functions[0];
- EXPECT_STREQ("function", function->name_.c_str());
- EXPECT_EQ(0xfde4abbed390c394LL, function->address_);
- EXPECT_EQ(0x10U, function->size_);
- EXPECT_EQ(0U, function->parameter_size_);
- ASSERT_EQ((size_t) 1, function->lines_.size());
- Module::Line *line = &function->lines_[0];
- EXPECT_EQ(0xfde4abbed390c394LL, line->address_);
- EXPECT_EQ(0x10U, line->size_); // derived from EndFunction
- EXPECT_TRUE(line->file_ == file);
- EXPECT_EQ(174823314, line->number_);
+ EXPECT_STREQ("function", function->name.c_str());
+ EXPECT_EQ(0xfde4abbed390c394LL, function->address);
+ EXPECT_EQ(0x10U, function->size);
+ EXPECT_EQ(0U, function->parameter_size);
+ ASSERT_EQ((size_t) 1, function->lines.size());
+ Module::Line *line = &function->lines[0];
+ EXPECT_EQ(0xfde4abbed390c394LL, line->address);
+ EXPECT_EQ(0x10U, line->size); // derived from EndFunction
+ EXPECT_TRUE(line->file == file);
+ EXPECT_EQ(174823314, line->number);
}
TEST(InferSizes, LineSize) {
@@ -101,23 +101,23 @@ TEST(InferSizes, LineSize) {
ASSERT_EQ((size_t) 1, functions.size());
Module::Function *function = functions[0];
- EXPECT_STREQ("function", function->name_.c_str());
- EXPECT_EQ(0xb4513962eff94e92LL, function->address_);
- EXPECT_EQ(0x1000100000000ULL, function->size_); // inferred from CU end
- EXPECT_EQ(0U, function->parameter_size_);
- ASSERT_EQ((size_t) 2, function->lines_.size());
-
- Module::Line *line1 = &function->lines_[0];
- EXPECT_EQ(0xb4513962eff94e92LL, line1->address_);
- EXPECT_EQ(0x100000000ULL, line1->size_); // derived from EndFunction
- EXPECT_TRUE(line1->file_ == file1);
- EXPECT_EQ(77396614, line1->number_);
-
- Module::Line *line2 = &function->lines_[1];
- EXPECT_EQ(0xb4513963eff94e92LL, line2->address_);
- EXPECT_EQ(0x1000000000000ULL, line2->size_); // derived from EndFunction
- EXPECT_TRUE(line2->file_ == file2);
- EXPECT_EQ(87660088, line2->number_);
+ EXPECT_STREQ("function", function->name.c_str());
+ EXPECT_EQ(0xb4513962eff94e92LL, function->address);
+ EXPECT_EQ(0x1000100000000ULL, function->size); // inferred from CU end
+ EXPECT_EQ(0U, function->parameter_size);
+ ASSERT_EQ((size_t) 2, function->lines.size());
+
+ Module::Line *line1 = &function->lines[0];
+ EXPECT_EQ(0xb4513962eff94e92LL, line1->address);
+ EXPECT_EQ(0x100000000ULL, line1->size); // derived from EndFunction
+ EXPECT_TRUE(line1->file == file1);
+ EXPECT_EQ(77396614, line1->number);
+
+ Module::Line *line2 = &function->lines[1];
+ EXPECT_EQ(0xb4513963eff94e92LL, line2->address);
+ EXPECT_EQ(0x1000000000000ULL, line2->size); // derived from EndFunction
+ EXPECT_TRUE(line2->file == file2);
+ EXPECT_EQ(87660088, line2->number);
}
TEST(FunctionNames, Mangled) {
@@ -148,11 +148,11 @@ TEST(FunctionNames, Mangled) {
EXPECT_STREQ("std::vector<unsigned long long, "
"std::allocator<unsigned long long> >::"
"push_back(unsigned long long const&)",
- function->name_.c_str());
- EXPECT_EQ(0xf2cfda63cef7f46dLL, function->address_);
- EXPECT_LT(0U, function->size_); // should have used dummy size
- EXPECT_EQ(0U, function->parameter_size_);
- ASSERT_EQ(0U, function->lines_.size());
+ function->name.c_str());
+ EXPECT_EQ(0xf2cfda63cef7f46dLL, function->address);
+ EXPECT_LT(0U, function->size); // should have used dummy size
+ EXPECT_EQ(0U, function->parameter_size);
+ ASSERT_EQ(0U, function->lines.size());
}
// TODO --- if we actually cared about STABS. Even without these we've
diff --git a/src/common/linux/dwarf_cu_to_module.cc b/src/common/linux/dwarf_cu_to_module.cc
index 8063d25f..c7cc3688 100644
--- a/src/common/linux/dwarf_cu_to_module.cc
+++ b/src/common/linux/dwarf_cu_to_module.cc
@@ -316,10 +316,10 @@ void DwarfCUToModule::FuncHandler::Finish() {
// Create a Module::Function based on the data we've gathered, and
// add it to the functions_ list.
Module::Function *func = new Module::Function;
- func->name_ = name_;
- func->address_ = low_pc_;
- func->size_ = high_pc_ - low_pc_;
- func->parameter_size_ = 0;
+ func->name = name_;
+ func->address = low_pc_;
+ func->size = high_pc_ - low_pc_;
+ func->parameter_size = 0;
cu_context_->functions.push_back(func);
}
}
@@ -404,15 +404,15 @@ void DwarfCUToModule::WarningReporter::UncoveredFunction(
const Module::Function &function) {
UncoveredHeading();
fprintf(stderr, " function%s: %s\n",
- function.size_ == 0 ? " (zero-length)" : "",
- function.name_.c_str());
+ function.size == 0 ? " (zero-length)" : "",
+ function.name.c_str());
}
void DwarfCUToModule::WarningReporter::UncoveredLine(const Module::Line &line) {
UncoveredHeading();
fprintf(stderr, " line%s: %s:%d at 0x%llx\n",
- (line.size_ == 0 ? " (zero-length)" : ""),
- line.file_->name_.c_str(), line.number_, line.address_);
+ (line.size == 0 ? " (zero-length)" : ""),
+ line.file->name.c_str(), line.number, line.address);
}
DwarfCUToModule::DwarfCUToModule(FileContext *file_context,
@@ -545,7 +545,7 @@ inline bool within(const T &item, Module::Address address) {
// Because Module::Address is unsigned, and unsigned arithmetic
// wraps around, this will be false if ADDRESS falls before the
// start of ITEM, or if it falls after ITEM's end.
- return address - item.address_ < item.size_;
+ return address - item.address < item.size;
}
}
@@ -579,7 +579,7 @@ void DwarfCUToModule::AssignLinesToFunctions() {
const Module::Line *last_line_cited = NULL;
// Make a single pass through both vectors from lower to higher
- // addresses, populating each Function's lines_ vector with lines
+ // addresses, populating each Function's lines vector with lines
// from our lines_ vector that fall within the function's address
// range.
vector<Module::Function *>::iterator func_it = functions->begin();
@@ -597,15 +597,15 @@ void DwarfCUToModule::AssignLinesToFunctions() {
if (func_it != functions->end() && line_it != lines_.end()) {
func = *func_it;
line = &*line_it;
- current = std::min(func->address_, line->address_);
+ current = std::min(func->address, line->address);
} else if (line_it != lines_.end()) {
func = NULL;
line = &*line_it;
- current = line->address_;
+ current = line->address;
} else if (func_it != functions->end()) {
func = *func_it;
line = NULL;
- current = (*func_it)->address_;
+ current = (*func_it)->address;
} else {
return;
}
@@ -640,25 +640,25 @@ void DwarfCUToModule::AssignLinesToFunctions() {
// iterator. So neither iterator moves.
// Assert the first invariant (see above).
- assert(!func || current < func->address_ || within(*func, current));
- assert(!line || current < line->address_ || within(*line, current));
+ assert(!func || current < func->address || within(*func, current));
+ assert(!line || current < line->address || within(*line, current));
// The next transition after CURRENT.
Module::Address next_transition;
// Figure out which state we're in, add lines or warn, and compute
// the next transition address.
- if (func && current >= func->address_) {
- if (line && current >= line->address_) {
+ if (func && current >= func->address) {
+ if (line && current >= line->address) {
// Covered by both a line and a function.
- Module::Address func_left = func->size_ - (current - func->address_);
- Module::Address line_left = line->size_ - (current - line->address_);
+ Module::Address func_left = func->size - (current - func->address);
+ Module::Address line_left = line->size - (current - line->address);
// This may overflow, but things work out.
next_transition = current + std::min(func_left, line_left);
Module::Line l = *line;
- l.address_ = current;
- l.size_ = next_transition - current;
- func->lines_.push_back(l);
+ l.address = current;
+ l.size = next_transition - current;
+ func->lines.push_back(l);
last_line_used = line;
} else {
// Covered by a function, but no line.
@@ -666,14 +666,14 @@ void DwarfCUToModule::AssignLinesToFunctions() {
reporter->UncoveredFunction(*func);
last_function_cited = func;
}
- if (line && within(*func, line->address_))
- next_transition = line->address_;
+ if (line && within(*func, line->address))
+ next_transition = line->address;
else
// If this overflows, we'll catch it below.
- next_transition = func->address_ + func->size_;
+ next_transition = func->address + func->size;
}
} else {
- if (line && current >= line->address_) {
+ if (line && current >= line->address) {
// Covered by a line, but no function.
//
// If GCC emits padding after one function to align the start
@@ -688,15 +688,15 @@ void DwarfCUToModule::AssignLinesToFunctions() {
if (line != last_line_cited
&& !(func
&& line == last_line_used
- && func->address_ - line->address_ == line->size_)) {
+ && func->address - line->address == line->size)) {
reporter->UncoveredLine(*line);
last_line_cited = line;
}
- if (func && within(*line, func->address_))
- next_transition = func->address_;
+ if (func && within(*line, func->address))
+ next_transition = func->address;
else
// If this overflows, we'll catch it below.
- next_transition = line->address_ + line->size_;
+ next_transition = line->address + line->size;
} else {
// Covered by neither a function nor a line. By the invariant,
// both func and line begin after CURRENT. The next transition
@@ -704,11 +704,11 @@ void DwarfCUToModule::AssignLinesToFunctions() {
// is earliest.
assert (func || line);
if (func && line)
- next_transition = std::min(func->address_, line->address_);
+ next_transition = std::min(func->address, line->address);
else if (func)
- next_transition = func->address_;
+ next_transition = func->address;
else
- next_transition = line->address_;
+ next_transition = line->address;
}
}
@@ -724,12 +724,12 @@ void DwarfCUToModule::AssignLinesToFunctions() {
// about what result we produce in that case, just as long as we don't
// hang or crash.
while (func_it != functions->end()
- && current >= (*func_it)->address_
+ && current >= (*func_it)->address
&& !within(**func_it, next_transition))
func_it++;
func = (func_it != functions->end()) ? *func_it : NULL;
while (line_it != lines_.end()
- && current >= line_it->address_
+ && current >= line_it->address
&& !within(*line_it, next_transition))
line_it++;
line = (line_it != lines_.end()) ? &*line_it : NULL;
diff --git a/src/common/linux/dwarf_cu_to_module_unittest.cc b/src/common/linux/dwarf_cu_to_module_unittest.cc
index 30ce6ca2..bfaa8c51 100644
--- a/src/common/linux/dwarf_cu_to_module_unittest.cc
+++ b/src/common/linux/dwarf_cu_to_module_unittest.cc
@@ -276,10 +276,10 @@ const size_t CUFixtureBase::dummy_line_size_ =
void CUFixtureBase::PushLine(Module::Address address, Module::Address size,
const string &filename, int line_number) {
Module::Line l;
- l.address_ = address;
- l.size_ = size;
- l.file_ = module_.FindFile(filename);
- l.number_ = line_number;
+ l.address = address;
+ l.size = size;
+ l.file = module_.FindFile(filename);
+ l.number = line_number;
lines_.push_back(l);
}
@@ -539,17 +539,17 @@ void CUFixtureBase::TestFunction(int i, const string &name,
ASSERT_LT((size_t) i, functions_.size());
Module::Function *function = functions_[i];
- EXPECT_EQ(name, function->name_);
- EXPECT_EQ(address, function->address_);
- EXPECT_EQ(size, function->size_);
- EXPECT_EQ(0U, function->parameter_size_);
+ EXPECT_EQ(name, function->name);
+ EXPECT_EQ(address, function->address);
+ EXPECT_EQ(size, function->size);
+ EXPECT_EQ(0U, function->parameter_size);
}
void CUFixtureBase::TestLineCount(int i, size_t expected) {
FillFunctions();
ASSERT_LT((size_t) i, functions_.size());
- ASSERT_EQ(expected, functions_[i]->lines_.size());
+ ASSERT_EQ(expected, functions_[i]->lines.size());
}
void CUFixtureBase::TestLine(int i, int j,
@@ -557,13 +557,13 @@ void CUFixtureBase::TestLine(int i, int j,
const string &filename, int number) {
FillFunctions();
ASSERT_LT((size_t) i, functions_.size());
- ASSERT_LT((size_t) j, functions_[i]->lines_.size());
+ ASSERT_LT((size_t) j, functions_[i]->lines.size());
- Module::Line *line = &functions_[i]->lines_[j];
- EXPECT_EQ(address, line->address_);
- EXPECT_EQ(size, line->size_);
- EXPECT_EQ(filename, line->file_->name_.c_str());
- EXPECT_EQ(number, line->number_);
+ Module::Line *line = &functions_[i]->lines[j];
+ EXPECT_EQ(address, line->address);
+ EXPECT_EQ(size, line->size);
+ EXPECT_EQ(filename, line->file->name.c_str());
+ EXPECT_EQ(number, line->number);
}
// Include caller locations for our test subroutines.
@@ -1280,7 +1280,7 @@ TEST_F(Specifications, InterCU) {
vector<Module::Function *> functions;
m.GetFunctions(&functions, functions.end());
EXPECT_EQ(1U, functions.size());
- EXPECT_STREQ("class_A::member_func_B", functions[0]->name_.c_str());
+ EXPECT_STREQ("class_A::member_func_B", functions[0]->name.c_str());
}
TEST_F(Specifications, BadOffset) {
diff --git a/src/common/linux/dwarf_line_to_module.cc b/src/common/linux/dwarf_line_to_module.cc
index 745d324c..afef1c0e 100644
--- a/src/common/linux/dwarf_line_to_module.cc
+++ b/src/common/linux/dwarf_line_to_module.cc
@@ -108,11 +108,11 @@ void DwarfLineToModule::AddLine(uint64 address, uint64 length,
return;
}
Module::Line line;
- line.address_ = address;
+ line.address = address;
// We set the size when we get the next line or the EndSequence call.
- line.size_ = length;
- line.file_ = file;
- line.number_ = line_num;
+ line.size = length;
+ line.file = file;
+ line.number = line_num;
lines_->push_back(line);
}
diff --git a/src/common/linux/dwarf_line_to_module_unittest.cc b/src/common/linux/dwarf_line_to_module_unittest.cc
index ad0bcc8c..c13d6acf 100644
--- a/src/common/linux/dwarf_line_to_module_unittest.cc
+++ b/src/common/linux/dwarf_line_to_module_unittest.cc
@@ -48,13 +48,13 @@ TEST(Simple, One) {
vector<Module::File *> files;
m.GetFiles(&files);
EXPECT_EQ(1U, files.size());
- EXPECT_STREQ("file1", files[0]->name_.c_str());
+ EXPECT_STREQ("file1", files[0]->name.c_str());
EXPECT_EQ(1U, lines.size());
- EXPECT_EQ(0x6fd126fbf74f2680ULL, lines[0].address_);
- EXPECT_EQ(0x63c9a14cf556712bULL, lines[0].size_);
- EXPECT_TRUE(lines[0].file_ == files[0]);
- EXPECT_EQ(0x4c090cbf, lines[0].number_);
+ EXPECT_EQ(0x6fd126fbf74f2680ULL, lines[0].address);
+ EXPECT_EQ(0x63c9a14cf556712bULL, lines[0].size);
+ EXPECT_TRUE(lines[0].file == files[0]);
+ EXPECT_EQ(0x4c090cbf, lines[0].number);
}
TEST(Simple, Many) {
@@ -83,38 +83,38 @@ TEST(Simple, Many) {
vector<Module::File *> files;
m.GetFiles(&files);
ASSERT_EQ(5U, files.size());
- EXPECT_STREQ("directory1/file1", files[0]->name_.c_str());
- EXPECT_STREQ("directory1/file2", files[1]->name_.c_str());
- EXPECT_STREQ("directory2/file1", files[2]->name_.c_str());
- EXPECT_STREQ("directory2/file2", files[3]->name_.c_str());
- EXPECT_STREQ("file3", files[4]->name_.c_str());
+ EXPECT_STREQ("directory1/file1", files[0]->name.c_str());
+ EXPECT_STREQ("directory1/file2", files[1]->name.c_str());
+ EXPECT_STREQ("directory2/file1", files[2]->name.c_str());
+ EXPECT_STREQ("directory2/file2", files[3]->name.c_str());
+ EXPECT_STREQ("file3", files[4]->name.c_str());
ASSERT_EQ(5U, lines.size());
- EXPECT_EQ(0x69900c5d553b7274ULL, lines[0].address_);
- EXPECT_EQ(0x90fded183f0d0d3cULL, lines[0].size_);
- EXPECT_TRUE(lines[0].file_ == files[0]);
- EXPECT_EQ(0x15b0f0a9, lines[0].number_);
-
- EXPECT_EQ(0x45811219a39b7101ULL, lines[1].address_);
- EXPECT_EQ(0x25a5e6a924afc41fULL, lines[1].size_);
- EXPECT_TRUE(lines[1].file_ == files[2]);
- EXPECT_EQ(0x4d259ce9, lines[1].number_);
-
- EXPECT_EQ(0xfa90514c1dc9704bULL, lines[2].address_);
- EXPECT_EQ(0x0063efeabc02f313ULL, lines[2].size_);
- EXPECT_TRUE(lines[2].file_ == files[1]);
- EXPECT_EQ(0x1ee9fa4f, lines[2].number_);
-
- EXPECT_EQ(0x556b55fb6a647b10ULL, lines[3].address_);
- EXPECT_EQ(0x3f3089ca2bfd80f5ULL, lines[3].size_);
- EXPECT_TRUE(lines[3].file_ == files[3]);
- EXPECT_EQ(0x77fc280e, lines[3].number_);
-
- EXPECT_EQ(0xe2d72a37f8d9403aULL, lines[4].address_);
- EXPECT_EQ(0x034dfab5b0d4d236ULL, lines[4].size_);
- EXPECT_TRUE(lines[4].file_ == files[4]);
- EXPECT_EQ(0x75047044, lines[4].number_);
+ EXPECT_EQ(0x69900c5d553b7274ULL, lines[0].address);
+ EXPECT_EQ(0x90fded183f0d0d3cULL, lines[0].size);
+ EXPECT_TRUE(lines[0].file == files[0]);
+ EXPECT_EQ(0x15b0f0a9, lines[0].number);
+
+ EXPECT_EQ(0x45811219a39b7101ULL, lines[1].address);
+ EXPECT_EQ(0x25a5e6a924afc41fULL, lines[1].size);
+ EXPECT_TRUE(lines[1].file == files[2]);
+ EXPECT_EQ(0x4d259ce9, lines[1].number);
+
+ EXPECT_EQ(0xfa90514c1dc9704bULL, lines[2].address);
+ EXPECT_EQ(0x0063efeabc02f313ULL, lines[2].size);
+ EXPECT_TRUE(lines[2].file == files[1]);
+ EXPECT_EQ(0x1ee9fa4f, lines[2].number);
+
+ EXPECT_EQ(0x556b55fb6a647b10ULL, lines[3].address);
+ EXPECT_EQ(0x3f3089ca2bfd80f5ULL, lines[3].size);
+ EXPECT_TRUE(lines[3].file == files[3]);
+ EXPECT_EQ(0x77fc280e, lines[3].number);
+
+ EXPECT_EQ(0xe2d72a37f8d9403aULL, lines[4].address);
+ EXPECT_EQ(0x034dfab5b0d4d236ULL, lines[4].size);
+ EXPECT_TRUE(lines[4].file == files[4]);
+ EXPECT_EQ(0x75047044, lines[4].number);
}
TEST(Filenames, Absolute) {
@@ -130,9 +130,9 @@ TEST(Filenames, Absolute) {
vector<Module::File *> files;
m.GetFiles(&files);
ASSERT_EQ(1U, files.size());
- EXPECT_STREQ("/absolute", files[0]->name_.c_str());
+ EXPECT_STREQ("/absolute", files[0]->name.c_str());
ASSERT_EQ(1U, lines.size());
- EXPECT_TRUE(lines[0].file_ == files[0]);
+ EXPECT_TRUE(lines[0].file == files[0]);
}
TEST(Filenames, Relative) {
@@ -148,9 +148,9 @@ TEST(Filenames, Relative) {
vector<Module::File *> files;
m.GetFiles(&files);
ASSERT_EQ(1U, files.size());
- EXPECT_STREQ("directory1/relative", files[0]->name_.c_str());
+ EXPECT_STREQ("directory1/relative", files[0]->name.c_str());
ASSERT_EQ(1U, lines.size());
- EXPECT_TRUE(lines[0].file_ == files[0]);
+ EXPECT_TRUE(lines[0].file == files[0]);
}
TEST(Filenames, StrangeFile) {
@@ -163,7 +163,7 @@ TEST(Filenames, StrangeFile) {
h.AddLine(1, 1, 1, 0, 0);
ASSERT_EQ(1U, lines.size());
- EXPECT_STREQ("directory1/", lines[0].file_->name_.c_str());
+ EXPECT_STREQ("directory1/", lines[0].file->name.c_str());
}
TEST(Filenames, StrangeDirectory) {
@@ -176,7 +176,7 @@ TEST(Filenames, StrangeDirectory) {
h.AddLine(1, 1, 1, 0, 0);
ASSERT_EQ(1U, lines.size());
- EXPECT_STREQ("/file1", lines[0].file_->name_.c_str());
+ EXPECT_STREQ("/file1", lines[0].file->name.c_str());
}
TEST(Filenames, StrangeDirectoryAndFile) {
@@ -189,7 +189,7 @@ TEST(Filenames, StrangeDirectoryAndFile) {
h.AddLine(1, 1, 1, 0, 0);
ASSERT_EQ(1U, lines.size());
- EXPECT_STREQ("/", lines[0].file_->name_.c_str());
+ EXPECT_STREQ("/", lines[0].file->name.c_str());
}
// We should silently ignore attempts to define directory number zero,
@@ -205,7 +205,7 @@ TEST(Errors, DirectoryZero) {
h.AddLine(1, 1, 1, 0, 0);
ASSERT_EQ(1U, lines.size());
- EXPECT_STREQ("relative", lines[0].file_->name_.c_str());
+ EXPECT_STREQ("relative", lines[0].file->name.c_str());
}
// We should refuse to add lines with bogus file numbers. We should
@@ -235,7 +235,7 @@ TEST(Errors, BadDirectoryNumber) {
h.AddLine(1, 1, 1, 0, 0);
ASSERT_EQ(1U, lines.size());
- EXPECT_STREQ("baddirnumber1", lines[0].file_->name_.c_str());
+ EXPECT_STREQ("baddirnumber1", lines[0].file->name.c_str());
}
// We promise not to report empty lines.
@@ -261,5 +261,5 @@ TEST(Errors, BigLine) {
h.AddLine(0xffffffffffffffffULL, 2, 1, 0, 0);
ASSERT_EQ(1U, lines.size());
- EXPECT_EQ(1U, lines[0].size_);
+ EXPECT_EQ(1U, lines[0].size);
}
diff --git a/src/common/linux/module.cc b/src/common/linux/module.cc
index 70b70ab5..57352ff8 100644
--- a/src/common/linux/module.cc
+++ b/src/common/linux/module.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009, Google Inc.
+// Copyright (c) 2010, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -83,10 +83,10 @@ Module::File *Module::FindFile(const string &name) {
if (destiny == files_.end()
|| *destiny->first != name) { // Repeated string comparison, boo hoo.
File *file = new File;
- file->name_ = name;
- file->source_id_ = -1;
+ file->name = name;
+ file->source_id = -1;
destiny = files_.insert(destiny,
- FileByNameMap::value_type(&file->name_, file));
+ FileByNameMap::value_type(&file->name, file));
}
return destiny->second;
}
@@ -111,16 +111,16 @@ void Module::AssignSourceIds() {
// First, give every source file an id of -1.
for (FileByNameMap::iterator file_it = files_.begin();
file_it != files_.end(); file_it++)
- file_it->second->source_id_ = -1;
+ file_it->second->source_id = -1;
// Next, mark all files actually cited by our functions' line number
// info, by setting each one's source id to zero.
for (vector<Function *>::const_iterator func_it = functions_.begin();
func_it != functions_.end(); func_it++) {
Function *func = *func_it;
- for (vector<Line>::iterator line_it = func->lines_.begin();
- line_it != func->lines_.end(); line_it++)
- line_it->file_->source_id_ = 0;
+ for (vector<Line>::iterator line_it = func->lines.begin();
+ line_it != func->lines.end(); line_it++)
+ line_it->file->source_id = 0;
}
// Finally, assign source ids to those files that have been marked.
@@ -130,8 +130,8 @@ void Module::AssignSourceIds() {
int next_source_id = 0;
for (FileByNameMap::iterator file_it = files_.begin();
file_it != files_.end(); file_it++)
- if (! file_it->second->source_id_)
- file_it->second->source_id_ = next_source_id++;
+ if (! file_it->second->source_id)
+ file_it->second->source_id = next_source_id++;
}
bool Module::ReportError() {
@@ -152,9 +152,9 @@ bool Module::Write(FILE *stream) {
for (FileByNameMap::iterator file_it = files_.begin();
file_it != files_.end(); file_it++) {
File *file = file_it->second;
- if (file->source_id_ >= 0) {
+ if (file->source_id >= 0) {
if (0 > fprintf(stream, "FILE %d %s\n",
- file->source_id_, file->name_.c_str()))
+ file->source_id, file->name.c_str()))
return ReportError();
}
}
@@ -164,18 +164,18 @@ bool Module::Write(FILE *stream) {
func_it != functions_.end(); func_it++) {
Function *func = *func_it;
if (0 > fprintf(stream, "FUNC %llx %llx %llx %s\n",
- (unsigned long long) (func->address_ - load_address_),
- (unsigned long long) func->size_,
- (unsigned long long) func->parameter_size_,
- func->name_.c_str()))
+ (unsigned long long) (func->address - load_address_),
+ (unsigned long long) func->size,
+ (unsigned long long) func->parameter_size,
+ func->name.c_str()))
return ReportError();
- for (vector<Line>::iterator line_it = func->lines_.begin();
- line_it != func->lines_.end(); line_it++)
+ for (vector<Line>::iterator line_it = func->lines.begin();
+ line_it != func->lines.end(); line_it++)
if (0 > fprintf(stream, "%llx %llx %d %d\n",
- (unsigned long long) (line_it->address_ - load_address_),
- (unsigned long long) line_it->size_,
- line_it->number_,
- line_it->file_->source_id_))
+ (unsigned long long) (line_it->address - load_address_),
+ (unsigned long long) line_it->size,
+ line_it->number,
+ line_it->file->source_id))
return ReportError();
}
diff --git a/src/common/linux/module.h b/src/common/linux/module.h
index ef9e114b..1feac8a7 100644
--- a/src/common/linux/module.h
+++ b/src/common/linux/module.h
@@ -67,12 +67,12 @@ class Module {
// A source file.
struct File {
// The name of the source file.
- string name_;
+ string name;
// The file's source id. The Write member function clears this
// field and assigns source ids a fresh, so any value placed here
// before calling Write will be lost.
- int source_id_;
+ int source_id;
};
// A function.
@@ -80,21 +80,21 @@ class Module {
// For sorting by address. (Not style-guide compliant, but it's
// stupid not to put this in the struct.)
static bool CompareByAddress(const Function *x, const Function *y) {
- return x->address_ < y->address_;
+ return x->address < y->address;
}
// The function's name.
- string name_;
+ string name;
// The start address and length of the function's code.
- Address address_, size_;
+ Address address, size;
// The function's parameter size.
- Address parameter_size_;
+ Address parameter_size;
// Source lines belonging to this function, sorted by increasing
// address.
- vector<Line> lines_;
+ vector<Line> lines;
};
// A source line.
@@ -102,12 +102,12 @@ class Module {
// For sorting by address. (Not style-guide compliant, but it's
// stupid not to put this in the struct.)
static bool CompareByAddress(const Module::Line &x, const Module::Line &y) {
- return x.address_ < y.address_;
+ return x.address < y.address;
}
- Address address_, size_; // The address and size of the line's code.
- File *file_; // The source file.
- int number_; // The source line number.
+ Address address, size; // The address and size of the line's code.
+ File *file; // The source file.
+ int number; // The source line number.
};
// Create a new module with the given name, operating system,
diff --git a/src/common/linux/module_unittest.cc b/src/common/linux/module_unittest.cc
index 2520a236..975d2ff6 100644
--- a/src/common/linux/module_unittest.cc
+++ b/src/common/linux/module_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009, Google Inc.
+// Copyright (c) 2010, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -111,13 +111,13 @@ TEST(Write, OneLineFunc) {
Module::File *file = m.FindFile("file_name.cc");
Module::Function *function = new(Module::Function);
- function->name_ = "function_name";
- function->address_ = 0xe165bf8023b9d9abLL;
- function->size_ = 0x1e4bb0eb1cbf5b09LL;
- function->parameter_size_ = 0x772beee89114358aLL;
+ function->name = "function_name";
+ function->address = 0xe165bf8023b9d9abLL;
+ function->size = 0x1e4bb0eb1cbf5b09LL;
+ function->parameter_size = 0x772beee89114358aLL;
Module::Line line = { 0xe165bf8023b9d9abLL, 0x1e4bb0eb1cbf5b09LL,
file, 67519080 };
- function->lines_.push_back(line);
+ function->lines.push_back(line);
m.AddFunction(function);
m.Write(f);
@@ -145,18 +145,18 @@ TEST(Write, RelativeLoadAddress) {
// A function.
Module::Function *function = new(Module::Function);
- function->name_ = "A_FLIBBERTIJIBBET::a_will_o_the_wisp(a clown)";
- function->address_ = 0xbec774ea5dd935f3LL;
- function->size_ = 0x2922088f98d3f6fcLL;
- function->parameter_size_ = 0xe5e9aa008bd5f0d0LL;
+ function->name = "A_FLIBBERTIJIBBET::a_will_o_the_wisp(a clown)";
+ function->address = 0xbec774ea5dd935f3LL;
+ function->size = 0x2922088f98d3f6fcLL;
+ function->parameter_size = 0xe5e9aa008bd5f0d0LL;
// Some source lines. The module should not sort these.
Module::Line line1 = { 0xbec774ea5dd935f3LL, 0x1c2be6d6c5af2611LL,
file1, 41676901 };
Module::Line line2 = { 0xdaf35bc123885c04LL, 0xcf621b8d324d0ebLL,
file2, 67519080 };
- function->lines_.push_back(line2);
- function->lines_.push_back(line1);
+ function->lines.push_back(line2);
+ function->lines.push_back(line1);
m.AddFunction(function);
@@ -185,18 +185,18 @@ TEST(Write, OmitUnusedFiles) {
// Create a function.
Module::Function *function = new(Module::Function);
- function->name_ = "function_name";
- function->address_ = 0x9b926d464f0b9384LL;
- function->size_ = 0x4f524a4ba795e6a6LL;
- function->parameter_size_ = 0xbbe8133a6641c9b7LL;
+ function->name = "function_name";
+ function->address = 0x9b926d464f0b9384LL;
+ function->size = 0x4f524a4ba795e6a6LL;
+ function->parameter_size = 0xbbe8133a6641c9b7LL;
// Source files that refer to some files, but not others.
Module::Line line1 = { 0x595fa44ebacc1086LL, 0x1e1e0191b066c5b3LL,
file1, 137850127 };
Module::Line line2 = { 0x401ce8c8a12d25e3LL, 0x895751c41b8d2ce2LL,
file3, 28113549 };
- function->lines_.push_back(line1);
- function->lines_.push_back(line2);
+ function->lines.push_back(line1);
+ function->lines.push_back(line2);
m.AddFunction(function);
m.AssignSourceIds();
@@ -204,13 +204,13 @@ TEST(Write, OmitUnusedFiles) {
vector<Module::File *> vec;
m.GetFiles(&vec);
EXPECT_EQ((size_t) 3, vec.size());
- EXPECT_STREQ("filename1", vec[0]->name_.c_str());
- EXPECT_NE(-1, vec[0]->source_id_);
+ EXPECT_STREQ("filename1", vec[0]->name.c_str());
+ EXPECT_NE(-1, vec[0]->source_id);
// Expect filename2 not to be used.
- EXPECT_STREQ("filename2", vec[1]->name_.c_str());
- EXPECT_EQ(-1, vec[1]->source_id_);
- EXPECT_STREQ("filename3", vec[2]->name_.c_str());
- EXPECT_NE(-1, vec[2]->source_id_);
+ EXPECT_STREQ("filename2", vec[1]->name.c_str());
+ EXPECT_EQ(-1, vec[1]->source_id);
+ EXPECT_STREQ("filename3", vec[2]->name.c_str());
+ EXPECT_NE(-1, vec[2]->source_id);
FILE *f = checked_tmpfile();
m.Write(f);
@@ -234,16 +234,16 @@ TEST(Construct, AddFunctions) {
// Two functions.
Module::Function *function1 = new(Module::Function);
- function1->name_ = "_without_form";
- function1->address_ = 0xd35024aa7ca7da5cLL;
- function1->size_ = 0x200b26e605f99071LL;
- function1->parameter_size_ = 0xf14ac4fed48c4a99LL;
+ function1->name = "_without_form";
+ function1->address = 0xd35024aa7ca7da5cLL;
+ function1->size = 0x200b26e605f99071LL;
+ function1->parameter_size = 0xf14ac4fed48c4a99LL;
Module::Function *function2 = new(Module::Function);
- function2->name_ = "_and_void";
- function2->address_ = 0x2987743d0b35b13fLL;
- function2->size_ = 0xb369db048deb3010LL;
- function2->parameter_size_ = 0x938e556cb5a79988LL;
+ function2->name = "_and_void";
+ function2->address = 0x2987743d0b35b13fLL;
+ function2->size = 0xb369db048deb3010LL;
+ function2->parameter_size = 0x938e556cb5a79988LL;
// Put them in a vector.
vector<Module::Function *> vec;