29 Mar 2003 01:18
RFA: gdb linux nptl patch 1
J. Johnston <jjohnstn <at> redhat.com>
2003-03-29 00:18:58 GMT
2003-03-29 00:18:58 GMT
The following is the first of a set of proposed patches for gdb to support the new nptl threading model for linux. In the old linuxthreads model, the lwp was equal to the pid. In the new nptl model, the lwp is unique for each thread and the pid value is common among sibling threads. A side-effect of this difference is that with linuxthreads, you could see individual threads externally on the ps list. With the new nptl kernel, you will not be able to see child thread lwps on the list. Another key difference is how a tid is represented. In the linuxthreads model, a tid was an index into a table and was restricted to 16-bits. In the new nptl model, there is no such restriction on the number of threads and the tid is in fact an address (i.e. not 16 bits). In the current linux-proc.c logic, when performing a gcore command, pr_status note information is created by taking the pid and concatenating this to the tid to form a 32-bit construct. Obviously, in the new nptl model this won't work as the tid itself is either 32-bits or 64-bits. It should also be mentioned that this logic does not match what the kernel spits out in a corefile. For linuxthreads, the kernel is just putting the lwp = pid in the pr_status notes. Logic that works for either model and matches what the kernel is doing is to use the lwp and only the lwp in the pr_status notes. This creates a slight problem because linux-proc.c uses the thread_info list to run through all the threads. Unfortunately, the thread_info list contains ptid_t structs that contain the pid and the tid, but no lwp. In the old linuxthreads model, this isn't a problem because the pid is in fact equal to the lwp. In the nptl model, we can't simply convert a pid/tid combination into its associated lwp because this logic is hidden in libthread_db. At present, the libthread_db library is only loaded by the thread-db layer. While there are routines to convert a tid to lwp and vice-versa, these routines are not externally exposed(Continue reading)
Jason, got a machine to test this on? Or should this be assumed to work?
Andrew
RSS Feed