mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 01:39:21 +02:00
Merge remote-tracking branch 'origin/GP-5742_ghidra1_CommentTypeCleanup--SQUASHED' into Ghidra_11.4
This commit is contained in:
commit
e03fb9af76
211 changed files with 4627 additions and 4860 deletions
|
@ -26,7 +26,7 @@ import ghidra.app.services.DebuggerTraceManagerService;
|
|||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.PointerDataType;
|
||||
import ghidra.program.model.lang.*;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Instruction;
|
||||
import ghidra.program.model.symbol.SourceType;
|
||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
|
@ -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
|
||||
|
@ -409,8 +404,7 @@ public class PopulateDemoTrace extends GhidraScript {
|
|||
trace.getCodeManager()
|
||||
.codeUnits()
|
||||
.getAt(0, cloneLabel.getAddress())
|
||||
.setComment(
|
||||
CodeUnit.EOL_COMMENT, "Pretend this is a syscall");
|
||||
.setComment(CommentType.EOL, "Pretend this is a syscall");
|
||||
|
||||
/**
|
||||
* Stub out "exit"
|
||||
|
@ -419,8 +413,7 @@ public class PopulateDemoTrace extends GhidraScript {
|
|||
trace.getCodeManager()
|
||||
.codeUnits()
|
||||
.getAt(0, exitLabel.getAddress())
|
||||
.setComment(
|
||||
CodeUnit.EOL_COMMENT, "Pretend this is a syscall");
|
||||
.setComment(CommentType.EOL, "Pretend this is a syscall");
|
||||
|
||||
/**
|
||||
* "Launch" the program by initializing RIP and RSP of the main thread
|
||||
|
@ -504,10 +497,10 @@ 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())
|
||||
.flip());
|
||||
memory.putBytes(snap, addr(STACK2_BOTTOM + stack2offset),
|
||||
buf.clear()
|
||||
.putLong(mainInstructions.get(pc2 = pc1).getAddress().getOffset())
|
||||
.flip());
|
||||
|
||||
placeRegUnits(snap, thread1);
|
||||
placeRegUnits(snap, thread2);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
@ -353,7 +350,7 @@ public class AnalysisUnwoundFrame<T> extends AbstractUnwoundFrame<T> {
|
|||
TraceData frame = trace.getCodeManager()
|
||||
.definedData()
|
||||
.create(span, spPlusParams, platform, structure);
|
||||
frame.setComment(CodeUnit.PRE_COMMENT, getDescription());
|
||||
frame.setComment(CommentType.PRE, getDescription());
|
||||
TraceReferenceManager refs = trace.getReferenceManager();
|
||||
refs.clearReferencesFrom(span, frame.getRange());
|
||||
refs.clearReferencesTo(span, frame.getRange());
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -95,7 +95,7 @@ public class ListingUnwoundFrame extends AbstractUnwoundFrame<WatchValue> {
|
|||
*/
|
||||
private static Integer getLevel(TraceData data) {
|
||||
// TODO: Should this go into a property instead?
|
||||
String comment = data.getComment(CodeUnit.PRE_COMMENT);
|
||||
String comment = data.getComment(CommentType.PRE);
|
||||
if (comment == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ public class ListingUnwoundFrame extends AbstractUnwoundFrame<WatchValue> {
|
|||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return frame.getComment(CodeUnit.PRE_COMMENT);
|
||||
return frame.getComment(CommentType.PRE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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,19 +703,19 @@ 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), CodeUnit.EOL_COMMENT, "Test EOL Comment");
|
||||
listing.setComment(tb.addr(0x55550321), CodeUnit.PLATE_COMMENT, "Test Plate Comment");
|
||||
listing.setComment(tb.addr(0x55550123), CommentType.EOL, "Test EOL Comment");
|
||||
listing.setComment(tb.addr(0x55550321), CommentType.PLATE, "Test Plate Comment");
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -735,8 +728,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
|
|||
|
||||
assertEquals(Set.of(tb.addr(stSpace, 0x55550123), tb.addr(stSpace, 0x55550321)), addresses);
|
||||
assertEquals("Test EOL Comment",
|
||||
listing.getComment(CodeUnit.EOL_COMMENT, tb.addr(stSpace, 0x55550123)));
|
||||
listing.getComment(CommentType.EOL, tb.addr(stSpace, 0x55550123)));
|
||||
assertEquals("Test Plate Comment",
|
||||
listing.getComment(CodeUnit.PLATE_COMMENT, tb.addr(stSpace, 0x55550321)));
|
||||
listing.getComment(CommentType.PLATE, tb.addr(stSpace, 0x55550321)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,9 +129,8 @@ 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()
|
||||
.getPropertyMapExtends(name, valueClass);
|
||||
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,10 +356,9 @@ public interface DBTraceCodeUnitAdapter extends TraceCodeUnit, MemBufferMixin {
|
|||
|
||||
@Override
|
||||
default ReferenceIterator getReferenceIteratorTo() {
|
||||
return new ReferenceIteratorAdapter(
|
||||
getTrace().getReferenceManager()
|
||||
.getReferencesTo(getStartSnap(), getAddress())
|
||||
.iterator());
|
||||
return new ReferenceIteratorAdapter(getTrace().getReferenceManager()
|
||||
.getReferencesTo(getStartSnap(), getAddress())
|
||||
.iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -377,9 +373,8 @@ public interface DBTraceCodeUnitAdapter extends TraceCodeUnit, MemBufferMixin {
|
|||
|
||||
@Override
|
||||
default void removeOperandReference(int index, Address refAddr) {
|
||||
TraceReference ref =
|
||||
getTrace().getReferenceManager()
|
||||
.getReference(getStartSnap(), getAddress(), refAddr, index);
|
||||
TraceReference ref = getTrace().getReferenceManager()
|
||||
.getReference(getStartSnap(), getAddress(), refAddr, index);
|
||||
if (ref == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,11 +347,12 @@ 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),
|
||||
rng -> getTopCodeIterator(
|
||||
s -> codeOperations.codeUnits().get(s, rng, forward).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)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -377,11 +370,12 @@ 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),
|
||||
rng -> getTopCodeIterator(
|
||||
s -> codeOperations.codeUnits().get(s, rng, forward).iterator(),
|
||||
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)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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(
|
||||
s -> program.trace.getCommentAdapter().getAddressSetView(Lifespan.at(s)))
|
||||
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[] {};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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,13 +363,10 @@ 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) {
|
||||
fail("It appears a new comment type was added");
|
||||
}
|
||||
public void testDetectNewCommentTypes() {
|
||||
for (CommentType type : CommentType.values()) {
|
||||
if (type.ordinal() > CommentType.REPEATABLE.ordinal()) {
|
||||
fail("It appears a new comment type was added");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -399,28 +395,28 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
// pass
|
||||
}
|
||||
|
||||
assertNull(i4004.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertNull(i4004.getComment(CommentType.EOL));
|
||||
try (Transaction tx = b.startTransaction()) {
|
||||
i4004.setComment(CodeUnit.EOL_COMMENT, "My EOL Comment");
|
||||
i4004.setComment(CommentType.EOL, "My EOL Comment");
|
||||
}
|
||||
assertEquals("My EOL Comment", i4004.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertNull(i4006.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertEquals("My EOL Comment", i4004.getComment(CommentType.EOL));
|
||||
assertNull(i4006.getComment(CommentType.EOL));
|
||||
|
||||
assertArrayEquals(EMPTY_STRING_ARRAY, i4004.getCommentAsArray(CodeUnit.PRE_COMMENT));
|
||||
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(CodeUnit.EOL_COMMENT));
|
||||
assertEquals("My EOL Comment", i4004.getComment(CommentType.EOL));
|
||||
assertArrayEquals(new String[] { "My", "Pre", "Comment" },
|
||||
i4004.getCommentAsArray(CodeUnit.PRE_COMMENT));
|
||||
assertArrayEquals(EMPTY_STRING_ARRAY, i4006.getCommentAsArray(CodeUnit.PRE_COMMENT));
|
||||
assertEquals("My\nPre\nComment", i4004.getComment(CodeUnit.PRE_COMMENT));
|
||||
i4004.getCommentAsArray(CommentType.PRE));
|
||||
assertArrayEquals(EMPTY_STRING_ARRAY, i4006.getCommentAsArray(CommentType.PRE));
|
||||
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(CodeUnit.PRE_COMMENT));
|
||||
assertNull(i4004.getComment(CommentType.PRE));
|
||||
|
||||
TraceInstruction i4004_10;
|
||||
DBTraceCommentAdapter commentAdapter = b.trace.getCommentAdapter();
|
||||
|
@ -436,25 +432,24 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
|
|||
assertEquals(Lifespan.nowOn(0), c4004.getLifespan());
|
||||
|
||||
i4004_10 = b.addInstruction(10, b.addr(0x4004), b.host);
|
||||
i4004_10.setComment(CodeUnit.PRE_COMMENT, "Get this back in the mix");
|
||||
i4004_10.setComment(CodeUnit.EOL_COMMENT, "A different comment");
|
||||
i4004_10.setComment(CommentType.PRE, "Get this back in the mix");
|
||||
i4004_10.setComment(CommentType.EOL, "A different comment");
|
||||
}
|
||||
assertEquals(Lifespan.span(0, 9), c4004.getLifespan());
|
||||
assertEquals("My EOL Comment", i4004.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertEquals("My EOL Comment", i4004.getComment(CommentType.EOL));
|
||||
|
||||
try (Transaction tx = b.startTransaction()) {
|
||||
commentAdapter.clearComments(Lifespan.nowOn(0), b.range(0x4000, 0x5000),
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
}
|
||||
assertNull(i4004.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertEquals("Get this back in the mix", i4004_10.getComment(CodeUnit.PRE_COMMENT));
|
||||
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(CodeUnit.EOL_COMMENT));
|
||||
assertNull(i4004_10.getComment(CodeUnit.PRE_COMMENT));
|
||||
assertNull(i4004.getComment(CommentType.EOL));
|
||||
assertNull(i4004_10.getComment(CommentType.PRE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -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));
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/* ###
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -18,17 +17,16 @@
|
|||
|
||||
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 {
|
||||
|
||||
@Override
|
||||
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!" );
|
||||
}
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
Address minAddress = currentProgram.getMinAddress();
|
||||
Listing listing = currentProgram.getListing();
|
||||
CodeUnit codeUnit = listing.getCodeUnitAt(minAddress);
|
||||
codeUnit.setComment(CommentType.PLATE,
|
||||
"AddCommentToProgramScript - This is an added comment!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
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.listing.Instruction;
|
||||
import ghidra.program.model.symbol.*;
|
||||
|
||||
|
@ -147,14 +147,14 @@ public class AutoRenameSimpleLabels extends GhidraScript {
|
|||
|
||||
// now also propogate the repeatable comment up as well
|
||||
|
||||
String comment = currentProgram.getListing().getComment(CodeUnit.REPEATABLE_COMMENT,
|
||||
operand_addr);
|
||||
String comment =
|
||||
currentProgram.getListing().getComment(CommentType.REPEATABLE, operand_addr);
|
||||
if (comment != null) {
|
||||
if (currentProgram.getListing().getComment(CodeUnit.REPEATABLE_COMMENT,
|
||||
startAddr) == null) {
|
||||
if (currentProgram.getListing()
|
||||
.getComment(CommentType.REPEATABLE, startAddr) == null) {
|
||||
//println("updating comment for " + operand +" is " + comment);
|
||||
currentProgram.getListing().setComment(startAddr,
|
||||
CodeUnit.REPEATABLE_COMMENT, comment);
|
||||
currentProgram.getListing()
|
||||
.setComment(startAddr, CommentType.REPEATABLE, comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -19,37 +19,37 @@
|
|||
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.Listing;
|
||||
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 {
|
||||
public void run() throws Exception {
|
||||
Listing listing = currentProgram.getListing();
|
||||
AddressSetView set = currentProgram.getMemory();
|
||||
if (currentSelection != null && !currentSelection.isEmpty()) {
|
||||
set = currentSelection;
|
||||
}
|
||||
int updateCount=0;
|
||||
AddressIterator iter = listing.getCommentAddressIterator(CodeUnit.PLATE_COMMENT, set, true);
|
||||
int updateCount = 0;
|
||||
AddressIterator iter = listing.getCommentAddressIterator(CommentType.PLATE, set, true);
|
||||
while (iter.hasNext()) {
|
||||
Address addr = iter.next();
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr);
|
||||
if (cu != null) {
|
||||
String[] comment = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
|
||||
String[] comment = cu.getCommentAsArray(CommentType.PLATE);
|
||||
if (comment.length == 1 && comment[0].equals(DEAD_PLATE)) {
|
||||
cu.setComment(CodeUnit.PLATE_COMMENT, null);
|
||||
cu.setComment(CommentType.PLATE, null);
|
||||
++updateCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updateCount > 0) {
|
||||
String cmt = updateCount > 1? "comments" : "comment";
|
||||
String cmt = updateCount > 1 ? "comments" : "comment";
|
||||
println("Removed " + updateCount + " default plate " + cmt + ".");
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -19,37 +19,37 @@
|
|||
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.Listing;
|
||||
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 {
|
||||
public void run() throws Exception {
|
||||
Listing listing = currentProgram.getListing();
|
||||
AddressSetView set = currentProgram.getMemory();
|
||||
if (currentSelection != null && !currentSelection.isEmpty()) {
|
||||
set = currentSelection;
|
||||
}
|
||||
int updateCount=0;
|
||||
AddressIterator iter = listing.getCommentAddressIterator(CodeUnit.PLATE_COMMENT, set, true);
|
||||
int updateCount = 0;
|
||||
AddressIterator iter = listing.getCommentAddressIterator(CommentType.PLATE, set, true);
|
||||
while (iter.hasNext()) {
|
||||
Address addr = iter.next();
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr);
|
||||
if (cu != null) {
|
||||
String[] comment = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
|
||||
String[] comment = cu.getCommentAsArray(CommentType.PLATE);
|
||||
if (comment.length == 1 && comment[0].equals(EMPTY_PLATE)) {
|
||||
cu.setComment(CodeUnit.PLATE_COMMENT, null);
|
||||
cu.setComment(CommentType.PLATE, null);
|
||||
++updateCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updateCount > 0) {
|
||||
String cmt = updateCount > 1? "comments" : "comment";
|
||||
String cmt = updateCount > 1 ? "comments" : "comment";
|
||||
println("Removed " + updateCount + " emtpy plate " + cmt + ".");
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -18,38 +18,36 @@
|
|||
//@category Update
|
||||
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressIterator;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.Listing;
|
||||
import ghidra.program.model.address.*;
|
||||
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 {
|
||||
public void run() throws Exception {
|
||||
Listing listing = currentProgram.getListing();
|
||||
AddressSetView set = currentProgram.getMemory();
|
||||
if (currentSelection != null && !currentSelection.isEmpty()) {
|
||||
set = currentSelection;
|
||||
}
|
||||
int updateCount=0;
|
||||
AddressIterator iter = listing.getCommentAddressIterator(CodeUnit.POST_COMMENT, set, true);
|
||||
int updateCount = 0;
|
||||
AddressIterator iter = listing.getCommentAddressIterator(CommentType.POST, set, true);
|
||||
while (iter.hasNext()) {
|
||||
Address addr = iter.next();
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr);
|
||||
String[] comment = cu.getCommentAsArray(CodeUnit.POST_COMMENT);
|
||||
String[] comment = cu.getCommentAsArray(CommentType.POST);
|
||||
if (comment.length == 1 && comment[0].endsWith(EXIT_COMMENT)) {
|
||||
cu.setComment(CodeUnit.POST_COMMENT, null);
|
||||
cu.setComment(CommentType.POST, null);
|
||||
++updateCount;
|
||||
}
|
||||
}
|
||||
if (updateCount > 0) {
|
||||
String cmt = updateCount > 1? "comments" : "comment";
|
||||
String cmt = updateCount > 1 ? "comments" : "comment";
|
||||
println("Removed " + updateCount + " exit post " + cmt + ".");
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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());
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/* ###
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -19,168 +18,141 @@
|
|||
// 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.*;
|
||||
|
||||
import java.util.*;
|
||||
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 {
|
||||
Listing l = this.currentProgram.getListing();
|
||||
|
||||
@Override
|
||||
public void run() throws Exception
|
||||
{
|
||||
Listing l = this.currentProgram.getListing();
|
||||
if (this.askYesNo("Function Analysis - Register Touches", "Analyze complete listing?")) {
|
||||
FunctionIterator fi = l.getFunctions(true);
|
||||
while (fi.hasNext() && !monitor.isCancelled()) {
|
||||
doAnalysis(l, fi.next());
|
||||
}
|
||||
}
|
||||
else {
|
||||
doAnalysis(l, l.getFunctionContaining(this.currentAddress));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.askYesNo("Function Analysis - Register Touches",
|
||||
"Analyze complete listing?"))
|
||||
{
|
||||
FunctionIterator fi = l.getFunctions(true);
|
||||
while (fi.hasNext() && !monitor.isCancelled())
|
||||
{
|
||||
doAnalysis(l, fi.next());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doAnalysis(l, l.getFunctionContaining(this.currentAddress));
|
||||
}
|
||||
}
|
||||
private void doAnalysis(Listing list, Function func) {
|
||||
if (func == null) {
|
||||
println("No function to analyze.");
|
||||
return;
|
||||
}
|
||||
HashSet<String> affected, accessed;
|
||||
Vector<String> restored;
|
||||
Stack<String> pushPops;
|
||||
boolean reviewRestored = false;
|
||||
Instruction inst;
|
||||
InstructionIterator iIter;
|
||||
|
||||
private void doAnalysis(Listing list, Function func)
|
||||
{
|
||||
if (func == null) {
|
||||
println("No function to analyze.");
|
||||
return;
|
||||
}
|
||||
HashSet<String> affected, accessed;
|
||||
Vector<String> restored;
|
||||
Stack<String> pushPops;
|
||||
boolean reviewRestored = false;
|
||||
Instruction inst;
|
||||
InstructionIterator iIter;
|
||||
|
||||
monitor.setMessage("Analyzing registers in " + func.getName());
|
||||
monitor.setMessage("Analyzing registers in " + func.getName());
|
||||
|
||||
String comment = list.getComment(CodeUnit.PLATE_COMMENT, func.getBody().getMinAddress());
|
||||
String comment = list.getComment(CommentType.PLATE, func.getBody().getMinAddress());
|
||||
|
||||
if (comment != null && comment.indexOf("TOUCHED REGISTER SUMMARY") > -1)
|
||||
return;
|
||||
if (comment != null && comment.indexOf("TOUCHED REGISTER SUMMARY") > -1)
|
||||
return;
|
||||
|
||||
pushPops = new Stack<String>();
|
||||
affected = new HashSet<String>();
|
||||
accessed = new HashSet<String>();
|
||||
restored = new Vector<String>();
|
||||
pushPops = new Stack<String>();
|
||||
affected = new HashSet<String>();
|
||||
accessed = new HashSet<String>();
|
||||
restored = new Vector<String>();
|
||||
|
||||
iIter = list.getInstructions(func.getBody(), true);
|
||||
|
||||
while (iIter.hasNext() && !monitor.isCancelled())
|
||||
{
|
||||
inst = iIter.next();
|
||||
iIter = list.getInstructions(func.getBody(), true);
|
||||
|
||||
Object o[] = inst.getResultObjects();
|
||||
for (int i = 0; i < o.length; i++)
|
||||
{
|
||||
if (o[i] instanceof Register)
|
||||
{
|
||||
String name = ((Register) o[i]).getName();
|
||||
while (iIter.hasNext() && !monitor.isCancelled()) {
|
||||
inst = iIter.next();
|
||||
|
||||
if (inst.getMnemonicString().equalsIgnoreCase("pop"))
|
||||
{
|
||||
if (!name.equalsIgnoreCase("mult_addr")
|
||||
&& !name.equalsIgnoreCase("sp"))
|
||||
{
|
||||
if (pushPops.size() > 0)
|
||||
{
|
||||
restored.add(pushPops.pop() + "->" + name);
|
||||
}
|
||||
else
|
||||
{
|
||||
reviewRestored = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
affected.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
o = inst.getInputObjects();
|
||||
Object o[] = inst.getResultObjects();
|
||||
for (Object element : o) {
|
||||
if (element instanceof Register) {
|
||||
String name = ((Register) element).getName();
|
||||
|
||||
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"))
|
||||
{
|
||||
pushPops.push(name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
accessed.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inst.getMnemonicString().equalsIgnoreCase("pop")) {
|
||||
if (!name.equalsIgnoreCase("mult_addr") && !name.equalsIgnoreCase("sp")) {
|
||||
if (pushPops.size() > 0) {
|
||||
restored.add(pushPops.pop() + "->" + name);
|
||||
}
|
||||
else {
|
||||
reviewRestored = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
affected.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
o = inst.getInputObjects();
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if (comment != null) {
|
||||
buffer.append(comment);
|
||||
buffer.append("\r\n");
|
||||
buffer.append(DIVIDER);
|
||||
}
|
||||
buffer.append("TOUCHED REGISTER SUMMARY:\r\n");
|
||||
buffer.append(DIVIDER);
|
||||
buffer.append("Register(s) Affected:\r\n");
|
||||
buffer.append(getString(affected, 8));
|
||||
buffer.append(DIVIDER);
|
||||
buffer.append("Register(s) Accessed:\r\n");
|
||||
buffer.append(getString(accessed, 8));
|
||||
buffer.append(DIVIDER);
|
||||
buffer.append("Register(s) Restored:\r\n");
|
||||
buffer.append(getString(restored, 4));
|
||||
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 {
|
||||
accessed.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if (comment != null) {
|
||||
buffer.append(comment);
|
||||
buffer.append("\r\n");
|
||||
buffer.append(DIVIDER);
|
||||
}
|
||||
buffer.append("TOUCHED REGISTER SUMMARY:\r\n");
|
||||
buffer.append(DIVIDER);
|
||||
buffer.append("Register(s) Affected:\r\n");
|
||||
buffer.append(getString(affected, 8));
|
||||
buffer.append(DIVIDER);
|
||||
buffer.append("Register(s) Accessed:\r\n");
|
||||
buffer.append(getString(accessed, 8));
|
||||
buffer.append(DIVIDER);
|
||||
buffer.append("Register(s) Restored:\r\n");
|
||||
buffer.append(getString(restored, 4));
|
||||
|
||||
if (pushPops.size() > 0)
|
||||
{
|
||||
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);
|
||||
|
||||
buffer.append("Registers Remaining on Stack:\r\n");
|
||||
buffer.append(" "+getString(pushPops, 8));
|
||||
}
|
||||
if (pushPops.size() > 0) {
|
||||
|
||||
list.setComment(func.getEntryPoint(), CodeUnit.PLATE_COMMENT, buffer.toString());
|
||||
}
|
||||
buffer.append("Registers Remaining on Stack:\r\n");
|
||||
buffer.append(" " + getString(pushPops, 8));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
commaCount++;
|
||||
if (commaCount % itemsPerLine == 0)
|
||||
temp = temp.substring(0, i + 1) + "\r\n"
|
||||
+ temp.substring(i + 1).trim();
|
||||
}
|
||||
list.setComment(func.getEntryPoint(), CommentType.PLATE, buffer.toString());
|
||||
}
|
||||
|
||||
return temp + "\r\n";
|
||||
}
|
||||
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) {
|
||||
commaCount++;
|
||||
if (commaCount % itemsPerLine == 0)
|
||||
temp = temp.substring(0, i + 1) + "\r\n" + temp.substring(i + 1).trim();
|
||||
}
|
||||
|
||||
return temp + "\r\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -38,7 +38,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.listing.Listing;
|
||||
import ghidra.program.model.mem.Memory;
|
||||
import ghidra.program.model.symbol.*;
|
||||
|
@ -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();
|
||||
|
@ -99,9 +99,9 @@ public class ZapBCTRScript extends GhidraScript {
|
|||
|
||||
// insert funcName as EOL comment and
|
||||
// add a mnemonic ref from instAddr to funcAddr
|
||||
listing.setComment(instAddr, CodeUnit.EOL_COMMENT, funcName);
|
||||
listing.getInstructionAt(instAddr).addMnemonicReference(funcAddr, RefType.COMPUTED_CALL,
|
||||
SourceType.USER_DEFINED);
|
||||
listing.setComment(instAddr, CommentType.EOL, funcName);
|
||||
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);
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -325,24 +325,24 @@ public class CodeUnitInfoPasteCmd implements Command<Program> {
|
|||
String[] repeatableComment = info.getRepeatableComment();
|
||||
|
||||
if (plateComment != null) {
|
||||
String[] oldComment = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
|
||||
cu.setCommentAsArray(CodeUnit.PLATE_COMMENT, appendComment(oldComment, plateComment));
|
||||
String[] oldComment = cu.getCommentAsArray(CommentType.PLATE);
|
||||
cu.setCommentAsArray(CommentType.PLATE, appendComment(oldComment, plateComment));
|
||||
}
|
||||
if (preComment != null) {
|
||||
String[] oldComment = cu.getCommentAsArray(CodeUnit.PRE_COMMENT);
|
||||
cu.setCommentAsArray(CodeUnit.PRE_COMMENT, appendComment(oldComment, preComment));
|
||||
String[] oldComment = cu.getCommentAsArray(CommentType.PRE);
|
||||
cu.setCommentAsArray(CommentType.PRE, appendComment(oldComment, preComment));
|
||||
}
|
||||
if (postComment != null) {
|
||||
String[] oldComment = cu.getCommentAsArray(CodeUnit.POST_COMMENT);
|
||||
cu.setCommentAsArray(CodeUnit.POST_COMMENT, appendComment(oldComment, postComment));
|
||||
String[] oldComment = cu.getCommentAsArray(CommentType.POST);
|
||||
cu.setCommentAsArray(CommentType.POST, appendComment(oldComment, postComment));
|
||||
}
|
||||
if (eolComment != null) {
|
||||
String[] oldComment = cu.getCommentAsArray(CodeUnit.EOL_COMMENT);
|
||||
cu.setCommentAsArray(CodeUnit.EOL_COMMENT, appendComment(oldComment, eolComment));
|
||||
String[] oldComment = cu.getCommentAsArray(CommentType.EOL);
|
||||
cu.setCommentAsArray(CommentType.EOL, appendComment(oldComment, eolComment));
|
||||
}
|
||||
if (repeatableComment != null) {
|
||||
String[] oldComment = cu.getCommentAsArray(CodeUnit.REPEATABLE_COMMENT);
|
||||
cu.setCommentAsArray(CodeUnit.REPEATABLE_COMMENT,
|
||||
String[] oldComment = cu.getCommentAsArray(CommentType.REPEATABLE);
|
||||
cu.setCommentAsArray(CommentType.REPEATABLE,
|
||||
appendComment(oldComment, repeatableComment));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import ghidra.program.model.listing.*;
|
|||
public class SetCommentCmd implements Command<Program> {
|
||||
|
||||
private Address address;
|
||||
private int commentType;
|
||||
private CommentType commentType;
|
||||
private String comment;
|
||||
private String cmdName;
|
||||
private String message;
|
||||
|
@ -37,7 +37,18 @@ public class SetCommentCmd implements Command<Program> {
|
|||
* @param commentType valid comment type (see CodeUnit)
|
||||
* @param comment comment for code unit
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "11.4")
|
||||
public SetCommentCmd(Address addr, int commentType, String comment) {
|
||||
this(addr, CommentType.valueOf(commentType), comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct command
|
||||
* @param addr address of code unit where comment will be placed
|
||||
* @param commentType valid comment type (see CodeUnit)
|
||||
* @param comment comment for code unit
|
||||
*/
|
||||
public SetCommentCmd(Address addr, CommentType commentType, String comment) {
|
||||
this.address = addr;
|
||||
this.commentType = commentType;
|
||||
this.comment = comment;
|
||||
|
@ -112,12 +123,11 @@ 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 CodeUnit#PLATE_COMMENT},
|
||||
* {@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,
|
||||
int commentType) {
|
||||
CommentType commentType) {
|
||||
SetCommentCmd commentCmd = new SetCommentCmd(addr, commentType, comment);
|
||||
commentCmd.applyTo(program);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -83,31 +83,31 @@ public class SetCommentsCmd implements Command<Program> {
|
|||
CodeUnit cu = getCodeUnit(program);
|
||||
|
||||
if (cu != null) {
|
||||
if (commentChanged(cu.getComment(CodeUnit.PRE_COMMENT), preComment)) {
|
||||
if (commentChanged(cu.getComment(CommentType.PRE), preComment)) {
|
||||
String updatedPreComment = CommentUtils.fixupAnnotations(preComment, program);
|
||||
updatedPreComment = CommentUtils.sanitize(updatedPreComment);
|
||||
cu.setComment(CodeUnit.PRE_COMMENT, updatedPreComment);
|
||||
cu.setComment(CommentType.PRE, updatedPreComment);
|
||||
}
|
||||
if (commentChanged(cu.getComment(CodeUnit.POST_COMMENT), postComment)) {
|
||||
if (commentChanged(cu.getComment(CommentType.POST), postComment)) {
|
||||
String updatedPostComment = CommentUtils.fixupAnnotations(postComment, program);
|
||||
updatedPostComment = CommentUtils.sanitize(updatedPostComment);
|
||||
cu.setComment(CodeUnit.POST_COMMENT, updatedPostComment);
|
||||
cu.setComment(CommentType.POST, updatedPostComment);
|
||||
}
|
||||
if (commentChanged(cu.getComment(CodeUnit.EOL_COMMENT), eolComment)) {
|
||||
if (commentChanged(cu.getComment(CommentType.EOL), eolComment)) {
|
||||
String updatedEOLComment = CommentUtils.fixupAnnotations(eolComment, program);
|
||||
updatedEOLComment = CommentUtils.sanitize(updatedEOLComment);
|
||||
cu.setComment(CodeUnit.EOL_COMMENT, updatedEOLComment);
|
||||
cu.setComment(CommentType.EOL, updatedEOLComment);
|
||||
}
|
||||
if (commentChanged(cu.getComment(CodeUnit.PLATE_COMMENT), plateComment)) {
|
||||
if (commentChanged(cu.getComment(CommentType.PLATE), plateComment)) {
|
||||
String updatedPlateComment = CommentUtils.fixupAnnotations(plateComment, program);
|
||||
updatedPlateComment = CommentUtils.sanitize(updatedPlateComment);
|
||||
cu.setComment(CodeUnit.PLATE_COMMENT, updatedPlateComment);
|
||||
cu.setComment(CommentType.PLATE, updatedPlateComment);
|
||||
}
|
||||
if (commentChanged(cu.getComment(CodeUnit.REPEATABLE_COMMENT), repeatableComment)) {
|
||||
if (commentChanged(cu.getComment(CommentType.REPEATABLE), repeatableComment)) {
|
||||
String updatedRepeatableComment =
|
||||
CommentUtils.fixupAnnotations(repeatableComment, program);
|
||||
updatedRepeatableComment = CommentUtils.sanitize(updatedRepeatableComment);
|
||||
cu.setComment(CodeUnit.REPEATABLE_COMMENT, updatedRepeatableComment);
|
||||
cu.setComment(CommentType.REPEATABLE, updatedRepeatableComment);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -184,7 +184,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
|
|||
createFragment(sectionDT.getName(), sectionStart, sectionDT.getLength());
|
||||
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr(offset));
|
||||
cu.setComment(CodeUnit.PLATE_COMMENT,
|
||||
cu.setComment(CommentType.PLATE,
|
||||
"#" + i + ") " + name + " at 0x" + Long.toHexString(sections[i].getAddress()));
|
||||
|
||||
if (sections[i].getType() == ElfSectionHeaderConstants.SHT_NOBITS ||
|
||||
|
@ -203,7 +203,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
|
|||
}
|
||||
|
||||
cu = listing.getCodeUnitAt(dataStart);
|
||||
cu.setComment(CodeUnit.PRE_COMMENT, sections[i].getNameAsString() + " Size: 0x" +
|
||||
cu.setComment(CommentType.PRE, sections[i].getNameAsString() + " Size: 0x" +
|
||||
Long.toHexString(sections[i].getSize()));
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
|
|||
for (int i = 0; i < programHeaders.length; i++) {
|
||||
monitor.checkCancelled();
|
||||
Data d = array.getComponent(i);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, programHeaders[i].getComment());
|
||||
d.setComment(CommentType.EOL, programHeaders[i].getComment());
|
||||
|
||||
Address addr = addr(programHeaders[i].getOffset());
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -292,7 +292,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
|
|||
dynamicType != null ? (dynamicType.name + " - " + dynamicType.description)
|
||||
: ("DT_0x" + StringUtilities.pad(Integer.toHexString(tagType), '0', 8));
|
||||
|
||||
dynamicData.setComment(CodeUnit.EOL_COMMENT, comment);
|
||||
dynamicData.setComment(CommentType.EOL, comment);
|
||||
|
||||
Data valueData = dynamicData.getComponent(1);
|
||||
|
||||
|
@ -323,7 +323,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
|
|||
if (dynamicStringTable != null) {
|
||||
String str = dynamicStringTable.readString(reader, dynamic.getValue());
|
||||
if (str != null && str.length() != 0) {
|
||||
data.setComment(CodeUnit.EOL_COMMENT, str);
|
||||
data.setComment(CommentType.EOL, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -384,7 +384,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
|
|||
|
||||
try {
|
||||
Address currAddr = symbolTableAddr.add(j * symbolTable2.getEntrySize());
|
||||
listing.setComment(currAddr, CodeUnit.EOL_COMMENT,
|
||||
listing.setComment(currAddr, CommentType.EOL,
|
||||
name + " at 0x" + Long.toHexString(symbols[j].getValue()));
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -418,7 +418,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
|
|||
createData(relocationTableAddress, dataType);
|
||||
}
|
||||
else {
|
||||
listing.setComment(relocationTableAddress, CodeUnit.PRE_COMMENT,
|
||||
listing.setComment(relocationTableAddress, CommentType.PRE,
|
||||
"ELF Relocation Table (markup not yet supported)");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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) */
|
||||
|
@ -194,7 +195,7 @@ public class CliMetadataTokenAnalyzer extends AbstractAnalyzer {
|
|||
|
||||
int strIndex = (int) strIndexOp.getUnsignedValue();
|
||||
|
||||
inst.setComment(CodeUnit.EOL_COMMENT,
|
||||
inst.setComment(CommentType.EOL,
|
||||
"\"" + metaStream.getUserStringsStream().getUserString(strIndex) + "\"");
|
||||
}
|
||||
|
||||
|
@ -229,7 +230,7 @@ public class CliMetadataTokenAnalyzer extends AbstractAnalyzer {
|
|||
|
||||
private void markMetadataRow(Instruction inst, CliAbstractTableRow tableRow,
|
||||
String prependComment, String appendComment, CliStreamMetadata stream) {
|
||||
inst.setComment(CodeUnit.EOL_COMMENT, String.format("%s%s%s", prependComment,
|
||||
inst.setComment(CommentType.EOL, String.format("%s%s%s", prependComment,
|
||||
tableRow.getShortRepresentation(stream), appendComment));
|
||||
}
|
||||
|
||||
|
|
|
@ -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,9 +456,9 @@ 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())
|
||||
: null;
|
||||
Function duffzeroFunc =
|
||||
duffzeroFuncdata != null ? funcMgr.getFunctionAt(duffzeroFuncdata.getFuncAddress())
|
||||
: null;
|
||||
List<Variable> duffzeroParams = regInfo.getDuffzeroParams(program);
|
||||
if (duffzeroFunc != null && !duffzeroParams.isEmpty()) {
|
||||
// NOTE: some go archs don't create duffzero functions. See
|
||||
|
@ -489,15 +485,14 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
|
|||
}
|
||||
|
||||
GoFuncData duffcopyFuncdata = goBinary.getFunctionByName("runtime.duffcopy");
|
||||
Function duffcopyFunc = duffcopyFuncdata != null
|
||||
? funcMgr.getFunctionAt(duffcopyFuncdata.getFuncAddress())
|
||||
: null;
|
||||
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),
|
||||
new ParameterImpl("src", 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,
|
||||
FunctionUpdateType.DYNAMIC_STORAGE_ALL_PARAMS, true, SourceType.ANALYSIS);
|
||||
|
@ -672,13 +667,13 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
|
|||
func.setName(duffFunc.getName() + "_" + func.getEntryPoint(),
|
||||
SourceType.ANALYSIS);
|
||||
func.setParentNamespace(funcNS);
|
||||
FunctionUpdateType fut = duffFunc.hasCustomVariableStorage()
|
||||
? FunctionUpdateType.CUSTOM_STORAGE
|
||||
: FunctionUpdateType.DYNAMIC_STORAGE_ALL_PARAMS;
|
||||
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);
|
||||
if (duffComment != null && !duffComment.isBlank()) {
|
||||
new SetCommentCmd(func.getEntryPoint(), CodeUnit.PLATE_COMMENT, duffComment)
|
||||
new SetCommentCmd(func.getEntryPoint(), CommentType.PLATE, duffComment)
|
||||
.applyTo(program);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -62,9 +62,8 @@ 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 " +
|
||||
program.getDomainFile());
|
||||
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;
|
||||
}
|
||||
|
@ -410,7 +404,7 @@ class MinGWPseudoRelocationHandler {
|
|||
else {
|
||||
// TODO: Not sure how to preserve relationship to external symbol
|
||||
// which refers to Library
|
||||
listing.setComment(nextExtAddr, CodeUnit.PLATE_COMMENT,
|
||||
listing.setComment(nextExtAddr, CommentType.PLATE,
|
||||
"External Location: " + extSym.getName(true));
|
||||
String name = extLoc.getOriginalImportedName();
|
||||
boolean demangle = true;
|
||||
|
@ -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(
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -31,7 +31,7 @@ import ghidra.util.task.TaskMonitor;
|
|||
|
||||
public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
|
||||
private static final String DESCRIPTION =
|
||||
"An analyzer for extracting _objc_msgSend information.";
|
||||
"An analyzer for extracting _objc_msgSend information.";
|
||||
|
||||
private static final String NAME = "Objective-C Message";
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
|
|||
return;
|
||||
}
|
||||
InstructionIterator instructionIterator =
|
||||
program.getListing().getInstructions(function.getBody(), true);
|
||||
program.getListing().getInstructions(function.getBody(), true);
|
||||
while (instructionIterator.hasNext()) {
|
||||
if (monitor.isCancelled()) {
|
||||
break;
|
||||
|
@ -96,7 +96,7 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
|
|||
Instruction instruction = instructionIterator.next();
|
||||
|
||||
if (isCallingObjcMsgSend(instruction)) {
|
||||
String eolComment = instruction.getComment(CodeUnit.EOL_COMMENT);
|
||||
String eolComment = instruction.getComment(CommentType.EOL);
|
||||
|
||||
if (eolComment != null) {//if a comment already exists, ignore...
|
||||
continue;
|
||||
|
@ -126,8 +126,8 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
|
|||
private boolean isObjcNameMatch(Symbol symbol) {
|
||||
String name = symbol.getName();
|
||||
return name.startsWith(ObjectiveC1_Constants.OBJC_MSG_SEND) ||
|
||||
name.equals(ObjectiveC1_Constants.READ_UNIX2003) ||
|
||||
name.startsWith("thunk" + ObjectiveC1_Constants.OBJC_MSG_SEND);
|
||||
name.equals(ObjectiveC1_Constants.READ_UNIX2003) ||
|
||||
name.startsWith("thunk" + ObjectiveC1_Constants.OBJC_MSG_SEND);
|
||||
}
|
||||
|
||||
private class CurrentState {
|
||||
|
@ -224,7 +224,7 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
|
|||
pullNameThrough(state, toAddress, null);
|
||||
|
||||
if (state.isValid()) {
|
||||
instruction.setComment(CodeUnit.EOL_COMMENT, state.toString());
|
||||
instruction.setComment(CommentType.EOL, state.toString());
|
||||
setReference(fromAddress, state);
|
||||
break;
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
|
|||
|
||||
private boolean isClassBlock(MemoryBlock block) {
|
||||
return block.getName().equals(ObjectiveC1_Constants.OBJC_SECTION_CLASS_REFS) ||
|
||||
block.getName().equals(ObjectiveC1_Constants.OBJC_SECTION_CLASS);
|
||||
block.getName().equals(ObjectiveC1_Constants.OBJC_SECTION_CLASS);
|
||||
}
|
||||
|
||||
private boolean isValidInstruction(Instruction instruction) {
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -44,6 +44,7 @@ public class ObjectiveC2_MessageAnalyzer extends AbstractAnalyzer {
|
|||
setPriority(AnalysisPriority.FORMAT_ANALYSIS.after());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean added(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log)
|
||||
throws CancelledException {
|
||||
AddressIterator iterator = set.getAddresses(true);
|
||||
|
@ -63,6 +64,7 @@ public class ObjectiveC2_MessageAnalyzer extends AbstractAnalyzer {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAnalyze(Program program) {
|
||||
return ObjectiveC2_Constants.isObjectiveC2(program);
|
||||
}
|
||||
|
@ -81,7 +83,7 @@ public class ObjectiveC2_MessageAnalyzer extends AbstractAnalyzer {
|
|||
Instruction instruction = instructionIterator.next();
|
||||
|
||||
if (isCallingObjcMsgSend(instruction)) {
|
||||
String eolComment = instruction.getComment(CodeUnit.EOL_COMMENT);
|
||||
String eolComment = instruction.getComment(CommentType.EOL);
|
||||
|
||||
if (eolComment != null) {//if a comment already exists, ignore...
|
||||
continue;
|
||||
|
@ -194,8 +196,8 @@ public class ObjectiveC2_MessageAnalyzer extends AbstractAnalyzer {
|
|||
}
|
||||
|
||||
if (currentClass != null && currentMethod != null) {
|
||||
instruction.setComment(CodeUnit.EOL_COMMENT, "[" + currentClass + " " +
|
||||
currentMethod + "]");
|
||||
instruction.setComment(CommentType.EOL,
|
||||
"[" + currentClass + " " + currentMethod + "]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -185,7 +185,7 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
|
|||
}
|
||||
|
||||
private String getEolComment(CodeUnit codeUnit) {
|
||||
String comment = codeUnit.getComment(CodeUnit.EOL_COMMENT);
|
||||
String comment = codeUnit.getComment(CommentType.EOL);
|
||||
if (comment == null) {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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);
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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();
|
||||
|
|
|
@ -15,123 +15,129 @@
|
|||
*/
|
||||
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());
|
||||
}
|
||||
static {
|
||||
PluggableServiceRegistry.registerPluggableService(CommentsActionFactory.class,
|
||||
new CommentsActionFactory());
|
||||
}
|
||||
|
||||
public static DockingAction getSetCommentsAction(CommentsDialog dialog,
|
||||
String name, String actionName, int commentType) {
|
||||
CommentsActionFactory factory = PluggableServiceRegistry.getPluggableService(CommentsActionFactory.class);
|
||||
return factory.doGetSetCommentsAction(dialog, name, actionName, commentType);
|
||||
}
|
||||
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);
|
||||
return factory.doGetEditCommentsAction(dialog, name);
|
||||
}
|
||||
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);
|
||||
return factory.doIsCommentSupported(loc);
|
||||
public static boolean isCommentSupported(ProgramLocation loc) {
|
||||
CommentsActionFactory factory =
|
||||
PluggableServiceRegistry.getPluggableService(CommentsActionFactory.class);
|
||||
return factory.doIsCommentSupported(loc);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected DockingAction doGetSetCommentsAction(CommentsDialog dialog,
|
||||
String name, String actionName, int commentType) {
|
||||
return new SetCommentsAction(dialog, name, actionName, 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) {
|
||||
return new EditCommentsAction(dialog, name);
|
||||
}
|
||||
protected DockingAction doGetEditCommentsAction(CommentsDialog dialog, String name) {
|
||||
return new EditCommentsAction(dialog, name);
|
||||
}
|
||||
|
||||
protected boolean doIsCommentSupported(ProgramLocation loc) {
|
||||
if (loc == null || loc.getAddress() == null) {
|
||||
return false;
|
||||
}
|
||||
return ((loc instanceof CodeUnitLocation) || ((loc instanceof FunctionLocation) && !(loc instanceof VariableLocation)));
|
||||
}
|
||||
protected boolean doIsCommentSupported(ProgramLocation loc) {
|
||||
if (loc == null || loc.getAddress() == null) {
|
||||
return false;
|
||||
}
|
||||
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 static class SetCommentsAction extends DockingAction {
|
||||
private final CommentsDialog dialog;
|
||||
private final CommentType commentType; // may be null for Generic Comment
|
||||
|
||||
SetCommentsAction(CommentsDialog dialog, String name,
|
||||
String actionName, int commentType) {
|
||||
super(actionName, name);
|
||||
this.dialog = dialog;
|
||||
this.commentType = commentType;
|
||||
setPopupMenuData(new MenuData(new String[] { "Comments",
|
||||
actionName + "..." }, "comments"));
|
||||
setHelpLocation(new HelpLocation("CommentsPlugin", "Edit_Comments"));
|
||||
}
|
||||
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"));
|
||||
setHelpLocation(new HelpLocation("CommentsPlugin", "Edit_Comments"));
|
||||
}
|
||||
|
||||
protected int getEditCommentType(ActionContext context) {
|
||||
return commentType;
|
||||
}
|
||||
/**
|
||||
* {@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);
|
||||
dialog.showDialog(cu, type);
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionContext context) {
|
||||
CodeUnit cu = getCodeUnit(context);
|
||||
CommentType type = getEditCommentType(context);
|
||||
dialog.showDialog(cu, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForContext(ActionContext actionContext) {
|
||||
ProgramLocation loc = getLocationForContext(actionContext);
|
||||
if (!isCommentSupported(loc)) {
|
||||
return false;
|
||||
}
|
||||
return CommentTypeUtils.isCommentAllowed(getCodeUnit(actionContext), loc);
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabledForContext(ActionContext actionContext) {
|
||||
ProgramLocation loc = getLocationForContext(actionContext);
|
||||
if (!isCommentSupported(loc)) {
|
||||
return false;
|
||||
}
|
||||
return CommentTypeUtils.isCommentAllowed(getCodeUnit(actionContext), loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidContext(ActionContext context) {
|
||||
return (context instanceof ListingActionContext);
|
||||
}
|
||||
@Override
|
||||
public boolean isValidContext(ActionContext context) {
|
||||
return (context instanceof ListingActionContext);
|
||||
}
|
||||
|
||||
protected CodeUnit getCodeUnit(ActionContext actionContext) {
|
||||
ProgramLocationActionContext context = (ProgramLocationActionContext) actionContext;
|
||||
return context.getCodeUnit();
|
||||
}
|
||||
protected CodeUnit getCodeUnit(ActionContext actionContext) {
|
||||
ProgramLocationActionContext context = (ProgramLocationActionContext) actionContext;
|
||||
return context.getCodeUnit();
|
||||
}
|
||||
|
||||
protected ProgramLocation getLocationForContext(
|
||||
ActionContext actionContext) {
|
||||
ProgramLocationActionContext context = (ProgramLocationActionContext) actionContext;
|
||||
return context.getLocation();
|
||||
}
|
||||
}
|
||||
protected ProgramLocation getLocationForContext(ActionContext actionContext) {
|
||||
ProgramLocationActionContext context = (ProgramLocationActionContext) actionContext;
|
||||
return context.getLocation();
|
||||
}
|
||||
}
|
||||
|
||||
private static class EditCommentsAction extends SetCommentsAction {
|
||||
// Edit Comments Action info
|
||||
private final static String[] EDIT_MENUPATH = new String[] {
|
||||
"Comments", "Set..." };
|
||||
private static class EditCommentsAction extends SetCommentsAction {
|
||||
// Edit Comments Action info
|
||||
private final static String[] EDIT_MENUPATH = new String[] { "Comments", "Set..." };
|
||||
|
||||
EditCommentsAction(CommentsDialog dialog, String name) {
|
||||
super(dialog, name, "Edit Comments", CodeUnit.NO_COMMENT);
|
||||
setPopupMenuData(new MenuData(EDIT_MENUPATH, "comments"));
|
||||
setKeyBindingData(new KeyBindingData(KeyEvent.VK_SEMICOLON, 0));
|
||||
}
|
||||
EditCommentsAction(CommentsDialog dialog, String name) {
|
||||
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) {
|
||||
CodeUnit cu = getCodeUnit(context);
|
||||
return CommentTypeUtils.getCommentType(cu, getLocationForContext(context), CodeUnit.NO_COMMENT);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected CommentType getEditCommentType(ActionContext context) {
|
||||
CodeUnit cu = getCodeUnit(context);
|
||||
return CommentTypeUtils.getCommentType(cu, getLocationForContext(context), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,9 @@ import ghidra.app.util.viewer.field.AnnotatedStringHandler;
|
|||
import ghidra.app.util.viewer.field.CommentUtils;
|
||||
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.
|
||||
|
@ -89,15 +91,15 @@ 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;
|
||||
|
||||
preComment = cu.getComment(CodeUnit.PRE_COMMENT);
|
||||
postComment = cu.getComment(CodeUnit.POST_COMMENT);
|
||||
eolComment = cu.getComment(CodeUnit.EOL_COMMENT);
|
||||
plateComment = cu.getComment(CodeUnit.PLATE_COMMENT);
|
||||
repeatableComment = cu.getComment(CodeUnit.REPEATABLE_COMMENT);
|
||||
preComment = cu.getComment(CommentType.PRE);
|
||||
postComment = cu.getComment(CommentType.POST);
|
||||
eolComment = cu.getComment(CommentType.EOL);
|
||||
plateComment = cu.getComment(CommentType.PLATE);
|
||||
repeatableComment = cu.getComment(CommentType.REPEATABLE);
|
||||
|
||||
preComment = (preComment == null) ? "" : preComment;
|
||||
postComment = (postComment == null) ? "" : postComment;
|
||||
|
@ -133,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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -94,26 +94,26 @@ class CommentTableModel extends AddressBasedTableModel<CommentRowObject> {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (cu.getComment(CodeUnit.PRE_COMMENT) != null) {
|
||||
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.PRE_COMMENT));
|
||||
if (cu.getComment(CommentType.PRE) != null) {
|
||||
accumulator.add(new CommentRowObject(commentAddr, CommentType.PRE));
|
||||
}
|
||||
if (cu.getComment(CodeUnit.POST_COMMENT) != null) {
|
||||
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.POST_COMMENT));
|
||||
if (cu.getComment(CommentType.POST) != null) {
|
||||
accumulator.add(new CommentRowObject(commentAddr, CommentType.POST));
|
||||
}
|
||||
if (cu.getComment(CodeUnit.EOL_COMMENT) != null) {
|
||||
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.EOL_COMMENT));
|
||||
if (cu.getComment(CommentType.EOL) != null) {
|
||||
accumulator.add(new CommentRowObject(commentAddr, CommentType.EOL));
|
||||
}
|
||||
if (cu.getComment(CodeUnit.PLATE_COMMENT) != null) {
|
||||
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.PLATE_COMMENT));
|
||||
if (cu.getComment(CommentType.PLATE) != null) {
|
||||
accumulator.add(new CommentRowObject(commentAddr, CommentType.PLATE));
|
||||
}
|
||||
if (cu.getComment(CodeUnit.REPEATABLE_COMMENT) != null) {
|
||||
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.REPEATABLE_COMMENT));
|
||||
if (cu.getComment(CommentType.REPEATABLE) != null) {
|
||||
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;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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();
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -97,7 +97,6 @@ public class AddressTable {
|
|||
this.skipAmount = skipAmount;
|
||||
this.shiftedAddr = shiftedAddr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new address table from any remaining table entries starting at startPos
|
||||
|
@ -388,8 +387,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 {
|
||||
|
@ -472,8 +470,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);
|
||||
}
|
||||
|
||||
|
@ -496,7 +494,7 @@ public class AddressTable {
|
|||
}
|
||||
|
||||
if (comment != null) {
|
||||
program.getListing().setComment(topAddress, CodeUnit.EOL_COMMENT, comment);
|
||||
program.getListing().setComment(topAddress, CommentType.EOL, comment);
|
||||
}
|
||||
|
||||
if (flagNewCode && newCodeFound) {
|
||||
|
@ -574,8 +572,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
|
||||
|
@ -607,8 +606,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) {
|
||||
|
@ -1233,12 +1232,12 @@ public class AddressTable {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// undefined data is OK, could be a pointer
|
||||
if (data.getDataType() instanceof Undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// data intersects, calculate valid entries and stop looking
|
||||
if (pointerSet.intersects(dataAddr, data.getMaxAddress())) {
|
||||
count = (int) (dataAddr.subtract(topAddr) / (addrSize + skipAmount));
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -19,7 +19,7 @@ import ghidra.app.cmd.comments.SetCommentCmd;
|
|||
import ghidra.app.cmd.data.CreateDataCmd;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -100,12 +100,10 @@ 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 type of comment ({@link CodeUnit#PLATE_COMMENT},
|
||||
* {@link CodeUnit#PRE_COMMENT}, {@link CodeUnit#EOL_COMMENT}, {@link CodeUnit#POST_COMMENT},
|
||||
* {@link CodeUnit#REPEATABLE_COMMENT})
|
||||
* @param commentType the type of comment
|
||||
*/
|
||||
protected static void createAndCommentData(Program program, Address addr, DataType dt,
|
||||
String comment, int commentType) {
|
||||
String comment, CommentType commentType) {
|
||||
createData(program, addr, dt);
|
||||
SetCommentCmd.createComment(program, addr, comment, commentType);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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 =
|
||||
|
@ -288,11 +286,11 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
|
|||
Address csMaxAddr = callSite.getMaxAddress();
|
||||
String startTryComment = "try { // try from " + csMinAddr + " to " + csMaxAddr +
|
||||
" has its CatchHandler @ " + lpAddr;
|
||||
String existingComment = program.getListing().getComment(CodeUnit.PRE_COMMENT, csMinAddr);
|
||||
String existingComment = program.getListing().getComment(CommentType.PRE, csMinAddr);
|
||||
if (existingComment == null || !existingComment.contains(startTryComment)) {
|
||||
String mergedComment = StringUtilities.mergeStrings(existingComment, startTryComment);
|
||||
SetCommentCmd setCommentCmd =
|
||||
new SetCommentCmd(csMinAddr, CodeUnit.PRE_COMMENT, mergedComment);
|
||||
new SetCommentCmd(csMinAddr, CommentType.PRE, mergedComment);
|
||||
setCommentCmd.applyTo(program);
|
||||
}
|
||||
}
|
||||
|
@ -304,12 +302,11 @@ 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(CodeUnit.POST_COMMENT, commentAddr);
|
||||
String existingComment = program.getListing().getComment(CommentType.POST, commentAddr);
|
||||
if (existingComment == null || !existingComment.contains(endTryComment)) {
|
||||
String mergedComment = StringUtilities.mergeStrings(existingComment, endTryComment);
|
||||
SetCommentCmd setCommentCmd =
|
||||
new SetCommentCmd(commentAddr, CodeUnit.POST_COMMENT, mergedComment);
|
||||
new SetCommentCmd(commentAddr, CommentType.POST, mergedComment);
|
||||
setCommentCmd.applyTo(program);
|
||||
}
|
||||
}
|
||||
|
@ -322,11 +319,10 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
|
|||
typeInfos.stream().map(a -> getCatchParamInfo(a)).collect(Collectors.joining(", "));
|
||||
String startCatchComment =
|
||||
"catch(" + typeString + ") { ... } // from try @ " + csAddr + " with catch @ " + lpAddr;
|
||||
String existingComment = program.getListing().getComment(CodeUnit.PRE_COMMENT, lpAddr);
|
||||
String existingComment = program.getListing().getComment(CommentType.PRE, lpAddr);
|
||||
if (existingComment == null || !existingComment.contains(startCatchComment)) {
|
||||
String mergedComment = StringUtilities.mergeStrings(existingComment, startCatchComment);
|
||||
SetCommentCmd setCommentCmd =
|
||||
new SetCommentCmd(lpAddr, CodeUnit.PRE_COMMENT, mergedComment);
|
||||
SetCommentCmd setCommentCmd = new SetCommentCmd(lpAddr, CommentType.PRE, mergedComment);
|
||||
setCommentCmd.applyTo(program);
|
||||
}
|
||||
}
|
||||
|
@ -346,12 +342,12 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
|
|||
// // TODO If we can determine the length of the catch handler we could mark its end too.
|
||||
// Address lpMaxAddr = ?;
|
||||
// String endCatchComment = "} // end catchHandler()";
|
||||
// String existingComment = program.getListing().getComment(CodeUnit.POST_COMMENT, lpMaxAddr);
|
||||
// String existingComment = program.getListing().getComment(CommentType.POST, lpMaxAddr);
|
||||
// if (existingComment == null || !existingComment.contains(endCatchComment)) {
|
||||
// String mergedComment =
|
||||
// StringUtilities.mergeStrings(existingComment, endCatchComment);
|
||||
// SetCommentCmd setCommentCmd =
|
||||
// new SetCommentCmd(lpMaxAddr, CodeUnit.POST_COMMENT, endCatchComment);
|
||||
// new SetCommentCmd(lpMaxAddr, CommentType.POST, endCatchComment);
|
||||
// setCommentCmd.applyTo(program);
|
||||
// }
|
||||
}
|
||||
|
@ -429,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -24,7 +24,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.RegionDescriptor;
|
|||
import ghidra.app.plugin.exceptionhandlers.gcc.structures.ehFrame.*;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.data.ByteDataType;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.program.model.mem.MemoryBlock;
|
||||
|
@ -176,8 +176,7 @@ abstract class AbstractFrameSection implements CieSource {
|
|||
|
||||
private void createPlateComment(Address curAddress, String fdeComment) {
|
||||
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(curAddress, CodeUnit.PLATE_COMMENT, fdeComment);
|
||||
SetCommentCmd commentCmd = new SetCommentCmd(curAddress, CommentType.PLATE, fdeComment);
|
||||
commentCmd.applyTo(program);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -22,7 +22,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.structures.ehFrame.*;
|
|||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressOutOfBoundsException;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.program.model.mem.MemoryBlock;
|
||||
|
@ -127,7 +127,7 @@ public class EhFrameHeaderSection {
|
|||
dataCmd.applyTo(program);
|
||||
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(curAddress, CodeUnit.EOL_COMMENT, "Encoded FDE count");
|
||||
new SetCommentCmd(curAddress, CommentType.EOL, "Encoded FDE count");
|
||||
commentCmd.applyTo(program);
|
||||
|
||||
curAddress = curAddress.add(ctx.getEncodedLength());
|
||||
|
@ -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);
|
||||
|
||||
|
@ -169,7 +169,7 @@ public class EhFrameHeaderSection {
|
|||
dataCmd.applyTo(program);
|
||||
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(curAddress, CodeUnit.EOL_COMMENT, "Encoded eh_frame_ptr");
|
||||
new SetCommentCmd(curAddress, CommentType.EOL, "Encoded eh_frame_ptr");
|
||||
commentCmd.applyTo(program);
|
||||
|
||||
curAddress = curAddress.add(ctx.getEncodedLength());
|
||||
|
@ -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();
|
||||
|
@ -196,7 +196,7 @@ public class EhFrameHeaderSection {
|
|||
fde_table.create(curAddress, fdeTblDecoder, fdeTableCnt);
|
||||
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(curAddress, CodeUnit.PLATE_COMMENT, "Frame Description Entry Table");
|
||||
new SetCommentCmd(curAddress, CommentType.PLATE, "Frame Description Entry Table");
|
||||
commentCmd.applyTo(program);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -134,7 +134,7 @@ public class Cie extends GccAnalysisClass {
|
|||
* appropriate comment for the new structure.
|
||||
*/
|
||||
String comment = "(CIE) Length";
|
||||
createAndCommentData(program, addr, dwordDT, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, dwordDT, comment, CommentType.EOL);
|
||||
program.getMemory().getBytes(addr, enc_length);
|
||||
curSize += DWORD_LEN;
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class Cie extends GccAnalysisClass {
|
|||
* appropriate comment for the new structure.
|
||||
*/
|
||||
String comment = "(CIE) ID";
|
||||
createAndCommentData(program, addr, dwordDT, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, dwordDT, comment, CommentType.EOL);
|
||||
|
||||
program.getMemory().getBytes(addr, enc_cieId);
|
||||
cieId = (int) GccAnalysisUtils.readDWord(program, addr);
|
||||
|
@ -184,7 +184,7 @@ public class Cie extends GccAnalysisClass {
|
|||
* appropriate comment for the new structure.
|
||||
*/
|
||||
String comment = "(CIE) Version";
|
||||
createAndCommentData(program, addr, new ByteDataType(), comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, new ByteDataType(), comment, CommentType.EOL);
|
||||
version = GccAnalysisUtils.readByte(program, addr);
|
||||
curSize += BYTE_LEN;
|
||||
|
||||
|
@ -208,7 +208,7 @@ public class Cie extends GccAnalysisClass {
|
|||
* and sets an appropriate comment for the new structure.
|
||||
*/
|
||||
String comment = "(CIE) Augmentation String";
|
||||
createAndCommentData(program, addr, new StringDataType(), comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, new StringDataType(), comment, CommentType.EOL);
|
||||
Data dataAt = program.getListing().getDataAt(addr);
|
||||
if (dataAt == null) {
|
||||
throw new ExceptionHandlerFrameException(
|
||||
|
@ -236,7 +236,7 @@ public class Cie extends GccAnalysisClass {
|
|||
* appropriate comment for the new structure.
|
||||
*/
|
||||
String comment = "(CIE) Pointer Size";
|
||||
createAndCommentData(program, addr, new ByteDataType(), comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, new ByteDataType(), comment, CommentType.EOL);
|
||||
ptrSize = GccAnalysisUtils.readByte(program, addr);
|
||||
curSize += BYTE_LEN;
|
||||
|
||||
|
@ -258,7 +258,7 @@ public class Cie extends GccAnalysisClass {
|
|||
* appropriate comment for the new structure.
|
||||
*/
|
||||
String comment = "(CIE) Segment Size";
|
||||
createAndCommentData(program, addr, new ByteDataType(), comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, new ByteDataType(), comment, CommentType.EOL);
|
||||
segmentSize = GccAnalysisUtils.readByte(program, addr);
|
||||
curSize += BYTE_LEN;
|
||||
|
||||
|
@ -285,7 +285,7 @@ public class Cie extends GccAnalysisClass {
|
|||
codeAlignFactor = (int) uleb128.asLong();
|
||||
|
||||
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
curSize += uleb128.getLength();
|
||||
|
||||
|
@ -312,7 +312,7 @@ public class Cie extends GccAnalysisClass {
|
|||
dataAlignFactor = (int) sleb128.asLong();
|
||||
|
||||
createAndCommentData(program, addr, SignedLeb128DataType.dataType, comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
curSize += sleb128.getLength();
|
||||
|
||||
|
@ -356,7 +356,7 @@ public class Cie extends GccAnalysisClass {
|
|||
|
||||
}
|
||||
|
||||
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
|
||||
curSize += encodedLen;
|
||||
|
||||
return addr.add(encodedLen);
|
||||
|
@ -382,7 +382,7 @@ public class Cie extends GccAnalysisClass {
|
|||
augmentationDataLength = (int) uleb128.asLong();
|
||||
|
||||
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
curSize += uleb128.getLength();
|
||||
|
||||
|
@ -430,8 +430,7 @@ public class Cie extends GccAnalysisClass {
|
|||
initialInstructionCount = intLength - curSize;
|
||||
arrayCmd = new CreateArrayCmd(addr, initialInstructionCount, new ByteDataType(), BYTE_LEN);
|
||||
arrayCmd.applyTo(program);
|
||||
SetCommentCmd.createComment(program, addr, "(CIE) Initial Instructions",
|
||||
CodeUnit.EOL_COMMENT);
|
||||
SetCommentCmd.createComment(program, addr, "(CIE) Initial Instructions", CommentType.EOL);
|
||||
|
||||
initialInstructions = new byte[initialInstructionCount];
|
||||
int numBytesRead = program.getMemory().getBytes(addr, initialInstructions);
|
||||
|
@ -525,8 +524,8 @@ public class Cie extends GccAnalysisClass {
|
|||
}
|
||||
|
||||
private void markEndOfFrame(Address addr) {
|
||||
createAndCommentData(program, addr, dwordDT, "End of Frame", CodeUnit.EOL_COMMENT);
|
||||
SetCommentCmd commentCmd = new SetCommentCmd(addr, CodeUnit.PLATE_COMMENT, "END OF FRAME");
|
||||
createAndCommentData(program, addr, dwordDT, "End of Frame", CommentType.EOL);
|
||||
SetCommentCmd commentCmd = new SetCommentCmd(addr, CommentType.PLATE, "END OF FRAME");
|
||||
commentCmd.applyTo(program);
|
||||
}
|
||||
|
||||
|
@ -549,7 +548,7 @@ public class Cie extends GccAnalysisClass {
|
|||
if (intLength == 0xffffffff) {
|
||||
hasExtLength = true;
|
||||
String comment = "(CIE) Extended Length";
|
||||
createAndCommentData(program, addr, new QWordDataType(), comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, new QWordDataType(), comment, CommentType.EOL);
|
||||
program.getMemory().getBytes(addr, enc_extLength);
|
||||
addr = addr.add(QWORD_LEN);
|
||||
curSize += QWORD_LEN;
|
||||
|
@ -620,7 +619,7 @@ public class Cie extends GccAnalysisClass {
|
|||
String lsdaComment = "(CIE Augmentation Data) LSDA Personality Function Pointer Encoding";
|
||||
|
||||
createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex),
|
||||
new DwarfEncodingModeDataType(), lsdaComment, CodeUnit.EOL_COMMENT);
|
||||
new DwarfEncodingModeDataType(), lsdaComment, CommentType.EOL);
|
||||
}
|
||||
|
||||
private void processFdeEncoding(Address augmentationDataAddr, int augmentationDataIndex,
|
||||
|
@ -630,7 +629,7 @@ public class Cie extends GccAnalysisClass {
|
|||
|
||||
createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex),
|
||||
new DwarfEncodingModeDataType(), "(CIE Augmentation Data) FDE Encoding",
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
}
|
||||
|
||||
private DwarfEHDecoder processPersonalityEncoding(Address augmentationDataAddr,
|
||||
|
@ -643,7 +642,7 @@ public class Cie extends GccAnalysisClass {
|
|||
String prsnltyComment = "(CIE Augmentation Data) Personality Function Pointer Encoding";
|
||||
|
||||
createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex),
|
||||
new DwarfEncodingModeDataType(), prsnltyComment, CodeUnit.EOL_COMMENT);
|
||||
new DwarfEncodingModeDataType(), prsnltyComment, CommentType.EOL);
|
||||
return personalityDecoder;
|
||||
}
|
||||
|
||||
|
@ -660,11 +659,11 @@ public class Cie extends GccAnalysisClass {
|
|||
createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex),
|
||||
prnsFuncPtrDt,
|
||||
"(CIE Augmentation Data) Personality Function Pointer (" + personalityFuncAddr + ")",
|
||||
CodeUnit.EOL_COMMENT);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -20,8 +20,7 @@ import ghidra.app.cmd.comments.SetCommentCmd;
|
|||
import ghidra.app.plugin.exceptionhandlers.gcc.GccAnalysisUtils;
|
||||
import ghidra.app.util.bin.LEB128Info;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
|
@ -393,7 +392,7 @@ public class DwarfCallFrameOpcodeParser {
|
|||
}
|
||||
}
|
||||
|
||||
SetCommentCmd.createComment(program, instrAddr, sb.toString(), CodeUnit.EOL_COMMENT);
|
||||
SetCommentCmd.createComment(program, instrAddr, sb.toString(), CommentType.EOL);
|
||||
|
||||
Msg.info(this, sb.toString());
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/* ###
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -22,7 +21,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.datatype.DwarfEncodingModeDataTyp
|
|||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressOutOfBoundsException;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -39,7 +38,7 @@ import ghidra.util.task.TaskMonitor;
|
|||
* </pre>
|
||||
*/
|
||||
public class ExceptionHandlerFrameHeader {
|
||||
|
||||
|
||||
/* Class Members */
|
||||
private TaskMonitor monitor;
|
||||
private Program prog;
|
||||
|
@ -48,7 +47,7 @@ public class ExceptionHandlerFrameHeader {
|
|||
private int eh_FramePtrEncoding;
|
||||
private int eh_FrameDescEntryCntEncoding;
|
||||
private int eh_FrameTableEncoding;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for an ExceptionHandlerFrameHeader.
|
||||
* @param monitor a status monitor for indicating progress or allowing a task to be cancelled.
|
||||
|
@ -75,11 +74,11 @@ public class ExceptionHandlerFrameHeader {
|
|||
*/
|
||||
public void addToDataTypeManager() {
|
||||
DataTypeManager dtManager = prog.getDataTypeManager();
|
||||
|
||||
|
||||
/* Add the ehFrameHdr Structure to the dataTypeManager */
|
||||
dtManager.addDataType(ehFrameHdrStruct, DataTypeConflictHandler.REPLACE_HANDLER );
|
||||
dtManager.addDataType(ehFrameHdrStruct, DataTypeConflictHandler.REPLACE_HANDLER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method that creates an Exception Handler Frame Header Structure
|
||||
* at the address specified by 'addr'. If addr is 'null', this method returns without creating
|
||||
|
@ -91,19 +90,20 @@ public class ExceptionHandlerFrameHeader {
|
|||
*/
|
||||
public void create(Address addr) throws MemoryAccessException, AddressOutOfBoundsException {
|
||||
CreateStructureCmd dataCmd = null;
|
||||
|
||||
|
||||
if (addr == null || monitor.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* 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 */
|
||||
SetCommentCmd commentCmd = new SetCommentCmd(addr, CodeUnit.PLATE_COMMENT, "Exception Handler Frame Header");
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(addr, CommentType.PLATE, "Exception Handler Frame Header");
|
||||
commentCmd.applyTo(prog);
|
||||
|
||||
|
||||
// Set the class members accordingly
|
||||
eh_version = prog.getMemory().getByte(addr) & 0xFF;
|
||||
eh_FramePtrEncoding = prog.getMemory().getByte(addr.add(1)) & 0xFF;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -177,7 +177,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
|
|||
* and sets an appropriate comment for the new structure.
|
||||
*/
|
||||
String comment = "(FDE) Length";
|
||||
createAndCommentData(program, addr, dwordDT, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, dwordDT, comment, CommentType.EOL);
|
||||
intLength = program.getMemory().getInt(addr);
|
||||
|
||||
return addr.add(DWORD_LEN);
|
||||
|
@ -202,7 +202,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
|
|||
DataType locType = new DWordDataType();
|
||||
int locTypeSize = locType.getLength();
|
||||
|
||||
createAndCommentData(program, addr, locType, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, locType, comment, CommentType.EOL);
|
||||
|
||||
intPtr = (int) GccAnalysisUtils.readDWord(program, addr);
|
||||
|
||||
|
@ -266,7 +266,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
|
|||
|
||||
DataType encodedDt = cie.getFDEDecoder().getDataType(program);
|
||||
|
||||
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
|
||||
if (pcBeginAddr.getOffset() != 0x0) {
|
||||
program.getReferenceManager()
|
||||
.addMemoryReference(addr, pcBeginAddr, RefType.DATA, SourceType.ANALYSIS, 0);
|
||||
|
@ -324,7 +324,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
|
|||
}
|
||||
|
||||
int dtLength = dataType.getLength();
|
||||
createAndCommentData(program, addr, dataType, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, dataType, comment, CommentType.EOL);
|
||||
|
||||
curSize += dtLength;
|
||||
|
||||
|
@ -358,7 +358,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
|
|||
intAugmentationDataLength = (int) uleb128.asLong();
|
||||
|
||||
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
curSize += uleb128.getLength();
|
||||
|
||||
|
@ -377,7 +377,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
|
|||
* Create a new Augmentation Data field at the specified address
|
||||
* and sets an appropriate comment for the new structure.
|
||||
*/
|
||||
SetCommentCmd.createComment(program, addr, "(FDE) Augmentation Data", CodeUnit.EOL_COMMENT);
|
||||
SetCommentCmd.createComment(program, addr, "(FDE) Augmentation Data", CommentType.EOL);
|
||||
|
||||
this.augmentationData = new byte[intAugmentationDataLength];
|
||||
program.getMemory().getBytes(addr, augmentationData);
|
||||
|
@ -406,7 +406,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
|
|||
}
|
||||
|
||||
SetCommentCmd.createComment(program, addr, "(FDE) Call Frame Instructions",
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
callFrameInstructions = new byte[instructionLength];
|
||||
program.getMemory().getBytes(addr, callFrameInstructions);
|
||||
|
@ -512,8 +512,8 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
|
|||
}
|
||||
|
||||
private void markEndOfFrame(Address addr) {
|
||||
createAndCommentData(program, addr, dwordDT, "End of Frame", CodeUnit.EOL_COMMENT);
|
||||
SetCommentCmd commentCmd = new SetCommentCmd(addr, CodeUnit.PLATE_COMMENT, "END OF FRAME");
|
||||
createAndCommentData(program, addr, dwordDT, "End of Frame", CommentType.EOL);
|
||||
SetCommentCmd commentCmd = new SetCommentCmd(addr, CommentType.PLATE, "END OF FRAME");
|
||||
commentCmd.applyTo(program);
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
|
|||
if (intLength == -1) {
|
||||
hasExtLength = true;
|
||||
String comment = "(FDE) Extended Length";
|
||||
createAndCommentData(program, addr, new QWordDataType(), comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, new QWordDataType(), comment, CommentType.EOL);
|
||||
// prog.getMemory().getBytes(addr, extLength);
|
||||
addr = addr.add(QWORD_LEN);
|
||||
curSize += QWORD_LEN;
|
||||
|
@ -631,7 +631,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
|
|||
|
||||
String lsdaComment = "(FDE Augmentation Data) LSDA Data Pointer";
|
||||
createAndCommentData(program, augmentationDataAddr, lsdaDecoder.getDataType(program),
|
||||
lsdaComment, CodeUnit.EOL_COMMENT);
|
||||
lsdaComment, CommentType.EOL);
|
||||
|
||||
if (augmentationDataAddr.equals(lsdaAddr)) {
|
||||
// decoded a reference that returned here -- a null reference
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -20,8 +20,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.*;
|
|||
import ghidra.app.util.bin.LEB128Info;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.data.SignedLeb128DataType;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
|
@ -83,7 +82,7 @@ public class LSDAActionRecord extends GccAnalysisClass {
|
|||
addr = createNextActionRef(addr);
|
||||
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(address, CodeUnit.PLATE_COMMENT, "(LSDA) Action Record");
|
||||
new SetCommentCmd(address, CommentType.PLATE, "(LSDA) Action Record");
|
||||
commentCmd.applyTo(program);
|
||||
|
||||
nextAddress = addr;
|
||||
|
@ -98,7 +97,7 @@ public class LSDAActionRecord extends GccAnalysisClass {
|
|||
typeFilter = (int) sleb128.asLong();
|
||||
|
||||
createAndCommentData(program, addr, SignedLeb128DataType.dataType, comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
size += sleb128.getLength();
|
||||
|
||||
|
@ -120,7 +119,7 @@ public class LSDAActionRecord extends GccAnalysisClass {
|
|||
}
|
||||
|
||||
createAndCommentData(program, addr, SignedLeb128DataType.dataType, comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
size += sleb128.getLength();
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -20,7 +20,7 @@ import java.util.*;
|
|||
import ghidra.app.cmd.comments.SetCommentCmd;
|
||||
import ghidra.app.plugin.exceptionhandlers.gcc.RegionDescriptor;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -76,7 +76,7 @@ public class LSDAActionTable {
|
|||
monitor.setMessage("Creating LSDA Action Table");
|
||||
|
||||
LSDAActionRecord rec = null;
|
||||
|
||||
|
||||
while (address.compareTo(maxAddress) <= 0) {
|
||||
rec = new LSDAActionRecord(monitor, program, region, this);
|
||||
rec.create(address);
|
||||
|
@ -89,7 +89,7 @@ public class LSDAActionTable {
|
|||
nextAddress = address;
|
||||
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(tableAddress, CodeUnit.PLATE_COMMENT, "(LSDA) Action Table");
|
||||
new SetCommentCmd(tableAddress, CommentType.PLATE, "(LSDA) Action Table");
|
||||
commentCmd.applyTo(program);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -21,7 +21,7 @@ import ghidra.app.util.bin.LEB128Info;
|
|||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.data.UnsignedLeb128DataType;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.program.model.symbol.RefType;
|
||||
|
@ -96,17 +96,19 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
|
|||
landingPadAddr = lpStart.add(getLandingPadOffset());
|
||||
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(baseAddr, CodeUnit.PLATE_COMMENT, "(LSDA) Call Site Record");
|
||||
new SetCommentCmd(baseAddr, CommentType.PLATE, "(LSDA) Call Site Record");
|
||||
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;
|
||||
|
@ -124,7 +126,7 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
|
|||
|
||||
DataType encodedDt = decoder.getDataType(program);
|
||||
|
||||
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
|
||||
|
||||
return addr.add(encodedLen);
|
||||
}
|
||||
|
@ -141,7 +143,7 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
|
|||
|
||||
DataType encodedDt = decoder.getDataType(program);
|
||||
|
||||
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
|
||||
|
||||
return addr.add(encodedLen);
|
||||
}
|
||||
|
@ -158,7 +160,7 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
|
|||
|
||||
DataType encodedDt = decoder.getDataType(program);
|
||||
|
||||
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
|
||||
|
||||
return addr.add(encodedLen);
|
||||
}
|
||||
|
@ -175,7 +177,7 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
|
|||
}
|
||||
|
||||
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
return addr.add(uleb128.getLength());
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -20,8 +20,7 @@ import java.util.*;
|
|||
import ghidra.app.cmd.comments.SetCommentCmd;
|
||||
import ghidra.app.plugin.exceptionhandlers.gcc.*;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -78,7 +77,7 @@ public class LSDACallSiteTable extends GccAnalysisClass {
|
|||
monitor.setMessage("Creating GCC LSDA Call Site Table ");
|
||||
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(baseAddr, CodeUnit.PLATE_COMMENT, "(LSDA) Call Site Table");
|
||||
new SetCommentCmd(baseAddr, CommentType.PLATE, "(LSDA) Call Site Table");
|
||||
commentCmd.applyTo(program);
|
||||
|
||||
Address limit = baseAddr.add(header.getCallSiteTableLength() - 1);
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -21,7 +21,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.datatype.DwarfEncodingModeDataTyp
|
|||
import ghidra.app.util.bin.LEB128Info;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.program.model.symbol.SourceType;
|
||||
|
@ -40,7 +40,6 @@ public class LSDAHeader extends GccAnalysisClass {
|
|||
|
||||
static final int OMITTED_ENCODING_TYPE = 0xFF;
|
||||
|
||||
|
||||
/* Class Members */
|
||||
private RegionDescriptor region;
|
||||
|
||||
|
@ -84,7 +83,7 @@ public class LSDAHeader extends GccAnalysisClass {
|
|||
|
||||
String comment = "(LSDA) LPStart Encoding";
|
||||
createAndCommentData(program, addr, new DwarfEncodingModeDataType(), comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
lpStartEncoding = GccAnalysisUtils.readByte(program, addr);
|
||||
|
||||
curSize += BYTE_LEN;
|
||||
|
@ -122,7 +121,7 @@ public class LSDAHeader extends GccAnalysisClass {
|
|||
|
||||
DataType encodedDt = decoder.getDataType(program);
|
||||
|
||||
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT);
|
||||
createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
|
||||
|
||||
curSize += encodedLen;
|
||||
return addr.add(encodedLen);
|
||||
|
@ -134,7 +133,7 @@ public class LSDAHeader extends GccAnalysisClass {
|
|||
ttypeEncoding = GccAnalysisUtils.readByte(program, addr);
|
||||
|
||||
createAndCommentData(program, addr, new DwarfEncodingModeDataType(), comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
curSize += BYTE_LEN;
|
||||
return addr.add(BYTE_LEN);
|
||||
|
@ -155,7 +154,7 @@ public class LSDAHeader extends GccAnalysisClass {
|
|||
ttypeOffset = uleb128.asLong() + curSize;
|
||||
|
||||
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
return addr.add(uleb128.getLength());
|
||||
}
|
||||
|
@ -165,7 +164,7 @@ public class LSDAHeader extends GccAnalysisClass {
|
|||
callSiteTableEncoding = GccAnalysisUtils.readByte(program, addr);
|
||||
|
||||
createAndCommentData(program, addr, new DwarfEncodingModeDataType(), comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
curSize += BYTE_LEN;
|
||||
return addr.add(BYTE_LEN);
|
||||
|
@ -179,7 +178,7 @@ public class LSDAHeader extends GccAnalysisClass {
|
|||
callSiteTableLength = (int) uleb128.asLong();
|
||||
|
||||
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
|
||||
CodeUnit.EOL_COMMENT);
|
||||
CommentType.EOL);
|
||||
|
||||
curSize += uleb128.getLength();
|
||||
return addr.add(uleb128.getLength());
|
||||
|
@ -243,7 +242,7 @@ public class LSDAHeader extends GccAnalysisClass {
|
|||
}
|
||||
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(baseAddr, CodeUnit.PLATE_COMMENT, "(LSDA) Exception Table");
|
||||
new SetCommentCmd(baseAddr, CommentType.PLATE, "(LSDA) Exception Table");
|
||||
commentCmd.applyTo(program);
|
||||
|
||||
nextAddress = addr;
|
||||
|
|
|
@ -18,7 +18,7 @@ package ghidra.app.plugin.exceptionhandlers.gcc.structures.gccexcepttable;
|
|||
import ghidra.app.cmd.comments.SetCommentCmd;
|
||||
import ghidra.app.plugin.exceptionhandlers.gcc.RegionDescriptor;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -125,7 +124,8 @@ public class LSDATable {
|
|||
}
|
||||
}
|
||||
|
||||
SetCommentCmd commentCmd = new SetCommentCmd(baseAdress, CodeUnit.PLATE_COMMENT, "Language-Specific Data Area");
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(baseAdress, CommentType.PLATE, "Language-Specific Data Area");
|
||||
commentCmd.applyTo(program);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/* ###
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -23,7 +22,7 @@ import ghidra.app.cmd.comments.SetCommentCmd;
|
|||
import ghidra.app.plugin.exceptionhandlers.gcc.*;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.program.model.symbol.RefType;
|
||||
|
@ -92,25 +91,25 @@ public class LSDATypeTable extends GccAnalysisClass {
|
|||
|
||||
typeInfoAddrs.add(typeRef);
|
||||
|
||||
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
catch (MemoryAccessException mae) {
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(addr, CodeUnit.EOL_COMMENT, "Unable to resolve pointer");
|
||||
new SetCommentCmd(addr, CommentType.EOL, "Unable to resolve pointer");
|
||||
commentCmd.applyTo(program);
|
||||
}
|
||||
|
||||
addr = addr.subtract(stride);
|
||||
}
|
||||
|
||||
SetCommentCmd commentCmd =
|
||||
new SetCommentCmd(top, CodeUnit.PLATE_COMMENT, "(LSDA) Type Table");
|
||||
SetCommentCmd commentCmd = new SetCommentCmd(top, CommentType.PLATE, "(LSDA) Type Table");
|
||||
commentCmd.applyTo(program);
|
||||
|
||||
nextAddress = bottom.add(1);
|
||||
|
@ -124,7 +123,7 @@ public class LSDATypeTable extends GccAnalysisClass {
|
|||
}
|
||||
|
||||
createAndCommentData(program, addr, new ArrayDataType(new ByteDataType(), incr, 1),
|
||||
" -- alignment pad", CodeUnit.EOL_COMMENT);
|
||||
" -- alignment pad", CommentType.EOL);
|
||||
|
||||
return addr.add(incr);
|
||||
|
||||
|
|
|
@ -3855,7 +3855,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
|||
* @see #getPlateComment(Address)
|
||||
*/
|
||||
public String getPlateCommentAsRendered(Address address) {
|
||||
String comment = currentProgram.getListing().getComment(CodeUnit.PLATE_COMMENT, address);
|
||||
String comment = currentProgram.getListing().getComment(CommentType.PLATE, address);
|
||||
PluginTool tool = state.getTool();
|
||||
if (tool != null) {
|
||||
comment = CommentUtils.getDisplayString(comment, currentProgram);
|
||||
|
@ -3874,7 +3874,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
|||
* @see #getPreComment(Address)
|
||||
*/
|
||||
public String getPreCommentAsRendered(Address address) {
|
||||
String comment = currentProgram.getListing().getComment(CodeUnit.PRE_COMMENT, address);
|
||||
String comment = currentProgram.getListing().getComment(CommentType.PRE, address);
|
||||
PluginTool tool = state.getTool();
|
||||
if (tool != null) {
|
||||
comment = CommentUtils.getDisplayString(comment, currentProgram);
|
||||
|
@ -3892,7 +3892,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
|||
* @see #getPostComment(Address)
|
||||
*/
|
||||
public String getPostCommentAsRendered(Address address) {
|
||||
String comment = currentProgram.getListing().getComment(CodeUnit.POST_COMMENT, address);
|
||||
String comment = currentProgram.getListing().getComment(CommentType.POST, address);
|
||||
PluginTool tool = state.getTool();
|
||||
if (tool != null) {
|
||||
comment = CommentUtils.getDisplayString(comment, currentProgram);
|
||||
|
@ -3910,7 +3910,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
|||
* @see #getEOLComment(Address)
|
||||
*/
|
||||
public String getEOLCommentAsRendered(Address address) {
|
||||
String comment = currentProgram.getListing().getComment(CodeUnit.EOL_COMMENT, address);
|
||||
String comment = currentProgram.getListing().getComment(CommentType.EOL, address);
|
||||
PluginTool tool = state.getTool();
|
||||
if (tool != null) {
|
||||
comment = CommentUtils.getDisplayString(comment, currentProgram);
|
||||
|
@ -3928,8 +3928,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
|||
* @see #getRepeatableComment(Address)
|
||||
*/
|
||||
public String getRepeatableCommentAsRendered(Address address) {
|
||||
String comment =
|
||||
currentProgram.getListing().getComment(CodeUnit.REPEATABLE_COMMENT, address);
|
||||
String comment = currentProgram.getListing().getComment(CommentType.REPEATABLE, address);
|
||||
PluginTool tool = state.getTool();
|
||||
if (tool != null) {
|
||||
comment = CommentUtils.getDisplayString(comment, currentProgram);
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/* ###
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/* ###
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -22,26 +21,30 @@ 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;
|
||||
|
||||
CommentTypes() {
|
||||
}
|
||||
static {
|
||||
COMMENT_TYPES = new int[NUMBER_OF_COMMENT_TYPES];
|
||||
private static int[] COMMENT_TYPES;
|
||||
private static int NUMBER_OF_COMMENT_TYPES = 5;
|
||||
|
||||
CommentTypes() {
|
||||
}
|
||||
|
||||
static {
|
||||
COMMENT_TYPES = new int[NUMBER_OF_COMMENT_TYPES];
|
||||
COMMENT_TYPES[0] = CodeUnit.PRE_COMMENT;
|
||||
COMMENT_TYPES[1] = CodeUnit.POST_COMMENT;
|
||||
COMMENT_TYPES[2] = CodeUnit.EOL_COMMENT;
|
||||
COMMENT_TYPES[3] = CodeUnit.PLATE_COMMENT;
|
||||
COMMENT_TYPES[4] = CodeUnit.REPEATABLE_COMMENT;
|
||||
}
|
||||
COMMENT_TYPES[3] = CodeUnit.PLATE_COMMENT;
|
||||
COMMENT_TYPES[4] = CodeUnit.REPEATABLE_COMMENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array containing the comment types on a code unit.
|
||||
*/
|
||||
public static int[] getTypes() {
|
||||
return COMMENT_TYPES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -118,7 +117,7 @@ public class EolComments {
|
|||
}
|
||||
|
||||
Collection<String> comments =
|
||||
Arrays.asList(codeUnit.getCommentAsArray(CodeUnit.REPEATABLE_COMMENT));
|
||||
Arrays.asList(codeUnit.getCommentAsArray(CommentType.REPEATABLE));
|
||||
addStrings(comments, repeatables);
|
||||
}
|
||||
|
||||
|
@ -582,7 +581,7 @@ public class EolComments {
|
|||
Listing listing = program.getListing();
|
||||
|
||||
// prefer listing comments first since there may not be a code unit at this address
|
||||
String repeatable = listing.getComment(CodeUnit.REPEATABLE_COMMENT, address);
|
||||
String repeatable = listing.getComment(CommentType.REPEATABLE, address);
|
||||
if (repeatable != null) {
|
||||
return StringUtilities.toLines(repeatable);
|
||||
}
|
||||
|
@ -597,7 +596,7 @@ public class EolComments {
|
|||
return f.getRepeatableCommentAsArray();
|
||||
}
|
||||
|
||||
return cu.getCommentAsArray(CodeUnit.REPEATABLE_COMMENT);
|
||||
return cu.getCommentAsArray(CommentType.REPEATABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
@ -187,7 +188,7 @@ public class NoteGnuProperty extends ElfNote {
|
|||
DataType elementDT = getElementDataType(dtm, element);
|
||||
Data elementData = DataUtilities.createData(program, address, elementDT, -1, false,
|
||||
ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA);
|
||||
listing.setComment(address, CodeUnit.EOL_COMMENT,
|
||||
listing.setComment(address, CommentType.EOL,
|
||||
element.typeName() + "=" + element.value());
|
||||
address = elementData.getMaxAddress().next();
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
@ -129,15 +129,15 @@ public abstract class DataDirectory implements PeMarkupable {
|
|||
}
|
||||
|
||||
protected void setPlateComment(Program prog, Address addr, String comment) {
|
||||
prog.getListing().setComment(addr, CodeUnit.PLATE_COMMENT, comment);
|
||||
prog.getListing().setComment(addr, CommentType.PLATE, comment);
|
||||
}
|
||||
|
||||
protected void setEolComment(Program prog, Address addr, String comment) {
|
||||
prog.getListing().setComment(addr, CodeUnit.EOL_COMMENT, comment);
|
||||
prog.getListing().setComment(addr, CommentType.EOL, comment);
|
||||
}
|
||||
|
||||
protected void setPreComment(Program prog, Address addr, String comment) {
|
||||
prog.getListing().setComment(addr, CodeUnit.PRE_COMMENT, comment);
|
||||
prog.getListing().setComment(addr, CommentType.PRE, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -439,13 +439,13 @@ 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);
|
||||
}
|
||||
catch (CodeUnitInsertionException e) {
|
||||
|
@ -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()
|
||||
|
@ -520,9 +520,9 @@ public class CliTableMethodDef extends CliAbstractTable {
|
|||
int codeLength = (int) endAddr.subtract(startAddr) + 1;
|
||||
ArrayDataType codeDT = new ArrayDataType(BYTE, codeLength, 1);
|
||||
data = listing.createData(startAddr, codeDT);
|
||||
|
||||
|
||||
// comment the type of code that should appear here
|
||||
data.setComment(CodeUnit.PRE_COMMENT,
|
||||
data.setComment(CommentType.PRE,
|
||||
(methodRow.isManaged() ? ".NET CLR Managed Code" : "Native Code"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -96,10 +96,9 @@ 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));
|
||||
listing.setComment(address, CodeUnit.EOL_COMMENT,
|
||||
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
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -156,7 +156,7 @@ class ProgramTextWriter {
|
|||
//// Plate Property ////////////////////////////////////////////
|
||||
boolean cuHasPlate = false;
|
||||
if (options.isShowProperties()) {
|
||||
String[] plate = currentCodeUnit.getCommentAsArray(CodeUnit.PLATE_COMMENT);
|
||||
String[] plate = currentCodeUnit.getCommentAsArray(CommentType.PLATE);
|
||||
cuHasPlate = plate != null && plate.length > 0;
|
||||
if (cuHasPlate) {
|
||||
processPlate(currentCodeUnit, plate);
|
||||
|
@ -200,7 +200,7 @@ class ProgramTextWriter {
|
|||
//// Pre-Comment ///////////////////////////////////////////////
|
||||
|
||||
if (options.isShowComments()) {
|
||||
String[] pre = currentCodeUnit.getCommentAsArray(CodeUnit.PRE_COMMENT);
|
||||
String[] pre = currentCodeUnit.getCommentAsArray(CommentType.PRE);
|
||||
if (pre != null && pre.length > 0) {
|
||||
String fill = genFill(options.getAddrWidth() + options.getBytesWidth());
|
||||
for (String element : pre) {
|
||||
|
@ -301,7 +301,7 @@ class ProgramTextWriter {
|
|||
|
||||
//// Post Comment //////////////////////////////////////////////
|
||||
if (options.isShowComments()) {
|
||||
String[] post = currentCodeUnit.getCommentAsArray(CodeUnit.POST_COMMENT);
|
||||
String[] post = currentCodeUnit.getCommentAsArray(CommentType.POST);
|
||||
if (post != null) {
|
||||
String fill = genFill(options.getAddrWidth() + options.getBytesWidth());
|
||||
for (String element : post) {
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
@ -482,7 +481,7 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
|
|||
Address address = program.getImageBase().add(dd.getAddressOfRawData());
|
||||
try {
|
||||
program.getListing().createData(address, new StringDataType(), actualData.length());
|
||||
program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, "Debug Misc");
|
||||
program.getListing().setComment(address, CommentType.PLATE, "Debug Misc");
|
||||
address = address.add(actualData.length());
|
||||
program.getListing().createData(address, new DWordDataType());
|
||||
}
|
||||
|
@ -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) {
|
||||
|
|
|
@ -545,18 +545,18 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
comment = Long.toHexString(symbols[index].getValue());
|
||||
}
|
||||
|
||||
cu.setComment(CodeUnit.EOL_COMMENT, comment);
|
||||
cu.setComment(CommentType.EOL, comment);
|
||||
|
||||
// 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;
|
||||
// }
|
||||
}
|
||||
|
@ -837,7 +837,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
}
|
||||
|
||||
createData(interpStrAddr, TerminatedStringDataType.dataType);
|
||||
listing.setComment(interpStrAddr, CodeUnit.EOL_COMMENT, "Initial Elf program interpreter");
|
||||
listing.setComment(interpStrAddr, CommentType.EOL, "Initial Elf program interpreter");
|
||||
}
|
||||
|
||||
private void processImports(TaskMonitor monitor) throws CancelledException {
|
||||
|
@ -1230,7 +1230,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
monitor.incrementProgress(1);
|
||||
|
||||
Data d = array.getComponent(i);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, programHeaders[i].getComment());
|
||||
d.setComment(CommentType.EOL, programHeaders[i].getComment());
|
||||
if (programHeaders[i].getType() == ElfProgramHeaderConstants.PT_NULL) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1301,7 +1301,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
if (type != null) {
|
||||
comment = comment + " - " + type;
|
||||
}
|
||||
d.setComment(CodeUnit.EOL_COMMENT, comment);
|
||||
d.setComment(CommentType.EOL, comment);
|
||||
|
||||
Address sectionAddr = findLoadAddress(sections[i], 0);
|
||||
if (sectionAddr != null) {
|
||||
|
@ -1340,7 +1340,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
listing.createData(relocTableAddr, dataType);
|
||||
}
|
||||
else {
|
||||
listing.setComment(relocTableAddr, CodeUnit.PRE_COMMENT,
|
||||
listing.setComment(relocTableAddr, CommentType.PRE,
|
||||
"ELF Relocation Table (markup not yet supported)");
|
||||
}
|
||||
}
|
||||
|
@ -2021,14 +2021,14 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
|
||||
// Add versioned symbol as comment only
|
||||
Address address = s.getAddress();
|
||||
String comment = listing.getComment(CodeUnit.PRE_COMMENT, address);
|
||||
String comment = listing.getComment(CommentType.PRE, address);
|
||||
if (comment == null || comment.length() == 0) {
|
||||
comment = symName;
|
||||
}
|
||||
else {
|
||||
comment += "\n" + symName;
|
||||
}
|
||||
listing.setComment(address, CodeUnit.PRE_COMMENT, comment);
|
||||
listing.setComment(address, CommentType.PRE, comment);
|
||||
setElfSymbolAddress(elfSymbol, address);
|
||||
return true;
|
||||
}
|
||||
|
@ -2499,21 +2499,21 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
|
||||
Address addr = hashTableAddr;
|
||||
Data d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "Hash Table - nbucket");
|
||||
d.setComment(CommentType.EOL, "Hash Table - nbucket");
|
||||
long nbucket = d.getScalar(0).getUnsignedValue();
|
||||
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "Hash Table - nchain");
|
||||
d.setComment(CommentType.EOL, "Hash Table - nchain");
|
||||
long nchain = d.getScalar(0).getUnsignedValue();
|
||||
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, new ArrayDataType(dt, (int) nbucket, dt.getLength()));
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "Hash Table - buckets");
|
||||
d.setComment(CommentType.EOL, "Hash Table - buckets");
|
||||
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, new ArrayDataType(dt, (int) nchain, dt.getLength()));
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "Hash Table - chains");
|
||||
d.setComment(CommentType.EOL, "Hash Table - chains");
|
||||
}
|
||||
catch (Exception e) {
|
||||
log("Failed to properly markup Hash table at " + hashTableAddr + ": " + getMessage(e));
|
||||
|
@ -2542,36 +2542,36 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
|
||||
Address addr = hashTableAddr;
|
||||
Data d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU Hash Table - nbucket");
|
||||
d.setComment(CommentType.EOL, "GNU Hash Table - nbucket");
|
||||
long nbucket = d.getScalar(0).getUnsignedValue();
|
||||
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU Hash Table - symbase");
|
||||
d.setComment(CommentType.EOL, "GNU Hash Table - symbase");
|
||||
long symbolBase = d.getScalar(0).getUnsignedValue();
|
||||
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU Hash Table - bloom_size");
|
||||
d.setComment(CommentType.EOL, "GNU Hash Table - bloom_size");
|
||||
long bloomSize = d.getScalar(0).getUnsignedValue();
|
||||
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU Hash Table - bloom_shift");
|
||||
d.setComment(CommentType.EOL, "GNU Hash Table - bloom_shift");
|
||||
|
||||
addr = addr.add(d.getLength());
|
||||
DataType bloomDataType =
|
||||
elf.is64Bit() ? QWordDataType.dataType : DWordDataType.dataType;
|
||||
d = listing.createData(addr,
|
||||
new ArrayDataType(bloomDataType, (int) bloomSize, bloomDataType.getLength()));
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU Hash Table - bloom");
|
||||
d.setComment(CommentType.EOL, "GNU Hash Table - bloom");
|
||||
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, new ArrayDataType(dt, (int) nbucket, dt.getLength()));
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU Hash Table - buckets");
|
||||
d.setComment(CommentType.EOL, "GNU Hash Table - buckets");
|
||||
|
||||
addr = addr.add(d.getLength());
|
||||
listing.setComment(addr, CodeUnit.EOL_COMMENT, "GNU Hash Table - chain");
|
||||
listing.setComment(addr, CommentType.EOL, "GNU Hash Table - chain");
|
||||
|
||||
// Rely on dynamic symbol table for number of symbols
|
||||
ElfSymbolTable dynamicSymbolTable = elf.getDynamicSymbolTable();
|
||||
|
@ -2612,30 +2612,30 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
// Elf32_Word ngnusyms; // number of entries in chains (and xlat); dynsymcount=symndx+ngnusyms
|
||||
Address addr = hashTableAddr;
|
||||
Data d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU XHash Table - ngnusyms");
|
||||
d.setComment(CommentType.EOL, "GNU XHash Table - ngnusyms");
|
||||
long ngnusyms = d.getScalar(0).getUnsignedValue();
|
||||
|
||||
// Elf32_Word nbuckets; // number of hash table buckets
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU XHash Table - nbuckets");
|
||||
d.setComment(CommentType.EOL, "GNU XHash Table - nbuckets");
|
||||
long nbuckets = d.getScalar(0).getUnsignedValue();
|
||||
|
||||
// Elf32_Word symndx; // number of initial .dynsym entires skipped in chains[] (and xlat[])
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU XHash Table - symndx");
|
||||
d.setComment(CommentType.EOL, "GNU XHash Table - symndx");
|
||||
|
||||
// Elf32_Word maskwords; // number of ElfW(Addr) words in bitmask
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU XHash Table - maskwords");
|
||||
d.setComment(CommentType.EOL, "GNU XHash Table - maskwords");
|
||||
long maskwords = d.getScalar(0).getUnsignedValue();
|
||||
|
||||
// Elf32_Word shift2; // bit shift of hashval for second Bloom filter bit
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, dt);
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU XHash Table - shift2");
|
||||
d.setComment(CommentType.EOL, "GNU XHash Table - shift2");
|
||||
|
||||
// ElfW(Addr) bitmask[maskwords]; // 2 bit Bloom filter on hashval
|
||||
addr = addr.add(d.getLength());
|
||||
|
@ -2643,22 +2643,22 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
elf.is64Bit() ? QWordDataType.dataType : DWordDataType.dataType;
|
||||
d = listing.createData(addr,
|
||||
new ArrayDataType(bloomDataType, (int) maskwords, bloomDataType.getLength()));
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU XHash Table - bitmask");
|
||||
d.setComment(CommentType.EOL, "GNU XHash Table - bitmask");
|
||||
|
||||
// Elf32_Word buckets[nbuckets]; // indices into chains[]
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, new ArrayDataType(dt, (int) nbuckets, dt.getLength()));
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU XHash Table - buckets");
|
||||
d.setComment(CommentType.EOL, "GNU XHash Table - buckets");
|
||||
|
||||
// Elf32_Word chains[ngnusyms]; // consecutive hashvals in a given bucket; last entry in chain has LSB set
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, new ArrayDataType(dt, (int) ngnusyms, dt.getLength()));
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU XHash Table - chains");
|
||||
d.setComment(CommentType.EOL, "GNU XHash Table - chains");
|
||||
|
||||
// Elf32_Word xlat[ngnusyms]; // parallel to chains[]; index into .dynsym
|
||||
addr = addr.add(d.getLength());
|
||||
d = listing.createData(addr, new ArrayDataType(dt, (int) ngnusyms, dt.getLength()));
|
||||
d.setComment(CodeUnit.EOL_COMMENT, "GNU XHash Table - xlat");
|
||||
d.setComment(CommentType.EOL, "GNU XHash Table - xlat");
|
||||
}
|
||||
catch (Exception e) {
|
||||
log("Failed to properly markup GNU Hash table at " + hashTableAddr + ": " +
|
||||
|
@ -2688,7 +2688,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
}
|
||||
Data structData = array.getComponent(i);
|
||||
if (structData != null) {
|
||||
structData.setComment(CodeUnit.EOL_COMMENT, name);
|
||||
structData.setComment(CommentType.EOL, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2736,7 +2736,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
String comment =
|
||||
dynamicType != null ? (dynamicType.name + " - " + dynamicType.description)
|
||||
: ("DT_0x" + StringUtilities.pad(Integer.toHexString(tagType), '0', 8));
|
||||
dynamicData.setComment(CodeUnit.EOL_COMMENT, comment);
|
||||
dynamicData.setComment(CommentType.EOL, comment);
|
||||
|
||||
Data valueData = dynamicData.getComponent(1);
|
||||
|
||||
|
@ -2749,7 +2749,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
|
|||
if (dynamicStringTable != null) {
|
||||
String str = dynamicStringTable.readString(elf.getReader(), value);
|
||||
if (str != null && str.length() != 0) {
|
||||
valueData.setComment(CodeUnit.EOL_COMMENT, str);
|
||||
valueData.setComment(CommentType.EOL, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ public class NeLoader extends AbstractOrdinalSupportLoader {
|
|||
buffer.append("Other Flags: " + Conv.toHexString(ib.getOtherFlags()) + "\n");
|
||||
buffer.append(ib.getOtherFlagsAsString());
|
||||
|
||||
firstCU.setComment(CodeUnit.PLATE_COMMENT, buffer.toString());
|
||||
firstCU.setComment(CommentType.PLATE, buffer.toString());
|
||||
}
|
||||
|
||||
private void processSegmentTable(MessageLog log, InformationBlock ib, SegmentTable st,
|
||||
|
@ -314,7 +314,7 @@ public class NeLoader extends AbstractOrdinalSupportLoader {
|
|||
buff.append((segments[i].isReadOnly() ? TAB + "Read Only" + "\n" : ""));
|
||||
buff.append((segments[i].is32bit() ? TAB + "Use 32 Bit" + "\n" : ""));
|
||||
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
|
||||
cu.setComment(CodeUnit.PRE_COMMENT, buff.toString());
|
||||
cu.setComment(CommentType.PRE, buff.toString());
|
||||
}
|
||||
|
||||
for (Segment segment : segments) {
|
||||
|
@ -392,7 +392,7 @@ public class NeLoader extends AbstractOrdinalSupportLoader {
|
|||
buf.append("Usage: " + Conv.toHexString(resource.getUsage()) + "\n");
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr);
|
||||
if (cu != null) {
|
||||
cu.setComment(CodeUnit.PRE_COMMENT, buf.toString());
|
||||
cu.setComment(CommentType.PRE, buf.toString());
|
||||
}
|
||||
|
||||
//if this resource is a string table,
|
||||
|
|
|
@ -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);
|
||||
|
@ -992,7 +991,7 @@ public class PeLoader extends AbstractPeDebugLoader {
|
|||
catch (CancelledException e) {
|
||||
// Move on
|
||||
}
|
||||
|
||||
|
||||
// Check for Swift
|
||||
List<String> sectionNames =
|
||||
Arrays.stream(pe.getNTHeader().getFileHeader().getSectionHeaders())
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -180,7 +179,7 @@ public class PlateFieldFactory extends FieldFactory {
|
|||
|
||||
addBlankLines(elements, numberBlankLines, cu);
|
||||
|
||||
String[] comments = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
|
||||
String[] comments = cu.getCommentAsArray(CommentType.PLATE);
|
||||
return generateFormattedPlateComment(elements, comments, offcutComments, cu.getProgram());
|
||||
}
|
||||
|
||||
|
@ -210,7 +209,7 @@ public class PlateFieldFactory extends FieldFactory {
|
|||
}
|
||||
|
||||
private String getCommentText(CodeUnit cu, List<String> offcutComments) {
|
||||
String[] comments = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
|
||||
String[] comments = cu.getCommentAsArray(CommentType.PLATE);
|
||||
if (comments == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -503,7 +502,7 @@ public class PlateFieldFactory extends FieldFactory {
|
|||
}
|
||||
|
||||
CodeUnit cu = (CodeUnit) proxyObject;
|
||||
String[] comments = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
|
||||
String[] comments = cu.getCommentAsArray(CommentType.PLATE);
|
||||
RowColLocation dataLocation =
|
||||
((ListingTextField) listingField).screenToDataLocation(row, col);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ public class PostCommentFieldFactory extends FieldFactory {
|
|||
String[] autoComment = getAutoPostComment(cu);
|
||||
List<String> offcutComments = CommentUtils.getOffcutComments(cu, CommentType.POST);
|
||||
|
||||
String[] comments = cu.getCommentAsArray(CodeUnit.POST_COMMENT);
|
||||
String[] comments = cu.getCommentAsArray(CommentType.POST);
|
||||
if (comments != null && comments.length > 0 && (cu instanceof Data)) {
|
||||
return getTextField(comments, autoComment, offcutComments, proxy, x, false);
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ public class PostCommentFieldFactory extends FieldFactory {
|
|||
}
|
||||
|
||||
CodeUnit cu = (CodeUnit) obj;
|
||||
String[] comment = cu.getCommentAsArray(CodeUnit.POST_COMMENT);
|
||||
String[] comment = cu.getCommentAsArray(CommentType.POST);
|
||||
|
||||
int[] cpath = null;
|
||||
if (cu instanceof Data) {
|
||||
|
@ -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());
|
||||
|
|
|
@ -130,7 +130,7 @@ public class PreCommentFieldFactory extends FieldFactory {
|
|||
}
|
||||
}
|
||||
|
||||
return cu.getCommentAsArray(CodeUnit.PRE_COMMENT);
|
||||
return cu.getCommentAsArray(CommentType.PRE);
|
||||
}
|
||||
|
||||
private String[] getAutoPreComments(CodeUnit cu) {
|
||||
|
@ -147,13 +147,13 @@ public class PreCommentFieldFactory extends FieldFactory {
|
|||
return null;
|
||||
}
|
||||
CodeUnit cu = (CodeUnit) obj;
|
||||
String[] comment = cu.getCommentAsArray(CodeUnit.PRE_COMMENT);
|
||||
String[] comment = cu.getCommentAsArray(CommentType.PRE);
|
||||
int[] cpath = null;
|
||||
if (cu instanceof Data) {
|
||||
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());
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/* ###
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -933,6 +933,7 @@ public class ProgramBuilder {
|
|||
});
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "11.4")
|
||||
public void createComment(String address, String comment, int commentType) {
|
||||
tx(() -> {
|
||||
Listing listing = program.getListing();
|
||||
|
@ -940,6 +941,13 @@ public class ProgramBuilder {
|
|||
});
|
||||
}
|
||||
|
||||
public void createComment(String address, String comment, CommentType commentType) {
|
||||
tx(() -> {
|
||||
Listing listing = program.getListing();
|
||||
listing.setComment(addr(address), commentType, comment);
|
||||
});
|
||||
}
|
||||
|
||||
public void createFunctionComment(String entryPointAddress, String comment) {
|
||||
tx(() -> {
|
||||
FunctionManager functionManager = program.getFunctionManager();
|
||||
|
@ -1104,10 +1112,9 @@ public class ProgramBuilder {
|
|||
}
|
||||
|
||||
return tx(() -> {
|
||||
FileBytes fileBytes =
|
||||
program.getMemory()
|
||||
.createFileBytes("test", 0, size, new ByteArrayInputStream(bytes),
|
||||
TaskMonitor.DUMMY);
|
||||
FileBytes fileBytes = program.getMemory()
|
||||
.createFileBytes("test", 0, size, new ByteArrayInputStream(bytes),
|
||||
TaskMonitor.DUMMY);
|
||||
|
||||
return fileBytes;
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -534,7 +531,7 @@ public class FlatProgramAPI {
|
|||
* @return true if the PLATE comment was successfully set
|
||||
*/
|
||||
public final boolean setPlateComment(Address address, String comment) {
|
||||
SetCommentCmd cmd = new SetCommentCmd(address, CodeUnit.PLATE_COMMENT, comment);
|
||||
SetCommentCmd cmd = new SetCommentCmd(address, CommentType.PLATE, comment);
|
||||
return cmd.applyTo(currentProgram);
|
||||
}
|
||||
|
||||
|
@ -545,7 +542,7 @@ public class FlatProgramAPI {
|
|||
* @return true if the PRE comment was successfully set
|
||||
*/
|
||||
public final boolean setPreComment(Address address, String comment) {
|
||||
SetCommentCmd cmd = new SetCommentCmd(address, CodeUnit.PRE_COMMENT, comment);
|
||||
SetCommentCmd cmd = new SetCommentCmd(address, CommentType.PRE, comment);
|
||||
return cmd.applyTo(currentProgram);
|
||||
}
|
||||
|
||||
|
@ -556,7 +553,7 @@ public class FlatProgramAPI {
|
|||
* @return true if the POST comment was successfully set
|
||||
*/
|
||||
public final boolean setPostComment(Address address, String comment) {
|
||||
SetCommentCmd cmd = new SetCommentCmd(address, CodeUnit.POST_COMMENT, comment);
|
||||
SetCommentCmd cmd = new SetCommentCmd(address, CommentType.POST, comment);
|
||||
return cmd.applyTo(currentProgram);
|
||||
}
|
||||
|
||||
|
@ -567,7 +564,7 @@ public class FlatProgramAPI {
|
|||
* @return true if the EOL comment was successfully set
|
||||
*/
|
||||
public final boolean setEOLComment(Address address, String comment) {
|
||||
SetCommentCmd cmd = new SetCommentCmd(address, CodeUnit.EOL_COMMENT, comment);
|
||||
SetCommentCmd cmd = new SetCommentCmd(address, CommentType.EOL, comment);
|
||||
return cmd.applyTo(currentProgram);
|
||||
}
|
||||
|
||||
|
@ -578,7 +575,7 @@ public class FlatProgramAPI {
|
|||
* @return true if the repeatable comment was successfully set
|
||||
*/
|
||||
public final boolean setRepeatableComment(Address address, String comment) {
|
||||
SetCommentCmd cmd = new SetCommentCmd(address, CodeUnit.REPEATABLE_COMMENT, comment);
|
||||
SetCommentCmd cmd = new SetCommentCmd(address, CommentType.REPEATABLE, comment);
|
||||
return cmd.applyTo(currentProgram);
|
||||
}
|
||||
|
||||
|
@ -593,7 +590,7 @@ public class FlatProgramAPI {
|
|||
* @see GhidraScript#getPlateCommentAsRendered(Address)
|
||||
*/
|
||||
public final String getPlateComment(Address address) {
|
||||
return currentProgram.getListing().getComment(CodeUnit.PLATE_COMMENT, address);
|
||||
return currentProgram.getListing().getComment(CommentType.PLATE, address);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -607,7 +604,7 @@ public class FlatProgramAPI {
|
|||
* @see GhidraScript#getPreCommentAsRendered(Address)
|
||||
*/
|
||||
public final String getPreComment(Address address) {
|
||||
return currentProgram.getListing().getComment(CodeUnit.PRE_COMMENT, address);
|
||||
return currentProgram.getListing().getComment(CommentType.PRE, address);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -621,7 +618,7 @@ public class FlatProgramAPI {
|
|||
* @see GhidraScript#getPostCommentAsRendered(Address)
|
||||
*/
|
||||
public final String getPostComment(Address address) {
|
||||
return currentProgram.getListing().getComment(CodeUnit.POST_COMMENT, address);
|
||||
return currentProgram.getListing().getComment(CommentType.POST, address);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -634,7 +631,7 @@ public class FlatProgramAPI {
|
|||
* @see GhidraScript#getEOLCommentAsRendered(Address)
|
||||
*/
|
||||
public final String getEOLComment(Address address) {
|
||||
return currentProgram.getListing().getComment(CodeUnit.EOL_COMMENT, address);
|
||||
return currentProgram.getListing().getComment(CommentType.EOL, address);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -647,7 +644,7 @@ public class FlatProgramAPI {
|
|||
* @see GhidraScript#getRepeatableCommentAsRendered(Address)
|
||||
*/
|
||||
public final String getRepeatableComment(Address address) {
|
||||
return currentProgram.getListing().getComment(CodeUnit.REPEATABLE_COMMENT, address);
|
||||
return currentProgram.getListing().getComment(CommentType.REPEATABLE, address);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -889,13 +886,13 @@ public class FlatProgramAPI {
|
|||
Address addr = null;
|
||||
|
||||
monitor.setMessage("Searching plate comments...");
|
||||
addr = findComment(CodeUnit.PLATE_COMMENT, text);
|
||||
addr = findComment(CommentType.PLATE, text);
|
||||
if (addr != null) {
|
||||
return addr;
|
||||
}
|
||||
|
||||
monitor.setMessage("Searching pre comments...");
|
||||
addr = findComment(CodeUnit.PRE_COMMENT, text);
|
||||
addr = findComment(CommentType.PRE, text);
|
||||
if (addr != null) {
|
||||
return addr;
|
||||
}
|
||||
|
@ -944,19 +941,19 @@ public class FlatProgramAPI {
|
|||
}
|
||||
|
||||
monitor.setMessage("Searching eol comments...");
|
||||
addr = findComment(CodeUnit.EOL_COMMENT, text);
|
||||
addr = findComment(CommentType.EOL, text);
|
||||
if (addr != null) {
|
||||
return addr;
|
||||
}
|
||||
|
||||
monitor.setMessage("Searching repeatable comments...");
|
||||
addr = findComment(CodeUnit.REPEATABLE_COMMENT, text);
|
||||
addr = findComment(CommentType.REPEATABLE, text);
|
||||
if (addr != null) {
|
||||
return addr;
|
||||
}
|
||||
|
||||
monitor.setMessage("Searching post comments...");
|
||||
addr = findComment(CodeUnit.POST_COMMENT, text);
|
||||
addr = findComment(CommentType.POST, text);
|
||||
if (addr != null) {
|
||||
return addr;
|
||||
}
|
||||
|
@ -1934,8 +1931,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2395,8 +2391,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2407,8 +2402,7 @@ public class FlatProgramAPI {
|
|||
*/
|
||||
public final List<Equate> getEquates(Instruction instruction, int operandIndex) {
|
||||
return currentProgram.getEquateTable()
|
||||
.getEquates(instruction.getMinAddress(),
|
||||
operandIndex);
|
||||
.getEquates(instruction.getMinAddress(), operandIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2420,8 +2414,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;
|
||||
}
|
||||
|
@ -2634,7 +2627,7 @@ public class FlatProgramAPI {
|
|||
return folder;
|
||||
}
|
||||
|
||||
private Address findComment(int type, String text) {
|
||||
private Address findComment(CommentType type, String text) {
|
||||
Listing listing = currentProgram.getListing();
|
||||
Memory memory = currentProgram.getMemory();
|
||||
AddressIterator iter = listing.getCommentAddressIterator(type, memory, true);
|
||||
|
|
|
@ -133,7 +133,7 @@ public class CodeUnitFormat {
|
|||
stringBuffer.append(getOperandRepresentationString(cu, 0));
|
||||
}
|
||||
if (includeEOLcomment) {
|
||||
String eolComment = cu.getComment(CodeUnit.EOL_COMMENT);
|
||||
String eolComment = cu.getComment(CommentType.EOL);
|
||||
if (eolComment != null) {
|
||||
// fixup annotations
|
||||
eolComment = CommentUtils.getDisplayString(eolComment, cu.getProgram());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -234,7 +234,7 @@ public class ClassicSampleX86ProgramBuilder extends ProgramBuilder {
|
|||
//
|
||||
// Comments
|
||||
//
|
||||
createComment("0x0100415a", "Repeatable Comment", CodeUnit.REPEATABLE_COMMENT);
|
||||
createComment("0x0100415a", "Repeatable Comment", CommentType.REPEATABLE);
|
||||
|
||||
//
|
||||
// References
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -18,7 +18,7 @@ package ghidra.util.table.field;
|
|||
import ghidra.docking.settings.Settings;
|
||||
import ghidra.framework.plugintool.ServiceProvider;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.util.*;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -58,6 +59,6 @@ public class EOLCommentTableColumn extends
|
|||
return null;
|
||||
}
|
||||
Address address = location.getAddress();
|
||||
return program.getListing().getComment(CodeUnit.EOL_COMMENT, address);
|
||||
return program.getListing().getComment(CommentType.EOL, address);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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,8 +46,8 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
|
|||
super();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddLatestInstr() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestInstr() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
@Override
|
||||
|
@ -64,12 +64,12 @@ 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
|
||||
public void testAddMyInstr() throws Exception {
|
||||
@Test
|
||||
public void testAddMyInstr() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
@Override
|
||||
|
@ -86,12 +86,12 @@ 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
|
||||
public void testAddLatestData() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestData() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
@Override
|
||||
|
@ -108,12 +108,12 @@ 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
|
||||
public void testAddMyData() throws Exception {
|
||||
@Test
|
||||
public void testAddMyData() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
@Override
|
||||
|
@ -130,12 +130,12 @@ 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
|
||||
public void testAddLatestInstrMyDataPickLatest() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestInstrMyDataPickLatest() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
@Override
|
||||
|
@ -153,12 +153,12 @@ 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
|
||||
public void testAddLatestInstrMyDataPickMy() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestInstrMyDataPickMy() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
@Override
|
||||
|
@ -176,12 +176,12 @@ 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
|
||||
public void testAddLatestInstrMyDataPickOrig() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestInstrMyDataPickOrig() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
@Override
|
||||
|
@ -199,12 +199,12 @@ 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
|
||||
public void testAddLatestDataMyInstrPickLatest() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestDataMyInstrPickLatest() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
@Override
|
||||
|
@ -222,14 +222,14 @@ 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
|
||||
public void testAddLatestDataMyInstrPickMy() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestDataMyInstrPickMy() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void modifyLatest(ProgramDB program) {
|
||||
createData(program, "0x10013d9", new DWordDataType());
|
||||
|
@ -245,14 +245,14 @@ 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
|
||||
public void testAddLatestDataMyInstrPickOrig() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestDataMyInstrPickOrig() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void modifyLatest(ProgramDB program) {
|
||||
createData(program, "0x10013d9", new TerminatedStringDataType());
|
||||
|
@ -268,14 +268,14 @@ 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
|
||||
public void testAddLatestInstrMyInstrPickLatest() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestInstrMyInstrPickLatest() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void modifyLatest(ProgramDB program) {
|
||||
disassemble(program, "0x10013d9", "0x10013e1");
|
||||
|
@ -291,12 +291,12 @@ 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
|
||||
public void testAddLatestInstrMyInstrPickMy() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestInstrMyInstrPickMy() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
@Override
|
||||
|
@ -314,12 +314,12 @@ 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
|
||||
public void testAddLatestInstrMyInstrPickOrig() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestInstrMyInstrPickOrig() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
@Override
|
||||
|
@ -337,14 +337,14 @@ 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
|
||||
public void testAddLatestDataMyDataPickLatest() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestDataMyDataPickLatest() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void modifyLatest(ProgramDB program) {
|
||||
createData(program, "0x10013d9", new WordDataType());
|
||||
|
@ -360,14 +360,14 @@ 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
|
||||
public void testAddLatestDataMyDataPickMy() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestDataMyDataPickMy() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void modifyLatest(ProgramDB program) {
|
||||
createData(program, "0x10013d9", new WordDataType());
|
||||
|
@ -383,14 +383,14 @@ 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
|
||||
public void testAddLatestDataMyDataPickOrig() throws Exception {
|
||||
@Test
|
||||
public void testAddLatestDataMyDataPickOrig() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void modifyLatest(ProgramDB program) {
|
||||
createData(program, "0x10013d9", new WordDataType());
|
||||
|
@ -406,12 +406,12 @@ 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
|
||||
public void testSameInstrLatestMy() throws Exception {
|
||||
@Test
|
||||
public void testSameInstrLatestMy() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
@Override
|
||||
public void modifyLatest(ProgramDB program) {
|
||||
|
@ -427,14 +427,14 @@ 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
|
||||
public void testSameDataLatestMy() throws Exception {
|
||||
@Test
|
||||
public void testSameDataLatestMy() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void modifyLatest(ProgramDB program) {
|
||||
createData(program, "0x10013d9", new DWordDataType());
|
||||
|
@ -449,34 +449,38 @@ 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
|
||||
public void testMergeCodeUnitsOriginal() throws Exception {
|
||||
@Test
|
||||
public void testMergeCodeUnitsOriginal() throws Exception {
|
||||
mtf.initialize("notepad", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
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",
|
||||
SourceType.USER_DEFINED);
|
||||
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,30 +565,34 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
|
|||
assertSameCodeUnits(resultProgram, latestProgram, latestAddrs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMergeCodeUnitsLatest() throws Exception {
|
||||
@Test
|
||||
public void testMergeCodeUnitsLatest() throws Exception {
|
||||
mtf.initialize("notepad", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
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",
|
||||
SourceType.USER_DEFINED);
|
||||
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,30 +672,34 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMergeCodeUnitsMine() throws Exception {
|
||||
@Test
|
||||
public void testMergeCodeUnitsMine() throws Exception {
|
||||
mtf.initialize("notepad", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
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",
|
||||
SourceType.USER_DEFINED);
|
||||
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,8 +782,8 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
|
|||
assertSameCodeUnits(resultProgram, latestProgram, latestAddrs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMergeCodeUnitsUseForAllPickLatest() throws Exception {
|
||||
@Test
|
||||
public void testMergeCodeUnitsUseForAllPickLatest() throws Exception {
|
||||
setupUseForAll();
|
||||
|
||||
executeMerge(ASK_USER); // auto set is [0100231d, 01002328] [010023be, 010023c2] [010080e2, 010080e3]
|
||||
|
@ -778,27 +805,31 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
|
|||
|
||||
private void setupUseForAll() throws Exception {
|
||||
mtf.initialize("DiffTestPgm1", new ProgramModifierListener() {
|
||||
|
||||
|
||||
@Override
|
||||
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",
|
||||
SourceType.USER_DEFINED);
|
||||
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,8 +892,8 @@ public class CodeUnitMergeManager1Test extends AbstractListingMergeManagerTest {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMergeCodeUnitsUseForAllPickMine() throws Exception {
|
||||
@Test
|
||||
public void testMergeCodeUnitsUseForAllPickMine() throws Exception {
|
||||
setupUseForAll();
|
||||
|
||||
executeMerge(ASK_USER);
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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"
|
||||
|
@ -538,7 +534,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
|
|||
// in Browser(1) add a pre comment at 331
|
||||
CodeUnit cu = programOne.getListing().getCodeUnitAt(addr(programOne, 0x331));
|
||||
int transactionID = programOne.startTransaction("test");
|
||||
cu.setComment(CodeUnit.PRE_COMMENT, "my pre comment for this test");
|
||||
cu.setComment(CommentType.PRE, "my pre comment for this test");
|
||||
programOne.endTransaction(transactionID, true);
|
||||
waitForSwing();
|
||||
|
||||
|
@ -572,7 +568,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
|
|||
|
||||
// verify pre comment at 331 remains unaffected
|
||||
cu = programOne.getListing().getCodeUnitAt(addr(programOne, 0x331));
|
||||
assertEquals("my pre comment for this test", cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
assertEquals("my pre comment for this test", cu.getComment(CommentType.PRE));
|
||||
|
||||
// verify browser field
|
||||
|
||||
|
@ -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();
|
||||
|
@ -649,18 +642,18 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
|
|||
|
||||
// verify comments are copied
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr(programOne, 0x0320));
|
||||
assertEquals("My Plate Comment", cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertEquals("My Post comment", cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertEquals("My Plate Comment", cu.getComment(CommentType.PLATE));
|
||||
assertEquals("My Post comment", cu.getComment(CommentType.POST));
|
||||
|
||||
cu = listing.getCodeUnitAt(addr(programOne, 0x326));
|
||||
assertEquals("More Plate Comments (1)", cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertEquals("More Post comments (1)", cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertEquals("More EOL comments (1)", cu.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertEquals("More Plate Comments (1)", cu.getComment(CommentType.PLATE));
|
||||
assertEquals("More Post comments (1)", cu.getComment(CommentType.POST));
|
||||
assertEquals("More EOL comments (1)", cu.getComment(CommentType.EOL));
|
||||
|
||||
cu = listing.getCodeUnitAt(addr(programOne, 0x32a));
|
||||
assertEquals("More Plate Comments (2)", cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertEquals("More Post comments (2)", cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertEquals("More EOL comments (2)", cu.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertEquals("More Plate Comments (2)", cu.getComment(CommentType.PLATE));
|
||||
assertEquals("More Post comments (2)", cu.getComment(CommentType.POST));
|
||||
assertEquals("More EOL comments (2)", cu.getComment(CommentType.EOL));
|
||||
|
||||
cb.goToField(addr(programOne, 0x0320), PlateFieldFactory.FIELD_NAME, 0, 0);
|
||||
ListingTextField f = (ListingTextField) cb.getCurrentField();
|
||||
|
@ -708,7 +701,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
|
|||
Address addr = addr(programOne, 0x334);
|
||||
for (String element : comments) {
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr);
|
||||
assertEquals(element, cu.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertEquals(element, cu.getComment(CommentType.EOL));
|
||||
assertTrue(cb.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0));
|
||||
ListingTextField f = (ListingTextField) cb.getCurrentField();
|
||||
assertEquals(element, f.getText());
|
||||
|
@ -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());
|
||||
|
@ -791,18 +783,18 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
|
|||
function.setComment("my function comment");
|
||||
// add some Plate, Pre, and Post comments within this function.
|
||||
CodeUnit cu = listing.getCodeUnitAt(addr(programTwo, 0x0320));
|
||||
cu.setComment(CodeUnit.PLATE_COMMENT, "My Plate Comment");
|
||||
cu.setComment(CodeUnit.POST_COMMENT, "My Post comment");
|
||||
cu.setComment(CommentType.PLATE, "My Plate Comment");
|
||||
cu.setComment(CommentType.POST, "My Post comment");
|
||||
|
||||
cu = listing.getCodeUnitAt(addr(programTwo, 0x326));
|
||||
cu.setComment(CodeUnit.PLATE_COMMENT, "More Plate Comments (1)");
|
||||
cu.setComment(CodeUnit.POST_COMMENT, "More Post comments (1)");
|
||||
cu.setComment(CodeUnit.EOL_COMMENT, "More EOL comments (1)");
|
||||
cu.setComment(CommentType.PLATE, "More Plate Comments (1)");
|
||||
cu.setComment(CommentType.POST, "More Post comments (1)");
|
||||
cu.setComment(CommentType.EOL, "More EOL comments (1)");
|
||||
|
||||
cu = listing.getCodeUnitAt(addr(programTwo, 0x32a));
|
||||
cu.setComment(CodeUnit.PLATE_COMMENT, "More Plate Comments (2)");
|
||||
cu.setComment(CodeUnit.POST_COMMENT, "More Post comments (2)");
|
||||
cu.setComment(CodeUnit.EOL_COMMENT, "More EOL comments (2)");
|
||||
cu.setComment(CommentType.PLATE, "More Plate Comments (2)");
|
||||
cu.setComment(CommentType.POST, "More Post comments (2)");
|
||||
cu.setComment(CommentType.EOL, "More EOL comments (2)");
|
||||
|
||||
// Edit the label at 0x32d (RSR05) and make it part of a scope
|
||||
Symbol symbol = getUniqueSymbol(programTwo, "RSR05", null);
|
||||
|
@ -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,10 +846,9 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
|
|||
}
|
||||
|
||||
private void assertEnabled(DockingActionIf action, ComponentProvider provider) {
|
||||
boolean isEnabled =
|
||||
runSwing(() -> {
|
||||
return action.isEnabledForContext(provider.getActionContext(null));
|
||||
});
|
||||
boolean isEnabled = runSwing(() -> {
|
||||
return action.isEnabledForContext(provider.getActionContext(null));
|
||||
});
|
||||
assertTrue("Action was not enabled when it should be", isEnabled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -595,7 +595,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
|
|||
|
||||
cb.goToField(callAddress, "Bytes", 0, 0);
|
||||
|
||||
SetCommentCmd eolCmd = new SetCommentCmd(callAddress, CodeUnit.EOL_COMMENT,
|
||||
SetCommentCmd eolCmd = new SetCommentCmd(callAddress, CommentType.EOL,
|
||||
"a bb ccc dddd eeeee ffff ggg hhh ii j k ll mmm nnn oooo " +
|
||||
"ppppp qqqq rrrr ssss tttt uuuuu vvvvvv wwwww\n\n\n\n" +
|
||||
"AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM NNN OOO PPP QQQ " +
|
||||
|
@ -604,7 +604,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
|
|||
"4444 55555 666666 7777777 88888888 999999999 0000000000 1 22 333 4444 55555");
|
||||
tool.execute(eolCmd, program);
|
||||
|
||||
SetCommentCmd repeatCmd = new SetCommentCmd(callAddress, CodeUnit.REPEATABLE_COMMENT,
|
||||
SetCommentCmd repeatCmd = new SetCommentCmd(callAddress, CommentType.REPEATABLE,
|
||||
"Local repeatable line1.\n" + "\n" + "Line3 of repeatable.");
|
||||
tool.execute(repeatCmd, program);
|
||||
|
||||
|
@ -613,7 +613,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
|
|||
new CreateFunctionCmd(null, callRefAddress, body, SourceType.USER_DEFINED);
|
||||
tool.execute(createFunctionCmd, program);
|
||||
|
||||
SetCommentCmd callRepeatCmd = new SetCommentCmd(callRefAddress, CodeUnit.REPEATABLE_COMMENT,
|
||||
SetCommentCmd callRepeatCmd = new SetCommentCmd(callRefAddress, CommentType.REPEATABLE,
|
||||
"\n" + "Function Repeatable line2");
|
||||
tool.execute(callRepeatCmd, program);
|
||||
|
||||
|
@ -621,8 +621,8 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
|
|||
SourceType.USER_DEFINED, 0, false);
|
||||
tool.execute(addRefCmd, program);
|
||||
|
||||
SetCommentCmd commentRefCmd = new SetCommentCmd(otherRefAddress,
|
||||
CodeUnit.REPEATABLE_COMMENT, "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
|
||||
|
@ -789,8 +789,8 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
|
|||
|
||||
//--- Verify register variable markup options
|
||||
|
||||
Command cmd = new AddRegisterRefCmd(addr("0x1002d0b"), 0, program.getRegister("EDI"),
|
||||
SourceType.USER_DEFINED);
|
||||
Command<Program> cmd = new AddRegisterRefCmd(addr("0x1002d0b"), 0,
|
||||
program.getRegister("EDI"), SourceType.USER_DEFINED);
|
||||
applyCmd(program, cmd);
|
||||
cb.updateNow();
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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,8 +129,8 @@ 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");
|
||||
assertEquals(comment1, subData1.getComment(CodeUnit.EOL_COMMENT));
|
||||
setAt(addr, CommentType.EOL, comment1, "OK");
|
||||
assertEquals(comment1, subData1.getComment(CommentType.EOL));
|
||||
|
||||
browser.goToField(addr(0x10080a2), "+", 0, 0);
|
||||
|
||||
|
@ -146,8 +143,8 @@ 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");
|
||||
assertEquals(comment, subData.getComment(CodeUnit.EOL_COMMENT));
|
||||
setAt(addr, CommentType.EOL, comment, "OK");
|
||||
assertEquals(comment, subData.getComment(CommentType.EOL));
|
||||
|
||||
browser.goToField(addr(0x010080a2), EolCommentFieldFactory.FIELD_NAME, 0, 0);
|
||||
assertEquals(comment, browser.getCurrentFieldText());
|
||||
|
@ -171,11 +168,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
waitForSwing();
|
||||
|
||||
comment += "\n\nHI, MOM";
|
||||
assertEquals(comment, subData.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertEquals(comment, subData.getComment(CommentType.EOL));
|
||||
|
||||
performAction(deleteAction, browser.getProvider(), false);
|
||||
waitForSwing();
|
||||
assertNull(subData.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertNull(subData.getComment(CommentType.EOL));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -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,12 +272,12 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
openX86ProgramInTool();
|
||||
Address addr = addr(0x01006420);
|
||||
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
|
||||
setAt(addr, CodeUnit.PRE_COMMENT, PRE, "OK");
|
||||
assertEquals(PRE, cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
setAt(addr, CommentType.PRE, PRE, "OK");
|
||||
assertEquals(PRE, cu.getComment(CommentType.PRE));
|
||||
undo(program);
|
||||
assertNull(cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
assertNull(cu.getComment(CommentType.PRE));
|
||||
redo(program);
|
||||
assertEquals(PRE, cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
assertEquals(PRE, cu.getComment(CommentType.PRE));
|
||||
browser.goToField(addr, PreCommentFieldFactory.FIELD_NAME, 0, 0);
|
||||
assertEquals(PRE, browser.getCurrentFieldText());
|
||||
}
|
||||
|
@ -290,12 +287,12 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
openX86ProgramInTool();
|
||||
Address addr = addr(0x01006420);
|
||||
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
|
||||
setAt(addr, CodeUnit.POST_COMMENT, POST, "OK");
|
||||
assertEquals(POST, cu.getComment(CodeUnit.POST_COMMENT));
|
||||
setAt(addr, CommentType.POST, POST, "OK");
|
||||
assertEquals(POST, cu.getComment(CommentType.POST));
|
||||
undo(program);
|
||||
assertNull(cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertNull(cu.getComment(CommentType.POST));
|
||||
redo(program);
|
||||
assertEquals(POST, cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertEquals(POST, cu.getComment(CommentType.POST));
|
||||
browser.goToField(addr, PostCommentFieldFactory.FIELD_NAME, 0, 0);
|
||||
assertEquals(POST, browser.getCurrentFieldText());
|
||||
}
|
||||
|
@ -305,12 +302,12 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
openX86ProgramInTool();
|
||||
Address addr = addr(0x01006420);
|
||||
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
|
||||
setAt(addr, CodeUnit.EOL_COMMENT, EOL, "OK");
|
||||
assertEquals(EOL, cu.getComment(CodeUnit.EOL_COMMENT));
|
||||
setAt(addr, CommentType.EOL, EOL, "OK");
|
||||
assertEquals(EOL, cu.getComment(CommentType.EOL));
|
||||
undo(program);
|
||||
assertNull(cu.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertNull(cu.getComment(CommentType.EOL));
|
||||
redo(program);
|
||||
assertEquals(EOL, cu.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertEquals(EOL, cu.getComment(CommentType.EOL));
|
||||
browser.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0);
|
||||
assertEquals(EOL, browser.getCurrentFieldText());
|
||||
}
|
||||
|
@ -321,12 +318,12 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
resetFormatOptions(browser);
|
||||
Address addr = addr(0x01006420);
|
||||
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
|
||||
setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK");
|
||||
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
setAt(addr, CommentType.PLATE, PLATE, "OK");
|
||||
assertEquals(PLATE, cu.getComment(CommentType.PLATE));
|
||||
undo(program);
|
||||
assertNull(cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertNull(cu.getComment(CommentType.PLATE));
|
||||
redo(program);
|
||||
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertEquals(PLATE, cu.getComment(CommentType.PLATE));
|
||||
browser.goToField(addr, PlateFieldFactory.FIELD_NAME, 0, 0);
|
||||
//allow for the "*" that get added to the plate
|
||||
assertEquals(65, browser.getCurrentFieldText().indexOf(PLATE));
|
||||
|
@ -337,12 +334,12 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
openX86ProgramInTool();
|
||||
Address addr = addr(0x01006420);
|
||||
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
|
||||
setAt(addr, CodeUnit.REPEATABLE_COMMENT, REPEAT, "OK");
|
||||
assertEquals(REPEAT, cu.getComment(CodeUnit.REPEATABLE_COMMENT));
|
||||
setAt(addr, CommentType.REPEATABLE, REPEAT, "OK");
|
||||
assertEquals(REPEAT, cu.getComment(CommentType.REPEATABLE));
|
||||
undo(program);
|
||||
assertNull(cu.getComment(CodeUnit.REPEATABLE_COMMENT));
|
||||
assertNull(cu.getComment(CommentType.REPEATABLE));
|
||||
redo(program);
|
||||
assertEquals(REPEAT, cu.getComment(CodeUnit.REPEATABLE_COMMENT));
|
||||
assertEquals(REPEAT, cu.getComment(CommentType.REPEATABLE));
|
||||
browser.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0);
|
||||
assertEquals(REPEAT, browser.getCurrentFieldText());
|
||||
}
|
||||
|
@ -354,8 +351,8 @@ 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");
|
||||
assertEquals(longComment, cu.getComment(CodeUnit.REPEATABLE_COMMENT));
|
||||
setAt(addr, CommentType.REPEATABLE, longComment, "OK");
|
||||
assertEquals(longComment, cu.getComment(CommentType.REPEATABLE));
|
||||
|
||||
// this fails when excepting
|
||||
assertTrue(browser.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0));
|
||||
|
@ -367,33 +364,33 @@ 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(CodeUnit.PRE_COMMENT));
|
||||
assertEquals(POST, cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertEquals(EOL, cu.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertEquals(REPEAT, cu.getComment(CodeUnit.REPEATABLE_COMMENT));
|
||||
assertEquals(PRE, cu.getComment(CommentType.PRE));
|
||||
assertEquals(POST, cu.getComment(CommentType.POST));
|
||||
assertEquals(EOL, cu.getComment(CommentType.EOL));
|
||||
assertEquals(PLATE, cu.getComment(CommentType.PLATE));
|
||||
assertEquals(REPEAT, cu.getComment(CommentType.REPEATABLE));
|
||||
|
||||
undo(program, 5);
|
||||
|
||||
assertNull(cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
assertNull(cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertNull(cu.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertNull(cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertNull(cu.getComment(CodeUnit.REPEATABLE_COMMENT));
|
||||
assertNull(cu.getComment(CommentType.PRE));
|
||||
assertNull(cu.getComment(CommentType.POST));
|
||||
assertNull(cu.getComment(CommentType.EOL));
|
||||
assertNull(cu.getComment(CommentType.PLATE));
|
||||
assertNull(cu.getComment(CommentType.REPEATABLE));
|
||||
|
||||
redo(program, 5);
|
||||
|
||||
assertEquals(PRE, cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
assertEquals(POST, cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertEquals(EOL, cu.getComment(CodeUnit.EOL_COMMENT));
|
||||
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertEquals(REPEAT, cu.getComment(CodeUnit.REPEATABLE_COMMENT));
|
||||
assertEquals(PRE, cu.getComment(CommentType.PRE));
|
||||
assertEquals(POST, cu.getComment(CommentType.POST));
|
||||
assertEquals(EOL, cu.getComment(CommentType.EOL));
|
||||
assertEquals(PLATE, cu.getComment(CommentType.PLATE));
|
||||
assertEquals(REPEAT, cu.getComment(CommentType.REPEATABLE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -401,12 +398,12 @@ 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);
|
||||
waitForSwing();
|
||||
assertEquals("Bla bla bla", cu.getComment(CodeUnit.REPEATABLE_COMMENT));
|
||||
assertEquals("Bla bla bla", cu.getComment(CommentType.REPEATABLE));
|
||||
assertTrue(!commentsDialog.isVisible());
|
||||
}
|
||||
|
||||
|
@ -415,12 +412,12 @@ 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(CodeUnit.PRE_COMMENT));
|
||||
assertEquals(PRE, cu.getComment(CommentType.PRE));
|
||||
redo(program);
|
||||
assertEquals(PRE_U, cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
assertEquals(PRE_U, cu.getComment(CommentType.PRE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -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);
|
||||
|
@ -439,7 +436,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
pressButton(button, false);
|
||||
waitForSwing();
|
||||
|
||||
assertEquals("Bla bla bla", cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertEquals("Bla bla bla", cu.getComment(CommentType.POST));
|
||||
assertFalse(commentsDialog.isVisible());
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -460,7 +457,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
pressButton(button, false);
|
||||
waitForSwing();
|
||||
|
||||
assertNull(cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertNull(cu.getComment(CommentType.POST));
|
||||
assertFalse(commentsDialog.isVisible());
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -482,7 +479,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
pressButton(button, false);
|
||||
waitForSwing();
|
||||
|
||||
assertNull(cu.getComment(CodeUnit.POST_COMMENT));
|
||||
assertNull(cu.getComment(CommentType.POST));
|
||||
assertTrue(commentsDialog.isVisible());
|
||||
|
||||
close(commentsDialog);
|
||||
|
@ -493,14 +490,14 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
openX86ProgramInTool();
|
||||
Address addr = addr(0xf0000250);
|
||||
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
|
||||
setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK");
|
||||
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
removeAt(addr, CodeUnit.PLATE_COMMENT);
|
||||
assertNull(cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
setAt(addr, CommentType.PLATE, PLATE, "OK");
|
||||
assertEquals(PLATE, cu.getComment(CommentType.PLATE));
|
||||
removeAt(addr, CommentType.PLATE);
|
||||
assertNull(cu.getComment(CommentType.PLATE));
|
||||
undo(program);
|
||||
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertEquals(PLATE, cu.getComment(CommentType.PLATE));
|
||||
redo(program);
|
||||
assertNull(cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertNull(cu.getComment(CommentType.PLATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -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,8 +538,8 @@ 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");
|
||||
assertEquals(comment, cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
setAt(addr, CommentType.PRE, comment, "OK");
|
||||
assertEquals(comment, cu.getComment(CommentType.PRE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -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,8 +581,8 @@ 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");
|
||||
assertEquals(comment, cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
setAt(srcAddr, CommentType.PRE, comment, "OK");
|
||||
assertEquals(comment, cu.getComment(CommentType.PRE));
|
||||
|
||||
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 23);
|
||||
click(browser, 2);
|
||||
|
@ -602,8 +598,8 @@ 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");
|
||||
assertEquals(comment, cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
setAt(srcAddr, CommentType.PRE, comment, "OK");
|
||||
assertEquals(comment, cu.getComment(CommentType.PRE));
|
||||
|
||||
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 23);
|
||||
click(browser, 2);
|
||||
|
@ -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,8 +673,8 @@ 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");
|
||||
assertEquals(comment, cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
setAt(srcAddr, CommentType.PRE, comment, "OK");
|
||||
assertEquals(comment, cu.getComment(CommentType.PRE));
|
||||
|
||||
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 19);
|
||||
click(browser, 2);
|
||||
|
@ -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,11 +719,11 @@ 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";
|
||||
assertEquals(spaceComment, cu.getComment(CodeUnit.PLATE_COMMENT));
|
||||
assertEquals(spaceComment, cu.getComment(CommentType.PLATE));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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");
|
||||
assertEquals(legal, cu.getComment(CodeUnit.PRE_COMMENT));
|
||||
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);
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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);
|
||||
|
|
|
@ -567,8 +567,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"), CodeUnit.EOL_COMMENT, "my comment");
|
||||
SetCommentCmd cmd = new SetCommentCmd(addr("0x10022cc"), CommentType.EOL, "my comment");
|
||||
applyCmd(program, cmd);
|
||||
|
||||
performAction(clearWithOptionsAction, cb.getProvider(), false);
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -41,7 +41,7 @@ import ghidra.framework.model.*;
|
|||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.CommentType;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.symbol.SourceType;
|
||||
import ghidra.program.model.symbol.SymbolTable;
|
||||
|
@ -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));
|
||||
|
||||
|
@ -589,7 +589,7 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
try {
|
||||
p.getListing()
|
||||
.setComment(p.getAddressFactory().getAddress("01000000"),
|
||||
CodeUnit.REPEATABLE_COMMENT, "This is a simple comment change.");
|
||||
CommentType.REPEATABLE, "This is a simple comment change.");
|
||||
}
|
||||
finally {
|
||||
p.endTransaction(transactionID, true);
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
@ -280,9 +280,9 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
|
|||
listing.createData(addr(0x01006890), floatDt);
|
||||
|
||||
Data data = listing.getDataAt(addr(0x0100688c));
|
||||
data.setComment(CodeUnit.EOL_COMMENT, "this is a float data type");
|
||||
data.setComment(CommentType.EOL, "this is a float data type");
|
||||
data = listing.getDataAt(addr(0x01006890));
|
||||
data.setComment(CodeUnit.EOL_COMMENT, "this is another float data type");
|
||||
data.setComment(CommentType.EOL, "this is another float data type");
|
||||
|
||||
}
|
||||
finally {
|
||||
|
@ -357,9 +357,9 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
|
|||
listing.createData(addr(0x01006890), floatDt);
|
||||
|
||||
Data data = listing.getDataAt(addr(0x0100688c));
|
||||
data.setComment(CodeUnit.EOL_COMMENT, "this is a float data type");
|
||||
data.setComment(CommentType.EOL, "this is a float data type");
|
||||
data = listing.getDataAt(addr(0x01006890));
|
||||
data.setComment(CodeUnit.EOL_COMMENT, "this is another float data type");
|
||||
data.setComment(CommentType.EOL, "this is another float data type");
|
||||
|
||||
}
|
||||
finally {
|
||||
|
@ -445,9 +445,9 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
|
|||
listing.createData(addr(0x01006890), floatDt);
|
||||
|
||||
Data data = listing.getDataAt(addr(0x0100688c));
|
||||
data.setComment(CodeUnit.EOL_COMMENT, "this is a float data type");
|
||||
data.setComment(CommentType.EOL, "this is a float data type");
|
||||
data = listing.getDataAt(addr(0x01006890));
|
||||
data.setComment(CodeUnit.EOL_COMMENT, "this is another float data type");
|
||||
data.setComment(CommentType.EOL, "this is another float data type");
|
||||
|
||||
}
|
||||
finally {
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -376,17 +376,17 @@ public class SearchTextPlugin1Test extends AbstractGhidraHeadedIntegrationTest {
|
|||
|
||||
CodeUnit cu = listing.getCodeUnitAt(getAddr(0x0100416f));
|
||||
int transactionID = program.startTransaction("test");
|
||||
cu.setComment(CodeUnit.EOL_COMMENT, "call sscanf");
|
||||
cu.setComment(CommentType.EOL, "call sscanf");
|
||||
|
||||
cu = listing.getCodeUnitAt(getAddr(0x01004178));
|
||||
cu.setComment(CodeUnit.REPEATABLE_COMMENT, "make a reference to sscanf");
|
||||
cu.setComment(CommentType.REPEATABLE, "make a reference to sscanf");
|
||||
|
||||
cu = listing.getCodeUnitAt(getAddr(0x01004192));
|
||||
cu.setComment(CodeUnit.PLATE_COMMENT, "another ref to sscanf");
|
||||
cu.setComment(CodeUnit.POST_COMMENT, "sscanf in a post comment");
|
||||
cu.setComment(CommentType.PLATE, "another ref to sscanf");
|
||||
cu.setComment(CommentType.POST, "sscanf in a post comment");
|
||||
|
||||
cu = listing.getCodeUnitAt(getAddr(0x0100467b));
|
||||
cu.setComment(CodeUnit.PRE_COMMENT, "call sscanf here");
|
||||
cu.setComment(CommentType.PRE, "call sscanf here");
|
||||
|
||||
program.endTransaction(transactionID, true);
|
||||
|
||||
|
@ -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 {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue