Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement indexed values for DWARF 5 #358

Merged
merged 12 commits into from
Jan 15, 2019
51 changes: 43 additions & 8 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ extern crate gimli;
extern crate test;

use gimli::{
AttributeValue, DebugAbbrev, DebugAranges, DebugInfo, DebugLine, DebugLineOffset, DebugLoc,
DebugLocLists, DebugPubNames, DebugPubTypes, DebugRanges, DebugRngLists, EntriesTreeNode,
Expression, Format, LittleEndian, LocationLists, Operation, RangeLists, Reader,
AttributeValue, DebugAbbrev, DebugAddr, DebugAddrBase, DebugAranges, DebugInfo, DebugLine,
DebugLineOffset, DebugLoc, DebugLocLists, DebugPubNames, DebugPubTypes, DebugRanges,
DebugRngLists, EndianSlice, EntriesTreeNode, Expression, Format, LittleEndian, LocationLists,
Operation, RangeLists, Reader, ReaderOffset,
};
use std::env;
use std::fs::File;
Expand Down Expand Up @@ -224,6 +225,9 @@ fn bench_parsing_debug_loc(b: &mut test::Bencher) {
let debug_abbrev = read_section("debug_abbrev");
let debug_abbrev = DebugAbbrev::new(&debug_abbrev, LittleEndian);

let debug_addr = DebugAddr::from(EndianSlice::new(&[], LittleEndian));
let debug_addr_base = DebugAddrBase(0);

let debug_loc = read_section("debug_loc");
let debug_loc = DebugLoc::new(&debug_loc, LittleEndian);
let debug_loclists = DebugLocLists::new(&[], LittleEndian);
Expand Down Expand Up @@ -266,7 +270,14 @@ fn bench_parsing_debug_loc(b: &mut test::Bencher) {
b.iter(|| {
for &(offset, version, address_size, base_address) in &*offsets {
let mut locs = loclists
.locations(offset, version, address_size, base_address)
.locations(
offset,
version,
address_size,
base_address,
&debug_addr,
debug_addr_base,
)
.expect("Should parse locations OK");
while let Some(loc) = locs.next().expect("Should parse next location") {
test::black_box(loc);
Expand All @@ -283,6 +294,9 @@ fn bench_parsing_debug_ranges(b: &mut test::Bencher) {
let debug_abbrev = read_section("debug_abbrev");
let debug_abbrev = DebugAbbrev::new(&debug_abbrev, LittleEndian);

let debug_addr = DebugAddr::from(EndianSlice::new(&[], LittleEndian));
let debug_addr_base = DebugAddrBase(0);

let debug_ranges = read_section("debug_ranges");
let debug_ranges = DebugRanges::new(&debug_ranges, LittleEndian);
let debug_rnglists = DebugRngLists::new(&[], LittleEndian);
Expand Down Expand Up @@ -325,7 +339,14 @@ fn bench_parsing_debug_ranges(b: &mut test::Bencher) {
b.iter(|| {
for &(offset, version, address_size, base_address) in &*offsets {
let mut ranges = rnglists
.ranges(offset, version, address_size, base_address)
.ranges(
offset,
version,
address_size,
base_address,
&debug_addr,
debug_addr_base,
)
.expect("Should parse ranges OK");
while let Some(range) = ranges.next().expect("Should parse next range") {
test::black_box(range);
Expand Down Expand Up @@ -404,8 +425,11 @@ fn bench_evaluating_debug_info_expressions(b: &mut test::Bencher) {
fn debug_loc_expressions<R: Reader>(
debug_info: &DebugInfo<R>,
debug_abbrev: &DebugAbbrev<R>,
debug_addr: &DebugAddr<R>,
loclists: &LocationLists<R>,
) -> Vec<(Expression<R>, u8, Format)> {
let debug_addr_base = DebugAddrBase(R::Offset::from_u8(0));

let mut expressions = Vec::new();

let mut iter = debug_info.units();
Expand Down Expand Up @@ -435,7 +459,14 @@ fn debug_loc_expressions<R: Reader>(
while let Some(attr) = attrs.next().expect("Should parse entry's attribute") {
if let gimli::AttributeValue::LocationListsRef(offset) = attr.value() {
let mut locs = loclists
.locations(offset, unit.version(), unit.address_size(), low_pc)
.locations(
offset,
unit.version(),
unit.address_size(),
low_pc,
debug_addr,
debug_addr_base,
)
.expect("Should parse locations OK");
while let Some(loc) = locs.next().expect("Should parse next location") {
expressions.push((loc.data, unit.address_size(), unit.format()));
Expand All @@ -456,12 +487,14 @@ fn bench_parsing_debug_loc_expressions(b: &mut test::Bencher) {
let debug_abbrev = read_section("debug_abbrev");
let debug_abbrev = DebugAbbrev::new(&debug_abbrev, LittleEndian);

let debug_addr = DebugAddr::from(EndianSlice::new(&[], LittleEndian));

let debug_loc = read_section("debug_loc");
let debug_loc = DebugLoc::new(&debug_loc, LittleEndian);
let debug_loclists = DebugLocLists::new(&[], LittleEndian);
let loclists = LocationLists::new(debug_loc, debug_loclists).expect("Should parse loclists");

let expressions = debug_loc_expressions(&debug_info, &debug_abbrev, &loclists);
let expressions = debug_loc_expressions(&debug_info, &debug_abbrev, &debug_addr, &loclists);

b.iter(|| {
for &(expression, address_size, format) in &*expressions {
Expand All @@ -482,12 +515,14 @@ fn bench_evaluating_debug_loc_expressions(b: &mut test::Bencher) {
let debug_abbrev = read_section("debug_abbrev");
let debug_abbrev = DebugAbbrev::new(&debug_abbrev, LittleEndian);

let debug_addr = DebugAddr::from(EndianSlice::new(&[], LittleEndian));

let debug_loc = read_section("debug_loc");
let debug_loc = DebugLoc::new(&debug_loc, LittleEndian);
let debug_loclists = DebugLocLists::new(&[], LittleEndian);
let loclists = LocationLists::new(debug_loc, debug_loclists).expect("Should parse loclists");

let expressions = debug_loc_expressions(&debug_info, &debug_abbrev, &loclists);
let expressions = debug_loc_expressions(&debug_info, &debug_abbrev, &debug_addr, &loclists);

b.iter(|| {
for &(expression, address_size, format) in &*expressions {
Expand Down
Loading