diff --git a/sysmodules/rosalina/include/gdb/thread.h b/sysmodules/rosalina/include/gdb/thread.h index dd79292..885da3b 100644 --- a/sysmodules/rosalina/include/gdb/thread.h +++ b/sysmodules/rosalina/include/gdb/thread.h @@ -39,3 +39,4 @@ GDB_DECLARE_QUERY_HANDLER(fThreadInfo); GDB_DECLARE_QUERY_HANDLER(sThreadInfo); GDB_DECLARE_QUERY_HANDLER(ThreadEvents); GDB_DECLARE_QUERY_HANDLER(ThreadExtraInfo); +GDB_DECLARE_QUERY_HANDLER(GetTLSAddr); diff --git a/sysmodules/rosalina/source/gdb/query.c b/sysmodules/rosalina/source/gdb/query.c index af2a79c..384ee61 100644 --- a/sysmodules/rosalina/source/gdb/query.c +++ b/sysmodules/rosalina/source/gdb/query.c @@ -59,6 +59,7 @@ static const struct GDB_QUERY_HANDLER_LIST_ITEM(sThreadInfo, READ), GDB_QUERY_HANDLER_LIST_ITEM(ThreadEvents, WRITE), GDB_QUERY_HANDLER_LIST_ITEM(ThreadExtraInfo, READ), + GDB_QUERY_HANDLER_LIST_ITEM(GetTLSAddr, READ), GDB_QUERY_HANDLER_LIST_ITEM_3("C", CurrentThreadId, READ), GDB_QUERY_HANDLER_LIST_ITEM_3("Search", SearchMemory, READ), GDB_QUERY_HANDLER_LIST_ITEM(CatchSyscalls, WRITE), diff --git a/sysmodules/rosalina/source/gdb/thread.c b/sysmodules/rosalina/source/gdb/thread.c index e10bbff..783c127 100644 --- a/sysmodules/rosalina/source/gdb/thread.c +++ b/sysmodules/rosalina/source/gdb/thread.c @@ -302,3 +302,27 @@ GDB_DECLARE_QUERY_HANDLER(ThreadExtraInfo) return GDB_SendHexPacket(ctx, buf, (u32)n); } + +GDB_DECLARE_QUERY_HANDLER(GetTLSAddr) +{ + u32 lst[3]; + if(GDB_ParseHexIntegerList(lst, ctx->commandData, 3, 0) == NULL) + return GDB_ReplyErrno(ctx, EILSEQ); + + // We don't care about the 'lm' parameter... + u32 id = lst[0]; + u32 offset = lst[1]; + + u32 tls = 0; + + for(u32 i = 0; i < MAX_DEBUG_THREAD; i++) + { + if(ctx->threadInfos[i].id == id) + tls = ctx->threadInfos[i].tls; + } + + if(tls == 0) + return GDB_ReplyErrno(ctx, EINVAL); + + return GDB_SendFormattedPacket(ctx, "%08x", tls + offset); +}