Skip to content

Commit

Permalink
Merge pull request #1079 from haneefdm/master
Browse files Browse the repository at this point in the history
Fix for #1007
  • Loading branch information
haneefdm authored Jan 17, 2025
2 parents cd7ef5f + a2900a4 commit ea3fb4b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ChangeLog

# V1.13.0-pre1
# V1.13.0-pre3
* 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)
* It Stops the current session. This means the current GDB and any GDB-server (openocd, stlink, etc. are also terminated)
* If then Starts a new session using the same configuration.
Expand All @@ -14,6 +14,7 @@
so the extension no longer depends on other extensions to provide related functionality.
* Black Magic Probe now supports SWO via the dedicated USB endpoint.
* ST-LINK GDB server (*not* st-util) now supports SWO functionality, using standard configuration options.
* 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.

# V1.12.1
* Fix for [#923: Local variables with same name between functions not tracking or updating context](https://github.com/Marus/cortex-debug/issues/923)
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.13.0-pre2",
"version": "1.13.0-pre3",
"preview": false,
"activationEvents": [
"onDebugResolve:cortex-debug",
Expand Down
32 changes: 18 additions & 14 deletions src/gdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,11 +909,6 @@ export class GDBDebugSession extends LoggingDebugSession {
private startGdb(response: DebugProtocol.LaunchResponse): Promise<void> {
const gdbExePath = this.args.gdbPath;
const gdbargs = ['-q', '--interpreter=mi2'].concat(this.args.debuggerArgs || []);
// if (!this.args.symbolFiles) {
// if (!path.isAbsolute(this.args.executable)) {
// this.args.executable = path.join(this.args.cwd, this.args.executable);
// }
// }
const dbgMsg = 'Launching GDB: ' + quoteShellCmdLine([gdbExePath, ...gdbargs]) + '\n';
this.handleMsg('log', dbgMsg);
if (!this.args.showDevDebugOutput) {
Expand Down Expand Up @@ -941,24 +936,33 @@ export class GDBDebugSession extends LoggingDebugSession {
`interpreter-exec console "source ${this.args.extensionPath}/support/gdb-swo.init"`,
...this.formatRadixGdbCommand()
];

const loadFiles = this.args.loadFiles;
let isLoaded = false;
if (this.args.symbolFiles) {
// If you just used 'add-symbol-file' debugging works but RTOS detection fails
// for most debuggers. While many options work for add-symbol-file, symbol-file
// does not allow a textaddress or sections. See issue #1007
for (const symF of this.args.symbolFiles) {
let cmd = `interpreter-exec console "add-symbol-file \\"${symF.file}\\""`;
cmd += symF.offset ? ` -o ${hexFormat(symF.offset)}"` : '';
cmd += (typeof symF.textaddress === 'number') ? ` ${hexFormat(symF.textaddress)}"` : '';
const offset = symF.offset ? `-o ${hexFormat(symF.offset)}"` : '';
let otherArgs = (typeof symF.textaddress === 'number') ? ` ${hexFormat(symF.textaddress)}"` : '';
for (const section of symF.sections) {
cmd += ` -s ${section.name} ${section.address}`;
otherArgs += ` -s ${section.name} ${section.address}`;
}
this.gdbInitCommands.push(cmd);
const gdbCmd = (otherArgs === '') ? 'symbol-file' : 'add-symbol-file';
const cmd = `${gdbCmd} \\"${symF.file}\\" ${offset} ${otherArgs}`.trimEnd();
this.gdbInitCommands.push(`interpreter-exec console "${cmd}"`);
}
if (this.gdbInitCommands.length === 0) {
this.handleMsg('log', 'Info: GDB may not start since there were no files with symbols in "symbolFiles?\n');
}
if (this.args.executable) {
this.gdbInitCommands.push(`file-exec-file "${this.args.executable}"`);
}
} else {
} else if (!loadFiles && this.args.executable) {
this.gdbInitCommands.push(`file-exec-and-symbols "${this.args.executable}"`);
isLoaded = true;
}

if (!isLoaded && !loadFiles && this.args.executable) {
this.args.loadFiles = [this.args.executable];
}
const ret = this.miDebugger.start(this.args.cwd, this.gdbInitCommands);
return ret;
Expand Down

0 comments on commit ea3fb4b

Please sign in to comment.