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

Method setVariableRequest

src/gdb.ts:1872–1907  ·  view source on GitHub ↗
(response: DebugProtocol.SetVariableResponse, args: DebugProtocol.SetVariableArguments)

Source from the content-addressed store, hash-verified

1870 }
1871
1872 protected async setVariableRequest(response: DebugProtocol.SetVariableResponse, args: DebugProtocol.SetVariableArguments): Promise<void> {
1873 try {
1874 let name = args.name;
1875 let threadId = -1;
1876 let frameId = -1;
1877 const varRef = args.variablesReference;
1878 const isReg = (varRef >= HandleRegions.REG_HANDLE_START && varRef < HandleRegions.REG_HANDLE_FINISH);
1879 const globOrStatic = !isReg && this.getFloatingVariable(varRef, name);
1880 if (isReg) {
1881 const varObj = await this.miDebugger.varCreate(varRef, '$' + name, '-', '*');
1882 name = varObj.name;
1883 [threadId, frameId] = decodeReference(varRef);
1884 } else if (globOrStatic) {
1885 name = globOrStatic.name;
1886 } else if (varRef >= HandleRegions.VAR_HANDLES_START) {
1887 const parent = this.variableHandles.get(args.variablesReference) as VariableObject;
1888 const fullName = parent.children[name];
1889 name = fullName ? fullName : `${parent.name}.${name}`;
1890 } else if (varRef >= HandleRegions.STACK_HANDLES_START && varRef < HandleRegions.STACK_HANDLES_FINISH) {
1891 const tryName = this.createStackVarName(name, varRef);
1892 if (this.variableHandlesReverse.hasOwnProperty(tryName)) {
1893 name = tryName;
1894 }
1895 [threadId, frameId] = decodeReference(varRef);
1896 }
1897 const res = await this.miDebugger.varAssign(name, args.value, threadId, frameId);
1898 // TODO: Need to check for errors
1899 response.body = {
1900 value: res.result('value')
1901 };
1902 this.sendResponse(response);
1903 }
1904 catch (err) {
1905 this.sendErrorResponse(response, 11, `Could not set variable: ${err}`);
1906 }
1907 }
1908
1909 // These should really by multiple pairs that are unique so you cannot mix up
1910 // the response and args

Callers

nothing calls this directly

Calls 6

getFloatingVariableMethod · 0.95
createStackVarNameMethod · 0.95
decodeReferenceFunction · 0.85
varCreateMethod · 0.80
varAssignMethod · 0.80
resultMethod · 0.80

Tested by

no test coverage detected