Re: [PATCH 2/3] Check data is GC'ed

Yao Qi
2014-08-29T13:32:21Z

Doug Evans <dje@google.com> writes:

> > if (pdi->d.locdesc
> > && addr == 0
> > - && !dwarf2_per_objfile->has_section_at_zero)
> > + /* When the address is 0, if the object file doesn't have
> > + section at zero or the section at zero is executable,
> > + we think address 0 means the corresponding variable is
> > + removed by linker, instead of there is a data at address
> > + 0. */
> > + && (dwarf2_per_objfile->section_at_zero == NULL
> > + || dwarf2_per_objfile->section_at_zero->flags & SEC_CODE))
>
> Could there be a DW_TAG_variable in SEC_CODE?
> Someone might put one there for a particular reason.

I don't figure out a reason to do so, but it is possible via:

__attribute__((section(".text"))) int foo = 1;

I can't think of other heuristics, so if GDB has a section at address
zero, GDB can't tell address zero in debug information means the
corresponding variable is GC'ed by linker or the variable address is
zero.

How about open a PR about GDB is unable to know whether a variable is
GC'ed by linker if there is a section at address zero? and kfail
dw2-var-zero-addr.exp conditionally? Something like:

if [is_address_zero_readable] {
setup_kfail "gdb/PR" "*-*-*"
}
gdb_test "print &var" {No symbol "var" in current context\.}

What do you think?

--
Yao (齐尧)