From 22d582d26a2038e55e9cd3aaaeead3bab4cf012c Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 4 Dec 2026 23:16:49 +0800 Subject: [PATCH] refactor(firmware): share vector table omission reporting (#16761) --- .../firmware/firmwareVectorTableParser.ts | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/domain/firmware/firmwareVectorTableParser.ts b/src/domain/firmware/firmwareVectorTableParser.ts index c355ace2a52..2f7f30e1889 100644 --- a/src/domain/firmware/firmwareVectorTableParser.ts +++ b/src/domain/firmware/firmwareVectorTableParser.ts @@ -358,30 +358,25 @@ const finalizeTableHeader = (input: TableHeaderInput) => { architecturalTableBytes === undefined ? availableFromOffset : Math.min(availableFromOffset, architecturalTableBytes); + const hasUndecodedSlots = decodedSlotBytes < effectiveTableBytes; + const omissionStart = hasUndecodedSlots ? decodedSlotBytes : consumedBytes; + const omissionEnd = hasUndecodedSlots + ? effectiveTableBytes + : availableFromOffset; const coverageAcc = new CoverageAccumulator().recordComplete(); - if (customCapReason !== undefined) { - coverageAcc.recordOmission(customCapReason); - limitations.push(customCapReason); - } else if (decodedSlotBytes < effectiveTableBytes) { - const afterSlotsOffset = options.vectorTableOffset + decodedSlotBytes; - const omission = + let omission = customCapReason; + if (omission === undefined && omissionStart < omissionEnd) { + const afterSlotsOffset = options.vectorTableOffset + omissionStart; + omission = entryCount === addressableEntries && entryCount < options.maxEntries ? `Decoded ${String(entryCount)} slots (${String(consumedBytes)} bytes); later slots would lie past the end of the ${options.architecture === "avr" ? "AVR program" : "32-bit"} address space and were not interpreted.` : entryCount < options.maxEntries - ? `Decoded ${String(entryCount)} slots (${String(consumedBytes)} bytes); ${String(effectiveTableBytes - decodedSlotBytes)} trailing byte(s) past offset ${String(afterSlotsOffset)} do not form a complete ${slotWidthLabel} slot.` - : consumedBytes > decodedSlotBytes - ? `Decoded ${String(entryCount)} slot(s) (${String(decodedSlotBytes)} slot bytes; ${String(consumedBytes)} bytes examined) up to max_entries; ${String(effectiveTableBytes - decodedSlotBytes)} vector-table byte(s) past offset ${String(afterSlotsOffset)} were not decoded as vector slots.` + ? `Decoded ${String(entryCount)} slots (${String(consumedBytes)} bytes); ${String(omissionEnd - omissionStart)} trailing byte(s) past offset ${String(afterSlotsOffset)} do not form a complete ${slotWidthLabel} slot.` + : consumedBytes > omissionStart + ? `Decoded ${String(entryCount)} slot(s) (${String(omissionStart)} slot bytes; ${String(consumedBytes)} bytes examined) up to max_entries; ${String(omissionEnd - omissionStart)} vector-table byte(s) past offset ${String(afterSlotsOffset)} were not decoded as vector slots.` : `Decoded ${String(entryCount)} slots (${String(consumedBytes)} bytes) up to max_entries; bytes past offset ${String(afterSlotsOffset)} were not interpreted as vector slots.`; - coverageAcc.recordOmission(omission); - limitations.push(omission); - } else if (consumedBytes < availableFromOffset) { - const afterConsumedOffset = options.vectorTableOffset + consumedBytes; - const omission = - entryCount === addressableEntries && entryCount < options.maxEntries - ? `Decoded ${String(entryCount)} slots (${String(consumedBytes)} bytes); later slots would lie past the end of the ${options.architecture === "avr" ? "AVR program" : "32-bit"} address space and were not interpreted.` - : entryCount < options.maxEntries - ? `Decoded ${String(entryCount)} slots (${String(consumedBytes)} bytes); ${String(availableFromOffset - consumedBytes)} trailing byte(s) past offset ${String(afterConsumedOffset)} do not form a complete ${slotWidthLabel} slot.` - : `Decoded ${String(entryCount)} slots (${String(consumedBytes)} bytes) up to max_entries; bytes past offset ${String(afterConsumedOffset)} were not interpreted as vector slots.`; + } + if (omission !== undefined) { coverageAcc.recordOmission(omission); limitations.push(omission); }