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

Simon Marchi
2018-03-24T03:40:31Z

Hi Tom,

I haven't looked at in details, but I just have one comment for now:

On 2018-03-21 01:18 PM, Tom Tromey wrote:
> diff --git a/gdb/symtab.h b/gdb/symtab.h
> index f9d52e7697..2b3d8018a7 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -1228,9 +1228,23 @@ struct rust_vtable_symbol : public symbol
> struct linetable_entry
> {
> int line;
> - CORE_ADDR pc;
> +
> + /* Note that the PC as stored is unrelocated. The appropriate
> + offset must be applied before it can be used. */
> + CORE_ADDR m_pc;
> };
>
> +#define SET_LINETABLE_ENTRY_ADDRESS(ENTRY, PC) \
> + ((ENTRY).m_pc = (PC))
> +#define LINETABLE_ENTRY_RAW_ADDRESS(ENTRY) \
> + ((ENTRY).m_pc + 0)
> +#define LINETABLE_ENTRY_ADDRESS(SYMTAB, ENTRY) \
> + gdbarch_addr_bits_remove \
> + (get_objfile_arch (SYMTAB_OBJFILE (SYMTAB)), \
> + ((ENTRY).m_pc \
> + + ANOFFSET (SYMTAB_OBJFILE (SYMTAB)->section_offsets, \
> + SYMTAB_COMPUNIT (SYMTAB)->block_line_section)))

Is it possible to make these functions instead of macros? They could even be
made into methods of struct linetable_entry without making the structure
non-pod. I think it would also make the code more readable:

LINETABLE_ENTRY_RAW_ADDRESS (e)
SET_LINETABLE_ENTRY_ADDRESS (e, pc);
LINETABLE_ENTRY_ADDRESS (s, e)

vs

e.raw_address ()
e.set_address (pc)
e.address (s)

I think it makes a good difference in terms of readability in those big ifs:

if (LINETABLE_ENTRY_ADDRESS (iter_s, *item) > pc
&& (!alt || (LINETABLE_ENTRY_ADDRESS (iter_s, *item)
< LINETABLE_ENTRY_ADDRESS (alt_symtab, *alt))))
Simon