diff options
8 files changed, 121 insertions, 58 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFLaunchLabelProvider.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFLaunchLabelProvider.java index 1fadeea27..4415dbbf0 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFLaunchLabelProvider.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFLaunchLabelProvider.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.tm.internal.tcf.debug.ui.adapters; +import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider; import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate; import org.eclipse.swt.graphics.RGB; @@ -35,8 +36,10 @@ class TCFLaunchLabelProvider implements IElementLabelProvider { result.setForeground(new RGB(255, 0, 0), 0); } if (status.length() > 0) status = " (" + status + ")"; - String label = launch.getLaunchConfiguration().getName() + status; - result.setLabel(label, 0); + String name = "?"; + ILaunchConfiguration cfg = launch.getLaunchConfiguration(); + if (cfg != null) name = cfg.getName(); + result.setLabel(name + status, 0); result.done(); } } diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFSourceLookupDirector.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFSourceLookupDirector.java index c34a9ae9a..2e044bd0b 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFSourceLookupDirector.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFSourceLookupDirector.java @@ -14,8 +14,8 @@ import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant; /** - * TCF source lookup director. For TCF source lookup there is one source lookup - * participant. + * TCF source lookup director. + * For TCF source lookup there is one source lookup participant. */ public class TCFSourceLookupDirector extends AbstractSourceLookupDirector { diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java index 8e5283dd7..f1c62b3ab 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java @@ -143,6 +143,10 @@ public class TCFLaunch extends Launch { protected void runLaunchSequence(final Runnable done) { try { ILaunchConfiguration cfg = getLaunchConfiguration(); + if (cfg == null) { + Protocol.invokeLater(done); + return; + } final String file = cfg.getAttribute(TCFLaunchDelegate.ATTR_PROGRAM_FILE, ""); if (file.length() == 0) { Protocol.invokeLater(done); diff --git a/plugins/org.eclipse.tm.tcf.dsf/plugin.xml b/plugins/org.eclipse.tm.tcf.dsf/plugin.xml index 03786907c..4cfe25925 100644 --- a/plugins/org.eclipse.tm.tcf.dsf/plugin.xml +++ b/plugins/org.eclipse.tm.tcf.dsf/plugin.xml @@ -4,7 +4,7 @@ <extension point="org.eclipse.debug.core.launchConfigurationTypes"> <launchConfigurationType - sourceLocatorId="org.eclipse.tm.tcf.debug.SourceLocator" + sourceLocatorId="org.eclipse.tm.tcf.dsf.SourceLocator" name="DSF over TCF" sourcePathComputerId="org.eclipse.tm.tcf.debug.SourcePathComputer" delegate="org.eclipse.tm.internal.tcf.dsf.launch.TCFDSFLaunchDelegate" @@ -12,4 +12,12 @@ id="org.eclipse.tm.tcf.dsf.LaunchConfigurationType"> </launchConfigurationType> </extension> + <extension + point="org.eclipse.debug.core.sourceLocators"> + <sourceLocator + name="TCF/DSF Source Lookup Director" + class="org.eclipse.tm.internal.tcf.dsf.launch.TCFDSFSourceLookupDirector" + id="org.eclipse.tm.tcf.dsf.SourceLocator"> + </sourceLocator> + </extension> </plugin> diff --git a/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/launch/TCFDSFSourceLookupDirector.java b/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/launch/TCFDSFSourceLookupDirector.java new file mode 100644 index 000000000..39a98ebc0 --- /dev/null +++ b/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/launch/TCFDSFSourceLookupDirector.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.tcf.dsf.launch; + +import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; +import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant; + +/** + * TCF/DSF source lookup director. + * For TCF/DSF source lookup there is one source lookup participant. + */ +public class TCFDSFSourceLookupDirector extends AbstractSourceLookupDirector { + + public void initializeParticipants() { + addParticipants(new ISourceLookupParticipant[] { new TCFDSFSourceLookupParticipant() }); + } +} diff --git a/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/launch/TCFDSFSourceLookupParticipant.java b/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/launch/TCFDSFSourceLookupParticipant.java new file mode 100644 index 000000000..9cc4290bc --- /dev/null +++ b/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/launch/TCFDSFSourceLookupParticipant.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.tcf.dsf.launch; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.tm.internal.tcf.debug.launch.TCFSourceLookupParticipant; +import org.eclipse.tm.internal.tcf.dsf.services.TCFDSFStack.TCFFrameDMC; +import org.eclipse.tm.internal.tcf.dsf.services.TCFDSFStack.TCFFrameData; +import org.eclipse.tm.tcf.protocol.Protocol; + +/** + * The TCF source lookup participant knows how to translate a TCFFrameData + * into a source file name + */ +public class TCFDSFSourceLookupParticipant extends TCFSourceLookupParticipant { + + @Override + public String getSourceName(final Object object) throws CoreException { + if (object instanceof TCFFrameDMC) { + final Object[] res = new Object[1]; + Protocol.invokeAndWait(new Runnable() { + public void run() { + TCFFrameDMC dmc = (TCFFrameDMC)object; + if (!dmc.frame_data.validate()) { + dmc.frame_data.wait(this); + return; + } + TCFFrameData data = dmc.frame_data.getData(); + res[0] = data.code_area; + } + }); + return super.getSourceName(res[0]); + } + return super.getSourceName(object); + } +} diff --git a/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/services/TCFDSFStack.java b/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/services/TCFDSFStack.java index c53702243..841ebe8ab 100644 --- a/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/services/TCFDSFStack.java +++ b/plugins/org.eclipse.tm.tcf.dsf/src/org/eclipse/tm/internal/tcf/dsf/services/TCFDSFStack.java @@ -41,13 +41,11 @@ import org.osgi.framework.BundleContext; public class TCFDSFStack extends AbstractDsfService implements IStack { - private static final String TOP_FRAME = "TopFrame:"; - - class TCFFrameDMC extends AbstractDMContext implements IFrameDMContext, Comparable<TCFFrameDMC> { + public class TCFFrameDMC extends AbstractDMContext implements IFrameDMContext, Comparable<TCFFrameDMC> { - final String id; - final TCFDSFExecutionDMC exe_dmc; - final TCFDataCache<TCFFrameData> frame_data; + public final String id; + public final TCFDSFExecutionDMC exe_dmc; + public final TCFDataCache<TCFFrameData> frame_data; int level; TCFFrameData prev_data; @@ -65,18 +63,12 @@ public class TCFDSFStack extends AbstractDsfService implements IStack { reset(null); return true; } - if (level == 0) { - assert id.startsWith(TOP_FRAME); - // Top frame is special case: most of its data is stored in CPU registers. - // Other frames are stored in memory - in thread stack area. - return getTopFrame(); - } command = tcf_stk_service.getContext(new String[]{ id }, new IStackTrace.DoneGetContext() { public void doneGetContext(IToken token, Exception err, IStackTrace.StackTraceContext[] context) { if (command != token) return; TCFFrameData data = null; TCFAddress a = null; - Number n = context[0].getReturnAddress(); + Number n = context[0].getInstructionAddress(); if (n != null) a = new TCFAddress(n); // Optimization: skip source position lookup if same address if (prev_data != null && prev_data.address != null && prev_data.address.equals(a)) { @@ -97,22 +89,6 @@ public class TCFDSFStack extends AbstractDsfService implements IStack { return false; } - private boolean getTopFrame() { - assert level == 0; - TCFDataCache<TCFDSFRunControlState> cache = exe_dmc.run_control_state_cache; - if (!cache.validate()) { - cache.wait(this); - return false; - } - TCFFrameData data = new TCFFrameData(); - TCFDSFRunControlState state = cache.getData(); - if (state != null) data.address = state.getPC(); - data.level = level; - if (!getSourcePos(data)) return false; - reset(prev_data = data); - return true; - } - private boolean getSourcePos(final TCFFrameData data) { if (tcf_lns_service == null) return true; if (data.address == null) return true; @@ -162,14 +138,14 @@ public class TCFDSFStack extends AbstractDsfService implements IStack { } } - private static class TCFFrameData implements IFrameDMData { + public static class TCFFrameData implements IFrameDMData { - IStackTrace.StackTraceContext context; - IAddress address; - int level; - String function; - Throwable src_pos_error; - ILineNumbers.CodeArea code_area; + public IStackTrace.StackTraceContext context; + public IAddress address; + public int level; + public String function; + public Throwable src_pos_error; + public ILineNumbers.CodeArea code_area; public IAddress getAddress() { return address; @@ -189,12 +165,12 @@ public class TCFDSFStack extends AbstractDsfService implements IStack { } public int getLine() { - if (code_area == null) return 0; + if (code_area == null) return -1; return code_area.start_line; } public int getColumn() { - if (code_area == null) return 0; + if (code_area == null) return -1; return code_area.start_column; } } @@ -204,6 +180,8 @@ public class TCFDSFStack extends AbstractDsfService implements IStack { private final TCFDSFExecutionDMC dmc; private final Map<String,TCFFrameDMC> frame_pool; + private String top_frame_id; + FramesCache(IChannel channel, TCFDSFExecutionDMC dmc) { super(channel); this.dmc = dmc; @@ -214,7 +192,10 @@ public class TCFDSFStack extends AbstractDsfService implements IStack { public boolean startDataRetrieval() { assert command == null; if (tcf_stk_service == null) { - reset(null); + HashMap<String,TCFFrameDMC> data = new HashMap<String,TCFFrameDMC>(); + top_frame_id = "TopFrame:" + dmc.getTcfContextId(); + data.put(top_frame_id, createFrameDMC(top_frame_id, 0)); + set(null, null, data); return true; } assert !dmc.isDisposed(); @@ -225,22 +206,22 @@ public class TCFDSFStack extends AbstractDsfService implements IStack { if (contexts != null) { for (int i = 0; i < contexts.length; i++) { String id = contexts[i]; - TCFFrameDMC n = frame_pool.get(id); - if (n == null) frame_pool.put(id, n = new TCFFrameDMC(dmc, id)); - n.level = contexts.length - i; - data.put(id, n); + data.put(id, createFrameDMC(id, contexts.length - i - 1)); } } - String id = TOP_FRAME + dmc.getTcfContextId(); - TCFFrameDMC n = frame_pool.get(id); - if (n == null) frame_pool.put(id, n = new TCFFrameDMC(dmc, id)); - n.level = 0; - data.put(id, n); set(token, err, data); } }); return false; } + + TCFFrameDMC createFrameDMC(String id, int level) { + TCFFrameDMC n = frame_pool.get(id); + if (n == null) frame_pool.put(id, n = new TCFFrameDMC(dmc, id)); + n.level = level; + if (n.level == 0) top_frame_id = id; + return n; + } void invalidateFrames() { reset(); @@ -467,11 +448,7 @@ public class TCFDSFStack extends AbstractDsfService implements IStack { return; } FramesCache cache = (FramesCache)cache0; - String id = TOP_FRAME + exe.getTcfContextId(); - TCFFrameDMC n = cache.frame_pool.get(id); - if (n == null) cache.frame_pool.put(id, n = new TCFFrameDMC(exe, id)); - n.level = 0; - rm.setData(n); + rm.setData(cache.createFrameDMC(cache.top_frame_id, 0)); rm.done(); } else { diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFDataCache.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFDataCache.java index 15246d90e..39c6f52a6 100644 --- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFDataCache.java +++ b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFDataCache.java @@ -68,6 +68,7 @@ public abstract class TCFDataCache<V> implements Runnable { * Note: It is prohibited to call this method when cache is not valid. */ public V getData() { + assert Protocol.isDispatchThread(); assert valid; return data; } @@ -88,6 +89,7 @@ public abstract class TCFDataCache<V> implements Runnable { * @param req */ public void wait(Runnable cb) { + assert Protocol.isDispatchThread(); assert !valid; if (cb != null) waiting_list.add(cb); } |