GP-3664: Quick-Fix Debugger module mapper with shared projects.

This commit is contained in:
Dan 2023-08-02 16:03:39 -04:00
parent 07b664bbbf
commit e71a56e827
4 changed files with 24 additions and 5 deletions

View File

@ -15,6 +15,7 @@
*/
package ghidra.app.plugin.core.debug.service.modules;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.*;
import java.util.Map.Entry;
@ -971,6 +972,9 @@ public class DebuggerStaticMappingServicePlugin extends Plugin
try {
Program program = ProgramURLUtils.openHackedUpGhidraURL(programManager,
tool.getProject(), url, ProgramManager.OPEN_VISIBLE);
if (program == null) {
failures.add(new FileNotFoundException(url.toString()));
}
result.add(program);
}
catch (Exception e) {

View File

@ -373,6 +373,7 @@ public class ProgramModuleIndexer implements DomainFolderChangeAdapter {
.stream()
.map(m -> ProgramURLUtils.getFileForHackedUpGhidraURL(project,
m.getStaticProgramURL()))
.filter(Objects::nonNull)
.collect(Collectors.toSet());
Set<DomainFile> libraries = DebuggerStaticMappingUtils.collectLibraries(alreadyMapped);
alreadyMapped.stream()

View File

@ -61,11 +61,12 @@ public enum ProgramURLUtils {
String asString = ghidraURL.toExternalForm();
int bangLoc = asString.indexOf('!');
if (bangLoc == -1) {
ProjectData projectData = project.getProjectData(ghidraURL);
ProjectData projectData =
project.getProjectData(GhidraURL.getProjectURL(ghidraURL));
if (projectData == null) {
return null;
}
return projectData.getFile(ghidraURL.getPath());
return projectData.getFile(GhidraURL.getProjectPathname(ghidraURL));
}
URL localProjURL = new URL(asString.substring(0, bangLoc));
ProjectData projectData = project.getProjectData(localProjURL);
@ -84,6 +85,9 @@ public enum ProgramURLUtils {
public static Program openHackedUpGhidraURL(ProgramManager programManager, Project project,
URL ghidraURL, int state) {
DomainFile file = getFileForHackedUpGhidraURL(project, ghidraURL);
if (file == null) {
return null;
}
return programManager.openProgram(file, DomainFile.DEFAULT_VERSION, state);
}
}

View File

@ -76,8 +76,8 @@ public class DefaultProject implements Project {
*
* @param projectManager the manager of this project
* @param projectLocator location and name of project
* @param repository shared repository associated with the new project. Can
* be null for non-shared projects
* @param repository shared repository associated with the new project. Can be null for
* non-shared projects
* @throws IOException if I/O error occurs.
* @throws LockException if unable to establish project lock
*/
@ -684,7 +684,17 @@ public class DefaultProject implements Project {
if (projectLocator.getURL().equals(url)) {
return fileMgr;
}
return otherViews.get(url);
URL remoteURL = getProjectData().getRootFolder().getSharedProjectURL();
if (remoteURL != null) {
remoteURL = GhidraURL.getProjectURL(url);
}
if (remoteURL.equals(url)) {
return fileMgr;
}
synchronized (otherViews) {
return otherViews.get(url);
}
}
@Override