-
Notifications
You must be signed in to change notification settings - Fork 108
Support file hashes in .debug_line #972
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
Conversation
src/debuginfo/line_info.rs
Outdated
}); | ||
|
||
line_program.file_has_timestamp = true; | ||
line_program.file_has_md5 = md5.is_some(); |
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.
It may be possible for files coming from different crates (due to for example macros) to have different hash algorithms. Does always setting this to true
work? Or will gdb or lldb think an MD5 of 0 means that the file should actually hash to 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.
Seems that true
here means zeroed md5 considered as a hash.
What exactly do you mean for "files coming from different crates"? I think SourceFile
should have some info about its crate, so even same files from different crates are added separately here, isn't it?
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 think if one crate uses no hash and it is imported in another crate using md5 as hash, that the files from the imported crate will still get no hash, while the files of the other crate will get an md5 hash.
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.
If you pass None
for file_info
to add_file
, gimli will write a FileInfo
with md5
set to 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.
What are these cases, when that hash is not available? I'm not sure that can even possible
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.
You can switch to an SHA-1 hash using -Zsrc-hash-algorithm=sha1
.
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.
Quiet weird scenario, if I understood correctly. So the complete case is:
- compile crate Y with defaults;
- compile crate X (whose depends on Y) with sha1 src-hash;
Now if include both crates there will be 2 X-es, but only one with a debug file hashes, right?
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 was referring to:
// foo/lib.rs (compile with defaults)
pub fn foo_fn<T>() {}
// bar/lib.rs (compile with sha1 src-hash)
pub fn call_foo_fn() {
foo_fn::<()>();
}
In crate bar, the debuginfo for foo_fn::<()>
will refer to foo/lib.rs
with md5 hash, while the debuginfo of call_foo_fn
will refer to bar/lib.rs
with sha1 hash.
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.
If you pass None for file_info to add_file, gimli will write a FileInfo with md5 set to 0.
That seems like a bug in gimli. LLVM only emits the MD5 field if all files have MD5 info. DWARF does not support only having MD5 fields for some of the files.
Co-Authored-By: bjorn3 <[email protected]>
Thanks for the PR! Unfortunately I just noticed that my gdb and lldb don't yet support DWARF version 5. I have switched this PR to version 4 for now, which means that no md5 hash is currently emitted. Once my gdb and lldb support it, I will switch back to DWARF version 5. I will merge this PR anyway, as it does almost all of the work necessary to support md5 checksums. |
resolves #936