Skip to content

Ghidra is a software reverse engineering (SRE) framework

make set-activation more like individual activation

Jason P. Leasurea654060fbe49
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java
index fe127ccbfe..81e6e35818 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java
@@ -18,6 +18,7 @@ package ghidra.app.plugin.core.osgi;
import java.awt.*;
import java.io.File;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -124,15 +125,16 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
TableColumn column;
//
- column =
- bundleStatusTable.getColumnModel().getColumn(bundleStatusTableModel.enabledColumn.index);
+ column = bundleStatusTable.getColumnModel().getColumn(
+ bundleStatusTableModel.enabledColumn.index);
column.setPreferredWidth(skinnyWidth);
column.setMinWidth(skinnyWidth);
column.setMaxWidth(skinnyWidth);
column.setWidth(skinnyWidth);
//
- column = bundleStatusTable.getColumnModel().getColumn(bundleStatusTableModel.activeColumn.index);
+ column =
+ bundleStatusTable.getColumnModel().getColumn(bundleStatusTableModel.activeColumn.index);
column.setPreferredWidth(skinnyWidth);
column.setMinWidth(skinnyWidth);
column.setMaxWidth(skinnyWidth);
@@ -160,11 +162,13 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
});
//
- column = bundleStatusTable.getColumnModel().getColumn(bundleStatusTableModel.typeColumn.index);
+ column =
+ bundleStatusTable.getColumnModel().getColumn(bundleStatusTableModel.typeColumn.index);
FontMetrics fontmetrics = panel.getFontMetrics(panel.getFont());
column.setMaxWidth(10 +
SwingUtilities.computeStringWidth(fontmetrics, GhidraBundle.Type.SourceDir.toString()));
- column = bundleStatusTable.getColumnModel().getColumn(bundleStatusTableModel.pathColumn.index);
+ column =
+ bundleStatusTable.getColumnModel().getColumn(bundleStatusTableModel.pathColumn.index);
column.setCellRenderer(new GTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(GTableCellRenderingData data) {
@@ -389,24 +393,36 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
// suppress RowObjectSelectionManager repairs until after we're done
bundleStatusTable.chill();
- List<GhidraBundle> gbs =
+ List<BundleStatus> statuses =
bundleStatusTableModel.getRowObjects(selectedModelRows).stream().filter(
- bs -> !bs.isActive()).map(
- bs -> bundleHost.getExistingGhidraBundle(bs.getPath())).collect(
- Collectors.toList());
+ bs -> !bs.isActive()).collect(Collectors.toUnmodifiableList());
+
+ for (BundleStatus bs : statuses) {
+ bs.setBusy(true);
+ }
+ notifyTableDataChanged();
+
+ List<GhidraBundle> gbs = statuses.stream().map(
+ bs -> bundleHost.getExistingGhidraBundle(bs.getPath())).collect(
+ Collectors.toList());
int total = gbs.size();
int total_activated = 0;
monitor.setMaximum(gbs.size());
- while (!gbs.isEmpty()) {
+ while (!gbs.isEmpty() && !monitor.isCancelled()) {
List<GhidraBundle> l = gbs.stream().filter(
gb -> bundleHost.canResolveAll(gb.getAllReqs())).collect(
Collectors.toList());
if (l.isEmpty()) {
- console.getStdErr().printf("%d unresolvable bundles remain\n", gbs.size());
- return;
+ console.getStdErr().printf("%d incompletely resolved bundles remain\n",
+ gbs.size());
+ // final round
+ l = gbs;
+ gbs = Collections.emptyList();
+ }
+ else {
+ gbs.removeAll(l);
}
- gbs.removeAll(l);
for (GhidraBundle gb : l) {
try {
@@ -420,6 +436,12 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
monitor.incrementProgress(1);
}
}
+ if (monitor.isCancelled()) {
+ for (BundleStatus bs : statuses) {
+ bs.setBusy(false);
+ }
+ notifyTableDataChanged();
+ }
long endTime = System.nanoTime();
console.getStdOut().printf("%d/%d bundles activated in %3.2f seconds.\n",
total_activated, total, (endTime - startTime) / 1e9);
@@ -507,7 +529,12 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
public void notifyTableRowChanged(BundleStatus status) {
int modelRowIndex = bundleStatusTableModel.getRowIndex(status);
int viewRowIndex = filterPanel.getViewRow(modelRowIndex);
- bundleStatusTable.notifyTableChanged(new TableModelEvent(bundleStatusTableModel, viewRowIndex));
+ bundleStatusTable.notifyTableChanged(
+ new TableModelEvent(bundleStatusTableModel, viewRowIndex));
+ }
+
+ public void notifyTableDataChanged() {
+ bundleStatusTable.notifyTableChanged(new TableModelEvent(bundleStatusTableModel));
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
index b7fda1cf5a..640a74ba35 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
@@ -129,8 +129,8 @@ public class BundleStatusTableModel extends AbstractSortedTableModel<BundleStatu
BundleStatus getStatus(GhidraBundle gb) {
BundleStatus status = loc2status.get(gb.getBundleLoc());
if (status == null) {
- Msg.showError(BundleStatusTableModel.this, provider.getComponent(), "bundle status error",
- "bundle has no status!");
+ Msg.showError(BundleStatusTableModel.this, provider.getComponent(),
+ "bundle status error", "bundle has no status!");
}
return status;
}
@@ -175,6 +175,7 @@ public class BundleStatusTableModel extends AbstractSortedTableModel<BundleStatu
public void bundleActivationChange(GhidraBundle gb, boolean newActivation) {
BundleStatus status = getStatus(gb);
int row = getRowIndex(status);
+ status.setBusy(false);
if (newActivation) {
status.setActive(true);
status.setSummary(gb.getSummary());
@@ -368,7 +369,6 @@ public class BundleStatusTableModel extends AbstractSortedTableModel<BundleStatu
return statuses;
}
-
/**
* This is for testing only!
*
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraSourceBundle.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraSourceBundle.java
index 5cc43c936f..de7875c075 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraSourceBundle.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/GhidraSourceBundle.java
@@ -420,18 +420,24 @@ public class GhidraSourceBundle extends GhidraBundle {
@Override
public boolean clean() {
+ boolean anythingChanged = false;
+ if (!buildErrors.isEmpty()) {
+ buildErrors.clear();
+ anythingChanged |= true;
+ }
+
try {
Bundle b = getBundle();
if (b != null) {
bundleHost.deactivateSynchronously(b);
}
- return wipeBinDir();
+ return anythingChanged | wipeBinDir();
}
catch (IOException | GhidraBundleException | InterruptedException e) {
Msg.showError(this, null, "source bundle clean error",
"while attempting to delete the compiled directory, an exception was thrown", e);
}
- return false;
+ return anythingChanged;
}
private static Predicate<String> bintail =