gdb for android target: getting pthread_t

Viewed 28

I have to debug a problem in portable code, that triggers on an android system. I have got logs and a core dump from the target system. Since the program uses multiple threads, I have to find specific threads, whose pthread_t is written to the log files.

Unfortunately (and in contrast to linux), the debugger does not show the pthread_t value for android targets:

  Id   Target Id         Frame
* 1    LWP 1820          0x0000e4ae2ef5fd2c in syscall () from /home/.../libc.so
  2    LWP 2374          0x0000e4ae2ef5fd2c in syscall () from /home/.../libc.so
  3    LWP 2375          0x0000e4ae2ef5fd2c in syscall () from /home/.../libc.so
  4    LWP 2376          0x0000e4ae2ef5fd2c in syscall () from /home/.../libc.so

Does anybody know how to get the pthread_t for these threads?

This is, what gdb prints on the native linux target, where the pthread_t is printed:

(gdb) info threads
  Id   Target Id                         Frame
* 1    Thread 0x7f50c7e28640 (LWP 18837) 0x00007f50c86b882c in __pthread_kill_implementation () from /lib64/libc.so.6
  2    Thread 0x7f50c862a740 (LWP 18835) 0x00007f50c86b37ea in __futex_abstimed_wait_common () from /lib64/libc.so.6
  3    Thread 0x7f50c8629640 (LWP 18836) 0x00007f50c8700565 in clock_nanosleep () from /lib64/libc.so.6
(gdb)

73, Mario

P.S. I tried gdb 7.11 from android NDK as well as gdb-11.2 built from source for target aarch64-linux-android

PP.S. I disassembled pthread_self():

(gdb) disassemble pthread_self
Dump of assembler code for function pthread_self:
   0x0000e4ae2efc65f0 <+0>:     mrs     x8, tpidr_el0
   0x0000e4ae2efc65f4 <+4>:     cbz     x8, 0xe4ae2efc6600 <pthread_self+16>
   0x0000e4ae2efc65f8 <+8>:     ldr     x0, [x8, #8]
   0x0000e4ae2efc65fc <+12>:    ret
   0x0000e4ae2efc6600 <+16>:    mov     x0, xzr
   0x0000e4ae2efc6604 <+20>:    ret
End of assembler dump.

but printing the tpidr_el0 register is not that easy in gdb:

(gdb) print $tpidr_el0
$2 = void
(gdb)
0 Answers
Related