Sign in Join
Wiki copytemporary

IDE Window: Ide Options - Backend Value Converter: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11# About Backend-Converters
22
33
44Backend-Converters are plugins for the debugger backend. They can be used to enhance/alter the display of specific values.
55
66As they are executed in the backend, they can fetch additional information and include this in the resulting watch data.
77
88Backend-Converters must be compiled into the Lazarus exe. They can either be included within an existing Debugger-backend, or they can be added by 3rd party packages. Currently only the LazDebuggerFp (FpDebug) supports Backend-Converters.
99
1010For a Backend-Converters to be used, it must be associated with the type-name of the watched data.
1111
1212# Configuration
1313
1414## Add / Remove
1515
1616Will add/remove entries to/from the list on top of the Window. Those entries can then be selected and configured.
1717
1818## "Enabled" Checkbox
1919
2020Each entry in the list has a checkbox.
2121
2222- If enabled, then the "Match type name" will be checked for each watch that is evaluated. Any data will be processed by the first matching Backend-Converter.
2323- If disabled, the converter can be explicitly assigned in the "Watches properties". Watches for which a Backend-Converters is assigned will still check if the type-name matches.
2424
2525For Watches that return structured data or references to other data, and the embedded data is part of the result (e.g. a field of an object), such embedded data will also be checked and converted if matching. If the outer value matches, any embedded data must be included by the Backend-Converters. In this case it is not subject to further conversion.
2626
2727## Name
2828
2929Change the name of the Backend-Converters
3030
3131## Action
3232
3333Select a registered Backend-Converters
3434
3535## Match types by name
3636
3737Each line can contain a type-name or pattern.
3838
3939The following is recognized:
4040
4141- "TFoo" exact typename (case insensitive)
4242- "*oo", "TF*", "T*o" an asterisk matches zero, one or more chars
4343- "is:TFoo" must be an object, and must inherit from TFoo. (also accepts "is:TF*")
4444
4545For the outer value of the watch, the "is:" operator will take the type of the instance. For nested values, only the declared type is tested.
4646
4747## Other ...
4848
4949Each converter may have it's own additional settings. If they have additional configuration will be shown at the bottom of the Window.
5050
5151# How/When is a converter applied to a watch
5252
5353For each watch that the debugger backend processes, it follows the steps below
5454
5555- Evaluate the watch
5656- Check settings in the watch properties
5757
5858
5959The following setting are available
6060
6161- Default:
6262
6363
6464
6565All "Enabled" converters will be considered.
6666
6767Converters from the project are first considered, the Converters from the global IDE config
6868
6969Both list will be processed from top to bottom, until the first match is found.
7070
7171- No Converter:
7272
7373
7474
7575The watch will not be processed
7676
7777- \<NAME\>:
7878
7979
8080
8181Only the selected converter \<NAME\> will be considered (if it matches in the below)
8282
8383The converter will be considered even if it is not "Enabled"
8484
8585- For each converter from the first step, the "Match types by name" settings are checked
8686
8787:* The type-name of evaluated result will be checked
8888
8989
9090
9191If the type-name matches, the converter will be called.
9292
9393Even if that converter then fails or rejects:\
9494No further converter will be considered. No checks on nested (array/struct) values will be performed.
9595
9696# Per Project settings
9797
9898Additional settings can be made on a per Project basis: [[IDE Window: Project Options - Value Converter]]
9999
100100# Example Backend-Converters
101101
102102Those only work with LazDebuggerFp.
103103
104104## "Convert variant to value type"
105105
106106Convert variants to their value.
107107
108108Depending on Dwarf versions variants either show as record with all the available fields, or as record with 2 values "(vtype: 1; xxx: ...)".
109109
110110- The converter simply shows the value. E.g. just the integer, or string.
111111- The converter can not add typeinfo. E.g. enum are stored as integer, and as integer they are displayed
112112- The converter does not support custom variant types, for that use CallSysVarToLStr. (Unlike CallSysVarToLStr, this converter does not call any functions in the debuggee)
113113
114114## CallSysVarToLStr
115115
116116This only works for variant data (including custom variants).
117117
118118It will invoke the function "VarToLStr()" (from "TVariantManager"). The function will be invoked in the debugged process. The Backend-Converter returns the textual representation given by "VarToLStr()".
119119
120120## JsonForDebug
121121
122122Calls a user defined function (default "JSonForDebug") in the debugged process.
123123
124124The function must support exactly the following parameters.
125125
126-` procedure JsonForDebug(`\
127-`   const Value;   // or  :Pointer;  `\
128-`   var TypeName: AnsiString;`\
129-`   out JsonResultText: AnsiString`\
130-` );`
126+``` pascal
127+ procedure JsonForDebug(
128+ const Value; // or :Pointer;
129+ var TypeName: AnsiString;
130+ out JsonResultText: AnsiString
131+ );
132+```
131133
132134The result text will be returned as watch representation. If it is valid JSon, the IDE will allow to expand/unfold entries.
133135
134136If a JSON object has a key matching the "Key for Address", it will be read for the Address column in the watches window. If a JSON object has a key matching the "Key for Typename", it will be read for the type-name column in the inspect window.
135137
136138---
137139*From the Free Pascal wiki, page "IDE Window: Ide Options - Backend Value Converter", as it stood on 2023-06-11 after a change by Martin, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
138140Category: Debugging

Back to history