GP-5834 fix DWARF file / line issue

remove access to dwarfline file count because it encourages callers to
try to iterate via index, which is not something they should do.
This commit is contained in:
dev747368 2025-07-17 15:41:43 +00:00
parent 2c10392a79
commit 20c8d97c85
6 changed files with 43 additions and 59 deletions

View file

@ -88,13 +88,7 @@ public class DWARFLineInfoSourceMapScript extends GhidraScript {
for (DWARFCompilationUnit cu : compUnits) {
DWARFLine dLine = cu.getLine();
monitor.increment();
for (int i = 0; i < dLine.getNumFiles(); ++i) {
String filePath = dLine.getFilePath(i, true);
if (filePath == null) {
continue;
}
byte[] md5 = dLine.getFile(i).getMD5();
SourceFileInfo sfi = new SourceFileInfo(filePath, md5);
for (SourceFileInfo sfi : dLine.getAllSourceFileInfos()) {
if (sourceFileInfoToSourceFile.containsKey(sfi)) {
continue;
}
@ -102,11 +96,11 @@ public class DWARFLineInfoSourceMapScript extends GhidraScript {
continue;
}
try {
String path = SourceFileUtils.normalizeDwarfPath(filePath,
String path = SourceFileUtils.normalizeDwarfPath(sfi.filePath(),
COMPILATION_ROOT_DIRECTORY);
SourceFileIdType type =
md5 == null ? SourceFileIdType.NONE : SourceFileIdType.MD5;
SourceFile sFile = new SourceFile(path, type, md5);
sfi.md5() == null ? SourceFileIdType.NONE : SourceFileIdType.MD5;
SourceFile sFile = new SourceFile(path, type, sfi.md5());
sourceManager.addSourceFile(sFile);
sourceFileInfoToSourceFile.put(sfi, sFile);
}