diff options
author | Pedro Alves <palves@redhat.com> | 2010-06-20 22:23:36 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2010-06-20 22:23:36 +0000 |
commit | 9e4344e5eae3650abd27c0a7b384604c4b32c37b (patch) | |
tree | 108173b5eff8f3ae736b4b446f4e66aa99055f67 | |
parent | c6beb2cba632df8ac2cd5fa9392c5c91333fe091 (diff) | |
download | gdb-9e4344e5eae3650abd27c0a7b384604c4b32c37b.zip gdb-9e4344e5eae3650abd27c0a7b384604c4b32c37b.tar.gz gdb-9e4344e5eae3650abd27c0a7b384604c4b32c37b.tar.bz2 |
2010-06-20 Ian Lance Taylor <iant@google.com>
Pedro Alves <pedro@codesourcery.com>
* linux-x86-low.c (always_true): Delete.
(EMIT_ASM, EMIT_ASM32): Use an uncondition asm jmp instead of
trying to fool the compiler with always_true.
-rw-r--r-- | gdb/gdbserver/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/gdbserver/linux-x86-low.c | 46 |
2 files changed, 28 insertions, 25 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index f25e409..99aacba 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,10 @@ +2010-06-20 Ian Lance Taylor <iant@google.com> + Pedro Alves <pedro@codesourcery.com> + + * linux-x86-low.c (always_true): Delete. + (EMIT_ASM, EMIT_ASM32): Use an uncondition asm jmp instead of + trying to fool the compiler with always_true. + 2010-06-20 Pedro Alves <pedro@codesourcery.com> * tracepoint.c (condition_true_at_tracepoint): Don't run compiled diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index 772aaa3..1e0d684 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -1484,41 +1484,37 @@ 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 we need to keep the compiler from discarding what looks like dead code, plus suppress various warnings. */ -#define EMIT_ASM(NAME,INSNS) \ - { 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: \ - ; } - +#define EMIT_ASM(NAME, INSNS) \ + do \ + { \ + extern unsigned char start_ ## NAME, end_ ## NAME; \ + add_insns (&start_ ## NAME, &end_ ## NAME - &start_ ## NAME); \ + __asm__ ("jmp end_" #NAME "\n" \ + "\t" "start_" #NAME ":" \ + "\t" INSNS "\n" \ + "\t" "end_" #NAME ":"); \ + } while (0) #ifdef __x86_64__ #define EMIT_ASM32(NAME,INSNS) \ - { 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: \ - ; } + do \ + { \ + extern unsigned char start_ ## NAME, end_ ## NAME; \ + add_insns (&start_ ## NAME, &end_ ## NAME - &start_ ## NAME); \ + __asm__ (".code32\n" \ + "\t" "jmp end_" #NAME "\n" \ + "\t" "start_" #NAME ":\n" \ + "\t" INSNS "\n" \ + "\t" "end_" #NAME ":\n" \ + ".code64\n"); \ + } while (0) #else |