Re: Improving GDB's mechanism to check if function is GC'ed

Pedro Alves
2015-06-11T08:54:46Z

On 06/11/2015 09:30 AM, Yao Qi wrote:
>> >
>> > IIUC, this triggers on use of add-symbol-file with relocatable
>> > objects, when there's real code at address 0. I think that's the angle
>> > we should look at things.
>> >
> Yes, that is the problem. GDB thinks the function is GC'ed by linker
> but in fact it isn't.

The key point here is _relocatable_ objects. These are special in
that they aren't fully linked, so they have relocations in the debug info,
and their sections on file start at address zero. See default_symfile_offsets.

I still don't understand how lowpc doesn't end up as 0 in the case
at hand, meaning there's really code at 0.

Or does lowpc really end up as 0, but the real issue is that "lowpc==0"
is ambiguous, and we need to track a separate "have pc range" flag?

Taimoor, I'd expect you're passing a "0" to add-symbol-file, like:

(gdb) add-symbol-file ... -s .some_section 0 ...

I think it'd help to see an example invocation of the command.

I'd think it possible to expand gdb.base/relocate.exp (or create
a new test based on it) to cover this scenario everywhere.

Thanks,
Pedro Alves