GDB (xrefs)
Loading...
Searching...
No Matches
jit.c
Go to the documentation of this file.
1/* Handle JIT code generation in the inferior for GDB, the GNU Debugger.
2
3 Copyright (C) 2009-2023 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
22#include "jit.h"
23#include "jit-reader.h"
24#include "block.h"
25#include "breakpoint.h"
26#include "command.h"
27#include "dictionary.h"
28#include "filenames.h"
29#include "frame-unwind.h"
30#include "gdbcmd.h"
31#include "gdbcore.h"
32#include "inferior.h"
33#include "observable.h"
34#include "objfiles.h"
35#include "regcache.h"
36#include "symfile.h"
37#include "symtab.h"
38#include "target.h"
39#include "gdbsupport/gdb-dlfcn.h"
40#include <sys/stat.h>
41#include "gdb_bfd.h"
42#include "readline/tilde.h"
43#include "completer.h"
44#include <forward_list>
45
46static std::string jit_reader_dir;
47
48static const char jit_break_name[] = "__jit_debug_register_code";
49
50static const char jit_descriptor_name[] = "__jit_debug_descriptor";
51
53static void jit_inferior_exit_hook (struct inferior *inf);
54
55/* True if we want to see trace of jit level stuff. */
56
57static bool jit_debug = false;
58
59/* Print a "jit" debug statement. */
60
61#define jit_debug_printf(fmt, ...) \
62 debug_prefixed_printf_cond (jit_debug, "jit", fmt, ##__VA_ARGS__)
63
64static void
65show_jit_debug (struct ui_file *file, int from_tty,
66 struct cmd_list_element *c, const char *value)
67{
68 gdb_printf (file, _("JIT debugging is %s.\n"), value);
69}
70
71/* Implementation of the "maintenance info jit" command. */
72
73static void
74maint_info_jit_cmd (const char *args, int from_tty)
75{
77 bool printed_header = false;
78
79 gdb::optional<ui_out_emit_table> table_emitter;
80
81 /* Print a line for each JIT-ed objfile. */
82 for (objfile *obj : inf->pspace->objfiles ())
83 {
84 if (obj->jited_data == nullptr)
85 continue;
86
87 if (!printed_header)
88 {
89 table_emitter.emplace (current_uiout, 3, -1, "jit-created-objfiles");
90
91 /* The +2 allows for the leading '0x', then one character for
92 every 4-bits. */
93 int addr_width = 2 + (gdbarch_ptr_bit (obj->arch ()) / 4);
94
95 /* The std::max here selects between the width of an address (as
96 a string) and the width of the column header string. */
97 current_uiout->table_header (std::max (addr_width, 22), ui_left,
98 "jit_code_entry-address",
99 "jit_code_entry address");
100 current_uiout->table_header (std::max (addr_width, 15), ui_left,
101 "symfile-address", "symfile address");
102 current_uiout->table_header (20, ui_left,
103 "symfile-size", "symfile size");
104 current_uiout->table_body ();
105
106 printed_header = true;
107 }
108
109 ui_out_emit_tuple tuple_emitter (current_uiout, "jit-objfile");
110
111 current_uiout->field_core_addr ("jit_code_entry-address", obj->arch (),
112 obj->jited_data->addr);
113 current_uiout->field_core_addr ("symfile-address", obj->arch (),
114 obj->jited_data->symfile_addr);
115 current_uiout->field_unsigned ("symfile-size",
116 obj->jited_data->symfile_size);
117 current_uiout->text ("\n");
118 }
119}
120
122{
123 jit_reader (struct gdb_reader_funcs *f, gdb_dlhandle_up &&h)
124 : functions (f), handle (std::move (h))
125 {
126 }
127
129 {
131 }
132
134
136 gdb_dlhandle_up handle;
137};
138
139/* One reader that has been loaded successfully, and can potentially be used to
140 parse debug info. */
141
142static struct jit_reader *loaded_jit_reader = NULL;
143
144typedef struct gdb_reader_funcs * (reader_init_fn_type) (void);
145static const char reader_init_fn_sym[] = "gdb_init_reader";
146
147/* Try to load FILE_NAME as a JIT debug info reader. */
148
149static struct jit_reader *
150jit_reader_load (const char *file_name)
151{
152 reader_init_fn_type *init_fn;
153 struct gdb_reader_funcs *funcs = NULL;
154
155 jit_debug_printf ("Opening shared object %s", file_name);
156
157 gdb_dlhandle_up so = gdb_dlopen (file_name);
158
159 init_fn = (reader_init_fn_type *) gdb_dlsym (so, reader_init_fn_sym);
160 if (!init_fn)
161 error (_("Could not locate initialization function: %s."),
163
164 if (gdb_dlsym (so, "plugin_is_GPL_compatible") == NULL)
165 error (_("Reader not GPL compatible."));
166
167 funcs = init_fn ();
169 error (_("Reader version does not match GDB version."));
170
171 return new jit_reader (funcs, std::move (so));
172}
173
174/* Provides the jit-reader-load command. */
175
176static void
177jit_reader_load_command (const char *args, int from_tty)
178{
179 if (args == NULL)
180 error (_("No reader name provided."));
181 gdb::unique_xmalloc_ptr<char> file (tilde_expand (args));
182
183 if (loaded_jit_reader != NULL)
184 error (_("JIT reader already loaded. Run jit-reader-unload first."));
185
186 if (!IS_ABSOLUTE_PATH (file.get ()))
187 file = xstrprintf ("%s%s%s", jit_reader_dir.c_str (),
188 SLASH_STRING, file.get ());
189
190 loaded_jit_reader = jit_reader_load (file.get ());
193}
194
195/* Provides the jit-reader-unload command. */
196
197static void
198jit_reader_unload_command (const char *args, int from_tty)
199{
201 error (_("No JIT reader loaded."));
202
205
206 delete loaded_jit_reader;
207 loaded_jit_reader = NULL;
208}
209
210/* Destructor for jiter_objfile_data. */
211
213{
214 if (this->jit_breakpoint != nullptr)
216}
217
218/* Fetch the jiter_objfile_data associated with OBJF. If no data exists
219 yet, make a new structure and attach it. */
220
221static jiter_objfile_data *
223{
224 if (objf->jiter_data == nullptr)
225 objf->jiter_data.reset (new jiter_objfile_data ());
226
227 return objf->jiter_data.get ();
228}
229
230/* Remember OBJFILE has been created for struct jit_code_entry located
231 at inferior address ENTRY. */
232
233static void
234add_objfile_entry (struct objfile *objfile, CORE_ADDR entry,
235 CORE_ADDR symfile_addr, ULONGEST symfile_size)
236{
237 gdb_assert (objfile->jited_data == nullptr);
238
239 objfile->jited_data.reset (new jited_objfile_data (entry, symfile_addr,
240 symfile_size));
241}
242
243/* Helper function for reading the global JIT descriptor from remote
244 memory. Returns true if all went well, false otherwise. */
245
246static bool
248 jit_descriptor *descriptor,
249 objfile *jiter)
250{
251 int err;
252 struct type *ptr_type;
253 int ptr_size;
254 int desc_size;
255 gdb_byte *desc_buf;
256 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
257
258 gdb_assert (jiter != nullptr);
259 jiter_objfile_data *objf_data = jiter->jiter_data.get ();
260 gdb_assert (objf_data != nullptr);
261
262 CORE_ADDR addr = objf_data->descriptor->value_address (jiter);
263
264 jit_debug_printf ("descriptor_addr = %s", paddress (gdbarch, addr));
265
266 /* Figure out how big the descriptor is on the remote and how to read it. */
268 ptr_size = ptr_type->length ();
269 desc_size = 8 + 2 * ptr_size; /* Two 32-bit ints and two pointers. */
270 desc_buf = (gdb_byte *) alloca (desc_size);
271
272 /* Read the descriptor. */
273 err = target_read_memory (addr, desc_buf, desc_size);
274 if (err)
275 {
276 gdb_printf (gdb_stderr, _("Unable to read JIT descriptor from "
277 "remote memory\n"));
278 return false;
279 }
280
281 /* Fix the endianness to match the host. */
282 descriptor->version = extract_unsigned_integer (&desc_buf[0], 4, byte_order);
283 descriptor->action_flag =
284 extract_unsigned_integer (&desc_buf[4], 4, byte_order);
285 descriptor->relevant_entry = extract_typed_address (&desc_buf[8], ptr_type);
286 descriptor->first_entry =
287 extract_typed_address (&desc_buf[8 + ptr_size], ptr_type);
288
289 return true;
290}
291
292/* Helper function for reading a JITed code entry from remote memory. */
293
294static void
296 CORE_ADDR code_addr, struct jit_code_entry *code_entry)
297{
298 int err, off;
299 struct type *ptr_type;
300 int ptr_size;
301 int entry_size;
302 int align_bytes;
303 gdb_byte *entry_buf;
304 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
305
306 /* Figure out how big the entry is on the remote and how to read it. */
308 ptr_size = ptr_type->length ();
309
310 /* Figure out where the uint64_t value will be. */
311 align_bytes = type_align (builtin_type (gdbarch)->builtin_uint64);
312 off = 3 * ptr_size;
313 off = (off + (align_bytes - 1)) & ~(align_bytes - 1);
314
315 entry_size = off + 8; /* Three pointers and one 64-bit int. */
316 entry_buf = (gdb_byte *) alloca (entry_size);
317
318 /* Read the entry. */
319 err = target_read_memory (code_addr, entry_buf, entry_size);
320 if (err)
321 error (_("Unable to read JIT code entry from remote memory!"));
322
323 /* Fix the endianness to match the host. */
325 code_entry->next_entry = extract_typed_address (&entry_buf[0], ptr_type);
326 code_entry->prev_entry =
327 extract_typed_address (&entry_buf[ptr_size], ptr_type);
328 code_entry->symfile_addr =
329 extract_typed_address (&entry_buf[2 * ptr_size], ptr_type);
330 code_entry->symfile_size =
331 extract_unsigned_integer (&entry_buf[off], 8, byte_order);
332}
333
334/* Proxy object for building a block. */
335
337{
338 gdb_block (gdb_block *parent, CORE_ADDR begin, CORE_ADDR end,
339 const char *name)
340 : parent (parent),
341 begin (begin),
342 end (end),
343 name (name != nullptr ? xstrdup (name) : nullptr)
344 {}
345
346 /* The parent of this block. */
348
349 /* Points to the "real" block that is being built out of this
350 instance. This block will be added to a blockvector, which will
351 then be added to a symtab. */
352 struct block *real_block = nullptr;
353
354 /* The first and last code address corresponding to this block. */
355 CORE_ADDR begin, end;
356
357 /* The name of this block (if any). If this is non-NULL, the
358 FUNCTION symbol symbol is set to this value. */
359 gdb::unique_xmalloc_ptr<char> name;
360};
361
362/* Proxy object for building a symtab. */
363
365{
366 explicit gdb_symtab (const char *file_name)
367 : file_name (file_name != nullptr ? file_name : "")
368 {}
369
370 /* The list of blocks in this symtab. These will eventually be
371 converted to real blocks.
372
373 This is specifically a linked list, instead of, for example, a vector,
374 because the pointers are returned to the user's debug info reader. So
375 it's important that the objects don't change location during their
376 lifetime (which would happen with a vector of objects getting resized). */
377 std::forward_list<gdb_block> blocks;
378
379 /* The number of blocks inserted. */
380 int nblocks = 0;
381
382 /* A mapping between line numbers to PC. */
383 gdb::unique_xmalloc_ptr<struct linetable> linetable;
384
385 /* The source file for this symtab. */
386 std::string file_name;
387};
388
389/* Proxy object for building an object. */
390
392{
393 /* Symtabs of this object.
394
395 This is specifically a linked list, instead of, for example, a vector,
396 because the pointers are returned to the user's debug info reader. So
397 it's important that the objects don't change location during their
398 lifetime (which would happen with a vector of objects getting resized). */
399 std::forward_list<gdb_symtab> symtabs;
400};
401
402/* The type of the `private' data passed around by the callback
403 functions. */
404
406{
407 /* Address of the jit_code_entry in the inferior's address space. */
408 CORE_ADDR entry_addr;
409
410 /* The code entry, copied in our address space. */
412
414};
415
416/* The reader calls into this function to read data off the targets
417 address space. */
418
419static enum gdb_status
420jit_target_read_impl (GDB_CORE_ADDR target_mem, void *gdb_buf, int len)
421{
422 int result = target_read_memory ((CORE_ADDR) target_mem,
423 (gdb_byte *) gdb_buf, len);
424 if (result == 0)
425 return GDB_SUCCESS;
426 else
427 return GDB_FAIL;
428}
429
430/* The reader calls into this function to create a new gdb_object
431 which it can then pass around to the other callbacks. Right now,
432 all that is required is allocating the memory. */
433
434static struct gdb_object *
436{
437 /* CB is not required right now, but sometime in the future we might
438 need a handle to it, and we'd like to do that without breaking
439 the ABI. */
440 return new gdb_object;
441}
442
443/* Readers call into this function to open a new gdb_symtab, which,
444 again, is passed around to other callbacks. */
445
446static struct gdb_symtab *
448 struct gdb_object *object,
449 const char *file_name)
450{
451 /* CB stays unused. See comment in jit_object_open_impl. */
452
453 object->symtabs.emplace_front (file_name);
454 return &object->symtabs.front ();
455}
456
457/* Called by readers to open a new gdb_block. This function also
458 inserts the new gdb_block in the correct place in the corresponding
459 gdb_symtab. */
460
461static struct gdb_block *
463 struct gdb_symtab *symtab, struct gdb_block *parent,
465{
466 /* Place the block at the beginning of the list, it will be sorted when the
467 symtab is finalized. */
468 symtab->blocks.emplace_front (parent, begin, end, name);
469 symtab->nblocks++;
470
471 return &symtab->blocks.front ();
472}
473
474/* Readers call this to add a line mapping (from PC to line number) to
475 a gdb_symtab. */
476
477static void
479 struct gdb_symtab *stab, int nlines,
480 struct gdb_line_mapping *map)
481{
482 int i;
483 int alloc_len;
484
485 if (nlines < 1)
486 return;
487
488 alloc_len = sizeof (struct linetable)
489 + (nlines - 1) * sizeof (struct linetable_entry);
490 stab->linetable.reset (XNEWVAR (struct linetable, alloc_len));
491 stab->linetable->nitems = nlines;
492 for (i = 0; i < nlines; i++)
493 {
494 stab->linetable->item[i].pc = (CORE_ADDR) map[i].pc;
495 stab->linetable->item[i].line = map[i].line;
496 stab->linetable->item[i].is_stmt = 1;
497 }
498}
499
500/* Called by readers to close a gdb_symtab. Does not need to do
501 anything as of now. */
502
503static void
505 struct gdb_symtab *stab)
506{
507 /* Right now nothing needs to be done here. We may need to do some
508 cleanup here in the future (again, without breaking the plugin
509 ABI). */
510}
511
512/* Transform STAB to a proper symtab, and add it it OBJFILE. */
513
514static void
516{
517 struct compunit_symtab *cust;
518 size_t blockvector_size;
519 CORE_ADDR begin, end;
520 struct blockvector *bv;
521
522 int actual_nblocks = FIRST_LOCAL_BLOCK + stab->nblocks;
523
524 /* Sort the blocks in the order they should appear in the blockvector. */
525 stab->blocks.sort([] (const gdb_block &a, const gdb_block &b)
526 {
527 if (a.begin != b.begin)
528 return a.begin < b.begin;
529
530 return a.end > b.end;
531 });
532
533 cust = allocate_compunit_symtab (objfile, stab->file_name.c_str ());
534 symtab *filetab = allocate_symtab (cust, stab->file_name.c_str ());
536
537 /* JIT compilers compile in memory. */
538 cust->set_dirname (nullptr);
539
540 /* Copy over the linetable entry if one was provided. */
541 if (stab->linetable)
542 {
543 size_t size = ((stab->linetable->nitems - 1)
544 * sizeof (struct linetable_entry)
545 + sizeof (struct linetable));
546 filetab->set_linetable ((struct linetable *)
547 obstack_alloc (&objfile->objfile_obstack, size));
548 memcpy (filetab->linetable (), stab->linetable.get (), size);
549 }
550
551 blockvector_size = (sizeof (struct blockvector)
552 + (actual_nblocks - 1) * sizeof (struct block *));
553 bv = (struct blockvector *) obstack_alloc (&objfile->objfile_obstack,
554 blockvector_size);
555 cust->set_blockvector (bv);
556
557 /* At the end of this function, (begin, end) will contain the PC range this
558 entire blockvector spans. */
559 bv->set_map (nullptr);
560 begin = stab->blocks.front ().begin;
561 end = stab->blocks.front ().end;
562 bv->set_num_blocks (actual_nblocks);
563
564 /* First run over all the gdb_block objects, creating a real block
565 object for each. Simultaneously, keep setting the real_block
566 fields. */
567 int block_idx = FIRST_LOCAL_BLOCK;
568 for (gdb_block &gdb_block_iter : stab->blocks)
569 {
571 struct symbol *block_name = new (&objfile->objfile_obstack) symbol;
572 struct type *block_type = arch_type (objfile->arch (),
573 TYPE_CODE_VOID,
574 TARGET_CHAR_BIT,
575 "void");
576
579 /* The address range. */
580 new_block->set_start (gdb_block_iter.begin);
581 new_block->set_end (gdb_block_iter.end);
582
583 /* The name. */
584 block_name->set_domain (VAR_DOMAIN);
585 block_name->set_aclass_index (LOC_BLOCK);
586 block_name->set_symtab (filetab);
588 block_name->set_value_block (new_block);
589
590 block_name->m_name = obstack_strdup (&objfile->objfile_obstack,
591 gdb_block_iter.name.get ());
592
593 new_block->set_function (block_name);
594
595 bv->set_block (block_idx, new_block);
596 if (begin > new_block->start ())
597 begin = new_block->start ();
598 if (end < new_block->end ())
599 end = new_block->end ();
600
601 gdb_block_iter.real_block = new_block;
602
603 block_idx++;
604 }
605
606 /* Now add the special blocks. */
607 struct block *block_iter = NULL;
608 for (enum block_enum i : { GLOBAL_BLOCK, STATIC_BLOCK })
609 {
610 struct block *new_block;
611
612 new_block = (i == GLOBAL_BLOCK
617 new_block->set_superblock (block_iter);
618 block_iter = new_block;
619
620 new_block->set_start (begin);
622
623 bv->set_block (i, new_block);
624
625 if (i == GLOBAL_BLOCK)
627 }
628
629 /* Fill up the superblock fields for the real blocks, using the
630 real_block fields populated earlier. */
631 for (gdb_block &gdb_block_iter : stab->blocks)
632 {
633 if (gdb_block_iter.parent != NULL)
634 {
635 /* If the plugin specifically mentioned a parent block, we
636 use that. */
637 gdb_block_iter.real_block->set_superblock
638 (gdb_block_iter.parent->real_block);
639
640 }
641 else
642 {
643 /* And if not, we set a default parent block. */
644 gdb_block_iter.real_block->set_superblock (bv->static_block ());
645 }
646 }
647}
648
649/* Called when closing a gdb_objfile. Converts OBJ to a proper
650 objfile. */
651
652static void
654 struct gdb_object *obj)
655{
657 std::string objfile_name
658 = string_printf ("<< JIT compiled code at %s >>",
659 paddress (priv_data->gdbarch,
660 priv_data->entry.symfile_addr));
661
662 objfile *objfile = objfile::make (nullptr, objfile_name.c_str (),
664 objfile->per_bfd->gdbarch = priv_data->gdbarch;
665
666 for (gdb_symtab &symtab : obj->symtabs)
668
670 priv_data->entry.symfile_addr,
671 priv_data->entry.symfile_size);
672
673 delete obj;
674}
675
676/* Try to read CODE_ENTRY using the loaded jit reader (if any).
677 ENTRY_ADDR is the address of the struct jit_code_entry in the
678 inferior address space. */
679
680static int
682 CORE_ADDR entry_addr)
683{
684 int status;
685 jit_dbg_reader_data priv_data
686 {
687 entry_addr,
688 *code_entry,
689 gdbarch
690 };
691 struct gdb_reader_funcs *funcs;
692 struct gdb_symbol_callbacks callbacks =
693 {
699
702
703 &priv_data
704 };
705
707 return 0;
708
709 gdb::byte_vector gdb_mem (code_entry->symfile_size);
710
711 status = 1;
712 try
713 {
714 if (target_read_memory (code_entry->symfile_addr, gdb_mem.data (),
715 code_entry->symfile_size))
716 status = 0;
717 }
718 catch (const gdb_exception &e)
719 {
720 status = 0;
721 }
722
723 if (status)
724 {
726 if (funcs->read (funcs, &callbacks, gdb_mem.data (),
727 code_entry->symfile_size)
728 != GDB_SUCCESS)
729 status = 0;
730 }
731
732 if (status == 0)
733 jit_debug_printf ("Could not read symtab using the loaded JIT reader.");
734
735 return status;
736}
737
738/* Try to read CODE_ENTRY using BFD. ENTRY_ADDR is the address of the
739 struct jit_code_entry in the inferior address space. */
740
741static void
743 CORE_ADDR entry_addr,
744 struct gdbarch *gdbarch)
745{
746 struct bfd_section *sec;
747 struct objfile *objfile;
748 const struct bfd_arch_info *b;
749
750 jit_debug_printf ("symfile_addr = %s, symfile_size = %s",
751 paddress (gdbarch, code_entry->symfile_addr),
752 pulongest (code_entry->symfile_size));
753
755 (code_entry->symfile_addr, code_entry->symfile_size, gnutarget));
756 if (nbfd == NULL)
757 {
758 gdb_puts (_("Error opening JITed symbol file, ignoring it.\n"),
759 gdb_stderr);
760 return;
761 }
762
763 /* Check the format. NOTE: This initializes important data that GDB uses!
764 We would segfault later without this line. */
765 if (!bfd_check_format (nbfd.get (), bfd_object))
766 {
768JITed symbol file is not an object file, ignoring it.\n"));
769 return;
770 }
771
772 /* Check bfd arch. */
774 if (b->compatible (b, bfd_get_arch_info (nbfd.get ())) != b)
775 warning (_("JITed object file architecture %s is not compatible "
776 "with target architecture %s."),
777 bfd_get_arch_info (nbfd.get ())->printable_name,
778 b->printable_name);
779
780 /* Read the section address information out of the symbol file. Since the
781 file is generated by the JIT at runtime, it should all of the absolute
782 addresses that we care about. */
784 for (sec = nbfd->sections; sec != NULL; sec = sec->next)
785 if ((bfd_section_flags (sec) & (SEC_ALLOC|SEC_LOAD)) != 0)
786 {
787 /* We assume that these virtual addresses are absolute, and do not
788 treat them as offsets. */
789 sai.emplace_back (bfd_section_vma (sec),
790 bfd_section_name (sec),
791 sec->index);
792 }
793
794 /* This call does not take ownership of SAI. */
796 bfd_get_filename (nbfd.get ()), 0,
797 &sai,
799
800 add_objfile_entry (objfile, entry_addr, code_entry->symfile_addr,
801 code_entry->symfile_size);
802}
803
804/* This function registers code associated with a JIT code entry. It uses the
805 pointer and size pair in the entry to read the symbol file from the remote
806 and then calls symbol_file_add_from_local_memory to add it as though it were
807 a symbol file added by the user. */
808
809static void
811 CORE_ADDR entry_addr, struct jit_code_entry *code_entry)
812{
813 int success;
814
815 jit_debug_printf ("symfile_addr = %s, symfile_size = %s",
816 paddress (gdbarch, code_entry->symfile_addr),
817 pulongest (code_entry->symfile_size));
818
819 success = jit_reader_try_read_symtab (gdbarch, code_entry, entry_addr);
820
821 if (!success)
822 jit_bfd_try_read_symtab (code_entry, entry_addr, gdbarch);
823}
824
825/* Look up the objfile with this code entry address. */
826
827static struct objfile *
828jit_find_objf_with_entry_addr (CORE_ADDR entry_addr)
829{
830 for (objfile *objf : current_program_space->objfiles ())
831 {
832 if (objf->jited_data != nullptr && objf->jited_data->addr == entry_addr)
833 return objf;
834 }
835
836 return NULL;
837}
838
839/* This is called when a breakpoint is deleted. It updates the
840 inferior's cache, if needed. */
841
842static void
844{
845 if (b->type != bp_jit_event)
846 return;
847
848 for (bp_location *iter : b->locations ())
849 {
850 for (objfile *objf : iter->pspace->objfiles ())
851 {
852 jiter_objfile_data *jiter_data = objf->jiter_data.get ();
853
854 if (jiter_data != nullptr
855 && jiter_data->jit_breakpoint == iter->owner)
856 {
857 jiter_data->cached_code_address = 0;
858 jiter_data->jit_breakpoint = nullptr;
859 }
860 }
861 }
862}
863
864/* (Re-)Initialize the jit breakpoints for JIT-producing objfiles in
865 PSPACE. */
866
867static void
869{
870 for (objfile *the_objfile : pspace->objfiles ())
871 {
872 /* Skip separate debug objects. */
873 if (the_objfile->separate_debug_objfile_backlink != nullptr)
874 continue;
875
876 if (the_objfile->skip_jit_symbol_lookup)
877 continue;
878
879 /* Lookup the registration symbol. If it is missing, then we
880 assume we are not attached to a JIT. */
881 bound_minimal_symbol reg_symbol
882 = lookup_minimal_symbol (jit_break_name, nullptr, the_objfile);
883 if (reg_symbol.minsym == NULL
884 || reg_symbol.value_address () == 0)
885 {
886 /* No need to repeat the lookup the next time. */
887 the_objfile->skip_jit_symbol_lookup = true;
888 continue;
889 }
890
891 bound_minimal_symbol desc_symbol
892 = lookup_minimal_symbol (jit_descriptor_name, NULL, the_objfile);
893 if (desc_symbol.minsym == NULL
894 || desc_symbol.value_address () == 0)
895 {
896 /* No need to repeat the lookup the next time. */
897 the_objfile->skip_jit_symbol_lookup = true;
898 continue;
899 }
900
901 jiter_objfile_data *objf_data
902 = get_jiter_objfile_data (the_objfile);
903 objf_data->register_code = reg_symbol.minsym;
904 objf_data->descriptor = desc_symbol.minsym;
905
906 CORE_ADDR addr = objf_data->register_code->value_address (the_objfile);
907 jit_debug_printf ("breakpoint_addr = %s", paddress (gdbarch, addr));
908
909 /* Check if we need to re-create the breakpoint. */
910 if (objf_data->cached_code_address == addr)
911 continue;
912
913 /* Delete the old breakpoint. */
914 if (objf_data->jit_breakpoint != nullptr)
916
917 /* Put a breakpoint in the registration symbol. */
918 objf_data->cached_code_address = addr;
920 }
921}
922
923/* The private data passed around in the frame unwind callback
924 functions. */
925
927{
928 /* Cached register values. See jit_frame_sniffer to see how this
929 works. */
930 std::unique_ptr<detached_regcache> regcache;
931
932 /* The frame being unwound. */
934};
935
936/* Sets the value of a particular register in this frame. */
937
938static void
939jit_unwind_reg_set_impl (struct gdb_unwind_callbacks *cb, int dwarf_regnum,
940 struct gdb_reg_value *value)
941{
942 struct jit_unwind_private *priv;
943 int gdb_reg;
944
945 priv = (struct jit_unwind_private *) cb->priv_data;
946
948 dwarf_regnum);
949 if (gdb_reg == -1)
950 {
951 jit_debug_printf ("Could not recognize DWARF regnum %d", dwarf_regnum);
952 value->free (value);
953 return;
954 }
955
956 priv->regcache->raw_supply (gdb_reg, value->value);
957 value->free (value);
958}
959
960static void
962{
963 xfree (value);
964}
965
966/* Get the value of register REGNUM in the previous frame. */
967
968static struct gdb_reg_value *
970{
971 struct jit_unwind_private *priv;
972 struct gdb_reg_value *value;
973 int gdb_reg, size;
974 struct gdbarch *frame_arch;
975
976 priv = (struct jit_unwind_private *) cb->priv_data;
977 frame_arch = get_frame_arch (priv->this_frame);
978
979 gdb_reg = gdbarch_dwarf2_reg_to_regnum (frame_arch, regnum);
980 size = register_size (frame_arch, gdb_reg);
981 value = ((struct gdb_reg_value *)
982 xmalloc (sizeof (struct gdb_reg_value) + size - 1));
983 value->defined = deprecated_frame_register_read (priv->this_frame, gdb_reg,
984 value->value);
985 value->size = size;
987 return value;
988}
989
990/* gdb_reg_value has a free function, which must be called on each
991 saved register value. */
992
993static void
994jit_dealloc_cache (frame_info *this_frame, void *cache)
995{
996 struct jit_unwind_private *priv_data = (struct jit_unwind_private *) cache;
997 delete priv_data;
998}
999
1000/* The frame sniffer for the pseudo unwinder.
1001
1002 While this is nominally a frame sniffer, in the case where the JIT
1003 reader actually recognizes the frame, it does a lot more work -- it
1004 unwinds the frame and saves the corresponding register values in
1005 the cache. jit_frame_prev_register simply returns the saved
1006 register values. */
1007
1008static int
1010 frame_info_ptr this_frame, void **cache)
1011{
1012 struct jit_unwind_private *priv_data;
1013 struct gdb_unwind_callbacks callbacks;
1014 struct gdb_reader_funcs *funcs;
1015
1016 callbacks.reg_get = jit_unwind_reg_get_impl;
1017 callbacks.reg_set = jit_unwind_reg_set_impl;
1019
1020 if (loaded_jit_reader == NULL)
1021 return 0;
1022
1024
1025 gdb_assert (!*cache);
1026
1027 priv_data = new struct jit_unwind_private;
1028 *cache = priv_data;
1029 /* Take a snapshot of current regcache. */
1030 priv_data->regcache.reset
1032 priv_data->this_frame = this_frame;
1033
1034 callbacks.priv_data = priv_data;
1035
1036 /* Try to coax the provided unwinder to unwind the stack */
1037 if (funcs->unwind (funcs, &callbacks) == GDB_SUCCESS)
1038 {
1039 jit_debug_printf ("Successfully unwound frame using JIT reader.");
1040 return 1;
1041 }
1042
1043 jit_debug_printf ("Could not unwind frame using JIT reader.");
1044
1045 jit_dealloc_cache (this_frame.get (), *cache);
1046 *cache = NULL;
1047
1048 return 0;
1049}
1050
1051
1052/* The frame_id function for the pseudo unwinder. Relays the call to
1053 the loaded plugin. */
1054
1055static void
1057 struct frame_id *this_id)
1058{
1059 struct jit_unwind_private priv;
1060 struct gdb_frame_id frame_id;
1061 struct gdb_reader_funcs *funcs;
1062 struct gdb_unwind_callbacks callbacks;
1063
1064 priv.regcache.reset ();
1065 priv.this_frame = this_frame;
1066
1067 /* We don't expect the frame_id function to set any registers, so we
1068 set reg_set to NULL. */
1069 callbacks.reg_get = jit_unwind_reg_get_impl;
1070 callbacks.reg_set = NULL;
1072 callbacks.priv_data = &priv;
1073
1074 gdb_assert (loaded_jit_reader);
1076
1077 frame_id = funcs->get_frame_id (funcs, &callbacks);
1078 *this_id = frame_id_build (frame_id.stack_address, frame_id.code_address);
1079}
1080
1081/* Pseudo unwinder function. Reads the previously fetched value for
1082 the register from the cache. */
1083
1084static struct value *
1085jit_frame_prev_register (frame_info_ptr this_frame, void **cache, int reg)
1086{
1087 struct jit_unwind_private *priv = (struct jit_unwind_private *) *cache;
1088 struct gdbarch *gdbarch;
1089
1090 if (priv == NULL)
1091 return frame_unwind_got_optimized (this_frame, reg);
1092
1093 gdbarch = priv->regcache->arch ();
1094 gdb_byte *buf = (gdb_byte *) alloca (register_size (gdbarch, reg));
1095 enum register_status status = priv->regcache->cooked_read (reg, buf);
1096
1097 if (status == REG_VALID)
1098 return frame_unwind_got_bytes (this_frame, reg, buf);
1099 else
1100 return frame_unwind_got_optimized (this_frame, reg);
1101}
1102
1103/* Relay everything back to the unwinder registered by the JIT debug
1104 info reader.*/
1105
1106static const struct frame_unwind jit_frame_unwind =
1107{
1108 "jit",
1113 NULL,
1116};
1117
1118
1119/* This is the information that is stored at jit_gdbarch_data for each
1120 architecture. */
1121
1123{
1124 /* Has the (pseudo) unwinder been pretended? */
1126};
1127
1128/* An unwinder is registered for every gdbarch. This key is used to
1129 remember if the unwinder has been registered for a particular
1130 gdbarch. */
1131
1133
1134/* Check GDBARCH and prepend the pseudo JIT unwinder if needed. */
1135
1136static void
1138{
1140 if (data == nullptr)
1141 data = jit_gdbarch_data.emplace (gdbarch);
1142
1143 if (!data->unwinder_registered)
1144 {
1146 data->unwinder_registered = 1;
1147 }
1148}
1149
1150/* Register any already created translations. */
1151
1152static void
1154{
1155 struct jit_descriptor descriptor;
1156 struct jit_code_entry cur_entry;
1157 CORE_ADDR cur_entry_addr;
1158 struct gdbarch *gdbarch = inf->gdbarch;
1159 program_space *pspace = inf->pspace;
1160
1161 jit_debug_printf ("called");
1162
1164
1166
1167 for (objfile *jiter : pspace->objfiles ())
1168 {
1169 if (jiter->jiter_data == nullptr)
1170 continue;
1171
1172 /* Read the descriptor so we can check the version number and load
1173 any already JITed functions. */
1174 if (!jit_read_descriptor (gdbarch, &descriptor, jiter))
1175 continue;
1176
1177 /* Check that the version number agrees with that we support. */
1178 if (descriptor.version != 1)
1179 {
1181 _("Unsupported JIT protocol version %ld "
1182 "in descriptor (expected 1)\n"),
1183 (long) descriptor.version);
1184 continue;
1185 }
1186
1187 /* If we've attached to a running program, we need to check the
1188 descriptor to register any functions that were already
1189 generated. */
1190 for (cur_entry_addr = descriptor.first_entry;
1191 cur_entry_addr != 0;
1192 cur_entry_addr = cur_entry.next_entry)
1193 {
1194 jit_read_code_entry (gdbarch, cur_entry_addr, &cur_entry);
1195
1196 /* This hook may be called many times during setup, so make sure
1197 we don't add the same symbol file twice. */
1198 if (jit_find_objf_with_entry_addr (cur_entry_addr) != NULL)
1199 continue;
1200
1201 jit_register_code (gdbarch, cur_entry_addr, &cur_entry);
1202 }
1203 }
1204}
1205
1206/* Looks for the descriptor and registration symbols and breakpoints
1207 the registration function. If it finds both, it registers all the
1208 already JITed code. If it has already found the symbols, then it
1209 doesn't try again. */
1210
1211static void
1213{
1215}
1216
1217/* Exported routine to call to re-set the jit breakpoints,
1218 e.g. when a program is rerun. */
1219
1220void
1222{
1224}
1225
1226/* This function cleans up any code entries left over when the
1227 inferior exits. We get left over code when the inferior exits
1228 without unregistering its code, for example when it crashes. */
1229
1230static void
1232{
1234 {
1235 if (objf->jited_data != nullptr && objf->jited_data->addr != 0)
1236 objf->unlink ();
1237 }
1238}
1239
1240void
1242{
1243 struct jit_descriptor descriptor;
1244
1245 /* If we get a JIT breakpoint event for this objfile, it is necessarily a
1246 JITer. */
1247 gdb_assert (jiter->jiter_data != nullptr);
1248
1249 /* Read the descriptor from remote memory. */
1250 if (!jit_read_descriptor (gdbarch, &descriptor, jiter))
1251 return;
1252 CORE_ADDR entry_addr = descriptor.relevant_entry;
1253
1254 /* Do the corresponding action. */
1255 switch (descriptor.action_flag)
1256 {
1257 case JIT_NOACTION:
1258 break;
1259
1260 case JIT_REGISTER:
1261 {
1262 jit_code_entry code_entry;
1263 jit_read_code_entry (gdbarch, entry_addr, &code_entry);
1264 jit_register_code (gdbarch, entry_addr, &code_entry);
1265 break;
1266 }
1267
1268 case JIT_UNREGISTER:
1269 {
1270 objfile *jited = jit_find_objf_with_entry_addr (entry_addr);
1271 if (jited == nullptr)
1273 _("Unable to find JITed code "
1274 "entry at address: %s\n"),
1275 paddress (gdbarch, entry_addr));
1276 else
1277 jited->unlink ();
1278
1279 break;
1280 }
1281
1282 default:
1283 error (_("Unknown action_flag value in JIT descriptor!"));
1284 break;
1285 }
1286}
1287
1288void _initialize_jit ();
1289void
1291{
1295 _("Set JIT debugging."),
1296 _("Show JIT debugging."),
1297 _("When set, JIT debugging is enabled."),
1298 NULL,
1301
1303 _("Print information about JIT-ed code objects."),
1305
1310
1311 if (is_dl_available ())
1312 {
1313 struct cmd_list_element *c;
1314
1315 c = add_com ("jit-reader-load", no_class, jit_reader_load_command, _("\
1316Load FILE as debug info reader and unwinder for JIT compiled code.\n\
1317Usage: jit-reader-load FILE\n\
1318Try to load file FILE as a debug info reader (and unwinder) for\n\
1319JIT compiled code. The file is loaded from " JIT_READER_DIR ",\n\
1320relocated relative to the GDB executable if required."));
1322
1323 c = add_com ("jit-reader-unload", no_class,
1325Unload the currently loaded JIT debug info reader.\n\
1326Usage: jit-reader-unload\n\n\
1327Do \"help jit-reader-load\" for info on loading debug info readers."));
1329 }
1330}
int regnum
const char *const name
void * xmalloc(YYSIZE_T)
void xfree(void *)
struct gdbarch * target_gdbarch(void)
void f()
Definition 1.cc:36
struct block * allocate_block(struct obstack *obstack)
Definition block.c:397
struct block * allocate_global_block(struct obstack *obstack)
Definition block.c:407
void set_block_compunit_symtab(struct block *block, struct compunit_symtab *cu)
Definition block.c:417
void delete_breakpoint(struct breakpoint *bpt)
struct breakpoint * create_jit_event_breakpoint(struct gdbarch *gdbarch, CORE_ADDR address)
@ bp_jit_event
Definition breakpoint.h:198
frame_info * get() const
Definition frame-info.h:120
void * get(unsigned key)
Definition registry.h:211
struct cmd_list_element * showdebuglist
Definition cli-cmds.c:165
struct cmd_list_element * maintenanceinfolist
Definition cli-cmds.c:145
struct cmd_list_element * setdebuglist
Definition cli-cmds.c:163
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition cli-decode.c:233
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
Definition cli-decode.c:117
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:739
@ class_maintenance
Definition command.h:65
@ no_class
Definition command.h:53
void noop_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *prefix)
Definition completer.c:195
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition completer.c:204
#define JIT_READER_DIR_RELOCATABLE
Definition config.h:616
#define JIT_READER_DIR
Definition config.h:612
const char * gnutarget
Definition corefile.c:394
std::string relocate_gdb_directory(const char *initial, bool relocatable)
Definition main.c:164
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
Definition findvar.c:153
block_enum
Definition defs.h:630
@ STATIC_BLOCK
Definition defs.h:632
@ GLOBAL_BLOCK
Definition defs.h:631
@ FIRST_LOCAL_BLOCK
Definition defs.h:633
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition defs.h:526
struct multidictionary * mdict_create_linear(struct obstack *obstack, const struct pending *symbol_list)
Definition dictionary.c:993
struct value * frame_unwind_got_optimized(frame_info_ptr frame, int regnum)
void frame_unwind_prepend_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
enum unwind_stop_reason default_frame_unwind_stop_reason(frame_info_ptr this_frame, void **this_cache)
struct value * frame_unwind_got_bytes(frame_info_ptr frame, int regnum, const gdb_byte *buf)
void reinit_frame_cache(void)
Definition frame.c:2006
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition frame.c:713
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition frame.c:2907
bool deprecated_frame_register_read(frame_info_ptr frame, int regnum, gdb_byte *myaddr)
Definition frame.c:1416
@ NORMAL_FRAME
Definition frame.h:179
gdb_bfd_ref_ptr gdb_bfd_open_from_target_memory(CORE_ADDR addr, ULONGEST size, const char *target)
Definition gdb_bfd.c:322
gdb::ref_ptr< struct bfd, gdb_bfd_ref_policy > gdb_bfd_ref_ptr
Definition gdb_bfd.h:78
int gdbarch_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, int dwarf2_regnr)
Definition gdbarch.c:2125
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition gdbarch.c:1370
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
Definition gdbarch.c:1361
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
Definition gdbarch.c:1691
struct type * lookup_function_type(struct type *type)
Definition gdbtypes.c:539
struct type * arch_type(struct gdbarch *gdbarch, enum type_code code, int bit, const char *name)
Definition gdbtypes.c:5815
unsigned type_align(struct type *type)
Definition gdbtypes.c:3645
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
Definition gnu-nat.c:1790
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
Definition gnu-nat.c:1791
size_t size
Definition go32-nat.c:241
struct inferior * current_inferior(void)
Definition inferior.c:54
gdb_status
Definition jit-reader.h:63
@ GDB_SUCCESS
Definition jit-reader.h:65
@ GDB_FAIL
Definition jit-reader.h:64
unsigned long GDB_CORE_ADDR
Definition jit-reader.h:59
#define GDB_READER_INTERFACE_VERSION
Definition jit-reader.h:29
static const char jit_descriptor_name[]
Definition jit.c:50
static void jit_inferior_created_hook(inferior *inf)
Definition jit.c:1212
static void add_objfile_entry(struct objfile *objfile, CORE_ADDR entry, CORE_ADDR symfile_addr, ULONGEST symfile_size)
Definition jit.c:234
static void jit_breakpoint_re_set_internal(struct gdbarch *gdbarch, program_space *pspace)
Definition jit.c:868
static struct gdb_block * jit_block_open_impl(struct gdb_symbol_callbacks *cb, struct gdb_symtab *symtab, struct gdb_block *parent, GDB_CORE_ADDR begin, GDB_CORE_ADDR end, const char *name)
Definition jit.c:462
static int jit_frame_sniffer(const struct frame_unwind *self, frame_info_ptr this_frame, void **cache)
Definition jit.c:1009
static const registry< gdbarch >::key< jit_gdbarch_data_type > jit_gdbarch_data
Definition jit.c:1132
static void reg_value_free_impl(struct gdb_reg_value *value)
Definition jit.c:961
void _initialize_jit()
Definition jit.c:1290
static struct gdb_reg_value * jit_unwind_reg_get_impl(struct gdb_unwind_callbacks *cb, int regnum)
Definition jit.c:969
static void jit_inferior_init(inferior *inf)
Definition jit.c:1153
static void jit_bfd_try_read_symtab(struct jit_code_entry *code_entry, CORE_ADDR entry_addr, struct gdbarch *gdbarch)
Definition jit.c:742
static struct gdb_symtab * jit_symtab_open_impl(struct gdb_symbol_callbacks *cb, struct gdb_object *object, const char *file_name)
Definition jit.c:447
static const struct frame_unwind jit_frame_unwind
Definition jit.c:1106
void jit_event_handler(gdbarch *gdbarch, objfile *jiter)
Definition jit.c:1241
static std::string jit_reader_dir
Definition jit.c:46
static struct jit_reader * loaded_jit_reader
Definition jit.c:142
static void jit_breakpoint_deleted(struct breakpoint *b)
Definition jit.c:843
static void jit_read_code_entry(struct gdbarch *gdbarch, CORE_ADDR code_addr, struct jit_code_entry *code_entry)
Definition jit.c:295
static void jit_reader_load_command(const char *args, int from_tty)
Definition jit.c:177
void jit_breakpoint_re_set(void)
Definition jit.c:1221
static void jit_symtab_close_impl(struct gdb_symbol_callbacks *cb, struct gdb_symtab *stab)
Definition jit.c:504
static void jit_register_code(struct gdbarch *gdbarch, CORE_ADDR entry_addr, struct jit_code_entry *code_entry)
Definition jit.c:810
static void jit_prepend_unwinder(struct gdbarch *gdbarch)
Definition jit.c:1137
static const char jit_break_name[]
Definition jit.c:48
static jiter_objfile_data * get_jiter_objfile_data(objfile *objf)
Definition jit.c:222
static struct jit_reader * jit_reader_load(const char *file_name)
Definition jit.c:150
static void jit_frame_this_id(frame_info_ptr this_frame, void **cache, struct frame_id *this_id)
Definition jit.c:1056
static struct gdb_object * jit_object_open_impl(struct gdb_symbol_callbacks *cb)
Definition jit.c:435
static void jit_reader_unload_command(const char *args, int from_tty)
Definition jit.c:198
static void jit_inferior_exit_hook(struct inferior *inf)
Definition jit.c:1231
static void jit_unwind_reg_set_impl(struct gdb_unwind_callbacks *cb, int dwarf_regnum, struct gdb_reg_value *value)
Definition jit.c:939
struct gdb_reader_funcs *() reader_init_fn_type(void)
Definition jit.c:144
#define jit_debug_printf(fmt,...)
Definition jit.c:61
static struct value * jit_frame_prev_register(frame_info_ptr this_frame, void **cache, int reg)
Definition jit.c:1085
static void jit_dealloc_cache(frame_info *this_frame, void *cache)
Definition jit.c:994
static int jit_reader_try_read_symtab(gdbarch *gdbarch, jit_code_entry *code_entry, CORE_ADDR entry_addr)
Definition jit.c:681
static const char reader_init_fn_sym[]
Definition jit.c:145
static enum gdb_status jit_target_read_impl(GDB_CORE_ADDR target_mem, void *gdb_buf, int len)
Definition jit.c:420
static void jit_symtab_line_mapping_add_impl(struct gdb_symbol_callbacks *cb, struct gdb_symtab *stab, int nlines, struct gdb_line_mapping *map)
Definition jit.c:478
static void finalize_symtab(struct gdb_symtab *stab, struct objfile *objfile)
Definition jit.c:515
static bool jit_read_descriptor(gdbarch *gdbarch, jit_descriptor *descriptor, objfile *jiter)
Definition jit.c:247
static void jit_object_close_impl(struct gdb_symbol_callbacks *cb, struct gdb_object *obj)
Definition jit.c:653
static void show_jit_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition jit.c:65
static bool jit_debug
Definition jit.c:57
static struct objfile * jit_find_objf_with_entry_addr(CORE_ADDR entry_addr)
Definition jit.c:828
static void maint_info_jit_cmd(const char *args, int from_tty)
Definition jit.c:74
@ JIT_REGISTER
Definition jit.h:34
@ JIT_UNREGISTER
Definition jit.h:35
@ JIT_NOACTION
Definition jit.h:33
block_type
Definition mdebugread.c:237
static struct block * new_block(enum block_type, enum language)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition minsyms.c:363
observable< struct inferior * > inferior_exit
observable< struct inferior * > inferior_execd
observable< struct breakpoint * > breakpoint_deleted
observable< inferior * > inferior_created
Definition aarch64.h:50
@ OBJF_SHARED
@ OBJF_NOT_FILENAME
const char * objfile_name(const struct objfile *objfile)
Definition objfiles.c:1308
struct program_space * current_program_space
Definition progspace.c:39
int register_size(struct gdbarch *gdbarch, int regnum)
Definition regcache.c:170
Definition block.h:109
void set_start(CORE_ADDR start)
Definition block.h:115
CORE_ADDR start() const
Definition block.h:111
void set_multidict(multidictionary *multidict)
Definition block.h:147
void set_end(CORE_ADDR end)
Definition block.h:123
CORE_ADDR end() const
Definition block.h:119
void set_superblock(const block *superblock)
Definition block.h:139
void set_function(symbol *function)
Definition block.h:131
struct block * static_block()
Definition block.h:302
void set_map(addrmap *map)
Definition block.h:318
void set_block(int i, struct block *block)
Definition block.h:279
void set_num_blocks(int num_blocks)
Definition block.h:286
CORE_ADDR value_address() const
Definition minsyms.h:41
struct minimal_symbol * minsym
Definition minsyms.h:49
bptype type
Definition breakpoint.h:733
bp_location_range locations() const
struct type * builtin_data_ptr
Definition gdbtypes.h:2303
void set_blockvector(struct blockvector *blockvector)
Definition symtab.h:1783
void set_dirname(const char *dirname)
Definition symtab.h:1768
struct gdb_block * parent
Definition jit.c:347
CORE_ADDR begin
Definition jit.c:355
CORE_ADDR end
Definition jit.c:355
struct block * real_block
Definition jit.c:352
gdb_block(gdb_block *parent, CORE_ADDR begin, CORE_ADDR end, const char *name)
Definition jit.c:338
gdb::unique_xmalloc_ptr< char > name
Definition jit.c:359
std::forward_list< gdb_symtab > symtabs
Definition jit.c:399
gdb_read_debug_info * read
Definition jit-reader.h:336
gdb_destroy_reader * destroy
Definition jit-reader.h:339
gdb_unwind_frame * unwind
Definition jit-reader.h:337
gdb_get_frame_id * get_frame_id
Definition jit-reader.h:338
unsigned char value[1]
Definition jit-reader.h:211
int nblocks
Definition jit.c:380
gdb::unique_xmalloc_ptr< struct linetable > linetable
Definition jit.c:383
std::forward_list< gdb_block > blocks
Definition jit.c:377
std::string file_name
Definition jit.c:386
gdb_symtab(const char *file_name)
Definition jit.c:366
gdb_unwind_reg_set * reg_set
Definition jit-reader.h:271
gdb_target_read * target_read
Definition jit-reader.h:272
gdb_unwind_reg_get * reg_get
Definition jit-reader.h:270
const char * m_name
Definition symtab.h:532
Definition gnu-nat.c:154
Definition jit.h:46
CORE_ADDR symfile_addr
Definition jit.h:49
CORE_ADDR next_entry
Definition jit.h:47
CORE_ADDR prev_entry
Definition jit.h:48
ULONGEST symfile_size
Definition jit.h:50
struct gdbarch * gdbarch
Definition jit.c:413
const jit_code_entry & entry
Definition jit.c:411
CORE_ADDR entry_addr
Definition jit.c:408
uint32_t action_flag
Definition jit.h:66
CORE_ADDR first_entry
Definition jit.h:68
uint32_t version
Definition jit.h:63
CORE_ADDR relevant_entry
Definition jit.h:67
gdb_dlhandle_up handle
Definition jit.c:136
~jit_reader()
Definition jit.c:128
DISABLE_COPY_AND_ASSIGN(jit_reader)
struct gdb_reader_funcs * functions
Definition jit.c:135
jit_reader(struct gdb_reader_funcs *f, gdb_dlhandle_up &&h)
Definition jit.c:123
frame_info_ptr this_frame
Definition jit.c:933
std::unique_ptr< detached_regcache > regcache
Definition jit.c:930
~jiter_objfile_data()
Definition jit.c:212
breakpoint * jit_breakpoint
Definition jit.h:90
CORE_ADDR cached_code_address
Definition jit.h:87
minimal_symbol * register_code
Definition jit.h:79
minimal_symbol * descriptor
Definition jit.h:82
Definition symtab.h:1548
CORE_ADDR pc
Definition symtab.h:1560
CORE_ADDR value_address(objfile *objfile) const
Definition symtab.c:421
struct gdbarch * gdbarch
Definition objfiles.h:276
std::unique_ptr< jiter_objfile_data > jiter_data
Definition objfiles.h:776
struct program_space * pspace
Definition objfiles.h:641
struct gdbarch * arch() const
Definition objfiles.h:482
struct objfile_per_bfd_storage * per_bfd
Definition objfiles.h:657
static objfile * make(gdb_bfd_ref_ptr bfd_, const char *name_, objfile_flags flags_, objfile *parent=nullptr)
Definition objfiles.c:451
std::unique_ptr< jited_objfile_data > jited_data
Definition objfiles.h:780
auto_obstack objfile_obstack
Definition objfiles.h:673
void unlink()
Definition objfiles.c:470
objfiles_safe_range objfiles_safe()
Definition progspace.h:225
objfiles_range objfiles()
Definition progspace.h:209
void set_value_block(const block *block)
Definition symtab.h:1353
void set_aclass_index(unsigned int aclass_index)
Definition symtab.h:1225
void set_type(struct type *type)
Definition symtab.h:1290
void set_domain(domain_enum domain)
Definition symtab.h:1245
void set_symtab(struct symtab *symtab)
Definition symtab.c:6505
void set_linetable(struct linetable *linetable)
Definition symtab.h:1618
struct linetable * linetable() const
Definition symtab.h:1613
ULONGEST length() const
Definition gdbtypes.h:954
Definition value.c:181
struct value::@195::@196 reg
value(struct type *type_)
Definition value.c:182
void add_compunit_symtab_to_objfile(struct compunit_symtab *cu)
Definition symfile.c:2851
struct symtab * allocate_symtab(struct compunit_symtab *cust, const char *filename, const char *filename_for_id)
Definition symfile.c:2778
struct compunit_symtab * allocate_compunit_symtab(struct objfile *objfile, const char *name)
Definition symfile.c:2825
struct objfile * symbol_file_add_from_bfd(const gdb_bfd_ref_ptr &abfd, const char *name, symfile_add_flags add_flags, section_addr_info *addrs, objfile_flags flags, struct objfile *parent)
Definition symfile.c:1163
std::vector< other_sections > section_addr_info
Definition symfile.h:74
@ LOC_BLOCK
Definition symtab.h:999
@ VAR_DOMAIN
Definition symtab.h:881
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition target.c:1771
@ ui_left
Definition ui-out.h:45
#define current_uiout
Definition ui-out.h:40
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition utils.c:3114
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1865
void gdb_puts(const char *linebuffer, struct ui_file *stream)
Definition utils.c:1788
#define gdb_stderr
Definition utils.h:193