Two logging fixes to win32-low.cc

Message ID 20260901192455.3344494-1-tromey@adacore.com
State New
Headers
Series Two logging fixes to win32-low.cc |

Checks

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

Commit Message

Tom Tromey Sept. 1, 2026, 7:24 p.m. UTC
  While debugging the Windows gdbserver, I found a couple of minor
problems in some logging statements in win32-low.cc.

First, one spot could call target_waitstatus::sig for the wrong kind
of object, resulting in an assertion failure.

Second, the "unknown" logging case can be made a bit nicer by printing
a string rather than an integer.
---
 gdbserver/win32-low.cc | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)


base-commit: 6f24afa4391bd33f1263378280b99385d2c13055
  

Comments

Andrew Burgess Sept. 1, 2026, 7:34 p.m. UTC | #1
Tom Tromey <tromey@adacore.com> writes:

> While debugging the Windows gdbserver, I found a couple of minor
> problems in some logging statements in win32-low.cc.
>
> First, one spot could call target_waitstatus::sig for the wrong kind
> of object, resulting in an assertion failure.
>
> Second, the "unknown" logging case can be made a bit nicer by printing
> a string rather than an integer.

LGTM.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

> ---
>  gdbserver/win32-low.cc | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
> index 7629beca213..13c14a7c69f 100644
> --- a/gdbserver/win32-low.cc
> +++ b/gdbserver/win32-low.cc
> @@ -1168,8 +1168,11 @@ win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
>  	case TARGET_WAITKIND_SIGNALLED:
>  	case TARGET_WAITKIND_LOADED:
>  	  {
> -	    OUTMSG2 (("Child Stopped with signal = %d \n",
> -		      ourstatus->sig ()));
> +	    if (ourstatus->kind () == TARGET_WAITKIND_LOADED)
> +	      OUTMSG2 (("Child stopped due to library load\n"));
> +	    else
> +	      OUTMSG2 (("Child stopped with signal = %d \n",
> +			ourstatus->sig ()));
>  	    maybe_adjust_pc (current_event);
>  
>  	    /* All-stop, suspend all threads until they are explicitly
> @@ -1179,8 +1182,8 @@ win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
>  	    return debug_event_ptid (&current_event);
>  	  }
>  	default:
> -	  OUTMSG (("Ignoring unknown internal event, %d\n",
> -		  ourstatus->kind ()));
> +	  OUTMSG (("Ignoring unknown internal event, %s\n",
> +		   ourstatus->to_string ().c_str ()));
>  	  [[fallthrough]];
>  	case TARGET_WAITKIND_SPURIOUS:
>  	  /* do nothing, just continue */
>
> base-commit: 6f24afa4391bd33f1263378280b99385d2c13055
> -- 
> 2.55.0
  

Patch

diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 7629beca213..13c14a7c69f 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1168,8 +1168,11 @@  win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
 	case TARGET_WAITKIND_SIGNALLED:
 	case TARGET_WAITKIND_LOADED:
 	  {
-	    OUTMSG2 (("Child Stopped with signal = %d \n",
-		      ourstatus->sig ()));
+	    if (ourstatus->kind () == TARGET_WAITKIND_LOADED)
+	      OUTMSG2 (("Child stopped due to library load\n"));
+	    else
+	      OUTMSG2 (("Child stopped with signal = %d \n",
+			ourstatus->sig ()));
 	    maybe_adjust_pc (current_event);
 
 	    /* All-stop, suspend all threads until they are explicitly
@@ -1179,8 +1182,8 @@  win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
 	    return debug_event_ptid (&current_event);
 	  }
 	default:
-	  OUTMSG (("Ignoring unknown internal event, %d\n",
-		  ourstatus->kind ()));
+	  OUTMSG (("Ignoring unknown internal event, %s\n",
+		   ourstatus->to_string ().c_str ()));
 	  [[fallthrough]];
 	case TARGET_WAITKIND_SPURIOUS:
 	  /* do nothing, just continue */