From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: "'Doug Evans'" <dje@google.com>, "'Hui Zhu'" <teawater@gmail.com>
Cc: <gdb-patches@sourceware.org>,
"'Pedro Alves'" <pedro@codesourcery.com>,
"'Stan Shebs'" <stan@codesourcery.com>,
"'Eli Zaretskii'" <eliz@gnu.org>, <tromey@redhat.com>,
"'Michael Snyder'" <msnyder@vmware.com>
Subject: [RFA-new version][gdbserver] x86 agent expression bytecode compiler (speed up conditional tracepoints)
Date: Sun, 20 Jun 2010 09:30:00 -0000 [thread overview]
Message-ID: <003301cb105b$1abd19e0$50374da0$@muller@ics-cnrs.unistra.fr> (raw)
In-Reply-To: <AANLkTikfpnDiFzT5yxW3hu1sR0PfFKgd87qMeqTZZzlF@mail.gmail.com>
> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Doug Evans
> Envoyé : Saturday, June 19, 2010 7:26 PM
> À : Hui Zhu
> Cc : gdb-patches@sourceware.org; Pedro Alves; Stan Shebs; Eli
> Zaretskii; tromey@redhat.com; Michael Snyder
> Objet : Re: [NEWS/RFA] Re: [gdbserver] x86 agent expression bytecode
> compiler (speed up conditional tracepoints)
>
> The fix to the compilation problem (for now) should be as trivial as
> applying Ian's suggested change.
> gcc doesn't optimize *inside* the asm statement.
As I said in a previous email, Ian's patch didn't work for me.
http://sourceware.org/ml/gdb-patches/2010-06/msg00424.html
I propose here another small patch that fixes the linking failure.
Using a volatile variable, it explicitly forbids the compiler
to optimize out code by forbidding the assumption that this value will
never change.
This works on gcc16, an the approach seems reasonable.
Pierre Muller
gdbserver/ChangeLog entry:
2010-06-20 Pierre Muller <muller@ics.u-strasbg.fr>
* linux-x86-low.c (always_true): Delete function.
(always_true): New volatile variable.
(EMIT_ASM, EMIT_ASM32): Adapt to always_true change.
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,13 +1484,12 @@ add_insns (unsigned char *start, int len
current_insn_ptr = buildaddr;
}
-/* A function used to trick optimizers. */
+/* A simple function returning the constant 1 is not enough
+ to trick modern optimizers anymore. Use a volatile variable
+ seems to force inclusion of the code, as the compiler is forced
+ to assume that that value could be changed by some external code. */
-int
-always_true (void)
-{
- return 1;
-}
+static volatile int always_true = 1;
/* Our general strategy for emitting code is to avoid specifying raw
bytes whenever possible, and instead copy a block of inline asm
@@ -1501,7 +1500,7 @@ always_true (void)
#define EMIT_ASM(NAME,INSNS) \
{ extern unsigned char start_ ## NAME, end_ ## NAME; \
add_insns (&start_ ## NAME, &end_ ## NAME - &start_ ## NAME); \
- if (always_true ()) \
+ if (always_true) \
goto skipover ## NAME; \
__asm__ ("start_" #NAME ":\n\t" INSNS "\n\tend_" #NAME ":\n\t"); \
skipover ## NAME: \
@@ -1513,7 +1512,7 @@ always_true (void)
#define EMIT_ASM32(NAME,INSNS) \
{ extern unsigned char start_ ## NAME, end_ ## NAME; \
add_insns (&start_ ## NAME, &end_ ## NAME - &start_ ## NAME); \
- if (always_true ()) \
+ if (always_true) \
goto skipover ## NAME; \
__asm__ (".code32\n\tstart_" #NAME ":\n\t" INSNS "\n\tend_" #NAME ":\n"
\
"\t.code64\n\t"); \
next prev parent reply other threads:[~2010-06-20 9:30 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-07 16:00 [gdbserver] " Pedro Alves
2010-06-07 16:04 ` Michael Snyder
2010-06-07 16:35 ` Joel Brobecker
2010-06-10 17:28 ` Tom Tromey
2010-06-10 17:36 ` Pedro Alves
2010-06-10 18:43 ` Tom Tromey
2010-06-14 11:15 ` [NEWS/RFA] " Pedro Alves
2010-06-14 17:29 ` Eli Zaretskii
2010-06-14 22:19 ` Pedro Alves
2010-06-16 18:57 ` Doug Evans
2010-06-16 19:13 ` Stan Shebs
2010-06-16 19:16 ` Pedro Alves
2010-06-16 19:21 ` Doug Evans
2010-06-16 23:58 ` Ian Lance Taylor
2010-06-20 22:27 ` Pedro Alves
2010-06-16 19:31 ` Stan Shebs
2010-06-17 18:03 ` Michael Snyder
2010-06-19 16:13 ` Hui Zhu
2010-06-19 16:16 ` Doug Evans
2010-06-19 17:13 ` Hui Zhu
2010-06-19 17:26 ` Doug Evans
2010-06-20 9:30 ` Pierre Muller [this message]
[not found] ` <-3945058798826177264@unknownmsgid>
2010-06-20 15:30 ` [RFA-new version][gdbserver] " Doug Evans
2010-06-20 17:02 ` Pierre Muller
[not found] ` <-1673004315710326113@unknownmsgid>
2010-06-20 17:11 ` Doug Evans
2010-06-20 18:41 ` Tom Tromey
2010-06-20 20:36 ` Pierre Muller
2010-06-20 21:07 ` Pierre Muller
2010-06-21 1:47 ` Tom Tromey
2010-06-21 6:31 ` Pierre Muller
2010-06-20 18:31 ` [NEWS/RFA] Re: [gdbserver] " Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='003301cb105b$1abd19e0$50374da0$@muller@ics-cnrs.unistra.fr' \
--to=pierre.muller@ics-cnrs.unistra.fr \
--cc=dje@google.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=msnyder@vmware.com \
--cc=pedro@codesourcery.com \
--cc=stan@codesourcery.com \
--cc=teawater@gmail.com \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox