rtos: Support for "none" rtos
[fw/openocd] / src / rtos / rtos.c
index c9c4efd41be25aace93def82a3ed391ec4f9b451..3e43e828d1baeed460c5718c49e2b5849b04b1b7 100644 (file)
@@ -1,19 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
 /***************************************************************************
  *   Copyright (C) 2011 by Broadcom Corporation                            *
  *   Evan Hunter - ehunter@broadcom.com                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -140,6 +129,9 @@ int rtos_create(struct jim_getopt_info *goi, struct target *target)
        if (e != JIM_OK)
                return e;
 
+       if (strcmp(cp, "none") == 0)
+               return JIM_OK;
+
        if (strcmp(cp, "auto") == 0) {
                /* Auto detect tries to look up all symbols for each RTOS,
                 * and runs the RTOS driver's _detect() function when GDB
@@ -159,7 +151,7 @@ int rtos_create(struct jim_getopt_info *goi, struct target *target)
        res = Jim_GetResult(goi->interp);
        for (x = 0; rtos_types[x]; x++)
                Jim_AppendStrings(goi->interp, res, rtos_types[x]->name, ", ", NULL);
-       Jim_AppendStrings(goi->interp, res, " or auto", NULL);
+       Jim_AppendStrings(goi->interp, res, ", auto or none", NULL);
 
        return JIM_ERR;
 }
@@ -234,7 +226,7 @@ int rtos_qsymbol(struct connection *connection, char const *packet, int packet_s
        uint64_t addr = 0;
        size_t reply_len;
        char reply[GDB_BUFFER_SIZE + 1], cur_sym[GDB_BUFFER_SIZE / 2 + 1] = ""; /* Extra byte for null-termination */
-       struct symbol_table_elem *next_sym = NULL;
+       struct symbol_table_elem *next_sym;
        struct target *target = get_target_from_connection(connection);
        struct rtos *os = target->rtos;
 
@@ -266,8 +258,17 @@ int rtos_qsymbol(struct connection *connection, char const *packet, int packet_s
                        cur_sym[0] = '\x00';
                }
        }
+
+       LOG_DEBUG("RTOS: Address of symbol '%s' is 0x%" PRIx64, cur_sym, addr);
+
        next_sym = next_symbol(os, cur_sym, addr);
 
+       /* Should never happen unless the debugger misbehaves */
+       if (!next_sym) {
+               LOG_WARNING("RTOS: Debugger sent us qSymbol with '%s' that we did not ask for", cur_sym);
+               goto done;
+       }
+
        if (!next_sym->symbol_name) {
                /* No more symbols need looking up */
 
@@ -291,6 +292,8 @@ int rtos_qsymbol(struct connection *connection, char const *packet, int packet_s
                goto done;
        }
 
+       LOG_DEBUG("RTOS: Requesting symbol lookup of '%s' from the debugger", next_sym->symbol_name);
+
        reply_len = snprintf(reply, sizeof(reply), "qSymbol:");
        reply_len += hexify(reply + reply_len,
                (const uint8_t *)next_sym->symbol_name, strlen(next_sym->symbol_name),
@@ -605,7 +608,7 @@ int rtos_generic_stack_read(struct target *target,
                LOG_OUTPUT("\r\n");
 #endif
 
-       int64_t new_stack_ptr;
+       target_addr_t new_stack_ptr;
        if (stacking->calculate_process_stack) {
                new_stack_ptr = stacking->calculate_process_stack(target,
                                stack_data, stacking, stack_ptr);