Merge remote-tracking branch 'origin/Ghidra_11.4'

This commit is contained in:
ghidra1 2025-06-06 18:50:01 -04:00
commit f981f43fad
183 changed files with 3088 additions and 3278 deletions

View file

@ -236,8 +236,7 @@ public class PopulateDemoTrace extends GhidraScript {
return;
}
TraceCodeSpace code =
thread.getTrace().getCodeManager().getCodeRegisterSpace(thread, true);
TraceCodeSpace code = thread.getTrace().getCodeManager().getCodeRegisterSpace(thread, true);
code.definedUnits().clear(Lifespan.nowOn(tick), reg, TaskMonitor.DUMMY);
code.definedData().create(Lifespan.nowOn(tick), reg, PointerDataType.dataType);
}
@ -344,20 +343,16 @@ public class PopulateDemoTrace extends GhidraScript {
*/
mainLabel = trace.getSymbolManager()
.labels()
.create(snap, null, addr(0x00400000),
"main", global, SourceType.USER_DEFINED);
.create(snap, null, addr(0x00400000), "main", global, SourceType.USER_DEFINED);
cloneLabel = trace.getSymbolManager()
.labels()
.create(snap, null, addr(0x00400060),
"clone", global, SourceType.USER_DEFINED);
.create(snap, null, addr(0x00400060), "clone", global, SourceType.USER_DEFINED);
childLabel = trace.getSymbolManager()
.labels()
.create(snap, null, addr(0x00400034),
"child", global, SourceType.USER_DEFINED);
.create(snap, null, addr(0x00400034), "child", global, SourceType.USER_DEFINED);
exitLabel = trace.getSymbolManager()
.labels()
.create(snap, null, addr(0x00400061),
"exit", global, SourceType.USER_DEFINED);
.create(snap, null, addr(0x00400061), "exit", global, SourceType.USER_DEFINED);
/**
* Note the use of getProgramView as a means of using components intended for Program
@ -502,9 +497,9 @@ public class PopulateDemoTrace extends GhidraScript {
regs2.putBytes(snap, reg("RSP"),
buf.clear().putLong(STACK2_BOTTOM + stack2offset).flip());
regs2.putBytes(snap, reg("RAX"), buf.clear().putLong(1).flip());
memory.putBytes(snap, addr(STACK2_BOTTOM + stack2offset), buf.clear()
.putLong(
mainInstructions.get(pc2 = pc1).getAddress().getOffset())
memory.putBytes(snap, addr(STACK2_BOTTOM + stack2offset),
buf.clear()
.putLong(mainInstructions.get(pc2 = pc1).getAddress().getOffset())
.flip());
placeRegUnits(snap, thread1);

View file

@ -309,12 +309,11 @@ public class DebuggerCopyPlan {
long off = addr.subtract(fromRange.getMinAddress());
Address dest = intoAddress.add(off);
// Ugly, but there's not MAX/MIN_COMMENT_TYPE
for (int i = CodeUnit.EOL_COMMENT; i <= CodeUnit.REPEATABLE_COMMENT; i++) {
String comment = fromListing.getComment(i, addr);
if (comment == null) {
continue;
for (CommentType type : CommentType.values()) {
String comment = fromListing.getComment(type, addr);
if (comment != null) {
intoListing.setComment(dest, type, comment);
}
intoListing.setComment(dest, i, comment);
}
}
}

View file

@ -144,16 +144,14 @@ public class AnalysisUnwoundFrame<T> extends AbstractUnwoundFrame<T> {
info.mapSavedRegisters(base, registerMap);
Address pcVal = info.computeNextPc(base, state, codeSpace, pc);
Address spVal = info.computeNextSp(base);
return unwinder.unwind(coordinates, level + 1, pcVal, spVal, state, registerMap,
monitor);
return unwinder.unwind(coordinates, level + 1, pcVal, spVal, state, registerMap, monitor);
}
@Override
protected Address applyBase(long offset) {
if (base == null) {
throw new UnwindException(
"Cannot compute stack address for offset %d.\nFrame error: %s".formatted(offset,
info.error().getMessage()),
throw new UnwindException("Cannot compute stack address for offset %d.\nFrame error: %s"
.formatted(offset, info.error().getMessage()),
info.error());
}
return base.add(offset);
@ -191,8 +189,7 @@ public class AnalysisUnwoundFrame<T> extends AbstractUnwoundFrame<T> {
@Override
public String getDescription() {
return String.format("%s %s pc=%s sp=%s base=%s",
level, info.function(),
return String.format("%s %s pc=%s sp=%s base=%s", level, info.function(),
pcVal == null ? null : pcVal.toString(false),
spVal == null ? null : spVal.toString(false),
base == null ? null : base.toString(false));

View file

@ -76,8 +76,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
r.nextBytes(src);
try (Transaction tx = tb.startTransaction()) {
DBTraceMemoryManager memory = tb.trace.getMemoryManager();
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff),
TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE);
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff), TraceMemoryFlag.READ,
TraceMemoryFlag.EXECUTE);
memory.putBytes(0, tb.addr(0x55550000), ByteBuffer.wrap(src));
}
@ -108,8 +108,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
try (Transaction tx = tb.startTransaction()) {
DBTraceMemoryManager memory = tb.trace.getMemoryManager();
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff),
TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE);
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff), TraceMemoryFlag.READ,
TraceMemoryFlag.EXECUTE);
memory.putBytes(0, tb.addr(0x55550000), ByteBuffer.allocate(4096));
memory.setState(0, tb.addr(0x55551000), TraceMemoryState.ERROR);
}
@ -126,11 +126,9 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
IntRangeMap map =
program.getIntRangeMap(PropertyBasedBackgroundColorModel.COLOR_PROPERTY_NAME);
AddressSet staleSet =
map.getAddressSet(DebuggerResources.COLOR_BACKGROUND_STALE.getRGB());
AddressSet staleSet = map.getAddressSet(DebuggerResources.COLOR_BACKGROUND_STALE.getRGB());
assertEquals(tb.set(tb.range(stSpace, 0x00401001, 0x0040ffff)), staleSet);
AddressSet errorSet =
map.getAddressSet(DebuggerResources.COLOR_BACKGROUND_ERROR.getRGB());
AddressSet errorSet = map.getAddressSet(DebuggerResources.COLOR_BACKGROUND_ERROR.getRGB());
assertEquals(tb.set(tb.range(stSpace, 0x00401000, 0x00401000)), errorSet);
}
@ -186,10 +184,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
try (Transaction tx = tb.startTransaction()) {
DBTraceMemoryManager memory = tb.trace.getMemoryManager();
memory.createRegion(".text", 0, trng, TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE);
InstructionIterator iit = asm.assemble(tb.addr(0x55550000),
"imm r0, #123",
"imm r1, #234",
"add r0, r1");
InstructionIterator iit =
asm.assemble(tb.addr(0x55550000), "imm r0, #123", "imm r1, #234", "add r0, r1");
assertTrue(iit.hasNext());
}
@ -234,10 +230,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
try (Transaction tx = tb.startTransaction()) {
DBTraceMemoryManager memory = tb.trace.getMemoryManager();
memory.createRegion(".text", 0, trng, TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE);
InstructionIterator iit = asm.assemble(tb.addr(0x55550000),
"MOV RAX, 1234",
"MOV RCX, 2345",
"ADD RAX, RCX");
InstructionIterator iit =
asm.assemble(tb.addr(0x55550000), "MOV RAX, 1234", "MOV RCX, 2345", "ADD RAX, RCX");
assertTrue(iit.hasNext());
}
@ -299,8 +293,7 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
"ADD EAX, ECX");
checkCtx = iit.next();
*/
memory.putBytes(0, tb.addr(0x55550000), tb.buf(
0xb8, 0xd2, 0x04, 0x00, 0x00, // MOV EAX,1234
memory.putBytes(0, tb.addr(0x55550000), tb.buf(0xb8, 0xd2, 0x04, 0x00, 0x00, // MOV EAX,1234
0xb9, 0x29, 0x09, 0x00, 0x00, // MOV ECX,2345
0x01, 0xc8 // ADD EAX,ECX
));
@ -487,8 +480,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
try (Transaction tx = tb.startTransaction()) {
DBTraceMemoryManager memory = tb.trace.getMemoryManager();
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff),
TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE);
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff), TraceMemoryFlag.READ,
TraceMemoryFlag.EXECUTE);
DBTraceNamespaceSymbol global = tb.trace.getSymbolManager().getGlobalNamespace();
DBTraceLabelSymbolView labels = tb.trace.getSymbolManager().labels();
@ -558,8 +551,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
try (Transaction tx = tb.startTransaction()) {
DBTraceMemoryManager memory = tb.trace.getMemoryManager();
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff),
TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE);
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff), TraceMemoryFlag.READ,
TraceMemoryFlag.EXECUTE);
DBTraceBreakpointManager breakpoints = tb.trace.getBreakpointManager();
breakpoints.placeBreakpoint("[1]", 0, tb.addr(0x55550123), List.of(),
@ -571,8 +564,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
Address paddr = tb.addr(stSpace, 0x55550000);
try (Transaction tx = program.openTransaction("Init")) {
program.getMemory()
.createInitializedBlock(".text", paddr, 0x10000,
(byte) 0, TaskMonitor.DUMMY, false);
.createInitializedBlock(".text", paddr, 0x10000, (byte) 0, TaskMonitor.DUMMY,
false);
// Set up a collision. This is normal with relocations
program.getBookmarkManager()
.setBookmark(tb.addr(stSpace, 0x55550123), "BreakpointDisabled", "SW_EXECUTE;1",
@ -611,8 +604,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
try (Transaction tx = tb.startTransaction()) {
DBTraceMemoryManager memory = tb.trace.getMemoryManager();
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff),
TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE);
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff), TraceMemoryFlag.READ,
TraceMemoryFlag.EXECUTE);
BookmarkManager bookmarks = view.getBookmarkManager();
bookmarks.defineType("TestType", DebuggerResources.ICON_DEBUGGER, Palette.BLUE, 1);
@ -622,8 +615,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
Address paddr = tb.addr(stSpace, 0x55550000);
try (Transaction tx = program.openTransaction("Init")) {
program.getMemory()
.createInitializedBlock(".text", paddr, 0x10000,
(byte) 0, TaskMonitor.DUMMY, false);
.createInitializedBlock(".text", paddr, 0x10000, (byte) 0, TaskMonitor.DUMMY,
false);
AllCopiers.BOOKMARKS.copy(view, tb.range(0x55550000, 0x5555ffff), program, paddr,
TaskMonitor.DUMMY);
@ -659,27 +652,27 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
try (Transaction tx = tb.startTransaction()) {
DBTraceMemoryManager memory = tb.trace.getMemoryManager();
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff),
TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE);
memory.createRegion(".data", 0, tb.range(0x55560000, 0x5556ffff),
TraceMemoryFlag.READ, TraceMemoryFlag.WRITE);
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff), TraceMemoryFlag.READ,
TraceMemoryFlag.EXECUTE);
memory.createRegion(".data", 0, tb.range(0x55560000, 0x5556ffff), TraceMemoryFlag.READ,
TraceMemoryFlag.WRITE);
ReferenceManager references = view.getReferenceManager();
references.addMemoryReference(tb.addr(0x55550123),
tb.addr(0x55550321), RefType.COMPUTED_CALL, SourceType.USER_DEFINED, -1);
references.addMemoryReference(tb.addr(0x55550123),
tb.addr(0x55560321), RefType.READ, SourceType.USER_DEFINED, -1);
references.addMemoryReference(tb.addr(0x55560123),
tb.addr(0x55550321), RefType.PARAM, SourceType.USER_DEFINED, -1);
references.addMemoryReference(tb.addr(0x55560123),
tb.addr(0x55560321), RefType.DATA, SourceType.USER_DEFINED, -1);
references.addMemoryReference(tb.addr(0x55550123), tb.addr(0x55550321),
RefType.COMPUTED_CALL, SourceType.USER_DEFINED, -1);
references.addMemoryReference(tb.addr(0x55550123), tb.addr(0x55560321), RefType.READ,
SourceType.USER_DEFINED, -1);
references.addMemoryReference(tb.addr(0x55560123), tb.addr(0x55550321), RefType.PARAM,
SourceType.USER_DEFINED, -1);
references.addMemoryReference(tb.addr(0x55560123), tb.addr(0x55560321), RefType.DATA,
SourceType.USER_DEFINED, -1);
}
Address paddr = tb.addr(stSpace, 0x55550000);
try (Transaction tx = program.openTransaction("Init")) {
program.getMemory()
.createInitializedBlock(".text", paddr, 0x10000,
(byte) 0, TaskMonitor.DUMMY, false);
.createInitializedBlock(".text", paddr, 0x10000, (byte) 0, TaskMonitor.DUMMY,
false);
AllCopiers.REFERENCES.copy(view, tb.range(0x55550000, 0x5555ffff), program, paddr,
TaskMonitor.DUMMY);
@ -710,8 +703,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
try (Transaction tx = tb.startTransaction()) {
DBTraceMemoryManager memory = tb.trace.getMemoryManager();
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff),
TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE);
memory.createRegion(".text", 0, tb.range(0x55550000, 0x5555ffff), TraceMemoryFlag.READ,
TraceMemoryFlag.EXECUTE);
Listing listing = view.getListing();
listing.setComment(tb.addr(0x55550123), CommentType.EOL, "Test EOL Comment");
@ -721,8 +714,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
Address paddr = tb.addr(stSpace, 0x55550000);
try (Transaction tx = program.openTransaction("Init")) {
program.getMemory()
.createInitializedBlock(".text", paddr, 0x10000,
(byte) 0, TaskMonitor.DUMMY, false);
.createInitializedBlock(".text", paddr, 0x10000, (byte) 0, TaskMonitor.DUMMY,
false);
AllCopiers.COMMENTS.copy(view, tb.range(0x55550000, 0x5555ffff), program, paddr,
TaskMonitor.DUMMY);

View file

@ -15,7 +15,7 @@
*/
package ghidra.trace.database.listing;
import static ghidra.lifecycle.Unfinished.TODO;
import static ghidra.lifecycle.Unfinished.*;
import java.nio.ByteBuffer;
import java.util.*;
@ -27,6 +27,7 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressRangeImpl;
import ghidra.program.model.lang.Register;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.mem.*;
import ghidra.program.model.symbol.*;
import ghidra.trace.database.DBTrace;
@ -128,8 +129,7 @@ public interface DBTraceCodeUnitAdapter extends TraceCodeUnit, MemBufferMixin {
@Override
default <T> T getProperty(String name, Class<T> valueClass) {
try (LockHold hold = LockHold.lock(getTrace().getReadWriteLock().readLock())) {
TracePropertyMap<? extends T> map =
getTrace().getInternalAddressPropertyManager()
TracePropertyMap<? extends T> map = getTrace().getInternalAddressPropertyManager()
.getPropertyMapExtends(name, valueClass);
if (map == null) {
return null;
@ -250,17 +250,16 @@ public interface DBTraceCodeUnitAdapter extends TraceCodeUnit, MemBufferMixin {
}
@Override
default void setComment(int commentType, String comment) {
default void setComment(CommentType commentType, String comment) {
if (getThread() != null) {
TODO(); // TODO: Comments in register space
}
getTrace().getCommentAdapter()
.setComment(getLifespan(), getAddress(), commentType,
comment);
.setComment(getLifespan(), getAddress(), commentType, comment);
}
@Override
default String getComment(int commentType) {
default String getComment(CommentType commentType) {
if (getThread() != null) {
// TODO: Comments in register space
return null;
@ -269,12 +268,12 @@ public interface DBTraceCodeUnitAdapter extends TraceCodeUnit, MemBufferMixin {
}
@Override
default void setCommentAsArray(int commentType, String[] comment) {
default void setCommentAsArray(CommentType commentType, String[] comment) {
setComment(commentType, DBTraceCommentAdapter.commentFromArray(comment));
}
@Override
default String[] getCommentAsArray(int commentType) {
default String[] getCommentAsArray(CommentType commentType) {
return DBTraceCommentAdapter.arrayFromComment(getComment(commentType));
}
@ -297,16 +296,15 @@ public interface DBTraceCodeUnitAdapter extends TraceCodeUnit, MemBufferMixin {
@Override
default void addMnemonicReference(Address refAddr, RefType refType, SourceType sourceType) {
getTrace().getReferenceManager()
.addMemoryReference(getLifespan(), getAddress(), refAddr,
refType, sourceType, MNEMONIC);
.addMemoryReference(getLifespan(), getAddress(), refAddr, refType, sourceType,
MNEMONIC);
}
@Override
default void addOperandReference(int index, Address refAddr, RefType type,
SourceType sourceType) {
getTrace().getReferenceManager()
.addMemoryReference(getLifespan(), getAddress(), refAddr,
type, sourceType, index);
.addMemoryReference(getLifespan(), getAddress(), refAddr, type, sourceType, index);
}
@Override
@ -319,16 +317,16 @@ public interface DBTraceCodeUnitAdapter extends TraceCodeUnit, MemBufferMixin {
default void setStackReference(int opIndex, int offset, SourceType sourceType,
RefType refType) {
getTrace().getReferenceManager()
.addStackReference(getLifespan(), getAddress(), offset,
refType, sourceType, opIndex);
.addStackReference(getLifespan(), getAddress(), offset, refType, sourceType,
opIndex);
}
@Override
default void setRegisterReference(int opIndex, Register reg, SourceType sourceType,
RefType refType) {
getTrace().getReferenceManager()
.addRegisterReference(getLifespan(), getAddress(), reg,
refType, sourceType, opIndex);
.addRegisterReference(getLifespan(), getAddress(), reg, refType, sourceType,
opIndex);
}
@Override
@ -346,8 +344,7 @@ public interface DBTraceCodeUnitAdapter extends TraceCodeUnit, MemBufferMixin {
@Override
default DBTraceReference getPrimaryReference(int index) {
return getTrace().getReferenceManager()
.getPrimaryReferenceFrom(getStartSnap(), getAddress(),
index);
.getPrimaryReferenceFrom(getStartSnap(), getAddress(), index);
}
@Override
@ -359,8 +356,7 @@ public interface DBTraceCodeUnitAdapter extends TraceCodeUnit, MemBufferMixin {
@Override
default ReferenceIterator getReferenceIteratorTo() {
return new ReferenceIteratorAdapter(
getTrace().getReferenceManager()
return new ReferenceIteratorAdapter(getTrace().getReferenceManager()
.getReferencesTo(getStartSnap(), getAddress())
.iterator());
}
@ -377,8 +373,7 @@ public interface DBTraceCodeUnitAdapter extends TraceCodeUnit, MemBufferMixin {
@Override
default void removeOperandReference(int index, Address refAddr) {
TraceReference ref =
getTrace().getReferenceManager()
TraceReference ref = getTrace().getReferenceManager()
.getReference(getStartSnap(), getAddress(), refAddr, index);
if (ref == null) {
return;

View file

@ -25,7 +25,7 @@ import db.DBRecord;
import ghidra.framework.data.OpenMode;
import ghidra.program.model.address.*;
import ghidra.program.model.lang.Language;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Listing;
import ghidra.trace.database.DBTrace;
import ghidra.trace.database.DBTraceUtils;
@ -52,8 +52,6 @@ import ghidra.util.task.TaskMonitor;
public class DBTraceCommentAdapter
extends DBTraceAddressSnapRangePropertyMap<DBTraceCommentEntry, DBTraceCommentEntry> {
protected static final String[] EMPTY_STRING_ARRAY = new String[] {};
protected static final int MIN_COMMENT_TYPE = CodeUnit.EOL_COMMENT;
protected static final int MAX_COMMENT_TYPE = CodeUnit.REPEATABLE_COMMENT;
/**
* A comment entry
@ -136,15 +134,16 @@ public class DBTraceCommentAdapter
* @param commentType the type of comment as in {@link Listing#setComment(Address, int, String)}
* @param comment the comment
*/
public void setComment(Lifespan lifespan, Address address, int commentType, String comment) {
if (commentType < MIN_COMMENT_TYPE || commentType > MAX_COMMENT_TYPE) {
throw new IllegalArgumentException("commentType");
public void setComment(Lifespan lifespan, Address address, CommentType commentType,
String comment) {
if (commentType == null) {
throw new IllegalArgumentException("null commentType");
}
String oldValue = null;
try (LockHold hold = LockHold.lock(lock.writeLock())) {
for (DBTraceCommentEntry entry : reduce(TraceAddressSnapRangeQuery
.intersecting(new AddressRangeImpl(address, address), lifespan)).values()) {
if (entry.type == commentType) {
if (entry.type == commentType.ordinal()) {
if (entry.getLifespan().contains(lifespan.lmin())) {
oldValue = entry.comment;
}
@ -153,7 +152,7 @@ public class DBTraceCommentAdapter
}
if (comment != null) {
DBTraceCommentEntry entry = put(address, lifespan, null);
entry.set((byte) commentType, comment);
entry.set((byte) commentType.ordinal(), comment);
}
}
trace.setChanged(new TraceChangeRecord<TraceAddressSnapRange, String>(
@ -190,11 +189,11 @@ public class DBTraceCommentAdapter
* @param commentType the type of comment
* @return the comment text
*/
public String getComment(long snap, Address address, int commentType) {
public String getComment(long snap, Address address, CommentType commentType) {
try (LockHold hold = LockHold.lock(lock.readLock())) {
for (DBTraceCommentEntry entry : reduce(TraceAddressSnapRangeQuery.at(address, snap))
.values()) {
if (entry.type != commentType) {
if (entry.type != commentType.ordinal()) {
continue;
}
return entry.comment;
@ -208,13 +207,13 @@ public class DBTraceCommentAdapter
*
* @param span the lifespan fo the box
* @param range the address range of the box
* @param commentType a comment type to clear, or {@link CodeUnit#NO_COMMENT} to clear all.
* @param commentType a comment type to clear, or null to clear all.
*/
public void clearComments(Lifespan span, AddressRange range, int commentType) {
public void clearComments(Lifespan span, AddressRange range, CommentType commentType) {
try (LockHold hold = LockHold.lock(lock.writeLock())) {
for (DBTraceCommentEntry entry : reduce(
TraceAddressSnapRangeQuery.intersecting(range, span)).values()) {
if (commentType == CodeUnit.NO_COMMENT || entry.type == commentType) {
if (commentType == null || entry.type == commentType.ordinal()) {
makeWay(entry, span);
}
}

View file

@ -145,8 +145,7 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
}
protected Comparator<CodeUnit> getUnitComparator(boolean forward) {
return forward
? (u1, u2) -> u1.getMinAddress().compareTo(u2.getMinAddress())
return forward ? (u1, u2) -> u1.getMinAddress().compareTo(u2.getMinAddress())
: (u1, u2) -> -u1.getMinAddress().compareTo(u2.getMinAddress());
}
@ -160,8 +159,7 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
protected AddressSet getAddressSet(Address start, boolean forward) {
AddressFactory factory = program.getAddressFactory();
AddressSetView all = program.getAllAddresses();
return forward
? factory.getAddressSet(start, all.getMaxAddress())
return forward ? factory.getAddressSet(start, all.getMaxAddress())
: factory.getAddressSet(all.getMinAddress(), start);
}
@ -184,8 +182,8 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
}
protected Iterator<? extends TraceInstruction> getInstructionIterator(boolean forward) {
return getTopCodeIterator(
s -> codeOperations.instructions().get(s, forward).iterator(), forward);
return getTopCodeIterator(s -> codeOperations.instructions().get(s, forward).iterator(),
forward);
}
protected Iterator<? extends TraceData> getDefinedDataIterator(Address start, boolean forward) {
@ -195,13 +193,13 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
protected Iterator<? extends TraceData> getDefinedDataIterator(AddressSetView set,
boolean forward) {
return getTopCodeIterator(
s -> codeOperations.definedData().get(s, set, forward).iterator(), forward);
return getTopCodeIterator(s -> codeOperations.definedData().get(s, set, forward).iterator(),
forward);
}
protected Iterator<? extends TraceData> getDefinedDataIterator(boolean forward) {
return getTopCodeIterator(
s -> codeOperations.definedData().get(s, forward).iterator(), forward);
return getTopCodeIterator(s -> codeOperations.definedData().get(s, forward).iterator(),
forward);
}
protected Iterator<? extends TraceCodeUnit> getDefinedUnitIterator(Address start,
@ -226,8 +224,8 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
defStart = defUnit.getMinAddress();
}
}
Iterator<AddressRange> defIter = IteratorUtils.transformedIterator(
getDefinedUnitIterator(defStart, forward), u -> u.getRange());
Iterator<AddressRange> defIter = IteratorUtils
.transformedIterator(getDefinedUnitIterator(defStart, forward), u -> u.getRange());
AddressRangeIterator undefIter =
AddressRangeIterators.subtract(set.iterator(forward), defIter, start, forward);
AddressIteratorAdapter undefAddrIter = new AddressIteratorAdapter(undefIter, forward);
@ -236,8 +234,8 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
}
protected AddressRangeIterator getUndefinedRangeIterator(AddressSetView set, boolean forward) {
Iterator<AddressRange> defIter = IteratorUtils.transformedIterator(
getDefinedUnitIterator(set, forward), u -> u.getRange());
Iterator<AddressRange> defIter = IteratorUtils
.transformedIterator(getDefinedUnitIterator(set, forward), u -> u.getRange());
return AddressRangeIterators.subtract(set.iterator(forward), defIter,
forward ? set.getMinAddress() : set.getMaxAddress(), forward);
}
@ -267,17 +265,14 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
}
protected Iterator<TraceCodeUnit> getCodeUnitIterator(AddressSetView set, boolean forward) {
return new MergeSortingIterator<>(List.of(
getDefinedUnitIterator(set, forward),
getUndefinedDataIterator(set, forward)),
return new MergeSortingIterator<>(
List.of(getDefinedUnitIterator(set, forward), getUndefinedDataIterator(set, forward)),
getUnitComparator(forward));
}
protected Iterator<TraceCodeUnit> getCodeUnitIterator(Address start, boolean forward) {
return new MergeSortingIterator<>(List.of(
getDefinedUnitIterator(start, forward),
getUndefinedDataIterator(start, forward)),
getUnitComparator(forward));
return new MergeSortingIterator<>(List.of(getDefinedUnitIterator(start, forward),
getUndefinedDataIterator(start, forward)), getUnitComparator(forward));
}
protected Iterator<TraceCodeUnit> getCodeUnitIterator(boolean forward) {
@ -286,17 +281,14 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
}
protected Iterator<TraceData> getDataIterator(AddressSetView set, boolean forward) {
return new MergeSortingIterator<>(List.of(
getDefinedDataIterator(set, forward),
getUndefinedDataIterator(set, forward)),
return new MergeSortingIterator<>(
List.of(getDefinedDataIterator(set, forward), getUndefinedDataIterator(set, forward)),
getUnitComparator(forward));
}
protected Iterator<TraceData> getDataIterator(Address start, boolean forward) {
return new MergeSortingIterator<>(List.of(
getDefinedDataIterator(start, forward),
getUndefinedDataIterator(start, forward)),
getUnitComparator(forward));
return new MergeSortingIterator<>(List.of(getDefinedDataIterator(start, forward),
getUndefinedDataIterator(start, forward)), getUnitComparator(forward));
}
protected Iterator<TraceData> getDataIterator(boolean forward) {
@ -355,8 +347,9 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
return new WrappingCodeUnitIterator(Collections.emptyIterator());
}
// TODO: The property map doesn't heed forking.
return new WrappingCodeUnitIterator(NestedIterator.start(
map.getAddressSetView(Lifespan.at(program.snap)).iterator(forward),
return new WrappingCodeUnitIterator(
NestedIterator
.start(map.getAddressSetView(Lifespan.at(program.snap)).iterator(forward),
rng -> getTopCodeIterator(
s -> codeOperations.codeUnits().get(s, rng, forward).iterator(),
forward)));
@ -377,8 +370,9 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
return new WrappingCodeUnitIterator(Collections.emptyIterator());
}
// TODO: The property map doesn't heed forking.
return new WrappingCodeUnitIterator(NestedIterator.start(
map.getAddressSetView(Lifespan.at(program.snap)).iterator(addr, forward),
return new WrappingCodeUnitIterator(
NestedIterator
.start(map.getAddressSetView(Lifespan.at(program.snap)).iterator(addr, forward),
rng -> getTopCodeIterator(
s -> codeOperations.codeUnits().get(s, rng, forward).iterator(),
forward)));
@ -404,31 +398,30 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
new IntersectionAddressSetView(map.getAddressSetView(Lifespan.at(program.snap)),
addrSet).iterator(forward),
rng -> getTopCodeIterator(
s -> codeOperations.codeUnits().get(s, rng, forward).iterator(),
forward)));
s -> codeOperations.codeUnits().get(s, rng, forward).iterator(), forward)));
}
protected AddressSetView getCommentAddresses(int commentType, AddressSetView addrSet) {
return new IntersectionAddressSetView(addrSet, program.viewport.unionedAddresses(
s -> program.trace.getCommentAdapter()
.getAddressSetView(Lifespan.at(s), e -> e.getType() == commentType)));
protected AddressSetView getCommentAddresses(CommentType commentType, AddressSetView addrSet) {
return new IntersectionAddressSetView(addrSet,
program.viewport.unionedAddresses(s -> program.trace.getCommentAdapter()
.getAddressSetView(Lifespan.at(s), e -> e.getType() == commentType.ordinal())));
}
protected AddressSetView getCommentAddresses(AddressSetView addrSet) {
return new IntersectionAddressSetView(addrSet, program.viewport.unionedAddresses(
s -> program.trace.getCommentAdapter()
.getAddressSetView(Lifespan.at(s))));
s -> program.trace.getCommentAdapter().getAddressSetView(Lifespan.at(s))));
}
@Override
public CodeUnitIterator getCommentCodeUnitIterator(int commentType, AddressSetView addrSet) {
public CodeUnitIterator getCommentCodeUnitIterator(CommentType commentType,
AddressSetView addrSet) {
return new WrappingCodeUnitIterator(
getCodeUnitIterator(getCommentAddresses(commentType, addrSet), true));
}
@Override
public AddressIterator getCommentAddressIterator(int commentType, AddressSetView addrSet,
boolean forward) {
public AddressIterator getCommentAddressIterator(CommentType commentType,
AddressSetView addrSet, boolean forward) {
return getCommentAddresses(commentType, addrSet).getAddresses(forward);
}
@ -439,13 +432,14 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
@Override
public long getCommentAddressCount() {
return program.viewport.unionedAddresses(
return program.viewport
.unionedAddresses(
s -> program.trace.getCommentAdapter().getAddressSetView(Lifespan.at(s)))
.getNumAddresses();
}
@Override
public String getComment(int commentType, Address address) {
public String getComment(CommentType commentType, Address address) {
try (LockHold hold = program.trace.lockRead()) {
return program.viewport.getTop(
s -> program.trace.getCommentAdapter().getComment(s, address, commentType));
@ -463,10 +457,9 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
}
@Override
public void setComment(Address address, int commentType, String comment) {
public void setComment(Address address, CommentType commentType, String comment) {
program.trace.getCommentAdapter()
.setComment(Lifespan.nowOn(program.snap), address,
commentType, comment);
.setComment(Lifespan.nowOn(program.snap), address, commentType, comment);
}
@Override
@ -787,7 +780,7 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
public void clearComments(Address startAddr, Address endAddr) {
program.trace.getCommentAdapter()
.clearComments(Lifespan.nowOn(program.snap),
new AddressRangeImpl(startAddr, endAddr), CodeUnit.NO_COMMENT);
new AddressRangeImpl(startAddr, endAddr), null);
}
@Override
@ -957,7 +950,7 @@ public abstract class AbstractDBTraceProgramViewListing implements TraceProgramV
}
@Override
public CommentHistory[] getCommentHistory(Address addr, int commentType) {
public CommentHistory[] getCommentHistory(Address addr, CommentType commentType) {
return new CommentHistory[] {};
}
}

View file

@ -341,7 +341,7 @@ public class DBTraceProgramView implements TraceProgramView {
return;
}
queues.fireEvent(
new CommentChangeRecord(commentType.ordinal(), range.getX1(), oldValue, newValue));
new CommentChangeRecord(commentType, range.getX1(), oldValue, newValue));
}
private void commentEolChanged(TraceAddressSpace space, TraceAddressSnapRange range,

View file

@ -19,7 +19,7 @@ import java.util.*;
import ghidra.framework.model.EventType;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.trace.database.target.DBTraceObject;
import ghidra.trace.database.target.DBTraceObjectInterface;
import ghidra.trace.model.Lifespan;
@ -117,9 +117,7 @@ public class DBTraceObjectStackFrame implements TraceObjectStackFrame, DBTraceOb
try (LockHold hold = object.getTrace().lockRead()) {
Address pc = getProgramCounter(snap);
return pc == null ? null
: object.getTrace()
.getCommentAdapter()
.getComment(snap, pc, CodeUnit.EOL_COMMENT);
: object.getTrace().getCommentAdapter().getComment(snap, pc, CommentType.EOL);
}
}
@ -130,8 +128,8 @@ public class DBTraceObjectStackFrame implements TraceObjectStackFrame, DBTraceOb
TraceObjectValue pcAttr = object.getValue(snap, TraceObjectStackFrame.KEY_PC);
object.getTrace()
.getCommentAdapter()
.setComment(pcAttr.getLifespan(), (Address) pcAttr.getValue(),
CodeUnit.EOL_COMMENT, comment);
.setComment(pcAttr.getLifespan(), (Address) pcAttr.getValue(), CommentType.EOL,
comment);
}
}

View file

@ -18,7 +18,7 @@ package ghidra.trace.util;
import ghidra.docking.settings.Settings;
import ghidra.program.model.address.AddressSpace;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.ProgramFragment;
import ghidra.trace.model.Trace;
import ghidra.trace.model.bookmark.TraceBookmark;
@ -150,13 +150,13 @@ public interface TraceEvents {
* @param commentType the comment type
* @return the event type
*/
static TraceCommentEvent byCommentType(int commentType) {
static TraceCommentEvent byCommentType(CommentType commentType) {
return switch (commentType) {
case CodeUnit.PLATE_COMMENT -> PLATE_COMMENT_CHANGED;
case CodeUnit.PRE_COMMENT -> PRE_COMMENT_CHANGED;
case CodeUnit.POST_COMMENT -> POST_COMMENT_CHANGED;
case CodeUnit.EOL_COMMENT -> EOL_COMMENT_CHANGED;
case CodeUnit.REPEATABLE_COMMENT -> REPEATABLE_COMMENT_CHANGED;
case CommentType.PLATE -> PLATE_COMMENT_CHANGED;
case CommentType.PRE -> PRE_COMMENT_CHANGED;
case CommentType.POST -> POST_COMMENT_CHANGED;
case CommentType.EOL -> EOL_COMMENT_CHANGED;
case CommentType.REPEATABLE -> REPEATABLE_COMMENT_CHANGED;
default -> throw new AssertionError();
};
}

View file

@ -18,7 +18,6 @@ package ghidra.trace.database.listing;
import static org.junit.Assert.*;
import java.io.IOException;
import java.lang.reflect.Field;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.*;
@ -210,8 +209,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
try (Transaction tx = b.startTransaction()) {
b.trace.getMemoryManager()
.addRegion(".text", Lifespan.nowOn(0),
b.range(0x4000, 0x4fff), TraceMemoryFlag.READ);
.addRegion(".text", Lifespan.nowOn(0), b.range(0x4000, 0x4fff),
TraceMemoryFlag.READ);
}
assertEquals("00004004", ins.getAddressString(false, false));
@ -364,16 +363,13 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
}
@Test
public void testDetectNewCommentTypes()
throws IllegalArgumentException, IllegalAccessException {
for (Field f : CodeUnit.class.getFields()) {
if (f.getName().endsWith("_COMMENT")) {
if (f.getInt(null) > CodeUnit.REPEATABLE_COMMENT) {
public void testDetectNewCommentTypes() {
for (CommentType type : CommentType.values()) {
if (type.ordinal() > CommentType.REPEATABLE.ordinal()) {
fail("It appears a new comment type was added");
}
}
}
}
@Test
public void testCommentSettersGetters() throws CodeUnitInsertionException {
@ -385,7 +381,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
}
try (Transaction tx = b.startTransaction()) {
i4004.setComment(CodeUnit.NO_COMMENT, "Shouldn't work");
i4004.setComment(null, "Shouldn't work");
fail();
}
catch (IllegalArgumentException e) {
@ -408,7 +404,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
assertArrayEquals(EMPTY_STRING_ARRAY, i4004.getCommentAsArray(CommentType.PRE));
try (Transaction tx = b.startTransaction()) {
i4004.setCommentAsArray(CodeUnit.PRE_COMMENT, new String[] { "My", "Pre", "Comment" });
i4004.setCommentAsArray(CommentType.PRE, new String[] { "My", "Pre", "Comment" });
}
assertEquals("My EOL Comment", i4004.getComment(CommentType.EOL));
assertArrayEquals(new String[] { "My", "Pre", "Comment" },
@ -417,8 +413,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
assertEquals("My\nPre\nComment", i4004.getComment(CommentType.PRE));
try (Transaction tx = b.startTransaction()) {
i4004.setCommentAsArray(CodeUnit.PRE_COMMENT, null);
i4006.setCommentAsArray(CodeUnit.PRE_COMMENT, null); // NOP
i4004.setCommentAsArray(CommentType.PRE, null);
i4006.setCommentAsArray(CommentType.PRE, null); // NOP
}
assertNull(i4004.getComment(CommentType.PRE));
@ -444,14 +440,13 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
try (Transaction tx = b.startTransaction()) {
commentAdapter.clearComments(Lifespan.nowOn(0), b.range(0x4000, 0x5000),
CodeUnit.EOL_COMMENT);
CommentType.EOL);
}
assertNull(i4004.getComment(CommentType.EOL));
assertEquals("Get this back in the mix", i4004_10.getComment(CommentType.PRE));
try (Transaction tx = b.startTransaction()) {
commentAdapter.clearComments(Lifespan.nowOn(0), b.range(0x4000, 0x5000),
CodeUnit.NO_COMMENT);
commentAdapter.clearComments(Lifespan.nowOn(0), b.range(0x4000, 0x5000), null);
}
assertNull(i4004.getComment(CommentType.EOL));
assertNull(i4004_10.getComment(CommentType.PRE));
@ -579,9 +574,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
DBTraceReference refTo;
try (Transaction tx = b.startTransaction()) {
refTo = b.trace.getReferenceManager()
.addMemoryReference(Lifespan.ALL, b.addr(0x3000),
b.addr(0x4004), RefType.COMPUTED_JUMP, SourceType.USER_DEFINED,
CodeUnit.MNEMONIC);
.addMemoryReference(Lifespan.ALL, b.addr(0x3000), b.addr(0x4004),
RefType.COMPUTED_JUMP, SourceType.USER_DEFINED, CodeUnit.MNEMONIC);
}
assertEquals(Set.of(refTo), set((Iterator<Reference>) i4004.getReferenceIteratorTo()));
@ -636,8 +630,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
thread = b.getOrAddThread("Thread 1", 0);
DBTraceCodeSpace regCode = manager.getCodeRegisterSpace(thread, true);
data = regCode.definedData()
.create(Lifespan.nowOn(0), b.language.getRegister("r4"),
LongDataType.dataType);
.create(Lifespan.nowOn(0), b.language.getRegister("r4"), LongDataType.dataType);
// getForRegister requires unit to match size
undReg = regCode.undefinedData().getAt(0, b.language.getRegister("r5").getAddress());
}
@ -832,8 +825,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
try (Transaction tx = b.startTransaction()) {
// StringDataType accesses memory via program view, so "block" must exist
b.trace.getMemoryManager()
.addRegion("myRegion", Lifespan.nowOn(0),
b.range(0x4000, 0x4fff), TraceMemoryFlag.READ);
.addRegion("myRegion", Lifespan.nowOn(0), b.range(0x4000, 0x4fff),
TraceMemoryFlag.READ);
dl4000 = b.addData(0, b.addr(0x4000), LongDataType.dataType, b.buf(1, 2, 3, 4));
dp4006 = b.addData(0, b.addr(0x4006), PointerDataType.dataType,
@ -970,8 +963,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
try (Transaction tx = b.startTransaction()) {
// Disassembler's new cacheing in mem-buffer uses program view, so "block" must exist
b.trace.getMemoryManager()
.addRegion("myRegion", Lifespan.nowOn(0),
b.range(0x4000, 0x4fff), TraceMemoryFlag.READ);
.addRegion("myRegion", Lifespan.nowOn(0), b.range(0x4000, 0x4fff),
TraceMemoryFlag.READ);
i4004 = b.addInstruction(0, b.addr(0x4004), b.host, b.buf(0xc8, 0x47));
assertEquals("add r4,#0x7", i4004.toString());
@ -1074,8 +1067,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
i4004.addOperandReference(1, b.addr(0x5000), RefType.DATA_IND, SourceType.USER_DEFINED);
// TODO: This should probably be default for first/only reference
b.trace.getReferenceManager()
.getReference(0, b.addr(0x4004), b.addr(0x5000),
1)
.getReference(0, b.addr(0x4004), b.addr(0x5000), 1)
.setPrimary(true);
}
assertEquals(OperandType.ADDRESS | OperandType.SCALAR, i4004.getOperandType(1));
@ -1247,8 +1239,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
try (Transaction tx = b.startTransaction()) {
// Disassembler's new cacheing in mem-buffer uses program view, so "block" must exist
b.trace.getMemoryManager()
.addRegion("myRegion", Lifespan.nowOn(0),
b.range(0x4000, 0x4fff), TraceMemoryFlag.READ);
.addRegion("myRegion", Lifespan.nowOn(0), b.range(0x4000, 0x4fff),
TraceMemoryFlag.READ);
guest = b.trace.getPlatformManager().addGuestPlatform(x86.getDefaultCompilerSpec());
guest.addMappedRange(b.addr(0x0000), b.addr(guest, 0x0000), 1L << 32);
@ -1378,8 +1370,7 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
thread = b.getOrAddThread("Thread 1", 0);
DBTraceCodeSpace regCode = manager.getCodeRegisterSpace(thread, true);
dR4 = regCode.definedData()
.create(Lifespan.nowOn(0), b.language.getRegister("r4"),
myStruct);
.create(Lifespan.nowOn(0), b.language.getRegister("r4"), myStruct);
}
myStruct = (Structure) b.trace.getDataTypeManager().getDataType("/myStruct");
myTypedef = (TypeDef) b.trace.getDataTypeManager().getDataType("/myTypedef");
@ -1603,8 +1594,8 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
try (Transaction tx = b.startTransaction()) {
// StringDataType accesses memory via program view, so "block" must exist
b.trace.getMemoryManager()
.addRegion("myRegion", Lifespan.nowOn(0),
b.range(0x4000, 0x4fff), TraceMemoryFlag.READ);
.addRegion("myRegion", Lifespan.nowOn(0), b.range(0x4000, 0x4fff),
TraceMemoryFlag.READ);
d4000 = b.addData(0, b.addr(0x4000), LongDataType.dataType, b.buf(1, 2, 3, 4));
d4004 = b.addData(0, b.addr(0x4004), myStruct, b.buf(5, 6, 7, 8, 9));

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,9 +17,7 @@
import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Listing;
import ghidra.program.model.listing.*;
public class AddCommentToProgramScript extends GhidraScript {
@ -28,7 +25,8 @@ public class AddCommentToProgramScript extends GhidraScript {
public void run() throws Exception {
Address minAddress = currentProgram.getMinAddress();
Listing listing = currentProgram.getListing();
CodeUnit codeUnit = listing.getCodeUnitAt( minAddress );
codeUnit.setComment( CodeUnit.PLATE_COMMENT, "AddCommentToProgramScript - This is an added comment!" );
CodeUnit codeUnit = listing.getCodeUnitAt(minAddress);
codeUnit.setComment(CommentType.PLATE,
"AddCommentToProgramScript - This is an added comment!");
}
}

View file

@ -49,7 +49,6 @@ public class AutoRenameSimpleLabels extends GhidraScript {
@Override
public void run() throws Exception {
String tmpString = "\nScript: AutoRenameSimpleLabels() \n";
//get listing of symbols
SymbolIterator iter = currentProgram.getSymbolTable().getAllSymbols(true);
@ -147,18 +146,16 @@ public class AutoRenameSimpleLabels extends GhidraScript {
// now also propogate the repeatable comment up as well
String comment = currentProgram.getListing().getComment(CommentType.REPEATABLE,
operand_addr);
if (comment != null) {
if (currentProgram.getListing().getComment(CommentType.REPEATABLE,
startAddr) == null) {
String comment =
currentProgram.getListing().getComment(CommentType.REPEATABLE, operand_addr);
if (comment != null && currentProgram.getListing()
.getComment(CommentType.REPEATABLE, startAddr) == null) {
//println("updating comment for " + operand +" is " + comment);
currentProgram.getListing()
.setComment(startAddr, CommentType.REPEATABLE, comment);
}
}
}
}
println("Modified a total of " + modified_count + " entries");
}

View file

@ -24,9 +24,7 @@ import ghidra.program.model.listing.*;
public class DeleteDeadDefaultPlatesScript extends GhidraScript {
private static String DEAD_PLATE = " DEAD";
/* (non-Javadoc)
* @see ghidra.app.script.GhidraScript#run()
*/
@Override
public void run() throws Exception {
Listing listing = currentProgram.getListing();
@ -34,7 +32,8 @@ public class DeleteDeadDefaultPlatesScript extends GhidraScript {
if (currentSelection != null && !currentSelection.isEmpty()) {
set = currentSelection;
}
int updateCount=0;
int updateCount = 0;
AddressIterator iter = listing.getCommentAddressIterator(CommentType.PLATE, set, true);
while (iter.hasNext()) {
Address addr = iter.next();
@ -48,7 +47,7 @@ public class DeleteDeadDefaultPlatesScript extends GhidraScript {
}
}
if (updateCount > 0) {
String cmt = updateCount > 1? "comments" : "comment";
String cmt = updateCount > 1 ? "comments" : "comment";
println("Removed " + updateCount + " default plate " + cmt + ".");
}
else {

View file

@ -24,9 +24,7 @@ import ghidra.program.model.listing.*;
public class DeleteEmptyPlateCommentsScript extends GhidraScript {
private static String EMPTY_PLATE = "";
/* (non-Javadoc)
* @see ghidra.app.script.GhidraScript#run()
*/
@Override
public void run() throws Exception {
Listing listing = currentProgram.getListing();
@ -34,7 +32,8 @@ public class DeleteEmptyPlateCommentsScript extends GhidraScript {
if (currentSelection != null && !currentSelection.isEmpty()) {
set = currentSelection;
}
int updateCount=0;
int updateCount = 0;
AddressIterator iter = listing.getCommentAddressIterator(CommentType.PLATE, set, true);
while (iter.hasNext()) {
Address addr = iter.next();
@ -48,7 +47,7 @@ public class DeleteEmptyPlateCommentsScript extends GhidraScript {
}
}
if (updateCount > 0) {
String cmt = updateCount > 1? "comments" : "comment";
String cmt = updateCount > 1 ? "comments" : "comment";
println("Removed " + updateCount + " emtpy plate " + cmt + ".");
}
else {

View file

@ -24,9 +24,7 @@ import ghidra.program.model.listing.*;
public class DeleteExitCommentsScript extends GhidraScript {
private static String EXIT_COMMENT = " Exit **********\r\n ";
/* (non-Javadoc)
* @see ghidra.app.script.GhidraScript#run()
*/
@Override
public void run() throws Exception {
Listing listing = currentProgram.getListing();
@ -34,7 +32,8 @@ public class DeleteExitCommentsScript extends GhidraScript {
if (currentSelection != null && !currentSelection.isEmpty()) {
set = currentSelection;
}
int updateCount=0;
int updateCount = 0;
AddressIterator iter = listing.getCommentAddressIterator(CommentType.POST, set, true);
while (iter.hasNext()) {
Address addr = iter.next();
@ -46,7 +45,7 @@ public class DeleteExitCommentsScript extends GhidraScript {
}
}
if (updateCount > 0) {
String cmt = updateCount > 1? "comments" : "comment";
String cmt = updateCount > 1 ? "comments" : "comment";
println("Removed " + updateCount + " exit post " + cmt + ".");
}
else {

View file

@ -27,6 +27,7 @@ import java.util.List;
import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.mem.Memory;
import ghidra.util.exception.CancelledException;
@ -72,14 +73,14 @@ public class LocateMemoryAddressesForFileOffset extends GhidraScript {
println("File offset " + Long.toHexString(fileOffset) +
" is associated with memory block:address " + memBlockName + ":" + addr.toString());
CodeUnit myCodeUnit = currentProgram.getListing().getCodeUnitContaining(addr);
String comment = myCodeUnit.getComment(0);
String comment = myCodeUnit.getComment(CommentType.EOL);
if (comment == null) {
myCodeUnit.setComment(0,
myCodeUnit.setComment(CommentType.EOL,
this.getScriptName() + ": File offset: " + Long.toHexString(fileOffset) +
", Memory block:address " + memBlockName + ":" + addr.toString());
}
else {
myCodeUnit.setComment(0,
myCodeUnit.setComment(CommentType.EOL,
comment + ", " + this.getScriptName() + ": File offset: " +
Long.toHexString(fileOffset) + ", Memory block:address " + memBlockName + ":" +
addr.toString());

View file

@ -48,8 +48,7 @@ import ghidra.program.model.block.CodeBlock;
import ghidra.program.model.block.PartitionCodeSubModel;
import ghidra.program.model.data.DataType;
import ghidra.program.model.lang.*;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Instruction;
import ghidra.program.model.listing.*;
import ghidra.program.model.pcode.PcodeOp;
import ghidra.program.model.pcode.Varnode;
import ghidra.program.model.symbol.*;
@ -180,7 +179,8 @@ public class MultiInstructionMemReference extends GhidraScript {
public boolean evaluateReference(VarnodeContext context, Instruction instr, int pcodeop,
Address address, int size, DataType dataType, RefType refType) {
return super.evaluateReference(context, instr, pcodeop, address, size, dataType, refType);
return super.evaluateReference(context, instr, pcodeop, address, size, dataType,
refType);
}
private boolean checkInstructionMatch(final int opIdx, boolean input,
@ -287,7 +287,7 @@ public class MultiInstructionMemReference extends GhidraScript {
}
Address lastSetLocation = context.getLastSetLocation(singleRegister, null);
String comment = instr.getComment(Instruction.EOL_COMMENT);
String comment = instr.getComment(CommentType.EOL);
if (comment == null) {
comment = "";
}
@ -300,7 +300,7 @@ public class MultiInstructionMemReference extends GhidraScript {
return false;
}
comment = (comment.trim().length() == 0 ? markup : comment + "\n" + markup);
instr.setComment(Instruction.EOL_COMMENT, comment);
instr.setComment(CommentType.EOL, comment);
return false;
}

View file

@ -18,39 +18,33 @@
// function's plate comment.
//@category Analysis
import java.util.*;
import ghidra.app.script.GhidraScript;
import ghidra.program.model.lang.Register;
import ghidra.program.model.listing.*;
public class RegisterTouchesPerFunction extends GhidraScript
{
private final static String DIVIDER = "*************************************************************\r\n";
public class RegisterTouchesPerFunction extends GhidraScript {
private final static String DIVIDER =
"*************************************************************\r\n";
@Override
public void run() throws Exception
{
public void run() throws Exception {
Listing l = this.currentProgram.getListing();
if (this.askYesNo("Function Analysis - Register Touches",
"Analyze complete listing?"))
{
if (this.askYesNo("Function Analysis - Register Touches", "Analyze complete listing?")) {
FunctionIterator fi = l.getFunctions(true);
while (fi.hasNext() && !monitor.isCancelled())
{
while (fi.hasNext() && !monitor.isCancelled()) {
doAnalysis(l, fi.next());
}
}
else
{
else {
doAnalysis(l, l.getFunctionContaining(this.currentAddress));
}
}
private void doAnalysis(Listing list, Function func)
{
private void doAnalysis(Listing list, Function func) {
if (func == null) {
println("No function to analyze.");
return;
@ -65,7 +59,6 @@ public class RegisterTouchesPerFunction extends GhidraScript
monitor.setMessage("Analyzing registers in " + func.getName());
String comment = list.getComment(CommentType.PLATE, func.getBody().getMinAddress());
if (comment != null && comment.indexOf("TOUCHED REGISTER SUMMARY") > -1)
return;
@ -76,55 +69,40 @@ public class RegisterTouchesPerFunction extends GhidraScript
iIter = list.getInstructions(func.getBody(), true);
while (iIter.hasNext() && !monitor.isCancelled())
{
while (iIter.hasNext() && !monitor.isCancelled()) {
inst = iIter.next();
Object o[] = inst.getResultObjects();
for (int i = 0; i < o.length; i++)
{
if (o[i] instanceof Register)
{
String name = ((Register) o[i]).getName();
for (Object element : o) {
if (element instanceof Register) {
String name = ((Register) element).getName();
if (inst.getMnemonicString().equalsIgnoreCase("pop"))
{
if (!name.equalsIgnoreCase("mult_addr")
&& !name.equalsIgnoreCase("sp"))
{
if (pushPops.size() > 0)
{
if (inst.getMnemonicString().equalsIgnoreCase("pop")) {
if (!name.equalsIgnoreCase("mult_addr") && !name.equalsIgnoreCase("sp")) {
if (pushPops.size() > 0) {
restored.add(pushPops.pop() + "->" + name);
}
else
{
else {
reviewRestored = true;
}
}
}
else
{
else {
affected.add(name);
}
}
}
o = inst.getInputObjects();
for (int i = 0; i < o.length; i++)
{
if (o[i] instanceof Register)
{
String name = ((Register) o[i]).getName();
if (inst.getMnemonicString().equalsIgnoreCase("push"))
{
if (!name.equalsIgnoreCase("mult_addr")
&& !name.equalsIgnoreCase("sp"))
{
for (Object element : o) {
if (element instanceof Register) {
String name = ((Register) element).getName();
if (inst.getMnemonicString().equalsIgnoreCase("push")) {
if (!name.equalsIgnoreCase("mult_addr") && !name.equalsIgnoreCase("sp")) {
pushPops.push(name);
}
}
else
{
else {
accessed.add(name);
}
}
@ -148,36 +126,30 @@ public class RegisterTouchesPerFunction extends GhidraScript
buffer.append("Register(s) Restored:\r\n");
buffer.append(getString(restored, 4));
if(reviewRestored)
{
if (reviewRestored) {
buffer.append("##Review - due to branches this list may not be accurate\r\n");
println(func.getName() + " - Review - due to branches this list may not be accurate");
}
buffer.append(DIVIDER);
if (pushPops.size() > 0)
{
if (pushPops.size() > 0) {
buffer.append("Registers Remaining on Stack:\r\n");
buffer.append(" "+getString(pushPops, 8));
buffer.append(" " + getString(pushPops, 8));
}
list.setComment(func.getEntryPoint(), CommentType.PLATE, buffer.toString());
}
private String getString(Collection<String> c, int itemsPerLine)
{
private String getString(Collection<String> c, int itemsPerLine) {
TreeSet<Object> ts = new TreeSet<Object>(c);
String temp = ts.toString();
temp = temp.substring(1, temp.length() - 1);
int i = 0;
int commaCount = 0;
while ((i = temp.indexOf(',', i + 1)) >= 0)
{
while ((i = temp.indexOf(',', i + 1)) >= 0) {
commaCount++;
if (commaCount % itemsPerLine == 0)
temp = temp.substring(0, i + 1) + "\r\n"
+ temp.substring(i + 1).trim();
temp = temp.substring(0, i + 1) + "\r\n" + temp.substring(i + 1).trim();
}
return temp + "\r\n";

View file

@ -60,8 +60,8 @@ public class ZapBCTRScript extends GhidraScript {
}
// first try input as class and search for symbol "<class>::__vtbl"
List<Symbol> symbols = currentProgram.getSymbolTable().getSymbols("__vtbl",
getNamespace(null, classNameOrAddr));
List<Symbol> symbols = currentProgram.getSymbolTable()
.getSymbols("__vtbl", getNamespace(null, classNameOrAddr));
// if symbol found, then vtblAddr is the symbol's address
if (symbols.size() == 1) {
vtblAddr = symbols.get(0).getAddress();
@ -100,8 +100,8 @@ public class ZapBCTRScript extends GhidraScript {
// insert funcName as EOL comment and
// add a mnemonic ref from instAddr to funcAddr
listing.setComment(instAddr, CommentType.EOL, funcName);
listing.getInstructionAt(instAddr).addMnemonicReference(funcAddr, RefType.COMPUTED_CALL,
SourceType.USER_DEFINED);
listing.getInstructionAt(instAddr)
.addMnemonicReference(funcAddr, RefType.COMPUTED_CALL, SourceType.USER_DEFINED);
/* old code that replaces the 'bctr' with a 'bl'
int code = 0x48000001 | ((int)displacement & 0x3ffffff);

View file

@ -25,10 +25,9 @@ import ghidra.program.model.listing.*;
public class AppendCommentCmd implements Command<Program> {
private Address address;
private int commentType;
private CommentType commentType;
private String comment;
private String separator;
private String cmdName;
private String message;
/**
@ -40,17 +39,30 @@ public class AppendCommentCmd implements Command<Program> {
* @param separator characters to separate the new comment from the previous comment when
* concatenating.
*/
@Deprecated(forRemoval = true, since = "11.4")
public AppendCommentCmd(Address addr, int commentType, String comment, String separator) {
this(addr, CommentType.valueOf(commentType), comment, separator);
}
/**
* Construct command
* @param addr address of code unit where comment will be placed
* @param commentType comment type
* @param comment comment for code unit, should not be null
* @param separator characters to separate the new comment from the previous comment when
* concatenating.
*/
public AppendCommentCmd(Address addr, CommentType commentType, String comment,
String separator) {
this.address = addr;
this.commentType = commentType;
this.comment = comment;
this.separator = separator;
cmdName = "Append Comment";
}
@Override
public String getName() {
return cmdName;
return "Append Comment";
}
@Override

View file

@ -326,23 +326,23 @@ public class CodeUnitInfoPasteCmd implements Command<Program> {
if (plateComment != null) {
String[] oldComment = cu.getCommentAsArray(CommentType.PLATE);
cu.setCommentAsArray(CodeUnit.PLATE_COMMENT, appendComment(oldComment, plateComment));
cu.setCommentAsArray(CommentType.PLATE, appendComment(oldComment, plateComment));
}
if (preComment != null) {
String[] oldComment = cu.getCommentAsArray(CommentType.PRE);
cu.setCommentAsArray(CodeUnit.PRE_COMMENT, appendComment(oldComment, preComment));
cu.setCommentAsArray(CommentType.PRE, appendComment(oldComment, preComment));
}
if (postComment != null) {
String[] oldComment = cu.getCommentAsArray(CommentType.POST);
cu.setCommentAsArray(CodeUnit.POST_COMMENT, appendComment(oldComment, postComment));
cu.setCommentAsArray(CommentType.POST, appendComment(oldComment, postComment));
}
if (eolComment != null) {
String[] oldComment = cu.getCommentAsArray(CommentType.EOL);
cu.setCommentAsArray(CodeUnit.EOL_COMMENT, appendComment(oldComment, eolComment));
cu.setCommentAsArray(CommentType.EOL, appendComment(oldComment, eolComment));
}
if (repeatableComment != null) {
String[] oldComment = cu.getCommentAsArray(CommentType.REPEATABLE);
cu.setCommentAsArray(CodeUnit.REPEATABLE_COMMENT,
cu.setCommentAsArray(CommentType.REPEATABLE,
appendComment(oldComment, repeatableComment));
}
}

View file

@ -38,12 +38,9 @@ public class SetCommentCmd implements Command<Program> {
* @param comment comment for code unit
* @deprecated Use {@link #SetCommentCmd(Address, CommentType, String)} instead
*/
@Deprecated
@Deprecated(forRemoval = true, since = "11.4")
public SetCommentCmd(Address addr, int commentType, String comment) {
this.address = addr;
this.commentType = CommentType.values()[commentType];
this.comment = comment;
cmdName = comment == null ? "Delete Comment" : "Set Comment";
this(addr, CommentType.valueOf(commentType), comment);
}
/**
@ -132,11 +129,11 @@ public class SetCommentCmd implements Command<Program> {
* {@link CodeUnit#REPEATABLE_COMMENT})
* @deprecated Use {@link #createComment(Program, Address, String, CommentType)} instead
*/
@Deprecated
@Deprecated(forRemoval = true, since = "11.4")
public static void createComment(Program program, Address addr, String comment,
int commentType) {
SetCommentCmd commentCmd =
new SetCommentCmd(addr, CommentType.values()[commentType], comment);
new SetCommentCmd(addr, CommentType.valueOf(commentType), comment);
commentCmd.applyTo(program);
}
@ -147,9 +144,7 @@ public class SetCommentCmd implements Command<Program> {
* @param program the program being analyzed
* @param addr the address where data is created
* @param comment the comment about the data
* @param commentType the type of comment ({@link CommentType#PLATE},
* {@link CodeUnit#PRE_COMMENT}, {@link CodeUnit#EOL_COMMENT}, {@link CodeUnit#POST_COMMENT},
* {@link CodeUnit#REPEATABLE_COMMENT})
* @param commentType the type of comment
*/
public static void createComment(Program program, Address addr, String comment,
CommentType commentType) {

View file

@ -238,8 +238,8 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
private void processInterpretor(ElfHeader elf, ByteProvider provider, Program program)
throws CancelledException {
for (ElfProgramHeader programHeader : elf.getProgramHeaders(
ElfProgramHeaderConstants.PT_INTERP)) {
for (ElfProgramHeader programHeader : elf
.getProgramHeaders(ElfProgramHeaderConstants.PT_INTERP)) {
monitor.checkCancelled();
long offset = programHeader.getOffset();
if (offset == 0) {
@ -339,8 +339,8 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
}
Address refAddr = addr(programLoadHeader.getOffset(dynamicRefAddr));
program.getReferenceManager().addMemoryReference(fromAddr, refAddr, RefType.DATA,
SourceType.ANALYSIS, 0);
program.getReferenceManager()
.addMemoryReference(fromAddr, refAddr, RefType.DATA, SourceType.ANALYSIS, 0);
try {
createLabel(refAddr, "_" + dynamic.getTagAsString(), true, SourceType.ANALYSIS);

View file

@ -105,6 +105,7 @@ public class CliMetadataTokenAnalyzer extends AbstractAnalyzer {
CliStreamMetadata metadataStream = metadataRoot.getMetadataStream();
InstructionIterator instIter = program.getListing().getInstructions(set, true);
while (instIter.hasNext()) {
monitor.checkCancelled();
try {
Instruction inst = instIter.next();
/* Base Instructions (Partition II.3) */

View file

@ -166,8 +166,7 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
"Golang symbol analyzer: scheduling RTTI propagation after reference analysis");
aam.schedule(new PropagateRttiBackgroundCommand(goBinary, markupSession),
PROP_RTTI_PRIORITY.priority());
Msg.info(this,
"Golang symbol analyzer: scheduling closure function fixup");
Msg.info(this, "Golang symbol analyzer: scheduling closure function fixup");
aam.schedule(new FixClosureFuncArgsBackgroundCommand(goBinary),
FIX_CLOSURES_PRIORITY.priority());
}
@ -328,8 +327,7 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
: null;
String typeStr = typeStructAddr != null
? AddressAnnotatedStringHandler.createAddressAnnotationString(
typeStructAddr,
recvType.getName())
typeStructAddr, recvType.getName())
: funcDefResult.symbolName().receiverString();
markupSession.appendComment(func, "",
"Golang method in type %s".formatted(typeStr));
@ -354,7 +352,6 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
.formatted(functionSignatureFromMethod));
}
private void fixGcWriteBarrierFunctions() {
if (GoConstants.GCWRITE_BUFFERED_VERS.contains(goBinary.getGoVer())) {
fixGcWriteBarrierBufferedFunctions();
@ -390,8 +387,7 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
func = funcData != null ? funcData.getFunction() : null;
if (func != null) {
func.updateFunction(ccname, retVal, List.of(),
FunctionUpdateType.DYNAMIC_STORAGE_ALL_PARAMS, true,
SourceType.ANALYSIS);
FunctionUpdateType.DYNAMIC_STORAGE_ALL_PARAMS, true, SourceType.ANALYSIS);
}
}
}
@ -460,8 +456,8 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
DataType voidPtr = program.getDataTypeManager().getPointer(VoidDataType.dataType);
GoFuncData duffzeroFuncdata = goBinary.getFunctionByName("runtime.duffzero");
Function duffzeroFunc = duffzeroFuncdata != null
? funcMgr.getFunctionAt(duffzeroFuncdata.getFuncAddress())
Function duffzeroFunc =
duffzeroFuncdata != null ? funcMgr.getFunctionAt(duffzeroFuncdata.getFuncAddress())
: null;
List<Variable> duffzeroParams = regInfo.getDuffzeroParams(program);
if (duffzeroFunc != null && !duffzeroParams.isEmpty()) {
@ -489,14 +485,13 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
}
GoFuncData duffcopyFuncdata = goBinary.getFunctionByName("runtime.duffcopy");
Function duffcopyFunc = duffcopyFuncdata != null
? funcMgr.getFunctionAt(duffcopyFuncdata.getFuncAddress())
Function duffcopyFunc =
duffcopyFuncdata != null ? funcMgr.getFunctionAt(duffcopyFuncdata.getFuncAddress())
: null;
if (duffcopyFuncdata != null &&
goBinary.hasCallingConvention(GOLANG_DUFFCOPY_CALLINGCONVENTION_NAME)) {
try {
List<Variable> params =
List.of(new ParameterImpl("dest", voidPtr, program),
List<Variable> params = List.of(new ParameterImpl("dest", voidPtr, program),
new ParameterImpl("src", voidPtr, program));
duffcopyFunc.updateFunction(GOLANG_DUFFCOPY_CALLINGCONVENTION_NAME,
new ReturnParameterImpl(VoidDataType.dataType, program), params,
@ -672,8 +667,8 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
func.setName(duffFunc.getName() + "_" + func.getEntryPoint(),
SourceType.ANALYSIS);
func.setParentNamespace(funcNS);
FunctionUpdateType fut = duffFunc.hasCustomVariableStorage()
? FunctionUpdateType.CUSTOM_STORAGE
FunctionUpdateType fut =
duffFunc.hasCustomVariableStorage() ? FunctionUpdateType.CUSTOM_STORAGE
: FunctionUpdateType.DYNAMIC_STORAGE_ALL_PARAMS;
func.updateFunction(ccName, duffFunc.getReturn(),
Arrays.asList(duffFunc.getParameters()), fut, true, SourceType.ANALYSIS);
@ -1079,8 +1074,8 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
}
record CallSiteInfo(Reference ref, Function callingFunc, Function calledFunc,
Register register,
java.util.function.Function<GoType, DataType> returnTypeMapper) {}
Register register, java.util.function.Function<GoType, DataType> returnTypeMapper) {
}
private GoRttiMapper goBinary;
private Program program;

View file

@ -62,8 +62,7 @@ public class MingwRelocationAnalyzer extends AbstractAnalyzer {
if (!program.hasExclusiveAccess()) {
// Exclusive access required since relocation table lacks merge support
if (!alreadyProcessed(program)) {
Msg.error(this,
NAME + " analyzer disabled; requires exclusive access to " +
Msg.error(this, NAME + " analyzer disabled; requires exclusive access to " +
program.getDomainFile());
}
return false;
@ -226,11 +225,9 @@ class MinGWPseudoRelocationHandler {
static boolean isSupportedProgram(Program program) {
Language language = program.getLanguage();
int size = language.getLanguageDescription().getSize();
return "x86".equals(language.getProcessor().toString()) &&
(size == 32 || size == 64) &&
return "x86".equals(language.getProcessor().toString()) && (size == 32 || size == 64) &&
"windows".equals(program.getCompilerSpec().getCompilerSpecID().toString()) &&
CompilerEnum.GCC.label.equals(program.getCompiler()) &&
getRDataBlock(program) != null;
CompilerEnum.GCC.label.equals(program.getCompiler()) && getRDataBlock(program) != null;
}
private static MemoryBlock getRDataBlock(Program program) {
@ -252,7 +249,6 @@ class MinGWPseudoRelocationHandler {
}
}
boolean processRelocations(MessageLog log, TaskMonitor monitor) throws CancelledException {
Address pdwListBeginAddr = relocList.getListStartAddress();
@ -297,8 +293,8 @@ class MinGWPseudoRelocationHandler {
boolean success;
switch (version) {
case RP_VERSION_V1:
success = relocateV1(pdwListBeginAddr, (int) (size / OLD_STYLE_ENTRY_SIZE), log,
monitor);
success =
relocateV1(pdwListBeginAddr, (int) (size / OLD_STYLE_ENTRY_SIZE), log, monitor);
break;
case RP_VERSION_V2:
success = relocateV2(pdwListBeginAddr, (int) (size / NEW_STYLE_ENTRY_HEADER_SIZE),
@ -369,8 +365,7 @@ class MinGWPseudoRelocationHandler {
return existingEntry;
}
Reference ref =
program.getReferenceManager().getPrimaryReferenceFrom(iatEntryAddr, 0);
Reference ref = program.getReferenceManager().getPrimaryReferenceFrom(iatEntryAddr, 0);
if (!ref.isExternalReference()) {
return null;
}
@ -380,8 +375,7 @@ class MinGWPseudoRelocationHandler {
return null;
}
ExternalLocation extLoc =
program.getExternalManager().getExternalLocation(extSym);
ExternalLocation extLoc = program.getExternalManager().getExternalLocation(extSym);
if (extLoc == null) {
return null;
}
@ -583,12 +577,12 @@ class MinGWPseudoRelocationHandler {
}
if (addend != 0) {
ElfRelocationHandler.warnExternalOffsetRelocation(program,
targetAddr, pointerValue, symbolName, addend, null);
ElfRelocationHandler.warnExternalOffsetRelocation(program, targetAddr,
pointerValue, symbolName, addend, null);
if (!memory.getBlock(targetAddr).isExecute()) {
// assume pointer if not in execute block
ElfRelocationHandler.applyComponentOffsetPointer(program,
targetAddr, addend);
ElfRelocationHandler.applyComponentOffsetPointer(program, targetAddr,
addend);
}
}
}
@ -624,8 +618,7 @@ class MinGWPseudoRelocationHandler {
ClearDataMode.CLEAR_ALL_CONFLICT_DATA);
}
catch (CodeUnitInsertionException e) {
log.appendMsg(
"Failed to markup Mingw pseudo-relocation List at: " + pdwListBeginAddr);
log.appendMsg("Failed to markup Mingw pseudo-relocation List at: " + pdwListBeginAddr);
}
return true;
}
@ -640,8 +633,8 @@ class MinGWPseudoRelocationHandler {
relocHeaderStruct.add(DWordDataType.dataType, "version", null);
try {
DataUtilities.createData(program, relocHeaderAddr, relocHeaderStruct, -1,
false, ClearDataMode.CLEAR_ALL_CONFLICT_DATA);
DataUtilities.createData(program, relocHeaderAddr, relocHeaderStruct, -1, false,
ClearDataMode.CLEAR_ALL_CONFLICT_DATA);
}
catch (CodeUnitInsertionException e) {
log.appendMsg(

View file

@ -196,8 +196,8 @@ public class ObjectiveC2_MessageAnalyzer extends AbstractAnalyzer {
}
if (currentClass != null && currentMethod != null) {
instruction.setComment(CommentType.EOL, "[" + currentClass + " " +
currentMethod + "]");
instruction.setComment(CommentType.EOL,
"[" + currentClass + " " + currentMethod + "]");
break;
}
}

View file

@ -66,7 +66,7 @@ public class CodeBrowserClipboardProvider extends ByteCopier
implements ClipboardContentProviderService, OptionsChangeListener {
protected static final PaintContext PAINT_CONTEXT = new PaintContext();
private static int[] COMMENT_TYPES = CommentTypes.getTypes();
private static int[] COMMENT_TYPESx = CommentTypes.getTypes();
public static final ClipboardType ADDRESS_TEXT_TYPE =
new ClipboardType(DataFlavor.stringFlavor, "Address");
@ -757,7 +757,7 @@ public class CodeBrowserClipboardProvider extends ByteCopier
if (currentLocation instanceof CommentFieldLocation) {
CommentFieldLocation commentFieldLocation = (CommentFieldLocation) currentLocation;
Address address = commentFieldLocation.getAddress();
int commentType = commentFieldLocation.getCommentType();
CommentType commentType = commentFieldLocation.getCommentType();
SetCommentCmd cmd = new SetCommentCmd(address, commentType, string);
return tool.execute(cmd, currentProgram);
}
@ -802,11 +802,10 @@ public class CodeBrowserClipboardProvider extends ByteCopier
}
private void setCommentInfo(CodeUnit cu, CodeUnitInfo info) {
for (int element : COMMENT_TYPES) {
String[] comments = cu.getCommentAsArray(element);
for (CommentType type : CommentType.values()) {
String[] comments = cu.getCommentAsArray(type);
if (comments != null && comments.length > 0) {
info.setComment(element, comments);
info.setComment(type, comments);
}
}
}

View file

@ -22,6 +22,7 @@ import javax.swing.*;
import docking.DialogComponentProvider;
import ghidra.app.util.HelpTopics;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.util.HelpLocation;
/**
@ -37,7 +38,7 @@ public class CommentHistoryDialog extends DialogComponentProvider {
private CommentHistoryPanel platePanel;
private CommentHistoryPanel repeatablePanel;
CommentHistoryDialog(CodeUnit cu, int initialCommentType) {
CommentHistoryDialog(CodeUnit cu, CommentType initialCommentType) {
super("Show Comment History");
setHelpLocation(new HelpLocation(HelpTopics.COMMENTS, "Show_Comment_History"));
addWorkPanel(buildMainPanel(cu, initialCommentType));
@ -45,7 +46,7 @@ public class CommentHistoryDialog extends DialogComponentProvider {
setPreferredSize(500, 300);
}
private JPanel buildMainPanel(CodeUnit cu, int initialCommentType) {
private JPanel buildMainPanel(CodeUnit cu, CommentType initialCommentType) {
JPanel mainPanel = new JPanel(new BorderLayout());
tabbedPane = new JTabbedPane();
mainPanel.add(tabbedPane);
@ -55,11 +56,11 @@ public class CommentHistoryDialog extends DialogComponentProvider {
// corresponding tab. This will cause a screen reader to read the history for a tab
// when it is selected.
eolPanel = new CommentHistoryPanel(CodeUnit.EOL_COMMENT, cu);
prePanel = new CommentHistoryPanel(CodeUnit.PRE_COMMENT, cu);
postPanel = new CommentHistoryPanel(CodeUnit.POST_COMMENT, cu);
platePanel = new CommentHistoryPanel(CodeUnit.PLATE_COMMENT, cu);
repeatablePanel = new CommentHistoryPanel(CodeUnit.REPEATABLE_COMMENT, cu);
eolPanel = new CommentHistoryPanel(CommentType.EOL, cu);
prePanel = new CommentHistoryPanel(CommentType.PRE, cu);
postPanel = new CommentHistoryPanel(CommentType.POST, cu);
platePanel = new CommentHistoryPanel(CommentType.PLATE, cu);
repeatablePanel = new CommentHistoryPanel(CommentType.REPEATABLE, cu);
addTab(" EOL Comment ", eolPanel);
addTab(" Pre Comment ", prePanel);

View file

@ -44,9 +44,9 @@ class CommentHistoryPanel extends JPanel {
private StyledDocument doc;
private JTextPane textPane;
private int commentType;
private CommentType commentType;
CommentHistoryPanel(int commentType, CodeUnit cu) {
CommentHistoryPanel(CommentType commentType, CodeUnit cu) {
super(new BorderLayout());
setUpAttributes();

View file

@ -15,47 +15,50 @@
*/
package ghidra.app.plugin.core.comments;
import ghidra.app.context.*;
import ghidra.framework.*;
import ghidra.program.model.listing.*;
import ghidra.program.util.*;
import ghidra.util.*;
import java.awt.event.KeyEvent;
import java.awt.event.*;
import docking.*;
import docking.ActionContext;
import docking.action.*;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ProgramLocationActionContext;
import ghidra.framework.PluggableServiceRegistry;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.util.*;
import ghidra.util.HelpLocation;
public class CommentsActionFactory {
static {
PluggableServiceRegistry.registerPluggableService(CommentsActionFactory.class, new CommentsActionFactory());
PluggableServiceRegistry.registerPluggableService(CommentsActionFactory.class,
new CommentsActionFactory());
}
public static DockingAction getSetCommentsAction(CommentsDialog dialog,
String name, String actionName, int commentType) {
CommentsActionFactory factory = PluggableServiceRegistry.getPluggableService(CommentsActionFactory.class);
public static DockingAction getSetCommentsAction(CommentsDialog dialog, String name,
String actionName, CommentType commentType) {
CommentsActionFactory factory =
PluggableServiceRegistry.getPluggableService(CommentsActionFactory.class);
return factory.doGetSetCommentsAction(dialog, name, actionName, commentType);
}
public static DockingAction getEditCommentsAction(CommentsDialog dialog,
String name) {
CommentsActionFactory factory = PluggableServiceRegistry.getPluggableService(CommentsActionFactory.class);
public static DockingAction getEditCommentsAction(CommentsDialog dialog, String name) {
CommentsActionFactory factory =
PluggableServiceRegistry.getPluggableService(CommentsActionFactory.class);
return factory.doGetEditCommentsAction(dialog, name);
}
public static boolean isCommentSupported(ProgramLocation loc) {
CommentsActionFactory factory = PluggableServiceRegistry.getPluggableService(CommentsActionFactory.class);
CommentsActionFactory factory =
PluggableServiceRegistry.getPluggableService(CommentsActionFactory.class);
return factory.doIsCommentSupported(loc);
}
protected DockingAction doGetSetCommentsAction(CommentsDialog dialog,
String name, String actionName, int commentType) {
protected DockingAction doGetSetCommentsAction(CommentsDialog dialog, String name,
String actionName, CommentType commentType) {
return new SetCommentsAction(dialog, name, actionName, commentType);
}
protected DockingAction doGetEditCommentsAction(CommentsDialog dialog,
String name) {
protected DockingAction doGetEditCommentsAction(CommentsDialog dialog, String name) {
return new EditCommentsAction(dialog, name);
}
@ -63,31 +66,36 @@ public class CommentsActionFactory {
if (loc == null || loc.getAddress() == null) {
return false;
}
return ((loc instanceof CodeUnitLocation) || ((loc instanceof FunctionLocation) && !(loc instanceof VariableLocation)));
return ((loc instanceof CodeUnitLocation) ||
((loc instanceof FunctionLocation) && !(loc instanceof VariableLocation)));
}
private static class SetCommentsAction extends DockingAction {
private final CommentsDialog dialog;
private final int commentType;
private final CommentType commentType; // may be null for Generic Comment
SetCommentsAction(CommentsDialog dialog, String name,
String actionName, int commentType) {
SetCommentsAction(CommentsDialog dialog, String name, String actionName,
CommentType commentType) {
super(actionName, name);
this.dialog = dialog;
this.commentType = commentType;
setPopupMenuData(new MenuData(new String[] { "Comments",
actionName + "..." }, "comments"));
setPopupMenuData(
new MenuData(new String[] { "Comments", actionName + "..." }, "comments"));
setHelpLocation(new HelpLocation("CommentsPlugin", "Edit_Comments"));
}
protected int getEditCommentType(ActionContext context) {
/**
* {@return comment type or null for Generic Comment}
* @param context action context
*/
protected CommentType getEditCommentType(ActionContext context) {
return commentType;
}
@Override
public void actionPerformed(ActionContext context) {
CodeUnit cu = getCodeUnit(context);
int type = getEditCommentType(context);
CommentType type = getEditCommentType(context);
dialog.showDialog(cu, type);
}
@ -110,8 +118,7 @@ public class CommentsActionFactory {
return context.getCodeUnit();
}
protected ProgramLocation getLocationForContext(
ActionContext actionContext) {
protected ProgramLocation getLocationForContext(ActionContext actionContext) {
ProgramLocationActionContext context = (ProgramLocationActionContext) actionContext;
return context.getLocation();
}
@ -119,19 +126,18 @@ public class CommentsActionFactory {
private static class EditCommentsAction extends SetCommentsAction {
// Edit Comments Action info
private final static String[] EDIT_MENUPATH = new String[] {
"Comments", "Set..." };
private final static String[] EDIT_MENUPATH = new String[] { "Comments", "Set..." };
EditCommentsAction(CommentsDialog dialog, String name) {
super(dialog, name, "Edit Comments", CodeUnit.NO_COMMENT);
super(dialog, name, "Edit Comments", null);
setPopupMenuData(new MenuData(EDIT_MENUPATH, "comments"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_SEMICOLON, 0));
}
@Override
protected int getEditCommentType(ActionContext context) {
protected CommentType getEditCommentType(ActionContext context) {
CodeUnit cu = getCodeUnit(context);
return CommentTypeUtils.getCommentType(cu, getLocationForContext(context), CodeUnit.NO_COMMENT);
return CommentTypeUtils.getCommentType(cu, getLocationForContext(context), null);
}
}
}

View file

@ -37,6 +37,7 @@ import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.util.HelpLocation;
import ghidra.util.exception.AssertException;
/**
* Dialog for setting the comments for a CodeUnit.
@ -90,7 +91,7 @@ public class CommentsDialog extends ReusableDialogComponentProvider implements K
* @param cu code unit
* @param type comment type
*/
void showDialog(CodeUnit cu, int type) {
void showDialog(CodeUnit cu, CommentType type) {
setTitle("Set Comment(s) at Address " + cu.getMinAddress());
codeUnit = cu;
@ -134,23 +135,29 @@ public class CommentsDialog extends ReusableDialogComponentProvider implements K
tool.showDialog(this);
}
void setCommentType(int type) {
void setCommentType(CommentType type) {
if (type == null) {
tab.setSelectedIndex(0);
return;
}
switch (type) {
case CodeUnit.EOL_COMMENT:
case CommentType.EOL:
tab.setSelectedIndex(0);
break;
case CodeUnit.PRE_COMMENT:
case CommentType.PRE:
tab.setSelectedIndex(1);
break;
case CodeUnit.POST_COMMENT:
case CommentType.POST:
tab.setSelectedIndex(2);
break;
case CodeUnit.PLATE_COMMENT:
case CommentType.PLATE:
tab.setSelectedIndex(3);
break;
case CodeUnit.REPEATABLE_COMMENT:
case CommentType.REPEATABLE:
tab.setSelectedIndex(4);
break;
default:
throw new AssertException("Unsupported comment type: " + type.name());
}
}

View file

@ -27,8 +27,7 @@ import ghidra.app.plugin.PluginCategoryNames;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Program;
import ghidra.program.model.listing.*;
import ghidra.program.util.*;
import ghidra.util.HelpLocation;
@ -129,7 +128,7 @@ public class CommentsPlugin extends Plugin implements OptionsChangeListener {
* @param loc the {@link ProgramLocation} for which to delete the comment
*/
void deleteComments(Program program, ProgramLocation loc) {
int commentType = CommentTypeUtils.getCommentType(null, loc, CodeUnit.EOL_COMMENT);
CommentType commentType = CommentTypeUtils.getCommentType(null, loc, CommentType.EOL);
SetCommentCmd cmd = new SetCommentCmd(loc.getByteAddress(), commentType, null);
tool.execute(cmd, program);
}
@ -138,8 +137,8 @@ public class CommentsPlugin extends Plugin implements OptionsChangeListener {
if (codeUnit == null) {
return false;
}
int commentType = CommentTypeUtils.getCommentType(null, loc, CodeUnit.NO_COMMENT);
return (commentType != CodeUnit.NO_COMMENT && codeUnit.getComment(commentType) != null);
CommentType commentType = CommentTypeUtils.getCommentType(null, loc, null);
return (commentType != null && codeUnit.getComment(commentType) != null);
}
////////////////////////////////////////////////////////////////
@ -151,23 +150,23 @@ public class CommentsPlugin extends Plugin implements OptionsChangeListener {
editAction = CommentsActionFactory.getEditCommentsAction(dialog, name);
tool.addAction(editAction);
preCommentEditAction = CommentsActionFactory.getSetCommentsAction(dialog, name,
"Set Pre Comment", CodeUnit.PRE_COMMENT);
"Set Pre Comment", CommentType.PRE);
tool.addAction(preCommentEditAction);
postCommentEditAction = CommentsActionFactory.getSetCommentsAction(dialog, name,
"Set Post Comment", CodeUnit.POST_COMMENT);
"Set Post Comment", CommentType.POST);
tool.addAction(postCommentEditAction);
plateCommentEditAction = CommentsActionFactory.getSetCommentsAction(dialog, name,
"Set Plate Comment", CodeUnit.PLATE_COMMENT);
"Set Plate Comment", CommentType.PLATE);
tool.addAction(plateCommentEditAction);
eolCommentEditAction = CommentsActionFactory.getSetCommentsAction(dialog, name,
"Set EOL Comment", CodeUnit.EOL_COMMENT);
"Set EOL Comment", CommentType.EOL);
tool.addAction(eolCommentEditAction);
repeatableCommentEditAction = CommentsActionFactory.getSetCommentsAction(dialog, name,
"Set Repeatable Comment", CodeUnit.REPEATABLE_COMMENT);
"Set Repeatable Comment", CommentType.REPEATABLE);
tool.addAction(repeatableCommentEditAction);
deleteAction = new ListingContextAction("Delete Comments", pluginName) {
@ -215,7 +214,8 @@ public class CommentsPlugin extends Plugin implements OptionsChangeListener {
else {
historyAction.getPopupMenuData().setMenuPath(HISTORY_MENUPATH);
}
historyAction.setEnabled(CommentTypeUtils.isCommentAllowed(context.getCodeUnit(), loc));
historyAction
.setEnabled(CommentTypeUtils.isCommentAllowed(context.getCodeUnit(), loc));
return true;
}
};
@ -227,7 +227,7 @@ public class CommentsPlugin extends Plugin implements OptionsChangeListener {
private void showCommentHistory(ListingActionContext context) {
CodeUnit cu = context.getCodeUnit();
ProgramLocation loc = context.getLocation();
int commentType = CommentTypeUtils.getCommentType(null, loc, CodeUnit.EOL_COMMENT);
CommentType commentType = CommentTypeUtils.getCommentType(null, loc, CommentType.EOL);
CommentHistoryDialog historyDialog = new CommentHistoryDialog(cu, commentType);
tool.showDialog(historyDialog, context.getComponentProvider());
}
@ -254,31 +254,34 @@ public class CommentsPlugin extends Plugin implements OptionsChangeListener {
}
CommentFieldLocation cfLoc = (CommentFieldLocation) loc;
int type = cfLoc.getCommentType();
CommentType type = cfLoc.getCommentType();
switch (type) {
case CodeUnit.PRE_COMMENT:
case PRE:
action.getPopupMenuData()
.setMenuPath(
new String[] { "Comments", actionString + " Pre-Comment" + endString });
break;
case CodeUnit.POST_COMMENT:
case POST:
action.getPopupMenuData()
.setMenuPath(new String[] { "Comments",
actionString + " Post-Comment" + endString });
break;
case CodeUnit.EOL_COMMENT:
case EOL:
action.getPopupMenuData()
.setMenuPath(
new String[] { "Comments", actionString + " EOL Comment" + endString });
break;
case CodeUnit.REPEATABLE_COMMENT:
case REPEATABLE:
action.getPopupMenuData()
.setMenuPath(new String[] { "Comments",
actionString + " Repeatable Comment" + endString });
break;
default:
break;
}
}
}

View file

@ -16,13 +16,14 @@
package ghidra.app.plugin.core.commentwindow;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CommentType;
class CommentRowObject implements Comparable<CommentRowObject> {
private final Address address;
private final int commentType;
private final CommentType commentType;
CommentRowObject(Address address, int commentType) {
CommentRowObject(Address address, CommentType commentType) {
this.address = address;
this.commentType = commentType;
}
@ -31,7 +32,7 @@ class CommentRowObject implements Comparable<CommentRowObject> {
return address;
}
int getCommentType() {
CommentType getCommentType() {
return commentType;
}
@ -40,7 +41,7 @@ class CommentRowObject implements Comparable<CommentRowObject> {
final int prime = 31;
int result = 1;
result = prime * result + ((address == null) ? 0 : address.hashCode());
result = prime * result + commentType;
result = prime * result + commentType.hashCode();
return result;
}
@ -75,7 +76,7 @@ class CommentRowObject implements Comparable<CommentRowObject> {
int result = address.compareTo(o.address);
if (result == 0) {
result = commentType - o.commentType;
result = commentType.compareTo(o.commentType);
}
return result;
}

View file

@ -95,25 +95,25 @@ class CommentTableModel extends AddressBasedTableModel<CommentRowObject> {
}
if (cu.getComment(CommentType.PRE) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.PRE_COMMENT));
accumulator.add(new CommentRowObject(commentAddr, CommentType.PRE));
}
if (cu.getComment(CommentType.POST) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.POST_COMMENT));
accumulator.add(new CommentRowObject(commentAddr, CommentType.POST));
}
if (cu.getComment(CommentType.EOL) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.EOL_COMMENT));
accumulator.add(new CommentRowObject(commentAddr, CommentType.EOL));
}
if (cu.getComment(CommentType.PLATE) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.PLATE_COMMENT));
accumulator.add(new CommentRowObject(commentAddr, CommentType.PLATE));
}
if (cu.getComment(CommentType.REPEATABLE) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.REPEATABLE_COMMENT));
accumulator.add(new CommentRowObject(commentAddr, CommentType.REPEATABLE));
}
}
}
void commentAdded(Address addr, int commentType) {
void commentAdded(Address addr, CommentType commentType) {
String comment = listing.getComment(commentType, addr);
if (comment == null) {
@ -125,7 +125,7 @@ class CommentTableModel extends AddressBasedTableModel<CommentRowObject> {
}
void commentRemoved(Address addr, int commentType) {
void commentRemoved(Address addr, CommentType commentType) {
removeObject(new CommentRowObject(addr, commentType));
}
@ -161,23 +161,23 @@ class CommentTableModel extends AddressBasedTableModel<CommentRowObject> {
}
@Override
public String getValue(CommentRowObject rowObject, Settings settings, Program program,
public String getValue(CommentRowObject rowObject, Settings settings, Program p,
ServiceProvider provider) throws IllegalArgumentException {
String returnString = "";
if (rowObject.getCommentType() == CodeUnit.EOL_COMMENT) {
if (rowObject.getCommentType() == CommentType.EOL) {
return "EOL Comment";
}
if (rowObject.getCommentType() == CodeUnit.PLATE_COMMENT) {
if (rowObject.getCommentType() == CommentType.PLATE) {
return "Plate Comment";
}
if (rowObject.getCommentType() == CodeUnit.PRE_COMMENT) {
if (rowObject.getCommentType() == CommentType.PRE) {
return "Pre Comment";
}
if (rowObject.getCommentType() == CodeUnit.POST_COMMENT) {
if (rowObject.getCommentType() == CommentType.POST) {
return "Post Comment";
}
if (rowObject.getCommentType() == CodeUnit.REPEATABLE_COMMENT) {
if (rowObject.getCommentType() == CommentType.REPEATABLE) {
return "Repeatable Comment";
}
return returnString;
@ -198,7 +198,7 @@ class CommentTableModel extends AddressBasedTableModel<CommentRowObject> {
}
@Override
public String getValue(CommentRowObject rowObject, Settings settings, Program program,
public String getValue(CommentRowObject rowObject, Settings settings, Program p,
ServiceProvider provider) throws IllegalArgumentException {
String comment = getCommentForRowObject(rowObject);
return comment;

View file

@ -30,6 +30,7 @@ import ghidra.framework.plugintool.PluginInfo;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.program.util.CommentChangeRecord;
import ghidra.program.util.ProgramSelection;
@ -94,7 +95,7 @@ public class CommentWindowPlugin extends ProgramPlugin {
}
private void handleCommentChanged(CommentChangeRecord ccr) {
int commentType = ccr.getCommentType();
CommentType commentType = ccr.getCommentType();
String oldComment = ccr.getOldComment();
String newComment = ccr.getNewComment();
Address commentAddress = ccr.getStart();

View file

@ -25,6 +25,7 @@ import javax.swing.table.JTableHeader;
import docking.ActionContext;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation;
import ghidra.util.table.*;
@ -153,13 +154,13 @@ class CommentWindowProvider extends ComponentProviderAdapter {
}
}
void commentAdded(Address address, int commentType) {
void commentAdded(Address address, CommentType commentType) {
if (isVisible()) {
commentModel.commentAdded(address, commentType);
}
}
void commentRemoved(Address address, int commentType) {
void commentRemoved(Address address, CommentType commentType) {
if (isVisible()) {
commentModel.commentRemoved(address, commentType);
}

View file

@ -99,7 +99,6 @@ public class AddressTable {
this.shiftedAddr = shiftedAddr;
}
/**
* Create a new address table from any remaining table entries starting at startPos
*
@ -389,8 +388,7 @@ public class AddressTable {
Address lastAddress = null;
DataType ptrDT = program.getDataTypeManager()
.addDataType(
PointerDataType.getPointer(null, addrSize), null);
.addDataType(PointerDataType.getPointer(null, addrSize), null);
for (int i = 0; i < tableSize; i++) {
Address loc = tableAddr.add(i * addrSize);
try {
@ -473,8 +471,8 @@ public class AddressTable {
if (!flagNewCode || !newCodeFound) {
// create a case label
if (!ftype.isCall()) {
AddLabelCmd lcmd = new AddLabelCmd(target,
caseName + Integer.toHexString(i), true, SourceType.ANALYSIS);
AddLabelCmd lcmd = new AddLabelCmd(target, caseName + Integer.toHexString(i),
true, SourceType.ANALYSIS);
switchLabelList.add(lcmd);
}
@ -575,8 +573,9 @@ public class AddressTable {
// not putting switch into functions anymore
// program.getSymbolTable().getNamespace(start_inst.getMinAddress());
try {
space = program.getSymbolTable().createNameSpace(null,
"switch_" + start_inst.getMinAddress(), SourceType.ANALYSIS);
space = program.getSymbolTable()
.createNameSpace(null, "switch_" + start_inst.getMinAddress(),
SourceType.ANALYSIS);
}
catch (DuplicateNameException e) {
// just go with default space
@ -608,8 +607,8 @@ public class AddressTable {
}
// make sure the reference is associated with this symbol
Symbol s = program.getSymbolTable().getGlobalSymbol(tableNameLabel.getLabelName(),
tableNameLabel.getLabelAddr());
Symbol s = program.getSymbolTable()
.getGlobalSymbol(tableNameLabel.getLabelName(), tableNameLabel.getLabelAddr());
for (int op = 0; op < start_inst.getNumOperands(); op++) {
Reference fromRefs[] = start_inst.getOperandReferences(op);
for (Reference fromRef : fromRefs) {

View file

@ -28,11 +28,11 @@ import ghidra.util.StringUtilities;
public class CommentFieldSearcher extends ProgramDatabaseFieldSearcher {
private AddressIterator iterator;
private final int commentType;
private final CommentType commentType;
private Program program;
public CommentFieldSearcher(Program program, ProgramLocation startLoc, AddressSetView set,
boolean forward, Pattern pattern, int commentType) {
boolean forward, Pattern pattern, CommentType commentType) {
super(pattern, forward, startLoc, set);
this.commentType = commentType;
@ -89,16 +89,16 @@ public class CommentFieldSearcher extends ProgramDatabaseFieldSearcher {
int charOffset = getRelativeCharOffset(index, rowIndex, comments);
int[] dataPath = getDataComponentPath(address);
switch (commentType) {
case CodeUnit.EOL_COMMENT:
case EOL:
return new EolCommentFieldLocation(program, address, dataPath, comments, rowIndex,
charOffset, rowIndex);
case CodeUnit.PLATE_COMMENT:
case PLATE:
return new PlateFieldLocation(program, address, dataPath, rowIndex, charOffset,
comments, rowIndex);
case CodeUnit.REPEATABLE_COMMENT:
case REPEATABLE:
return new RepeatableCommentFieldLocation(program, address, dataPath, comments,
rowIndex, charOffset, rowIndex); // TODO One of searchStrIndex parameters is wrong.
case CodeUnit.POST_COMMENT:
case POST:
return new PostCommentFieldLocation(program, address, dataPath, comments, rowIndex,
charOffset);
default:

View file

@ -23,7 +23,7 @@ import ghidra.app.plugin.core.searchtext.Searcher;
import ghidra.app.util.viewer.field.BrowserCodeUnitFormat;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
import ghidra.util.UserSearchUtils;
@ -181,7 +181,7 @@ public class ProgramDatabaseSearcher implements Searcher {
if (options.searchComments()) {
searchers.add(new CommentFieldSearcher(program, adjustedStart, trimmedSet, forward,
pattern, CodeUnit.PLATE_COMMENT));
pattern, CommentType.PLATE));
}
if (options.searchFunctions()) {
searchers.add(
@ -189,7 +189,7 @@ public class ProgramDatabaseSearcher implements Searcher {
}
if (options.searchComments()) {
searchers.add(new CommentFieldSearcher(program, adjustedStart, trimmedSet, forward,
pattern, CodeUnit.PRE_COMMENT));
pattern, CommentType.PRE));
}
if (options.searchLabels()) {
searchers.add(
@ -209,10 +209,9 @@ public class ProgramDatabaseSearcher implements Searcher {
program, adjustedStart, trimmedSet, forward, pattern, format));
}
if (options.searchBothInstructionMnemonicAndOperands()) {
searchers.add(
InstructionMnemonicOperandFieldSearcher
.createInstructionMnemonicAndOperandFieldSearcher(
program, adjustedStart, trimmedSet, forward, pattern, format));
searchers.add(InstructionMnemonicOperandFieldSearcher
.createInstructionMnemonicAndOperandFieldSearcher(program, adjustedStart,
trimmedSet, forward, pattern, format));
}
if (options.searchOnlyInstructionMnemonics()) {
searchers.add(
@ -226,11 +225,11 @@ public class ProgramDatabaseSearcher implements Searcher {
}
if (options.searchComments()) {
searchers.add(new CommentFieldSearcher(program, adjustedStart, trimmedSet, forward,
pattern, CodeUnit.EOL_COMMENT));
pattern, CommentType.EOL));
searchers.add(new CommentFieldSearcher(program, adjustedStart, trimmedSet, forward,
pattern, CodeUnit.REPEATABLE_COMMENT));
pattern, CommentType.REPEATABLE));
searchers.add(new CommentFieldSearcher(program, adjustedStart, trimmedSet, forward,
pattern, CodeUnit.POST_COMMENT));
pattern, CommentType.POST));
}
}

View file

@ -100,7 +100,7 @@ public abstract class GccAnalysisClass {
* @param addr the address where data is created
* @param dt the type for the data
* @param comment the comment about the data
* @param commentType the {@link CommentType type of comment }
* @param commentType the type of comment
*/
protected static void createAndCommentData(Program program, Address addr, DataType dt,
String comment, CommentType commentType) {

View file

@ -46,14 +46,12 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
public static final String DESCRIPTION =
"Locates and annotates exception-handling infrastructure installed by the GCC compiler";
protected static final String OPTION_NAME_CREATE_TRY_CATCH_COMMENTS =
"Create Try Catch Comments";
private static final String OPTION_DESCRIPTION_CREATE_TRY_CATCH_COMMENTS =
protected static final String OPTION_NAME_CREATE_TRY_CATCHS = "Create Try Catch Comments";
private static final String OPTION_DESCRIPTION_CREATE_TRY_CATCHS =
"Selecting this check box causes the analyzer to create comments in the " +
"disassembly listing for the try and catch code.";
private static final boolean OPTION_DEFAULT_CREATE_TRY_CATCH_COMMENTS_ENABLED = true;
private boolean createTryCatchCommentsEnabled =
OPTION_DEFAULT_CREATE_TRY_CATCH_COMMENTS_ENABLED;
private static final boolean OPTION_DEFAULT_CREATE_TRY_CATCHS_ENABLED = true;
private boolean createTryCatchCommentsEnabled = OPTION_DEFAULT_CREATE_TRY_CATCHS_ENABLED;
private Set<Program> visitedPrograms = new HashSet<>();
private AutoAnalysisManagerListener analysisListener =
@ -304,8 +302,7 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
if (csMaxCodeUnit != null) {
Address commentAddr = csMaxCodeUnit.getMinAddress();
String endTryComment = "} // end try from " + csMinAddr + " to " + csMaxAddr;
String existingComment =
program.getListing().getComment(CommentType.POST, commentAddr);
String existingComment = program.getListing().getComment(CommentType.POST, commentAddr);
if (existingComment == null || !existingComment.contains(endTryComment)) {
String mergedComment = StringUtilities.mergeStrings(existingComment, endTryComment);
SetCommentCmd setCommentCmd =
@ -350,7 +347,7 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
// String mergedComment =
// StringUtilities.mergeStrings(existingComment, endCatchComment);
// SetCommentCmd setCommentCmd =
// new SetCommentCmd(lpMaxAddr, CodeUnit.POST_COMMENT, endCatchComment);
// new SetCommentCmd(lpMaxAddr, CommentType.POST, endCatchComment);
// setCommentCmd.applyTo(program);
// }
}
@ -428,14 +425,14 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
@Override
public void registerOptions(Options options, Program program) {
options.registerOption(OPTION_NAME_CREATE_TRY_CATCH_COMMENTS, createTryCatchCommentsEnabled,
null, OPTION_DESCRIPTION_CREATE_TRY_CATCH_COMMENTS);
options.registerOption(OPTION_NAME_CREATE_TRY_CATCHS, createTryCatchCommentsEnabled, null,
OPTION_DESCRIPTION_CREATE_TRY_CATCHS);
}
@Override
public void optionsChanged(Options options, Program program) {
createTryCatchCommentsEnabled = options.getBoolean(OPTION_NAME_CREATE_TRY_CATCH_COMMENTS,
createTryCatchCommentsEnabled);
createTryCatchCommentsEnabled =
options.getBoolean(OPTION_NAME_CREATE_TRY_CATCHS, createTryCatchCommentsEnabled);
}
}

View file

@ -160,8 +160,8 @@ public class EhFrameHeaderSection {
DwarfDecodeContext ctx = new DwarfDecodeContext(program, curAddress, curMemBlock);
Address frmPtrAddr = frmPtrDecoder.decodeAddress(ctx);
program.getReferenceManager().addMemoryReference(curAddress, frmPtrAddr, RefType.DATA,
SourceType.ANALYSIS, 0);
program.getReferenceManager()
.addMemoryReference(curAddress, frmPtrAddr, RefType.DATA, SourceType.ANALYSIS, 0);
DataType frmPtrDataType = frmPtrDecoder.getDataType(program);
@ -185,8 +185,8 @@ public class EhFrameHeaderSection {
}
private void createFdeTable(Address curAddress, ExceptionHandlerFrameHeader eh_frame_hdr,
int fdeTableCnt, TaskMonitor monitor) throws MemoryAccessException,
ExceptionHandlerFrameException {
int fdeTableCnt, TaskMonitor monitor)
throws MemoryAccessException, ExceptionHandlerFrameException {
/* Build the Frame Descriptor Entry Table */
int fdeTblEnc = eh_frame_hdr.getEh_FrameTableEncoding();

View file

@ -661,9 +661,9 @@ public class Cie extends GccAnalysisClass {
"(CIE Augmentation Data) Personality Function Pointer (" + personalityFuncAddr + ")",
CommentType.EOL);
program.getReferenceManager().addMemoryReference(
augmentationDataAddr.add(augmentationDataIndex), personalityFuncAddr, RefType.DATA,
SourceType.ANALYSIS, 0);
program.getReferenceManager()
.addMemoryReference(augmentationDataAddr.add(augmentationDataIndex),
personalityFuncAddr, RefType.DATA, SourceType.ANALYSIS, 0);
return personalityDecodeContext;
}

View file

@ -76,7 +76,7 @@ public class ExceptionHandlerFrameHeader {
DataTypeManager dtManager = prog.getDataTypeManager();
/* Add the ehFrameHdr Structure to the dataTypeManager */
dtManager.addDataType(ehFrameHdrStruct, DataTypeConflictHandler.REPLACE_HANDLER );
dtManager.addDataType(ehFrameHdrStruct, DataTypeConflictHandler.REPLACE_HANDLER);
}
/**
@ -96,7 +96,7 @@ public class ExceptionHandlerFrameHeader {
}
/* Create a new structure at the start of the .eh_frame_hdr section */
dataCmd = new CreateStructureCmd( ehFrameHdrStruct, addr );
dataCmd = new CreateStructureCmd(ehFrameHdrStruct, addr);
dataCmd.applyTo(prog);
/* Set a comment on the newly created structure */

View file

@ -100,13 +100,15 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
commentCmd.applyTo(program);
if (program.getMemory().contains(callSiteBaseAddr)) {
program.getReferenceManager().addMemoryReference(callSiteDataAddr, callSiteBaseAddr,
RefType.DATA, SourceType.ANALYSIS, 0);
program.getReferenceManager()
.addMemoryReference(callSiteDataAddr, callSiteBaseAddr, RefType.DATA,
SourceType.ANALYSIS, 0);
}
if (program.getMemory().contains(landingPadAddr)) {
program.getReferenceManager().addMemoryReference(lpDataAddr, landingPadAddr,
RefType.DATA, SourceType.ANALYSIS, 0);
program.getReferenceManager()
.addMemoryReference(lpDataAddr, landingPadAddr, RefType.DATA,
SourceType.ANALYSIS, 0);
}
nextAddress = addr;

View file

@ -40,7 +40,6 @@ public class LSDAHeader extends GccAnalysisClass {
static final int OMITTED_ENCODING_TYPE = 0xFF;
/* Class Members */
private RegionDescriptor region;

View file

@ -78,8 +78,7 @@ public class LSDATable {
* @param region the region of the program associated with this table
* @throws MemoryAccessException if memory couldn't be accessed for the LSDA table
*/
public void create(Address tableAddr, RegionDescriptor region)
throws MemoryAccessException {
public void create(Address tableAddr, RegionDescriptor region) throws MemoryAccessException {
region.setLSDATable(this);

View file

@ -94,8 +94,9 @@ public class LSDATypeTable extends GccAnalysisClass {
createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
if (typeRef.getOffset() != 0) {
program.getReferenceManager().addMemoryReference(addr, typeRef, RefType.DATA,
SourceType.ANALYSIS, 0);
program.getReferenceManager()
.addMemoryReference(addr, typeRef, RefType.DATA, SourceType.ANALYSIS,
0);
}
}

View file

@ -3928,8 +3928,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
* @see #getRepeatableComment(Address)
*/
public String getRepeatableCommentAsRendered(Address address) {
String comment =
currentProgram.getListing().getComment(CommentType.REPEATABLE, address);
String comment = currentProgram.getListing().getComment(CommentType.REPEATABLE, address);
PluginTool tool = state.getTool();
if (tool != null) {
comment = CommentUtils.getDisplayString(comment, currentProgram);

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,14 +15,14 @@
*/
package ghidra.app.util;
import java.util.ArrayList;
import java.util.List;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.*;
import ghidra.program.model.pcode.Varnode;
import ghidra.program.model.symbol.*;
import java.util.ArrayList;
import java.util.List;
/**
* Container object to keep a relative index, label, and comments. Used
* in a list for copying/pasting labels and comments from one program to
@ -91,23 +90,23 @@ public class CodeUnitInfo {
List<SourceType> scopeSymSourceList = new ArrayList<SourceType>();
List<String> otherSymList = new ArrayList<String>();
List<SourceType> otherSymSourceList = new ArrayList<SourceType>();
for (int i = 0; i < symbols.length; i++) {
SymbolType symbolType = symbols[i].getSymbolType();
if (symbols[i].isDynamic()) {
for (Symbol symbol : symbols) {
SymbolType symbolType = symbol.getSymbolType();
if (symbol.isDynamic()) {
hasDynamicSymbol = true;
}
else if (symbols[i].isPrimary()) {
primarySymbolName = symbols[i].getName();
primarySymbolSource = symbols[i].getSource();
else if (symbol.isPrimary()) {
primarySymbolName = symbol.getName();
primarySymbolSource = symbol.getSource();
primarySymbolInFunctionScope = (symbolType == SymbolType.FUNCTION);
}
else if (symbolType == SymbolType.FUNCTION) {
scopeSymList.add(symbols[i].getName());
scopeSymSourceList.add(symbols[i].getSource());
scopeSymList.add(symbol.getName());
scopeSymSourceList.add(symbol.getSource());
}
else {
otherSymList.add(symbols[i].getName());
otherSymSourceList.add(symbols[i].getSource());
otherSymList.add(symbol.getName());
otherSymSourceList.add(symbol.getSource());
}
}
functionScopeSymbolNames = new String[scopeSymList.size()];
@ -122,30 +121,34 @@ public class CodeUnitInfo {
/**
* Set the comment to be transferred.
* @param commentType CodeUnit.PRE_COMMENT, POST_COMMENT,
* PLATE_COMMENT, EOL_COMMENT, or REPEATABLE.
* @param commentType comment type
* @param comment comment
*/
public void setComment(int commentType, String[] comment) {
public void setComment(CommentType commentType, String[] comment) {
switch (commentType) {
case CodeUnit.PLATE_COMMENT:
case PLATE:
plateComment = comment;
break;
case CodeUnit.PRE_COMMENT:
case PRE:
preComment = comment;
break;
case CodeUnit.POST_COMMENT:
case POST:
postComment = comment;
break;
case CodeUnit.REPEATABLE_COMMENT:
case REPEATABLE:
repeatableComment = comment;
break;
case CodeUnit.EOL_COMMENT:
case EOL:
eolComment = comment;
break;
default:
throw new IllegalArgumentException(
"Unsupported comment type: " + commentType.name());
}
}
@ -387,17 +390,17 @@ public class CodeUnitInfo {
*/
private void setNonStackVarInfo(Variable[] vars) {
int variableIndex = 0;
for (int i = 0; i < vars.length; i++) {
if (vars[i].isStackVariable()) {
for (Variable var : vars) {
if (var.isStackVariable()) {
continue; // skip stack variables
}
varNames[variableIndex] = vars[i].getName();
varSources[variableIndex] = vars[i].getSource();
Varnode firstVarnode = vars[i].getFirstStorageVarnode();
varNames[variableIndex] = var.getName();
varSources[variableIndex] = var.getSource();
Varnode firstVarnode = var.getFirstStorageVarnode();
varAddrs[variableIndex] =
firstVarnode != null ? firstVarnode.getAddress() : Address.NO_ADDRESS;
varFUOffsets[variableIndex] = vars[i].getFirstUseOffset();
varComments[variableIndex] = vars[i].getComment();
varFUOffsets[variableIndex] = var.getFirstUseOffset();
varComments[variableIndex] = var.getComment();
++variableIndex;
}
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,14 +21,17 @@ import ghidra.program.model.listing.CodeUnit;
* Class with a convenience method to get an array of the CodeUnit
* comment types. The method is useful to loop through the comment types
* once you have a code unit.
* @deprecated the {@link CommentType enum should be used in place of integers}
*/
@Deprecated(forRemoval = true, since = "11.4")
public class CommentTypes {
private static int[] COMMENT_TYPES;
private static int NUMBER_OF_COMMENT_TYPES=5;
private static int NUMBER_OF_COMMENT_TYPES = 5;
CommentTypes() {
}
static {
COMMENT_TYPES = new int[NUMBER_OF_COMMENT_TYPES];
COMMENT_TYPES[0] = CodeUnit.PRE_COMMENT;
@ -38,6 +40,7 @@ public class CommentTypes {
COMMENT_TYPES[3] = CodeUnit.PLATE_COMMENT;
COMMENT_TYPES[4] = CodeUnit.REPEATABLE_COMMENT;
}
/**
* Get an array containing the comment types on a code unit.
*/

View file

@ -101,8 +101,7 @@ public class EolComments {
}
private void loadEols() {
Collection<String> comments =
Arrays.asList(codeUnit.getCommentAsArray(CommentType.EOL));
Collection<String> comments = Arrays.asList(codeUnit.getCommentAsArray(CommentType.EOL));
addStrings(comments, eols);
}

View file

@ -78,15 +78,15 @@ public class DWARFUtil {
*/
public static Field getStaticFinalFieldWithValue(Class<?> clazz, long value) {
Field[] fields = clazz.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
if ((!Modifier.isFinal(fields[i].getModifiers())) ||
(!Modifier.isStatic(fields[i].getModifiers()))) {
for (Field field : fields) {
if ((!Modifier.isFinal(field.getModifiers())) ||
(!Modifier.isStatic(field.getModifiers()))) {
continue;
}
try {
long fieldValue = fields[i].getLong(null);
long fieldValue = field.getLong(null);
if (fieldValue == value) {
return fields[i];
return field;
}
}
catch (IllegalArgumentException | IllegalAccessException e) {
@ -98,10 +98,6 @@ public class DWARFUtil {
//--------------------------------------
private static Pattern MANGLED_NESTING_REGEX = Pattern.compile("(.*_Z)?N([0-9]+.*)");
/**
@ -286,8 +282,7 @@ public class DWARFUtil {
String memberName = childDIEA.getName();
int memberOffset = 0;
try {
memberOffset =
childDIEA.parseDataMemberOffset(DW_AT_data_member_location, 0);
memberOffset = childDIEA.parseDataMemberOffset(DW_AT_data_member_location, 0);
}
catch (DWARFExpressionException | IOException e) {
// ignore, leave as default value 0
@ -359,7 +354,7 @@ public class DWARFUtil {
return;
}
}
AppendCommentCmd cmd = new AppendCommentCmd(address, commentType.ordinal(),
AppendCommentCmd cmd = new AppendCommentCmd(address, commentType,
Objects.requireNonNullElse(prefix, "") + comment, sep);
cmd.applyTo(program);
}
@ -398,8 +393,7 @@ public class DWARFUtil {
}
DIEAggregate funcDIEA = paramDIEA.getParent();
DWARFAttributeValue dwATObjectPointer =
funcDIEA.getAttribute(DW_AT_object_pointer);
DWARFAttributeValue dwATObjectPointer = funcDIEA.getAttribute(DW_AT_object_pointer);
if (dwATObjectPointer != null && dwATObjectPointer instanceof DWARFNumericAttribute dnum &&
paramDIEA.hasOffset(dnum.getUnsignedValue())) {
return true;
@ -442,8 +436,7 @@ public class DWARFUtil {
public static ResourceFile getLanguageExternalFile(Language lang, String name)
throws IOException {
String filename = getLanguageExternalNameValue(lang, name);
return filename != null
? new ResourceFile(getLanguageDefinitionDirectory(lang), filename)
return filename != null ? new ResourceFile(getLanguageDefinitionDirectory(lang), filename)
: null;
}

View file

@ -82,7 +82,8 @@ public class NoteGnuProperty extends ElfNote {
/**
* Contains the information of an individual note property.
*/
public record NotePropertyElement(int type, String typeName, String value, int length) {}
public record NotePropertyElement(int type, String typeName, String value, int length) {
}
private static NotePropertyElement readNextNotePropertyElement(BinaryReader reader, int intSize)
throws IOException {

View file

@ -120,8 +120,8 @@ public abstract class DataDirectory implements PeMarkupable {
}
protected void createDirectoryBookmark(Program program, Address addr) {
program.getBookmarkManager().setBookmark(addr, BookmarkType.INFO, "PE Header",
getDirectoryName());
program.getBookmarkManager()
.setBookmark(addr, BookmarkType.INFO, "PE Header", getDirectoryName());
}
protected void setBookmark(Program prog, Address addr, String comment) {

View file

@ -439,12 +439,12 @@ public class CliTableMethodDef extends CliAbstractTable {
// Create the function, if already created, update the existing function
Function func = funcMgr.getFunctionAt(startAddr);
if (func == null) {
func = funcMgr
.createFunction(funcName, startAddr, funcAddrSet, SourceType.ANALYSIS);
func = funcMgr.createFunction(funcName, startAddr, funcAddrSet,
SourceType.ANALYSIS);
}
func.setReturnType(returnType, SourceType.ANALYSIS);
func.updateFunction(null, null, FunctionUpdateType.DYNAMIC_STORAGE_ALL_PARAMS,
true, SourceType.ANALYSIS, parameters);
func.updateFunction(null, null, FunctionUpdateType.DYNAMIC_STORAGE_ALL_PARAMS, true,
SourceType.ANALYSIS, parameters);
markToPreventIncorrectProcessorDisassembly(program, methodRow, startAddr, endAddr);
}
@ -503,9 +503,9 @@ public class CliTableMethodDef extends CliAbstractTable {
* @param endAddr end address of the function
* @throws CodeUnitInsertionException couldn't create dagta.
*/
private void markToPreventIncorrectProcessorDisassembly(Program program, CliMethodDefRow methodRow,
Address startAddr, Address endAddr) throws CodeUnitInsertionException {
private void markToPreventIncorrectProcessorDisassembly(Program program,
CliMethodDefRow methodRow, Address startAddr, Address endAddr)
throws CodeUnitInsertionException {
PrototypeModel cliCallingConvention = program.getLanguage()
.getDefaultCompilerSpec()

View file

@ -96,9 +96,8 @@ public class DemangledAddressTable extends DemangledObject {
Listing listing = program.getListing();
if (program.getMemory().isExternalBlockAddress(address)) {
Msg.warn(this,
"Unable to fully apply external demangled Address Table at " + address + ": " +
s.getName(true));
Msg.warn(this, "Unable to fully apply external demangled Address Table at " + address +
": " + s.getName(true));
listing.setComment(address, CommentType.EOL,
"WARNING: Unable to apply demangled Address Table");
return true; // don't complain

View file

@ -355,9 +355,8 @@ class ProgramTextWriter {
return;
}
int len = options.getAddrWidth() + options.getBytesWidth() +
options.getPreMnemonicWidth() + options.getMnemonicWidth() +
options.getOperandWidth();
int len = options.getAddrWidth() + options.getBytesWidth() + options.getPreMnemonicWidth() +
options.getMnemonicWidth() + options.getOperandWidth();
String fill = genFill(len);
for (int i = 0; i < comments.size(); ++i) {

View file

@ -94,8 +94,8 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
maps.add(postCommentMap);
maps.add(eolCommentMap);
int[] types = new int[] { CodeUnit.PLATE_COMMENT, CodeUnit.PRE_COMMENT,
CodeUnit.POST_COMMENT, CodeUnit.EOL_COMMENT };
CommentType[] types = new CommentType[] { CommentType.PLATE, CommentType.PRE,
CommentType.POST, CommentType.EOL };
String[] typeNames = new String[] { "PLATE", "PRE", "POST", "EOL" };
int index = 0;
for (HashMap<Address, StringBuffer> map : maps) {
@ -273,7 +273,7 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
//log.appendMsg("Unable to demangle: "+name);
}
if (builder.length() > 0) {
setComment(CodeUnit.PLATE_COMMENT, address, builder.toString());
setComment(CommentType.PLATE, address, builder.toString());
}
}
@ -295,11 +295,11 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
Address startAddr = addr.add(Conv.intToLong(starts[k]));
String cmt = "START-> " + file.getName() + ": " + "?";
setComment(CodeUnit.PRE_COMMENT, startAddr, cmt);
setComment(CommentType.PRE, startAddr, cmt);
Address endAddr = addr.add(Conv.intToLong(ends[k]));
cmt = "END-> " + file.getName() + ": " + "?";
setComment(CodeUnit.PRE_COMMENT, endAddr, cmt);
setComment(CommentType.PRE, endAddr, cmt);
if (monitor.isCancelled()) {
return;
@ -380,8 +380,7 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
}
protected boolean processDebugCoffSymbol(DebugCOFFSymbol symbol, NTHeader ntHeader,
Map<SectionHeader, Address> sectionToAddress, Program program,
TaskMonitor monitor) {
Map<SectionHeader, Address> sectionToAddress, Program program, TaskMonitor monitor) {
if (symbol.getSectionNumber() == 0) {
return true;
@ -453,7 +452,7 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
if (aux == null) {
continue;
}
setComment(CodeUnit.PRE_COMMENT, address, aux.toString());
setComment(CommentType.PRE, address, aux.toString());
}
return true;
@ -499,54 +498,57 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
private void addLineComment(Address addr, int line) {
String cmt = addr + " -> " + "Line #" + line;
setComment(CodeUnit.PRE_COMMENT, addr, cmt);
setComment(CommentType.PRE, addr, cmt);
}
protected boolean hasComment(int type, Address address) {
protected boolean hasComment(CommentType type, Address address) {
switch (type) {
case CodeUnit.PLATE_COMMENT:
case PLATE:
return plateCommentMap.get(address) != null;
case CodeUnit.PRE_COMMENT:
case PRE:
return preCommentMap.get(address) != null;
case CodeUnit.POST_COMMENT:
case POST:
return postCommentMap.get(address) != null;
case CodeUnit.EOL_COMMENT:
case EOL:
return eolCommentMap.get(address) != null;
default:
throw new IllegalArgumentException("Unsupported comment type: " + type.name());
}
return false;
}
protected void setComment(int type, Address address, String comment) {
protected void setComment(CommentType type, Address address, String comment) {
StringBuffer buffer = null;
switch (type) {
case CodeUnit.PLATE_COMMENT:
case CommentType.PLATE:
buffer = plateCommentMap.get(address);
if (buffer == null) {
buffer = new StringBuffer();
plateCommentMap.put(address, buffer);
}
break;
case CodeUnit.PRE_COMMENT:
case CommentType.PRE:
buffer = preCommentMap.get(address);
if (buffer == null) {
buffer = new StringBuffer();
preCommentMap.put(address, buffer);
}
break;
case CodeUnit.POST_COMMENT:
case CommentType.POST:
buffer = postCommentMap.get(address);
if (buffer == null) {
buffer = new StringBuffer();
postCommentMap.put(address, buffer);
}
break;
case CodeUnit.EOL_COMMENT:
case CommentType.EOL:
buffer = eolCommentMap.get(address);
if (buffer == null) {
buffer = new StringBuffer();
eolCommentMap.put(address, buffer);
}
break;
default:
throw new IllegalArgumentException("Unsupported comment type: " + type.name());
}
if (buffer != null) {
if (buffer.length() > 0) {

View file

@ -550,13 +550,13 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
// Scalar scalar = (Scalar)data.getValue();
// switch ((int)scalar.getValue()) {
// case GNU_Constants.VER_NDX_LOCAL:
// data.setComment(Data.EOL_COMMENT, symbols[index].getNameAsString()+ " - local version");
// data.setComment(Data.EOL, symbols[index].getNameAsString()+ " - local version");
// break;
// case GNU_Constants.VER_NDX_GLOBAL:
// data.setComment(Data.EOL_COMMENT, symbols[index].getNameAsString()+ " - global version");
// data.setComment(Data.EOL, symbols[index].getNameAsString()+ " - global version");
// break;
// default:
// data.setComment(Data.EOL_COMMENT, symbols[index].getNameAsString()+ " - ??");
// data.setComment(Data.EOL, symbols[index].getNameAsString()+ " - ??");
// break;
// }
}

View file

@ -254,7 +254,7 @@ public class PeLoader extends AbstractPeDebugLoader {
dt = section.toDataType();
DataUtilities.createData(program, start, dt, -1,
DataUtilities.ClearDataMode.CHECK_FOR_SPACE);
setComment(CodeUnit.EOL_COMMENT, start, section.getName());
setComment(CommentType.EOL, start, section.getName());
start = start.add(dt.getLength());
}
}
@ -383,7 +383,7 @@ public class PeLoader extends AbstractPeDebugLoader {
Address address = space.getAddress(addr);
setComment(CodeUnit.PRE_COMMENT, address, importInfo.getComment());
setComment(CommentType.PRE, address, importInfo.getComment());
Data data = listing.getDefinedDataAt(address);
if (data != null && data.isPointer()) {
@ -547,7 +547,7 @@ public class PeLoader extends AbstractPeDebugLoader {
}
Address address = space.getAddress(export.getAddress());
setComment(CodeUnit.PRE_COMMENT, address, export.getComment());
setComment(CommentType.PRE, address, export.getComment());
symTable.addExternalEntryPoint(address);
String name = export.getName();
@ -713,9 +713,8 @@ public class PeLoader extends AbstractPeDebugLoader {
int dataSize = (virtualSize > 0 || rawDataSize < 0) ? virtualSize : 0;
if (dataSize > 0) {
if (block != null) {
MemoryBlock paddingBlock =
MemoryBlockUtils.createInitializedBlock(prog, false, sectionName,
address, dataSize, "", "", r, w, x, log);
MemoryBlock paddingBlock = MemoryBlockUtils.createInitializedBlock(prog,
false, sectionName, address, dataSize, "", "", r, w, x, log);
if (paddingBlock != null) {
try {
prog.getMemory().join(block, paddingBlock);

View file

@ -166,9 +166,8 @@ public class PlateFieldFactory extends FieldFactory {
ListingFieldHighlightFactoryAdapter hlFactory =
new ListingFieldHighlightFactoryAdapter(hlProvider);
PlateFieldTextField textField =
new PlateFieldTextField(elements, this, proxy, startX, width, commentText, isClipped,
hlFactory);
PlateFieldTextField textField = new PlateFieldTextField(elements, this, proxy, startX,
width, commentText, isClipped, hlFactory);
PlateListingTextField listingField = new PlateListingTextField(proxy, textField, hlFactory);
return listingField;
}
@ -256,8 +255,8 @@ public class PlateFieldFactory extends FieldFactory {
commentsList.add(CommentUtils.parseTextForAnnotations(c, p, prototype, row++));
}
for (String offcut : offcutComments) {
AttributedString as = new AttributedString(offcut, CommentColors.OFFCUT,
getMetrics(style), false, null);
AttributedString as =
new AttributedString(offcut, CommentColors.OFFCUT, getMetrics(style), false, null);
commentsList.add(new TextFieldElement(as, commentsList.size(), 0));
}
@ -540,7 +539,7 @@ public class PlateFieldFactory extends FieldFactory {
}
CommentFieldLocation commentLocation = (CommentFieldLocation) programLoc;
if (commentLocation.getCommentType() != CodeUnit.PLATE_COMMENT) {
if (commentLocation.getCommentType() != CommentType.PLATE) {
return null;
}
@ -603,8 +602,8 @@ public class PlateFieldFactory extends FieldFactory {
@Override
public FieldFactory newInstance(FieldFormatModel formatModel,
ListingHighlightProvider hsProvider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
ListingHighlightProvider hsProvider, ToolOptions toolOptions,
ToolOptions fieldOptions) {
return new PlateFieldFactory(formatModel, hsProvider, toolOptions, fieldOptions);
}

View file

@ -313,7 +313,7 @@ public class PostCommentFieldFactory extends FieldFactory {
}
CommentFieldLocation loc = (CommentFieldLocation) programLoc;
if (loc.getCommentType() != CodeUnit.POST_COMMENT) {
if (loc.getCommentType() != CommentType.POST) {
return null;
}
return new FieldLocation(index, fieldNum, loc.getRow(), loc.getCharOffset());

View file

@ -153,7 +153,7 @@ public class PreCommentFieldFactory extends FieldFactory {
cpath = ((Data) cu).getComponentPath();
}
return new CommentFieldLocation(cu.getProgram(), cu.getMinAddress(), cpath, comment,
CodeUnit.PRE_COMMENT, row, col);
CommentType.PRE, row, col);
}
@Override
@ -164,7 +164,7 @@ public class PreCommentFieldFactory extends FieldFactory {
}
CommentFieldLocation loc = (CommentFieldLocation) programLoc;
if (loc.getCommentType() != CodeUnit.PRE_COMMENT) {
if (loc.getCommentType() != CommentType.PRE) {
return null;
}
return new FieldLocation(index, fieldNum, loc.getRow(), loc.getCharOffset());

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,11 +15,16 @@
*/
package ghidra.app.util.xml;
import ghidra.app.util.CommentTypes;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import ghidra.app.util.importer.MessageLog;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.util.XmlProgramUtilities;
import ghidra.util.exception.AssertException;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
import ghidra.util.xml.XmlAttributes;
@ -28,8 +32,6 @@ import ghidra.util.xml.XmlWriter;
import ghidra.xml.XmlElement;
import ghidra.xml.XmlPullParser;
import java.io.IOException;
/**
* XML manager for all types of comments.
*/
@ -39,31 +41,31 @@ class CommentsXmlMgr {
private AddressFactory factory;
private Listing listing;
private static int[] COMMENT_TYPES;
private static String[] COMMENT_TAGS;
private static Map<CommentType, String> COMMENT_TAGS;
static {
COMMENT_TYPES = CommentTypes.getTypes();
COMMENT_TAGS = new String[COMMENT_TYPES.length];
for (int i = 0; i < COMMENT_TAGS.length; i++) {
COMMENT_TAGS = new HashMap<>();
for (CommentType type : CommentType.values()) {
switch (COMMENT_TYPES[i]) {
case CodeUnit.PRE_COMMENT:
COMMENT_TAGS[i] = "pre";
switch (type) {
case CommentType.PRE:
COMMENT_TAGS.put(type, "pre");
break;
case CodeUnit.POST_COMMENT:
COMMENT_TAGS[i] = "post";
case CommentType.POST:
COMMENT_TAGS.put(type, "post");
break;
case CodeUnit.EOL_COMMENT:
COMMENT_TAGS[i] = "end-of-line";
case CommentType.EOL:
COMMENT_TAGS.put(type, "end-of-line");
break;
case CodeUnit.PLATE_COMMENT:
COMMENT_TAGS[i] = "plate";
case CommentType.PLATE:
COMMENT_TAGS.put(type, "plate");
break;
case CodeUnit.REPEATABLE_COMMENT:
COMMENT_TAGS[i] = "repeatable";
case CommentType.REPEATABLE:
COMMENT_TAGS.put(type, "repeatable");
break;
default:
throw new AssertException("Unsupported comment type: " + type.name());
}
}
}
@ -79,9 +81,11 @@ class CommentsXmlMgr {
* Process the entry point section of the XML file.
* @param parser xml reader
* @param monitor monitor that can be canceled
* @throws AddressFormatException
* @throws CancelledException
*/
void read(XmlPullParser parser, TaskMonitor monitor) throws AddressFormatException,
CancelledException {
void read(XmlPullParser parser, TaskMonitor monitor)
throws AddressFormatException, CancelledException {
XmlElement element = parser.next();
while (true) {
if (monitor.isCancelled()) {
@ -103,9 +107,10 @@ class CommentsXmlMgr {
* @param set address set that is either the entire program or a selection
* @param monitor monitor that can be canceled
* should be written
* @throws IOException
* @throws CancelledException if task is cancelled
*/
void write(XmlWriter writer, AddressSetView set, TaskMonitor monitor) throws CancelledException {
void write(XmlWriter writer, AddressSetView set, TaskMonitor monitor)
throws CancelledException {
monitor.setMessage("Writing COMMENTS ...");
if (set == null) {
@ -117,17 +122,15 @@ class CommentsXmlMgr {
CodeUnitIterator iter = listing.getCodeUnitIterator(CodeUnit.COMMENT_PROPERTY, set, true);
while (iter.hasNext()) {
if (monitor.isCancelled()) {
throw new CancelledException();
}
monitor.checkCancelled();
CodeUnit cu = iter.next();
for (int i = 0; i < COMMENT_TYPES.length; i++) {
for (CommentType type : CommentType.values()) {
if (monitor.isCancelled()) {
return;
}
String comments = cu.getComment(COMMENT_TYPES[i]);
String comments = cu.getComment(type);
if (comments != null) {
writeComment(writer, cu.getMinAddress(), COMMENT_TAGS[i], comments);
writeComment(writer, cu.getMinAddress(), COMMENT_TAGS.get(type), comments);
}
}
}
@ -143,8 +146,8 @@ class CommentsXmlMgr {
}
try {
String typeStr = element.getAttribute("TYPE");
int commentType = getCommentType(typeStr);
if (commentType < 0) {
CommentType commentType = getCommentType(typeStr);
if (commentType == null) {
log.appendMsg("Unknown comment type: " + typeStr);
parser.discardSubTree(element);
return;
@ -180,12 +183,15 @@ class CommentsXmlMgr {
writer.writeElement("COMMENT", attrs, comments);
}
private int getCommentType(String typeStr) {
for (int i = 0; i < COMMENT_TAGS.length; i++) {
if (COMMENT_TAGS[i].equals(typeStr)) {
return COMMENT_TYPES[i];
private CommentType getCommentType(String typeStr) {
if (StringUtils.isBlank(typeStr)) {
return null;
}
for (CommentType type : CommentType.values()) {
if (typeStr.equals(COMMENT_TAGS.get(type))) {
return type;
}
}
return -1; // unknown comment
return null; // unknown comment
}
}

View file

@ -20,6 +20,7 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.program.util.*;
import ghidra.util.exception.AssertException;
/**
* QuickFix for updating listing comments.
@ -80,11 +81,11 @@ public class UpdateCommentQuickFix extends QuickFix {
case POST:
return new PostCommentFieldLocation(program, address, null, null, 0, 0);
case PRE:
return new CommentFieldLocation(program, address, null, null, type.ordinal(), 0, 0);
return new CommentFieldLocation(program, address, null, null, type, 0, 0);
case REPEATABLE:
return new RepeatableCommentFieldLocation(program, address, null, null, 0, 0, 0);
default:
return null;
throw new AssertException("Unsupported comment type: " + type.name());
}
}

View file

@ -933,15 +933,15 @@ public class ProgramBuilder {
});
}
@Deprecated(forRemoval = true, since = "11.4")
public void createComment(String address, String comment, int commentType) {
CommentType type = CommentType.values()[commentType];
createComment(address, comment, type);
createComment(address, comment, CommentType.valueOf(commentType));
}
public void createComment(String address, String comment, CommentType type) {
public void createComment(String address, String comment, CommentType commentType) {
tx(() -> {
Listing listing = program.getListing();
listing.setComment(addr(address), type, comment);
listing.setComment(addr(address), commentType, comment);
});
}
@ -1109,8 +1109,7 @@ public class ProgramBuilder {
}
return tx(() -> {
FileBytes fileBytes =
program.getMemory()
FileBytes fileBytes = program.getMemory()
.createFileBytes("test", 0, size, new ByteArrayInputStream(bytes),
TaskMonitor.DUMMY);

View file

@ -319,8 +319,8 @@ public class FlatProgramAPI {
* @param bookmarks true if bookmarks should be cleared
* @return true if the address set was successfully cleared
*/
public final boolean clearListing(AddressSetView set, boolean instructions,
boolean data, boolean symbols, boolean comments, boolean properties, boolean functions,
public final boolean clearListing(AddressSetView set, boolean instructions, boolean data,
boolean symbols, boolean comments, boolean properties, boolean functions,
boolean registers, boolean equates, boolean userReferences, boolean analysisReferences,
boolean importReferences, boolean defaultReferences, boolean bookmarks) {
@ -358,12 +358,10 @@ public class FlatProgramAPI {
long length, boolean overlay) throws Exception {
if (input == null) {
return currentProgram.getMemory()
.createUninitializedBlock(name, start, length,
overlay);
.createUninitializedBlock(name, start, length, overlay);
}
return currentProgram.getMemory()
.createInitializedBlock(name, start, input, length,
monitor, overlay);
.createInitializedBlock(name, start, input, length, monitor, overlay);
}
/**
@ -379,8 +377,7 @@ public class FlatProgramAPI {
boolean overlay) throws Exception {
ByteArrayInputStream input = new ByteArrayInputStream(bytes);
return currentProgram.getMemory()
.createInitializedBlock(name, start, input, bytes.length,
monitor, overlay);
.createInitializedBlock(name, start, input, bytes.length, monitor, overlay);
}
/**
@ -1940,8 +1937,7 @@ public class FlatProgramAPI {
public final Reference addInstructionXref(Address from, Address to, int opIndex,
FlowType type) {
return currentProgram.getReferenceManager()
.addMemoryReference(from, to, type,
SourceType.USER_DEFINED, opIndex);
.addMemoryReference(from, to, type, SourceType.USER_DEFINED, opIndex);
}
/**
@ -2401,8 +2397,7 @@ public class FlatProgramAPI {
*/
public final Equate getEquate(Instruction instruction, int operandIndex, long value) {
return currentProgram.getEquateTable()
.getEquate(instruction.getMinAddress(), operandIndex,
value);
.getEquate(instruction.getMinAddress(), operandIndex, value);
}
/**
@ -2413,8 +2408,7 @@ public class FlatProgramAPI {
*/
public final List<Equate> getEquates(Instruction instruction, int operandIndex) {
return currentProgram.getEquateTable()
.getEquates(instruction.getMinAddress(),
operandIndex);
.getEquates(instruction.getMinAddress(), operandIndex);
}
/**
@ -2426,8 +2420,7 @@ public class FlatProgramAPI {
Object obj = data.getValue();
if (obj instanceof Scalar) {
return currentProgram.getEquateTable()
.getEquate(data.getMinAddress(), 0,
((Scalar) obj).getValue());
.getEquate(data.getMinAddress(), 0, ((Scalar) obj).getValue());
}
return null;
}

View file

@ -643,32 +643,32 @@ public class ProgramDiff {
case ProgramDiffFilter.EOL_COMMENT_DIFFS:
monitorMsg = "Checking End of Line Comment Differences";
monitor.setMessage(monitorMsg);
as = getCommentDiffs(CodeUnit.EOL_COMMENT, addrs,
new CommentTypeComparator(CodeUnit.EOL_COMMENT), monitor);
as = getCommentDiffs(CommentType.EOL, addrs,
new CommentTypeComparator(CommentType.EOL), monitor);
break;
case ProgramDiffFilter.REPEATABLE_COMMENT_DIFFS:
monitorMsg = "Checking Repeatable Comment Differences";
monitor.setMessage(monitorMsg);
as = getCommentDiffs(CodeUnit.REPEATABLE_COMMENT, addrs,
new CommentTypeComparator(CodeUnit.REPEATABLE_COMMENT), monitor);
as = getCommentDiffs(CommentType.REPEATABLE, addrs,
new CommentTypeComparator(CommentType.REPEATABLE), monitor);
break;
case ProgramDiffFilter.PRE_COMMENT_DIFFS:
monitorMsg = "Checking Pre-Comment Differences";
monitor.setMessage(monitorMsg);
as = getCommentDiffs(CodeUnit.PRE_COMMENT, addrs,
new CommentTypeComparator(CodeUnit.PRE_COMMENT), monitor);
as = getCommentDiffs(CommentType.PRE, addrs,
new CommentTypeComparator(CommentType.PRE), monitor);
break;
case ProgramDiffFilter.POST_COMMENT_DIFFS:
monitorMsg = "Checking Post-Comment Differences";
monitor.setMessage(monitorMsg);
as = getCommentDiffs(CodeUnit.POST_COMMENT, addrs,
new CommentTypeComparator(CodeUnit.POST_COMMENT), monitor);
as = getCommentDiffs(CommentType.POST, addrs,
new CommentTypeComparator(CommentType.POST), monitor);
break;
case ProgramDiffFilter.PLATE_COMMENT_DIFFS:
monitorMsg = "Checking Plate Comment Differences";
monitor.setMessage(monitorMsg);
as = getCommentDiffs(CodeUnit.PLATE_COMMENT, addrs,
new CommentTypeComparator(CodeUnit.PLATE_COMMENT), monitor);
as = getCommentDiffs(CommentType.PLATE, addrs,
new CommentTypeComparator(CommentType.PLATE), monitor);
break;
case ProgramDiffFilter.REFERENCE_DIFFS:
monitorMsg = "Checking Reference Differences";
@ -926,32 +926,32 @@ public class ProgramDiff {
case ProgramDiffFilter.EOL_COMMENT_DIFFS:
monitorMsg = "Checking End of Line Comment Differences";
monitor.setMessage(monitorMsg);
as = getCommentDiffs(CodeUnit.EOL_COMMENT, checkAddressSet,
new CommentTypeComparator(CodeUnit.EOL_COMMENT), monitor);
as = getCommentDiffs(CommentType.EOL, checkAddressSet,
new CommentTypeComparator(CommentType.EOL), monitor);
break;
case ProgramDiffFilter.REPEATABLE_COMMENT_DIFFS:
monitorMsg = "Checking Repeatable Comment Differences";
monitor.setMessage(monitorMsg);
as = getCommentDiffs(CodeUnit.REPEATABLE_COMMENT, checkAddressSet,
new CommentTypeComparator(CodeUnit.REPEATABLE_COMMENT), monitor);
as = getCommentDiffs(CommentType.REPEATABLE, checkAddressSet,
new CommentTypeComparator(CommentType.REPEATABLE), monitor);
break;
case ProgramDiffFilter.PRE_COMMENT_DIFFS:
monitorMsg = "Checking Pre-Comment Differences";
monitor.setMessage(monitorMsg);
as = getCommentDiffs(CodeUnit.PRE_COMMENT, checkAddressSet,
new CommentTypeComparator(CodeUnit.PRE_COMMENT), monitor);
as = getCommentDiffs(CommentType.PRE, checkAddressSet,
new CommentTypeComparator(CommentType.PRE), monitor);
break;
case ProgramDiffFilter.POST_COMMENT_DIFFS:
monitorMsg = "Checking Post-Comment Differences";
monitor.setMessage(monitorMsg);
as = getCommentDiffs(CodeUnit.POST_COMMENT, checkAddressSet,
new CommentTypeComparator(CodeUnit.POST_COMMENT), monitor);
as = getCommentDiffs(CommentType.POST, checkAddressSet,
new CommentTypeComparator(CommentType.POST), monitor);
break;
case ProgramDiffFilter.PLATE_COMMENT_DIFFS:
monitorMsg = "Checking Plate Comment Differences";
monitor.setMessage(monitorMsg);
as = getCommentDiffs(CodeUnit.PLATE_COMMENT, checkAddressSet,
new CommentTypeComparator(CodeUnit.PLATE_COMMENT), monitor);
as = getCommentDiffs(CommentType.PLATE, checkAddressSet,
new CommentTypeComparator(CommentType.PLATE), monitor);
break;
case ProgramDiffFilter.REFERENCE_DIFFS:
monitorMsg = "Checking Reference Differences";
@ -1773,7 +1773,7 @@ public class ProgramDiff {
* Determines the code unit addresses where there are differences of the
* indicated type between program1 and program2.
* @param cuiType the type of difference on the code unit. These are defined
* in <CODE>CodeUnit</CODE>. (i.e. CodeUnit.EOL_COMMENT_PROPERTY).
* in <CODE>CodeUnit</CODE>. (i.e. CommentType.EOL_PROPERTY).
* @param addressSet the addresses to check for differences.
* The addresses in this address set should be derived from program1.
* @param c the comparator to use for determining where the differences are.
@ -1798,7 +1798,7 @@ public class ProgramDiff {
* Determines the code unit addresses where there are comment differences of the
* indicated type between program1 and program2.
* @param commentType the type of comment. These are defined
* in <CODE>CodeUnit</CODE>. (i.e. CodeUnit.EOL_COMMENT).
* in <CODE>CodeUnit</CODE>. (i.e. CommentType.EOL).
* @param addressSet the addresses to check for differences.
* The addresses in this address set should be derived from program1.
* @param c the comparator to use for determining where the differences are.
@ -1810,7 +1810,7 @@ public class ProgramDiff {
* The addresses in this address set are derived from program1.
* @throws CancelledException if the user cancelled the Diff.
*/
private AddressSet getCommentDiffs(int commentType, AddressSetView addressSet,
private AddressSet getCommentDiffs(CommentType commentType, AddressSetView addressSet,
CommentTypeComparator c, TaskMonitor monitor) throws CancelledException {
AddressIterator iter1 = listing1.getCommentAddressIterator(commentType, addressSet, true);
AddressSet addressSet2 = DiffUtility.getCompatibleAddressSet(addressSet, program2);
@ -2638,13 +2638,13 @@ public class ProgramDiff {
private class CommentTypeComparator extends ProgramDiffComparatorImpl<Address> {
/**
* the type of comment to compare
* <br>CodeUnit.PLATE_COMMENT
* <br>CodeUnit.PRE_COMMENT
* <br>CodeUnit.EOL_COMMENT
* <br>CodeUnit.REPEATABLE_COMMENT
* <br>CodeUnit.POST_COMMENT
* <br>CommentType.PLATE
* <br>CommentType.PRE
* <br>CommentType.EOL
* <br>CommentType.REPEATABLE
* <br>CommentType.POST
*/
int type;
CommentType type;
private Listing comparatorListing1;
private Listing comparatorListing2;
@ -2652,7 +2652,7 @@ public class ProgramDiff {
* Generic constructor for comparing program differences.
* @param type the comment type
*/
private CommentTypeComparator(int type) {
private CommentTypeComparator(CommentType type) {
this.type = type;
comparatorListing1 = program1.getListing();
comparatorListing2 = program2.getListing();

View file

@ -1398,19 +1398,19 @@ public class ProgramDiffDetails {
}
private void addEOLCommentDetails() {
hasEolCommentDiffs = addSpecificCommentDetails(CodeUnit.EOL_COMMENT, "EOL-Comment");
hasEolCommentDiffs = addSpecificCommentDetails(CommentType.EOL, "EOL-Comment");
}
private void addPreCommentDetails() {
hasPreCommentDiffs = addSpecificCommentDetails(CodeUnit.PRE_COMMENT, "Pre-Comment");
hasPreCommentDiffs = addSpecificCommentDetails(CommentType.PRE, "Pre-Comment");
}
private void addPostCommentDetails() {
hasPostCommentDiffs = addSpecificCommentDetails(CodeUnit.POST_COMMENT, "Post-Comment");
hasPostCommentDiffs = addSpecificCommentDetails(CommentType.POST, "Post-Comment");
}
private void addPlateCommentDetails() {
hasPlateCommentDiffs = addSpecificCommentDetails(CodeUnit.PLATE_COMMENT, "Plate-Comment");
hasPlateCommentDiffs = addSpecificCommentDetails(CommentType.PLATE, "Plate-Comment");
}
/**
@ -1455,7 +1455,7 @@ public class ProgramDiffDetails {
private void addRepeatableCommentDetails() {
hasRepeatableCommentDiffs =
addSpecificCommentDetails(CodeUnit.REPEATABLE_COMMENT, "Repeatable-Comment");
addSpecificCommentDetails(CommentType.REPEATABLE, "Repeatable-Comment");
}
/**
@ -1490,7 +1490,7 @@ public class ProgramDiffDetails {
return retString;
}
private boolean addSpecificCommentDetails(int commentType, String commentName) {
private boolean addSpecificCommentDetails(CommentType commentType, String commentName) {
boolean hasCommentDiff = false;
try {
for (Address p1Address = minP1Address; p1Address

View file

@ -1546,30 +1546,30 @@ public class ProgramMerge {
}
String typeStr = "Unknown";
int cuCommentType;
CommentType cuCommentType;
switch (type) {
case ProgramMergeFilter.PLATE_COMMENTS:
typeStr = "Plate";
cuCommentType = CodeUnit.PLATE_COMMENT;
cuCommentType = CommentType.PLATE;
break;
case ProgramMergeFilter.PRE_COMMENTS:
typeStr = "Pre";
cuCommentType = CodeUnit.PRE_COMMENT;
cuCommentType = CommentType.PRE;
break;
case ProgramMergeFilter.EOL_COMMENTS:
typeStr = "EOL";
cuCommentType = CodeUnit.EOL_COMMENT;
cuCommentType = CommentType.EOL;
break;
case ProgramMergeFilter.REPEATABLE_COMMENTS:
typeStr = "Repeatable";
cuCommentType = CodeUnit.REPEATABLE_COMMENT;
cuCommentType = CommentType.REPEATABLE;
break;
case ProgramMergeFilter.POST_COMMENTS:
typeStr = "Post";
cuCommentType = CodeUnit.POST_COMMENT;
cuCommentType = CommentType.POST;
break;
default:
throw new AssertException("Unrecognized comment type: " + type);
throw new AssertException("Unsupported comment type: " + type);
}
monitor.setMessage("Applying " + typeStr + " comments...");
@ -1604,11 +1604,11 @@ public class ProgramMerge {
* <CODE>mergeComments</CODE> merges the comment of the indicated
* type in program1 with the comment in program2 at the specified address.
* @param commentType comment type to merge (from CodeUnit class).
* <br>EOL_COMMENT, PRE_COMMENT, POST_COMMENT, REPEATABLE_COMMENT, OR PLATE_COMMENT.
* <br>EOL, PRE, POST, REPEATABLE, OR PLATE.
* @param originAddress the address
* This address should be derived from the origin program.
*/
public void mergeComments(int commentType, Address originAddress) {
public void mergeComments(CommentType commentType, Address originAddress) {
Address resultAddress = originToResultTranslator.getAddress(originAddress);
String resultComment = resultListing.getComment(commentType, resultAddress);
String origComment = originListing.getComment(commentType, originAddress);
@ -1620,11 +1620,11 @@ public class ProgramMerge {
* <CODE>replaceComment</CODE> replaces the comment of the indicated
* type in program1 with the comment in program2 at the specified address.
* @param commentType comment type to replace (from CodeUnit class).
* <br>EOL_COMMENT, PRE_COMMENT, POST_COMMENT, REPEATABLE_COMMENT, OR PLATE_COMMENT.
* <br>EOL, PRE, POST, REPEATABLE, OR PLATE.
* @param originAddress the address
* This address should be derived from the origin program.
*/
public void replaceComment(int commentType, Address originAddress) {
public void replaceComment(CommentType commentType, Address originAddress) {
Address resultAddress = originToResultTranslator.getAddress(originAddress);
String origComment = originListing.getComment(commentType, originAddress);
resultListing.setComment(resultAddress, commentType, origComment);

View file

@ -234,7 +234,7 @@ public class ClassicSampleX86ProgramBuilder extends ProgramBuilder {
//
// Comments
//
createComment("0x0100415a", "Repeatable Comment", CodeUnit.REPEATABLE_COMMENT);
createComment("0x0100415a", "Repeatable Comment", CommentType.REPEATABLE);
//
// References

View file

@ -26,8 +26,8 @@ import ghidra.program.util.*;
* This table column displays the Label for either the program location or the address
* associated with a row in the table.
*/
public class EOLCommentTableColumn extends
ProgramLocationTableColumnExtensionPoint<ProgramLocation, String> {
public class EOLCommentTableColumn
extends ProgramLocationTableColumnExtensionPoint<ProgramLocation, String> {
@Override
public ProgramLocation getProgramLocation(ProgramLocation rowObject, Settings settings,
@ -35,7 +35,8 @@ public class EOLCommentTableColumn extends
String comment = getEOLComment(rowObject, program);
if (comment != null) {
return new EolCommentFieldLocation(program, rowObject.getAddress(), null, null, 0, 0, 0);
return new EolCommentFieldLocation(program, rowObject.getAddress(), null, null, 0, 0,
0);
}
return rowObject;
}

View file

@ -25,7 +25,7 @@ import ghidra.program.database.ProgramModifierListener;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSet;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Instruction;
import ghidra.program.model.mem.*;
import ghidra.program.model.symbol.SourceType;
@ -46,7 +46,7 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
super();
}
@Test
@Test
public void testAddLatestInstr() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -64,11 +64,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
executeMerge(ASK_USER);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, latestProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013e1")));
assertSameCodeUnits(resultProgram, latestProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013e1")));
}
@Test
@Test
public void testAddMyInstr() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -86,11 +86,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
executeMerge(ASK_USER);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, myProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013e1")));
assertSameCodeUnits(resultProgram, myProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013e1")));
}
@Test
@Test
public void testAddLatestData() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -108,11 +108,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
executeMerge(ASK_USER);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, latestProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013da")));
assertSameCodeUnits(resultProgram, latestProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013da")));
}
@Test
@Test
public void testAddMyData() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -130,11 +130,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
executeMerge(ASK_USER);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, myProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013dc")));
assertSameCodeUnits(resultProgram, myProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013dc")));
}
@Test
@Test
public void testAddLatestInstrMyDataPickLatest() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -153,11 +153,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013dc", KEEP_LATEST);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, latestProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013dc")));
assertSameCodeUnits(resultProgram, latestProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013dc")));
}
@Test
@Test
public void testAddLatestInstrMyDataPickMy() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -176,11 +176,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013e4", KEEP_MY);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, myProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013e4")));
assertSameCodeUnits(resultProgram, myProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013e4")));
}
@Test
@Test
public void testAddLatestInstrMyDataPickOrig() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -199,11 +199,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013e4", KEEP_ORIGINAL);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, originalProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013e4")));
assertSameCodeUnits(resultProgram, originalProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013e4")));
}
@Test
@Test
public void testAddLatestDataMyInstrPickLatest() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -222,11 +222,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013e4", KEEP_LATEST);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, latestProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013e4")));
assertSameCodeUnits(resultProgram, latestProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013e4")));
}
@Test
@Test
public void testAddLatestDataMyInstrPickMy() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -245,11 +245,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013dc", KEEP_MY);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, myProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013dc")));
assertSameCodeUnits(resultProgram, myProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013dc")));
}
@Test
@Test
public void testAddLatestDataMyInstrPickOrig() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -268,11 +268,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013e4", KEEP_ORIGINAL);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, originalProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013e4")));
assertSameCodeUnits(resultProgram, originalProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013e4")));
}
@Test
@Test
public void testAddLatestInstrMyInstrPickLatest() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -291,11 +291,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013e2", KEEP_LATEST);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, latestProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013e2")));
assertSameCodeUnits(resultProgram, latestProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013e2")));
}
@Test
@Test
public void testAddLatestInstrMyInstrPickMy() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -314,11 +314,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013e2", KEEP_MY);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, myProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013e2")));
assertSameCodeUnits(resultProgram, myProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013e2")));
}
@Test
@Test
public void testAddLatestInstrMyInstrPickOrig() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -337,11 +337,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013e2", KEEP_ORIGINAL);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, originalProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013e2")));
assertSameCodeUnits(resultProgram, originalProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013e2")));
}
@Test
@Test
public void testAddLatestDataMyDataPickLatest() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -360,11 +360,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013dc", KEEP_LATEST);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, latestProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013dc")));
assertSameCodeUnits(resultProgram, latestProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013dc")));
}
@Test
@Test
public void testAddLatestDataMyDataPickMy() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -383,11 +383,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013dc", KEEP_MY);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, myProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013dc")));
assertSameCodeUnits(resultProgram, myProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013dc")));
}
@Test
@Test
public void testAddLatestDataMyDataPickOrig() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -406,11 +406,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
chooseCodeUnit("0x10013d9", "0x10013dc", KEEP_ORIGINAL);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, originalProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013dc")));
assertSameCodeUnits(resultProgram, originalProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013dc")));
}
@Test
@Test
public void testSameInstrLatestMy() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@Override
@ -427,11 +427,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
executeMerge(ASK_USER);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, latestProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013e1")));
assertSameCodeUnits(resultProgram, latestProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013e1")));
}
@Test
@Test
public void testSameDataLatestMy() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -449,11 +449,11 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
executeMerge(ASK_USER);
waitForMergeCompletion();
assertSameCodeUnits(resultProgram, latestProgram, new AddressSet(addr("0x10013d9"),
addr("0x10013dc")));
assertSameCodeUnits(resultProgram, latestProgram,
new AddressSet(addr("0x10013d9"), addr("0x10013dc")));
}
@Test
@Test
public void testMergeCodeUnitsOriginal() throws Exception {
mtf.initialize("notepad", new ProgramModifierListener() {
@ -461,22 +461,26 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
public void modifyLatest(ProgramDB program) {
try {
// Clear Code Units from 1002312 to 1002320
program.getListing().clearCodeUnits(addr(program, "0x1002312"),
addr(program, "0x1002320"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x1002312"), addr(program, "0x1002320"),
false);
// Clear Code Units from 1002390 to 1002394
program.getListing().clearCodeUnits(addr(program, "0x1002390"),
addr(program, "0x1002394"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x1002390"), addr(program, "0x1002394"),
false);
// Put a label @ from 10023be-10023c2 to create a conflict with the code unit.
program.getSymbolTable().createLabel(addr(program, "0x10023be"), "LabelABC",
program.getSymbolTable()
.createLabel(addr(program, "0x10023be"), "LabelABC",
SourceType.USER_DEFINED);
// Put an Ascii at 10080d0
program.getListing().createData(addr(program, "0x10080d0"), new CharDataType());
// Put a Float at 10080db
program.getListing().createData(addr(program, "0x10080db"), new FloatDataType());
program.getListing()
.createData(addr(program, "0x10080db"), new FloatDataType());
Memory mem = program.getMemory();
MemoryBlock block = mem.getBlock(addr(program, "0x1001000"));
@ -503,17 +507,21 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
public void modifyPrivate(ProgramDB program) {
try {
// Clear Code Units from 100231d to 1002328
program.getListing().clearCodeUnits(addr(program, "0x100231d"),
addr(program, "0x1002328"), false);
assertTrue(!(program.getListing().getCodeUnitAt(addr(program, "0x1002328")) instanceof Instruction));
program.getListing()
.clearCodeUnits(addr(program, "0x100231d"), addr(program, "0x1002328"),
false);
assertTrue(!(program.getListing()
.getCodeUnitAt(addr(program, "0x1002328")) instanceof Instruction));
// Put a comment @ 1002390-1002394 to create a conflict with the code unit.
program.getListing().getCodeUnitAt(addr(program, "0x1002390")).setComment(
CodeUnit.EOL_COMMENT, "EOL comment");
program.getListing()
.getCodeUnitAt(addr(program, "0x1002390"))
.setComment(CommentType.EOL, "EOL comment");
// Clear Code Units from 10023be to 10023c2
program.getListing().clearCodeUnits(addr(program, "0x10023be"),
addr(program, "0x10023c2"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x10023be"), addr(program, "0x10023c2"),
false);
// Put a structure at 10080d0 to 10080d3
StructureDataType struct = new StructureDataType("Item", 4);
@ -524,8 +532,9 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
program.getListing().createData(addr(program, "0x10080e2"), new WordDataType());
// Clear Code Units from 100652a to 100652a
program.getListing().clearCodeUnits(addr(program, "0x100652a"),
addr(program, "0x100652a"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x100652a"), addr(program, "0x100652a"),
false);
}
catch (CodeUnitInsertionException e) {
e.printStackTrace();
@ -556,7 +565,7 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
assertSameCodeUnits(resultProgram, latestProgram, latestAddrs);
}
@Test
@Test
public void testMergeCodeUnitsLatest() throws Exception {
mtf.initialize("notepad", new ProgramModifierListener() {
@ -564,22 +573,26 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
public void modifyLatest(ProgramDB program) {
try {
// Clear Code Units from 1002312 to 1002320
program.getListing().clearCodeUnits(addr(program, "0x1002312"),
addr(program, "0x1002320"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x1002312"), addr(program, "0x1002320"),
false);
// Clear Code Units from 1002390 to 1002394
program.getListing().clearCodeUnits(addr(program, "0x1002390"),
addr(program, "0x1002394"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x1002390"), addr(program, "0x1002394"),
false);
// Put a label @ from 10023be-10023c2 to create a conflict with the code unit.
program.getSymbolTable().createLabel(addr(program, "0x10023be"), "LabelABC",
program.getSymbolTable()
.createLabel(addr(program, "0x10023be"), "LabelABC",
SourceType.USER_DEFINED);
// Put an Ascii at 10080d0
program.getListing().createData(addr(program, "0x10080d0"), new CharDataType());
// Put a Float at 10080db
program.getListing().createData(addr(program, "0x10080db"), new FloatDataType());
program.getListing()
.createData(addr(program, "0x10080db"), new FloatDataType());
Memory mem = program.getMemory();
MemoryBlock block = mem.getBlock(addr(program, "0x1001000"));
@ -606,17 +619,21 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
public void modifyPrivate(ProgramDB program) {
try {
// Clear Code Units from 100231d to 1002328
program.getListing().clearCodeUnits(addr(program, "0x100231d"),
addr(program, "0x1002328"), false);
assertTrue(!(program.getListing().getCodeUnitAt(addr(program, "0x1002328")) instanceof Instruction));
program.getListing()
.clearCodeUnits(addr(program, "0x100231d"), addr(program, "0x1002328"),
false);
assertTrue(!(program.getListing()
.getCodeUnitAt(addr(program, "0x1002328")) instanceof Instruction));
// Put a comment @ 1002390-1002394 to create a conflict with the code unit.
program.getListing().getCodeUnitAt(addr(program, "0x1002390")).setComment(
CodeUnit.EOL_COMMENT, "EOL comment");
program.getListing()
.getCodeUnitAt(addr(program, "0x1002390"))
.setComment(CommentType.EOL, "EOL comment");
// Clear Code Units from 10023be to 10023c2
program.getListing().clearCodeUnits(addr(program, "0x10023be"),
addr(program, "0x10023c2"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x10023be"), addr(program, "0x10023c2"),
false);
// Put a structure at 10080d0 to 10080d3
StructureDataType struct = new StructureDataType("Item", 4);
@ -627,8 +644,9 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
program.getListing().createData(addr(program, "0x10080e2"), new WordDataType());
// Clear Code Units from 100652a to 100652a
program.getListing().clearCodeUnits(addr(program, "0x100652a"),
addr(program, "0x100652a"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x100652a"), addr(program, "0x100652a"),
false);
}
catch (CodeUnitInsertionException e) {
@ -654,7 +672,7 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
}
@Test
@Test
public void testMergeCodeUnitsMine() throws Exception {
mtf.initialize("notepad", new ProgramModifierListener() {
@ -662,22 +680,26 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
public void modifyLatest(ProgramDB program) {
try {
// Clear Code Units from 1002312 to 1002320
program.getListing().clearCodeUnits(addr(program, "0x1002312"),
addr(program, "0x1002320"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x1002312"), addr(program, "0x1002320"),
false);
// Clear Code Units from 1002390 to 1002394
program.getListing().clearCodeUnits(addr(program, "0x1002390"),
addr(program, "0x1002394"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x1002390"), addr(program, "0x1002394"),
false);
// Put a label @ from 10023be-10023c2 to create a conflict with the code unit.
program.getSymbolTable().createLabel(addr(program, "0x10023be"), "LabelABC",
program.getSymbolTable()
.createLabel(addr(program, "0x10023be"), "LabelABC",
SourceType.USER_DEFINED);
// Put an Ascii at 10080d0
program.getListing().createData(addr(program, "0x10080d0"), new CharDataType());
// Put a Float at 10080db
program.getListing().createData(addr(program, "0x10080db"), new FloatDataType());
program.getListing()
.createData(addr(program, "0x10080db"), new FloatDataType());
Memory mem = program.getMemory();
MemoryBlock block = mem.getBlock(addr(program, "0x1001000"));
@ -704,17 +726,21 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
public void modifyPrivate(ProgramDB program) {
try {
// Clear Code Units from 100231d to 1002328
program.getListing().clearCodeUnits(addr(program, "0x100231d"),
addr(program, "0x1002328"), false);
assertTrue(!(program.getListing().getCodeUnitAt(addr(program, "0x1002328")) instanceof Instruction));
program.getListing()
.clearCodeUnits(addr(program, "0x100231d"), addr(program, "0x1002328"),
false);
assertTrue(!(program.getListing()
.getCodeUnitAt(addr(program, "0x1002328")) instanceof Instruction));
// Put a comment @ 1002390-1002394 to create a conflict with the code unit.
program.getListing().getCodeUnitAt(addr(program, "0x1002390")).setComment(
CodeUnit.EOL_COMMENT, "EOL comment");
program.getListing()
.getCodeUnitAt(addr(program, "0x1002390"))
.setComment(CommentType.EOL, "EOL comment");
// Clear Code Units from 10023be to 10023c2
program.getListing().clearCodeUnits(addr(program, "0x10023be"),
addr(program, "0x10023c2"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x10023be"), addr(program, "0x10023c2"),
false);
// Put a structure at 10080d0 to 10080d3
StructureDataType struct = new StructureDataType("Item", 4);
@ -725,8 +751,9 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
program.getListing().createData(addr(program, "0x10080e2"), new WordDataType());
// Clear Code Units from 100652a to 100652a
program.getListing().clearCodeUnits(addr(program, "0x100652a"),
addr(program, "0x100652a"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x100652a"), addr(program, "0x100652a"),
false);
}
catch (CodeUnitInsertionException e) {
e.printStackTrace();
@ -755,7 +782,7 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
assertSameCodeUnits(resultProgram, latestProgram, latestAddrs);
}
@Test
@Test
public void testMergeCodeUnitsUseForAllPickLatest() throws Exception {
setupUseForAll();
@ -783,22 +810,26 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
public void modifyLatest(ProgramDB program) {
try {
// Clear Code Units from 1002312 to 1002320
program.getListing().clearCodeUnits(addr(program, "0x1002312"),
addr(program, "0x1002320"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x1002312"), addr(program, "0x1002320"),
false);
// Clear Code Units from 1002390 to 1002394
program.getListing().clearCodeUnits(addr(program, "0x1002390"),
addr(program, "0x1002394"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x1002390"), addr(program, "0x1002394"),
false);
// Put a label @ from 10023be-10023c2 to create a conflict with the code unit.
program.getSymbolTable().createLabel(addr(program, "0x10023be"), "LabelABC",
program.getSymbolTable()
.createLabel(addr(program, "0x10023be"), "LabelABC",
SourceType.USER_DEFINED);
// Put an Ascii at 10080d0
program.getListing().createData(addr(program, "0x10080d0"), new CharDataType());
// Put a Float at 10080db
program.getListing().createData(addr(program, "0x10080db"), new FloatDataType());
program.getListing()
.createData(addr(program, "0x10080db"), new FloatDataType());
Memory mem = program.getMemory();
MemoryBlock block = mem.getBlock(addr(program, "0x1001000"));
@ -825,17 +856,21 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
public void modifyPrivate(ProgramDB program) {
try {
// Clear Code Units from 100231d to 1002328
program.getListing().clearCodeUnits(addr(program, "0x100231d"),
addr(program, "0x1002328"), false);
assertTrue(!(program.getListing().getCodeUnitAt(addr(program, "0x1002328")) instanceof Instruction));
program.getListing()
.clearCodeUnits(addr(program, "0x100231d"), addr(program, "0x1002328"),
false);
assertTrue(!(program.getListing()
.getCodeUnitAt(addr(program, "0x1002328")) instanceof Instruction));
// Put a comment @ 1002390-1002394 to create a conflict with the code unit.
program.getListing().getCodeUnitAt(addr(program, "0x1002390")).setComment(
CodeUnit.EOL_COMMENT, "EOL comment");
program.getListing()
.getCodeUnitAt(addr(program, "0x1002390"))
.setComment(CommentType.EOL, "EOL comment");
// Clear Code Units from 10023be to 10023c2
program.getListing().clearCodeUnits(addr(program, "0x10023be"),
addr(program, "0x10023c2"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x10023be"), addr(program, "0x10023c2"),
false);
// Put a structure at 10080d0 to 10080d3
StructureDataType struct = new StructureDataType("Item", 4);
@ -846,8 +881,9 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
program.getListing().createData(addr(program, "0x10080e2"), new WordDataType());
// Clear Code Units from 100652a to 100652a
program.getListing().clearCodeUnits(addr(program, "0x100652a"),
addr(program, "0x100652a"), false);
program.getListing()
.clearCodeUnits(addr(program, "0x100652a"), addr(program, "0x100652a"),
false);
}
catch (CodeUnitInsertionException e) {
e.printStackTrace();
@ -856,7 +892,7 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
});
}
@Test
@Test
public void testMergeCodeUnitsUseForAllPickMine() throws Exception {
setupUseForAll();

View file

@ -35,7 +35,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
super();
}
@Test
@Test
public void testMergeCommentsLatest() throws Exception {
mtf.initialize("notepad", new ProgramModifierListener() {
@ -127,7 +127,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals("Latest Repeatable Comment", cu.getComment(CommentType.REPEATABLE));
}
@Test
@Test
public void testMergeCommentsMy() throws Exception {
mtf.initialize("notepad", new ProgramModifierListener() {
@ -220,7 +220,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals("My Repeatable Comment", cu.getComment(CommentType.REPEATABLE));
}
@Test
@Test
public void testMergeCommentsBoth() throws Exception {
mtf.initialize("notepad", new ProgramModifierListener() {
@ -296,8 +296,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
"Plate Comment");
// Repeatable Comment @ 100284a
assertEquals(
listing.getCodeUnitAt(addr("0x100284a")).getComment(CommentType.REPEATABLE),
assertEquals(listing.getCodeUnitAt(addr("0x100284a")).getComment(CommentType.REPEATABLE),
"Repeatable Comment");
// Latest has comment
@ -318,7 +317,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
cu.getComment(CommentType.REPEATABLE));
}
@Test
@Test
public void testMergeCommentsAskUser() throws Exception {
mtf.initialize("notepad", new ProgramModifierListener() {
@ -400,8 +399,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
"Plate Comment");
// Repeatable Comment @ 100284a
assertEquals(
listing.getCodeUnitAt(addr("0x100284a")).getComment(CommentType.REPEATABLE),
assertEquals(listing.getCodeUnitAt(addr("0x100284a")).getComment(CommentType.REPEATABLE),
"Repeatable Comment");
// Latest has comment
@ -418,7 +416,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals("My Post Comment", cu.getComment(CommentType.POST));
}
@Test
@Test
public void testDeleteMy() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -453,7 +451,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertNull(cu.getComment(CommentType.POST));
}
@Test
@Test
public void testDeleteLatest() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -488,7 +486,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertNull(cu.getComment(CommentType.POST));
}
@Test
@Test
public void testDeleteBoth() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -530,7 +528,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertNull(cu.getComment(CommentType.POST));
}
@Test
@Test
public void testChangeLatestDeleteMyPickLatest() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -577,7 +575,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals("Latest Post Comment", cu.getComment(CommentType.POST));
}
@Test
@Test
public void testChangeLatestDeleteMyPickMy() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -624,7 +622,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertNull(cu.getComment(CommentType.POST));
}
@Test
@Test
public void testChangeMyDeleteLatestPickLatest() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -671,7 +669,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertNull(cu.getComment(CommentType.POST));
}
@Test
@Test
public void testChangeMyDeleteLatestPickMy() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -718,7 +716,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals("My Post Comment", cu.getComment(CommentType.POST));
}
@Test
@Test
public void testAddUnInitNoConflict() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -784,7 +782,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals("My Post Comment", cu.getComment(CommentType.POST));
}
@Test
@Test
public void testAddUnInitWithConflict() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -874,8 +872,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals("My Repeatable Comment", cu.getComment(CommentType.REPEATABLE));
assertEquals("My Post Comment", cu.getComment(CommentType.POST));
cu = listing.getCodeUnitAt(addr("0x1008608"));
assertEquals("Latest Plate Comment\nMy Plate Comment",
cu.getComment(CommentType.PLATE));
assertEquals("Latest Plate Comment\nMy Plate Comment", cu.getComment(CommentType.PLATE));
assertEquals("Latest Pre Comment\nMy Pre Comment", cu.getComment(CommentType.PRE));
assertEquals("Latest EOL Comment\nMy EOL Comment", cu.getComment(CommentType.EOL));
assertEquals("Latest Repeatable Comment\nMy Repeatable Comment",
@ -883,7 +880,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals("Latest Post Comment\nMy Post Comment", cu.getComment(CommentType.POST));
}
@Test
@Test
public void testAddCommentInsideCodeUnit() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -930,8 +927,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals("Pre", listing.getComment(CommentType.PRE, addr("0x10065e3")));
assertEquals("Post", listing.getComment(CommentType.POST, addr("0x10065e3")));
assertEquals("Plate", listing.getComment(CommentType.PLATE, addr("0x10065e3")));
assertEquals("Repeatable",
listing.getComment(CommentType.REPEATABLE, addr("0x10065e3")));
assertEquals("Repeatable", listing.getComment(CommentType.REPEATABLE, addr("0x10065e3")));
cu = listing.getCodeUnitContaining(addr("0x10065e9"));
assertEquals(addr("0x10065e8"), cu.getMinAddress());
@ -941,11 +937,10 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals("Pre2", listing.getComment(CommentType.PRE, addr("0x10065e9")));
assertEquals("Post2", listing.getComment(CommentType.POST, addr("0x10065e9")));
assertEquals("Plate2", listing.getComment(CommentType.PLATE, addr("0x10065e9")));
assertEquals("Repeatable2",
listing.getComment(CommentType.REPEATABLE, addr("0x10065e9")));
assertEquals("Repeatable2", listing.getComment(CommentType.REPEATABLE, addr("0x10065e9")));
}
@Test
@Test
public void testChangeLatestCommentInsideMyCodeUnit() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -965,8 +960,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
@Override
public void modifyPrivate(ProgramDB program) {
disassemble(program,
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")),
false);
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")), false);
}
});
@ -982,23 +976,20 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertTrue(cu instanceof Instruction);
assertEquals("New EOL Comment", listing.getComment(CommentType.EOL, addr("0x1002040")));
assertEquals("New Pre Comment", listing.getComment(CommentType.PRE, addr("0x1002040")));
assertEquals("New Post Comment",
listing.getComment(CommentType.POST, addr("0x1002040")));
assertEquals("New Plate Comment",
listing.getComment(CommentType.PLATE, addr("0x1002040")));
assertEquals("New Post Comment", listing.getComment(CommentType.POST, addr("0x1002040")));
assertEquals("New Plate Comment", listing.getComment(CommentType.PLATE, addr("0x1002040")));
assertEquals("New Repeatable Comment",
listing.getComment(CommentType.REPEATABLE, addr("0x1002040")));
}
@Test
@Test
public void testChangeMyCommentInsideLatestCodeUnit() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@Override
public void modifyLatest(ProgramDB program) {
disassemble(program,
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")),
false);
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")), false);
}
@Override
@ -1027,15 +1018,13 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertTrue(cu instanceof Instruction);
assertEquals("New EOL Comment", listing.getComment(CommentType.EOL, addr("0x1002040")));
assertEquals("New Pre Comment", listing.getComment(CommentType.PRE, addr("0x1002040")));
assertEquals("New Post Comment",
listing.getComment(CommentType.POST, addr("0x1002040")));
assertEquals("New Plate Comment",
listing.getComment(CommentType.PLATE, addr("0x1002040")));
assertEquals("New Post Comment", listing.getComment(CommentType.POST, addr("0x1002040")));
assertEquals("New Plate Comment", listing.getComment(CommentType.PLATE, addr("0x1002040")));
assertEquals("New Repeatable Comment",
listing.getComment(CommentType.REPEATABLE, addr("0x1002040")));
}
@Test
@Test
public void testRemoveCommentInsideMyCodeUnit() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -1050,8 +1039,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
Listing listing = program.getListing();
listing.setComment(addr(program, "0x1002040"), CommentType.PRE, null);
disassemble(program,
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")),
false);
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")), false);
}
});
@ -1073,7 +1061,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
listing.getComment(CommentType.REPEATABLE, addr("0x1002040")));
}
@Test
@Test
public void testRemoveCommentInsideLatestCodeUnit() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -1082,8 +1070,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
Listing listing = program.getListing();
listing.setComment(addr(program, "0x1002040"), CommentType.POST, null);
disassemble(program,
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")),
false);
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")), false);
}
@Override
@ -1111,7 +1098,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
listing.getComment(CommentType.REPEATABLE, addr("0x1002040")));
}
@Test
@Test
public void testChangeCommentInsideMyCodeUnit() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -1141,15 +1128,15 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
listing.setComment(addr(program, "0x1002040"), CommentType.REPEATABLE,
"New Repeatable Comment");
disassemble(program,
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")),
false);
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")), false);
}
});
executeMerge(ASK_USER);
chooseVerticalCheckBoxes(new String[] { LATEST_CHECK_BOX_NAME }); // Pre
chooseVerticalCheckBoxes(new String[] { CHECKED_OUT_CHECK_BOX_NAME }); // EOL
chooseVerticalCheckBoxes(new String[] { LATEST_CHECK_BOX_NAME, CHECKED_OUT_CHECK_BOX_NAME }); // Post
chooseVerticalCheckBoxes(
new String[] { LATEST_CHECK_BOX_NAME, CHECKED_OUT_CHECK_BOX_NAME }); // Post
waitForMergeCompletion();
Listing listing = resultProgram.getListing();
@ -1160,17 +1147,15 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
assertEquals(2, cu.getLength());
assertTrue(cu instanceof Instruction);
assertEquals("My EOL Comment", listing.getComment(CommentType.EOL, addr("0x1002040")));
assertEquals("Latest Pre Comment",
listing.getComment(CommentType.PRE, addr("0x1002040")));
assertEquals("Latest Pre Comment", listing.getComment(CommentType.PRE, addr("0x1002040")));
assertEquals("Latest Post Comment\nMy Post Comment",
listing.getComment(CommentType.POST, addr("0x1002040")));
assertEquals("New Plate Comment",
listing.getComment(CommentType.PLATE, addr("0x1002040")));
assertEquals("New Plate Comment", listing.getComment(CommentType.PLATE, addr("0x1002040")));
assertEquals("New Repeatable Comment",
listing.getComment(CommentType.REPEATABLE, addr("0x1002040")));
}
@Test
@Test
public void testChangeCommentInsideLatestCodeUnit() throws Exception {
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
@ -1178,8 +1163,7 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
public void modifyLatest(ProgramDB program) {
Listing listing = program.getListing();
disassemble(program,
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")),
false);
new AddressSet(addr(program, "0x100203e"), addr(program, "0x1002043")), false);
listing.setComment(addr(program, "0x1002040"), CommentType.EOL, "New EOL Comment");
listing.setComment(addr(program, "0x1002040"), CommentType.PRE, "New Pre Comment");
listing.setComment(addr(program, "0x1002040"), CommentType.POST,
@ -1206,7 +1190,8 @@ public class CommentMergeManager2Test extends AbstractListingMergeManagerTest {
executeMerge(ASK_USER);
chooseVerticalCheckBoxes(new String[] { LATEST_CHECK_BOX_NAME }); // Plate
chooseVerticalCheckBoxes(new String[] { CHECKED_OUT_CHECK_BOX_NAME }); // Repeatable
chooseVerticalCheckBoxes(new String[] { LATEST_CHECK_BOX_NAME, CHECKED_OUT_CHECK_BOX_NAME }); // Post
chooseVerticalCheckBoxes(
new String[] { LATEST_CHECK_BOX_NAME, CHECKED_OUT_CHECK_BOX_NAME }); // Post
waitForMergeCompletion();
Listing listing = resultProgram.getListing();

View file

@ -77,13 +77,13 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
builder.createLabel("0x31b", "RSTOR()");
builder.addBytesFallthrough("0x0326");
builder.createComment("0x0326", "Hey There", CodeUnit.EOL_COMMENT);
builder.createComment("0x0182", "SAVE register 'I'", CodeUnit.EOL_COMMENT);
builder.createComment("0x0334", "Set the SP to RAM:ESAV", CodeUnit.EOL_COMMENT);
builder.createComment("0x0335", "RESTORE register 'DE'", CodeUnit.EOL_COMMENT);
builder.createComment("0x0336", "RESTORE register 'BC'", CodeUnit.EOL_COMMENT);
builder.createComment("0x0337", "RESTORE register 'A' and FLAGS", CodeUnit.EOL_COMMENT);
builder.createComment("0x0338", "RESTORE register 'SP'", CodeUnit.EOL_COMMENT);
builder.createComment("0x0326", "Hey There", CommentType.EOL);
builder.createComment("0x0182", "SAVE register 'I'", CommentType.EOL);
builder.createComment("0x0334", "Set the SP to RAM:ESAV", CommentType.EOL);
builder.createComment("0x0335", "RESTORE register 'DE'", CommentType.EOL);
builder.createComment("0x0336", "RESTORE register 'BC'", CommentType.EOL);
builder.createComment("0x0337", "RESTORE register 'A' and FLAGS", CommentType.EOL);
builder.createComment("0x0338", "RESTORE register 'SP'", CommentType.EOL);
builder.createMemoryReference("0x1000", "0x331", RefType.UNCONDITIONAL_JUMP,
SourceType.DEFAULT);
@ -197,8 +197,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
int transactionID = programOne.startTransaction("test");
programOne.getSymbolTable()
.createLabel(addr(programOne, 0x032a), "MyLabel",
SourceType.USER_DEFINED);
.createLabel(addr(programOne, 0x032a), "MyLabel", SourceType.USER_DEFINED);
programOne.endTransaction(transactionID, true);
goTo(toolTwo, 0x0326);
@ -389,8 +388,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
// in Browser(1) change default label at 331 to JUNK
int transactionID = programOne.startTransaction("test");
programOne.getSymbolTable()
.createLabel(addr(programOne, 0x0331), "JUNK",
SourceType.USER_DEFINED);
.createLabel(addr(programOne, 0x0331), "JUNK", SourceType.USER_DEFINED);
programOne.endTransaction(transactionID, true);
//
// in Browser(1) go to 331
@ -431,8 +429,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
// in program 2, create a second label, JUNK2, at 0331
int transactionID = programOne.startTransaction("test");
programOne.getSymbolTable()
.createLabel(addr(programOne, 0x331), "JUNK2",
SourceType.USER_DEFINED);
.createLabel(addr(programOne, 0x331), "JUNK2", SourceType.USER_DEFINED);
programOne.endTransaction(transactionID, true);
// in Browser(2) select 331 through 334, contains "RSR10"
@ -480,8 +477,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
public void testPasteWhereUserLabelExists() throws Exception {
int transactionID = programOne.startTransaction("test");
programOne.getSymbolTable()
.createLabel(addr(programOne, 0x331), "JUNK2",
SourceType.USER_DEFINED);
.createLabel(addr(programOne, 0x331), "JUNK2", SourceType.USER_DEFINED);
programOne.endTransaction(transactionID, true);
// in Browser(2) select 331 through 334, contains "RSR10"
@ -593,16 +589,14 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
cb.goToField(addr(programOne, 0x0331), LabelFieldFactory.FIELD_NAME, 0, 0);
f = (ListingTextField) cb.getCurrentField();
assertEquals(programOne.getSymbolTable()
.getSymbol("LAB_00000331", addr(programOne, 0x0331),
null)
.getSymbol("LAB_00000331", addr(programOne, 0x0331), null)
.getName(),
f.getText());
cb.goToField(addr(programOne, 0x031b), LabelFieldFactory.FIELD_NAME, 0, 0);
f = (ListingTextField) cb.getCurrentField();
assertEquals(programOne.getSymbolTable()
.getSymbol("LAB_0000031b", addr(programOne, 0x031b),
null)
.getSymbol("LAB_0000031b", addr(programOne, 0x031b), null)
.getName(),
f.getText());
@ -629,8 +623,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
int transactionID = programOne.startTransaction("test");
String name = SymbolUtilities.getDefaultFunctionName(min);
programOne.getListing()
.createFunction(name, min, new AddressSet(min, max),
SourceType.USER_DEFINED);
.createFunction(name, min, new AddressSet(min, max), SourceType.USER_DEFINED);
programOne.endTransaction(transactionID, true);
programOne.flushEvents();
waitForSwing();
@ -722,8 +715,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
private void copyToolTwoLabels() {
ClipboardPlugin plugin = getPlugin(toolTwo, ClipboardPlugin.class);
ClipboardContentProviderService service =
getClipboardService(plugin);
ClipboardContentProviderService service = getClipboardService(plugin);
DockingAction action = getLocalAction(service, "Copy Special", plugin);
assertNotNull(action);
assertEnabled(action, cb2.getProvider());
@ -826,8 +818,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
waitForSwing();
}
private ClipboardContentProviderService getClipboardService(
ClipboardPlugin clipboardPlugin) {
private ClipboardContentProviderService getClipboardService(ClipboardPlugin clipboardPlugin) {
Map<?, ?> serviceMap = (Map<?, ?>) getInstanceField("serviceActionMap", clipboardPlugin);
Set<?> keySet = serviceMap.keySet();
for (Object name : keySet) {
@ -855,8 +846,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
}
private void assertEnabled(DockingActionIf action, ComponentProvider provider) {
boolean isEnabled =
runSwing(() -> {
boolean isEnabled = runSwing(() -> {
return action.isEnabledForContext(provider.getActionContext(null));
});
assertTrue("Action was not enabled when it should be", isEnabled);

View file

@ -87,7 +87,7 @@ public class CopyPasteFunctionInfoTest extends AbstractGhidraHeadedIntegrationTe
builder.createFunction("0x1006420");
builder.createEntryPoint("0x1006420", "entry");
builder.createFunction("0x1004700");
builder.createComment("0x1006420", "FUNCTION", CodeUnit.PLATE_COMMENT);
builder.createComment("0x1006420", "FUNCTION", CommentType.PLATE);
DataType dt = Undefined4DataType.dataType;
Parameter p = new ParameterImpl(null, dt, builder.getProgram());
builder.createEmptyFunction("BOB", "0x1004260", 1, dt, p, p, p, p, p, p, p, p, p, p, p, p,

View file

@ -621,8 +621,8 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
SourceType.USER_DEFINED, 0, false);
tool.execute(addRefCmd, program);
SetCommentCmd commentRefCmd = new SetCommentCmd(otherRefAddress,
CommentType.REPEATABLE, "Mem ref line1.\n" + "");
SetCommentCmd commentRefCmd =
new SetCommentCmd(otherRefAddress, CommentType.REPEATABLE, "Mem ref line1.\n" + "");
tool.execute(commentRefCmd, program);
// these values are all DEFAULT, by default; set them in case that changes in the future

View file

@ -61,9 +61,6 @@ import ghidra.util.task.TaskMonitor;
public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
private final static int[] TYPES = new int[] { CodeUnit.EOL_COMMENT, CodeUnit.PRE_COMMENT,
CodeUnit.POST_COMMENT, CodeUnit.PLATE_COMMENT, CodeUnit.REPEATABLE_COMMENT, };
private final static String PRE = "This is a PRE comment.";
private final static String POST = "This is a POST comment.";
private final static String EOL = "This is a EOL comment.";
@ -132,7 +129,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Data subData1 = data.getComponent(0);
assertEquals(new WordDataType().getName(), subData1.getDataType().getName());
String comment1 = "aaa bbb ccc ddd eee";
setAt(addr, CodeUnit.EOL_COMMENT, comment1, "OK");
setAt(addr, CommentType.EOL, comment1, "OK");
assertEquals(comment1, subData1.getComment(CommentType.EOL));
browser.goToField(addr(0x10080a2), "+", 0, 0);
@ -146,7 +143,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Data subData = data.getComponent(1).getComponent(0);
assertEquals(new FloatDataType().getName(), subData.getDataType().getName());
String comment = "This is a comment on a structure element.";
setAt(addr, CodeUnit.EOL_COMMENT, comment, "OK");
setAt(addr, CommentType.EOL, comment, "OK");
assertEquals(comment, subData.getComment(CommentType.EOL));
browser.goToField(addr(0x010080a2), EolCommentFieldFactory.FIELD_NAME, 0, 0);
@ -183,11 +180,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0x01006420);
for (int element : TYPES) {
for (CommentType type : CommentType.values()) {
tx(program, () -> program.getListing().setComment(addr, element, "Test" + element));
tx(program, () -> program.getListing().setComment(addr, type, "Test" + type));
sendProgramLocation(addr, element);
sendProgramLocation(addr, type);
performAction(editAction, browser.getProvider(), false);
waitForSwing();
@ -198,7 +195,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
JTabbedPane tab = findComponent(dialog.getComponent(), JTabbedPane.class);
assertNotNull(tab);
assertEquals(element, tab.getSelectedIndex());
assertEquals(type.ordinal(), tab.getSelectedIndex());
pressButtonByText(dialog.getComponent(), "Dismiss", false);
waitForSwing();
@ -238,7 +235,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
tool2.firePluginEvent(new OpenProgramPluginEvent("Test", program));
Address addr = addr(0x01006420);
sendProgramLocation(addr, CodeUnit.EOL_COMMENT);
sendProgramLocation(addr, CommentType.EOL);
String comment = "Drag and Drop is a direct manipulation gesture\n" +
"found in many Graphical User Interface\n" +
@ -246,7 +243,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
"between two entities logically associated with\n" +
"presentation elements in the GUI.\n";
setAt(addr, CodeUnit.EOL_COMMENT, comment, "OK");
setAt(addr, CommentType.EOL, comment, "OK");
setFieldWidth(browser, EolCommentFieldFactory.FIELD_NAME, 100);
@ -275,7 +272,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PRE_COMMENT, PRE, "OK");
setAt(addr, CommentType.PRE, PRE, "OK");
assertEquals(PRE, cu.getComment(CommentType.PRE));
undo(program);
assertNull(cu.getComment(CommentType.PRE));
@ -290,7 +287,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.POST_COMMENT, POST, "OK");
setAt(addr, CommentType.POST, POST, "OK");
assertEquals(POST, cu.getComment(CommentType.POST));
undo(program);
assertNull(cu.getComment(CommentType.POST));
@ -305,7 +302,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.EOL_COMMENT, EOL, "OK");
setAt(addr, CommentType.EOL, EOL, "OK");
assertEquals(EOL, cu.getComment(CommentType.EOL));
undo(program);
assertNull(cu.getComment(CommentType.EOL));
@ -321,7 +318,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
resetFormatOptions(browser);
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK");
setAt(addr, CommentType.PLATE, PLATE, "OK");
assertEquals(PLATE, cu.getComment(CommentType.PLATE));
undo(program);
assertNull(cu.getComment(CommentType.PLATE));
@ -337,7 +334,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.REPEATABLE_COMMENT, REPEAT, "OK");
setAt(addr, CommentType.REPEATABLE, REPEAT, "OK");
assertEquals(REPEAT, cu.getComment(CommentType.REPEATABLE));
undo(program);
assertNull(cu.getComment(CommentType.REPEATABLE));
@ -354,7 +351,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
String longComment = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8\n";
setAt(addr, CodeUnit.REPEATABLE_COMMENT, longComment, "OK");
setAt(addr, CommentType.REPEATABLE, longComment, "OK");
assertEquals(longComment, cu.getComment(CommentType.REPEATABLE));
// this fails when excepting
@ -367,11 +364,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PRE_COMMENT, PRE, "OK");
setAt(addr, CodeUnit.POST_COMMENT, POST, "OK");
setAt(addr, CodeUnit.EOL_COMMENT, EOL, "OK");
setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK");
setAt(addr, CodeUnit.REPEATABLE_COMMENT, REPEAT, "OK");
setAt(addr, CommentType.PRE, PRE, "OK");
setAt(addr, CommentType.POST, POST, "OK");
setAt(addr, CommentType.EOL, EOL, "OK");
setAt(addr, CommentType.PLATE, PLATE, "OK");
setAt(addr, CommentType.REPEATABLE, REPEAT, "OK");
assertEquals(PRE, cu.getComment(CommentType.PRE));
assertEquals(POST, cu.getComment(CommentType.POST));
@ -401,7 +398,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0x01006000);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.REPEATABLE_COMMENT, "Bla bla bla", "Apply");
setAt(addr, CommentType.REPEATABLE, "Bla bla bla", "Apply");
final CommentsDialog commentsDialog = waitForDialogComponent(CommentsDialog.class);
assertNotNull(commentsDialog);
pressButtonByText(commentsDialog.getComponent(), "Dismiss", false);
@ -415,8 +412,8 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0xf0001300);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PRE_COMMENT, PRE, "OK");
setAt(addr, CodeUnit.PRE_COMMENT, PRE_U, "OK");
setAt(addr, CommentType.PRE, PRE, "OK");
setAt(addr, CommentType.PRE, PRE_U, "OK");
undo(program);
assertEquals(PRE, cu.getComment(CommentType.PRE));
redo(program);
@ -428,7 +425,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0x01006000);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.POST_COMMENT, "Bla bla bla", "Dismiss");
setAt(addr, CommentType.POST, "Bla bla bla", "Dismiss");
CommentsDialog commentsDialog = waitForDialogComponent(CommentsDialog.class);
OptionDialog saveDialog = waitForDialogComponent(OptionDialog.class);
assertNotNull(saveDialog);
@ -448,7 +445,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0x01006000);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.POST_COMMENT, "Bla bla bla", "Dismiss");
setAt(addr, CommentType.POST, "Bla bla bla", "Dismiss");
CommentsDialog commentsDialog = waitForDialogComponent(CommentsDialog.class);
assertNotNull(commentsDialog);
OptionDialog saveDialog = waitForDialogComponent(OptionDialog.class);
@ -469,7 +466,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0x01006000);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.POST_COMMENT, "Bla bla bla", "Dismiss");
setAt(addr, CommentType.POST, "Bla bla bla", "Dismiss");
CommentsDialog commentsDialog = waitForDialogComponent(CommentsDialog.class);
assertNotNull(commentsDialog);
@ -493,9 +490,9 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0xf0000250);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK");
setAt(addr, CommentType.PLATE, PLATE, "OK");
assertEquals(PLATE, cu.getComment(CommentType.PLATE));
removeAt(addr, CodeUnit.PLATE_COMMENT);
removeAt(addr, CommentType.PLATE);
assertNull(cu.getComment(CommentType.PLATE));
undo(program);
assertEquals(PLATE, cu.getComment(CommentType.PLATE));
@ -508,11 +505,10 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
openX86ProgramInTool();
Address addr = addr(0x0100bbbb);
setAt(addr, CodeUnit.EOL_COMMENT, EOL, "OK");
setAt(addr, CodeUnit.EOL_COMMENT, EOL_U, "OK");
setAt(addr, CommentType.EOL, EOL, "OK");
setAt(addr, CommentType.EOL, EOL_U, "OK");
CommentHistory[] history =
program.getListing().getCommentHistory(addr, CodeUnit.EOL_COMMENT);
CommentHistory[] history = program.getListing().getCommentHistory(addr, CommentType.EOL);
assertEquals(2, history.length);
for (int i = 0; i < history.length; i++) {
@ -542,7 +538,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
String comment = buffer.toString();
Address addr = addr(0x01006000);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PRE_COMMENT, comment, "OK");
setAt(addr, CommentType.PRE, comment, "OK");
assertEquals(comment, cu.getComment(CommentType.PRE));
}
@ -555,7 +551,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
String comment = "This is a comment with address " + commentAddress + " in it.";
CommentsDialog dialog = editComment(addr(0x01006990));
JTextArea commentTextArea = getTextArea(dialog, CodeUnit.EOL_COMMENT);
JTextArea commentTextArea = getTextArea(dialog, CommentType.EOL);
runSwing(() -> {
commentTextArea.setText(comment);
@ -585,7 +581,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(srcAddr);
String comment = "This is a comment DAT_01008094 with a label in it.";
setAt(srcAddr, CodeUnit.PRE_COMMENT, comment, "OK");
setAt(srcAddr, CommentType.PRE, comment, "OK");
assertEquals(comment, cu.getComment(CommentType.PRE));
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 23);
@ -602,7 +598,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(srcAddr);
String comment = "This is a comment 01008094 with an address in it.";
setAt(srcAddr, CodeUnit.PRE_COMMENT, comment, "OK");
setAt(srcAddr, CommentType.PRE, comment, "OK");
assertEquals(comment, cu.getComment(CommentType.PRE));
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 23);
@ -622,7 +618,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address srcAddr = addr(0x01006990);
String comment = "This is a comment {@sym DAT_01008094} with an annotation in it.";
setAt(srcAddr, CodeUnit.PRE_COMMENT, comment, "OK");
setAt(srcAddr, CommentType.PRE, comment, "OK");
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 23);
click(browser, 2);
@ -638,7 +634,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address srcAddr = addr(0x01006990);
String comment = "This is a comment {@sym Deadpool::Bob} with an annotation in it.";
setAt(srcAddr, CodeUnit.PRE_COMMENT, comment, "OK");
setAt(srcAddr, CommentType.PRE, comment, "OK");
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 20);
click(browser, 2);
@ -654,7 +650,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address srcAddr = addr(0x01006990);
String comment = "This is a symbol {@program Test@Deadpool::Bob} annotation.";
setAt(srcAddr, CodeUnit.PRE_COMMENT, comment, "OK");
setAt(srcAddr, CommentType.PRE, comment, "OK");
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 23);
click(browser, 2);
@ -677,7 +673,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(srcAddr);
String comment = "This is a comment DAT_* with a wildcard in it.";
setAt(srcAddr, CodeUnit.PRE_COMMENT, comment, "OK");
setAt(srcAddr, CommentType.PRE, comment, "OK");
assertEquals(comment, cu.getComment(CommentType.PRE));
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 19);
@ -709,7 +705,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
AddressSpace extmemSpace = af.getAddressSpace("EXTMEM");
Address addr = extmemSpace.getAddress(0);
setAt(addr, CodeUnit.PLATE_COMMENT, "Around the world in 80 days.", "OK");
setAt(addr, CommentType.PLATE, "Around the world in 80 days.", "OK");
browser.goToField(addr, PlateFieldFactory.FIELD_NAME, 1, 22);
click(browser, 2);
@ -723,7 +719,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
String tabComment = "abcd\tdefg\n\t1\t2\t3\t4";
setAt(addr, CodeUnit.PLATE_COMMENT, tabComment, "OK");
setAt(addr, CommentType.PLATE, tabComment, "OK");
// space comment is exactly the same; i.e. make sure that no tab conversion happens
String spaceComment = "abcd\tdefg\n\t1\t2\t3\t4";
@ -790,12 +786,12 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
String illegal = "null\0 comment";
String legal = "null comment";
setAt(addr, CodeUnit.PRE_COMMENT, illegal, "OK");
setAt(addr, CommentType.PRE, illegal, "OK");
assertEquals(legal, cu.getComment(CommentType.PRE));
}
private void setAt(Address addr, int commentType, String comment, String nameOfButtonToClick)
throws Exception {
private void setAt(Address addr, CommentType commentType, String comment,
String nameOfButtonToClick) throws Exception {
CommentsDialog dialog = editComment(addr);
assertEquals("Set Comment(s) at Address " + addr.toString(), dialog.getTitle());
@ -817,7 +813,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
return waitForDialogComponent(CommentsDialog.class);
}
private JTextArea getTextArea(CommentsDialog dialog, int commentType) {
private JTextArea getTextArea(CommentsDialog dialog, CommentType commentType) {
runSwing(() -> dialog.setCommentType(commentType));
waitForSwing();
@ -829,7 +825,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
return textArea;
}
private void removeAt(Address addr, int commentType) throws Exception {
private void removeAt(Address addr, CommentType commentType) throws Exception {
sendProgramLocation(addr, commentType);
performAction(deleteAction, browser.getProvider(), false);
waitForSwing();
@ -839,11 +835,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
return program.getAddressFactory().getDefaultAddressSpace().getAddress(offset);
}
private ProgramLocation sendProgramLocation(Address addr, int type) {
private ProgramLocation sendProgramLocation(Address addr, CommentType type) {
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
String[] comment = cu.getCommentAsArray(type);
ProgramLocation loc = type == CodeUnit.EOL_COMMENT
ProgramLocation loc = type == CommentType.EOL
? new EolCommentFieldLocation(program, addr, null, comment, 0, 0, 0)
: new CommentFieldLocation(program, addr, null, comment, type, 0, 0);

View file

@ -29,7 +29,7 @@ import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.services.ProgramManager;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.test.*;
@ -79,11 +79,11 @@ public class CommentWindowPluginTest extends AbstractGhidraHeadedIntegrationTest
ClassicSampleX86ProgramBuilder builder = new ClassicSampleX86ProgramBuilder();
program = builder.getProgram();
builder.createComment("01006420", "test EOL comment", CodeUnit.EOL_COMMENT);
builder.createComment("01008004", "test Pre comment", CodeUnit.PRE_COMMENT);
builder.createComment("0100b2b", "test Post comment", CodeUnit.POST_COMMENT);
builder.createComment("010018a0", "test Plate comment", CodeUnit.PLATE_COMMENT);
builder.createComment("010018cf", "test Repeatable comment", CodeUnit.REPEATABLE_COMMENT);
builder.createComment("01006420", "test EOL comment", CommentType.EOL);
builder.createComment("01008004", "test Pre comment", CommentType.PRE);
builder.createComment("0100b2b", "test Post comment", CommentType.POST);
builder.createComment("010018a0", "test Plate comment", CommentType.PLATE);
builder.createComment("010018cf", "test Repeatable comment", CommentType.REPEATABLE);
ProgramManager pm = tool.getService(ProgramManager.class);
pm.openProgram(program.getDomainFile());
@ -144,7 +144,7 @@ public class CommentWindowPluginTest extends AbstractGhidraHeadedIntegrationTest
assertEquals(5, numComments);
addComment(addr("0x01001000"), CodeUnit.EOL_COMMENT, "Added EOL Comment");
addComment(addr("0x01001000"), CommentType.EOL, "Added EOL Comment");
assertRowCount(6);
@ -169,7 +169,7 @@ public class CommentWindowPluginTest extends AbstractGhidraHeadedIntegrationTest
assertEquals("test EOL comment", getTableComment(rowIndex));
// Then set the comment to a different value
setComment(addr("0x01006420"), CodeUnit.EOL_COMMENT, "Changed EOL Comment");
setComment(addr("0x01006420"), CommentType.EOL, "Changed EOL Comment");
// Test to see if the changed comment is in the table
assertEquals("Changed EOL Comment", getTableComment(rowIndex));
@ -193,7 +193,7 @@ public class CommentWindowPluginTest extends AbstractGhidraHeadedIntegrationTest
loadProgram("notepad");
}
private void addComment(Address addr, int commentType, String comment) {
private void addComment(Address addr, CommentType commentType, String comment) {
int id = program.startTransaction(testName.getMethodName());
try {
program.getListing().setComment(addr, commentType, comment);
@ -230,7 +230,7 @@ public class CommentWindowPluginTest extends AbstractGhidraHeadedIntegrationTest
return commentTable.getValueAt(rowIndex, CommentTableModel.COMMENT_COL).toString();
}
private void setComment(Address addr, int commentType, String comment) {
private void setComment(Address addr, CommentType commentType, String comment) {
int id = program.startTransaction(testName.getMethodName());
try {
program.getListing().setComment(addr, commentType, comment);

View file

@ -566,7 +566,7 @@ public class ClearTest extends AbstractGhidraHeadedIntegrationTest {
public void testClearComments() throws Exception {
assertTrue(cb.goToField(addr("0x10022cc"), "Bytes", 0, 4));
SetCommentCmd cmd =new SetCommentCmd(addr("0x10022cc"), CommentType.EOL, "my comment");
SetCommentCmd cmd = new SetCommentCmd(addr("0x10022cc"), CommentType.EOL, "my comment");
applyCmd(program, cmd);
performAction(clearWithOptionsAction, cb.getProvider(), false);

View file

@ -383,8 +383,8 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
String newName = "myNewLogin";
renameProgramFile(p, newName);
ArrayList<DomainObjectChangeRecord> changeRecs = new ArrayList<>();
changeRecs.add(
new DomainObjectChangeRecord(DomainObjectEvent.RENAMED, oldName, p.getName()));
changeRecs
.add(new DomainObjectChangeRecord(DomainObjectEvent.RENAMED, oldName, p.getName()));
DomainObjectChangedEvent ev = new DomainObjectChangedEvent(p, changeRecs);
runSwing(() -> env.getPlugin(MultiTabPlugin.class).domainObjectChanged(ev));

View file

@ -37,8 +37,7 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
private static final String FIND_DIALOG_TITLE = "Enter Search String";
private static final String REPLACE_DIALOG_TITLE = "Enter Replace String";
private static final int[] COMMENT_TYPES = { CodeUnit.EOL_COMMENT, CodeUnit.PRE_COMMENT,
CodeUnit.POST_COMMENT, CodeUnit.PLATE_COMMENT, CodeUnit.REPEATABLE_COMMENT };
private static final int SCRIPT_TIMEOUT = 100000;
private TestEnv env;
@ -65,19 +64,18 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
builder = new ToyProgramBuilder("ReplaceCommentTest", true, this);
builder.createMemory(".text", "0x1001000", 0x4000);
builder.createComment("0x01001000", "EOL Comment", CodeUnit.EOL_COMMENT);
builder.createComment("0x01001100", "Pre Comment", CodeUnit.PRE_COMMENT);
builder.createComment("0x01001200", "Post Comment", CodeUnit.POST_COMMENT);
builder.createComment("0x01001300", "Plate Comment", CodeUnit.PLATE_COMMENT);
builder.createComment("0x01001400", "Repeatable Comment", CodeUnit.REPEATABLE_COMMENT);
builder.createComment("0x01001500", "EOL Comment Repeated", CodeUnit.EOL_COMMENT);
builder.createComment("0x01001600", "EOL Comment Repeated", CodeUnit.EOL_COMMENT);
builder.createComment("0x01001700", "Generic Comment Repeated", CodeUnit.EOL_COMMENT);
builder.createComment("0x01001800", "Generic Comment Repeated", CodeUnit.PRE_COMMENT);
builder.createComment("0x01001900", "Generic Comment Repeated", CodeUnit.POST_COMMENT);
builder.createComment("0x01002000", "Generic Comment Repeated", CodeUnit.PLATE_COMMENT);
builder.createComment("0x01002100", "Generic Comment Repeated",
CodeUnit.REPEATABLE_COMMENT);
builder.createComment("0x01001000", "EOL Comment", CommentType.EOL);
builder.createComment("0x01001100", "Pre Comment", CommentType.PRE);
builder.createComment("0x01001200", "Post Comment", CommentType.POST);
builder.createComment("0x01001300", "Plate Comment", CommentType.PLATE);
builder.createComment("0x01001400", "Repeatable Comment", CommentType.REPEATABLE);
builder.createComment("0x01001500", "EOL Comment Repeated", CommentType.EOL);
builder.createComment("0x01001600", "EOL Comment Repeated", CommentType.EOL);
builder.createComment("0x01001700", "Generic Comment Repeated", CommentType.EOL);
builder.createComment("0x01001800", "Generic Comment Repeated", CommentType.PRE);
builder.createComment("0x01001900", "Generic Comment Repeated", CommentType.POST);
builder.createComment("0x01002000", "Generic Comment Repeated", CommentType.PLATE);
builder.createComment("0x01002100", "Generic Comment Repeated", CommentType.REPEATABLE);
return builder.getProgram();
}
@ -92,13 +90,13 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
ScriptTaskListener scriptID = env.runScript(script);
assertNotNull(scriptID);
assertCommentEquals(0x01001000, "EOL Comment", CodeUnit.EOL_COMMENT);
assertCommentEquals(0x01001000, "EOL Comment", CommentType.EOL);
respondToDialog("EOL Comment", FIND_DIALOG_TITLE);
respondToDialog("New Value", REPLACE_DIALOG_TITLE);
waitForScriptCompletion(scriptID, SCRIPT_TIMEOUT);
assertCommentEquals(0x01001000, "New Value", CodeUnit.EOL_COMMENT);
assertCommentEquals(0x01001000, "New Value", CommentType.EOL);
}
@Test
@ -106,13 +104,13 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
ScriptTaskListener scriptID = env.runScript(script);
assertNotNull(scriptID);
assertCommentEquals(0x01001100, "Pre Comment", CodeUnit.PRE_COMMENT);
assertCommentEquals(0x01001100, "Pre Comment", CommentType.PRE);
respondToDialog("Pre Comment", FIND_DIALOG_TITLE);
respondToDialog("New Value", REPLACE_DIALOG_TITLE);
waitForScriptCompletion(scriptID, SCRIPT_TIMEOUT);
assertCommentEquals(0x01001100, "New Value", CodeUnit.PRE_COMMENT);
assertCommentEquals(0x01001100, "New Value", CommentType.PRE);
}
@Test
@ -120,13 +118,13 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
ScriptTaskListener scriptID = env.runScript(script);
assertNotNull(scriptID);
assertCommentEquals(0x01001200, "Post Comment", CodeUnit.POST_COMMENT);
assertCommentEquals(0x01001200, "Post Comment", CommentType.POST);
respondToDialog("Post Comment", FIND_DIALOG_TITLE);
respondToDialog("New Value", REPLACE_DIALOG_TITLE);
waitForScriptCompletion(scriptID, SCRIPT_TIMEOUT);
assertCommentEquals(0x01001200, "New Value", CodeUnit.POST_COMMENT);
assertCommentEquals(0x01001200, "New Value", CommentType.POST);
}
@Test
@ -134,13 +132,13 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
ScriptTaskListener scriptID = env.runScript(script);
assertNotNull(scriptID);
assertCommentEquals(0x01001300, "Plate Comment", CodeUnit.PLATE_COMMENT);
assertCommentEquals(0x01001300, "Plate Comment", CommentType.PLATE);
respondToDialog("Plate Comment", FIND_DIALOG_TITLE);
respondToDialog("New Value", REPLACE_DIALOG_TITLE);
waitForScriptCompletion(scriptID, SCRIPT_TIMEOUT);
assertCommentEquals(0x01001300, "New Value", CodeUnit.PLATE_COMMENT);
assertCommentEquals(0x01001300, "New Value", CommentType.PLATE);
}
@Test
@ -148,13 +146,13 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
ScriptTaskListener scriptID = env.runScript(script);
assertNotNull(scriptID);
assertCommentEquals(0x01001400, "Repeatable Comment", CodeUnit.REPEATABLE_COMMENT);
assertCommentEquals(0x01001400, "Repeatable Comment", CommentType.REPEATABLE);
respondToDialog("Repeatable Comment", FIND_DIALOG_TITLE);
respondToDialog("New Value", REPLACE_DIALOG_TITLE);
waitForScriptCompletion(scriptID, SCRIPT_TIMEOUT);
assertCommentEquals(0x01001400, "New Value", CodeUnit.REPEATABLE_COMMENT);
assertCommentEquals(0x01001400, "New Value", CommentType.REPEATABLE);
}
@Test
@ -162,15 +160,15 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
ScriptTaskListener scriptID = env.runScript(script);
assertNotNull(scriptID);
assertCommentEquals(0x01001500, "EOL Comment Repeated", CodeUnit.EOL_COMMENT);
assertCommentEquals(0x01001600, "EOL Comment Repeated", CodeUnit.EOL_COMMENT);
assertCommentEquals(0x01001500, "EOL Comment Repeated", CommentType.EOL);
assertCommentEquals(0x01001600, "EOL Comment Repeated", CommentType.EOL);
respondToDialog("EOL Comment Repeated", FIND_DIALOG_TITLE);
respondToDialog("New Value", REPLACE_DIALOG_TITLE);
waitForScriptCompletion(scriptID, SCRIPT_TIMEOUT);
assertCommentEquals(0x01001500, "New Value", CodeUnit.EOL_COMMENT);
assertCommentEquals(0x01001600, "New Value", CodeUnit.EOL_COMMENT);
assertCommentEquals(0x01001500, "New Value", CommentType.EOL);
assertCommentEquals(0x01001600, "New Value", CommentType.EOL);
}
@Test
@ -178,21 +176,21 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
ScriptTaskListener scriptID = env.runScript(script);
assertNotNull(scriptID);
assertCommentEquals(0x01001700, "Generic Comment Repeated", CodeUnit.EOL_COMMENT);
assertCommentEquals(0x01001800, "Generic Comment Repeated", CodeUnit.PRE_COMMENT);
assertCommentEquals(0x01001900, "Generic Comment Repeated", CodeUnit.POST_COMMENT);
assertCommentEquals(0x01002000, "Generic Comment Repeated", CodeUnit.PLATE_COMMENT);
assertCommentEquals(0x01002100, "Generic Comment Repeated", CodeUnit.REPEATABLE_COMMENT);
assertCommentEquals(0x01001700, "Generic Comment Repeated", CommentType.EOL);
assertCommentEquals(0x01001800, "Generic Comment Repeated", CommentType.PRE);
assertCommentEquals(0x01001900, "Generic Comment Repeated", CommentType.POST);
assertCommentEquals(0x01002000, "Generic Comment Repeated", CommentType.PLATE);
assertCommentEquals(0x01002100, "Generic Comment Repeated", CommentType.REPEATABLE);
respondToDialog("Generic Comment Repeated", FIND_DIALOG_TITLE);
respondToDialog("New Value", REPLACE_DIALOG_TITLE);
waitForScriptCompletion(scriptID, SCRIPT_TIMEOUT);
assertCommentEquals(0x01001700, "New Value", CodeUnit.EOL_COMMENT);
assertCommentEquals(0x01001800, "New Value", CodeUnit.PRE_COMMENT);
assertCommentEquals(0x01001900, "New Value", CodeUnit.POST_COMMENT);
assertCommentEquals(0x01002000, "New Value", CodeUnit.PLATE_COMMENT);
assertCommentEquals(0x01002100, "New Value", CodeUnit.REPEATABLE_COMMENT);
assertCommentEquals(0x01001700, "New Value", CommentType.EOL);
assertCommentEquals(0x01001800, "New Value", CommentType.PRE);
assertCommentEquals(0x01001900, "New Value", CommentType.POST);
assertCommentEquals(0x01002000, "New Value", CommentType.PLATE);
assertCommentEquals(0x01002100, "New Value", CommentType.REPEATABLE);
}
@Test
@ -203,7 +201,7 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
respondToDialog("This Value Does Not Exist", FIND_DIALOG_TITLE);
respondToDialog("New Value", REPLACE_DIALOG_TITLE);
assertCommentDoesNotExists("New Value");
assertCommentDoesNotExist("New Value");
}
@Test
@ -211,21 +209,21 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
ScriptTaskListener scriptID = env.runScript(script);
assertNotNull(scriptID);
assertCommentEquals(0x01001000, "EOL Comment", CodeUnit.EOL_COMMENT);
assertCommentEquals(0x01001100, "Pre Comment", CodeUnit.PRE_COMMENT);
assertCommentEquals(0x01001200, "Post Comment", CodeUnit.POST_COMMENT);
assertCommentEquals(0x01001300, "Plate Comment", CodeUnit.PLATE_COMMENT);
assertCommentEquals(0x01001400, "Repeatable Comment", CodeUnit.REPEATABLE_COMMENT);
assertCommentEquals(0x01001000, "EOL Comment", CommentType.EOL);
assertCommentEquals(0x01001100, "Pre Comment", CommentType.PRE);
assertCommentEquals(0x01001200, "Post Comment", CommentType.POST);
assertCommentEquals(0x01001300, "Plate Comment", CommentType.PLATE);
assertCommentEquals(0x01001400, "Repeatable Comment", CommentType.REPEATABLE);
respondToDialog("Comment", FIND_DIALOG_TITLE);
respondToDialog("Test", REPLACE_DIALOG_TITLE);
waitForScriptCompletion(scriptID, SCRIPT_TIMEOUT);
assertCommentEquals(0x01001000, "EOL Test", CodeUnit.EOL_COMMENT);
assertCommentEquals(0x01001100, "Pre Test", CodeUnit.PRE_COMMENT);
assertCommentEquals(0x01001200, "Post Test", CodeUnit.POST_COMMENT);
assertCommentEquals(0x01001300, "Plate Test", CodeUnit.PLATE_COMMENT);
assertCommentEquals(0x01001400, "Repeatable Test", CodeUnit.REPEATABLE_COMMENT);
assertCommentEquals(0x01001000, "EOL Test", CommentType.EOL);
assertCommentEquals(0x01001100, "Pre Test", CommentType.PRE);
assertCommentEquals(0x01001200, "Post Test", CommentType.POST);
assertCommentEquals(0x01001300, "Plate Test", CommentType.PLATE);
assertCommentEquals(0x01001400, "Repeatable Test", CommentType.REPEATABLE);
}
private void respondToDialog(String response, String titleValue) {
@ -235,21 +233,22 @@ public class FindAndReplaceCommentScriptTest extends AbstractGhidraHeadedIntegra
pressButtonByText(askStringDialog, "OK");
}
private void assertCommentEquals(int commentAddress, String commentValue, int commentType) {
private void assertCommentEquals(int commentAddress, String commentValue,
CommentType commentType) {
Address address = program.getMinAddress().getNewAddress(commentAddress);
String existingComment = listing.getComment(commentType, address);
assertEquals(commentValue, existingComment);
}
private void assertCommentDoesNotExists(String comment) {
private void assertCommentDoesNotExist(String comment) {
Memory memory = program.getMemory();
Iterator<Address> addressIterator = listing.getCommentAddressIterator(memory, true);
boolean commentExists = false;
while (addressIterator.hasNext()) {
Address address = addressIterator.next();
for (int i : COMMENT_TYPES) {
String foundComment = listing.getComment(i, address);
for (CommentType type : CommentType.values()) {
String foundComment = listing.getComment(type, address);
if (foundComment != null && foundComment.equals(comment)) {
commentExists = true;
}

View file

@ -100,7 +100,7 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
builder.disassemble("0x10029bd", 0xe, true);
builder.createLabel("0x01001068", "CreateDCW");
builder.createComment("0x01001068", "CreateDCW", CodeUnit.EOL_COMMENT);
builder.createComment("0x01001068", "CreateDCW", CommentType.EOL);
builder.createLabel("0x010010b4", "CreateFileW");
builder.createLabel("0x010012bc", "CreateWindowExW");
@ -119,8 +119,8 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
// dt.add(new BooleanDataType(), "likesCheese", null);
// dt.add(new PointerDataType(dt), "next", null);
builder.createComment("0x01006642", "EOL comment", CodeUnit.EOL_COMMENT);
builder.createComment("0x01006648", "EOL comment", CodeUnit.EOL_COMMENT);
builder.createComment("0x01006642", "EOL comment", CommentType.EOL);
builder.createComment("0x01006648", "EOL comment", CommentType.EOL);
return builder.getProgram();
}
@ -789,7 +789,7 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
}
else if (location instanceof EolCommentFieldLocation) {
EolCommentFieldLocation eLoc = (EolCommentFieldLocation) location;
assertEquals(CodeUnit.EOL_COMMENT, eLoc.getCommentType());
assertEquals(CommentType.EOL, eLoc.getCommentType());
String[] comment = eLoc.getComment();
for (String element : comment) {
if (element.indexOf(text) >= 0) {
@ -801,7 +801,7 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
}
else if (location instanceof AutomaticCommentFieldLocation) {
AutomaticCommentFieldLocation eLoc = (AutomaticCommentFieldLocation) location;
assertEquals(CodeUnit.EOL_COMMENT, eLoc.getCommentType());
assertEquals(CommentType.EOL, eLoc.getCommentType());
String[] comment = eLoc.getComment();
for (String element : comment) {
if (element.indexOf(text) >= 0) {

View file

@ -114,7 +114,7 @@ public class SearchTextPlugin1Test extends AbstractGhidraHeadedIntegrationTest {
builder.createMemory(".debug_data", Long.toHexString(0xF0001300), 0x1C);
builder.createOverlayMemory("otherOverlay", "OTHER:0", 100);
builder.createComment("0x100415a", "scanf, fscanf, sscanf ...", CodeUnit.PRE_COMMENT);
builder.createComment("0x100415a", "scanf, fscanf, sscanf ...", CommentType.PRE);
//create and disassemble a function
builder.setBytes("0x0100415a",
"55 8b ec 83 ec 0c 33 c0 c7 45 f8 01 00 00 00 21 45 fc 39 45 08 c7 45 f4 04" +
@ -167,7 +167,7 @@ public class SearchTextPlugin1Test extends AbstractGhidraHeadedIntegrationTest {
param, param);
builder.createComment("otherOverlay:4", "This is a comment in the other overlay",
CodeUnit.EOL_COMMENT);
CommentType.EOL);
return builder.getProgram();
}
@ -403,7 +403,7 @@ public class SearchTextPlugin1Test extends AbstractGhidraHeadedIntegrationTest {
ProgramLocation loc = cbPlugin.getCurrentLocation();
assertEquals(getAddr(0x0100416f), loc.getAddress());
assertTrue(loc instanceof CommentFieldLocation);
assertEquals(CodeUnit.EOL_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.EOL, ((CommentFieldLocation) loc).getCommentType());
JButton searchButton = (JButton) findButton(dialog.getComponent(), "Next");
pressButton(searchButton);
@ -412,7 +412,7 @@ public class SearchTextPlugin1Test extends AbstractGhidraHeadedIntegrationTest {
loc = cbPlugin.getCurrentLocation();
assertEquals(getAddr(0x01004178), loc.getAddress());
assertTrue(loc instanceof CommentFieldLocation);
assertEquals(CodeUnit.REPEATABLE_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.REPEATABLE, ((CommentFieldLocation) loc).getCommentType());
pressButton(searchButton);
waitForSearchTasks(dialog);
@ -422,7 +422,7 @@ public class SearchTextPlugin1Test extends AbstractGhidraHeadedIntegrationTest {
assertTrue(loc instanceof CommentFieldLocation);
assertEquals("Search result not placed at the matching character position", 15,
loc.getCharOffset());
assertEquals(CodeUnit.PLATE_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.PLATE, ((CommentFieldLocation) loc).getCommentType());
pressButton(searchButton);
waitForSearchTasks(dialog);
@ -430,7 +430,7 @@ public class SearchTextPlugin1Test extends AbstractGhidraHeadedIntegrationTest {
loc = cbPlugin.getCurrentLocation();
assertEquals(getAddr(0x01004192), loc.getAddress());
assertTrue(loc instanceof CommentFieldLocation);
assertEquals(CodeUnit.POST_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.POST, ((CommentFieldLocation) loc).getCommentType());
pressButton(searchButton);
waitForSearchTasks(dialog);
@ -443,7 +443,7 @@ public class SearchTextPlugin1Test extends AbstractGhidraHeadedIntegrationTest {
loc = cbPlugin.getCurrentLocation();
assertEquals(getAddr(0x0100415a), loc.getAddress());
assertTrue(loc instanceof CommentFieldLocation);
assertEquals(CodeUnit.PRE_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.PRE, ((CommentFieldLocation) loc).getCommentType());
}
private void programLocationChange2(String buttonText) throws Exception {

View file

@ -83,7 +83,7 @@ public class SearchTextPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
builder.createMemory(".rsrc", Long.toHexString(0x100A000), 0x5400);
builder.createMemory(".bound_import_table", Long.toHexString(0xF0000248), 0xA8);
builder.createMemory(".debug_data", Long.toHexString(0xF0001300), 0x1C);
builder.createComment("0x100415a", "scanf, fscanf, sscanf ...", CodeUnit.PRE_COMMENT);
builder.createComment("0x100415a", "scanf, fscanf, sscanf ...", CommentType.PRE);
//create and disassemble a function
builder.setBytes("0x0100415a",

View file

@ -92,7 +92,7 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
builder.createMemory(".rsrc", Long.toHexString(0x100A000), 0x5400);
builder.createMemory(".bound_import_table", Long.toHexString(0xF0000248), 0xA8);
builder.createMemory(".debug_data", Long.toHexString(0xF0001300), 0x1C);
builder.createComment("0x100415a", "scanf, fscanf, sscanf ...", CodeUnit.PRE_COMMENT);
builder.createComment("0x100415a", "scanf, fscanf, sscanf ...", CommentType.PRE);
//create and disassemble a function
builder.setBytes("0x0100415a",
"55 8b ec 83 ec 0c 33 c0 c7 45 f8 01 00 00 00 21 45 fc 39 45 08 c7 45 f4 04" +
@ -218,7 +218,7 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
ProgramLocation loc = cbPlugin.getCurrentLocation();
assertTrue(loc instanceof CommentFieldLocation);
assertEquals(CodeUnit.PLATE_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.PLATE, ((CommentFieldLocation) loc).getCommentType());
assertEquals(cu.getMinAddress(), loc.getAddress());
triggerEnter(tf);
@ -226,7 +226,7 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
loc = cbPlugin.getCurrentLocation();
assertTrue(loc instanceof CommentFieldLocation);
assertEquals(CodeUnit.PRE_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.PRE, ((CommentFieldLocation) loc).getCommentType());
triggerEnter(tf);
waitForSearchTasks(dialog);
@ -246,14 +246,14 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
waitForSearchTasks(dialog);
loc = cbPlugin.getCurrentLocation();
assertTrue(loc instanceof CommentFieldLocation);
assertEquals(CodeUnit.EOL_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.EOL, ((CommentFieldLocation) loc).getCommentType());
assertEquals(cu.getMinAddress(), loc.getAddress());
triggerEnter(tf);
waitForSearchTasks(dialog);
loc = cbPlugin.getCurrentLocation();
assertTrue(loc instanceof CommentFieldLocation);
assertEquals(CodeUnit.POST_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.POST, ((CommentFieldLocation) loc).getCommentType());
assertEquals(cu.getMinAddress(), loc.getAddress());
}
@ -287,7 +287,7 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
ProgramLocation loc = cbPlugin.getCurrentLocation();
assertTrue(loc instanceof CommentFieldLocation);
assertEquals(CodeUnit.PLATE_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.PLATE, ((CommentFieldLocation) loc).getCommentType());
triggerEnter(searchButton);
@ -306,7 +306,7 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
waitForSearchTasks(dialog);
loc = cbPlugin.getCurrentLocation();
assertTrue(loc instanceof CommentFieldLocation);
assertEquals(CodeUnit.PRE_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.PRE, ((CommentFieldLocation) loc).getCommentType());
}
@Test
@ -562,13 +562,11 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
assertTrue(loc instanceof FunctionSignatureFieldLocation);
String signature = ((FunctionSignatureFieldLocation) loc).getSignature();
Function function = listing.getFunctionAt(loc.getAddress());
ListingHighlightProvider highlightProvider =
cbPlugin.getFormatManager().getFormatHighlightProvider();
FieldPanel fieldPanel = cbPlugin.getFieldPanel();
ListingField field = (ListingField) fieldPanel.getCurrentField();
FieldFactory factory = field.getFieldFactory();
Highlight[] h = highlightProvider.createHighlights(signature, field, -1);
int numberOfHighlights = h.length;
@ -596,7 +594,6 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
assertTrue(loc instanceof OperandFieldLocation);
field = (ListingField) fieldPanel.getCurrentField();
factory = field.getFieldFactory();
h = highlightProvider.createHighlights(signature, field, -1);
assertTrue("Did not update highlights for new search.", (numberOfHighlights != h.length));

View file

@ -97,7 +97,7 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
p2.setComment("cause a hit! -- imm xxx");
Parameter p3 = new ParameterImpl(null, new DoubleDataType(), program);
builder.createEmptyFunction("MyFunc", "0", 26, new WordDataType(), p1, p2, p3);
builder.createComment("0", "Blah Blah Blah -- imm", CodeUnit.PLATE_COMMENT);
builder.createComment("0", "Blah Blah Blah -- imm", CommentType.PLATE);
ProgramManager pm = tool.getService(ProgramManager.class);
pm.openProgram(program.getDomainFile());
@ -128,22 +128,22 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
Pattern pattern = UserSearchUtils.createSearchPattern("XXZ*", false);
ProgramLocation startLocation = new ProgramLocation(program, program.getMinAddress());
CommentFieldSearcher searcher = new CommentFieldSearcher(program, startLocation, null, true,
pattern, CodeUnit.EOL_COMMENT);
CommentFieldSearcher searcher =
new CommentFieldSearcher(program, startLocation, null, true, pattern, CommentType.EOL);
currentAddress = searcher.getNextSignificantAddress(null);
assertNull(getNextMatch(searcher));
// add a comment with no match
addEolComment(0x1005146L, "Test EOL comments...");
searcher = new CommentFieldSearcher(program, startLocation, null, true, pattern,
CodeUnit.EOL_COMMENT);
searcher =
new CommentFieldSearcher(program, startLocation, null, true, pattern, CommentType.EOL);
currentAddress = searcher.getNextSignificantAddress(null);
assertNull(getNextMatch(searcher));
// add a comment that has one match
addEolComment(0x1005d4bL, "Test something with eXXZabc");
searcher = new CommentFieldSearcher(program, startLocation, null, true, pattern,
CodeUnit.EOL_COMMENT);
searcher =
new CommentFieldSearcher(program, startLocation, null, true, pattern, CommentType.EOL);
currentAddress = searcher.getNextSignificantAddress(null);
ProgramLocation loc = getNextMatch(searcher);
assertNotNull(loc);
@ -151,8 +151,8 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
// add a comment with two matches for a total of 3 matches
addEolComment(0x100595f, "Hit found: eXXZabc followed by XXZabc");
searcher = new CommentFieldSearcher(program, startLocation, null, true, pattern,
CodeUnit.EOL_COMMENT);
searcher =
new CommentFieldSearcher(program, startLocation, null, true, pattern, CommentType.EOL);
currentAddress = searcher.getNextSignificantAddress(null);
loc = getNextMatch(searcher);
@ -176,8 +176,8 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
Pattern pattern = UserSearchUtils.createSearchPattern("*", false);
ProgramLocation startLocation = new ProgramLocation(program, program.getMinAddress());
CommentFieldSearcher searcher = new CommentFieldSearcher(program, startLocation, null, true,
pattern, CodeUnit.EOL_COMMENT);
CommentFieldSearcher searcher =
new CommentFieldSearcher(program, startLocation, null, true, pattern, CommentType.EOL);
currentAddress = searcher.getNextSignificantAddress(null);
int count = 0;
Address[] addrs =
@ -198,8 +198,8 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
Pattern pattern = UserSearchUtils.createSearchPattern("ABC*123", false);
ProgramLocation startLocation = new ProgramLocation(program, program.getMinAddress());
CommentFieldSearcher searcher = new CommentFieldSearcher(program, startLocation, null, true,
pattern, CodeUnit.EOL_COMMENT);
CommentFieldSearcher searcher =
new CommentFieldSearcher(program, startLocation, null, true, pattern, CommentType.EOL);
currentAddress = searcher.getNextSignificantAddress(null);
ProgramLocation loc = getNextMatch(searcher);
@ -479,7 +479,7 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
loc = ts.search().programLocation();
assertTrue("Expected CommentFieldLocation, got " + loc.getClass() + " instead!",
(loc instanceof CommentFieldLocation));
assertEquals(CodeUnit.POST_COMMENT, ((CommentFieldLocation) loc).getCommentType());
assertEquals(CommentType.POST, ((CommentFieldLocation) loc).getCommentType());
}

View file

@ -172,10 +172,10 @@ public class EolCommentFieldFactoryTest extends AbstractGhidraHeadedIntegrationT
}
private void setRepeatableComment(Address a, String comment) {
setComment(a, CodeUnit.REPEATABLE_COMMENT, comment);
setComment(a, CommentType.REPEATABLE, comment);
}
private void setComment(Address a, int commentType, String comment) {
private void setComment(Address a, CommentType commentType, String comment) {
CodeUnit cu = program.getListing().getCodeUnitAt(a);
tx(program, () -> {
cu.setComment(commentType, comment);

View file

@ -96,7 +96,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
builder.createFunction("1001300");
builder.createLabel("1001400", "bob");
builder.createComment("1001400", "my comment", CodeUnit.PLATE_COMMENT);
builder.createComment("1001400", "my comment", CommentType.PLATE);
builder.addBytesReturn("1001500");
builder.disassemble("1001500", 4);
@ -136,8 +136,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
tx(program, () -> {
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
cu.setCommentAsArray(CodeUnit.PLATE_COMMENT,
new String[] { "this is", "a plate comment" });
cu.setCommentAsArray(CommentType.PLATE, new String[] { "this is", "a plate comment" });
// create a reference to addr
ReferenceManager rm = program.getReferenceManager();
rm.addMemoryReference(getAddr(0x010023ee), addr, RefType.DATA, SourceType.USER_DEFINED,
@ -172,11 +171,11 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
tx(program, () -> {
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
cu.setCommentAsArray(CodeUnit.PLATE_COMMENT, new String[] { originalText });
cu.setCommentAsArray(CommentType.PLATE, new String[] { originalText });
// create a reference to addr
program.getReferenceManager()
.addMemoryReference(getAddr(0x010023ee), addr,
RefType.DATA, SourceType.USER_DEFINED, 0);
.addMemoryReference(getAddr(0x010023ee), addr, RefType.DATA,
SourceType.USER_DEFINED, 0);
});
cb.updateNow();
@ -437,8 +436,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
tx(program, () -> {
cu.setComment(CommentType.PLATE,
"this is a comment\ngo to the address 0x010028de");
cu.setComment(CommentType.PLATE, "this is a comment\ngo to the address 0x010028de");
});
assertTrue(cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 2, 23));
click(cb, 2);
@ -459,10 +457,8 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
tx(program, () -> {
program.getSymbolTable()
.createLabel(addr, testName.getMethodName(),
SourceType.USER_DEFINED);
cu.setComment(CommentType.PLATE,
"this is a comment\ngo to the address 0x010028de");
.createLabel(addr, testName.getMethodName(), SourceType.USER_DEFINED);
cu.setComment(CommentType.PLATE, "this is a comment\ngo to the address 0x010028de");
});
int nonCommentHeader = precedingBlankLines + 1; // +1 for the '***' line

View file

@ -167,7 +167,6 @@ public class PostCommentFieldFactoryTest extends AbstractGhidraHeadedIntegration
builder.createReturnInstruction("100e002");
builder.createEmptyFunction("call_dest_12", "0x100e020", 10, null);
return builder.getProgram();
}
@ -1008,8 +1007,7 @@ public class PostCommentFieldFactoryTest extends AbstractGhidraHeadedIntegration
assertTrue(cb.goToField(addr("100d000"), PostCommentFieldFactory.FIELD_NAME, 0, 1));
ListingField tf = cb.getCurrentField();
//old way of overriding (With RefType.UNCONDITIONAL CALL) does not yield a post comment
assertEquals(
"-- CALLOTHER(pcodeop_three) Call Override: call_dest_10 (0100d020)",
assertEquals("-- CALLOTHER(pcodeop_three) Call Override: call_dest_10 (0100d020)",
tf.getText());
}

View file

@ -247,7 +247,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
String comment2 =
"I want this sentence to wrap to the next line so that I can test wrapping.";
String[] comments = new String[] { comment1, comment2 };
inst.setCommentAsArray(CodeUnit.EOL_COMMENT, comments);
inst.setCommentAsArray(CommentType.EOL, comments);
program.endTransaction(id, true);
Options opt = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS);
opt.setBoolean("EOL Comments Field.Enable Word Wrapping", true);
@ -284,7 +284,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
String comment2 =
"I want this sentence to wrap to the next line so that I can test wrapping.";
String[] comments = new String[] { comment1, comment2 };
inst.setCommentAsArray(CodeUnit.EOL_COMMENT, comments);
inst.setCommentAsArray(CommentType.EOL, comments);
program.endTransaction(id, true);
// Options opt = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS);
// opt.putBoolean("test", "EOL Comments Field.Enable Word Wrapping", true);

View file

@ -783,8 +783,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testIteratorForComments() throws Exception {
startTransaction();
mem.createInitializedBlock("test", addr(0), 100, (byte) 0, TaskMonitor.DUMMY,
false);
mem.createInitializedBlock("test", addr(0), 100, (byte) 0, TaskMonitor.DUMMY, false);
for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
@ -811,10 +810,8 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testIteratorForCommentType() throws Exception {
startTransaction();
mem.createInitializedBlock("test", addr(0), 100, (byte) 0, TaskMonitor.DUMMY,
false);
mem.createInitializedBlock("test2", addr(5000), 100, (byte) 0,
TaskMonitor.DUMMY, false);
mem.createInitializedBlock("test", addr(0), 100, (byte) 0, TaskMonitor.DUMMY, false);
mem.createInitializedBlock("test2", addr(5000), 100, (byte) 0, TaskMonitor.DUMMY, false);
for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
@ -829,8 +826,8 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
}
endTransaction();
CodeUnitIterator iter = ((ProgramDB) program).getCodeManager().getCommentCodeUnitIterator(
CodeUnit.PLATE_COMMENT, mem);
CodeUnitIterator iter = ((ProgramDB) program).getCodeManager()
.getCommentCodeUnitIterator(CommentType.PLATE, mem);
int n = 0;
Address expectedAddr = null;
while (iter.hasNext()) {
@ -851,8 +848,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testIteratorForCommentsBackwards() throws Exception {
startTransaction();
mem.createInitializedBlock("test", addr(0), 100, (byte) 0, TaskMonitor.DUMMY,
false);
mem.createInitializedBlock("test", addr(0), 100, (byte) 0, TaskMonitor.DUMMY, false);
CodeUnit cu = listing.getCodeUnitAt(addr(90));
cu.setComment(CommentType.PLATE, "comment for plate " + addr(90));
@ -892,8 +888,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetPropertyCodeUnitIterator() throws Exception {
startTransaction();
mem.createInitializedBlock("test", addr(0), 100, (byte) 0, TaskMonitor.DUMMY,
false);
mem.createInitializedBlock("test", addr(0), 100, (byte) 0, TaskMonitor.DUMMY, false);
for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
cu.setProperty("Numbers", i);
@ -915,8 +910,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetPropertyCuIteratorBackwards() throws Exception {
startTransaction();
mem.createInitializedBlock("test", addr(0), 100, (byte) 0, TaskMonitor.DUMMY,
false);
mem.createInitializedBlock("test", addr(0), 100, (byte) 0, TaskMonitor.DUMMY, false);
for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i));
cu.setProperty("Numbers", i);
@ -937,8 +931,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetPropertCUIteratorSet() throws Exception {
startTransaction();
mem.createInitializedBlock("bk1", addr(0), 200, (byte) 0, TaskMonitor.DUMMY,
false);
mem.createInitializedBlock("bk1", addr(0), 200, (byte) 0, TaskMonitor.DUMMY, false);
// addresses 10-19
for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
@ -973,8 +966,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
public void testPropertyCommentIterator() throws Exception {
startTransaction();
// mem.createUninitializedBlock("Test", addr(0), 200);
mem.createInitializedBlock("bk1", addr(0), 200, (byte) 0, TaskMonitor.DUMMY,
false);
mem.createInitializedBlock("bk1", addr(0), 200, (byte) 0, TaskMonitor.DUMMY, false);
for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
cu.setComment(CommentType.EOL, "This is an eol comment " + i);
@ -1196,8 +1188,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetDataBackwards() throws Exception {
startTransaction();
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0,
TaskMonitor.DUMMY, false);
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0, TaskMonitor.DUMMY, false);
for (int i = 0; i < 10; i++) {
listing.createData(addr(i), DataType.DEFAULT, 1);
@ -1251,8 +1242,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCompositeData() throws Exception {
startTransaction();
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0,
TaskMonitor.DUMMY, false);
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0, TaskMonitor.DUMMY, false);
Structure struct = new StructureDataType("struct_1", 100);
Structure struct2 = new StructureDataType("struct_2", 0);
@ -1306,8 +1296,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCompositeDataStartingAt() throws Exception {
startTransaction();
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0,
TaskMonitor.DUMMY, false);
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0, TaskMonitor.DUMMY, false);
Structure struct = new StructureDataType("struct_1", 100);
Structure struct2 = new StructureDataType("struct_2", 0);
@ -1360,8 +1349,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCompositeDataInSet() throws Exception {
startTransaction();
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0,
TaskMonitor.DUMMY, false);
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0, TaskMonitor.DUMMY, false);
Structure struct = new StructureDataType("struct_1", 100);
Structure struct2 = new StructureDataType("struct_2", 0);
@ -1418,8 +1406,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
public void testGetDefinedDataIterator() throws Exception {
startTransaction();
mem.removeBlock(mem.getBlock(addr(1000)), monitor);
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0,
TaskMonitor.DUMMY, false);
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0, TaskMonitor.DUMMY, false);
for (int i = 0; i < 10; i++) {
listing.createData(addr(i), new ByteDataType(), 1);
@ -1491,8 +1478,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
public void testGetDefinedDataAtIterator() throws Exception {
startTransaction();
mem.removeBlock(mem.getBlock(addr(1000)), monitor);
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0,
TaskMonitor.DUMMY, false);
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0, TaskMonitor.DUMMY, false);
for (int i = 0; i < 10; i++) {
listing.createData(addr(i), DataType.DEFAULT, 1);
@ -1553,8 +1539,7 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetDefinedDataSetIterator() throws Exception {
startTransaction();
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0,
TaskMonitor.DUMMY, false);
mem.createInitializedBlock("test", addr(0), 1000, (byte) 0, TaskMonitor.DUMMY, false);
for (int i = 0; i < 10; i++) {
listing.createData(addr(i), new ByteDataType(), 0);

View file

@ -179,14 +179,14 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder1.createMemory("d1", "0x100", 0x100, null, (byte) 0xAC);
programBuilder1.createMemory("d2", "0x200", 0x100);
programBuilder1.createLabel("0x01006420", "Function1");
programBuilder1.createComment("0x010059a3", "Here we are.", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x010059a3", "Here we are.", CommentType.EOL);
programBuilder1.setBytes("0x01002b45", "ee");
programBuilder1.setBytes("0x01002b49", "57");
programBuilder2.createMemory("d1", "0x100", 0x100, null, (byte) 0xAF);
programBuilder2.createMemory("d4", "0x400", 0x100);
programBuilder2.createLabel("0x01006420", "Function2");
programBuilder2.createComment("0x010059a3", "There you have it.", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x010059a3", "There you have it.", CommentType.EOL);
programBuilder2.setBytes("0x01002b45", "8b");
programBuilder2.setBytes("0x01002b49", "ee");
@ -276,7 +276,7 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder1.createMemory("d1", "0x100", 0x100, null, (byte) 0xAC);
programBuilder1.createMemory("d2", "0x200", 0x100);
programBuilder1.createLabel("0x01006420", "Function1");
programBuilder1.createComment("0x010059a3", "Here we are.", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x010059a3", "Here we are.", CommentType.EOL);
programBuilder1.setBytes("0x01002b45", "ee");
programBuilder1.setBytes("0x01002b49", "57", true);
programBuilder1.clearCodeUnits("0x01002cf5", "0x01002d6d", true);
@ -285,7 +285,7 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder2.createMemory("d1", "0x100", 0x100, null, (byte) 0xAF);
programBuilder2.createMemory("d4", "0x400", 0x100);
programBuilder2.createLabel("0x01006420", "Function2");
programBuilder2.createComment("0x010059a3", "There you have it.", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x010059a3", "There you have it.", CommentType.EOL);
programBuilder2.setBytes("0x01002b45", "8b");
programBuilder2.setBytes("0x01002b49", "ee", true);
programBuilder2.clearCodeUnits("0x01002239", "0x0100248e", true);
@ -363,12 +363,11 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference1() throws Exception {
// 0x1002040: p1 has Plate, Pre, EOL, Post, & Repeatable comment.
programBuilder1.createComment("0x1002040", "My Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x1002040", "My Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x1002040", "My EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x1002040", "My Post Comment", CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x1002040", "My Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x1002040", "My Plate Comment", CommentType.PLATE);
programBuilder1.createComment("0x1002040", "My Pre Comment", CommentType.PRE);
programBuilder1.createComment("0x1002040", "My EOL Comment", CommentType.EOL);
programBuilder1.createComment("0x1002040", "My Post Comment", CommentType.POST);
programBuilder1.createComment("0x1002040", "My Repeatable Comment", CommentType.REPEATABLE);
checkCommentDifference(0x1002040);
}
@ -376,12 +375,12 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference2() throws Exception {
// 0x100204c: p2 has Plate, Pre, EOL, Post, & Repeatable comment.
programBuilder2.createComment("0x100204c", "Other Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100204c", "Other Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder2.createComment("0x100204c", "Other EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x100204c", "Other Post Comment", CodeUnit.POST_COMMENT);
programBuilder2.createComment("0x100204c", "Other Plate Comment", CommentType.PLATE);
programBuilder2.createComment("0x100204c", "Other Pre Comment", CommentType.PRE);
programBuilder2.createComment("0x100204c", "Other EOL Comment", CommentType.EOL);
programBuilder2.createComment("0x100204c", "Other Post Comment", CommentType.POST);
programBuilder2.createComment("0x100204c", "Other Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
checkCommentDifference(0x100204c);
}
@ -389,7 +388,7 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference3() throws Exception {
// 0x1002304: p1 has EOL comment.
programBuilder1.createComment("0x1002304", "My EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x1002304", "My EOL Comment", CommentType.EOL);
checkCommentDifference(0x1002304);
}
@ -397,7 +396,7 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference4() throws Exception {
// 0x1002306: p1 has pre-comment.
programBuilder1.createComment("0x1002306", "My Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x1002306", "My Pre Comment", CommentType.PRE);
checkCommentDifference(0x1002306);
}
@ -405,8 +404,8 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference5() throws Exception {
// 0x100230b: p1 has plate and post comments.
programBuilder1.createComment("0x100230b", "My Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100230b", "My Post Comment", CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x100230b", "My Plate Comment", CommentType.PLATE);
programBuilder1.createComment("0x100230b", "My Post Comment", CommentType.POST);
checkCommentDifference(0x100230b);
}
@ -414,8 +413,8 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference6() throws Exception {
// p2 plate comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100230d", "Other Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100230d", "Plate Comment", CommentType.PLATE);
programBuilder2.createComment("0x100230d", "Other Plate Comment", CommentType.PLATE);
checkCommentDifference(0x100230d);
}
@ -423,8 +422,8 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference7() throws Exception {
// p2 pre comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder2.createComment("0x100230d", "Other Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x100230d", "Pre Comment", CommentType.PRE);
programBuilder2.createComment("0x100230d", "Other Pre Comment", CommentType.PRE);
checkCommentDifference(0x100230d);
}
@ -432,8 +431,8 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference8() throws Exception {
// p2 eol comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x100230d", "Other EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x100230d", "EOL Comment", CommentType.EOL);
programBuilder2.createComment("0x100230d", "Other EOL Comment", CommentType.EOL);
checkCommentDifference(0x100230d);
}
@ -441,8 +440,8 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference9() throws Exception {
// p2 post comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Post Comment", CodeUnit.POST_COMMENT);
programBuilder2.createComment("0x100230d", "Other Post Comment", CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x100230d", "Post Comment", CommentType.POST);
programBuilder2.createComment("0x100230d", "Other Post Comment", CommentType.POST);
checkCommentDifference(0x100230d);
}
@ -450,10 +449,9 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference10() throws Exception {
// p2 repeatable comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x100230d", "Repeatable Comment", CommentType.REPEATABLE);
programBuilder2.createComment("0x100230d", "Other Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
checkCommentDifference(0x100230d);
}
@ -461,10 +459,9 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference11() throws Exception {
// 0x1002336: Different Repeatable comments.
programBuilder1.createComment("0x1002336", "Once upon a time,",
CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x1002336", "Once upon a time,", CommentType.REPEATABLE);
programBuilder2.createComment("0x1002336", "This is a sample comment.",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
checkCommentDifference(0x1002336);
}
@ -473,8 +470,8 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
public void testGetCommentDifference12() throws Exception {
// 0x1002346: P1 Repeatable comment contains P2 Repeatable comment.
programBuilder1.createComment("0x1002346", "This is a sample comment.",
CodeUnit.REPEATABLE_COMMENT);
programBuilder2.createComment("0x1002346", "This is a sample", CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
programBuilder2.createComment("0x1002346", "This is a sample", CommentType.REPEATABLE);
checkCommentDifference(0x1002346);
}
@ -482,9 +479,9 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference13() throws Exception {
// 0x1002350: P1 Repeatable comment contained within P2 Repeatable comment.
programBuilder1.createComment("0x1002350", "This is a sample", CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x1002350", "This is a sample", CommentType.REPEATABLE);
programBuilder2.createComment("0x1002350", "This is a sample comment.",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
checkCommentDifference(0x1002350);
}
@ -492,9 +489,8 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference14() throws Exception {
// 0x100238f: Different EOL comments.
programBuilder1.createComment("0x100238f", "Once upon a time,", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x100238f", "This is a sample comment.",
CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x100238f", "Once upon a time,", CommentType.EOL);
programBuilder2.createComment("0x100238f", "This is a sample comment.", CommentType.EOL);
checkCommentDifference(0x100238f);
}
@ -502,9 +498,8 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference15() throws Exception {
// 0x1002395: Different Pre comments.
programBuilder1.createComment("0x1002395", "Once upon a time,", CodeUnit.PRE_COMMENT);
programBuilder2.createComment("0x1002395", "This is a sample comment.",
CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x1002395", "Once upon a time,", CommentType.PRE);
programBuilder2.createComment("0x1002395", "This is a sample comment.", CommentType.PRE);
checkCommentDifference(0x1002395);
}
@ -512,9 +507,8 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference16() throws Exception {
// 0x100239d: Different Plate comments.
programBuilder1.createComment("0x100239d", "Once upon a time,", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100239d", "This is a sample comment.",
CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100239d", "Once upon a time,", CommentType.PLATE);
programBuilder2.createComment("0x100239d", "This is a sample comment.", CommentType.PLATE);
checkCommentDifference(0x100239d);
}
@ -522,9 +516,8 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference17() throws Exception {
// 0x100239d: Different Post comments.
programBuilder1.createComment("0x100239d", "Once upon a time,", CodeUnit.POST_COMMENT);
programBuilder2.createComment("0x100239d", "This is a sample comment.",
CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x100239d", "Once upon a time,", CommentType.POST);
programBuilder2.createComment("0x100239d", "This is a sample comment.", CommentType.POST);
checkCommentDifference(0x100239d);
}
@ -532,8 +525,7 @@ public class ProgramDiff1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testGetCommentDifference18() throws Exception {
// 0x1002a91: p2 has a plate comment.
programBuilder2.createComment("0x1002a91", "This is a sample comment.",
CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x1002a91", "This is a sample comment.", CommentType.PLATE);
checkCommentDifference(0x1002a91);
}

View file

@ -29,7 +29,7 @@ import ghidra.program.database.ProgramBuilder;
import ghidra.program.model.address.*;
import ghidra.program.model.data.*;
import ghidra.program.model.lang.Register;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.program.model.symbol.*;
import ghidra.test.ClassicSampleX86ProgramBuilder;
@ -76,6 +76,7 @@ public class ProgramDiff4Test extends AbstractProgramDiffTest {
programBuilder1 = null;
programBuilder2 = null;
}
/**
* Test that ProgramDiff can determine the blank format line user defined property
* differences between Program1 and Program2.
@ -478,12 +479,12 @@ public class ProgramDiff4Test extends AbstractProgramDiffTest {
programBuilder1.createMemory("d1", "0x100", 0x100, null, (byte) 0xAC);
programBuilder1.createMemory("d2", "0x200", 0x100);
programBuilder1.createLabel("0x01006420", "Function1");
programBuilder1.createComment("0x010059a3", "Here we are.", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x010059a3", "Here we are.", CommentType.EOL);
programBuilder2.createMemory("d1", "0x100", 0x100, null, (byte) 0xAF);
programBuilder2.createMemory("d4", "0x400", 0x100);
programBuilder2.createLabel("0x01006420", "Function2");
programBuilder2.createComment("0x010059a3", "There you have it.", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x010059a3", "There you have it.", CommentType.EOL);
programDiff = new ProgramDiff(p1, p2);
programDiff.setFilter(new ProgramDiffFilter(ProgramDiffFilter.ALL_DIFFS));
@ -523,12 +524,12 @@ public class ProgramDiff4Test extends AbstractProgramDiffTest {
programBuilder1.createMemory("d1", "0x100", 0x100, null, (byte) 0xAC);
programBuilder1.createMemory("d2", "0x200", 0x100);
programBuilder1.createLabel("0x01006420", "Function1");
programBuilder1.createComment("0x010059a3", "Here we are.", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x010059a3", "Here we are.", CommentType.EOL);
programBuilder2.createMemory("d1", "0x100", 0x100, null, (byte) 0xAF);
programBuilder2.createMemory("d4", "0x400", 0x100);
programBuilder2.createLabel("0x01006420", "Function2");
programBuilder2.createComment("0x010059a3", "There you have it.", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x010059a3", "There you have it.", CommentType.EOL);
programDiff = new ProgramDiff(p1, p2);
programDiff.setFilter(new ProgramDiffFilter(ProgramDiffFilter.ALL_DIFFS));
@ -540,8 +541,8 @@ public class ProgramDiff4Test extends AbstractProgramDiffTest {
assertTrue(diffs.contains(addr(p1, 0x010059a3)));
// Program Diff only determines differences within the limited set.
programDiff.setLimitedAddressSet(
new AddressSet(addr(p1, 0x01002239), addr(p1, 0x0100248c)));
programDiff
.setLimitedAddressSet(new AddressSet(addr(p1, 0x01002239), addr(p1, 0x0100248c)));
AddressSet as = new AddressSet();
as.addRange(addr(p1, 0x01002239), addr(p1, 0x0100248c));
assertEquals(as, programDiff.getLimitedAddressSet());
@ -658,18 +659,16 @@ public class ProgramDiff4Test extends AbstractProgramDiffTest {
@Test
public void testNoCommentDifference() throws Exception {
// 0x1002040: p1 has Plate, Pre, EOL, Post, & Repeatable comment.
programBuilder1.createComment("0x1002040", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x1002040", "Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x1002040", "EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x1002040", "Post Comment", CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x1002040", "Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
programBuilder2.createComment("0x1002040", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x1002040", "Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder2.createComment("0x1002040", "EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x1002040", "Post Comment", CodeUnit.POST_COMMENT);
programBuilder2.createComment("0x1002040", "Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x1002040", "Plate Comment", CommentType.PLATE);
programBuilder1.createComment("0x1002040", "Pre Comment", CommentType.PRE);
programBuilder1.createComment("0x1002040", "EOL Comment", CommentType.EOL);
programBuilder1.createComment("0x1002040", "Post Comment", CommentType.POST);
programBuilder1.createComment("0x1002040", "Repeatable Comment", CommentType.REPEATABLE);
programBuilder2.createComment("0x1002040", "Plate Comment", CommentType.PLATE);
programBuilder2.createComment("0x1002040", "Pre Comment", CommentType.PRE);
programBuilder2.createComment("0x1002040", "EOL Comment", CommentType.EOL);
programBuilder2.createComment("0x1002040", "Post Comment", CommentType.POST);
programBuilder2.createComment("0x1002040", "Repeatable Comment", CommentType.REPEATABLE);
checkNoCommentDifference();
}
@ -822,12 +821,12 @@ public class ProgramDiff4Test extends AbstractProgramDiffTest {
programBuilder1.createMemory("d1", "0x100", 0x100, null, (byte) 0xAC);
programBuilder1.createMemory("d2", "0x200", 0x100);
programBuilder1.createLabel("0x01006420", "Function1");
programBuilder1.createComment("0x010059a3", "Here we are.", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x010059a3", "Here we are.", CommentType.EOL);
programBuilder2.createMemory("d1", "0x100", 0x100, null, (byte) 0xAF);
programBuilder2.createMemory("d4", "0x400", 0x100);
programBuilder2.createLabel("0x01006420", "Function2");
programBuilder2.createComment("0x010059a3", "There you have it.", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x010059a3", "There you have it.", CommentType.EOL);
programDiff = new ProgramDiff(p1, p2);
programDiff.setFilter(new ProgramDiffFilter(ProgramDiffFilter.ALL_DIFFS));

View file

@ -318,12 +318,12 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder1.createMemory("d1", "0x100", 0x100, null, (byte) 0xAC);
programBuilder1.createMemory("d2", "0x200", 0x100);
programBuilder1.createLabel("0x01006420", "Function1");
programBuilder1.createComment("0x010059a3", "Here we are.", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x010059a3", "Here we are.", CommentType.EOL);
programBuilder2.createMemory("d1", "0x100", 0x100, null, (byte) 0xAF);
programBuilder2.createMemory("d4", "0x400", 0x100);
programBuilder2.createLabel("0x01006420", "Function2");
programBuilder2.createComment("0x010059a3", "There you have it.", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x010059a3", "There you have it.", CommentType.EOL);
programMerge = new ProgramMergeManager(p1, p2);
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.ALL_DIFFS));
@ -335,8 +335,8 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
assertTrue(diffs.contains(addr(p1, 0x010059a3)));
// Program Diff only determines differences within the limited set.
programMerge = new ProgramMergeManager(p1, p2,
new AddressSet(addr(0x01002239), addr(0x0100248c)));
programMerge =
new ProgramMergeManager(p1, p2, new AddressSet(addr(0x01002239), addr(0x0100248c)));
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.ALL_DIFFS));
AddressSet as = new AddressSet();
as.addRange(addr(0x01002239), addr(0x0100248c));
@ -355,12 +355,12 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder1.createMemory("d1", "0x100", 0x100, null, (byte) 0xAC);
programBuilder1.createMemory("d2", "0x200", 0x100);
programBuilder1.createLabel("0x01006420", "Function1");
programBuilder1.createComment("0x010059a3", "Here we are.", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x010059a3", "Here we are.", CommentType.EOL);
programBuilder2.createMemory("d1", "0x100", 0x100, null, (byte) 0xAF);
programBuilder2.createMemory("d4", "0x400", 0x100);
programBuilder2.createLabel("0x01006420", "Function2");
programBuilder2.createComment("0x010059a3", "There you have it.", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x010059a3", "There you have it.", CommentType.EOL);
programMerge = new ProgramMergeManager(p1, p2);
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.ALL_DIFFS));
@ -396,12 +396,12 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder1.createMemory("d1", "0x100", 0x100, null, (byte) 0xAC);
programBuilder1.createMemory("d2", "0x200", 0x100);
programBuilder1.createLabel("0x01006420", "Function1");
programBuilder1.createComment("0x010059a3", "Here we are.", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x010059a3", "Here we are.", CommentType.EOL);
programBuilder2.createMemory("d1", "0x100", 0x100, null, (byte) 0xAF);
programBuilder2.createMemory("d4", "0x400", 0x100);
programBuilder2.createLabel("0x01006420", "Function2");
programBuilder2.createComment("0x010059a3", "There you have it.", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x010059a3", "There you have it.", CommentType.EOL);
programMerge = new ProgramMergeManager(p1, p2);
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.ALL_DIFFS));
@ -438,85 +438,76 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testReplaceCommentDifferences() throws Exception {
// 0x1002040: p1 has Plate, Pre, EOL, Post, & Repeatable comment.
programBuilder1.createComment("0x1002040", "My Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x1002040", "My Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x1002040", "My EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x1002040", "My Post Comment", CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x1002040", "My Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x1002040", "My Plate Comment", CommentType.PLATE);
programBuilder1.createComment("0x1002040", "My Pre Comment", CommentType.PRE);
programBuilder1.createComment("0x1002040", "My EOL Comment", CommentType.EOL);
programBuilder1.createComment("0x1002040", "My Post Comment", CommentType.POST);
programBuilder1.createComment("0x1002040", "My Repeatable Comment", CommentType.REPEATABLE);
// 0x100204c: p2 has Plate, Pre, EOL, Post, & Repeatable comment.
programBuilder2.createComment("0x100204c", "Other Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100204c", "Other Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder2.createComment("0x100204c", "Other EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x100204c", "Other Post Comment", CodeUnit.POST_COMMENT);
programBuilder2.createComment("0x100204c", "Other Plate Comment", CommentType.PLATE);
programBuilder2.createComment("0x100204c", "Other Pre Comment", CommentType.PRE);
programBuilder2.createComment("0x100204c", "Other EOL Comment", CommentType.EOL);
programBuilder2.createComment("0x100204c", "Other Post Comment", CommentType.POST);
programBuilder2.createComment("0x100204c", "Other Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
// 0x1002304: p1 has EOL comment.
programBuilder1.createComment("0x1002304", "My EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x1002304", "My EOL Comment", CommentType.EOL);
// 0x1002306: p1 has pre-comment.
programBuilder1.createComment("0x1002306", "My Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x1002306", "My Pre Comment", CommentType.PRE);
// 0x100230b: p1 has plate and post comments.
programBuilder1.createComment("0x100230b", "My Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100230b", "My Post Comment", CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x100230b", "My Plate Comment", CommentType.PLATE);
programBuilder1.createComment("0x100230b", "My Post Comment", CommentType.POST);
// 0x100230d: p2 plate comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100230d", "Other Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100230d", "Plate Comment", CommentType.PLATE);
programBuilder2.createComment("0x100230d", "Other Plate Comment", CommentType.PLATE);
// 0x100230d: p2 pre comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder2.createComment("0x100230d", "Other Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x100230d", "Pre Comment", CommentType.PRE);
programBuilder2.createComment("0x100230d", "Other Pre Comment", CommentType.PRE);
// 0x100230d: p2 eol comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x100230d", "Other EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x100230d", "EOL Comment", CommentType.EOL);
programBuilder2.createComment("0x100230d", "Other EOL Comment", CommentType.EOL);
// 0x100230d: p2 post comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Post Comment", CodeUnit.POST_COMMENT);
programBuilder2.createComment("0x100230d", "Other Post Comment", CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x100230d", "Post Comment", CommentType.POST);
programBuilder2.createComment("0x100230d", "Other Post Comment", CommentType.POST);
// 0x100230d: p2 repeatable comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x100230d", "Repeatable Comment", CommentType.REPEATABLE);
programBuilder2.createComment("0x100230d", "Other Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
// 0x1002336: Different Repeatable comments.
programBuilder1.createComment("0x1002336", "Once upon a time,",
CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x1002336", "Once upon a time,", CommentType.REPEATABLE);
programBuilder2.createComment("0x1002336", "This is a sample comment.",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
// 0x1002346: P1 Repeatable comment contains P2 Repeatable comment.
programBuilder1.createComment("0x1002346", "This is a sample comment.",
CodeUnit.REPEATABLE_COMMENT);
programBuilder2.createComment("0x1002346", "This is a sample", CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
programBuilder2.createComment("0x1002346", "This is a sample", CommentType.REPEATABLE);
// 0x1002350: P1 Repeatable comment contained within P2 Repeatable comment.
programBuilder1.createComment("0x1002350", "This is a sample", CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x1002350", "This is a sample", CommentType.REPEATABLE);
programBuilder2.createComment("0x1002350", "This is a sample comment.",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
// 0x100238f: Different EOL comments.
programBuilder1.createComment("0x100238f", "Once upon a time,", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x100238f", "This is a sample comment.",
CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x100238f", "Once upon a time,", CommentType.EOL);
programBuilder2.createComment("0x100238f", "This is a sample comment.", CommentType.EOL);
// 0x1002395: Different Pre comments.
programBuilder1.createComment("0x1002395", "Once upon a time,", CodeUnit.PRE_COMMENT);
programBuilder2.createComment("0x1002395", "This is a sample comment.",
CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x1002395", "Once upon a time,", CommentType.PRE);
programBuilder2.createComment("0x1002395", "This is a sample comment.", CommentType.PRE);
// 0x100239d: Different Plate comments.
programBuilder1.createComment("0x100239d", "Once upon a time,", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100239d", "This is a sample comment.",
CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100239d", "Once upon a time,", CommentType.PLATE);
programBuilder2.createComment("0x100239d", "This is a sample comment.", CommentType.PLATE);
// 0x100239d: Different Post comments.
programBuilder1.createComment("0x100239d", "Once upon a time,", CodeUnit.POST_COMMENT);
programBuilder2.createComment("0x100239d", "This is a sample comment.",
CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x100239d", "Once upon a time,", CommentType.POST);
programBuilder2.createComment("0x100239d", "This is a sample comment.", CommentType.POST);
// 0x1002a91: p2 has a plate comment.
programBuilder2.createComment("0x1002a91", "This is a sample comment.",
CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x1002a91", "This is a sample comment.", CommentType.PLATE);
// 0x10030d2: p1 has plate comment.
programBuilder1.createComment("0x10030d2", "Once upon a time,", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x10030d2", "Once upon a time,", CommentType.PLATE);
// 0x10030d8: p2 has plate comment.
programBuilder2.createComment("0x10030d8", "This is a sample comment.",
CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x10030d8", "This is a sample comment.", CommentType.PLATE);
// 0x100355f: p1 has plate comment.
programBuilder1.createComment("0x100355f", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100355f", "Plate Comment", CommentType.PLATE);
// 0x100415a: p1 and p2 have same plate comments.
programBuilder1.createComment("0x100415a", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100415a", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100415a", "Plate Comment", CommentType.PLATE);
programBuilder2.createComment("0x100415a", "Plate Comment", CommentType.PLATE);
programMerge = new ProgramMergeManager(p1, p2);
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.COMMENT_DIFFS));
@ -633,85 +624,76 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testMergeCommentDifferences() throws Exception {
// 0x1002040: p1 has Plate, Pre, EOL, Post, & Repeatable comment.
programBuilder1.createComment("0x1002040", "My Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x1002040", "My Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x1002040", "My EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x1002040", "My Post Comment", CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x1002040", "My Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x1002040", "My Plate Comment", CommentType.PLATE);
programBuilder1.createComment("0x1002040", "My Pre Comment", CommentType.PRE);
programBuilder1.createComment("0x1002040", "My EOL Comment", CommentType.EOL);
programBuilder1.createComment("0x1002040", "My Post Comment", CommentType.POST);
programBuilder1.createComment("0x1002040", "My Repeatable Comment", CommentType.REPEATABLE);
// 0x100204c: p2 has Plate, Pre, EOL, Post, & Repeatable comment.
programBuilder2.createComment("0x100204c", "Other Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100204c", "Other Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder2.createComment("0x100204c", "Other EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x100204c", "Other Post Comment", CodeUnit.POST_COMMENT);
programBuilder2.createComment("0x100204c", "Other Plate Comment", CommentType.PLATE);
programBuilder2.createComment("0x100204c", "Other Pre Comment", CommentType.PRE);
programBuilder2.createComment("0x100204c", "Other EOL Comment", CommentType.EOL);
programBuilder2.createComment("0x100204c", "Other Post Comment", CommentType.POST);
programBuilder2.createComment("0x100204c", "Other Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
// 0x1002304: p1 has EOL comment.
programBuilder1.createComment("0x1002304", "My EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x1002304", "My EOL Comment", CommentType.EOL);
// 0x1002306: p1 has pre-comment.
programBuilder1.createComment("0x1002306", "My Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x1002306", "My Pre Comment", CommentType.PRE);
// 0x100230b: p1 has plate and post comments.
programBuilder1.createComment("0x100230b", "My Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100230b", "My Post Comment", CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x100230b", "My Plate Comment", CommentType.PLATE);
programBuilder1.createComment("0x100230b", "My Post Comment", CommentType.POST);
// 0x100230d: p2 plate comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100230d", "Other Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100230d", "Plate Comment", CommentType.PLATE);
programBuilder2.createComment("0x100230d", "Other Plate Comment", CommentType.PLATE);
// 0x100230d: p2 pre comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder2.createComment("0x100230d", "Other Pre Comment", CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x100230d", "Pre Comment", CommentType.PRE);
programBuilder2.createComment("0x100230d", "Other Pre Comment", CommentType.PRE);
// 0x100230d: p2 eol comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x100230d", "Other EOL Comment", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x100230d", "EOL Comment", CommentType.EOL);
programBuilder2.createComment("0x100230d", "Other EOL Comment", CommentType.EOL);
// 0x100230d: p2 post comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Post Comment", CodeUnit.POST_COMMENT);
programBuilder2.createComment("0x100230d", "Other Post Comment", CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x100230d", "Post Comment", CommentType.POST);
programBuilder2.createComment("0x100230d", "Other Post Comment", CommentType.POST);
// 0x100230d: p2 repeatable comments contain the p1 comment string.
programBuilder1.createComment("0x100230d", "Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x100230d", "Repeatable Comment", CommentType.REPEATABLE);
programBuilder2.createComment("0x100230d", "Other Repeatable Comment",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
// 0x1002336: Different Repeatable comments.
programBuilder1.createComment("0x1002336", "Once upon a time,",
CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x1002336", "Once upon a time,", CommentType.REPEATABLE);
programBuilder2.createComment("0x1002336", "This is a sample comment.",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
// 0x1002346: P1 Repeatable comment contains P2 Repeatable comment.
programBuilder1.createComment("0x1002346", "This is a sample comment.",
CodeUnit.REPEATABLE_COMMENT);
programBuilder2.createComment("0x1002346", "This is a sample", CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
programBuilder2.createComment("0x1002346", "This is a sample", CommentType.REPEATABLE);
// 0x1002350: P1 Repeatable comment contained within P2 Repeatable comment.
programBuilder1.createComment("0x1002350", "This is a sample", CodeUnit.REPEATABLE_COMMENT);
programBuilder1.createComment("0x1002350", "This is a sample", CommentType.REPEATABLE);
programBuilder2.createComment("0x1002350", "This is a sample comment.",
CodeUnit.REPEATABLE_COMMENT);
CommentType.REPEATABLE);
// 0x100238f: Different EOL comments.
programBuilder1.createComment("0x100238f", "Once upon a time,", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x100238f", "This is a sample comment.",
CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x100238f", "Once upon a time,", CommentType.EOL);
programBuilder2.createComment("0x100238f", "This is a sample comment.", CommentType.EOL);
// 0x1002395: Different Pre comments.
programBuilder1.createComment("0x1002395", "Once upon a time,", CodeUnit.PRE_COMMENT);
programBuilder2.createComment("0x1002395", "This is a sample comment.",
CodeUnit.PRE_COMMENT);
programBuilder1.createComment("0x1002395", "Once upon a time,", CommentType.PRE);
programBuilder2.createComment("0x1002395", "This is a sample comment.", CommentType.PRE);
// 0x100239d: Different Plate comments.
programBuilder1.createComment("0x100239d", "Once upon a time,", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100239d", "This is a sample comment.",
CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100239d", "Once upon a time,", CommentType.PLATE);
programBuilder2.createComment("0x100239d", "This is a sample comment.", CommentType.PLATE);
// 0x100239d: Different Post comments.
programBuilder1.createComment("0x100239d", "Once upon a time,", CodeUnit.POST_COMMENT);
programBuilder2.createComment("0x100239d", "This is a sample comment.",
CodeUnit.POST_COMMENT);
programBuilder1.createComment("0x100239d", "Once upon a time,", CommentType.POST);
programBuilder2.createComment("0x100239d", "This is a sample comment.", CommentType.POST);
// 0x1002a91: p2 has a plate comment.
programBuilder2.createComment("0x1002a91", "This is a sample comment.",
CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x1002a91", "This is a sample comment.", CommentType.PLATE);
// 0x10030d2: p1 has plate comment.
programBuilder1.createComment("0x10030d2", "Once upon a time,", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x10030d2", "Once upon a time,", CommentType.PLATE);
// 0x10030d8: p2 has plate comment.
programBuilder2.createComment("0x10030d8", "This is a sample comment.",
CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x10030d8", "This is a sample comment.", CommentType.PLATE);
// 0x100355f: p1 has plate comment.
programBuilder1.createComment("0x100355f", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100355f", "Plate Comment", CommentType.PLATE);
// 0x100415a: p1 and p2 have same plate comments.
programBuilder1.createComment("0x100415a", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder2.createComment("0x100415a", "Plate Comment", CodeUnit.PLATE_COMMENT);
programBuilder1.createComment("0x100415a", "Plate Comment", CommentType.PLATE);
programBuilder2.createComment("0x100415a", "Plate Comment", CommentType.PLATE);
programMerge = new ProgramMergeManager(p1, p2);
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.COMMENT_DIFFS));
@ -842,8 +824,8 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder2.applyDataType("0x0100102c", new Pointer32DataType(), 1);
programBuilder2.createExternalReference("0x0100102c", "ADVAPI32.dll", "IsTextUnicode", 0);
programMerge = new ProgramMergeManager(p1, p2,
new AddressSet(addr(0x01001000), addr(0x010017ff)));
programMerge =
new ProgramMergeManager(p1, p2, new AddressSet(addr(0x01001000), addr(0x010017ff)));
AddressSet as = new AddressSet(addr(0x0100102c), addr(0x0100102f));
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.REFERENCE_DIFFS));
@ -864,8 +846,8 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder2.applyDataType("0x01001034", new Pointer32DataType(), 1);
programBuilder2.createExternalReference("0x01001034", "myGDI32.dll", "SomePlace", 0);
programMerge = new ProgramMergeManager(p1, p2,
new AddressSet(addr(0x01001000), addr(0x010017ff)));
programMerge =
new ProgramMergeManager(p1, p2, new AddressSet(addr(0x01001000), addr(0x010017ff)));
AddressSet as = new AddressSet(addr(0x01001034), addr(0x01001037));
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.REFERENCE_DIFFS));
@ -886,8 +868,8 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder2.applyDataType("0x01001038", new Pointer32DataType(), 1);
programBuilder2.createExternalReference("0x01001038", "GDI32.dll", "ABC12345", 0);
programMerge = new ProgramMergeManager(p1, p2,
new AddressSet(addr(0x01001000), addr(0x010017ff)));
programMerge =
new ProgramMergeManager(p1, p2, new AddressSet(addr(0x01001000), addr(0x010017ff)));
AddressSet as = new AddressSet(addr(0x01001038), addr(0x0100103b));
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.REFERENCE_DIFFS));
@ -908,8 +890,8 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder2.applyDataType("0x0100103c", new Pointer32DataType(), 1);
programBuilder2.createExternalReference("0x0100103c", "GDI32.dll", "XYZ", "0x77f4abcd", 0);
programMerge = new ProgramMergeManager(p1, p2,
new AddressSet(addr(0x01001000), addr(0x010017ff)));
programMerge =
new ProgramMergeManager(p1, p2, new AddressSet(addr(0x01001000), addr(0x010017ff)));
AddressSet as = new AddressSet(addr(0x0100103c), addr(0x0100103f));
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.REFERENCE_DIFFS));
@ -929,8 +911,8 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder2.applyDataType("0x01001044", new Pointer32DataType(), 1);
programBuilder2.createExternalReference("0x01001044", "GDI32.dll", "MNM", 0);
programMerge = new ProgramMergeManager(p1, p2,
new AddressSet(addr(0x01001000), addr(0x010017ff)));
programMerge =
new ProgramMergeManager(p1, p2, new AddressSet(addr(0x01001000), addr(0x010017ff)));
AddressSet as = new AddressSet(addr(0x01001044), addr(0x01001047));
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.REFERENCE_DIFFS));
@ -1699,8 +1681,7 @@ public class ProgramMerge1Test extends AbstractGhidraHeadedIntegrationTest {
SymbolTable symtab2 = p2.getSymbolTable();
symtab2.createLabel(addr(0x1002969), "ONE", SourceType.USER_DEFINED);
AddressSet limitedAddrSet = new AddressSet(addr(0x1002950), addr(0x100299b));
programMerge =
new ProgramMergeManager(p1, p2, limitedAddrSet);
programMerge = new ProgramMergeManager(p1, p2, limitedAddrSet);
AddressSet as = new AddressSet(addr(0x100295d));
AddressSet as2 = new AddressSet(addr(0x1002969));

View file

@ -148,8 +148,8 @@ public class ProgramMerge3Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder1.createBookmark("0x1002323", BookmarkType.INFO, "stuff", "My bookmark");
programBuilder2.createBookmark("0x1002323", BookmarkType.INFO, "stuff", "My bookmark");
programMerge = new ProgramMergeManager(p1, p2,
new AddressSet(addr(0x1002306), addr(0x100232f)));
programMerge =
new ProgramMergeManager(p1, p2, new AddressSet(addr(0x1002306), addr(0x100232f)));
AddressSet as = new AddressSet(addr(0x100230b), addr(0x100231c));
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.BOOKMARK_DIFFS));
programMerge.setMergeFilter(
@ -245,7 +245,7 @@ public class ProgramMerge3Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder1.createMemory("d1", "0x100", 0x100, null, (byte) 0xAC);
programBuilder1.createMemory("d2", "0x200", 0x100);
programBuilder1.createLabel("0x01006420", "Function1");
programBuilder1.createComment("0x010059a3", "Here we are.", CodeUnit.EOL_COMMENT);
programBuilder1.createComment("0x010059a3", "Here we are.", CommentType.EOL);
programBuilder1.setBytes("0x01002b45", "ee");
programBuilder1.setBytes("0x01002b49", "57", true);
programBuilder1.clearCodeUnits("0x01002cf5", "0x01002d6d", true);
@ -254,7 +254,7 @@ public class ProgramMerge3Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder2.createMemory("d1", "0x100", 0x100, null, (byte) 0xAF);
programBuilder2.createMemory("d4", "0x400", 0x100);
programBuilder2.createLabel("0x01006420", "Function2");
programBuilder2.createComment("0x010059a3", "There you have it.", CodeUnit.EOL_COMMENT);
programBuilder2.createComment("0x010059a3", "There you have it.", CommentType.EOL);
programBuilder2.setBytes("0x01002b45", "8b");
programBuilder2.setBytes("0x01002b49", "ee", true);
programBuilder2.clearCodeUnits("0x01002239", "0x0100248e", true);
@ -747,8 +747,8 @@ public class ProgramMerge3Test extends AbstractGhidraHeadedIntegrationTest {
programBuilder2.createMemoryReference("0x01001028", "0x01001000", RefType.INDIRECTION,
SourceType.DEFAULT);
programMerge = new ProgramMergeManager(p1, p2,
new AddressSet(addr(0x01001000), addr(0x010017ff)));
programMerge =
new ProgramMergeManager(p1, p2, new AddressSet(addr(0x01001000), addr(0x010017ff)));
AddressSet as = new AddressSet(addr(0x01001028), addr(0x0100102b));
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.REFERENCE_DIFFS));
@ -769,8 +769,8 @@ public class ProgramMerge3Test extends AbstractGhidraHeadedIntegrationTest {
function2.setBody(new AddressSet(addr(0x100299e), addr(0x1002a89)));
p2.endTransaction(transactionID, true);
programMerge = new ProgramMergeManager(p1, p2,
new AddressSet(addr(0x0100299e), addr(0x01002a90)));
programMerge =
new ProgramMergeManager(p1, p2, new AddressSet(addr(0x0100299e), addr(0x01002a90)));
AddressSet as = new AddressSet(addr(0x0100299e), addr(0x0100299e));
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.FUNCTION_DIFFS));
programMerge.setMergeFilter(
@ -971,8 +971,8 @@ public class ProgramMerge3Test extends AbstractGhidraHeadedIntegrationTest {
p2.getFunctionManager().removeFunction(addr(0x10030d2));
p2.endTransaction(transactionID, true);
programMerge = new ProgramMergeManager(p1, p2,
new AddressSet(addr(0x10030d2), addr(0x10030d7)));
programMerge =
new ProgramMergeManager(p1, p2, new AddressSet(addr(0x10030d2), addr(0x10030d7)));
AddressSet as = new AddressSet(addr(0x10030d2), addr(0x10030d2));
programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.FUNCTION_DIFFS));
programMerge.setMergeFilter(

View file

@ -120,22 +120,22 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x100101c);
CodeUnit cu = program.getListing().getCodeUnitAt(a);
String[] comment = cu.getCommentAsArray(CommentType.PRE);
locs[0] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
locs[0] = new CommentFieldLocation(program, a, null, comment, CommentType.PRE, 0, 5);
a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CommentType.PRE);
locs[1] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
locs[1] = new CommentFieldLocation(program, a, null, comment, CommentType.PRE, 0, 5);
a = addr(0x100352f);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CommentType.EOL);
locs[2] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 0, 5);
locs[2] = new CommentFieldLocation(program, a, null, comment, CommentType.EOL, 0, 5);
a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CommentType.EOL);
locs[3] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 1, 5);
locs[3] = new CommentFieldLocation(program, a, null, comment, CommentType.EOL, 1, 5);
a = addr(0x10075ff);
cu = program.getListing().getCodeUnitAt(a);
@ -169,12 +169,12 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x100101c);
CodeUnit cu = program.getListing().getCodeUnitAt(a);
String[] comment = cu.getCommentAsArray(CommentType.PRE);
locs[0] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
locs[0] = new CommentFieldLocation(program, a, null, comment, CommentType.PRE, 0, 5);
a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CommentType.PRE);
locs[1] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
locs[1] = new CommentFieldLocation(program, a, null, comment, CommentType.PRE, 0, 5);
return locs;
}
@ -185,12 +185,12 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x100352f);
CodeUnit cu = program.getListing().getCodeUnitAt(a);
String[] comment = cu.getCommentAsArray(CommentType.EOL);
locs[0] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 0, 5);
locs[0] = new CommentFieldLocation(program, a, null, comment, CommentType.EOL, 0, 5);
a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CommentType.EOL);
locs[1] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 1, 5);
locs[1] = new CommentFieldLocation(program, a, null, comment, CommentType.EOL, 1, 5);
return locs;
}
@ -535,8 +535,7 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
@Override
public ProgramLocation[] getLocationsWithLocalLabels() {
ProgramLocation[] locs = new ProgramLocation[2];
locs[0] =
new LabelFieldLocation(program, addr(0x1002d1f), "MyLocal");
locs[0] = new LabelFieldLocation(program, addr(0x1002d1f), "MyLocal");
locs[1] = new LabelFieldLocation(program, addr(0x1002d2b), "AnotherLocal");
return locs;
}

Some files were not shown because too many files have changed in this diff Show more