I want to comment gdb
commands in the command prompt at the end of the line for two use cases:
gdb
command file for automatic executionWhile gdb
command files seem to support comments via the hash (#
) symbol
I cannot find any command marker for the gdb
command line:
(gdb) print 1
$2 = 1
(gdb) print 1 // comment
A syntax error in expression, near `/ comment'.
(gdb) print 1 -- comment
A syntax error in expression, near `comment'.
(gdb) print 1 # comment
Invalid character '#' in expression.
(gdb) print 1 ; comment
Invalid character ';' in expression.
(gdb) print 1 /* comment */
No symbol "comment" in current context.
How can I append comments?
Edit: According to the gdb
documentation
Any text from a # to the end of the line is a comment; it does nothing. This is useful mainly in command files
I am not sure why it doesn't work as documented...
You can use it on its own line, but not at the end of a line. E.g.:
(gdb) # foo
(gdb) print "foo"
$1 = "foo"