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

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

View File

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

View File

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

View File

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

View File

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

View File

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