From 30df737334c53b62d0a3c2eb9fbc02bcb4cd6984 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Mon, 1 Jun 2020 13:30:02 -0400 Subject: [PATCH 1/2] PyDev source directory can now be found in the Eclipse dropins directory Updating GhidraDev version to 2.1.1 --- .../GhidraDev/GhidraDevFeature/category.xml | 2 +- .../GhidraDev/GhidraDevFeature/feature.xml | 2 +- .../GhidraDevPlugin/GhidraDev_README.html | 4 +- .../GhidraDevPlugin/META-INF/MANIFEST.MF | 2 +- .../utils/PyDevUtils.java | 47 ++++++++++++++----- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevFeature/category.xml b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevFeature/category.xml index c04702a7a4..c97bad1bd1 100644 --- a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevFeature/category.xml +++ b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevFeature/category.xml @@ -1,6 +1,6 @@ - + diff --git a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevFeature/feature.xml b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevFeature/feature.xml index a12a0a45be..b014ffeb63 100644 --- a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevFeature/feature.xml +++ b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevFeature/feature.xml @@ -2,7 +2,7 @@ diff --git a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/GhidraDev_README.html b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/GhidraDev_README.html index ced223204e..c3c0c8cf21 100644 --- a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/GhidraDev_README.html +++ b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/GhidraDev_README.html @@ -19,7 +19,7 @@

GhidraDev README

GhidraDev provides support for developing and debugging Ghidra scripts and modules in Eclipse.

-

The information provided in this document is effective as of GhidraDev 2.1.0 and is subject to +

The information provided in this document is effective as of GhidraDev 2.1.1 and is subject to change with future releases.

    @@ -53,6 +53,8 @@ change with future releases.

Change History

+

2.1.1: Python debugging now works when PyDev is installed via the Eclipse "dropins" +directory.

2.1.0:

  • diff --git a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/META-INF/MANIFEST.MF b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/META-INF/MANIFEST.MF index b2d2405b25..303b7e3f1b 100644 --- a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/META-INF/MANIFEST.MF +++ b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: GhidraDev Bundle-SymbolicName: ghidra.ghidradev;singleton:=true -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.1.1.qualifier Bundle-Activator: ghidradev.Activator Require-Bundle: org.eclipse.ant.core;bundle-version="3.5.200", org.eclipse.buildship.core;bundle-version="3.0.0", diff --git a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/PyDevUtils.java b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/PyDevUtils.java index a5301df55c..edb9b1b0e3 100644 --- a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/PyDevUtils.java +++ b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/PyDevUtils.java @@ -16,14 +16,27 @@ package ghidradev.ghidraprojectcreator.utils; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; import javax.naming.OperationNotSupportedException; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; +import ghidradev.Activator; + /** * Utility methods for interacting with PyDev. */ @@ -142,21 +155,33 @@ public class PyDevUtils { * Gets The PyDev source directory. * * @return The PyDev source directory, or null if it was not found. + * @throws CoreException if there was a problem searching for the PyDev source directory. */ - public static File getPyDevSrcDir() { + public static File getPyDevSrcDir() throws CoreException { String eclipsePath = Platform.getInstallLocation().getURL().getFile(); - File pluginsDir = new File(eclipsePath, "plugins"); - File[] pluginSubDirs = pluginsDir.listFiles(File::isDirectory); - if (pluginSubDirs != null) { - for (File dir : pluginSubDirs) { - if (dir.getName().startsWith("org.python.pydev")) { - File pysrcDir = new File(dir, "pysrc"); - if (pysrcDir.isDirectory()) { - return pysrcDir; - } + + List searchDirs = new ArrayList<>(); + searchDirs.add(new File(eclipsePath, "plugins")); + searchDirs.add(new File(eclipsePath, "dropins")); + + for (File searchRoot : searchDirs) { + try (Stream paths = Files.walk(Paths.get(searchRoot.toURI()))) { + Optional pysrcDir = paths.filter( + Files::isDirectory) + .filter(p -> p.endsWith("pysrc")) + .map(p -> p.toFile()) + .filter(f -> f.getParentFile().getName().startsWith("org.python.pydev")) + .findFirst(); + if (pysrcDir.isPresent()) { + return pysrcDir.get(); } } + catch (IOException e) { + throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, + IStatus.ERROR, "Problem searching for PyDev source directory", e)); + } } + return null; } } From 7391472a5609a9a0d698048c980c7cbace956b9b Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Tue, 22 Sep 2020 15:02:52 -0400 Subject: [PATCH 2/2] GP-186- Ghidra Dev - updated build docs Closes #1922 --- .../GhidraDev/GhidraDevPlugin/build_README.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build_README.txt b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build_README.txt index d9d898acda..bbd691628e 100644 --- a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build_README.txt +++ b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/build_README.txt @@ -6,8 +6,7 @@ NOTE: Only "Eclipse for RCP and RAP Developers" has the ability to do the below following instructions assume that you are using this version of Eclipse. Importing GhidraDev Eclipse projects (they are deactivated by default): - 1) Uncomment the line in settings.gradle that includes the GhidraDev project. - 2) Run "gradle eclipse" to generate the GhidraDev Eclipse projects. + 1) Run gradle eclipse -PeclipsePDE 3) From Eclipse, File --> Import --> General --> Existing Projects into Workspace 4) From the ghidra repo, import "Eclipse GhidraDevFeature" and "Eclipse GhidraDevPlugin". @@ -27,7 +26,7 @@ Building from Eclipse: 2) File --> Export --> Plug-in Development --> Deployable features 3) Check ghidra.ghidradev (x.y.z.qualifier) 4) Select "Archive file" and choose a directory to save it to. It must end up in - ghidra.bin/GhidraBuild/Eclipse/GhidraDev/. Name it GhidraDev-x.y.z.zip. + ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/. Name it GhidraDev-x.y.z.zip. 5) In the "Options" tab make sure things look like this: - Export source: UNCHECKED - Package as individual JAR archives: CHECKED