[RFC] Add task-specific breakpoint capability...

Joel Brobecker brobecker@adacore.com
Tue Mar 24 21:27:00 GMT 2009


Hello,

This patch is to complete the addition of (Ada) tasking support
in GDB which AdaCore contributed a few months ago.  The idea is
to allow a user to stop on a breakpoint only if the task that
triggered the breakpoint corresponds to a specific task, identified
by its task ID (from the "info tasks" command).  This is very
similar to the thread-specific breakpoints both in implementation
and user interface.

Here is what it looks like from the CLI:

    (gdb) info tasks
      ID       TID P-ID Pri State                  Name
    *  1    640010    0  48 Running                main_task
       2    640d00    1  48 Accept or Select Term  keyboard1
       3    644320    1  48 Accept or Select Term  keyboard2

Task IDs are on the left hand side. So insert a breakpoint that stops
only when task 2 hits it, the user would use the "task" keyword
after the breakpoint location:

    (gdb) break tasks.adb:13 task 2
    Breakpoint 3 at 0x403195: file tasks.adb, line 13. (2 locations)

Resuming the execution should stop on our breakpoint iff task 2
hits it. This is verified by doing another "info tasks" after
hitting the breakpoint:

    (gdb) continue
    [...]
    (gdb) info tasks
      ID       TID P-ID Pri State                  Name
       1    640010    0  48 Waiting on RV with 2   main_task
    *  2    640d00    1  48 Accepting RV with 1    keyboard1
       3    644320    1  48 Accept or Select Term  keyboard2

The "*" marker shows that the task on which we stopped is indeed
task 2 :).

The reason why I'm posting this as an RFC is that, although
the implementation is pretty straightforward, for some reason,
I find it a bit inelegant. Having two integers which are pretty
much mutually exclusive sounds pretty bad to me. But, on the other
hand, I didn't really find anything that is that much better.

One possibility that I envisioned was to avoid storing the thread/
task ID, but store the associated ptid instead. Then, the part
of the code that checks whether the right thread/task can be merged
together. But then we need an extra enum that allows us to remember
whether the breakpoint was task-specific, or thread-specific. We need
that piece of information when displaying the list of breakopints:

    (gdb) info breakpoints 
    Num     Type           Disp Enb Address            What
    2       breakpoint     keep y   0x0000000000403472 in task_switch.break_me
                                                   at task_switch.adb:43 task 3

(we print "task TASK_NO" in the "what" column).

I'm not completely sure this is worth it or not. For now, here is
the code as we've implemented many many moons ago at AdaCore. It
gets the job done, and I don't feel like it's too invasive. If
you guys think the idea above, or any other suggestion, is worth
a shot, let me know.

Once we converge on a solution, I'll provide doc updates, a testcase,
and we'll also probably need to look at extending MI.

Thoughts?

Thanks,
-- 
Joel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: task-specific-breakpoint.diff
Type: text/x-diff
Size: 7678 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20090324/eee65443/attachment.bin>


More information about the Gdb-patches mailing list