From 684cf1dd304ef8bf2c4c7d1d5f58a1e28d6dca1f Mon Sep 17 00:00:00 2001
From: Alan Bowman <alan.michael.bowman@gmail.com>
Date: Mon, 23 May 2011 20:37:58 +0100
Subject: [PATCH 2/2] Report actual current thread

---
 src/rtos/rtos.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 9eed08e..818a979 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -453,7 +453,17 @@ int gdb_thread_packet(struct connection *connection, struct target *target, char
 	}
 	else if (strstr(packet, "qC"))
 	{
-		gdb_put_packet(connection, "QC0", 3);
+		if( target->rtos!=NULL )
+		{
+			char buffer[15];
+			int size;
+			size = snprintf(buffer, 15, "QC%08X", (int)target->rtos->current_thread);
+			gdb_put_packet(connection, buffer, size);
+		}
+		else
+		{
+			gdb_put_packet(connection, "QC0", 3);
+		}
 		return ERROR_OK;
 	}
 	else if ( packet[0] == 'T' ) // Is thread alive?
-- 
1.7.1

