* Does GDB will remove trap instruction and restore original instruction when GDB quit?
@ 2021-10-03 7:34 周春明(日月)
2021-10-03 14:07 ` Simon Marchi
0 siblings, 1 reply; 2+ messages in thread
From: 周春明(日月) @ 2021-10-03 7:34 UTC (permalink / raw)
To: 周春明(日月),
Simon Marchi, Gdb-patches, gdb-patches
Dear GDB experts,
I have a question, Does GDB will remove trap instruction and restore original instruction when GDB quit?
Could you help to point where code to do that?
Thanks,
-Riyue
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Does GDB will remove trap instruction and restore original instruction when GDB quit?
2021-10-03 7:34 Does GDB will remove trap instruction and restore original instruction when GDB quit? 周春明(日月)
@ 2021-10-03 14:07 ` Simon Marchi
0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2021-10-03 14:07 UTC (permalink / raw)
To: 周春明(日月), Gdb-patches, gdb-patches
On 2021-10-03 03:34, 周春明(日月) wrote:
>
> Dear GDB experts,
>
> I have a question, Does GDB will remove trap instruction and restore original instruction when GDB quit?
> Could you help to point where code to do that?
Of course GDB removes the breakpoint instructions, otherwise the
detached process would crash if it encounters one of them.
By default, when the program stops and all threads are stopped, GDB
removes the breakpoints from the program. So if GDB detaches at that
moment, the breakpoints will already be removed.
If detaching while threads are running, then it happens through this
path:
-> quit_force
-> kill_or_detach
-> target_detach
-> linux_nat_target::detach (assuming you're on Linux, otherwise the equivalent detach method)
-> remove_breakpoints_inf
Simon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-03 14:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-03 7:34 Does GDB will remove trap instruction and restore original instruction when GDB quit? 周春明(日月)
2021-10-03 14:07 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).