Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "CDT/Archive/Debug/Catchpoints support"

< CDT‎ | Archive
(Other changes)
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
 +
{{warning|Note: The contents of this page refer to design documents reflecting work in progress of Eclipse CDT features and for some features that have never been implemented. Therefore they may not refer to the current state of CDT. Please visit [[CDT/designs]] for links to the maintained and up to date design documents.  }}
 +
 +
[[Category:CDT:Archive]]
 +
 
== Overview ==
 
== Overview ==
This document describe design ideas of adding catchpoints support to CDT.
+
This document describe design ideas of adding event breakpoints (catchpoints) support to CDT.
Catchpoints is special breakpoints which is similar to event handlers in eclipse, they don't attach to resource like regular breakpoints; but instead they attach to debugger events.  
+
Event Breakpoints are special breakpoints which are similar to event handlers in eclipse, they don't attach to resource like regular breakpoints; but instead they attach to debugger events.  
 
Event can be for example "catch exception" or something like "load library event".
 
Event can be for example "catch exception" or something like "load library event".
 +
 +
[https://bugs.eclipse.org/bugs/show_bug.cgi?id=226689 bug 226689]
  
 
Please leave your comments here: [[Talk:CDT:_Debug:_Catchpoints_support]]
 
Please leave your comments here: [[Talk:CDT:_Debug:_Catchpoints_support]]
  
 
== Workflow & UI ==
 
== Workflow & UI ==
* Adding catchpoint
+
* Adding an event breakpoint
** From breakpoints view, right click Add catchpoint... Dialog opens. Dialog contains type of event to catch and maybe additional argument field. Creating extensible Add Breakpoint contributions is covered by [https://bugs.eclipse.org/bugs/show_bug.cgi?id=227394 bug 227394].
+
** From breakpoints view, invoke action Add Event Breakpoint...  
** From console, triggers adding breakpoints by backend
+
**:: Dialog opens. Dialog contains type of event to catch and maybe additional argument field. User edit it press Ok. [[Image:AddCatpointDialog.png|thumb|right]]
** If no contributions to catchpoint types been made, action should be disabled or give appropriate error when attempt to run
+
**:: Creating extensible Add Breakpoint contributions is covered by [https://bugs.eclipse.org/bugs/show_bug.cgi?id=227394 bug 227394]. It most likely not going to make Ganymede so for now I can just add it context menu or in view menu.
* Removing catchpoint
+
**:: If no contributions to event breakpoint types been made, action should be disabled or give appropriate error when attempt to run
** Removing catchpoint from breakpoints view, select breakpoint, right click -> Delete
+
** From console, triggers adding breakpoints by backend - Breakpoint appears in the list
 +
* Removing an event breakpoint
 +
** Removing event breakpoint from breakpoints view, select breakpoint, right click -> Delete
 
** From console, triggers deleting breakpoint by backend
 
** From console, triggers deleting breakpoint by backend
* Viewing/Editing
+
* Viewing/Editing [[Image:catchpointsBreakpointsView.png|thumb|right]] [[Image:CatchProperties.png|thumb|right]]
** Catchpoint is visible as Element in Breakpoints view. Label contains event type label and argument, followed by default cbreakpoint attributes
+
** Event breakpoint is visible as Element in Breakpoints view. Label contains event type label and argument, followed by default cEventBreakpoint attributes
** Select catchpoint in breakpoints view, right click -> Show breakpoint properties
+
** Select event breakpoint in breakpoints view, right click -> Show breakpoint properties
** Catchpoint properties contain common page, conditions and triggered actions.
+
** Event breakpoint properties contain common page, conditions and triggered actions.
** Common tab is similar to regular breakpoint except file/line stuff, and in addition it has event type and extra control for event argument (viewing or editing).
+
** Common tab is similar to a standard breakpoint except file/line stuff, and in addition it has event type and extra control for event argument (viewing or editing).
  
== Catchpoint contributions ==
+
== Event Breakpoint contributions ==
* Main Catchpoints attributes would consist of Catchpoint type (event type - String) and Extra argument (Object)
+
* Main Event Breakpoint attributes would consist of event type (String) and Extra argument (Object)
 
* We need the following contributions one way or another:
 
* We need the following contributions one way or another:
 
*1) Label for event type. This will be visible in Breakpoints view as a part of element Label, in Add Breakpoint wizard/dialog, in Breakpoint Properties
 
*1) Label for event type. This will be visible in Breakpoints view as a part of element Label, in Add Breakpoint wizard/dialog, in Breakpoint Properties
Line 28: Line 37:
 
*4) Custom control for viewing/modifying event argument, for Common properties page
 
*4) Custom control for viewing/modifying event argument, for Common properties page
  
To implement 1 we need some sort of catchpoint type registry.
+
To implement 1 we need some sort of event breakpoint type registry.
  
 
To implement 2:  
 
To implement 2:  
*2a Use toString method of Argument type in catchpoint label provider
+
*2a Use toString method of Argument type in event breakpoint label provider
 
*2b Implement adapters mechanism for ILabelProvider (Breakpoints view does not support IElementLabelProvider yet)
 
*2b Implement adapters mechanism for ILabelProvider (Breakpoints view does not support IElementLabelProvider yet)
  
Line 41: Line 50:
 
:: example: text for "gdb.catch" event type (value of org.eclipse.cdt.debug.breakpoint.type attribute) is "Exception Caught"
 
:: example: text for "gdb.catch" event type (value of org.eclipse.cdt.debug.breakpoint.type attribute) is "Exception Caught"
 
* Mechanism to register Label provider for a new breakpoint type element
 
* Mechanism to register Label provider for a new breakpoint type element
:: this allows to show label for non-standard breakpoint type, like Catchpoint itself at the moment
+
:: this allows to show label for non-standard breakpoint type, like Event Breakpoint itself at the moment
:: example: register adapter for ILabelProvider on ICCatchpoint. getText() returns concatenation of event type label, extra argument, condition and count.
+
:: example: register adapter for ILabelProvider on ICEventBreakpoint. getText() returns concatenation of event type label, extra argument, condition and count.
 
* Mechanism to register a list of supported values of a new breakpoint attribute
 
* Mechanism to register a list of supported values of a new breakpoint attribute
:: this would allow to register possible catchpoint events.  
+
:: this would allow to register possible event breakpoint events.  
 
:: example: extension that list contributes event types from gdb backend  
 
:: example: extension that list contributes event types from gdb backend  
 
* Mechanism to register extension Control for Common property page to show a new breakpoint attribute
 
* Mechanism to register extension Control for Common property page to show a new breakpoint attribute
 
:: this allows to actually view custom breakpoint attributes in Common page. If it is just one attribute added such as breakpoint type: hardware/software viewing them in separate property page is overkill
 
:: this allows to actually view custom breakpoint attributes in Common page. If it is just one attribute added such as breakpoint type: hardware/software viewing them in separate property page is overkill
:: example: extension that contribute property page to create extra argument (C/C++ type) for exception catchpoint.
+
:: example: extension that contribute property page to create extra argument (C/C++ type) for exception event breakpoint
  
 
== Implementation ==
 
== Implementation ==
Line 54: Line 63:
 
* To represent event type there is two options: use marker type or use marker attribute. I will go with attribute for now.
 
* To represent event type there is two options: use marker type or use marker attribute. I will go with attribute for now.
  
=== UI ===
+
 
* Add extension point that allow to contribute event type and its editors, example
+
 
    <extension
+
        point="org.eclipse.cdt.debug.ui.catchpoints">
+
        <catchpointPresentation
+
            eventTypeId="org.eclipse.cdt.debug.gdb.catch"
+
            eventTypeLabel="Exception Caught"
+
            hasArgument="true"
+
            argumentLabel="Exception Name"
+
            controlClass="org.eclipse.cdt.debug.ui.utils.CTypeAssistLookup"
+
        />
+
    </extension>
+
 
=== Public API ===
 
=== Public API ===
* Add interface org.eclipse.cdt.debug.core.model.ICCatchpoint extends ICBreakpoint
+
* Add interface org.eclipse.cdt.debug.core.model.ICEventBreakpoint extends ICBreakpoint
 
** In there define strings for 2 addition marker attributes: event type id and event argument
 
** In there define strings for 2 addition marker attributes: event type id and event argument
 
** Define 2 getter methods for these attribute
 
** Define 2 getter methods for these attribute
* Add interface org.eclipse.cdt.debug.core.cdi.model.ICDICatchpoint extends ICDIBreakpoint
+
* Add interface org.eclipse.cdt.debug.core.cdi.model.ICDIEventBreakpoint extends ICDIBreakpoint
  
 
=== Other changes ===
 
=== Other changes ===
* Add class org.eclipse.cdt.debug.internal.core.breakpoints.CCatchpoint extends CBreakpoint implements ICCatchpoint
+
* Add class org.eclipse.cdt.debug.internal.core.breakpoints.CEventBreakpoint extends CBreakpoint implements ICEventBreakpoint
 
* Add org.eclipse.debug.core.breakpoints extension for breakpoint markers
 
* Add org.eclipse.debug.core.breakpoints extension for breakpoint markers
* Add createCatchpoint method in CDTDebugModel
+
* Add createEventBreakpoint method in CDTDebugModel
 
* Support in CBreakpointManager handleBreakpontCreatedEvent
 
* Support in CBreakpointManager handleBreakpontCreatedEvent
 
...
 
...
  
;Platform Core extension for marker attribute values:
 
  <extension id="com.xyz.coolMarkerValues" point="org.eclipse.core.resources.markersValues">
 
      <marker id="com.xyz.coolMarker">
 
      <attribute name="owner">
 
        <value id="harris.bob"/>
 
        <value id="harris.mary"/>
 
      </attribute>
 
      </marker>
 
  </extension>
 
  
;Platform UI extension for marker attribute externalizable values
+
;Platform UI (or CDT) extension for marker attribute externalizable values
 +
Schema: [[CDT: Debug: breakpointUiContributions]]
  
  <extension id="com.xyz.coolMarkerLabels" point="org.eclipse.ui.resources.markersValueLabels">
+
Examples:
      <marker id="com.xyz.coolMarker">
+
      <attribute name="owner" label="Resource Owner">
+
        <value id="harris.bob" label="Bob Harris"/>
+
        <value id="harris.mary" label="Mary Harris"/>
+
      </attribute>
+
      </marker>
+
  </extension>
+
  
;CDT Extension point for Common property page contribution
+
<extension id="com.xyz.coolMarkerLabels" point="org.eclipse.cdt.debug.ui.breakpointContribution">
 +
    <breakpointLabels markerId="com.xyz.coolMarker">
 +
    <attribute name="owner" label="Resource Owner">
 +
        <value value="harris.bob" label="Bob Harris"/>
 +
        <value value="harris.mary" label="Mary Harris"/>
 +
    </attribute>
 +
    </breakpointLabels>
 +
</extension>
  
  <extension id="com.xyz.coolAttributesContribution" point="org.eclipse.cdt.debug.breakpoints.attributesContribution">  
+
Actual example from CDI/MI implementation:
      <commonContribution
+
      class="com.xyz.OwnerPropertyPagePart">
+
  <extension point="org.eclipse.cdt.debug.ui.breakpointContribution">
      <enabledWhen>
+
    <breakpointLabels markerId="org.eclipse.cdt.debug.core.cEventBreakpointMarker">  
          # something like this (converted to xml :)
+
    <attribute name="org.eclipse.cdt.debug.core.eventbreakpoint_event_id" label="Breakpoint Event Type" type="enum">
          marker.type instanceof com.xyz.coolMarker && marker.model == org.eclipse.cdt.debug.core && marker.owner != null
+
        <value value="org.eclipse.cdt.debug.gdb.catch" label="Exception Caught">
              
+
            <attribute name="org.eclipse.cdt.debug.core.catchpoint_event_arg" label="C/C++ Type"
      </eanbledWhen>      
+
                type="string" fieldEditor="org.eclipse.cdt.debug.ui.breakpoints.CTypeFieldEditor">
      </commonContribution>
+
            </attribute>
     
+
        </value>
  </extension>
+
        <value value="org.eclipse.cdt.debug.gdb.throw" label="Exception Thrown"/>
 +
        <value value="org.eclipse.cdt.debug.gdb.signal" label="Signal Caught">
 +
            <attribute name="org.eclipse.cdt.debug.core.eventbreakpoint_event_arg" label="Signal Number"
 +
                type="integer" fieldEditor="org.eclipse.jface.preference.IntegerFieldEditor">
 +
             </attribute>
 +
        </value>
 +
    </attribute>  
 +
    </breakpointLabels>
 +
</extension>

Latest revision as of 15:22, 22 January 2020

Warning2.png
Note: The contents of this page refer to design documents reflecting work in progress of Eclipse CDT features and for some features that have never been implemented. Therefore they may not refer to the current state of CDT. Please visit CDT/designs for links to the maintained and up to date design documents.

Overview

This document describe design ideas of adding event breakpoints (catchpoints) support to CDT. Event Breakpoints are special breakpoints which are similar to event handlers in eclipse, they don't attach to resource like regular breakpoints; but instead they attach to debugger events. Event can be for example "catch exception" or something like "load library event".

bug 226689

Please leave your comments here: Talk:CDT:_Debug:_Catchpoints_support

Workflow & UI

  • Adding an event breakpoint
    • From breakpoints view, invoke action Add Event Breakpoint...
      Dialog opens. Dialog contains type of event to catch and maybe additional argument field. User edit it press Ok.
      AddCatpointDialog.png
      Creating extensible Add Breakpoint contributions is covered by bug 227394. It most likely not going to make Ganymede so for now I can just add it context menu or in view menu.
      If no contributions to event breakpoint types been made, action should be disabled or give appropriate error when attempt to run
    • From console, triggers adding breakpoints by backend - Breakpoint appears in the list
  • Removing an event breakpoint
    • Removing event breakpoint from breakpoints view, select breakpoint, right click -> Delete
    • From console, triggers deleting breakpoint by backend
  • Viewing/Editing
    CatchpointsBreakpointsView.png
    CatchProperties.png
    • Event breakpoint is visible as Element in Breakpoints view. Label contains event type label and argument, followed by default cEventBreakpoint attributes
    • Select event breakpoint in breakpoints view, right click -> Show breakpoint properties
    • Event breakpoint properties contain common page, conditions and triggered actions.
    • Common tab is similar to a standard breakpoint except file/line stuff, and in addition it has event type and extra control for event argument (viewing or editing).

Event Breakpoint contributions

  • Main Event Breakpoint attributes would consist of event type (String) and Extra argument (Object)
  • We need the following contributions one way or another:
  • 1) Label for event type. This will be visible in Breakpoints view as a part of element Label, in Add Breakpoint wizard/dialog, in Breakpoint Properties
  • 2) Part of label for event argument, to be visible in Breakpoint view
  • 3) Custom control for creating event argument, in Add Breakpoint wizard/dialog
  • 4) Custom control for viewing/modifying event argument, for Common properties page

To implement 1 we need some sort of event breakpoint type registry.

To implement 2:

  • 2a Use toString method of Argument type in event breakpoint label provider
  • 2b Implement adapters mechanism for ILabelProvider (Breakpoints view does not support IElementLabelProvider yet)

To implement 3 and 4 we can use same control, which can contributed using extensions points

Now if we generalize it we can have:

  • Mechanism to register a static label (text) for a new breakpoint attribute value
this allows to handle event type Label and Label for other breakpoint attributes such as hardware/software type
example: text for "gdb.catch" event type (value of org.eclipse.cdt.debug.breakpoint.type attribute) is "Exception Caught"
  • Mechanism to register Label provider for a new breakpoint type element
this allows to show label for non-standard breakpoint type, like Event Breakpoint itself at the moment
example: register adapter for ILabelProvider on ICEventBreakpoint. getText() returns concatenation of event type label, extra argument, condition and count.
  • Mechanism to register a list of supported values of a new breakpoint attribute
this would allow to register possible event breakpoint events.
example: extension that list contributes event types from gdb backend
  • Mechanism to register extension Control for Common property page to show a new breakpoint attribute
this allows to actually view custom breakpoint attributes in Common page. If it is just one attribute added such as breakpoint type: hardware/software viewing them in separate property page is overkill
example: extension that contribute property page to create extra argument (C/C++ type) for exception event breakpoint

Implementation

  • CBreakpoint already provides extensibility mechanism that can be used for catchpoint contributions (BreakpointExtention)?
  • To represent event type there is two options: use marker type or use marker attribute. I will go with attribute for now.


Public API

  • Add interface org.eclipse.cdt.debug.core.model.ICEventBreakpoint extends ICBreakpoint
    • In there define strings for 2 addition marker attributes: event type id and event argument
    • Define 2 getter methods for these attribute
  • Add interface org.eclipse.cdt.debug.core.cdi.model.ICDIEventBreakpoint extends ICDIBreakpoint

Other changes

  • Add class org.eclipse.cdt.debug.internal.core.breakpoints.CEventBreakpoint extends CBreakpoint implements ICEventBreakpoint
  • Add org.eclipse.debug.core.breakpoints extension for breakpoint markers
  • Add createEventBreakpoint method in CDTDebugModel
  • Support in CBreakpointManager handleBreakpontCreatedEvent

...


Platform UI (or CDT) extension for marker attribute externalizable values

Schema: CDT: Debug: breakpointUiContributions

Examples:

<extension id="com.xyz.coolMarkerLabels" point="org.eclipse.cdt.debug.ui.breakpointContribution">
    <breakpointLabels markerId="com.xyz.coolMarker"> 
    <attribute name="owner" label="Resource Owner">
       <value value="harris.bob" label="Bob Harris"/>
       <value value="harris.mary" label="Mary Harris"/>
    </attribute> 
    </breakpointLabels>
</extension>

Actual example from CDI/MI implementation:

 <extension point="org.eclipse.cdt.debug.ui.breakpointContribution">
    <breakpointLabels markerId="org.eclipse.cdt.debug.core.cEventBreakpointMarker"> 
    <attribute name="org.eclipse.cdt.debug.core.eventbreakpoint_event_id" label="Breakpoint Event Type" type="enum">
       <value value="org.eclipse.cdt.debug.gdb.catch" label="Exception Caught">
           <attribute name="org.eclipse.cdt.debug.core.catchpoint_event_arg" label="C/C++ Type" 
                type="string" fieldEditor="org.eclipse.cdt.debug.ui.breakpoints.CTypeFieldEditor">
           </attribute>
       </value>
       <value value="org.eclipse.cdt.debug.gdb.throw" label="Exception Thrown"/>
       <value value="org.eclipse.cdt.debug.gdb.signal" label="Signal Caught">
           <attribute name="org.eclipse.cdt.debug.core.eventbreakpoint_event_arg" label="Signal Number" 
                type="integer" fieldEditor="org.eclipse.jface.preference.IntegerFieldEditor">
           </attribute>
       </value>
    </attribute> 
    </breakpointLabels>
</extension>

Back to the top