diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index b83c7d1d3..1f1d58477 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -1362,8 +1362,21 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, cr } if (lines[crashStackStartLine].startsWith("SIG")) { signalType = `${lines[crashStackStartLine]}\n`; - signalInfo = `si_code=${lines[crashStackStartLine + 1]}, si_addr=${bucketSignalAddress(lines[crashStackStartLine + 2])}\n`; - crashStackStartLine += 3; + const siCodeRaw: string | undefined = lines[crashStackStartLine + 1]; + const siAddrRaw: string | undefined = lines[crashStackStartLine + 2]; + const siCode: string = siCodeRaw?.trim() ?? ""; + const siAddr: string = siAddrRaw?.trim() ?? ""; + const signalInfoParts: string[] = []; + if (siCode.length > 0) { + signalInfoParts.push(`si_code=${siCode}`); + } + if (siAddr.length > 0) { + signalInfoParts.push(`si_addr=${bucketSignalAddress(siAddr)}`); + } + signalInfo = signalInfoParts.length > 0 ? `${signalInfoParts.join(", ")}\n` : ""; + // Only advance past the header lines that actually exist so a missing si_code/si_addr + // line does not cause the first stack frame to be skipped. + crashStackStartLine += 1 + (siCodeRaw !== undefined ? 1 : 0) + (siAddrRaw !== undefined ? 1 : 0); } else { // The signal type may fail to be written. // Intentionally different from SIGUNKNOWN from cpptools,