This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] testsuite/gdb.arch/i386-prologue.c: Fix compiling on Cygwin
- From: mec dot gnu at mindspring dot com (Michael Elizabeth Chastain)
- To: gdb-patches at sources dot redhat dot com
- Cc: vinschen at redhat dot com
- Date: Mon, 28 Jun 2004 13:55:05 -0400 (EDT)
- Subject: Re: [RFA] testsuite/gdb.arch/i386-prologue.c: Fix compiling on Cygwin
> the gdb.arch/i386-prologue.c testcase doesn't compile on Cygwin since
> on Cygwin the assenmbler labels need leading underscores to match the
> same names in C. The below patch fixes that.
I acknowledge the problem, but I don't like to see #ifdef __CYGWIN__
in the middle of i386-prologue.c. So I am declining this patch.
Can you add a layer to this? Use a new symbol such as SYMBOL_PREFIX so
that i386-prologue.exp can tell i386-prologue.c whether to add a leading
underscore or not.
In i386-prologue.exp, something like this:
# some targets have leading underscores on assembly symbols.
# TODO: detect this automatically
set additional_flags ""
if { [istarget "i?86-*-cygwin*"] {
set additional_flags "additional_flags=-DSYMBOL_PREFIX=_"
}
...
gdb_compile ... executable {debug $additional_flags} ...
It would be better to auto-detect the need for a leading underscore,
perhaps by compiling a test program. But you don't need to do that
for this patch.
i386-prologue.exp would look like this. First there is some
preprocessor gunk to add "..." around the value of SYMBOL_PREFIX:
#define xstringify(arg) stringify(arg)
#define stringify(arg) #arg
/* add "..." around SYMBOL_PREFIX to make SP_STRING */
#ifdef SYMBOL_PREFIX
#define SP_STRING xstringify(SYMBOL_PREFIX)
#else
#define SP_STRING ""
#endif
...
Then in the places where you want optional leading underscores, just add
SP_STRING to the big asm string. The big asm string already depends on
string concatenation so this ought to work fine:
" .align 8\n"
SP_STRING "gdb1253:\n"
" pushl %ebp\n"
I'm open to ideas if you have improvements or a different idea. My goal
here is that i386-prologue.c does not have any target-specific tests in
it.
Michael C
===
* gdb.arch/i386-prologue.c: Conditionalize label names to build
on Cygwin.