Skip to content

Commit ea3fb4b

Browse files
authored
Merge pull request #1079 from haneefdm/master
Fix for #1007
2 parents cd7ef5f + a2900a4 commit ea3fb4b

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ChangeLog
22

3-
# V1.13.0-pre1
3+
# V1.13.0-pre3
44
* MAJOR Change. The `Restart` button functionality has been completely changed. This was not a stable function and VSCode kept changing its definition over the years multiple times. However they provide a default functionality, so the `Restart` button still works but very differently from our implementation. As of today, VSCode seems to do the following (and this extension is not involved)
55
* It Stops the current session. This means the current GDB and any GDB-server (openocd, stlink, etc. are also terminated)
66
* If then Starts a new session using the same configuration.
@@ -14,6 +14,7 @@
1414
so the extension no longer depends on other extensions to provide related functionality.
1515
* Black Magic Probe now supports SWO via the dedicated USB endpoint.
1616
* ST-LINK GDB server (*not* st-util) now supports SWO functionality, using standard configuration options.
17+
* Bugfix #1007: An issue with how gdb works prevented RTOS detection when `"symbolFiles"` was used. It will now work if you do not use additional options to specify sections or a textaddress.
1718

1819
# V1.12.1
1920
* Fix for [#923: Local variables with same name between functions not tracking or updating context](https://github.com/Marus/cortex-debug/issues/923)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.13.0-pre2",
2+
"version": "1.13.0-pre3",
33
"preview": false,
44
"activationEvents": [
55
"onDebugResolve:cortex-debug",

src/gdb.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -909,11 +909,6 @@ export class GDBDebugSession extends LoggingDebugSession {
909909
private startGdb(response: DebugProtocol.LaunchResponse): Promise<void> {
910910
const gdbExePath = this.args.gdbPath;
911911
const gdbargs = ['-q', '--interpreter=mi2'].concat(this.args.debuggerArgs || []);
912-
// if (!this.args.symbolFiles) {
913-
// if (!path.isAbsolute(this.args.executable)) {
914-
// this.args.executable = path.join(this.args.cwd, this.args.executable);
915-
// }
916-
// }
917912
const dbgMsg = 'Launching GDB: ' + quoteShellCmdLine([gdbExePath, ...gdbargs]) + '\n';
918913
this.handleMsg('log', dbgMsg);
919914
if (!this.args.showDevDebugOutput) {
@@ -941,24 +936,33 @@ export class GDBDebugSession extends LoggingDebugSession {
941936
`interpreter-exec console "source ${this.args.extensionPath}/support/gdb-swo.init"`,
942937
...this.formatRadixGdbCommand()
943938
];
939+
940+
const loadFiles = this.args.loadFiles;
941+
let isLoaded = false;
944942
if (this.args.symbolFiles) {
943+
// If you just used 'add-symbol-file' debugging works but RTOS detection fails
944+
// for most debuggers. While many options work for add-symbol-file, symbol-file
945+
// does not allow a textaddress or sections. See issue #1007
945946
for (const symF of this.args.symbolFiles) {
946-
let cmd = `interpreter-exec console "add-symbol-file \\"${symF.file}\\""`;
947-
cmd += symF.offset ? ` -o ${hexFormat(symF.offset)}"` : '';
948-
cmd += (typeof symF.textaddress === 'number') ? ` ${hexFormat(symF.textaddress)}"` : '';
947+
const offset = symF.offset ? `-o ${hexFormat(symF.offset)}"` : '';
948+
let otherArgs = (typeof symF.textaddress === 'number') ? ` ${hexFormat(symF.textaddress)}"` : '';
949949
for (const section of symF.sections) {
950-
cmd += ` -s ${section.name} ${section.address}`;
950+
otherArgs += ` -s ${section.name} ${section.address}`;
951951
}
952-
this.gdbInitCommands.push(cmd);
952+
const gdbCmd = (otherArgs === '') ? 'symbol-file' : 'add-symbol-file';
953+
const cmd = `${gdbCmd} \\"${symF.file}\\" ${offset} ${otherArgs}`.trimEnd();
954+
this.gdbInitCommands.push(`interpreter-exec console "${cmd}"`);
953955
}
954956
if (this.gdbInitCommands.length === 0) {
955957
this.handleMsg('log', 'Info: GDB may not start since there were no files with symbols in "symbolFiles?\n');
956958
}
957-
if (this.args.executable) {
958-
this.gdbInitCommands.push(`file-exec-file "${this.args.executable}"`);
959-
}
960-
} else {
959+
} else if (!loadFiles && this.args.executable) {
961960
this.gdbInitCommands.push(`file-exec-and-symbols "${this.args.executable}"`);
961+
isLoaded = true;
962+
}
963+
964+
if (!isLoaded && !loadFiles && this.args.executable) {
965+
this.args.loadFiles = [this.args.executable];
962966
}
963967
const ret = this.miDebugger.start(this.args.cwd, this.gdbInitCommands);
964968
return ret;

0 commit comments

Comments
 (0)