microsoft / microsoft/vscode-cpptools
Launching of custom GDB does not correctly set CWD (breaks relative paths)
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- TypeScript
- Estrellas
- 6.2k
- Forks
- 1.7k
- Merge medio
- 14 h 46 min
- PR fusionados (30 d)
- 61
Descripción
I'm trying to debug an STM32 microcontroller through OpenOCD in VSCode 1.13.0 on Windows 10.
I have this launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "ARM GDB Launch",
"logging": { "trace": true, "traceResponse": true, "engineLogging": true },
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"program": "${workspaceRoot}/BUILD/DISCO_F407VG/GCC_ARM/tracker.elf",
"windows": {
"miDebuggerPath": "arm-none-eabi-gdb.exe"
},
"linux": {
"miDebuggerPath": "arm-none-eabi-gdb"
},
"miDebuggerServerAddress": "localhost:3333",
"targetArchitecture": "arm",
"customLaunchSetupCommands": [
{
"description": "Set remote target",
"text": "file BUILD/DISCO_F407VG/GCC_ARM/tracker.elf"
},
{
"description": "Set remote target",
"text": "target remote localhost:3333"
},
{
"description": "Set hardware breakpoints",
"text": "set remote hardware-breakpoint-limit 6"
},
{
"description": "Set hardware breakpoints",
"text": "set remote hardware-watchpoint-limit 4"
},
{
"description": "Reset 1",
"text": "monitor reset halt"
},
{
"description": "Load code",
"text": "load"
},
{
"description": "Reset 2",
"text": "monitor reset halt"
}
]
}
]
}
However, this doesn't work. I get the following error:
Unable to start debugging. Unexpected GDB output from command "-interpreter-exec console "file BUILD/DISCO_F407VG/GCC_ARM/tracker.elf"". BUILD/DISCO_F407VG/GCC_ARM/tracker.elf: No such file or directory.
However, the file is there, and if I use the full path, it works. (I do consider it bad practice to use full paths in any code, specially code that others might use).
Since it looked like a path problem, I launched SysInternals' Process Explorer and tried to find the arm-none-eabi-gdb.exe process. I found that its Current directory field is just empty! Screenshot:

One workaround that I found, at least until the bug is fixed, is to create a batch (.bat) with this content:
@arm-none-eabi-gdb.exe %*
Then I changed the miDebuggerPath setting to:
"miDebuggerPath": "${workspaceRoot}/wingdb.bat"
Where wingdb.bat is the name of the file I just created.
Curiously, this does work, which suggests that VSCode is not properly setting the debugger's current directory properly.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la configuración de launch.json, especialmente cwd y miDebuggerPath, y reproduce el fallo usando el comando file relativo en customLaunchSetupCommands. Compara el lanzamiento directo de arm-none-eabi-gdb.exe con la solución alternativa wingdb.bat. Se considera terminado cuando el proceso del depurador recibe el directorio actual previsto y resuelve la ruta relativa a tracker.elf sin una ruta completa ni un wrapper.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100