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

fix(debuginfo): Calculate line record sizes for DWARF #220

Merged
merged 1 commit into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions debuginfo/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,15 @@ pub struct LineInfo<'data> {

impl fmt::Debug for LineInfo<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("LineInfo")
.field("address", &format_args!("{:#x}", self.address))
.field("file", &self.file)
let mut s = f.debug_struct("LineInfo");
s.field("address", &format_args!("{:#x}", self.address));

match self.size {
Some(size) => s.field("size", &format_args!("{:#x}", size)),
None => s.field("size", &self.size),
};

s.field("file", &self.file)
.field("line", &self.line)
.finish()
}
Expand Down
11 changes: 10 additions & 1 deletion debuginfo/src/dwarf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ struct DwarfRow {
address: u64,
file_index: u64,
line: Option<u64>,
size: Option<u64>,
}

/// A sequence in the DWARF line program.
Expand All @@ -202,6 +203,13 @@ impl<'d, 'a> DwarfLineProgram<'d> {

while let Ok(Some((_, &program_row))) = state_machine.next_row() {
let address = program_row.address();

if let Some(last_row) = sequence_rows.last_mut() {
if address >= last_row.address {
last_row.size = Some(address - last_row.address);
Comment on lines +208 to +209
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows a row-size of 0. I assume this is intentional

}
}

if program_row.end_sequence() {
// Theoretically, there could be multiple DW_LNE_end_sequence in a row. We're not
// interested in empty sequences, so we can skip them completely.
Expand Down Expand Up @@ -242,6 +250,7 @@ impl<'d, 'a> DwarfLineProgram<'d> {
address,
file_index,
line,
size: None,
});
}
prev_address = address;
Expand Down Expand Up @@ -557,7 +566,7 @@ impl<'d, 'a> DwarfUnit<'d, 'a> {
last = Some((row.file_index, line));
lines.push(LineInfo {
address: row.address - self.inner.info.load_address,
size: None,
size: row.size,
file,
line,
});
Expand Down