* [RFC 00/18] Allow building (more) C tests with a C++ compiler
@ 2020-09-14 0:14 Pedro Alves
2020-09-14 0:14 ` [RFC 02/18] gdb.base/display.exp C++ify Pedro Alves
` (17 more replies)
0 siblings, 18 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
I've been playing with the AMD ROCm toolchain (GPU debugging, yay!)
and I had the idea of writing a board file that runs the whole
testsuite against the GPU, compiling programs with HIP.
Of course any testcase that relies on system calls like fork/exec, or
even threads, can't work, but there are many tests under gdb.base/ ,
gdb.mi/ , gdb.python/ , etc. that are useful and exercise many of the
core gdb commands and features.
Since HIP is a C++-based language however (similar to CUDA), many of
those simple test programs don't compile or test cleanly, since they
are written in C without care for C++ compatibility.
Regardless of HIP, many of the tests written in C aren't really
testing C-specific things, but rather GDB core commands. It's just
that C is seen as the lowest common denominator. It seems like a good
idea to be able to run them in C++ mode too, to say, discover spurious
GCC vs G++ differences. gdb.base/break.exp uncovered one such
difference that seems like a buglet (I'll probably file a GCC bug).
We already have some tests under gdb.base/ that explicitly test both C
and C++ modes, like align-c.exp/align-c++.exp and others. I propose
allowing some more tests to run in C++ mode. I'm not proposing always
running the tests in both C and C++, at least not yet. Essentially,
I'm currently only after making it possible to run these test with
either:
$ make check RUNTESTFLAGS="CC_FOR_TARGET='g++'"
$ make check RUNTESTFLAGS="CC_FOR_TARGET='clang++ -Wno-deprecated'"
which is a necessary step anyway if we ever want to always run these
tests in both C and C++ modes.
Most of the changes are actually trivial and the kind you'd expect --
avoid identifiers named "this", explicit casts from 'void *' to 'type
*' or from int to enum. In the .exp files, adjust to the fact that in
C++ mode, GDB prints the full prototype of functions (i.e., shows
parameter types), or that some commands by default show mangled names.
I don't think I'll do this to other tests in the foreseeable future,
as this this already enables a good subset of the testsuite, and most
the remaining tests fail to compile with HIP for other reasons AFAICT.
gdb/testsuite/gdb.base/break.exp | 50 +++++++++++++----------
gdb/testsuite/gdb.base/charset.c | 7 +++-
gdb/testsuite/gdb.base/charset.exp | 12 +++---
gdb/testsuite/gdb.base/display.exp | 3 ++
gdb/testsuite/gdb.base/examine-backward.c | 7 +++-
gdb/testsuite/gdb.base/examine-backward.exp | 7 +++-
gdb/testsuite/gdb.base/exprs.c | 4 +-
gdb/testsuite/gdb.base/find.c | 3 +-
gdb/testsuite/gdb.base/find.exp | 3 ++
gdb/testsuite/gdb.base/nested-addr.c | 2 +-
gdb/testsuite/gdb.base/nested-addr.exp | 2 +-
gdb/testsuite/gdb.base/printcmds.c | 6 +--
gdb/testsuite/gdb.base/prologue.c | 6 +++
gdb/testsuite/gdb.base/prologue.exp | 2 +-
gdb/testsuite/gdb.base/ptype.c | 8 ++--
gdb/testsuite/gdb.base/ptype1.c | 2 +-
gdb/testsuite/gdb.base/setvar.c | 4 +-
gdb/testsuite/gdb.base/share-env-with-gdbserver.c | 2 +-
gdb/testsuite/gdb.base/sizeof.c | 2 +-
gdb/testsuite/gdb.base/symbol-alias.exp | 2 +-
gdb/testsuite/gdb.base/symbol-alias2.c | 6 +++
gdb/testsuite/gdb.base/watchpoint.c | 4 +-
gdb/testsuite/gdb.base/watchpoint.exp | 4 +-
gdb/testsuite/gdb.base/whatis.c | 4 +-
gdb/testsuite/gdb.cp/call-c-1.c | 3 ++
gdb/testsuite/gdb.mi/var-cmd.c | 2 +-
gdb/testsuite/gdb.python/py-as-string.c | 2 +-
gdb/testsuite/gdb.python/py-frame-inline.exp | 2 +-
gdb/testsuite/gdb.python/py-framefilter-mi.c | 4 +-
gdb/testsuite/gdb.python/py-framefilter.c | 8 ++--
gdb/testsuite/gdb.python/py-nested-maps.c | 44 ++++++++++----------
31 files changed, 128 insertions(+), 89 deletions(-)
base-commit: dc3a371e83b6df36beb8c6d12a07d3e469b68a36
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 02/18] gdb.base/display.exp C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 03/18] gdb.base/break.exp C++ify Pedro Alves
` (16 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
---
gdb/testsuite/gdb.base/display.exp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp
index a9d4f753ff9..242e13bc291 100644
--- a/gdb/testsuite/gdb.base/display.exp
+++ b/gdb/testsuite/gdb.base/display.exp
@@ -195,6 +195,9 @@ gdb_test "print j" " = 0\[\\r\\n\]+" "debug test output 3"
# x/0 j doesn't produce any output and terminates PA64 process when testing
gdb_test_no_output "x/0 j"
+# For when the test is built in C++ mode.
+gdb_test_no_output "set print asm-demangle on"
+
gdb_test "print/0 j" ".*Item count other than 1 is meaningless.*"
gdb_test "print/s sum" " = 1000" "ignored s"
gdb_test "print/i sum" ".*Format letter.*is meaningless.*.*" "no i"
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 03/18] gdb.base/break.exp C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
2020-09-14 0:14 ` [RFC 02/18] gdb.base/display.exp C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 04/18] gdb.base/nested-addr.exp C++ify Pedro Alves
` (15 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
Some adjustments to make gdb.base/break.exp work when compiled as a
C++ program. Passes cleanly with Clang++, but not with G++. The
latter puts a breakpoint at an unexpected line in one case. It seems
like a bug that gcc and g++ behave differently here.
---
gdb/testsuite/gdb.base/break.exp | 50 ++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 22 deletions(-)
diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index 8c7ce42d805..35813e3dfee 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -121,16 +121,22 @@ set main_line $bp_location6
set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
+# In C++ mode, we see a full prototype; in C mode, we only see the
+# function name, with no parameter info.
+proc func {name} {
+ return "${name}(?:\(\[^\r\n\]*\))?"
+}
+
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
-\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:$bp_location8.*
-\[0-9\]+\[\t \]+breakpoint keep y.* in factorial at .*$srcfile:$bp_location7.*
-\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
-\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
-\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.*
-\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.*
-\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4" \
+\[0-9\]+\[\t \]+breakpoint keep y.* in [func main] at .*$srcfile:$main_line.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in [func marker2] at .*$srcfile1:$bp_location8.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in [func factorial] at .*$srcfile:$bp_location7.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in [func main] at .*$srcfile:$bp_location1.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in [func main] at .*$srcfile:$bp_location1.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in [func main] at .*$srcfile:$bp_location2.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in [func multi_line_if_conditional] at .*$srcfile:$bp_location3.*
+\[0-9\]+\[\t \]+breakpoint keep y.* in [func multi_line_while_conditional] at .*$srcfile:$bp_location4" \
"breakpoint info"
#
@@ -149,7 +155,7 @@ gdb_test_multiple "info break 2 4 6" "info break 2 4 6" {
set see1 1
exp_continue
}
- -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in marker2 at \[^\r\n\]*" {
+ -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
set see2 1
exp_continue
}
@@ -186,11 +192,11 @@ set see5 0
set see6 0
gdb_test_multiple "info break 3-5" "info break 3-5" {
- -re "1\[\t \]+breakpoint *keep y.* in main at .*:$main_line\[^\r\n\]*" {
+ -re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$main_line\[^\r\n\]*" {
set see1 1
exp_continue
}
- -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in marker2 at \[^\r\n\]*" {
+ -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
set see2 1
exp_continue
}
@@ -243,11 +249,11 @@ set see5 0
set see6 0
gdb_test_multiple "info break" "check disable with history values" {
- -re "1\[\t \]+breakpoint *keep y.* in main at .*:$main_line\[^\r\n\]*" {
+ -re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$main_line\[^\r\n\]*" {
set see1 1
exp_continue
}
- -re "2\[\t \]+breakpoint *keep n\[^\r\n\]* in marker2 at \[^\r\n\]*" {
+ -re "2\[\t \]+breakpoint *keep n\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
set see2 1
exp_continue
}
@@ -289,11 +295,11 @@ set see5 0
set see6 0
gdb_test_multiple "info break" "check disable with convenience values" {
- -re "1\[\t \]+breakpoint *keep y.* in main at .*:$main_line\[^\r\n\]*" {
+ -re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$main_line\[^\r\n\]*" {
set see1 1
exp_continue
}
- -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in marker2 at \[^\r\n\]*" {
+ -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
set see2 1
exp_continue
}
@@ -452,12 +458,12 @@ gdb_test "tbreak $srcfile:$bp_location11" "Temporary breakpoint.*at.* file .*$s
# check to see what breakpoints are set (temporary this time)
#
gdb_test "info break" "Num Type.*Disp Enb Address.*What.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial at .*$srcfile:$bp_location7.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \
+\[0-9\]+\[\t \]+breakpoint del.*y.*in [func main] at .*$srcfile:$main_line.*\[\r\n\]
+\[0-9\]+\[\t \]+breakpoint del.*y.*in [func factorial] at .*$srcfile:$bp_location7.*\[\r\n\]
+\[0-9\]+\[\t \]+breakpoint del.*y.*in [func main] at .*$srcfile:$bp_location1.*\[\r\n\]
+\[0-9\]+\[\t \]+breakpoint del.*y.*in [func main] at .*$srcfile:$bp_location6.*\[\r\n\]
+\[0-9\]+\[\t \]+breakpoint del.*y.*in [func main] at .*$srcfile:$bp_location2.*\[\r\n\]
+\[0-9\]+\[\t \]+breakpoint del.*y.*in [func main] at .*$srcfile:$bp_location11.*" \
"Temporary breakpoint info"
@@ -606,7 +612,7 @@ gdb_test "break marker2" \
"set breakpoint on to-be-called function"
gdb_test "print marker2(99)" \
- "The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.marker2. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.*" \
+ "The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.[func marker2]. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.*" \
"hit breakpoint on called function"
# As long as we're stopped (breakpointed) in a called function,
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 04/18] gdb.base/nested-addr.exp C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
2020-09-14 0:14 ` [RFC 02/18] gdb.base/display.exp C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 03/18] gdb.base/break.exp C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 05/18] gdb.base/examine-backward.exp C++ify and Clang Pedro Alves
` (14 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
Adjust gdb.base/nested-addr.exp to let the testcase build and run as a
C++ program. "print /d" is used so we get "= 1" instead of "= true"
in C++ mode.
---
gdb/testsuite/gdb.base/nested-addr.c | 2 +-
gdb/testsuite/gdb.base/nested-addr.exp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/gdb.base/nested-addr.c b/gdb/testsuite/gdb.base/nested-addr.c
index 4725753382d..3d1cfd45376 100644
--- a/gdb/testsuite/gdb.base/nested-addr.c
+++ b/gdb/testsuite/gdb.base/nested-addr.c
@@ -28,7 +28,7 @@ static foo *foo_array = NULL;
int
main (void)
{
- foo_array = calloc (3, sizeof (*foo_array));
+ foo_array = (foo *) calloc (3, sizeof (*foo_array));
foo_array[1].a = 10;
foo_array[2].b = 20;
return 0; /* BREAK */
diff --git a/gdb/testsuite/gdb.base/nested-addr.exp b/gdb/testsuite/gdb.base/nested-addr.exp
index 7ed0d65d327..15071cac9c7 100644
--- a/gdb/testsuite/gdb.base/nested-addr.exp
+++ b/gdb/testsuite/gdb.base/nested-addr.exp
@@ -31,4 +31,4 @@ gdb_test "print &foo_array\[1\].a" "= \\(int \\*\\) $hex.*"
# A bug in EVAL_AVOID_SIDE_EFFECTS mode used to yield the following error:
# Attempt to take address of value not located in memory.
-gdb_test "print 1 && &foo_array\[1\].a" "= 1"
+gdb_test "print /d 1 && &foo_array\[1\].a" "= 1"
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 05/18] gdb.base/examine-backward.exp C++ify and Clang
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (2 preceding siblings ...)
2020-09-14 0:14 ` [RFC 04/18] gdb.base/nested-addr.exp C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 06/18] gdb.base/printcmds.c C++-ify Pedro Alves
` (13 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
Adjust gdb.base/examine-backward.exp to let the testcase build and run
as a C++ program, built with either G++ or Clang++.
The change to use unsigned char instead of plain char is to avoid
narrowing warnings:
gdb compile failed, src/gdb/testsuite/gdb.base/examine-backward.c:55:1: error: narrowing conversion of '227' from 'int' to 'char' [-Wnarrowing]
55 | };
| ^
---
gdb/testsuite/gdb.base/examine-backward.c | 7 +++++--
gdb/testsuite/gdb.base/examine-backward.exp | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/gdb/testsuite/gdb.base/examine-backward.c b/gdb/testsuite/gdb.base/examine-backward.c
index cf61df8bbe7..4db40959c48 100644
--- a/gdb/testsuite/gdb.base/examine-backward.c
+++ b/gdb/testsuite/gdb.base/examine-backward.c
@@ -36,11 +36,11 @@ literals. The content of each array is the same as followings:
TestStrings, to avoid showing garbage when we look for strings
backwards from TestStrings. */
-const char Barrier[] = {
+const unsigned char Barrier[] = {
0x00,
};
-const char TestStrings[] = {
+const unsigned char TestStrings[] = {
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
@@ -92,6 +92,9 @@ const int TestStringsW[] = {
int
main (void)
{
+ /* Clang++ eliminates the variables if nothing references them. */
+ int dummy = Barrier[0] + TestStrings[0] + TestStringsH[0] + TestStringsW[0];
+
/* Backward disassemble test requires at least 20 instructions in
this function. Adding a simple bubble sort. */
int i, j;
diff --git a/gdb/testsuite/gdb.base/examine-backward.exp b/gdb/testsuite/gdb.base/examine-backward.exp
index c1ab4d1ce8d..b2d9fc1e1b2 100644
--- a/gdb/testsuite/gdb.base/examine-backward.exp
+++ b/gdb/testsuite/gdb.base/examine-backward.exp
@@ -345,9 +345,12 @@ with_test_prefix "backward disassemble general" {
set length_to_examine {1 2 3 4 10}
set disassmbly {}
- gdb_test "x/i main" "0x\[0-9a-fA-F\]+ <main>:\t.*" \
+ gdb_test_no_output "set print asm-demangle on"
+ set main_re "main(\\(\\))?"
+
+ gdb_test "x/i main" "0x\[0-9a-fA-F\]+ <$main_re>:\t.*" \
"move the current position to main (x/i)"
- gdb_test "x/-i" "0x\[0-9a-fA-F\]+ <main>:\t.*" \
+ gdb_test "x/-i" "0x\[0-9a-fA-F\]+ <$main_re>:\t.*" \
"move the current position to main (x/-i)"
for {set i 0} {$i < [llength $length_to_examine]} {incr i} {
set len [lindex $length_to_examine $i]
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 06/18] gdb.base/printcmds.c C++-ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (3 preceding siblings ...)
2020-09-14 0:14 ` [RFC 05/18] gdb.base/examine-backward.exp C++ify and Clang Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 07/18] gdb.base/watchpoint.{c,exp} Pedro Alves
` (12 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
Adjust gdb.base/printcmds.c to make it buildable as a C++ program.
---
gdb/testsuite/gdb.base/printcmds.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdb/testsuite/gdb.base/printcmds.c b/gdb/testsuite/gdb.base/printcmds.c
index 04b766fc0c2..9af6bf3aacb 100644
--- a/gdb/testsuite/gdb.base/printcmds.c
+++ b/gdb/testsuite/gdb.base/printcmds.c
@@ -108,7 +108,7 @@ enum flag_enum
FE_TWO_LEGACY = 0x02,
};
-enum flag_enum three = FE_ONE | FE_TWO;
+enum flag_enum three = (enum flag_enum) (FE_ONE | FE_TWO);
/* Another enum considered as a "flag enum", but with no enumerator with value
0. */
@@ -118,7 +118,7 @@ enum flag_enum_without_zero
FEWZ_TWO = 0x02,
};
-enum flag_enum_without_zero flag_enum_without_zero = 0;
+enum flag_enum_without_zero flag_enum_without_zero = (enum flag_enum_without_zero) 0;
/* Not a flag enum, an enumerator value has multiple bits sets. */
enum not_flag_enum
@@ -128,7 +128,7 @@ enum not_flag_enum
NFE_F0 = 0xf0,
};
-enum not_flag_enum three_not_flag = NFE_ONE | NFE_TWO;
+enum not_flag_enum three_not_flag = (enum not_flag_enum) (NFE_ONE | NFE_TWO);
/* A structure with an embedded array at an offset > 0. The array has
all elements with the same repeating value, which must not be the
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 07/18] gdb.base/watchpoint.{c,exp}
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (4 preceding siblings ...)
2020-09-14 0:14 ` [RFC 06/18] gdb.base/printcmds.c C++-ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 08/18] gdb.base/charset.exp C++ify Pedro Alves
` (11 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
Adjust gdb.base/watchpoint.c so that it can be built as a C++ program.
Fixes:
gdb compile failed, src/gdb/testsuite/gdb.base/watchpoint.c:33:16: error: initializer-string for array of chars is too long [-fpermissive]
33 | char buf[30] = "testtesttesttesttesttesttestte";
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/gdb/testsuite/gdb.base/watchpoint.c:62:14: error: expected unqualified-id before 'nullptr'
62 | struct foo5 *nullptr;
| ^~~~~~~
---
gdb/testsuite/gdb.base/watchpoint.c | 4 ++--
gdb/testsuite/gdb.base/watchpoint.exp | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdb/testsuite/gdb.base/watchpoint.c b/gdb/testsuite/gdb.base/watchpoint.c
index 60f60d6c02c..3d6e36ff081 100644
--- a/gdb/testsuite/gdb.base/watchpoint.c
+++ b/gdb/testsuite/gdb.base/watchpoint.c
@@ -30,7 +30,7 @@ int ival2 = -1;
int ival3 = -1;
int ival4 = -1;
int ival5 = -1;
-char buf[30] = "testtesttesttesttesttesttestte";
+char buf[31] = "testtesttesttesttesttesttestte";
struct foo
{
int val;
@@ -59,7 +59,7 @@ struct foo5
struct { int x; } *p;
};
-struct foo5 *nullptr;
+struct foo5 *null_ptr;
void marker1 ()
{
diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index 1ed73e8b491..fc84f98534b 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -604,9 +604,9 @@ proc test_watch_location {} {
gdb_continue_to_breakpoint "func5 breakpoint here"
# Check first if a null pointer can be dereferenced on the target.
- gdb_test_multiple "p *nullptr" "" {
+ gdb_test_multiple "p *null_ptr" "" {
-re "Cannot access memory at address 0x0.*$gdb_prompt $" {
- gdb_test "watch -location nullptr->p->x" \
+ gdb_test "watch -location null_ptr->p->x" \
"Cannot access memory at address 0x0"
}
-re ".*$gdb_prompt $" {
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 08/18] gdb.base/charset.exp C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (5 preceding siblings ...)
2020-09-14 0:14 ` [RFC 07/18] gdb.base/watchpoint.{c,exp} Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 09/18] gdb.base/{exprs,ptype,ptype1,setvar,whatis}.c C++ify Pedro Alves
` (10 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
wchar_t is built-in in C++, so don't make a phony typedef.
The "print /d" is so that we also get "1" instead of "true" in C++
mode.
---
gdb/testsuite/gdb.base/charset.c | 7 ++++++-
gdb/testsuite/gdb.base/charset.exp | 12 ++++++------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/gdb/testsuite/gdb.base/charset.c b/gdb/testsuite/gdb.base/charset.c
index 20d548b1928..b1e6d3add08 100644
--- a/gdb/testsuite/gdb.base/charset.c
+++ b/gdb/testsuite/gdb.base/charset.c
@@ -49,11 +49,12 @@ char iso_8859_1_string[NUM_CHARS];
char ebcdic_us_string[NUM_CHARS];
char ibm1047_string[NUM_CHARS];
+#ifndef __cplusplus
+
/* We make a phony wchar_t and then pretend that this platform uses
UTF-32 (or UTF-16, depending on the size -- same difference for the
purposes of this test). */
typedef unsigned int wchar_t;
-wchar_t utf_32_string[NUM_CHARS];
/* We also define a couple phony types for testing the u'' and U''
support. It is ok if these have the wrong size on some platforms
@@ -61,6 +62,10 @@ wchar_t utf_32_string[NUM_CHARS];
typedef unsigned short char16_t;
typedef unsigned int char32_t;
+#endif
+
+wchar_t utf_32_string[NUM_CHARS];
+
/* Make sure to use the typedefs. */
char16_t uvar;
char32_t Uvar;
diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp
index a4345faf056..1a04f1daacd 100644
--- a/gdb/testsuite/gdb.base/charset.exp
+++ b/gdb/testsuite/gdb.base/charset.exp
@@ -409,7 +409,7 @@ foreach target_charset $charset_subset {
"parse character literal in ${target_charset}"
# Check that the character literal was encoded correctly.
- gdb_test "print $L'A' == $var_name\[7\]" \
+ gdb_test "print /d $L'A' == $var_name\[7\]" \
" = 1" \
"check value of parsed character literal in ${target_charset}"
@@ -419,7 +419,7 @@ foreach target_charset $charset_subset {
"parse string literal in ${target_charset}"
# Check that the string literal was encoded correctly.
- gdb_test "print $L\"q\"\[0\] == $var_name\[49\]" \
+ gdb_test "print /d $L\"q\"\[0\] == $var_name\[49\]" \
" = 1" \
"check value of parsed string literal in ${target_charset}"
@@ -470,12 +470,12 @@ foreach target_charset $charset_subset {
if {$have_escape} {
# Try parsing a backslash escape in a character literal.
- gdb_test "print $L'\\${escape}' == $var_name\[$i\]" \
+ gdb_test "print /d $L'\\${escape}' == $var_name\[$i\]" \
" = 1" \
"check value of '\\${escape}' in ${target_charset}"
# Try parsing a backslash escape in a string literal.
- gdb_test "print $L\"\\${escape}\"\[0\] == $var_name\[$i\]" \
+ gdb_test "print /d $L\"\\${escape}\"\[0\] == $var_name\[$i\]" \
" = 1" \
"check value of \"\\${escape}\" in ${target_charset}"
}
@@ -485,7 +485,7 @@ foreach target_charset $charset_subset {
# get the unescaped character, in the target character set.
gdb_test "print $L'\\q'" " = \[0-9-\]+ $L'q'" \
"print escape that doesn't exist in $target_charset"
- gdb_test "print $L'\\q' == $var_name\[49\]" " = 1" \
+ gdb_test "print /d $L'\\q' == $var_name\[49\]" " = 1" \
"check value of escape that doesn't exist in $target_charset"
}
@@ -585,7 +585,7 @@ if {$ucs2_ok} {
}
# Regression test for a cleanup bug in the charset code.
-gdb_test "print 'a' == 'a' || 'b' == 'b'" \
+gdb_test "print /d 'a' == 'a' || 'b' == 'b'" \
".* = 1" \
"EVAL_SKIP cleanup handling regression test"
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 09/18] gdb.base/{exprs,ptype,ptype1,setvar,whatis}.c C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (6 preceding siblings ...)
2020-09-14 0:14 ` [RFC 08/18] gdb.base/charset.exp C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 10/18] gdb.mi/var-cmd.c C++ify Pedro Alves
` (9 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
This adjusts:
gdb.base/{exprs,ptype,ptype1,setvar,whatis}.c,
to make them buildable as C++ programs.
---
gdb/testsuite/gdb.base/exprs.c | 4 ++--
gdb/testsuite/gdb.base/ptype.c | 8 ++++----
gdb/testsuite/gdb.base/ptype1.c | 2 +-
gdb/testsuite/gdb.base/setvar.c | 4 ++--
gdb/testsuite/gdb.base/whatis.c | 4 ++--
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/gdb/testsuite/gdb.base/exprs.c b/gdb/testsuite/gdb.base/exprs.c
index cd605f39d30..195b88e9142 100644
--- a/gdb/testsuite/gdb.base/exprs.c
+++ b/gdb/testsuite/gdb.base/exprs.c
@@ -156,7 +156,7 @@ double v_double_func () { return (0.0); }
struct link {
struct link *next;
#ifdef __STDC__
- struct link *(*linkfunc) (struct link *this, int flags);
+ struct link *(*linkfunc) (struct link *self, int flags);
#else
struct link *(*linkfunc) ();
#endif
@@ -166,7 +166,7 @@ struct link {
union tu_link {
struct link *next;
#ifdef __STDC__
- struct link *(*linkfunc) (struct link *this, int flags);
+ struct link *(*linkfunc) (struct link *self, int flags);
#else
struct link *(*linkfunc) ();
#endif
diff --git a/gdb/testsuite/gdb.base/ptype.c b/gdb/testsuite/gdb.base/ptype.c
index 4148da771e1..6d12c2add42 100644
--- a/gdb/testsuite/gdb.base/ptype.c
+++ b/gdb/testsuite/gdb.base/ptype.c
@@ -168,7 +168,7 @@ double v_double_func () { return (0.0); }
struct link {
struct link *next;
#ifdef __STDC__
- struct link *(*linkfunc) (struct link *this, int flags);
+ struct link *(*linkfunc) (struct link *self, int flags);
#else
struct link *(*linkfunc) ();
#endif
@@ -178,7 +178,7 @@ struct link {
union tu_link {
struct link *next;
#ifdef __STDC__
- struct link *(*linkfunc) (struct link *this, int flags);
+ struct link *(*linkfunc) (struct link *self, int flags);
#else
struct link *(*linkfunc) ();
#endif
@@ -269,11 +269,11 @@ func_type v_func_type;
/***********/
-extern char charfoo ();
+extern char charfoo (int);
typedef int foo;
-foo intfoo (afoo)
+foo intfoo (int afoo)
{
charfoo (afoo);
return (afoo * 2);
diff --git a/gdb/testsuite/gdb.base/ptype1.c b/gdb/testsuite/gdb.base/ptype1.c
index 25871509cba..43ab05694e2 100644
--- a/gdb/testsuite/gdb.base/ptype1.c
+++ b/gdb/testsuite/gdb.base/ptype1.c
@@ -1,6 +1,6 @@
typedef char foo;
-foo charfoo (afoo)
+foo charfoo (int afoo)
{
return (afoo * 2);
}
diff --git a/gdb/testsuite/gdb.base/setvar.c b/gdb/testsuite/gdb.base/setvar.c
index 1b8d8088654..415eb6f2aaa 100644
--- a/gdb/testsuite/gdb.base/setvar.c
+++ b/gdb/testsuite/gdb.base/setvar.c
@@ -161,7 +161,7 @@ double v_double_func () { return (0.0); }
struct link {
struct link *next;
#ifdef __STDC__
- struct link *(*linkfunc) (struct link *this, int flags);
+ struct link *(*linkfunc) (struct link *self, int flags);
#else
struct link *(*linkfunc) ();
#endif
@@ -171,7 +171,7 @@ struct link {
union tu_link {
struct link *next;
#ifdef __STDC__
- struct link *(*linkfunc) (struct link *this, int flags);
+ struct link *(*linkfunc) (struct link *self, int flags);
#else
struct link *(*linkfunc) ();
#endif
diff --git a/gdb/testsuite/gdb.base/whatis.c b/gdb/testsuite/gdb.base/whatis.c
index 11c84d291cd..743cb61abfe 100644
--- a/gdb/testsuite/gdb.base/whatis.c
+++ b/gdb/testsuite/gdb.base/whatis.c
@@ -207,7 +207,7 @@ double v_double_func () { return (0.0); }
struct link {
struct link *next;
#ifdef __STDC__
- struct link *(*linkfunc) (struct link *this, int flags);
+ struct link *(*linkfunc) (struct link *self, int flags);
#else
struct link *(*linkfunc) ();
#endif
@@ -217,7 +217,7 @@ struct link {
union tu_link {
struct link *next;
#ifdef __STDC__
- struct link *(*linkfunc) (struct link *this, int flags);
+ struct link *(*linkfunc) (struct link *self, int flags);
#else
struct link *(*linkfunc) ();
#endif
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 10/18] gdb.mi/var-cmd.c C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (7 preceding siblings ...)
2020-09-14 0:14 ` [RFC 09/18] gdb.base/{exprs,ptype,ptype1,setvar,whatis}.c C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 11/18] gdb.python/{py-framefilter-mi,py-framefilter}.c C++ify Pedro Alves
` (8 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
This adjusts gdb.mi/var-cmd.c to make it buildable as a C++ program.
---
gdb/testsuite/gdb.mi/var-cmd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.mi/var-cmd.c b/gdb/testsuite/gdb.mi/var-cmd.c
index 0529b67c7f1..f209106dd65 100644
--- a/gdb/testsuite/gdb.mi/var-cmd.c
+++ b/gdb/testsuite/gdb.mi/var-cmd.c
@@ -566,7 +566,7 @@ do_anonymous_type_tests (void)
};
} v = {1, {2}, {3}};
- anon = malloc (sizeof (struct anonymous));
+ anon = (struct anonymous *) malloc (sizeof (struct anonymous));
anon->a = 1;
anon->b = 2;
anon->c = (char *) 3;
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 11/18] gdb.python/{py-framefilter-mi,py-framefilter}.c C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (8 preceding siblings ...)
2020-09-14 0:14 ` [RFC 10/18] gdb.mi/var-cmd.c C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 13/18] gdb.base/{prologue,symbol-alias}.exp C++ify Pedro Alves
` (7 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
This adjusts:
gdb.python/{py-framefilter-mi,py-framefilter}.c
to make them buildable as C++ programs.
---
gdb/testsuite/gdb.python/py-framefilter-mi.c | 4 ++--
gdb/testsuite/gdb.python/py-framefilter.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/gdb.python/py-framefilter-mi.c b/gdb/testsuite/gdb.python/py-framefilter-mi.c
index 10779069d58..bc2ad1e4a05 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-mi.c
+++ b/gdb/testsuite/gdb.python/py-framefilter-mi.c
@@ -83,8 +83,8 @@ void funca(void)
fb.f = 42;
fb.s = 19;
- bf = malloc (sizeof (foobar));
- bf->nothing = malloc (128);
+ bf = (foobar *) malloc (sizeof (foobar));
+ bf->nothing = (char *) malloc (128);
bf->nothing = "Bar Foo";
bf->f = 24;
bf->s = 91;
diff --git a/gdb/testsuite/gdb.python/py-framefilter.c b/gdb/testsuite/gdb.python/py-framefilter.c
index d98005f0e46..675a0c5ac99 100644
--- a/gdb/testsuite/gdb.python/py-framefilter.c
+++ b/gdb/testsuite/gdb.python/py-framefilter.c
@@ -84,8 +84,8 @@ void funca(void)
fb.f = 42;
fb.s = 19;
- bf = alloca (sizeof (foobar));
- bf->nothing = alloca (128);
+ bf = (foobar *) alloca (sizeof (foobar));
+ bf->nothing = (char *) alloca (128);
bf->nothing = "Bar Foo";
bf->f = 24;
bf->s = 91;
@@ -112,8 +112,8 @@ int func2(int f)
fb.f = 84;
fb.s = 38;
- bf = alloca (sizeof (foobar));
- bf->nothing = alloca (128);
+ bf = (foobar *) alloca (sizeof (foobar));
+ bf->nothing = (char *) alloca (128);
bf->nothing = "Elided Bar Foo";
bf->f = 48;
bf->s = 182;
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 13/18] gdb.base/{prologue,symbol-alias}.exp C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (9 preceding siblings ...)
2020-09-14 0:14 ` [RFC 11/18] gdb.python/{py-framefilter-mi,py-framefilter}.c C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 14/18] gdb.base/share-env-with-gdbserver.exp C++ify Pedro Alves
` (6 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
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/gdb.base/prologue.c | 6 ++++++
gdb/testsuite/gdb.base/prologue.exp | 2 +-
gdb/testsuite/gdb.base/symbol-alias.exp | 2 +-
gdb/testsuite/gdb.base/symbol-alias2.c | 6 ++++++
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/gdb.base/prologue.c b/gdb/testsuite/gdb.base/prologue.c
index c7de9162936..717bd3f106e 100644
--- a/gdb/testsuite/gdb.base/prologue.c
+++ b/gdb/testsuite/gdb.base/prologue.c
@@ -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 ();
diff --git a/gdb/testsuite/gdb.base/prologue.exp b/gdb/testsuite/gdb.base/prologue.exp
index ee834884735..20ab22efb9e 100644
--- a/gdb/testsuite/gdb.base/prologue.exp
+++ b/gdb/testsuite/gdb.base/prologue.exp
@@ -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"
diff --git a/gdb/testsuite/gdb.base/symbol-alias.exp b/gdb/testsuite/gdb.base/symbol-alias.exp
index fcdcce2b702..1907cad478d 100644
--- a/gdb/testsuite/gdb.base/symbol-alias.exp
+++ b/gdb/testsuite/gdb.base/symbol-alias.exp
@@ -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}"
}
diff --git a/gdb/testsuite/gdb.base/symbol-alias2.c b/gdb/testsuite/gdb.base/symbol-alias2.c
index e53c212607e..2c6185f4516 100644
--- a/gdb/testsuite/gdb.base/symbol-alias2.c
+++ b/gdb/testsuite/gdb.base/symbol-alias2.c
@@ -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)
{
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 14/18] gdb.base/share-env-with-gdbserver.exp C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (10 preceding siblings ...)
2020-09-14 0:14 ` [RFC 13/18] gdb.base/{prologue,symbol-alias}.exp C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 15/18] gdb.base/sizeof.exp C++ify Pedro Alves
` (5 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
---
gdb/testsuite/gdb.base/share-env-with-gdbserver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
index 17e95756a0a..a153f774fca 100644
--- a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
+++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
@@ -30,7 +30,7 @@ int
main (int argc, char *argv[])
{
/* Call malloc to ensure it is linked in. */
- char *tmp = malloc (1);
+ char *tmp = (char *) malloc (1);
/* Similarly call my_getenv instead of getenv directly to make sure
the former isn't optimized out. my_getenv is called by GDB. */
const char *myvar = my_getenv ("GDB_TEST_VAR");
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 15/18] gdb.base/sizeof.exp C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (11 preceding siblings ...)
2020-09-14 0:14 ` [RFC 14/18] gdb.base/share-env-with-gdbserver.exp C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 16/18] gdb.python/py-as-string.exp C++ify Pedro Alves
` (4 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
Fixes:
src/gdb/testsuite/gdb.base/sizeof.c:54:9: error: cannot initialize a variable of type 'char *' with an lvalue of type 'void *'
---
gdb/testsuite/gdb.base/sizeof.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/sizeof.c b/gdb/testsuite/gdb.base/sizeof.c
index fde52139ef8..4cf8c55898b 100644
--- a/gdb/testsuite/gdb.base/sizeof.c
+++ b/gdb/testsuite/gdb.base/sizeof.c
@@ -51,7 +51,7 @@ struct {
static void
fill (void *buf, long sizeof_buf)
{
- char *p = buf;
+ char *p = (char *) buf;
int i;
for (i = 0; i < sizeof_buf; i++)
p[i] = "The quick brown dingo jumped over the layzy dog."[i];
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 16/18] gdb.python/py-as-string.exp C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (12 preceding siblings ...)
2020-09-14 0:14 ` [RFC 15/18] gdb.base/sizeof.exp C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 17/18] gdb.python/py-frame-inline.exp and C++ Pedro Alves
` (3 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
---
gdb/testsuite/gdb.python/py-as-string.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.python/py-as-string.c b/gdb/testsuite/gdb.python/py-as-string.c
index 7780a9c93c2..245bcb286bd 100644
--- a/gdb/testsuite/gdb.python/py-as-string.c
+++ b/gdb/testsuite/gdb.python/py-as-string.c
@@ -23,7 +23,7 @@ enum EnumType {
};
static enum EnumType enum_valid = ENUM_VALUE_B;
-static enum EnumType enum_invalid = 20;
+static enum EnumType enum_invalid = (enum EnumType) 20;
int
main ()
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 17/18] gdb.python/py-frame-inline.exp and C++
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (13 preceding siblings ...)
2020-09-14 0:14 ` [RFC 16/18] gdb.python/py-as-string.exp C++ify Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 0:14 ` [RFC 18/18] gdb.cp/call-c.exp C++ify Pedro Alves
` (2 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
---
gdb/testsuite/gdb.python/py-frame-inline.exp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.python/py-frame-inline.exp b/gdb/testsuite/gdb.python/py-frame-inline.exp
index 71bffd375db..2b3d8e2b0e1 100644
--- a/gdb/testsuite/gdb.python/py-frame-inline.exp
+++ b/gdb/testsuite/gdb.python/py-frame-inline.exp
@@ -54,4 +54,4 @@ gdb_test "python print (gdb.newest_frame())" ".*"
# Regression test to verify that Frame.function works properly for
# inline frames.
-gdb_test "python print (gdb.newest_frame().function())" "f"
+gdb_test "python print (gdb.newest_frame().function())" "f(\\(\\))?"
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC 18/18] gdb.cp/call-c.exp C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (14 preceding siblings ...)
2020-09-14 0:14 ` [RFC 17/18] gdb.python/py-frame-inline.exp and C++ Pedro Alves
@ 2020-09-14 0:14 ` Pedro Alves
2020-09-14 20:18 ` [RFC 00/18] Allow building (more) C tests with a C++ compiler Tom Tromey
2020-09-16 11:38 ` [RESEND][RFC 01/18] gdb.base/find.exp C++ify Pedro Alves
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-14 0:14 UTC (permalink / raw)
To: gdb-patches
---
gdb/testsuite/gdb.cp/call-c-1.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gdb/testsuite/gdb.cp/call-c-1.c b/gdb/testsuite/gdb.cp/call-c-1.c
index 5d3d019672d..fa79f0311bc 100644
--- a/gdb/testsuite/gdb.cp/call-c-1.c
+++ b/gdb/testsuite/gdb.cp/call-c-1.c
@@ -15,4 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#ifdef __cplusplus
+extern "C"
+#endif
int foo(int x) { return x; }
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC 00/18] Allow building (more) C tests with a C++ compiler
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (15 preceding siblings ...)
2020-09-14 0:14 ` [RFC 18/18] gdb.cp/call-c.exp C++ify Pedro Alves
@ 2020-09-14 20:18 ` Tom Tromey
2020-09-16 11:39 ` Pedro Alves
2020-09-16 11:38 ` [RESEND][RFC 01/18] gdb.base/find.exp C++ify Pedro Alves
17 siblings, 1 reply; 21+ messages in thread
From: Tom Tromey @ 2020-09-14 20:18 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:
Pedro> We already have some tests under gdb.base/ that explicitly test both C
Pedro> and C++ modes, like align-c.exp/align-c++.exp and others. I propose
Pedro> allowing some more tests to run in C++ mode.
Seems fine to me. I skimmed a few patches and what I saw seemed
reasonable enough.
I didn't see patch #1 for whatever reason.
Tom
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RESEND][RFC 01/18] gdb.base/find.exp C++ify
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
` (16 preceding siblings ...)
2020-09-14 20:18 ` [RFC 00/18] Allow building (more) C tests with a C++ compiler Tom Tromey
@ 2020-09-16 11:38 ` Pedro Alves
17 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-16 11:38 UTC (permalink / raw)
To: gdb-patches
[For some reason, this patch didn't make it to the archives. Resending.]
We need #include <string.h> for memset.
---
gdb/testsuite/gdb.base/find.c | 3 ++-
gdb/testsuite/gdb.base/find.exp | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/find.c b/gdb/testsuite/gdb.base/find.c
index b97eb129883..d9db06790f2 100644
--- a/gdb/testsuite/gdb.base/find.c
+++ b/gdb/testsuite/gdb.base/find.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdint.h>
+#include <string.h>
/* According to C99 <stdint.h> has to provide these identifiers as
types, but is also free to define macros shadowing the typedefs.
@@ -54,7 +55,7 @@ static void
init_bufs ()
{
search_buf_size = BUF_SIZE;
- search_buf = malloc (search_buf_size);
+ search_buf = (char *) malloc (search_buf_size);
if (search_buf == NULL)
exit (1);
memset (search_buf, 'x', search_buf_size);
diff --git a/gdb/testsuite/gdb.base/find.exp b/gdb/testsuite/gdb.base/find.exp
index ad512d51c78..6e11b776b8b 100644
--- a/gdb/testsuite/gdb.base/find.exp
+++ b/gdb/testsuite/gdb.base/find.exp
@@ -42,6 +42,9 @@ set two_patterns_found "${newline}2 patterns found\[.\]"
# Test string pattern.
+# For when the testcase is built in C++ mode.
+gdb_test_no_output "set print asm-demangle on"
+
gdb_test_no_output "set *(int32_t*) &int8_search_buf\[10\] = 0x61616161" ""
gdb_test "find &int8_search_buf\[0\], +sizeof(int8_search_buf), 'a', 'a', 'a'" \
--
2.14.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC 00/18] Allow building (more) C tests with a C++ compiler
2020-09-14 20:18 ` [RFC 00/18] Allow building (more) C tests with a C++ compiler Tom Tromey
@ 2020-09-16 11:39 ` Pedro Alves
2020-09-17 23:11 ` Pedro Alves
0 siblings, 1 reply; 21+ messages in thread
From: Pedro Alves @ 2020-09-16 11:39 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 9/14/20 9:18 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:
>
> Pedro> We already have some tests under gdb.base/ that explicitly test both C
> Pedro> and C++ modes, like align-c.exp/align-c++.exp and others. I propose
> Pedro> allowing some more tests to run in C++ mode.
>
> Seems fine to me. I skimmed a few patches and what I saw seemed
> reasonable enough.
Awesome, thanks.
> I didn't see patch #1 for whatever reason.
Curious. I don't see it in the archives, but I did get a copy
via the mailing list. Anyhow, I've resent it now:
https://sourceware.org/pipermail/gdb-patches/2020-September/171893.html
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFC 00/18] Allow building (more) C tests with a C++ compiler
2020-09-16 11:39 ` Pedro Alves
@ 2020-09-17 23:11 ` Pedro Alves
0 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2020-09-17 23:11 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 9/16/20 12:39 PM, Pedro Alves wrote:
> On 9/14/20 9:18 PM, Tom Tromey wrote:
>>>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:
>>
>> Pedro> We already have some tests under gdb.base/ that explicitly test both C
>> Pedro> and C++ modes, like align-c.exp/align-c++.exp and others. I propose
>> Pedro> allowing some more tests to run in C++ mode.
>>
>> Seems fine to me. I skimmed a few patches and what I saw seemed
>> reasonable enough.
>
> Awesome, thanks.
I went ahead and wrote ChangeLogs & merged it. I figure it's not worth
it to repost just for ChangeLogs.
Thanks again.
Pedro Alves
>
>> I didn't see patch #1 for whatever reason.
>
> Curious. I don't see it in the archives, but I did get a copy
> via the mailing list. Anyhow, I've resent it now:
>
> https://sourceware.org/pipermail/gdb-patches/2020-September/171893.html
>
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2020-09-17 23:11 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 0:14 [RFC 00/18] Allow building (more) C tests with a C++ compiler Pedro Alves
2020-09-14 0:14 ` [RFC 02/18] gdb.base/display.exp C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 03/18] gdb.base/break.exp C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 04/18] gdb.base/nested-addr.exp C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 05/18] gdb.base/examine-backward.exp C++ify and Clang Pedro Alves
2020-09-14 0:14 ` [RFC 06/18] gdb.base/printcmds.c C++-ify Pedro Alves
2020-09-14 0:14 ` [RFC 07/18] gdb.base/watchpoint.{c,exp} Pedro Alves
2020-09-14 0:14 ` [RFC 08/18] gdb.base/charset.exp C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 09/18] gdb.base/{exprs,ptype,ptype1,setvar,whatis}.c C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 10/18] gdb.mi/var-cmd.c C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 11/18] gdb.python/{py-framefilter-mi,py-framefilter}.c C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 13/18] gdb.base/{prologue,symbol-alias}.exp C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 14/18] gdb.base/share-env-with-gdbserver.exp C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 15/18] gdb.base/sizeof.exp C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 16/18] gdb.python/py-as-string.exp C++ify Pedro Alves
2020-09-14 0:14 ` [RFC 17/18] gdb.python/py-frame-inline.exp and C++ Pedro Alves
2020-09-14 0:14 ` [RFC 18/18] gdb.cp/call-c.exp C++ify Pedro Alves
2020-09-14 20:18 ` [RFC 00/18] Allow building (more) C tests with a C++ compiler Tom Tromey
2020-09-16 11:39 ` Pedro Alves
2020-09-17 23:11 ` Pedro Alves
2020-09-16 11:38 ` [RESEND][RFC 01/18] gdb.base/find.exp C++ify Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).