Skip to content

Commit 58b3775

Browse files
committed
updating test debug client to support memory events and memory references
1 parent 09da273 commit 58b3775

3 files changed

Lines changed: 20 additions & 31 deletions

File tree

src/gdb/GDBDebugSessionBase.ts

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,11 +2671,19 @@ export abstract class GDBDebugSessionBase extends LoggingDebugSession {
26712671
})
26722672
).value
26732673
: varobj.value;
2674+
const variablesReference =
2675+
parseInt(varobj.numchild, 10) > 0
2676+
? this.variableHandles.create({
2677+
type: 'object',
2678+
frameHandle,
2679+
varobjName: varobj.varname,
2680+
})
2681+
: 0;
2682+
let memoryReferenceResult:
2683+
| MIGDBDataEvaluateExpressionResponse
2684+
| undefined;
2685+
let hasMemoryReference = false;
26742686
if (this.supportsMemoryReferences) {
2675-
let memoryReferenceResult:
2676-
| MIGDBDataEvaluateExpressionResponse
2677-
| undefined;
2678-
let hasMemoryReference = false;
26792687
try {
26802688
memoryReferenceResult =
26812689
await mi.sendDataEvaluateExpression(
@@ -2691,36 +2699,15 @@ export abstract class GDBDebugSessionBase extends LoggingDebugSession {
26912699
} catch (err) {
26922700
hasMemoryReference = false;
26932701
}
2694-
const variablesReference =
2695-
parseInt(varobj.numchild, 10) > 0
2696-
? this.variableHandles.create({
2697-
type: 'object',
2698-
frameHandle,
2699-
varobjName: varobj.varname,
2700-
})
2701-
: 0;
2702-
response.body = {
2703-
result,
2704-
type: varobj.type,
2705-
variablesReference,
2706-
memoryReference:
2707-
hasMemoryReference && memoryReferenceResult
2708-
? memoryReferenceResult.value
2709-
: undefined,
2710-
};
27112702
}
2712-
const variablesReference =
2713-
parseInt(varobj.numchild, 10) > 0
2714-
? this.variableHandles.create({
2715-
type: 'object',
2716-
frameHandle,
2717-
varobjName: varobj.varname,
2718-
})
2719-
: 0;
27202703
response.body = {
27212704
result,
27222705
type: varobj.type,
27232706
variablesReference,
2707+
memoryReference:
2708+
hasMemoryReference && memoryReferenceResult
2709+
? memoryReferenceResult.value
2710+
: undefined,
27242711
};
27252712
}
27262713

src/integration-tests/debugClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ export class CdtDebugClient extends DebugClient {
141141
if (!args) {
142142
args = {
143143
supportsRunInTerminalRequest: true,
144+
supportsMemoryEvent: true,
145+
supportsMemoryReferences: true,
144146
adapterID: this['_debugType'],
145147
linesStartAt1: true,
146148
columnsStartAt1: true,

src/integration-tests/evaluate.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,10 @@ describe('evaluate request global variables', function () {
539539
expression: 'global_int',
540540
frameId: scope.frame.id,
541541
});
542-
expect(watchRes.body.memoryReference).to.be.a('string');
542+
expect(watchRes.body.memoryReference).to.not.be.undefined;
543543
});
544544

545-
it('response for variables should include memory reference if the expression does not have an lvalue', async function () {
545+
it('should not include memory reference if the expression does not have an lvalue', async function () {
546546
const watchRes = await dc.evaluateRequest({
547547
context: 'watch',
548548
expression: 'global_int + 1',

0 commit comments

Comments
 (0)