Skip to main content
Jump to: navigation, search

DSDP/DD/DSF CodingCamp ExpressionServiceExcercise

< DSDP‎ | DD


  • Populate contents of the variables view with local variables of the selected stack frame.
  • Retrieve the sub-expressions of arrays and structs to show in Variable view.
  • Enable evaluating of expressions that user types in the Expression view.


Stack Service

MI Implementation
Existing functionality
  • Retrieves list of all stack frames for a given execution context
  • Retrieves the list of local variables for a given stack frame context
Missing functionality / Cleanup tasks
  • Retrieving the list of local variables for a given stack frame context
  • Simplify logic to retrieve argument data.
  • Add tracing to the service

Expression Service

MI Implementation
Existing functionality
  • Provided implementation was written to the interface but never tested.
  • The expression service is correctly created and shutdown during the launch sequence
Missing functionality
  • As mentioned above the implementation was never tested, so it's not reliable as a reference.
  • Existing implementation does not manage the variable objects created by GDB using the "-var-create" command. Therefore all GDB variable objects that are created are leaked.
  • The expression service needs to retrieve the variable value in the number format that is specified by the client.

Variable view VM (View Model)

This is the primary client of the expression service, which populates the contents of the variables view. The view model was written against the expression service interface, and should work with a correctly implemented expression and stack services.

Reference Code and Documentation

org.eclipse.cdt.debug.mi.core.cdi.ExpressionManager This is the CDT component which creates/reads/manages GDB variable objects. It is the closest CDI equivalent to the MI Expression service implementation and is a good reference for how to property create teh commands and interpret the command results. However this manager does not cache results of variable reads, which in a way is the primary purpose of the expression service.

MI Var Commands In the org.eclipse.dd.dsf.mi.core.command package, see the commands: DsfMIVarCreate, DsfMIVarDelete, DsfMIVarEvaluateExpression, DsfMIVarSetFormat, and their corresponding MI documentation. Also in the org.eclipse.cdt.debug.mi.core.command package, see: MIVarAssign, MIVarInfoExpression, MIVarInfoNumChildren, MIVarInfoType, MIVarListChildren. These command objects will first need to be compied over into the corresponding DSF package along with their info object.

Design Considerations

MI Var objects

The MI protocol uses variable objects, which in effect are handles for accessing expression information. These handles need to be tracked by the client and deleted when no longer needed. Meanwhile the IExpression service creates context handles (IExpressionDMContext), which do not need to be deleted by the clients. I.e. the client may request information on many different variables and then never read them again, or it may repeatedly retrieve the same couple of variables over and over again. So the expression service implementation needs to determine how to best control the life-cycle of these variable objects, and maybe it will need to adapt to the client usage.

As a simpler alternative, the service implementation could create and destroy the var objects for each data retrieval. This would eliminate the guess-work from the service on when to delete the variable objects, but it may degrate the performance.

Caching variable data

The standard command cache provided by DSF framework, caches command results keyed on the commands. This works well when the command used to retrieve the data is the same every time, e.g. -stack-list-frames, -data-list-register-values. However the commands used to retrieve expression data need to use the variable objects, and if two different variable objects are used to retrieve the same data, the cache is not going to match it. Most likely the expression service will need a custom cache mechanism, which will track the variable objects for each expression as well as the information retrieved for the variable.

Back to the top