`
zhaozhongwei
  • 浏览: 52812 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

eclipse debug

阅读更多

JDIModelPresentation

IDebugModelPresentation #getEditorInput方法得到editinput

 

org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility#lookup方法里通过

 

if (presentation != null) {
     editorInput= presentation.getEditorInput(sourceElement);
    }
    if (editorInput != null) {
     editorId= presentation.getEditorId(editorInput, sourceElement);
    } 

 

然后都设置到SourceLookupResult里

 

org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility#display方法里

得到editor,如果

editorPresentation.addAnnotations(editor, frame)的值为true(非文本的的不过调试),这需要我们的IDebugModelPresentation同时也是IDebugEditorPresentation而且需要方法addAnnotations返回true,图形定位就是在这里完成的。

然后调用如下代码:

    Decoration decoration = new StandardDecoration(editorPresentation, editor, frame.getThread());
    DecorationManager.addDecoration(decoration);

 

如果addAnnotations返回false,这个时候编辑器应该是ITextEditor类型或这个可以被adapt到ITextEditor,然后根据IStackFrame得到行数,然后再得到IRegion,从而调用:

editor.selectAndReveal(region.getOffset(), 0);

来定位到当前行。

 

 

断点是在ToggleBreakpointAdapter#toggleBreakpoints中创建的,比如JavaLineBreakpoint是在toggleLineBreakpoints方法中创建的,在这个方法中有如下判断:

IJavaLineBreakpoint existingBreakpoint = JDIDebugModel.lineBreakpointExists(resource, tname, lnumber);
       if (existingBreakpoint != null) {
        DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(existingBreakpoint, true);
        return Status.OK_STATUS;
       }

 

也就是如果存在了就删除。

 

 

 

为特定的modelId定制变量值修改及保存功能

 <extension
       point="org.eclipse.debug.ui.variableValueEditors">
    <variableValueEditor
          modelId="org.eclipse.jdt.debug"
          class="org.eclipse.jdt.internal.debug.ui.actions.JavaVariableValueEditor"/>
 </extension>

 

 

扩展点org.eclipse.jdt.launching.vmInstallTypes,是在installed jres 点add按钮出现的jre类型。

可以通过如下扩展点给对应的vmtype添加下一页的ui内容

 

 <extension
       point="org.eclipse.jdt.debug.ui.vmInstallPages">
    <vmInstallPage
          class="org.eclipse.jdt.internal.debug.ui.jres.EEVMPage"
          vmInstallType="org.eclipse.jdt.launching.EEVMType">
    </vmInstallPage>
 </extension>

 

如果没给对应的vmInstallType添加对应的page则使用默认的StandardVMPage

 

 

TreeModelContentProvider是变量视图的ContentProvider,会委托给具体的类来做,比如jdt中是通过JavaStackFrameContentProvider(通过JDIStackFrame adapt 而来)来完成的,labelprovider是JavaVariableLabelProvider来完成的。

 

InternalTreeModelViewer#CellModifierProxy变量值修改。

 

而点完某个变量,如果这个变量是Object,会调用对象的toString()方法,显示在变量下面的文本区域。这是通过JDIThread的invokeMethod(ClassType, ObjectReference, Method, List, boolean)方法完成的

 

 

分享到:
评论
2 楼 zhaozhongwei 2010-05-05  
editor.selectAndReveal(region.getOffset(), 0);

所以这个和你的editor有关,你先确定这个方法被调用,然后看看你的editor里这个方法都做了什么。我想应该有关,但不确定,很久没弄debug了:)

兄弟相称就可以,我也是小弟呵呵
1 楼 popjxc 2010-05-04  
你好,看了你的文章启发很大。
请问一下,selectAndReveal方法是让选中的行有一个绿条吗?
小弟现在的debugger中的绿条不能刷新,需要用鼠标点一下才能变绿,好奇怪呀。。

相关推荐

Global site tag (gtag.js) - Google Analytics