This patch allows LLDB to accept register sizes which are not aligned
to 8 bits bitsize boundary. This fixes a crash in LLDB when connecting
to OpenOCD stub. GDB xml description allows for non-aligned bit lengths
but they are rounded off to nearest byte during transfer. In case of
OpenOCD some of SOC specific system registers were less than a single
byte in length and were causing LLDB to crash.
Details
- Reviewers
labath mgorny - Commits
- rGd2b9d0fdda5e: Round XML register bitsize to byte boundary
Diff Detail
Event Timeline
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | ||
---|---|---|
4261 | I suppose LLDB crashed because byte_size was zero? Maybe add an assert for that then. |
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | ||
---|---|---|
4360–4361 | Ah, right. I suppose you could skip zero-byte registers though. That should amend the assert with better release behavior. |
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | ||
---|---|---|
4360–4361 | on a second thought, I dont see a zero sized register being sent by stub as a big enough reason to abort the whole debug session unless its one of GPRs. May be we skip the assert altogether and replace it with an error message. |
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | ||
---|---|---|
4360–4361 | Yes, you are correct. Probably LLDB_LOG would go in line with how we handle these things. |
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | ||
---|---|---|
4360–4361 | LLDB_LOG will hide message from user unless log is enabled. I think user must be notified that register is zero sized and thats why you wont be able to see it in register read. Similar to the way we notify user about unhandled register attibutes like "save-restore". |
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | ||
---|---|---|
4360–4361 | BTW, I came very close to deleting that printf when I was touching this code last month. |
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | ||
---|---|---|
4360–4361 | +1 on not crashing. The remote sending us garbage shouldn't cause us to crash - we should try to make sense of the garbage, and if we can't, error out gracefully. Better to print an error and ignore the register than crash or abort the session. |
I suppose LLDB crashed because byte_size was zero? Maybe add an assert for that then.