Skip to content

Commit 3d2db5c

Browse files
committed
feat: generalize config file records for HTAB and List ptr custom
Now they are in same format as internal represenatation: type, parent, member - no specialization for member or variable. Compatibility with previous format is saved, but schema.json changed to new version without syntax help. This is required to more convenient updating of configuration file in callbacks (for now this is single update after new NodeTags found).
1 parent faeef98 commit 3d2db5c

File tree

8 files changed

+712
-645
lines changed

8 files changed

+712
-645
lines changed

docs/config_file.md

Lines changed: 68 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,13 @@ This information stored in `customListTypes` member. This is array of objects:
191191
"customListTypes": [
192192
{
193193
"type": "MyCustomType *",
194-
"member": ["ParentStruct", "parent_member"]
194+
"parent": "ParentStruct",
195+
"member": "parent_member"
195196
},
196197
{
197198
"type": "MyCustomType *",
198-
"variable": ["ParentFunction", "variable_name"]
199+
"parent": "ParentFunction",
200+
"member": "variable_name"
199201
}
200202
]
201203
}
@@ -204,24 +206,23 @@ This information stored in `customListTypes` member. This is array of objects:
204206
Each object contain:
205207

206208
- `type` - fully-qualified type name (that is `struct` or `pointer` should be included) to which pointer will be casted.
207-
- `member` - pair of struct name and member of this struct. Definition looks like this:
208-
209-
```c
210-
typedef struct ParentStruct
211-
{
212-
List *parent_member;
213-
} ParentStruct;
214-
```
215-
216-
- `variable` - pair of function name and variable inside it. Definition looks like this:
217-
218-
```c
219-
void
220-
ParentFunction()
221-
{
222-
List *variable_name;
223-
}
224-
```
209+
- `parent` - name of struct or function (parent entity) containing this member or variable.
210+
- `member` - name of member or variable that contains `List *` value.
211+
212+
As you can mention this configuration is generalized, because it's clear from context how to handle `parent`. Example above is for following code:
213+
214+
```c
215+
typedef struct ParentStruct
216+
{
217+
List *parent_member;
218+
} ParentStruct;
219+
220+
void
221+
ParentFunction()
222+
{
223+
List *variable_name;
224+
}
225+
```
225226

226227
With this 2 strategies extension detects `List`s with custom types.
227228

@@ -237,11 +238,13 @@ This information stored in `htab` member. This is an array of objects similar to
237238
"htab": [
238239
{
239240
"type": "SampleType *",
240-
"member": ["ParentStruct", "parent_member"]
241+
"parent": "ParentStruct",
242+
"member": "parent_member"
241243
},
242244
{
243245
"type": "SampleType *",
244-
"variable": ["ParentFunction", "variable_name"]
246+
"parent": "ParentFunction",
247+
"member": "variable_name"
245248
}
246249
]
247250
}
@@ -250,23 +253,24 @@ This information stored in `htab` member. This is an array of objects similar to
250253
Each object contain:
251254

252255
- `type` - fully qualified type name of entry in `HTAB`
253-
- `member` - array of struct name and member inside this struct with `HTAB *` type. Definition looks like this:
256+
- `parent` - name of struct or function (parent entity) containing this member or variable.
257+
- `member` - name of member or variable that contains `List *` value.
254258

255-
```c
256-
typedef struct ParentStruct
257-
{
258-
HTAB *parent_member;
259-
} ParentStruct;
260-
```
259+
> You can notice that schema is the same as for custom `List *` type.
261260
262-
- `variable` - array of function name and variable inside this function with `HTAB *` type. Definition looks like this
261+
Example aboves is for following code:
263262

264-
```c
265-
void ParentFunction()
266-
{
267-
HTAB *variable_name;
268-
}
269-
```
263+
```c
264+
typedef struct ParentStruct
265+
{
266+
HTAB *parent_member;
267+
}
268+
269+
void ParentFunction()
270+
{
271+
HTAB *variable_name;
272+
}
273+
```
270274

271275
Also, there is support for `simplehash.c` hash tables ("simplehash" further). They are code generated using macros, so for each specific hash table there are functions and structures defined.
272276
Several builtin simplehashes exists and using configuration file you can add your own.
@@ -323,3 +327,31 @@ Fields:
323327
- `member` - name of the member with enum type (`type->member`)
324328
- `flags` - array of enum value definitions: MACRO VALUE + NUMERIC VALUE
325329
- `fields` - array of inner fields: human readable name of field + MACRO MASK for member + numeric value of mask
330+
331+
Example above is for following code:
332+
333+
```c
334+
#define EM_FIRST 0x01
335+
#define EM_SECOND 0x02
336+
#define EM_THIRD 0x04
337+
338+
#define EM_FIELD_MASK 0xF
339+
340+
typedef struct ParentType
341+
{
342+
int enum_member;
343+
}
344+
345+
void function()
346+
{
347+
ParentType *value;
348+
if (value->enum_member & EM_FIRST) {
349+
/* ... */
350+
}
351+
352+
int innerField = value->enum_member & EM_FIELD_MASK;
353+
if (innerField == 4) {
354+
/* ... */
355+
}
356+
}
357+
```

docs/pg_variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ While debug session there is `Pg variables` view available in debug view contain
1010

1111
It contains all variables that available in default `variables` view, but
1212
stored variables are processed by extension.
13-
Description of processing methods are [below](#type-investigation).
13+
Description of processing methods are [below](#type-exploring).
1414

1515
This view refreshed after each step, but you can force refresh it using
1616
refresh button in right upper corner.

properties.schema.json

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,17 @@
7979
"pattern": "\\*$",
8080
"description": "Type to which 'ListCell's will be casted. Must be pointer."
8181
},
82-
"member": {
83-
"type": "array",
84-
"minItems": 2,
85-
"maxItems": 2,
86-
"description": "Pair of parent struct name and member name inside this struct, identifying this List*"
82+
"parent": {
83+
"type": "string",
84+
"description": "Name of struct or function which this 'List *' belongs to. If this is a member then name of structure, otherwise if this is variable in function, then enter function name."
8785
},
88-
"variable": {
89-
"type": "array",
90-
"minItems": 2,
91-
"maxItems": 2,
92-
"description": "Pair of function name and variable name inside this function, identifying this List*"
86+
"member": {
87+
"type": "string",
88+
"description": "Name of member of variable which contains this 'List *'."
9389
}
9490
},
9591
"required": [
96-
"type"
92+
"type", "parent", "member"
9793
]
9894
},
9995
"htab": {
@@ -103,23 +99,19 @@
10399
"type": {
104100
"type": "string",
105101
"pattern": "\\*$",
106-
"description": "Type of entry in Hash Table. Must be pointer."
102+
"description": "Type of entry in Hash Table to which entry will be casted. Must be pointer."
107103
},
108-
"member": {
109-
"type": "array",
110-
"minItems": 2,
111-
"maxItems": 2,
112-
"description": "Pair of parent struct name and member name inside this struct, identifying this HTAB*"
104+
"parent": {
105+
"type": "string",
106+
"description": "Name of struct or function which this 'HTAB *' belongs to. If this is a member then name of structure, otherwise if this is variable in function, then enter function name."
113107
},
114-
"variable": {
115-
"type": "array",
116-
"minItems": 2,
117-
"maxItems": 2,
118-
"description": "Pair of function name and variable inside this function, identifying this HTAB*"
108+
"member": {
109+
"type": "string",
110+
"description": "Name of member of variable which contains this 'HTAB *'"
119111
}
120112
},
121113
"required": [
122-
"type"
114+
"type", "parent", "member"
123115
]
124116
},
125117
"simplehash": {

0 commit comments

Comments
 (0)