public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH V2 0/5] gdb/testsuite: Miscelleanous fixes
@ 2023-04-23 19:31 Sandra Loosemore
  2023-04-23 19:31 ` [PATCH V2 1/5] gdb/testsuite: Fix style.exp failures on targets without argc/argv support Sandra Loosemore
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sandra Loosemore @ 2023-04-23 19:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom

Reposting this series, which now incorporates minor tweaks suggested by
Tom Tromey to parts 2, 3, and 4.  Parts 1 and 5 are unchanged.

OK for trunk?

-Sandra

Sandra Loosemore (5):
  gdb/testsuite: Fix style.exp failures on targets without argc/argv
    support
  gdb/testsuite: Fix style.exp failures on targets without libopcodes
    styling
  gdb/testsuite: Adjust some testcases to allow Windows pathnames
  gdb/testsuite: Disable some tests that are broken on remote Windows
    host
  gdb/testsuite: Make hook-stop.exp ignore termination message from GDB
    stub

 gdb/testsuite/gdb.base/bad-file.exp           |  3 ++
 gdb/testsuite/gdb.base/early-init-file.exp    |  3 ++
 .../gdb.base/empty-host-env-vars.exp          |  3 ++
 gdb/testsuite/gdb.base/hook-stop.exp          |  2 +-
 .../maint-expand-symbols-header-file.exp      |  4 +-
 gdb/testsuite/gdb.base/setshow.exp            | 17 +++++--
 gdb/testsuite/gdb.base/style.exp              | 49 ++++++++++++++++---
 gdb/testsuite/gdb.dwarf2/dw2-filename.exp     |  2 +-
 gdb/testsuite/gdb.mi/mi-info-sources.exp      | 32 ++++++------
 9 files changed, 86 insertions(+), 29 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 1/5] gdb/testsuite: Fix style.exp failures on targets without argc/argv support
  2023-04-23 19:31 [PATCH V2 0/5] gdb/testsuite: Miscelleanous fixes Sandra Loosemore
@ 2023-04-23 19:31 ` Sandra Loosemore
  2023-04-23 19:31 ` [PATCH V2 2/5] gdb/testsuite: Fix style.exp failures on targets without libopcodes styling Sandra Loosemore
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Sandra Loosemore @ 2023-04-23 19:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom

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.
---
 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] 5+ messages in thread

* [PATCH V2 2/5] gdb/testsuite: Fix style.exp failures on targets without libopcodes styling
  2023-04-23 19:31 [PATCH V2 0/5] gdb/testsuite: Miscelleanous fixes Sandra Loosemore
  2023-04-23 19:31 ` [PATCH V2 1/5] gdb/testsuite: Fix style.exp failures on targets without argc/argv support Sandra Loosemore
@ 2023-04-23 19:31 ` Sandra Loosemore
  2023-04-23 19:31 ` [PATCH V2 3/5] gdb/testsuite: Adjust some testcases to allow Windows pathnames Sandra Loosemore
  2023-04-24 17:16 ` [PATCH V2 0/5] gdb/testsuite: Miscelleanous fixes Tom Tromey
  3 siblings, 0 replies; 5+ messages in thread
From: Sandra Loosemore @ 2023-04-23 19:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom

Do not expect disassembler output to be styled by libopcodes if GDB
reports the target does not support that.
---
 gdb/testsuite/gdb.base/style.exp | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 60f909e2402..94c9dc46d73 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -24,6 +24,26 @@ if {[build_executable "failed to build" $testfile $srcfile {debug macros}]} {
     return -1
 }
 
+# Check whether libopcodes styling is supported for this target.
+set have_libopcodes_styling 1
+proc test_for_libopcodes_styling {} {
+  global binfile
+  global have_libopcodes_styling
+  clean_restart ${binfile}
+
+  gdb_test_multiple "maint set libopcodes-styling enabled on" "" {
+      -re "^maint set libopcodes-styling enabled on\r\n" {
+	  exp_continue
+      }
+      -re "Use of libopcodes styling not supported on architecture \[^\r\n\]+\r\n" {
+	  set have_libopcodes_styling 0
+	  exp_continue
+      }
+     -re "^$::gdb_prompt $" {
+     }
+  }
+}
+
 # The tests in this file are run multiple times with GDB's styles
 # disabled one at a time.  This variable is the style that is
 # currently disabled.
@@ -68,6 +88,7 @@ proc clean_restart_and_disable { prefix args } {
 proc run_style_tests { } {
     global testfile srcfile hex binfile
     global currently_disabled_style decimal hex
+    global have_libopcodes_styling
 
     save_vars { env(TERM) } {
 	# We need an ANSI-capable terminal to get the output.
@@ -195,7 +216,7 @@ proc run_style_tests { } {
 	# symbol will be styled.  However, if pygments is not being
 	# used then we can know how the symbol name will be styled.
 	set main [limited_style main function]
-	if { $::python_disassembly_styling } {
+	if { $::python_disassembly_styling || !$have_libopcodes_styling } {
 	    set func "some_called_function"
 	} else {
 	    set func [limited_style some_called_function function]
@@ -495,6 +516,9 @@ if {[allow_python_tests] && [gdb_py_module_available "pygments"]} {
     set python_disassembly_styling false
 }
 
+# Check to see if libopcodes styling is available for this target
+test_for_libopcodes_styling
+
 # Run tests with all styles in their default state.
 with_test_prefix "all styles enabled" {
     run_style_tests
-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 3/5] gdb/testsuite: Adjust some testcases to allow Windows pathnames
  2023-04-23 19:31 [PATCH V2 0/5] gdb/testsuite: Miscelleanous fixes Sandra Loosemore
  2023-04-23 19:31 ` [PATCH V2 1/5] gdb/testsuite: Fix style.exp failures on targets without argc/argv support Sandra Loosemore
  2023-04-23 19:31 ` [PATCH V2 2/5] gdb/testsuite: Fix style.exp failures on targets without libopcodes styling Sandra Loosemore
@ 2023-04-23 19:31 ` Sandra Loosemore
  2023-04-24 17:16 ` [PATCH V2 0/5] gdb/testsuite: Miscelleanous fixes Tom Tromey
  3 siblings, 0 replies; 5+ messages in thread
From: Sandra Loosemore @ 2023-04-23 19:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom

This patch fixes some testcases that formerly had patterns with
hardwired "/" pathname separators in them, which broke when testing on
(remote) Windows host.
---
 .../maint-expand-symbols-header-file.exp      |  4 +--
 gdb/testsuite/gdb.base/setshow.exp            | 17 ++++++++--
 gdb/testsuite/gdb.dwarf2/dw2-filename.exp     |  2 +-
 gdb/testsuite/gdb.mi/mi-info-sources.exp      | 32 +++++++++----------
 4 files changed, 33 insertions(+), 22 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 86821ca1db0..684e2b6c3a4 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
 	}
     }
@@ -294,13 +305,13 @@ proc_with_prefix test_setshow_history {} {
 
     #test show history filename ~/foobar.baz
     gdb_test "show history filename" \
-	"The filename in which to record the command history is \"[string_to_regexp $HOME]/foobar.baz\"..*" \
+	"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] 5+ messages in thread

* Re: [PATCH V2 0/5] gdb/testsuite: Miscelleanous fixes
  2023-04-23 19:31 [PATCH V2 0/5] gdb/testsuite: Miscelleanous fixes Sandra Loosemore
                   ` (2 preceding siblings ...)
  2023-04-23 19:31 ` [PATCH V2 3/5] gdb/testsuite: Adjust some testcases to allow Windows pathnames Sandra Loosemore
@ 2023-04-24 17:16 ` Tom Tromey
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2023-04-24 17:16 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: gdb-patches, tom

>>>>> "Sandra" == Sandra Loosemore <sandra@codesourcery.com> writes:

Sandra> Reposting this series, which now incorporates minor tweaks suggested by
Sandra> Tom Tromey to parts 2, 3, and 4.  Parts 1 and 5 are unchanged.

Sandra> OK for trunk?

Thank you.  This looks good to me.
Reviewed-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-24 17:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-23 19:31 [PATCH V2 0/5] gdb/testsuite: Miscelleanous fixes Sandra Loosemore
2023-04-23 19:31 ` [PATCH V2 1/5] gdb/testsuite: Fix style.exp failures on targets without argc/argv support Sandra Loosemore
2023-04-23 19:31 ` [PATCH V2 2/5] gdb/testsuite: Fix style.exp failures on targets without libopcodes styling Sandra Loosemore
2023-04-23 19:31 ` [PATCH V2 3/5] gdb/testsuite: Adjust some testcases to allow Windows pathnames Sandra Loosemore
2023-04-24 17:16 ` [PATCH V2 0/5] gdb/testsuite: Miscelleanous fixes Tom Tromey

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).