From e2257ce96a2652000f314cfa7acbe269b135d37d Mon Sep 17 00:00:00 2001 From: ghidra007 Date: Tue, 16 Nov 2021 11:48:08 -0500 Subject: [PATCH] GP-1495 added check for error decompiling function and put bad bookmarks if it happens. --- .../classrecovery/RecoveredClassUtils.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RecoveredClassUtils.java b/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RecoveredClassUtils.java index 711bae1f52..aa62742119 100644 --- a/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RecoveredClassUtils.java +++ b/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RecoveredClassUtils.java @@ -3313,6 +3313,24 @@ public class RecoveredClassUtils { // listing has void too, otherwise, leave it as is, probably a void String returnType = getReturnTypeFromDecompiler(constructorFunction); + // Set error bookmark, add error message, and get the listing return type if the + // decompiler return type is null + if (returnType == null) { + + String error = "Decompiler Error: The decompiler failed to decompile function at " + + constructorFunction.getEntryPoint().toString() + + " possibly due to the addition of " + className + " class structure."; + + Msg.debug(this, error); + + program.getBookmarkManager().setBookmark(constructorFunction.getEntryPoint(), + BookmarkType.ERROR, "Decompiler Error", error); + + // get the return type from the listing and in some cases it will + // indicate the correct type to help determine the below type to add + returnType = constructorFunction.getReturnType().getDisplayName(); + } + if (returnType.equals("void")) { DataType voidDataType = new VoidDataType(); constructorFunction.setReturnType(voidDataType, SourceType.ANALYSIS);