forked from eclipse-cdt-cloud/cdt-gdb-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change behavior of evaluate request handling
As discussed in eclipse-cdt-cloud#47, this patch changes how evaluate requests are handled. Currently, they are handled as GDB commands. The intent of the request is more to evaluate expressions in the target language. This is already what we do when context is 'watch'. This patch makes it so we handle it the same way regardless of the context. A simple test for the evaluate request is added. Signed-off-by: Simon Marchi <[email protected]>
- Loading branch information
Simon Marchi
committed
Jan 17, 2019
1 parent
deda840
commit b321388
Showing
5 changed files
with
116 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2019 Ericsson and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*********************************************************************/ | ||
|
||
import { expect } from 'chai'; | ||
import * as path from 'path'; | ||
import { DebugClient } from 'vscode-debugadapter-testsupport/lib/debugClient'; | ||
import { getScopes, Scope, standardBefore, standardBeforeEach, testProgramsDir } from './utils'; | ||
|
||
// Allow non-arrow functions: https://mochajs.org/#arrow-functions | ||
// tslint:disable:only-arrow-functions | ||
|
||
let dc: DebugClient; | ||
let scope: Scope; | ||
|
||
const evaluateProgram = path.join(testProgramsDir, 'evaluate'); | ||
const evaluateSrc = path.join(testProgramsDir, 'evaluate.cpp'); | ||
|
||
before(standardBefore); | ||
|
||
beforeEach(async function() { | ||
// Move the timeout out of the way if the adapter is going to be debugged. | ||
if (process.env.INSPECT_DEBUG_ADAPTER) { | ||
this.timeout(9999999); | ||
} | ||
dc = await standardBeforeEach(); | ||
await dc.hitBreakpoint({ | ||
verbose: true, | ||
program: evaluateProgram, | ||
logFile: '/tmp/gdb.log', | ||
}, { path: evaluateSrc, line: 2 }); | ||
scope = await getScopes(dc); | ||
}); | ||
|
||
afterEach(async function() { | ||
await dc.stop(); | ||
}); | ||
|
||
describe('evaluate request', function() { | ||
// Move the timeout out of the way if the adapter is going to be debugged. | ||
if (process.env.INSPECT_DEBUG_ADAPTER) { | ||
this.timeout(9999999); | ||
} | ||
|
||
it('should evaluate a simple literal expression', async function() { | ||
const res = await dc.evaluateRequest({ | ||
context: 'repl', | ||
expression: '2', | ||
frameId: scope.frameId, | ||
}); | ||
|
||
expect(res.body.result).eq('2'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
empty | ||
evaluate | ||
mem | ||
vars | ||
*.o | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
int main() { | ||
return 0; | ||
} |