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
Clean up addr2line so it is a real library #1
Conversation
1 similar comment
Thanks for the pull request! Digging in now...
No worries.
Thank you!!
It should be easy enough to write integration tests by using We could also try comparing our results with the canonical As far as unit tests go, its more about semi-tediously writing test data and breaking down each function as far as possible. These things can, of course, be done in follow up PRs if you are so inclined :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just a couple nitpicks that I'd like to see fixed before we merge this in :)
Thanks again for doing this!
gimli = "0.9.0" | ||
memmap = "0.5.0" | ||
object = "0.1.0" | ||
owning_ref = { git = "https://github.com/Kimundi/owning-ref-rs" } # need OwningHandle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a placeholder until the next release is cut? We won't be able to publish on crates.io with a git dependency :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
|
||
[dependencies] | ||
fallible-iterator = "0.1.3" | ||
getopts = "0.2.14" | ||
clap = "2.*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer specifying a proper version here. Cargo will automatically treat 2.3.6
as ^2.3.6
, which is anything in the range [2.3.6, 3.0.0)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason you want 2.3.6
, or should we start at the current latest (2.19.1
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.3.6 was just an example. The latest version is perfect, thanks!
.short("e") | ||
.long("exe") | ||
.default_value("a.out") | ||
.help("Specify the name of the executable for which addresses should be translated.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/name/path/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the help text verbatim from the addr2line
man page for consistency, but I'm happy to change it if you prefer path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, disregard then.
Do we have a way of referring to the path to build artifacts from inside an integration test?
This was more in line with what I was thinking, though the questions above still apply with regards to getting access to our own build artifact in the tests. Also, can we rely on the test running (Travis) to have
I think I'd prefer for them to be follow-up PRs :) |
Just pushed the |
1 similar comment
From http://doc.crates.io/environment-variables.html:
So we could do something like this: use std::env;
let mut addr2line = PathBuf::new(env::var("CARGO_TARGET_DIR").unwrap());
addr2line.push("addr2line");
Right -- we would just want to make sure that we didn't get
I think so. If not, we can install it with
Of course :)
Nah, its fine. Thanks again! Very appreciated! |
Unfortunately |
One alternative is to just stuff some C code in there and use native code compilation. |
What would the C code do that we can't do in rust? You could look at how others have solved it, eg https://github.com/BurntSushi/ripgrep/blob/master/tests/workdir.rs, doesn't look like there is a simple solution though. |
It's just easier to compile reliably from running commands is all. See #4. |
Sorry for not breaking this down into smaller commits, but there wasn't a good way of doing that without the intermittent commits being unintuitive, broken, or both. This moves all the logic into the library, provides a documented API (with
#[deny(missing_docs)]
), and extends the binary such that its interface matches that ofaddr2line
. It builds cleanly on both stable and nightly.Next steps would probably be to add support for extracting containing function, not just file + line. I think this shouldn't be too painful, but you never know. I would also like to try and find a good way to test this, but I'm not entirely sure how to go about that. Suggestions welcome!
The darkest corners of this PR is the nested use of
owning_ref::OwningHandle
. This is necessary so that we can construct astruct
which contains amemmap
, anobject::File
that borrows the map, andgimli
objects that borrow theobject::File
. Luckily, it all works out somewhat nicely. The biggest bummer at the moment is that errors in the construction of theobject::File
andgimli
objects cause panics, which is due to the lack of being able to forward errors throughowning_ref::OwningHandle
. I've filed a bug about this, so hopefully it will be resolved in not too long.I've left the
Unit
stuff mostly intact, including the comment saying