Skip to content

Commit f9a0329

Browse files
committed
adding evaluate request context to function args and adding an = sign to live watch
1 parent 37531b5 commit f9a0329

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/debug-session/gdbtarget-debug-session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ export class GDBTargetDebugSession {
5454
this._cbuildRunParsePromise = undefined;
5555
}
5656

57-
public async evaluateGlobalExpression(expression: string): Promise<string> {
57+
public async evaluateGlobalExpression(expression: string, context = 'hover'): Promise<string> {
5858
try {
5959
const frameId = (vscode.debug.activeStackItem as vscode.DebugStackFrame)?.frameId ?? 0;
6060
const args: DebugProtocol.EvaluateArguments = {
6161
expression,
6262
frameId, // Currently required by CDT GDB Adapter
63-
context: 'hover'
63+
context: context
6464
};
6565
const response = await this.session.customRequest('evaluate', args) as DebugProtocol.EvaluateResponse['body'];
6666
return response.result;

src/views/live-watch/live-watch.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class LiveWatchTreeDataProvider implements vscode.TreeDataProvider<LiveWa
3434
private roots: LiveWatchNode[] = [];
3535
private nodeID: number;
3636
private _context: vscode.ExtensionContext;
37-
private activeSession: GDBTargetDebugSession | undefined;
37+
private _activeSession: GDBTargetDebugSession | undefined;
3838

3939
constructor(private readonly context: vscode.ExtensionContext) {
4040
this.roots = this.context.workspaceState.get<LiveWatchNode[]>(this.STORAGE_KEY) ?? [];
@@ -53,12 +53,16 @@ export class LiveWatchTreeDataProvider implements vscode.TreeDataProvider<LiveWa
5353
}
5454

5555
public getTreeItem(element: LiveWatchNode): vscode.TreeItem {
56-
const item = new vscode.TreeItem(element.expression, vscode.TreeItemCollapsibleState.None);
56+
const item = new vscode.TreeItem(element.expression + ' = ', vscode.TreeItemCollapsibleState.None);
5757
item.description = element.value || '';
5858
item.contextValue = 'expression';
5959
return item;
6060
}
6161

62+
public get activeSession(): GDBTargetDebugSession | undefined {
63+
return this._activeSession;
64+
}
65+
6266
public async activate(tracker: GDBTargetDebugTracker): Promise<void> {
6367
this.addVSCodeCommands();
6468
const onDidChangeActiveDebugSession = tracker.onDidChangeActiveDebugSession(async (session) => await this.handleOnDidChangeActiveDebugSession(session));
@@ -69,7 +73,7 @@ export class LiveWatchTreeDataProvider implements vscode.TreeDataProvider<LiveWa
6973
const onStackTrace = tracker.onDidChangeActiveStackItem(async () => await this.refresh());
7074
// Clearing active session on closing the session
7175
const onWillStopSession = tracker.onWillStopSession(async (session) => {
72-
this.activeSession = session;
76+
this._activeSession = session;
7377
await this.refresh();
7478
await this.save();
7579
});
@@ -90,13 +94,13 @@ export class LiveWatchTreeDataProvider implements vscode.TreeDataProvider<LiveWa
9094
}
9195

9296
private async handleOnDidChangeActiveDebugSession(session: GDBTargetDebugSession | undefined): Promise<void> {
93-
this.activeSession = session;
97+
this._activeSession = session;
9498
await this.refresh();
9599
}
96100

97101
private async handleOnWillStartSession(session: GDBTargetDebugSession): Promise<void> {
98102
session.refreshTimer.onRefresh(async (refreshSession) => {
99-
this.activeSession = refreshSession;
103+
this._activeSession = refreshSession;
100104
await this.refresh();
101105
});
102106
}
@@ -144,10 +148,10 @@ export class LiveWatchTreeDataProvider implements vscode.TreeDataProvider<LiveWa
144148
}
145149

146150
private async evaluate(expression: string): Promise<string> {
147-
if (!this.activeSession) {
151+
if (!this._activeSession) {
148152
return 'No active session';
149153
}
150-
const result = await this.activeSession.evaluateGlobalExpression(expression);
154+
const result = await this._activeSession.evaluateGlobalExpression(expression, 'watch');
151155
return result;
152156
}
153157

@@ -187,14 +191,14 @@ export class LiveWatchTreeDataProvider implements vscode.TreeDataProvider<LiveWa
187191

188192
private async refresh(node?: LiveWatchNode) {
189193
if (node) {
190-
this._onDidChangeTreeData.fire(node);
191194
node.value = await this.evaluate(node.expression);
195+
this._onDidChangeTreeData.fire(node);
192196
return;
193197
}
194-
this._onDidChangeTreeData.fire();
195198
for (const n of this.roots) {
196199
n.value = await this.evaluate(n.expression);
197200
}
201+
this._onDidChangeTreeData.fire();
198202
}
199203

200204
private async save() {

0 commit comments

Comments
 (0)