Skip to content

Commit 15ebcd3

Browse files
committed
Thread context should always contain FP regisers
RTX only stacks the floating point registers when it detects that a thread makes use of them. Previously ThreadMRI would only return the FP registers in the context if the thread had them but GDB will actually return an error if it sees the size of the context change between debug halts. This commit will return a dummy set of zeroed out float registers to GDB when the RTX thread doesn't have any of its own to return.
1 parent 3d7df56 commit 15ebcd3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

libraries/ThreadMRI/src/ThreadMRI.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ void (*g_origSerialISR)(void);
120120
#define CONTEXT_ENTRIES 5
121121
#endif
122122

123-
static ScatterGatherEntry g_contextEntries[CONTEXT_ENTRIES];
123+
static ScatterGatherEntry g_contextEntries[CONTEXT_ENTRIES];
124+
125+
// Floats to be returned in context if the thread being debugged hsa no stored float state.
126+
static uint32_t g_tempFloats[33];
124127

125128
// UNDONE: For debugging. If different than g_haltedThreadId then the mriMain() thread was signalled when the previous
126129
// instance was still running.
@@ -331,6 +334,15 @@ static void readThreadContext(osThreadId_t thread)
331334
// FPSCR
332335
g_contextEntries[7].pValues = pThreadContext + 48;
333336
g_contextEntries[7].count = 1;
337+
} else {
338+
memset(g_tempFloats, 0, sizeof(g_tempFloats));
339+
// S0-S31, FPSCR
340+
g_contextEntries[5].pValues = g_tempFloats;
341+
g_contextEntries[5].count = 33;
342+
g_contextEntries[6].pValues = NULL;
343+
g_contextEntries[6].count = 0;
344+
g_contextEntries[7].pValues = NULL;
345+
g_contextEntries[7].count = 0;
334346
}
335347
}
336348

0 commit comments

Comments
 (0)