Skip to content

Commit bc604e0

Browse files
authored
Adding support to EvaluationOptions from dap. (#1323)
* Adding support to EvaluationOptions from dap, as discussed in this issue: #1315 * Fix tests * Pushing generated file after merge.
1 parent 86a9efa commit bc604e0

File tree

10 files changed

+327
-8
lines changed

10 files changed

+327
-8
lines changed

src/adapter/debugAdapter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ export class DebugAdapter implements IDisposable {
264264
supportsBreakpointLocationsRequest: true,
265265
supportsClipboardContext: true,
266266
supportsExceptionFilterOptions: true,
267+
supportsEvaluationOptions: extended ? true : false,
267268
supportsDebuggerProperties: extended ? true : false,
268269
supportsSetSymbolOptions: extended ? true : false,
269270
//supportsDataBreakpoints: false,

src/adapter/stackTrace.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,19 @@ export class StackTrace {
101101
this._lastFrameThread = thread;
102102
}
103103

104-
async loadFrames(limit: number): Promise<FrameElement[]> {
104+
async loadFrames(limit: number, noFuncEval?: boolean): Promise<FrameElement[]> {
105105
while (this.frames.length < limit && this._asyncStackTraceId) {
106106
if (this._asyncStackTraceId.debuggerId)
107107
this._lastFrameThread = Thread.threadForDebuggerId(this._asyncStackTraceId.debuggerId);
108108
if (!this._lastFrameThread) {
109109
this._asyncStackTraceId = undefined;
110110
break;
111111
}
112+
if (noFuncEval)
113+
this._lastFrameThread
114+
.cdp()
115+
.DotnetDebugger.setEvaluationOptions({ options: { noFuncEval }, type: 'stackFrame' });
116+
112117
const response = await this._lastFrameThread
113118
.cdp()
114119
.Debugger.getStackTrace({ stackTraceId: this._asyncStackTraceId });
@@ -176,10 +181,10 @@ export class StackTrace {
176181
return (await Promise.all(promises)).join('\n') + '\n';
177182
}
178183

179-
async toDap(params: Dap.StackTraceParams): Promise<Dap.StackTraceResult> {
184+
async toDap(params: Dap.StackTraceParamsExtended): Promise<Dap.StackTraceResult> {
180185
const from = params.startFrame || 0;
181186
let to = (params.levels || 50) + from;
182-
const frames = await this.loadFrames(to);
187+
const frames = await this.loadFrames(to, params.noFuncEval);
183188
to = Math.min(frames.length, params.levels ? to : frames.length);
184189

185190
const result: Promise<Dap.StackFrame>[] = [];

src/adapter/threads.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ export class Thread implements IVariableStoreLocationProvider {
436436
.map(label => ({ label, start: 0, length: params.text.length }));
437437
}
438438

439-
async evaluate(args: Dap.EvaluateParams): Promise<Dap.EvaluateResult> {
439+
async evaluate(args: Dap.EvaluateParamsExtended): Promise<Dap.EvaluateResult> {
440440
let callFrameId: Cdp.Debugger.CallFrameId | undefined;
441441
let stackFrame: StackFrame | undefined;
442442
if (args.frameId !== undefined) {
@@ -495,6 +495,12 @@ export class Thread implements IVariableStoreLocationProvider {
495495
params.expression += getReplSourceSuffix();
496496
}
497497

498+
if (args.evaluationOptions)
499+
this.cdp().DotnetDebugger.setEvaluationOptions({
500+
options: args.evaluationOptions,
501+
type: 'evaluation',
502+
});
503+
498504
const responsePromise = this.evaluator.evaluate(
499505
callFrameId
500506
? { ...params, callFrameId }

src/adapter/variableStore.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@ class VariableContext {
271271
/**
272272
* Creates Variables for each property on the RemoteObject.
273273
*/
274-
public async createObjectPropertyVars(object: Cdp.Runtime.RemoteObject): Promise<Variable[]> {
274+
public async createObjectPropertyVars(
275+
object: Cdp.Runtime.RemoteObject,
276+
evaluationOptions?: Dap.EvaluationOptions,
277+
): Promise<Variable[]> {
275278
const properties: (Promise<Variable[]> | Variable[])[] = [];
276279

277280
if (this.settings.customPropertiesGenerator) {
@@ -299,6 +302,12 @@ class VariableContext {
299302
return [];
300303
}
301304

305+
if (evaluationOptions)
306+
this.cdp.DotnetDebugger.setEvaluationOptions({
307+
options: evaluationOptions,
308+
type: 'variable',
309+
});
310+
302311
const [accessorsProperties, ownProperties, stringyProps] = await Promise.all([
303312
this.cdp.Runtime.getProperties({
304313
objectId: object.objectId,
@@ -789,8 +798,8 @@ class ObjectVariable extends Variable implements IMemoryReadable {
789798
return result.value;
790799
}
791800

792-
public override getChildren(_params: Dap.VariablesParams) {
793-
return this.context.createObjectPropertyVars(this.remoteObject);
801+
public override getChildren(_params: Dap.VariablesParamsExtended) {
802+
return this.context.createObjectPropertyVars(this.remoteObject, _params.evaluationOptions);
794803
}
795804
}
796805

src/build/dapCustom.ts

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ const dapCustom: JSONSchema4 = {
602602
supportsDebuggerProperties: {
603603
type: 'boolean',
604604
},
605+
supportsEvaluationOptions: {
606+
type: 'boolean',
607+
},
605608
supportsSetSymbolOptions: {
606609
type: 'boolean',
607610
description: 'The debug adapter supports the set symbol options request',
@@ -611,6 +614,120 @@ const dapCustom: JSONSchema4 = {
611614
],
612615
},
613616

617+
...makeRequest('evaluationOptions', 'Used by evaluate and variables.', {
618+
properties: {
619+
evaluateParams: {
620+
$ref: '#/definitions/EvaluateParamsExtended',
621+
},
622+
variablesParams: {
623+
$ref: '#/definitions/VariablesParamsExtended',
624+
},
625+
stackTraceParams: {
626+
$ref: '#/definitions/StackTraceParamsExtended',
627+
},
628+
},
629+
}),
630+
631+
EvaluationOptions: {
632+
type: 'object',
633+
description:
634+
'Options passed to expression evaluation commands ("evaluate" and "variables") to control how the evaluation occurs.',
635+
properties: {
636+
treatAsStatement: {
637+
type: 'boolean',
638+
description: 'Evaluate the expression as a statement.',
639+
},
640+
allowImplicitVars: {
641+
type: 'boolean',
642+
description: 'Allow variables to be declared as part of the expression.',
643+
},
644+
noSideEffects: {
645+
type: 'boolean',
646+
description: 'Evaluate without side effects.',
647+
},
648+
noFuncEval: {
649+
type: 'boolean',
650+
description: 'Exclude funceval during evaluation.',
651+
},
652+
noToString: {
653+
type: 'boolean',
654+
description: 'Exclude calling `ToString` during evaluation.',
655+
},
656+
forceEvaluationNow: {
657+
type: 'boolean',
658+
description: 'Evaluation should take place immediately if possible.',
659+
},
660+
forceRealFuncEval: {
661+
type: 'boolean',
662+
description: 'Exclude interpretation from evaluation methods.',
663+
},
664+
runAllThreads: {
665+
type: 'boolean',
666+
description: 'Allow all threads to run during the evaluation.',
667+
},
668+
rawStructures: {
669+
type: 'boolean',
670+
description:
671+
"The 'raw' view of objects and structions should be shown - visualization improvements should be disabled.",
672+
},
673+
filterToFavorites: {
674+
type: 'boolean',
675+
description:
676+
'Variables responses containing favorites should be filtered to only those items',
677+
},
678+
simpleDisplayString: {
679+
type: 'boolean',
680+
description:
681+
'Auto generated display strings for variables with favorites should not include field names.',
682+
},
683+
},
684+
},
685+
686+
EvaluateParamsExtended: {
687+
allOf: [
688+
{ $ref: '#/definitions/EvaluateParams' },
689+
{
690+
type: 'object',
691+
description: 'Extension of EvaluateParams',
692+
properties: {
693+
evaluationOptions: {
694+
$ref: '#/definitions/EvaluationOptions',
695+
},
696+
},
697+
},
698+
],
699+
},
700+
701+
VariablesParamsExtended: {
702+
allOf: [
703+
{ $ref: '#/definitions/VariablesParams' },
704+
{
705+
type: 'object',
706+
description: 'Extension of VariablesParams',
707+
properties: {
708+
evaluationOptions: {
709+
$ref: '#/definitions/EvaluationOptions',
710+
},
711+
},
712+
},
713+
],
714+
},
715+
716+
StackTraceParamsExtended: {
717+
allOf: [
718+
{ $ref: '#/definitions/StackTraceParams' },
719+
{
720+
type: 'object',
721+
description: 'Extension of StackTraceParams',
722+
properties: {
723+
noFuncEval: {
724+
type: 'boolean',
725+
},
726+
},
727+
},
728+
],
729+
},
730+
614731
...makeRequest('setSymbolOptions', 'Sets options for locating symbols.'),
615732

616733
SetSymbolOptionsArguments: {

src/build/wasmCustom.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export default {
1818
description:
1919
'Arguments for "setDebuggerProperty" request. Properties are determined by debugger.',
2020
},
21+
{
22+
id: 'EvaluationOptions',
23+
type: 'object',
24+
description: 'Options that will be used to evaluate or to get variables.',
25+
},
2126
{
2227
id: 'SetSymbolOptionsParams',
2328
type: 'object',
@@ -36,6 +41,20 @@ export default {
3641
},
3742
],
3843
},
44+
{
45+
name: 'setEvaluationOptions',
46+
description: 'Set options for evaluation',
47+
parameters: [
48+
{
49+
name: 'options',
50+
$ref: 'EvaluationOptions',
51+
},
52+
{
53+
name: 'type',
54+
type: 'string',
55+
},
56+
],
57+
},
3958
{
4059
name: 'setSymbolOptions',
4160
description: 'Sets options for locating symbols.',

src/cdp/api.d.ts

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9944,6 +9944,13 @@ export namespace Cdp {
99449944
params: DotnetDebugger.SetDebuggerPropertyParams,
99459945
): Promise<DotnetDebugger.SetDebuggerPropertyResult | undefined>;
99469946

9947+
/**
9948+
* Set options for evaluation
9949+
*/
9950+
setEvaluationOptions(
9951+
params: DotnetDebugger.SetEvaluationOptionsParams,
9952+
): Promise<DotnetDebugger.SetEvaluationOptionsResult | undefined>;
9953+
99479954
/**
99489955
* Sets options for locating symbols.
99499956
*/
@@ -9968,6 +9975,20 @@ export namespace Cdp {
99689975
*/
99699976
export interface SetDebuggerPropertyResult {}
99709977

9978+
/**
9979+
* Parameters of the 'DotnetDebugger.setEvaluationOptions' method.
9980+
*/
9981+
export interface SetEvaluationOptionsParams {
9982+
options: EvaluationOptions;
9983+
9984+
type: string;
9985+
}
9986+
9987+
/**
9988+
* Return value of the 'DotnetDebugger.setEvaluationOptions' method.
9989+
*/
9990+
export interface SetEvaluationOptionsResult {}
9991+
99719992
/**
99729993
* Parameters of the 'DotnetDebugger.setSymbolOptions' method.
99739994
*/
@@ -9985,6 +10006,13 @@ export namespace Cdp {
998510006
[key: string]: any;
998610007
}
998710008

10009+
/**
10010+
* Options that will be used to evaluate or to get variables.
10011+
*/
10012+
export interface EvaluationOptions {
10013+
[key: string]: any;
10014+
}
10015+
998810016
/**
998910017
* Arguments for "setSymbolOptions" request. Properties are determined by debugger.
999010018
*/
@@ -22769,7 +22797,8 @@ export namespace Cdp {
2276922797
| 'SameSiteCrossOriginNavigationNotOptIn'
2277022798
| 'ActivationNavigationParameterMismatch'
2277122799
| 'ActivatedInBackground'
22772-
| 'EmbedderHostDisallowed';
22800+
| 'EmbedderHostDisallowed'
22801+
| 'ActivationNavigationDestroyedBeforeSuccess';
2277322802
}
2277422803

2277522804
/**
@@ -23777,6 +23806,16 @@ export namespace Cdp {
2377723806
*/
2377823807
throwOnSideEffect?: boolean;
2377923808

23809+
/**
23810+
* An alternative way to specify the execution context to call function on.
23811+
* Compared to contextId that may be reused across processes, this is guaranteed to be
23812+
* system-unique, so it can be used to prevent accidental function call
23813+
* in context different than intended (e.g. as a result of navigation across process
23814+
* boundaries).
23815+
* This is mutually exclusive with `executionContextId`.
23816+
*/
23817+
uniqueContextId?: string;
23818+
2378023819
/**
2378123820
* Whether the result should contain `webDriverValue`, serialized according to
2378223821
* https://w3c.github.io/webdriver-bidi. This is mutually exclusive with `returnByValue`, but
@@ -26052,6 +26091,13 @@ export namespace Cdp {
2605226091
params: Storage.ClearSharedStorageEntriesParams,
2605326092
): Promise<Storage.ClearSharedStorageEntriesResult | undefined>;
2605426093

26094+
/**
26095+
* Resets the budget for `ownerOrigin` by clearing all budget withdrawals.
26096+
*/
26097+
resetSharedStorageBudget(
26098+
params: Storage.ResetSharedStorageBudgetParams,
26099+
): Promise<Storage.ResetSharedStorageBudgetResult | undefined>;
26100+
2605526101
/**
2605626102
* Enables/disables issuing of sharedStorageAccessed events.
2605726103
*/
@@ -26536,6 +26582,18 @@ export namespace Cdp {
2653626582
*/
2653726583
export interface ClearSharedStorageEntriesResult {}
2653826584

26585+
/**
26586+
* Parameters of the 'Storage.resetSharedStorageBudget' method.
26587+
*/
26588+
export interface ResetSharedStorageBudgetParams {
26589+
ownerOrigin: string;
26590+
}
26591+
26592+
/**
26593+
* Return value of the 'Storage.resetSharedStorageBudget' method.
26594+
*/
26595+
export interface ResetSharedStorageBudgetResult {}
26596+
2653926597
/**
2654026598
* Parameters of the 'Storage.setSharedStorageTracking' method.
2654126599
*/

0 commit comments

Comments
 (0)