mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-18 17:53:43 +08:00
GP-6469: from review
GP-6469: cancel everything
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.
|
||||
@@ -45,6 +45,7 @@ public class SarifBookmarkWriter extends AbstractExtWriter {
|
||||
private void genBookmarks(TaskMonitor monitor) throws CancelledException, IOException{
|
||||
monitor.initialize(bookmarks.size());
|
||||
for (Bookmark b : bookmarks) {
|
||||
monitor.checkCancelled();
|
||||
ExtBookmark isf = new ExtBookmark(b);
|
||||
SarifObject sarif = new SarifObject(BookmarksSarifMgr.SUBKEY, BookmarksSarifMgr.KEY, getTree(isf), b.getAddress(), b.getAddress());
|
||||
objects.add(getTree(sarif));
|
||||
|
||||
@@ -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.
|
||||
@@ -50,6 +50,7 @@ public class SarifCodeWriter extends AbstractExtWriter {
|
||||
private void genCode(TaskMonitor monitor) throws CancelledException, IOException{
|
||||
monitor.initialize(blocks.size());
|
||||
for (AddressRange range : blocks) {
|
||||
monitor.checkCancelled();
|
||||
ExtCodeBlock isf = new ExtCodeBlock(range);
|
||||
SarifObject sarif = new SarifObject(CodeSarifMgr.SUBKEY, CodeSarifMgr.KEY, getTree(isf), range.getMinAddress(), range.getMaxAddress());
|
||||
objects.add(getTree(sarif));
|
||||
|
||||
@@ -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.
|
||||
@@ -56,6 +56,7 @@ public class SarifCommentWriter extends AbstractExtWriter {
|
||||
}
|
||||
monitor.initialize(comments0.size());
|
||||
for (Pair<CodeUnit, Pair<String, String>> pair : comments0) {
|
||||
monitor.checkCancelled();
|
||||
CodeUnit cu = pair.first;
|
||||
ExtComment isf = new ExtComment(pair.second, true);
|
||||
SarifObject sarif = new SarifObject(CommentsSarifMgr.SUBKEY, CommentsSarifMgr.KEY, getTree(isf), cu.getMinAddress(),
|
||||
|
||||
@@ -45,6 +45,7 @@ public class SarifDataWriter extends AbstractExtWriter {
|
||||
private void genData(TaskMonitor monitor) throws CancelledException {
|
||||
monitor.initialize(definedData.size());
|
||||
for (Data d : definedData) {
|
||||
monitor.checkCancelled();
|
||||
ExtData isf = new ExtData(d);
|
||||
SarifObject sarif = new SarifObject("DefinedData", DefinedDataSarifMgr.KEY,
|
||||
getTree(isf), d.getMinAddress(), d.getMaxAddress());
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -44,6 +44,7 @@ public class SarifEntryPointWriter extends AbstractExtWriter {
|
||||
private void genCode(TaskMonitor monitor) throws CancelledException, IOException{
|
||||
monitor.initialize(entryPoints.size());
|
||||
for (Address addr : entryPoints) {
|
||||
monitor.checkCancelled();
|
||||
ExtEntryPoint isf = new ExtEntryPoint(addr);
|
||||
SarifObject sarif = new SarifObject(ExtEntryPointSarifMgr.SUBKEY, ExtEntryPointSarifMgr.KEY, getTree(isf), addr, addr);
|
||||
objects.add(getTree(sarif));
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -44,6 +44,7 @@ public class SarifEquateWriter extends AbstractExtWriter {
|
||||
private void genCode(TaskMonitor monitor) throws CancelledException, IOException{
|
||||
monitor.initialize(equates.size());
|
||||
for (Equate equate : equates) {
|
||||
monitor.checkCancelled();
|
||||
ExtEquate isf = new ExtEquate(equate);
|
||||
SarifObject sarif = new SarifObject(EquatesSarifMgr.SUBKEY, EquatesSarifMgr.KEY, getTree(isf), null);
|
||||
objects.add(getTree(sarif));
|
||||
|
||||
+1
@@ -53,6 +53,7 @@ public class SarifClassesNamespaceWriter extends AbstractExtWriter {
|
||||
monitor.initialize(classes.size());
|
||||
Iterator<GhidraClass> classNamespaces = symbolTable.getClassNamespaces();
|
||||
while (classNamespaces.hasNext()) {
|
||||
monitor.checkCancelled();
|
||||
GhidraClass next = classNamespaces.next();
|
||||
walkSymbols(next);
|
||||
monitor.increment();
|
||||
|
||||
+3
-4
@@ -22,10 +22,7 @@ import java.util.List;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
|
||||
import ghidra.program.model.symbol.ExternalLocation;
|
||||
import ghidra.program.model.symbol.ExternalLocationIterator;
|
||||
import ghidra.program.model.symbol.ExternalManager;
|
||||
import ghidra.program.model.symbol.SourceType;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
import sarif.export.AbstractExtWriter;
|
||||
@@ -53,6 +50,7 @@ public class SarifExternalLibraryWriter extends AbstractExtWriter {
|
||||
private void genLibraries(TaskMonitor monitor) throws CancelledException, IOException {
|
||||
monitor.initialize(externalNames.size());
|
||||
for (String n : externalNames) {
|
||||
monitor.checkCancelled();
|
||||
String path = externalManager.getExternalLibraryPath(n);
|
||||
if (path == null) {
|
||||
path = "";
|
||||
@@ -63,6 +61,7 @@ public class SarifExternalLibraryWriter extends AbstractExtWriter {
|
||||
|
||||
ExternalLocationIterator externalLocations = externalManager.getExternalLocations(n);
|
||||
while (externalLocations.hasNext()) {
|
||||
monitor.checkCancelled();
|
||||
ExternalLocation loc = externalLocations.next();
|
||||
ExtLibraryLocation obj = new ExtLibraryLocation(loc);
|
||||
SarifObject sarif2 = new SarifObject(ExternalLibSarifMgr.SUBKEY1, ExternalLibSarifMgr.KEY, getTree(obj), loc.getAddress(), loc.getAddress());
|
||||
|
||||
@@ -56,6 +56,7 @@ public class SarifFunctionWriter extends AbstractExtWriter {
|
||||
private void genFunctions(TaskMonitor monitor) throws CancelledException, IOException{
|
||||
monitor.initialize(requestedFunctions.size());
|
||||
for (Function f : requestedFunctions) {
|
||||
monitor.checkCancelled();
|
||||
addSymbol(f.getSymbol());
|
||||
ExtFunction isf = new ExtFunction(f, monitor);
|
||||
SarifObject sarif = new SarifObject("Function", FunctionsSarifMgr.KEY, getTree(isf), f.getBody());
|
||||
|
||||
@@ -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.
|
||||
@@ -52,6 +52,7 @@ public class SarifMemoryMapWriter extends AbstractExtWriter {
|
||||
private void genMaps(TaskMonitor monitor) throws CancelledException, IOException {
|
||||
monitor.initialize(memory.size());
|
||||
for (Pair<AddressRange, MemoryBlock> m : memory) {
|
||||
monitor.checkCancelled();
|
||||
AddressRange range = m.first;
|
||||
ExtMemoryMap isf = new ExtMemoryMap(m.first, m.second, bytesFile, write);
|
||||
SarifObject sarif = new SarifObject(MemoryMapSarifMgr.SUBKEY, MemoryMapSarifMgr.KEY, getTree(isf),
|
||||
|
||||
@@ -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.
|
||||
@@ -52,9 +52,7 @@ public class SarifPropertyListWriter extends AbstractExtWriter {
|
||||
List<String> propNames = propList.getOptionNames();
|
||||
Collections.sort(propNames);
|
||||
for (String name : propNames) {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new CancelledException();
|
||||
}
|
||||
monitor.checkCancelled();
|
||||
if (propList.isAlias(name)) { // don't write out properties that are just mirrors of some other property
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -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,16 +19,9 @@ import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressIterator;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.model.util.IntPropertyMap;
|
||||
import ghidra.program.model.util.LongPropertyMap;
|
||||
import ghidra.program.model.util.ObjectPropertyMap;
|
||||
import ghidra.program.model.util.PropertyMap;
|
||||
import ghidra.program.model.util.StringPropertyMap;
|
||||
import ghidra.program.model.util.VoidPropertyMap;
|
||||
import ghidra.program.model.util.*;
|
||||
import ghidra.util.SaveableColor;
|
||||
import ghidra.util.SaveablePoint;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
@@ -78,6 +71,7 @@ public class SarifPropertyMapWriter extends AbstractExtWriter {
|
||||
private void genVoidMap(VoidPropertyMap map, TaskMonitor monitor) throws CancelledException {
|
||||
AddressIterator iter = set != null ? map.getPropertyIterator(set) : map.getPropertyIterator();
|
||||
while (iter.hasNext()) {
|
||||
monitor.checkCancelled();
|
||||
Address addr = iter.next();
|
||||
ExtProperty isf = new ExtProperty(map.getName(), "void", null);
|
||||
SarifObject sarif = new SarifObject(PropertiesSarifMgr.SUBKEY, PropertiesSarifMgr.KEY, getTree(isf), addr,
|
||||
@@ -90,9 +84,7 @@ public class SarifPropertyMapWriter extends AbstractExtWriter {
|
||||
private void genIntMap(IntPropertyMap map, TaskMonitor monitor) throws CancelledException {
|
||||
AddressIterator iter = set != null ? map.getPropertyIterator(set) : map.getPropertyIterator();
|
||||
while (iter.hasNext()) {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new CancelledException();
|
||||
}
|
||||
monitor.checkCancelled();
|
||||
try {
|
||||
Address addr = iter.next();
|
||||
int value = map.getInt(addr);
|
||||
@@ -109,9 +101,7 @@ public class SarifPropertyMapWriter extends AbstractExtWriter {
|
||||
private void genLongMap(LongPropertyMap map, TaskMonitor monitor) throws CancelledException {
|
||||
AddressIterator iter = set != null ? map.getPropertyIterator(set) : map.getPropertyIterator();
|
||||
while (iter.hasNext()) {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new CancelledException();
|
||||
}
|
||||
monitor.checkCancelled();
|
||||
try {
|
||||
Address addr = iter.next();
|
||||
long value = map.getLong(addr);
|
||||
@@ -129,9 +119,7 @@ public class SarifPropertyMapWriter extends AbstractExtWriter {
|
||||
private void genStringMap(StringPropertyMap map, TaskMonitor monitor) throws CancelledException {
|
||||
AddressIterator iter = set != null ? map.getPropertyIterator(set) : map.getPropertyIterator();
|
||||
while (iter.hasNext()) {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new CancelledException();
|
||||
}
|
||||
monitor.checkCancelled();
|
||||
Address addr = iter.next();
|
||||
String value = map.getString(addr);
|
||||
ExtProperty isf = new ExtProperty(map.getName(), "string", value);
|
||||
@@ -145,9 +133,7 @@ public class SarifPropertyMapWriter extends AbstractExtWriter {
|
||||
private void genObjectMap(ObjectPropertyMap<?> map, TaskMonitor monitor) throws CancelledException {
|
||||
AddressIterator iter = set != null ? map.getPropertyIterator(set) : map.getPropertyIterator();
|
||||
while (iter.hasNext()) {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new CancelledException();
|
||||
}
|
||||
monitor.checkCancelled();
|
||||
Address addr = iter.next();
|
||||
Object value = map.get(addr);
|
||||
ExtProperty isf;
|
||||
|
||||
@@ -23,9 +23,7 @@ import com.google.gson.JsonArray;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.symbol.Equate;
|
||||
import ghidra.program.model.symbol.EquateReference;
|
||||
import ghidra.program.model.symbol.EquateTable;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
import sarif.export.AbstractExtWriter;
|
||||
@@ -52,17 +50,12 @@ public class SarifEquateRefWriter extends AbstractExtWriter {
|
||||
|
||||
Iterator<Equate> iter = equateTable.getEquates();
|
||||
while (iter.hasNext()) {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new CancelledException();
|
||||
}
|
||||
Equate equate = iter.next();
|
||||
String name = equate.getName();
|
||||
long value = equate.getValue();
|
||||
EquateReference[] refs = equate.getReferences();
|
||||
for (int i = 0; i < refs.length; i++) {
|
||||
if (monitor.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
monitor.checkCancelled();
|
||||
Address addr = refs[i].getAddress();
|
||||
if (!set.contains(addr)) {
|
||||
continue;
|
||||
|
||||
@@ -23,9 +23,7 @@ import com.google.gson.JsonArray;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
||||
import ghidra.program.model.symbol.Equate;
|
||||
import ghidra.program.model.symbol.EquateReference;
|
||||
import ghidra.program.model.symbol.EquateTable;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
import sarif.export.AbstractExtWriter;
|
||||
@@ -60,9 +58,7 @@ public class SarifEquateWriter extends AbstractExtWriter {
|
||||
long value = equate.getValue();
|
||||
EquateReference[] refs = equate.getReferences();
|
||||
for (int i = 0; i < refs.length; i++) {
|
||||
if (monitor.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
monitor.checkCancelled();
|
||||
Address addr = refs[i].getAddress();
|
||||
if (!set.contains(addr)) {
|
||||
continue;
|
||||
|
||||
@@ -23,12 +23,7 @@ import java.util.List;
|
||||
import com.google.gson.JsonArray;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.symbol.ExternalLocation;
|
||||
import ghidra.program.model.symbol.ExternalReference;
|
||||
import ghidra.program.model.symbol.Reference;
|
||||
import ghidra.program.model.symbol.ReferenceManager;
|
||||
import ghidra.program.model.symbol.ShiftedReference;
|
||||
import ghidra.program.model.symbol.StackReference;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
import sarif.export.AbstractExtWriter;
|
||||
@@ -63,9 +58,7 @@ public class SarifReferenceWriter extends AbstractExtWriter {
|
||||
for (Address addr : references) {
|
||||
Reference[] refs = referenceManager.getReferencesFrom(addr);
|
||||
for (int i = 0; i < refs.length; i++) {
|
||||
if (monitor.isCancelled()) {
|
||||
throw new CancelledException();
|
||||
}
|
||||
monitor.checkCancelled();
|
||||
Reference ref = refs[i];
|
||||
if (ref.isRegisterReference()) {
|
||||
ExtRegisterReference mref = new ExtRegisterReference(ref);
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -44,6 +44,7 @@ public class SarifRelocationWriter extends AbstractExtWriter {
|
||||
private void genRelocation(TaskMonitor monitor) throws CancelledException, IOException {
|
||||
monitor.initialize(relocs.size());
|
||||
for (Relocation r : relocs) {
|
||||
monitor.checkCancelled();
|
||||
ExtRelocation isf = new ExtRelocation(r);
|
||||
SarifObject sarif = new SarifObject(RelocationTableSarifMgr.SUBKEY, RelocationTableSarifMgr.KEY,
|
||||
getTree(isf), r.getAddress(), r.getAddress());
|
||||
|
||||
@@ -22,9 +22,7 @@ import java.util.List;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
|
||||
import ghidra.program.model.symbol.SourceType;
|
||||
import ghidra.program.model.symbol.Symbol;
|
||||
import ghidra.program.model.symbol.SymbolType;
|
||||
import ghidra.program.model.symbol.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
import sarif.export.AbstractExtWriter;
|
||||
@@ -49,6 +47,7 @@ public class SarifSymbolWriter extends AbstractExtWriter {
|
||||
private void genSymbols(TaskMonitor monitor) throws CancelledException, IOException{
|
||||
monitor.initialize(symbols.size());
|
||||
for (Symbol s : symbols) {
|
||||
monitor.checkCancelled();
|
||||
SymbolType symbolType = s.getSymbolType();
|
||||
if (s.getSource() == SourceType.DEFAULT) {
|
||||
continue;
|
||||
|
||||
@@ -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.
|
||||
@@ -47,6 +47,7 @@ public class SarifTreeWriter extends AbstractExtWriter {
|
||||
private void genTree(TaskMonitor monitor) throws CancelledException, IOException {
|
||||
monitor.initialize(modules.size());
|
||||
for (Pair<String, ProgramModule> pair : modules) {
|
||||
monitor.checkCancelled();
|
||||
ExtModule isf = new ExtModule(pair.first, pair.second, visited);
|
||||
SarifObject sarif = new SarifObject(ProgramTreeSarifMgr.SUBKEY, ProgramTreeSarifMgr.KEY, getTree(isf), null);
|
||||
objects.add(getTree(sarif));
|
||||
|
||||
Reference in New Issue
Block a user