mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-5742 Cleanup preferred CommentType enum use. Changed SARIF data component comment JSON serialization from int to String.
This commit is contained in:
@@ -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.
|
||||
@@ -114,7 +114,7 @@ public class CreateTypeDescriptorBackgroundCmd
|
||||
Data nameData = DataUtilities.createData(program, arrayAddr, charArray,
|
||||
charArray.getLength(), getClearDataMode());
|
||||
|
||||
nameData.setComment(CodeUnit.EOL_COMMENT, "TypeDescriptor.name");
|
||||
nameData.setComment(CommentType.EOL, "TypeDescriptor.name");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -233,7 +233,7 @@ public class EHDataTypeUtilities {
|
||||
String dataTypeName, String suffix, Address address, DataApplyOptions applyOptions) {
|
||||
|
||||
Listing listing = program.getListing();
|
||||
String existingComment = listing.getComment(CodeUnit.PLATE_COMMENT, address);
|
||||
String existingComment = listing.getComment(CommentType.PLATE, address);
|
||||
if (!applyOptions.shouldCreateComments()) {
|
||||
return existingComment;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class EHDataTypeUtilities {
|
||||
String appliedSuffix = (suffix != null) ? (suffix) : "";
|
||||
String appliedExisting = (existingComment != null) ? (existingComment + "\n") : "";
|
||||
String appliedComment = appliedExisting + appliedPrefix + dataTypeName + appliedSuffix;
|
||||
listing.setComment(address, CodeUnit.PLATE_COMMENT, appliedComment);
|
||||
listing.setComment(address, CommentType.PLATE, appliedComment);
|
||||
return appliedComment;
|
||||
}
|
||||
return existingComment;
|
||||
@@ -276,7 +276,6 @@ public class EHDataTypeUtilities {
|
||||
// Make sure we have underscores in name
|
||||
dataTypeName = SymbolUtilities.replaceInvalidChars(dataTypeName, true);
|
||||
|
||||
|
||||
SymbolTable symbolTable = program.getSymbolTable();
|
||||
SymbolIterator symbols = symbolTable.getSymbolsAsIterator(address);
|
||||
for (Symbol symbol : symbols) {
|
||||
|
||||
@@ -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.
|
||||
@@ -120,8 +120,7 @@ public class CreateVfTableBackgroundCmd extends AbstractCreateDataBackgroundCmd<
|
||||
String prefixString = ((demangledTypeDescriptor != null)
|
||||
? (demangledTypeDescriptor + Namespace.DELIMITER)
|
||||
: "");
|
||||
data.setComment(CodeUnit.EOL_COMMENT,
|
||||
"terminator for " + prefixString + VF_TABLE_LABEL);
|
||||
data.setComment(CommentType.EOL, "terminator for " + prefixString + VF_TABLE_LABEL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -172,20 +171,22 @@ public class CreateVfTableBackgroundCmd extends AbstractCreateDataBackgroundCmd<
|
||||
if (rtti0Model == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Label
|
||||
boolean shouldCreateComment = true;
|
||||
if (applyOptions.shouldCreateLabel()) {
|
||||
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, vfTableAddress, rtti0Model,
|
||||
VF_TABLE_LABEL);
|
||||
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, vfTableAddress,
|
||||
rtti0Model, VF_TABLE_LABEL);
|
||||
}
|
||||
|
||||
// Plate Comment
|
||||
if (shouldCreateComment) {
|
||||
// comment created if a label was created, or createLabel option off
|
||||
EHDataTypeUtilities.createPlateCommentIfNeeded(program, RttiUtil.CONST_PREFIX +
|
||||
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
||||
VF_TABLE_LABEL, null, vfTableAddress, applyOptions);
|
||||
EHDataTypeUtilities
|
||||
.createPlateCommentIfNeeded(program,
|
||||
RttiUtil.CONST_PREFIX + RttiUtil.getDescriptorTypeNamespace(rtti0Model) +
|
||||
Namespace.DELIMITER,
|
||||
VF_TABLE_LABEL, null, vfTableAddress, applyOptions);
|
||||
}
|
||||
|
||||
// Create functions that are referred to by the vf table.
|
||||
@@ -215,23 +216,23 @@ public class CreateVfTableBackgroundCmd extends AbstractCreateDataBackgroundCmd<
|
||||
if (rtti0Model == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
monitor.checkCancelled();
|
||||
|
||||
// Label
|
||||
boolean shouldCreateComment = true;
|
||||
if (applyOptions.shouldCreateLabel()) {
|
||||
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, metaAddress, rtti0Model,
|
||||
VF_TABLE_LABEL + NAME_SEPARATOR + META_LABEL + "_ptr");
|
||||
shouldCreateComment = RttiUtil.createSymbolFromDemangledType(program, metaAddress,
|
||||
rtti0Model, VF_TABLE_LABEL + NAME_SEPARATOR + META_LABEL + "_ptr");
|
||||
}
|
||||
|
||||
// Plate Comment
|
||||
if (shouldCreateComment) {
|
||||
// comment created if a label was created, or createLabel option off
|
||||
EHDataTypeUtilities.createPlateCommentIfNeeded(
|
||||
program, META_LABEL + " pointer for " +
|
||||
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
||||
VF_TABLE_LABEL, null, metaAddress, applyOptions);
|
||||
program, META_LABEL + " pointer for " +
|
||||
RttiUtil.getDescriptorTypeNamespace(rtti0Model) + Namespace.DELIMITER,
|
||||
VF_TABLE_LABEL, null, metaAddress, applyOptions);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -209,7 +209,7 @@ public class PropagateExternalParametersAnalyzer extends AbstractAnalyzer {
|
||||
Parameter param = params[index];
|
||||
DataType dt = param.getDataType();
|
||||
String name = param.getName();
|
||||
SetCommentCmd cmd = new SetCommentCmd(cu.getAddress(), CodeUnit.EOL_COMMENT,
|
||||
SetCommentCmd cmd = new SetCommentCmd(cu.getAddress(), CommentType.EOL,
|
||||
dt.getDisplayName() + " " + name + " for " + externalFunctionName);
|
||||
cmd.applyTo(currentProgram);
|
||||
|
||||
@@ -267,8 +267,7 @@ public class PropagateExternalParametersAnalyzer extends AbstractAnalyzer {
|
||||
// use the 'results' to propagate param info to the local variables, data, and params of
|
||||
// the calling function
|
||||
Msg.trace(this, "Processing propagation results - count: " + results.size());
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
PushedParamInfo paramInfo = results.get(i);
|
||||
for (PushedParamInfo paramInfo : results) {
|
||||
Address paramAddress = paramInfo.getAddress();
|
||||
Instruction instruction = listing.getInstructionAt(paramAddress);
|
||||
|
||||
@@ -310,17 +309,16 @@ public class PropagateExternalParametersAnalyzer extends AbstractAnalyzer {
|
||||
|
||||
private void createComment(Address dataAddress, String newComment, PushedParamInfo info) {
|
||||
Listing listing = currentProgram.getListing();
|
||||
String plateComment = listing.getComment(CodeUnit.PLATE_COMMENT, dataAddress);
|
||||
String plateComment = listing.getComment(CommentType.PLATE, dataAddress);
|
||||
if (plateComment == null) {
|
||||
// add a comment
|
||||
SetCommentCmd cmd = new SetCommentCmd(dataAddress, CodeUnit.PLATE_COMMENT, newComment);
|
||||
SetCommentCmd cmd = new SetCommentCmd(dataAddress, CommentType.PLATE, newComment);
|
||||
cmd.applyTo(currentProgram);
|
||||
}
|
||||
else if (!plateComment.contains(info.getCalledFunctionName())) {
|
||||
// update the existing comment
|
||||
String updatedComment = plateComment + "\n" + newComment;
|
||||
SetCommentCmd cmd =
|
||||
new SetCommentCmd(dataAddress, CodeUnit.PLATE_COMMENT, updatedComment);
|
||||
SetCommentCmd cmd = new SetCommentCmd(dataAddress, CommentType.PLATE, updatedComment);
|
||||
cmd.applyTo(currentProgram);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user