Barry Song <21cn...@gmail.com> wrote:

> So my questions are:
>
> 1.   Should I compile the native gdb using android toolchain and android
> bionic/libthread libraries?
> 2.   Why can’t the current gdb capture multithreads for android
> processes? This question is actually about the theory for gdb to know
> multi-threads. In my opinion, both gnu and android use clone() to fork
> threads and threads in one process have same tgid in kernel and all
> threads return same getpid() value. Why not gdb just travel process
> lists to find multi-threads?

I'm not sure what exactly is going on on Android with bionic.  However,
GDB currently does require support from the thread library in order to
debug multi-threaded applications.  This is needed e.g. to properly
handle thread-local storage variables.  GDB will also use this support
to detect threads of a running process it is attaching to.

(It is true that GDB *could* e.g. look at /proc to find threads, instead
of inspecting thread library data structures.  However, since the link
to those data structures is required anyway, e.g. for TLS, this has not
been implemented so far ...)

When using glibc's libpthread, the support routines gdb uses to inspect
target thread library datastructures are provided in libthread_db.so.1
(which comes with glibc, and is linked into gdb).  I do not know the
details on whether/how bionic provides a corresponding service.

However, from looking at the gdbserver sources provided with Android,
it seems there are some differences; in particular, there's this patch:

+/* Android doesn't have libthread_db.so.1, just libthread_db.so.  */
+#ifdef __ANDROID__
+#define LIBTHREAD_DB_SO "libthread_db.so"
+#endif
+

If libthread_db is named differently, this would explain why GDB is
unable to find and use it.


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  STSM, GNU compiler and toolchain for Linux on System z and Cell/B.E.
  IBM Deutschland Research & Development GmbH
  Vorsitzende des Aufsichtsrats: Martina Koederitz | Geschäftsführung: Dirk
Wittkopp
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht
Stuttgart, HRB 243294
_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to