-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This covers some but not all cases of tombstones. In particular, we don't have a test for a DW_LNE_set_address tombstone in the middle of a line number sequence. This also handles an integer overflow for a tombstone address in DW_AT_low_pc. We already did the right thing in release builds.
- Loading branch information
Showing
13 changed files
with
142 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "testinput"] | ||
path = testinput | ||
url = https://github.com/gimli-rs/object-testfiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
0x0000000000001040 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:9 | ||
0x0000000000001044 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
0x0000000000001740 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:9 | ||
0x0000000000001744 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
0x0000000000000000 | ||
_Z2f1v | ||
/object/testfiles/dwarf/tombstone.cpp:3 | ||
0x0000000000000004 | ||
_Z2f1v | ||
/object/testfiles/dwarf/tombstone.cpp:8 | ||
0x00000000000005a0 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:9 | ||
0x00000000000005a4 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
0x0000000000001740 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:9 | ||
0x0000000000001744 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
0x0000000000000000 | ||
_Z2f1v | ||
/object/testfiles/dwarf/tombstone.cpp:3 | ||
0x0000000000000004 | ||
_Z2f1v | ||
/object/testfiles/dwarf/tombstone.cpp:8 | ||
0x0000000000001040 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:9 | ||
0x0000000000001044 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
0x0000000000000000 | ||
_Z2f1v | ||
/object/testfiles/dwarf/tombstone.cpp:3 | ||
0x0000000000000004 | ||
_Z2f1v | ||
/object/testfiles/dwarf/tombstone.cpp:8 | ||
0x00000000000005a0 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:9 | ||
0x00000000000005a4 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
0x0000000000001740 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:9 | ||
0x0000000000001744 | ||
main | ||
/object/testfiles/dwarf/tombstone.cpp:14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use std::path::PathBuf; | ||
use std::process::Command; | ||
use std::{env, fs}; | ||
|
||
use libtest_mimic::{Arguments, Failed, Trial}; | ||
|
||
fn main() { | ||
let args = Arguments::from_args(); | ||
libtest_mimic::run(&args, make_tests()).exit(); | ||
} | ||
|
||
fn make_tests() -> Vec<Trial> { | ||
let testinput = PathBuf::from("testinput/dwarf"); | ||
let testoutput = PathBuf::from("testoutput/dwarf"); | ||
|
||
let mut tests = Vec::new(); | ||
let mut dirs = vec![(testinput, testoutput)]; | ||
while let Some((in_dir, out_dir)) = dirs.pop() { | ||
for entry in out_dir.read_dir().unwrap() { | ||
let entry = entry.unwrap(); | ||
let out_path = entry.path(); | ||
let mut in_path = in_dir.clone(); | ||
in_path.push(entry.file_name()); | ||
|
||
let file_type = entry.file_type().unwrap(); | ||
if file_type.is_dir() { | ||
dirs.push((in_path, out_path)); | ||
} else if file_type.is_file() { | ||
tests.push(Trial::test( | ||
format!("addr2line -e {}", in_path.display()), | ||
move || run_test(in_path, out_path), | ||
)); | ||
} | ||
} | ||
} | ||
tests | ||
} | ||
|
||
fn run_test(in_path: PathBuf, out_path: PathBuf) -> Result<(), Failed> { | ||
let mut exe = env::current_exe().unwrap(); | ||
assert!(exe.pop()); | ||
if exe.file_name().unwrap().to_str().unwrap() == "deps" { | ||
assert!(exe.pop()); | ||
} | ||
exe.push("addr2line"); | ||
assert!(exe.is_file()); | ||
|
||
let mut cmd = Command::new(exe); | ||
cmd.env("RUST_BACKTRACE", "1"); | ||
cmd.arg("--exe").arg(in_path).arg("--all").arg("-afi"); | ||
|
||
let output = cmd.output().unwrap(); | ||
assert!(output.status.success()); | ||
let out_data = output.stdout; | ||
|
||
if env::var_os("ADDR2LINE_TESTOUTPUT_UPDATE").is_some() { | ||
fs::write(out_path, &out_data).unwrap(); | ||
return Ok(()); | ||
} | ||
|
||
let expect_out_data = fs::read(out_path).unwrap(); | ||
if out_data != expect_out_data { | ||
return Err("mismatch".into()); | ||
} | ||
|
||
Ok(()) | ||
} |