Reputation: 333
I print the packets exchanged between gdb and qemu-i386, I see that when I type si
in gdb and current pc point to iret
instruction, the gdb will send vCont;s:1
to qemu-i386-server, but if the current pc point to normal instruction, the gdb will send Z0;addr:4
and vCont;c:1
to qemu to let qemu continue until breakpoint.
And my question is, I implemented a mips32 emulator and also the gdb server, when I type si
in my emulator debugger and current pc point to a instruction eret
(which is similar to iret in i386), the gdb send a Z0;addr:4
to let me add a breakpoint after the eret instruction and then send me a vCont;c:1
to let me continue, since the eret will set pc to epc, so the break point will never reach, and the si
command typed in gdb end with unbounded continue. I want to let gdb just send me a vCont;s:1
, so that the si command will only execute one instruction. Thanks in advance !
Upvotes: 1
Views: 316
Reputation: 22569
I believe there are two components to getting gdb to send vCont;s
.
First, your stub has to reply correctly to the vCont
probe packet. For example, gdbserver shows:
Sending packet: $vCont?#49...Packet received: vCont;c;C;t;s;S;r
Here, gdb has queried with vCont?
, and the remote has put s
into the reply. So, when appropriate, gdb will send vCont;s
.
By default, though, gdb uses its knowledge of the target's instruction set to decide how to single-step. That is, it decodes the instruction and determines the address at which to set a "single step breakpoint". (I don't know why it is done this way in gdb.)
Assuming your stub already replies correctly, then there are two ways to solve your problem, both involving patching gdb.
I noticed that arm_linux_software_single_step
does this:
if (target_can_do_single_step () == 1)
return {};
So one idea would be to change the MIPS port to do this as well. I don't know whether this would be accepted upstream (it may impact other MIPS stubs negatively somehow).
Or, change mips_software_single_step
to correctly decode the eret
instruction. This seems like a good idea regardless.
Upvotes: 0