GDB (xrefs)

compile-c-symbols.c
Go to the documentation of this file.
1 /* Convert symbols from GDB to GCC
2
3 Copyright (C) 2014-2018 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20
21 #include "defs.h"
22 #include "compile-internal.h"
23 #include "symtab.h"
24 #include "parser-defs.h"
25 #include "block.h"
26 #include "objfiles.h"
27 #include "compile.h"
28 #include "value.h"
29 #include "exceptions.h"
30 #include "gdbtypes.h"
31 #include "dwarf2loc.h"
32
33
34
35 /* Object of this type are stored in the compiler's symbol_err_map. */
36
37 struct symbol_error
38 {
39 /* The symbol. */
40
41 const struct symbol *sym;
42
43 /* The error message to emit. This is malloc'd and owned by the
44 hash table. */
45
46 char *message;
47 };
48
49 /* Hash function for struct symbol_error. */
50
51 static hashval_t
52 hash_symbol_error (const void *a)
53 {
54 const struct symbol_error *se = (const struct symbol_error *) a;
55
56 return htab_hash_pointer (se->sym);
57 }
58
59 /* Equality function for struct symbol_error. */
60
61 static int
62 eq_symbol_error (const void *a, const void *b)
63 {
64 const struct symbol_error *sea = (const struct symbol_error *) a;
65 const struct symbol_error *seb = (const struct symbol_error *) b;
66
67 return sea->sym == seb->sym;
68 }
69
70 /* Deletion function for struct symbol_error. */
71
72 static void
73 del_symbol_error (void *a)
74 {
75 struct symbol_error *se = (struct symbol_error *) a;
76
77 xfree (se->message);
78 xfree (se);
79 }
80
81 /* Associate SYMBOL with some error text. */
82
83 static void
84 insert_symbol_error (htab_t hash, const struct symbol *sym, const char *text)
85 {
86 struct symbol_error e;
87 void **slot;
88
89 e.sym = sym;
90 slot = htab_find_slot (hash, &e, INSERT);
91 if (*slot == NULL)
92 {
93 struct symbol_error *e = XNEW (struct symbol_error);
94
95 e->sym = sym;
96 e->message = xstrdup (text);
97 *slot = e;
98 }
99 }
100
101 /* Emit the error message corresponding to SYM, if one exists, and
102 arrange for it not to be emitted again. */
103
104 static void
105 error_symbol_once (struct compile_c_instance *context,
106 const struct symbol *sym)
107 {
108 struct symbol_error search;
109 struct symbol_error *err;
110
111 if (context->symbol_err_map == NULL)
112 return;
113
114 search.sym = sym;
115 err = (struct symbol_error *) htab_find (context->symbol_err_map, &search);
116 if (err == NULL || err->message == NULL)
117 return;
118
119 gdb::unique_xmalloc_ptr<char> message (err->message);
120 err->message = NULL;
121 error (_("%s"), message.get ());
122 }
123
124
125
126 /* Compute the name of the pointer representing a local symbol's
127 address. */
128
129 static gdb::unique_xmalloc_ptr<char>
130 symbol_substitution_name (struct symbol *sym)
131 {
132 return gdb::unique_xmalloc_ptr<char>
133 (concat ("__", SYMBOL_NATURAL_NAME (sym), "_ptr", (char *) NULL));
134 }
135
136 /* Convert a given symbol, SYM, to the compiler's representation.
137 CONTEXT is the compiler instance. IS_GLOBAL is true if the
138 symbol came from the global scope. IS_LOCAL is true if the symbol
139 came from a local scope. (Note that the two are not strictly
140 inverses because the symbol might have come from the static
141 scope.) */
142
143 static void
144 convert_one_symbol (struct compile_c_instance *context,
145 struct block_symbol sym,
146 int is_global,
147 int is_local)
148 {
149 gcc_type sym_type;
150 const char *filename = symbol_symtab (sym.symbol)->filename;
151 unsigned short line = SYMBOL_LINE (sym.symbol);
152
153 error_symbol_once (context, sym.symbol);
154
155 if (SYMBOL_CLASS (sym.symbol) == LOC_LABEL)
156 sym_type = 0;
157 else
158 sym_type = convert_type (context, SYMBOL_TYPE (sym.symbol));
159
160 if (SYMBOL_DOMAIN (sym.symbol) == STRUCT_DOMAIN)
161 {
162 /* Binding a tag, so we don't need to build a decl. */
163 C_CTX (context)->c_ops->tagbind (C_CTX (context),
164 SYMBOL_NATURAL_NAME (sym.symbol),
165 sym_type, filename, line);
166 }
167 else
168 {
169 gcc_decl decl;
170 enum gcc_c_symbol_kind kind;
171 CORE_ADDR addr = 0;
172 gdb::unique_xmalloc_ptr<char> symbol_name;
173
174 switch (SYMBOL_CLASS (sym.symbol))
175 {
176 case LOC_TYPEDEF:
177 kind = GCC_C_SYMBOL_TYPEDEF;
178 break;
179
180 case LOC_LABEL:
181 kind = GCC_C_SYMBOL_LABEL;
182 addr = SYMBOL_VALUE_ADDRESS (sym.symbol);
183 break;
184
185 case LOC_BLOCK:
186 kind = GCC_C_SYMBOL_FUNCTION;
187 addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym.symbol));
188 if (is_global && TYPE_GNU_IFUNC (SYMBOL_TYPE (sym.symbol)))
189 addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
190 break;
191
192 case LOC_CONST:
193 if (TYPE_CODE (SYMBOL_TYPE (sym.symbol)) == TYPE_CODE_ENUM)
194 {
195 /* Already handled by convert_enum. */
196 return;
197 }
198 C_CTX (context)->c_ops->build_constant
199 (C_CTX (context),
200 sym_type, SYMBOL_NATURAL_NAME (sym.symbol),
201 SYMBOL_VALUE (sym.symbol),
202 filename, line);
203 return;
204
205 case LOC_CONST_BYTES:
206 error (_("Unsupported LOC_CONST_BYTES for symbol \"%s\"."),
207 SYMBOL_PRINT_NAME (sym.symbol));
208
209 case LOC_UNDEF:
210 internal_error (__FILE__, __LINE__, _("LOC_UNDEF found for \"%s\"."),
211 SYMBOL_PRINT_NAME (sym.symbol));
212
213 case LOC_COMMON_BLOCK:
214 error (_("Fortran common block is unsupported for compilation "
215 "evaluaton of symbol \"%s\"."),
216 SYMBOL_PRINT_NAME (sym.symbol));
217
218 case LOC_OPTIMIZED_OUT:
219 error (_("Symbol \"%s\" cannot be used for compilation evaluation "
220 "as it is optimized out."),
221 SYMBOL_PRINT_NAME (sym.symbol));
222
223 case LOC_COMPUTED:
224 if (is_local)
225 goto substitution;
226 /* Probably TLS here. */
227 warning (_("Symbol \"%s\" is thread-local and currently can only "
228 "be referenced from the current thread in "
229 "compiled code."),
230 SYMBOL_PRINT_NAME (sym.symbol));
231 /* FALLTHROUGH */
232 case LOC_UNRESOLVED:
233 /* 'symbol_name' cannot be used here as that one is used only for
234 local variables from compile_dwarf_expr_to_c.
235 Global variables can be accessed by GCC only by their address, not
236 by their name. */
237 {
238 struct value *val;
239 struct frame_info *frame = NULL;
240
241 if (symbol_read_needs_frame (sym.symbol))
242 {
243 frame = get_selected_frame (NULL);
244 if (frame == NULL)
245 error (_("Symbol \"%s\" cannot be used because "
246 "there is no selected frame"),
247 SYMBOL_PRINT_NAME (sym.symbol));
248 }
249
250 val = read_var_value (sym.symbol, sym.block, frame);
251 if (VALUE_LVAL (val) != lval_memory)
252 error (_("Symbol \"%s\" cannot be used for compilation "
253 "evaluation as its address has not been found."),
254 SYMBOL_PRINT_NAME (sym.symbol));
255
256 kind = GCC_C_SYMBOL_VARIABLE;
257 addr = value_address (val);
258 }
259 break;
260
261
262 case LOC_REGISTER:
263 case LOC_ARG:
264 case LOC_REF_ARG:
265 case LOC_REGPARM_ADDR:
266 case LOC_LOCAL:
267 substitution:
268 kind = GCC_C_SYMBOL_VARIABLE;
269 symbol_name = symbol_substitution_name (sym.symbol);
270 break;
271
272 case LOC_STATIC:
273 kind = GCC_C_SYMBOL_VARIABLE;
274 addr = SYMBOL_VALUE_ADDRESS (sym.symbol);
275 break;
276
277 case LOC_FINAL_VALUE:
278 default:
279 gdb_assert_not_reached ("Unreachable case in convert_one_symbol.");
280
281 }
282
283 /* Don't emit local variable decls for a raw expression. */
284 if (context->base.scope != COMPILE_I_RAW_SCOPE
285 || symbol_name == NULL)
286 {
287 decl = C_CTX (context)->c_ops->build_decl
288 (C_CTX (context),
289 SYMBOL_NATURAL_NAME (sym.symbol),
290 kind,
291 sym_type,
292 symbol_name.get (), addr,
293 filename, line);
294
295 C_CTX (context)->c_ops->bind (C_CTX (context), decl, is_global);
296 }
297 }
298 }
299
300 /* Convert a full symbol to its gcc form. CONTEXT is the compiler to
301 use, IDENTIFIER is the name of the symbol, SYM is the symbol
302 itself, and DOMAIN is the domain which was searched. */
303
304 static void
305 convert_symbol_sym (struct compile_c_instance *context, const char *identifier,
306 struct block_symbol sym, domain_enum domain)
307 {
308 const struct block *static_block;
309 int is_local_symbol;
310
311 /* If we found a symbol and it is not in the static or global
312 scope, then we should first convert any static or global scope
313 symbol of the same name. This lets this unusual case work:
314
315 int x; // Global.
316 int func(void)
317 {
318 int x;
319 // At this spot, evaluate "extern int x; x"
320 }
321 */
322
323 static_block = block_static_block (sym.block);
324 /* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block. */
325 is_local_symbol = (sym.block != static_block && static_block != NULL);
326 if (is_local_symbol)
327 {
328 struct block_symbol global_sym;
329
330 global_sym = lookup_symbol (identifier, NULL, domain, NULL);
331 /* If the outer symbol is in the static block, we ignore it, as
332 it cannot be referenced. */
333 if (global_sym.symbol != NULL
334 && global_sym.block != block_static_block (global_sym.block))
335 {
336 if (compile_debug)
337 fprintf_unfiltered (gdb_stdlog,
338 "gcc_convert_symbol \"%s\": global symbol\n",
339 identifier);
340 convert_one_symbol (context, global_sym, 1, 0);
341 }
342 }
343
344 if (compile_debug)
345 fprintf_unfiltered (gdb_stdlog,
346 "gcc_convert_symbol \"%s\": local symbol\n",
347 identifier);
348 convert_one_symbol (context, sym, 0, is_local_symbol);
349 }
350
351 /* Convert a minimal symbol to its gcc form. CONTEXT is the compiler
352 to use and BMSYM is the minimal symbol to convert. */
353
354 static void
355 convert_symbol_bmsym (struct compile_c_instance *context,
356 struct bound_minimal_symbol bmsym)
357 {
358 struct minimal_symbol *msym = bmsym.minsym;
359 struct objfile *objfile = bmsym.objfile;
360 struct type *type;
361 enum gcc_c_symbol_kind kind;
362 gcc_type sym_type;
363 gcc_decl decl;
364 CORE_ADDR addr;
365
366 addr = MSYMBOL_VALUE_ADDRESS (objfile, msym);
367
368 /* Conversion copied from write_exp_msymbol. */
369 switch (MSYMBOL_TYPE (msym))
370 {
371 case mst_text:
372 case mst_file_text:
373 case mst_solib_trampoline:
374 type = objfile_type (objfile)->nodebug_text_symbol;
375 kind = GCC_C_SYMBOL_FUNCTION;
376 break;
377
378 case mst_text_gnu_ifunc:
379 type = objfile_type (objfile)->nodebug_text_gnu_ifunc_symbol;
380 kind = GCC_C_SYMBOL_FUNCTION;
381 addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
382 break;
383
384 case mst_data:
385 case mst_file_data:
386 case mst_bss:
387 case mst_file_bss:
388 type = objfile_type (objfile)->nodebug_data_symbol;
389 kind = GCC_C_SYMBOL_VARIABLE;
390 break;
391
392 case mst_slot_got_plt:
393 type = objfile_type (objfile)->nodebug_got_plt_symbol;
394 kind = GCC_C_SYMBOL_FUNCTION;
395 break;
396
397 default:
398 type = objfile_type (objfile)->nodebug_unknown_symbol;
399 kind = GCC_C_SYMBOL_VARIABLE;
400 break;
401 }
402
403 sym_type = convert_type (context, type);
404 decl = C_CTX (context)->c_ops->build_decl (C_CTX (context),
405 MSYMBOL_NATURAL_NAME (msym),
406 kind, sym_type, NULL, addr,
407 NULL, 0);
408 C_CTX (context)->c_ops->bind (C_CTX (context), decl, 1 /* is_global */);
409 }
410
411 /* See compile-internal.h. */
412
413 void
414 gcc_convert_symbol (void *datum,
415 struct gcc_c_context *gcc_context,
416 enum gcc_c_oracle_request request,
417 const char *identifier)
418 {
419 struct compile_c_instance *context = (struct compile_c_instance *) datum;
420 domain_enum domain;
421 int found = 0;
422
423 switch (request)
424 {
425 case GCC_C_ORACLE_SYMBOL:
426 domain = VAR_DOMAIN;
427 break;
428 case GCC_C_ORACLE_TAG:
429 domain = STRUCT_DOMAIN;
430 break;
431 case GCC_C_ORACLE_LABEL:
432 domain = LABEL_DOMAIN;
433 break;
434 default:
435 gdb_assert_not_reached ("Unrecognized oracle request.");
436 }
437
438 /* We can't allow exceptions to escape out of this callback. Safest
439 is to simply emit a gcc error. */
440 TRY
441 {
442 struct block_symbol sym;
443
444 sym = lookup_symbol (identifier, context->base.block, domain, NULL);
445 if (sym.symbol != NULL)
446 {
447 convert_symbol_sym (context, identifier, sym, domain);
448 found = 1;
449 }
450 else if (domain == VAR_DOMAIN)
451 {
452 struct bound_minimal_symbol bmsym;
453
454 bmsym = lookup_minimal_symbol (identifier, NULL, NULL);
455 if (bmsym.minsym != NULL)
456 {
457 convert_symbol_bmsym (context, bmsym);
458 found = 1;
459 }
460 }
461 }
462
463 CATCH (e, RETURN_MASK_ALL)
464 {
465 C_CTX (context)->c_ops->error (C_CTX (context), e.message);
466 }
467 END_CATCH
468
469 if (compile_debug && !found)
470 fprintf_unfiltered (gdb_stdlog,
471 "gcc_convert_symbol \"%s\": lookup_symbol failed\n",
472 identifier);
473 return;
474 }
475
476 /* See compile-internal.h. */
477
478 gcc_address
479 gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
480 const char *identifier)
481 {
482 struct compile_c_instance *context = (struct compile_c_instance *) datum;
483 gcc_address result = 0;
484 int found = 0;
485
486 /* We can't allow exceptions to escape out of this callback. Safest
487 is to simply emit a gcc error. */
488 TRY
489 {
490 struct symbol *sym;
491
492 /* We only need global functions here. */
493 sym = lookup_symbol (identifier, NULL, VAR_DOMAIN, NULL).symbol;
494 if (sym != NULL && SYMBOL_CLASS (sym) == LOC_BLOCK)
495 {
496 if (compile_debug)
497 fprintf_unfiltered (gdb_stdlog,
498 "gcc_symbol_address \"%s\": full symbol\n",
499 identifier);
500 result = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
501 if (TYPE_GNU_IFUNC (SYMBOL_TYPE (sym)))
502 result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
503 found = 1;
504 }
505 else
506 {
507 struct bound_minimal_symbol msym;
508
509 msym = lookup_bound_minimal_symbol (identifier);
510 if (msym.minsym != NULL)
511 {
512 if (compile_debug)
513 fprintf_unfiltered (gdb_stdlog,
514 "gcc_symbol_address \"%s\": minimal "
515 "symbol\n",
516 identifier);
517 result = BMSYMBOL_VALUE_ADDRESS (msym);
518 if (MSYMBOL_TYPE (msym.minsym) == mst_text_gnu_ifunc)
519 result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
520 found = 1;
521 }
522 }
523 }
524
525 CATCH (e, RETURN_MASK_ERROR)
526 {
527 C_CTX (context)->c_ops->error (C_CTX (context), e.message);
528 }
529 END_CATCH
530
531 if (compile_debug && !found)
532 fprintf_unfiltered (gdb_stdlog,
533 "gcc_symbol_address \"%s\": failed\n",
534 identifier);
535 return result;
536 }
537
538
539
540 /* A hash function for symbol names. */
541
542 static hashval_t
543 hash_symname (const void *a)
544 {
545 const struct symbol *sym = (const struct symbol *) a;
546
547 return htab_hash_string (SYMBOL_NATURAL_NAME (sym));
548 }
549
550 /* A comparison function for hash tables that just looks at symbol
551 names. */
552
553 static int
554 eq_symname (const void *a, const void *b)
555 {
556 const struct symbol *syma = (const struct symbol *) a;
557 const struct symbol *symb = (const struct symbol *) b;
558
559 return strcmp (SYMBOL_NATURAL_NAME (syma), SYMBOL_NATURAL_NAME (symb)) == 0;
560 }
561
562 /* If a symbol with the same name as SYM is already in HASHTAB, return
563 1. Otherwise, add SYM to HASHTAB and return 0. */
564
565 static int
566 symbol_seen (htab_t hashtab, struct symbol *sym)
567 {
568 void **slot;
569
570 slot = htab_find_slot (hashtab, sym, INSERT);
571 if (*slot != NULL)
572 return 1;
573
574 *slot = sym;
575 return 0;
576 }
577
578 /* Generate C code to compute the length of a VLA. */
579
580 static void
581 generate_vla_size (struct compile_c_instance *compiler,
582 string_file &stream,
583 struct gdbarch *gdbarch,
584 unsigned char *registers_used,
585 CORE_ADDR pc,
586 struct type *type,
587 struct symbol *sym)
588 {
589 type = check_typedef (type);
590
591 if (TYPE_IS_REFERENCE (type))
592 type = check_typedef (TYPE_TARGET_TYPE (type));
593
594 switch (TYPE_CODE (type))
595 {
596 case TYPE_CODE_RANGE:
597 {
598 if (TYPE_HIGH_BOUND_KIND (type) == PROP_LOCEXPR
599 || TYPE_HIGH_BOUND_KIND (type) == PROP_LOCLIST)
600 {
601 const struct dynamic_prop *prop = &TYPE_RANGE_DATA (type)->high;
602 std::string name = c_get_range_decl_name (prop);
603
604 dwarf2_compile_property_to_c (stream, name.c_str (),
605 gdbarch, registers_used,
606 prop, pc, sym);
607 }
608 }
609 break;
610
611 case TYPE_CODE_ARRAY:
612 generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
613 TYPE_INDEX_TYPE (type), sym);
614 generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
615 TYPE_TARGET_TYPE (type), sym);
616 break;
617
618 case TYPE_CODE_UNION:
619 case TYPE_CODE_STRUCT:
620 {
621 int i;
622
623 for (i = 0; i < TYPE_NFIELDS (type); ++i)
624 if (!field_is_static (&TYPE_FIELD (type, i)))
625 generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
626 TYPE_FIELD_TYPE (type, i), sym);
627 }
628 break;
629 }
630 }
631
632 /* Generate C code to compute the address of SYM. */
633
634 static void
635 generate_c_for_for_one_variable (struct compile_c_instance *compiler,
636 string_file &stream,
637 struct gdbarch *gdbarch,
638 unsigned char *registers_used,
639 CORE_ADDR pc,
640 struct symbol *sym)
641 {
642
643 TRY
644 {
645 if (is_dynamic_type (SYMBOL_TYPE (sym)))
646 {
647 /* We need to emit to a temporary buffer in case an error
648 occurs in the middle. */
649 string_file local_file;
650
651 generate_vla_size (compiler, local_file, gdbarch, registers_used, pc,
652 SYMBOL_TYPE (sym), sym);
653
654 stream.write (local_file.c_str (), local_file.size ());
655 }
656
657 if (SYMBOL_COMPUTED_OPS (sym) != NULL)
658 {
659 gdb::unique_xmalloc_ptr<char> generated_name
660 = symbol_substitution_name (sym);
661 /* We need to emit to a temporary buffer in case an error
662 occurs in the middle. */
663 string_file local_file;
664
665 SYMBOL_COMPUTED_OPS (sym)->generate_c_location (sym, local_file,
666 gdbarch,
667 registers_used,
668 pc,
669 generated_name.get ());
670 stream.write (local_file.c_str (), local_file.size ());
671 }
672 else
673 {
674 switch (SYMBOL_CLASS (sym))
675 {
676 case LOC_REGISTER:
677 case LOC_ARG:
678 case LOC_REF_ARG:
679 case LOC_REGPARM_ADDR:
680 case LOC_LOCAL:
681 error (_("Local symbol unhandled when generating C code."));
682
683 case LOC_COMPUTED:
684 gdb_assert_not_reached (_("LOC_COMPUTED variable "
685 "missing a method."));
686
687 default:
688 /* Nothing to do for all other cases, as they don't represent
689 local variables. */
690 break;
691 }
692 }
693 }
694
695 CATCH (e, RETURN_MASK_ERROR)
696 {
697 if (compiler->symbol_err_map == NULL)
698 compiler->symbol_err_map = htab_create_alloc (10,
699 hash_symbol_error,
700 eq_symbol_error,
701 del_symbol_error,
702 xcalloc,
703 xfree);
704 insert_symbol_error (compiler->symbol_err_map, sym, e.message);
705 }
706 END_CATCH
707 }
708
709 /* See compile-internal.h. */
710
711 unsigned char *
712 generate_c_for_variable_locations (struct compile_c_instance *compiler,
713 string_file &stream,
714 struct gdbarch *gdbarch,
715 const struct block *block,
716 CORE_ADDR pc)
717 {
718 struct cleanup *outer;
719 const struct block *static_block = block_static_block (block);
720 unsigned char *registers_used;
721
722 /* If we're already in the static or global block, there is nothing
723 to write. */
724 if (static_block == NULL || block == static_block)
725 return NULL;
726
727 registers_used = XCNEWVEC (unsigned char, gdbarch_num_regs (gdbarch));
728 outer = make_cleanup (xfree, registers_used);
729
730 /* Ensure that a given name is only entered once. This reflects the
731 reality of shadowing. */
732 htab_up symhash (htab_create_alloc (1, hash_symname, eq_symname, NULL,
733 xcalloc, xfree));
734
735 while (1)
736 {
737 struct symbol *sym;
738 struct block_iterator iter;
739
740 /* Iterate over symbols in this block, generating code to
741 compute the location of each local variable. */
742 for (sym = block_iterator_first (block, &iter);
743 sym != NULL;
744 sym = block_iterator_next (&iter))
745 {
746 if (!symbol_seen (symhash.get (), sym))
747 generate_c_for_for_one_variable (compiler, stream, gdbarch,
748 registers_used, pc, sym);
749 }
750
751 /* If we just finished the outermost block of a function, we're
752 done. */
753 if (BLOCK_FUNCTION (block) != NULL)
754 break;
755 block = BLOCK_SUPERBLOCK (block);
756 }
757
758 discard_cleanups (outer);
759 return registers_used;
760 }
c_get_range_decl_name
std::string c_get_range_decl_name(const struct dynamic_prop *prop)
Definition: compile-c-support.c:62
target_gdbarch
struct gdbarch * target_gdbarch(void)
Definition: gdbarch.c:5467
err
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
Definition: gnu-nat.c:1822
TYPE_HIGH_BOUND_KIND
#define TYPE_HIGH_BOUND_KIND(range_type)
Definition: gdbtypes.h:1252
gdbarch
Definition: gdbarch.c:127
string
const char * string
Definition: signals.c:50
block_iterator_next
struct symbol * block_iterator_next(struct block_iterator *iterator)
Definition: block.c:584
compile_c_instance
Definition: compile-internal.h:62
TYPE_CODE_ARRAY
Definition: gdbtypes.h:104
TYPE_RANGE_DATA
#define TYPE_RANGE_DATA(thistype)
Definition: gdbtypes.h:1243
generate_c_for_variable_locations
unsigned char * generate_c_for_variable_locations(struct compile_c_instance *compiler, string_file &stream, struct gdbarch *gdbarch, const struct block *block, CORE_ADDR pc)
Definition: compile-c-symbols.c:712
convert_symbol_sym
static void convert_symbol_sym(struct compile_c_instance *context, const char *identifier, struct block_symbol sym, domain_enum domain)
Definition: compile-c-symbols.c:305
TYPE_CODE_ENUM
Definition: gdbtypes.h:108
get_selected_frame
struct frame_info * get_selected_frame(const char *message)
Definition: frame.c:1638
SYMBOL_PRINT_NAME
#define SYMBOL_PRINT_NAME(symbol)
Definition: symtab.h:542
symbol_error::message
char * message
Definition: compile-c-symbols.c:46
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
dwarf2_compile_property_to_c
void dwarf2_compile_property_to_c(string_file &stream, const char *result_name, struct gdbarch *gdbarch, unsigned char *registers_used, const struct dynamic_prop *prop, CORE_ADDR pc, struct symbol *sym)
Definition: dwarf2loc.c:2694
mst_bss
Definition: symtab.h:587
RETURN_MASK_ALL
Definition: common-exceptions.h:44
xfree
void xfree(void *)
LOC_BLOCK
Definition: symtab.h:854
compile_c_instance::base
struct compile_instance base
Definition: compile-internal.h:67
BMSYMBOL_VALUE_ADDRESS
#define BMSYMBOL_VALUE_ADDRESS(symbol)
Definition: symtab.h:691
warning
void warning(const char *fmt,...)
Definition: errors.c:26
hash_symname
static hashval_t hash_symname(const void *a)
Definition: compile-c-symbols.c:543
insert_symbol_error
static void insert_symbol_error(htab_t hash, const struct symbol *sym, const char *text)
Definition: compile-c-symbols.c:84
LOC_FINAL_VALUE
Definition: symtab.h:899
domain_enum
enum domain_enum_tag domain_enum
TYPE_CODE_RANGE
Definition: gdbtypes.h:127
objfile_type
const struct objfile_type * objfile_type(struct objfile *objfile)
Definition: gdbtypes.c:5363
RETURN_MASK_ERROR
Definition: common-exceptions.h:43
LOC_COMMON_BLOCK
Definition: symtab.h:896
SYMBOL_CLASS
#define SYMBOL_CLASS(symbol)
Definition: symtab.h:1155
compile_debug
int compile_debug
Definition: compile.c:57
internal_error
void internal_error(const char *file, int line, const char *fmt,...)
Definition: errors.c:50
LOC_UNDEF
Definition: symtab.h:797
compile_c_instance::symbol_err_map
htab_t symbol_err_map
Definition: compile-internal.h:75
symbol_seen
static int symbol_seen(htab_t hashtab, struct symbol *sym)
Definition: compile-c-symbols.c:566
frame_info
Definition: frame.c:85
symbol_error::sym
const struct symbol * sym
Definition: compile-c-symbols.c:41
string_file::write
void write(const char *buf, long length_buf) override
Definition: ui-file.c:138
LOC_TYPEDEF
Definition: symtab.h:844
objfile_type::nodebug_data_symbol
struct type * nodebug_data_symbol
Definition: gdbtypes.h:1618
lookup_symbol
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
Definition: symtab.c:1893
mst_text_gnu_ifunc
Definition: symtab.h:583
symtab::filename
const char * filename
Definition: symtab.h:1309
gdbarch_num_regs
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition: gdbarch.c:2039
dynamic_prop
Definition: gdbtypes.h:398
cleanup
Definition: cleanups.c:38
STRUCT_DOMAIN
Definition: symtab.h:745
_
#define _(String)
Definition: gdb_locale.h:35
mst_file_data
Definition: symtab.h:601
defs.h
TYPE_FIELD
#define TYPE_FIELD(thistype, n)
Definition: gdbtypes.h:1370
BLOCK_START
#define BLOCK_START(bl)
Definition: block.h:105
LOC_ARG
Definition: symtab.h:823
TYPE_FIELD_TYPE
#define TYPE_FIELD_TYPE(thistype, n)
Definition: gdbtypes.h:1371
END_CATCH
#define END_CATCH
Definition: common-exceptions.h:259
VALUE_LVAL
#define VALUE_LVAL(val)
Definition: value.h:414
LABEL_DOMAIN
Definition: symtab.h:753
LOC_LOCAL
Definition: symtab.h:839
objfiles.h
TYPE_IS_REFERENCE
#define TYPE_IS_REFERENCE(t)
Definition: gdbtypes.h:332
XNEW
#define XNEW(T)
Definition: poison.h:109
BLOCK_FUNCTION
#define BLOCK_FUNCTION(bl)
Definition: block.h:107
eq_symname
static int eq_symname(const void *a, const void *b)
Definition: compile-c-symbols.c:554
LOC_REGISTER
Definition: symtab.h:819
gcc_convert_symbol
void gcc_convert_symbol(void *datum, struct gcc_c_context *gcc_context, enum gcc_c_oracle_request request, const char *identifier)
Definition: compile-c-symbols.c:414
objfile_type::nodebug_text_gnu_ifunc_symbol
struct type * nodebug_text_gnu_ifunc_symbol
Definition: gdbtypes.h:1616
parser-defs.h
XCNEWVEC
#define XCNEWVEC(T, N)
Definition: poison.h:157
TRY
#define TRY
Definition: common-exceptions.h:246
generate_c_for_for_one_variable
static void generate_c_for_for_one_variable(struct compile_c_instance *compiler, string_file &stream, struct gdbarch *gdbarch, unsigned char *registers_used, CORE_ADDR pc, struct symbol *sym)
Definition: compile-c-symbols.c:635
symtab.h
lval_memory
Definition: defs.h:383
name
const char *const name
Definition: aarch64-tdep.c:76
symbol_error
Definition: compile-c-symbols.c:37
C_CTX
#define C_CTX(I)
Definition: compile-internal.h:81
check_typedef
struct type * check_typedef(struct type *type)
Definition: gdbtypes.c:2421
TYPE_GNU_IFUNC
#define TYPE_GNU_IFUNC(t)
Definition: gdbtypes.h:283
SYMBOL_VALUE_ADDRESS
#define SYMBOL_VALUE_ADDRESS(symbol)
Definition: symtab.h:464
LOC_CONST_BYTES
Definition: symtab.h:859
CATCH
#define CATCH(EXCEPTION, MASK)
Definition: common-exceptions.h:254
LOC_COMPUTED
Definition: symtab.h:892
PROP_LOCEXPR
Definition: gdbtypes.h:381
gdb::unique_xmalloc_ptr
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
Definition: gdb_unique_ptr.h:48
SYMBOL_DOMAIN
#define SYMBOL_DOMAIN(symbol)
Definition: symtab.h:1152
field_is_static
int field_is_static(struct field *f)
Definition: gdbtypes.c:4224
mst_data
Definition: symtab.h:586
read_var_value
struct value * read_var_value(struct symbol *var, const struct block *var_block, struct frame_info *frame)
Definition: findvar.c:807
mst_slot_got_plt
Definition: symtab.h:585
block_symbol::block
const struct block * block
Definition: symtab.h:1140
bound_minimal_symbol
Definition: minsyms.h:29
htab_up
std::unique_ptr< htab, htab_deleter > htab_up
Definition: utils.h:266
fprintf_unfiltered
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2018
symbol_read_needs_frame
int symbol_read_needs_frame(struct symbol *sym)
Definition: findvar.c:392
block_symbol
Definition: symtab.h:1133
gdb_assert_not_reached
#define gdb_assert_not_reached(message)
Definition: gdb_assert.h:55
SYMBOL_COMPUTED_OPS
#define SYMBOL_COMPUTED_OPS(symbol)
Definition: symtab.h:1163
make_cleanup
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
Definition: cleanups.c:116
TYPE_CODE_UNION
Definition: gdbtypes.h:107
type
Definition: gdbtypes.h:749
hash_symbol_error
static hashval_t hash_symbol_error(const void *a)
Definition: compile-c-symbols.c:52
LOC_CONST
Definition: symtab.h:801
LOC_UNRESOLVED
Definition: symtab.h:883
BLOCK_SUPERBLOCK
#define BLOCK_SUPERBLOCK(bl)
Definition: block.h:108
MSYMBOL_NATURAL_NAME
#define MSYMBOL_NATURAL_NAME(symbol)
Definition: symtab.h:705
type
static const char * type
Definition: language.c:113
exceptions.h
SYMBOL_LINE
#define SYMBOL_LINE(symbol)
Definition: symtab.h:1162
objfile_type::nodebug_got_plt_symbol
struct type * nodebug_got_plt_symbol
Definition: gdbtypes.h:1617
string_file::size
size_t size() const
Definition: ui-file.h:138
LOC_STATIC
Definition: symtab.h:805
convert_symbol_bmsym
static void convert_symbol_bmsym(struct compile_c_instance *context, struct bound_minimal_symbol bmsym)
Definition: compile-c-symbols.c:355
error_symbol_once
static void error_symbol_once(struct compile_c_instance *context, const struct symbol *sym)
Definition: compile-c-symbols.c:105
LOC_REGPARM_ADDR
Definition: symtab.h:835
TYPE_CODE_STRUCT
Definition: gdbtypes.h:106
dwarf2loc.h
block_symbol::symbol
struct symbol * symbol
Definition: symtab.h:1136
SYMBOL_VALUE
#define SYMBOL_VALUE(symbol)
Definition: symtab.h:463
LOC_REF_ARG
Definition: symtab.h:827
block
Definition: block.h:60
value
Definition: value.c:169
hash
unsigned long hash(const void *addr, int length)
Definition: bcache.c:98
gcc_symbol_address
gcc_address gcc_symbol_address(void *datum, struct gcc_c_context *gcc_context, const char *identifier)
Definition: compile-c-symbols.c:479
objfile_type::nodebug_unknown_symbol
struct type * nodebug_unknown_symbol
Definition: gdbtypes.h:1619
objfile
Definition: objfiles.h:286
compile.h
MSYMBOL_TYPE
#define MSYMBOL_TYPE(msymbol)
Definition: symtab.h:680
discard_cleanups
void discard_cleanups(struct cleanup *old_chain)
Definition: cleanups.c:212
TYPE_TARGET_TYPE
#define TYPE_TARGET_TYPE(thistype)
Definition: gdbtypes.h:1226
PROP_LOCLIST
Definition: gdbtypes.h:382
SYMBOL_BLOCK_VALUE
#define SYMBOL_BLOCK_VALUE(symbol)
Definition: symtab.h:467
block_static_block
const struct block * block_static_block(const struct block *block)
Definition: block.c:364
TYPE_CODE
#define TYPE_CODE(thistype)
Definition: gdbtypes.h:1238
TYPE_INDEX_TYPE
#define TYPE_INDEX_TYPE(type)
Definition: gdbtypes.h:1242
compile_instance::scope
enum compile_i_scope_types scope
Definition: compile-internal.h:44
string_file::c_str
const char * c_str() const
Definition: ui-file.h:137
bound_minimal_symbol::minsym
struct minimal_symbol * minsym
Definition: minsyms.h:34
compile-internal.h
lookup_bound_minimal_symbol
struct bound_minimal_symbol lookup_bound_minimal_symbol(const char *name)
Definition: minsyms.c:430
TYPE_NFIELDS
#define TYPE_NFIELDS(thistype)
Definition: gdbtypes.h:1239
LOC_LABEL
Definition: symtab.h:848
mst_text
Definition: symtab.h:582
VAR_DOMAIN
Definition: symtab.h:739
mst_solib_trampoline
Definition: symtab.h:597
value.h
block_iterator
Definition: block.h:197
objfile_type::nodebug_text_symbol
struct type * nodebug_text_symbol
Definition: gdbtypes.h:1615
eq_symbol_error
static int eq_symbol_error(const void *a, const void *b)
Definition: compile-c-symbols.c:62
SYMBOL_NATURAL_NAME
#define SYMBOL_NATURAL_NAME(symbol)
Definition: symtab.h:513
gdbtypes.h
is_dynamic_type
int is_dynamic_type(struct type *type)
Definition: gdbtypes.c:1976
compile_instance::block
const struct block * block
Definition: compile-internal.h:48
gdb_stdlog
#define gdb_stdlog
Definition: utils.h:349
frame_info::addr
CORE_ADDR addr
Definition: frame.c:128
SYMBOL_TYPE
#define SYMBOL_TYPE(symbol)
Definition: symtab.h:1161
convert_one_symbol
static void convert_one_symbol(struct compile_c_instance *context, struct block_symbol sym, int is_global, int is_local)
Definition: compile-c-symbols.c:144
symbol
Definition: symtab.h:1049
LOC_OPTIMIZED_OUT
Definition: symtab.h:888
block_iterator_first
struct symbol * block_iterator_first(const struct block *block, struct block_iterator *iterator)
Definition: block.c:570
minimal_symbol
Definition: symtab.h:623
bound_minimal_symbol::objfile
struct objfile * objfile
Definition: minsyms.h:39
mst_file_bss
Definition: symtab.h:602
convert_type
gcc_type convert_type(struct compile_c_instance *context, struct type *type)
Definition: compile-c-types.c:411
value_address
CORE_ADDR value_address(const struct value *value)
Definition: value.c:1529
COMPILE_I_RAW_SCOPE
Definition: defs.h:73
lookup_minimal_symbol
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition: minsyms.c:311
xcalloc
PTR xcalloc(size_t number, size_t size)
Definition: common-utils.c:72
symbol_substitution_name
static gdb::unique_xmalloc_ptr< char > symbol_substitution_name(struct symbol *sym)
Definition: compile-c-symbols.c:130
symbol_symtab
struct symtab * symbol_symtab(const struct symbol *symbol)
Definition: symtab.c:5803
del_symbol_error
static void del_symbol_error(void *a)
Definition: compile-c-symbols.c:73
error
void error(const char *fmt,...)
Definition: errors.c:38
block.h
generate_vla_size
static void generate_vla_size(struct compile_c_instance *compiler, string_file &stream, struct gdbarch *gdbarch, unsigned char *registers_used, CORE_ADDR pc, struct type *type, struct symbol *sym)
Definition: compile-c-symbols.c:581
gnu_ifunc_resolve_addr
#define gnu_ifunc_resolve_addr
Definition: symtab.h:1736
MSYMBOL_VALUE_ADDRESS
#define MSYMBOL_VALUE_ADDRESS(objfile, symbol)
Definition: symtab.h:687
mst_file_text
Definition: symtab.h:600
string_file
Definition: ui-file.h:106