Skip to content

Commit 4774d95

Browse files
authored
Fix si_code=, si_addr=undefined. (#14608)
* Fix si_code=, si_addr=undefined.
1 parent 9e662ff commit 4774d95

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

Extension/src/LanguageServer/extension.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,8 +1362,21 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, cr
13621362
}
13631363
if (lines[crashStackStartLine].startsWith("SIG")) {
13641364
signalType = `${lines[crashStackStartLine]}\n`;
1365-
signalInfo = `si_code=${lines[crashStackStartLine + 1]}, si_addr=${bucketSignalAddress(lines[crashStackStartLine + 2])}\n`;
1366-
crashStackStartLine += 3;
1365+
const siCodeRaw: string | undefined = lines[crashStackStartLine + 1];
1366+
const siAddrRaw: string | undefined = lines[crashStackStartLine + 2];
1367+
const siCode: string = siCodeRaw?.trim() ?? "";
1368+
const siAddr: string = siAddrRaw?.trim() ?? "";
1369+
const signalInfoParts: string[] = [];
1370+
if (siCode.length > 0) {
1371+
signalInfoParts.push(`si_code=${siCode}`);
1372+
}
1373+
if (siAddr.length > 0) {
1374+
signalInfoParts.push(`si_addr=${bucketSignalAddress(siAddr)}`);
1375+
}
1376+
signalInfo = signalInfoParts.length > 0 ? `${signalInfoParts.join(", ")}\n` : "";
1377+
// Only advance past the header lines that actually exist so a missing si_code/si_addr
1378+
// line does not cause the first stack frame to be skipped.
1379+
crashStackStartLine += 1 + (siCodeRaw !== undefined ? 1 : 0) + (siAddrRaw !== undefined ? 1 : 0);
13671380
} else {
13681381
// The signal type may fail to be written.
13691382
// Intentionally different from SIGUNKNOWN from cpptools,

0 commit comments

Comments
 (0)