public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 1/5] gdb/testsuite: Fix style.exp failures on targets without argc/argv support
Date: Wed, 19 Apr 2023 13:30:42 -0600	[thread overview]
Message-ID: <20230419193046.548783-2-sandra@codesourcery.com> (raw)
In-Reply-To: <20230419193046.548783-1-sandra@codesourcery.com>

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


  reply	other threads:[~2023-04-19 19:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19 19:30 [PATCH 0/5] gdb/testsuite: Miscellaneous fixes Sandra Loosemore
2023-04-19 19:30 ` Sandra Loosemore [this message]
2023-04-19 19:30 ` [PATCH 2/5] gdb/testsuite: Fix style.exp failures on targets without libopcodes styling Sandra Loosemore
2023-04-21 14:37   ` Tom Tromey
2023-04-21 19:15     ` Sandra Loosemore
2023-04-19 19:30 ` [PATCH 3/5] gdb/testsuite: Adjust some testcases to allow Windows pathnames Sandra Loosemore
2023-04-21 14:44   ` Tom Tromey
2023-04-21 19:26     ` Sandra Loosemore
2023-04-22  0:11       ` Tom Tromey
2023-04-19 19:30 ` [PATCH 4/5] gdb/testsuite: Disable some tests that are broken on remote Windows host Sandra Loosemore
2023-04-21 14:46   ` Tom Tromey
2023-04-21 14:52   ` Tom Tromey
2023-04-21 19:33     ` Sandra Loosemore
2023-04-22  0:11       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230419193046.548783-2-sandra@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).