-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Teach debuginfo to generate namespaces for each component of a path #1541
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
Comments
Clearing milestone. Just a bug, IMO. Re-nominate if you disagree. |
@catamorphism Please adjust milestones via nomination-to-change, not direct edits. Milestones represent group decisions. |
just a bug, removing milestone/nomination. |
Not sure whether this is "enhancement" or "wrong", so tagging with both. |
I have a prototype for this. However, I stumbled upon a GDB peculiarity while working on the implementation. GDB seems to use the linkage_name attribute (if present) to find out which namespace a function is in. That is, it de-mangles the linkage name to produce If the linkage_name attribute is not present in the debug info, then GDB will display the name correctly. So, I would opt for not setting the linkage_name instead of either |
I'm happy to see what happens if we don't include a linkage name. |
OK, I've investigated this a bit more systematically now and I can't reproduce the 'no linkage name' behaviour. That is, with correct description of the namespace hierarchy but missing I've tested many different combinations and the only way to get GDB to display function names correctly seems to be via the linkage name attribute. That also means that we have to set the incorrect linkage name (missing hash and version number suffix). There are still two design decisions to make that I would like to have some input on: (2) Is it important to set the correct source line attribute for namespaces? I see three alternatives here:
Option (1) would be the most simple but creates slightly incorrect debug info. I would prefer option (3). Any comments? |
Rust's lifetimes assure us that option 3's criterion will always hold,
|
In this case we are not concerned with values or references outliving the function scope they were defined in, but with types and functions not being visible outside the function they are defined in. For example, the following code is perfectly legal as far as the current rustc is concerned: pub fn aaa() -> int {
pub mod bbb {
pub struct CCC {
x: int
}
pub fn ddd() -> CCC {
return CCC { x: 0 };
}
}
return bbb::ddd().x;
} That is, we have a module defined in the body of a function. This module again can contain arbitrary items. This is fine for the pre-pass algorithm as long as it can stop whenever it encounters a function. But if the following code were legal, the pre-pass algorithm would also have to handle functions: // code from example above...
fn xxx() -> aaa::bbb::CCC {
...
} But to fully instantiate function debug info, the pre-pass algorithm would also have to handle type debuginfo, which can lead to cyclic dependencies. This would make the whole algorithm a lot more complicated. Consider the following example: mod aaa {
fn bbb() -> ddd::eee::fff {
struct ccc { ... }
}
}
mod ddd {
fn eee -> aaa::bbb::ccc {
struct fff { ... }
...
}
} We would start at It would be doable, of course, by introducing stubs for functions and later patching those with the actual references. But I'd rather keep everything dead simple if possible. Since modules alone just form a tree they can't introduce cyclic dependencies, so a simple tree traversal would do the trick. |
Use a BufWriter in emit_module to reduce syscall overhead
Currently function information is generated with the fully-qualified path. Instead, we should link to the parent module in the context field, using DW_AT_namespace to represent modules.
The text was updated successfully, but these errors were encountered: