This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Thread Specific Breakpoints in Remote Targets
>>>>> "Josh" == Josh Watt <jpewdev@gmail.com> writes:
Josh> As can been seen from the log, the stub is sending a message to
Josh> switch to thread 1040 ($Hg410#44) right before setting the
Josh> breakpoint (and again before deleting it). In subsequent
Josh> operation, it is apparent that it is always switching to this
Josh> thread when setting and clearing a breakpoint.
FWIW I found your note very clear, thanks for the dump and background
info.
Josh> Because of this, our remote stub cannot rely on the currently
Josh> selected thread as the target thread for a given breakpoint and
Josh> must communicate with GDB every time a breakpoint is hit.
I did not understand this though.
It sounds like you are making breakpoints on the target thread-specific
based on the current thread. But I thought we didn't (yet) have a way
to inform the target that a given breakpoint was thread-specific (but I
don't know this area extremely well -- if I'm wrong I'd like to know
about it).
Josh> I looked through some of the code, and I think it is due to the
Josh> following:
Josh> In breakpoint.c there are calls to
Josh> switch_to_program_space_and_thread() at lines 1895 and 2662 which
Josh> must be selecting the wrong thread, but I'm not sure how to make
Josh> it select the correct thread (if it is even supposed to).
I think you are correct. switch_to_program_space_and_thread selects the
first (meaning first in gdb's internal table) live thread of the
first inferior bound to that program space.
I am not sure whether this choice particularly matters to all callers of
switch_to_program_space_and_thread. However, I think it probably does not
matter to callers from breakpoint.c; I think those could safely
short-circuit switching if the current program space is already correct
and if the current thread is live.
This, I think, will fix your immediate problem but I can't claim the
result will really be correct. I think it would be preferable to
implement real target support for thread-specific breakpoints.
Tom