Skip to content

gdb: gdb source cli command does not allow quotes

When runGdbScript or configGdbScript is set in the "Run->Configure Launches/gdb" section the debug session commands for GDB are not run correctly as source cli command in gdb/mi interpreter doesn't support quotes:

kdevelop.plugins.debuggercommon: SEND: "21source '/tmp/openocd/openocd-0.11.0~rc2/openocd.gdb'"
kdevelop.plugins.debuggercommon: Debugger output (pid = 287192 ):  "&\"source '/tmp/openocd/openocd-0.11.0~rc2/openocd.gdb'\\n\""
kdevelop.plugins.debuggercommon: Debugger output (pid = 287192 ):  "&\"'/tmp/openocd/openocd-0.11.0~rc2/openocd.gdb': No existe el fichero o el directorio.\\n\""
kdevelop.plugins.debuggercommon: Debugger output (pid = 287192 ):  "21^error,msg=\"'/tmp/openocd/openocd-0.11.0~rc2/openocd.gdb': No existe el fichero o el directorio.\""
kdevelop.plugins.debuggercommon: Handling error
kdevelop.plugins.debuggercommon: Command error, times 137 137 0
$ echo "directory /tmp" > /tmp/test.gdb
$ gdb --interpreter=mi
=thread-group-added,id="i1"
~"GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git\n"
~"Copyright (C) 2021 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
~"\nType \"show copying\" and \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-linux-gnu\".\n"
~"Type \"show configuration\" for configuration details.\n"
~"For bug reporting instructions, please see:\n"
~"<https://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
~"\n\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\".\n"
=cmd-param-changed,param="history save",value="on"
=cmd-param-changed,param="history size",value="10240"
=cmd-param-changed,param="style address intensity",value="bold"
(gdb) 
source '/tmp/test.gdb'
&"source '/tmp/test.gdb'\n"
&"'/tmp/test.gdb': No existe el fichero o el directorio.\n"
^error,msg="'/tmp/test.gdb': No existe el fichero o el directorio."
(gdb) 
source /tmp/test.gdb
&"source /tmp/test.gdb\n"
^done
(gdb) 

I've shortly tried to add a testcase for this but I think it's not trivial.

Edited by Raúl Sánchez Siles

Merge request reports