Skip to content

Commit 8910390

Browse files
authored
Fix/sysview commands (VSC-1712) (#1580)
* Update SystemView tracing commands to use mcore and add ELF file path (#1573) * Create gdbinit file in build directory for GDB heap tracing (#1573) * Improve GDB heap trace process cleanup (#1573) - Add graceful GDB shutdown with quit command - Add delay before force kill to allow GDB to exit cleanly - Disable GDB confirmation prompts with 'set confirm off' - Fix typo in error message ("stoping" -> "stopping")
1 parent 6013a28 commit 8910390

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

src/espIdf/tracing/gdbHeapTraceManager.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ export class GdbHeapTraceManager {
6262
/\\/g,
6363
"/"
6464
)}/htrace_${new Date().getTime()}.svdat`;
65-
await this.createGdbinitFile(fileName, workspace.fsPath);
65+
const buildDirPath = readParameter(
66+
"idf.buildPath",
67+
workspace
68+
) as string;
69+
const buildExists = await pathExists(buildDirPath);
70+
if (!buildExists) {
71+
throw new Error(`${buildDirPath} doesn't exist. Build first.`);
72+
}
73+
await this.createGdbinitFile(fileName, buildDirPath);
6674
const modifiedEnv = await appendIdfAndToolsToPath(workspace);
6775
const idfTarget = modifiedEnv.IDF_TARGET || "esp32";
6876
const gdbTool = getToolchainToolName(idfTarget, "gdb");
@@ -73,14 +81,6 @@ export class GdbHeapTraceManager {
7381
if (!isGdbToolInPath) {
7482
throw new Error(`${gdbTool} is not available in PATH.`);
7583
}
76-
const buildDirPath = readParameter(
77-
"idf.buildPath",
78-
workspace
79-
) as string;
80-
const buildExists = await pathExists(buildDirPath);
81-
if (!buildExists) {
82-
throw new Error(`${buildDirPath} doesn't exist. Build first.`);
83-
}
8484
const projectName = await getProjectName(buildDirPath);
8585
const elfFilePath = join(buildDirPath, `${projectName}.elf`);
8686
const elfFileExists = await pathExists(elfFilePath);
@@ -132,16 +132,20 @@ export class GdbHeapTraceManager {
132132
public async stop() {
133133
try {
134134
if (this.childProcess) {
135-
this.childProcess.stdin.end();
136-
this.childProcess.kill("SIGKILL");
135+
this.childProcess.stdin.write("quit\n");
136+
// Give GDB some time to process the quit command
137+
await new Promise(resolve => setTimeout(resolve, 1000));
138+
if (!this.childProcess.killed) {
139+
this.childProcess.kill("SIGKILL");
140+
}
137141
this.childProcess = null;
138142
}
139143
this.archiveDataProvider.populateArchiveTree();
140144
this.showStartButton();
141145
} catch (error) {
142146
const msg = error.message
143147
? error.message
144-
: "Error stoping GDB Heap Tracing";
148+
: "Error stopping GDB Heap Tracing";
145149
Logger.errorNotify(msg, error, "GdbHeapTraceManager stop");
146150
}
147151
}
@@ -170,9 +174,9 @@ export class GdbHeapTraceManager {
170174
traceFilePath: string,
171175
workspaceFolder: string
172176
) {
173-
let content = `set pagination off\ntarget remote :3333\n\nmon reset halt\nflushregs\n\n`;
174-
content += `tb heap_trace_start\ncommands\nmon esp sysview start ${traceFilePath}\n`;
175-
content += `c\nend\n\ntb heap_trace_stop\ncommands\nmon esp sysview stop\nend\n\nc`;
177+
let content = `set pagination off\nset confirm off\ntarget remote :3333\n\nmon reset halt\nflushregs\n\n`;
178+
content += `tb heap_trace_start\ncommands\nmon esp sysview_mcore start ${traceFilePath}\n`;
179+
content += `c\nend\n\ntb heap_trace_stop\ncommands\nmon esp sysview_mcore stop\nend\n\nc`;
176180
const filePath = join(workspaceFolder, this.gdbinitFileName);
177181
await writeFile(filePath, content);
178182
}

src/espIdf/tracing/tools/sysviewTraceProc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class SysviewTraceProc extends AbstractTracingToolManager {
4343
}
4444
return await this.parseInternal(
4545
"python",
46-
["sysviewtrace_proc.py", "-j", `file://${this.traceFilePath}`],
46+
["sysviewtrace_proc.py", "-j", "-b", `file://${this.elfFilePath}`, `file://${this.traceFilePath}`],
4747
{
4848
cwd: this.appTraceToolsPath(),
4949
}

0 commit comments

Comments
 (0)