Skip to content

Ghidra is a software reverse engineering (SRE) framework

clean up OSGi state reporting and help page

Jason P. Leasurea3320ef3abb4
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/BundleManager/BundleManager.htm b/Ghidra/Features/Base/src/main/help/help/topics/BundleManager/BundleManager.htm
index c39ad2d2a5..51b94f217f 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/BundleManager/BundleManager.htm
+++ b/Ghidra/Features/Base/src/main/help/help/topics/BundleManager/BundleManager.htm
@@ -162,8 +162,16 @@
<li> <span style="font-weight:bold;color:#009900">active</span> - the bundle is built and classes within
can be loaded
</ul>
- </p>
- <p>The normally hidden column "OSGi State" is also available.</p>
+
+ <p>The normally hidden column "OSGi State" is also available. In addition to the Bundle
+ state, this column will report</p>
+ <ul style="padding-left:8em">
+ <li> (DISABLED) - if the bundle is disabled
+ <li> (ENABLED) - if the bundle is enabled, but the bundle manager has no handle to it.
+ If this state persists, there is likely an internal error
+ <li> (UNINSTALLED) - if the bundle is enabled, but the framework has released its handle.
+ This is typical for an inactive bundle
+ </ul>
<h2><a name="AddBundles"/><a name="RemoveBundles"/>Adding and removing bundles from the manager</h2>
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java
index 6bdf8a0668..9090cc431e 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleHost.java
@@ -193,14 +193,14 @@ public class BundleHost {
public Collection<GhidraBundle> add(List<ResourceFile> bundleFiles, boolean enabled,
boolean systemBundle) {
Map<ResourceFile, GhidraBundle> newBundleMap = bundleFiles.stream()
- .collect(Collectors.toUnmodifiableMap(Function.identity(),
- bundleFile -> createGhidraBundle(BundleHost.this, bundleFile, enabled,
- systemBundle)));
+ .collect(Collectors.toUnmodifiableMap(Function.identity(),
+ bundleFile -> createGhidraBundle(BundleHost.this, bundleFile, enabled,
+ systemBundle)));
fileToBundleMap.putAll(newBundleMap);
bundleLocationToBundleMap.putAll(newBundleMap.values()
- .stream()
- .collect(Collectors.toUnmodifiableMap(GhidraBundle::getLocationIdentifier,
- Function.identity())));
+ .stream()
+ .collect(Collectors.toUnmodifiableMap(GhidraBundle::getLocationIdentifier,
+ Function.identity())));
Collection<GhidraBundle> newBundles = newBundleMap.values();
fireBundlesAdded(newBundles);
return newBundles;
@@ -482,7 +482,7 @@ public class BundleHost {
}
frameworkBundleContext
- .addBundleListener(new MyBundleListener(frameworkBundleContext.getBundle()));
+ .addBundleListener(new MyBundleListener(frameworkBundleContext.getBundle()));
try {
felixFramework.start();
@@ -659,8 +659,8 @@ public class BundleHost {
monitor.setMaximum(bundlesRemaining.size());
while (!bundlesRemaining.isEmpty() && !monitor.isCancelled()) {
List<GhidraBundle> resolvableBundles = bundlesRemaining.stream()
- .filter(bundle -> canResolveAll(bundle.getAllRequirements()))
- .collect(Collectors.toList());
+ .filter(bundle -> canResolveAll(bundle.getAllRequirements()))
+ .collect(Collectors.toList());
if (resolvableBundles.isEmpty()) {
// final round, try everything we couldn't resolve to generate errors
resolvableBundles = bundlesRemaining;
@@ -881,7 +881,8 @@ public class BundleHost {
String.format("not a GhidraBundle: %s\n", osgiBundle.getLocation()));
}
break;
- case BundleEvent.UNINSTALLED:
+ // force "inactive" updates for all other states
+ default:
bundle = bundleLocationToBundleMap.get(osgiBundle.getLocation());
if (bundle != null) {
fireBundleActivationChange(bundle, false);
@@ -891,8 +892,6 @@ public class BundleHost {
String.format("not a GhidraBundle: %s\n", osgiBundle.getLocation()));
}
break;
- default:
- break;
}
}
}
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 b3ed9433b2..b72e2b6b2d 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
@@ -411,7 +411,7 @@ public class BundleStatusTableModel
public String getValue(BundleStatus status, Settings settings, List<BundleStatus> data,
ServiceProvider serviceProvider0) throws IllegalArgumentException {
if (!status.isEnabled()) {
- return "(disabled)";
+ return "(DISABLED)";
}
GhidraBundle bundle = bundleHost.getExistingGhidraBundle(status.getFile());
if (bundle != null) {
@@ -419,9 +419,9 @@ public class BundleStatusTableModel
if (osgiBundle != null) {
return OSGiUtils.getStateString(osgiBundle);
}
- return "uninstalled";
+ return "(UNINSTALLED)";
}
- return "(enabled)";
+ return "(ENABLED)";
}
@Override