Adubbz / Ghidra-Switch-Loader

Nintendo Switch loader for Ghidra
ISC License
278 stars 41 forks source link

error: cannot find symbol getMsgCount() on ghidra 9.2.2 #21

Closed H0neyBadger closed 1 year ago

H0neyBadger commented 3 years ago

Hello, I'm having the following error during the build of the Ghidra-Switch-Loader:

bash ./gradlew -PGHIDRA_INSTALL_DIR=/var/home/h0neybadger/Documents/switch/ghidra/ghidra_9.2.2_PUBLIC                      
Starting a Gradle Daemon (subsequent builds will be faster)                                                                                                             

> Task :compileJava                                                                                                                                                     
/var/home/h0neybadger/Documents/switch/ghidra/Ghidra-Switch-Loader/src/main/java/adubbz/nx/loader/common/MemoryBlockHelper.java:127: error: cannot find symbol          
        if (this.log.getMsgCount() > 0)                                                                                                                                 
                    ^                                                                                                                                                   
  symbol:   method getMsgCount()                                                                                                                                        
  location: variable log of type MessageLog                                                                                                                             
Note: /var/home/h0neybadger/Documents/switch/ghidra/Ghidra-Switch-Loader/src/main/java/adubbz/nx/analyzer/ipc/IPCEmulator.java uses or overrides a deprecated API.      
Note: Recompile with -Xlint:deprecation for details.                                                                                                                    
Note: /var/home/h0neybadger/Documents/switch/ghidra/Ghidra-Switch-Loader/src/main/java/adubbz/nx/analyzer/IPCAnalyzer.java uses unchecked or unsafe operations.         
Note: Recompile with -Xlint:unchecked for details.                                                                                                                      
1 error                                                                                                                                                                 

> Task :compileJava FAILED                                                                                                                                              

FAILURE: Build failed with an exception.                                                                                                                                

* What went wrong:                                                                                                                                                      
Execution failed for task ':compileJava'.                                                                                                                               
> Compilation failed; see the compiler error output for details.                                                                                                        

* Try:                                                                                                                                                                  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.                    

* Get more help at https://help.gradle.org                                                                                                                              

BUILD FAILED in 44s

After a quick investigation, I replaced the this.log.getMsgCount() > 0 condition by this.log.hasMessages()

diff --git a/src/main/java/adubbz/nx/loader/common/MemoryBlockHelper.java b/src/main/java/adubbz/nx/loader/common/MemoryBlockHelper.java
index b51e29c..c0b34b1 100644
--- a/src/main/java/adubbz/nx/loader/common/MemoryBlockHelper.java
+++ b/src/main/java/adubbz/nx/loader/common/MemoryBlockHelper.java
@@ -124,7 +124,7 @@ public class MemoryBlockHelper

     public void flushLog()
     {
-        if (this.log.getMsgCount() > 0)
+        if (this.log.hasMessages())
         {
             Msg.info(this, this.log.toString());
             this.log.clear();

But I'm not sure if my setup is correct https://github.com/NationalSecurityAgency/ghidra/blob/cbe83dcd7853dc09e7c05113a4cf9a5fb0fb1fad/Ghidra/Framework/Generic/src/main/java/ghidra/app/util/importer/MessageLog.java#L115

Let me know if I can help.

Adubbz commented 3 years ago

This is due to this API being changed recently by Ghidra and I haven't updated this to support it yet.

MaKiPL commented 3 years ago

Compiled with your fix- works fine, plugin loads correctly. Please open pull request for @Adubbz or maybe we can send pre-compiled plugin to host on release if this change breaks the earlier Ghidra versions