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

Add the ability to dump specific DIEs with --debug-info=0xdeadbeef. #564

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

khuey
Copy link
Contributor

@khuey khuey commented Jun 22, 2021

No description provided.

Copy link
Collaborator

@philipc philipc left a comment

Choose a reason for hiding this comment

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

Can you please rebase to get CI passing.

@@ -386,7 +387,12 @@ fn main() {
"print .eh-frame exception handling frame information",
);
opts.optflag("G", "", "show global die offsets");
opts.optflag("i", "", "print .debug_info and .debug_types sections");
opts.optflagopt(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think optflagopt is a good choice. Previously you could do dwarfdump -i filename but now that doesn't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So what should we do instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dwarfdump -i -- filename works but yeah that's not ideal.

Copy link
Collaborator

Choose a reason for hiding this comment

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

How about -o/--offset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we could do that, though the reason I chose this was to match llvm-dwarfdump.

Maybe we should switch to structopt instead. I think it can be made to do the right thing here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah okay, yeah matching llvm-dwarfdump would be good (llvm-dwarfdump --help didn't show that option). If you want, can leave this how it is and switch later.

let mut entries = unit.entries();
while let Some((delta_depth, entry)) = entries.next_dfs()? {
depth += delta_depth;
if let Some(o) = flags.info_offset {
if o == entry.offset().to_debug_info_offset(&unit.header).unwrap() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will panic if there is a .debug_types section.

@@ -427,6 +433,24 @@ fn main() {
}
if matches.opt_present("i") {
flags.info = true;
if let Some(offset) = matches.opt_str("i") {
let offset = match offset
.get(2..)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice if the 0x was optional.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My primary concern was that we were skipping the first two characters without checking what they were. llvm-dwarfdump treats it as decimal if 0x is missing, so I guess we need to match that, or give an error.

Some(offset) => offset,
None => {
writeln!(
&mut io::stderr(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use eprintln! (and there's an existing call that could be changed too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants