Skip to content

Commit

Permalink
Issue463 and other improvements (#466)
Browse files Browse the repository at this point in the history
* bug fix

* Globals are now sorted

* Do not auto show the gdb-server window

* Global var sort, put __* variables at the bottom

* TSLint

* more TSLint

* TSLint

* register/variable hex/dec modes support

* workaround for radix bug in gdb

* Refresh inline buttons

* V0.4.2

* V4.0.2 updates

* Bug: tooltip not updating properly, better tooltip
  • Loading branch information
haneefdm authored Aug 16, 2021
1 parent 1f61aab commit 7fc1e9c
Show file tree
Hide file tree
Showing 22 changed files with 647 additions and 188 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
ChangeLog
# V0.4.2

* Now you can toggle Hex mode for Registers and Variables independently from the Debug Panel.
* The title bar of the Registers View contains a button to toggle between Hex and Natural modes
<img src=https://user-images.githubusercontent.com/41269583/129577447-473bfbde-a748-441c-83f1-315c1568cb5a.png width="250" />
* In the Variable Window, you can right click on any variable and it allows you to toggle the Hex mode. This setting applies also applies to Watch variables. Too bad we don't have access to the title bar and there is no good way of implementing a per-variable format

<img src=https://user-images.githubusercontent.com/41269583/129577748-ffd64c20-4e0b-4508-9434-63cef9a74329.png width=250 />
* There is now a Refresh button in the title bars of the Registers and Peripheral Windows. The registers window, when refreshed will use the current stack/frame to retrieve the values.
* You can hover over a scalar variable name and get a tool-tip that gives you decimal, hex, octal and binary forms of the same.
<img src=https://user-images.githubusercontent.com/41269583/129586732-71228fee-6d6c-4993-ac8f-c9ca93b7772f.png width=350 />
* Terminal input
* Support for `Paste` in RTT in RTT terminals (See Issue #463)
* Input entered into RTT Terminals can now have thier encoding be use using the `iencoding` option for the `console` and `binary` encoders
* Global variables are now sorted in the Variables Windows. But all variables starting with double underscores `__` are pushed to the bottom.

# V0.4.1

Minor bug fix. The `launch.json` option `clearSearch` was not working for `rttConfig`. Only affected OpenOCD users.
# V0.4.0

Expand Down
10 changes: 10 additions & 0 deletions images/hex-off-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions images/hex-off-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions images/hex-on-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions images/hex-on-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion options-doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_properties(pkg, type):
# pp.pprint(categories)

MISSING_ATTRIBUTES = ['extensionPath',
'flattenAnonymous', 'registerUseNaturalFormat', 'toolchainPath']
'flattenAnonymous', 'registerUseNaturalFormat', 'variableUseNaturalFormat', 'toolchainPath']

all_properties = {**attach_properties, **launch_properties}

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.

120 changes: 105 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.4.1",
"version": "0.4.2",
"activationEvents": [
"onDebugResolve:cortex-debug"
],
Expand Down Expand Up @@ -105,6 +105,11 @@
"type": "boolean",
"default": true,
"description": "If true, display registers in their natural format as specified by ARM. Hex otherwise."
},
"cortex-debug.variableUseNaturalFormat": {
"type": "boolean",
"default": true,
"description": "If true, display variables in their natural format as specified by ARM. Hex otherwise."
}
}
},
Expand All @@ -124,13 +129,51 @@
"title": "Copy Value",
"icon": "$(files)"
},
{
"command": "cortex-debug.registers.refresh",
"title": "Refresh",
"icon": "$(refresh)"
},
{
"command": "cortex-debug.registers.regHexModeTurnOff",
"title": "Enable Natural mode",
"icon": {
"light": "images/hex-on-light.svg",
"dark": "images/hex-on-dark.svg"
}
},
{
"command": "cortex-debug.registers.regHexModeTurnOn",
"title": "Enable Hex mode",
"icon": {
"light": "images/hex-off-light.svg",
"dark": "images/hex-off-dark.svg"
}
},
{
"command": "cortex-debug.registers.varHexModeTurnOff",
"title": "Enable Natural mode",
"icon": {
"light": "images/hex-on-light.svg",
"dark": "images/hex-on-dark.svg"
}
},
{
"command": "cortex-debug.registers.varHexModeTurnOn",
"title": "Enable Hex mode",
"icon": {
"light": "images/hex-off-light.svg",
"dark": "images/hex-off-dark.svg"
}
},
{
"command": "cortex-debug.peripherals.setFormat",
"title": "Set Value Format"
},
{
"command": "cortex-debug.peripherals.forceRefresh",
"title": "Refresh"
"title": "Refresh",
"icon": "$(refresh)"
},
{
"command": "cortex-debug.peripherals.pin",
Expand Down Expand Up @@ -614,19 +657,26 @@
},
"encoding": {
"type": "string",
"description": "ascii, utf8, ucs2, utf16le are for 'console', rest are for 'binary' type data",
"default": "",
"description": "How binary data bytes are converted into a number. All little-endian",
"default": "unsigned",
"enum": [
"ascii",
"utf8",
"ucs2",
"utf16le",
"unsigned",
"signed",
"Q16.16",
"float"
]
},
"iencoding": {
"type": "string",
"description": "How keyoard input is encoded. Cooked mode only",
"default": "utf8",
"enum": [
"ascii",
"utf8",
"ucs2",
"utf16le"
]
},
"scale": {
"default": 1,
"description": "Binary only: This setting will scale the raw value from the ITM port by the specified value. Can be used, for example, to scale a raw n-bit ADC reading to a voltage value. (e.g to scale a 12-bit ADC reading to a 3.3v scale you would need a scale value of 3.3/4096 = 0.0008056640625",
Expand Down Expand Up @@ -1428,19 +1478,26 @@
},
"encoding": {
"type": "string",
"description": "ascii, utf8, ucs2, utf16le are for 'console', rest are for 'binary' type data",
"default": "",
"description": "How binary data bytes are converted into a number. All little-endian",
"default": "unsigned",
"enum": [
"ascii",
"utf8",
"ucs2",
"utf16le",
"unsigned",
"signed",
"Q16.16",
"float"
]
},
"iencoding": {
"type": "string",
"description": "How keyoard input is encoded Cooked mode only",
"default": "utf8",
"enum": [
"ascii",
"utf8",
"ucs2",
"utf16le"
]
},
"scale": {
"default": 1,
"description": "Binary only: This setting will scale the raw value from the ITM port by the specified value. Can be used, for example, to scale a raw n-bit ADC reading to a voltage value. (e.g to scale a 12-bit ADC reading to a 3.3v scale you would need a scale value of 3.3/4096 = 0.0008056640625",
Expand Down Expand Up @@ -2044,7 +2101,40 @@
"when": "view == cortex-debug.peripherals"
}
],
"view/title": []
"view/title": [
{
"command": "cortex-debug.registers.regHexModeTurnOn",
"when": "view == cortex-debug.registers && debugState == stopped && cortex-debug:registerUseNaturalFormat",
"group": "navigation"
},
{
"command": "cortex-debug.registers.regHexModeTurnOff",
"when": "view == cortex-debug.registers && debugState == stopped && !cortex-debug:registerUseNaturalFormat",
"group": "navigation"
},
{
"command": "cortex-debug.registers.refresh",
"when": "view == cortex-debug.registers && debugState == stopped",
"group": "navigation"
},
{
"command": "cortex-debug.peripherals.forceRefresh",
"when": "view == cortex-debug.peripherals && debugState == stopped",
"group": "navigation"
}
],
"debug/variables/context": [
{
"command": "cortex-debug.registers.varHexModeTurnOn",
"when": "inDebugMode && debugType == 'cortex-debug' && debugState == stopped && cortex-debug:variableUseNaturalFormat",
"group": "navigation"
},
{
"command": "cortex-debug.registers.varHexModeTurnOff",
"when": "inDebugMode && debugType == 'cortex-debug' && debugState == stopped && !cortex-debug:variableUseNaturalFormat",
"group": "navigation"
}
]
},
"views": {
"debug": [
Expand Down
42 changes: 38 additions & 4 deletions src/backend/backend.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { MINode } from './mi_parse';
import { DebugProtocol } from 'vscode-debugprotocol/lib/debugProtocol';

export interface Breakpoint {
file?: string;
line?: number;
Expand Down Expand Up @@ -74,6 +73,42 @@ export class VariableObject {
this.hasMore = !!MINode.valueOf(node, 'has_more');
}

public createToolTip(name: string, value: string): string {
let ret = this.type;
if (this.isCompound()) {
return ret;
}

let val = 0;
if ((/^0[xX][0-9A-Fa-f]+/.test(value)) || /^[-]?[0-9]+/.test(value)) {
val = parseInt(value.toLowerCase());

ret += ' ' + name + ';' ;
if (this.value.startsWith('<')) {
console.log(this);
}

ret += `\ndec: ${val}`;
if (this.value.startsWith('-')) {
val = val < 0 ? -val : val;
val = ((val ^ 0xffffffff) + 1) >>> 0;
}
let str = val.toString(16);
str = '0x' + '0'.repeat(8 - str.length) + str;
ret += `\nhex: ${str}`;

str = val.toString(8);
str = '0'.repeat(12 - str.length) + str;
ret += `\noct: ${str}`;

str = val.toString(2);
str = '0'.repeat(32 - str.length) + str;
str = str.substr(0, 8) + ' ' + str.substr(8, 8) + ' ' + str.substr(16, 8) + ' ' + str.substr(24, 8);
ret += `\nbin: ${str}`;
}
return ret;
}

public applyChanges(node: MINode) {
this.value = MINode.valueOf(node, 'value');
if (!!MINode.valueOf(node, 'type_changed')) {
Expand Down Expand Up @@ -101,9 +136,8 @@ export class VariableObject {
},
variablesReference: this.id
};
if (this.displayhint) {
// res.kind = this.displayhint;
}

res.type = this.createToolTip(res.name, res.value); // This ends up becoming a tool-tip
return res;
}
}
Expand Down
27 changes: 13 additions & 14 deletions src/backend/mi2/mi2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class MI2 extends EventEmitter implements IBackend {
this.emit('running', parsed);
}
else if (record.asyncClass === 'stopped') {
let reason = parsed.record('reason');
const reason = parsed.record('reason');
if (trace) {
this.log('stderr', 'stop: ' + reason);
}
Expand All @@ -181,7 +181,6 @@ export class MI2 extends EventEmitter implements IBackend {
this.emit('exited-normally', parsed);
}
else {
let msg = 'Not implemented stop reason (assuming exception): ';
if ((reason === undefined) && this.firstStop) {
this.log('console', 'Program stopped, probably due to a reset and/or halt issued by debugger');
this.emit('stopped', parsed, 'entry');
Expand Down Expand Up @@ -323,18 +322,18 @@ export class MI2 extends EventEmitter implements IBackend {
}

public goto(filename: string, line: number): Thenable<boolean> {
if (trace) {
this.log('stderr', 'goto');
}
return new Promise((resolve, reject) => {
const target: string = '"' + (filename ? escape(filename) + ":" : "") + line.toString() + '"';
this.sendCommand("break-insert -t " + target).then(() => {
this.sendCommand("exec-jump " + target).then((info) => {
resolve(info.resultRecords.resultClass === 'running');
}, reject);
}, reject);
});
}
if (trace) {
this.log('stderr', 'goto');
}
return new Promise((resolve, reject) => {
const target: string = '"' + (filename ? escape(filename) + ':' : '') + line.toString() + '"';
this.sendCommand('break-insert -t ' + target).then(() => {
this.sendCommand('exec-jump ' + target).then((info) => {
resolve(info.resultRecords.resultClass === 'running');
}, reject);
}, reject);
});
}

public restart(commands: string[]): Thenable<boolean> {
if (trace) {
Expand Down
4 changes: 2 additions & 2 deletions src/backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class GDBServer extends EventEmitter {
});
}
else { // For servers like BMP that are always running directly on the probe
this.connectToConsole();
this.connectToConsole();
resolve(true);
}
});
Expand Down Expand Up @@ -173,7 +173,7 @@ export class GDBServer extends EventEmitter {
if (this.consoleSocket) {
this.consoleSocket.write(data);
} else {
console.error('sendToConsole: console not open. How did this happen?')
console.error('sendToConsole: console not open. How did this happen?');
}
}

Expand Down
Loading

0 comments on commit 7fc1e9c

Please sign in to comment.