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
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;
}
return target->rtos->gdb_thread_packet(connection, packet, packet_size);
}
-static struct symbol_table_elem *next_symbol(struct rtos *os, char *cur_symbol, uint64_t cur_addr)
+static struct symbol_table_elem *find_symbol(const struct rtos *os, const char *symbol)
{
struct symbol_table_elem *s;
- if (!os->symbols)
- os->type->get_symbol_list_to_lookup(&os->symbols);
-
- if (!cur_symbol[0])
- return &os->symbols[0];
-
for (s = os->symbols; s->symbol_name; s++)
- if (!strcmp(s->symbol_name, cur_symbol)) {
- s->address = cur_addr;
- s++;
+ if (!strcmp(s->symbol_name, symbol))
return s;
- }
return NULL;
}
-/* searches for 'symbol' in the lookup table for 'os' and returns TRUE,
- * if 'symbol' is not declared optional */
-static bool is_symbol_mandatory(const struct rtos *os, const char *symbol)
+static struct symbol_table_elem *next_symbol(struct rtos *os, char *cur_symbol, uint64_t cur_addr)
{
- for (struct symbol_table_elem *s = os->symbols; s->symbol_name; ++s) {
- if (!strcmp(s->symbol_name, symbol))
- return !s->optional;
- }
- return false;
+ if (!os->symbols)
+ os->type->get_symbol_list_to_lookup(&os->symbols);
+
+ if (!cur_symbol[0])
+ return &os->symbols[0];
+
+ struct symbol_table_elem *s = find_symbol(os, cur_symbol);
+ if (!s)
+ return NULL;
+
+ s->address = cur_addr;
+ s++;
+ return s;
}
/* rtos_qsymbol() processes and replies to all qSymbol packets from GDB.
cur_sym[len] = 0;
if ((strcmp(packet, "qSymbol::") != 0) && /* GDB is not offering symbol lookup for the first time */
- (!sscanf(packet, "qSymbol:%" SCNx64 ":", &addr)) && /* GDB did not find an address for a symbol */
- is_symbol_mandatory(os, cur_sym)) { /* the symbol is mandatory for this RTOS */
+ (!sscanf(packet, "qSymbol:%" SCNx64 ":", &addr))) { /* GDB did not find an address for a symbol */
/* GDB could not find an address for the previous symbol */
- if (!target->rtos_auto_detect) {
- LOG_WARNING("RTOS %s not detected. (GDB could not find symbol \'%s\')", os->type->name, cur_sym);
- goto done;
- } else {
- /* Autodetecting RTOS - try next RTOS */
- if (!rtos_try_next(target)) {
- LOG_WARNING("No RTOS could be auto-detected!");
+ struct symbol_table_elem *sym = find_symbol(os, cur_sym);
+
+ if (sym && !sym->optional) { /* the symbol is mandatory for this RTOS */
+ if (!target->rtos_auto_detect) {
+ LOG_WARNING("RTOS %s not detected. (GDB could not find symbol \'%s\')", os->type->name, cur_sym);
goto done;
- }
+ } else {
+ /* Autodetecting RTOS - try next RTOS */
+ if (!rtos_try_next(target)) {
+ LOG_WARNING("No RTOS could be auto-detected!");
+ goto done;
+ }
- /* Next RTOS selected - invalidate current symbol */
- cur_sym[0] = '\x00';
+ /* Next RTOS selected - invalidate current symbol */
+ cur_sym[0] = '\x00';
+ }
}
}