A personal way to get thread information is to use get_thread_area() . On the get_thread_area() man page:
get_thread_area() returns a record in the current thread of the Thread Local Storage (TLS) array. The record index corresponds to the value u_info->entry_number passed by the user. If the value is within the bounds, get_thread_area() copies the corresponding TLS record to the area pointed to by u_info .
But, if you want to read the value of the register, you need to use the built-in assembly. For example, to get the esp value, you can use the following built-in assembly:
unsigned sp; __asm __volatile("movl %%esp, %0" : "=r" (sp)); return sp;
This way you can extract ebp , eip , etc. Hope this helps!
source share