palves / gdb Goto Github PK
View Code? Open in Web Editor NEWSome of Pedro Alves's in-progress GDB work. See Wiki for more info.
Home Page: https://github.com/palves/gdb/wiki
License: GNU General Public License v2.0
Some of Pedro Alves's in-progress GDB work. See Wiki for more info.
Home Page: https://github.com/palves/gdb/wiki
License: GNU General Public License v2.0
The thread id displayed by itset which (the part after the dot) is not good.
(gdb) itset which
Thread 1.1 (Thread 0x7ffff7fc5740 (LWP 13508)) is in: all, stopped, L
Thread 1.2 (Thread 0x7ffff77f6700 (LWP 13512)) is in: all, stopped
Thread 1.3 (Thread 0x7ffff6ff5700 (LWP 13513)) is in: all, stopped
Thread 1.4 (Thread 0x7ffff67f4700 (LWP 13514)) is in: all, stopped
Thread 1.5 (Thread 0x7ffff5ff3700 (LWP 13515)) is in: all, stopped
Thread 2.6 (Thread 0x7ffff7fc5740 (LWP 13516)) is in: all, stopped, I, L
Thread 2.7 (Thread 0x7ffff77f6700 (LWP 13517)) is in: all, stopped, I
Thread 2.8 (Thread 0x7ffff6ff5700 (LWP 13518)) is in: all, stopped, I
Thread 2.9 (Thread 0x7ffff67f4700 (LWP 13519)) is in: all, stopped, I
Thread 2.10 (Thread 0x7ffff5ff3700 (LWP 13520)) is in: all, stopped, I
(gdb) i th
Id Target Id Frame
1.1 1 Thread 0x7ffff7fc5740 (LWP 13508) "threads" all_threads_started () at threads.c:32
1.2 2 Thread 0x7ffff77f6700 (LWP 13512) "threads" 0x00007ffff7bc923c in pthread_barrier_wait () from /lib/x86_64-linux-gnu/libpthread.so.0
1.3 3 Thread 0x7ffff6ff5700 (LWP 13513) "threads" 0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
1.4 4 Thread 0x7ffff67f4700 (LWP 13514) "threads" 0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
1.5 5 Thread 0x7ffff5ff3700 (LWP 13515) "threads" 0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
* 2.1 6 Thread 0x7ffff7fc5740 (LWP 13516) "threads" all_threads_started () at threads.c:32
2.2 7 Thread 0x7ffff77f6700 (LWP 13517) "threads" 0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
2.3 8 Thread 0x7ffff6ff5700 (LWP 13518) "threads" 0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
2.4 9 Thread 0x7ffff67f4700 (LWP 13519) "threads" 0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
2.5 10 Thread 0x7ffff5ff3700 (LWP 13520) "threads" 0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
It's not possible to use in a spec a group that starts with a letter that means something special in the syntax.
(gdb) itset define group1 tt2.2,tt2.3
(gdb) itfocus group1
Unknown named I/T set: `roup1'
(gdb) itset define allo tt1.1
(gdb) itfocus allo
Unknown named I/T set: `llo'
(gdb) itset define indiana tt1.1
(gdb) itfocus indiana
Unknown named I/T set: `ndiana'
(gdb) itset define tarte tt1.1
(gdb) itfocus tarte
Unknown named I/T set: `arte'
There is an asymmetry between what is accepted by defset/itset define as a group name, and what the spec syntax accepts. We should reject names that aren't compatible with the syntax.
(gdb) itset define spatule-123 t1.1
(gdb) itset view
all contains:
inferiors: 1, 2
threads: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
cores: 0, 0, 0, 2, 3, 2, 1, 0, 2, 1
empty contains:
running contains:
inferiors: 1, 2
threads: 2, 3, 4, 5, 7, 8, 9, 10
cores: 0, 0, 2, 3, 1, 0, 2, 1
stopped contains:
inferiors: 1, 2
threads: 1, 6
cores: 0, 2
I contains:
threads: 6, 7, 8, 9, 10
cores: 2, 1, 0, 2, 1
T contains:
inferiors: 2
L contains:
inferiors: 1
threads: 1, 6
cores: 0, 2
spatule-123 contains:
inferiors: 1, 2
threads: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
cores: 0, 0, 0, 2, 3, 2, 1, 0, 2, 1
(gdb) itfocus spatule-123
Unknown named I/T set: `spatule'
So, we have a few threads:
(gdb) i th
Id Target Id Frame
* 1.1 Thread 0x7ffff7fc5740 (LWP 9277) "test_pthread" break_here () at test_pthread.c:112
1.2 Thread 0x7ffff77f6700 (LWP 9281) "test_pthread" 0x00007ffff7bcaf1c in __lll_lock_wait ()
from /lib/x86_64-linux-gnu/libpthread.so.0
1.3 Thread 0x7ffff6ff5700 (LWP 9282) "test_pthread" 0x00007ffff7bcaf1c in __lll_lock_wait ()
from /lib/x86_64-linux-gnu/libpthread.so.0
1.4 Thread 0x7ffff67f4700 (LWP 9283) "test_pthread" 0x00007ffff7bc923c in pthread_barrier_wait
() from /lib/x86_64-linux-gnu/libpthread.so.0
1.5 Thread 0x7ffff5ff3700 (LWP 9284) "test_pthread" 0x00007ffff7bc923c in pthread_barrier_wait
() from /lib/x86_64-linux-gnu/libpthread.so.0
1.6 Thread 0x7ffff57f2700 (LWP 9285) "test_pthread" 0x00007ffff7bc923c in pthread_barrier_wait
() from /lib/x86_64-linux-gnu/libpthread.so.0
1.7 Thread 0x7ffff4ff1700 (LWP 9286) "test_pthread" 0x00007ffff7bcaf1c in __lll_lock_wait ()
from /lib/x86_64-linux-gnu/libpthread.so.0
1.8 Thread 0x7ffff47f0700 (LWP 9287) "test_pthread" 0x00007ffff7bcaf1c in __lll_lock_wait ()
from /lib/x86_64-linux-gnu/libpthread.so.0
1.9 Thread 0x7ffff3fef700 (LWP 9288) "test_pthread" 0x00007ffff78460fb in ?? ()
from /lib/x86_64-linux-gnu/libc.so.6
And the current width is default:
(gdb) itfocus
Focus is `dt1.1'.
Current inferior is 1.
Current thread is 1.
I try to define a workers
set that contains two threads:
(gdb) itset define workers (t1.2,t1.3)
It ends up containing all the threads of inferior one:
(gdb) itset view
...
workers contains:
inferiors: 1
threads: 1, 2, 3, 4, 5, 6, 7, 8, 9
cores: 3, 2, 3, 1, 1, 1, 1, 3, 1
That's probably because the default width for that operation is the inferior (or all, I haven't tried with more than one inferior), something like that. When I set the width to thread:
(gdb) itfocus t itset define workers2 (t1.2,t1.3)
The set only contains the specified threads:
(gdb) itset view
...
workers contains:
inferiors: 1
threads: 1, 2, 3, 4, 5, 6, 7, 8, 9
cores: 3, 2, 3, 1, 1, 1, 1, 3, 1
workers2 contains:
inferiors: 1
threads: 2, 3
cores: 2, 3
Shouldn't the default width for the defset command be thread? It seems counter intuitive if it automatically includes more threads than the user specified.
$ ./gdb -nx -x script.gdb
with script.gdb:
set pagination off
file /bin/ls
add-inferior -exec /bin/ls
and then:
(gdb) itfocus a run
I am not sure exactly what the right behavior would be, but I see various bad things happening. Sometimes, gdb is stuck wait()
ing on something, with ctrl-C doing nothing. Other times, when one inferior manages to finish, we come back to the prompt and the other inferior/thread is stopped, with a borked stack. Trying to continue sometimes work, sometimes it leads to an infinite wait.
I don't know if I am not using it right, or if it's buggy, but here is how it goes. I use the following test case:
#include <stdio.h>
#include <pthread.h>
static pthread_barrier_t barrier;
void *t1_func(void *arg) {
int i;
pthread_barrier_wait (&barrier);
for (i = 0; i < 100; i++) {
sleep (1);
}
return NULL;
}
void *t2_func(void *arg) {
int i;
pthread_barrier_wait (&barrier);
for (i = 0; i < 100; i++) {
sleep (1);
}
return NULL;
}
void all_threads_started (void)
{
}
int main(int argc, char **argv) {
pthread_t t1, t2;
pthread_barrier_init (&barrier, NULL, 3);
pthread_create(&t1, NULL, t1_func, NULL);
pthread_create(&t2, NULL, t2_func, NULL);
pthread_barrier_wait (&barrier);
all_threads_started ();
pthread_join(t1, NULL);
pthread_join(t2, NULL);
return 0;
}
I start gdb with:
$ ./gdb -nx threads -ex "b all_threads_started" -ex r
Once there, I want to set a breakpoint in the thread 1's (t1.2) code that will only interrupt thread 2 (t1.3).
(gdb) itfocus tt1.2 break -suspend tt1.3 threads.c:12
Breakpoint 2 at 0x40076c: file threads.c, line 12.
(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000004007cf in all_threads_started at threads.c:32
trigger only in: at1.1
suspend all of: at*.*
breakpoint already hit 1 time
2 breakpoint keep y 0x000000000040076c in t1_func at threads.c:12
trigger only in: tt1.2
suspend all of: tt1.3
So far this looks good, breakpoint 2 will only get triggered by thread 1.2 and will only suspend thread 1.3. I continue:
(gdb) c
Continuing.
[Switching to Thread 0x7ffff77f6700 (LWP 31988)]
Breakpoint 2, t1_func (arg=0x0) at threads.c:12
12 sleep (1);
(gdb) i th
Id Target Id Frame
1.1 Thread 0x7ffff7fc5740 (LWP 31984) "threads" (running)
* 1.2 Thread 0x7ffff77f6700 (LWP 31988) "threads" t1_func (arg=0x0) at threads.c:12
1.3 Thread 0x7ffff6ff5700 (LWP 31989) "threads" 0x00007ffff78b7dfd in nanosleep ()
from /lib/x86_64-linux-gnu/libc.so.6
Thread 1.3 is interrupted somewhere in its sleep, which is expected, but thread 1.2 was stopped as well, which is unexpected.
If I try in non-stop instead:
$ ./gdb -nx threads -ex "set non-stop on" -ex "b all_threads_started" -ex r
depending on whether I stop the threads before inserting the breakpoints, I get two different results:
(gdb) i th
Id Target Id Frame
* 1.1 Thread 0x7ffff7fc5740 (LWP 32591) "threads" all_threads_started () at threads.c:32
1.2 Thread 0x7ffff77f6700 (LWP 32595) "threads" (running)
1.3 Thread 0x7ffff6ff5700 (LWP 32596) "threads" (running)
(gdb) itfocus tt1.2 break -suspend tt1.3 threads.c:12
Breakpoint 2 at 0x40076c: file threads.c, line 12.
(gdb)
Breakpoint 2, t1_func (arg=0x0) at threads.c:12
12 sleep (1);
i th
Id Target Id Frame
* 1.1 Thread 0x7ffff7fc5740 (LWP 32591) "threads" all_threads_started () at threads.c:32
1.2 Thread 0x7ffff77f6700 (LWP 32595) "threads" t1_func (arg=0x0) at threads.c:12
1.3 Thread 0x7ffff6ff5700 (LWP 32596) "threads" (running)
t1.2 was stopped, whereas we would have expected thread 1.3 to stop. Thread 1.1 is still stopped, which is fine because I haven't told it to resume.
And:
(gdb) interrupt -a
(gdb)
[Thread 0x7ffff77f6700 (LWP 401)] #2 stopped.
0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
[Thread 0x7ffff6ff5700 (LWP 402)] #3 stopped.
0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
i th
Id Target Id Frame
* 1.1 Thread 0x7ffff7fc5740 (LWP 397) "threads" all_threads_started () at threads.c:32
1.2 Thread 0x7ffff77f6700 (LWP 401) "threads" 0x00007ffff78b7dfd in nanosleep ()
from /lib/x86_64-linux-gnu/libc.so.6
1.3 Thread 0x7ffff6ff5700 (LWP 402) "threads" 0x00007ffff78b7dfd in nanosleep ()
from /lib/x86_64-linux-gnu/libc.so.6
(gdb) itfocus tt1.2 break -suspend tt1.3 threads.c:12
Breakpoint 2 at 0x40076c: file threads.c, line 12.
(gdb) c -a &
Continuing.
We would expect a stop of thread 1.3, but nothing stops. The info breakpoint still shows the correct information:
(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000004007cf in all_threads_started at threads.c:32
trigger only in: at1.1
suspend all of:
breakpoint already hit 1 time
2 breakpoint keep y 0x000000000040076c in t1_func at threads.c:12
trigger only in: tt1.2
suspend all of: tt1.3
While itfocusing two threads, interrupt, continue and interrupt again.
(gdb) status
Id Target Id Status
1 (process 17081) [/home/emaisin/build/binutils-gdb-itsets/gdb/threads]
1.1 Thread 0x7ffff7fc5740 (LWP 17081) "threads" all_threads_started () at threads.c:32
1.2 Thread 0x7ffff77f6700 (LWP 17085) "threads" (running)
1.3 Thread 0x7ffff6ff5700 (LWP 17086) "threads" (running)
1.4 Thread 0x7ffff67f4700 (LWP 17087) "threads" (running)
1.5 Thread 0x7ffff5ff3700 (LWP 17088) "threads" (running)
2 (process 17089) [/home/emaisin/build/binutils-gdb-itsets/gdb/threads]
* 2.1 Thread 0x7ffff7fc5740 (LWP 17089) "threads" all_threads_started () at threads.c:32
2.2 Thread 0x7ffff77f6700 (LWP 17090) "threads" (running)
2.3 Thread 0x7ffff6ff5700 (LWP 17091) "threads" (running)
2.4 Thread 0x7ffff67f4700 (LWP 17092) "threads" (running)
2.5 Thread 0x7ffff5ff3700 (LWP 17093) "threads" (running)
(gdb) itfocus tt1.2,tt2.2
Focus is `tt1.2,tt2.2'.
Current inferior is 1.
Current thread is 2.
(gdb) interrupt
(gdb)
[Thread 0x7ffff77f6700 (LWP 17085)] #2 stopped.
0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
[Thread 0x7ffff77f6700 (LWP 17090)] #7 stopped.
0x00007ffff78b7dfd in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) status
Id Target Id Status
1 (process 17081) [/home/emaisin/build/binutils-gdb-itsets/gdb/threads]
* 1.2 Thread 0x7ffff77f6700 (LWP 17085) "threads" 0x00007ffff78b7dfd in nanosleep ()
from /lib/x86_64-linux-gnu/libc.so.6
2 (process 17089) [/home/emaisin/build/binutils-gdb-itsets/gdb/threads]
+ 2.2 Thread 0x7ffff77f6700 (LWP 17090) "threads" 0x00007ffff78b7dfd in nanosleep ()
from /lib/x86_64-linux-gnu/libc.so.6
(gdb) c &
Continuing.
(gdb) status
Id Target Id Status
1 (process 17081) [/home/emaisin/build/binutils-gdb-itsets/gdb/threads]
* 1.2 Thread 0x7ffff77f6700 (LWP 17085) "threads" (running)
2 (process 17089) [/home/emaisin/build/binutils-gdb-itsets/gdb/threads]
+ 2.2 Thread 0x7ffff77f6700 (LWP 17090) "threads" (running)
(gdb) interrupt
/home/emaisin/src/binutils-gdb/gdb/inline-frame.c:338: internal-error: skip_inline_frames: Assertion `find_inline_frame_state (ptid) == NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.