aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorGuinevere Larsen <blarsen@redhat.com>2023-07-14 17:43:41 +0200
committerGuinevere Larsen <blarsen@redhat.com>2023-09-15 09:33:42 +0200
commitf8bf778c811236ea93c1b325bb9a2f38f9276104 (patch)
treebfae6bb8cd342e7d1daf21693d8095be41dd4936 /gdb
parent95fc47d5c6b363b9b195baf1850b0ba95438ce69 (diff)
downloadgdb-f8bf778c811236ea93c1b325bb9a2f38f9276104.zip
gdb-f8bf778c811236ea93c1b325bb9a2f38f9276104.tar.gz
gdb-f8bf778c811236ea93c1b325bb9a2f38f9276104.tar.bz2
gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp
As mentioned in commit 3f5bbc3e2075ef5061a815c73fdc277218489f22, some compilers such as clang don't add debug information about stderr by default, leaving it to external debug packages. This commit adds a way to check if GDB has access to stderr information when in MI mode, and uses this new mechanism to skip the related section of the test gdb.mi/mi-dprintf.exp. It also fixes an incorrect name for a test in that file. Co-Authored-By: Andrew Burgess <aburgess@redhat.com> Approved-By: Kevin Buettner <kevinb@redhat.com>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/gdb.mi/mi-dprintf.exp11
-rw-r--r--gdb/testsuite/lib/mi-support.exp14
2 files changed, 22 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.mi/mi-dprintf.exp b/gdb/testsuite/gdb.mi/mi-dprintf.exp
index e40fa61..d771993 100644
--- a/gdb/testsuite/gdb.mi/mi-dprintf.exp
+++ b/gdb/testsuite/gdb.mi/mi-dprintf.exp
@@ -127,6 +127,7 @@ proc mi_continue_dprintf {args} {
mi_continue_dprintf "gdb"
# The "call" style depends on having I/O functions available, so test.
+set has_stderr_symbol [mi_gdb_is_stderr_available]
if ![target_info exists gdb,noinferiorio] {
@@ -136,9 +137,13 @@ if ![target_info exists gdb,noinferiorio] {
mi_gdb_test "set dprintf-style call" ".*" "mi set dprintf style to call"
mi_continue_dprintf "call"
- mi_gdb_test "set dprintf-function fprintf" ".*" "mi set dprintf-channel stderr"
- mi_gdb_test "set dprintf-channel stderr" ".*" "mi set dprintf channel"
- mi_continue_dprintf "fprintf"
+ # Some compilers don't add information about stderr,
+ # so skip these tests if needed.
+ if {$::has_stderr_symbol} {
+ mi_gdb_test "set dprintf-function fprintf" ".*" "mi set dprintf function"
+ mi_gdb_test "set dprintf-channel stderr" ".*" "mi set dprintf channel"
+ mi_continue_dprintf "fprintf"
+ }
}
set target_can_dprintf 0
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 872d93a..4c6deda 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -2942,3 +2942,17 @@ proc foreach_mi_ui_mode { var_name body } {
}
}
}
+
+# Check if GDB has information about the stderr symbol.
+proc mi_gdb_is_stderr_available {} {
+ set has_stderr_symbol false
+ gdb_test_multiple "-data-evaluate-expression stderr" "stderr symbol check" {
+ -re "\\^error,msg=\"'stderr' has unknown type; cast it to its declared type\"\r\n$::mi_gdb_prompt$" {
+ # Default value of false is fine.
+ }
+ -re "$::mi_gdb_prompt$" {
+ set has_stderr_symbol true
+ }
+ }
+ return $has_stderr_symbol
+}