|
Lines 24-40
Link Here
|
| 24 |
import org.eclipse.core.runtime.IStatus; |
24 |
import org.eclipse.core.runtime.IStatus; |
| 25 |
import org.eclipse.core.runtime.SafeRunner; |
25 |
import org.eclipse.core.runtime.SafeRunner; |
| 26 |
import org.eclipse.core.runtime.Status; |
26 |
import org.eclipse.core.runtime.Status; |
|
|
27 |
import org.eclipse.debug.core.DebugEvent; |
| 27 |
import org.eclipse.debug.core.DebugException; |
28 |
import org.eclipse.debug.core.DebugException; |
| 28 |
import org.eclipse.debug.core.DebugPlugin; |
29 |
import org.eclipse.debug.core.DebugPlugin; |
|
|
30 |
import org.eclipse.debug.core.IDebugEventSetListener; |
| 29 |
import org.eclipse.debug.core.ILaunch; |
31 |
import org.eclipse.debug.core.ILaunch; |
| 30 |
import org.eclipse.debug.core.ILaunchListener; |
|
|
| 31 |
import org.eclipse.debug.core.model.IDebugTarget; |
32 |
import org.eclipse.debug.core.model.IDebugTarget; |
| 32 |
import org.eclipse.debug.core.model.IMemoryBlock; |
33 |
import org.eclipse.debug.core.model.IMemoryBlock; |
| 33 |
import org.eclipse.debug.core.model.IMemoryBlockExtension; |
34 |
import org.eclipse.debug.core.model.IMemoryBlockExtension; |
| 34 |
import org.eclipse.debug.core.model.IMemoryBlockRetrieval; |
35 |
import org.eclipse.debug.core.model.IMemoryBlockRetrieval; |
| 35 |
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension; |
36 |
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension; |
| 36 |
import org.eclipse.debug.core.model.MemoryByte; |
37 |
import org.eclipse.debug.core.model.MemoryByte; |
| 37 |
import org.eclipse.debug.internal.ui.DebugUIMessages; |
|
|
| 38 |
import org.eclipse.debug.internal.ui.memory.MemoryRenderingManager; |
38 |
import org.eclipse.debug.internal.ui.memory.MemoryRenderingManager; |
| 39 |
import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; |
39 |
import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; |
| 40 |
import org.eclipse.debug.ui.DebugUITools; |
40 |
import org.eclipse.debug.ui.DebugUITools; |
|
Lines 82-88
Link Here
|
| 82 |
import org.eclipse.swt.layout.FormLayout; |
82 |
import org.eclipse.swt.layout.FormLayout; |
| 83 |
import org.eclipse.swt.widgets.Composite; |
83 |
import org.eclipse.swt.widgets.Composite; |
| 84 |
import org.eclipse.swt.widgets.Control; |
84 |
import org.eclipse.swt.widgets.Control; |
| 85 |
import org.eclipse.swt.widgets.Display; |
|
|
| 86 |
import org.eclipse.swt.widgets.Label; |
85 |
import org.eclipse.swt.widgets.Label; |
| 87 |
import org.eclipse.swt.widgets.Menu; |
86 |
import org.eclipse.swt.widgets.Menu; |
| 88 |
import org.eclipse.ui.IActionBars; |
87 |
import org.eclipse.ui.IActionBars; |
|
Lines 91-96
Link Here
|
| 91 |
import org.eclipse.ui.IWorkbenchPreferenceConstants; |
90 |
import org.eclipse.ui.IWorkbenchPreferenceConstants; |
| 92 |
import org.eclipse.ui.PlatformUI; |
91 |
import org.eclipse.ui.PlatformUI; |
| 93 |
import org.eclipse.ui.part.ViewPart; |
92 |
import org.eclipse.ui.part.ViewPart; |
|
|
93 |
import org.eclipse.ui.progress.UIJob; |
| 94 |
import org.eclipse.ui.progress.WorkbenchJob; |
94 |
import org.eclipse.ui.progress.WorkbenchJob; |
| 95 |
|
95 |
|
| 96 |
/** |
96 |
/** |
|
Lines 106-112
Link Here
|
| 106 |
*/ |
106 |
*/ |
| 107 |
|
107 |
|
| 108 |
@SuppressWarnings("restriction") |
108 |
@SuppressWarnings("restriction") |
| 109 |
public class MemoryBrowser extends ViewPart implements IDebugContextListener, ILaunchListener, IMemoryRenderingSite |
109 |
public class MemoryBrowser extends ViewPart implements IDebugContextListener, IMemoryRenderingSite, IDebugEventSetListener |
| 110 |
{ |
110 |
{ |
| 111 |
public static final String ID = "org.eclipse.cdt.debug.ui.memory.memorybrowser.MemoryBrowser"; //$NON-NLS-1$ |
111 |
public static final String ID = "org.eclipse.cdt.debug.ui.memory.memorybrowser.MemoryBrowser"; //$NON-NLS-1$ |
| 112 |
|
112 |
|
|
Lines 226-232
Link Here
|
| 226 |
selection = contextService.getActiveContext(); |
226 |
selection = contextService.getActiveContext(); |
| 227 |
} |
227 |
} |
| 228 |
|
228 |
|
| 229 |
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); |
229 |
DebugPlugin.getDefault().addDebugEventListener(this); |
| 230 |
|
230 |
|
| 231 |
if(selection instanceof StructuredSelection) |
231 |
if(selection instanceof StructuredSelection) |
| 232 |
handleDebugContextChanged(((StructuredSelection) selection).getFirstElement()); |
232 |
handleDebugContextChanged(((StructuredSelection) selection).getFirstElement()); |
|
Lines 257-263
Link Here
|
| 257 |
} |
257 |
} |
| 258 |
|
258 |
|
| 259 |
public void dispose() { |
259 |
public void dispose() { |
| 260 |
DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); |
260 |
DebugPlugin.getDefault().removeDebugEventListener(this); |
| 261 |
IDebugContextService contextService = |
261 |
IDebugContextService contextService = |
| 262 |
DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()); |
262 |
DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()); |
| 263 |
if (isBug145635Patched()) { |
263 |
if (isBug145635Patched()) { |
|
Lines 269-286
Link Here
|
| 269 |
super.dispose(); |
269 |
super.dispose(); |
| 270 |
} |
270 |
} |
| 271 |
|
271 |
|
| 272 |
public void launchAdded(ILaunch launch) {} |
272 |
/* (non-Javadoc) |
| 273 |
public void launchChanged(ILaunch launch) {} |
273 |
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[]) |
| 274 |
|
274 |
*/ |
| 275 |
public void launchRemoved(ILaunch launch) { |
275 |
public void handleDebugEvents(DebugEvent[] events) { |
| 276 |
// For CDT launch is not adaptable to memory rendering, but the debug targets do. |
276 |
for (DebugEvent event: events) { |
| 277 |
for (IDebugTarget target : launch.getDebugTargets()) { |
277 |
Object source = event.getSource(); |
| 278 |
IMemoryBlockRetrieval retrieval = ((IMemoryBlockRetrieval) target.getAdapter(IMemoryBlockRetrieval.class)); |
278 |
if (event.getKind() == DebugEvent.TERMINATE && source instanceof IMemoryBlockRetrieval) { |
| 279 |
if(retrieval != null) |
279 |
releaseTabFolder(source); |
| 280 |
releaseTabFolder(retrieval); |
280 |
} |
| 281 |
} |
281 |
} |
| 282 |
} |
282 |
} |
| 283 |
|
283 |
|
| 284 |
public IMemoryRenderingContainer getContainer(String id) { |
284 |
public IMemoryRenderingContainer getContainer(String id) { |
| 285 |
return null; |
285 |
return null; |
| 286 |
} |
286 |
} |
|
Lines 334-340
Link Here
|
| 334 |
if(((IMemoryBlockExtension) rendering.getMemoryBlock()).supportBaseAddressModification()) |
334 |
if(((IMemoryBlockExtension) rendering.getMemoryBlock()).supportBaseAddressModification()) |
| 335 |
((IMemoryBlockExtension) rendering.getMemoryBlock()).setBaseAddress(newBase); |
335 |
((IMemoryBlockExtension) rendering.getMemoryBlock()).setBaseAddress(newBase); |
| 336 |
rendering.goToAddress(newBase); |
336 |
rendering.goToAddress(newBase); |
| 337 |
Display.getDefault().asyncExec(new Runnable(){ |
337 |
runOnUIThread(new Runnable(){ |
| 338 |
public void run() |
338 |
public void run() |
| 339 |
{ |
339 |
{ |
| 340 |
updateLabel(activeFolder.getSelection(), rendering); |
340 |
updateLabel(activeFolder.getSelection(), rendering); |
|
Lines 422-428
Link Here
|
| 422 |
} |
422 |
} |
| 423 |
IMemoryBlockExtension block = (IMemoryBlockExtension) item.getData(KEY_MEMORY_BLOCK); |
423 |
IMemoryBlockExtension block = (IMemoryBlockExtension) item.getData(KEY_MEMORY_BLOCK); |
| 424 |
try { |
424 |
try { |
| 425 |
block.dispose(); |
425 |
if (block != null) |
|
|
426 |
block.dispose(); |
| 426 |
} catch (DebugException e) { |
427 |
} catch (DebugException e) { |
| 427 |
MemoryBrowserPlugin.getDefault().getLog().log(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID, "Could not dispose memory block", e)); //$NON-NLS-1$ |
428 |
MemoryBrowserPlugin.getDefault().getLog().log(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID, "Could not dispose memory block", e)); //$NON-NLS-1$ |
| 428 |
} |
429 |
} |
|
Lines 536-544
Link Here
|
| 536 |
|
537 |
|
| 537 |
if(context instanceof IAdaptable) |
538 |
if(context instanceof IAdaptable) |
| 538 |
{ |
539 |
{ |
| 539 |
IMemoryBlockRetrieval retrieval = ((IMemoryBlockRetrieval) ((IAdaptable) context).getAdapter(IMemoryBlockRetrieval.class)); |
540 |
IAdaptable adaptable_context = (IAdaptable) context; |
|
|
541 |
IMemoryBlockRetrieval retrieval = ((IMemoryBlockRetrieval) adaptable_context.getAdapter(IMemoryBlockRetrieval.class)); |
| 542 |
ILaunch launch = ((ILaunch) adaptable_context.getAdapter(ILaunch.class)); |
| 540 |
|
543 |
|
| 541 |
if(retrieval != null) |
544 |
if(retrieval != null && launch != null && !launch.isTerminated()) |
| 542 |
{ |
545 |
{ |
| 543 |
fGotoAddressBarControl.setVisible(true); |
546 |
fGotoAddressBarControl.setVisible(true); |
| 544 |
CTabFolder tabFolder = getTabFolder(retrieval); |
547 |
CTabFolder tabFolder = getTabFolder(retrieval); |
|
Lines 666-685
Link Here
|
| 666 |
return fContextFolders.put(context, folder); |
669 |
return fContextFolders.put(context, folder); |
| 667 |
} |
670 |
} |
| 668 |
|
671 |
|
| 669 |
private void releaseTabFolder(Object context) |
672 |
private void releaseTabFolder(final Object context) |
| 670 |
{ |
673 |
{ |
| 671 |
final CTabFolder folder = getTabFolder(context); |
674 |
final CTabFolder folder = getTabFolder(context); |
| 672 |
if(folder != null) |
675 |
if(folder != null) |
| 673 |
{ |
676 |
{ |
| 674 |
for(CTabItem tab : folder.getItems()) { |
677 |
Runnable run = new Runnable() { |
| 675 |
disposeTab(tab); |
678 |
public void run() { |
| 676 |
} |
679 |
for(CTabItem tab : folder.getItems()) { |
| 677 |
} |
680 |
disposeTab(tab); |
| 678 |
fContextFolders.remove(context); |
681 |
} |
| 679 |
folder.dispose(); |
682 |
fContextFolders.remove(context); |
| 680 |
|
683 |
folder.dispose(); |
| 681 |
if (fStackLayout.topControl.equals(folder)) { |
684 |
|
| 682 |
handleUnsupportedSelection(); |
685 |
if (fStackLayout.topControl.equals(folder)) { |
|
|
686 |
handleUnsupportedSelection(); |
| 687 |
} |
| 688 |
} |
| 689 |
}; |
| 690 |
runOnUIThread(run); |
| 683 |
} |
691 |
} |
| 684 |
} |
692 |
} |
| 685 |
|
693 |
|
|
Lines 757-762
Link Here
|
| 757 |
newBlock.dispose(); |
765 |
newBlock.dispose(); |
| 758 |
return address; |
766 |
return address; |
| 759 |
} |
767 |
} |
|
|
768 |
|
| 769 |
/** |
| 770 |
* execute runnable on UI thread if the current thread is not an UI thread |
| 771 |
* @param runnable |
| 772 |
*/ |
| 773 |
private void runOnUIThread(final Runnable runnable) |
| 774 |
{ |
| 775 |
if (MemoryBrowserPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow() != null) { |
| 776 |
runnable.run(); |
| 777 |
} |
| 778 |
else { |
| 779 |
UIJob job = new UIJob("Memory Browser UI Job"){ //$NON-NLS-1$ |
| 780 |
public IStatus runInUIThread(IProgressMonitor monitor) { |
| 781 |
runnable.run(); |
| 782 |
return Status.OK_STATUS; |
| 783 |
}}; |
| 784 |
job.setSystem(true); |
| 785 |
job.schedule(); |
| 786 |
} |
| 787 |
} |
| 760 |
} |
788 |
} |
| 761 |
|
789 |
|
| 762 |
|
790 |
|