rtos: Destroy RTOS and fix memory leak
[openocd.git] / src / target / target.c
index 51fdff3425e0e630084690fefa1f234b9d3ccbc7..b77400c1f02b2dca2baf0564ffbf09edd40d7961 100644 (file)
@@ -94,6 +94,7 @@ extern struct target_type cortexr4_target;
 extern struct target_type arm11_target;
 extern struct target_type ls1_sap_target;
 extern struct target_type mips_m4k_target;
+extern struct target_type mips_mips64_target;
 extern struct target_type avr_target;
 extern struct target_type dsp563xx_target;
 extern struct target_type dsp5680xx_target;
@@ -110,6 +111,7 @@ extern struct target_type stm8_target;
 extern struct target_type riscv_target;
 extern struct target_type mem_ap_target;
 extern struct target_type esirisc_target;
+extern struct target_type arcv2_target;
 
 static struct target_type *target_types[] = {
        &arm7tdmi_target,
@@ -145,8 +147,10 @@ static struct target_type *target_types[] = {
        &riscv_target,
        &mem_ap_target,
        &esirisc_target,
+       &arcv2_target,
 #if BUILD_TARGET64
        &aarch64_target,
+       &mips_mips64_target,
 #endif
        NULL,
 };
@@ -215,6 +219,7 @@ static const Jim_Nvp nvp_target_event[] = {
        { .value = TARGET_EVENT_RESET_END,           .name = "reset-end" },
 
        { .value = TARGET_EVENT_EXAMINE_START, .name = "examine-start" },
+       { .value = TARGET_EVENT_EXAMINE_FAIL, .name = "examine-fail" },
        { .value = TARGET_EVENT_EXAMINE_END, .name = "examine-end" },
 
        { .value = TARGET_EVENT_DEBUG_HALTED, .name = "debug-halted" },
@@ -704,13 +709,17 @@ static int default_check_reset(struct target *target)
        return ERROR_OK;
 }
 
+/* Equvivalent Tcl code arp_examine_one is in src/target/startup.tcl
+ * Keep in sync */
 int target_examine_one(struct target *target)
 {
        target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_START);
 
        int retval = target->type->examine(target);
-       if (retval != ERROR_OK)
+       if (retval != ERROR_OK) {
+               target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_FAIL);
                return retval;
+       }
 
        target_call_event_callbacks(target, TARGET_EVENT_EXAMINE_END);
 
@@ -1680,7 +1689,7 @@ static int target_call_timer_callbacks_check_time(int checktime)
         * next item; initially, that's a standalone "root of the
         * list" variable. */
        struct target_timer_callback **callback = &target_timer_callbacks;
-       while (*callback) {
+       while (callback && *callback) {
                if ((*callback)->removed) {
                        struct target_timer_callback *p = *callback;
                        *callback = (*callback)->next;
@@ -2040,6 +2049,8 @@ static void target_destroy(struct target *target)
                target->smp = 0;
        }
 
+       rtos_destroy(target);
+
        free(target->gdb_port_override);
        free(target->type);
        free(target->trace_info);
@@ -2279,7 +2290,7 @@ static int target_read_buffer_default(struct target *target, target_addr_t addre
        return ERROR_OK;
 }
 
-int target_checksum_memory(struct target *target, target_addr_t address, uint32_t size, uint32_tcrc)
+int target_checksum_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t *crc)
 {
        uint8_t *buffer;
        int retval;
@@ -3336,8 +3347,8 @@ COMMAND_HANDLER(handle_mw_command)
        target_addr_t address;
        COMMAND_PARSE_ADDRESS(CMD_ARGV[0], address);
 
-       target_addr_t value;
-       COMMAND_PARSE_ADDRESS(CMD_ARGV[1], value);
+       uint64_t value;
+       COMMAND_PARSE_NUMBER(u64, CMD_ARGV[1], value);
 
        unsigned count = 1;
        if (CMD_ARGC == 3)
@@ -3636,14 +3647,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver
 
                                data = malloc(buf_cnt);
 
-                               /* Can we use 32bit word accesses? */
-                               int size = 1;
-                               int count = buf_cnt;
-                               if ((count % 4) == 0) {
-                                       size *= 4;
-                                       count /= 4;
-                               }
-                               retval = target_read_memory(target, image.sections[i].base_address, size, count, data);
+                               retval = target_read_buffer(target, image.sections[i].base_address, buf_cnt, data);
                                if (retval == ERROR_OK) {
                                        uint32_t t;
                                        for (t = 0; t < buf_cnt; t++) {
@@ -5162,7 +5166,6 @@ static int jim_target_wait_state(Jim_Interp *interp, int argc, Jim_Obj *const *a
                                "target: %s wait %s fails (%#s) %s",
                                target_name(target), n->name,
                                eObj, target_strerror_safe(e));
-               Jim_FreeNewObj(interp, eObj);
                return JIM_ERR;
        }
        return JIM_OK;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)