Skip to content

Commit c686a5d

Browse files
committed
chore: adapt value struct formatters for pointer versions
1 parent 071883e commit c686a5d

File tree

1 file changed

+41
-16
lines changed

1 file changed

+41
-16
lines changed

src/variables.ts

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ async function formatExprMember(v: Variable, member: string) {
880880
}
881881
}
882882

883-
function getNodeVariableDescriptionFormatter(nodetag: string) {
883+
function getFormatterForNodeVariable(nodetag: string) {
884884
let member;
885885
switch (nodetag) {
886886
case 'TargetEntry':
@@ -928,6 +928,41 @@ function getNodeVariableDescriptionFormatter(nodetag: string) {
928928
}
929929
}
930930

931+
function getFormatterForValueStruct(effectiveType: string, debugVariable: dap.DebugVariable,
932+
context: ExecContext) {
933+
if (effectiveType === 'bitmapword' || effectiveType === 'bits8') {
934+
/* Show bitmapword as bitmask, not integer */
935+
return formatBitmask;
936+
} else if ( effectiveType === 'XLogRecPtr'
937+
&& shouldFormatXLogRecPtr(debugVariable, context)) {
938+
return formatXLogRecPtr;
939+
} else if (effectiveType === 'RelFileLocator') {
940+
return formatRelFileLocator;
941+
} else if (effectiveType === 'RelFileLocatorBackend') {
942+
return formatRelFileLocatorBackend;
943+
} else if (effectiveType === 'NameData') {
944+
return formatNameData;
945+
}
946+
}
947+
948+
function getFormatterForPointerType(effectiveType: string,) {
949+
if (effectiveType === 'bitmapword *' || effectiveType === 'bits8 *') {
950+
return formatBitmask;
951+
} else if (effectiveType === 'RelFileLocator *') {
952+
return formatRelFileLocator;
953+
} else if (effectiveType === 'RelFileLocatorBackend *') {
954+
return formatRelFileLocatorBackend;
955+
} else if (effectiveType === 'NameData *') {
956+
return formatNameData;
957+
}
958+
959+
/*
960+
* These types require only reading members, but others
961+
* use special handling, i.e. XLogRecPtr calls 'pg_lsn_out'
962+
* which requires getting actual scalar value.
963+
*/
964+
}
965+
931966
function isValidMemoryContextTag(tag: string) {
932967
/*
933968
* Different versions has different algorithms (tags)
@@ -1200,20 +1235,8 @@ export abstract class Variable {
12001235
}
12011236
}
12021237
}
1203-
1204-
if (effectiveType === 'bitmapword' || effectiveType === 'bits8') {
1205-
/* Show bitmapword as bitmask, not integer */
1206-
args.formatter = formatBitmask;
1207-
} else if ( effectiveType === 'XLogRecPtr'
1208-
&& shouldFormatXLogRecPtr(debugVariable, context)) {
1209-
args.formatter = formatXLogRecPtr;
1210-
} else if (effectiveType === 'RelFileLocator') {
1211-
args.formatter = formatRelFileLocator;
1212-
} else if (effectiveType === 'RelFileLocatorBackend') {
1213-
args.formatter = formatRelFileLocatorBackend;
1214-
} else if (effectiveType === 'NameData') {
1215-
args.formatter = formatNameData;
1216-
}
1238+
1239+
args.formatter = getFormatterForValueStruct(effectiveType, debugVariable, context);
12171240

12181241
return new RealVariable(args);
12191242
}
@@ -1311,6 +1334,8 @@ export abstract class Variable {
13111334
return new SimplehashMember(entry, args);
13121335
}
13131336
}
1337+
1338+
args.formatter = getFormatterForPointerType(effectiveType);
13141339

13151340
/* At the end - it is simple variable */
13161341
return new RealVariable(args);
@@ -2152,7 +2177,7 @@ export class NodeVariable extends RealVariable {
21522177
*
21532178
* So, this is the only suitable place for such logic.
21542179
*/
2155-
args.formatter = getNodeVariableDescriptionFormatter(realTag);
2180+
args.formatter = getFormatterForNodeVariable(realTag);
21562181

21572182
/* Expressions with it's representation */
21582183
if (context.nodeVarRegistry.exprs.has(realTag)) {

0 commit comments

Comments
 (0)