-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[lldb] Incorrect RISC-V register values displayed #121712
Comments
@llvm/issue-subscribers-lldb Author: None (patryk4815)
LLDB for some reason display wrong register.
This issue occurs when running the same program on an LLDB (invalid): GDB (good): Additional note: After switching to Environment:
|
Ideally registers are described in an XML document sent to LLDB when we first connect. We get the layout of the register data from this. If we don't get that information, some targets have a fallback layout. Which is essentially what GDB would assume the layout is. I don't know whether we have done that for RISC-V, but if we are not getting XML, some assumptions must be being made here and it would be weird for one thread to assume a different layout to another. (unless that thread had more registers enabled?) You can see if XML is sent by enabling logging before you connect to the debug target:
Then you're looking for something like:
I would also not rely on the order of register display to be the order of the data in the G packet. It's possible it is, but I doubt that's always the case.
Edit: I was looking at the thread list thinking it was the backtrace. If thread #2 works, could you also look at the G packet contents for thread 2? I wonder if the location of the sp value changes. I assume the threads here are not hardware threads but FreeRTOS threads, so I'm tempted to point to OpenOCD's FreeRTOS awareness as the problem, but if GDB manages, LLDB should too. |
https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterFallback.cpp has the fallback layouts, I don't see RISC-V here. My guess is that we just hope that LLDB's layout matches the debug target's in this case. |
@DavidSpickett I see lldb don't send |
It seems that the |
Somewhere I remember there is a reason for us not using the I see lldb reading what I think is sp for thread 1 twice:
The first one matches what GBD showed:
But then the value changes:
Not sure why lldb needs to re-read it there, but it should be the same value anyway. You could try manually sending (this isn't uncommon, debug servers like OpenOCD are generally tested against GDB only, so it's easy to miss things) |
LLDB for some reason display wrong register.
This issue occurs when running the same program on an
ESP32-C3
(a simple blinking LED application).Specifically, the
sp
register, along with other registers, shows a value different from what is reported in theg packet
.LLDB (invalid):
GDB (good):
Additional note: After switching to
thread 2
, the register values are displayed correctly.Environment:
The text was updated successfully, but these errors were encountered: