This is an automated email from Gerrit.

"Marek Vrbka <marek.vr...@codasip.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7720

-- gerrit

commit 35c52e5789333a7a77bb9c2fbfa5ed53dd8ebbc1
Author: Marek Vrbka <marek.vr...@codasip.com>
Date:   Mon May 29 14:41:34 2023 +0200

    gdb_server: add debug signal reason prints
    
    Added debug prints to show what is the target debug reason. Also added
    debug print for Ctrl-C response. This is useful for troubleshooting and
    log analysis.
    
    Change-Id: I055936257d989efe7255656198a8d73a367fcd15
    Signed-off-by: Marek Vrbka <marek.vr...@codasip.com>

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 943fe40088..66132731c8 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -145,6 +145,9 @@ static char gdb_running_type;
 
 static int gdb_last_signal(struct target *target)
 {
+       LOG_TARGET_DEBUG(target, "Debug reason is: %s",
+                       target_debug_reason_str(target->debug_reason));
+
        switch (target->debug_reason) {
                case DBG_REASON_DBGRQ:
                        return 0x2;             /* SIGINT */
@@ -159,8 +162,9 @@ static int gdb_last_signal(struct target *target)
                case DBG_REASON_NOTHALTED:
                        return 0x0;             /* no signal... shouldn't 
happen */
                default:
-                       LOG_USER("undefined debug reason %d - target needs 
reset",
-                                       target->debug_reason);
+                       LOG_USER("undefined debug reason %d (%s) - target needs 
reset",
+                                       target->debug_reason,
+                                       
target_debug_reason_str(target->debug_reason));
                        return 0x0;
        }
 }
@@ -798,6 +802,8 @@ static void gdb_signal_reply(struct target *target, struct 
connection *connectio
                }
 
                if (gdb_connection->ctrl_c) {
+                       LOG_TARGET_DEBUG(target, "Responding with signal 2 
(SIGINT) "
+                                       "to debugger due to Ctrl-C");
                        signal_var = 0x2;
                } else
                        signal_var = gdb_last_signal(ct);
diff --git a/src/target/target.c b/src/target/target.c
index 0099292119..5858aa573b 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -7147,3 +7147,29 @@ static int target_register_user_commands(struct 
command_context *cmd_ctx)
 
        return register_commands(cmd_ctx, NULL, target_exec_command_handlers);
 }
+
+const char *target_debug_reason_str(enum target_debug_reason reason)
+{
+       switch (reason) {
+               case DBG_REASON_DBGRQ:
+                       return "DBGRQ";
+               case DBG_REASON_BREAKPOINT:
+                       return "BREAKPOINT";
+               case DBG_REASON_WATCHPOINT:
+                       return "WATCHPOINT";
+               case DBG_REASON_WPTANDBKPT:
+                       return "WPTANDBKPT";
+               case DBG_REASON_SINGLESTEP:
+                       return "SINGLESTEP";
+               case DBG_REASON_NOTHALTED:
+                       return "NOTHALTED";
+               case DBG_REASON_EXIT:
+                       return "EXIT";
+               case DBG_REASON_EXC_CATCH:
+                       return "EXC_CATCH";
+               case DBG_REASON_UNDEFINED:
+                       return "UNDEFINED";
+               default:
+                       return "UNKNOWN!";
+       }
+}
diff --git a/src/target/target.h b/src/target/target.h
index 2a2f5315ff..abeb8ed511 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -803,4 +803,6 @@ extern bool get_target_reset_nag(void);
 
 #define TARGET_DEFAULT_POLLING_INTERVAL                100
 
+const char *target_debug_reason_str(enum target_debug_reason reason);
+
 #endif /* OPENOCD_TARGET_TARGET_H */

-- 

Reply via email to