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 ?
Use the "info threads" command to see the IDs of currently known threads. The GDB thread debugging facility allows you to observe all threads while your program runs--but whenever GDB takes control, one thread in particular is always the focus of debugging. This thread is called the current thread.
In the GNU C Library implementation running on Linux, the process ID is the thread group ID of all threads in the process. You can get the process ID of a process by calling getpid . The function getppid returns the process ID of the parent of the current process (this is also known as the parent process ID).
In some threads implementations, the thread ID is a 4-byte integer that starts at 1 and increases by 1 every time a thread is created. This integer can be used in a non-portable fashion by an application.
Thread Id is a long positive integer that is created when the thread was created. During the entire lifecycle of a thread, the thread ID is unique and remains unchanged. It can be reused when the thread is terminated.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With