Skip to content

Commit

Permalink
toggle hex display setting
Browse files Browse the repository at this point in the history
  • Loading branch information
haneefdm committed Jan 3, 2022
1 parent 8bf04df commit 3f6c41c
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 20 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ChangeLog

# V1.1.5
* Fixed issue with with SWO (or RTT) not working the first time. It was a race condition where we were trying to connect too fast. Now we re-try
* Feature: There now a command (default key-binding Ctrl+Shift+X) to toggle Hex display in the Variables window. Does not affect the Registers window (which may be going away) as it has its own command and button. You can find this command in the "Command Palette" as "Cortex-Debug: Toggle hex display in Variables window"
* Fixed issue with with SWO (or RTT) not working the first time. It was a race condition where we were trying to connect too fast. Now we re-try. The max timeout is 5 mins.
* Fixed SWO and RTT are now session aware. As in, you can have multiple RTT/SWO windows from different debug sessions.
# V1.1.4
* BugFix: Reset was broken in previous release
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,15 @@
}
},
{
"command": "cortex-debug.registers.varHexModeTurnOff",
"command": "cortex-debug.varHexModeTurnOff",
"title": "Enable Natural mode",
"icon": {
"light": "images/hex-on-light.svg",
"dark": "images/hex-on-dark.svg"
}
},
{
"command": "cortex-debug.registers.varHexModeTurnOn",
"command": "cortex-debug.varHexModeTurnOn",
"title": "Enable Hex mode",
"icon": {
"light": "images/hex-off-light.svg",
Expand Down Expand Up @@ -430,8 +430,20 @@
"category": "Cortex-Debug",
"command": "cortex-debug.setForceDisassembly",
"title": "Set Force Disassembly"
},
{
"category": "Cortex-Debug",
"command": "cortex-debug.toggleVariableHexFormat",
"title": "Toggle hex display in Variables window"
}
],
"keybindings": [
{
"command": "cortex-debug.toggleVariableHexFormat",
"key": "ctrl+shift+x",
"when": "debugType == cortex-debug"
}
],
"languages": [
{
"id": "cortex-debug.disassembly",
Expand Down Expand Up @@ -2421,6 +2433,10 @@
{
"command": "cortex-debug.resetDevice",
"when": "debugType == cortex-debug"
},
{
"command": "cortex-debug.toggleVariableHexFormat",
"when": "debugType == cortex-debug"
}
],
"debug/toolBar": [
Expand Down Expand Up @@ -2531,12 +2547,12 @@
],
"debug/variables/context": [
{
"command": "cortex-debug.registers.varHexModeTurnOn",
"command": "cortex-debug.varHexModeTurnOn",
"when": "inDebugMode && debugType == 'cortex-debug' && debugState == stopped && cortex-debug:variableUseNaturalFormat",
"group": "navigation"
},
{
"command": "cortex-debug.registers.varHexModeTurnOff",
"command": "cortex-debug.varHexModeTurnOff",
"when": "inDebugMode && debugType == 'cortex-debug' && debugState == stopped && !cortex-debug:variableUseNaturalFormat",
"group": "navigation"
}
Expand Down
47 changes: 36 additions & 11 deletions src/frontend/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ export class CortexDebugExtension {
vscode.commands.registerCommand('cortex-debug.registers.refresh', this.registersRefresh.bind(this)),
vscode.commands.registerCommand('cortex-debug.registers.regHexModeTurnOn', this.registersNaturalMode.bind(this, false)),
vscode.commands.registerCommand('cortex-debug.registers.regHexModeTurnOff', this.registersNaturalMode.bind(this, true)),
vscode.commands.registerCommand('cortex-debug.registers.varHexModeTurnOn', this.variablesNaturalMode.bind(this, false)),
vscode.commands.registerCommand('cortex-debug.registers.varHexModeTurnOff', this.variablesNaturalMode.bind(this, true)),
vscode.commands.registerCommand('cortex-debug.varHexModeTurnOn', this.variablesNaturalMode.bind(this, false)),
vscode.commands.registerCommand('cortex-debug.varHexModeTurnOff', this.variablesNaturalMode.bind(this, true)),
vscode.commands.registerCommand('cortex-debug.toggleVariableHexFormat', this.toggleVariablesHexMode.bind(this)),

vscode.commands.registerCommand('cortex-debug.examineMemory', this.examineMemory.bind(this)),
vscode.commands.registerCommand('cortex-debug.viewDisassembly', this.showDisassembly.bind(this)),
Expand Down Expand Up @@ -163,8 +164,8 @@ export class CortexDebugExtension {
}

private settingsChanged(e: vscode.ConfigurationChangeEvent) {
const msg = 'New format will take effect next time the program pauses';
if (e.affectsConfiguration(`cortex-debug.${CortexDebugKeys.REGISTER_DISPLAY_MODE}`)) {
const msg = 'Cortex-Debug: New format will take effect next time the program pauses';
const session = CortexDebugExtension.getActiveCDSession();
if (session) {
const mySession = CDebugSession.FindSession(session);
Expand All @@ -178,16 +179,25 @@ export class CortexDebugExtension {
}
}
if (e.affectsConfiguration(`cortex-debug.${CortexDebugKeys.VARIABLE_DISPLAY_MODE}`)) {
const session = CortexDebugExtension.getActiveCDSession();
if (session) {
const mySession = CDebugSession.FindSession(session);
const config = vscode.workspace.getConfiguration('cortex-debug');
const isHex = config.get(CortexDebugKeys.VARIABLE_DISPLAY_MODE, true) ? false : true;
session.customRequest('set-var-format', { hex: isHex });
if (mySession.status === 'running') {
vscode.window.showInformationMessage(msg);
const config = vscode.workspace.getConfiguration('cortex-debug');
const isHex = config.get(CortexDebugKeys.VARIABLE_DISPLAY_MODE, true) ? false : true;
let foundStopped = false;
for (const s of CDebugSession.CurrentSessions) {
try {
// Session may not have actually started according to VSCode but we know of it
s.session.customRequest('set-var-format', { hex: isHex });
if (s.status === 'stopped') {
foundStopped = true;
}
}
catch (e) {
}
}
if (!foundStopped) {
const fmt = isHex ? 'hex' : 'dec';
const msg = `Cortex-Debug: Variables window format "${fmt}" will take effect next time the program pauses`;
vscode.window.showInformationMessage(msg);
}
}
if (e.affectsConfiguration(`cortex-debug.${CortexDebugKeys.SERVER_LOG_FILE_NAME}`)) {
const config = vscode.workspace.getConfiguration('cortex-debug');
Expand Down Expand Up @@ -498,6 +508,21 @@ export class CortexDebugExtension {
}
}

private toggleVariablesHexMode() {
// 'cxt' contains the treeItem on which this menu was invoked. Maybe we can do something
// with it later
const config = vscode.workspace.getConfiguration('cortex-debug');
const curVal = config.get(CortexDebugKeys.VARIABLE_DISPLAY_MODE, true);
const newVal = !curVal;
vscode.commands.executeCommand('setContext', `cortex-debug:${CortexDebugKeys.VARIABLE_DISPLAY_MODE}`, newVal);
try {
config.update(CortexDebugKeys.VARIABLE_DISPLAY_MODE, newVal);
}
catch (e) {
console.error(e);
}
}

// Debug Events
private debugSessionStarted(session: vscode.DebugSession) {
if (session.type !== 'cortex-debug') { return; }
Expand Down
4 changes: 2 additions & 2 deletions src/gdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ export class GDBDebugSession extends DebugSession {
this.miDebugger.sendCommand(cmd);
}
if (this.stopped) {
// We area already stopped but this fakes a stop again which referhes all debugger windows
// We area already stopped but this fakes a stop again which refreshes all debugger windows
// We don't have a way to only referesh portions. It is all or nothing, there is a bit
// of screen flashing and causes changes in GUI contexts (stack for instance)
this.sendEvent(new StoppedEvent(this.stoppedReason, this.currentThreadId, true));
Expand Down Expand Up @@ -2090,7 +2090,7 @@ export class GDBDebugSession extends DebugSession {

try {
const [threadId, frameId] = GDBDebugSession.decodeReference(args.variablesReference);
const fmt = this.args.registerUseNaturalFormat ? 'N' : 'x';
const fmt = this.args.variableUseNaturalFormat ? 'N' : 'x';
// --thread --frame does not work properly
this.miDebugger.sendCommand(`thread-select ${threadId}`);
this.miDebugger.sendCommand(`stack-select-frame ${frameId}`);
Expand Down

0 comments on commit 3f6c41c

Please sign in to comment.