From 47468598dda212347550145e33e689c5fcf81b1c Mon Sep 17 00:00:00 2001 From: James <49045138+ghidracadabra@users.noreply.github.com> Date: Thu, 30 Jan 2025 02:20:43 +0000 Subject: [PATCH] GP-0 improved dwarf source line exception handling --- .../ghidra/app/util/bin/format/dwarf/DWARFImporter.java | 4 ++-- .../ghidra/app/util/bin/format/golang/rtti/GoFuncData.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFImporter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFImporter.java index 6372ba65f3..580d1c3695 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFImporter.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFImporter.java @@ -305,8 +305,8 @@ public class DWARFImporter { try { sourceManager.addSourceMapEntry(source, sfa.lineNum(), addr, length); } - catch (AddressOverflowException e) { - String errorString = "AddressOverflowException for source map entry %s %d %s %x %d" + catch (AddressOverflowException | IllegalArgumentException e) { + String errorString = e.getClass().getName() + " for source map entry %s %d %s %x %d" .formatted(source.getFilename(), sfa.lineNum(), addr.toString(), sfa.address(), length); if (numSourceLineErrorReports++ < MAX_NUM_SOURCE_LINE_ERROR_REPORTS) { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/GoFuncData.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/GoFuncData.java index 828bfefdbd..7ee0aaa817 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/GoFuncData.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/GoFuncData.java @@ -403,14 +403,18 @@ public class GoFuncData implements StructureMarkup { Address startAddr = programContext.getCodeAddress(startpc); long len = lineEval.getPC() - startpc; + SourceFile sourceFile = new SourceFile(fileName); try { - SourceFile sourceFile = new SourceFile(fileName); + sfman.addSourceFile(sourceFile); sfman.addSourceMapEntry(sourceFile, lineNum, startAddr, len); } catch (AddressOverflowException e) { Msg.error(this, "Failed to add source file mapping", e); } + catch (IllegalArgumentException e) { + // overlapping entry + } } } startpc = lineEval.getPC();