MCPcopy Create free account
hub / github.com/Marus/cortex-debug / evaluateRequest

Method evaluateRequest

src/gdb.ts:3105–3264  ·  view source on GitHub ↗
(r: DebugProtocol.EvaluateResponse, a: DebugProtocol.EvaluateArguments)

Source from the content-addressed store, hash-verified

3103
3104 private evaluateQ = new RequestQueue<DebugProtocol.EvaluateResponse, DebugProtocol.EvaluateArguments>();
3105 protected evaluateRequest(r: DebugProtocol.EvaluateResponse, a: DebugProtocol.EvaluateArguments): Promise<void> {
3106 a.context = a.context || 'hover'; // Not sure who is calling with an undefined context
3107 if (a.context !== 'repl') {
3108 if (this.isBusy()) {
3109 this.busyError(r, a);
3110 return Promise.resolve();
3111 }
3112 }
3113
3114 const doit = (response: DebugProtocol.EvaluateResponse, args: DebugProtocol.EvaluateArguments) => {
3115 return new Promise<void>(async (resolve) => {
3116 if (this.isBusy() && (a.context !== 'repl')) {
3117 this.busyError(response, args);
3118 resolve();
3119 return;
3120 }
3121 const createVariable = (arg, options?) => {
3122 if (options) {
3123 return this.variableHandles.create(new ExtendedVariable(arg, options));
3124 }
3125 else {
3126 return this.variableHandles.create(arg);
3127 }
3128 };
3129
3130 const findOrCreateVariable = (varObj: VariableObject): number => {
3131 let id: number;
3132 if (this.variableHandlesReverse.hasOwnProperty(varObj.name)) {
3133 id = this.variableHandlesReverse[varObj.name];
3134 }
3135 else {
3136 id = createVariable(varObj);
3137 this.variableHandlesReverse[varObj.name] = id;
3138 }
3139 return varObj.isCompound() ? id : 0;
3140 };
3141
3142 // Spec says if 'frameId' is specified, evaluate in the scope specified or in the global scope. Well,
3143 // we don't have a way to specify global scope ... use floating variable.
3144 let threadId = this.stoppedThreadId || 1;
3145 let frameId = 0;
3146 if (args.frameId !== undefined) { // Should always be valid
3147 [threadId, frameId] = decodeReference(args.frameId);
3148 }
3149
3150 if (args.context !== 'repl') {
3151 try {
3152 const exp = args.expression;
3153 const hasher = crypto.createHash('sha256');
3154 hasher.update(exp);
3155 if (args.frameId !== undefined) {
3156 hasher.update(args.frameId.toString(16));
3157 }
3158 const exprName = hasher.digest('hex');
3159 const varObjName = `${args.context}_${exprName}`;
3160 let varObj: VariableObject;
3161 let outOfScope = false;
3162 try {

Callers 2

customRequestMethod · 0.45
doitMethod · 0.45

Calls 3

isBusyMethod · 0.95
busyErrorMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected