Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/testsuite] Fix gdb.mi/mi-info-sources.exp for extra debug info
Date: Mon, 12 Jul 2021 13:15:12 +0200	[thread overview]
Message-ID: <60e9b0a9-15a6-7e76-6ae1-c8352ab3f877@suse.de> (raw)
In-Reply-To: <20210705155244.GA18313@delia>

[-- Attachment #1: Type: text/plain, Size: 148 bytes --]

On 7/5/21 5:52 PM, Tom de Vries wrote:

I ended up pushing this patch, which takes care of more problems with
various target boards.

Thanks,
- Tom

[-- Attachment #2: 0001-gdb-testsuite-Fix-gdb.mi-mi-info-sources.exp-for-extra-debug-info.patch --]
[-- Type: text/x-patch, Size: 7002 bytes --]

[gdb/testsuite] Fix gdb.mi/mi-info-sources.exp for extra debug info

When running test-case gdb.mi/mi-info-sources.exp, I run into:
...
Running src/gdb/testsuite/gdb.mi/mi-info-sources.exp ...
ERROR: internal buffer is full.
...
due to extra debug info from the shared libraries.

Fix this by using "nosharedlibrary".

Then I run into these FAILs:
...
FAIL: gdb.mi/mi-info-sources.exp: debug_read=false: \
  -file-list-exec-source-files (unexpected output)
FAIL: gdb.mi/mi-info-sources.exp: debug_read=true: \
  -file-list-exec-source-files (unexpected output)
FAIL: gdb.mi/mi-info-sources.exp: debug_read=true: \
  -file-list-exec-source-files --group-by-objfile, look for \
  mi-info-sources.c (unexpected output)
FAIL: gdb.mi/mi-info-sources.exp: debug_read=true: \
  -file-list-exec-source-files --group-by-objfile, look for \
  mi-info-sources-base.c (unexpected output)
...
due to openSUSE executables which have debug info for objects from sources
like sysdeps/x86_64/crtn.S.

Fix these by updating the patterns, and adding "maint expand-symtabs" to
reliably get fully-read objfiles.

Then I run into FAILs when using the readnow target board.  Fix these by
skipping the relevant tests.

Then I run into FAILs when using the cc-with-gnu-debuglink board.  Fix these
by updating the patterns.

Tested on x86_64-linux, with native, check-read1, readnow, cc-with-gdb-index,
cc-with-debug-names, cc-with-gnu-debuglink, cc-with-dwz, cc-with-dwz-m.

gdb/testsuite/ChangeLog:

2021-07-05  Tom de Vries  <tdevries@suse.de>

	* lib/mi-support.exp (mi_readnow): New proc.
	* gdb.mi/mi-info-sources.exp: Use nosharedlibrary.  Update patterns.
	Skip tests for readnow.  Use "maint expand-symtabs".

---
 gdb/testsuite/gdb.mi/mi-info-sources.exp | 73 ++++++++++++++++++++++----------
 gdb/testsuite/lib/mi-support.exp         | 28 ++++++++++++
 2 files changed, 79 insertions(+), 22 deletions(-)

diff --git a/gdb/testsuite/gdb.mi/mi-info-sources.exp b/gdb/testsuite/gdb.mi/mi-info-sources.exp
index c4d6b910ef8..a43e939063a 100644
--- a/gdb/testsuite/gdb.mi/mi-info-sources.exp
+++ b/gdb/testsuite/gdb.mi/mi-info-sources.exp
@@ -28,8 +28,14 @@ if {[prepare_for_testing $testfile.exp $testfile \
 
 mi_clean_restart $binfile
 
+set readnow_p [mi_readnow]
+
 mi_runto_main
 
+# Unload symbols for shared libraries to prevent
+# 'ERROR: internal buffer is full'.
+mi_gdb_test "nosharedlibrary" ".*\\^done" "nosharedlibrary"
+
 # Helper to build expected MI output pattern for a list.  NAME is the
 # name of the list (which can be the empty string) and args is one
 # or more strings representing the fields of the list, which will be
@@ -108,27 +114,45 @@ proc check_info_sources { debug_fully_read } {
     with_test_prefix "debug_read=${debug_fully_read}" {
 
 	if { $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 "debug-fully-read" "${debug_fully_read}"]] \
-		       [mi_tuple "" \
-			    [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
-			    [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
-			    [mi_field "debug-fully-read" "true"]]]
+	    set p1 \
+		[mi_list "files" \
+		     ".*" \
+		     [mi_tuple "" \
+			  [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 "debug-fully-read" "true"]] \
+		     ".*"]
 	} else {
-	    set p [mi_list "files" \
-		       [mi_tuple "" \
-			    [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
-			    [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
-			    [mi_field "debug-fully-read" "true"]] \
-		       [mi_tuple "" \
-			    [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 p1 \
+		[mi_list "files" \
+		     ".*" \
+		     [mi_tuple "" \
+			  [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 "debug-fully-read" "${debug_fully_read}"]] \
+		     ".*"]
 	}
-	mi_gdb_test "-file-list-exec-source-files" ".*\\^done,${p}" "-file-list-exec-source-files"
+
+	mi_gdb_test "-file-list-exec-source-files" ".*\\^done,${p1}" \
+	    "-file-list-exec-source-files, src1"
+	mi_gdb_test "-file-list-exec-source-files" ".*\\^done,${p2}" \
+	    "-file-list-exec-source-files, src2"
 
 	set p [mi_list "files" \
 		   [mi_tuple "" \
@@ -147,7 +171,7 @@ proc check_info_sources { debug_fully_read } {
 
 	set p [mi_list "files" \
 		   [mi_tuple "" \
-			[mi_field "filename" "\[^\"\]+/mi-info-sources"] \
+			[mi_field "filename" "\[^\"\]+/mi-info-sources(\.debug)?"] \
 			[mi_field "debug-info" "${debug_info}"] \
 			[mi_list "sources" \
 			     ".*" \
@@ -162,7 +186,7 @@ proc check_info_sources { debug_fully_read } {
 
 	set p [mi_list "files" \
 		   [mi_tuple "" \
-			[mi_field "filename" "\[^\"\]+/mi-info-sources"] \
+			[mi_field "filename" "\[^\"\]+/mi-info-sources(\.debug)?"] \
 			[mi_field "debug-info" "${debug_info}"] \
 			[mi_list "sources" \
 			     ".*" \
@@ -177,8 +201,13 @@ proc check_info_sources { debug_fully_read } {
     }
 }
 
-check_info_sources "false"
+if { ! $readnow_p } {
+    check_info_sources "false"
+}
 
 mi_continue_to "some_other_func"
 
+# Force "fully-read".
+mi_gdb_test "maint expand-symtabs"
+
 check_info_sources "true"
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index d1c87dc7517..78290031763 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -663,6 +663,34 @@ proc mi_gdb_load { arg } {
     return 0
 }
 
+# Return 1 if symbols were read in using -readnow.  Otherwise, return 0.
+# Based on readnow from lib/gdb.exp.
+
+proc mi_readnow { args } {
+    global mi_gdb_prompt
+
+    if { [llength $args] == 1 } {
+	set re [lindex $args 0]
+    } else {
+	set re ""
+    }
+
+    set readnow_p 0
+    set cmd "maint print objfiles $re"
+    send_gdb "$cmd\n"
+    gdb_expect {
+	-re ".gdb_index: faked for ..readnow.." {
+	    # Record that we've seen the above pattern.
+	    set readnow_p 1
+	    exp_continue
+	}
+	-re "\\^done\r\n$mi_gdb_prompt$" {
+	}
+    }
+
+    return $readnow_p
+}
+
 # mi_gdb_test COMMAND PATTERN MESSAGE [IPATTERN] -- send a command to gdb; 
 #   test the result.
 #

  reply	other threads:[~2021-07-12 11:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05 15:52 Tom de Vries
2021-07-12 11:15 ` Tom de Vries [this message]
2021-07-19  9:33   ` Andrew Burgess

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=60e9b0a9-15a6-7e76-6ae1-c8352ab3f877@suse.de \
    --to=tdevries@suse.de \
    --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