6

I am trying to debug an application written in c++, compiled for an ARM based processor running linux.

When the application intermittently crashes, it stops at a certain thread and I assume that thread is where is the fault is (segmentation fault).

My problem is, I am having trouble identifying WHAT this thread is. I see that the following printed in eclipse when GDB is running.

What are the numbers underlined in blue and is there a way for me to access them programmatically, so that I know where to look in the code ?

enter image description here

Heshan Perera
  • 4,592
  • 8
  • 44
  • 57

3 Answers3

4

In addition to @Heshan Perera answer.

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

UNIX:

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

WINDOWS: (Not tested)

#include <windows.h>
GetCurrentThreadId();
Community
  • 1
  • 1
WaeCo
  • 1,155
  • 1
  • 10
  • 21
0

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

Heshan Perera
  • 4,592
  • 8
  • 44
  • 57
0

A better solution, if you're on Linux/gcc, is to actually give a descriptive name to the thread with pthread_setname_np. gdb will then use this name when hitting breakpoints, and so on. Note that this is a GNU extension to pthreads.

EML
  • 9,619
  • 6
  • 46
  • 78