This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: gdb "automation" question
* On Tue, Jun 22, 2010 at 6:09 PM, Tom Tromey <tromey@redhat.com> wrote:
> Steffen> define defaction
> Steffen> ? .... other default actions ...
> Steffen> ? define hook-stop
> Steffen> ? ? ?show_log
> Steffen> ? end
> Steffen> end
> Steffen> but I get an error ("This command cannot be used at top level").
>
> At least in the current sources this error only comes from the
> tracepoint code. ?I don't have a tree before 7.0 handy, so if you're
> using something older, maybe upgrading would help this. ?Or maybe the
> "..." includes tracepoint commands?
No, I did not use tracepoints (not supported on platform).
I re-tested with version 7.1, which was the most recent I could
find on http://ftp.gnu.org/gnu/gdb/.
I observed the same issue.
Here a minimal "This command cannot be used at the top level"
example:
------------------------------------------------------------------->8=======
steffen@host:dir/arm-elf $ cat gdb-commands.txt
# Do not edit, automatically generated by make
define defactions
define hook-stop
show_log
end
end
document defactions
Default actions
end
steffen@host:dir/arm-elf $ /usr/local/build/gdb-7.1/build/gdb/gdb
GNU gdb (GDB) 7.1
[...]
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-elf".
[...]
(gdb) so gdb-commands.txt
/path/dir/arm-elf/gdb-commands.txt:6: Error in sourced command file:
This command cannot be used at the top level.
=======8<-------------------------------------------------------------------
This shows the error without any tracepoint.
Similar attempt, but this blocks / hangs.
First what works:
------------------------------------------------------------------->8=======
steffen@host:dir/arm-elf $ cat gdb-commands.txt
# Do not edit, automatically generated by make
define tr
disable
target remote 1.2.3.4:4000
monitor set appName 829901
symbol-file 8299011999.elf
end
steffen@host:dir/arm-elf $ /usr/local/build/gdb-7.1/build/gdb/gdb
[...]
(gdb) so gdb-commands.txt
(gdb) q
=======8<-------------------------------------------------------------------
So this works, but when adding "define hook-stop\n end" to get rid
of the hook, it hangs:
------------------------------------------------------------------->8=======
steffen@host:dir/arm-elf $ cat gdb-commands.txt
# Do not edit, automatically generated by make
define tr
disable
define hook-stop
end
target remote 1.2.3.4:4000
monitor set appName 829901
symbol-file 8299011999.elf
end
steffen@host:dir/arm-elf $ /usr/local/build/gdb-7.1/build/gdb/gdb
[...]
(gdb) so gdb-commands.txt
<<<<<<<<<<<<<<<<<< PRESSED CTRL-C >>>>>>>>>>>>>>>>>>
/path/dir/arm-elf/gdb-commands.txt:6: Error in sourced command file:
1.2.3.4:4000: Interrupted system call.
=======8<-------------------------------------------------------------------
Why does it attempt to do anything remotely when adding a
"define"? Shouldn't this just define a new command?
BTW, I cleant my ~/.gdbinit for the test:
------------------------------------------------------------------->8=======
define show_log
if clogStaticLogBuffer[0] != 0
printf "%s", clogStaticLogBuffer
end
set clogStaticLogBuffer[0] = 0
end
=======8<-------------------------------------------------------------------