aboutsummaryrefslogtreecommitdiff
path: root/src/rtos
diff options
context:
space:
mode:
authorSpencer Oliver <spen@spen-soft.co.uk>2012-10-26 12:47:06 +0100
committerPeter Stuge <peter@stuge.se>2012-10-28 01:40:21 +0000
commit538a86c3395d0476d2fdcc9bddc4e9e550734c96 (patch)
tree53aabde1956cc30f1d1198939375c88ad0b20d3c /src/rtos
parent6f65045b3791525e99d09d07b5f9d8dd5aa511e5 (diff)
downloadriscv-openocd-538a86c3395d0476d2fdcc9bddc4e9e550734c96.zip
riscv-openocd-538a86c3395d0476d2fdcc9bddc4e9e550734c96.tar.gz
riscv-openocd-538a86c3395d0476d2fdcc9bddc4e9e550734c96.tar.bz2
gdb: use strncmp rather than strstr
All the packets received will be at start of the packet buffer, so use more efficient strncmp. Change-Id: Ib9c45d8f53425367006b1f880c1bde27f03a6cf9 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/932 Tested-by: jenkins Reviewed-by: Matthias Blaicher <matthias@blaicher.com> Reviewed-by: Peter Stuge <peter@stuge.se>
Diffstat (limited to 'src/rtos')
-rw-r--r--src/rtos/linux.c8
-rw-r--r--src/rtos/rtos.c14
2 files changed, 11 insertions, 11 deletions
diff --git a/src/rtos/linux.c b/src/rtos/linux.c
index 3f1b214..9c95597 100644
--- a/src/rtos/linux.c
+++ b/src/rtos/linux.c
@@ -1396,7 +1396,7 @@ static int linux_thread_packet(struct connection *connection, char *packet,
break;
case 'q':
- if ((strstr(packet, "qSymbol"))) {
+ if (strncmp(packet, "qSymbol", 7) == 0) {
if (rtos_qsymbol(connection, packet, packet_size) == 1) {
linux_compute_virt2phys(target,
target->rtos->
@@ -1405,7 +1405,7 @@ static int linux_thread_packet(struct connection *connection, char *packet,
}
break;
- } else if (strstr(packet, "qfThreadInfo")) {
+ } else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
if (linux_os->thread_list == NULL) {
retval = linux_gdb_thread_packet(target,
connection,
@@ -1419,10 +1419,10 @@ static int linux_thread_packet(struct connection *connection, char *packet,
packet_size);
break;
}
- } else if (strstr(packet, "qsThreadInfo")) {
+ } else if (strncmp(packet, "qsThreadInfo", 12) == 0) {
gdb_put_packet(connection, "l", 1);
break;
- } else if (strstr(packet, "qThreadExtraInfo,")) {
+ } else if (strncmp(packet, "qThreadExtraInfo,", 17) == 0) {
linux_thread_extra_info(target, connection, packet,
packet_size);
break;
diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 00025ab..349f84d 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -244,7 +244,7 @@ int rtos_thread_packet(struct connection *connection, char *packet, int packet_s
{
struct target *target = get_target_from_connection(connection);
- if (strstr(packet, "qThreadExtraInfo,")) {
+ if (strncmp(packet, "qThreadExtraInfo,", 17) == 0) {
if ((target->rtos != NULL) && (target->rtos->thread_details != NULL) &&
(target->rtos->thread_count != 0)) {
threadid_t threadid = 0;
@@ -306,14 +306,14 @@ int rtos_thread_packet(struct connection *connection, char *packet, int packet_s
}
gdb_put_packet(connection, "", 0);
return ERROR_OK;
- } else if (strstr(packet, "qSymbol")) {
+ } else if (strncmp(packet, "qSymbol", 7) == 0) {
if (rtos_qsymbol(connection, packet, packet_size) == 1) {
target->rtos_auto_detect = false;
target->rtos->type->create(target);
target->rtos->type->update_threads(target->rtos);
}
return ERROR_OK;
- } else if (strstr(packet, "qfThreadInfo")) {
+ } else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
int i;
if ((target->rtos != NULL) && (target->rtos->thread_count != 0)) {
@@ -332,17 +332,17 @@ int rtos_thread_packet(struct connection *connection, char *packet, int packet_s
gdb_put_packet(connection, "", 0);
return ERROR_OK;
- } else if (strstr(packet, "qsThreadInfo")) {
+ } else if (strncmp(packet, "qsThreadInfo", 12) == 0) {
gdb_put_packet(connection, "l", 1);
return ERROR_OK;
- } else if (strstr(packet, "qAttached")) {
+ } else if (strncmp(packet, "qAttached", 9) == 0) {
gdb_put_packet(connection, "1", 1);
return ERROR_OK;
- } else if (strstr(packet, "qOffsets")) {
+ } else if (strncmp(packet, "qOffsets", 8) == 0) {
char offsets[] = "Text=0;Data=0;Bss=0";
gdb_put_packet(connection, offsets, sizeof(offsets)-1);
return ERROR_OK;
- } else if (strstr(packet, "qC")) {
+ } else if (strncmp(packet, "qC", 2) == 0) {
if (target->rtos != NULL) {
char buffer[19];
int size;