Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/dsf
diff options
context:
space:
mode:
authorAnton Leherbauer2010-10-14 09:41:19 -0400
committerAnton Leherbauer2010-10-14 09:41:19 -0400
commita92513f4fa2c9ff6ecf56520b6127e571184aa49 (patch)
tree04a55de83d2ebad1949f178058b05861e8adafae /dsf
parent214b66c2480a0bd73f8077a0a848a204b7685891 (diff)
downloadorg.eclipse.cdt-a92513f4fa2c9ff6ecf56520b6127e571184aa49.tar.gz
org.eclipse.cdt-a92513f4fa2c9ff6ecf56520b6127e571184aa49.tar.xz
org.eclipse.cdt-a92513f4fa2c9ff6ecf56520b6127e571184aa49.zip
Bug 323683 - [disassembly][pda] NPE with PDA session
Diffstat (limited to 'dsf')
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyBackendDsf.java43
1 files changed, 38 insertions, 5 deletions
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyBackendDsf.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyBackendDsf.java
index 94315e9f216..0c316f39001 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyBackendDsf.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyBackendDsf.java
@@ -18,6 +18,7 @@ import static org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyUtils
import java.math.BigInteger;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.TimeUnit;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
@@ -97,11 +98,43 @@ public class DisassemblyBackendDsf implements IDisassemblyBackend, SessionEndedL
DsfSession.removeSessionEndedListener(this);
}
- public static boolean supportsDebugContext_(IAdaptable context) {
- return context.getAdapter(IDMVMContext.class) != null;
- }
-
- /* (non-Javadoc)
+ public static boolean supportsDebugContext_(IAdaptable context) {
+ IDMVMContext dmvmContext = (IDMVMContext) context.getAdapter(IDMVMContext.class);
+ return dmvmContext != null && hasDisassemblyService(dmvmContext.getDMContext());
+ }
+
+ private static boolean hasDisassemblyService(final IDMContext dmContext) {
+ DsfSession session = DsfSession.getSession(dmContext.getSessionId());
+ if (session == null || !session.isActive()) {
+ return false;
+ }
+ if (session.getExecutor().isInExecutorThread()) {
+ DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId());
+ IDisassembly disassSvc = tracker.getService(IDisassembly.class);
+ tracker.dispose();
+ return disassSvc != null;
+ }
+ Query<Boolean> query = new Query<Boolean>() {
+ @Override
+ protected void execute(DataRequestMonitor<Boolean> rm) {
+ try {
+ rm.setData(hasDisassemblyService(dmContext));
+ } finally {
+ rm.done();
+ }
+ }
+ };
+ try {
+ session.getExecutor().execute(query);
+ Boolean result = query.get(1, TimeUnit.SECONDS);
+ return result != null && result.booleanValue();
+ } catch (Exception exc) {
+ // ignored on purpose
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#supportsDebugContext(org.eclipse.core.runtime.IAdaptable)
*/
public boolean supportsDebugContext(IAdaptable context) {

Back to the top