How to avoid code elimination

phi gcc phi.gcc@gmail.com
Sun Nov 26 11:08:00 GMT 2017


Hi All,

I am new to gcc (used other C compilers before).

I have construct of the like in my C code

.
.
.
if(cond)
{ e=e;
}
.
.

The reasoning here is that I need to stuff a GDB break point on e=e;
cond goes from false to true after some long to wait condition occurs.

Basically my debug session goes like this

set a temp break in this function reach it, then stick a BP on e=e,
then run and wait the BP.

The e=e; comes form the idea that I reuse here whatever int scalar is
in the vincinity.

I tried to compile with -O0 but to no joy gcc always remove my 'NOP'
intruction knowing better than me what I could do with it.

Is there any other idioms I should use, may be an asm("nop") or the
like I guess ?

Thanx in advance
Cheers,
Phi



More information about the Gcc-help mailing list