From 41211639ba654e54ad1a1212682e4f829f3aad33 Mon Sep 17 00:00:00 2001 From: Adam Higerd Date: Mon, 3 Aug 2020 20:29:14 -0500 Subject: [PATCH] Stack traces: fix flipped variables that cause a crash --- src/debugger/stack-trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/debugger/stack-trace.c b/src/debugger/stack-trace.c index a10c0bde8..50c3a523c 100644 --- a/src/debugger/stack-trace.c +++ b/src/debugger/stack-trace.c @@ -84,7 +84,7 @@ void mStackTraceFormatFrame(struct mStackTrace* stack, struct mDebuggerSymbols* const char* functionName = mDebuggerSymbolReverseLookup(st, stackFrame->entryAddress, stackFrame->entrySegment); if (functionName) { written += snprintf(out + written, *length - written, "%s ", functionName); - } else if (prevFrame->entrySegment >= 0) { + } else if (stackFrame->entrySegment >= 0) { written += snprintf(out + written, *length - written, "0x%02X:%08X ", stackFrame->entrySegment, stackFrame->entryAddress); } else { written += snprintf(out + written, *length - written, "0x%08X ", stackFrame->entryAddress); @@ -111,7 +111,7 @@ void mStackTraceFormatFrame(struct mStackTrace* stack, struct mDebuggerSymbols* functionName = mDebuggerSymbolReverseLookup(st, prevFrame->entryAddress, prevFrame->entrySegment); if (functionName) { written += snprintf(out + written, *length - written, " [%s+%d]", functionName, offset); - } else if (stackFrame->entrySegment >= 0) { + } else if (prevFrame->entrySegment >= 0) { written += snprintf(out + written, *length - written, " [0x%02X:%08X+%d]", prevFrame->entrySegment, prevFrame->entryAddress, offset); } else { written += snprintf(out + written, *length - written, " [0x%08X+%d]", prevFrame->entryAddress, offset);