Skip to content

Commit 9c19188

Browse files
committed
Fix LLDB support
Explicitly define types of containers for Boost.Geometry types Get raw types also for members
1 parent 61a5e46 commit 9c19188

File tree

4 files changed

+50
-18
lines changed

4 files changed

+50
-18
lines changed

resources/boost.json

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@
190190
"type": "boost::geometry::model::linestring<.+>",
191191
"kind": "linestring",
192192
"points": {
193-
"container": { "name": "*($T1<$T0,$T2<$T0>>*)(&$this)" }
193+
"container": {
194+
"name": "$this",
195+
"type": "$T1<$T0,$T2<$T0>>"
196+
}
194197
}
195198
},
196199
{
@@ -206,7 +209,10 @@
206209
"kind": "ring",
207210
"cw": "$T1",
208211
"points": {
209-
"container": { "name": "*($T3<$T0,$T4<$T0>>*)(&$this)" }
212+
"container": {
213+
"name": "$this",
214+
"type": "$T3<$T0,$T4<$T0>>"
215+
}
210216
}
211217
},
212218
{
@@ -227,21 +233,30 @@
227233
"type": "boost::geometry::model::multi_point<.+>",
228234
"kind": "multipoint",
229235
"points": {
230-
"container": { "name": "*($T1<$T0,$T2<$T0>>*)(&$this)" }
236+
"container": {
237+
"name": "$this",
238+
"type": "$T1<$T0,$T2<$T0>>"
239+
}
231240
}
232241
},
233242
{
234243
"type": "boost::geometry::model::multi_linestring<.+>",
235244
"kind": "multilinestring",
236245
"linestrings": {
237-
"container": { "name": "*($T1<$T0,$T2<$T0>>*)(&$this)" }
246+
"container": {
247+
"name": "$this",
248+
"type": "$T1<$T0,$T2<$T0>>"
249+
}
238250
}
239251
},
240252
{
241253
"type": "boost::geometry::model::multi_polygon<.+>",
242254
"kind": "multipolygon",
243255
"polygons": {
244-
"container": { "name": "*($T1<$T0,$T2<$T0>>*)(&$this)" }
256+
"container": {
257+
"name": "$this",
258+
"type": "$T1<$T0,$T2<$T0>>"
259+
}
245260
}
246261
},
247262
{

src/debugger.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,13 @@ export class Debugger {
306306
return type;
307307
}
308308

309+
// NOTE: In LLDB members of cv types are also cv while in GDB they are not
310+
// This function can be used to consistently get types without modifiers
311+
async getRawType(expression: string): Promise<string | undefined> {
312+
const type = await this.getType(expression);
313+
return type !== undefined ? this.rawType(type) : undefined;
314+
}
315+
309316
async getValue(expression: string): Promise<string | undefined> {
310317
const result = await this.evaluate(expression);
311318
if (this._isPythonError(result?.type))
@@ -331,6 +338,16 @@ export class Debugger {
331338
}
332339
return type !== undefined && value !== undefined ? [value, type] : undefined;
333340
}
341+
342+
// NOTE: In LLDB members of cv types are also cv while in GDB they are not
343+
// This function can be used to consistently get types without modifiers
344+
async getValueAndRawType(expression: string): Promise<[string, string] | undefined> {
345+
const result = await this.getValueAndType(expression);
346+
if (result !== undefined) {
347+
result[1] = this.rawType(result[1]);
348+
}
349+
return result;
350+
}
334351

335352
async evaluate(expression: string, context: string | undefined = undefined) {
336353
if (this.sessionInfo === undefined)

src/extension.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ import * as vscode from 'vscode';
99

1010

1111
async function handleVariable(dbg: Debugger, gwVariable: GraphicalWatchVariable): Promise<[string, draw.PlotlyData]> {
12-
const type = await dbg.getType(gwVariable.name);
13-
if (type !== undefined) {
14-
const rawType = dbg.rawType(type);
15-
let variable: load.Variable = new load.Variable(gwVariable.name, rawType);
12+
const origType = await dbg.getType(gwVariable.name);
13+
if (origType !== undefined) {
14+
const type = dbg.rawType(origType);
15+
let variable: load.Variable = new load.Variable(gwVariable.name, type);
1616
let loader = await load.getLoader(dbg, variable);
1717
if (loader !== undefined) {
1818
const drawable = await loader.load(dbg, variable);
1919
if (drawable !== undefined) {
20-
return [type, drawable.toPlotly(gwVariable.color)];
20+
return [origType, drawable.toPlotly(gwVariable.color)];
2121
}
2222
}
23-
return ['unknown (' + type + ')', draw.PlotlyData.empty(gwVariable.color)];
23+
return ['unknown (' + origType + ')', draw.PlotlyData.empty(gwVariable.color)];
2424
}
2525
return ['not available', draw.PlotlyData.empty(gwVariable.color)];
2626
}

src/loader.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ async function evaluateExpression(dbg: debug.Debugger, variable: Variable, expre
185185
// Technically if expressionType is passed we don't have to evaluate the expression because
186186
// the type is known. But right now this function is used to check if a type contains members
187187
// defined in json file. So get the value anyway and after that alter the type.
188-
let vt = await dbg.getValueAndType(str);
188+
let vt = await dbg.getValueAndRawType(str);
189189
if (vt === undefined)
190190
return undefined;
191191
if (expressionType !== undefined) {
@@ -223,7 +223,7 @@ async function getValueOrEvaluateExpression(dbg: debug.Debugger, variable: Varia
223223
const val = getValueFromExpressionStr(dbg, str);
224224
if (val !== undefined)
225225
return val;
226-
const vt = await dbg.getValueAndType(str);
226+
const vt = await dbg.getValueAndRawType(str);
227227
return vt !== undefined ? new EvaluatedExpression(expr, str, vt[1]) : undefined;
228228
}
229229

@@ -398,7 +398,7 @@ export class Values extends ContainerLoader {
398398
const elStr = this._container.element(variable);
399399
if (elStr === undefined)
400400
return undefined;
401-
const elType = await dbg.getType(elStr);
401+
const elType = await dbg.getRawType(elStr);
402402
if (elType === undefined)
403403
return undefined;
404404
let ys: number[] = [];
@@ -422,7 +422,7 @@ export class Points extends ContainerLoader {
422422
const elStr = this._container.element(variable);
423423
if (elStr === undefined)
424424
return undefined;
425-
const elType = await dbg.getType(elStr);
425+
const elType = await dbg.getRawType(elStr);
426426
if (elType === undefined)
427427
return undefined;
428428
let xs: number[] = [];
@@ -451,7 +451,7 @@ export class Geometries extends ContainerLoader {
451451
const elStr = this._container.element(variable);
452452
if (elStr === undefined)
453453
return undefined;
454-
const elType = await dbg.getType(elStr);
454+
const elType = await dbg.getRawType(elStr);
455455
if (elType === undefined)
456456
return undefined;
457457
let drawables: draw.Drawable[] = [];
@@ -769,7 +769,7 @@ export class GeometryCollection extends ContainerLoader {
769769
async load(dbg: debug.Debugger, variable: Variable): Promise<draw.Drawable | undefined> {
770770
let drawables: draw.Drawable[] = [];
771771
for await (let elStr of this._container.elements(dbg, variable)) {
772-
const elType = await dbg.getType(elStr);
772+
const elType = await dbg.getRawType(elStr);
773773
if (elType === undefined)
774774
return undefined;
775775
const v = new Variable(elStr, elType);
@@ -1221,7 +1221,7 @@ async function getElements(dbg: debug.Debugger,
12211221
elemKindPred: KindPredicate): Promise<Loader | undefined> {
12221222
const elemStr = container.element(variable);
12231223
if (elemStr !== undefined) {
1224-
const elemType = await dbg.getType(elemStr);
1224+
const elemType = await dbg.getRawType(elemStr);
12251225
if (elemType !== undefined) {
12261226
const elemVar = new Variable(elemStr, elemType);
12271227
const elemLoad = await getLoader(dbg, elemVar, elemKindPred);

0 commit comments

Comments
 (0)