public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Toward multicore GDB - Set theory
@ 2011-11-02  0:04 Stan Shebs
  2011-11-03 21:01 ` Tom Tromey
  0 siblings, 1 reply; 9+ messages in thread
From: Stan Shebs @ 2011-11-02  0:04 UTC (permalink / raw)
  To: gdb

In a program with hundreds or even thousands of threads, the user cannot 
be effective with the two options that GDB currently provides - work 
with one thread, or all of them at once.

This was anticipated some years ago in the discussions of the HPD forum 
that Michael Snyder and I participated in.  The resulting spec 
introduced the concept of the process/thread set (see 
http://sourceware.org/frysk/documentation/hpd.html), which was 
implemented in the TotalView debugger 
(http://www.roguewave.com/support/product-documentation/totalview-family.aspx#totalview 
for the user manual).  We extend sets to include cores, about which more 
in a moment.

The basic idea is simple; a p/t set is just a set of processes and 
threads.  We introduce a notation that allows us to construct sets, 
where <process>.<thread> refers to a particular thread of a process, and 
the two components can be elided, wildcarded, etc.  So we would have 
things like [4523,16493] for a set of two processes, [4523.workerbee] 
for a particular named thread, [4523.1-7,*.8-15] for eight threads of 
one process plus all threads numbered 8 to 15 from any other process 
under our control, and so forth.

We then use set notation interesting with commands:

(gdb) [.7-80] print mytlsglob
$45 = [.8,16,32,64] 0xbadbad ; [.*] 0xfeedface

shows most threads with the same value for a variable, and a handful of 
threads with a different value.

Similarly, you could do selective stepping, in this case to step just 
four threads of a process:

(gdb) [.5-8] step
<misc output>
5: 45 foo() ...
6: 47 bar() ...
...
(gdb)

Similarly, the single-thread option for breakpoints will be generalized 
to sets.

Users will expect to be able to do all the usual set operations (union, 
intersection, negation), and to apply names to sets.  There needs to be 
a "focus" command that sets the default set of interest, applied to 
subsequent commands.

It should also be possible to define sets with predicates - [1245.*] can 
be thought of as having a predicate that is true for any thread of 
process 1245.  Additional predicates could be things like [1245.*future] 
for any thread not existing at the time the set is defined, or 
[1245.*suspended] for any thread that is not running at the moment.

Well, you say, all very interesting, but what does this have to with 
cores?  As a thread-like hardware resource, what really goes on with 
cores is assignment of processes and threads to cores.  So our idea is 
to add it as a sort of predicate-like annotation to p/t sets, yielding 
set descriptions like [4523.*@45], which designates all the threads of 
process 4523 that are currently assigned to core 45.

The astute reader will notice many holes.  In particular, I am not 
giving a formal definition of set syntax and how it fits into the CLI, 
because I want us to develop some consensus on what would work best.  
Key decisions to be made are:

1) square brackets? curly brackets? nothing at all?

2) prefix? postfix? both?

3) build in extensibility? or leave to Python somehow?

4) is there a better term than ptc set?

Set operations applied to execution control present some implementation 
challenges, and if you've been following Pedro's recent work, one of the 
goals is to remove the single-threaded all-or-nothing assumptions that 
have been in GDB's native support for a long time.  After that we expect 
to post a first version of ptc set support, and then the fun really begins!

Stan
stan@codesourcery.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-11-08 15:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-02  0:04 Toward multicore GDB - Set theory Stan Shebs
2011-11-03 21:01 ` Tom Tromey
2011-11-04 13:20   ` Pedro Alves
2011-11-07 17:38   ` Joel Brobecker
2011-11-08  1:14     ` Daniel Jacobowitz
2011-11-08  5:17   ` Matt Rice
2011-11-08 14:50     ` Pedro Alves
2011-11-08 15:04       ` Tom Tromey
2011-11-08 15:45         ` Pedro Alves

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).