From c33be6de41550bf38ab08cd73936c4ea164bc736 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 12 Jul 2021 13:13:38 +0200 Subject: [PATCH] [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 * 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. # -- 2.30.2