Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/patch'
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmkurtz committed Aug 26, 2021
2 parents 044e8ae + 0c0fdff commit 91aea06
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ protected Instruction doAddInstructions(Range<Long> lifespan, Iterator<Instructi
lastInstruction = replaceIfNotNull(lastInstruction,
doAddInstructions(lifespan, delayed.iterator(), true));
}
else {
lastInstruction =
doCreateInstruction(lifespan, startAddress, prototype, protoInstr);
}
lastInstruction =
doCreateInstruction(lifespan, startAddress, prototype, protoInstr);
}
if (errorAddress != null && conflictCodeUnit == null &&
errorAddress.compareTo(startAddress) <= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.common.collect.Range;

import ghidra.app.cmd.disassemble.ArmDisassembleCommand;
import ghidra.app.cmd.disassemble.MipsDisassembleCommand;
import ghidra.program.database.ProgramBuilder;
import ghidra.program.disassemble.Disassembler;
import ghidra.program.model.address.AddressOverflowException;
Expand Down Expand Up @@ -209,10 +210,37 @@ public void testThumbSampleDBTrace() throws Exception {
new ArmDisassembleCommand(b.addr(0xb6fa2cdc), restricted, true);
thumbDis.applyTo(b.trace.getFixedProgramView(0), TaskMonitor.DUMMY);

CodeUnit cu1 = b.trace.getCodeManager().codeUnits().getAt(0, b.addr(0xb6fa2cdc));
DBTraceCodeUnitsMemoryView cuManager = b.trace.getCodeManager().codeUnits();
CodeUnit cu1 = cuManager.getAt(0, b.addr(0xb6fa2cdc));
assertEquals("push { r4, r5, r6, r7, r8, lr }", cu1.toString());
CodeUnit cu2 = b.trace.getCodeManager().codeUnits().getAt(0, b.addr(0xb6fa2ce0));
CodeUnit cu2 = cuManager.getAt(0, b.addr(0xb6fa2ce0));
assertEquals("sub sp,#0x1d8", cu2.toString());
}
}

@Test
@TestLanguage("MIPS:BE:64:default")
public void testDelaySlotSampleDBTrace() throws Exception {
try (UndoableTransaction tid = b.startTransaction()) {
DBTraceMemoryManager memory = b.trace.getMemoryManager();
memory.createRegion(".text", 0, b.range(0x120000000L, 0x120010000L),
Set.of(TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE));
memory.putBytes(0, b.addr(0x1200035b4L), b.buf(
// bal LAB_1200035bc
0x04, 0x11, 0x00, 0x01,
// _nop
0x00, 0x00, 0x00, 0x00));

AddressSet restricted = new AddressSet(b.addr(0x1200035b4L), b.addr(0x1200035bbL));
MipsDisassembleCommand mipsDis =
new MipsDisassembleCommand(b.addr(0x1200035b4L), restricted, false);
mipsDis.applyTo(b.trace.getFixedProgramView(0), TaskMonitor.DUMMY);

DBTraceCodeUnitsMemoryView cuManager = b.trace.getCodeManager().codeUnits();
CodeUnit cu1 = cuManager.getAt(0, b.addr(0x1200035b4L));
assertEquals("bal 0x1200035bc", cu1.toString());
CodeUnit cu2 = cuManager.getAt(0, b.addr(0x1200035b8L));
assertEquals("_nop", cu2.toString());
}
}
}
2 changes: 1 addition & 1 deletion Ghidra/Features/Base/.launch/Ghidra.launch
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="Framework Utility"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="ghidra.GhidraRun"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Framework Utility"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:+IgnoreUnrecognizedVMOptions -Djava.system.class.loader=ghidra.GhidraClassLoader -Xshare:off -Dfile.encoding=UTF8 -Duser.country=US -Duser.language=en -Dsun.java2d.pmoffscreen=false -Dsun.java2d.xrender=true -Dsun.java2d.d3d=false -Xdock:name=&quot;Ghidra&quot; -Dvisualvm.display.name=Ghidra -Dpython.console.encoding=UTF-8 -DContinuesInterceptor.disabled=true --illegal-access=permit"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:+IgnoreUnrecognizedVMOptions -Djava.system.class.loader=ghidra.GhidraClassLoader -Xshare:off -Dfile.encoding=UTF8 -Duser.country=US -Duser.language=en -Dsun.java2d.pmoffscreen=false -Dsun.java2d.xrender=true -Dsun.java2d.d3d=false -Xdock:name=&quot;Ghidra&quot; -Dvisualvm.display.name=Ghidra -Dpython.console.encoding=UTF-8 --illegal-access=permit"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ PARSER_END(CParser)

TOKEN_MGR_DECLS :
{
static int parenNesting = 0;
int parenNesting = 0;
}

SKIP :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public class PreProcessor {
private HashMap<String, Integer> alreadyDone;

// Toggle printing
private static int verboseLevel = 0;
private int verboseLevel = 0;

public int verboseLevel() {
int vl = verboseLevel;
Expand Down Expand Up @@ -1125,6 +1125,7 @@ public class PreProcessor {
this.pathList = parent.pathList;
this.shift = parent.shift;
this.alreadyDone = parent.alreadyDone;
this.verboseLevel = parent.verboseLevel;
}

public PreProcessor(String[] args) throws ParseException {
Expand Down Expand Up @@ -2174,7 +2175,7 @@ PPToken ValueExpression() :
// LEXICAL SCANNER SECTION
TOKEN_MGR_DECLS :
{
static int parenNesting = 0;
int parenNesting = 0;
}

<DEFAULT>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class ContinuesFactory implements GenericFactory {

private static final boolean disabled = Boolean.getBoolean("ContinuesInterceptor.disabled");
private static final boolean enabled = Boolean.getBoolean("ContinuesInterceptor.enabled");

private ExceptionHandler exceptionHandler;

Expand All @@ -36,7 +36,7 @@ public ContinuesFactory(ExceptionHandler exceptionHandler) {
public Object create(Class<?> type, Object... args) {
try {
Object thing;
if (disabled) {
if (!enabled) {
Constructor<?> c = type.getConstructor(new Class<?>[0]);
thing = c.newInstance(args);
}
Expand Down
6 changes: 3 additions & 3 deletions Ghidra/RuntimeScripts/Common/support/launch.properties
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ VMARGS=--illegal-access=permit
#VMARGS=-Ddisable.alternating.row.colors=true

# The ContinuesInterceptor allows the import process to proceed if parsing corrupted headers
# generates uncaught exceptions. Disabling it can be helpful when trying to debug what went
# wrong because the ContinuesIntercepter affects the usefulness of the stack trace.
#VMARGS=-DContinuesInterceptor.disabled=true
# generates uncaught exceptions. Its usage has been deprecated and will be removed in a future
# release of Ghidra. It is disabled by default.
#VMARGS=-DContinuesInterceptor.enabled=true

# Limit on XML parsing. See https://docs.oracle.com/javase/tutorial/jaxp/limits/limits.html
#VMARGS=-Djdk.xml.totalEntitySizeLimit=50000000
Expand Down

0 comments on commit 91aea06

Please sign in to comment.