[PATCHv2,1/3] gdb: don't try to style content in error calls

Message ID bc0485ade3896ca899db18a0a09b415d31d8df9b.1704206350.git.aburgess@redhat.com
State New
Headers
Series Changes to error reporting from the expression parser |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Patch failed to apply

Commit Message

Andrew Burgess Jan. 2, 2024, 2:43 p.m. UTC
  While working on a later commit in this series I realised that the
error() function doesn't support output styling.  Due to the way that
output from error() calls is passed around within the exception
object and often combined with other output, it's not immediately
obvious to me if we should be trying to support styling in this
context or not.

On inspection, I found two places in GDB where we apparently try to
apply styling within the error() output, however, both of these places
are in infrequently used (and likely untested) code.

So, rather than try to implement styling in the error() output, right
now I'm proposing to just remove these two attempts to style error()
output.

This doesn't mean that someone shouldn't add error() styling in the
future, but right now, I'm not planning to do that, so I just wanted
to fix these two mistakes as I saw them.
---
 gdb/procfs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

John Baldwin Jan. 3, 2024, 7:50 p.m. UTC | #1
On 1/2/24 6:43 AM, Andrew Burgess wrote:
> While working on a later commit in this series I realised that the
> error() function doesn't support output styling.  Due to the way that
> output from error() calls is passed around within the exception
> object and often combined with other output, it's not immediately
> obvious to me if we should be trying to support styling in this
> context or not.
> 
> On inspection, I found two places in GDB where we apparently try to
> apply styling within the error() output, however, both of these places
> are in infrequently used (and likely untested) code.
> 
> So, rather than try to implement styling in the error() output, right
> now I'm proposing to just remove these two attempts to style error()
> output.
> 
> This doesn't mean that someone shouldn't add error() styling in the
> future, but right now, I'm not planning to do that, so I just wanted
> to fix these two mistakes as I saw them.
> ---
>   gdb/procfs.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/gdb/procfs.c b/gdb/procfs.c
> index 1410bbc0d7d..0eafc2eddcc 100644
> --- a/gdb/procfs.c
> +++ b/gdb/procfs.c
> @@ -605,10 +605,8 @@ static void
>   proc_error (procinfo *pi, const char *func, int line)
>   {
>     int saved_errno = errno;
> -  error ("procfs: %s line %d, %ps: %s",
> -	 func, line, styled_string (file_name_style.style (),
> -				    pi->pathname),
> -	 safe_strerror (saved_errno));
> +  error ("procfs: %s line %d, %s: %s",
> +	 func, line, pi->pathname, safe_strerror (saved_errno));
>   }
>   
>   /* Updates the status struct in the procinfo.  There is a 'valid'

One nit: the log mentions two places in GDB, but the patch seems to only
fix one such place?
  

Patch

diff --git a/gdb/procfs.c b/gdb/procfs.c
index 1410bbc0d7d..0eafc2eddcc 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -605,10 +605,8 @@  static void
 proc_error (procinfo *pi, const char *func, int line)
 {
   int saved_errno = errno;
-  error ("procfs: %s line %d, %ps: %s",
-	 func, line, styled_string (file_name_style.style (),
-				    pi->pathname),
-	 safe_strerror (saved_errno));
+  error ("procfs: %s line %d, %s: %s",
+	 func, line, pi->pathname, safe_strerror (saved_errno));
 }
 
 /* Updates the status struct in the procinfo.  There is a 'valid'