ghidra
ghidra copied to clipboard
Fix test for ghidra root path in cpp decompiler console
-
FileManage::discoverGhidraRoot
is only used byconsolemain.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 bydiscoverGhidraRoot
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, butscanDirectoryRecursive
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
Hello, are there any updates on this?
bump :>