Re: [NEWS/RFA] Re: [gdbserver] x86 agent expression bytecode compiler (speed up conditional tracepoints)

Michael Snyder
2010-06-17T18:03:24Z

Stan Shebs wrote:
> Pedro Alves wrote:
>> On Wednesday 16 June 2010 20:12:44, Stan Shebs wrote:
>>
>>> Doug Evans wrote:
>>>
>>>> On Mon, Jun 14, 2010 at 3:19 PM, Pedro Alves <pedro@codesourcery.com> wrote:
>>>>
>>>>
>>>>> Thanks. I've checked the whole thing in.
>>>>>
>>>>>
>>>> I'm getting build failures that go away when compiling linux-x86-low.c with -g.
>>>>
>>>> gcc is optimizing out the skipped over stuff I believe.
>>>>
>>>>
>>> Hmm, this particular trickery was my idea, but it always seemed
>>> vulnerable to ever-smarter optimization. Does anybody have any better
>>> strategy? Declaring the asm volatile didn't work, because the compiler
>>> was whacking everything around it.
>>>
>>> The other approach is to build up instructions from bitfields, which is
>>> reliable but needs a lot of setup and helper routines.
>>>
>> Quick thought: can we stick a couple of __attribute__((used))'s in the
>> macro, so the compiler doesn optimized things away, thinking they're
>> unused (given the uses are behind asm)?
>>
>
> The compiler is discarding the code with the definitions of the labels,
> because it's thinking they are maybe somewhere else in the program (the
> error is at link time). Moving the labels into C code would fix that I
> think, but then it's hard to guarantee that the compiler won't sneak in
> a bit of code between label and asm sequence.

Hurrr. Code that depends on such deep knowledge of the compiler's
behavior is wrong code, IMO.