RE: [RFA-new version][gdbserver] x86 agent expression bytecode compiler (speed up conditional tracepoints)

Pierre Muller
2010-06-20T20:36:51Z

This patch fixes compilation on gcc16.

May I commit this?

Pierre

gdbserver/ChangeLog entry:

2010-06-20 Ian Lance Taylor <iant@google.com>
Pierre Muller <muller@ics.u-strasbg.fr>

* linux-x86-low.c (always_true): Delete function.
(EMIT_ASM, EMIT_ASM32): Use `do ... while (0)' to avoid
code been optimzed out.

Index: src/gdb/gdbserver/linux-x86-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-x86-low.c,v
retrieving revision 1.19
diff -u -p -r1.19 linux-x86-low.c
--- src/gdb/gdbserver/linux-x86-low.c 15 Jun 2010 10:44:48 -0000
1.19
+++ src/gdb/gdbserver/linux-x86-low.c 20 Jun 2010 06:25:07 -0000
@@ -1484,14 +1484,6 @@ add_insns (unsigned char *start, int len
current_insn_ptr = buildaddr;
}

-/* A function used to trick optimizers. */
-
-int
-always_true (void)
-{
- return 1;
-}
-
/* Our general strategy for emitting code is to avoid specifying raw
bytes whenever possible, and instead copy a block of inline asm
that is embedded in the function. This is a little messy, because
@@ -1499,26 +1491,20 @@ always_true (void)
code, plus suppress various warnings. */

#define EMIT_ASM(NAME,INSNS) \
- { extern unsigned char start_ ## NAME, end_ ## NAME; \
+ do { extern unsigned char start_ ## NAME, end_ ## NAME; \
add_insns (&start_ ## NAME, &end_ ## NAME - &start_ ## NAME); \
- if (always_true ()) \
- goto skipover ## NAME; \
__asm__ ("start_" #NAME ":\n\t" INSNS "\n\tend_" #NAME ":\n\t"); \
- skipover ## NAME: \
- ; }
+ ; } while (0)

#ifdef __x86_64__

#define EMIT_ASM32(NAME,INSNS) \
- { extern unsigned char start_ ## NAME, end_ ## NAME; \
+ do { extern unsigned char start_ ## NAME, end_ ## NAME; \
add_insns (&start_ ## NAME, &end_ ## NAME - &start_ ## NAME); \
- if (always_true ()) \
- goto skipover ## NAME; \
__asm__ (".code32\n\tstart_" #NAME ":\n\t" INSNS "\n\tend_" #NAME ":\n"
\
"\t.code64\n\t"); \
- skipover ## NAME: \
- ; }
+ ; } while (0)

#else