qHostInfo proposal to add breakpoint pc offset

On some architectures, when a breakpoint is hit, the PC is set to a different value and needs to be adjusted. This is handled in ProcesGDBRemote.cpp by the variable m_breakpoint_pc_offset. The problem is this variable is only set via a python target definition file.

I propose extending qHostInfo to add bp_pc_decr:. m_breakpoint_pc_offset would be set to this signed integer.

Ted

Might that value be dependent on the type of code that is getting executed? (e.g. ARM thumb vs. ARM32)? IOW is it really stable for a given host?

Yes, it would. But anything that would change the breakpoint size dynamically would have to set m_breakpoint_pc_offset (probably to 0, the default) and manipulate the PC in target dependent code. It wouldn’t be able to use this change, but wouldn’t be hurt by it.

It is always better if the GDB server can do the backing up of the PC and we generally want this to happen. We don't always know how breakpoints are set when we use the Z packets to set/clear breakpoints. If there are hardware resources, then a breakpoint might get set as a hardware breakpoint and not require the backing up of the PC. Again, these are all details that the GDB server should be in charge of. If you hit a breakpoint that was set by the user, then the PC should be backed up. If you hit a hard coded breakpoint trap that was compiled in to the code, then you don't backup the PC.

I believe this support was added for one GDB server that didn't do the backing up, but I would rather not have every GDB server have to tell us that. Do you have one such GDB server that doesn't backup the PC when it should be?

Greg

Yes - we have 2 GDB servers. One is in a simulator, and uses "hardware"
breakpoints. These give us the PC correctly. The other is a stub running on
hardware that uses software breakpoints, and gives us PC+4. We could change
it, but we're using GDB to talk to it right now, and GDB expects PC+4.

Ted

Yes - we have 2 GDB servers. One is in a simulator, and uses "hardware"
breakpoints. These give us the PC correctly. The other is a stub running on
hardware that uses software breakpoints, and gives us PC+4. We could change
it, but we're using GDB to talk to it right now, and GDB expects PC+4.

Maybe if one of the LLDB specific packets is sent to your GDB server (qHostInfo would be a good one) you can switch over to returning the correct PC? Then you can still work with GDB and LLDB.

That was actually my first thought, but then I found m_breakpoint_pc_offset
and thought it would be useful to expose it via RSP instead of just by
target definition file.

My implementation keeps the same behavior if the GDB server doesn't use
bp_pc_decr; it sets m_breakpoint_pc_offset to 0.

Ted