GDB (xrefs)

/tmp/gdb-8.1/gdb/bsd-uthread.c
Go to the documentation of this file.
1 /* BSD user-level threads support.
2
3 Copyright (C) 2005-2018 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21 #include "gdbcore.h"
22 #include "gdbthread.h"
23 #include "inferior.h"
24 #include "objfiles.h"
25 #include "observer.h"
26 #include "regcache.h"
27 #include "solib.h"
28 #include "solist.h"
29 #include "symfile.h"
30 #include "target.h"
31
32 #include "gdb_obstack.h"
33
34 #include "bsd-uthread.h"
35
36 /* HACK: Save the bsd_uthreads ops returned by bsd_uthread_target. */
37 static struct target_ops *bsd_uthread_ops_hack;
38
39
40 /* Architecture-specific operations. */
41
42 /* Per-architecture data key. */
43 static struct gdbarch_data *bsd_uthread_data;
44
45 struct bsd_uthread_ops
46 {
47 /* Supply registers for an inactive thread to a register cache. */
48 void (*supply_uthread)(struct regcache *, int, CORE_ADDR);
49
50 /* Collect registers for an inactive thread from a register cache. */
51 void (*collect_uthread)(const struct regcache *, int, CORE_ADDR);
52 };
53
54 static void *
55 bsd_uthread_init (struct obstack *obstack)
56 {
57 struct bsd_uthread_ops *ops;
58
59 ops = OBSTACK_ZALLOC (obstack, struct bsd_uthread_ops);
60 return ops;
61 }
62
63 /* Set the function that supplies registers from an inactive thread
64 for architecture GDBARCH to SUPPLY_UTHREAD. */
65
66 void
67 bsd_uthread_set_supply_uthread (struct gdbarch *gdbarch,
68 void (*supply_uthread) (struct regcache *,
69 int, CORE_ADDR))
70 {
71 struct bsd_uthread_ops *ops
72 = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
73
74 ops->supply_uthread = supply_uthread;
75 }
76
77 /* Set the function that collects registers for an inactive thread for
78 architecture GDBARCH to SUPPLY_UTHREAD. */
79
80 void
81 bsd_uthread_set_collect_uthread (struct gdbarch *gdbarch,
82 void (*collect_uthread) (const struct regcache *,
83 int, CORE_ADDR))
84 {
85 struct bsd_uthread_ops *ops
86 = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
87
88 ops->collect_uthread = collect_uthread;
89 }
90
91 /* Magic number to help recognize a valid thread structure. */
92 #define BSD_UTHREAD_PTHREAD_MAGIC 0xd09ba115
93
94 /* Check whether the thread structure at ADDR is valid. */
95
96 static void
97 bsd_uthread_check_magic (CORE_ADDR addr)
98 {
99 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
100 ULONGEST magic = read_memory_unsigned_integer (addr, 4, byte_order);
101
102 if (magic != BSD_UTHREAD_PTHREAD_MAGIC)
103 error (_("Bad magic"));
104 }
105
106 /* Thread states. */
107 #define BSD_UTHREAD_PS_RUNNING 0
108 #define BSD_UTHREAD_PS_DEAD 18
109
110 /* Address of the pointer to the thread structure for the running
111 thread. */
112 static CORE_ADDR bsd_uthread_thread_run_addr;
113
114 /* Address of the list of all threads. */
115 static CORE_ADDR bsd_uthread_thread_list_addr;
116
117 /* Offsets of various "interesting" bits in the thread structure. */
118 static int bsd_uthread_thread_state_offset = -1;
119 static int bsd_uthread_thread_next_offset = -1;
120 static int bsd_uthread_thread_ctx_offset;
121
122 /* Name of shared threads library. */
123 static const char *bsd_uthread_solib_name;
124
125 /* Non-zero if the thread startum implemented by this module is active. */
126 static int bsd_uthread_active;
127
128 static CORE_ADDR
129 bsd_uthread_lookup_address (const char *name, struct objfile *objfile)
130 {
131 struct bound_minimal_symbol sym;
132
133 sym = lookup_minimal_symbol (name, NULL, objfile);
134 if (sym.minsym)
135 return BMSYMBOL_VALUE_ADDRESS (sym);
136
137 return 0;
138 }
139
140 static int
141 bsd_uthread_lookup_offset (const char *name, struct objfile *objfile)
142 {
143 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
144 CORE_ADDR addr;
145
146 addr = bsd_uthread_lookup_address (name, objfile);
147 if (addr == 0)
148 return 0;
149
150 return read_memory_unsigned_integer (addr, 4, byte_order);
151 }
152
153 static CORE_ADDR
154 bsd_uthread_read_memory_address (CORE_ADDR addr)
155 {
156 struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
157 return read_memory_typed_address (addr, ptr_type);
158 }
159
160 /* If OBJFILE contains the symbols corresponding to one of the
161 supported user-level threads libraries, activate the thread stratum
162 implemented by this module. */
163
164 static int
165 bsd_uthread_activate (struct objfile *objfile)
166 {
167 struct gdbarch *gdbarch = target_gdbarch ();
168 struct bsd_uthread_ops *ops
169 = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
170
171 /* Skip if the thread stratum has already been activated. */
172 if (bsd_uthread_active)
173 return 0;
174
175 /* There's no point in enabling this module if no
176 architecture-specific operations are provided. */
177 if (!ops->supply_uthread)
178 return 0;
179
180 bsd_uthread_thread_run_addr =
181 bsd_uthread_lookup_address ("_thread_run", objfile);
182 if (bsd_uthread_thread_run_addr == 0)
183 return 0;
184
185 bsd_uthread_thread_list_addr =
186 bsd_uthread_lookup_address ("_thread_list", objfile);
187 if (bsd_uthread_thread_list_addr == 0)
188 return 0;
189
190 bsd_uthread_thread_state_offset =
191 bsd_uthread_lookup_offset ("_thread_state_offset", objfile);
192 if (bsd_uthread_thread_state_offset == 0)
193 return 0;
194
195 bsd_uthread_thread_next_offset =
196 bsd_uthread_lookup_offset ("_thread_next_offset", objfile);
197 if (bsd_uthread_thread_next_offset == 0)
198 return 0;
199
200 bsd_uthread_thread_ctx_offset =
201 bsd_uthread_lookup_offset ("_thread_ctx_offset", objfile);
202
203 push_target (bsd_uthread_ops_hack);
204 bsd_uthread_active = 1;
205 return 1;
206 }
207
208 /* Cleanup due to deactivation. */
209
210 static void
211 bsd_uthread_close (struct target_ops *self)
212 {
213 bsd_uthread_active = 0;
214 bsd_uthread_thread_run_addr = 0;
215 bsd_uthread_thread_list_addr = 0;
216 bsd_uthread_thread_state_offset = 0;
217 bsd_uthread_thread_next_offset = 0;
218 bsd_uthread_thread_ctx_offset = 0;
219 bsd_uthread_solib_name = NULL;
220 }
221
222 /* Deactivate the thread stratum implemented by this module. */
223
224 static void
225 bsd_uthread_deactivate (void)
226 {
227 /* Skip if the thread stratum has already been deactivated. */
228 if (!bsd_uthread_active)
229 return;
230
231 unpush_target (bsd_uthread_ops_hack);
232 }
233
234 static void
235 bsd_uthread_inferior_created (struct target_ops *ops, int from_tty)
236 {
237 bsd_uthread_activate (NULL);
238 }
239
240 /* Likely candidates for the threads library. */
241 static const char *bsd_uthread_solib_names[] =
242 {
243 "/usr/lib/libc_r.so", /* FreeBSD */
244 "/usr/lib/libpthread.so", /* OpenBSD */
245 NULL
246 };
247
248 static void
249 bsd_uthread_solib_loaded (struct so_list *so)
250 {
251 const char **names = bsd_uthread_solib_names;
252
253 for (names = bsd_uthread_solib_names; *names; names++)
254 {
255 if (startswith (so->so_original_name, *names))
256 {
257 solib_read_symbols (so, 0);
258
259 if (bsd_uthread_activate (so->objfile))
260 {
261 bsd_uthread_solib_name = so->so_original_name;
262 return;
263 }
264 }
265 }
266 }
267
268 static void
269 bsd_uthread_solib_unloaded (struct so_list *so)
270 {
271 if (!bsd_uthread_solib_name)
272 return;
273
274 if (strcmp (so->so_original_name, bsd_uthread_solib_name) == 0)
275 bsd_uthread_deactivate ();
276 }
277
278 static void
279 bsd_uthread_mourn_inferior (struct target_ops *ops)
280 {
281 struct target_ops *beneath = find_target_beneath (ops);
282 beneath->to_mourn_inferior (beneath);
283 bsd_uthread_deactivate ();
284 }
285
286 static void
287 bsd_uthread_fetch_registers (struct target_ops *ops,
288 struct regcache *regcache, int regnum)
289 {
290 struct gdbarch *gdbarch = regcache->arch ();
291 struct bsd_uthread_ops *uthread_ops
292 = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
293 ptid_t ptid = regcache_get_ptid (regcache);
294 CORE_ADDR addr = ptid_get_tid (ptid);
295 struct target_ops *beneath = find_target_beneath (ops);
296 CORE_ADDR active_addr;
297 scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
298
299 /* We are doing operations (e.g. reading memory) that rely on
300 inferior_ptid. */
301 inferior_ptid = ptid;
302
303 /* Always fetch the appropriate registers from the layer beneath. */
304 beneath->to_fetch_registers (beneath, regcache, regnum);
305
306 /* FIXME: That might have gotten us more than we asked for. Make
307 sure we overwrite all relevant registers with values from the
308 thread structure. This can go once we fix the underlying target. */
309 regnum = -1;
310
311 active_addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr);
312 if (addr != 0 && addr != active_addr)
313 {
314 bsd_uthread_check_magic (addr);
315 uthread_ops->supply_uthread (regcache, regnum,
316 addr + bsd_uthread_thread_ctx_offset);
317 }
318 }
319
320 static void
321 bsd_uthread_store_registers (struct target_ops *ops,
322 struct regcache *regcache, int regnum)
323 {
324 struct gdbarch *gdbarch = regcache->arch ();
325 struct bsd_uthread_ops *uthread_ops
326 = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
327 struct target_ops *beneath = find_target_beneath (ops);
328 ptid_t ptid = regcache_get_ptid (regcache);
329 CORE_ADDR addr = ptid_get_tid (ptid);
330 CORE_ADDR active_addr;
331 scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
332
333 /* We are doing operations (e.g. reading memory) that rely on
334 inferior_ptid. */
335 inferior_ptid = ptid;
336
337 active_addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr);
338 if (addr != 0 && addr != active_addr)
339 {
340 bsd_uthread_check_magic (addr);
341 uthread_ops->collect_uthread (regcache, regnum,
342 addr + bsd_uthread_thread_ctx_offset);
343 }
344 else
345 {
346 /* Updating the thread that is currently running; pass the
347 request to the layer beneath. */
348 beneath->to_store_registers (beneath, regcache, regnum);
349 }
350 }
351
352 static ptid_t
353 bsd_uthread_wait (struct target_ops *ops,
354 ptid_t ptid, struct target_waitstatus *status, int options)
355 {
356 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
357 CORE_ADDR addr;
358 struct target_ops *beneath = find_target_beneath (ops);
359
360 /* Pass the request to the layer beneath. */
361 ptid = beneath->to_wait (beneath, ptid, status, options);
362
363 /* If the process is no longer alive, there's no point in figuring
364 out the thread ID. It will fail anyway. */
365 if (status->kind == TARGET_WAITKIND_SIGNALLED
366 || status->kind == TARGET_WAITKIND_EXITED)
367 return ptid;
368
369 /* Fetch the corresponding thread ID, and augment the returned
370 process ID with it. */
371 addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr);
372 if (addr != 0)
373 {
374 gdb_byte buf[4];
375
376 /* FIXME: For executables linked statically with the threads
377 library, we end up here before the program has actually been
378 executed. In that case ADDR will be garbage since it has
379 been read from the wrong virtual memory image. */
380 if (target_read_memory (addr, buf, 4) == 0)
381 {
382 ULONGEST magic = extract_unsigned_integer (buf, 4, byte_order);
383 if (magic == BSD_UTHREAD_PTHREAD_MAGIC)
384 ptid = ptid_build (ptid_get_pid (ptid), 0, addr);
385 }
386 }
387
388 /* If INFERIOR_PTID doesn't have a tid member yet, and we now have a
389 ptid with tid set, then ptid is still the initial thread of
390 the process. Notify GDB core about it. */
391 if (ptid_get_tid (inferior_ptid) == 0
392 && ptid_get_tid (ptid) != 0 && !in_thread_list (ptid))
393 thread_change_ptid (inferior_ptid, ptid);
394
395 /* Don't let the core see a ptid without a corresponding thread. */
396 if (!in_thread_list (ptid) || is_exited (ptid))
397 add_thread (ptid);
398
399 return ptid;
400 }
401
402 static void
403 bsd_uthread_resume (struct target_ops *ops,
404 ptid_t ptid, int step, enum gdb_signal sig)
405 {
406 /* Pass the request to the layer beneath. */
407 struct target_ops *beneath = find_target_beneath (ops);
408 beneath->to_resume (beneath, ptid, step, sig);
409 }
410
411 static int
412 bsd_uthread_thread_alive (struct target_ops *ops, ptid_t ptid)
413 {
414 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
415 struct target_ops *beneath = find_target_beneath (ops);
416 CORE_ADDR addr = ptid_get_tid (ptid);
417
418 if (addr != 0)
419 {
420 int offset = bsd_uthread_thread_state_offset;
421 ULONGEST state;
422
423 bsd_uthread_check_magic (addr);
424
425 state = read_memory_unsigned_integer (addr + offset, 4, byte_order);
426 if (state == BSD_UTHREAD_PS_DEAD)
427 return 0;
428 }
429
430 return beneath->to_thread_alive (beneath, ptid);
431 }
432
433 static void
434 bsd_uthread_update_thread_list (struct target_ops *ops)
435 {
436 pid_t pid = ptid_get_pid (inferior_ptid);
437 int offset = bsd_uthread_thread_next_offset;
438 CORE_ADDR addr;
439
440 prune_threads ();
441
442 addr = bsd_uthread_read_memory_address (bsd_uthread_thread_list_addr);
443 while (addr != 0)
444 {
445 ptid_t ptid = ptid_build (pid, 0, addr);
446
447 if (!in_thread_list (ptid) || is_exited (ptid))
448 {
449 /* If INFERIOR_PTID doesn't have a tid member yet, then ptid
450 is still the initial thread of the process. Notify GDB
451 core about it. */
452 if (ptid_get_tid (inferior_ptid) == 0)
453 thread_change_ptid (inferior_ptid, ptid);
454 else
455 add_thread (ptid);
456 }
457
458 addr = bsd_uthread_read_memory_address (addr + offset);
459 }
460 }
461
462 /* Possible states a thread can be in. */
463 static const char *bsd_uthread_state[] =
464 {
465 "RUNNING",
466 "SIGTHREAD",
467 "MUTEX_WAIT",
468 "COND_WAIT",
469 "FDLR_WAIT",
470 "FDLW_WAIT",
471 "FDR_WAIT",
472 "FDW_WAIT",
473 "FILE_WAIT",
474 "POLL_WAIT",
475 "SELECT_WAIT",
476 "SLEEP_WAIT",
477 "WAIT_WAIT",
478 "SIGSUSPEND",
479 "SIGWAIT",
480 "SPINBLOCK",
481 "JOIN",
482 "SUSPENDED",
483 "DEAD",
484 "DEADLOCK"
485 };
486
487 /* Return a string describing th state of the thread specified by
488 INFO. */
489
490 static const char *
491 bsd_uthread_extra_thread_info (struct target_ops *self,
492 struct thread_info *info)
493 {
494 enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
495 CORE_ADDR addr = ptid_get_tid (info->ptid);
496
497 if (addr != 0)
498 {
499 int offset = bsd_uthread_thread_state_offset;
500 ULONGEST state;
501
502 state = read_memory_unsigned_integer (addr + offset, 4, byte_order);
503 if (state < ARRAY_SIZE (bsd_uthread_state))
504 return bsd_uthread_state[state];
505 }
506
507 return NULL;
508 }
509
510 static const char *
511 bsd_uthread_pid_to_str (struct target_ops *ops, ptid_t ptid)
512 {
513 if (ptid_get_tid (ptid) != 0)
514 {
515 static char buf[64];
516
517 xsnprintf (buf, sizeof buf, "process %d, thread 0x%lx",
518 ptid_get_pid (ptid), ptid_get_tid (ptid));
519 return buf;
520 }
521
522 return normal_pid_to_str (ptid);
523 }
524
525 static struct target_ops *
526 bsd_uthread_target (void)
527 {
528 struct target_ops *t = XCNEW (struct target_ops);
529
530 t->to_shortname = "bsd-uthreads";
531 t->to_longname = "BSD user-level threads";
532 t->to_doc = "BSD user-level threads";
533 t->to_close = bsd_uthread_close;
534 t->to_mourn_inferior = bsd_uthread_mourn_inferior;
535 t->to_fetch_registers = bsd_uthread_fetch_registers;
536 t->to_store_registers = bsd_uthread_store_registers;
537 t->to_wait = bsd_uthread_wait;
538 t->to_resume = bsd_uthread_resume;
539 t->to_thread_alive = bsd_uthread_thread_alive;
540 t->to_update_thread_list = bsd_uthread_update_thread_list;
541 t->to_extra_thread_info = bsd_uthread_extra_thread_info;
542 t->to_pid_to_str = bsd_uthread_pid_to_str;
543 t->to_stratum = thread_stratum;
544 t->to_magic = OPS_MAGIC;
545 bsd_uthread_ops_hack = t;
546
547 return t;
548 }
549
550 void
551 _initialize_bsd_uthread (void)
552 {
553 complete_target_initialization (bsd_uthread_target ());
554
555 bsd_uthread_data = gdbarch_data_register_pre_init (bsd_uthread_init);
556
557 observer_attach_inferior_created (bsd_uthread_inferior_created);
558 observer_attach_solib_loaded (bsd_uthread_solib_loaded);
559 observer_attach_solib_unloaded (bsd_uthread_solib_unloaded);
560 }
target_gdbarch
struct gdbarch * target_gdbarch(void)
Definition: gdbarch.c:5467
gdbarch
Definition: gdbarch.c:127
bsd_uthread_wait
static ptid_t bsd_uthread_wait(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options)
Definition: bsd-uthread.c:353
add_thread
struct thread_info * add_thread(ptid_t ptid)
Definition: thread.c:333
bsd_uthread_thread_next_offset
static int bsd_uthread_thread_next_offset
Definition: bsd-uthread.c:119
gdb_obstack.h
target_ops::to_longname
const char * to_longname
Definition: target.h:416
target_waitstatus
Definition: waitstatus.h:104
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
ptid_get_pid
int ptid_get_pid(const ptid_t &ptid)
Definition: ptid.c:47
pid
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
Definition: gnu-nat.c:1824
bsd_uthread_read_memory_address
static CORE_ADDR bsd_uthread_read_memory_address(CORE_ADDR addr)
Definition: bsd-uthread.c:154
solist.h
BMSYMBOL_VALUE_ADDRESS
#define BMSYMBOL_VALUE_ADDRESS(symbol)
Definition: symtab.h:691
bsd_uthread_state
static const char * bsd_uthread_state[]
Definition: bsd-uthread.c:463
push_target
void push_target(struct target_ops *t)
Definition: target.c:642
builtin_type
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
Definition: gdbtypes.c:5217
regcache_get_ptid
ptid_t regcache_get_ptid(const struct regcache *regcache)
Definition: regcache.c:229
unpush_target
int unpush_target(struct target_ops *t)
Definition: target.c:689
target_ops::to_close
void(* to_close)(struct target_ops *)
Definition: target.h:431
target_ops::to_pid_to_str
const char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
Definition: target.h:630
bsd_uthread_extra_thread_info
static const char * bsd_uthread_extra_thread_info(struct target_ops *self, struct thread_info *info)
Definition: bsd-uthread.c:491
so_list
Definition: solist.h:38
bsd_uthread_solib_name
static const char * bsd_uthread_solib_name
Definition: bsd-uthread.c:123
bsd_uthread_thread_ctx_offset
static int bsd_uthread_thread_ctx_offset
Definition: bsd-uthread.c:120
gdbarch_data_register_pre_init
struct gdbarch_data * gdbarch_data_register_pre_init(gdbarch_data_pre_init_ftype *pre_init)
Definition: gdbarch.c:5130
bsd_uthread_set_collect_uthread
void bsd_uthread_set_collect_uthread(struct gdbarch *gdbarch, void(*collect_uthread)(const struct regcache *, int, CORE_ADDR))
Definition: bsd-uthread.c:81
bsd_uthread_target
static struct target_ops * bsd_uthread_target(void)
Definition: bsd-uthread.c:526
bsd_uthread_update_thread_list
static void bsd_uthread_update_thread_list(struct target_ops *ops)
Definition: bsd-uthread.c:434
_
#define _(String)
Definition: gdb_locale.h:35
bsd_uthread_lookup_address
static CORE_ADDR bsd_uthread_lookup_address(const char *name, struct objfile *objfile)
Definition: bsd-uthread.c:129
defs.h
bsd_uthread_solib_names
static const char * bsd_uthread_solib_names[]
Definition: bsd-uthread.c:241
bsd_uthread_ops::collect_uthread
void(* collect_uthread)(const struct regcache *, int, CORE_ADDR)
Definition: bsd-uthread.c:51
objfiles.h
ptid_build
ptid_t ptid_build(int pid, long lwp, long tid)
Definition: ptid.c:31
observer.h
make_scoped_restore
scoped_restore_tmpl< T > make_scoped_restore(T *var)
Definition: scoped_restore.h:105
observer_attach_inferior_created
struct observer * observer_attach_inferior_created(observer_inferior_created_ftype *f)
normal_pid_to_str
const char * normal_pid_to_str(ptid_t ptid)
Definition: target.c:3234
in_thread_list
int in_thread_list(ptid_t ptid)
Definition: thread.c:628
TARGET_WAITKIND_SIGNALLED
Definition: waitstatus.h:39
thread_stratum
Definition: target.h:88
name
const char *const name
Definition: aarch64-tdep.c:76
OPS_MAGIC
#define OPS_MAGIC
Definition: target.h:1270
bsd_uthread_active
static int bsd_uthread_active
Definition: bsd-uthread.c:126
_initialize_bsd_uthread
void _initialize_bsd_uthread(void)
Definition: bsd-uthread.c:551
bsd_uthread_ops_hack
static struct target_ops * bsd_uthread_ops_hack
Definition: bsd-uthread.c:37
complete_target_initialization
void complete_target_initialization(struct target_ops *t)
Definition: target.c:317
target_ops
Definition: target.h:412
bsd_uthread_inferior_created
static void bsd_uthread_inferior_created(struct target_ops *ops, int from_tty)
Definition: bsd-uthread.c:235
bsd_uthread_fetch_registers
static void bsd_uthread_fetch_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
Definition: bsd-uthread.c:287
bsd_uthread_thread_list_addr
static CORE_ADDR bsd_uthread_thread_list_addr
Definition: bsd-uthread.c:115
extract_unsigned_integer
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
Definition: defs.h:577
regcache.h
bound_minimal_symbol
Definition: minsyms.h:29
ptid_get_tid
long ptid_get_tid(const ptid_t &ptid)
Definition: ptid.c:63
ptid_t
Definition: ptid.h:35
target_ops::to_resume
void(* to_resume)(struct target_ops *, ptid_t, int TARGET_DEBUG_PRINTER(target_debug_print_step), enum gdb_signal) TARGET_DEFAULT_NORETURN(noprocess())
Definition: target.h:447
observer_attach_solib_unloaded
struct observer * observer_attach_solib_unloaded(observer_solib_unloaded_ftype *f)
so_list::so_original_name
char so_original_name[SO_NAME_MAX_PATH_SIZE]
Definition: solist.h:57
gdbarch_byte_order
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition: gdbarch.c:1509
gdbthread.h
inferior.h
bsd_uthread_init
static void * bsd_uthread_init(struct obstack *obstack)
Definition: bsd-uthread.c:55
scoped_restore_base
Definition: scoped_restore.h:24
type
Definition: gdbtypes.h:749
thread_change_ptid
void thread_change_ptid(ptid_t old_ptid, ptid_t new_ptid)
Definition: thread.c:855
solib.h
status
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
Definition: gnu-nat.c:1822
target_ops::to_doc
const char * to_doc
Definition: target.h:417
startswith
static int startswith(const char *string, const char *pattern)
Definition: common-utils.h:107
BSD_UTHREAD_PS_DEAD
#define BSD_UTHREAD_PS_DEAD
Definition: bsd-uthread.c:108
thread_info::ptid
ptid_t ptid
Definition: gdbthread.h:219
bsd_uthread_lookup_offset
static int bsd_uthread_lookup_offset(const char *name, struct objfile *objfile)
Definition: bsd-uthread.c:141
find_target_beneath
struct target_ops * find_target_beneath(struct target_ops *t)
Definition: target.c:3153
regnum
int regnum
Definition: aarch64-tdep.c:77
bsd_uthread_deactivate
static void bsd_uthread_deactivate(void)
Definition: bsd-uthread.c:225
bsd_uthread_thread_state_offset
static int bsd_uthread_thread_state_offset
Definition: bsd-uthread.c:118
bsd_uthread_pid_to_str
static const char * bsd_uthread_pid_to_str(struct target_ops *ops, ptid_t ptid)
Definition: bsd-uthread.c:511
objfile
Definition: objfiles.h:286
bsd_uthread_data
static struct gdbarch_data * bsd_uthread_data
Definition: bsd-uthread.c:43
gdb_byte
bfd_byte gdb_byte
Definition: common-types.h:38
bsd_uthread_thread_alive
static int bsd_uthread_thread_alive(struct target_ops *ops, ptid_t ptid)
Definition: bsd-uthread.c:412
target_ops::to_fetch_registers
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
Definition: target.h:457
target_ops::to_mourn_inferior
void(* to_mourn_inferior)(struct target_ops *) TARGET_DEFAULT_FUNC(default_mourn_inferior)
Definition: target.h:606
target_ops::to_extra_thread_info
const char *(* to_extra_thread_info)(struct target_ops *, struct thread_info *) TARGET_DEFAULT_RETURN(NULL)
Definition: target.h:632
bsd_uthread_solib_loaded
static void bsd_uthread_solib_loaded(struct so_list *so)
Definition: bsd-uthread.c:249
prune_threads
void prune_threads(void)
Definition: thread.c:727
XCNEW
#define XCNEW(T)
Definition: poison.h:121
gdbcore.h
xsnprintf
int xsnprintf(char *str, size_t size, const char *format,...)
Definition: common-utils.c:134
target_read_memory
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: target.c:1370
bsd_uthread_solib_unloaded
static void bsd_uthread_solib_unloaded(struct so_list *so)
Definition: bsd-uthread.c:269
inferior_ptid
ptid_t inferior_ptid
Definition: infcmd.c:94
builtin_type::builtin_data_ptr
struct type * builtin_data_ptr
Definition: gdbtypes.h:1554
target_ops::to_stratum
enum strata to_stratum
Definition: target.h:656
offset
int offset
Definition: agent.c:65
TARGET_WAITKIND_EXITED
Definition: waitstatus.h:31
bsd_uthread_check_magic
static void bsd_uthread_check_magic(CORE_ADDR addr)
Definition: bsd-uthread.c:97
regcache::arch
gdbarch * arch() const
Definition: regcache.c:221
bsd_uthread_mourn_inferior
static void bsd_uthread_mourn_inferior(struct target_ops *ops)
Definition: bsd-uthread.c:279
BSD_UTHREAD_PTHREAD_MAGIC
#define BSD_UTHREAD_PTHREAD_MAGIC
Definition: bsd-uthread.c:92
target.h
bsd-uthread.h
is_exited
int is_exited(ptid_t ptid)
Definition: thread.c:969
target_ops::to_shortname
const char * to_shortname
Definition: target.h:415
ULONGEST
unsigned long long ULONGEST
Definition: common-types.h:53
target_ops::to_magic
int to_magic
Definition: target.h:1261
regcache
Definition: regcache.h:232
bsd_uthread_ops
Definition: bsd-uthread.c:45
solib_read_symbols
int solib_read_symbols(struct so_list *so, symfile_add_flags flags)
Definition: solib.c:676
OBSTACK_ZALLOC
#define OBSTACK_ZALLOC(OBSTACK, TYPE)
Definition: gdb_obstack.h:27
target_ops::to_thread_alive
int(* to_thread_alive)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
Definition: target.h:626
read_memory_unsigned_integer
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition: corefile.c:326
read_memory_typed_address
CORE_ADDR read_memory_typed_address(CORE_ADDR addr, struct type *type)
Definition: corefile.c:383
bsd_uthread_store_registers
static void bsd_uthread_store_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
Definition: bsd-uthread.c:321
target_ops::to_update_thread_list
void(* to_update_thread_list)(struct target_ops *) TARGET_DEFAULT_IGNORE()
Definition: target.h:628
so_list::objfile
struct objfile * objfile
Definition: solist.h:77
gdbarch_data
Definition: gdbarch.c:5084
target_ops::to_store_registers
void(* to_store_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_NORETURN(noprocess())
Definition: target.h:459
lookup_minimal_symbol
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition: minsyms.c:311
bsd_uthread_set_supply_uthread
void bsd_uthread_set_supply_uthread(struct gdbarch *gdbarch, void(*supply_uthread)(struct regcache *, int, CORE_ADDR))
Definition: bsd-uthread.c:67
target_ops::to_wait
ptid_t(* to_wait)(struct target_ops *, ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER(target_debug_print_options)) TARGET_DEFAULT_FUNC(default_target_wait)
Definition: target.h:453
bsd_uthread_thread_run_addr
static CORE_ADDR bsd_uthread_thread_run_addr
Definition: bsd-uthread.c:112
thread_info
Definition: gdbthread.h:205
error
void error(const char *fmt,...)
Definition: errors.c:38
target_ops::beneath
struct target_ops * beneath
Definition: target.h:414
bsd_uthread_close
static void bsd_uthread_close(struct target_ops *self)
Definition: bsd-uthread.c:211
bsd_uthread_ops::supply_uthread
void(* supply_uthread)(struct regcache *, int, CORE_ADDR)
Definition: bsd-uthread.c:48
observer_attach_solib_loaded
struct observer * observer_attach_solib_loaded(observer_solib_loaded_ftype *f)
symfile.h
bsd_uthread_resume
static void bsd_uthread_resume(struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal sig)
Definition: bsd-uthread.c:403
bsd_uthread_activate
static int bsd_uthread_activate(struct objfile *objfile)
Definition: bsd-uthread.c:165