aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Nordell <tnordell@airgain.com>2022-09-07 11:35:33 -0500
committerAntonio Borneo <borneo.antonio@gmail.com>2022-09-17 20:58:16 +0000
commit9f5a74c228cbab3d80c47c87fa9735167da7eb77 (patch)
tree41c4a382074750369c94430078123e17be1a0c21 /src
parent4279b23fcacaf3bb6f7c5e8da9386eaeeafe5736 (diff)
downloadriscv-openocd-9f5a74c228cbab3d80c47c87fa9735167da7eb77.zip
riscv-openocd-9f5a74c228cbab3d80c47c87fa9735167da7eb77.tar.gz
riscv-openocd-9f5a74c228cbab3d80c47c87fa9735167da7eb77.tar.bz2
rtos: Create a new helper function find_symbol(...)
This will be utilized for an upcoming refactorization to support -flto compiled programs. Signed-off-by: Tim Nordell <tnordell@airgain.com> Change-Id: Id523c0b3ac2dad8b248ea0d2cac7b4dd2f83d293 Reviewed-on: https://review.openocd.org/c/openocd/+/7177 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/rtos/rtos.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 3e43e82..3c3896d 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -170,35 +170,40 @@ int gdb_thread_packet(struct connection *connection, char const *packet, int pac
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;
+ for (s = os->symbols; s->symbol_name; s++)
+ if (!strcmp(s->symbol_name, symbol))
+ return s;
+
+ return NULL;
+}
+
+static struct symbol_table_elem *next_symbol(struct rtos *os, char *cur_symbol, uint64_t cur_addr)
+{
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++;
- return s;
- }
+ struct symbol_table_elem *s = find_symbol(os, cur_symbol);
+ if (!s)
+ return NULL;
- return NULL;
+ s->address = cur_addr;
+ s++;
+ return s;
}
/* 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)
{
- for (struct symbol_table_elem *s = os->symbols; s->symbol_name; ++s) {
- if (!strcmp(s->symbol_name, symbol))
- return !s->optional;
- }
- return false;
+ struct symbol_table_elem *s = find_symbol(os, symbol);
+ return s && !s->optional;
}
/* rtos_qsymbol() processes and replies to all qSymbol packets from GDB.