-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
no debug-info on locals in stack frames when stepping though rust-msgpack #9641
Comments
This is a great testcase; thanks. Breaking on example::main and stepping is working fine for me; I'm going to investigate when things start to go wrong. |
Easy example: |
Yes, that is probably related to the "peculiar stepping behavior" I talked about in the blog post. The |
Given that stack frame 1 is: I imagine the biggest problem may actually be the mapping of code to lines. That will mask lots of local variable visibility issues, since it appears that we've halted in the wrong place (not where we set the breakpoint). |
Yeah, that's what I meant. The whole area of generating good line tables has received virtually no attention so far (you should try stepping through an if-expression ;) |
Both Michael and I have taken a look at this, and neither of us have found anything conclusive. Information dump:
From my own investigations, I applied this patch (https://gist.github.com/jdm/7903912) and ended up generating very similar IR to clang for the programs at https://gist.github.com/jdm/7903924, but breaking on step::Foo::foopy still showed the same problem. |
This may not be entirely our fault. Problem sometimes also occurs in Clang (Ubuntu clang version 3.2-1~exp9ubuntu1), e.g. for the following program: void function(int a, int b, int c)
{
a = b;
c = b;
}
int main() {
function(10, 11, 12);
} Instructing gdb to break at
After one step the variables have the correct values, so this seems to be the same problem. |
Here is what I tried and found so far:
Unfortunately, all of these measures combined still don't alleviate the problem. The LLVM IR looks right, the Looks like this issue will pester us a while longer |
OK, I think I know a bit more about the nature of this problem now: However, the additional machine code generated for checking whether more stack space needs to be allocated seems to throw off GDB's prologue detection and it thinks the regular part of the function has already begun there. So, my current guess is that Rust's dynamic stack allocation is what leads to this behaviour. Note that LLVM does seem to generate correct PROLOGUE END markers in the DWARF line tables, even for functions with split stacks and the IR and DWARF for Rust programs now look pretty much the same as for similar C programs compiled with CLANG. It's possible that this problem would not occur with LLDB. I've not yet had a chance to try that. All the changes mentioned above make sense and lead to cleaner line table generation. I'll prepare a pull request ASAP |
This PR improves the stepping experience in GDB. It contains some fine tuning of line information and makes *rustc* produce nearly the same IR/DWARF as Clang. The focus of the changes is function prologue handling which has caused some problems in the past (#9641). It seems that GDB does not properly handle function prologues when the function uses segmented stacks, i.e. it does not recognize that the `__morestack` check is part of the prologue. When setting a breakpoint like `break foo` it will set the break point before the arguments of `foo()` have been loaded and still contain bogus values. For function with the #[no_split_stack] attribute this problem has never occurred for me so I'm pretty sure that segmented stacks are the cause of the problem. @jdm mentioned that segmented stack won't be completely abandoned after all. I'd be grateful if you could tell me about what the future might bring in this regard (@brson, @cmr). Anyway, this PR should alleviate this problem at least in the case when setting breakpoints using line numbers and also make it less confusing when setting them via function names because then GDB will break *before* the first statement where one could conceivably argue that arguments need not be initialized yet. Also, a koala: 🐨 Cheers, Michael
Enable cargo sparse registry in CI https://blog.rust-lang.org/2022/06/22/sparse-registry-testing.html The initial registry update takes around 1 minute currently, so this gives quite a nice speed boost to CI build times r? `@flip1995` changelog: none
Josh asked for where I was seeing debug-info goes missing. Most places, in my experience. An easy to repro example is just to debug the msgpack bindings, as below. The rust compiler itself, I'm told from rust/irc, is another prime example.
The text was updated successfully, but these errors were encountered: