struct symbol * block_containing_function (const struct block *bl) { while (BLOCK_FUNCTION (bl) == NULL && BLOCK_SUPERBLOCK (bl) != NULL) bl = BLOCK_SUPERBLOCK (bl); return BLOCK_FUNCTION (bl); }
struct symbol * block_function (const struct block *bl) { while (BLOCK_FUNCTION (bl) == 0 && BLOCK_SUPERBLOCK (bl) != 0) bl = BLOCK_SUPERBLOCK (bl); return BLOCK_FUNCTION (bl); }
struct symbol * block_linkage_function (const struct block *bl) { while ((BLOCK_FUNCTION (bl) == NULL || block_inlined_p (bl)) && BLOCK_SUPERBLOCK (bl) != NULL) bl = BLOCK_SUPERBLOCK (bl); return BLOCK_FUNCTION (bl); }
struct symbol * get_frame_function (struct frame_info *frame) { struct block *bl = get_frame_block (frame, 0); if (bl == NULL) return NULL; while (BLOCK_FUNCTION (bl) == NULL && BLOCK_SUPERBLOCK (bl) != NULL) bl = BLOCK_SUPERBLOCK (bl); return BLOCK_FUNCTION (bl); }
char * go_block_package_name (const struct block *block) { while (block != NULL) { struct symbol *function = BLOCK_FUNCTION (block); if (function != NULL) { char *package_name = go_symbol_package_name (function); if (package_name != NULL) return package_name; /* Stop looking if we find a function without a package name. We're most likely outside of Go and thus the concept of the "current" package is gone. */ return NULL; } block = BLOCK_SUPERBLOCK (block); } return NULL; }
static PyObject * blpy_get_function (PyObject *self, void *closure) { struct symbol *sym; struct block *block = NULL; BLPY_REQUIRE_VALID (self, block); sym = BLOCK_FUNCTION (block); if (sym) return symbol_to_symbol_object (sym); Py_RETURN_NONE; }
struct block * allocate_block(struct obstack *obstack) { struct block *bl = (struct block *)obstack_alloc(obstack, sizeof(struct block)); BLOCK_START(bl) = 0; BLOCK_END(bl) = 0; BLOCK_FUNCTION(bl) = NULL; BLOCK_SUPERBLOCK(bl) = NULL; BLOCK_DICT(bl) = NULL; BLOCK_NAMESPACE(bl) = NULL; BLOCK_GCC_COMPILED(bl) = 0; /* APPLE LOCAL begin address ranges */ BLOCK_RANGES(bl) = NULL; /* APPLE LOCAL end address ranges */ return bl; }
int contained_in (const struct block *a, const struct block *b) { if (!a || !b) return 0; do { if (a == b) return 1; /* If A is a function block, then A cannot be contained in B, except if A was inlined. */ if (BLOCK_FUNCTION (a) != NULL && !block_inlined_p (a)) return 0; a = BLOCK_SUPERBLOCK (a); } while (a != NULL); return 0; }
struct symbol * find_pc_sect_function (CORE_ADDR pc, struct bfd_section *section) { /* APPLE LOCAL begin cache lookup values for improved performance */ struct block *b; /* APPLE LOCAL inlined function symbols & blocks */ struct symbol *func_sym; if (pc == last_function_lookup_pc && pc == last_mapped_section_lookup_pc && section == cached_mapped_section && cached_pc_function) return cached_pc_function; last_function_lookup_pc = pc; b = block_for_pc_sect (pc, section); if (b == 0) { cached_pc_function = NULL; return 0; } /* APPLE LOCAL begin inlined function symbols & blocks */ func_sym = NULL; if (BLOCK_FUNCTION (b) == 0) { /* APPLE LOCAL radar 6381384, add section to symtab lookups. */ func_sym = block_inlined_function (b, section); } if (!func_sym) func_sym = block_function (b); cached_pc_function = func_sym; return func_sym; /* APPLE LOCAL end inlined function symbols & blocks */ /* APPLE LOCAL end cache lookup values for improved performance */ }
/* Standard implementation of print_subexp for use in language_defn vectors. */ void print_subexp_standard (struct expression *exp, int *pos, struct ui_file *stream, enum precedence prec) { unsigned tem; const struct op_print *op_print_tab; int pc; unsigned nargs; char *op_str; int assign_modify = 0; enum exp_opcode opcode; enum precedence myprec = PREC_NULL; /* Set to 1 for a right-associative operator. */ int assoc = 0; struct value *val; char *tempstr = NULL; op_print_tab = exp->language_defn->la_op_print_tab; pc = (*pos)++; opcode = exp->elts[pc].opcode; switch (opcode) { /* Common ops */ case OP_SCOPE: myprec = PREC_PREFIX; assoc = 0; fputs_filtered (type_name_no_tag (exp->elts[pc + 1].type), stream); fputs_filtered ("::", stream); nargs = longest_to_int (exp->elts[pc + 2].longconst); (*pos) += 4 + BYTES_TO_EXP_ELEM (nargs + 1); fputs_filtered (&exp->elts[pc + 3].string, stream); return; case OP_LONG: (*pos) += 3; value_print (value_from_longest (exp->elts[pc + 1].type, exp->elts[pc + 2].longconst), stream, 0, Val_no_prettyprint); return; case OP_DOUBLE: (*pos) += 3; value_print (value_from_double (exp->elts[pc + 1].type, exp->elts[pc + 2].doubleconst), stream, 0, Val_no_prettyprint); return; case OP_VAR_VALUE: { struct block *b; (*pos) += 3; b = exp->elts[pc + 1].block; if (b != NULL && BLOCK_FUNCTION (b) != NULL && SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)) != NULL) { fputs_filtered (SYMBOL_PRINT_NAME (BLOCK_FUNCTION (b)), stream); fputs_filtered ("::", stream); } fputs_filtered (SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol), stream); } return; case OP_LAST: (*pos) += 2; fprintf_filtered (stream, "$%d", longest_to_int (exp->elts[pc + 1].longconst)); return; case OP_REGISTER: { int regnum = longest_to_int (exp->elts[pc + 1].longconst); const char *name = user_reg_map_regnum_to_name (current_gdbarch, regnum); (*pos) += 2; fprintf_filtered (stream, "$%s", name); return; } case OP_BOOL: (*pos) += 2; fprintf_filtered (stream, "%s", longest_to_int (exp->elts[pc + 1].longconst) ? "TRUE" : "FALSE"); return; case OP_INTERNALVAR: (*pos) += 2; fprintf_filtered (stream, "$%s", internalvar_name (exp->elts[pc + 1].internalvar)); return; case OP_FUNCALL: (*pos) += 2; nargs = longest_to_int (exp->elts[pc + 1].longconst); print_subexp (exp, pos, stream, PREC_SUFFIX); fputs_filtered (" (", stream); for (tem = 0; tem < nargs; tem++) { if (tem != 0) fputs_filtered (", ", stream); print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); } fputs_filtered (")", stream); return; case OP_NAME: case OP_EXPRSTRING: nargs = longest_to_int (exp->elts[pc + 1].longconst); (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); fputs_filtered (&exp->elts[pc + 2].string, stream); return; case OP_STRING: nargs = longest_to_int (exp->elts[pc + 1].longconst); (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); /* LA_PRINT_STRING will print using the current repeat count threshold. If necessary, we can temporarily set it to zero, or pass it as an additional parameter to LA_PRINT_STRING. -fnf */ LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0); return; case OP_BITSTRING: nargs = longest_to_int (exp->elts[pc + 1].longconst); (*pos) += 3 + BYTES_TO_EXP_ELEM ((nargs + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT); fprintf_unfiltered (stream, "B'<unimplemented>'"); return; case OP_OBJC_NSSTRING: /* Objective-C Foundation Class NSString constant. */ nargs = longest_to_int (exp->elts[pc + 1].longconst); (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); fputs_filtered ("@\"", stream); LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0); fputs_filtered ("\"", stream); return; case OP_OBJC_MSGCALL: { /* Objective C message (method) call. */ char *selector; (*pos) += 3; nargs = longest_to_int (exp->elts[pc + 2].longconst); fprintf_unfiltered (stream, "["); print_subexp (exp, pos, stream, PREC_SUFFIX); if (0 == target_read_string (exp->elts[pc + 1].longconst, &selector, 1024, NULL)) { error (_("bad selector")); return; } if (nargs) { char *s, *nextS; s = alloca (strlen (selector) + 1); strcpy (s, selector); for (tem = 0; tem < nargs; tem++) { nextS = strchr (s, ':'); *nextS = '\0'; fprintf_unfiltered (stream, " %s: ", s); s = nextS + 1; print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); } } else { fprintf_unfiltered (stream, " %s", selector); } fprintf_unfiltered (stream, "]"); /* "selector" was malloc'd by target_read_string. Free it. */ xfree (selector); return; } case OP_ARRAY: (*pos) += 3; nargs = longest_to_int (exp->elts[pc + 2].longconst); nargs -= longest_to_int (exp->elts[pc + 1].longconst); nargs++; tem = 0; if (exp->elts[pc + 4].opcode == OP_LONG && exp->elts[pc + 5].type == builtin_type_char && exp->language_defn->la_language == language_c) { /* Attempt to print C character arrays using string syntax. Walk through the args, picking up one character from each of the OP_LONG expression elements. If any array element does not match our expection of what we should find for a simple string, revert back to array printing. Note that the last expression element is an explicit null terminator byte, which doesn't get printed. */ tempstr = alloca (nargs); pc += 4; while (tem < nargs) { if (exp->elts[pc].opcode != OP_LONG || exp->elts[pc + 1].type != builtin_type_char) { /* Not a simple array of char, use regular array printing. */ tem = 0; break; } else { tempstr[tem++] = longest_to_int (exp->elts[pc + 2].longconst); pc += 4; } } } if (tem > 0) { LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0); (*pos) = pc; } else { fputs_filtered (" {", stream); for (tem = 0; tem < nargs; tem++) { if (tem != 0) { fputs_filtered (", ", stream); } print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); } fputs_filtered ("}", stream); } return; case OP_LABELED: tem = longest_to_int (exp->elts[pc + 1].longconst); (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); /* Gcc support both these syntaxes. Unsure which is preferred. */ #if 1 fputs_filtered (&exp->elts[pc + 2].string, stream); fputs_filtered (": ", stream); #else fputs_filtered (".", stream); fputs_filtered (&exp->elts[pc + 2].string, stream); fputs_filtered ("=", stream); #endif print_subexp (exp, pos, stream, PREC_SUFFIX); return; case TERNOP_COND: if ((int) prec > (int) PREC_COMMA) fputs_filtered ("(", stream); /* Print the subexpressions, forcing parentheses around any binary operations within them. This is more parentheses than are strictly necessary, but it looks clearer. */ print_subexp (exp, pos, stream, PREC_HYPER); fputs_filtered (" ? ", stream); print_subexp (exp, pos, stream, PREC_HYPER); fputs_filtered (" : ", stream); print_subexp (exp, pos, stream, PREC_HYPER); if ((int) prec > (int) PREC_COMMA) fputs_filtered (")", stream); return; case TERNOP_SLICE: case TERNOP_SLICE_COUNT: print_subexp (exp, pos, stream, PREC_SUFFIX); fputs_filtered ("(", stream); print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); fputs_filtered (opcode == TERNOP_SLICE ? " : " : " UP ", stream); print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); fputs_filtered (")", stream); return; case STRUCTOP_STRUCT: tem = longest_to_int (exp->elts[pc + 1].longconst); (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); print_subexp (exp, pos, stream, PREC_SUFFIX); fputs_filtered (".", stream); fputs_filtered (&exp->elts[pc + 2].string, stream); return; /* Will not occur for Modula-2 */ case STRUCTOP_PTR: tem = longest_to_int (exp->elts[pc + 1].longconst); (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); print_subexp (exp, pos, stream, PREC_SUFFIX); fputs_filtered ("->", stream); fputs_filtered (&exp->elts[pc + 2].string, stream); return; case BINOP_SUBSCRIPT: print_subexp (exp, pos, stream, PREC_SUFFIX); fputs_filtered ("[", stream); print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); fputs_filtered ("]", stream); return; case UNOP_POSTINCREMENT: print_subexp (exp, pos, stream, PREC_SUFFIX); fputs_filtered ("++", stream); return; case UNOP_POSTDECREMENT: print_subexp (exp, pos, stream, PREC_SUFFIX); fputs_filtered ("--", stream); return; case UNOP_CAST: (*pos) += 2; if ((int) prec > (int) PREC_PREFIX) fputs_filtered ("(", stream); fputs_filtered ("(", stream); type_print (exp->elts[pc + 1].type, "", stream, 0); fputs_filtered (") ", stream); print_subexp (exp, pos, stream, PREC_PREFIX); if ((int) prec > (int) PREC_PREFIX) fputs_filtered (")", stream); return; case UNOP_MEMVAL: (*pos) += 2; if ((int) prec > (int) PREC_PREFIX) fputs_filtered ("(", stream); if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC && exp->elts[pc + 3].opcode == OP_LONG) { /* We have a minimal symbol fn, probably. It's encoded as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address). Swallow the OP_LONG (including both its opcodes); ignore its type; print the value in the type of the MEMVAL. */ (*pos) += 4; val = value_at_lazy (exp->elts[pc + 1].type, (CORE_ADDR) exp->elts[pc + 5].longconst); value_print (val, stream, 0, Val_no_prettyprint); } else { fputs_filtered ("{", stream); type_print (exp->elts[pc + 1].type, "", stream, 0); fputs_filtered ("} ", stream); print_subexp (exp, pos, stream, PREC_PREFIX); } if ((int) prec > (int) PREC_PREFIX) fputs_filtered (")", stream); return; case BINOP_ASSIGN_MODIFY: opcode = exp->elts[pc + 1].opcode; (*pos) += 2; myprec = PREC_ASSIGN; assoc = 1; assign_modify = 1; op_str = "???"; for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++) if (op_print_tab[tem].opcode == opcode) { op_str = op_print_tab[tem].string; break; } if (op_print_tab[tem].opcode != opcode) /* Not found; don't try to keep going because we don't know how to interpret further elements. */ error (_("Invalid expression")); break; /* C++ ops */ case OP_THIS: ++(*pos); fputs_filtered ("this", stream); return; /* Objective-C ops */ case OP_OBJC_SELF: ++(*pos); fputs_filtered ("self", stream); /* The ObjC equivalent of "this". */ return; /* Modula-2 ops */ case MULTI_SUBSCRIPT: (*pos) += 2; nargs = longest_to_int (exp->elts[pc + 1].longconst); print_subexp (exp, pos, stream, PREC_SUFFIX); fprintf_unfiltered (stream, " ["); for (tem = 0; tem < nargs; tem++) { if (tem != 0) fprintf_unfiltered (stream, ", "); print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); } fprintf_unfiltered (stream, "]"); return; case BINOP_VAL: (*pos) += 2; fprintf_unfiltered (stream, "VAL("); type_print (exp->elts[pc + 1].type, "", stream, 0); fprintf_unfiltered (stream, ","); print_subexp (exp, pos, stream, PREC_PREFIX); fprintf_unfiltered (stream, ")"); return; case BINOP_INCL: case BINOP_EXCL: error (_("print_subexp: Not implemented.")); /* Default ops */ default: op_str = "???"; for (tem = 0; op_print_tab[tem].opcode != OP_NULL; tem++) if (op_print_tab[tem].opcode == opcode) { op_str = op_print_tab[tem].string; myprec = op_print_tab[tem].precedence; assoc = op_print_tab[tem].right_assoc; break; } if (op_print_tab[tem].opcode != opcode) /* Not found; don't try to keep going because we don't know how to interpret further elements. For example, this happens if opcode is OP_TYPE. */ error (_("Invalid expression")); } /* Note that PREC_BUILTIN will always emit parentheses. */ if ((int) myprec < (int) prec) fputs_filtered ("(", stream); if ((int) opcode > (int) BINOP_END) { if (assoc) { /* Unary postfix operator. */ print_subexp (exp, pos, stream, PREC_SUFFIX); fputs_filtered (op_str, stream); } else { /* Unary prefix operator. */ fputs_filtered (op_str, stream); if (myprec == PREC_BUILTIN_FUNCTION) fputs_filtered ("(", stream); print_subexp (exp, pos, stream, PREC_PREFIX); if (myprec == PREC_BUILTIN_FUNCTION) fputs_filtered (")", stream); } } else { /* Binary operator. */ /* Print left operand. If operator is right-associative, increment precedence for this operand. */ print_subexp (exp, pos, stream, (enum precedence) ((int) myprec + assoc)); /* Print the operator itself. */ if (assign_modify) fprintf_filtered (stream, " %s= ", op_str); else if (op_str[0] == ',') fprintf_filtered (stream, "%s ", op_str); else fprintf_filtered (stream, " %s ", op_str); /* Print right operand. If operator is left-associative, increment precedence for this operand. */ print_subexp (exp, pos, stream, (enum precedence) ((int) myprec + !assoc)); } if ((int) myprec < (int) prec) fputs_filtered (")", stream); }
static void list_args_or_locals (enum what_to_list what, enum print_values values, struct frame_info *fi, int skip_unavailable) { const struct block *block; struct symbol *sym; struct block_iterator iter; struct cleanup *cleanup_list; struct type *type; char *name_of_result; struct ui_out *uiout = current_uiout; block = get_frame_block (fi, 0); switch (what) { case locals: name_of_result = "locals"; break; case arguments: name_of_result = "args"; break; case all: name_of_result = "variables"; break; default: internal_error (__FILE__, __LINE__, "unexpected what_to_list: %d", (int) what); } cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, name_of_result); while (block != 0) { ALL_BLOCK_SYMBOLS (block, iter, sym) { int print_me = 0; switch (SYMBOL_CLASS (sym)) { default: case LOC_UNDEF: /* catches errors */ case LOC_CONST: /* constant */ case LOC_TYPEDEF: /* local typedef */ case LOC_LABEL: /* local label */ case LOC_BLOCK: /* local function */ case LOC_CONST_BYTES: /* loc. byte seq. */ case LOC_UNRESOLVED: /* unresolved static */ case LOC_OPTIMIZED_OUT: /* optimized out */ print_me = 0; break; case LOC_ARG: /* argument */ case LOC_REF_ARG: /* reference arg */ case LOC_REGPARM_ADDR: /* indirect register arg */ case LOC_LOCAL: /* stack local */ case LOC_STATIC: /* static */ case LOC_REGISTER: /* register */ case LOC_COMPUTED: /* computed location */ if (what == all) print_me = 1; else if (what == locals) print_me = !SYMBOL_IS_ARGUMENT (sym); else print_me = SYMBOL_IS_ARGUMENT (sym); break; } if (print_me) { struct symbol *sym2; struct frame_arg arg, entryarg; if (SYMBOL_IS_ARGUMENT (sym)) sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), block, VAR_DOMAIN, NULL); else sym2 = sym; gdb_assert (sym2 != NULL); memset (&arg, 0, sizeof (arg)); arg.sym = sym2; arg.entry_kind = print_entry_values_no; memset (&entryarg, 0, sizeof (entryarg)); entryarg.sym = sym2; entryarg.entry_kind = print_entry_values_no; switch (values) { case PRINT_SIMPLE_VALUES: type = check_typedef (sym2->type); if (TYPE_CODE (type) != TYPE_CODE_ARRAY && TYPE_CODE (type) != TYPE_CODE_STRUCT && TYPE_CODE (type) != TYPE_CODE_UNION) { case PRINT_ALL_VALUES: if (SYMBOL_IS_ARGUMENT (sym)) read_frame_arg (sym2, fi, &arg, &entryarg); else read_frame_local (sym2, fi, &arg); } break; } if (arg.entry_kind != print_entry_values_only) list_arg_or_local (&arg, what, values, skip_unavailable); if (entryarg.entry_kind != print_entry_values_no) list_arg_or_local (&entryarg, what, values, skip_unavailable); xfree (arg.error); xfree (entryarg.error); } } if (BLOCK_FUNCTION (block)) break; else block = BLOCK_SUPERBLOCK (block); }
struct block_symbol cp_lookup_symbol_imports_or_template (const char *scope, const char *name, const struct block *block, const domain_enum domain) { struct symbol *function = BLOCK_FUNCTION (block); struct block_symbol result; if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, "cp_lookup_symbol_imports_or_template" " (%s, %s, %s, %s)\n", scope, name, host_address_to_string (block), domain_name (domain)); } if (function != NULL && SYMBOL_LANGUAGE (function) == language_cplus) { /* Search the function's template parameters. */ if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function)) { struct template_symbol *templ = (struct template_symbol *) function; struct symbol *sym = search_symbol_list (name, templ->n_template_arguments, templ->template_arguments); if (sym != NULL) { if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, "cp_lookup_symbol_imports_or_template" " (...) = %s\n", host_address_to_string (sym)); } return (struct block_symbol) {sym, block}; } } /* Search the template parameters of the function's defining context. */ if (SYMBOL_NATURAL_NAME (function)) { struct type *context; char *name_copy = xstrdup (SYMBOL_NATURAL_NAME (function)); struct cleanup *cleanups = make_cleanup (xfree, name_copy); const struct language_defn *lang = language_def (language_cplus); struct gdbarch *arch = symbol_arch (function); const struct block *parent = BLOCK_SUPERBLOCK (block); struct symbol *sym; while (1) { unsigned int prefix_len = cp_entire_prefix_len (name_copy); if (prefix_len == 0) context = NULL; else { name_copy[prefix_len] = '\0'; context = lookup_typename (lang, arch, name_copy, parent, 1); } if (context == NULL) break; sym = search_symbol_list (name, TYPE_N_TEMPLATE_ARGUMENTS (context), TYPE_TEMPLATE_ARGUMENTS (context)); if (sym != NULL) { do_cleanups (cleanups); if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, "cp_lookup_symbol_imports_or_template (...) = %s\n", host_address_to_string (sym)); } return (struct block_symbol) {sym, parent}; } } do_cleanups (cleanups); } }
int block_inlined_p (const struct block *bl) { return BLOCK_FUNCTION (bl) != NULL && SYMBOL_INLINED (BLOCK_FUNCTION (bl)); }
static struct type * get_out_value_type (struct symbol *func_sym, struct objfile *objfile, enum compile_i_scope_types scope) { struct symbol *gdb_ptr_type_sym; /* Initialize it just to avoid a GCC false warning. */ struct symbol *gdb_val_sym = NULL; struct type *gdb_ptr_type, *gdb_type_from_ptr, *gdb_type, *retval; /* Initialize it just to avoid a GCC false warning. */ const struct block *block = NULL; const struct blockvector *bv; int nblocks = 0; int block_loop = 0; bv = SYMTAB_BLOCKVECTOR (func_sym->owner.symtab); nblocks = BLOCKVECTOR_NBLOCKS (bv); gdb_ptr_type_sym = NULL; for (block_loop = 0; block_loop < nblocks; block_loop++) { struct symbol *function = NULL; const struct block *function_block; block = BLOCKVECTOR_BLOCK (bv, block_loop); if (BLOCK_FUNCTION (block) != NULL) continue; gdb_val_sym = block_lookup_symbol (block, COMPILE_I_EXPR_VAL, VAR_DOMAIN); if (gdb_val_sym == NULL) continue; function_block = block; while (function_block != BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) && function_block != BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) { function_block = BLOCK_SUPERBLOCK (function_block); function = BLOCK_FUNCTION (function_block); if (function != NULL) break; } if (function != NULL && (BLOCK_SUPERBLOCK (function_block) == BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) && (strcmp (SYMBOL_LINKAGE_NAME (function), GCC_FE_WRAPPER_FUNCTION) == 0)) break; } if (block_loop == nblocks) error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE); gdb_type = SYMBOL_TYPE (gdb_val_sym); gdb_type = check_typedef (gdb_type); gdb_ptr_type_sym = block_lookup_symbol (block, COMPILE_I_EXPR_PTR_TYPE, VAR_DOMAIN); if (gdb_ptr_type_sym == NULL) error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE); gdb_ptr_type = SYMBOL_TYPE (gdb_ptr_type_sym); gdb_ptr_type = check_typedef (gdb_ptr_type); if (TYPE_CODE (gdb_ptr_type) != TYPE_CODE_PTR) error (_("Type of \"%s\" is not a pointer"), COMPILE_I_EXPR_PTR_TYPE); gdb_type_from_ptr = TYPE_TARGET_TYPE (gdb_ptr_type); if (types_deeply_equal (gdb_type, gdb_type_from_ptr)) { if (scope != COMPILE_I_PRINT_ADDRESS_SCOPE) error (_("Expected address scope in compiled module \"%s\"."), objfile_name (objfile)); return gdb_type; } if (TYPE_CODE (gdb_type) != TYPE_CODE_PTR) error (_("Invalid type code %d of symbol \"%s\" " "in compiled module \"%s\"."), TYPE_CODE (gdb_type_from_ptr), COMPILE_I_EXPR_VAL, objfile_name (objfile)); retval = gdb_type_from_ptr; switch (TYPE_CODE (gdb_type_from_ptr)) { case TYPE_CODE_ARRAY: gdb_type_from_ptr = TYPE_TARGET_TYPE (gdb_type_from_ptr); break; case TYPE_CODE_FUNC: break; default: error (_("Invalid type code %d of symbol \"%s\" " "in compiled module \"%s\"."), TYPE_CODE (gdb_type_from_ptr), COMPILE_I_EXPR_PTR_TYPE, objfile_name (objfile)); } if (!types_deeply_equal (gdb_type_from_ptr, TYPE_TARGET_TYPE (gdb_type))) error (_("Referenced types do not match for symbols \"%s\" and \"%s\" " "in compiled module \"%s\"."), COMPILE_I_EXPR_PTR_TYPE, COMPILE_I_EXPR_VAL, objfile_name (objfile)); if (scope == COMPILE_I_PRINT_ADDRESS_SCOPE) return NULL; return retval; }
/* Print a list of the locals or the arguments for the currently selected frame. If the argument passed is 0, printonly the names of the variables, if an argument of 1 is passed, print the values as well. */ static void list_args_or_locals (int locals, int values, struct frame_info *fi) { struct block *block; struct symbol *sym; struct dict_iterator iter; int nsyms; struct cleanup *cleanup_list; static struct ui_stream *stb = NULL; struct type *type; stb = ui_out_stream_new (uiout); block = get_frame_block (fi, 0); cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, locals ? "locals" : "args"); while (block != 0) { ALL_BLOCK_SYMBOLS (block, iter, sym) { int print_me = 0; switch (SYMBOL_CLASS (sym)) { default: case LOC_UNDEF: /* catches errors */ case LOC_CONST: /* constant */ case LOC_TYPEDEF: /* local typedef */ case LOC_LABEL: /* local label */ case LOC_BLOCK: /* local function */ case LOC_CONST_BYTES: /* loc. byte seq. */ case LOC_UNRESOLVED: /* unresolved static */ case LOC_OPTIMIZED_OUT: /* optimized out */ print_me = 0; break; case LOC_ARG: /* argument */ case LOC_REF_ARG: /* reference arg */ case LOC_REGPARM: /* register arg */ case LOC_REGPARM_ADDR: /* indirect register arg */ case LOC_LOCAL_ARG: /* stack arg */ case LOC_BASEREG_ARG: /* basereg arg */ case LOC_COMPUTED_ARG: /* arg with computed location */ if (!locals) print_me = 1; break; case LOC_LOCAL: /* stack local */ case LOC_BASEREG: /* basereg local */ case LOC_STATIC: /* static */ case LOC_REGISTER: /* register */ case LOC_COMPUTED: /* computed location */ if (locals) print_me = 1; break; } if (print_me) { struct cleanup *cleanup_tuple = NULL; struct symbol *sym2; if (values != PRINT_NO_VALUES) cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); ui_out_field_string (uiout, "name", SYMBOL_PRINT_NAME (sym)); if (!locals) sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym), block, VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL); else sym2 = sym; switch (values) { case PRINT_SIMPLE_VALUES: type = check_typedef (sym2->type); type_print (sym2->type, "", stb->stream, -1); ui_out_field_stream (uiout, "type", stb); if (TYPE_CODE (type) != TYPE_CODE_ARRAY && TYPE_CODE (type) != TYPE_CODE_STRUCT && TYPE_CODE (type) != TYPE_CODE_UNION) { print_variable_value (sym2, fi, stb->stream); ui_out_field_stream (uiout, "value", stb); } do_cleanups (cleanup_tuple); break; case PRINT_ALL_VALUES: print_variable_value (sym2, fi, stb->stream); ui_out_field_stream (uiout, "value", stb); do_cleanups (cleanup_tuple); break; } } } if (BLOCK_FUNCTION (block)) break; else block = BLOCK_SUPERBLOCK (block); }