ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

Fix test for ghidra root path in cpp decompiler console

Open Thodoris1999 opened this issue 1 year ago • 2 comments

  • FileManage::discoverGhidraRoot is only used by consolemain.cc to find ghidra root given the executable path (argv[0]). It only uses this path to discover all of the repository's sleigh language definitions (SleighArchitecture::scanForSleighDirectories(root)). It does the following two tests to verify that path:
  • FileManage::testDevelopmentPath is only used by discoverGhidraRoot to find the ghidra root in a "development" environment. It moves up the directory hierarchy looking for a "Ghidra" directory that has a parent with some weird requirements (ends in ".git", starts with "ghidra." and is more than 10 characters). This obviously doesn't work and I don't quite understand what exactly those rules were intended for.
  • FileManage::testInstallationPath looks for the "Ghidra" directory and checks that it contains a "server" subdirectory with a "server.conf". This is reasonable for an installation environment, but scanDirectoryRecursive only looks for directories and not regular files, so this doesn't work on my machine (linux) either.

Instead I replaced those two tests with a single test that simply looks for the first Ghidra directory relative to the executable that contains a Processor subdirectory, which is a more direct test for discoverGhidraRoot's intended use (to find language definitions). This works in both development and installed environments. I also added a check for if FileManage::discoverGhidraRoot is passing an empty string to splitPath because this was also causing errors if the executable is called as a relative path

Resolves #5309

Thodoris1999 avatar May 08 '23 20:05 Thodoris1999

Hello, are there any updates on this?

em-eight avatar May 19 '23 12:05 em-eight

bump :>

Thodoris1999 avatar Apr 16 '24 18:04 Thodoris1999