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.
+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...
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 ();
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"
# 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}"
}
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)
{