Re: [PATCH v2 3/4] gdbserver: Add powerpc fast tracepoint support.

Marcin Kościelnicki
2016-03-31T01:31:40Z

On 30/03/16 17:35, Ulrich Weigand wrote:
> Simon Marchi wrote:
>
>> Ahh, it seems like the ordering is important here. If I include it before
>> <elf.h> (and everything that includes <elf.h>), it works.
>
> Hmm, it would probably be best to avoid mixing in-tree BFD headers and
> system headers this way. I'd suggest to *not* include <elf.h> at all,
> but instead use:
>
> #include "elf/common.h"
> #include "elf/ppc64.h"
>
> Bye,
> Ulrich
>

That doesn't work either:

../../../gdb/gdbserver/linux-ppc-low.c: In function Â‘is_elfv2_inferiorÂ’:
../../../gdb/gdbserver/linux-ppc-low.c:763:3: error: unknown type name
Â‘Elf64_EhdrÂ’
Elf64_Ehdr ehdr;
^
../../../gdb/gdbserver/linux-ppc-low.c:772:18: error: request for member
Â‘e_identÂ’ in something not a structure or union
if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG))
^
../../../gdb/gdbserver/linux-ppc-low.c:772:28: error: Â‘ELFMAGÂ’
undeclared (first use in this function)
if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG))
^
../../../gdb/gdbserver/linux-ppc-low.c:772:28: note: each undeclared
identifier is reported only once for each function it appears in
../../../gdb/gdbserver/linux-ppc-low.c:772:36: error: Â‘SELFMAGÂ’
undeclared (first use in this function)
if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG))
^
../../../gdb/gdbserver/linux-ppc-low.c:775:15: error: request for member
Â‘e_flagsÂ’ in something not a structure or union
return (ehdr.e_flags & EF_PPC64_ABI) == 2;
^
../../../gdb/gdbserver/linux-ppc-low.c:776:1: error: control reaches end
of non-void function [-Werror=return-type]
}
^

There's no equivalent to ELFMAG in the BFD headers, and getting to
e_flags requires more work too (you need elf/external.h and manually
assemble the word from bytes). Perhaps it'd be simpler to just define
EF_PPC64_ABI manually if it's not defined?