How to programmatically identify a stream identifier printed in GDB

I am trying to debug an application written in C ++ compiled for an ARM based processor using linux.

When the application is interrupted, it stops in a specific thread, and I assume that the thread is where the segmentation fault is.

My problem is that I am having problems defining WHAT this thread. I see that after GDB is launched, it is printed in an eclipse.

What are the numbers underlined in blue, and do I have access to them programmatically so that I know where to look for the code?

enter image description here

+5
source share
3 answers

In addition to @Heshan Perera, answer.

You can also access the thread id, which is a large number, inside your program

UNIX:

#include <sys/syscall.h> syscall(SYS_gettid); 

WINDOWS: (not verified)

 #include <windows.h> GetCurrentThreadId(); 
+2
source

Based on this link posted by @Selcuk Cihan in the comment above, the first number in square brackets is the integer assigned by GDB itself and the other is the SysTag assigned to the stream.

0
source

The best solution, if you are using Linux / gcc, should actually give a descriptive name to the stream with pthread_setname_np , then gdb will use that name when hitting breakpoints, etc. Please note that this is the GNU extension for pthreads.

0
source

All Articles