Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 262814

Summary: Class Cast exception when Expression view has expressions defined by non-Java debug session
Product: [Eclipse Project] JDT Reporter: Elena Laskavaia <elaskavaia.cdt>
Component: DebugAssignee: Pawel Piech <pawel.1.piech>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: darin.eclipse
Version: 3.4.1   
Target Milestone: 3.5 M6   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Elena Laskavaia CLA 2009-01-28 14:40:34 EST
!STACK 0
I have C program (CDT) and Java program. I launch debug session for C program
and add watch expression. When I launch java program and add java watch expression. When I switch between C stack frame and Java stack frame I get this
CCE:


java.lang.ClassCastException: org.eclipse.cdt.debug.internal.core.model.CValue
	at org.eclipse.jdt.internal.debug.ui.JDIModelPresentation.getExpressionText(JDIModelPresentation.java:1312)
	at org.eclipse.jdt.internal.debug.ui.JDIModelPresentation.getWatchExpressionText(JDIModelPresentation.java:1359)
	at org.eclipse.jdt.internal.debug.ui.JDIModelPresentation.getText(JDIModelPresentation.java:228)
	at org.eclipse.debug.internal.ui.LazyModelPresentation.getText(LazyModelPresentation.java:185)
	at org.eclipse.debug.internal.ui.DelegatingModelPresentation.getText(DelegatingModelPresentation.java:158)
	at org.eclipse.debug.internal.ui.VariablesViewModelPresentation.getText(VariablesViewModelPresentation.java:25)
	at org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider.getLabel(DebugElementLabelProvider.java:35)
	at org.eclipse.debug.internal.ui.model.elements.VariableLabelProvider.getLabel(VariableLabelProvider.java:89)
	at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider.retrieveLabel(ElementLabelProvider.java:212)
	at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider$LabelUpdater.run(ElementLabelProvider.java:157)
	at org.eclipse.debug.internal.ui.model.elements.ElementLabelProvider$LabelJob.run(ElementLabelProvider.java:71)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 1 Darin Wright CLA 2009-02-04 13:40:24 EST
The label provider for a watch expression is derived from the expression's context's "debug model ID". The context is set from the selected stack frame. Sounds like a synch problem where the label was being retrived when it was bound the Java model, but it has since been bound to C model.

It would be safer to derive the model from the expression's current value if it has one, else delegate to the context's model.

Comment 2 Darin Wright CLA 2009-02-04 13:41:12 EST
I updated the logic in WatchExpression.getModelIdentifier(). Pawel, please verify. I can't reproduce the problem with PDA, but perhaps you can try with CDT.
Comment 3 Pawel Piech CLA 2009-02-06 13:44:39 EST
I cannot reproduce the CCE either (with CDT), but the patch looks fine to me.
Comment 4 Elena Laskavaia CLA 2009-02-06 14:17:52 EST
checked with current trunk - no CCE anymore, thanks