From 04ddbf5981398744453a181796c89d28fe8d3fe5 Mon Sep 17 00:00:00 2001 From: emteere <47253321+emteere@users.noreply.github.com> Date: Fri, 9 Oct 2020 17:39:08 -0400 Subject: [PATCH] Fixes for building SleighEditor, buildreadme, and added popcount to grammar --- .../ghidra.xtext.sleigh.ide/build.gradle | 10 ++++++++++ .../ghidra.xtext.sleigh.tests/build.gradle | 10 ++++++++++ .../ghidra/xtext/sleigh/tests/SleighParsingTest.xtend | 1 + .../ghidra.xtext.sleigh.ui.tests/build.gradle | 10 ++++++++++ .../ghidra.xtext.sleigh.ui/build.gradle | 10 ++++++++++ .../ghidra.xtext.sleigh/build.gradle | 10 ++++++++++ .../ghidra.xtext.sleigh/build_README.txt | 6 ++++-- .../src/ghidra/xtext/sleigh/Sleigh.xtext | 1 + 8 files changed, 56 insertions(+), 2 deletions(-) diff --git a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ide/build.gradle b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ide/build.gradle index 346edff8af..47fb6a0d3c 100644 --- a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ide/build.gradle +++ b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ide/build.gradle @@ -5,6 +5,16 @@ apply plugin: 'java' if (hasProperty("eclipseDSL")) { apply plugin: 'eclipse' eclipse { + // Check to make sure the generated build folders exists + def srcGenFolder = file ("src-gen") + if (!srcGenFolder.exists()) { + srcGenFolder.mkdirs() + } + def xtendGenFolder = file ("xtend-gen") + if (!xtendGenFolder.exists()) { + xtendGenFolder.mkdirs() + } + project { name = 'Eclipse SleighEditor IDE' buildCommand 'org.eclipse.pde.ManifestBuilder' diff --git a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.tests/build.gradle b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.tests/build.gradle index f2266d2784..2868767233 100644 --- a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.tests/build.gradle +++ b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.tests/build.gradle @@ -5,6 +5,16 @@ apply plugin: 'java' if (hasProperty("eclipseDSL")) { apply plugin: 'eclipse' eclipse { + // Check to make sure the generated build folders exists + def srcGenFolder = file ("src-gen") + if (!srcGenFolder.exists()) { + srcGenFolder.mkdirs() + } + def xtendGenFolder = file ("xtend-gen") + if (!xtendGenFolder.exists()) { + xtendGenFolder.mkdirs() + } + project { name = 'Eclipse SleighEditor Tests' buildCommand 'org.eclipse.pde.ManifestBuilder' diff --git a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.tests/src/ghidra/xtext/sleigh/tests/SleighParsingTest.xtend b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.tests/src/ghidra/xtext/sleigh/tests/SleighParsingTest.xtend index 21c62985f6..a2a075d8b9 100644 --- a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.tests/src/ghidra/xtext/sleigh/tests/SleighParsingTest.xtend +++ b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.tests/src/ghidra/xtext/sleigh/tests/SleighParsingTest.xtend @@ -181,6 +181,7 @@ class SleighParsingTest { @if defined(ENDIAN) reg = tmp; @endif + tmp = popcount(CC); } Dest: loc is op=0 [ loc = inst_next; ] { export loc; } diff --git a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ui.tests/build.gradle b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ui.tests/build.gradle index 3057f75f08..f297a4d46d 100644 --- a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ui.tests/build.gradle +++ b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ui.tests/build.gradle @@ -5,6 +5,16 @@ apply plugin: 'java' if (hasProperty("eclipseDSL")) { apply plugin: 'eclipse' eclipse { + // Check to make sure the generated build folders exists + def srcGenFolder = file ("src-gen") + if (!srcGenFolder.exists()) { + srcGenFolder.mkdirs() + } + def xtendGenFolder = file ("xtend-gen") + if (!xtendGenFolder.exists()) { + xtendGenFolder.mkdirs() + } + project { name = 'Eclipse SleighEditor UI Tests' buildCommand 'org.eclipse.pde.ManifestBuilder' diff --git a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ui/build.gradle b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ui/build.gradle index 8f18815c74..d6088f4ca0 100644 --- a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ui/build.gradle +++ b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh.ui/build.gradle @@ -5,6 +5,16 @@ apply plugin: 'java' if (hasProperty("eclipseDSL")) { apply plugin: 'eclipse' eclipse { + // Check to make sure the generated build folders exists + def srcGenFolder = file ("src-gen") + if (!srcGenFolder.exists()) { + srcGenFolder.mkdirs() + } + def xtendGenFolder = file ("xtend-gen") + if (!xtendGenFolder.exists()) { + xtendGenFolder.mkdirs() + } + project { name = 'Eclipse SleighEditor UI' buildCommand 'org.eclipse.pde.ManifestBuilder' diff --git a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/build.gradle b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/build.gradle index b824254ccc..534e0c6d0f 100644 --- a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/build.gradle +++ b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/build.gradle @@ -5,6 +5,16 @@ apply plugin: 'java' if (hasProperty("eclipseDSL")) { apply plugin: 'eclipse' eclipse { + // Check to make sure the generated build folders exists + def srcGenFolder = file ("src-gen") + if (!srcGenFolder.exists()) { + srcGenFolder.mkdirs() + } + def xtendGenFolder = file ("xtend-gen") + if (!xtendGenFolder.exists()) { + xtendGenFolder.mkdirs() + } + project { name = 'Eclipse SleighEditor' buildCommand 'org.eclipse.pde.ManifestBuilder' diff --git a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/build_README.txt b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/build_README.txt index ab599c09e1..5497a9a2b6 100644 --- a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/build_README.txt +++ b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/build_README.txt @@ -13,13 +13,13 @@ have added 80Meg. Importing GhidraSleighEditor Eclipse projects (they are deactivated by default): 1) Uncomment the line in settings.gradle that includes the GhidraSleighEditor project. - 2) Run "gradle eclipse -PSleighEditor" to generate the GhidraSleighEditor Eclipse projects. + 2) Run "gradle eclipse -PeclipseDSL" to generate the GhidraSleighEditor Eclipse projects. 3) From Eclipse, File --> Import --> General --> Existing Projects into Workspace 4) From the ghidra repo, import all "Eclipse GhidraSleighEditor *" projects. Generating all Sleigh XTEXT generated files: - 1) open ghidra.xtext.sleigh project + 1) open "Eclipse SleighEditor" project 2) navigate to the file src --> ghidra.xtext.sleigh --> GenerateSleigh.mwe2 3) NOTE: the following will download a jar file from the internet (not from NSA) unless you pre-download. @@ -28,6 +28,8 @@ Generating all Sleigh XTEXT generated files: 3c) Rename the file to .antlr-generator-3.2.0-patch.jar 3) From the popup menu RunAs --> MWE2 Workflow - Files in xtend-gen and src-gen will be created + 4) If there are any red bookmarks on any of the Eclipse Sliehg* projects, + - Select all the Eclipse Sleigh* projects, and refresh from the popup menu - The project should rebuild, and there should be no red Problem errors diff --git a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/src/ghidra/xtext/sleigh/Sleigh.xtext b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/src/ghidra/xtext/sleigh/Sleigh.xtext index d5d22878df..844e1df12f 100644 --- a/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/src/ghidra/xtext/sleigh/Sleigh.xtext +++ b/GhidraBuild/EclipsePlugins/GhidraSleighEditor/ghidra.xtext.sleigh/src/ghidra/xtext/sleigh/Sleigh.xtext @@ -658,6 +658,7 @@ exprSingle returns Expression: | pcodeop='ceil' '(' op1=expr ')' | pcodeop='floor' '(' op1=expr ')' | pcodeop='round' '(' op1=expr ')' + | pcodeop='popcount' '(' op1=expr ')' | pcodeop='cpool' '(' op1=expr ',' op2=expr ',' op3=expr ')' | pcodeop='newobject' '(' op1=newObjParams ')' | op=[macroOrPcode] op1=paramlist