Re: [RFA 1/2] Make line tables independent of progspace

Simon Marchi
2018-03-29T15:04:19Z

On 2018-03-28 03:27 PM, Maciej W. Rozycki wrote:
> It's not clear to me offhand what the impact on processing that involves
> `addr_bits_remove' the change proposed will have. So what specifically
> would you like me to comment on here?

Err sorry I wasn't very clear. Currently, for addresses coming from the line
table, gdbarch_addr_bits_remove is called on the relocated address in
dwarf_record_line_1, before that address is put in the line table data structure.

In Tom's patch, since we store unrelocated addresses in the line table, relocation
happens "just in time" when reading the address from the table.
gdbarch_addr_bits_remove is called at this time:

CORE_ADDR
linetable_entry::address (struct symtab *symtab) const
{
return gdbarch_addr_bits_remove
(get_objfile_arch (SYMTAB_OBJFILE (symtab)),
m_pc + ANOFFSET (SYMTAB_OBJFILE (symtab)->section_offsets,
SYMTAB_COMPUNIT (symtab)->block_line_section));
}

I just wanted to confirm it was still fine with mips' implementation of
addr_bits_remove. But now I realize that other arches implement this callback too,
not only mips. I think I originally meant to ask about gdbarch_adjust_dwarf2_line,
which is only implemented by mips.

Since adjust_dwarf2_line used to be passed the relocated address, Tom included a
"hack" where he relocates the address, passes it through gdbarch_adjust_dwarf2_line,
and unrelocates it:

/* Handle DW_LNE_set_address. */
void handle_set_address (CORE_ADDR baseaddr, CORE_ADDR address)
{
m_op_index = 0;
/* Pass the relocated address to the gdbarch for modification, but
then only store the relative address. */
address += baseaddr;
m_address = (gdbarch_adjust_dwarf2_line (m_gdbarch, address, false)
- baseaddr);
}

I think right now this is necessary, because mips_adjust_dwarf2_line does a
minimal symbol lookup, which are relocated. So if we passed an unrelocated
address, I guess it wouldn't find the symbol.

I just wanted to make sure there wasn't anything you saw that is obviously
wrong with this approach. I think that eventually we'll be able to pass an
unrelocated address to adjust_dwarf2_line, but in the mean time we probably
need this hack.

Simon