Ghidra is a software reverse engineering (SRE) framework
GP-6176: Better logging from AbstractObjcTypeMetadata
Ryan Kurtz2fed7541a083
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/AbstractObjcTypeMetadata.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/AbstractObjcTypeMetadata.javaindex 03139e71ef..b86b36f3f3 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/AbstractObjcTypeMetadata.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/AbstractObjcTypeMetadata.java@@ -18,7 +18,6 @@ package ghidra.app.util.bin.format.objc;import java.io.Closeable;import java.io.IOException;-import ghidra.app.util.bin.format.objc.objc1.Objc1TypeMetadata;import ghidra.app.util.importer.MessageLog;import ghidra.program.model.listing.Program;import ghidra.util.exception.CancelledException;@@ -60,7 +59,17 @@ public abstract class AbstractObjcTypeMetadata implements Closeable {* @param message The message to log*/public void log(String message) {- log.appendMsg(Objc1TypeMetadata.class.getSimpleName(), message);+ log.appendMsg(getClass().getSimpleName(), message);+ }++ /**+ * Convenience method to perform logging (with exception)+ *+ * @param message The message to log+ * @param e The exception to log+ */+ public void log(String message, Exception e) {+ log.appendMsg(getClass().getSimpleName(), message + ": " + e.getMessage());}@Overridediff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeMetadata.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeMetadata.javaindex c55dc26d31..69dbdbb911 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeMetadata.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc1/Objc1TypeMetadata.java@@ -93,7 +93,7 @@ public class Objc1TypeMetadata extends AbstractObjcTypeMetadata {}}catch (IOException e) {- log("Failed to parse modules from section '" + section + "'");+ log("Failed to parse modules from section '" + section + "'", e);}}@@ -112,7 +112,7 @@ public class Objc1TypeMetadata extends AbstractObjcTypeMetadata {}}catch (IOException e) {- log("Failed to parse protocols from section '" + section + "'");+ log("Failed to parse protocols from section '" + section + "'", e);}}@@ -123,7 +123,7 @@ public class Objc1TypeMetadata extends AbstractObjcTypeMetadata {module.applyTo(program.getGlobalNamespace(), monitor);}catch (Exception e) {- log("Failed to markup: " + module.getName());+ log("Failed to markup: " + module.getName(), e);}}for (Objc1Protocol protocol : protocols) {@@ -131,7 +131,7 @@ public class Objc1TypeMetadata extends AbstractObjcTypeMetadata {protocol.applyTo(program.getGlobalNamespace(), monitor);}catch (Exception e) {- log("Failed to markup: " + protocol.getName());+ log("Failed to markup: " + protocol.getName(), e);}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2TypeMetadata.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2TypeMetadata.javaindex 8e2ab3e68b..2bb4e9368b 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2TypeMetadata.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/objc/objc2/Objc2TypeMetadata.java@@ -180,7 +180,7 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {}}catch (IOException e) {- log("Failed to parse Objective-C categeory from section '" + section + "'");+ log("Failed to parse Objective-C categeory from section '" + section + "'", e);}}@@ -206,7 +206,7 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {}}catch (IOException e) {- log("Failed to parse Objective-C class from section '" + section + "'");+ log("Failed to parse Objective-C class from section '" + section + "'", e);}}@@ -233,7 +233,7 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {}}catch (IOException e) {- log("Failed to parse Objective-C protocol from section '" + section + "'");+ log("Failed to parse Objective-C protocol from section '" + section + "'", e);}}@@ -256,7 +256,7 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {}}catch (IOException e) {- log("Failed to parse Objective-C message reference from section '" + section + "'");+ log("Failed to parse Objective-C message reference from section '" + section + "'", e);}}@@ -270,7 +270,8 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {}}catch (IOException e) {- log("Failed to parse Objective-C libObjc optimizations from section '" + section + "'");+ log("Failed to parse Objective-C libObjc optimizations from section '" + section + "'",+ e);}}@@ -282,7 +283,7 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {DataUtilities.ClearDataMode.CLEAR_SINGLE_DATA);}catch (Exception e) {- log("Failed to create pointer at " + addr);+ log("Failed to create pointer at " + addr, e);}}for (Objc2ImageInfo imageInfo : imageInfos) {@@ -290,7 +291,7 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {imageInfo.applyTo(program.getGlobalNamespace(), monitor);}catch (Exception e) {- log("Failed to markup: " + imageInfo);+ log("Failed to markup: " + imageInfo, e);}}for (Objc2Category category : categories) {@@ -298,7 +299,7 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {category.applyTo(program.getGlobalNamespace(), monitor);}catch (Exception e) {- log("Failed to markup: " + category);+ log("Failed to markup: " + category, e);}}for (Objc2Class cls : classes) {@@ -306,7 +307,7 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {cls.applyTo(program.getGlobalNamespace(), monitor);}catch (Exception e) {- log("Failed to markup: " + cls);+ log("Failed to markup: " + cls, e);}}for (Objc2Protocol protocol : protocols) {@@ -316,7 +317,7 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {protocol.applyTo(namespace, monitor);}catch (Exception e) {- log("Failed to markup: " + protocol);+ log("Failed to markup: " + protocol, e);}}for (Objc2MessageReference messageRef : messageRefs) {@@ -324,7 +325,7 @@ public class Objc2TypeMetadata extends AbstractObjcTypeMetadata {messageRef.applyTo(program.getGlobalNamespace(), monitor);}catch (Exception e) {- log("Failed to markup: " + messageRef);+ log("Failed to markup: " + messageRef, e);}}