static htab_t syscm_get_symbol_map (struct symbol *symbol) { htab_t htab; if (SYMBOL_OBJFILE_OWNED (symbol)) { struct objfile *objfile = symbol_objfile (symbol); htab = objfile_data (objfile, syscm_objfile_data_key); if (htab == NULL) { htab = gdbscm_create_eqable_gsmob_ptr_map (syscm_hash_symbol_smob, syscm_eq_symbol_smob); set_objfile_data (objfile, syscm_objfile_data_key, htab); } } else { struct gdbarch *gdbarch = symbol_arch (symbol); struct syscm_gdbarch_data *data = gdbarch_data (gdbarch, syscm_gdbarch_data_key); htab = data->htab; } return htab; }
/* Enable shared library breakpoint for the OpenCL runtime running on the SPU. */ static void ocl_enable_break (struct objfile *objfile) { struct bound_minimal_symbol event_sym; struct bound_minimal_symbol addr_sym; /* The OpenCL runtime on the SPU will call __opencl_program_update_event whenever an OpenCL program is loaded. */ event_sym = lookup_minimal_symbol ("__opencl_program_update_event", NULL, objfile); /* The PPU address of the OpenCL program can be found at opencl_elf_image_address. */ addr_sym = lookup_minimal_symbol ("opencl_elf_image_address", NULL, objfile); if (event_sym.minsym && addr_sym.minsym) { /* Place a solib_event breakpoint on the symbol. */ CORE_ADDR event_addr = BMSYMBOL_VALUE_ADDRESS (event_sym); create_solib_event_breakpoint (get_objfile_arch (objfile), event_addr); /* Store the address of the symbol that will point to OpenCL program using the per-objfile private data mechanism. */ if (objfile_data (objfile, ocl_program_data_key) == NULL) { CORE_ADDR *ocl_program_addr_base = OBSTACK_CALLOC ( &objfile->objfile_obstack, objfile->sections_end - objfile->sections, CORE_ADDR); *ocl_program_addr_base = BMSYMBOL_VALUE_ADDRESS (addr_sym); set_objfile_data (objfile, ocl_program_data_key, ocl_program_addr_base); } } }
static int debug_qf_map_symtabs_matching_filename (struct objfile *objfile, const char *name, const char *real_path, int (*callback) (struct symtab *, void *), void *data) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); int retval; fprintf_filtered (gdb_stdlog, "qf->map_symtabs_matching_filename (%s, \"%s\", \"%s\", %s, %s)\n", objfile_debug_name (objfile), name, real_path ? real_path : NULL, host_address_to_string (callback), host_address_to_string (data)); retval = debug_data->real_sf->qf->map_symtabs_matching_filename (objfile, name, real_path, callback, data); fprintf_filtered (gdb_stdlog, "qf->map_symtabs_matching_filename (...) = %d\n", retval); return retval; }
/* Return a borrowed reference to the Python object of type Objfile representing OBJFILE. If the object has already been created, return it. Otherwise, create it. Return NULL and set the Python error on failure. */ PyObject * objfile_to_objfile_object (struct objfile *objfile) { objfile_object *object; object = objfile_data (objfile, objfpy_objfile_data_key); if (!object) { object = PyObject_New (objfile_object, &objfile_object_type); if (object) { PyObject *dict; object->objfile = objfile; object->printers = PyList_New (0); if (!object->printers) { Py_DECREF (object); return NULL; } set_objfile_data (objfile, objfpy_objfile_data_key, object); } } return (PyObject *) object; }
static void debug_qf_dump (struct objfile *objfile) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); fprintf_filtered (gdb_stdlog, "qf->dump (%s)\n", debug_objfile_name (objfile)); debug_data->real_sf->qf->dump (objfile); }
static void debug_qf_expand_all_symtabs (struct objfile *objfile) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); fprintf_filtered (gdb_stdlog, "qf->expand_all_symtabs (%s)\n", objfile_debug_name (objfile)); debug_data->real_sf->qf->expand_all_symtabs (objfile); }
static void debug_qf_forget_cached_source_info (struct objfile *objfile) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); fprintf_filtered (gdb_stdlog, "qf->forget_cached_source_info (%s)\n", objfile_debug_name (objfile)); debug_data->real_sf->qf->forget_cached_source_info (objfile); }
/* Appends OpenCL programs to the list of `struct so_list' objects. */ static void append_ocl_sos (struct so_list **link_ptr) { CORE_ADDR *ocl_program_addr_base; struct objfile *objfile; ALL_OBJFILES (objfile) { ocl_program_addr_base = (CORE_ADDR *) objfile_data (objfile, ocl_program_data_key); if (ocl_program_addr_base != NULL) { enum bfd_endian byte_order = bfd_big_endian (objfile->obfd)? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE; TRY { CORE_ADDR data = read_memory_unsigned_integer (*ocl_program_addr_base, sizeof (CORE_ADDR), byte_order); if (data != 0x0) { struct so_list *newobj; /* Allocate so_list structure. */ newobj = XCNEW (struct so_list); /* Encode FD and object ID in path name. */ xsnprintf (newobj->so_name, sizeof newobj->so_name, "@%s <%d>", hex_string (data), SPUADDR_SPU (*ocl_program_addr_base)); strcpy (newobj->so_original_name, newobj->so_name); *link_ptr = newobj; link_ptr = &newobj->next; } } CATCH (ex, RETURN_MASK_ALL) { /* Ignore memory errors. */ switch (ex.error) { case MEMORY_ERROR: break; default: throw_exception (ex); break; } } END_CATCH } } }
static void debug_qf_expand_symtabs_with_fullname (struct objfile *objfile, const char *fullname) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); fprintf_filtered (gdb_stdlog, "qf->expand_symtabs_with_fullname (%s, \"%s\")\n", objfile_debug_name (objfile), fullname); debug_data->real_sf->qf->expand_symtabs_with_fullname (objfile, fullname); }
static int debug_qf_has_symbols (struct objfile *objfile) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); int retval; retval = debug_data->real_sf->qf->has_symbols (objfile); fprintf_filtered (gdb_stdlog, "qf->has_symbols (%s) = %d\n", objfile_debug_name (objfile), retval); return retval; }
static htab_t stscm_objfile_symtab_map (struct symtab *symtab) { struct objfile *objfile = SYMTAB_OBJFILE (symtab); htab_t htab = objfile_data (objfile, stscm_objfile_data_key); if (htab == NULL) { htab = gdbscm_create_eqable_gsmob_ptr_map (stscm_hash_symtab_smob, stscm_eq_symtab_smob); set_objfile_data (objfile, stscm_objfile_data_key, htab); } return htab; }
/* Given a symtab, and a symtab_object that has previously been allocated and initialized, populate the symtab_object with the struct symtab data. Also, register the symtab_object life-cycle with the life-cycle of the object file associated with this symtab, if needed. */ static void set_symtab (symtab_object *obj, struct symtab *symtab) { obj->symtab = symtab; obj->prev = NULL; if (symtab) { obj->next = objfile_data (symtab->objfile, stpy_objfile_data_key); if (obj->next) obj->next->prev = obj; set_objfile_data (symtab->objfile, stpy_objfile_data_key, obj); } else obj->next = NULL; }
static void debug_qf_relocate (struct objfile *objfile, const struct section_offsets *new_offsets, const struct section_offsets *delta) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); fprintf_filtered (gdb_stdlog, "qf->relocate (%s, %s, %s)\n", objfile_debug_name (objfile), host_address_to_string (new_offsets), host_address_to_string (delta)); debug_data->real_sf->qf->relocate (objfile, new_offsets, delta); }
static htab_t syscm_objfile_symbol_map (struct symbol *symbol) { struct objfile *objfile = SYMBOL_SYMTAB (symbol)->objfile; htab_t htab = objfile_data (objfile, syscm_objfile_data_key); if (htab == NULL) { htab = gdbscm_create_eqable_gsmob_ptr_map (syscm_hash_symbol_smob, syscm_eq_symbol_smob); set_objfile_data (objfile, syscm_objfile_data_key, htab); } return htab; }
void gdbscm_add_objfile_ref (struct objfile *objfile, const struct objfile_data *data_key, chained_gdb_smob *g_smob) { g_smob->prev = NULL; if (objfile != NULL) { g_smob->next = objfile_data (objfile, data_key); if (g_smob->next) g_smob->next->prev = g_smob; set_objfile_data (objfile, data_key, g_smob); } else g_smob->next = NULL; }
static struct symtab * debug_qf_find_last_source_symtab (struct objfile *objfile) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); struct symtab *retval; fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (%s)\n", objfile_debug_name (objfile)); retval = debug_data->real_sf->qf->find_last_source_symtab (objfile); fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (...) = %s\n", retval ? debug_symtab_name (retval) : "NULL"); return retval; }
/* Given a block, and a block_object that has previously been allocated and initialized, populate the block_object with the struct block data. Also, register the block_object life-cycle with the life-cycle of the the object file associated with this block, if needed. */ static void set_block (block_object *obj, struct block *block, struct objfile *objfile) { obj->block = block; obj->prev = NULL; if (objfile) { obj->objfile = objfile; obj->next = objfile_data (objfile, blpy_objfile_data_key); if (obj->next) obj->next->prev = obj; set_objfile_data (objfile, blpy_objfile_data_key, obj); } else obj->next = NULL; }
/* Given a symtab, and a symtab_object that has previously been allocated and initialized, populate the symtab_object with the struct symtab data. Also, register the symtab_object life-cycle with the life-cycle of the object file associated with this symtab, if needed. */ static void set_symtab (symtab_object *obj, struct symtab *symtab) { obj->symtab = symtab; obj->prev = NULL; if (symtab) { obj->next = ((struct stpy_symtab_object *) objfile_data (SYMTAB_OBJFILE (symtab), stpy_objfile_data_key)); if (obj->next) obj->next->prev = obj; set_objfile_data (SYMTAB_OBJFILE (symtab), stpy_objfile_data_key, obj); } else obj->next = NULL; }
/* Given a symbol, and a symbol_object that has previously been allocated and initialized, populate the symbol_object with the struct symbol data. Also, register the symbol_object life-cycle with the life-cycle of the the object file associated with this symbol, if needed. */ static void set_symbol (symbol_object *obj, struct symbol *symbol) { obj->symbol = symbol; obj->prev = NULL; if (SYMBOL_SYMTAB (symbol)) { obj->next = objfile_data (SYMBOL_SYMTAB (symbol)->objfile, sympy_objfile_data_key); if (obj->next) obj->next->prev = obj; set_objfile_data (SYMBOL_SYMTAB (symbol)->objfile, sympy_objfile_data_key, obj); } else obj->next = NULL; }
/* Given a sal, and a sal_object that has previously been allocated and initialized, populate the sal_object with the struct sal data. Also, register the sal_object life-cycle with the life-cycle of the object file associated with this sal, if needed. If a failure occurs during the sal population, this function will return -1. */ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION set_sal (sal_object *sal_obj, struct symtab_and_line sal) { symtab_object *symtab_obj; if (sal.symtab) { symtab_obj = (symtab_object *) symtab_to_symtab_object (sal.symtab); /* If a symtab existed in the sal, but it cannot be duplicated, we exit. */ if (symtab_obj == NULL) return -1; } else { symtab_obj = (symtab_object *) Py_None; Py_INCREF (Py_None); } sal_obj->sal = ((struct symtab_and_line *) xmemdup (&sal, sizeof (struct symtab_and_line), sizeof (struct symtab_and_line))); sal_obj->symtab = symtab_obj; sal_obj->prev = NULL; /* If the SAL does not have a symtab, we do not add it to the objfile cleanup observer linked list. */ if (sal_obj->symtab != (symtab_object *)Py_None) { sal_obj->next = ((struct salpy_sal_object *) objfile_data (SYMTAB_OBJFILE (sal_obj->symtab->symtab), salpy_objfile_data_key)); if (sal_obj->next) sal_obj->next->prev = sal_obj; set_objfile_data (SYMTAB_OBJFILE (sal_obj->symtab->symtab), salpy_objfile_data_key, sal_obj); } else sal_obj->next = NULL; return 0; }
/* Given a sal, and a sal_object that has previously been allocated and initialized, populate the sal_object with the struct sal data. Also, register the sal_object life-cycle with the life-cycle of the object file associated with this sal, if needed. If a failure occurs during the sal population, this function will return NULL. */ static int set_sal (sal_object *sal_obj, struct symtab_and_line sal) { symtab_object *symtab_obj; if (sal.symtab) { symtab_obj = (symtab_object *) symtab_to_symtab_object (sal.symtab); /* If a symtab existed in the sal, but it cannot be duplicated, we exit. */ if (symtab_obj == NULL) return 0; } else { symtab_obj = (symtab_object *) Py_None; Py_INCREF (Py_None); } sal_obj->sal = xmemdup (&sal, sizeof (struct symtab_and_line), sizeof (struct symtab_and_line)); sal_obj->symtab = symtab_obj; sal_obj->prev = NULL; /* If the SAL does not have a symtab, we do not add it to the objfile cleanup observer linked list. */ if (sal_obj->symtab != (symtab_object *)Py_None) { sal_obj->next = objfile_data (sal_obj->symtab->symtab->objfile, salpy_objfile_data_key); if (sal_obj->next) sal_obj->next->prev = sal_obj; set_objfile_data (sal_obj->symtab->symtab->objfile, salpy_objfile_data_key, sal_obj); } else sal_obj->next = NULL; return 1; }
static struct symtab * debug_qf_lookup_symbol (struct objfile *objfile, int kind, const char *name, domain_enum domain) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); struct symtab *retval; fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (%s, %d, \"%s\", %s)\n", debug_objfile_name (objfile), kind, name, domain_name (domain)); retval = debug_data->real_sf->qf->lookup_symbol (objfile, kind, name, domain); fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n", retval ? debug_symtab_name (retval) : "NULL"); return retval; }
static struct symtab * get_java_class_symtab (struct gdbarch *gdbarch) { struct objfile *objfile = get_dynamics_objfile (gdbarch); struct symtab *class_symtab = objfile->symtabs; if (class_symtab == NULL) { struct blockvector *bv; struct block *bl; struct jv_per_objfile_data *jv_data; class_symtab = allocate_symtab ("<java-classes>", objfile); class_symtab->language = language_java; bv = (struct blockvector *) obstack_alloc (&objfile->objfile_obstack, sizeof (struct blockvector) + sizeof (struct block *)); BLOCKVECTOR_NBLOCKS (bv) = 1; BLOCKVECTOR (class_symtab) = bv; /* Allocate dummy STATIC_BLOCK. */ bl = allocate_block (&objfile->objfile_obstack); BLOCK_DICT (bl) = dict_create_linear (&objfile->objfile_obstack, NULL); BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl; /* Allocate GLOBAL_BLOCK. */ bl = allocate_global_block (&objfile->objfile_obstack); BLOCK_DICT (bl) = dict_create_hashed_expandable (); set_block_symtab (bl, class_symtab); BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl; /* Arrange to free the dict. */ jv_data = objfile_data (objfile, jv_dynamics_objfile_data_key); jv_data->dict = BLOCK_DICT (bl); } return class_symtab; }
static struct mdebug_extra_func_info * non_heuristic_proc_desc (CORE_ADDR pc, CORE_ADDR *addrptr) { CORE_ADDR startaddr; struct mdebug_extra_func_info *proc_desc; struct block *b = block_for_pc (pc); struct symbol *sym; struct obj_section *sec; struct mips_objfile_private *priv; find_pc_partial_function (pc, NULL, &startaddr, NULL); if (addrptr) *addrptr = startaddr; priv = NULL; sec = find_pc_section (pc); if (sec != NULL) { priv = (struct mips_objfile_private *) objfile_data (sec->objfile, mips_pdr_data); /* Search the ".pdr" section generated by GAS. This includes most of the information normally found in ECOFF PDRs. */ the_bfd = sec->objfile->obfd; if (priv == NULL && (the_bfd->format == bfd_object && bfd_get_flavour (the_bfd) == bfd_target_elf_flavour && elf_elfheader (the_bfd)->e_ident[EI_CLASS] == ELFCLASS64)) { /* Right now GAS only outputs the address as a four-byte sequence. This means that we should not bother with this method on 64-bit targets (until that is fixed). */ priv = obstack_alloc (&sec->objfile->objfile_obstack, sizeof (struct mips_objfile_private)); priv->size = 0; set_objfile_data (sec->objfile, mips_pdr_data, priv); } else if (priv == NULL) { asection *bfdsec; priv = obstack_alloc (&sec->objfile->objfile_obstack, sizeof (struct mips_objfile_private)); bfdsec = bfd_get_section_by_name (sec->objfile->obfd, ".pdr"); if (bfdsec != NULL) { priv->size = bfd_section_size (sec->objfile->obfd, bfdsec); priv->contents = obstack_alloc (&sec->objfile->objfile_obstack, priv->size); bfd_get_section_contents (sec->objfile->obfd, bfdsec, priv->contents, 0, priv->size); /* In general, the .pdr section is sorted. However, in the presence of multiple code sections (and other corner cases) it can become unsorted. Sort it so that we can use a faster binary search. */ qsort (priv->contents, priv->size / 32, 32, compare_pdr_entries); } else priv->size = 0; set_objfile_data (sec->objfile, mips_pdr_data, priv); } the_bfd = NULL; if (priv->size != 0) { int low, mid, high; char *ptr; CORE_ADDR pdr_pc; low = 0; high = priv->size / 32; /* We've found a .pdr section describing this objfile. We want to find the entry which describes this code address. The .pdr information is not very descriptive; we have only a function start address. We have to look for the closest entry, because the local symbol at the beginning of this function may have been stripped - so if we ask the symbol table for the start address we may get a preceding global function. */ /* First, find the last .pdr entry starting at or before PC. */ do { mid = (low + high) / 2; ptr = priv->contents + mid * 32; pdr_pc = bfd_get_signed_32 (sec->objfile->obfd, ptr); pdr_pc += ANOFFSET (sec->objfile->section_offsets, SECT_OFF_TEXT (sec->objfile)); if (pdr_pc > pc) high = mid; else low = mid + 1; } while (low != high); /* Both low and high point one past the PDR of interest. If both are zero, that means this PC is before any region covered by a PDR, i.e. pdr_pc for the first PDR entry is greater than PC. */ if (low > 0) { ptr = priv->contents + (low - 1) * 32; pdr_pc = bfd_get_signed_32 (sec->objfile->obfd, ptr); pdr_pc += ANOFFSET (sec->objfile->section_offsets, SECT_OFF_TEXT (sec->objfile)); } /* We don't have a range, so we have no way to know for sure whether we're in the correct PDR or a PDR for a preceding function and the current function was a stripped local symbol. But if the PDR's PC is at least as great as the best guess from the symbol table, assume that it does cover the right area; if a .pdr section is present at all then nearly every function will have an entry. The biggest exception will be the dynamic linker stubs; conveniently these are placed before .text instead of after. */ if (pc >= pdr_pc && pdr_pc >= startaddr) { struct symbol *sym = find_pc_function (pc); if (addrptr) *addrptr = pdr_pc; /* Fill in what we need of the proc_desc. */ proc_desc = (struct mdebug_extra_func_info *) obstack_alloc (&sec->objfile->objfile_obstack, sizeof (struct mdebug_extra_func_info)); PROC_LOW_ADDR (proc_desc) = pdr_pc; PROC_FRAME_OFFSET (proc_desc) = bfd_get_signed_32 (sec->objfile->obfd, ptr + 20); PROC_FRAME_REG (proc_desc) = bfd_get_32 (sec->objfile->obfd, ptr + 24); PROC_REG_MASK (proc_desc) = bfd_get_32 (sec->objfile->obfd, ptr + 4); PROC_FREG_MASK (proc_desc) = bfd_get_32 (sec->objfile->obfd, ptr + 12); PROC_REG_OFFSET (proc_desc) = bfd_get_signed_32 (sec->objfile->obfd, ptr + 8); PROC_FREG_OFFSET (proc_desc) = bfd_get_signed_32 (sec->objfile->obfd, ptr + 16); PROC_PC_REG (proc_desc) = bfd_get_32 (sec->objfile->obfd, ptr + 28); proc_desc->pdr.isym = (long) sym; return proc_desc; } } } if (b == NULL) return NULL; if (startaddr > BLOCK_START (b)) { /* This is the "pathological" case referred to in a comment in print_frame_info. It might be better to move this check into symbol reading. */ return NULL; } sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN, 0); /* If we never found a PDR for this function in symbol reading, then examine prologues to find the information. */ if (sym) { proc_desc = (struct mdebug_extra_func_info *) SYMBOL_VALUE (sym); if (PROC_FRAME_REG (proc_desc) == -1) return NULL; else return proc_desc; } else return NULL; }
debug_data->real_sf->qf->expand_symtabs_with_fullname (objfile, fullname); } static void debug_qf_map_matching_symbols (struct objfile *objfile, const char *name, domain_enum namespace, int global, int (*callback) (struct block *, struct symbol *, void *), void *data, symbol_compare_ftype *match, symbol_compare_ftype *ordered_compare) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); fprintf_filtered (gdb_stdlog, "qf->map_matching_symbols (%s, \"%s\", %s, %d, %s, %s, %s, %s)\n", objfile_debug_name (objfile), name, domain_name (namespace), global, host_address_to_string (callback), host_address_to_string (data), host_address_to_string (match), host_address_to_string (ordered_compare)); debug_data->real_sf->qf->map_matching_symbols (objfile, name, namespace, global, callback, data, match, ordered_compare);
static int symfile_debug_installed (struct objfile *objfile) { return (objfile->sf != NULL && objfile_data (objfile, symfile_debug_objfile_data_key) != NULL); }