static void
create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
const gdb_byte *iter, *end;
struct obstack temp_obstack;
struct addrmap *mutable_map;
continue;
}
- addrmap_set_empty (mutable_map, lo + baseaddr, hi + baseaddr - 1,
- dw2_get_cutu (cu_index));
+ lo = gdbarch_adjust_dwarf2_addr (gdbarch, lo + baseaddr);
+ hi = gdbarch_adjust_dwarf2_addr (gdbarch, hi + baseaddr);
+ addrmap_set_empty (mutable_map, lo, hi - 1, dw2_get_cutu (cu_index));
}
objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
{
struct dwarf2_cu *cu = reader->cu;
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct dwarf2_per_cu_data *per_cu = cu->per_cu;
struct attribute *attr;
CORE_ADDR baseaddr;
/* Store the contiguous range if it is not empty; it can be empty for
CUs with no code. */
addrmap_set_empty (objfile->psymtabs_addrmap,
- best_lowpc + baseaddr,
- best_highpc + baseaddr - 1, pst);
+ gdbarch_adjust_dwarf2_addr (gdbarch,
+ best_lowpc + baseaddr),
+ gdbarch_adjust_dwarf2_addr (gdbarch,
+ best_highpc + baseaddr) - 1,
+ pst);
/* Check if comp unit has_children.
If so, read the rest of the partial symbols from this comp unit.
best_highpc = highpc;
}
}
- pst->textlow = best_lowpc + baseaddr;
- pst->texthigh = best_highpc + baseaddr;
+ pst->textlow = gdbarch_adjust_dwarf2_addr (gdbarch, best_lowpc + baseaddr);
+ pst->texthigh = gdbarch_adjust_dwarf2_addr (gdbarch, best_highpc + baseaddr);
pst->n_global_syms = objfile->global_psymbols.next -
(objfile->global_psymbols.list + pst->globals_offset);
add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
CORE_ADDR addr = 0;
const char *actual_name = NULL;
CORE_ADDR baseaddr;
switch (pdi->tag)
{
case DW_TAG_subprogram:
+ addr = gdbarch_adjust_dwarf2_addr (gdbarch, pdi->lowpc + baseaddr);
if (pdi->is_external || cu->language == language_ada)
{
/* brobecker/2007-12-26: Normally, only "external" DIEs are part
of the global scope. But in Ada, we want to be able to access
nested procedures globally. So all Ada subprograms are stored
in the global scope. */
- /* prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
- mst_text, objfile); */
+ /* prim_record_minimal_symbol (actual_name, addr, mst_text,
+ objfile); */
add_psymbol_to_list (actual_name, strlen (actual_name),
built_actual_name != NULL,
VAR_DOMAIN, LOC_BLOCK,
&objfile->global_psymbols,
- 0, pdi->lowpc + baseaddr,
- cu->language, objfile);
+ 0, addr, cu->language, objfile);
}
else
{
- /* prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
- mst_file_text, objfile); */
+ /* prim_record_minimal_symbol (actual_name, addr, mst_file_text,
+ objfile); */
add_psymbol_to_list (actual_name, strlen (actual_name),
built_actual_name != NULL,
VAR_DOMAIN, LOC_BLOCK,
&objfile->static_psymbols,
- 0, pdi->lowpc + baseaddr,
- cu->language, objfile);
+ 0, addr, cu->language, objfile);
}
break;
case DW_TAG_constant:
*highpc = pdi->highpc;
if (set_addrmap)
{
- CORE_ADDR baseaddr;
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ CORE_ADDR baseaddr;
+ CORE_ADDR highpc;
+ CORE_ADDR lowpc;
baseaddr = ANOFFSET (objfile->section_offsets,
SECT_OFF_TEXT (objfile));
- addrmap_set_empty (objfile->psymtabs_addrmap,
- pdi->lowpc + baseaddr,
- pdi->highpc - 1 + baseaddr,
+ lowpc = gdbarch_adjust_dwarf2_addr (gdbarch,
+ pdi->lowpc + baseaddr);
+ highpc = gdbarch_adjust_dwarf2_addr (gdbarch,
+ pdi->highpc + baseaddr);
+ addrmap_set_empty (objfile->psymtabs_addrmap, lowpc, highpc - 1,
cu->per_cu->v.psymtab);
}
}
{
struct dwarf2_cu *cu = per_cu->cu;
struct objfile *objfile = per_cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
CORE_ADDR lowpc, highpc;
struct compunit_symtab *cust;
struct cleanup *back_to, *delayed_list_cleanup;
CORE_ADDR baseaddr;
struct block *static_block;
+ CORE_ADDR addr;
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
it, by scanning the DIE's below the compilation unit. */
get_scope_pc_bounds (cu->dies, &lowpc, &highpc, cu);
- static_block
- = end_symtab_get_static_block (highpc + baseaddr, 0, 1);
+ addr = gdbarch_adjust_dwarf2_addr (gdbarch, highpc + baseaddr);
+ static_block = end_symtab_get_static_block (addr, 0, 1);
/* If the comp unit has DW_AT_ranges, it may have discontiguous ranges.
Also, DW_AT_ranges may record ranges not belonging to any child DIEs
read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct cleanup *back_to = make_cleanup (null_cleanup, 0);
CORE_ADDR lowpc = ((CORE_ADDR) -1);
CORE_ADDR highpc = ((CORE_ADDR) 0);
from finish_block. */
if (lowpc == ((CORE_ADDR) -1))
lowpc = highpc;
- lowpc += baseaddr;
- highpc += baseaddr;
+ lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr);
find_file_and_directory (die, cu, &name, &comp_dir);
read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct context_stack *new;
CORE_ADDR lowpc;
CORE_ADDR highpc;
return;
}
- lowpc += baseaddr;
- highpc += baseaddr;
+ lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr);
+ highpc = gdbarch_adjust_dwarf2_addr (gdbarch, highpc + baseaddr);
/* If we have any template arguments, then we must allocate a
different sort of symbol. */
/* If we have address ranges, record them. */
dwarf2_record_block_ranges (die, block, baseaddr, cu);
+ gdbarch_make_symbol_special (gdbarch, new->name, objfile);
+
/* Attach template arguments to function. */
if (! VEC_empty (symbolp, template_args))
{
read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct context_stack *new;
CORE_ADDR lowpc, highpc;
struct die_info *child_die;
describe ranges. */
if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL))
return;
- lowpc += baseaddr;
- highpc += baseaddr;
+ lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr);
+ highpc = gdbarch_adjust_dwarf2_addr (gdbarch, highpc + baseaddr);
push_context (0, lowpc);
if (die->child != NULL)
return;
}
pc = attr_value_as_address (attr) + baseaddr;
+ pc = gdbarch_adjust_dwarf2_addr (gdbarch, pc);
if (cu->call_site_htab == NULL)
cu->call_site_htab = htab_create_alloc_ex (16, core_addr_hash, core_addr_eq,
"low pc, for referencing DIE 0x%x [in module %s]"),
die->offset.sect_off, objfile_name (objfile));
else
- SET_FIELD_PHYSADDR (call_site->target, lowpc + baseaddr);
+ {
+ lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr);
+ SET_FIELD_PHYSADDR (call_site->target, lowpc);
+ }
}
}
else
struct partial_symtab *ranges_pst)
{
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct comp_unit_head *cu_header = &cu->header;
bfd *obfd = objfile->obfd;
unsigned int addr_size = cu_header->addr_size;
}
if (ranges_pst != NULL)
- addrmap_set_empty (objfile->psymtabs_addrmap,
- range_beginning + baseaddr,
- range_end - 1 + baseaddr,
- ranges_pst);
+ {
+ CORE_ADDR lowpc;
+ CORE_ADDR highpc;
+
+ lowpc = gdbarch_adjust_dwarf2_addr (gdbarch,
+ range_beginning + baseaddr);
+ highpc = gdbarch_adjust_dwarf2_addr (gdbarch,
+ range_end + baseaddr);
+ addrmap_set_empty (objfile->psymtabs_addrmap, lowpc, highpc - 1,
+ ranges_pst);
+ }
/* FIXME: This is recording everything as a low-high
segment of consecutive addresses. We should have a
CORE_ADDR baseaddr, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct attribute *attr;
struct attribute *attr_high;
if (cu->header.version >= 4 && attr_form_is_constant (attr_high))
high += low;
- record_block_range (block, baseaddr + low, baseaddr + high - 1);
+ low = gdbarch_adjust_dwarf2_addr (gdbarch, low + baseaddr);
+ high = gdbarch_adjust_dwarf2_addr (gdbarch, high + baseaddr);
+ record_block_range (block, low, high - 1);
}
}
continue;
}
+ start = gdbarch_adjust_dwarf2_addr (gdbarch, start);
+ end = gdbarch_adjust_dwarf2_addr (gdbarch, end);
record_block_range (block, start, end - 1);
}
}
const gdb_byte *info_ptr)
{
struct dwarf2_cu *cu = reader->cu;
+ struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
bfd *abfd = reader->abfd;
struct comp_unit_head *cu_header = &cu->header;
unsigned int bytes_read;
break;
case DW_FORM_addr:
DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
+ DW_ADDR (attr) = gdbarch_adjust_dwarf2_addr (gdbarch, DW_ADDR (attr));
info_ptr += bytes_read;
break;
case DW_FORM_block2:
/* Read the statement sequences until there's nothing left. */
while (line_ptr < line_end)
{
- /* state machine registers */
- CORE_ADDR address = 0;
+ /* State machine registers. Call `gdbarch_adjust_dwarf2_line'
+ on the initial 0 address as if there was a line entry for it
+ so that the backend has a chance to adjust it and also record
+ it in case it needs it. This is currently used by MIPS code,
+ cf. `mips_adjust_dwarf2_line'. */
+ CORE_ADDR address = gdbarch_adjust_dwarf2_line (gdbarch, 0, 0);
unsigned int file = 1;
unsigned int line = 1;
int is_stmt = lh->default_is_stmt;
{
/* Special opcode. */
unsigned char adj_opcode;
+ CORE_ADDR addr_adj;
int line_delta;
adj_opcode = op_code - lh->opcode_base;
- address += (((op_index + (adj_opcode / lh->line_range))
+ addr_adj = (((op_index + (adj_opcode / lh->line_range))
/ lh->maximum_ops_per_instruction)
* lh->minimum_instruction_length);
+ address += gdbarch_adjust_dwarf2_line (gdbarch, addr_adj, 1);
op_index = ((op_index + (adj_opcode / lh->line_range))
% lh->maximum_ops_per_instruction);
line_delta = lh->line_base + (adj_opcode % lh->line_range);
op_index = 0;
line_ptr += bytes_read;
address += baseaddr;
+ address = gdbarch_adjust_dwarf2_line (gdbarch, address, 0);
break;
case DW_LNE_define_file:
{
{
CORE_ADDR adjust
= read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ CORE_ADDR addr_adj;
- address += (((op_index + adjust)
+ addr_adj = (((op_index + adjust)
/ lh->maximum_ops_per_instruction)
* lh->minimum_instruction_length);
+ address += gdbarch_adjust_dwarf2_line (gdbarch, addr_adj, 1);
op_index = ((op_index + adjust)
% lh->maximum_ops_per_instruction);
line_ptr += bytes_read;
case DW_LNS_const_add_pc:
{
CORE_ADDR adjust = (255 - lh->opcode_base) / lh->line_range;
+ CORE_ADDR addr_adj;
- address += (((op_index + adjust)
+ addr_adj = (((op_index + adjust)
/ lh->maximum_ops_per_instruction)
* lh->minimum_instruction_length);
+ address += gdbarch_adjust_dwarf2_line (gdbarch, addr_adj, 1);
op_index = ((op_index + adjust)
% lh->maximum_ops_per_instruction);
}
break;
case DW_LNS_fixed_advance_pc:
- address += read_2_bytes (abfd, line_ptr);
- op_index = 0;
- line_ptr += 2;
+ {
+ CORE_ADDR addr_adj;
+
+ addr_adj = read_2_bytes (abfd, line_ptr);
+ address += gdbarch_adjust_dwarf2_line (gdbarch, addr_adj, 1);
+ op_index = 0;
+ line_ptr += 2;
+ }
break;
default:
{
struct symbol *space)
{
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct symbol *sym = NULL;
const char *name;
struct attribute *attr = NULL;
case DW_TAG_label:
attr = dwarf2_attr (die, DW_AT_low_pc, cu);
if (attr)
- SYMBOL_VALUE_ADDRESS (sym)
- = attr_value_as_address (attr) + baseaddr;
+ {
+ CORE_ADDR addr;
+
+ addr = attr_value_as_address (attr);
+ addr = gdbarch_adjust_dwarf2_addr (gdbarch, addr + baseaddr);
+ SYMBOL_VALUE_ADDRESS (sym) = addr;
+ }
SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_core_addr;
SYMBOL_DOMAIN (sym) = LABEL_DOMAIN;
SYMBOL_ACLASS_INDEX (sym) = LOC_LABEL;