gdb.base/{prologue,symbol-alias}.exp C++ify
authorPedro Alves <pedro@palves.net>
Thu, 17 Sep 2020 22:33:42 +0000 (23:33 +0100)
committerPedro Alves <pedro@palves.net>
Thu, 17 Sep 2020 23:07:41 +0000 (00:07 +0100)
Make these testcases work when compiled as C++ programs.

These testcases use the alias attribute, which requires passing in the
target function's mangled name in C++.  To avoid having to figure out
how the functions are mangled, explicitly specify a linkage name.
This is preferred over 'extern "C"' because that doesn't work with
static functions.

gdb/testsuite/ChangeLog:

* gdb.base/prologue.c [__cplusplus] (marker): Explicitly specify
linkage name.
* gdb.base/prologue.exp: Use print /d.
* gdb.base/symbol-alias.exp: Handle C++ output.
* gdb.base/symbol-alias2.c: Handle C++ output.
[__cplusplus] (func): Explicitly specify linkage name.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/prologue.c
gdb/testsuite/gdb.base/prologue.exp
gdb/testsuite/gdb.base/symbol-alias.exp
gdb/testsuite/gdb.base/symbol-alias2.c

index 211132a4362f14a7de90888002b2dc15a2eb35a3..b123bb60540d0a9bd597166468043de98866f061 100644 (file)
@@ -1,3 +1,12 @@
+2020-09-17  Pedro Alves  <pedro@palves.net>
+
+       * gdb.base/prologue.c [__cplusplus] (marker): Explicitly specify
+       linkage name.
+       * gdb.base/prologue.exp: Use print /d.
+       * gdb.base/symbol-alias.exp: Handle C++ output.
+       * gdb.base/symbol-alias2.c: Handle C++ output.
+       [__cplusplus] (func): Explicitly specify linkage name.
+
 2020-09-17  Pedro Alves  <pedro@palves.net>
 
        * gdb.python/py-nested-maps.c (struct key_t): Rename to...
index c7de916293626c19c623016bbb514b82d3242749..717bd3f106eb58f5b866db83984e14eef6d49c9d 100644 (file)
@@ -20,6 +20,12 @@ int leaf (void)
   return 1;
 }
 
+#ifdef __cplusplus
+/* So that the alias attribute below work without having to figure out
+   this function's mangled name.  */
+int marker (int val) asm ("marker");
+#endif
+
 int marker (int val)
 {
   leaf ();
index ee834884735c142c0796a91ef3e3ff8d17c0261f..20ab22efb9edcc0e42b598297ff1b3e048599b55 100644 (file)
@@ -59,4 +59,4 @@ set pc1 [find_breakpoint_pc "marker"]
 
 set pc2 [find_breakpoint_pc "other"]
 
-gdb_test "print $pc1 == $pc2" "\\\$$decimal = 1" "same pc from minimal symbol"
+gdb_test "print /d $pc1 == $pc2" "\\\$$decimal = 1" "same pc from minimal symbol"
index fcdcce2b702184ff00ee518a32dfad83b33fd18b..1907cad478d92de5009a1e9f4086c947004c168e 100644 (file)
@@ -27,7 +27,7 @@ if ![runto_main] then {
 
 # Functions.
 foreach f {"func" "func_alias"} {
-    gdb_test "p $f" " = {struct S \\*\\(void\\)} $hex <func>"
+    gdb_test "p $f" " = {(struct )?S \\*\\(void\\)} $hex <func(\\(\\))?>"
     gdb_test "p *${f}()" "= {field1 = 1, field2 = 2}"
 }
 
index e53c212607ee9aa6962bfedf5d4fad86855998a0..2c6185f45168a6bdbe1bbc5773902eaa39814bb3 100644 (file)
@@ -23,6 +23,12 @@ struct S
 
 struct S g_var_s = { 1, 2 };
 
+#ifdef __cplusplus
+/* So that the alias attribute below work without having to figure out
+   this function's mangled name.  */
+static struct S *func (void) asm ("func");
+#endif
+
 static struct S *
 func (void)
 {
This page took 0.035849 seconds and 4 git commands to generate.