gdb/jit: link to jit_objfile_data directly from the objfile struct
[binutils-gdb.git] / gdb / jit.c
1 /* Handle JIT code generation in the inferior for GDB, the GNU Debugger.
2
3 Copyright (C) 2009-2020 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
46 static std::string jit_reader_dir;
47
48 static const char *const jit_break_name = "__jit_debug_register_code";
49
50 static const char *const jit_descriptor_name = "__jit_debug_descriptor";
51
52 static void jit_inferior_init (struct gdbarch *gdbarch);
53 static void jit_inferior_exit_hook (struct inferior *inf);
54
55 /* An unwinder is registered for every gdbarch. This key is used to
56 remember if the unwinder has been registered for a particular
57 gdbarch. */
58
59 static struct gdbarch_data *jit_gdbarch_data;
60
61 /* Non-zero if we want to see trace of jit level stuff. */
62
63 static unsigned int jit_debug = 0;
64
65 static void
66 show_jit_debug (struct ui_file *file, int from_tty,
67 struct cmd_list_element *c, const char *value)
68 {
69 fprintf_filtered (file, _("JIT debugging is %s.\n"), value);
70 }
71
72 struct target_buffer
73 {
74 CORE_ADDR base;
75 ULONGEST size;
76 };
77
78 /* Opening the file is a no-op. */
79
80 static void *
81 mem_bfd_iovec_open (struct bfd *abfd, void *open_closure)
82 {
83 return open_closure;
84 }
85
86 /* Closing the file is just freeing the base/size pair on our side. */
87
88 static int
89 mem_bfd_iovec_close (struct bfd *abfd, void *stream)
90 {
91 xfree (stream);
92
93 /* Zero means success. */
94 return 0;
95 }
96
97 /* For reading the file, we just need to pass through to target_read_memory and
98 fix up the arguments and return values. */
99
100 static file_ptr
101 mem_bfd_iovec_pread (struct bfd *abfd, void *stream, void *buf,
102 file_ptr nbytes, file_ptr offset)
103 {
104 int err;
105 struct target_buffer *buffer = (struct target_buffer *) stream;
106
107 /* If this read will read all of the file, limit it to just the rest. */
108 if (offset + nbytes > buffer->size)
109 nbytes = buffer->size - offset;
110
111 /* If there are no more bytes left, we've reached EOF. */
112 if (nbytes == 0)
113 return 0;
114
115 err = target_read_memory (buffer->base + offset, (gdb_byte *) buf, nbytes);
116 if (err)
117 return -1;
118
119 return nbytes;
120 }
121
122 /* For statting the file, we only support the st_size attribute. */
123
124 static int
125 mem_bfd_iovec_stat (struct bfd *abfd, void *stream, struct stat *sb)
126 {
127 struct target_buffer *buffer = (struct target_buffer*) stream;
128
129 memset (sb, 0, sizeof (struct stat));
130 sb->st_size = buffer->size;
131 return 0;
132 }
133
134 /* Open a BFD from the target's memory. */
135
136 static gdb_bfd_ref_ptr
137 bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size,
138 const char *target)
139 {
140 struct target_buffer *buffer = XNEW (struct target_buffer);
141
142 buffer->base = addr;
143 buffer->size = size;
144 return gdb_bfd_openr_iovec ("<in-memory>", target,
145 mem_bfd_iovec_open,
146 buffer,
147 mem_bfd_iovec_pread,
148 mem_bfd_iovec_close,
149 mem_bfd_iovec_stat);
150 }
151
152 struct jit_reader
153 {
154 jit_reader (struct gdb_reader_funcs *f, gdb_dlhandle_up &&h)
155 : functions (f), handle (std::move (h))
156 {
157 }
158
159 ~jit_reader ()
160 {
161 functions->destroy (functions);
162 }
163
164 DISABLE_COPY_AND_ASSIGN (jit_reader);
165
166 struct gdb_reader_funcs *functions;
167 gdb_dlhandle_up handle;
168 };
169
170 /* One reader that has been loaded successfully, and can potentially be used to
171 parse debug info. */
172
173 static struct jit_reader *loaded_jit_reader = NULL;
174
175 typedef struct gdb_reader_funcs * (reader_init_fn_type) (void);
176 static const char *reader_init_fn_sym = "gdb_init_reader";
177
178 /* Try to load FILE_NAME as a JIT debug info reader. */
179
180 static struct jit_reader *
181 jit_reader_load (const char *file_name)
182 {
183 reader_init_fn_type *init_fn;
184 struct gdb_reader_funcs *funcs = NULL;
185
186 if (jit_debug)
187 fprintf_unfiltered (gdb_stdlog, _("Opening shared object %s.\n"),
188 file_name);
189 gdb_dlhandle_up so = gdb_dlopen (file_name);
190
191 init_fn = (reader_init_fn_type *) gdb_dlsym (so, reader_init_fn_sym);
192 if (!init_fn)
193 error (_("Could not locate initialization function: %s."),
194 reader_init_fn_sym);
195
196 if (gdb_dlsym (so, "plugin_is_GPL_compatible") == NULL)
197 error (_("Reader not GPL compatible."));
198
199 funcs = init_fn ();
200 if (funcs->reader_version != GDB_READER_INTERFACE_VERSION)
201 error (_("Reader version does not match GDB version."));
202
203 return new jit_reader (funcs, std::move (so));
204 }
205
206 /* Provides the jit-reader-load command. */
207
208 static void
209 jit_reader_load_command (const char *args, int from_tty)
210 {
211 if (args == NULL)
212 error (_("No reader name provided."));
213 gdb::unique_xmalloc_ptr<char> file (tilde_expand (args));
214
215 if (loaded_jit_reader != NULL)
216 error (_("JIT reader already loaded. Run jit-reader-unload first."));
217
218 if (!IS_ABSOLUTE_PATH (file.get ()))
219 file.reset (xstrprintf ("%s%s%s", jit_reader_dir.c_str (), SLASH_STRING,
220 file.get ()));
221
222 loaded_jit_reader = jit_reader_load (file.get ());
223 reinit_frame_cache ();
224 jit_inferior_created_hook ();
225 }
226
227 /* Provides the jit-reader-unload command. */
228
229 static void
230 jit_reader_unload_command (const char *args, int from_tty)
231 {
232 if (!loaded_jit_reader)
233 error (_("No JIT reader loaded."));
234
235 reinit_frame_cache ();
236 jit_inferior_exit_hook (current_inferior ());
237
238 delete loaded_jit_reader;
239 loaded_jit_reader = NULL;
240 }
241
242 /* Per-program space structure recording which objfile has the JIT
243 symbols. */
244
245 struct jit_program_space_data
246 {
247 /* The objfile. This is NULL if no objfile holds the JIT
248 symbols. */
249
250 struct objfile *objfile = nullptr;
251
252 /* If this program space has __jit_debug_register_code, this is the
253 cached address from the minimal symbol. This is used to detect
254 relocations requiring the breakpoint to be re-created. */
255
256 CORE_ADDR cached_code_address = 0;
257
258 /* This is the JIT event breakpoint, or NULL if it has not been
259 set. */
260
261 struct breakpoint *jit_breakpoint = nullptr;
262 };
263
264 static program_space_key<jit_program_space_data> jit_program_space_key;
265
266 /* Destructor for jit_objfile_data. */
267
268 jit_objfile_data::~jit_objfile_data ()
269 {
270 /* Free the data allocated in the jit_program_space_data slot. */
271 if (this->register_code != NULL)
272 {
273 struct jit_program_space_data *ps_data;
274
275 ps_data = jit_program_space_key.get (this->objfile->pspace);
276 if (ps_data != NULL && ps_data->objfile == this->objfile)
277 {
278 ps_data->objfile = NULL;
279 if (ps_data->jit_breakpoint != NULL)
280 delete_breakpoint (ps_data->jit_breakpoint);
281 ps_data->cached_code_address = 0;
282 }
283 }
284 }
285
286 /* Fetch the jit_objfile_data associated with OBJF. If no data exists
287 yet, make a new structure and attach it. */
288
289 static struct jit_objfile_data *
290 get_jit_objfile_data (struct objfile *objf)
291 {
292 if (objf->jit_data == nullptr)
293 objf->jit_data.reset (new jit_objfile_data (objf));
294
295 return objf->jit_data.get ();
296 }
297
298 /* Remember OBJFILE has been created for struct jit_code_entry located
299 at inferior address ENTRY. */
300
301 static void
302 add_objfile_entry (struct objfile *objfile, CORE_ADDR entry)
303 {
304 struct jit_objfile_data *objf_data;
305
306 objf_data = get_jit_objfile_data (objfile);
307 objf_data->addr = entry;
308 }
309
310 /* Return jit_program_space_data for current program space. Allocate
311 if not already present. */
312
313 static struct jit_program_space_data *
314 get_jit_program_space_data ()
315 {
316 struct jit_program_space_data *ps_data;
317
318 ps_data = jit_program_space_key.get (current_program_space);
319 if (ps_data == NULL)
320 ps_data = jit_program_space_key.emplace (current_program_space);
321 return ps_data;
322 }
323
324 /* Helper function for reading the global JIT descriptor from remote
325 memory. Returns true if all went well, false otherwise. */
326
327 static bool
328 jit_read_descriptor (gdbarch *gdbarch,
329 jit_descriptor *descriptor,
330 objfile *jiter)
331 {
332 int err;
333 struct type *ptr_type;
334 int ptr_size;
335 int desc_size;
336 gdb_byte *desc_buf;
337 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
338 struct jit_objfile_data *objf_data;
339
340 gdb_assert (jiter != nullptr);
341 objf_data = get_jit_objfile_data (jiter);
342
343 if (objf_data->descriptor == NULL)
344 return false;
345
346 if (jit_debug)
347 fprintf_unfiltered (gdb_stdlog,
348 "jit_read_descriptor, descriptor_addr = %s\n",
349 paddress (gdbarch, MSYMBOL_VALUE_ADDRESS (jiter,
350 objf_data->descriptor)));
351
352 /* Figure out how big the descriptor is on the remote and how to read it. */
353 ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
354 ptr_size = TYPE_LENGTH (ptr_type);
355 desc_size = 8 + 2 * ptr_size; /* Two 32-bit ints and two pointers. */
356 desc_buf = (gdb_byte *) alloca (desc_size);
357
358 /* Read the descriptor. */
359 err = target_read_memory (MSYMBOL_VALUE_ADDRESS (jiter,
360 objf_data->descriptor),
361 desc_buf, desc_size);
362 if (err)
363 {
364 printf_unfiltered (_("Unable to read JIT descriptor from "
365 "remote memory\n"));
366 return false;
367 }
368
369 /* Fix the endianness to match the host. */
370 descriptor->version = extract_unsigned_integer (&desc_buf[0], 4, byte_order);
371 descriptor->action_flag =
372 extract_unsigned_integer (&desc_buf[4], 4, byte_order);
373 descriptor->relevant_entry = extract_typed_address (&desc_buf[8], ptr_type);
374 descriptor->first_entry =
375 extract_typed_address (&desc_buf[8 + ptr_size], ptr_type);
376
377 return true;
378 }
379
380 /* Helper function for reading a JITed code entry from remote memory. */
381
382 static void
383 jit_read_code_entry (struct gdbarch *gdbarch,
384 CORE_ADDR code_addr, struct jit_code_entry *code_entry)
385 {
386 int err, off;
387 struct type *ptr_type;
388 int ptr_size;
389 int entry_size;
390 int align_bytes;
391 gdb_byte *entry_buf;
392 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
393
394 /* Figure out how big the entry is on the remote and how to read it. */
395 ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
396 ptr_size = TYPE_LENGTH (ptr_type);
397
398 /* Figure out where the uint64_t value will be. */
399 align_bytes = type_align (builtin_type (gdbarch)->builtin_uint64);
400 off = 3 * ptr_size;
401 off = (off + (align_bytes - 1)) & ~(align_bytes - 1);
402
403 entry_size = off + 8; /* Three pointers and one 64-bit int. */
404 entry_buf = (gdb_byte *) alloca (entry_size);
405
406 /* Read the entry. */
407 err = target_read_memory (code_addr, entry_buf, entry_size);
408 if (err)
409 error (_("Unable to read JIT code entry from remote memory!"));
410
411 /* Fix the endianness to match the host. */
412 ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
413 code_entry->next_entry = extract_typed_address (&entry_buf[0], ptr_type);
414 code_entry->prev_entry =
415 extract_typed_address (&entry_buf[ptr_size], ptr_type);
416 code_entry->symfile_addr =
417 extract_typed_address (&entry_buf[2 * ptr_size], ptr_type);
418 code_entry->symfile_size =
419 extract_unsigned_integer (&entry_buf[off], 8, byte_order);
420 }
421
422 /* Proxy object for building a block. */
423
424 struct gdb_block
425 {
426 gdb_block (gdb_block *parent, CORE_ADDR begin, CORE_ADDR end,
427 const char *name)
428 : parent (parent),
429 begin (begin),
430 end (end),
431 name (name != nullptr ? xstrdup (name) : nullptr)
432 {}
433
434 /* The parent of this block. */
435 struct gdb_block *parent;
436
437 /* Points to the "real" block that is being built out of this
438 instance. This block will be added to a blockvector, which will
439 then be added to a symtab. */
440 struct block *real_block = nullptr;
441
442 /* The first and last code address corresponding to this block. */
443 CORE_ADDR begin, end;
444
445 /* The name of this block (if any). If this is non-NULL, the
446 FUNCTION symbol symbol is set to this value. */
447 gdb::unique_xmalloc_ptr<char> name;
448 };
449
450 /* Proxy object for building a symtab. */
451
452 struct gdb_symtab
453 {
454 explicit gdb_symtab (const char *file_name)
455 : file_name (file_name != nullptr ? file_name : "")
456 {}
457
458 /* The list of blocks in this symtab. These will eventually be
459 converted to real blocks.
460
461 This is specifically a linked list, instead of, for example, a vector,
462 because the pointers are returned to the user's debug info reader. So
463 it's important that the objects don't change location during their
464 lifetime (which would happen with a vector of objects getting resized). */
465 std::forward_list<gdb_block> blocks;
466
467 /* The number of blocks inserted. */
468 int nblocks = 0;
469
470 /* A mapping between line numbers to PC. */
471 gdb::unique_xmalloc_ptr<struct linetable> linetable;
472
473 /* The source file for this symtab. */
474 std::string file_name;
475 };
476
477 /* Proxy object for building an object. */
478
479 struct gdb_object
480 {
481 /* Symtabs of this object.
482
483 This is specifically a linked list, instead of, for example, a vector,
484 because the pointers are returned to the user's debug info reader. So
485 it's important that the objects don't change location during their
486 lifetime (which would happen with a vector of objects getting resized). */
487 std::forward_list<gdb_symtab> symtabs;
488 };
489
490 /* The type of the `private' data passed around by the callback
491 functions. */
492
493 typedef CORE_ADDR jit_dbg_reader_data;
494
495 /* The reader calls into this function to read data off the targets
496 address space. */
497
498 static enum gdb_status
499 jit_target_read_impl (GDB_CORE_ADDR target_mem, void *gdb_buf, int len)
500 {
501 int result = target_read_memory ((CORE_ADDR) target_mem,
502 (gdb_byte *) gdb_buf, len);
503 if (result == 0)
504 return GDB_SUCCESS;
505 else
506 return GDB_FAIL;
507 }
508
509 /* The reader calls into this function to create a new gdb_object
510 which it can then pass around to the other callbacks. Right now,
511 all that is required is allocating the memory. */
512
513 static struct gdb_object *
514 jit_object_open_impl (struct gdb_symbol_callbacks *cb)
515 {
516 /* CB is not required right now, but sometime in the future we might
517 need a handle to it, and we'd like to do that without breaking
518 the ABI. */
519 return new gdb_object;
520 }
521
522 /* Readers call into this function to open a new gdb_symtab, which,
523 again, is passed around to other callbacks. */
524
525 static struct gdb_symtab *
526 jit_symtab_open_impl (struct gdb_symbol_callbacks *cb,
527 struct gdb_object *object,
528 const char *file_name)
529 {
530 /* CB stays unused. See comment in jit_object_open_impl. */
531
532 object->symtabs.emplace_front (file_name);
533 return &object->symtabs.front ();
534 }
535
536 /* Called by readers to open a new gdb_block. This function also
537 inserts the new gdb_block in the correct place in the corresponding
538 gdb_symtab. */
539
540 static struct gdb_block *
541 jit_block_open_impl (struct gdb_symbol_callbacks *cb,
542 struct gdb_symtab *symtab, struct gdb_block *parent,
543 GDB_CORE_ADDR begin, GDB_CORE_ADDR end, const char *name)
544 {
545 /* Place the block at the beginning of the list, it will be sorted when the
546 symtab is finalized. */
547 symtab->blocks.emplace_front (parent, begin, end, name);
548 symtab->nblocks++;
549
550 return &symtab->blocks.front ();
551 }
552
553 /* Readers call this to add a line mapping (from PC to line number) to
554 a gdb_symtab. */
555
556 static void
557 jit_symtab_line_mapping_add_impl (struct gdb_symbol_callbacks *cb,
558 struct gdb_symtab *stab, int nlines,
559 struct gdb_line_mapping *map)
560 {
561 int i;
562 int alloc_len;
563
564 if (nlines < 1)
565 return;
566
567 alloc_len = sizeof (struct linetable)
568 + (nlines - 1) * sizeof (struct linetable_entry);
569 stab->linetable.reset (XNEWVAR (struct linetable, alloc_len));
570 stab->linetable->nitems = nlines;
571 for (i = 0; i < nlines; i++)
572 {
573 stab->linetable->item[i].pc = (CORE_ADDR) map[i].pc;
574 stab->linetable->item[i].line = map[i].line;
575 stab->linetable->item[i].is_stmt = 1;
576 }
577 }
578
579 /* Called by readers to close a gdb_symtab. Does not need to do
580 anything as of now. */
581
582 static void
583 jit_symtab_close_impl (struct gdb_symbol_callbacks *cb,
584 struct gdb_symtab *stab)
585 {
586 /* Right now nothing needs to be done here. We may need to do some
587 cleanup here in the future (again, without breaking the plugin
588 ABI). */
589 }
590
591 /* Transform STAB to a proper symtab, and add it it OBJFILE. */
592
593 static void
594 finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
595 {
596 struct compunit_symtab *cust;
597 size_t blockvector_size;
598 CORE_ADDR begin, end;
599 struct blockvector *bv;
600
601 int actual_nblocks = FIRST_LOCAL_BLOCK + stab->nblocks;
602
603 /* Sort the blocks in the order they should appear in the blockvector. */
604 stab->blocks.sort([] (const gdb_block &a, const gdb_block &b)
605 {
606 if (a.begin != b.begin)
607 return a.begin < b.begin;
608
609 return a.end > b.end;
610 });
611
612 cust = allocate_compunit_symtab (objfile, stab->file_name.c_str ());
613 allocate_symtab (cust, stab->file_name.c_str ());
614 add_compunit_symtab_to_objfile (cust);
615
616 /* JIT compilers compile in memory. */
617 COMPUNIT_DIRNAME (cust) = NULL;
618
619 /* Copy over the linetable entry if one was provided. */
620 if (stab->linetable)
621 {
622 size_t size = ((stab->linetable->nitems - 1)
623 * sizeof (struct linetable_entry)
624 + sizeof (struct linetable));
625 SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust))
626 = (struct linetable *) obstack_alloc (&objfile->objfile_obstack, size);
627 memcpy (SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)),
628 stab->linetable.get (), size);
629 }
630
631 blockvector_size = (sizeof (struct blockvector)
632 + (actual_nblocks - 1) * sizeof (struct block *));
633 bv = (struct blockvector *) obstack_alloc (&objfile->objfile_obstack,
634 blockvector_size);
635 COMPUNIT_BLOCKVECTOR (cust) = bv;
636
637 /* At the end of this function, (begin, end) will contain the PC range this
638 entire blockvector spans. */
639 BLOCKVECTOR_MAP (bv) = NULL;
640 begin = stab->blocks.front ().begin;
641 end = stab->blocks.front ().end;
642 BLOCKVECTOR_NBLOCKS (bv) = actual_nblocks;
643
644 /* First run over all the gdb_block objects, creating a real block
645 object for each. Simultaneously, keep setting the real_block
646 fields. */
647 int block_idx = FIRST_LOCAL_BLOCK;
648 for (gdb_block &gdb_block_iter : stab->blocks)
649 {
650 struct block *new_block = allocate_block (&objfile->objfile_obstack);
651 struct symbol *block_name = new (&objfile->objfile_obstack) symbol;
652 struct type *block_type = arch_type (objfile->arch (),
653 TYPE_CODE_VOID,
654 TARGET_CHAR_BIT,
655 "void");
656
657 BLOCK_MULTIDICT (new_block)
658 = mdict_create_linear (&objfile->objfile_obstack, NULL);
659 /* The address range. */
660 BLOCK_START (new_block) = (CORE_ADDR) gdb_block_iter.begin;
661 BLOCK_END (new_block) = (CORE_ADDR) gdb_block_iter.end;
662
663 /* The name. */
664 SYMBOL_DOMAIN (block_name) = VAR_DOMAIN;
665 SYMBOL_ACLASS_INDEX (block_name) = LOC_BLOCK;
666 symbol_set_symtab (block_name, COMPUNIT_FILETABS (cust));
667 SYMBOL_TYPE (block_name) = lookup_function_type (block_type);
668 SYMBOL_BLOCK_VALUE (block_name) = new_block;
669
670 block_name->m_name = obstack_strdup (&objfile->objfile_obstack,
671 gdb_block_iter.name.get ());
672
673 BLOCK_FUNCTION (new_block) = block_name;
674
675 BLOCKVECTOR_BLOCK (bv, block_idx) = new_block;
676 if (begin > BLOCK_START (new_block))
677 begin = BLOCK_START (new_block);
678 if (end < BLOCK_END (new_block))
679 end = BLOCK_END (new_block);
680
681 gdb_block_iter.real_block = new_block;
682
683 block_idx++;
684 }
685
686 /* Now add the special blocks. */
687 struct block *block_iter = NULL;
688 for (enum block_enum i : { GLOBAL_BLOCK, STATIC_BLOCK })
689 {
690 struct block *new_block;
691
692 new_block = (i == GLOBAL_BLOCK
693 ? allocate_global_block (&objfile->objfile_obstack)
694 : allocate_block (&objfile->objfile_obstack));
695 BLOCK_MULTIDICT (new_block)
696 = mdict_create_linear (&objfile->objfile_obstack, NULL);
697 BLOCK_SUPERBLOCK (new_block) = block_iter;
698 block_iter = new_block;
699
700 BLOCK_START (new_block) = (CORE_ADDR) begin;
701 BLOCK_END (new_block) = (CORE_ADDR) end;
702
703 BLOCKVECTOR_BLOCK (bv, i) = new_block;
704
705 if (i == GLOBAL_BLOCK)
706 set_block_compunit_symtab (new_block, cust);
707 }
708
709 /* Fill up the superblock fields for the real blocks, using the
710 real_block fields populated earlier. */
711 for (gdb_block &gdb_block_iter : stab->blocks)
712 {
713 if (gdb_block_iter.parent != NULL)
714 {
715 /* If the plugin specifically mentioned a parent block, we
716 use that. */
717 BLOCK_SUPERBLOCK (gdb_block_iter.real_block) =
718 gdb_block_iter.parent->real_block;
719 }
720 else
721 {
722 /* And if not, we set a default parent block. */
723 BLOCK_SUPERBLOCK (gdb_block_iter.real_block) =
724 BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
725 }
726 }
727 }
728
729 /* Called when closing a gdb_objfile. Converts OBJ to a proper
730 objfile. */
731
732 static void
733 jit_object_close_impl (struct gdb_symbol_callbacks *cb,
734 struct gdb_object *obj)
735 {
736 struct objfile *objfile;
737 jit_dbg_reader_data *priv_data;
738
739 priv_data = (jit_dbg_reader_data *) cb->priv_data;
740
741 objfile = objfile::make (nullptr, "<< JIT compiled code >>",
742 OBJF_NOT_FILENAME);
743 objfile->per_bfd->gdbarch = target_gdbarch ();
744
745 for (gdb_symtab &symtab : obj->symtabs)
746 finalize_symtab (&symtab, objfile);
747
748 add_objfile_entry (objfile, *priv_data);
749
750 delete obj;
751 }
752
753 /* Try to read CODE_ENTRY using the loaded jit reader (if any).
754 ENTRY_ADDR is the address of the struct jit_code_entry in the
755 inferior address space. */
756
757 static int
758 jit_reader_try_read_symtab (struct jit_code_entry *code_entry,
759 CORE_ADDR entry_addr)
760 {
761 int status;
762 jit_dbg_reader_data priv_data;
763 struct gdb_reader_funcs *funcs;
764 struct gdb_symbol_callbacks callbacks =
765 {
766 jit_object_open_impl,
767 jit_symtab_open_impl,
768 jit_block_open_impl,
769 jit_symtab_close_impl,
770 jit_object_close_impl,
771
772 jit_symtab_line_mapping_add_impl,
773 jit_target_read_impl,
774
775 &priv_data
776 };
777
778 priv_data = entry_addr;
779
780 if (!loaded_jit_reader)
781 return 0;
782
783 gdb::byte_vector gdb_mem (code_entry->symfile_size);
784
785 status = 1;
786 try
787 {
788 if (target_read_memory (code_entry->symfile_addr, gdb_mem.data (),
789 code_entry->symfile_size))
790 status = 0;
791 }
792 catch (const gdb_exception &e)
793 {
794 status = 0;
795 }
796
797 if (status)
798 {
799 funcs = loaded_jit_reader->functions;
800 if (funcs->read (funcs, &callbacks, gdb_mem.data (),
801 code_entry->symfile_size)
802 != GDB_SUCCESS)
803 status = 0;
804 }
805
806 if (jit_debug && status == 0)
807 fprintf_unfiltered (gdb_stdlog,
808 "Could not read symtab using the loaded JIT reader.\n");
809 return status;
810 }
811
812 /* Try to read CODE_ENTRY using BFD. ENTRY_ADDR is the address of the
813 struct jit_code_entry in the inferior address space. */
814
815 static void
816 jit_bfd_try_read_symtab (struct jit_code_entry *code_entry,
817 CORE_ADDR entry_addr,
818 struct gdbarch *gdbarch)
819 {
820 struct bfd_section *sec;
821 struct objfile *objfile;
822 const struct bfd_arch_info *b;
823
824 if (jit_debug)
825 fprintf_unfiltered (gdb_stdlog,
826 "jit_bfd_try_read_symtab, symfile_addr = %s, "
827 "symfile_size = %s\n",
828 paddress (gdbarch, code_entry->symfile_addr),
829 pulongest (code_entry->symfile_size));
830
831 gdb_bfd_ref_ptr nbfd (bfd_open_from_target_memory (code_entry->symfile_addr,
832 code_entry->symfile_size,
833 gnutarget));
834 if (nbfd == NULL)
835 {
836 puts_unfiltered (_("Error opening JITed symbol file, ignoring it.\n"));
837 return;
838 }
839
840 /* Check the format. NOTE: This initializes important data that GDB uses!
841 We would segfault later without this line. */
842 if (!bfd_check_format (nbfd.get (), bfd_object))
843 {
844 printf_unfiltered (_("\
845 JITed symbol file is not an object file, ignoring it.\n"));
846 return;
847 }
848
849 /* Check bfd arch. */
850 b = gdbarch_bfd_arch_info (gdbarch);
851 if (b->compatible (b, bfd_get_arch_info (nbfd.get ())) != b)
852 warning (_("JITed object file architecture %s is not compatible "
853 "with target architecture %s."),
854 bfd_get_arch_info (nbfd.get ())->printable_name,
855 b->printable_name);
856
857 /* Read the section address information out of the symbol file. Since the
858 file is generated by the JIT at runtime, it should all of the absolute
859 addresses that we care about. */
860 section_addr_info sai;
861 for (sec = nbfd->sections; sec != NULL; sec = sec->next)
862 if ((bfd_section_flags (sec) & (SEC_ALLOC|SEC_LOAD)) != 0)
863 {
864 /* We assume that these virtual addresses are absolute, and do not
865 treat them as offsets. */
866 sai.emplace_back (bfd_section_vma (sec),
867 bfd_section_name (sec),
868 sec->index);
869 }
870
871 /* This call does not take ownership of SAI. */
872 objfile = symbol_file_add_from_bfd (nbfd.get (),
873 bfd_get_filename (nbfd.get ()), 0,
874 &sai,
875 OBJF_SHARED | OBJF_NOT_FILENAME, NULL);
876
877 add_objfile_entry (objfile, entry_addr);
878 }
879
880 /* This function registers code associated with a JIT code entry. It uses the
881 pointer and size pair in the entry to read the symbol file from the remote
882 and then calls symbol_file_add_from_local_memory to add it as though it were
883 a symbol file added by the user. */
884
885 static void
886 jit_register_code (struct gdbarch *gdbarch,
887 CORE_ADDR entry_addr, struct jit_code_entry *code_entry)
888 {
889 int success;
890
891 if (jit_debug)
892 fprintf_unfiltered (gdb_stdlog,
893 "jit_register_code, symfile_addr = %s, "
894 "symfile_size = %s\n",
895 paddress (gdbarch, code_entry->symfile_addr),
896 pulongest (code_entry->symfile_size));
897
898 success = jit_reader_try_read_symtab (code_entry, entry_addr);
899
900 if (!success)
901 jit_bfd_try_read_symtab (code_entry, entry_addr, gdbarch);
902 }
903
904 /* Look up the objfile with this code entry address. */
905
906 static struct objfile *
907 jit_find_objf_with_entry_addr (CORE_ADDR entry_addr)
908 {
909 for (objfile *objf : current_program_space->objfiles ())
910 {
911 if (objf->jit_data != nullptr && objf->jit_data->addr == entry_addr)
912 return objf;
913 }
914
915 return NULL;
916 }
917
918 /* This is called when a breakpoint is deleted. It updates the
919 inferior's cache, if needed. */
920
921 static void
922 jit_breakpoint_deleted (struct breakpoint *b)
923 {
924 struct bp_location *iter;
925
926 if (b->type != bp_jit_event)
927 return;
928
929 for (iter = b->loc; iter != NULL; iter = iter->next)
930 {
931 struct jit_program_space_data *ps_data;
932
933 ps_data = jit_program_space_key.get (iter->pspace);
934 if (ps_data != NULL && ps_data->jit_breakpoint == iter->owner)
935 {
936 ps_data->cached_code_address = 0;
937 ps_data->jit_breakpoint = NULL;
938 }
939 }
940 }
941
942 /* (Re-)Initialize the jit breakpoint if necessary.
943 Return true if the jit breakpoint has been successfully initialized. */
944
945 static bool
946 jit_breakpoint_re_set_internal (struct gdbarch *gdbarch,
947 struct jit_program_space_data *ps_data)
948 {
949 struct bound_minimal_symbol reg_symbol;
950 struct bound_minimal_symbol desc_symbol;
951 struct jit_objfile_data *objf_data;
952 CORE_ADDR addr;
953
954 if (ps_data->objfile == NULL)
955 {
956 /* Lookup the registration symbol. If it is missing, then we
957 assume we are not attached to a JIT. */
958 reg_symbol = lookup_bound_minimal_symbol (jit_break_name);
959 if (reg_symbol.minsym == NULL
960 || BMSYMBOL_VALUE_ADDRESS (reg_symbol) == 0)
961 return false;
962
963 desc_symbol = lookup_minimal_symbol (jit_descriptor_name, NULL,
964 reg_symbol.objfile);
965 if (desc_symbol.minsym == NULL
966 || BMSYMBOL_VALUE_ADDRESS (desc_symbol) == 0)
967 return false;
968
969 objf_data = get_jit_objfile_data (reg_symbol.objfile);
970 objf_data->register_code = reg_symbol.minsym;
971 objf_data->descriptor = desc_symbol.minsym;
972
973 ps_data->objfile = reg_symbol.objfile;
974 }
975 else
976 objf_data = get_jit_objfile_data (ps_data->objfile);
977
978 addr = MSYMBOL_VALUE_ADDRESS (ps_data->objfile, objf_data->register_code);
979
980 if (jit_debug)
981 fprintf_unfiltered (gdb_stdlog,
982 "jit_breakpoint_re_set_internal, "
983 "breakpoint_addr = %s\n",
984 paddress (gdbarch, addr));
985
986 if (ps_data->cached_code_address == addr)
987 return true;
988
989 /* Delete the old breakpoint. */
990 if (ps_data->jit_breakpoint != NULL)
991 delete_breakpoint (ps_data->jit_breakpoint);
992
993 /* Put a breakpoint in the registration symbol. */
994 ps_data->cached_code_address = addr;
995 ps_data->jit_breakpoint = create_jit_event_breakpoint (gdbarch, addr);
996
997 return true;
998 }
999
1000 /* The private data passed around in the frame unwind callback
1001 functions. */
1002
1003 struct jit_unwind_private
1004 {
1005 /* Cached register values. See jit_frame_sniffer to see how this
1006 works. */
1007 detached_regcache *regcache;
1008
1009 /* The frame being unwound. */
1010 struct frame_info *this_frame;
1011 };
1012
1013 /* Sets the value of a particular register in this frame. */
1014
1015 static void
1016 jit_unwind_reg_set_impl (struct gdb_unwind_callbacks *cb, int dwarf_regnum,
1017 struct gdb_reg_value *value)
1018 {
1019 struct jit_unwind_private *priv;
1020 int gdb_reg;
1021
1022 priv = (struct jit_unwind_private *) cb->priv_data;
1023
1024 gdb_reg = gdbarch_dwarf2_reg_to_regnum (get_frame_arch (priv->this_frame),
1025 dwarf_regnum);
1026 if (gdb_reg == -1)
1027 {
1028 if (jit_debug)
1029 fprintf_unfiltered (gdb_stdlog,
1030 _("Could not recognize DWARF regnum %d"),
1031 dwarf_regnum);
1032 value->free (value);
1033 return;
1034 }
1035
1036 priv->regcache->raw_supply (gdb_reg, value->value);
1037 value->free (value);
1038 }
1039
1040 static void
1041 reg_value_free_impl (struct gdb_reg_value *value)
1042 {
1043 xfree (value);
1044 }
1045
1046 /* Get the value of register REGNUM in the previous frame. */
1047
1048 static struct gdb_reg_value *
1049 jit_unwind_reg_get_impl (struct gdb_unwind_callbacks *cb, int regnum)
1050 {
1051 struct jit_unwind_private *priv;
1052 struct gdb_reg_value *value;
1053 int gdb_reg, size;
1054 struct gdbarch *frame_arch;
1055
1056 priv = (struct jit_unwind_private *) cb->priv_data;
1057 frame_arch = get_frame_arch (priv->this_frame);
1058
1059 gdb_reg = gdbarch_dwarf2_reg_to_regnum (frame_arch, regnum);
1060 size = register_size (frame_arch, gdb_reg);
1061 value = ((struct gdb_reg_value *)
1062 xmalloc (sizeof (struct gdb_reg_value) + size - 1));
1063 value->defined = deprecated_frame_register_read (priv->this_frame, gdb_reg,
1064 value->value);
1065 value->size = size;
1066 value->free = reg_value_free_impl;
1067 return value;
1068 }
1069
1070 /* gdb_reg_value has a free function, which must be called on each
1071 saved register value. */
1072
1073 static void
1074 jit_dealloc_cache (struct frame_info *this_frame, void *cache)
1075 {
1076 struct jit_unwind_private *priv_data = (struct jit_unwind_private *) cache;
1077
1078 gdb_assert (priv_data->regcache != NULL);
1079 delete priv_data->regcache;
1080 xfree (priv_data);
1081 }
1082
1083 /* The frame sniffer for the pseudo unwinder.
1084
1085 While this is nominally a frame sniffer, in the case where the JIT
1086 reader actually recognizes the frame, it does a lot more work -- it
1087 unwinds the frame and saves the corresponding register values in
1088 the cache. jit_frame_prev_register simply returns the saved
1089 register values. */
1090
1091 static int
1092 jit_frame_sniffer (const struct frame_unwind *self,
1093 struct frame_info *this_frame, void **cache)
1094 {
1095 struct jit_unwind_private *priv_data;
1096 struct gdb_unwind_callbacks callbacks;
1097 struct gdb_reader_funcs *funcs;
1098
1099 callbacks.reg_get = jit_unwind_reg_get_impl;
1100 callbacks.reg_set = jit_unwind_reg_set_impl;
1101 callbacks.target_read = jit_target_read_impl;
1102
1103 if (loaded_jit_reader == NULL)
1104 return 0;
1105
1106 funcs = loaded_jit_reader->functions;
1107
1108 gdb_assert (!*cache);
1109
1110 *cache = XCNEW (struct jit_unwind_private);
1111 priv_data = (struct jit_unwind_private *) *cache;
1112 /* Take a snapshot of current regcache. */
1113 priv_data->regcache = new detached_regcache (get_frame_arch (this_frame),
1114 true);
1115 priv_data->this_frame = this_frame;
1116
1117 callbacks.priv_data = priv_data;
1118
1119 /* Try to coax the provided unwinder to unwind the stack */
1120 if (funcs->unwind (funcs, &callbacks) == GDB_SUCCESS)
1121 {
1122 if (jit_debug)
1123 fprintf_unfiltered (gdb_stdlog, _("Successfully unwound frame using "
1124 "JIT reader.\n"));
1125 return 1;
1126 }
1127 if (jit_debug)
1128 fprintf_unfiltered (gdb_stdlog, _("Could not unwind frame using "
1129 "JIT reader.\n"));
1130
1131 jit_dealloc_cache (this_frame, *cache);
1132 *cache = NULL;
1133
1134 return 0;
1135 }
1136
1137
1138 /* The frame_id function for the pseudo unwinder. Relays the call to
1139 the loaded plugin. */
1140
1141 static void
1142 jit_frame_this_id (struct frame_info *this_frame, void **cache,
1143 struct frame_id *this_id)
1144 {
1145 struct jit_unwind_private priv;
1146 struct gdb_frame_id frame_id;
1147 struct gdb_reader_funcs *funcs;
1148 struct gdb_unwind_callbacks callbacks;
1149
1150 priv.regcache = NULL;
1151 priv.this_frame = this_frame;
1152
1153 /* We don't expect the frame_id function to set any registers, so we
1154 set reg_set to NULL. */
1155 callbacks.reg_get = jit_unwind_reg_get_impl;
1156 callbacks.reg_set = NULL;
1157 callbacks.target_read = jit_target_read_impl;
1158 callbacks.priv_data = &priv;
1159
1160 gdb_assert (loaded_jit_reader);
1161 funcs = loaded_jit_reader->functions;
1162
1163 frame_id = funcs->get_frame_id (funcs, &callbacks);
1164 *this_id = frame_id_build (frame_id.stack_address, frame_id.code_address);
1165 }
1166
1167 /* Pseudo unwinder function. Reads the previously fetched value for
1168 the register from the cache. */
1169
1170 static struct value *
1171 jit_frame_prev_register (struct frame_info *this_frame, void **cache, int reg)
1172 {
1173 struct jit_unwind_private *priv = (struct jit_unwind_private *) *cache;
1174 struct gdbarch *gdbarch;
1175
1176 if (priv == NULL)
1177 return frame_unwind_got_optimized (this_frame, reg);
1178
1179 gdbarch = priv->regcache->arch ();
1180 gdb_byte *buf = (gdb_byte *) alloca (register_size (gdbarch, reg));
1181 enum register_status status = priv->regcache->cooked_read (reg, buf);
1182
1183 if (status == REG_VALID)
1184 return frame_unwind_got_bytes (this_frame, reg, buf);
1185 else
1186 return frame_unwind_got_optimized (this_frame, reg);
1187 }
1188
1189 /* Relay everything back to the unwinder registered by the JIT debug
1190 info reader.*/
1191
1192 static const struct frame_unwind jit_frame_unwind =
1193 {
1194 NORMAL_FRAME,
1195 default_frame_unwind_stop_reason,
1196 jit_frame_this_id,
1197 jit_frame_prev_register,
1198 NULL,
1199 jit_frame_sniffer,
1200 jit_dealloc_cache
1201 };
1202
1203
1204 /* This is the information that is stored at jit_gdbarch_data for each
1205 architecture. */
1206
1207 struct jit_gdbarch_data_type
1208 {
1209 /* Has the (pseudo) unwinder been prepended? */
1210 int unwinder_registered;
1211 };
1212
1213 /* Check GDBARCH and prepend the pseudo JIT unwinder if needed. */
1214
1215 static void
1216 jit_prepend_unwinder (struct gdbarch *gdbarch)
1217 {
1218 struct jit_gdbarch_data_type *data;
1219
1220 data
1221 = (struct jit_gdbarch_data_type *) gdbarch_data (gdbarch, jit_gdbarch_data);
1222 if (!data->unwinder_registered)
1223 {
1224 frame_unwind_prepend_unwinder (gdbarch, &jit_frame_unwind);
1225 data->unwinder_registered = 1;
1226 }
1227 }
1228
1229 /* Register any already created translations. */
1230
1231 static void
1232 jit_inferior_init (struct gdbarch *gdbarch)
1233 {
1234 struct jit_descriptor descriptor;
1235 struct jit_code_entry cur_entry;
1236 struct jit_program_space_data *ps_data;
1237 CORE_ADDR cur_entry_addr;
1238
1239 if (jit_debug)
1240 fprintf_unfiltered (gdb_stdlog, "jit_inferior_init\n");
1241
1242 jit_prepend_unwinder (gdbarch);
1243
1244 ps_data = get_jit_program_space_data ();
1245 if (!jit_breakpoint_re_set_internal (gdbarch, ps_data))
1246 return;
1247
1248 /* There must be a JITer registered, otherwise we would exit early
1249 above. */
1250 objfile *jiter = ps_data->objfile;
1251
1252 /* Read the descriptor so we can check the version number and load
1253 any already JITed functions. */
1254 if (!jit_read_descriptor (gdbarch, &descriptor, jiter))
1255 return;
1256
1257 /* Check that the version number agrees with that we support. */
1258 if (descriptor.version != 1)
1259 {
1260 printf_unfiltered (_("Unsupported JIT protocol version %ld "
1261 "in descriptor (expected 1)\n"),
1262 (long) descriptor.version);
1263 return;
1264 }
1265
1266 /* If we've attached to a running program, we need to check the descriptor
1267 to register any functions that were already generated. */
1268 for (cur_entry_addr = descriptor.first_entry;
1269 cur_entry_addr != 0;
1270 cur_entry_addr = cur_entry.next_entry)
1271 {
1272 jit_read_code_entry (gdbarch, cur_entry_addr, &cur_entry);
1273
1274 /* This hook may be called many times during setup, so make sure we don't
1275 add the same symbol file twice. */
1276 if (jit_find_objf_with_entry_addr (cur_entry_addr) != NULL)
1277 continue;
1278
1279 jit_register_code (gdbarch, cur_entry_addr, &cur_entry);
1280 }
1281 }
1282
1283 /* inferior_created observer. */
1284
1285 static void
1286 jit_inferior_created (struct target_ops *ops, int from_tty)
1287 {
1288 jit_inferior_created_hook ();
1289 }
1290
1291 /* Exported routine to call when an inferior has been created. */
1292
1293 void
1294 jit_inferior_created_hook (void)
1295 {
1296 jit_inferior_init (target_gdbarch ());
1297 }
1298
1299 /* Exported routine to call to re-set the jit breakpoints,
1300 e.g. when a program is rerun. */
1301
1302 void
1303 jit_breakpoint_re_set (void)
1304 {
1305 jit_breakpoint_re_set_internal (target_gdbarch (),
1306 get_jit_program_space_data ());
1307 }
1308
1309 /* This function cleans up any code entries left over when the
1310 inferior exits. We get left over code when the inferior exits
1311 without unregistering its code, for example when it crashes. */
1312
1313 static void
1314 jit_inferior_exit_hook (struct inferior *inf)
1315 {
1316 for (objfile *objf : current_program_space->objfiles_safe ())
1317 {
1318 if (objf->jit_data != nullptr && objf->jit_data->addr != 0)
1319 objf->unlink ();
1320 }
1321 }
1322
1323 void
1324 jit_event_handler (gdbarch *gdbarch, objfile *jiter)
1325 {
1326 struct jit_descriptor descriptor;
1327 struct jit_code_entry code_entry;
1328 CORE_ADDR entry_addr;
1329 struct objfile *objf;
1330
1331 /* Read the descriptor from remote memory. */
1332 if (!jit_read_descriptor (gdbarch, &descriptor, jiter))
1333 return;
1334 entry_addr = descriptor.relevant_entry;
1335
1336 /* Do the corresponding action. */
1337 switch (descriptor.action_flag)
1338 {
1339 case JIT_NOACTION:
1340 break;
1341 case JIT_REGISTER:
1342 jit_read_code_entry (gdbarch, entry_addr, &code_entry);
1343 jit_register_code (gdbarch, entry_addr, &code_entry);
1344 break;
1345 case JIT_UNREGISTER:
1346 objf = jit_find_objf_with_entry_addr (entry_addr);
1347 if (objf == NULL)
1348 printf_unfiltered (_("Unable to find JITed code "
1349 "entry at address: %s\n"),
1350 paddress (gdbarch, entry_addr));
1351 else
1352 objf->unlink ();
1353
1354 break;
1355 default:
1356 error (_("Unknown action_flag value in JIT descriptor!"));
1357 break;
1358 }
1359 }
1360
1361 /* Initialize the jit_gdbarch_data slot with an instance of struct
1362 jit_gdbarch_data_type */
1363
1364 static void *
1365 jit_gdbarch_data_init (struct obstack *obstack)
1366 {
1367 struct jit_gdbarch_data_type *data =
1368 XOBNEW (obstack, struct jit_gdbarch_data_type);
1369
1370 data->unwinder_registered = 0;
1371
1372 return data;
1373 }
1374
1375 void _initialize_jit ();
1376 void
1377 _initialize_jit ()
1378 {
1379 jit_reader_dir = relocate_gdb_directory (JIT_READER_DIR,
1380 JIT_READER_DIR_RELOCATABLE);
1381 add_setshow_zuinteger_cmd ("jit", class_maintenance, &jit_debug,
1382 _("Set JIT debugging."),
1383 _("Show JIT debugging."),
1384 _("When non-zero, JIT debugging is enabled."),
1385 NULL,
1386 show_jit_debug,
1387 &setdebuglist, &showdebuglist);
1388
1389 gdb::observers::inferior_created.attach (jit_inferior_created);
1390 gdb::observers::inferior_exit.attach (jit_inferior_exit_hook);
1391 gdb::observers::breakpoint_deleted.attach (jit_breakpoint_deleted);
1392
1393 jit_gdbarch_data = gdbarch_data_register_pre_init (jit_gdbarch_data_init);
1394 if (is_dl_available ())
1395 {
1396 struct cmd_list_element *c;
1397
1398 c = add_com ("jit-reader-load", no_class, jit_reader_load_command, _("\
1399 Load FILE as debug info reader and unwinder for JIT compiled code.\n\
1400 Usage: jit-reader-load FILE\n\
1401 Try to load file FILE as a debug info reader (and unwinder) for\n\
1402 JIT compiled code. The file is loaded from " JIT_READER_DIR ",\n\
1403 relocated relative to the GDB executable if required."));
1404 set_cmd_completer (c, filename_completer);
1405
1406 c = add_com ("jit-reader-unload", no_class,
1407 jit_reader_unload_command, _("\
1408 Unload the currently loaded JIT debug info reader.\n\
1409 Usage: jit-reader-unload\n\n\
1410 Do \"help jit-reader-load\" for info on loading debug info readers."));
1411 set_cmd_completer (c, noop_completer);
1412 }
1413 }