* [PATCH V3 1/4] gdb/testsuite: Fix style.exp failures on targets without argc/argv support
2023-09-01 3:22 [PATCH V3 0/4] gdb/testsuite: Miscellaneous fixes Sandra Loosemore
@ 2023-09-01 3:22 ` Sandra Loosemore
2023-09-01 3:22 ` [PATCH V3 2/4] gdb/testsuite: Adjust some testcases to allow Windows pathnames Sandra Loosemore
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Sandra Loosemore @ 2023-09-01 3:22 UTC (permalink / raw)
To: gdb-patches
Some embedded targets don't have full support for argc/argv. argv
may print as "0x0" or as an address with a symbol name following.
This causes problems for the regexps in the style.exp line-wrapping
tests that assume it always prints as an ordinary address in backtrace
output.
This patch generalizes the regexps to handle these additional forms
and reworks some of the line-wrapping tests to account for the argv
address string being shorter or longer than a regular address.
Reviewed-By: Tom Tromey <tom@tromey.com>
---
gdb/testsuite/gdb.base/style.exp | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 0370550d251..60f909e2402 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -92,7 +92,7 @@ proc run_style_tests { } {
set argv ""
gdb_test_multiple "frame" "frame without styling" {
- -re -wrap "main \\(argc=.*, (argv=$hex)\\).*style\\.c:\[0-9\].*" {
+ -re -wrap "main \\(argc=.*, (argv=$hex.*)\\).*style\\.c:\[0-9\].*" {
set argv $expect_out(1,string)
pass $gdb_test_name
}
@@ -105,9 +105,13 @@ proc run_style_tests { } {
set file_expr "$base_file_expr:\[0-9\]+"
set arg_expr [limited_style "arg." variable]
+ # On some embedded targets that don't fully support argc/argv,
+ # argv may print as "0x0" or as an address with a symbol name
+ # following, so use a regexp general enough to match that and
+ # do not make assumptions about how long the address string is.
gdb_test "frame" \
[multi_line \
- "#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex\\)\\s+at\\s+$file_expr" \
+ "#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex.*\\)\\s+at\\s+$file_expr" \
"\[0-9\]+\\s+.*return.* break here .*"]
gdb_test "info breakpoints" "$main_expr at $file_expr.*"
@@ -134,16 +138,21 @@ proc run_style_tests { } {
# the line listing; this is why the words from the source
# code are spelled out in the final result line of the
# test.
+ set re0_styled \
+ [multi_line \
+ "#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex\\)" \
+ "\\s+at\\s+$file_expr" \
+ "\[0-9\]+\\s+.*return.* break here .*"]
set re1_styled \
[multi_line \
"#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+" \
- "\\s+$arg_expr=$hex\\)" \
+ "\\s+$arg_expr=$hex.*\\)" \
"\\s+at\\s+$file_expr" \
"\[0-9\]+\\s+.*return.* break here .*"]
set re2_styled \
[multi_line \
"#0\\s+$main_expr\\s+\\($arg_expr=.*" \
- "\\s+$arg_expr=$hex\\)\\s+at\\s+$file_expr" \
+ "\\s+$arg_expr=$hex.*\\)\\s+at\\s+$file_expr" \
"\[0-9\]+\\s+.*return.* break here .*"]
# The length of the line containing argv containing:
@@ -152,7 +161,11 @@ proc run_style_tests { } {
# - closing parenthesis
set line_len [expr 4 + $argv_len + 1]
- if { $line_len > $width } {
+ if { $argv == "argv=0x0" && $width >= 27 } {
+ # Embedded target with no argv support.
+ # #0 main (argc=0, argv=0x0)
+ set re_styled $re0_styled
+ } elseif { $line_len > $width } {
# At on the next line.
set re_styled $re1_styled
} else {
--
2.31.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V3 2/4] gdb/testsuite: Adjust some testcases to allow Windows pathnames
2023-09-01 3:22 [PATCH V3 0/4] gdb/testsuite: Miscellaneous fixes Sandra Loosemore
2023-09-01 3:22 ` [PATCH V3 1/4] gdb/testsuite: Fix style.exp failures on targets without argc/argv support Sandra Loosemore
@ 2023-09-01 3:22 ` Sandra Loosemore
2023-09-01 3:22 ` [PATCH V3 3/4] gdb/testsuite: Disable some tests that are broken on remote Windows host Sandra Loosemore
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Sandra Loosemore @ 2023-09-01 3:22 UTC (permalink / raw)
To: gdb-patches
This patch fixes some testcases that formerly had patterns with
hardwired "/" pathname separators in them, which broke when testing on
(remote) Windows host.
Reviewed-By: Tom Tromey <tom@tromey.com>
---
.../maint-expand-symbols-header-file.exp | 4 +--
gdb/testsuite/gdb.base/setshow.exp | 15 +++++++--
gdb/testsuite/gdb.dwarf2/dw2-filename.exp | 2 +-
gdb/testsuite/gdb.mi/mi-info-sources.exp | 32 +++++++++----------
4 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.exp b/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.exp
index d38d2ab7398..43b5aabea3c 100644
--- a/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.exp
+++ b/gdb/testsuite/gdb.base/maint-expand-symbols-header-file.exp
@@ -40,13 +40,13 @@ gdb_test_no_output "maint info symtabs" $test
gdb_test_no_output "maint expand-symtabs maint-expand-symbols-header-file.h"
# Check that the include symtab was in fact expanded.
-set file_re "\[^\r\n\]*/maint-expand-symbols-header-file.h"
+set file_re "\[^\r\n\]*maint-expand-symbols-header-file.h"
gdb_test "maint info symtabs" \
"\r\n\t{ symtab $file_re \\(\\(struct symtab \\*\\) $hex\\)\r\n.*" \
"check header file psymtab expansion"
# Check that the symtab the include symtab was referring to was expanded.
-set file_re "\[^\r\n\]*/maint-expand-symbols-header-file.c"
+set file_re "\[^\r\n\]*maint-expand-symbols-header-file.c"
gdb_test "maint info symtabs" \
"\r\n\t{ symtab $file_re \\(\\(struct symtab \\*\\) $hex\\)\r\n.*" \
"check source file psymtab expansion"
diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
index 8c160aa560e..ef01b6087f7 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -280,10 +280,21 @@ proc_with_prefix test_setshow_history {} {
#get home directory path
set HOME ""
+ set STRINGHOME ""
set test "show environment HOME"
gdb_test_multiple $test $test {
-re "\nHOME = (\[^\r\n\]*)\[\r\n\]+$::gdb_prompt $" {
set HOME $expect_out(1,string)
+ if { [ishost *-*-mingw*] } {
+ # STRINGHOME is how HOME prints with C string escapes.
+ # Specifically, all backslashes "\" in the pathname
+ # string have to be escaped as "\\". If you have other
+ # weird characters in your HOME pathname that need
+ # escaping too, maybe you shouldn't do that. :-P
+ regsub -all {\\} $HOME {\\\\} STRINGHOME
+ } else {
+ set STRINGHOME $HOME
+ }
pass $test
}
}
@@ -297,10 +308,10 @@ proc_with_prefix test_setshow_history {} {
"The filename in which to record the command history is \"[string_to_regexp $HOME]/foobar.baz\"..*" \
"show history filename (~/foobar.baz)"
gdb_test "p \$_gdb_setting(\"history filename\")" \
- " = \"[string_to_regexp $HOME]/foobar.baz\"" \
+ " = \"[string_to_regexp $STRINGHOME]/foobar.baz\"" \
"_gdb_setting history filename"
gdb_test "p \$_gdb_setting_str(\"history filename\")" \
- " = \"[string_to_regexp $HOME]/foobar.baz\"" \
+ " = \"[string_to_regexp $STRINGHOME]/foobar.baz\"" \
"_gdb_setting_str history filename"
#get current working directory
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-filename.exp b/gdb/testsuite/gdb.dwarf2/dw2-filename.exp
index 3bdac4c1cb8..c0ee3ac0d3f 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-filename.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-filename.exp
@@ -38,4 +38,4 @@ gdb_test "interpreter-exec mi -file-list-exec-source-files" \
".*{file=\"file1\\.txt\",fullname=\".+file1\\.txt\",debug-fully-read=\"\[^\"\]+\"}.*"
# And `info sources' should return the fullname incl. the directories.
-gdb_test "info sources" {[/]file1\.txt.*}
+gdb_test "info sources" {.+file1\.txt.*}
diff --git a/gdb/testsuite/gdb.mi/mi-info-sources.exp b/gdb/testsuite/gdb.mi/mi-info-sources.exp
index f639f3cdef9..3778ccb3fbe 100644
--- a/gdb/testsuite/gdb.mi/mi-info-sources.exp
+++ b/gdb/testsuite/gdb.mi/mi-info-sources.exp
@@ -118,16 +118,16 @@ proc check_info_sources { debug_fully_read } {
[mi_list "files" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources-base\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]] \
".*"]
set p2 \
[mi_list "files" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources\\.c"] \
[mi_field "debug-fully-read" "true"]] \
".*"]
} else {
@@ -135,16 +135,16 @@ proc check_info_sources { debug_fully_read } {
[mi_list "files" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources\\.c"] \
[mi_field "debug-fully-read" "true"]] \
".*"]
set p2 \
[mi_list "files" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources-base\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]] \
".*"]
}
@@ -156,8 +156,8 @@ proc check_info_sources { debug_fully_read } {
set p [mi_list "files" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources-base\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]]]
mi_gdb_test "-file-list-exec-source-files --basename -- base" ".*\\^done,${p}" \
"-file-list-exec-source-files --basename -- base"
@@ -171,13 +171,13 @@ proc check_info_sources { debug_fully_read } {
set p [mi_list "files" \
[mi_tuple "" \
- [mi_field "filename" "\[^\"\]+/mi-info-sources(\.debug)?"] \
+ [mi_field "filename" "\[^\"\]+mi-info-sources(\.debug)?"] \
[mi_field "debug-info" "${debug_info}"] \
[mi_list "sources" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources\\.c"] \
[mi_field "debug-fully-read" "true"]] \
".*"]]]
mi_gdb_test "-file-list-exec-source-files --group-by-objfile" \
@@ -186,13 +186,13 @@ proc check_info_sources { debug_fully_read } {
set p [mi_list "files" \
[mi_tuple "" \
- [mi_field "filename" "\[^\"\]+/mi-info-sources(\.debug)?"] \
+ [mi_field "filename" "\[^\"\]+mi-info-sources(\.debug)?"] \
[mi_field "debug-info" "${debug_info}"] \
[mi_list "sources" \
".*" \
[mi_tuple "" \
- [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
- [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
+ [mi_field "file" "\[^\"\]*mi-info-sources-base\\.c"] \
+ [mi_field "fullname" "\[^\"\]+mi-info-sources-base\\.c"] \
[mi_field "debug-fully-read" "${debug_fully_read}"]] \
".*"]]]
mi_gdb_test "-file-list-exec-source-files --group-by-objfile" \
--
2.31.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V3 3/4] gdb/testsuite: Disable some tests that are broken on remote Windows host
2023-09-01 3:22 [PATCH V3 0/4] gdb/testsuite: Miscellaneous fixes Sandra Loosemore
2023-09-01 3:22 ` [PATCH V3 1/4] gdb/testsuite: Fix style.exp failures on targets without argc/argv support Sandra Loosemore
2023-09-01 3:22 ` [PATCH V3 2/4] gdb/testsuite: Adjust some testcases to allow Windows pathnames Sandra Loosemore
@ 2023-09-01 3:22 ` Sandra Loosemore
2023-09-01 3:22 ` [PATCH V3 4/4] gdb/testsuite: Make hook-stop.exp ignore termination message from GDB stub Sandra Loosemore
2023-09-05 16:54 ` [PATCH V3 0/4] gdb/testsuite: Miscellaneous fixes Tom Tromey
4 siblings, 0 replies; 7+ messages in thread
From: Sandra Loosemore @ 2023-09-01 3:22 UTC (permalink / raw)
To: gdb-patches
These testcases assume host==build or that the remote host has a Posix
shell to run commands in. Don't try to run them if that's not the case.
Reviewed-By: Tom Tromey <tom@tromey.com>
---
gdb/testsuite/gdb.base/bad-file.exp | 3 +++
gdb/testsuite/gdb.base/early-init-file.exp | 3 +++
gdb/testsuite/gdb.base/empty-host-env-vars.exp | 3 +++
3 files changed, 9 insertions(+)
diff --git a/gdb/testsuite/gdb.base/bad-file.exp b/gdb/testsuite/gdb.base/bad-file.exp
index 5d8dfee8fea..5e050411f95 100644
--- a/gdb/testsuite/gdb.base/bad-file.exp
+++ b/gdb/testsuite/gdb.base/bad-file.exp
@@ -20,6 +20,9 @@
# print different text then the plan is to update the expected text
# instead of making this test linux-only or some such.
+# The pathnames and shell commands in this test don't work on Windows host.
+require {!ishost *-*-mingw*}
+
# There is no such file, but we still use the normal mechanism to pick
# its name and path.
standard_testfile
diff --git a/gdb/testsuite/gdb.base/early-init-file.exp b/gdb/testsuite/gdb.base/early-init-file.exp
index fcd1ff041a1..237439f9db7 100644
--- a/gdb/testsuite/gdb.base/early-init-file.exp
+++ b/gdb/testsuite/gdb.base/early-init-file.exp
@@ -15,6 +15,9 @@
# Test GDB's early init file mechanism.
+# Test assumes host == build.
+require {!is_remote host}
+
standard_testfile
# Compile the test executable.
diff --git a/gdb/testsuite/gdb.base/empty-host-env-vars.exp b/gdb/testsuite/gdb.base/empty-host-env-vars.exp
index 96240311c24..22f6b4d2ebe 100644
--- a/gdb/testsuite/gdb.base/empty-host-env-vars.exp
+++ b/gdb/testsuite/gdb.base/empty-host-env-vars.exp
@@ -13,6 +13,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# This test assumes host == build.
+require {!is_remote host}
+
# GDB reads some environment variables on startup, make sure it behaves
# correctly if these variables are defined but empty.
--
2.31.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V3 4/4] gdb/testsuite: Make hook-stop.exp ignore termination message from GDB stub
2023-09-01 3:22 [PATCH V3 0/4] gdb/testsuite: Miscellaneous fixes Sandra Loosemore
` (2 preceding siblings ...)
2023-09-01 3:22 ` [PATCH V3 3/4] gdb/testsuite: Disable some tests that are broken on remote Windows host Sandra Loosemore
@ 2023-09-01 3:22 ` Sandra Loosemore
2023-09-05 16:55 ` Tom Tromey
2023-09-05 16:54 ` [PATCH V3 0/4] gdb/testsuite: Miscellaneous fixes Tom Tromey
4 siblings, 1 reply; 7+ messages in thread
From: Sandra Loosemore @ 2023-09-01 3:22 UTC (permalink / raw)
To: gdb-patches
When a GDB stub is run via "target remote |", it sometimes produces
extra output that ends up mixed with GDB's own output. For example,
QEMU's built-in GDB stub responds to the vKill packet by printing
nios2-elf-qemu-system: QEMU: Terminated via GDBstub
before exiting.
This patch fixes the regexp in gdb.base/hook-stop.exp to allow such
messages between GDB's "continuing" and "Inferior killed" messages.
Reviewed-By: Tom Tromey <tom@tromey.com>
---
gdb/testsuite/gdb.base/hook-stop.exp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/hook-stop.exp b/gdb/testsuite/gdb.base/hook-stop.exp
index 0babd46aaea..50c5dfe9dc5 100644
--- a/gdb/testsuite/gdb.base/hook-stop.exp
+++ b/gdb/testsuite/gdb.base/hook-stop.exp
@@ -85,7 +85,7 @@ proc hook_stop_kill {} {
set test "run hook-stop"
gdb_test_multiple "continue" "$test" {
- -re "Continuing.\r\n\\\[Inferior $decimal \\(.*\\) killed\\\]\r\n${gdb_prompt} $" {
+ -re "Continuing.*\r\n\\\[Inferior $decimal \\(.*\\) killed\\\]\r\n${gdb_prompt} $" {
pass $test
}
}
--
2.31.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V3 0/4] gdb/testsuite: Miscellaneous fixes
2023-09-01 3:22 [PATCH V3 0/4] gdb/testsuite: Miscellaneous fixes Sandra Loosemore
` (3 preceding siblings ...)
2023-09-01 3:22 ` [PATCH V3 4/4] gdb/testsuite: Make hook-stop.exp ignore termination message from GDB stub Sandra Loosemore
@ 2023-09-05 16:54 ` Tom Tromey
4 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2023-09-05 16:54 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: gdb-patches
>>>>> "Sandra" == Sandra Loosemore <sandra@codesourcery.com> writes:
Sandra> This is a collection of patches we've had in our local tree for a
Sandra> while to fix various tests that are broken on nios2-elf and other
Sandra> embedded targets, and/or on remote Windows host. The last version was
Sandra> posted here
Sandra> https://sourceware.org/pipermail/gdb-patches/2023-April/199037.html
Sandra> and was reviewed by Tom Tromey, but not approved. I was busy with
Sandra> other things and neglected to keep pinging it, but let's try this again.
Sorry, I don't remember the state of this or why I didn't approve it.
Anyway I looked through this and I think it is fine.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread