Debugger Data Model C++ Overview
This topic provides an overview of how to use Debugger Data Model C++ Interfaces to extend and customize the capabilities of the debugger.
This topic includes the following sections.
Overview of the Debugger Data Model C++ Interface
To illustrate the goals of the debugger data model, consider this traditional debugger command.
0: kd> !process 0 0 PROCESS ffffe0007e6a7780 SessionId: 1 Cid: 0f68 Peb: 7ff7cfe7a000 ParentCid: 0f34 DirBase: 1f7fb9000 ObjectTable: ffffc001cec82780 HandleCount: 34. Image: echoapp.exe ...
The debugger command is using a binary mask and it provides text only output in non-standard ways. The text output is difficult to consume, format, or extend and the layout is specific to this command.
Contrast this to the debugger data model dx (Display Debugger Object Model Expression) command.
dx @$cursession.Processes.Where(p => p.Threads.Count() > 5)
This command uses a standard data model that is discoverable, extensible and composable in uniform ways.
Logically name spacing things and extending on specific objects allows for the discovery of debugger extension functionality.
The data model is the way that the new WinDbg Preview debugger, shows most things. Many elements in the new UI can be queried, extended, or scripted, because they are powered by the data model. For more information, see WinDbg Preview - Data Model.
Data Model Architectural View
The following diagram summarizes the major elements of the debugger data model architecture.
- To the left side, UI elements are shown that provide access to the objects and support such functionality as LINQ queries.
At the center of the Debugger Data Model is a uniform object representation in which everything is an instance of the IModelObject interface. While such an object may represent an intrinsic (e.g.: an integer value) or another data model interface, it often represents a dynamic object – a dictionary of key/value/metadata tuples and a set of concepts which describe abstract behaviors.
This diagram shows how the IModelObject uses Key Stores to contain values that a provider can create, register and manipulate.
- It shows a provider, that provides information to the object model
- On the left it shows the IModelObject, that is the common object model that is used to manipulate objects.
- In the center is the Key Store that is used to store and access values.
- At the bottom it shows Concepts that support objects with functionality such as the ability to convert to a displayable string or be indexed.
The Data Model: A Consumer View
The next diagram shows a consumer view of the data model. In the example the dx (Display Debugger Object Model Expression) command is being used to query information.
- The Dx command communicates through a serializer to the object enumeration interface.
- IDebugHost* objects are used to gather information from the debugger engine.
- Expression and semantic evaluators are used to send the request to the debugger engine.
The Data Model: A Producer View
This diagram shows a producer view of the data model.
- A NatVis provider is shown on the left that consumes XML that defines additional functionality.
- The bottom shows a native code provider that can also define additional functionality.
Data Model Manager
This diagram shows the central role that the data model manager plays in the management of objects.
- The Data Model Manager acts as a central registrar for all objects.
- On the left it shows how standard debugger elements such as sessions and process are registered.
- The namespace block shows the central registration list.
- The right side of the diagram shows two providers, one for NatVis on the top, and a C/C++ extension on the bottom.
Summary of Debugger Data Model Interfaces
There are a multitude of C++ interfaces which comprise different pieces of the data model. In order to approach these interfaces in a consistent and easy manner, they are broken down by general category. The main areas here:
The General Object Model
The first and most important set of interfaces define how to get access to the core data model and how to access and manipulate objects. IModelObject is the interface which represents every object in the data model (much like C#'s object). This is the main interface of interest for both consumers of and producers to the data model. The other interfaces are mechanisms for accessing different aspects of objects. The following interfaces are defined for this category:
Bridges Between DbgEng and the Data Model
Management of Data Models and Extensibility
The Data Model Manager is the core component which manages how all extensibility occurs. It is the central repository of a set of tables which map both native types to extension points as well as synthetic constructs to extension points. In addition, it is the entity which is responsible for the boxing of objects (conversion of ordinal values or strings into IModelObject's).
The following interfaces are defined for this category:
General Data Model Manager Access
Access to the Debugger's Type System and Memory Spaces
The underlying type system and memory spaces of the debugger are exposed in detail for extensions to make use of. The following interfaces are defined for this category:
General Host (Debugger) Interfaces
Host (Debugger) Type System Interfaces
Host (Debugger) Support for Scripting
Authoring and Consuming Scripts
The Data Model also has a general notion of what a script is and how to debug one. It is entirely possible for a debugger extension to come along and define a general bridge between the data model and another dynamic language (usually a scripting environment). This set of interfaces is how that is accomplished as well as how a debugger UI can make use of such scripts.
The following interfaces are defined for this category:
General Script Interfaces
Script Debugger Interfaces
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.