-
Notifications
You must be signed in to change notification settings - Fork 285
Custom Data Formatters
vadimcn edited this page Jun 26, 2021
·
4 revisions
So, you want to create custom data formatters for your favorite library or a programming language?
Here's how I would recommend going about it:
- Familiarize yourself with the options LLDB provides.
- Decide what level of customization your data types require. For many types, declarative type summary strings and type filters are quite adequate.
If this fits you needs:- Create a file containing LLDB commands that create your customizations.
- Load it via
command source <file path>command, which you can add toinitCommandsproperty in launch.json, or tolldb.launch.initCommandsconfiguration property in workspace or global settings.
For example,"initCommands": ["command source '${workspaceFolder}/my_type_formatters'"]. - Examples of declarative type summaries: [1], [2].
- Otherwise, you'll need to do some Python scripting:
- Create a new Python module containing:
- Functions for scripted summaries,
- Classes implementing the synthetic children provider interface,
-
__lldb_init_module(debugger, internal_dict)function, that will be called by LLDB upon importing the module.
Here, you will need to:- Create a type category object, which serves as a container of individual type formatters and allows turning them on or off all at the same time.
- Register scripted type summaries and synthetic providers.
- Load it via
command script import <file path>(see above).
- Resources:
-
LLDB Python API. Specifically you might be interested in these classes:
- SBValue, which is how LLDB represents variables and expression evaluation results.
- SBType, which represents types in your program.
- SBTypeNameSpecifier, which allows selecting which types a particular summary or synthetic apply to.
- Examples of type summaries.
- Examples of type synthetics,.
-
LLDB Python API. Specifically you might be interested in these classes:
- Create a new Python module containing: