Re: Spurious SIGTRAP reported by GDB 6.8 when debugging embedded RTOS application

Antony KING
2008-08-18T10:21:42Z

Thanks for the explanation. Unfortunately GDB has no influence over the
RTOS, it is merely an observer. This means that it cannot change the
status of threads or decide which thread is to execute; this is solely
under the control of the RTOS.

Your suggestion of disabling H/W single stepping is interesting but
unfortunately will not be suitable as we need the efficiency of the H/W
single step to ensure a responsive debug experience (especially under
Eclipse).

I think I might investigate the strategy of modifying GDB so that it
restores the currently selected thread back to the current running
thread when performing a step (or maybe generating an error).

Cheers,

Antony.

Ulrich Weigand wrote:
> Antony KING wrote:
>
>> you can see that GDB is reporting a "SIGTRAP" message after switching
>> threads from "Thread 3" (the active thread) to "Thread 7" and then
>> performing the step. GDB is expecting that on completion of the step the
>> stopped thread reported by the target will be same as was selected by
>> GDB before the step (e.g. "Thread 7"). This will not generally happen
>> with our RTOS since it is not possible to change the currently running
>> thread (as exhibited above).
>
> Here's my understanding of this issue: GDB does not actually care about
> the "currently running" thread -- this is up the OS scheduler which GDB
> cannot and does not attempt to influence.
>
> GDB does cares about the following two properties of threads:
>
> - Which threads are *runnable* (i.e. not stopped)
>
> GDB may -depending on the situation- want to tell the target to mark
> all threads runnable, no thread runnable, or just a single thread
> runnable. (If it marks all threads runnable, it is of course up to
> the OS which threads it schedules in which order to actually *run*
> on any of the physical processors.)
>
> - Which thread to run in hardware single-step mode
>
> On targets that support hardware single-step, GDB will want to decide
> *which* of the threads the single-step mode should be applied to.
> (GDB will only ever mark one thread for single-stepping.)
>
>
> It seems that you're running into problems with the second point:
> GDB has asked the target to hardware single-step thread 7, but your OS
> actually enabled hardware single-stepping for thread 3.
>
> If possible, you should fix this in your target implementation. If
> this is not possible for your RTOS, one simple way to solve the issue
> might be to tell the GDB core that your target does not support hardware
> single-stepping. Then, GDB will fall back to software single-stepping,
> where it cares for stepping the correct thread by itself.
>
> Bye,
> Ulrich