Add support for parsing the DW_AT_ranges attributes

This enables the DWARF reader to properly parse DW_AT_ranges attributes
in compilation units and functions. Code covered by a function is now
represented by a vector of ranges instead of a single contiguous range
and DW_AT_ranges entries are used to populate it. All the code and tests
that assumed functions to be contiguous entities has been updated to
reflect the change. DW_AT_ranges attributes found in compilation units
are parsed but no data is generated for them as it is not currently needed.

BUG=754

Change-Id: I310391b525aaba0dd329f1e3187486f2e0c6d442
Reviewed-on: https://chromium-review.googlesource.com/1124721
Reviewed-by: Ted Mielczarek <ted.mielczarek@gmail.com>
This commit is contained in:
Gabriele Svelto 2018-08-04 00:59:34 +02:00 committed by Ted Mielczarek
parent 7b98edabb6
commit 16e08520e6
20 changed files with 653 additions and 122 deletions

View file

@ -91,7 +91,8 @@ bool StabsToModule::StartFunction(const string &name,
uint64_t address) {
assert(!current_function_);
Module::Function *f = new Module::Function(Demangle(name), address);
f->size = 0; // We compute this in StabsToModule::Finalize().
Module::Range r(address, 0); // We compute this in StabsToModule::Finalize().
f->ranges.push_back(r);
f->parameter_size = 0; // We don't provide this information.
current_function_ = f;
boundaries_.push_back(static_cast<Module::Address>(address));
@ -167,14 +168,14 @@ void StabsToModule::Finalize() {
vector<Module::Address>::const_iterator boundary
= std::upper_bound(boundaries_.begin(), boundaries_.end(), f->address);
if (boundary != boundaries_.end())
f->size = *boundary - f->address;
f->ranges[0].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->ranges[0].size = kFallbackSize;
// Compute sizes for each of the function f's lines --- if it has any.
if (!f->lines.empty()) {
@ -185,7 +186,8 @@ void StabsToModule::Finalize() {
line_it != last_line; line_it++)
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->ranges[0].address + f->ranges[0].size) - last_line->address;
}
}
// Now that everything has a size, add our functions to the module, and