Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-6469: from review GP-6469: cancel everything

d-millarc2bb41d2604d
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/bkmk/SarifBookmarkWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/bkmk/SarifBookmarkWriter.java
index dc8164fde6..20e9383338 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/bkmk/SarifBookmarkWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/bkmk/SarifBookmarkWriter.java
@@ -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));
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/code/SarifCodeWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/code/SarifCodeWriter.java
index 934fda3077..4bf552f9a3 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/code/SarifCodeWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/code/SarifCodeWriter.java
@@ -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));
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/comments/SarifCommentWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/comments/SarifCommentWriter.java
index 8655226cce..f30ce4033b 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/comments/SarifCommentWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/comments/SarifCommentWriter.java
@@ -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(),
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/dd/SarifDataWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/dd/SarifDataWriter.java
index 1a592b6144..67aff5ce90 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/dd/SarifDataWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/dd/SarifDataWriter.java
@@ -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());
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/ep/SarifEntryPointWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/ep/SarifEntryPointWriter.java
index 9d967a065b..f2660652f4 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/ep/SarifEntryPointWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/ep/SarifEntryPointWriter.java
@@ -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));
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/equates/SarifEquateWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/equates/SarifEquateWriter.java
index 989534d888..3398d156cd 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/equates/SarifEquateWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/equates/SarifEquateWriter.java
@@ -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));
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/extlib/SarifClassesNamespaceWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/extlib/SarifClassesNamespaceWriter.java
index b52171ebff..e331b35d8b 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/extlib/SarifClassesNamespaceWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/extlib/SarifClassesNamespaceWriter.java
@@ -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();
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/extlib/SarifExternalLibraryWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/extlib/SarifExternalLibraryWriter.java
index 7e902e05ab..2ba1dc8ad7 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/extlib/SarifExternalLibraryWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/extlib/SarifExternalLibraryWriter.java
@@ -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());
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/func/SarifFunctionWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/func/SarifFunctionWriter.java
index 33ec4601e0..17196bda32 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/func/SarifFunctionWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/func/SarifFunctionWriter.java
@@ -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());
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/mm/SarifMemoryMapWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/mm/SarifMemoryMapWriter.java
index eb92676bce..173c86512f 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/mm/SarifMemoryMapWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/mm/SarifMemoryMapWriter.java
@@ -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),
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/props/SarifPropertyListWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/props/SarifPropertyListWriter.java
index f565866fb8..acf86222a7 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/props/SarifPropertyListWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/props/SarifPropertyListWriter.java
@@ -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;
}
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/props/SarifPropertyMapWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/props/SarifPropertyMapWriter.java
index d040498992..506bdda1af 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/props/SarifPropertyMapWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/props/SarifPropertyMapWriter.java
@@ -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;
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifEquateRefWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifEquateRefWriter.java
index 7b97c0f7aa..aa40003757 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifEquateRefWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifEquateRefWriter.java
@@ -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;
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifEquateWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifEquateWriter.java
index 0c45cd8c94..10ef049d42 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifEquateWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifEquateWriter.java
@@ -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;
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifReferenceWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifReferenceWriter.java
index 63a6f5dba0..c7bb7f5d18 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifReferenceWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/ref/SarifReferenceWriter.java
@@ -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);
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/relocs/SarifRelocationWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/relocs/SarifRelocationWriter.java
index 1e1215cb6d..7263de07ff 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/relocs/SarifRelocationWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/relocs/SarifRelocationWriter.java
@@ -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());
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/symbols/SarifSymbolWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/symbols/SarifSymbolWriter.java
index b044c58e36..603528d56b 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/symbols/SarifSymbolWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/symbols/SarifSymbolWriter.java
@@ -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;
diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/export/trees/SarifTreeWriter.java b/Ghidra/Features/Sarif/src/main/java/sarif/export/trees/SarifTreeWriter.java
index d1c4659734..783967e5ad 100644
--- a/Ghidra/Features/Sarif/src/main/java/sarif/export/trees/SarifTreeWriter.java
+++ b/Ghidra/Features/Sarif/src/main/java/sarif/export/trees/SarifTreeWriter.java
@@ -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));