-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
-C force-frame-pointers=yes
not respected by -Z build-std
or opt-level = "z"
#136198
Comments
-C force-frame-pointers=yes
not respected-C force-frame-pointers=yes
not respected by -Z build-std
or opt-level = "z"
Have you tried this with a compiler built sometime this year? I believe these are separate issues, can you describe the working vs. broken case in full for |
By "working" I mean "what is the working state that setting
Does it require setting ALL of these to break? Surely not? But can any of these flags be set without breaking it? These are separate issues, as I described. I believe you can set |
Ah, sorry, I misunderstood. There is no properly working state, as-is. It doesn't work as expected on debug, and the problem is made worse on release - the stack traces are forever collapsed to a maximum of 2, instead of just when the program enters the panic functions. As for using |
Oh, |
Then, my apologies as I must inventively paraphrase, but how is problem 2 a problem instead of just "it doesn't work as expected, and when I do other things that will probably make it harder for it to work, it still doesn't work as expected"? In general, optimization eliminates most of the information that can be used to trace anything. That's not a bug, that's just kinda what you're asking for. Asking for |
I probably seem overly perplexed for such a simple matter? Mostly I'm just trying to figure out if this needs to be split into 2 issues or not and at first it seemed there was indeed 2 root problems, but on review I suppose not. |
I suppose it is two issues?
These are both necessary for what I was attempting to do, so I didn't think to separate them. Should I? |
Right, I suppose your concern is
But I'm... not entirely sure how gdb discerns this, so I'm not entirely sure if gdb is telling the truth there. Er, to elaborate, I'm one of the most recent people who touched the code that actually does the forcing of frame pointers. It does get respected quite vigorously in many cases when we pass the code on to LLVM. In fact some cases which some people expect
Hmm. Does this code happen to have a more... architecturally neutral reproducer? Or at least less "and also, JTAG"? I suppose I can just rip out the |
Thankfully this work is open source, so I can share it. I was more hoping that it would be general enough so that I wouldn't need to get someone else familiar enough with the workflows of the project to start hacking on it. It's currently very late for me so I'll do it when I get up later this morning, but I will write up a comment here with a link to the repo, some setup help, and intro to hacking steps relevant to this issue. |
What likely happens here is that LLVM does tail call optimization. Rather than creating a new stack frame, LLVM will replace the stack frame of the caller with the stack frame of the callee if the call is the last thing the caller will do and a couple other conditions hold. Even with frame pointers there is no way to recover the old stack frame. |
Alright, so the repository in question is for the Bittide project. The branch I'm currently working on is As for getting set up with this repo, it has a The relevant source files for what I'm working on are:
In order to run the test case(s), first you have to build the necessary binaries. You can absolutely navigate to them and build them individually, but you can also just get everything in the repo done at once with |
Also I forgot to say, but I did bring things up to date (nightly 2025-01-28) and the issues were still present. |
So I've got a project I'm trying to debug, but I'm running into something of an issue. The setup is that I have RISC-V CPUs (
riscv32imc-unknown-none-elf
) debuggable over JTAG using OpenOCD + GDB. I would like to be able to get a backtrace out of GDB in the case that a program panics, but previously I was never able to guarantee that such a trace would be there since the stack would collapse as soon as execution entered intocore::panicking::panic
or the like. The way I was attempting to get backtraces from GDB was by doing something to the effect ofI figured that if I:
panic = "abort"
to the release profile inCargo.toml
.cargo/config.toml
:Then in theory, I should be guaranteed to get backtraces. So I wrote a simple program:
However, I have two problem cases:
crate::am::panic_cold_explicit
I believe). Until then, I get a full trace (very nice!).debug = true
,split-debuginfo = "unpacked"
, andopt-level = "z"
), the stack trace is never deeper than#0
and#1
in GDB. It reportsBacktrace stopped: frame did not save the PC
.panic = "abort"
was used for all of my testing.Meta
This was done on
nightly-2024-11-18
.The text was updated successfully, but these errors were encountered: