public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp
@ 2023-07-21  9:58 Bruno Larsen
  2023-08-03 13:43 ` [PING][PATCH " Bruno Larsen
  2023-09-15  0:29 ` [PATCH " Kevin Buettner
  0 siblings, 2 replies; 7+ messages in thread
From: Bruno Larsen @ 2023-07-21  9:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Bruno Larsen, Andrew Burgess

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>
---
 gdb/testsuite/gdb.mi/mi-dprintf.exp | 11 ++++++++---
 gdb/testsuite/lib/mi-support.exp    | 14 ++++++++++++++
 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 e40fa6121fa..d771993386b 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 49d5e2ef272..468c481ab95 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -2883,3 +2883,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
+}
-- 
2.41.0


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

* [PING][PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp
  2023-07-21  9:58 [PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp Bruno Larsen
@ 2023-08-03 13:43 ` Bruno Larsen
  2023-08-10 13:52   ` [PINGv2][PATCH " Guinevere Larsen
  2023-09-15  0:29 ` [PATCH " Kevin Buettner
  1 sibling, 1 reply; 7+ messages in thread
From: Bruno Larsen @ 2023-08-03 13:43 UTC (permalink / raw)
  To: Bruno Larsen, Bruno Larsen via Gdb-patches

Ping!

-- 
Cheers,
Bruno

On 21/07/2023 11:58, Bruno Larsen wrote:
> 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>
> ---
>   gdb/testsuite/gdb.mi/mi-dprintf.exp | 11 ++++++++---
>   gdb/testsuite/lib/mi-support.exp    | 14 ++++++++++++++
>   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 e40fa6121fa..d771993386b 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 49d5e2ef272..468c481ab95 100644
> --- a/gdb/testsuite/lib/mi-support.exp
> +++ b/gdb/testsuite/lib/mi-support.exp
> @@ -2883,3 +2883,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
> +}


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

* [PINGv2][PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp
  2023-08-03 13:43 ` [PING][PATCH " Bruno Larsen
@ 2023-08-10 13:52   ` Guinevere Larsen
  2023-08-23  9:59     ` [PINGv3][PATCH " Guinevere Larsen
  0 siblings, 1 reply; 7+ messages in thread
From: Guinevere Larsen @ 2023-08-10 13:52 UTC (permalink / raw)
  To: Bruno Larsen, Bruno Larsen via Gdb-patches

Ping!

-- 
Cheers,
Guinevere Larsen
She/Her/Hers

On 03/08/2023 15:43, Bruno Larsen wrote:
> Ping!
>


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

* [PINGv3][PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp
  2023-08-10 13:52   ` [PINGv2][PATCH " Guinevere Larsen
@ 2023-08-23  9:59     ` Guinevere Larsen
  2023-09-14 13:03       ` [PINGv4][PATCH " Guinevere Larsen
  0 siblings, 1 reply; 7+ messages in thread
From: Guinevere Larsen @ 2023-08-23  9:59 UTC (permalink / raw)
  To: Guinevere Larsen, Bruno Larsen via Gdb-patches

On 10/08/2023 15:52, Guinevere Larsen wrote:
> Ping!
>
Ping!

-- 
Cheers,
Guinevere Larsen
She/Her/Hers


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

* [PINGv4][PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp
  2023-08-23  9:59     ` [PINGv3][PATCH " Guinevere Larsen
@ 2023-09-14 13:03       ` Guinevere Larsen
  0 siblings, 0 replies; 7+ messages in thread
From: Guinevere Larsen @ 2023-09-14 13:03 UTC (permalink / raw)
  To: Guinevere Larsen, Bruno Larsen via Gdb-patches

On 23/08/2023 11:59, Guinevere Larsen wrote:
> On 10/08/2023 15:52, Guinevere Larsen wrote:
>> Ping!
>>
> Ping!
>
Ping!

-- 
Cheers,
Guinevere Larsen
She/Her/Hers


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

* Re: [PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp
  2023-07-21  9:58 [PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp Bruno Larsen
  2023-08-03 13:43 ` [PING][PATCH " Bruno Larsen
@ 2023-09-15  0:29 ` Kevin Buettner
  2023-09-15  7:36   ` Guinevere Larsen
  1 sibling, 1 reply; 7+ messages in thread
From: Kevin Buettner @ 2023-09-15  0:29 UTC (permalink / raw)
  To: Bruno Larsen via Gdb-patches; +Cc: Bruno Larsen, Andrew Burgess

On Fri, 21 Jul 2023 11:58:10 +0200
Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org> wrote:

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

LGTM.

Approved-by: Kevin Buettner <kevinb@redhat.com>


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

* Re: [PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp
  2023-09-15  0:29 ` [PATCH " Kevin Buettner
@ 2023-09-15  7:36   ` Guinevere Larsen
  0 siblings, 0 replies; 7+ messages in thread
From: Guinevere Larsen @ 2023-09-15  7:36 UTC (permalink / raw)
  To: Kevin Buettner, Bruno Larsen via Gdb-patches; +Cc: Andrew Burgess

On 15/09/2023 02:29, Kevin Buettner wrote:
> On Fri, 21 Jul 2023 11:58:10 +0200
> Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org> wrote:
>
>> 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>
> LGTM.
>
> Approved-by: Kevin Buettner <kevinb@redhat.com>
>
Thanks pushed!

-- 
Cheers,
Guinevere Larsen
She/Her/Hers


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

end of thread, other threads:[~2023-09-15  7:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21  9:58 [PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp Bruno Larsen
2023-08-03 13:43 ` [PING][PATCH " Bruno Larsen
2023-08-10 13:52   ` [PINGv2][PATCH " Guinevere Larsen
2023-08-23  9:59     ` [PINGv3][PATCH " Guinevere Larsen
2023-09-14 13:03       ` [PINGv4][PATCH " Guinevere Larsen
2023-09-15  0:29 ` [PATCH " Kevin Buettner
2023-09-15  7:36   ` Guinevere Larsen

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