OLD | NEW |
1 /* libthread_db assisted debugging support, generic parts. | 1 /* libthread_db assisted debugging support, generic parts. |
2 | 2 |
3 Copyright (C) 1999-2001, 2003-2012 Free Software Foundation, Inc. | 3 Copyright (C) 1999-2001, 2003-2012 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GDB. | 5 This file is part of GDB. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "symfile.h" | 33 #include "symfile.h" |
34 #include "objfiles.h" | 34 #include "objfiles.h" |
35 #include "target.h" | 35 #include "target.h" |
36 #include "regcache.h" | 36 #include "regcache.h" |
37 #include "solib.h" | 37 #include "solib.h" |
38 #include "solib-svr4.h" | 38 #include "solib-svr4.h" |
39 #include "gdbcore.h" | 39 #include "gdbcore.h" |
40 #include "observer.h" | 40 #include "observer.h" |
41 #include "linux-nat.h" | 41 #include "linux-nat.h" |
42 #include "linux-procfs.h" | 42 #include "linux-procfs.h" |
| 43 #include "linux-osdata.h" |
| 44 #include "auto-load.h" |
43 | 45 |
44 #include <signal.h> | 46 #include <signal.h> |
45 | 47 #include <ctype.h> |
46 #ifdef HAVE_GNU_LIBC_VERSION_H | |
47 #include <gnu/libc-version.h> | |
48 #endif | |
49 | 48 |
50 /* GNU/Linux libthread_db support. | 49 /* GNU/Linux libthread_db support. |
51 | 50 |
52 libthread_db is a library, provided along with libpthread.so, which | 51 libthread_db is a library, provided along with libpthread.so, which |
53 exposes the internals of the thread library to a debugger. It | 52 exposes the internals of the thread library to a debugger. It |
54 allows GDB to find existing threads, new threads as they are | 53 allows GDB to find existing threads, new threads as they are |
55 created, thread IDs (usually, the result of pthread_self), and | 54 created, thread IDs (usually, the result of pthread_self), and |
56 thread-local variables. | 55 thread-local variables. |
57 | 56 |
58 The libthread_db interface originates on Solaris, where it is | 57 The libthread_db interface originates on Solaris, where it is |
59 both more powerful and more complicated. This implementation | 58 both more powerful and more complicated. This implementation |
60 only works for LinuxThreads and NPTL, the two glibc threading | 59 only works for LinuxThreads and NPTL, the two glibc threading |
61 libraries. It assumes that each thread is permanently assigned | 60 libraries. It assumes that each thread is permanently assigned |
62 to a single light-weight process (LWP). | 61 to a single light-weight process (LWP). |
63 | 62 |
64 libthread_db-specific information is stored in the "private" field | 63 libthread_db-specific information is stored in the "private" field |
65 of struct thread_info. When the field is NULL we do not yet have | 64 of struct thread_info. When the field is NULL we do not yet have |
66 information about the new thread; this could be temporary (created, | 65 information about the new thread; this could be temporary (created, |
67 but the thread library's data structures do not reflect it yet) | 66 but the thread library's data structures do not reflect it yet) |
68 or permanent (created using clone instead of pthread_create). | 67 or permanent (created using clone instead of pthread_create). |
69 | 68 |
70 Process IDs managed by linux-thread-db.c match those used by | 69 Process IDs managed by linux-thread-db.c match those used by |
71 linux-nat.c: a common PID for all processes, an LWP ID for each | 70 linux-nat.c: a common PID for all processes, an LWP ID for each |
72 thread, and no TID. We save the TID in private. Keeping it out | 71 thread, and no TID. We save the TID in private. Keeping it out |
73 of the ptid_t prevents thread IDs changing when libpthread is | 72 of the ptid_t prevents thread IDs changing when libpthread is |
74 loaded or unloaded. */ | 73 loaded or unloaded. */ |
75 | 74 |
76 static char *libthread_db_search_path; | 75 static char *libthread_db_search_path; |
77 | 76 |
| 77 /* Set to non-zero if thread_db auto-loading is enabled |
| 78 by the "set auto-load libthread-db" command. */ |
| 79 static int auto_load_thread_db = 1; |
| 80 |
| 81 /* "show" command for the auto_load_thread_db configuration variable. */ |
| 82 |
| 83 static void |
| 84 show_auto_load_thread_db (struct ui_file *file, int from_tty, |
| 85 struct cmd_list_element *c, const char *value) |
| 86 { |
| 87 fprintf_filtered (file, _("Auto-loading of inferior specific libthread_db " |
| 88 "is %s.\n"), |
| 89 value); |
| 90 } |
| 91 |
78 static void | 92 static void |
79 set_libthread_db_search_path (char *ignored, int from_tty, | 93 set_libthread_db_search_path (char *ignored, int from_tty, |
80 struct cmd_list_element *c) | 94 struct cmd_list_element *c) |
81 { | 95 { |
82 if (*libthread_db_search_path == '\0') | 96 if (*libthread_db_search_path == '\0') |
83 { | 97 { |
84 xfree (libthread_db_search_path); | 98 xfree (libthread_db_search_path); |
85 libthread_db_search_path = xstrdup (LIBTHREAD_DB_SEARCH_PATH); | 99 libthread_db_search_path = xstrdup (LIBTHREAD_DB_SEARCH_PATH); |
86 } | 100 } |
87 } | 101 } |
(...skipping 24 matching lines...) Expand all Loading... |
112 struct thread_db_info | 126 struct thread_db_info |
113 { | 127 { |
114 struct thread_db_info *next; | 128 struct thread_db_info *next; |
115 | 129 |
116 /* Process id this object refers to. */ | 130 /* Process id this object refers to. */ |
117 int pid; | 131 int pid; |
118 | 132 |
119 /* Handle from dlopen for libthread_db.so. */ | 133 /* Handle from dlopen for libthread_db.so. */ |
120 void *handle; | 134 void *handle; |
121 | 135 |
| 136 /* Absolute pathname from gdb_realpath to disk file used for dlopen-ing |
| 137 HANDLE. It may be NULL for system library. */ |
| 138 char *filename; |
| 139 |
122 /* Structure that identifies the child process for the | 140 /* Structure that identifies the child process for the |
123 <proc_service.h> interface. */ | 141 <proc_service.h> interface. */ |
124 struct ps_prochandle proc_handle; | 142 struct ps_prochandle proc_handle; |
125 | 143 |
126 /* Connection to the libthread_db library. */ | 144 /* Connection to the libthread_db library. */ |
127 td_thragent_t *thread_agent; | 145 td_thragent_t *thread_agent; |
128 | 146 |
129 /* True if we need to apply the workaround for glibc/BZ5983. When | 147 /* True if we need to apply the workaround for glibc/BZ5983. When |
130 we catch a PTRACE_O_TRACEFORK, and go query the child's thread | 148 we catch a PTRACE_O_TRACEFORK, and go query the child's thread |
131 list, nptl_db returns the parent's threads in addition to the new | 149 list, nptl_db returns the parent's threads in addition to the new |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 for (info = thread_db_list; info; info_prev = info, info = info->next) | 259 for (info = thread_db_list; info; info_prev = info, info = info->next) |
242 if (pid == info->pid) | 260 if (pid == info->pid) |
243 break; | 261 break; |
244 | 262 |
245 if (info == NULL) | 263 if (info == NULL) |
246 return; | 264 return; |
247 | 265 |
248 if (info->handle != NULL) | 266 if (info->handle != NULL) |
249 dlclose (info->handle); | 267 dlclose (info->handle); |
250 | 268 |
| 269 xfree (info->filename); |
| 270 |
251 if (info_prev) | 271 if (info_prev) |
252 info_prev->next = info->next; | 272 info_prev->next = info->next; |
253 else | 273 else |
254 thread_db_list = info->next; | 274 thread_db_list = info->next; |
255 | 275 |
256 xfree (info); | 276 xfree (info); |
257 } | 277 } |
258 | 278 |
259 /* Prototypes for local functions. */ | 279 /* Prototypes for local functions. */ |
260 static int attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, | 280 static int attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 err = info->td_ta_event_addr_p (info->thread_agent, event, ¬ify); | 562 err = info->td_ta_event_addr_p (info->thread_agent, event, ¬ify); |
543 if (err != TD_OK) | 563 if (err != TD_OK) |
544 return err; | 564 return err; |
545 | 565 |
546 /* Set up the breakpoint. */ | 566 /* Set up the breakpoint. */ |
547 gdb_assert (exec_bfd); | 567 gdb_assert (exec_bfd); |
548 (*bp) = (gdbarch_convert_from_func_ptr_addr | 568 (*bp) = (gdbarch_convert_from_func_ptr_addr |
549 (target_gdbarch, | 569 (target_gdbarch, |
550 /* Do proper sign extension for the target. */ | 570 /* Do proper sign extension for the target. */ |
551 (bfd_get_sign_extend_vma (exec_bfd) > 0 | 571 (bfd_get_sign_extend_vma (exec_bfd) > 0 |
error: old chunk mismatch |
None
OLD | NEW |