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.address.*;
import ghidra.program.model.data.PointerDataType; import ghidra.program.model.data.PointerDataType;
import ghidra.program.model.lang.*; 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.listing.Instruction;
import ghidra.program.model.symbol.SourceType; import ghidra.program.model.symbol.SourceType;
import ghidra.program.model.util.CodeUnitInsertionException; import ghidra.program.model.util.CodeUnitInsertionException;
@ -409,8 +409,7 @@ public class PopulateDemoTrace extends GhidraScript {
trace.getCodeManager() trace.getCodeManager()
.codeUnits() .codeUnits()
.getAt(0, cloneLabel.getAddress()) .getAt(0, cloneLabel.getAddress())
.setComment( .setComment(CommentType.EOL, "Pretend this is a syscall");
CodeUnit.EOL_COMMENT, "Pretend this is a syscall");
/** /**
* Stub out "exit" * Stub out "exit"
@ -419,8 +418,7 @@ public class PopulateDemoTrace extends GhidraScript {
trace.getCodeManager() trace.getCodeManager()
.codeUnits() .codeUnits()
.getAt(0, exitLabel.getAddress()) .getAt(0, exitLabel.getAddress())
.setComment( .setComment(CommentType.EOL, "Pretend this is a syscall");
CodeUnit.EOL_COMMENT, "Pretend this is a syscall");
/** /**
* "Launch" the program by initializing RIP and RSP of the main thread * "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() TraceData frame = trace.getCodeManager()
.definedData() .definedData()
.create(span, spPlusParams, platform, structure); .create(span, spPlusParams, platform, structure);
frame.setComment(CodeUnit.PRE_COMMENT, getDescription()); frame.setComment(CommentType.PRE, getDescription());
TraceReferenceManager refs = trace.getReferenceManager(); TraceReferenceManager refs = trace.getReferenceManager();
refs.clearReferencesFrom(span, frame.getRange()); refs.clearReferencesFrom(span, frame.getRange());
refs.clearReferencesTo(span, frame.getRange()); refs.clearReferencesTo(span, frame.getRange());

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -95,7 +95,7 @@ public class ListingUnwoundFrame extends AbstractUnwoundFrame<WatchValue> {
*/ */
private static Integer getLevel(TraceData data) { private static Integer getLevel(TraceData data) {
// TODO: Should this go into a property instead? // TODO: Should this go into a property instead?
String comment = data.getComment(CodeUnit.PRE_COMMENT); String comment = data.getComment(CommentType.PRE);
if (comment == null) { if (comment == null) {
return null; return null;
} }
@ -213,7 +213,7 @@ public class ListingUnwoundFrame extends AbstractUnwoundFrame<WatchValue> {
@Override @Override
public String getDescription() { public String getDescription() {
return frame.getComment(CodeUnit.PRE_COMMENT); return frame.getComment(CommentType.PRE);
} }
@Override @Override

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -714,8 +714,8 @@ public class DebuggerCopyPlanTest extends AbstractGhidraHeadedDebuggerTest {
TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE); TraceMemoryFlag.READ, TraceMemoryFlag.EXECUTE);
Listing listing = view.getListing(); Listing listing = view.getListing();
listing.setComment(tb.addr(0x55550123), CodeUnit.EOL_COMMENT, "Test EOL Comment"); listing.setComment(tb.addr(0x55550123), CommentType.EOL, "Test EOL Comment");
listing.setComment(tb.addr(0x55550321), CodeUnit.PLATE_COMMENT, "Test Plate Comment"); listing.setComment(tb.addr(0x55550321), CommentType.PLATE, "Test Plate Comment");
} }
Address paddr = tb.addr(stSpace, 0x55550000); 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(Set.of(tb.addr(stSpace, 0x55550123), tb.addr(stSpace, 0x55550321)), addresses);
assertEquals("Test EOL Comment", 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", assertEquals("Test Plate Comment",
listing.getComment(CodeUnit.PLATE_COMMENT, tb.addr(stSpace, 0x55550321))); listing.getComment(CommentType.PLATE, tb.addr(stSpace, 0x55550321)));
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -399,28 +399,28 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
// pass // pass
} }
assertNull(i4004.getComment(CodeUnit.EOL_COMMENT)); assertNull(i4004.getComment(CommentType.EOL));
try (Transaction tx = b.startTransaction()) { 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)); assertEquals("My EOL Comment", i4004.getComment(CommentType.EOL));
assertNull(i4006.getComment(CodeUnit.EOL_COMMENT)); 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()) { try (Transaction tx = b.startTransaction()) {
i4004.setCommentAsArray(CodeUnit.PRE_COMMENT, new String[] { "My", "Pre", "Comment" }); 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" }, assertArrayEquals(new String[] { "My", "Pre", "Comment" },
i4004.getCommentAsArray(CodeUnit.PRE_COMMENT)); i4004.getCommentAsArray(CommentType.PRE));
assertArrayEquals(EMPTY_STRING_ARRAY, i4006.getCommentAsArray(CodeUnit.PRE_COMMENT)); assertArrayEquals(EMPTY_STRING_ARRAY, i4006.getCommentAsArray(CommentType.PRE));
assertEquals("My\nPre\nComment", i4004.getComment(CodeUnit.PRE_COMMENT)); assertEquals("My\nPre\nComment", i4004.getComment(CommentType.PRE));
try (Transaction tx = b.startTransaction()) { try (Transaction tx = b.startTransaction()) {
i4004.setCommentAsArray(CodeUnit.PRE_COMMENT, null); i4004.setCommentAsArray(CodeUnit.PRE_COMMENT, null);
i4006.setCommentAsArray(CodeUnit.PRE_COMMENT, null); // NOP i4006.setCommentAsArray(CodeUnit.PRE_COMMENT, null); // NOP
} }
assertNull(i4004.getComment(CodeUnit.PRE_COMMENT)); assertNull(i4004.getComment(CommentType.PRE));
TraceInstruction i4004_10; TraceInstruction i4004_10;
DBTraceCommentAdapter commentAdapter = b.trace.getCommentAdapter(); DBTraceCommentAdapter commentAdapter = b.trace.getCommentAdapter();
@ -436,25 +436,25 @@ public class DBTraceCodeUnitTest extends AbstractGhidraHeadlessIntegrationTest
assertEquals(Lifespan.nowOn(0), c4004.getLifespan()); assertEquals(Lifespan.nowOn(0), c4004.getLifespan());
i4004_10 = b.addInstruction(10, b.addr(0x4004), b.host); 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(CommentType.PRE, "Get this back in the mix");
i4004_10.setComment(CodeUnit.EOL_COMMENT, "A different comment"); i4004_10.setComment(CommentType.EOL, "A different comment");
} }
assertEquals(Lifespan.span(0, 9), c4004.getLifespan()); 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()) { try (Transaction tx = b.startTransaction()) {
commentAdapter.clearComments(Lifespan.nowOn(0), b.range(0x4000, 0x5000), commentAdapter.clearComments(Lifespan.nowOn(0), b.range(0x4000, 0x5000),
CodeUnit.EOL_COMMENT); CodeUnit.EOL_COMMENT);
} }
assertNull(i4004.getComment(CodeUnit.EOL_COMMENT)); assertNull(i4004.getComment(CommentType.EOL));
assertEquals("Get this back in the mix", i4004_10.getComment(CodeUnit.PRE_COMMENT)); assertEquals("Get this back in the mix", i4004_10.getComment(CommentType.PRE));
try (Transaction tx = b.startTransaction()) { try (Transaction tx = b.startTransaction()) {
commentAdapter.clearComments(Lifespan.nowOn(0), b.range(0x4000, 0x5000), commentAdapter.clearComments(Lifespan.nowOn(0), b.range(0x4000, 0x5000),
CodeUnit.NO_COMMENT); CodeUnit.NO_COMMENT);
} }
assertNull(i4004.getComment(CodeUnit.EOL_COMMENT)); assertNull(i4004.getComment(CommentType.EOL));
assertNull(i4004_10.getComment(CodeUnit.PRE_COMMENT)); assertNull(i4004_10.getComment(CommentType.PRE));
} }
@Test @Test

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -31,7 +31,7 @@
import ghidra.app.script.GhidraScript; import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address; 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.listing.Instruction;
import ghidra.program.model.symbol.*; import ghidra.program.model.symbol.*;
@ -147,14 +147,14 @@ public class AutoRenameSimpleLabels extends GhidraScript {
// now also propogate the repeatable comment up as well // 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); operand_addr);
if (comment != null) { if (comment != null) {
if (currentProgram.getListing().getComment(CodeUnit.REPEATABLE_COMMENT, if (currentProgram.getListing().getComment(CommentType.REPEATABLE,
startAddr) == null) { startAddr) == null) {
//println("updating comment for " + operand +" is " + comment); //println("updating comment for " + operand +" is " + comment);
currentProgram.getListing().setComment(startAddr, currentProgram.getListing()
CodeUnit.REPEATABLE_COMMENT, comment); .setComment(startAddr, CommentType.REPEATABLE, comment);
} }
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,8 +19,7 @@
import ghidra.app.script.GhidraScript; import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
import ghidra.program.model.listing.CodeUnit; import ghidra.program.model.listing.*;
import ghidra.program.model.listing.Listing;
public class DeleteDeadDefaultPlatesScript extends GhidraScript { public class DeleteDeadDefaultPlatesScript extends GhidraScript {
@ -36,14 +35,14 @@ public class DeleteDeadDefaultPlatesScript extends GhidraScript {
set = currentSelection; set = currentSelection;
} }
int updateCount=0; int updateCount=0;
AddressIterator iter = listing.getCommentAddressIterator(CodeUnit.PLATE_COMMENT, set, true); AddressIterator iter = listing.getCommentAddressIterator(CommentType.PLATE, set, true);
while (iter.hasNext()) { while (iter.hasNext()) {
Address addr = iter.next(); Address addr = iter.next();
CodeUnit cu = listing.getCodeUnitAt(addr); CodeUnit cu = listing.getCodeUnitAt(addr);
if (cu != null) { 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)) { if (comment.length == 1 && comment[0].equals(DEAD_PLATE)) {
cu.setComment(CodeUnit.PLATE_COMMENT, null); cu.setComment(CommentType.PLATE, null);
++updateCount; ++updateCount;
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,8 +19,7 @@
import ghidra.app.script.GhidraScript; import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
import ghidra.program.model.listing.CodeUnit; import ghidra.program.model.listing.*;
import ghidra.program.model.listing.Listing;
public class DeleteEmptyPlateCommentsScript extends GhidraScript { public class DeleteEmptyPlateCommentsScript extends GhidraScript {
@ -36,14 +35,14 @@ public class DeleteEmptyPlateCommentsScript extends GhidraScript {
set = currentSelection; set = currentSelection;
} }
int updateCount=0; int updateCount=0;
AddressIterator iter = listing.getCommentAddressIterator(CodeUnit.PLATE_COMMENT, set, true); AddressIterator iter = listing.getCommentAddressIterator(CommentType.PLATE, set, true);
while (iter.hasNext()) { while (iter.hasNext()) {
Address addr = iter.next(); Address addr = iter.next();
CodeUnit cu = listing.getCodeUnitAt(addr); CodeUnit cu = listing.getCodeUnitAt(addr);
if (cu != null) { 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)) { if (comment.length == 1 && comment[0].equals(EMPTY_PLATE)) {
cu.setComment(CodeUnit.PLATE_COMMENT, null); cu.setComment(CommentType.PLATE, null);
++updateCount; ++updateCount;
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -18,11 +18,8 @@
//@category Update //@category Update
import ghidra.app.script.GhidraScript; import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address; import ghidra.program.model.address.*;
import ghidra.program.model.address.AddressIterator; import ghidra.program.model.listing.*;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Listing;
public class DeleteExitCommentsScript extends GhidraScript { public class DeleteExitCommentsScript extends GhidraScript {
@ -38,13 +35,13 @@ public class DeleteExitCommentsScript extends GhidraScript {
set = currentSelection; set = currentSelection;
} }
int updateCount=0; int updateCount=0;
AddressIterator iter = listing.getCommentAddressIterator(CodeUnit.POST_COMMENT, set, true); AddressIterator iter = listing.getCommentAddressIterator(CommentType.POST, set, true);
while (iter.hasNext()) { while (iter.hasNext()) {
Address addr = iter.next(); Address addr = iter.next();
CodeUnit cu = listing.getCodeUnitAt(addr); 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)) { if (comment.length == 1 && comment[0].endsWith(EXIT_COMMENT)) {
cu.setComment(CodeUnit.POST_COMMENT, null); cu.setComment(CommentType.POST, null);
++updateCount; ++updateCount;
} }
} }

View file

@ -1,13 +1,12 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,12 +19,12 @@
//@category Analysis //@category Analysis
import java.util.*;
import ghidra.app.script.GhidraScript; import ghidra.app.script.GhidraScript;
import ghidra.program.model.lang.Register; import ghidra.program.model.lang.Register;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
import java.util.*;
public class RegisterTouchesPerFunction extends GhidraScript public class RegisterTouchesPerFunction extends GhidraScript
{ {
private final static String DIVIDER = "*************************************************************\r\n"; private final static String DIVIDER = "*************************************************************\r\n";
@ -65,7 +64,7 @@ public class RegisterTouchesPerFunction extends GhidraScript
monitor.setMessage("Analyzing registers in " + func.getName()); monitor.setMessage("Analyzing registers in " + func.getName());
String comment = list.getComment(CodeUnit.PLATE_COMMENT, func.getBody().getMinAddress()); String comment = list.getComment(CommentType.PLATE, func.getBody().getMinAddress());
if (comment != null && comment.indexOf("TOUCHED REGISTER SUMMARY") > -1) if (comment != null && comment.indexOf("TOUCHED REGISTER SUMMARY") > -1)
return; return;
@ -163,7 +162,7 @@ public class RegisterTouchesPerFunction extends GhidraScript
buffer.append(" "+getString(pushPops, 8)); 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) private String getString(Collection<String> c, int itemsPerLine)

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -38,7 +38,7 @@ import java.util.List;
import ghidra.app.script.GhidraScript; import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address; 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.listing.Listing;
import ghidra.program.model.mem.Memory; import ghidra.program.model.mem.Memory;
import ghidra.program.model.symbol.*; import ghidra.program.model.symbol.*;
@ -99,7 +99,7 @@ public class ZapBCTRScript extends GhidraScript {
// insert funcName as EOL comment and // insert funcName as EOL comment and
// add a mnemonic ref from instAddr to funcAddr // 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, listing.getInstructionAt(instAddr).addMnemonicReference(funcAddr, RefType.COMPUTED_CALL,
SourceType.USER_DEFINED); SourceType.USER_DEFINED);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -325,23 +325,23 @@ public class CodeUnitInfoPasteCmd implements Command<Program> {
String[] repeatableComment = info.getRepeatableComment(); String[] repeatableComment = info.getRepeatableComment();
if (plateComment != null) { if (plateComment != null) {
String[] oldComment = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT); String[] oldComment = cu.getCommentAsArray(CommentType.PLATE);
cu.setCommentAsArray(CodeUnit.PLATE_COMMENT, appendComment(oldComment, plateComment)); cu.setCommentAsArray(CodeUnit.PLATE_COMMENT, appendComment(oldComment, plateComment));
} }
if (preComment != null) { if (preComment != null) {
String[] oldComment = cu.getCommentAsArray(CodeUnit.PRE_COMMENT); String[] oldComment = cu.getCommentAsArray(CommentType.PRE);
cu.setCommentAsArray(CodeUnit.PRE_COMMENT, appendComment(oldComment, preComment)); cu.setCommentAsArray(CodeUnit.PRE_COMMENT, appendComment(oldComment, preComment));
} }
if (postComment != null) { if (postComment != null) {
String[] oldComment = cu.getCommentAsArray(CodeUnit.POST_COMMENT); String[] oldComment = cu.getCommentAsArray(CommentType.POST);
cu.setCommentAsArray(CodeUnit.POST_COMMENT, appendComment(oldComment, postComment)); cu.setCommentAsArray(CodeUnit.POST_COMMENT, appendComment(oldComment, postComment));
} }
if (eolComment != null) { if (eolComment != null) {
String[] oldComment = cu.getCommentAsArray(CodeUnit.EOL_COMMENT); String[] oldComment = cu.getCommentAsArray(CommentType.EOL);
cu.setCommentAsArray(CodeUnit.EOL_COMMENT, appendComment(oldComment, eolComment)); cu.setCommentAsArray(CodeUnit.EOL_COMMENT, appendComment(oldComment, eolComment));
} }
if (repeatableComment != null) { if (repeatableComment != null) {
String[] oldComment = cu.getCommentAsArray(CodeUnit.REPEATABLE_COMMENT); String[] oldComment = cu.getCommentAsArray(CommentType.REPEATABLE);
cu.setCommentAsArray(CodeUnit.REPEATABLE_COMMENT, cu.setCommentAsArray(CodeUnit.REPEATABLE_COMMENT,
appendComment(oldComment, repeatableComment)); appendComment(oldComment, repeatableComment));
} }

View file

@ -26,7 +26,7 @@ import ghidra.program.model.listing.*;
public class SetCommentCmd implements Command<Program> { public class SetCommentCmd implements Command<Program> {
private Address address; private Address address;
private int commentType; private CommentType commentType;
private String comment; private String comment;
private String cmdName; private String cmdName;
private String message; 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 addr address of code unit where comment will be placed
* @param commentType valid comment type (see CodeUnit) * @param commentType valid comment type (see CodeUnit)
* @param comment comment for code unit * @param comment comment for code unit
* @deprecated Use {@link #SetCommentCmd(Address, CommentType, String)} instead
*/ */
@Deprecated
public SetCommentCmd(Address addr, int commentType, String comment) { 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.address = addr;
this.commentType = commentType; this.commentType = commentType;
this.comment = comment; this.comment = comment;
@ -115,9 +130,29 @@ public class SetCommentCmd implements Command<Program> {
* @param commentType the type of comment ({@link CodeUnit#PLATE_COMMENT}, * @param commentType the type of comment ({@link CodeUnit#PLATE_COMMENT},
* {@link CodeUnit#PRE_COMMENT}, {@link CodeUnit#EOL_COMMENT}, {@link CodeUnit#POST_COMMENT}, * {@link CodeUnit#PRE_COMMENT}, {@link CodeUnit#EOL_COMMENT}, {@link CodeUnit#POST_COMMENT},
* {@link CodeUnit#REPEATABLE_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, public static void createComment(Program program, Address addr, String comment,
int commentType) { 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); SetCommentCmd commentCmd = new SetCommentCmd(addr, commentType, comment);
commentCmd.applyTo(program); commentCmd.applyTo(program);
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -83,31 +83,31 @@ public class SetCommentsCmd implements Command<Program> {
CodeUnit cu = getCodeUnit(program); CodeUnit cu = getCodeUnit(program);
if (cu != null) { if (cu != null) {
if (commentChanged(cu.getComment(CodeUnit.PRE_COMMENT), preComment)) { if (commentChanged(cu.getComment(CommentType.PRE), preComment)) {
String updatedPreComment = CommentUtils.fixupAnnotations(preComment, program); String updatedPreComment = CommentUtils.fixupAnnotations(preComment, program);
updatedPreComment = CommentUtils.sanitize(updatedPreComment); 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); String updatedPostComment = CommentUtils.fixupAnnotations(postComment, program);
updatedPostComment = CommentUtils.sanitize(updatedPostComment); 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); String updatedEOLComment = CommentUtils.fixupAnnotations(eolComment, program);
updatedEOLComment = CommentUtils.sanitize(updatedEOLComment); 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); String updatedPlateComment = CommentUtils.fixupAnnotations(plateComment, program);
updatedPlateComment = CommentUtils.sanitize(updatedPlateComment); 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 = String updatedRepeatableComment =
CommentUtils.fixupAnnotations(repeatableComment, program); CommentUtils.fixupAnnotations(repeatableComment, program);
updatedRepeatableComment = CommentUtils.sanitize(updatedRepeatableComment); updatedRepeatableComment = CommentUtils.sanitize(updatedRepeatableComment);
cu.setComment(CodeUnit.REPEATABLE_COMMENT, updatedRepeatableComment); cu.setComment(CommentType.REPEATABLE, updatedRepeatableComment);
} }
} }
return true; return true;

View file

@ -184,7 +184,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
createFragment(sectionDT.getName(), sectionStart, sectionDT.getLength()); createFragment(sectionDT.getName(), sectionStart, sectionDT.getLength());
CodeUnit cu = listing.getCodeUnitAt(addr(offset)); CodeUnit cu = listing.getCodeUnitAt(addr(offset));
cu.setComment(CodeUnit.PLATE_COMMENT, cu.setComment(CommentType.PLATE,
"#" + i + ") " + name + " at 0x" + Long.toHexString(sections[i].getAddress())); "#" + i + ") " + name + " at 0x" + Long.toHexString(sections[i].getAddress()));
if (sections[i].getType() == ElfSectionHeaderConstants.SHT_NOBITS || if (sections[i].getType() == ElfSectionHeaderConstants.SHT_NOBITS ||
@ -203,7 +203,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
} }
cu = listing.getCodeUnitAt(dataStart); 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())); Long.toHexString(sections[i].getSize()));
} }
} }
@ -228,7 +228,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
for (int i = 0; i < programHeaders.length; i++) { for (int i = 0; i < programHeaders.length; i++) {
monitor.checkCancelled(); monitor.checkCancelled();
Data d = array.getComponent(i); 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()); Address addr = addr(programHeaders[i].getOffset());
@ -292,7 +292,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
dynamicType != null ? (dynamicType.name + " - " + dynamicType.description) dynamicType != null ? (dynamicType.name + " - " + dynamicType.description)
: ("DT_0x" + StringUtilities.pad(Integer.toHexString(tagType), '0', 8)); : ("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); Data valueData = dynamicData.getComponent(1);
@ -323,7 +323,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
if (dynamicStringTable != null) { if (dynamicStringTable != null) {
String str = dynamicStringTable.readString(reader, dynamic.getValue()); String str = dynamicStringTable.readString(reader, dynamic.getValue());
if (str != null && str.length() != 0) { 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 { try {
Address currAddr = symbolTableAddr.add(j * symbolTable2.getEntrySize()); 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())); name + " at 0x" + Long.toHexString(symbols[j].getValue()));
} }
catch (Exception e) { catch (Exception e) {
@ -418,7 +418,7 @@ public class ElfBinaryAnalysisCommand extends FlatProgramAPI
createData(relocationTableAddress, dataType); createData(relocationTableAddress, dataType);
} }
else { else {
listing.setComment(relocationTableAddress, CodeUnit.PRE_COMMENT, listing.setComment(relocationTableAddress, CommentType.PRE,
"ELF Relocation Table (markup not yet supported)"); "ELF Relocation Table (markup not yet supported)");
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -194,7 +194,7 @@ public class CliMetadataTokenAnalyzer extends AbstractAnalyzer {
int strIndex = (int) strIndexOp.getUnsignedValue(); int strIndex = (int) strIndexOp.getUnsignedValue();
inst.setComment(CodeUnit.EOL_COMMENT, inst.setComment(CommentType.EOL,
"\"" + metaStream.getUserStringsStream().getUserString(strIndex) + "\""); "\"" + metaStream.getUserStringsStream().getUserString(strIndex) + "\"");
} }
@ -229,7 +229,7 @@ public class CliMetadataTokenAnalyzer extends AbstractAnalyzer {
private void markMetadataRow(Instruction inst, CliAbstractTableRow tableRow, private void markMetadataRow(Instruction inst, CliAbstractTableRow tableRow,
String prependComment, String appendComment, CliStreamMetadata stream) { 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)); tableRow.getShortRepresentation(stream), appendComment));
} }

View file

@ -678,7 +678,7 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
func.updateFunction(ccName, duffFunc.getReturn(), func.updateFunction(ccName, duffFunc.getReturn(),
Arrays.asList(duffFunc.getParameters()), fut, true, SourceType.ANALYSIS); Arrays.asList(duffFunc.getParameters()), fut, true, SourceType.ANALYSIS);
if (duffComment != null && !duffComment.isBlank()) { if (duffComment != null && !duffComment.isBlank()) {
new SetCommentCmd(func.getEntryPoint(), CodeUnit.PLATE_COMMENT, duffComment) new SetCommentCmd(func.getEntryPoint(), CommentType.PLATE, duffComment)
.applyTo(program); .applyTo(program);
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -410,7 +410,7 @@ class MinGWPseudoRelocationHandler {
else { else {
// TODO: Not sure how to preserve relationship to external symbol // TODO: Not sure how to preserve relationship to external symbol
// which refers to Library // which refers to Library
listing.setComment(nextExtAddr, CodeUnit.PLATE_COMMENT, listing.setComment(nextExtAddr, CommentType.PLATE,
"External Location: " + extSym.getName(true)); "External Location: " + extSym.getName(true));
String name = extLoc.getOriginalImportedName(); String name = extLoc.getOriginalImportedName();
boolean demangle = true; boolean demangle = true;

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -67,6 +67,7 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
inspectFunction(program, function, state, monitor); inspectFunction(program, function, state, monitor);
} }
catch (Exception e) { catch (Exception e) {
// do nothing
} }
} }
@ -96,7 +97,7 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
Instruction instruction = instructionIterator.next(); Instruction instruction = instructionIterator.next();
if (isCallingObjcMsgSend(instruction)) { 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... if (eolComment != null) {//if a comment already exists, ignore...
continue; continue;
@ -178,11 +179,9 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
return symbolTable.createNameSpace(parentNamespace, namespaceName, return symbolTable.createNameSpace(parentNamespace, namespaceName,
SourceType.ANALYSIS); SourceType.ANALYSIS);
} }
catch (DuplicateNameException e) { catch (InvalidInputException | DuplicateNameException e) {
return null;
} }
catch (InvalidInputException e) {
}
return null;
} }
} }
@ -224,7 +223,7 @@ public class ObjectiveC1_MessageAnalyzer extends AbstractAnalyzer {
pullNameThrough(state, toAddress, null); pullNameThrough(state, toAddress, null);
if (state.isValid()) { if (state.isValid()) {
instruction.setComment(CodeUnit.EOL_COMMENT, state.toString()); instruction.setComment(CommentType.EOL, state.toString());
setReference(fromAddress, state); setReference(fromAddress, state);
break; break;
} }

View file

@ -83,7 +83,7 @@ public class ObjectiveC2_MessageAnalyzer extends AbstractAnalyzer {
Instruction instruction = instructionIterator.next(); Instruction instruction = instructionIterator.next();
if (isCallingObjcMsgSend(instruction)) { 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... if (eolComment != null) {//if a comment already exists, ignore...
continue; continue;
@ -196,7 +196,7 @@ public class ObjectiveC2_MessageAnalyzer extends AbstractAnalyzer {
} }
if (currentClass != null && currentMethod != null) { if (currentClass != null && currentMethod != null) {
instruction.setComment(CodeUnit.EOL_COMMENT, "[" + currentClass + " " + instruction.setComment(CommentType.EOL, "[" + currentClass + " " +
currentMethod + "]"); currentMethod + "]");
break; break;
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -185,7 +185,7 @@ public class CreateBookmarkDialog extends DialogComponentProvider {
} }
private String getEolComment(CodeUnit codeUnit) { private String getEolComment(CodeUnit codeUnit) {
String comment = codeUnit.getComment(CodeUnit.EOL_COMMENT); String comment = codeUnit.getComment(CommentType.EOL);
if (comment == null) { if (comment == null) {
return ""; return "";
} }

View file

@ -35,6 +35,7 @@ import ghidra.app.util.viewer.field.AnnotatedStringHandler;
import ghidra.app.util.viewer.field.CommentUtils; import ghidra.app.util.viewer.field.CommentUtils;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.CodeUnit; import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.CommentType;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
/** /**
@ -93,11 +94,11 @@ public class CommentsDialog extends ReusableDialogComponentProvider implements K
setTitle("Set Comment(s) at Address " + cu.getMinAddress()); setTitle("Set Comment(s) at Address " + cu.getMinAddress());
codeUnit = cu; codeUnit = cu;
preComment = cu.getComment(CodeUnit.PRE_COMMENT); preComment = cu.getComment(CommentType.PRE);
postComment = cu.getComment(CodeUnit.POST_COMMENT); postComment = cu.getComment(CommentType.POST);
eolComment = cu.getComment(CodeUnit.EOL_COMMENT); eolComment = cu.getComment(CommentType.EOL);
plateComment = cu.getComment(CodeUnit.PLATE_COMMENT); plateComment = cu.getComment(CommentType.PLATE);
repeatableComment = cu.getComment(CodeUnit.REPEATABLE_COMMENT); repeatableComment = cu.getComment(CommentType.REPEATABLE);
preComment = (preComment == null) ? "" : preComment; preComment = (preComment == null) ? "" : preComment;
postComment = (postComment == null) ? "" : postComment; postComment = (postComment == null) ? "" : postComment;

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -94,19 +94,19 @@ class CommentTableModel extends AddressBasedTableModel<CommentRowObject> {
continue; continue;
} }
if (cu.getComment(CodeUnit.PRE_COMMENT) != null) { if (cu.getComment(CommentType.PRE) != null) {
accumulator.add(new CommentRowObject(commentAddr, CodeUnit.PRE_COMMENT)); 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)); 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)); 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)); 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)); accumulator.add(new CommentRowObject(commentAddr, CodeUnit.REPEATABLE_COMMENT));
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -36,7 +36,8 @@ import ghidra.program.model.symbol.*;
import ghidra.program.model.util.AddressSetPropertyMap; import ghidra.program.model.util.AddressSetPropertyMap;
import ghidra.program.model.util.CodeUnitInsertionException; import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.Msg; import ghidra.util.Msg;
import ghidra.util.exception.*; import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.InvalidInputException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
public class AddressTable { public class AddressTable {
@ -496,7 +497,7 @@ public class AddressTable {
} }
if (comment != null) { if (comment != null) {
program.getListing().setComment(topAddress, CodeUnit.EOL_COMMENT, comment); program.getListing().setComment(topAddress, CommentType.EOL, comment);
} }
if (flagNewCode && newCodeFound) { if (flagNewCode && newCodeFound) {

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,7 +19,7 @@ import ghidra.app.cmd.comments.SetCommentCmd;
import ghidra.app.cmd.data.CreateDataCmd; import ghidra.app.cmd.data.CreateDataCmd;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.*; 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.listing.Program;
import ghidra.program.model.util.CodeUnitInsertionException; import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
@ -100,12 +100,10 @@ public abstract class GccAnalysisClass {
* @param addr the address where data is created * @param addr the address where data is created
* @param dt the type for the data * @param dt the type for the data
* @param comment the comment about the data * @param comment the comment about the data
* @param commentType the type of comment ({@link CodeUnit#PLATE_COMMENT}, * @param commentType the {@link CommentType type of comment }
* {@link CodeUnit#PRE_COMMENT}, {@link CodeUnit#EOL_COMMENT}, {@link CodeUnit#POST_COMMENT},
* {@link CodeUnit#REPEATABLE_COMMENT})
*/ */
protected static void createAndCommentData(Program program, Address addr, DataType dt, protected static void createAndCommentData(Program program, Address addr, DataType dt,
String comment, int commentType) { String comment, CommentType commentType) {
createData(program, addr, dt); createData(program, addr, dt);
SetCommentCmd.createComment(program, addr, comment, commentType); SetCommentCmd.createComment(program, addr, comment, commentType);
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -288,11 +288,11 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
Address csMaxAddr = callSite.getMaxAddress(); Address csMaxAddr = callSite.getMaxAddress();
String startTryComment = "try { // try from " + csMinAddr + " to " + csMaxAddr + String startTryComment = "try { // try from " + csMinAddr + " to " + csMaxAddr +
" has its CatchHandler @ " + lpAddr; " 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)) { if (existingComment == null || !existingComment.contains(startTryComment)) {
String mergedComment = StringUtilities.mergeStrings(existingComment, startTryComment); String mergedComment = StringUtilities.mergeStrings(existingComment, startTryComment);
SetCommentCmd setCommentCmd = SetCommentCmd setCommentCmd =
new SetCommentCmd(csMinAddr, CodeUnit.PRE_COMMENT, mergedComment); new SetCommentCmd(csMinAddr, CommentType.PRE, mergedComment);
setCommentCmd.applyTo(program); setCommentCmd.applyTo(program);
} }
} }
@ -305,11 +305,11 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
Address commentAddr = csMaxCodeUnit.getMinAddress(); Address commentAddr = csMaxCodeUnit.getMinAddress();
String endTryComment = "} // end try from " + csMinAddr + " to " + csMaxAddr; String endTryComment = "} // end try from " + csMinAddr + " to " + csMaxAddr;
String existingComment = String existingComment =
program.getListing().getComment(CodeUnit.POST_COMMENT, commentAddr); program.getListing().getComment(CommentType.POST, commentAddr);
if (existingComment == null || !existingComment.contains(endTryComment)) { if (existingComment == null || !existingComment.contains(endTryComment)) {
String mergedComment = StringUtilities.mergeStrings(existingComment, endTryComment); String mergedComment = StringUtilities.mergeStrings(existingComment, endTryComment);
SetCommentCmd setCommentCmd = SetCommentCmd setCommentCmd =
new SetCommentCmd(commentAddr, CodeUnit.POST_COMMENT, mergedComment); new SetCommentCmd(commentAddr, CommentType.POST, mergedComment);
setCommentCmd.applyTo(program); setCommentCmd.applyTo(program);
} }
} }
@ -322,11 +322,10 @@ public class GccExceptionAnalyzer extends AbstractAnalyzer {
typeInfos.stream().map(a -> getCatchParamInfo(a)).collect(Collectors.joining(", ")); typeInfos.stream().map(a -> getCatchParamInfo(a)).collect(Collectors.joining(", "));
String startCatchComment = String startCatchComment =
"catch(" + typeString + ") { ... } // from try @ " + csAddr + " with catch @ " + lpAddr; "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)) { if (existingComment == null || !existingComment.contains(startCatchComment)) {
String mergedComment = StringUtilities.mergeStrings(existingComment, startCatchComment); String mergedComment = StringUtilities.mergeStrings(existingComment, startCatchComment);
SetCommentCmd setCommentCmd = SetCommentCmd setCommentCmd = new SetCommentCmd(lpAddr, CommentType.PRE, mergedComment);
new SetCommentCmd(lpAddr, CodeUnit.PRE_COMMENT, mergedComment);
setCommentCmd.applyTo(program); 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. // // TODO If we can determine the length of the catch handler we could mark its end too.
// Address lpMaxAddr = ?; // Address lpMaxAddr = ?;
// String endCatchComment = "} // end catchHandler()"; // 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)) { // if (existingComment == null || !existingComment.contains(endCatchComment)) {
// String mergedComment = // String mergedComment =
// StringUtilities.mergeStrings(existingComment, endCatchComment); // StringUtilities.mergeStrings(existingComment, endCatchComment);

View file

@ -5,9 +5,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -24,7 +24,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.RegionDescriptor;
import ghidra.app.plugin.exceptionhandlers.gcc.structures.ehFrame.*; import ghidra.app.plugin.exceptionhandlers.gcc.structures.ehFrame.*;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.ByteDataType; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.mem.MemoryBlock; import ghidra.program.model.mem.MemoryBlock;
@ -176,8 +176,7 @@ abstract class AbstractFrameSection implements CieSource {
private void createPlateComment(Address curAddress, String fdeComment) { private void createPlateComment(Address curAddress, String fdeComment) {
SetCommentCmd commentCmd = SetCommentCmd commentCmd = new SetCommentCmd(curAddress, CommentType.PLATE, fdeComment);
new SetCommentCmd(curAddress, CodeUnit.PLATE_COMMENT, fdeComment);
commentCmd.applyTo(program); commentCmd.applyTo(program);
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -22,7 +22,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.structures.ehFrame.*;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressOutOfBoundsException; import ghidra.program.model.address.AddressOutOfBoundsException;
import ghidra.program.model.data.DataType; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.mem.MemoryBlock; import ghidra.program.model.mem.MemoryBlock;
@ -127,7 +127,7 @@ public class EhFrameHeaderSection {
dataCmd.applyTo(program); dataCmd.applyTo(program);
SetCommentCmd commentCmd = SetCommentCmd commentCmd =
new SetCommentCmd(curAddress, CodeUnit.EOL_COMMENT, "Encoded FDE count"); new SetCommentCmd(curAddress, CommentType.EOL, "Encoded FDE count");
commentCmd.applyTo(program); commentCmd.applyTo(program);
curAddress = curAddress.add(ctx.getEncodedLength()); curAddress = curAddress.add(ctx.getEncodedLength());
@ -169,7 +169,7 @@ public class EhFrameHeaderSection {
dataCmd.applyTo(program); dataCmd.applyTo(program);
SetCommentCmd commentCmd = SetCommentCmd commentCmd =
new SetCommentCmd(curAddress, CodeUnit.EOL_COMMENT, "Encoded eh_frame_ptr"); new SetCommentCmd(curAddress, CommentType.EOL, "Encoded eh_frame_ptr");
commentCmd.applyTo(program); commentCmd.applyTo(program);
curAddress = curAddress.add(ctx.getEncodedLength()); curAddress = curAddress.add(ctx.getEncodedLength());
@ -196,7 +196,7 @@ public class EhFrameHeaderSection {
fde_table.create(curAddress, fdeTblDecoder, fdeTableCnt); fde_table.create(curAddress, fdeTblDecoder, fdeTableCnt);
SetCommentCmd commentCmd = SetCommentCmd commentCmd =
new SetCommentCmd(curAddress, CodeUnit.PLATE_COMMENT, "Frame Description Entry Table"); new SetCommentCmd(curAddress, CommentType.PLATE, "Frame Description Entry Table");
commentCmd.applyTo(program); commentCmd.applyTo(program);
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -134,7 +134,7 @@ public class Cie extends GccAnalysisClass {
* appropriate comment for the new structure. * appropriate comment for the new structure.
*/ */
String comment = "(CIE) Length"; 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); program.getMemory().getBytes(addr, enc_length);
curSize += DWORD_LEN; curSize += DWORD_LEN;
@ -161,7 +161,7 @@ public class Cie extends GccAnalysisClass {
* appropriate comment for the new structure. * appropriate comment for the new structure.
*/ */
String comment = "(CIE) ID"; 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); program.getMemory().getBytes(addr, enc_cieId);
cieId = (int) GccAnalysisUtils.readDWord(program, addr); cieId = (int) GccAnalysisUtils.readDWord(program, addr);
@ -184,7 +184,7 @@ public class Cie extends GccAnalysisClass {
* appropriate comment for the new structure. * appropriate comment for the new structure.
*/ */
String comment = "(CIE) Version"; 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); version = GccAnalysisUtils.readByte(program, addr);
curSize += BYTE_LEN; curSize += BYTE_LEN;
@ -208,7 +208,7 @@ public class Cie extends GccAnalysisClass {
* and sets an appropriate comment for the new structure. * and sets an appropriate comment for the new structure.
*/ */
String comment = "(CIE) Augmentation String"; 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); Data dataAt = program.getListing().getDataAt(addr);
if (dataAt == null) { if (dataAt == null) {
throw new ExceptionHandlerFrameException( throw new ExceptionHandlerFrameException(
@ -236,7 +236,7 @@ public class Cie extends GccAnalysisClass {
* appropriate comment for the new structure. * appropriate comment for the new structure.
*/ */
String comment = "(CIE) Pointer Size"; 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); ptrSize = GccAnalysisUtils.readByte(program, addr);
curSize += BYTE_LEN; curSize += BYTE_LEN;
@ -258,7 +258,7 @@ public class Cie extends GccAnalysisClass {
* appropriate comment for the new structure. * appropriate comment for the new structure.
*/ */
String comment = "(CIE) Segment Size"; 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); segmentSize = GccAnalysisUtils.readByte(program, addr);
curSize += BYTE_LEN; curSize += BYTE_LEN;
@ -285,7 +285,7 @@ public class Cie extends GccAnalysisClass {
codeAlignFactor = (int) uleb128.asLong(); codeAlignFactor = (int) uleb128.asLong();
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment, createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
curSize += uleb128.getLength(); curSize += uleb128.getLength();
@ -312,7 +312,7 @@ public class Cie extends GccAnalysisClass {
dataAlignFactor = (int) sleb128.asLong(); dataAlignFactor = (int) sleb128.asLong();
createAndCommentData(program, addr, SignedLeb128DataType.dataType, comment, createAndCommentData(program, addr, SignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
curSize += sleb128.getLength(); 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; curSize += encodedLen;
return addr.add(encodedLen); return addr.add(encodedLen);
@ -382,7 +382,7 @@ public class Cie extends GccAnalysisClass {
augmentationDataLength = (int) uleb128.asLong(); augmentationDataLength = (int) uleb128.asLong();
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment, createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
curSize += uleb128.getLength(); curSize += uleb128.getLength();
@ -430,8 +430,7 @@ public class Cie extends GccAnalysisClass {
initialInstructionCount = intLength - curSize; initialInstructionCount = intLength - curSize;
arrayCmd = new CreateArrayCmd(addr, initialInstructionCount, new ByteDataType(), BYTE_LEN); arrayCmd = new CreateArrayCmd(addr, initialInstructionCount, new ByteDataType(), BYTE_LEN);
arrayCmd.applyTo(program); arrayCmd.applyTo(program);
SetCommentCmd.createComment(program, addr, "(CIE) Initial Instructions", SetCommentCmd.createComment(program, addr, "(CIE) Initial Instructions", CommentType.EOL);
CodeUnit.EOL_COMMENT);
initialInstructions = new byte[initialInstructionCount]; initialInstructions = new byte[initialInstructionCount];
int numBytesRead = program.getMemory().getBytes(addr, initialInstructions); int numBytesRead = program.getMemory().getBytes(addr, initialInstructions);
@ -525,8 +524,8 @@ public class Cie extends GccAnalysisClass {
} }
private void markEndOfFrame(Address addr) { private void markEndOfFrame(Address addr) {
createAndCommentData(program, addr, dwordDT, "End of Frame", CodeUnit.EOL_COMMENT); createAndCommentData(program, addr, dwordDT, "End of Frame", CommentType.EOL);
SetCommentCmd commentCmd = new SetCommentCmd(addr, CodeUnit.PLATE_COMMENT, "END OF FRAME"); SetCommentCmd commentCmd = new SetCommentCmd(addr, CommentType.PLATE, "END OF FRAME");
commentCmd.applyTo(program); commentCmd.applyTo(program);
} }
@ -549,7 +548,7 @@ public class Cie extends GccAnalysisClass {
if (intLength == 0xffffffff) { if (intLength == 0xffffffff) {
hasExtLength = true; hasExtLength = true;
String comment = "(CIE) Extended Length"; 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); program.getMemory().getBytes(addr, enc_extLength);
addr = addr.add(QWORD_LEN); addr = addr.add(QWORD_LEN);
curSize += QWORD_LEN; curSize += QWORD_LEN;
@ -620,7 +619,7 @@ public class Cie extends GccAnalysisClass {
String lsdaComment = "(CIE Augmentation Data) LSDA Personality Function Pointer Encoding"; String lsdaComment = "(CIE Augmentation Data) LSDA Personality Function Pointer Encoding";
createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex), createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex),
new DwarfEncodingModeDataType(), lsdaComment, CodeUnit.EOL_COMMENT); new DwarfEncodingModeDataType(), lsdaComment, CommentType.EOL);
} }
private void processFdeEncoding(Address augmentationDataAddr, int augmentationDataIndex, private void processFdeEncoding(Address augmentationDataAddr, int augmentationDataIndex,
@ -630,7 +629,7 @@ public class Cie extends GccAnalysisClass {
createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex), createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex),
new DwarfEncodingModeDataType(), "(CIE Augmentation Data) FDE Encoding", new DwarfEncodingModeDataType(), "(CIE Augmentation Data) FDE Encoding",
CodeUnit.EOL_COMMENT); CommentType.EOL);
} }
private DwarfEHDecoder processPersonalityEncoding(Address augmentationDataAddr, private DwarfEHDecoder processPersonalityEncoding(Address augmentationDataAddr,
@ -643,7 +642,7 @@ public class Cie extends GccAnalysisClass {
String prsnltyComment = "(CIE Augmentation Data) Personality Function Pointer Encoding"; String prsnltyComment = "(CIE Augmentation Data) Personality Function Pointer Encoding";
createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex), createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex),
new DwarfEncodingModeDataType(), prsnltyComment, CodeUnit.EOL_COMMENT); new DwarfEncodingModeDataType(), prsnltyComment, CommentType.EOL);
return personalityDecoder; return personalityDecoder;
} }
@ -660,7 +659,7 @@ public class Cie extends GccAnalysisClass {
createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex), createAndCommentData(program, augmentationDataAddr.add(augmentationDataIndex),
prnsFuncPtrDt, prnsFuncPtrDt,
"(CIE Augmentation Data) Personality Function Pointer (" + personalityFuncAddr + ")", "(CIE Augmentation Data) Personality Function Pointer (" + personalityFuncAddr + ")",
CodeUnit.EOL_COMMENT); CommentType.EOL);
program.getReferenceManager().addMemoryReference( program.getReferenceManager().addMemoryReference(
augmentationDataAddr.add(augmentationDataIndex), personalityFuncAddr, RefType.DATA, augmentationDataAddr.add(augmentationDataIndex), personalityFuncAddr, RefType.DATA,

View file

@ -5,9 +5,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,7 +20,7 @@ import ghidra.app.cmd.comments.SetCommentCmd;
import ghidra.app.plugin.exceptionhandlers.gcc.GccAnalysisUtils; import ghidra.app.plugin.exceptionhandlers.gcc.GccAnalysisUtils;
import ghidra.app.util.bin.LEB128Info; import ghidra.app.util.bin.LEB128Info;
import ghidra.program.model.address.Address; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.util.Msg; 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()); Msg.info(this, sb.toString());
} }

View file

@ -1,13 +1,12 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -22,7 +21,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.datatype.DwarfEncodingModeDataTyp
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressOutOfBoundsException; import ghidra.program.model.address.AddressOutOfBoundsException;
import ghidra.program.model.data.*; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
@ -101,7 +100,8 @@ public class ExceptionHandlerFrameHeader {
dataCmd.applyTo(prog); dataCmd.applyTo(prog);
/* Set a comment on the newly created structure */ /* 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); commentCmd.applyTo(prog);
// Set the class members accordingly // Set the class members accordingly

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -177,7 +177,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
* and sets an appropriate comment for the new structure. * and sets an appropriate comment for the new structure.
*/ */
String comment = "(FDE) Length"; String comment = "(FDE) Length";
createAndCommentData(program, addr, dwordDT, comment, CodeUnit.EOL_COMMENT); createAndCommentData(program, addr, dwordDT, comment, CommentType.EOL);
intLength = program.getMemory().getInt(addr); intLength = program.getMemory().getInt(addr);
return addr.add(DWORD_LEN); return addr.add(DWORD_LEN);
@ -202,7 +202,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
DataType locType = new DWordDataType(); DataType locType = new DWordDataType();
int locTypeSize = locType.getLength(); 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); intPtr = (int) GccAnalysisUtils.readDWord(program, addr);
@ -266,7 +266,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
DataType encodedDt = cie.getFDEDecoder().getDataType(program); 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) { if (pcBeginAddr.getOffset() != 0x0) {
program.getReferenceManager() program.getReferenceManager()
.addMemoryReference(addr, pcBeginAddr, RefType.DATA, SourceType.ANALYSIS, 0); .addMemoryReference(addr, pcBeginAddr, RefType.DATA, SourceType.ANALYSIS, 0);
@ -324,7 +324,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
} }
int dtLength = dataType.getLength(); int dtLength = dataType.getLength();
createAndCommentData(program, addr, dataType, comment, CodeUnit.EOL_COMMENT); createAndCommentData(program, addr, dataType, comment, CommentType.EOL);
curSize += dtLength; curSize += dtLength;
@ -358,7 +358,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
intAugmentationDataLength = (int) uleb128.asLong(); intAugmentationDataLength = (int) uleb128.asLong();
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment, createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
curSize += uleb128.getLength(); curSize += uleb128.getLength();
@ -377,7 +377,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
* Create a new Augmentation Data field at the specified address * Create a new Augmentation Data field at the specified address
* and sets an appropriate comment for the new structure. * 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]; this.augmentationData = new byte[intAugmentationDataLength];
program.getMemory().getBytes(addr, augmentationData); program.getMemory().getBytes(addr, augmentationData);
@ -406,7 +406,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
} }
SetCommentCmd.createComment(program, addr, "(FDE) Call Frame Instructions", SetCommentCmd.createComment(program, addr, "(FDE) Call Frame Instructions",
CodeUnit.EOL_COMMENT); CommentType.EOL);
callFrameInstructions = new byte[instructionLength]; callFrameInstructions = new byte[instructionLength];
program.getMemory().getBytes(addr, callFrameInstructions); program.getMemory().getBytes(addr, callFrameInstructions);
@ -512,8 +512,8 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
} }
private void markEndOfFrame(Address addr) { private void markEndOfFrame(Address addr) {
createAndCommentData(program, addr, dwordDT, "End of Frame", CodeUnit.EOL_COMMENT); createAndCommentData(program, addr, dwordDT, "End of Frame", CommentType.EOL);
SetCommentCmd commentCmd = new SetCommentCmd(addr, CodeUnit.PLATE_COMMENT, "END OF FRAME"); SetCommentCmd commentCmd = new SetCommentCmd(addr, CommentType.PLATE, "END OF FRAME");
commentCmd.applyTo(program); commentCmd.applyTo(program);
} }
@ -526,7 +526,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
if (intLength == -1) { if (intLength == -1) {
hasExtLength = true; hasExtLength = true;
String comment = "(FDE) Extended Length"; 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); // prog.getMemory().getBytes(addr, extLength);
addr = addr.add(QWORD_LEN); addr = addr.add(QWORD_LEN);
curSize += QWORD_LEN; curSize += QWORD_LEN;
@ -631,7 +631,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {
String lsdaComment = "(FDE Augmentation Data) LSDA Data Pointer"; String lsdaComment = "(FDE Augmentation Data) LSDA Data Pointer";
createAndCommentData(program, augmentationDataAddr, lsdaDecoder.getDataType(program), createAndCommentData(program, augmentationDataAddr, lsdaDecoder.getDataType(program),
lsdaComment, CodeUnit.EOL_COMMENT); lsdaComment, CommentType.EOL);
if (augmentationDataAddr.equals(lsdaAddr)) { if (augmentationDataAddr.equals(lsdaAddr)) {
// decoded a reference that returned here -- a null reference // decoded a reference that returned here -- a null reference

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,7 +20,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.*;
import ghidra.app.util.bin.LEB128Info; import ghidra.app.util.bin.LEB128Info;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.SignedLeb128DataType; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
@ -83,7 +83,7 @@ public class LSDAActionRecord extends GccAnalysisClass {
addr = createNextActionRef(addr); addr = createNextActionRef(addr);
SetCommentCmd commentCmd = SetCommentCmd commentCmd =
new SetCommentCmd(address, CodeUnit.PLATE_COMMENT, "(LSDA) Action Record"); new SetCommentCmd(address, CommentType.PLATE, "(LSDA) Action Record");
commentCmd.applyTo(program); commentCmd.applyTo(program);
nextAddress = addr; nextAddress = addr;
@ -98,7 +98,7 @@ public class LSDAActionRecord extends GccAnalysisClass {
typeFilter = (int) sleb128.asLong(); typeFilter = (int) sleb128.asLong();
createAndCommentData(program, addr, SignedLeb128DataType.dataType, comment, createAndCommentData(program, addr, SignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
size += sleb128.getLength(); size += sleb128.getLength();
@ -120,7 +120,7 @@ public class LSDAActionRecord extends GccAnalysisClass {
} }
createAndCommentData(program, addr, SignedLeb128DataType.dataType, comment, createAndCommentData(program, addr, SignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
size += sleb128.getLength(); size += sleb128.getLength();

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,7 +20,7 @@ import java.util.*;
import ghidra.app.cmd.comments.SetCommentCmd; import ghidra.app.cmd.comments.SetCommentCmd;
import ghidra.app.plugin.exceptionhandlers.gcc.RegionDescriptor; import ghidra.app.plugin.exceptionhandlers.gcc.RegionDescriptor;
import ghidra.program.model.address.Address; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
@ -89,7 +89,7 @@ public class LSDAActionTable {
nextAddress = address; nextAddress = address;
SetCommentCmd commentCmd = SetCommentCmd commentCmd =
new SetCommentCmd(tableAddress, CodeUnit.PLATE_COMMENT, "(LSDA) Action Table"); new SetCommentCmd(tableAddress, CommentType.PLATE, "(LSDA) Action Table");
commentCmd.applyTo(program); commentCmd.applyTo(program);
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,7 +21,7 @@ import ghidra.app.util.bin.LEB128Info;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.program.model.data.UnsignedLeb128DataType; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.symbol.RefType; import ghidra.program.model.symbol.RefType;
@ -96,7 +96,7 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
landingPadAddr = lpStart.add(getLandingPadOffset()); landingPadAddr = lpStart.add(getLandingPadOffset());
SetCommentCmd commentCmd = SetCommentCmd commentCmd =
new SetCommentCmd(baseAddr, CodeUnit.PLATE_COMMENT, "(LSDA) Call Site Record"); new SetCommentCmd(baseAddr, CommentType.PLATE, "(LSDA) Call Site Record");
commentCmd.applyTo(program); commentCmd.applyTo(program);
if (program.getMemory().contains(callSiteBaseAddr)) { if (program.getMemory().contains(callSiteBaseAddr)) {
@ -124,7 +124,7 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
DataType encodedDt = decoder.getDataType(program); DataType encodedDt = decoder.getDataType(program);
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT); createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
return addr.add(encodedLen); return addr.add(encodedLen);
} }
@ -141,7 +141,7 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
DataType encodedDt = decoder.getDataType(program); DataType encodedDt = decoder.getDataType(program);
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT); createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
return addr.add(encodedLen); return addr.add(encodedLen);
} }
@ -158,7 +158,7 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
DataType encodedDt = decoder.getDataType(program); DataType encodedDt = decoder.getDataType(program);
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT); createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
return addr.add(encodedLen); return addr.add(encodedLen);
} }
@ -175,7 +175,7 @@ public class LSDACallSiteRecord extends GccAnalysisClass {
} }
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment, createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
return addr.add(uleb128.getLength()); return addr.add(uleb128.getLength());
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,7 +20,7 @@ import java.util.*;
import ghidra.app.cmd.comments.SetCommentCmd; import ghidra.app.cmd.comments.SetCommentCmd;
import ghidra.app.plugin.exceptionhandlers.gcc.*; import ghidra.app.plugin.exceptionhandlers.gcc.*;
import ghidra.program.model.address.*; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.util.Msg; import ghidra.util.Msg;
@ -78,7 +78,7 @@ public class LSDACallSiteTable extends GccAnalysisClass {
monitor.setMessage("Creating GCC LSDA Call Site Table "); monitor.setMessage("Creating GCC LSDA Call Site Table ");
SetCommentCmd commentCmd = SetCommentCmd commentCmd =
new SetCommentCmd(baseAddr, CodeUnit.PLATE_COMMENT, "(LSDA) Call Site Table"); new SetCommentCmd(baseAddr, CommentType.PLATE, "(LSDA) Call Site Table");
commentCmd.applyTo(program); commentCmd.applyTo(program);
Address limit = baseAddr.add(header.getCallSiteTableLength() - 1); Address limit = baseAddr.add(header.getCallSiteTableLength() - 1);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,7 +21,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.datatype.DwarfEncodingModeDataTyp
import ghidra.app.util.bin.LEB128Info; import ghidra.app.util.bin.LEB128Info;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
import ghidra.program.model.data.*; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.symbol.SourceType; import ghidra.program.model.symbol.SourceType;
@ -84,7 +84,7 @@ public class LSDAHeader extends GccAnalysisClass {
String comment = "(LSDA) LPStart Encoding"; String comment = "(LSDA) LPStart Encoding";
createAndCommentData(program, addr, new DwarfEncodingModeDataType(), comment, createAndCommentData(program, addr, new DwarfEncodingModeDataType(), comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
lpStartEncoding = GccAnalysisUtils.readByte(program, addr); lpStartEncoding = GccAnalysisUtils.readByte(program, addr);
curSize += BYTE_LEN; curSize += BYTE_LEN;
@ -122,7 +122,7 @@ public class LSDAHeader extends GccAnalysisClass {
DataType encodedDt = decoder.getDataType(program); DataType encodedDt = decoder.getDataType(program);
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT); createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
curSize += encodedLen; curSize += encodedLen;
return addr.add(encodedLen); return addr.add(encodedLen);
@ -134,7 +134,7 @@ public class LSDAHeader extends GccAnalysisClass {
ttypeEncoding = GccAnalysisUtils.readByte(program, addr); ttypeEncoding = GccAnalysisUtils.readByte(program, addr);
createAndCommentData(program, addr, new DwarfEncodingModeDataType(), comment, createAndCommentData(program, addr, new DwarfEncodingModeDataType(), comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
curSize += BYTE_LEN; curSize += BYTE_LEN;
return addr.add(BYTE_LEN); return addr.add(BYTE_LEN);
@ -155,7 +155,7 @@ public class LSDAHeader extends GccAnalysisClass {
ttypeOffset = uleb128.asLong() + curSize; ttypeOffset = uleb128.asLong() + curSize;
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment, createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
return addr.add(uleb128.getLength()); return addr.add(uleb128.getLength());
} }
@ -165,7 +165,7 @@ public class LSDAHeader extends GccAnalysisClass {
callSiteTableEncoding = GccAnalysisUtils.readByte(program, addr); callSiteTableEncoding = GccAnalysisUtils.readByte(program, addr);
createAndCommentData(program, addr, new DwarfEncodingModeDataType(), comment, createAndCommentData(program, addr, new DwarfEncodingModeDataType(), comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
curSize += BYTE_LEN; curSize += BYTE_LEN;
return addr.add(BYTE_LEN); return addr.add(BYTE_LEN);
@ -179,7 +179,7 @@ public class LSDAHeader extends GccAnalysisClass {
callSiteTableLength = (int) uleb128.asLong(); callSiteTableLength = (int) uleb128.asLong();
createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment, createAndCommentData(program, addr, UnsignedLeb128DataType.dataType, comment,
CodeUnit.EOL_COMMENT); CommentType.EOL);
curSize += uleb128.getLength(); curSize += uleb128.getLength();
return addr.add(uleb128.getLength()); return addr.add(uleb128.getLength());
@ -243,7 +243,7 @@ public class LSDAHeader extends GccAnalysisClass {
} }
SetCommentCmd commentCmd = SetCommentCmd commentCmd =
new SetCommentCmd(baseAddr, CodeUnit.PLATE_COMMENT, "(LSDA) Exception Table"); new SetCommentCmd(baseAddr, CommentType.PLATE, "(LSDA) Exception Table");
commentCmd.applyTo(program); commentCmd.applyTo(program);
nextAddress = addr; 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.cmd.comments.SetCommentCmd;
import ghidra.app.plugin.exceptionhandlers.gcc.RegionDescriptor; import ghidra.app.plugin.exceptionhandlers.gcc.RegionDescriptor;
import ghidra.program.model.address.Address; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.util.task.TaskMonitor; 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); commentCmd.applyTo(program);
} }

View file

@ -1,13 +1,12 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,7 +22,7 @@ import ghidra.app.cmd.comments.SetCommentCmd;
import ghidra.app.plugin.exceptionhandlers.gcc.*; import ghidra.app.plugin.exceptionhandlers.gcc.*;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.*; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.symbol.RefType; import ghidra.program.model.symbol.RefType;
@ -92,7 +91,7 @@ public class LSDATypeTable extends GccAnalysisClass {
typeInfoAddrs.add(typeRef); typeInfoAddrs.add(typeRef);
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT); createAndCommentData(program, addr, encodedDt, comment, CommentType.EOL);
if (typeRef.getOffset() != 0) { if (typeRef.getOffset() != 0) {
program.getReferenceManager().addMemoryReference(addr, typeRef, RefType.DATA, program.getReferenceManager().addMemoryReference(addr, typeRef, RefType.DATA,
@ -102,15 +101,14 @@ public class LSDATypeTable extends GccAnalysisClass {
} }
catch (MemoryAccessException mae) { catch (MemoryAccessException mae) {
SetCommentCmd commentCmd = SetCommentCmd commentCmd =
new SetCommentCmd(addr, CodeUnit.EOL_COMMENT, "Unable to resolve pointer"); new SetCommentCmd(addr, CommentType.EOL, "Unable to resolve pointer");
commentCmd.applyTo(program); commentCmd.applyTo(program);
} }
addr = addr.subtract(stride); addr = addr.subtract(stride);
} }
SetCommentCmd commentCmd = SetCommentCmd commentCmd = new SetCommentCmd(top, CommentType.PLATE, "(LSDA) Type Table");
new SetCommentCmd(top, CodeUnit.PLATE_COMMENT, "(LSDA) Type Table");
commentCmd.applyTo(program); commentCmd.applyTo(program);
nextAddress = bottom.add(1); nextAddress = bottom.add(1);
@ -124,7 +122,7 @@ public class LSDATypeTable extends GccAnalysisClass {
} }
createAndCommentData(program, addr, new ArrayDataType(new ByteDataType(), incr, 1), createAndCommentData(program, addr, new ArrayDataType(new ByteDataType(), incr, 1),
" -- alignment pad", CodeUnit.EOL_COMMENT); " -- alignment pad", CommentType.EOL);
return addr.add(incr); return addr.add(incr);

View file

@ -118,7 +118,7 @@ public class EolComments {
} }
Collection<String> comments = Collection<String> comments =
Arrays.asList(codeUnit.getCommentAsArray(CodeUnit.REPEATABLE_COMMENT)); Arrays.asList(codeUnit.getCommentAsArray(CommentType.REPEATABLE));
addStrings(comments, repeatables); addStrings(comments, repeatables);
} }
@ -582,7 +582,7 @@ public class EolComments {
Listing listing = program.getListing(); Listing listing = program.getListing();
// prefer listing comments first since there may not be a code unit at this address // 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) { if (repeatable != null) {
return StringUtilities.toLines(repeatable); return StringUtilities.toLines(repeatable);
} }
@ -597,7 +597,7 @@ public class EolComments {
return f.getRepeatableCommentAsArray(); 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); DataType elementDT = getElementDataType(dtm, element);
Data elementData = DataUtilities.createData(program, address, elementDT, -1, false, Data elementData = DataUtilities.createData(program, address, elementDT, -1, false,
ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA); ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA);
listing.setComment(address, CodeUnit.EOL_COMMENT, listing.setComment(address, CommentType.EOL,
element.typeName() + "=" + element.value()); element.typeName() + "=" + element.value());
address = elementData.getMaxAddress().next(); 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) { 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) { 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) { 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

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -522,7 +522,7 @@ public class CliTableMethodDef extends CliAbstractTable {
data = listing.createData(startAddr, codeDT); data = listing.createData(startAddr, codeDT);
// comment the type of code that should appear here // 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")); (methodRow.isManaged() ? ".NET CLR Managed Code" : "Native Code"));
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -99,7 +99,7 @@ public class DemangledAddressTable extends DemangledObject {
Msg.warn(this, Msg.warn(this,
"Unable to fully apply external demangled Address Table at " + address + ": " + "Unable to fully apply external demangled Address Table at " + address + ": " +
s.getName(true)); s.getName(true));
listing.setComment(address, CodeUnit.EOL_COMMENT, listing.setComment(address, CommentType.EOL,
"WARNING: Unable to apply demangled Address Table"); "WARNING: Unable to apply demangled Address Table");
return true; // don't complain return true; // don't complain
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -156,7 +156,7 @@ class ProgramTextWriter {
//// Plate Property //////////////////////////////////////////// //// Plate Property ////////////////////////////////////////////
boolean cuHasPlate = false; boolean cuHasPlate = false;
if (options.isShowProperties()) { if (options.isShowProperties()) {
String[] plate = currentCodeUnit.getCommentAsArray(CodeUnit.PLATE_COMMENT); String[] plate = currentCodeUnit.getCommentAsArray(CommentType.PLATE);
cuHasPlate = plate != null && plate.length > 0; cuHasPlate = plate != null && plate.length > 0;
if (cuHasPlate) { if (cuHasPlate) {
processPlate(currentCodeUnit, plate); processPlate(currentCodeUnit, plate);
@ -200,7 +200,7 @@ class ProgramTextWriter {
//// Pre-Comment /////////////////////////////////////////////// //// Pre-Comment ///////////////////////////////////////////////
if (options.isShowComments()) { if (options.isShowComments()) {
String[] pre = currentCodeUnit.getCommentAsArray(CodeUnit.PRE_COMMENT); String[] pre = currentCodeUnit.getCommentAsArray(CommentType.PRE);
if (pre != null && pre.length > 0) { if (pre != null && pre.length > 0) {
String fill = genFill(options.getAddrWidth() + options.getBytesWidth()); String fill = genFill(options.getAddrWidth() + options.getBytesWidth());
for (String element : pre) { for (String element : pre) {
@ -301,7 +301,7 @@ class ProgramTextWriter {
//// Post Comment ////////////////////////////////////////////// //// Post Comment //////////////////////////////////////////////
if (options.isShowComments()) { if (options.isShowComments()) {
String[] post = currentCodeUnit.getCommentAsArray(CodeUnit.POST_COMMENT); String[] post = currentCodeUnit.getCommentAsArray(CommentType.POST);
if (post != null) { if (post != null) {
String fill = genFill(options.getAddrWidth() + options.getBytesWidth()); String fill = genFill(options.getAddrWidth() + options.getBytesWidth());
for (String element : post) { for (String element : post) {

View file

@ -482,7 +482,7 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
Address address = program.getImageBase().add(dd.getAddressOfRawData()); Address address = program.getImageBase().add(dd.getAddressOfRawData());
try { try {
program.getListing().createData(address, new StringDataType(), actualData.length()); 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()); address = address.add(actualData.length());
program.getListing().createData(address, new DWordDataType()); program.getListing().createData(address, new DWordDataType());
} }

View file

@ -545,7 +545,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
comment = Long.toHexString(symbols[index].getValue()); comment = Long.toHexString(symbols[index].getValue());
} }
cu.setComment(CodeUnit.EOL_COMMENT, comment); cu.setComment(CommentType.EOL, comment);
// Scalar scalar = (Scalar)data.getValue(); // Scalar scalar = (Scalar)data.getValue();
// switch ((int)scalar.getValue()) { // switch ((int)scalar.getValue()) {
@ -837,7 +837,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
} }
createData(interpStrAddr, TerminatedStringDataType.dataType); 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 { private void processImports(TaskMonitor monitor) throws CancelledException {
@ -1230,7 +1230,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
monitor.incrementProgress(1); monitor.incrementProgress(1);
Data d = array.getComponent(i); 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) { if (programHeaders[i].getType() == ElfProgramHeaderConstants.PT_NULL) {
continue; continue;
} }
@ -1301,7 +1301,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
if (type != null) { if (type != null) {
comment = comment + " - " + type; comment = comment + " - " + type;
} }
d.setComment(CodeUnit.EOL_COMMENT, comment); d.setComment(CommentType.EOL, comment);
Address sectionAddr = findLoadAddress(sections[i], 0); Address sectionAddr = findLoadAddress(sections[i], 0);
if (sectionAddr != null) { if (sectionAddr != null) {
@ -1340,7 +1340,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
listing.createData(relocTableAddr, dataType); listing.createData(relocTableAddr, dataType);
} }
else { else {
listing.setComment(relocTableAddr, CodeUnit.PRE_COMMENT, listing.setComment(relocTableAddr, CommentType.PRE,
"ELF Relocation Table (markup not yet supported)"); "ELF Relocation Table (markup not yet supported)");
} }
} }
@ -2021,14 +2021,14 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
// Add versioned symbol as comment only // Add versioned symbol as comment only
Address address = s.getAddress(); 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) { if (comment == null || comment.length() == 0) {
comment = symName; comment = symName;
} }
else { else {
comment += "\n" + symName; comment += "\n" + symName;
} }
listing.setComment(address, CodeUnit.PRE_COMMENT, comment); listing.setComment(address, CommentType.PRE, comment);
setElfSymbolAddress(elfSymbol, address); setElfSymbolAddress(elfSymbol, address);
return true; return true;
} }
@ -2499,21 +2499,21 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
Address addr = hashTableAddr; Address addr = hashTableAddr;
Data d = listing.createData(addr, dt); 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(); long nbucket = d.getScalar(0).getUnsignedValue();
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, dt); 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(); long nchain = d.getScalar(0).getUnsignedValue();
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, new ArrayDataType(dt, (int) nbucket, dt.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()); addr = addr.add(d.getLength());
d = listing.createData(addr, new ArrayDataType(dt, (int) nchain, dt.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) { catch (Exception e) {
log("Failed to properly markup Hash table at " + hashTableAddr + ": " + getMessage(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; Address addr = hashTableAddr;
Data d = listing.createData(addr, dt); 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(); long nbucket = d.getScalar(0).getUnsignedValue();
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, dt); 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(); long symbolBase = d.getScalar(0).getUnsignedValue();
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, dt); 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(); long bloomSize = d.getScalar(0).getUnsignedValue();
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, dt); 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()); addr = addr.add(d.getLength());
DataType bloomDataType = DataType bloomDataType =
elf.is64Bit() ? QWordDataType.dataType : DWordDataType.dataType; elf.is64Bit() ? QWordDataType.dataType : DWordDataType.dataType;
d = listing.createData(addr, d = listing.createData(addr,
new ArrayDataType(bloomDataType, (int) bloomSize, bloomDataType.getLength())); 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()); addr = addr.add(d.getLength());
d = listing.createData(addr, new ArrayDataType(dt, (int) nbucket, dt.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()); 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 // Rely on dynamic symbol table for number of symbols
ElfSymbolTable dynamicSymbolTable = elf.getDynamicSymbolTable(); 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 // Elf32_Word ngnusyms; // number of entries in chains (and xlat); dynsymcount=symndx+ngnusyms
Address addr = hashTableAddr; Address addr = hashTableAddr;
Data d = listing.createData(addr, dt); 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(); long ngnusyms = d.getScalar(0).getUnsignedValue();
// Elf32_Word nbuckets; // number of hash table buckets // Elf32_Word nbuckets; // number of hash table buckets
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, dt); 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(); long nbuckets = d.getScalar(0).getUnsignedValue();
// Elf32_Word symndx; // number of initial .dynsym entires skipped in chains[] (and xlat[]) // Elf32_Word symndx; // number of initial .dynsym entires skipped in chains[] (and xlat[])
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, dt); 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 // Elf32_Word maskwords; // number of ElfW(Addr) words in bitmask
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, dt); 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(); long maskwords = d.getScalar(0).getUnsignedValue();
// Elf32_Word shift2; // bit shift of hashval for second Bloom filter bit // Elf32_Word shift2; // bit shift of hashval for second Bloom filter bit
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, dt); 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 // ElfW(Addr) bitmask[maskwords]; // 2 bit Bloom filter on hashval
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
@ -2643,22 +2643,22 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
elf.is64Bit() ? QWordDataType.dataType : DWordDataType.dataType; elf.is64Bit() ? QWordDataType.dataType : DWordDataType.dataType;
d = listing.createData(addr, d = listing.createData(addr,
new ArrayDataType(bloomDataType, (int) maskwords, bloomDataType.getLength())); 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[] // Elf32_Word buckets[nbuckets]; // indices into chains[]
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, new ArrayDataType(dt, (int) nbuckets, dt.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 // Elf32_Word chains[ngnusyms]; // consecutive hashvals in a given bucket; last entry in chain has LSB set
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, new ArrayDataType(dt, (int) ngnusyms, dt.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 // Elf32_Word xlat[ngnusyms]; // parallel to chains[]; index into .dynsym
addr = addr.add(d.getLength()); addr = addr.add(d.getLength());
d = listing.createData(addr, new ArrayDataType(dt, (int) ngnusyms, dt.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) { catch (Exception e) {
log("Failed to properly markup GNU Hash table at " + hashTableAddr + ": " + 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); Data structData = array.getComponent(i);
if (structData != null) { 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 = String comment =
dynamicType != null ? (dynamicType.name + " - " + dynamicType.description) dynamicType != null ? (dynamicType.name + " - " + dynamicType.description)
: ("DT_0x" + StringUtilities.pad(Integer.toHexString(tagType), '0', 8)); : ("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); Data valueData = dynamicData.getComponent(1);
@ -2749,7 +2749,7 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
if (dynamicStringTable != null) { if (dynamicStringTable != null) {
String str = dynamicStringTable.readString(elf.getReader(), value); String str = dynamicStringTable.readString(elf.getReader(), value);
if (str != null && str.length() != 0) { 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("Other Flags: " + Conv.toHexString(ib.getOtherFlags()) + "\n");
buffer.append(ib.getOtherFlagsAsString()); 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, 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].isReadOnly() ? TAB + "Read Only" + "\n" : ""));
buff.append((segments[i].is32bit() ? TAB + "Use 32 Bit" + "\n" : "")); buff.append((segments[i].is32bit() ? TAB + "Use 32 Bit" + "\n" : ""));
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
cu.setComment(CodeUnit.PRE_COMMENT, buff.toString()); cu.setComment(CommentType.PRE, buff.toString());
} }
for (Segment segment : segments) { for (Segment segment : segments) {
@ -392,7 +392,7 @@ public class NeLoader extends AbstractOrdinalSupportLoader {
buf.append("Usage: " + Conv.toHexString(resource.getUsage()) + "\n"); buf.append("Usage: " + Conv.toHexString(resource.getUsage()) + "\n");
CodeUnit cu = listing.getCodeUnitAt(addr); CodeUnit cu = listing.getCodeUnitAt(addr);
if (cu != null) { if (cu != null) {
cu.setComment(CodeUnit.PRE_COMMENT, buf.toString()); cu.setComment(CommentType.PRE, buf.toString());
} }
//if this resource is a string table, //if this resource is a string table,

View file

@ -180,7 +180,7 @@ public class PlateFieldFactory extends FieldFactory {
addBlankLines(elements, numberBlankLines, cu); addBlankLines(elements, numberBlankLines, cu);
String[] comments = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT); String[] comments = cu.getCommentAsArray(CommentType.PLATE);
return generateFormattedPlateComment(elements, comments, offcutComments, cu.getProgram()); return generateFormattedPlateComment(elements, comments, offcutComments, cu.getProgram());
} }
@ -210,7 +210,7 @@ public class PlateFieldFactory extends FieldFactory {
} }
private String getCommentText(CodeUnit cu, List<String> offcutComments) { private String getCommentText(CodeUnit cu, List<String> offcutComments) {
String[] comments = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT); String[] comments = cu.getCommentAsArray(CommentType.PLATE);
if (comments == null) { if (comments == null) {
return null; return null;
} }
@ -503,7 +503,7 @@ public class PlateFieldFactory extends FieldFactory {
} }
CodeUnit cu = (CodeUnit) proxyObject; CodeUnit cu = (CodeUnit) proxyObject;
String[] comments = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT); String[] comments = cu.getCommentAsArray(CommentType.PLATE);
RowColLocation dataLocation = RowColLocation dataLocation =
((ListingTextField) listingField).screenToDataLocation(row, col); ((ListingTextField) listingField).screenToDataLocation(row, col);

View file

@ -139,7 +139,7 @@ public class PostCommentFieldFactory extends FieldFactory {
String[] autoComment = getAutoPostComment(cu); String[] autoComment = getAutoPostComment(cu);
List<String> offcutComments = CommentUtils.getOffcutComments(cu, CommentType.POST); 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)) { if (comments != null && comments.length > 0 && (cu instanceof Data)) {
return getTextField(comments, autoComment, offcutComments, proxy, x, false); return getTextField(comments, autoComment, offcutComments, proxy, x, false);
} }
@ -291,7 +291,7 @@ public class PostCommentFieldFactory extends FieldFactory {
} }
CodeUnit cu = (CodeUnit) obj; CodeUnit cu = (CodeUnit) obj;
String[] comment = cu.getCommentAsArray(CodeUnit.POST_COMMENT); String[] comment = cu.getCommentAsArray(CommentType.POST);
int[] cpath = null; int[] cpath = null;
if (cu instanceof Data) { 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) { private String[] getAutoPreComments(CodeUnit cu) {
@ -147,7 +147,7 @@ public class PreCommentFieldFactory extends FieldFactory {
return null; return null;
} }
CodeUnit cu = (CodeUnit) obj; CodeUnit cu = (CodeUnit) obj;
String[] comment = cu.getCommentAsArray(CodeUnit.PRE_COMMENT); String[] comment = cu.getCommentAsArray(CommentType.PRE);
int[] cpath = null; int[] cpath = null;
if (cu instanceof Data) { if (cu instanceof Data) {
cpath = ((Data) cu).getComponentPath(); 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 use {@link #createLabel(Address, String, boolean)} instead.
* Deprecated in Ghidra 7.4
*/ */
@Deprecated(since = "7.4", forRemoval = true) @Deprecated(since = "7.4", forRemoval = true)
public final Symbol createSymbol(Address address, String name, boolean makePrimary) 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 * @return true if the PLATE comment was successfully set
*/ */
public final boolean setPlateComment(Address address, String comment) { 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); return cmd.applyTo(currentProgram);
} }
@ -545,7 +551,7 @@ public class FlatProgramAPI {
* @return true if the PRE comment was successfully set * @return true if the PRE comment was successfully set
*/ */
public final boolean setPreComment(Address address, String comment) { 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); return cmd.applyTo(currentProgram);
} }
@ -556,7 +562,7 @@ public class FlatProgramAPI {
* @return true if the POST comment was successfully set * @return true if the POST comment was successfully set
*/ */
public final boolean setPostComment(Address address, String comment) { 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); return cmd.applyTo(currentProgram);
} }
@ -567,7 +573,7 @@ public class FlatProgramAPI {
* @return true if the EOL comment was successfully set * @return true if the EOL comment was successfully set
*/ */
public final boolean setEOLComment(Address address, String comment) { 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); return cmd.applyTo(currentProgram);
} }
@ -578,7 +584,7 @@ public class FlatProgramAPI {
* @return true if the repeatable comment was successfully set * @return true if the repeatable comment was successfully set
*/ */
public final boolean setRepeatableComment(Address address, String comment) { 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); return cmd.applyTo(currentProgram);
} }
@ -593,7 +599,7 @@ public class FlatProgramAPI {
* @see GhidraScript#getPlateCommentAsRendered(Address) * @see GhidraScript#getPlateCommentAsRendered(Address)
*/ */
public final String getPlateComment(Address 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) * @see GhidraScript#getPreCommentAsRendered(Address)
*/ */
public final String getPreComment(Address 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) * @see GhidraScript#getPostCommentAsRendered(Address)
*/ */
public final String getPostComment(Address 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) * @see GhidraScript#getEOLCommentAsRendered(Address)
*/ */
public final String getEOLComment(Address 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) * @see GhidraScript#getRepeatableCommentAsRendered(Address)
*/ */
public final String getRepeatableComment(Address 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; Address addr = null;
monitor.setMessage("Searching plate comments..."); monitor.setMessage("Searching plate comments...");
addr = findComment(CodeUnit.PLATE_COMMENT, text); addr = findComment(CommentType.PLATE, text);
if (addr != null) { if (addr != null) {
return addr; return addr;
} }
monitor.setMessage("Searching pre comments..."); monitor.setMessage("Searching pre comments...");
addr = findComment(CodeUnit.PRE_COMMENT, text); addr = findComment(CommentType.PRE, text);
if (addr != null) { if (addr != null) {
return addr; return addr;
} }
@ -944,19 +950,19 @@ public class FlatProgramAPI {
} }
monitor.setMessage("Searching eol comments..."); monitor.setMessage("Searching eol comments...");
addr = findComment(CodeUnit.EOL_COMMENT, text); addr = findComment(CommentType.EOL, text);
if (addr != null) { if (addr != null) {
return addr; return addr;
} }
monitor.setMessage("Searching repeatable comments..."); monitor.setMessage("Searching repeatable comments...");
addr = findComment(CodeUnit.REPEATABLE_COMMENT, text); addr = findComment(CommentType.REPEATABLE, text);
if (addr != null) { if (addr != null) {
return addr; return addr;
} }
monitor.setMessage("Searching post comments..."); monitor.setMessage("Searching post comments...");
addr = findComment(CodeUnit.POST_COMMENT, text); addr = findComment(CommentType.POST, text);
if (addr != null) { if (addr != null) {
return addr; return addr;
} }
@ -2634,7 +2640,7 @@ public class FlatProgramAPI {
return folder; return folder;
} }
private Address findComment(int type, String text) { private Address findComment(CommentType type, String text) {
Listing listing = currentProgram.getListing(); Listing listing = currentProgram.getListing();
Memory memory = currentProgram.getMemory(); Memory memory = currentProgram.getMemory();
AddressIterator iter = listing.getCommentAddressIterator(type, memory, true); AddressIterator iter = listing.getCommentAddressIterator(type, memory, true);

View file

@ -133,7 +133,7 @@ public class CodeUnitFormat {
stringBuffer.append(getOperandRepresentationString(cu, 0)); stringBuffer.append(getOperandRepresentationString(cu, 0));
} }
if (includeEOLcomment) { if (includeEOLcomment) {
String eolComment = cu.getComment(CodeUnit.EOL_COMMENT); String eolComment = cu.getComment(CommentType.EOL);
if (eolComment != null) { if (eolComment != null) {
// fixup annotations // fixup annotations
eolComment = CommentUtils.getDisplayString(eolComment, cu.getProgram()); eolComment = CommentUtils.getDisplayString(eolComment, cu.getProgram());

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -18,7 +18,7 @@ package ghidra.util.table.field;
import ghidra.docking.settings.Settings; import ghidra.docking.settings.Settings;
import ghidra.framework.plugintool.ServiceProvider; import ghidra.framework.plugintool.ServiceProvider;
import ghidra.program.model.address.Address; 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.listing.Program;
import ghidra.program.util.*; import ghidra.program.util.*;
@ -58,6 +58,6 @@ public class EOLCommentTableColumn extends
return null; return null;
} }
Address address = location.getAddress(); Address address = location.getAddress();
return program.getListing().getComment(CodeUnit.EOL_COMMENT, address); return program.getListing().getComment(CommentType.EOL, address);
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -538,7 +538,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
// in Browser(1) add a pre comment at 331 // in Browser(1) add a pre comment at 331
CodeUnit cu = programOne.getListing().getCodeUnitAt(addr(programOne, 0x331)); CodeUnit cu = programOne.getListing().getCodeUnitAt(addr(programOne, 0x331));
int transactionID = programOne.startTransaction("test"); 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); programOne.endTransaction(transactionID, true);
waitForSwing(); waitForSwing();
@ -572,7 +572,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
// verify pre comment at 331 remains unaffected // verify pre comment at 331 remains unaffected
cu = programOne.getListing().getCodeUnitAt(addr(programOne, 0x331)); 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 // verify browser field
@ -649,18 +649,18 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
// verify comments are copied // verify comments are copied
CodeUnit cu = listing.getCodeUnitAt(addr(programOne, 0x0320)); CodeUnit cu = listing.getCodeUnitAt(addr(programOne, 0x0320));
assertEquals("My Plate Comment", cu.getComment(CodeUnit.PLATE_COMMENT)); assertEquals("My Plate Comment", cu.getComment(CommentType.PLATE));
assertEquals("My Post comment", cu.getComment(CodeUnit.POST_COMMENT)); assertEquals("My Post comment", cu.getComment(CommentType.POST));
cu = listing.getCodeUnitAt(addr(programOne, 0x326)); cu = listing.getCodeUnitAt(addr(programOne, 0x326));
assertEquals("More Plate Comments (1)", cu.getComment(CodeUnit.PLATE_COMMENT)); assertEquals("More Plate Comments (1)", cu.getComment(CommentType.PLATE));
assertEquals("More Post comments (1)", cu.getComment(CodeUnit.POST_COMMENT)); assertEquals("More Post comments (1)", cu.getComment(CommentType.POST));
assertEquals("More EOL comments (1)", cu.getComment(CodeUnit.EOL_COMMENT)); assertEquals("More EOL comments (1)", cu.getComment(CommentType.EOL));
cu = listing.getCodeUnitAt(addr(programOne, 0x32a)); cu = listing.getCodeUnitAt(addr(programOne, 0x32a));
assertEquals("More Plate Comments (2)", cu.getComment(CodeUnit.PLATE_COMMENT)); assertEquals("More Plate Comments (2)", cu.getComment(CommentType.PLATE));
assertEquals("More Post comments (2)", cu.getComment(CodeUnit.POST_COMMENT)); assertEquals("More Post comments (2)", cu.getComment(CommentType.POST));
assertEquals("More EOL comments (2)", cu.getComment(CodeUnit.EOL_COMMENT)); assertEquals("More EOL comments (2)", cu.getComment(CommentType.EOL));
cb.goToField(addr(programOne, 0x0320), PlateFieldFactory.FIELD_NAME, 0, 0); cb.goToField(addr(programOne, 0x0320), PlateFieldFactory.FIELD_NAME, 0, 0);
ListingTextField f = (ListingTextField) cb.getCurrentField(); ListingTextField f = (ListingTextField) cb.getCurrentField();
@ -708,7 +708,7 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
Address addr = addr(programOne, 0x334); Address addr = addr(programOne, 0x334);
for (String element : comments) { for (String element : comments) {
CodeUnit cu = listing.getCodeUnitAt(addr); 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)); assertTrue(cb.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0));
ListingTextField f = (ListingTextField) cb.getCurrentField(); ListingTextField f = (ListingTextField) cb.getCurrentField();
assertEquals(element, f.getText()); assertEquals(element, f.getText());
@ -791,18 +791,18 @@ public class CopyPasteCommentsTest extends AbstractProgramBasedTest {
function.setComment("my function comment"); function.setComment("my function comment");
// add some Plate, Pre, and Post comments within this function. // add some Plate, Pre, and Post comments within this function.
CodeUnit cu = listing.getCodeUnitAt(addr(programTwo, 0x0320)); CodeUnit cu = listing.getCodeUnitAt(addr(programTwo, 0x0320));
cu.setComment(CodeUnit.PLATE_COMMENT, "My Plate Comment"); cu.setComment(CommentType.PLATE, "My Plate Comment");
cu.setComment(CodeUnit.POST_COMMENT, "My Post comment"); cu.setComment(CommentType.POST, "My Post comment");
cu = listing.getCodeUnitAt(addr(programTwo, 0x326)); cu = listing.getCodeUnitAt(addr(programTwo, 0x326));
cu.setComment(CodeUnit.PLATE_COMMENT, "More Plate Comments (1)"); cu.setComment(CommentType.PLATE, "More Plate Comments (1)");
cu.setComment(CodeUnit.POST_COMMENT, "More Post comments (1)"); cu.setComment(CommentType.POST, "More Post comments (1)");
cu.setComment(CodeUnit.EOL_COMMENT, "More EOL comments (1)"); cu.setComment(CommentType.EOL, "More EOL comments (1)");
cu = listing.getCodeUnitAt(addr(programTwo, 0x32a)); cu = listing.getCodeUnitAt(addr(programTwo, 0x32a));
cu.setComment(CodeUnit.PLATE_COMMENT, "More Plate Comments (2)"); cu.setComment(CommentType.PLATE, "More Plate Comments (2)");
cu.setComment(CodeUnit.POST_COMMENT, "More Post comments (2)"); cu.setComment(CommentType.POST, "More Post comments (2)");
cu.setComment(CodeUnit.EOL_COMMENT, "More EOL comments (2)"); cu.setComment(CommentType.EOL, "More EOL comments (2)");
// Edit the label at 0x32d (RSR05) and make it part of a scope // Edit the label at 0x32d (RSR05) and make it part of a scope
Symbol symbol = getUniqueSymbol(programTwo, "RSR05", null); Symbol symbol = getUniqueSymbol(programTwo, "RSR05", null);

View file

@ -595,7 +595,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
cb.goToField(callAddress, "Bytes", 0, 0); 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 " + "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" + "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 " + "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"); "4444 55555 666666 7777777 88888888 999999999 0000000000 1 22 333 4444 55555");
tool.execute(eolCmd, program); 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."); "Local repeatable line1.\n" + "\n" + "Line3 of repeatable.");
tool.execute(repeatCmd, program); tool.execute(repeatCmd, program);
@ -613,7 +613,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
new CreateFunctionCmd(null, callRefAddress, body, SourceType.USER_DEFINED); new CreateFunctionCmd(null, callRefAddress, body, SourceType.USER_DEFINED);
tool.execute(createFunctionCmd, program); tool.execute(createFunctionCmd, program);
SetCommentCmd callRepeatCmd = new SetCommentCmd(callRefAddress, CodeUnit.REPEATABLE_COMMENT, SetCommentCmd callRepeatCmd = new SetCommentCmd(callRefAddress, CommentType.REPEATABLE,
"\n" + "Function Repeatable line2"); "\n" + "Function Repeatable line2");
tool.execute(callRepeatCmd, program); tool.execute(callRepeatCmd, program);
@ -622,7 +622,7 @@ public class CodeBrowserOptionsTest extends AbstractGhidraHeadedIntegrationTest
tool.execute(addRefCmd, program); tool.execute(addRefCmd, program);
SetCommentCmd commentRefCmd = new SetCommentCmd(otherRefAddress, SetCommentCmd commentRefCmd = new SetCommentCmd(otherRefAddress,
CodeUnit.REPEATABLE_COMMENT, "Mem ref line1.\n" + ""); CommentType.REPEATABLE, "Mem ref line1.\n" + "");
tool.execute(commentRefCmd, program); tool.execute(commentRefCmd, program);
// these values are all DEFAULT, by default; set them in case that changes in the future // these values are all DEFAULT, by default; set them in case that changes in the future

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -133,7 +133,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
assertEquals(new WordDataType().getName(), subData1.getDataType().getName()); assertEquals(new WordDataType().getName(), subData1.getDataType().getName());
String comment1 = "aaa bbb ccc ddd eee"; String comment1 = "aaa bbb ccc ddd eee";
setAt(addr, CodeUnit.EOL_COMMENT, comment1, "OK"); 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); browser.goToField(addr(0x10080a2), "+", 0, 0);
@ -147,7 +147,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
assertEquals(new FloatDataType().getName(), subData.getDataType().getName()); assertEquals(new FloatDataType().getName(), subData.getDataType().getName());
String comment = "This is a comment on a structure element."; String comment = "This is a comment on a structure element.";
setAt(addr, CodeUnit.EOL_COMMENT, comment, "OK"); 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); browser.goToField(addr(0x010080a2), EolCommentFieldFactory.FIELD_NAME, 0, 0);
assertEquals(comment, browser.getCurrentFieldText()); assertEquals(comment, browser.getCurrentFieldText());
@ -171,11 +171,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
waitForSwing(); waitForSwing();
comment += "\n\nHI, MOM"; comment += "\n\nHI, MOM";
assertEquals(comment, subData.getComment(CodeUnit.EOL_COMMENT)); assertEquals(comment, subData.getComment(CommentType.EOL));
performAction(deleteAction, browser.getProvider(), false); performAction(deleteAction, browser.getProvider(), false);
waitForSwing(); waitForSwing();
assertNull(subData.getComment(CodeUnit.EOL_COMMENT)); assertNull(subData.getComment(CommentType.EOL));
} }
@Test @Test
@ -276,11 +276,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420); Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PRE_COMMENT, PRE, "OK"); setAt(addr, CodeUnit.PRE_COMMENT, PRE, "OK");
assertEquals(PRE, cu.getComment(CodeUnit.PRE_COMMENT)); assertEquals(PRE, cu.getComment(CommentType.PRE));
undo(program); undo(program);
assertNull(cu.getComment(CodeUnit.PRE_COMMENT)); assertNull(cu.getComment(CommentType.PRE));
redo(program); redo(program);
assertEquals(PRE, cu.getComment(CodeUnit.PRE_COMMENT)); assertEquals(PRE, cu.getComment(CommentType.PRE));
browser.goToField(addr, PreCommentFieldFactory.FIELD_NAME, 0, 0); browser.goToField(addr, PreCommentFieldFactory.FIELD_NAME, 0, 0);
assertEquals(PRE, browser.getCurrentFieldText()); assertEquals(PRE, browser.getCurrentFieldText());
} }
@ -291,11 +291,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420); Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.POST_COMMENT, POST, "OK"); setAt(addr, CodeUnit.POST_COMMENT, POST, "OK");
assertEquals(POST, cu.getComment(CodeUnit.POST_COMMENT)); assertEquals(POST, cu.getComment(CommentType.POST));
undo(program); undo(program);
assertNull(cu.getComment(CodeUnit.POST_COMMENT)); assertNull(cu.getComment(CommentType.POST));
redo(program); redo(program);
assertEquals(POST, cu.getComment(CodeUnit.POST_COMMENT)); assertEquals(POST, cu.getComment(CommentType.POST));
browser.goToField(addr, PostCommentFieldFactory.FIELD_NAME, 0, 0); browser.goToField(addr, PostCommentFieldFactory.FIELD_NAME, 0, 0);
assertEquals(POST, browser.getCurrentFieldText()); assertEquals(POST, browser.getCurrentFieldText());
} }
@ -306,11 +306,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420); Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.EOL_COMMENT, EOL, "OK"); setAt(addr, CodeUnit.EOL_COMMENT, EOL, "OK");
assertEquals(EOL, cu.getComment(CodeUnit.EOL_COMMENT)); assertEquals(EOL, cu.getComment(CommentType.EOL));
undo(program); undo(program);
assertNull(cu.getComment(CodeUnit.EOL_COMMENT)); assertNull(cu.getComment(CommentType.EOL));
redo(program); redo(program);
assertEquals(EOL, cu.getComment(CodeUnit.EOL_COMMENT)); assertEquals(EOL, cu.getComment(CommentType.EOL));
browser.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0); browser.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0);
assertEquals(EOL, browser.getCurrentFieldText()); assertEquals(EOL, browser.getCurrentFieldText());
} }
@ -322,11 +322,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420); Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK"); setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK");
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT)); assertEquals(PLATE, cu.getComment(CommentType.PLATE));
undo(program); undo(program);
assertNull(cu.getComment(CodeUnit.PLATE_COMMENT)); assertNull(cu.getComment(CommentType.PLATE));
redo(program); redo(program);
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT)); assertEquals(PLATE, cu.getComment(CommentType.PLATE));
browser.goToField(addr, PlateFieldFactory.FIELD_NAME, 0, 0); browser.goToField(addr, PlateFieldFactory.FIELD_NAME, 0, 0);
//allow for the "*" that get added to the plate //allow for the "*" that get added to the plate
assertEquals(65, browser.getCurrentFieldText().indexOf(PLATE)); assertEquals(65, browser.getCurrentFieldText().indexOf(PLATE));
@ -338,11 +338,11 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006420); Address addr = addr(0x01006420);
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.REPEATABLE_COMMENT, REPEAT, "OK"); setAt(addr, CodeUnit.REPEATABLE_COMMENT, REPEAT, "OK");
assertEquals(REPEAT, cu.getComment(CodeUnit.REPEATABLE_COMMENT)); assertEquals(REPEAT, cu.getComment(CommentType.REPEATABLE));
undo(program); undo(program);
assertNull(cu.getComment(CodeUnit.REPEATABLE_COMMENT)); assertNull(cu.getComment(CommentType.REPEATABLE));
redo(program); redo(program);
assertEquals(REPEAT, cu.getComment(CodeUnit.REPEATABLE_COMMENT)); assertEquals(REPEAT, cu.getComment(CommentType.REPEATABLE));
browser.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0); browser.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0);
assertEquals(REPEAT, browser.getCurrentFieldText()); 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"; String longComment = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8\n";
setAt(addr, CodeUnit.REPEATABLE_COMMENT, longComment, "OK"); setAt(addr, CodeUnit.REPEATABLE_COMMENT, longComment, "OK");
assertEquals(longComment, cu.getComment(CodeUnit.REPEATABLE_COMMENT)); assertEquals(longComment, cu.getComment(CommentType.REPEATABLE));
// this fails when excepting // this fails when excepting
assertTrue(browser.goToField(addr, EolCommentFieldFactory.FIELD_NAME, 0, 0)); 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.PLATE_COMMENT, PLATE, "OK");
setAt(addr, CodeUnit.REPEATABLE_COMMENT, REPEAT, "OK"); setAt(addr, CodeUnit.REPEATABLE_COMMENT, REPEAT, "OK");
assertEquals(PRE, cu.getComment(CodeUnit.PRE_COMMENT)); assertEquals(PRE, cu.getComment(CommentType.PRE));
assertEquals(POST, cu.getComment(CodeUnit.POST_COMMENT)); assertEquals(POST, cu.getComment(CommentType.POST));
assertEquals(EOL, cu.getComment(CodeUnit.EOL_COMMENT)); assertEquals(EOL, cu.getComment(CommentType.EOL));
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT)); assertEquals(PLATE, cu.getComment(CommentType.PLATE));
assertEquals(REPEAT, cu.getComment(CodeUnit.REPEATABLE_COMMENT)); assertEquals(REPEAT, cu.getComment(CommentType.REPEATABLE));
undo(program, 5); undo(program, 5);
assertNull(cu.getComment(CodeUnit.PRE_COMMENT)); assertNull(cu.getComment(CommentType.PRE));
assertNull(cu.getComment(CodeUnit.POST_COMMENT)); assertNull(cu.getComment(CommentType.POST));
assertNull(cu.getComment(CodeUnit.EOL_COMMENT)); assertNull(cu.getComment(CommentType.EOL));
assertNull(cu.getComment(CodeUnit.PLATE_COMMENT)); assertNull(cu.getComment(CommentType.PLATE));
assertNull(cu.getComment(CodeUnit.REPEATABLE_COMMENT)); assertNull(cu.getComment(CommentType.REPEATABLE));
redo(program, 5); redo(program, 5);
assertEquals(PRE, cu.getComment(CodeUnit.PRE_COMMENT)); assertEquals(PRE, cu.getComment(CommentType.PRE));
assertEquals(POST, cu.getComment(CodeUnit.POST_COMMENT)); assertEquals(POST, cu.getComment(CommentType.POST));
assertEquals(EOL, cu.getComment(CodeUnit.EOL_COMMENT)); assertEquals(EOL, cu.getComment(CommentType.EOL));
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT)); assertEquals(PLATE, cu.getComment(CommentType.PLATE));
assertEquals(REPEAT, cu.getComment(CodeUnit.REPEATABLE_COMMENT)); assertEquals(REPEAT, cu.getComment(CommentType.REPEATABLE));
} }
@Test @Test
@ -406,7 +406,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
assertNotNull(commentsDialog); assertNotNull(commentsDialog);
pressButtonByText(commentsDialog.getComponent(), "Dismiss", false); pressButtonByText(commentsDialog.getComponent(), "Dismiss", false);
waitForSwing(); waitForSwing();
assertEquals("Bla bla bla", cu.getComment(CodeUnit.REPEATABLE_COMMENT)); assertEquals("Bla bla bla", cu.getComment(CommentType.REPEATABLE));
assertTrue(!commentsDialog.isVisible()); 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, "OK");
setAt(addr, CodeUnit.PRE_COMMENT, PRE_U, "OK"); setAt(addr, CodeUnit.PRE_COMMENT, PRE_U, "OK");
undo(program); undo(program);
assertEquals(PRE, cu.getComment(CodeUnit.PRE_COMMENT)); assertEquals(PRE, cu.getComment(CommentType.PRE));
redo(program); redo(program);
assertEquals(PRE_U, cu.getComment(CodeUnit.PRE_COMMENT)); assertEquals(PRE_U, cu.getComment(CommentType.PRE));
} }
@Test @Test
@ -439,7 +439,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
pressButton(button, false); pressButton(button, false);
waitForSwing(); waitForSwing();
assertEquals("Bla bla bla", cu.getComment(CodeUnit.POST_COMMENT)); assertEquals("Bla bla bla", cu.getComment(CommentType.POST));
assertFalse(commentsDialog.isVisible()); assertFalse(commentsDialog.isVisible());
} }
@ -460,7 +460,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
pressButton(button, false); pressButton(button, false);
waitForSwing(); waitForSwing();
assertNull(cu.getComment(CodeUnit.POST_COMMENT)); assertNull(cu.getComment(CommentType.POST));
assertFalse(commentsDialog.isVisible()); assertFalse(commentsDialog.isVisible());
} }
@ -482,7 +482,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
pressButton(button, false); pressButton(button, false);
waitForSwing(); waitForSwing();
assertNull(cu.getComment(CodeUnit.POST_COMMENT)); assertNull(cu.getComment(CommentType.POST));
assertTrue(commentsDialog.isVisible()); assertTrue(commentsDialog.isVisible());
close(commentsDialog); close(commentsDialog);
@ -494,13 +494,13 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0xf0000250); Address addr = addr(0xf0000250);
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PLATE_COMMENT, PLATE, "OK"); 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); removeAt(addr, CodeUnit.PLATE_COMMENT);
assertNull(cu.getComment(CodeUnit.PLATE_COMMENT)); assertNull(cu.getComment(CommentType.PLATE));
undo(program); undo(program);
assertEquals(PLATE, cu.getComment(CodeUnit.PLATE_COMMENT)); assertEquals(PLATE, cu.getComment(CommentType.PLATE));
redo(program); redo(program);
assertNull(cu.getComment(CodeUnit.PLATE_COMMENT)); assertNull(cu.getComment(CommentType.PLATE));
} }
@Test @Test
@ -543,7 +543,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
Address addr = addr(0x01006000); Address addr = addr(0x01006000);
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
setAt(addr, CodeUnit.PRE_COMMENT, comment, "OK"); setAt(addr, CodeUnit.PRE_COMMENT, comment, "OK");
assertEquals(comment, cu.getComment(CodeUnit.PRE_COMMENT)); assertEquals(comment, cu.getComment(CommentType.PRE));
} }
@Test @Test
@ -586,7 +586,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
String comment = "This is a comment DAT_01008094 with a label in it."; String comment = "This is a comment DAT_01008094 with a label in it.";
setAt(srcAddr, CodeUnit.PRE_COMMENT, comment, "OK"); 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); browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 23);
click(browser, 2); click(browser, 2);
@ -603,7 +603,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
String comment = "This is a comment 01008094 with an address in it."; String comment = "This is a comment 01008094 with an address in it.";
setAt(srcAddr, CodeUnit.PRE_COMMENT, comment, "OK"); 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); browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 23);
click(browser, 2); click(browser, 2);
@ -678,7 +678,7 @@ public class CommentsPluginTest extends AbstractGhidraHeadedIntegrationTest {
String comment = "This is a comment DAT_* with a wildcard in it."; String comment = "This is a comment DAT_* with a wildcard in it.";
setAt(srcAddr, CodeUnit.PRE_COMMENT, comment, "OK"); 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); browser.goToField(srcAddr, PreCommentFieldFactory.FIELD_NAME, 0, 19);
click(browser, 2); 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 // space comment is exactly the same; i.e. make sure that no tab conversion happens
String spaceComment = "abcd\tdefg\n\t1\t2\t3\t4"; 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 illegal = "null\0 comment";
String legal = "null comment"; String legal = "null comment";
setAt(addr, CodeUnit.PRE_COMMENT, illegal, "OK"); 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) private void setAt(Address addr, int commentType, String comment, String nameOfButtonToClick)

View file

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

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -41,7 +41,7 @@ import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.PluginTool;
import ghidra.program.database.ProgramBuilder; import ghidra.program.database.ProgramBuilder;
import ghidra.program.model.address.Address; 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.listing.Program;
import ghidra.program.model.symbol.SourceType; import ghidra.program.model.symbol.SourceType;
import ghidra.program.model.symbol.SymbolTable; import ghidra.program.model.symbol.SymbolTable;
@ -589,7 +589,7 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
try { try {
p.getListing() p.getListing()
.setComment(p.getAddressFactory().getAddress("01000000"), .setComment(p.getAddressFactory().getAddress("01000000"),
CodeUnit.REPEATABLE_COMMENT, "This is a simple comment change."); CommentType.REPEATABLE, "This is a simple comment change.");
} }
finally { finally {
p.endTransaction(transactionID, true); p.endTransaction(transactionID, true);

View file

@ -280,9 +280,9 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
listing.createData(addr(0x01006890), floatDt); listing.createData(addr(0x01006890), floatDt);
Data data = listing.getDataAt(addr(0x0100688c)); 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 = 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 { finally {
@ -357,9 +357,9 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
listing.createData(addr(0x01006890), floatDt); listing.createData(addr(0x01006890), floatDt);
Data data = listing.getDataAt(addr(0x0100688c)); 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 = 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 { finally {
@ -445,9 +445,9 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
listing.createData(addr(0x01006890), floatDt); listing.createData(addr(0x01006890), floatDt);
Data data = listing.getDataAt(addr(0x0100688c)); 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 = 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 { finally {

View file

@ -376,17 +376,17 @@ public class SearchTextPlugin1Test extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = listing.getCodeUnitAt(getAddr(0x0100416f)); CodeUnit cu = listing.getCodeUnitAt(getAddr(0x0100416f));
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
cu.setComment(CodeUnit.EOL_COMMENT, "call sscanf"); cu.setComment(CommentType.EOL, "call sscanf");
cu = listing.getCodeUnitAt(getAddr(0x01004178)); 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 = listing.getCodeUnitAt(getAddr(0x01004192));
cu.setComment(CodeUnit.PLATE_COMMENT, "another ref to sscanf"); cu.setComment(CommentType.PLATE, "another ref to sscanf");
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 = listing.getCodeUnitAt(getAddr(0x0100467b));
cu.setComment(CodeUnit.PRE_COMMENT, "call sscanf here"); cu.setComment(CommentType.PRE, "call sscanf here");
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -309,7 +309,7 @@ public class SearchTextPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
try { try {
cu.setComment(CodeUnit.POST_COMMENT, "********** my entry Exit **********"); cu.setComment(CommentType.POST, "********** my entry Exit **********");
} }
finally { finally {
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);
@ -340,7 +340,7 @@ public class SearchTextPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
try { try {
cu.setComment(CodeUnit.POST_COMMENT, "********** ___sbh_find_block Exit **********"); cu.setComment(CommentType.POST, "********** ___sbh_find_block Exit **********");
} }
finally { finally {
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);
@ -369,7 +369,7 @@ public class SearchTextPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
try { try {
cu.setComment(CodeUnit.POST_COMMENT, "********** ___sbh_find_block Exit **********"); cu.setComment(CommentType.POST, "********** ___sbh_find_block Exit **********");
} }
finally { finally {
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);
@ -395,7 +395,7 @@ public class SearchTextPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
try { try {
cu.setComment(CodeUnit.POST_COMMENT, "Comment test * with an asterisk"); cu.setComment(CommentType.POST, "Comment test * with an asterisk");
} }
finally { finally {
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -179,13 +179,13 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = listing.getCodeUnitAt(getAddr(0x01002c97)); CodeUnit cu = listing.getCodeUnitAt(getAddr(0x01002c97));
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
cu.setComment(CodeUnit.PLATE_COMMENT, "find hit for eax"); cu.setComment(CommentType.PLATE, "find hit for eax");
cu.setComment(CodeUnit.PRE_COMMENT, "find another hit for eax"); cu.setComment(CommentType.PRE, "find another hit for eax");
SymbolTable st = program.getSymbolTable(); SymbolTable st = program.getSymbolTable();
st.createLabel(cu.getMinAddress(), "My_EAX", SourceType.USER_DEFINED); 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); program.endTransaction(transactionID, true);
SearchTextDialog dialog = getDialog(); SearchTextDialog dialog = getDialog();
@ -340,16 +340,16 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = listing.getCodeUnitAt(getAddr(0x0100416f)); CodeUnit cu = listing.getCodeUnitAt(getAddr(0x0100416f));
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
cu.setComment(CodeUnit.EOL_COMMENT, "call sscanf"); cu.setComment(CommentType.EOL, "call sscanf");
cu = listing.getCodeUnitAt(getAddr(0x01004178)); 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 = 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 = listing.getCodeUnitAt(getAddr(0x0100467b));
cu.setComment(CodeUnit.PRE_COMMENT, "call sscanf here"); cu.setComment(CommentType.PRE, "call sscanf here");
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);
@ -427,16 +427,16 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = listing.getCodeUnitAt(getAddr(0x0100416f)); CodeUnit cu = listing.getCodeUnitAt(getAddr(0x0100416f));
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
cu.setComment(CodeUnit.EOL_COMMENT, "call sscanf"); cu.setComment(CommentType.EOL, "call sscanf");
cu = listing.getCodeUnitAt(getAddr(0x01004178)); 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 = 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 = listing.getCodeUnitAt(getAddr(0x0100467b));
cu.setComment(CodeUnit.PRE_COMMENT, "call sscanf here"); cu.setComment(CommentType.PRE, "call sscanf here");
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -382,17 +382,17 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
} }
void addEolComment(long longAddr, String comment) { 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); tool.execute(cmd, program);
} }
void addPreComment(long longAddr, String comment) { 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); tool.execute(cmd, program);
} }
void addPostComment(long longAddr, String comment) { 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); tool.execute(cmd, program);
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -122,7 +122,7 @@ public class EolCommentFieldFactoryTest extends AbstractGhidraHeadedIntegrationT
CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint()); CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint());
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
try { try {
cu.setComment(CodeUnit.EOL_COMMENT, comment); cu.setComment(CommentType.EOL, comment);
} }
finally { finally {
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -117,7 +117,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
Function function = program.getFunctionManager().getFunctionAt(addr); Function function = program.getFunctionManager().getFunctionAt(addr);
CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint()); 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); goToService.goTo(addr);
@ -148,7 +148,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
Function function = program.getFunctionManager().getFunctionAt(addr); Function function = program.getFunctionManager().getFunctionAt(addr);
CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint()); CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint());
String[] plateComments = cu.getCommentAsArray(CodeUnit.PLATE_COMMENT); String[] plateComments = cu.getCommentAsArray(CommentType.PLATE);
goToService.goTo(addr); goToService.goTo(addr);
@ -205,7 +205,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
tx(program, () -> { tx(program, () -> {
CreateFunctionCmd cmd = new CreateFunctionCmd(addr); CreateFunctionCmd cmd = new CreateFunctionCmd(addr);
cmd.applyTo(program); cmd.applyTo(program);
cu.setComment(CodeUnit.PLATE_COMMENT, null); cu.setComment(CommentType.PLATE, null);
}); });
cb.updateNow(); cb.updateNow();
@ -326,7 +326,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
} }
CodeUnit cu = listing.getCodeUnitAt(addr); 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(), assertTrue("Failed to navigate to plate field at address: " + cu.getMinAddress(),
cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 1, 1)); cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 1, 1));
ListingTextField tf = (ListingTextField) cb.getCurrentField(); ListingTextField tf = (ListingTextField) cb.getCurrentField();
@ -437,7 +437,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(addr); CodeUnit cu = program.getListing().getCodeUnitAt(addr);
tx(program, () -> { tx(program, () -> {
cu.setComment(CodeUnit.PLATE_COMMENT, cu.setComment(CommentType.PLATE,
"this is a comment\ngo to the address 0x010028de"); "this is a comment\ngo to the address 0x010028de");
}); });
assertTrue(cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 2, 23)); assertTrue(cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 2, 23));
@ -461,7 +461,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
program.getSymbolTable() program.getSymbolTable()
.createLabel(addr, testName.getMethodName(), .createLabel(addr, testName.getMethodName(),
SourceType.USER_DEFINED); SourceType.USER_DEFINED);
cu.setComment(CodeUnit.PLATE_COMMENT, cu.setComment(CommentType.PLATE,
"this is a comment\ngo to the address 0x010028de"); "this is a comment\ngo to the address 0x010028de");
}); });
@ -478,7 +478,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
public void testNavigationOnLabel() throws Exception { public void testNavigationOnLabel() throws Exception {
// add a plate comment that has "entry" in it // add a plate comment that has "entry" in it
CodeUnit cu = program.getListing().getCodeUnitAt(getAddr(0x0100292b)); 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)); assertTrue(cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 1, 8));
click(cb, 2); click(cb, 2);
@ -493,7 +493,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = program.getListing().getCodeUnitAt(getAddr(0x01001100)); CodeUnit cu = program.getListing().getCodeUnitAt(getAddr(0x01001100));
tx(program, () -> { 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)); assertTrue(cb.goToField(cu.getMinAddress(), PlateFieldFactory.FIELD_NAME, 1, 8));
click(cb, 2); click(cb, 2);
@ -521,7 +521,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
CodeUnit cu = program.getListing().getCodeUnitAt(getAddr(0x0100292b)); CodeUnit cu = program.getListing().getCodeUnitAt(getAddr(0x0100292b));
try { try {
cu.setComment(CodeUnit.PLATE_COMMENT, "go to FUN*"); cu.setComment(CommentType.PLATE, "go to FUN*");
} }
finally { finally {
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);
@ -591,7 +591,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest {
private void createPlateComment(CodeUnit cu, String text) { private void createPlateComment(CodeUnit cu, String text) {
tx(program, () -> { tx(program, () -> {
cu.setComment(CodeUnit.PLATE_COMMENT, text); cu.setComment(CommentType.PLATE, text);
}); });
cb.updateNow(); cb.updateNow();
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -280,7 +280,7 @@ public class PostCommentFieldFactoryTest extends AbstractGhidraHeadedIntegration
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
try { try {
cu.setComment(CodeUnit.POST_COMMENT, "My post comment"); cu.setComment(CommentType.POST, "My post comment");
} }
finally { finally {
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);
@ -1068,7 +1068,7 @@ public class PostCommentFieldFactoryTest extends AbstractGhidraHeadedIntegration
CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint()); CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint());
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
try { try {
cu.setComment(CodeUnit.POST_COMMENT, comment); cu.setComment(CommentType.POST, comment);
} }
finally { finally {
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -139,7 +139,7 @@ public class PreCommentFieldFactoryTest extends AbstractGhidraHeadedIntegrationT
CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint()); CodeUnit cu = program.getListing().getCodeUnitAt(function.getEntryPoint());
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
try { try {
cu.setComment(CodeUnit.PRE_COMMENT, comment); cu.setComment(CommentType.PRE, comment);
} }
finally { finally {
program.endTransaction(transactionID, true); program.endTransaction(transactionID, true);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -177,7 +177,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
Instruction inst = program.getListing().getInstructionAt(addr(0x1004772)); Instruction inst = program.getListing().getInstructionAt(addr(0x1004772));
String comment = String comment =
"This is a very long comment. I want this sentence to wrap to the next line so that I can test wrapping."; "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); program.endTransaction(id, true);
cb.updateNow(); cb.updateNow();
Layout l = getLayout(addr(0x1004772)); Layout l = getLayout(addr(0x1004772));
@ -209,7 +209,7 @@ public class ListingPanelTest extends AbstractGhidraHeadedIntegrationTest {
Instruction inst = program.getListing().getInstructionAt(addr(0x1004772)); Instruction inst = program.getListing().getInstructionAt(addr(0x1004772));
String comment = String comment =
"This is a very long comment. I want this sentence to wrap to the next line so that I can test wrapping."; "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); program.endTransaction(id, true);
Options opt = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS); Options opt = tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS);
opt.setBoolean("EOL Comments Field.Enable Word Wrapping", true); opt.setBoolean("EOL Comments Field.Enable Word Wrapping", true);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -788,8 +788,8 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10)); CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + i); cu.setComment(CommentType.PLATE, "comment for plate " + i);
assertEquals("comment for plate " + i, cu.getComment(CodeUnit.PLATE_COMMENT)); assertEquals("comment for plate " + i, cu.getComment(CommentType.PLATE));
} }
endTransaction(); endTransaction();
@ -802,8 +802,8 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
CodeUnit cu = iter.next(); CodeUnit cu = iter.next();
expectedAddr = addr(n + 10); expectedAddr = addr(n + 10);
assertEquals(expectedAddr, cu.getMinAddress()); assertEquals(expectedAddr, cu.getMinAddress());
assertNotNull(cu.getComment(CodeUnit.PLATE_COMMENT)); assertNotNull(cu.getComment(CommentType.PLATE));
assertNull(cu.getComment(CodeUnit.EOL_COMMENT)); assertNull(cu.getComment(CommentType.EOL));
++n; ++n;
} }
} }
@ -818,14 +818,14 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10)); CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + i); cu.setComment(CommentType.PLATE, "comment for plate " + i);
cu.setComment(CodeUnit.EOL_COMMENT, "comment for eol " + i); cu.setComment(CommentType.EOL, "comment for eol " + i);
} }
for (int i = 20; i < 30; i++) { for (int i = 20; i < 30; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 5000)); CodeUnit cu = listing.getCodeUnitAt(addr(i + 5000));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + i); cu.setComment(CommentType.PLATE, "comment for plate " + i);
cu.setComment(CodeUnit.EOL_COMMENT, "comment for eol " + i); cu.setComment(CommentType.EOL, "comment for eol " + i);
} }
endTransaction(); endTransaction();
@ -855,16 +855,16 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
false); false);
CodeUnit cu = listing.getCodeUnitAt(addr(90)); 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 = 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 = 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 = listing.getCodeUnitAt(addr(10));
cu.setComment(CodeUnit.PLATE_COMMENT, "comment for plate " + addr(10)); cu.setComment(CommentType.PLATE, "comment for plate " + addr(10));
endTransaction(); endTransaction();
CodeUnitIterator iter = CodeUnitIterator iter =
@ -977,12 +977,12 @@ public class CodeUnitIteratorTest extends AbstractGhidraHeadedIntegrationTest {
false); false);
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(i + 10)); CodeUnit cu = listing.getCodeUnitAt(addr(i + 10));
cu.setComment(CodeUnit.EOL_COMMENT, "This is an eol comment " + i); cu.setComment(CommentType.EOL, "This is an eol comment " + i);
assertNotNull(cu.getComment(CodeUnit.EOL_COMMENT)); assertNotNull(cu.getComment(CommentType.EOL));
} }
for (int i = 100; i < 120; i++) { for (int i = 100; i < 120; i++) {
CodeUnit cu = listing.getCodeUnitAt(addr(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(); endTransaction();
AddressSet set = new AddressSet(addr(0), addr(5)); AddressSet set = new AddressSet(addr(0), addr(5));

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -119,42 +119,42 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x100101c); Address a = addr(0x100101c);
CodeUnit cu = program.getListing().getCodeUnitAt(a); 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); locs[0] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
a = addr(0x10030e4); a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a); 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); locs[1] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
a = addr(0x100352f); a = addr(0x100352f);
cu = program.getListing().getCodeUnitAt(a); 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); locs[2] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 0, 5);
a = addr(0x10030e4); a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a); 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); locs[3] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 1, 5);
a = addr(0x10075ff); a = addr(0x10075ff);
cu = program.getListing().getCodeUnitAt(a); 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); locs[4] = new PostCommentFieldLocation(program, a, null, comment, 0, 5);
a = addr(0x1003cf3); a = addr(0x1003cf3);
cu = program.getListing().getCodeUnitAt(a); 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); locs[5] = new PostCommentFieldLocation(program, a, null, comment, 0, 0);
a = addr(0x10030f0); a = addr(0x10030f0);
cu = program.getListing().getCodeUnitAt(a); 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); locs[6] = new PlateFieldLocation(program, a, null, 0, 5, comment, -1);
a = addr(0x1003efc); a = addr(0x1003efc);
cu = program.getListing().getCodeUnitAt(a); 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); locs[7] = new PlateFieldLocation(program, a, null, 0, 3, comment, -1);
// TODO add test for repeatable comments. // TODO add test for repeatable comments.
@ -168,12 +168,12 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x100101c); Address a = addr(0x100101c);
CodeUnit cu = program.getListing().getCodeUnitAt(a); 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); locs[0] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
a = addr(0x10030e4); a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a); 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); locs[1] = new CommentFieldLocation(program, a, null, comment, CodeUnit.PRE_COMMENT, 0, 5);
return locs; return locs;
} }
@ -184,12 +184,12 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x100352f); Address a = addr(0x100352f);
CodeUnit cu = program.getListing().getCodeUnitAt(a); 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); locs[0] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 0, 5);
a = addr(0x10030e4); a = addr(0x10030e4);
cu = program.getListing().getCodeUnitAt(a); 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); locs[1] = new CommentFieldLocation(program, a, null, comment, CodeUnit.EOL_COMMENT, 1, 5);
return locs; return locs;
} }
@ -200,12 +200,12 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x10075ff); Address a = addr(0x10075ff);
CodeUnit cu = program.getListing().getCodeUnitAt(a); 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); locs[0] = new PostCommentFieldLocation(program, a, null, comment, 0, 5);
a = addr(0x1003cf3); a = addr(0x1003cf3);
cu = program.getListing().getCodeUnitAt(a); 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); locs[1] = new PostCommentFieldLocation(program, a, null, comment, 0, 0);
return locs; return locs;
} }
@ -216,12 +216,12 @@ public class SampleLocationGenerator implements GhidraLocationGenerator {
Address a = addr(0x10030f0); Address a = addr(0x10030f0);
CodeUnit cu = program.getListing().getCodeUnitAt(a); 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); locs[0] = new PlateFieldLocation(program, a, null, 0, 5, comment, -1);
a = addr(0x1003efc); a = addr(0x1003efc);
cu = program.getListing().getCodeUnitAt(a); 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); locs[1] = new PlateFieldLocation(program, a, null, 0, 3, comment, -1);
return locs; return locs;
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -174,14 +174,14 @@ public class CodeManagerTest extends AbstractGenericTest {
parseStatic(addr(0x2000), addr(0x2003)); parseStatic(addr(0x2000), addr(0x2003));
CodeUnit cu = listing.getCodeUnitAt(addr(0x2000)); CodeUnit cu = listing.getCodeUnitAt(addr(0x2000));
cu.setComment(CodeUnit.EOL_COMMENT, "eol comment"); cu.setComment(CommentType.EOL, "eol comment");
cu.setComment(CodeUnit.PLATE_COMMENT, "plate comment"); cu.setComment(CommentType.PLATE, "plate comment");
cu = listing.getCodeUnitAt(addr(0x2000)); cu = listing.getCodeUnitAt(addr(0x2000));
String comment = cu.getComment(CodeUnit.EOL_COMMENT); String comment = cu.getComment(CommentType.EOL);
assertNotNull(comment); assertNotNull(comment);
assertEquals("eol comment", comment); assertEquals("eol comment", comment);
comment = cu.getComment(CodeUnit.PLATE_COMMENT); comment = cu.getComment(CommentType.PLATE);
assertNotNull(comment); assertNotNull(comment);
assertEquals("plate comment", comment); assertEquals("plate comment", comment);
} }
@ -364,30 +364,30 @@ public class CodeManagerTest extends AbstractGenericTest {
InstructionIterator iter = listing.getInstructions(true); InstructionIterator iter = listing.getInstructions(true);
while (iter.hasNext()) { while (iter.hasNext()) {
Instruction inst = iter.next(); Instruction inst = iter.next();
inst.setComment(CodeUnit.PRE_COMMENT, "pre comment"); inst.setComment(CommentType.PRE, "pre comment");
inst.setComment(CodeUnit.EOL_COMMENT, "eol comment"); inst.setComment(CommentType.EOL, "eol comment");
assertEquals("pre comment", inst.getComment(CodeUnit.PRE_COMMENT)); assertEquals("pre comment", inst.getComment(CommentType.PRE));
assertEquals("eol comment", inst.getComment(CodeUnit.EOL_COMMENT)); assertEquals("eol comment", inst.getComment(CommentType.EOL));
} }
Instruction inst = listing.getInstructionAt(addr(0x2000)); Instruction inst = listing.getInstructionAt(addr(0x2000));
assertEquals("pre comment", inst.getComment(CodeUnit.PRE_COMMENT)); assertEquals("pre comment", inst.getComment(CommentType.PRE));
assertEquals("eol comment", inst.getComment(CodeUnit.EOL_COMMENT)); assertEquals("eol comment", inst.getComment(CommentType.EOL));
listing.clearComments(addr(0x2000), addr(0x2100)); listing.clearComments(addr(0x2000), addr(0x2100));
inst = listing.getInstructionAfter(addr(0x2000)); inst = listing.getInstructionAfter(addr(0x2000));
assertNull(inst.getComment(CodeUnit.PRE_COMMENT)); assertNull(inst.getComment(CommentType.PRE));
assertNull(inst.getComment(CodeUnit.EOL_COMMENT)); assertNull(inst.getComment(CommentType.EOL));
inst = listing.getInstructionAt(addr(0x2000)); inst = listing.getInstructionAt(addr(0x2000));
assertNull(inst.getComment(CodeUnit.PRE_COMMENT)); assertNull(inst.getComment(CommentType.PRE));
assertNull(inst.getComment(CodeUnit.EOL_COMMENT)); assertNull(inst.getComment(CommentType.EOL));
inst = listing.getInstructionBefore(addr(0x2000)); inst = listing.getInstructionBefore(addr(0x2000));
assertEquals("pre comment", inst.getComment(CodeUnit.PRE_COMMENT)); assertEquals("pre comment", inst.getComment(CommentType.PRE));
assertEquals("eol comment", inst.getComment(CodeUnit.EOL_COMMENT)); assertEquals("eol comment", inst.getComment(CommentType.EOL));
} }
@Test @Test
@ -536,7 +536,7 @@ public class CodeManagerTest extends AbstractGenericTest {
parseStatic(addr(0x1100), addr(0x1200)); parseStatic(addr(0x1100), addr(0x1200));
MemoryBlock block = mem.getBlock(addr(0x1000)); MemoryBlock block = mem.getBlock(addr(0x1000));
CodeUnit cu = listing.getCodeUnitContaining(block.getEnd()); CodeUnit cu = listing.getCodeUnitContaining(block.getEnd());
cu.setComment(CodeUnit.EOL_COMMENT, "eol comment"); cu.setComment(CommentType.EOL, "eol comment");
Address oldMin = cu.getMinAddress(); Address oldMin = cu.getMinAddress();
Address expectedNewMin = oldMin.addNoWrap(0x8000 - 0x1000); Address expectedNewMin = oldMin.addNoWrap(0x8000 - 0x1000);
@ -552,7 +552,7 @@ public class CodeManagerTest extends AbstractGenericTest {
cu = listing.getCodeUnitContaining(block.getEnd()); cu = listing.getCodeUnitContaining(block.getEnd());
assertEquals(expectedNewMin, cu.getMinAddress()); assertEquals(expectedNewMin, cu.getMinAddress());
assertNotNull(cu.getComment(CodeUnit.EOL_COMMENT)); assertNotNull(cu.getComment(CommentType.EOL));
assertEquals(12, cu.getIntProperty("Numbers")); assertEquals(12, cu.getIntProperty("Numbers"));
c = (SaveableColor) cu.getObjectProperty("FavoriteColor"); c = (SaveableColor) cu.getObjectProperty("FavoriteColor");
@ -576,32 +576,32 @@ public class CodeManagerTest extends AbstractGenericTest {
public void testCompositeDataComments() throws Exception { public void testCompositeDataComments() throws Exception {
CodeUnit cu = listing.getCodeUnitAt(addr(0x1741)); CodeUnit cu = listing.getCodeUnitAt(addr(0x1741));
cu.setComment(CodeUnit.EOL_COMMENT, "eol comment"); cu.setComment(CommentType.EOL, "eol comment");
cu.setComment(CodeUnit.PLATE_COMMENT, "plate comment"); cu.setComment(CommentType.PLATE, "plate comment");
cu.setComment(CodeUnit.POST_COMMENT, "post comment"); cu.setComment(CommentType.POST, "post comment");
cu.setComment(CodeUnit.PRE_COMMENT, "pre comment"); cu.setComment(CommentType.PRE, "pre comment");
Structure struct = new StructureDataType("struct_1", 0); Structure struct = new StructureDataType("struct_1", 0);
struct.add(DWordDataType.dataType); struct.add(DWordDataType.dataType);
struct.add(DWordDataType.dataType); struct.add(DWordDataType.dataType);
Data structData = listing.createData(addr(0x1741), struct, struct.getLength()); Data structData = listing.createData(addr(0x1741), struct, struct.getLength());
assertEquals("eol comment", structData.getComment(CodeUnit.EOL_COMMENT)); assertEquals("eol comment", structData.getComment(CommentType.EOL));
assertEquals("plate comment", structData.getComment(CodeUnit.PLATE_COMMENT)); assertEquals("plate comment", structData.getComment(CommentType.PLATE));
assertEquals("post comment", structData.getComment(CodeUnit.POST_COMMENT)); assertEquals("post comment", structData.getComment(CommentType.POST));
assertEquals("pre comment", structData.getComment(CodeUnit.PRE_COMMENT)); assertEquals("pre comment", structData.getComment(CommentType.PRE));
Data firstComp = structData.getComponent(0); Data firstComp = structData.getComponent(0);
assertEquals("eol comment", firstComp.getComment(CodeUnit.EOL_COMMENT)); assertEquals("eol comment", firstComp.getComment(CommentType.EOL));
assertEquals("plate comment", firstComp.getComment(CodeUnit.PLATE_COMMENT)); assertEquals("plate comment", firstComp.getComment(CommentType.PLATE));
assertEquals("post comment", firstComp.getComment(CodeUnit.POST_COMMENT)); assertEquals("post comment", firstComp.getComment(CommentType.POST));
assertEquals("pre comment", firstComp.getComment(CodeUnit.PRE_COMMENT)); assertEquals("pre comment", firstComp.getComment(CommentType.PRE));
structData.setComment(CodeUnit.EOL_COMMENT, "EOL"); structData.setComment(CommentType.EOL, "EOL");
assertEquals("EOL", firstComp.getComment(CodeUnit.EOL_COMMENT)); assertEquals("EOL", firstComp.getComment(CommentType.EOL));
firstComp.setComment(CodeUnit.POST_COMMENT, "POST"); firstComp.setComment(CommentType.POST, "POST");
assertEquals("POST", structData.getComment(CodeUnit.POST_COMMENT)); assertEquals("POST", structData.getComment(CommentType.POST));
} }
@Test @Test
@ -974,13 +974,13 @@ public class CodeManagerTest extends AbstractGenericTest {
// to 1-msec to avoid testing delays. // to 1-msec to avoid testing delays.
CodeUnit cu = listing.getCodeUnitAt(addr(0x1000)); 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 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 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(); CodeManager cm = ((ProgramDB) program).getCodeManager();
CommentHistory[] history = cm.getCommentHistory(addr(0x1000), CodeUnit.EOL_COMMENT); CommentHistory[] history = cm.getCommentHistory(addr(0x1000), CodeUnit.EOL_COMMENT);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -60,7 +60,7 @@ class DebugUtils {
transactionID = program.startTransaction("Colorize CodeCompare"); transactionID = program.startTransaction("Colorize CodeCompare");
Set<Entry<CodeUnit, TreeSet<AddressRange>>> entrySet = map.entrySet(); Set<Entry<CodeUnit, TreeSet<AddressRange>>> entrySet = map.entrySet();
for (Entry<CodeUnit, TreeSet<AddressRange>> entry : 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 { finally {

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -548,7 +548,7 @@ public class DecompileCallback {
private void encodeHeaderComment(Encoder encoder, Function func) throws IOException { private void encodeHeaderComment(Encoder encoder, Function func) throws IOException {
Address addr = func.getEntryPoint(); Address addr = func.getEntryPoint();
String text = listing.getComment(CodeUnit.PLATE_COMMENT, addr); String text = listing.getComment(CommentType.PLATE, addr);
if (text != null) { if (text != null) {
encoder.openElement(ELEM_COMMENT); encoder.openElement(ELEM_COMMENT);
encoder.writeString(ATTRIB_TYPE, "header"); encoder.writeString(ATTRIB_TYPE, "header");

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -194,7 +194,7 @@ public class ObjectiveC2_DecompilerMessageAnalyzer extends AbstractAnalyzer {
if (instruction == null) { if (instruction == null) {
return; return;
} }
if (instruction.getComment(CodeUnit.EOL_COMMENT) != null) { if (instruction.getComment(CommentType.EOL) != null) {
return; return;
} }
@ -217,7 +217,7 @@ public class ObjectiveC2_DecompilerMessageAnalyzer extends AbstractAnalyzer {
builder.append(split[i]); builder.append(split[i]);
} }
builder.delete(builder.length() - 2, builder.length() - 1); 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) { 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) { 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) { private void assertNextTokenIndex(int expectedIndex, int line, int... cols) {

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -29,7 +29,7 @@ import ghidra.file.formats.android.dex.util.DexUtil;
import ghidra.framework.model.DomainObject; import ghidra.framework.model.DomainObject;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.PointerDataType; 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.listing.Program;
import ghidra.program.model.mem.MemoryBlock; import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.model.symbol.*; import ghidra.program.model.symbol.*;
@ -189,7 +189,7 @@ public class DexLoader extends AbstractProgramWrapperLoader {
if (program.getMemory().getInt(methodIndexAddress) == -1) { if (program.getMemory().getInt(methodIndexAddress) == -1) {
program.getListing() program.getListing()
.setComment(methodIndexAddress, CodeUnit.PLATE_COMMENT, builder.toString()); .setComment(methodIndexAddress, CommentType.PLATE, builder.toString());
// Add placeholder symbol for external functions // Add placeholder symbol for external functions
String methodName = DexUtil.convertToString(header, item.getNameIndex()); String methodName = DexUtil.convertToString(header, item.getNameIndex());

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -31,10 +31,7 @@ import ghidra.program.model.data.StringDataType;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.util.CodeUnitInsertionException; import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.*;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.NotEmptyException;
import ghidra.util.exception.NotFoundException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
public abstract class FileFormatAnalyzer implements Analyzer { 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) { 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); return cmd.applyTo(program);
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -181,7 +181,7 @@ public abstract class ArtImageSections {
program.getMinAddress().getNewAddress(header.getImageBegin() + section.getOffset()); program.getMinAddress().getNewAddress(header.getImageBegin() + section.getOffset());
program.getSymbolTable().createLabel(address, name, SourceType.ANALYSIS); program.getSymbolTable().createLabel(address, name, SourceType.ANALYSIS);
program.getListing() program.getListing()
.setComment(address, CodeUnit.PLATE_COMMENT, "Size: " + section.getSize()); .setComment(address, CommentType.PLATE, "Size: " + section.getSize());
createFragment(program, address, section, name, monitor); createFragment(program, address, section, name, monitor);
} }
@ -210,7 +210,7 @@ public abstract class ArtImageSections {
String comment = String comment =
"Declaring Class: 0x" + Integer.toHexString(field.getDeclaringClass()); "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()); address = address.add(dataType.getLength());
@ -230,7 +230,7 @@ public abstract class ArtImageSections {
ArtField artField = fieldGroup.getFieldList().get(0); ArtField artField = fieldGroup.getFieldList().get(0);
String comment = String comment =
"Declaring Class: 0x" + Integer.toHexString(artField.getDeclaringClass()); "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()); address = address.add(dataType.getLength());
@ -261,7 +261,7 @@ public abstract class ArtImageSections {
program.getListing().createData(address, dataType); program.getListing().createData(address, dataType);
String comment = String comment =
"Declaring Class: 0x" + Integer.toHexString(method.getDeclaringClass()); "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()); address = address.add(dataType.getLength());
@ -282,7 +282,7 @@ public abstract class ArtImageSections {
ArtMethod artMethod = methodGroup.getMethodList().get(0); ArtMethod artMethod = methodGroup.getMethodList().get(0);
String comment = String comment =
"Declaring Class: 0x" + Integer.toHexString(artMethod.getDeclaringClass()); "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()); address = address.add(dataType.getLength());

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -255,8 +255,7 @@ public class DexMarkupInstructionsAnalyzer extends FileFormatAnalyzer {
String className = stringItem.getStringDataItem().getString(); String className = stringItem.getStringDataItem().getString();
setEquate(program, instruction.getMinAddress(), operand, className, classTypeIndex); setEquate(program, instruction.getMinAddress(), operand, className, classTypeIndex);
program.getListing() program.getListing().setComment(instruction.getMinAddress(), CommentType.EOL, className);
.setComment(instruction.getMinAddress(), CodeUnit.EOL_COMMENT, className);
} }
private void processString(Program program, Instruction instruction, int operand, private void processString(Program program, Instruction instruction, int operand,
@ -300,7 +299,6 @@ public class DexMarkupInstructionsAnalyzer extends FileFormatAnalyzer {
String valueName = format(className, fieldName); String valueName = format(className, fieldName);
setEquate(program, instruction.getMinAddress(), operand, fieldName, fieldIndex); setEquate(program, instruction.getMinAddress(), operand, fieldName, fieldIndex);
program.getListing() program.getListing().setComment(instruction.getMinAddress(), CommentType.EOL, valueName);
.setComment(instruction.getMinAddress(), CodeUnit.EOL_COMMENT, valueName);
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,9 +20,7 @@ import ghidra.app.util.importer.MessageLog;
import ghidra.program.flatapi.FlatProgramAPI; import ghidra.program.flatapi.FlatProgramAPI;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.program.model.listing.CodeUnit; import ghidra.program.model.listing.*;
import ghidra.program.model.listing.Data;
import ghidra.program.model.listing.Program;
import ghidra.program.model.symbol.RefType; import ghidra.program.model.symbol.RefType;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
@ -112,8 +110,7 @@ public abstract class FBPK_Partition implements StructConverter {
} }
program.getListing() program.getListing()
.setComment(address, CodeUnit.PLATE_COMMENT, .setComment(address, CommentType.PLATE, getName() + " - " + getPartitionIndex());
getName() + " - " + getPartitionIndex());
api.createFragment(getName(), address, partitionDataType.getLength()); api.createFragment(getName(), address, partitionDataType.getLength());

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -41,7 +41,7 @@ public abstract class FBPT implements StructConverter {
return; return;
} }
String comment = "FBPT" + "\n" + "Num of entries: " + getEntries().size(); 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()); api.createFragment(FBPK_Constants.FBPT, address, fbptDataType.getLength());
address = address.add(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); log.appendMsg("Unable to apply FBPT Entry data, stopping - " + address);
return; 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()); api.createFragment(FBPK_Constants.FBPT, address, entryDataType.getLength());
address = address.add(entryDataType.getLength()); address = address.add(entryDataType.getLength());
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -25,24 +25,12 @@ import ghidra.file.formats.android.dex.format.DexHeader;
import ghidra.file.formats.android.oat.oatdexfile.OatDexFile; import ghidra.file.formats.android.oat.oatdexfile.OatDexFile;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView; import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.Array; import ghidra.program.model.data.*;
import ghidra.program.model.data.ArrayDataType; import ghidra.program.model.listing.*;
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.mem.Memory; import ghidra.program.model.mem.Memory;
import ghidra.program.model.mem.MemoryBlock; import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.model.scalar.Scalar; import ghidra.program.model.scalar.Scalar;
import ghidra.program.model.symbol.Equate; import ghidra.program.model.symbol.*;
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.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
@ -199,7 +187,7 @@ public class OatHeaderAnalyzer extends FileFormatAnalyzer {
Data data = createData(program, address, dataType); Data data = createData(program, address, dataType);
Scalar scalar = data.getScalar(0); Scalar scalar = data.getScalar(0);
Address toAddr = destinationBlock.getStart().add(scalar.getUnsignedValue()); 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) { catch (Exception e) {
log.appendException(e); log.appendException(e);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -120,7 +120,7 @@ public class OatDexFile_S_T extends OatDexFile {
Address dataAddress = address.add(_offset); 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); program.getListing().clearCodeUnits(dataAddress, dataAddress, false, monitor);
Data data = program.getListing().createData(dataAddress, toDataType()); Data data = program.getListing().createData(dataAddress, toDataType());

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -15,9 +15,7 @@
*/ */
package ghidra.file.formats.android.vdex; package ghidra.file.formats.android.vdex;
import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.*;
import ghidra.app.util.bin.ByteProvider;
import ghidra.app.util.bin.MemoryByteProvider;
import ghidra.app.util.importer.MessageLog; import ghidra.app.util.importer.MessageLog;
import ghidra.file.analyzers.FileFormatAnalyzer; import ghidra.file.analyzers.FileFormatAnalyzer;
import ghidra.file.formats.android.dex.format.DexHeader; 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.file.formats.android.vdex.sections.DexSectionHeader_002;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView; import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.ArrayDataType; import ghidra.program.model.data.*;
import ghidra.program.model.data.ByteDataType; import ghidra.program.model.listing.CommentType;
import ghidra.program.model.data.DWordDataType;
import ghidra.program.model.data.DataType;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
@ -90,8 +85,7 @@ public class VdexHeaderAnalyzer extends FileFormatAnalyzer {
monitor.checkCancelled(); monitor.checkCancelled();
program.getListing() program.getListing()
.setComment(address, CodeUnit.PLATE_COMMENT, .setComment(address, CommentType.PLATE, "quicken info table entry");
"quicken info table entry");
createData(program, address, new DWordDataType()); createData(program, address, new DWordDataType());
address = address.add(4); address = address.add(4);
@ -130,7 +124,7 @@ public class VdexHeaderAnalyzer extends FileFormatAnalyzer {
if (sectionHeader != null) { if (sectionHeader != null) {
int dexSharedDataSize = sectionHeader.getDexSharedDataSize(); int dexSharedDataSize = sectionHeader.getDexSharedDataSize();
String comment = "dex_shared_data_size_ : 0x" + Integer.toHexString(dexSharedDataSize); 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()); DataType array = new ArrayDataType(BYTE, dexSharedDataSize, BYTE.getLength());
createData(program, address, array); createData(program, address, array);
address = address.add(dexSharedDataSize); address = address.add(dexSharedDataSize);
@ -146,7 +140,7 @@ public class VdexHeaderAnalyzer extends FileFormatAnalyzer {
String comment = String comment =
"verifier_deps_size_ : 0x" + Integer.toHexString(vdexHeader.getVerifierDepsSize()); "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(); int remainderSize = vdexHeader.getVerifierDepsSize();
@ -183,7 +177,7 @@ public class VdexHeaderAnalyzer extends FileFormatAnalyzer {
} }
String comment = "quickening_info_size_ : 0x" + Integer.toHexString(quickeningInfoSize); 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); 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.data.DataType;
import ghidra.program.model.lang.Language; import ghidra.program.model.lang.Language;
import ghidra.program.model.lang.Processor; 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.listing.Program;
import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryAccessException;
import ghidra.util.exception.CancelledException; import ghidra.util.exception.CancelledException;
@ -76,8 +76,7 @@ public class CramFsAnalyzer extends AbstractAnalyzer {
DataType dataType = cramFsSuper.toDataType(); DataType dataType = cramFsSuper.toDataType();
program.getListing().createData(minAddress, dataType); program.getListing().createData(minAddress, dataType);
program.getListing() program.getListing()
.setComment(minAddress, CodeUnit.PLATE_COMMENT, .setComment(minAddress, CommentType.PLATE, cramFsSuper.getRoot().toString());
cramFsSuper.getRoot().toString());
int offset = cramFsSuper.getRoot().getOffsetAdjusted(); int offset = cramFsSuper.getRoot().getOffsetAdjusted();
for (int i = 0; i < cramFsSuper.getFsid().getFiles() - 1; i++) { for (int i = 0; i < cramFsSuper.getFsid().getFiles() - 1; i++) {
@ -90,7 +89,7 @@ public class CramFsAnalyzer extends AbstractAnalyzer {
if (newInode.isFile()) { if (newInode.isFile()) {
Address inodeDataAddress = minAddress.add(newInode.getOffsetAdjusted()); Address inodeDataAddress = minAddress.add(newInode.getOffsetAdjusted());
program.getListing() program.getListing()
.setComment(inodeDataAddress, CodeUnit.PLATE_COMMENT, .setComment(inodeDataAddress, CommentType.PLATE,
newInode.getName() + " Data/Bytes\n"); newInode.getName() + " Data/Bytes\n");
} }
@ -98,7 +97,7 @@ public class CramFsAnalyzer extends AbstractAnalyzer {
program.getListing().createData(inodeAddress, inodeDataType); program.getListing().createData(inodeAddress, inodeDataType);
program.getListing() program.getListing()
.setComment(inodeAddress, CodeUnit.PLATE_COMMENT, .setComment(inodeAddress, CommentType.PLATE,
newInode.getName() + "\n" + newInode.toString()); newInode.getName() + "\n" + newInode.toString());
offset += inodeDataType.getLength(); offset += inodeDataType.getLength();

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,7 +23,7 @@ import ghidra.file.analyzers.FileFormatAnalyzer;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView; import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.DataType; 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.listing.Program;
import ghidra.util.exception.DuplicateNameException; import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor; import ghidra.util.task.TaskMonitor;
@ -154,7 +154,9 @@ public class Ext4Analyzer extends FileFormatAnalyzer {
Ext4Inode inode = new Ext4Inode(reader); Ext4Inode inode = new Ext4Inode(reader);
DataType dataType = inode.toDataType(); DataType dataType = inode.toDataType();
createData(program, address, dataType); 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()); address = address.add(superBlock.getS_inode_size());
reader.setPointerIndex(address.getOffset()); reader.setPointerIndex(address.getOffset());
monitor.incrementProgress(1); monitor.incrementProgress(1);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -15,9 +15,8 @@
*/ */
package ghidra.file.formats.ext4; package ghidra.file.formats.ext4;
import java.util.List;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import ghidra.app.cmd.comments.SetCommentCmd; import ghidra.app.cmd.comments.SetCommentCmd;
import ghidra.app.plugin.core.analysis.AutoAnalysisManager; import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
@ -203,7 +202,7 @@ public class NewExt4Analyzer extends FileFormatAnalyzer {
@Override @Override
protected boolean setPlateComment( Program program, Address address, String comment ) { 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 ) ) { if ( program.getMemory( ).contains( address ) ) {
return cmd.applyTo( program ); return cmd.applyTo( program );
} }

View file

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

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -64,7 +64,8 @@ public class TestAnalyzer extends AbstractAnalyzer {
//don't need to check this.. //don't need to check this..
} }
program.getListing().setComment(currentAddress, CodeUnit.PLATE_COMMENT, program.getListing()
.setComment(currentAddress, CommentType.PLATE,
"Address = " + currentAddress.toString()); "Address = " + currentAddress.toString());
currentAddress = currentAddress.add(data.getLength()); 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.address.Address;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.program.model.data.TerminatedStringDataType; 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.listing.Data;
import ghidra.program.model.symbol.*; import ghidra.program.model.symbol.*;
import ghidra.test.ToyProgramBuilder; import ghidra.test.ToyProgramBuilder;
@ -226,7 +226,7 @@ public class GnuDemanglerTest extends AbstractGenericTest {
assertEquals("AP_HAL::HAL::Callbacks", s.getParentNamespace().getName(true)); assertEquals("AP_HAL::HAL::Callbacks", s.getParentNamespace().getName(true));
assertEquals("typeinfo for AP_HAL::HAL::Callbacks", 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")); Data d = program.getListing().getDefinedDataAt(addr("01001000"));
assertNotNull(d); assertNotNull(d);
@ -259,7 +259,7 @@ public class GnuDemanglerTest extends AbstractGenericTest {
assertEquals("AP_HAL::HAL::Callbacks", s.getParentNamespace().getName(true)); assertEquals("AP_HAL::HAL::Callbacks", s.getParentNamespace().getName(true));
assertEquals("typeinfo name for AP_HAL::HAL::Callbacks", 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")); Data d = program.getListing().getDefinedDataAt(addr("01001000"));
assertNotNull(d); assertNotNull(d);

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -114,7 +114,7 @@ public class CreateTypeDescriptorBackgroundCmd
Data nameData = DataUtilities.createData(program, arrayAddr, charArray, Data nameData = DataUtilities.createData(program, arrayAddr, charArray,
charArray.getLength(), getClearDataMode()); charArray.getLength(), getClearDataMode());
nameData.setComment(CodeUnit.EOL_COMMENT, "TypeDescriptor.name"); nameData.setComment(CommentType.EOL, "TypeDescriptor.name");
return true; return true;
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -233,7 +233,7 @@ public class EHDataTypeUtilities {
String dataTypeName, String suffix, Address address, DataApplyOptions applyOptions) { String dataTypeName, String suffix, Address address, DataApplyOptions applyOptions) {
Listing listing = program.getListing(); Listing listing = program.getListing();
String existingComment = listing.getComment(CodeUnit.PLATE_COMMENT, address); String existingComment = listing.getComment(CommentType.PLATE, address);
if (!applyOptions.shouldCreateComments()) { if (!applyOptions.shouldCreateComments()) {
return existingComment; return existingComment;
} }
@ -245,7 +245,7 @@ public class EHDataTypeUtilities {
String appliedSuffix = (suffix != null) ? (suffix) : ""; String appliedSuffix = (suffix != null) ? (suffix) : "";
String appliedExisting = (existingComment != null) ? (existingComment + "\n") : ""; String appliedExisting = (existingComment != null) ? (existingComment + "\n") : "";
String appliedComment = appliedExisting + appliedPrefix + dataTypeName + appliedSuffix; String appliedComment = appliedExisting + appliedPrefix + dataTypeName + appliedSuffix;
listing.setComment(address, CodeUnit.PLATE_COMMENT, appliedComment); listing.setComment(address, CommentType.PLATE, appliedComment);
return appliedComment; return appliedComment;
} }
return existingComment; return existingComment;

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -120,7 +120,7 @@ public class CreateVfTableBackgroundCmd extends AbstractCreateDataBackgroundCmd<
String prefixString = ((demangledTypeDescriptor != null) String prefixString = ((demangledTypeDescriptor != null)
? (demangledTypeDescriptor + Namespace.DELIMITER) ? (demangledTypeDescriptor + Namespace.DELIMITER)
: ""); : "");
data.setComment(CodeUnit.EOL_COMMENT, data.setComment(CommentType.EOL,
"terminator for " + prefixString + VF_TABLE_LABEL); "terminator for " + prefixString + VF_TABLE_LABEL);
return true; return true;
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -209,7 +209,7 @@ public class PropagateExternalParametersAnalyzer extends AbstractAnalyzer {
Parameter param = params[index]; Parameter param = params[index];
DataType dt = param.getDataType(); DataType dt = param.getDataType();
String name = param.getName(); 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); dt.getDisplayName() + " " + name + " for " + externalFunctionName);
cmd.applyTo(currentProgram); cmd.applyTo(currentProgram);
@ -310,17 +310,16 @@ public class PropagateExternalParametersAnalyzer extends AbstractAnalyzer {
private void createComment(Address dataAddress, String newComment, PushedParamInfo info) { private void createComment(Address dataAddress, String newComment, PushedParamInfo info) {
Listing listing = currentProgram.getListing(); Listing listing = currentProgram.getListing();
String plateComment = listing.getComment(CodeUnit.PLATE_COMMENT, dataAddress); String plateComment = listing.getComment(CommentType.PLATE, dataAddress);
if (plateComment == null) { if (plateComment == null) {
// add a comment // add a comment
SetCommentCmd cmd = new SetCommentCmd(dataAddress, CodeUnit.PLATE_COMMENT, newComment); SetCommentCmd cmd = new SetCommentCmd(dataAddress, CommentType.PLATE, newComment);
cmd.applyTo(currentProgram); cmd.applyTo(currentProgram);
} }
else if (!plateComment.contains(info.getCalledFunctionName())) { else if (!plateComment.contains(info.getCalledFunctionName())) {
// update the existing comment // update the existing comment
String updatedComment = plateComment + "\n" + newComment; String updatedComment = plateComment + "\n" + newComment;
SetCommentCmd cmd = SetCommentCmd cmd = new SetCommentCmd(dataAddress, CommentType.PLATE, updatedComment);
new SetCommentCmd(dataAddress, CodeUnit.PLATE_COMMENT, updatedComment);
cmd.applyTo(currentProgram); cmd.applyTo(currentProgram);
} }
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -93,7 +93,7 @@ class ApplySymbols {
if (!"NONAME".equals(name)) { if (!"NONAME".equals(name)) {
preComment += " (" + name + ")"; preComment += " (" + name + ")";
} }
PdbUtil.appendComment(program, address, preComment, CodeUnit.PRE_COMMENT); PdbUtil.appendComment(program, address, preComment, CommentType.PRE);
continue; continue;
} }
@ -108,7 +108,7 @@ class ApplySymbols {
if (length == 0) { if (length == 0) {
// avoid creating symbol which may correspond to inline function code // avoid creating symbol which may correspond to inline function code
PdbUtil.appendComment(program, address, "Symbol Ref: {@symbol " + name + "}", PdbUtil.appendComment(program, address, "Symbol Ref: {@symbol " + name + "}",
CodeUnit.PRE_COMMENT); CommentType.PRE);
continue; continue;
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,7 +21,7 @@ import ghidra.app.util.PseudoInstruction;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.Composite; import ghidra.program.model.data.Composite;
import ghidra.program.model.data.Structure; 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.program.model.listing.Program;
import ghidra.util.Conv; import ghidra.util.Conv;
@ -52,10 +52,10 @@ final class PdbUtil {
* @param program program * @param program program
* @param address listing address * @param address listing address
* @param text comment text * @param text comment text
* @param commentType comment type ({@link CodeUnit} * @param commentType comment type
*/ */
final static void appendComment(Program program, Address address, String text, final static void appendComment(Program program, Address address, String text,
int commentType) { CommentType commentType) {
String comment = program.getListing().getComment(commentType, address); String comment = program.getListing().getComment(commentType, address);
if (comment != null) { if (comment != null) {

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,8 +20,7 @@ import java.util.Map;
import ghidra.app.cmd.comments.SetCommentCmd; import ghidra.app.cmd.comments.SetCommentCmd;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit; import ghidra.program.model.listing.*;
import ghidra.program.model.listing.Program;
import ghidra.util.Msg; import ghidra.util.Msg;
/** /**
@ -118,7 +117,7 @@ public class BlockCommentsManager {
private void finalizeBlockComments(Program program, long addressDelta) { private void finalizeBlockComments(Program program, long addressDelta) {
for (Map.Entry<Address, String> entry : blockPreComments.entrySet()) { for (Map.Entry<Address, String> entry : blockPreComments.entrySet()) {
appendBlockComment(program, entry.getKey().add(addressDelta), entry.getValue(), appendBlockComment(program, entry.getKey().add(addressDelta), entry.getValue(),
CodeUnit.PRE_COMMENT); CommentType.PRE);
} }
for (Map.Entry<Address, String> entry : blockPostComments.entrySet()) { for (Map.Entry<Address, String> entry : blockPostComments.entrySet()) {
CodeUnit codeUnit = program.getListing() CodeUnit codeUnit = program.getListing()
@ -129,14 +128,13 @@ public class BlockCommentsManager {
} }
else { else {
Address endCodeUnitAddress = codeUnit.getAddress(); Address endCodeUnitAddress = codeUnit.getAddress();
appendBlockComment(program, endCodeUnitAddress, entry.getValue(), appendBlockComment(program, endCodeUnitAddress, entry.getValue(), CommentType.POST);
CodeUnit.POST_COMMENT);
} }
} }
} }
private void appendBlockComment(Program program, Address address, String text, private void appendBlockComment(Program program, Address address, String text,
int commentType) { CommentType commentType) {
String comment = program.getListing().getComment(commentType, address); String comment = program.getListing().getComment(commentType, address);
comment = (comment == null) ? text : comment + "\n" + text; comment = (comment == null) ? text : comment + "\n" + text;
SetCommentCmd.createComment(program, address, comment, commentType); SetCommentCmd.createComment(program, address, comment, commentType);

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