aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2015-11-05 21:40:53 -0700
committerKevin Buettner <kevinb@redhat.com>2015-11-07 11:03:49 -0700
commitf01dcfd9a7954462ea08d2c7b24dad0ca5e07db2 (patch)
tree31de97d8c42616436eab61fb54b7884c1a3adf5f /gdb/testsuite
parent66e749b6edfe817aa78d70c437ff59904b3b9b45 (diff)
downloadgdb-f01dcfd9a7954462ea08d2c7b24dad0ca5e07db2.zip
gdb-f01dcfd9a7954462ea08d2c7b24dad0ca5e07db2.tar.gz
gdb-f01dcfd9a7954462ea08d2c7b24dad0ca5e07db2.tar.bz2
testsuite: Define and use gdb_target_symbol_prefix_flags_asm.
Some of the source code for the test cases in the GDB testsuite reside in .S files containing assembly code. These files typically define a symbol - such as main - which may, depending on the target, require a prefix such as underscore. For example, gdb.dwarf2/dw-compdir-oldgcc.S defines the symbol main: main: .globl main Some targets, such as rx-elf, require main to have an underscore prefix. (If it doesn't, a linker error results due to not being able to find _main required by crt0.o.) So, instead, the above should look like this for rx-elf and other targets with this same requirement: _main: .globl _main This patch defines a new tcl proc in lib/gdb named gdb_target_symbol_prefix_flags_asm. This proc returns a string which will - assuming everything else is wired up correctly - cause -DSYMBOL_PREFIX=_ to be passed on the command line to the compiler. The test cases are augmented with a macro definition for SYMBOL as follows: #define CONCAT1(a, b) CONCAT2(a, b) #define CONCAT2(a, b) a ## b #ifdef SYMBOL_PREFIX # define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str) #else # define SYMBOL(str) str #endif Symbols, such as main shown in the example earlier are then wrapped with SYMBOL like this: SYMBOL(main): .globl SYMBOL(main) The net effect will be to add a prefix for those targets which need it and add no prefix for those targets which do not. It should be noted that there was already a proc in lib/gdb.exp called gdb_target_symbol_prefix_flags. It still exists, but has been significantly rewritten. (There is only one small difference between the two versions.) That proc used to explicitly list targets which were known to require an underscore prefix. This is no longer done; the recently added proc, gdb_target_symbol_prefix, is now invoked to dynamically discover whether or not a prefix is required for that particular target. The difference between gdb_target_symbol_prefix_flags_asm and gdb_target_symbol_prefix_flags is that the former returns a bare prefix while the latter returns the prefix enclosed in double quotes. I.e. assuming that the discovered prefix is underscore, gdb_target_symbol_prefix_flags_asm returns: additional_flags=-DSYMBOL_PREFIX=_ while gdb_target_symbol_prefix_flags returns: additional_flags=-DSYMBOL_PREFIX="_" The double-quoted version is not suitable for using with .S files containing assembly code; there is no way to strip the double quotes using C preprocessor constructs. It would be possible to use the bare (non double quoted) version in C source code. However, the supporting macros become more complicated and therefore more difficult to maintain. gdb/testsuite/ChangeLog: * lib/gdb (gdb_target_symbol_prefix_flags_asm): New proc. (gdb_target_symbol_prefix_flags): Define in terms of _asm version. * gdb.arch/i386-float.exp, gdb.arch/i386-permbkpt.exp, gdb.dwarf2/dw2-canonicalize-type.exp, gdb.dwarf2/dw2-compdir-oldgcc.exp, gdb.dwarf2/dw2-minsym-in-cu.exp, gdb.dwarf2/dw2-op-stack-value.exp, gdb.dwarf2/dw2-unresolved.exp, gdb.dwarf2/fission-reread.exp, gdb.dwarf2/pr13961.exp: Use flags provided by gdb_target_symbol_prefix_flags_asm. * gdb.dwarf2/dw2-canonicalize-type.S, gdb.dwarf2/dw2-compdir-oldgcc.S, testsuite/gdb.dwarf2/dw2-minsym-in-cu.S, testsuite/gdb.dwarf2/dw2-unresolved-main.c, testsuite/gdb.dwarf2/dw2-unresolved.S, gdb.dwarf2/fission-reread.S, gdb.dwarf2/pr13961.S: Define and use SYMBOL macro (and supporting macros where needed). Use this macro for symbols which require the prefix provided by SYMBOL_PREFIX.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog19
-rw-r--r--gdb/testsuite/gdb.arch/i386-float.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-permbkpt.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S17
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp6
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-compdir-oldgcc.S11
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-compdir-oldgcc.exp6
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-minsym-in-cu.S17
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-minsym-in-cu.exp6
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-op-stack-value.exp3
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-unresolved-main.c22
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-unresolved.S21
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-unresolved.exp7
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-reread.S27
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-reread.exp6
-rw-r--r--gdb/testsuite/gdb.dwarf2/pr13961.S17
-rw-r--r--gdb/testsuite/gdb.dwarf2/pr13961.exp6
-rw-r--r--gdb/testsuite/lib/gdb.exp48
18 files changed, 194 insertions, 49 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8acc39e..16d5726 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,22 @@
+2015-11-07 Kevin Buettner <kevinb@redhat.com>
+
+ * lib/gdb (gdb_target_symbol_prefix_flags_asm): New proc.
+ (gdb_target_symbol_prefix_flags): Define in terms of _asm
+ version.
+ * gdb.arch/i386-float.exp, gdb.arch/i386-permbkpt.exp,
+ gdb.dwarf2/dw2-canonicalize-type.exp,
+ gdb.dwarf2/dw2-compdir-oldgcc.exp, gdb.dwarf2/dw2-minsym-in-cu.exp,
+ gdb.dwarf2/dw2-op-stack-value.exp, gdb.dwarf2/dw2-unresolved.exp,
+ gdb.dwarf2/fission-reread.exp, gdb.dwarf2/pr13961.exp: Use flags
+ provided by gdb_target_symbol_prefix_flags_asm.
+ * gdb.dwarf2/dw2-canonicalize-type.S, gdb.dwarf2/dw2-compdir-oldgcc.S,
+ testsuite/gdb.dwarf2/dw2-minsym-in-cu.S,
+ testsuite/gdb.dwarf2/dw2-unresolved-main.c,
+ testsuite/gdb.dwarf2/dw2-unresolved.S, gdb.dwarf2/fission-reread.S,
+ gdb.dwarf2/pr13961.S: Define and use SYMBOL macro (and supporting
+ macros where needed). Use this macro for symbols which require
+ the prefix provided by SYMBOL_PREFIX.
+
2015-11-05 Kevin Buettner <kevinb@redhat.com>
* lib/gdb.exp (gdb_target_symbol_prefix, gdb_target_symbol):
diff --git a/gdb/testsuite/gdb.arch/i386-float.exp b/gdb/testsuite/gdb.arch/i386-float.exp
index ab91bf6..e638ceb 100644
--- a/gdb/testsuite/gdb.arch/i386-float.exp
+++ b/gdb/testsuite/gdb.arch/i386-float.exp
@@ -26,7 +26,7 @@ if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
standard_testfile .S
# some targets have leading underscores on assembly symbols.
-set additional_flags [gdb_target_symbol_prefix_flags]
+set additional_flags [gdb_target_symbol_prefix_flags_asm]
if { [prepare_for_testing break.exp $testfile $srcfile [list debug $additional_flags]] } {
return -1
diff --git a/gdb/testsuite/gdb.arch/i386-permbkpt.exp b/gdb/testsuite/gdb.arch/i386-permbkpt.exp
index 775743d..a6f5673 100644
--- a/gdb/testsuite/gdb.arch/i386-permbkpt.exp
+++ b/gdb/testsuite/gdb.arch/i386-permbkpt.exp
@@ -26,7 +26,7 @@ if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
standard_testfile .S
# some targets have leading underscores on assembly symbols.
-set additional_flags [gdb_target_symbol_prefix_flags]
+set additional_flags [gdb_target_symbol_prefix_flags_asm]
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
untested i386-permbkpt.exp
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S
index 5c93cfc..909d725 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S
+++ b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.S
@@ -13,9 +13,18 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+#ifdef SYMBOL_PREFIX
+# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
+#else
+# define SYMBOL(str) str
+#endif
+
.text
- .globl main
-main:
+ .globl SYMBOL(main)
+SYMBOL(main):
.4byte 0
.Lmain_end:
.section .debug_info
@@ -29,12 +38,12 @@ debug_start:
.ascii "GNU C 4.4.3\0" /* DW_AT_producer */
.byte 0x4 /* DW_AT_language = DW_LANG_C_plus_plus */
.ascii "1.c\0" /* DW_AT_name */
- .4byte main /* DW_AT_low_pc */
+ .4byte SYMBOL(main) /* DW_AT_low_pc */
.4byte .Lmain_end /* DW_AT_high_pc */
.uleb128 0x4 /* (DIE (0x3c) DW_TAG_subprogram) */
.ascii "f\0" /* DW_AT_name */
/* Value 0 would require has_section_at_zero != 0 (which is true, though). */
- .4byte main /* DW_AT_low_pc */
+ .4byte SYMBOL(main) /* DW_AT_low_pc */
.4byte .Lmain_end /* DW_AT_high_pc */
.byte 0x1 /* DW_AT_prototyped */
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp
index c25e18e..94c9813 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-canonicalize-type.exp
@@ -19,10 +19,14 @@ if {![dwarf2_support]} {
return 0
}
+# Some targets have leading underscores on assembly symbols.
+set additional_flags [gdb_target_symbol_prefix_flags_asm]
+
standard_testfile .S
set executable ${testfile}
-if [prepare_for_testing $testfile.exp $testfile $srcfile {nodebug}] {
+if [prepare_for_testing $testfile.exp $testfile $srcfile \
+ [list nodebug $additional_flags]] {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-compdir-oldgcc.S b/gdb/testsuite/gdb.dwarf2/dw2-compdir-oldgcc.S
index 2419b0b..711043e 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-compdir-oldgcc.S
+++ b/gdb/testsuite/gdb.dwarf2/dw2-compdir-oldgcc.S
@@ -15,8 +15,17 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+#ifdef SYMBOL_PREFIX
+# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
+#else
+# define SYMBOL(str) str
+#endif
+
.text
-main: .globl main
+SYMBOL(main): .globl SYMBOL(main)
gcc42: .globl gcc42
.Lgcc42_procstart:
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-compdir-oldgcc.exp b/gdb/testsuite/gdb.dwarf2/dw2-compdir-oldgcc.exp
index f23d3a5..beb5dc3 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-compdir-oldgcc.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-compdir-oldgcc.exp
@@ -19,8 +19,12 @@ if {![dwarf2_support]} {
return 0
}
+# Some targets have leading underscores on assembly symbols.
+set additional_flags [gdb_target_symbol_prefix_flags_asm]
+
standard_testfile .S
-if {[prepare_for_testing $testfile.exp $testfile $srcfile]} {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile \
+ $additional_flags]} {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-minsym-in-cu.S b/gdb/testsuite/gdb.dwarf2/dw2-minsym-in-cu.S
index 8e602ab..74d379f 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-minsym-in-cu.S
+++ b/gdb/testsuite/gdb.dwarf2/dw2-minsym-in-cu.S
@@ -15,16 +15,25 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+#ifdef SYMBOL_PREFIX
+# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
+#else
+# define SYMBOL(str) str
+#endif
+
.text
.Lbegin_text1:
- .globl main
- .type main, %function
-main:
+ .globl SYMBOL(main)
+ .type SYMBOL(main), %function
+SYMBOL(main):
.Lbegin_main:
.int 0
.Lend_main:
- .size main, .-main
+ .size SYMBOL(main), .-SYMBOL(main)
.globl func2
.type func2, %function
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-minsym-in-cu.exp b/gdb/testsuite/gdb.dwarf2/dw2-minsym-in-cu.exp
index 34e514e..5b7bab6 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-minsym-in-cu.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-minsym-in-cu.exp
@@ -21,9 +21,13 @@ if {![dwarf2_support]} {
# This testfile has reproducibility only with cc-with-index.sh.
+# Some targets have leading underscores on assembly symbols.
+set additional_flags [gdb_target_symbol_prefix_flags_asm]
+
standard_testfile .S
-if [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] {
+if [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ ${additional_flags}] {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-op-stack-value.exp b/gdb/testsuite/gdb.dwarf2/dw2-op-stack-value.exp
index 00e8e36..aacdddb 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-op-stack-value.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-op-stack-value.exp
@@ -19,6 +19,9 @@ if {![dwarf2_support]} {
return 0
}
+# Some targets have leading underscores on assembly symbols.
+set additional_flags [gdb_target_symbol_prefix_flags_asm]
+
standard_testfile .S
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" $binfile \
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unresolved-main.c b/gdb/testsuite/gdb.dwarf2/dw2-unresolved-main.c
index e9a0fba..1c6d301 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-unresolved-main.c
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unresolved-main.c
@@ -17,6 +17,20 @@
#include <stdlib.h>
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+#ifdef SYMBOL_PREFIX
+# define SYMBOL1(str) CONCAT1(SYMBOL_PREFIX, str)
+#else
+# define SYMBOL1(str) str
+#endif
+
+#define STR1(s) #s
+#define STR(s) STR1(s)
+
+#define SYMBOL(str) STR(SYMBOL1(str))
+
asm (".globl cu_text_start");
asm ("cu_text_start:");
@@ -31,12 +45,12 @@ main (void)
extern unsigned char var;
/* Do not rely on the `extern' DIE output by GCC (GCC PR debug/39563). */
-asm (".globl extern_block_start");
-asm ("extern_block_start:");
+asm (".globl " SYMBOL(extern_block_start));
+asm (SYMBOL(extern_block_start) ":");
if (var != 2)
abort ();
-asm (".globl extern_block_end");
-asm ("extern_block_end:");
+asm (".globl " SYMBOL(extern_block_end));
+asm (SYMBOL(extern_block_end) ":");
}
return 0;
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unresolved.S b/gdb/testsuite/gdb.dwarf2/dw2-unresolved.S
index 1cfab89..f70a8cf 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-unresolved.S
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unresolved.S
@@ -15,15 +15,24 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+#ifdef SYMBOL_PREFIX
+# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
+#else
+# define SYMBOL(str) str
+#endif
+
.data
/* VAR1 is wrong here, in the real inferior it is located on stack. As both
places are never modified and they are initialized to the same value it
makes no difference. Ensure the name clash for "var". */
-var1: .byte 1
+SYMBOL(var1): .byte 1
- .globl var
-var: .byte 2
+ .globl SYMBOL(var)
+SYMBOL(var): .byte 2
/* Debug information */
@@ -64,12 +73,12 @@ var: .byte 2
.byte 2f - 1f /* DW_AT_location */
1: .byte 3 /* DW_OP_addr */
/* See VAR1 definition why this DIE is not correct. */
- .4byte var1 /* <addr> */
+ .4byte SYMBOL(var1) /* <addr> */
2: .4byte .Ltype_uchar-.Lcu1_begin /* DW_AT_type */
.uleb128 6 /* Abbrev: DW_TAG_lexical_block */
- .4byte extern_block_start /* DW_AT_low_pc */
- .4byte extern_block_end /* DW_AT_high_pc */
+ .4byte SYMBOL(extern_block_start) /* DW_AT_low_pc */
+ .4byte SYMBOL(extern_block_end) /* DW_AT_high_pc */
.uleb128 5 /* Abbrev: DW_TAG_variable (extern) */
.ascii "var\0" /* DW_AT_name */
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unresolved.exp b/gdb/testsuite/gdb.dwarf2/dw2-unresolved.exp
index 792b399..ba371b9 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-unresolved.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unresolved.exp
@@ -19,7 +19,12 @@ if {![dwarf2_support]} {
return 0
}
-if { [prepare_for_testing dw2-unresolved.exp "dw2-unresolved" {dw2-unresolved-main.c dw2-unresolved.S} {nodebug}] } {
+# Some targets have leading underscores on assembly symbols.
+set additional_flags [gdb_target_symbol_prefix_flags_asm]
+
+if { [prepare_for_testing dw2-unresolved.exp "dw2-unresolved" \
+ {dw2-unresolved-main.c dw2-unresolved.S} \
+ [list nodebug $additional_flags]] } {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/fission-reread.S b/gdb/testsuite/gdb.dwarf2/fission-reread.S
index 22cc3aa..3812ede 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-reread.S
+++ b/gdb/testsuite/gdb.dwarf2/fission-reread.S
@@ -38,27 +38,36 @@
further hand-edited to support that.
*/
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+#ifdef SYMBOL_PREFIX
+# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
+#else
+# define SYMBOL(str) str
+#endif
+
.file "fission-reread.cc"
- .globl baz
+ .globl SYMBOL(baz)
.data /* Previously this used .bss, but it's not portable. */
.align 4
- .type baz, %object
- .size baz, 4
-baz:
+ .type SYMBOL(baz), %object
+ .size SYMBOL(baz), 4
+SYMBOL(baz):
.zero 4
.text
.Ltext0:
- .globl main
- .type main, %function
-main:
+ .globl SYMBOL(main)
+ .type SYMBOL(main), %function
+SYMBOL(main):
.LFB0:
.file 1 "fission-reread.cc"
.loc 1 11 0
.4byte 0
.LFE0:
- .size main, .-main
+ .size SYMBOL(main), .-SYMBOL(main)
.Letext0:
.section .debug_types.dwo
@@ -450,4 +459,4 @@ main:
.section .debug_addr
.Ldebug_addr0:
.4byte .LFB0 /* DW_AT_low_pc */
- .4byte baz /* DW_AT_location */
+ .4byte SYMBOL(baz) /* DW_AT_location */
diff --git a/gdb/testsuite/gdb.dwarf2/fission-reread.exp b/gdb/testsuite/gdb.dwarf2/fission-reread.exp
index bcd0196..ec93902 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-reread.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-reread.exp
@@ -25,10 +25,14 @@ if ![dwarf2_support] {
return 0
}
+# Some targets have leading underscores on assembly symbols.
+set additional_flags [gdb_target_symbol_prefix_flags_asm]
+
standard_testfile .S
if [build_executable_from_fission_assembler \
- "$testfile.exp" "$binfile" "$srcfile" {nodebug}] {
+ "$testfile.exp" "$binfile" "$srcfile" \
+ [list nodebug $additional_flags]] {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/pr13961.S b/gdb/testsuite/gdb.dwarf2/pr13961.S
index 9d76438..0bff742 100644
--- a/gdb/testsuite/gdb.dwarf2/pr13961.S
+++ b/gdb/testsuite/gdb.dwarf2/pr13961.S
@@ -37,6 +37,15 @@
further hand-edited to support that.
*/
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+#ifdef SYMBOL_PREFIX
+# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
+#else
+# define SYMBOL(str) str
+#endif
+
.file "pr13961.cc"
.globl baz
@@ -55,13 +64,13 @@ baz:
.text
.Ltext0:
- .globl main
- .type main, %function
-main:
+ .globl SYMBOL(main)
+ .type SYMBOL(main), %function
+SYMBOL(main):
.LFB0:
.4byte 0
.LFE0:
- .size main, .-main
+ .size SYMBOL(main), .-SYMBOL(main)
.Letext0:
.section .debug_types,"",%progbits
diff --git a/gdb/testsuite/gdb.dwarf2/pr13961.exp b/gdb/testsuite/gdb.dwarf2/pr13961.exp
index 850b45d..f62e34b 100644
--- a/gdb/testsuite/gdb.dwarf2/pr13961.exp
+++ b/gdb/testsuite/gdb.dwarf2/pr13961.exp
@@ -22,9 +22,13 @@ if {![dwarf2_support]} {
return 0
}
+# Some targets have leading underscores on assembly symbols.
+set additional_flags [gdb_target_symbol_prefix_flags_asm]
+
standard_testfile .S
-if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] == -1 } {
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ ${additional_flags}] == -1 } {
return -1
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 83dd0a2..a420181 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5571,18 +5571,48 @@ proc gdb_target_symbol { symbol } {
return "${prefix}${symbol}"
}
-# gdb_target_symbol_prefix_flags returns a string that can be added
-# to gdb_compile options to define SYMBOL_PREFIX macro value
-# symbol_prefix_flags returns a string that can be added
-# for targets that use underscore as symbol prefix.
-# TODO: find out automatically if the target needs this.
+# gdb_target_symbol_prefix_flags_asm returns a string that can be
+# added to gdb_compile options to define the C-preprocessor macro
+# SYMBOL_PREFIX with a value that can be prepended to symbols
+# for targets which require a prefix, such as underscore.
+#
+# This version (_asm) defines the prefix without double quotes
+# surrounding the prefix. It is used to define the macro
+# SYMBOL_PREFIX for assembly language files. Another version, below,
+# is used for symbols in inline assembler in C/C++ files.
+#
+# The lack of quotes in this version (_asm) makes it possible to
+# define supporting macros in the .S file. (The version which
+# uses quotes for the prefix won't work for such files since it's
+# impossible to define a quote-stripping macro in C.)
+#
+# It's possible to use this version (_asm) for C/C++ source files too,
+# but a string is usually required in such files; providing a version
+# (no _asm) which encloses the prefix with double quotes makes it
+# somewhat easier to define the supporting macros in the test case.
+
+proc gdb_target_symbol_prefix_flags_asm {} {
+ set prefix [gdb_target_symbol_prefix]
+ if {$prefix ne ""} {
+ return "additional_flags=-DSYMBOL_PREFIX=$prefix"
+ } else {
+ return "";
+ }
+}
+
+# gdb_target_symbol_prefix_flags returns the same string as
+# gdb_target_symbol_prefix_flags_asm, above, but with the prefix
+# enclosed in double quotes if there is a prefix.
+#
+# See the comment for gdb_target_symbol_prefix_flags_asm for an
+# extended discussion.
proc gdb_target_symbol_prefix_flags {} {
- if { [istarget "i?86-*-cygwin*"] || [istarget "i?86-*-mingw*"]
- || [istarget "*-*-msdosdjgpp*"] || [istarget "*-*-go32*"] } {
- return "additional_flags=-DSYMBOL_PREFIX=\"_\""
+ set prefix [gdb_target_symbol_prefix]
+ if {$prefix ne ""} {
+ return "additional_flags=-DSYMBOL_PREFIX=\"$prefix\""
} else {
- return ""
+ return "";
}
}