GP-0: Fixing deprecated comment API warnings

This commit is contained in:
Ryan Kurtz 2025-06-02 09:54:19 -04:00
parent 5772ac2ab8
commit 684177702e
120 changed files with 1595 additions and 1641 deletions

View file

@ -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;
@ -409,8 +409,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 +418,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

View file

@ -353,7 +353,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());

View file

@ -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

View file

@ -714,8 +714,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
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);
@ -735,8 +735,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)));
}
}

View file

@ -399,28 +399,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" });
}
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
}
assertNull(i4004.getComment(CodeUnit.PRE_COMMENT));
assertNull(i4004.getComment(CommentType.PRE));
TraceInstruction i4004_10;
DBTraceCommentAdapter commentAdapter = b.trace.getCommentAdapter();
@ -436,25 +436,25 @@ 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);
}
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);
}
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

View file

@ -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,
String comment = currentProgram.getListing().getComment(CommentType.REPEATABLE,
operand_addr);
if (comment != null) {
if (currentProgram.getListing().getComment(CodeUnit.REPEATABLE_COMMENT,
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);
}
}
}

View file

@ -19,8 +19,7 @@
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 {
@ -36,14 +35,14 @@ public class DeleteDeadDefaultPlatesScript extends GhidraScript {
set = currentSelection;
}
int updateCount=0;
AddressIterator iter = listing.getCommentAddressIterator(CodeUnit.PLATE_COMMENT, set, true);
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;
}
}

View file

@ -19,8 +19,7 @@
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 {
@ -36,14 +35,14 @@ public class DeleteEmptyPlateCommentsScript extends GhidraScript {
set = currentSelection;
}
int updateCount=0;
AddressIterator iter = listing.getCommentAddressIterator(CodeUnit.PLATE_COMMENT, set, true);
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;
}
}

View file

@ -18,11 +18,8 @@
//@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 {
@ -38,13 +35,13 @@ public class DeleteExitCommentsScript extends GhidraScript {
set = currentSelection;
}
int updateCount=0;
AddressIterator iter = listing.getCommentAddressIterator(CodeUnit.POST_COMMENT, set, true);
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;
}
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,12 +19,12 @@
//@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";
@ -65,7 +64,7 @@ public class RegisterTouchesPerFunction extends GhidraScript
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;
@ -163,7 +162,7 @@ public class RegisterTouchesPerFunction extends GhidraScript
buffer.append(" "+getString(pushPops, 8));
}
list.setComment(func.getEntryPoint(), CodeUnit.PLATE_COMMENT, buffer.toString());
list.setComment(func.getEntryPoint(), CommentType.PLATE, buffer.toString());
}
private String getString(Collection<String> c, int itemsPerLine)

View file

@ -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.*;
@ -99,7 +99,7 @@ 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.setComment(instAddr, CommentType.EOL, funcName);
listing.getInstructionAt(instAddr).addMnemonicReference(funcAddr, RefType.COMPUTED_CALL,
SourceType.USER_DEFINED);

View file

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

View file

@ -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;
@ -36,8 +36,23 @@ public class SetCommentCmd implements Command<Program> {
* @param addr address of code unit where comment will be placed
* @param commentType valid comment type (see CodeUnit)
* @param comment comment for code unit
* @deprecated Use {@link #SetCommentCmd(Address, CommentType, String)} instead
*/
@Deprecated
public SetCommentCmd(Address addr, int commentType, String comment) {
this.address = addr;
this.commentType = CommentType.values()[commentType];
this.comment = comment;
cmdName = comment == null ? "Delete Comment" : "Set Comment";
}
/**
* 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;
@ -115,9 +130,29 @@ public class SetCommentCmd implements Command<Program> {
* @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})
* @deprecated Use {@link #createComment(Program, Address, String, CommentType)} instead
*/
@Deprecated
public static void createComment(Program program, Address addr, String comment,
int commentType) {
SetCommentCmd commentCmd =
new SetCommentCmd(addr, CommentType.values()[commentType], comment);
commentCmd.applyTo(program);
}
/**
* Creates the specified comment of the specified type at address. The current comment of
* this commentType will be cleared.
*
* @param program the program being analyzed
* @param addr the address where data is created
* @param comment the comment about the data
* @param commentType the type of comment ({@link CommentType#PLATE},
* {@link CodeUnit#PRE_COMMENT}, {@link CodeUnit#EOL_COMMENT}, {@link CodeUnit#POST_COMMENT},
* {@link CodeUnit#REPEATABLE_COMMENT})
*/
public static void createComment(Program program, Address addr, String comment,
CommentType commentType) {
SetCommentCmd commentCmd = new SetCommentCmd(addr, commentType, comment);
commentCmd.applyTo(program);
}

View file

@ -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;

View file

@ -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());
@ -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);
}
}
}
@ -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)");
}
}

View file

@ -194,7 +194,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 +229,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));
}

View file

@ -678,7 +678,7 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
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);
}
}

View file

@ -410,7 +410,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;

View file

@ -67,6 +67,7 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
inspectFunction(program, function, state, monitor);
}
catch (Exception e) {
// do nothing
}
}
@ -96,7 +97,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;
@ -178,13 +179,11 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
return symbolTable.createNameSpace(parentNamespace, namespaceName,
SourceType.ANALYSIS);
}
catch (DuplicateNameException e) {
}
catch (InvalidInputException e) {
}
catch (InvalidInputException | DuplicateNameException e) {
return null;
}
}
}
private void markupInstruction(Instruction instruction, CurrentState state,
TaskMonitor monitor) {
@ -224,7 +223,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;
}

View file

@ -83,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;
@ -196,7 +196,7 @@ public class ObjectiveC2_MessageAnalyzer extends AbstractAnalyzer {
}
if (currentClass != null && currentMethod != null) {
instruction.setComment(CodeUnit.EOL_COMMENT, "[" + currentClass + " " +
instruction.setComment(CommentType.EOL, "[" + currentClass + " " +
currentMethod + "]");
break;
}

View file

@ -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 "";
}

View file

@ -35,6 +35,7 @@ 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;
/**
@ -93,11 +94,11 @@ public class CommentsDialog extends ReusableDialogComponentProvider implements K
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;

View file

@ -94,19 +94,19 @@ class CommentTableModel extends AddressBasedTableModel<CommentRowObject> {
continue;
}
if (cu.getComment(CodeUnit.PRE_COMMENT) != null) {
if (cu.getComment(CommentType.PRE) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.PRE_COMMENT));
}
if (cu.getComment(CodeUnit.POST_COMMENT) != null) {
if (cu.getComment(CommentType.POST) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.POST_COMMENT));
}
if (cu.getComment(CodeUnit.EOL_COMMENT) != null) {
if (cu.getComment(CommentType.EOL) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.EOL_COMMENT));
}
if (cu.getComment(CodeUnit.PLATE_COMMENT) != null) {
if (cu.getComment(CommentType.PLATE) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.PLATE_COMMENT));
}
if (cu.getComment(CodeUnit.REPEATABLE_COMMENT) != null) {
if (cu.getComment(CommentType.REPEATABLE) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.REPEATABLE_COMMENT));
}
}

View file

@ -36,7 +36,8 @@ import ghidra.program.model.symbol.*;
import ghidra.program.model.util.AddressSetPropertyMap;
import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.Msg;
import ghidra.util.exception.*;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.InvalidInputException;
import ghidra.util.task.TaskMonitor;
public class AddressTable {
@ -496,7 +497,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) {

View file

@ -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 {@link CommentType 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);
}

View file

@ -288,11 +288,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);
}
}
@ -305,11 +305,11 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
Address commentAddr = csMaxCodeUnit.getMinAddress();
String endTryComment = "} // end try from " + csMinAddr + " to " + csMaxAddr;
String existingComment =
program.getListing().getComment(CodeUnit.POST_COMMENT, commentAddr);
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 +322,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,7 +345,7 @@ 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);

View file

@ -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);
}
}

View file

@ -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());
@ -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());
@ -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);
}

View file

@ -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,7 +659,7 @@ 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,

View file

@ -20,7 +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.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.util.Msg;
@ -393,7 +393,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());
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,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;
@ -101,7 +100,8 @@ public class ExceptionHandlerFrameHeader {
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

View file

@ -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

View file

@ -20,7 +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.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.util.task.TaskMonitor;
@ -83,7 +83,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 +98,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 +120,7 @@ public class LSDAActionRecord extends GccAnalysisClass {
}
createAndCommentData(program, addr, SignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT);
CommentType.EOL);
size += sleb128.getLength();

View file

@ -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;
@ -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);
}

View file

@ -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,7 +96,7 @@ 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)) {
@ -124,7 +124,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 +141,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 +158,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 +175,7 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
}
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT);
CommentType.EOL);
return addr.add(uleb128.getLength());
}

View file

@ -20,7 +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.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.util.Msg;
@ -78,7 +78,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);

View file

@ -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;
@ -84,7 +84,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 +122,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 +134,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 +155,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 +165,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 +179,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 +243,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;

View file

@ -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;
@ -125,7 +125,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);
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -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,7 +91,7 @@ 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,
@ -102,15 +101,14 @@ public class LSDATypeTable extends GccAnalysisClass {
}
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 +122,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);

View file

@ -118,7 +118,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 +582,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 +597,7 @@ public class EolComments {
return f.getRepeatableCommentAsArray();
}
return cu.getCommentAsArray(CodeUnit.REPEATABLE_COMMENT);
return cu.getCommentAsArray(CommentType.REPEATABLE);
}
/**

View file

@ -187,7 +187,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();
}

View file

@ -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);
}
/**

View file

@ -522,7 +522,7 @@ public class CliTableMethodDef extends CliAbstractTable {
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"));
}
}

View file

@ -99,7 +99,7 @@ public class DemangledAddressTable extends DemangledObject {
Msg.warn(this,
"Unable to fully apply external demangled Address Table at " + address + ": " +
s.getName(true));
listing.setComment(address, CodeUnit.EOL_COMMENT,
listing.setComment(address, CommentType.EOL,
"WARNING: Unable to apply demangled Address Table");
return true; // don't complain
}

View file

@ -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) {

View file

@ -482,7 +482,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());
}

View file

@ -545,7 +545,7 @@ 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()) {
@ -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);
}
}
}

View file

@ -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,

View file

@ -180,7 +180,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 +210,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;
}
@ -503,7 +503,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);

View file

@ -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) {

View file

@ -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,7 +147,7 @@ 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();

View file

@ -439,8 +439,14 @@ public class FlatProgramAPI {
}
/**
* Creates a label at the specified address in the global namespace.
* If makePrimary==true, then the new label is made primary.
* @param address the address to create the symbol
* @param name the name of the symbol
* @param makePrimary true if the symbol should be made primary
* @return the newly created code or function symbol
* @throws Exception if there is any exception
* @deprecated use {@link #createLabel(Address, String, boolean)} instead.
* Deprecated in Ghidra 7.4
*/
@Deprecated(since = "7.4", forRemoval = true)
public final Symbol createSymbol(Address address, String name, boolean makePrimary)
@ -534,7 +540,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 +551,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 +562,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 +573,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 +584,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 +599,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 +613,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 +627,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 +640,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 +653,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 +895,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 +950,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;
}
@ -2634,7 +2640,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);

View file

@ -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());

View file

@ -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.*;
@ -58,6 +58,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);
}
}

View file

@ -538,7 +538,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 +572,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
@ -649,18 +649,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 +708,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());
@ -791,18 +791,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);

View file

@ -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);
@ -622,7 +622,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
tool.execute(addRefCmd, program);
SetCommentCmd commentRefCmd = new SetCommentCmd(otherRefAddress,
CodeUnit.REPEATABLE_COMMENT, "Mem ref line1.\n" + "");
CommentType.REPEATABLE, "Mem ref line1.\n" + "");
tool.execute(commentRefCmd, program);
// these values are all DEFAULT, by default; set them in case that changes in the future

View file

@ -133,7 +133,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
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));
assertEquals(comment1, subData1.getComment(CommentType.EOL));
browser.goToField(addr(0x10080a2), "+", 0, 0);
@ -147,7 +147,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
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));
assertEquals(comment, subData.getComment(CommentType.EOL));
browser.goToField(addr(0x010080a2), EolCommentFieldFactory.FIELD_NAME, 0, 0);
assertEquals(comment, browser.getCurrentFieldText());
@ -171,11 +171,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
@ -276,11 +276,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PRE_COMMENT, PRE, "OK");
assertEquals(PRE, cu.getComment(CodeUnit.PRE_COMMENT));
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());
}
@ -291,11 +291,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.POST_COMMENT, POST, "OK");
assertEquals(POST, cu.getComment(CodeUnit.POST_COMMENT));
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());
}
@ -306,11 +306,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.EOL_COMMENT, EOL, "OK");
assertEquals(EOL, cu.getComment(CodeUnit.EOL_COMMENT));
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());
}
@ -322,11 +322,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK");
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT));
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));
@ -338,11 +338,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.REPEATABLE_COMMENT, REPEAT, "OK");
assertEquals(REPEAT, cu.getComment(CodeUnit.REPEATABLE_COMMENT));
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());
}
@ -355,7 +355,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
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));
assertEquals(longComment, cu.getComment(CommentType.REPEATABLE));
// this fails when excepting
assertTrue(browser.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0));
@ -373,27 +373,27 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK");
setAt(addr, CodeUnit.REPEATABLE_COMMENT, 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
@ -406,7 +406,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
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());
}
@ -418,9 +418,9 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
setAt(addr, CodeUnit.PRE_COMMENT, PRE, "OK");
setAt(addr, CodeUnit.PRE_COMMENT, 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
@ -439,7 +439,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());
}
@ -460,7 +460,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
pressButton(button, false);
waitForSwing();
assertNull(cu.getComment(CodeUnit.POST_COMMENT));
assertNull(cu.getComment(CommentType.POST));
assertFalse(commentsDialog.isVisible());
}
@ -482,7 +482,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);
@ -494,13 +494,13 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0xf0000250);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK");
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT));
assertEquals(PLATE, cu.getComment(CommentType.PLATE));
removeAt(addr, CodeUnit.PLATE_COMMENT);
assertNull(cu.getComment(CodeUnit.PLATE_COMMENT));
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
@ -543,7 +543,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006000);
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PRE_COMMENT, comment, "OK");
assertEquals(comment, cu.getComment(CodeUnit.PRE_COMMENT));
assertEquals(comment, cu.getComment(CommentType.PRE));
}
@Test
@ -586,7 +586,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
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));
assertEquals(comment, cu.getComment(CommentType.PRE));
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 23);
click(browser, 2);
@ -603,7 +603,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
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));
assertEquals(comment, cu.getComment(CommentType.PRE));
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 23);
click(browser, 2);
@ -678,7 +678,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
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));
assertEquals(comment, cu.getComment(CommentType.PRE));
browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 19);
click(browser, 2);
@ -727,7 +727,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
// 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));
}
/*
@ -791,7 +791,7 @@ 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));
assertEquals(legal, cu.getComment(CommentType.PRE));
}
private void setAt(Address addr, int commentType, String comment, String nameOfButtonToClick)

View file

@ -327,18 +327,17 @@ public class ClearTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testClearNotRemoveComment() throws Exception {
SetCommentCmd cmd =
new SetCommentCmd(addr("0x1003698"), CodeUnit.EOL_COMMENT, "my comment");
SetCommentCmd cmd = new SetCommentCmd(addr("0x1003698"), CommentType.EOL, "my comment");
applyCmd(program, cmd);
CodeUnit cu = program.getListing().getCodeUnitAt(addr("0x1003698"));
assertEquals("my comment", cu.getComment(CodeUnit.EOL_COMMENT));
assertEquals("my comment", cu.getComment(CommentType.EOL));
assertTrue(cb.goToField(addr("0x1003698"), "Bytes", 0, 4));
doClearAction(true);
cu = program.getListing().getCodeUnitAt(addr("0x1003698"));
assertEquals("my comment", cu.getComment(CodeUnit.EOL_COMMENT));
assertEquals("my comment", cu.getComment(CommentType.EOL));
}
@ -567,8 +566,7 @@ public class ClearTest extends AbstractGhidraHeadedIntegrationTest {
public void testClearComments() throws Exception {
assertTrue(cb.goToField(addr("0x10022cc"), "Bytes", 0, 4));
SetCommentCmd cmd =
new SetCommentCmd(addr("0x10022cc"), CodeUnit.EOL_COMMENT, "my comment");
SetCommentCmd cmd =new SetCommentCmd(addr("0x10022cc"), CommentType.EOL, "my comment");
applyCmd(program, cmd);
performAction(clearWithOptionsAction, cb.getProvider(), false);
@ -580,11 +578,11 @@ public class ClearTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(addr("0x10022cc"));
assertNull(cu.getComment(CodeUnit.EOL_COMMENT));
assertNull(cu.getComment(CommentType.EOL));
undo(program);
assertNotNull(cu.getComment(CodeUnit.EOL_COMMENT));
assertNotNull(cu.getComment(CommentType.EOL));
redo(program);
assertNull(cu.getComment(CodeUnit.EOL_COMMENT));
assertNull(cu.getComment(CommentType.EOL));
}

View file

@ -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;
@ -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);

View file

@ -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 {

View file

@ -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);

View file

@ -309,7 +309,7 @@ public class SearchTextPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
int transactionID = program.startTransaction("test");
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
try {
cu.setComment(CodeUnit.POST_COMMENT, "********** my entry Exit **********");
cu.setComment(CommentType.POST, "********** my entry Exit **********");
}
finally {
program.endTransaction(transactionID, true);
@ -340,7 +340,7 @@ public class SearchTextPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
int transactionID = program.startTransaction("test");
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
try {
cu.setComment(CodeUnit.POST_COMMENT, "********** ___sbh_find_block Exit **********");
cu.setComment(CommentType.POST, "********** ___sbh_find_block Exit **********");
}
finally {
program.endTransaction(transactionID, true);
@ -369,7 +369,7 @@ public class SearchTextPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
int transactionID = program.startTransaction("test");
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
try {
cu.setComment(CodeUnit.POST_COMMENT, "********** ___sbh_find_block Exit **********");
cu.setComment(CommentType.POST, "********** ___sbh_find_block Exit **********");
}
finally {
program.endTransaction(transactionID, true);
@ -395,7 +395,7 @@ public class SearchTextPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
int transactionID = program.startTransaction("test");
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
try {
cu.setComment(CodeUnit.POST_COMMENT, "Comment test * with an asterisk");
cu.setComment(CommentType.POST, "Comment test * with an asterisk");
}
finally {
program.endTransaction(transactionID, true);

View file

@ -179,13 +179,13 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = listing.getCodeUnitAt(getAddr(0x01002c97));
int transactionID = program.startTransaction("test");
cu.setComment(CodeUnit.PLATE_COMMENT, "find hit for eax");
cu.setComment(CodeUnit.PRE_COMMENT, "find another hit for eax");
cu.setComment(CommentType.PLATE, "find hit for eax");
cu.setComment(CommentType.PRE, "find another hit for eax");
SymbolTable st = program.getSymbolTable();
st.createLabel(cu.getMinAddress(), "My_EAX", SourceType.USER_DEFINED);
cu.setComment(CodeUnit.EOL_COMMENT, "eol comment for eax");
cu.setComment(CommentType.EOL, "eol comment for eax");
cu.setComment(CodeUnit.POST_COMMENT, "last comment for eax");
cu.setComment(CommentType.POST, "last comment for eax");
program.endTransaction(transactionID, true);
SearchTextDialog dialog = getDialog();
@ -340,16 +340,16 @@ public class SearchTextPlugin3Test 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.POST_COMMENT, "sscanf in a post comment");
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);
@ -427,16 +427,16 @@ public class SearchTextPlugin3Test 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.POST_COMMENT, "sscanf in a post comment");
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);

View file

@ -382,17 +382,17 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
}
void addEolComment(long longAddr, String comment) {
SetCommentCmd cmd = new SetCommentCmd(getAddr(longAddr), CodeUnit.EOL_COMMENT, comment);
SetCommentCmd cmd = new SetCommentCmd(getAddr(longAddr), CommentType.EOL, comment);
tool.execute(cmd, program);
}
void addPreComment(long longAddr, String comment) {
SetCommentCmd cmd = new SetCommentCmd(getAddr(longAddr), CodeUnit.PRE_COMMENT, comment);
SetCommentCmd cmd = new SetCommentCmd(getAddr(longAddr), CommentType.PRE, comment);
tool.execute(cmd, program);
}
void addPostComment(long longAddr, String comment) {
SetCommentCmd cmd = new SetCommentCmd(getAddr(longAddr), CodeUnit.POST_COMMENT, comment);
SetCommentCmd cmd = new SetCommentCmd(getAddr(longAddr), CommentType.POST, comment);
tool.execute(cmd, program);
}

View file

@ -122,7 +122,7 @@ public class EolCommentFieldFactoryTest extends AbstractGhidraHeadedIntegrationT
CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint());
int transactionID = program.startTransaction("test");
try {
cu.setComment(CodeUnit.EOL_COMMENT, comment);
cu.setComment(CommentType.EOL, comment);
}
finally {
program.endTransaction(transactionID, true);

View file

@ -117,7 +117,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
Function function = program.getFunctionManager().getFunctionAt(addr);
CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint());
tx(program, () -> cu.setComment(CodeUnit.PLATE_COMMENT, null));
tx(program, () -> cu.setComment(CommentType.PLATE, null));
goToService.goTo(addr);
@ -148,7 +148,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
Function function = program.getFunctionManager().getFunctionAt(addr);
CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint());
String[] plateComments = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
String[] plateComments = cu.getCommentAsArray(CommentType.PLATE);
goToService.goTo(addr);
@ -205,7 +205,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
tx(program, () -> {
CreateFunctionCmd cmd = new CreateFunctionCmd(addr);
cmd.applyTo(program);
cu.setComment(CodeUnit.PLATE_COMMENT, null);
cu.setComment(CommentType.PLATE, null);
});
cb.updateNow();
@ -326,7 +326,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
}
CodeUnit cu = listing.getCodeUnitAt(addr);
String[] plates = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
String[] plates = cu.getCommentAsArray(CommentType.PLATE);
assertTrue("Failed to navigate to plate field at address: " + cu.getMinAddress(),
cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 1, 1));
ListingTextField tf = (ListingTextField) cb.getCurrentField();
@ -437,7 +437,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(addr);
tx(program, () -> {
cu.setComment(CodeUnit.PLATE_COMMENT,
cu.setComment(CommentType.PLATE,
"this is a comment\ngo to the address 0x010028de");
});
assertTrue(cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 2, 23));
@ -461,7 +461,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
program.getSymbolTable()
.createLabel(addr, testName.getMethodName(),
SourceType.USER_DEFINED);
cu.setComment(CodeUnit.PLATE_COMMENT,
cu.setComment(CommentType.PLATE,
"this is a comment\ngo to the address 0x010028de");
});
@ -478,7 +478,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
public void testNavigationOnLabel() throws Exception {
// add a plate comment that has "entry" in it
CodeUnit cu = program.getListing().getCodeUnitAt(getAddr(0x0100292b));
tx(program, () -> cu.setComment(CodeUnit.PLATE_COMMENT, "go to entry"));
tx(program, () -> cu.setComment(CommentType.PLATE, "go to entry"));
assertTrue(cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 1, 8));
click(cb, 2);
@ -493,7 +493,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(getAddr(0x01001100));
tx(program, () -> {
cu.setComment(CodeUnit.PLATE_COMMENT, "go to FUN*");
cu.setComment(CommentType.PLATE, "go to FUN*");
});
assertTrue(cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 1, 8));
click(cb, 2);
@ -521,7 +521,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
int transactionID = program.startTransaction("test");
CodeUnit cu = program.getListing().getCodeUnitAt(getAddr(0x0100292b));
try {
cu.setComment(CodeUnit.PLATE_COMMENT, "go to FUN*");
cu.setComment(CommentType.PLATE, "go to FUN*");
}
finally {
program.endTransaction(transactionID, true);
@ -591,7 +591,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
private void createPlateComment(CodeUnit cu, String text) {
tx(program, () -> {
cu.setComment(CodeUnit.PLATE_COMMENT, text);
cu.setComment(CommentType.PLATE, text);
});
cb.updateNow();
}

View file

@ -280,7 +280,7 @@ public class PostCommentFieldFactoryTest extends AbstractGhidraHeadedIntegration
int transactionID = program.startTransaction("test");
try {
cu.setComment(CodeUnit.POST_COMMENT, "My post comment");
cu.setComment(CommentType.POST, "My post comment");
}
finally {
program.endTransaction(transactionID, true);
@ -1068,7 +1068,7 @@ public class PostCommentFieldFactoryTest extends AbstractGhidraHeadedIntegration
CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint());
int transactionID = program.startTransaction("test");
try {
cu.setComment(CodeUnit.POST_COMMENT, comment);
cu.setComment(CommentType.POST, comment);
}
finally {
program.endTransaction(transactionID, true);

View file

@ -139,7 +139,7 @@ public class PreCommentFieldFactoryTest extends AbstractGhidraHeadedIntegrationT
CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint());
int transactionID = program.startTransaction("test");
try {
cu.setComment(CodeUnit.PRE_COMMENT, comment);
cu.setComment(CommentType.PRE, comment);
}
finally {
program.endTransaction(transactionID, true);

View file

@ -177,7 +177,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
Instruction inst = program.getListing().getInstructionAt(addr(0x1004772));
String comment =
"This is a very long comment. I want this sentence to wrap to the next line so that I can test wrapping.";
inst.setComment(CodeUnit.EOL_COMMENT, comment);
inst.setComment(CommentType.EOL, comment);
program.endTransaction(id, true);
cb.updateNow();
Layout l = getLayout(addr(0x1004772));
@ -209,7 +209,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
Instruction inst = program.getListing().getInstructionAt(addr(0x1004772));
String comment =
"This is a very long comment. I want this sentence to wrap to the next line so that I can test wrapping.";
inst.setComment(CodeUnit.EOL_COMMENT, comment);
inst.setComment(CommentType.EOL, comment);
program.endTransaction(id, true);
Options opt = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS);
opt.setBoolean("EOL Comments Field.Enable Word Wrapping", true);

View file

@ -788,8 +788,8 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + i);
assertEquals("comment for plate " + i, cu.getComment(CodeUnit.PLATE_COMMENT));
cu.setComment(CommentType.PLATE, "comment for plate " + i);
assertEquals("comment for plate " + i, cu.getComment(CommentType.PLATE));
}
endTransaction();
@ -802,8 +802,8 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = iter.next();
expectedAddr = addr(n + 10);
assertEquals(expectedAddr, cu.getMinAddress());
assertNotNull(cu.getComment(CodeUnit.PLATE_COMMENT));
assertNull(cu.getComment(CodeUnit.EOL_COMMENT));
assertNotNull(cu.getComment(CommentType.PLATE));
assertNull(cu.getComment(CommentType.EOL));
++n;
}
}
@ -818,14 +818,14 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + i);
cu.setComment(CodeUnit.EOL_COMMENT, "comment for eol " + i);
cu.setComment(CommentType.PLATE, "comment for plate " + i);
cu.setComment(CommentType.EOL, "comment for eol " + i);
}
for (int i = 20; i < 30; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 5000));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + i);
cu.setComment(CodeUnit.EOL_COMMENT, "comment for eol " + i);
cu.setComment(CommentType.PLATE, "comment for plate " + i);
cu.setComment(CommentType.EOL, "comment for eol " + i);
}
endTransaction();
@ -855,16 +855,16 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
false);
CodeUnit cu = listing.getCodeUnitAt(addr(90));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + addr(90));
cu.setComment(CommentType.PLATE, "comment for plate " + addr(90));
cu = listing.getCodeUnitAt(addr(80));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + addr(80));
cu.setComment(CommentType.PLATE, "comment for plate " + addr(80));
cu = listing.getCodeUnitAt(addr(70));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + addr(70));
cu.setComment(CommentType.PLATE, "comment for plate " + addr(70));
cu = listing.getCodeUnitAt(addr(10));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + addr(10));
cu.setComment(CommentType.PLATE, "comment for plate " + addr(10));
endTransaction();
CodeUnitIterator iter =
@ -977,12 +977,12 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
false);
for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
cu.setComment(CodeUnit.EOL_COMMENT, "This is an eol comment " + i);
assertNotNull(cu.getComment(CodeUnit.EOL_COMMENT));
cu.setComment(CommentType.EOL, "This is an eol comment " + i);
assertNotNull(cu.getComment(CommentType.EOL));
}
for (int i = 100; i < 120; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i));
cu.setComment(CodeUnit.PRE_COMMENT, "This is pre comment " + i);
cu.setComment(CommentType.PRE, "This is pre comment " + i);
}
endTransaction();
AddressSet set = new AddressSet(addr(0), addr(5));

View file

@ -119,42 +119,42 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x100101c);
CodeUnit cu = program.getListing().getCodeUnitAt(a);
String[] comment = cu.getCommentAsArray(CodeUnit.PRE_COMMENT);
String[] comment = cu.getCommentAsArray(CommentType.PRE);
locs[0] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.PRE_COMMENT);
comment = cu.getCommentAsArray(CommentType.PRE);
locs[1] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
a = addr(0x100352f);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.EOL_COMMENT);
comment = cu.getCommentAsArray(CommentType.EOL);
locs[2] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 0, 5);
a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.EOL_COMMENT);
comment = cu.getCommentAsArray(CommentType.EOL);
locs[3] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 1, 5);
a = addr(0x10075ff);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.POST_COMMENT);
comment = cu.getCommentAsArray(CommentType.POST);
locs[4] = new PostCommentFieldLocation(program, a, null, comment, 0, 5);
a = addr(0x1003cf3);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.POST_COMMENT);
comment = cu.getCommentAsArray(CommentType.POST);
locs[5] = new PostCommentFieldLocation(program, a, null, comment, 0, 0);
a = addr(0x10030f0);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
comment = cu.getCommentAsArray(CommentType.PLATE);
locs[6] = new PlateFieldLocation(program, a, null, 0, 5, comment, -1);
a = addr(0x1003efc);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
comment = cu.getCommentAsArray(CommentType.PLATE);
locs[7] = new PlateFieldLocation(program, a, null, 0, 3, comment, -1);
// TODO add test for repeatable comments.
@ -168,12 +168,12 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x100101c);
CodeUnit cu = program.getListing().getCodeUnitAt(a);
String[] comment = cu.getCommentAsArray(CodeUnit.PRE_COMMENT);
String[] comment = cu.getCommentAsArray(CommentType.PRE);
locs[0] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.PRE_COMMENT);
comment = cu.getCommentAsArray(CommentType.PRE);
locs[1] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
return locs;
}
@ -184,12 +184,12 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x100352f);
CodeUnit cu = program.getListing().getCodeUnitAt(a);
String[] comment = cu.getCommentAsArray(CodeUnit.EOL_COMMENT);
String[] comment = cu.getCommentAsArray(CommentType.EOL);
locs[0] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 0, 5);
a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.EOL_COMMENT);
comment = cu.getCommentAsArray(CommentType.EOL);
locs[1] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 1, 5);
return locs;
}
@ -200,12 +200,12 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x10075ff);
CodeUnit cu = program.getListing().getCodeUnitAt(a);
String[] comment = cu.getCommentAsArray(CodeUnit.POST_COMMENT);
String[] comment = cu.getCommentAsArray(CommentType.POST);
locs[0] = new PostCommentFieldLocation(program, a, null, comment, 0, 5);
a = addr(0x1003cf3);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.POST_COMMENT);
comment = cu.getCommentAsArray(CommentType.POST);
locs[1] = new PostCommentFieldLocation(program, a, null, comment, 0, 0);
return locs;
}
@ -216,12 +216,12 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x10030f0);
CodeUnit cu = program.getListing().getCodeUnitAt(a);
String[] comment = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
String[] comment = cu.getCommentAsArray(CommentType.PLATE);
locs[0] = new PlateFieldLocation(program, a, null, 0, 5, comment, -1);
a = addr(0x1003efc);
cu = program.getListing().getCodeUnitAt(a);
comment = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT);
comment = cu.getCommentAsArray(CommentType.PLATE);
locs[1] = new PlateFieldLocation(program, a, null, 0, 3, comment, -1);
return locs;
}

View file

@ -174,14 +174,14 @@ public class CodeManagerTest extends AbstractGenericTest {
parseStatic(addr(0x2000), addr(0x2003));
CodeUnit cu = listing.getCodeUnitAt(addr(0x2000));
cu.setComment(CodeUnit.EOL_COMMENT, "eol comment");
cu.setComment(CodeUnit.PLATE_COMMENT, "plate comment");
cu.setComment(CommentType.EOL, "eol comment");
cu.setComment(CommentType.PLATE, "plate comment");
cu = listing.getCodeUnitAt(addr(0x2000));
String comment = cu.getComment(CodeUnit.EOL_COMMENT);
String comment = cu.getComment(CommentType.EOL);
assertNotNull(comment);
assertEquals("eol comment", comment);
comment = cu.getComment(CodeUnit.PLATE_COMMENT);
comment = cu.getComment(CommentType.PLATE);
assertNotNull(comment);
assertEquals("plate comment", comment);
}
@ -364,30 +364,30 @@ public class CodeManagerTest extends AbstractGenericTest {
InstructionIterator iter = listing.getInstructions(true);
while (iter.hasNext()) {
Instruction inst = iter.next();
inst.setComment(CodeUnit.PRE_COMMENT, "pre comment");
inst.setComment(CodeUnit.EOL_COMMENT, "eol comment");
inst.setComment(CommentType.PRE, "pre comment");
inst.setComment(CommentType.EOL, "eol comment");
assertEquals("pre comment", inst.getComment(CodeUnit.PRE_COMMENT));
assertEquals("eol comment", inst.getComment(CodeUnit.EOL_COMMENT));
assertEquals("pre comment", inst.getComment(CommentType.PRE));
assertEquals("eol comment", inst.getComment(CommentType.EOL));
}
Instruction inst = listing.getInstructionAt(addr(0x2000));
assertEquals("pre comment", inst.getComment(CodeUnit.PRE_COMMENT));
assertEquals("eol comment", inst.getComment(CodeUnit.EOL_COMMENT));
assertEquals("pre comment", inst.getComment(CommentType.PRE));
assertEquals("eol comment", inst.getComment(CommentType.EOL));
listing.clearComments(addr(0x2000), addr(0x2100));
inst = listing.getInstructionAfter(addr(0x2000));
assertNull(inst.getComment(CodeUnit.PRE_COMMENT));
assertNull(inst.getComment(CodeUnit.EOL_COMMENT));
assertNull(inst.getComment(CommentType.PRE));
assertNull(inst.getComment(CommentType.EOL));
inst = listing.getInstructionAt(addr(0x2000));
assertNull(inst.getComment(CodeUnit.PRE_COMMENT));
assertNull(inst.getComment(CodeUnit.EOL_COMMENT));
assertNull(inst.getComment(CommentType.PRE));
assertNull(inst.getComment(CommentType.EOL));
inst = listing.getInstructionBefore(addr(0x2000));
assertEquals("pre comment", inst.getComment(CodeUnit.PRE_COMMENT));
assertEquals("eol comment", inst.getComment(CodeUnit.EOL_COMMENT));
assertEquals("pre comment", inst.getComment(CommentType.PRE));
assertEquals("eol comment", inst.getComment(CommentType.EOL));
}
@Test
@ -536,7 +536,7 @@ public class CodeManagerTest extends AbstractGenericTest {
parseStatic(addr(0x1100), addr(0x1200));
MemoryBlock block = mem.getBlock(addr(0x1000));
CodeUnit cu = listing.getCodeUnitContaining(block.getEnd());
cu.setComment(CodeUnit.EOL_COMMENT, "eol comment");
cu.setComment(CommentType.EOL, "eol comment");
Address oldMin = cu.getMinAddress();
Address expectedNewMin = oldMin.addNoWrap(0x8000 - 0x1000);
@ -552,7 +552,7 @@ public class CodeManagerTest extends AbstractGenericTest {
cu = listing.getCodeUnitContaining(block.getEnd());
assertEquals(expectedNewMin, cu.getMinAddress());
assertNotNull(cu.getComment(CodeUnit.EOL_COMMENT));
assertNotNull(cu.getComment(CommentType.EOL));
assertEquals(12, cu.getIntProperty("Numbers"));
c = (SaveableColor) cu.getObjectProperty("FavoriteColor");
@ -576,32 +576,32 @@ public class CodeManagerTest extends AbstractGenericTest {
public void testCompositeDataComments() throws Exception {
CodeUnit cu = listing.getCodeUnitAt(addr(0x1741));
cu.setComment(CodeUnit.EOL_COMMENT, "eol comment");
cu.setComment(CodeUnit.PLATE_COMMENT, "plate comment");
cu.setComment(CodeUnit.POST_COMMENT, "post comment");
cu.setComment(CodeUnit.PRE_COMMENT, "pre comment");
cu.setComment(CommentType.EOL, "eol comment");
cu.setComment(CommentType.PLATE, "plate comment");
cu.setComment(CommentType.POST, "post comment");
cu.setComment(CommentType.PRE, "pre comment");
Structure struct = new StructureDataType("struct_1", 0);
struct.add(DWordDataType.dataType);
struct.add(DWordDataType.dataType);
Data structData = listing.createData(addr(0x1741), struct, struct.getLength());
assertEquals("eol comment", structData.getComment(CodeUnit.EOL_COMMENT));
assertEquals("plate comment", structData.getComment(CodeUnit.PLATE_COMMENT));
assertEquals("post comment", structData.getComment(CodeUnit.POST_COMMENT));
assertEquals("pre comment", structData.getComment(CodeUnit.PRE_COMMENT));
assertEquals("eol comment", structData.getComment(CommentType.EOL));
assertEquals("plate comment", structData.getComment(CommentType.PLATE));
assertEquals("post comment", structData.getComment(CommentType.POST));
assertEquals("pre comment", structData.getComment(CommentType.PRE));
Data firstComp = structData.getComponent(0);
assertEquals("eol comment", firstComp.getComment(CodeUnit.EOL_COMMENT));
assertEquals("plate comment", firstComp.getComment(CodeUnit.PLATE_COMMENT));
assertEquals("post comment", firstComp.getComment(CodeUnit.POST_COMMENT));
assertEquals("pre comment", firstComp.getComment(CodeUnit.PRE_COMMENT));
assertEquals("eol comment", firstComp.getComment(CommentType.EOL));
assertEquals("plate comment", firstComp.getComment(CommentType.PLATE));
assertEquals("post comment", firstComp.getComment(CommentType.POST));
assertEquals("pre comment", firstComp.getComment(CommentType.PRE));
structData.setComment(CodeUnit.EOL_COMMENT, "EOL");
assertEquals("EOL", firstComp.getComment(CodeUnit.EOL_COMMENT));
structData.setComment(CommentType.EOL, "EOL");
assertEquals("EOL", firstComp.getComment(CommentType.EOL));
firstComp.setComment(CodeUnit.POST_COMMENT, "POST");
assertEquals("POST", structData.getComment(CodeUnit.POST_COMMENT));
firstComp.setComment(CommentType.POST, "POST");
assertEquals("POST", structData.getComment(CommentType.POST));
}
@Test
@ -974,13 +974,13 @@ public class CodeManagerTest extends AbstractGenericTest {
// to 1-msec to avoid testing delays.
CodeUnit cu = listing.getCodeUnitAt(addr(0x1000));
cu.setComment(CodeUnit.EOL_COMMENT, "This is comment 1");
cu.setComment(CommentType.EOL, "This is comment 1");
Thread.sleep(1);// force a new date to get used
cu.setComment(CodeUnit.EOL_COMMENT, "This is a changed comment 2");
cu.setComment(CommentType.EOL, "This is a changed comment 2");
Thread.sleep(1);// force a new date to get used
cu.setComment(CodeUnit.EOL_COMMENT, "This is a changed comment 3");
cu.setComment(CommentType.EOL, "This is a changed comment 3");
CodeManager cm = ((ProgramDB) program).getCodeManager();
CommentHistory[] history = cm.getCommentHistory(addr(0x1000), CodeUnit.EOL_COMMENT);

View file

@ -60,7 +60,7 @@ class DebugUtils {
transactionID = program.startTransaction("Colorize CodeCompare");
Set<Entry<CodeUnit, TreeSet<AddressRange>>> entrySet = map.entrySet();
for (Entry<CodeUnit, TreeSet<AddressRange>> entry : entrySet) {
entry.getKey().setComment(CodeUnit.EOL_COMMENT, entry.getValue().toString());
entry.getKey().setComment(CommentType.EOL, entry.getValue().toString());
}
}
finally {

View file

@ -548,7 +548,7 @@ public class DecompileCallback {
private void encodeHeaderComment(Encoder encoder, Function func) throws IOException {
Address addr = func.getEntryPoint();
String text = listing.getComment(CodeUnit.PLATE_COMMENT, addr);
String text = listing.getComment(CommentType.PLATE, addr);
if (text != null) {
encoder.openElement(ELEM_COMMENT);
encoder.writeString(ATTRIB_TYPE, "header");

View file

@ -194,7 +194,7 @@ public class ObjectiveC2_DecompilerMessageAnalyzer extends AbstractAnalyzer {
if (instruction == null) {
return;
}
if (instruction.getComment(CodeUnit.EOL_COMMENT) != null) {
if (instruction.getComment(CommentType.EOL) != null) {
return;
}
@ -217,7 +217,7 @@ public class ObjectiveC2_DecompilerMessageAnalyzer extends AbstractAnalyzer {
builder.append(split[i]);
}
builder.delete(builder.length() - 2, builder.length() - 1);
instruction.setComment(CodeUnit.EOL_COMMENT, builder.toString());
instruction.setComment(CommentType.EOL, builder.toString());
}
private boolean isObjcCall(Program program, Varnode input, TaskMonitor monitor) {

View file

@ -2450,7 +2450,7 @@ public class DecompilerClangTest extends AbstractDecompilerTest {
}
private void setComment(String address, CommentType type, String comment) {
applyCmd(program, new SetCommentCmd(addr(address), type.ordinal(), comment));
applyCmd(program, new SetCommentCmd(addr(address), type, comment));
}
private void assertNextTokenIndex(int expectedIndex, int line, int... cols) {

View file

@ -29,7 +29,7 @@ import ghidra.file.formats.android.dex.util.DexUtil;
import ghidra.framework.model.DomainObject;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.PointerDataType;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.model.symbol.*;
@ -189,7 +189,7 @@ public class DexLoader extends AbstractProgramWrapperLoader {
if (program.getMemory().getInt(methodIndexAddress) == -1) {
program.getListing()
.setComment(methodIndexAddress, CodeUnit.PLATE_COMMENT, builder.toString());
.setComment(methodIndexAddress, CommentType.PLATE, builder.toString());
// Add placeholder symbol for external functions
String methodName = DexUtil.convertToString(header, item.getNameIndex());

View file

@ -31,10 +31,7 @@ import ghidra.program.model.data.StringDataType;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.NotEmptyException;
import ghidra.util.exception.NotFoundException;
import ghidra.util.exception.*;
import ghidra.util.task.TaskMonitor;
public abstract class FileFormatAnalyzer implements Analyzer {
@ -207,7 +204,7 @@ public abstract class FileFormatAnalyzer implements Analyzer {
}
protected boolean setPlateComment(Program program, Address address, String comment) {
SetCommentCmd cmd = new SetCommentCmd(address, CodeUnit.PLATE_COMMENT, comment);
SetCommentCmd cmd = new SetCommentCmd(address, CommentType.PLATE, comment);
return cmd.applyTo(program);
}

View file

@ -181,7 +181,7 @@ public abstract class ArtImageSections {
program.getMinAddress().getNewAddress(header.getImageBegin() + section.getOffset());
program.getSymbolTable().createLabel(address, name, SourceType.ANALYSIS);
program.getListing()
.setComment(address, CodeUnit.PLATE_COMMENT, "Size: " + section.getSize());
.setComment(address, CommentType.PLATE, "Size: " + section.getSize());
createFragment(program, address, section, name, monitor);
}
@ -210,7 +210,7 @@ public abstract class ArtImageSections {
String comment =
"Declaring Class: 0x" + Integer.toHexString(field.getDeclaringClass());
program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, comment);
program.getListing().setComment(address, CommentType.PLATE, comment);
address = address.add(dataType.getLength());
@ -230,7 +230,7 @@ public abstract class ArtImageSections {
ArtField artField = fieldGroup.getFieldList().get(0);
String comment =
"Declaring Class: 0x" + Integer.toHexString(artField.getDeclaringClass());
program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, comment);
program.getListing().setComment(address, CommentType.PLATE, comment);
}
address = address.add(dataType.getLength());
@ -261,7 +261,7 @@ public abstract class ArtImageSections {
program.getListing().createData(address, dataType);
String comment =
"Declaring Class: 0x" + Integer.toHexString(method.getDeclaringClass());
program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, comment);
program.getListing().setComment(address, CommentType.PLATE, comment);
address = address.add(dataType.getLength());
@ -282,7 +282,7 @@ public abstract class ArtImageSections {
ArtMethod artMethod = methodGroup.getMethodList().get(0);
String comment =
"Declaring Class: 0x" + Integer.toHexString(artMethod.getDeclaringClass());
program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, comment);
program.getListing().setComment(address, CommentType.PLATE, comment);
}
address = address.add(dataType.getLength());

View file

@ -255,8 +255,7 @@ public class DexMarkupInstructionsAnalyzer extends FileFormatAnalyzer {
String className = stringItem.getStringDataItem().getString();
setEquate(program, instruction.getMinAddress(), operand, className, classTypeIndex);
program.getListing()
.setComment(instruction.getMinAddress(), CodeUnit.EOL_COMMENT, className);
program.getListing().setComment(instruction.getMinAddress(), CommentType.EOL, className);
}
private void processString(Program program, Instruction instruction, int operand,
@ -300,7 +299,6 @@ public class DexMarkupInstructionsAnalyzer extends FileFormatAnalyzer {
String valueName = format(className, fieldName);
setEquate(program, instruction.getMinAddress(), operand, fieldName, fieldIndex);
program.getListing()
.setComment(instruction.getMinAddress(), CodeUnit.EOL_COMMENT, valueName);
program.getListing().setComment(instruction.getMinAddress(), CommentType.EOL, valueName);
}
}

View file

@ -20,9 +20,7 @@ import ghidra.app.util.importer.MessageLog;
import ghidra.program.flatapi.FlatProgramAPI;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.DataType;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Data;
import ghidra.program.model.listing.Program;
import ghidra.program.model.listing.*;
import ghidra.program.model.symbol.RefType;
import ghidra.util.task.TaskMonitor;
@ -112,8 +110,7 @@ public abstract class FBPK_Partition implements StructConverter {
}
program.getListing()
.setComment(address, CodeUnit.PLATE_COMMENT,
getName() + " - " + getPartitionIndex());
.setComment(address, CommentType.PLATE, getName() + " - " + getPartitionIndex());
api.createFragment(getName(), address, partitionDataType.getLength());

View file

@ -41,7 +41,7 @@ public abstract class FBPT implements StructConverter {
return;
}
String comment = "FBPT" + "\n" + "Num of entries: " + getEntries().size();
program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, comment);
program.getListing().setComment(address, CommentType.PLATE, comment);
api.createFragment(FBPK_Constants.FBPT, address, fbptDataType.getLength());
address = address.add(fbptDataType.getLength());
@ -59,7 +59,8 @@ public abstract class FBPT implements StructConverter {
log.appendMsg("Unable to apply FBPT Entry data, stopping - " + address);
return;
}
program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, entry.getName() + " - " + i++);
program.getListing()
.setComment(address, CommentType.PLATE, entry.getName() + " - " + i++);
api.createFragment(FBPK_Constants.FBPT, address, entryDataType.getLength());
address = address.add(entryDataType.getLength());
}

View file

@ -25,24 +25,12 @@ import ghidra.file.formats.android.dex.format.DexHeader;
import ghidra.file.formats.android.oat.oatdexfile.OatDexFile;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.Array;
import ghidra.program.model.data.ArrayDataType;
import ghidra.program.model.data.DWordDataType;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.Undefined1DataType;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Data;
import ghidra.program.model.listing.Program;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.Memory;
import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.model.scalar.Scalar;
import ghidra.program.model.symbol.Equate;
import ghidra.program.model.symbol.EquateTable;
import ghidra.program.model.symbol.RefType;
import ghidra.program.model.symbol.ReferenceManager;
import ghidra.program.model.symbol.SourceType;
import ghidra.program.model.symbol.Symbol;
import ghidra.program.model.symbol.SymbolTable;
import ghidra.program.model.symbol.*;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
@ -199,7 +187,7 @@ public class OatHeaderAnalyzer extends FileFormatAnalyzer {
Data data = createData(program, address, dataType);
Scalar scalar = data.getScalar(0);
Address toAddr = destinationBlock.getStart().add(scalar.getUnsignedValue());
program.getListing().setComment(address, CodeUnit.EOL_COMMENT, "->" + toAddr);
program.getListing().setComment(address, CommentType.EOL, "->" + toAddr);
}
catch (Exception e) {
log.appendException(e);

View file

@ -120,7 +120,7 @@ public class OatDexFile_S_T extends OatDexFile {
Address dataAddress = address.add(_offset);
program.getListing().setComment(dataAddress, CodeUnit.PLATE_COMMENT, getDexFileLocation());
program.getListing().setComment(dataAddress, CommentType.PLATE, getDexFileLocation());
program.getListing().clearCodeUnits(dataAddress, dataAddress, false, monitor);
Data data = program.getListing().createData(dataAddress, toDataType());

View file

@ -15,9 +15,7 @@
*/
package ghidra.file.formats.android.vdex;
import ghidra.app.util.bin.BinaryReader;
import ghidra.app.util.bin.ByteProvider;
import ghidra.app.util.bin.MemoryByteProvider;
import ghidra.app.util.bin.*;
import ghidra.app.util.importer.MessageLog;
import ghidra.file.analyzers.FileFormatAnalyzer;
import ghidra.file.formats.android.dex.format.DexHeader;
@ -25,11 +23,8 @@ import ghidra.file.formats.android.oat.OatUtilities;
import ghidra.file.formats.android.vdex.sections.DexSectionHeader_002;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.ArrayDataType;
import ghidra.program.model.data.ByteDataType;
import ghidra.program.model.data.DWordDataType;
import ghidra.program.model.data.DataType;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.util.task.TaskMonitor;
@ -90,8 +85,7 @@ public class VdexHeaderAnalyzer extends FileFormatAnalyzer {
monitor.checkCancelled();
program.getListing()
.setComment(address, CodeUnit.PLATE_COMMENT,
"quicken info table entry");
.setComment(address, CommentType.PLATE, "quicken info table entry");
createData(program, address, new DWordDataType());
address = address.add(4);
@ -130,7 +124,7 @@ public class VdexHeaderAnalyzer extends FileFormatAnalyzer {
if (sectionHeader != null) {
int dexSharedDataSize = sectionHeader.getDexSharedDataSize();
String comment = "dex_shared_data_size_ : 0x" + Integer.toHexString(dexSharedDataSize);
program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, comment);
program.getListing().setComment(address, CommentType.PLATE, comment);
DataType array = new ArrayDataType(BYTE, dexSharedDataSize, BYTE.getLength());
createData(program, address, array);
address = address.add(dexSharedDataSize);
@ -146,7 +140,7 @@ public class VdexHeaderAnalyzer extends FileFormatAnalyzer {
String comment =
"verifier_deps_size_ : 0x" + Integer.toHexString(vdexHeader.getVerifierDepsSize());
program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, comment);
program.getListing().setComment(address, CommentType.PLATE, comment);
int remainderSize = vdexHeader.getVerifierDepsSize();
@ -183,7 +177,7 @@ public class VdexHeaderAnalyzer extends FileFormatAnalyzer {
}
String comment = "quickening_info_size_ : 0x" + Integer.toHexString(quickeningInfoSize);
program.getListing().setComment(address, CodeUnit.PLATE_COMMENT, comment);
program.getListing().setComment(address, CommentType.PLATE, comment);
address = address.add(quickeningInfoSize);

View file

@ -25,7 +25,7 @@ import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.DataType;
import ghidra.program.model.lang.Language;
import ghidra.program.model.lang.Processor;
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.exception.CancelledException;
@ -76,8 +76,7 @@ public class CramFsAnalyzer extends AbstractAnalyzer {
DataType dataType = cramFsSuper.toDataType();
program.getListing().createData(minAddress, dataType);
program.getListing()
.setComment(minAddress, CodeUnit.PLATE_COMMENT,
cramFsSuper.getRoot().toString());
.setComment(minAddress, CommentType.PLATE, cramFsSuper.getRoot().toString());
int offset = cramFsSuper.getRoot().getOffsetAdjusted();
for (int i = 0; i < cramFsSuper.getFsid().getFiles() - 1; i++) {
@ -90,7 +89,7 @@ public class CramFsAnalyzer extends AbstractAnalyzer {
if (newInode.isFile()) {
Address inodeDataAddress = minAddress.add(newInode.getOffsetAdjusted());
program.getListing()
.setComment(inodeDataAddress, CodeUnit.PLATE_COMMENT,
.setComment(inodeDataAddress, CommentType.PLATE,
newInode.getName() + " Data/Bytes\n");
}
@ -98,7 +97,7 @@ public class CramFsAnalyzer extends AbstractAnalyzer {
program.getListing().createData(inodeAddress, inodeDataType);
program.getListing()
.setComment(inodeAddress, CodeUnit.PLATE_COMMENT,
.setComment(inodeAddress, CommentType.PLATE,
newInode.getName() + "\n" + newInode.toString());
offset += inodeDataType.getLength();

View file

@ -23,7 +23,7 @@ import ghidra.file.analyzers.FileFormatAnalyzer;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
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.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
@ -154,7 +154,9 @@ public class Ext4Analyzer extends FileFormatAnalyzer {
Ext4Inode inode = new Ext4Inode(reader);
DataType dataType = inode.toDataType();
createData(program, address, dataType);
program.getListing().setComment(address, CodeUnit.EOL_COMMENT, "0x" + (Integer.toHexString(inodesPerGroup * i + j )));
program.getListing()
.setComment(address, CommentType.EOL,
"0x" + (Integer.toHexString(inodesPerGroup * i + j)));
address = address.add(superBlock.getS_inode_size());
reader.setPointerIndex(address.getOffset());
monitor.incrementProgress(1);

View file

@ -15,9 +15,8 @@
*/
package ghidra.file.formats.ext4;
import java.util.List;
import java.io.IOException;
import java.util.List;
import ghidra.app.cmd.comments.SetCommentCmd;
import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
@ -203,7 +202,7 @@ public class NewExt4Analyzer extends FileFormatAnalyzer {
@Override
protected boolean setPlateComment( Program program, Address address, String comment ) {
SetCommentCmd cmd = new SetCommentCmd( address, CodeUnit.PLATE_COMMENT, comment );
SetCommentCmd cmd = new SetCommentCmd(address, CommentType.PLATE, comment);
if ( program.getMemory( ).contains( address ) ) {
return cmd.applyTo( program );
}

View file

@ -103,7 +103,8 @@ public class CFStringAnalyzer extends AbstractAnalyzer {
String comment = makeComment(cFString);
program.getListing().setComment(currentAddress, CodeUnit.REPEATABLE_COMMENT,
program.getListing()
.setComment(currentAddress, CommentType.REPEATABLE,
"\"" + comment + "\",00");
if (program.getSymbolTable().getGlobalSymbol(symbolString,

View file

@ -64,7 +64,8 @@ public class TestAnalyzer extends AbstractAnalyzer {
//don't need to check this..
}
program.getListing().setComment(currentAddress, CodeUnit.PLATE_COMMENT,
program.getListing()
.setComment(currentAddress, CommentType.PLATE,
"Address = " + currentAddress.toString());
currentAddress = currentAddress.add(data.getLength());

View file

@ -28,7 +28,7 @@ import ghidra.program.database.ProgramDB;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.TerminatedStringDataType;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Data;
import ghidra.program.model.symbol.*;
import ghidra.test.ToyProgramBuilder;
@ -226,7 +226,7 @@ public class GnuDemanglerTest extends AbstractGenericTest {
assertEquals("AP_HAL::HAL::Callbacks", s.getParentNamespace().getName(true));
assertEquals("typeinfo for AP_HAL::HAL::Callbacks",
program.getListing().getComment(CodeUnit.PLATE_COMMENT, addr("01001000")));
program.getListing().getComment(CommentType.PLATE, addr("01001000")));
Data d = program.getListing().getDefinedDataAt(addr("01001000"));
assertNotNull(d);
@ -259,7 +259,7 @@ public class GnuDemanglerTest extends AbstractGenericTest {
assertEquals("AP_HAL::HAL::Callbacks", s.getParentNamespace().getName(true));
assertEquals("typeinfo name for AP_HAL::HAL::Callbacks",
program.getListing().getComment(CodeUnit.PLATE_COMMENT, addr("01001000")));
program.getListing().getComment(CommentType.PLATE, addr("01001000")));
Data d = program.getListing().getDefinedDataAt(addr("01001000"));
assertNotNull(d);

View file

@ -114,7 +114,7 @@ public class CreateTypeDescriptorBackgroundCmd
Data nameData = DataUtilities.createData(program, arrayAddr, charArray,
charArray.getLength(), getClearDataMode());
nameData.setComment(CodeUnit.EOL_COMMENT, "TypeDescriptor.name");
nameData.setComment(CommentType.EOL, "TypeDescriptor.name");
return true;
}

View file

@ -233,7 +233,7 @@ public class EHDataTypeUtilities {
String dataTypeName, String suffix, Address address, DataApplyOptions applyOptions) {
Listing listing = program.getListing();
String existingComment = listing.getComment(CodeUnit.PLATE_COMMENT, address);
String existingComment = listing.getComment(CommentType.PLATE, address);
if (!applyOptions.shouldCreateComments()) {
return existingComment;
}
@ -245,7 +245,7 @@ public class EHDataTypeUtilities {
String appliedSuffix = (suffix != null) ? (suffix) : "";
String appliedExisting = (existingComment != null) ? (existingComment + "\n") : "";
String appliedComment = appliedExisting + appliedPrefix + dataTypeName + appliedSuffix;
listing.setComment(address, CodeUnit.PLATE_COMMENT, appliedComment);
listing.setComment(address, CommentType.PLATE, appliedComment);
return appliedComment;
}
return existingComment;

View file

@ -120,7 +120,7 @@ public class CreateVfTableBackgroundCmd extends AbstractCreateDataBackgroundCmd<
String prefixString = ((demangledTypeDescriptor != null)
? (demangledTypeDescriptor + Namespace.DELIMITER)
: "");
data.setComment(CodeUnit.EOL_COMMENT,
data.setComment(CommentType.EOL,
"terminator for " + prefixString + VF_TABLE_LABEL);
return true;
}

View file

@ -209,7 +209,7 @@ public class PropagateExternalParametersAnalyzer extends AbstractAnalyzer {
Parameter param = params[index];
DataType dt = param.getDataType();
String name = param.getName();
SetCommentCmd cmd = new SetCommentCmd(cu.getAddress(), CodeUnit.EOL_COMMENT,
SetCommentCmd cmd = new SetCommentCmd(cu.getAddress(), CommentType.EOL,
dt.getDisplayName() + " " + name + " for " + externalFunctionName);
cmd.applyTo(currentProgram);
@ -310,17 +310,16 @@ public class PropagateExternalParametersAnalyzer extends AbstractAnalyzer {
private void createComment(Address dataAddress, String newComment, PushedParamInfo info) {
Listing listing = currentProgram.getListing();
String plateComment = listing.getComment(CodeUnit.PLATE_COMMENT, dataAddress);
String plateComment = listing.getComment(CommentType.PLATE, dataAddress);
if (plateComment == null) {
// add a comment
SetCommentCmd cmd = new SetCommentCmd(dataAddress, CodeUnit.PLATE_COMMENT, newComment);
SetCommentCmd cmd = new SetCommentCmd(dataAddress, CommentType.PLATE, newComment);
cmd.applyTo(currentProgram);
}
else if (!plateComment.contains(info.getCalledFunctionName())) {
// update the existing comment
String updatedComment = plateComment + "\n" + newComment;
SetCommentCmd cmd =
new SetCommentCmd(dataAddress, CodeUnit.PLATE_COMMENT, updatedComment);
SetCommentCmd cmd = new SetCommentCmd(dataAddress, CommentType.PLATE, updatedComment);
cmd.applyTo(currentProgram);
}
}

View file

@ -93,7 +93,7 @@ class ApplySymbols {
if (!"NONAME".equals(name)) {
preComment += " (" + name + ")";
}
PdbUtil.appendComment(program, address, preComment, CodeUnit.PRE_COMMENT);
PdbUtil.appendComment(program, address, preComment, CommentType.PRE);
continue;
}
@ -108,7 +108,7 @@ class ApplySymbols {
if (length == 0) {
// avoid creating symbol which may correspond to inline function code
PdbUtil.appendComment(program, address, "Symbol Ref: {@symbol " + name + "}",
CodeUnit.PRE_COMMENT);
CommentType.PRE);
continue;
}

View file

@ -21,7 +21,7 @@ import ghidra.app.util.PseudoInstruction;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.Composite;
import ghidra.program.model.data.Structure;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.program.model.listing.Program;
import ghidra.util.Conv;
@ -52,10 +52,10 @@ final class PdbUtil {
* @param program program
* @param address listing address
* @param text comment text
* @param commentType comment type ({@link CodeUnit}
* @param commentType comment type
*/
final static void appendComment(Program program, Address address, String text,
int commentType) {
CommentType commentType) {
String comment = program.getListing().getComment(commentType, address);
if (comment != null) {

View file

@ -20,8 +20,7 @@ import java.util.Map;
import ghidra.app.cmd.comments.SetCommentCmd;
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.util.Msg;
/**
@ -118,7 +117,7 @@ public class BlockCommentsManager {
private void finalizeBlockComments(Program program, long addressDelta) {
for (Map.Entry<Address, String> entry : blockPreComments.entrySet()) {
appendBlockComment(program, entry.getKey().add(addressDelta), entry.getValue(),
CodeUnit.PRE_COMMENT);
CommentType.PRE);
}
for (Map.Entry<Address, String> entry : blockPostComments.entrySet()) {
CodeUnit codeUnit = program.getListing()
@ -129,14 +128,13 @@ public class BlockCommentsManager {
}
else {
Address endCodeUnitAddress = codeUnit.getAddress();
appendBlockComment(program, endCodeUnitAddress, entry.getValue(),
CodeUnit.POST_COMMENT);
appendBlockComment(program, endCodeUnitAddress, entry.getValue(), CommentType.POST);
}
}
}
private void appendBlockComment(Program program, Address address, String text,
int commentType) {
CommentType commentType) {
String comment = program.getListing().getComment(commentType, address);
comment = (comment == null) ? text : comment + "\n" + text;
SetCommentCmd.createComment(program, address, comment, commentType);

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