]> www.infradead.org Git - users/borneoa/openocd-next.git/commitdiff
rtos/hwthread: Use LOG_TARGET_xxx()
authorMarc Schink <dev@zapb.de>
Sat, 7 Dec 2024 09:53:56 +0000 (10:53 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Tue, 11 Feb 2025 11:53:59 +0000 (11:53 +0000)
Use LOG_TARGET_xxx() to indicate which target the message belongs to.

While at it, fix some coding style issues.

Change-Id: Iac0296498557a689468a4a19d0bc64f03178a0d0
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8727
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
src/rtos/hwthread.c

index c9f1a179202d8cbc5b009c0240cbdaaba68aff58..6332bd8ad0882601cb7b50fff8bfe71de8dd1ed9 100644 (file)
@@ -119,7 +119,7 @@ static int hwthread_update_threads(struct rtos *rtos)
        if (current_threadid <= thread_list_size)
                rtos->current_threadid = current_threadid;
        else
-               LOG_WARNING("SMP node change, disconnect GDB from core/thread %" PRId64,
+               LOG_TARGET_WARNING(target, "SMP node change, disconnect GDB from core/thread %" PRId64,
                            current_threadid);
 
        /* create space for new thread details */
@@ -204,7 +204,8 @@ static int hwthread_update_threads(struct rtos *rtos)
        else
                rtos->current_thread = threadid_from_target(target);
 
-       LOG_DEBUG("%s current_thread=%i", __func__, (int)rtos->current_thread);
+       LOG_TARGET_DEBUG(target, "%s current_thread=%i", __func__,
+               (int)rtos->current_thread);
        return 0;
 }
 
@@ -270,7 +271,8 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
                if (!reg_list[i]->valid) {
                        retval = reg_list[i]->type->get(reg_list[i]);
                        if (retval != ERROR_OK) {
-                               LOG_ERROR("Couldn't get register %s.", reg_list[i]->name);
+                               LOG_TARGET_ERROR(curr, "Couldn't get register %s",
+                                       reg_list[i]->name);
                                free(reg_list);
                                free(*rtos_reg_list);
                                return retval;
@@ -297,7 +299,8 @@ static int hwthread_get_thread_reg(struct rtos *rtos, int64_t thread_id,
 
        struct target *curr = hwthread_find_thread(target, thread_id);
        if (!curr) {
-               LOG_ERROR("Couldn't find RTOS thread for id %" PRId64 ".", thread_id);
+               LOG_TARGET_ERROR(target, "Couldn't find RTOS thread for id %" PRId64,
+                       thread_id);
                return ERROR_FAIL;
        }
 
@@ -308,8 +311,8 @@ static int hwthread_get_thread_reg(struct rtos *rtos, int64_t thread_id,
 
        struct reg *reg = register_get_by_number(curr->reg_cache, reg_num, true);
        if (!reg) {
-               LOG_ERROR("Couldn't find register %" PRIu32 " in thread %" PRId64 ".", reg_num,
-                               thread_id);
+               LOG_TARGET_ERROR(curr, "Couldn't find register %" PRIu32 " in thread %" PRId64,
+                       reg_num, thread_id);
                return ERROR_FAIL;
        }
 
@@ -372,17 +375,17 @@ static bool hwthread_detect_rtos(struct target *target)
 
 static int hwthread_thread_packet(struct connection *connection, const char *packet, int packet_size)
 {
-       struct target *target = get_target_from_connection(connection);
-
-       struct target *curr = NULL;
-       int64_t current_threadid;
-
        if (packet[0] == 'H' && packet[1] == 'g') {
+               int64_t current_threadid;
                sscanf(packet, "Hg%16" SCNx64, &current_threadid);
 
+               struct target *target = get_target_from_connection(connection);
+
                if (current_threadid > 0) {
+                       struct target *curr = NULL;
                        if (hwthread_target_for_threadid(connection, current_threadid, &curr) != ERROR_OK) {
-                               LOG_ERROR("hwthread: cannot find thread id %"PRId64, current_threadid);
+                               LOG_TARGET_ERROR(target, "hwthread: cannot find thread id %" PRId64,
+                                       current_threadid);
                                gdb_put_packet(connection, "E01", 3);
                                return ERROR_FAIL;
                        }
@@ -402,7 +405,7 @@ static int hwthread_thread_packet(struct connection *connection, const char *pac
 
 static int hwthread_create(struct target *target)
 {
-       LOG_INFO("Hardware thread awareness created");
+       LOG_TARGET_INFO(target, "Hardware thread awareness created");
 
        target->rtos->rtos_specific_params = NULL;
        target->rtos->current_thread = 0;