GDB (xrefs)

/tmp/gdb-8.1/gdb/ravenscar-thread.c
Go to the documentation of this file.
1 /* Ada Ravenscar thread support.
2
3 Copyright (C) 2004-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 "ada-lang.h"
24 #include "target.h"
25 #include "inferior.h"
26 #include "command.h"
27 #include "ravenscar-thread.h"
28 #include "observer.h"
29 #include "gdbcmd.h"
30 #include "top.h"
31 #include "regcache.h"
32 #include "objfiles.h"
33
34 /* This module provides support for "Ravenscar" tasks (Ada) when
35 debugging on bare-metal targets.
36
37 The typical situation is when debugging a bare-metal target over
38 the remote protocol. In that situation, the system does not know
39 about high-level comcepts such as threads, only about some code
40 running on one or more CPUs. And since the remote protocol does not
41 provide any handling for CPUs, the de facto standard for handling
42 them is to have one thread per CPU, where the thread's ptid has
43 its lwp field set to the CPU number (eg: 1 for the first CPU,
44 2 for the second one, etc). This module will make that assumption.
45
46 This module then creates and maintains the list of threads based
47 on the list of Ada tasks, with one thread per Ada tasks. The convention
48 is that threads corresponding to the CPUs (see assumption above)
49 have a ptid_t of the form (PID, LWP, 0), which threads corresponding
50 to our Ada tasks have a ptid_t of the form (PID, 0, TID) where TID
51 is the Ada task's ID as extracted from Ada runtime information.
52
53 Switching to a given Ada tasks (or its underlying thread) is performed
54 by fetching the registers of that tasks from the memory area where
55 the registers were saved. For any of the other operations, the
56 operation is performed by first finding the CPU on which the task
57 is running, switching to its corresponding ptid, and then performing
58 the operation on that ptid using the target beneath us. */
59
60 /* If non-null, ravenscar task support is enabled. */
61 static int ravenscar_task_support = 1;
62
63 /* This module's target-specific operations. */
64 static struct target_ops ravenscar_ops;
65
66 /* PTID of the last thread that received an event.
67 This can be useful to determine the associated task that received
68 the event, to make it the current task. */
69 static ptid_t base_ptid;
70
71 static const char running_thread_name[] = "__gnat_running_thread_table";
72
73 static const char known_tasks_name[] = "system__tasking__debug__known_tasks";
74 static const char first_task_name[] = "system__tasking__debug__first_task";
75
76 static const char ravenscar_runtime_initializer[] =
77 "system__bb__threads__initialize";
78
79 static void ravenscar_update_thread_list (struct target_ops *ops);
80 static ptid_t ravenscar_active_task (int cpu);
81 static const char *ravenscar_extra_thread_info (struct target_ops *self,
82 struct thread_info *tp);
83 static int ravenscar_thread_alive (struct target_ops *ops, ptid_t ptid);
84 static void ravenscar_fetch_registers (struct target_ops *ops,
85 struct regcache *regcache, int regnum);
86 static void ravenscar_store_registers (struct target_ops *ops,
87 struct regcache *regcache, int regnum);
88 static void ravenscar_prepare_to_store (struct target_ops *self,
89 struct regcache *regcache);
90 static void ravenscar_resume (struct target_ops *ops, ptid_t ptid, int step,
91 enum gdb_signal siggnal);
92 static void ravenscar_mourn_inferior (struct target_ops *ops);
93 static void ravenscar_update_inferior_ptid (void);
94 static int has_ravenscar_runtime (void);
95 static int ravenscar_runtime_initialized (void);
96 static void ravenscar_inferior_created (struct target_ops *target,
97 int from_tty);
98
99 /* Return nonzero iff PTID corresponds to a ravenscar task. */
100
101 static int
102 is_ravenscar_task (ptid_t ptid)
103 {
104 /* By construction, ravenscar tasks have their LWP set to zero.
105 Also make sure that the TID is nonzero, as some remotes, when
106 asked for the list of threads, will return the first thread
107 as having its TID set to zero. For instance, TSIM version
108 2.0.48 for LEON3 sends 'm0' as a reply to the 'qfThreadInfo'
109 query, which the remote protocol layer then treats as a thread
110 whose TID is 0. This is obviously not a ravenscar task. */
111 return ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) != 0;
112 }
113
114 /* Given PTID, which can be either a ravenscar task or a CPU thread,
115 return which CPU that ptid is running on.
116
117 This assume that PTID is a valid ptid_t. Otherwise, a gdb_assert
118 will be triggered. */
119
120 static int
121 ravenscar_get_thread_base_cpu (ptid_t ptid)
122 {
123 int base_cpu;
124
125 if (is_ravenscar_task (ptid))
126 {
127 struct ada_task_info *task_info = ada_get_task_info_from_ptid (ptid);
128
129 gdb_assert (task_info != NULL);
130 base_cpu = task_info->base_cpu;
131 }
132 else
133 {
134 /* We assume that the LWP of the PTID is equal to the CPU number. */
135 base_cpu = ptid_get_lwp (ptid);
136 }
137
138 return base_cpu;
139 }
140
141 /* Given a ravenscar task (identified by its ptid_t PTID), return nonzero
142 if this task is the currently active task on the cpu that task is
143 running on.
144
145 In other words, this function determine which CPU this task is
146 currently running on, and then return nonzero if the CPU in question
147 is executing the code for that task. If that's the case, then
148 that task's registers are in the CPU bank. Otherwise, the task
149 is currently suspended, and its registers have been saved in memory. */
150
151 static int
152 ravenscar_task_is_currently_active (ptid_t ptid)
153 {
154 ptid_t active_task_ptid
155 = ravenscar_active_task (ravenscar_get_thread_base_cpu (ptid));
156
157 return ptid_equal (ptid, active_task_ptid);
158 }
159
160 /* Return the CPU thread (as a ptid_t) on which the given ravenscar
161 task is running.
162
163 This is the thread that corresponds to the CPU on which the task
164 is running. */
165
166 static ptid_t
167 get_base_thread_from_ravenscar_task (ptid_t ptid)
168 {
169 int base_cpu;
170
171 if (!is_ravenscar_task (ptid))
172 return ptid;
173
174 base_cpu = ravenscar_get_thread_base_cpu (ptid);
175 return ptid_build (ptid_get_pid (ptid), base_cpu, 0);
176 }
177
178 /* Fetch the ravenscar running thread from target memory and
179 update inferior_ptid accordingly. */
180
181 static void
182 ravenscar_update_inferior_ptid (void)
183 {
184 int base_cpu;
185
186 base_ptid = inferior_ptid;
187
188 gdb_assert (!is_ravenscar_task (inferior_ptid));
189 base_cpu = ravenscar_get_thread_base_cpu (base_ptid);
190
191 /* If the runtime has not been initialized yet, the inferior_ptid is
192 the only ptid that there is. */
193 if (!ravenscar_runtime_initialized ())
194 return;
195
196 /* Make sure we set base_ptid before calling ravenscar_active_task
197 as the latter relies on it. */
198 inferior_ptid = ravenscar_active_task (base_cpu);
199 gdb_assert (!ptid_equal (inferior_ptid, null_ptid));
200
201 /* The running thread may not have been added to
202 system.tasking.debug's list yet; so ravenscar_update_thread_list
203 may not always add it to the thread list. Add it here. */
204 if (!find_thread_ptid (inferior_ptid))
205 add_thread (inferior_ptid);
206 }
207
208 /* The Ravenscar Runtime exports a symbol which contains the ID of
209 the thread that is currently running. Try to locate that symbol
210 and return its associated minimal symbol.
211 Return NULL if not found. */
212
213 static struct bound_minimal_symbol
214 get_running_thread_msymbol (void)
215 {
216 struct bound_minimal_symbol msym;
217
218 msym = lookup_minimal_symbol (running_thread_name, NULL, NULL);
219 if (!msym.minsym)
220 /* Older versions of the GNAT runtime were using a different
221 (less ideal) name for the symbol where the active thread ID
222 is stored. If we couldn't find the symbol using the latest
223 name, then try the old one. */
224 msym = lookup_minimal_symbol ("running_thread", NULL, NULL);
225
226 return msym;
227 }
228
229 /* Return True if the Ada Ravenscar run-time can be found in the
230 application. */
231
232 static int
233 has_ravenscar_runtime (void)
234 {
235 struct bound_minimal_symbol msym_ravenscar_runtime_initializer =
236 lookup_minimal_symbol (ravenscar_runtime_initializer, NULL, NULL);
237 struct bound_minimal_symbol msym_known_tasks =
238 lookup_minimal_symbol (known_tasks_name, NULL, NULL);
239 struct bound_minimal_symbol msym_first_task =
240 lookup_minimal_symbol (first_task_name, NULL, NULL);
241 struct bound_minimal_symbol msym_running_thread
242 = get_running_thread_msymbol ();
243
244 return (msym_ravenscar_runtime_initializer.minsym
245 && (msym_known_tasks.minsym || msym_first_task.minsym)
246 && msym_running_thread.minsym);
247 }
248
249 /* Return True if the Ada Ravenscar run-time can be found in the
250 application, and if it has been initialized on target. */
251
252 static int
253 ravenscar_runtime_initialized (void)
254 {
255 return (!(ptid_equal (ravenscar_active_task (1), null_ptid)));
256 }
257
258 /* Return the ID of the thread that is currently running.
259 Return 0 if the ID could not be determined. */
260
261 static CORE_ADDR
262 get_running_thread_id (int cpu)
263 {
264 struct bound_minimal_symbol object_msym = get_running_thread_msymbol ();
265 int object_size;
266 int buf_size;
267 gdb_byte *buf;
268 CORE_ADDR object_addr;
269 struct type *builtin_type_void_data_ptr =
270 builtin_type (target_gdbarch ())->builtin_data_ptr;
271
272 if (!object_msym.minsym)
273 return 0;
274
275 object_size = TYPE_LENGTH (builtin_type_void_data_ptr);
276 object_addr = (BMSYMBOL_VALUE_ADDRESS (object_msym)
277 + (cpu - 1) * object_size);
278 buf_size = object_size;
279 buf = (gdb_byte *) alloca (buf_size);
280 read_memory (object_addr, buf, buf_size);
281 return extract_typed_address (buf, builtin_type_void_data_ptr);
282 }
283
284 static void
285 ravenscar_resume (struct target_ops *ops, ptid_t ptid, int step,
286 enum gdb_signal siggnal)
287 {
288 struct target_ops *beneath = find_target_beneath (ops);
289
290 inferior_ptid = base_ptid;
291 beneath->to_resume (beneath, base_ptid, step, siggnal);
292 }
293
294 static ptid_t
295 ravenscar_wait (struct target_ops *ops, ptid_t ptid,
296 struct target_waitstatus *status,
297 int options)
298 {
299 struct target_ops *beneath = find_target_beneath (ops);
300 ptid_t event_ptid;
301
302 inferior_ptid = base_ptid;
303 event_ptid = beneath->to_wait (beneath, base_ptid, status, 0);
304 /* Find any new threads that might have been created, and update
305 inferior_ptid to the active thread.
306
307 Only do it if the program is still alive, though. Otherwise,
308 this causes problems when debugging through the remote protocol,
309 because we might try switching threads (and thus sending packets)
310 after the remote has disconnected. */
311 if (status->kind != TARGET_WAITKIND_EXITED
312 && status->kind != TARGET_WAITKIND_SIGNALLED)
313 {
314 inferior_ptid = event_ptid;
315 ravenscar_update_thread_list (ops);
316 ravenscar_update_inferior_ptid ();
317 }
318 return inferior_ptid;
319 }
320
321 /* Add the thread associated to the given TASK to the thread list
322 (if the thread has already been added, this is a no-op). */
323
324 static void
325 ravenscar_add_thread (struct ada_task_info *task)
326 {
327 if (find_thread_ptid (task->ptid) == NULL)
328 add_thread (task->ptid);
329 }
330
331 static void
332 ravenscar_update_thread_list (struct target_ops *ops)
333 {
334 ada_build_task_list ();
335
336 /* Do not clear the thread list before adding the Ada task, to keep
337 the thread that the process stratum has included into it
338 (base_ptid) and the running thread, that may not have been included
339 to system.tasking.debug's list yet. */
340
341 iterate_over_live_ada_tasks (ravenscar_add_thread);
342 }
343
344 static ptid_t
345 ravenscar_active_task (int cpu)
346 {
347 CORE_ADDR tid = get_running_thread_id (cpu);
348
349 if (tid == 0)
350 return null_ptid;
351 else
352 return ptid_build (ptid_get_pid (base_ptid), 0, tid);
353 }
354
355 static const char *
356 ravenscar_extra_thread_info (struct target_ops *self, struct thread_info *tp)
357 {
358 return "Ravenscar task";
359 }
360
361 static int
362 ravenscar_thread_alive (struct target_ops *ops, ptid_t ptid)
363 {
364 /* Ravenscar tasks are non-terminating. */
365 return 1;
366 }
367
368 static const char *
369 ravenscar_pid_to_str (struct target_ops *ops, ptid_t ptid)
370 {
371 static char buf[30];
372
373 snprintf (buf, sizeof (buf), "Thread %#x", (int) ptid_get_tid (ptid));
374 return buf;
375 }
376
377 static void
378 ravenscar_fetch_registers (struct target_ops *ops,
379 struct regcache *regcache, int regnum)
380 {
381 struct target_ops *beneath = find_target_beneath (ops);
382 ptid_t ptid = regcache_get_ptid (regcache);
383
384 if (ravenscar_runtime_initialized ()
385 && is_ravenscar_task (ptid)
386 && !ravenscar_task_is_currently_active (ptid))
387 {
388 struct gdbarch *gdbarch = regcache->arch ();
389 struct ravenscar_arch_ops *arch_ops
390 = gdbarch_ravenscar_ops (gdbarch);
391
392 arch_ops->to_fetch_registers (regcache, regnum);
393 }
394 else
395 beneath->to_fetch_registers (beneath, regcache, regnum);
396 }
397
398 static void
399 ravenscar_store_registers (struct target_ops *ops,
400 struct regcache *regcache, int regnum)
401 {
402 struct target_ops *beneath = find_target_beneath (ops);
403 ptid_t ptid = regcache_get_ptid (regcache);
404
405 if (ravenscar_runtime_initialized ()
406 && is_ravenscar_task (ptid)
407 && !ravenscar_task_is_currently_active (ptid))
408 {
409 struct gdbarch *gdbarch = regcache->arch ();
410 struct ravenscar_arch_ops *arch_ops
411 = gdbarch_ravenscar_ops (gdbarch);
412
413 arch_ops->to_store_registers (regcache, regnum);
414 }
415 else
416 beneath->to_store_registers (beneath, regcache, regnum);
417 }
418
419 static void
420 ravenscar_prepare_to_store (struct target_ops *self,
421 struct regcache *regcache)
422 {
423 struct target_ops *beneath = find_target_beneath (self);
424 ptid_t ptid = regcache_get_ptid (regcache);
425
426 if (ravenscar_runtime_initialized ()
427 && is_ravenscar_task (ptid)
428 && !ravenscar_task_is_currently_active (ptid))
429 {
430 struct gdbarch *gdbarch = regcache->arch ();
431 struct ravenscar_arch_ops *arch_ops
432 = gdbarch_ravenscar_ops (gdbarch);
433
434 arch_ops->to_prepare_to_store (regcache);
435 }
436 else
437 beneath->to_prepare_to_store (beneath, regcache);
438 }
439
440 /* Implement the to_stopped_by_sw_breakpoint target_ops "method". */
441
442 static int
443 ravenscar_stopped_by_sw_breakpoint (struct target_ops *ops)
444 {
445 ptid_t saved_ptid = inferior_ptid;
446 struct target_ops *beneath = find_target_beneath (ops);
447 int result;
448
449 inferior_ptid = get_base_thread_from_ravenscar_task (saved_ptid);
450 result = beneath->to_stopped_by_sw_breakpoint (beneath);
451 inferior_ptid = saved_ptid;
452 return result;
453 }
454
455 /* Implement the to_stopped_by_hw_breakpoint target_ops "method". */
456
457 static int
458 ravenscar_stopped_by_hw_breakpoint (struct target_ops *ops)
459 {
460 ptid_t saved_ptid = inferior_ptid;
461 struct target_ops *beneath = find_target_beneath (ops);
462 int result;
463
464 inferior_ptid = get_base_thread_from_ravenscar_task (saved_ptid);
465 result = beneath->to_stopped_by_hw_breakpoint (beneath);
466 inferior_ptid = saved_ptid;
467 return result;
468 }
469
470 /* Implement the to_stopped_by_watchpoint target_ops "method". */
471
472 static int
473 ravenscar_stopped_by_watchpoint (struct target_ops *ops)
474 {
475 ptid_t saved_ptid = inferior_ptid;
476 struct target_ops *beneath = find_target_beneath (ops);
477 int result;
478
479 inferior_ptid = get_base_thread_from_ravenscar_task (saved_ptid);
480 result = beneath->to_stopped_by_watchpoint (beneath);
481 inferior_ptid = saved_ptid;
482 return result;
483 }
484
485 /* Implement the to_stopped_data_address target_ops "method". */
486
487 static int
488 ravenscar_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
489 {
490 ptid_t saved_ptid = inferior_ptid;
491 struct target_ops *beneath = find_target_beneath (ops);
492 int result;
493
494 inferior_ptid = get_base_thread_from_ravenscar_task (saved_ptid);
495 result = beneath->to_stopped_data_address (beneath, addr_p);
496 inferior_ptid = saved_ptid;
497 return result;
498 }
499
500 static void
501 ravenscar_mourn_inferior (struct target_ops *ops)
502 {
503 struct target_ops *beneath = find_target_beneath (ops);
504
505 base_ptid = null_ptid;
506 beneath->to_mourn_inferior (beneath);
507 unpush_target (&ravenscar_ops);
508 }
509
510 /* Implement the to_core_of_thread target_ops "method". */
511
512 static int
513 ravenscar_core_of_thread (struct target_ops *ops, ptid_t ptid)
514 {
515 ptid_t saved_ptid = inferior_ptid;
516 struct target_ops *beneath = find_target_beneath (ops);
517 int result;
518
519 inferior_ptid = get_base_thread_from_ravenscar_task (saved_ptid);
520 result = beneath->to_core_of_thread (beneath, inferior_ptid);
521 inferior_ptid = saved_ptid;
522 return result;
523 }
524
525 /* Observer on inferior_created: push ravenscar thread stratum if needed. */
526
527 static void
528 ravenscar_inferior_created (struct target_ops *target, int from_tty)
529 {
530 const char *err_msg;
531
532 if (!ravenscar_task_support
533 || gdbarch_ravenscar_ops (target_gdbarch ()) == NULL
534 || !has_ravenscar_runtime ())
535 return;
536
537 err_msg = ada_get_tcb_types_info ();
538 if (err_msg != NULL)
539 {
540 warning (_("%s. Task/thread support disabled."), err_msg);
541 return;
542 }
543
544 ravenscar_update_inferior_ptid ();
545 push_target (&ravenscar_ops);
546 }
547
548 static ptid_t
549 ravenscar_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
550 {
551 return ptid_build (ptid_get_pid (base_ptid), 0, thread);
552 }
553
554 static void
555 init_ravenscar_thread_ops (void)
556 {
557 ravenscar_ops.to_shortname = "ravenscar";
558 ravenscar_ops.to_longname = "Ravenscar tasks.";
559 ravenscar_ops.to_doc = "Ravenscar tasks support.";
560 ravenscar_ops.to_resume = ravenscar_resume;
561 ravenscar_ops.to_wait = ravenscar_wait;
562 ravenscar_ops.to_fetch_registers = ravenscar_fetch_registers;
563 ravenscar_ops.to_store_registers = ravenscar_store_registers;
564 ravenscar_ops.to_prepare_to_store = ravenscar_prepare_to_store;
565 ravenscar_ops.to_stopped_by_sw_breakpoint
566 = ravenscar_stopped_by_sw_breakpoint;
567 ravenscar_ops.to_stopped_by_hw_breakpoint
568 = ravenscar_stopped_by_hw_breakpoint;
569 ravenscar_ops.to_stopped_by_watchpoint = ravenscar_stopped_by_watchpoint;
570 ravenscar_ops.to_stopped_data_address = ravenscar_stopped_data_address;
571 ravenscar_ops.to_thread_alive = ravenscar_thread_alive;
572 ravenscar_ops.to_update_thread_list = ravenscar_update_thread_list;
573 ravenscar_ops.to_pid_to_str = ravenscar_pid_to_str;
574 ravenscar_ops.to_extra_thread_info = ravenscar_extra_thread_info;
575 ravenscar_ops.to_get_ada_task_ptid = ravenscar_get_ada_task_ptid;
576 ravenscar_ops.to_mourn_inferior = ravenscar_mourn_inferior;
577 ravenscar_ops.to_has_all_memory = default_child_has_all_memory;
578 ravenscar_ops.to_has_memory = default_child_has_memory;
579 ravenscar_ops.to_has_stack = default_child_has_stack;
580 ravenscar_ops.to_has_registers = default_child_has_registers;
581 ravenscar_ops.to_has_execution = default_child_has_execution;
582 ravenscar_ops.to_stratum = thread_stratum;
583 ravenscar_ops.to_core_of_thread = ravenscar_core_of_thread;
584 ravenscar_ops.to_magic = OPS_MAGIC;
585 }
586
587 /* Command-list for the "set/show ravenscar" prefix command. */
588 static struct cmd_list_element *set_ravenscar_list;
589 static struct cmd_list_element *show_ravenscar_list;
590
591 /* Implement the "set ravenscar" prefix command. */
592
593 static void
594 set_ravenscar_command (const char *arg, int from_tty)
595 {
596 printf_unfiltered (_(\
597 "\"set ravenscar\" must be followed by the name of a setting.\n"));
598 help_list (set_ravenscar_list, "set ravenscar ", all_commands, gdb_stdout);
599 }
600
601 /* Implement the "show ravenscar" prefix command. */
602
603 static void
604 show_ravenscar_command (const char *args, int from_tty)
605 {
606 cmd_show_list (show_ravenscar_list, from_tty, "");
607 }
608
609 /* Implement the "show ravenscar task-switching" command. */
610
611 static void
612 show_ravenscar_task_switching_command (struct ui_file *file, int from_tty,
613 struct cmd_list_element *c,
614 const char *value)
615 {
616 if (ravenscar_task_support)
617 fprintf_filtered (file, _("\
618 Support for Ravenscar task/thread switching is enabled\n"));
619 else
620 fprintf_filtered (file, _("\
621 Support for Ravenscar task/thread switching is disabled\n"));
622 }
623
624 /* Module startup initialization function, automagically called by
625 init.c. */
626
627 void
628 _initialize_ravenscar (void)
629 {
630 init_ravenscar_thread_ops ();
631 base_ptid = null_ptid;
632
633 /* Notice when the inferior is created in order to push the
634 ravenscar ops if needed. */
635 observer_attach_inferior_created (ravenscar_inferior_created);
636
637 complete_target_initialization (&ravenscar_ops);
638
639 add_prefix_cmd ("ravenscar", no_class, set_ravenscar_command,
640 _("Prefix command for changing Ravenscar-specific settings"),
641 &set_ravenscar_list, "set ravenscar ", 0, &setlist);
642
643 add_prefix_cmd ("ravenscar", no_class, show_ravenscar_command,
644 _("Prefix command for showing Ravenscar-specific settings"),
645 &show_ravenscar_list, "show ravenscar ", 0, &showlist);
646
647 add_setshow_boolean_cmd ("task-switching", class_obscure,
648 &ravenscar_task_support, _("\
649 Enable or disable support for GNAT Ravenscar tasks"), _("\
650 Show whether support for GNAT Ravenscar tasks is enabled"),
651 _("\
652 Enable or disable support for task/thread switching with the GNAT\n\
653 Ravenscar run-time library for bareboard configuration."),
654 NULL, show_ravenscar_task_switching_command,
655 &set_ravenscar_list, &show_ravenscar_list);
656 }
target_gdbarch
struct gdbarch * target_gdbarch(void)
Definition: gdbarch.c:5467
gdbarch
Definition: gdbarch.c:127
top.h
_initialize_ravenscar
void _initialize_ravenscar(void)
Definition: ravenscar-thread.c:628
default_child_has_stack
int default_child_has_stack(struct target_ops *ops)
Definition: target.c:216
selftests::ptid::tid
static constexpr ptid_t tid
Definition: ptid-selftests.c:43
add_thread
struct thread_info * add_thread(ptid_t ptid)
Definition: thread.c:333
find_thread_ptid
struct thread_info * find_thread_ptid(ptid_t ptid)
Definition: thread.c:514
extract_typed_address
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
Definition: findvar.c:154
has_ravenscar_runtime
static int has_ravenscar_runtime(void)
Definition: ravenscar-thread.c:233
target_ops::to_longname
const char * to_longname
Definition: target.h:416
ada_task_info::base_cpu
int base_cpu
Definition: ada-lang.h:150
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
command.h
ravenscar_arch_ops
Definition: ravenscar-thread.h:25
no_class
Definition: command.h:41
cmd_list_element
Definition: cli-decode.h:46
BMSYMBOL_VALUE_ADDRESS
#define BMSYMBOL_VALUE_ADDRESS(symbol)
Definition: symtab.h:691
target_ops::to_has_memory
int(* to_has_memory)(struct target_ops *)
Definition: target.h:658
warning
void warning(const char *fmt,...)
Definition: errors.c:26
ravenscar_core_of_thread
static int ravenscar_core_of_thread(struct target_ops *ops, ptid_t ptid)
Definition: ravenscar-thread.c:513
get_running_thread_id
static CORE_ADDR get_running_thread_id(int cpu)
Definition: ravenscar-thread.c:262
ada-lang.h
ravenscar_arch_ops::to_fetch_registers
void(* to_fetch_registers)(struct regcache *, int)
Definition: ravenscar-thread.h:27
target_ops::to_has_stack
int(* to_has_stack)(struct target_ops *)
Definition: target.h:659
push_target
void push_target(struct target_ops *t)
Definition: target.c:642
gdbarch_ravenscar_ops
struct ravenscar_arch_ops * gdbarch_ravenscar_ops(struct gdbarch *gdbarch)
Definition: gdbarch.c:4836
builtin_type
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
Definition: gdbtypes.c:5217
target_ops::to_core_of_thread
int(* to_core_of_thread)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(-1)
Definition: target.h:1063
ravenscar_task_support
static int ravenscar_task_support
Definition: ravenscar-thread.c:61
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
show_ravenscar_task_switching_command
static void show_ravenscar_task_switching_command(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: ravenscar-thread.c:612
ravenscar_stopped_data_address
static int ravenscar_stopped_data_address(struct target_ops *ops, CORE_ADDR *addr_p)
Definition: ravenscar-thread.c:488
ada_get_task_info_from_ptid
struct ada_task_info * ada_get_task_info_from_ptid(ptid_t ptid)
Definition: ada-tasks.c:360
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
base_ptid
static ptid_t base_ptid
Definition: ravenscar-thread.c:69
ravenscar_update_thread_list
static void ravenscar_update_thread_list(struct target_ops *ops)
Definition: ravenscar-thread.c:332
ravenscar_get_ada_task_ptid
static ptid_t ravenscar_get_ada_task_ptid(struct target_ops *self, long lwp, long thread)
Definition: ravenscar-thread.c:549
ravenscar_runtime_initialized
static int ravenscar_runtime_initialized(void)
Definition: ravenscar-thread.c:253
_
#define _(String)
Definition: gdb_locale.h:35
ui_file
Definition: ui-file.h:26
ravenscar_stopped_by_watchpoint
static int ravenscar_stopped_by_watchpoint(struct target_ops *ops)
Definition: ravenscar-thread.c:473
defs.h
default_child_has_execution
int default_child_has_execution(struct target_ops *ops, ptid_t the_ptid)
Definition: target.c:236
set_ravenscar_command
static void set_ravenscar_command(const char *arg, int from_tty)
Definition: ravenscar-thread.c:594
set_ravenscar_list
static struct cmd_list_element * set_ravenscar_list
Definition: ravenscar-thread.c:588
ravenscar_ops
static struct target_ops ravenscar_ops
Definition: ravenscar-thread.c:64
objfiles.h
ravenscar_pid_to_str
static const char * ravenscar_pid_to_str(struct target_ops *ops, ptid_t ptid)
Definition: ravenscar-thread.c:369
ravenscar_active_task
static ptid_t ravenscar_active_task(int cpu)
Definition: ravenscar-thread.c:345
ptid_build
ptid_t ptid_build(int pid, long lwp, long tid)
Definition: ptid.c:31
observer.h
add_prefix_cmd
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
Definition: cli-decode.c:367
observer_attach_inferior_created
struct observer * observer_attach_inferior_created(observer_inferior_created_ftype *f)
default_child_has_memory
int default_child_has_memory(struct target_ops *ops)
Definition: target.c:206
TARGET_WAITKIND_SIGNALLED
Definition: waitstatus.h:39
init_ravenscar_thread_ops
static void init_ravenscar_thread_ops(void)
Definition: ravenscar-thread.c:555
setlist
struct cmd_list_element * setlist
Definition: cli-cmds.c:111
thread_stratum
Definition: target.h:88
get_base_thread_from_ravenscar_task
static ptid_t get_base_thread_from_ravenscar_task(ptid_t ptid)
Definition: ravenscar-thread.c:167
OPS_MAGIC
#define OPS_MAGIC
Definition: target.h:1270
ravenscar_prepare_to_store
static void ravenscar_prepare_to_store(struct target_ops *self, struct regcache *regcache)
Definition: ravenscar-thread.c:420
ravenscar_wait
static ptid_t ravenscar_wait(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options)
Definition: ravenscar-thread.c:295
is_ravenscar_task
static int is_ravenscar_task(ptid_t ptid)
Definition: ravenscar-thread.c:102
complete_target_initialization
void complete_target_initialization(struct target_ops *t)
Definition: target.c:317
ravenscar_task_is_currently_active
static int ravenscar_task_is_currently_active(ptid_t ptid)
Definition: ravenscar-thread.c:152
target_ops
Definition: target.h:412
fprintf_filtered
void fprintf_filtered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2008
ravenscar_get_thread_base_cpu
static int ravenscar_get_thread_base_cpu(ptid_t ptid)
Definition: ravenscar-thread.c:121
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
showlist
struct cmd_list_element * showlist
Definition: cli-cmds.c:119
ravenscar_stopped_by_sw_breakpoint
static int ravenscar_stopped_by_sw_breakpoint(struct target_ops *ops)
Definition: ravenscar-thread.c:443
default_child_has_all_memory
int default_child_has_all_memory(struct target_ops *ops)
Definition: target.c:196
gdbthread.h
inferior.h
target_ops::to_has_execution
int(* to_has_execution)(struct target_ops *, ptid_t)
Definition: target.h:661
ravenscar-thread.h
type
Definition: gdbtypes.h:749
running_thread_name
static const char running_thread_name[]
Definition: ravenscar-thread.c:71
show_ravenscar_command
static void show_ravenscar_command(const char *args, int from_tty)
Definition: ravenscar-thread.c:604
ravenscar_mourn_inferior
static void ravenscar_mourn_inferior(struct target_ops *ops)
Definition: ravenscar-thread.c:501
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
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
printf_unfiltered
void printf_unfiltered(const char *format,...)
Definition: utils.c:2056
read_memory
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: corefile.c:258
ravenscar_inferior_created
static void ravenscar_inferior_created(struct target_ops *target, int from_tty)
Definition: ravenscar-thread.c:528
ptid_get_lwp
long ptid_get_lwp(const ptid_t &ptid)
Definition: ptid.c:55
known_tasks_name
static const char known_tasks_name[]
Definition: ravenscar-thread.c:73
ada_task_info
Definition: ada-lang.h:117
cmd_show_list
void cmd_show_list(struct cmd_list_element *list, int from_tty, const char *prefix)
Definition: cli-setshow.c:657
ravenscar_add_thread
static void ravenscar_add_thread(struct ada_task_info *task)
Definition: ravenscar-thread.c:325
gdb_assert
#define gdb_assert(expr)
Definition: gdb_assert.h:32
value
Definition: value.c:169
first_task_name
static const char first_task_name[]
Definition: ravenscar-thread.c:74
ravenscar_extra_thread_info
static const char * ravenscar_extra_thread_info(struct target_ops *self, struct thread_info *tp)
Definition: ravenscar-thread.c:356
gdb_byte
bfd_byte gdb_byte
Definition: common-types.h:38
help_list
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
Definition: cli-decode.c:1071
ravenscar_store_registers
static void ravenscar_store_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
Definition: ravenscar-thread.c:399
null_ptid
ptid_t null_ptid
Definition: ptid.c:25
target_ops::to_fetch_registers
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
Definition: target.h:457
ada_task_info::ptid
ptid_t ptid
Definition: ada-lang.h:121
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
default_child_has_registers
int default_child_has_registers(struct target_ops *ops)
Definition: target.c:226
gdbcore.h
inferior_ptid
ptid_t inferior_ptid
Definition: infcmd.c:94
builtin_type::builtin_data_ptr
struct type * builtin_data_ptr
Definition: gdbtypes.h:1554
bound_minimal_symbol::minsym
struct minimal_symbol * minsym
Definition: minsyms.h:34
ravenscar_thread_alive
static int ravenscar_thread_alive(struct target_ops *ops, ptid_t ptid)
Definition: ravenscar-thread.c:362
target_ops::to_stratum
enum strata to_stratum
Definition: target.h:656
target_ops::to_stopped_by_sw_breakpoint
int(* to_stopped_by_sw_breakpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:483
show_ravenscar_list
static struct cmd_list_element * show_ravenscar_list
Definition: ravenscar-thread.c:589
add_setshow_boolean_cmd
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:569
TARGET_WAITKIND_EXITED
Definition: waitstatus.h:31
selftests::ptid::lwp
static constexpr ptid_t lwp
Definition: ptid-selftests.c:42
iterate_over_live_ada_tasks
void iterate_over_live_ada_tasks(ada_task_list_iterator_ftype *iterator)
Definition: ada-tasks.c:384
regcache::arch
gdbarch * arch() const
Definition: regcache.c:221
target.h
target_ops::to_stopped_by_watchpoint
int(* to_stopped_by_watchpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:531
ada_get_tcb_types_info
const char * ada_get_tcb_types_info(void)
Definition: ada-tasks.c:479
target_ops::to_stopped_by_hw_breakpoint
int(* to_stopped_by_hw_breakpoint)(struct target_ops *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:496
ptid_equal
int ptid_equal(const ptid_t &ptid1, const ptid_t &ptid2)
Definition: ptid.c:71
target_ops::to_shortname
const char * to_shortname
Definition: target.h:415
target_ops::to_magic
int to_magic
Definition: target.h:1261
regcache
Definition: regcache.h:232
ravenscar_fetch_registers
static void ravenscar_fetch_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
Definition: ravenscar-thread.c:378
target_ops::to_has_all_memory
int(* to_has_all_memory)(struct target_ops *)
Definition: target.h:657
all_commands
Definition: command.h:39
get_running_thread_msymbol
static struct bound_minimal_symbol get_running_thread_msymbol(void)
Definition: ravenscar-thread.c:214
TYPE_LENGTH
#define TYPE_LENGTH(thistype)
Definition: gdbtypes.h:1235
ravenscar_update_inferior_ptid
static void ravenscar_update_inferior_ptid(void)
Definition: ravenscar-thread.c:182
target_ops::to_thread_alive
int(* to_thread_alive)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
Definition: target.h:626
ada_build_task_list
int ada_build_task_list(void)
Definition: ada-tasks.c:1011
target_ops::to_stopped_data_address
int(* to_stopped_data_address)(struct target_ops *, CORE_ADDR *) TARGET_DEFAULT_RETURN(0)
Definition: target.h:535
target_ops::to_update_thread_list
void(* to_update_thread_list)(struct target_ops *) TARGET_DEFAULT_IGNORE()
Definition: target.h:628
target_ops::to_prepare_to_store
void(* to_prepare_to_store)(struct target_ops *, struct regcache *) TARGET_DEFAULT_NORETURN(noprocess())
Definition: target.h:461
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
target_ops::to_has_registers
int(* to_has_registers)(struct target_ops *)
Definition: target.h:660
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
class_obscure
Definition: command.h:43
target_ops::to_get_ada_task_ptid
ptid_t(* to_get_ada_task_ptid)(struct target_ops *, long lwp, long thread) TARGET_DEFAULT_FUNC(default_get_ada_task_ptid)
Definition: target.h:797
ravenscar_arch_ops::to_store_registers
void(* to_store_registers)(struct regcache *, int)
Definition: ravenscar-thread.h:28
gdbcmd.h
ravenscar_stopped_by_hw_breakpoint
static int ravenscar_stopped_by_hw_breakpoint(struct target_ops *ops)
Definition: ravenscar-thread.c:458
ravenscar_resume
static void ravenscar_resume(struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal siggnal)
Definition: ravenscar-thread.c:285
thread_info
Definition: gdbthread.h:205
ravenscar_arch_ops::to_prepare_to_store
void(* to_prepare_to_store)(struct regcache *)
Definition: ravenscar-thread.h:29
target_ops::beneath
struct target_ops * beneath
Definition: target.h:414
gdb_stdout
#define gdb_stdout
Definition: utils.h:340
ravenscar_runtime_initializer
static const char ravenscar_runtime_initializer[]
Definition: ravenscar-thread.c:76