This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 0/8] Implement 'frame apply COMMAND', enhance 'thread apply COMMAND'
- From: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- To: gdb-patches at sourceware dot org
- Date: Mon, 21 May 2018 13:06:43 +0200
- Subject: [RFA 0/8] Implement 'frame apply COMMAND', enhance 'thread apply COMMAND'
- Ironport-phdr: 9a23:oc2zFx1AzEY0xArNsmDT+DRfVm0co7zxezQtwd8Zse0RKvad9pjvdHbS+e9qxAeQG9mDsLQc06L/iOPJYSQ4+5GPsXQPItRndiQuroEopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZvJuTyB4Xek9m72/q99pHPbQhEniaxba9vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+VSxWx2IF+Yggjx6MSt8pN96ipco/0u+dJOXqX8ZKQ4UKdXDC86PGAv5c3krgfMQA2S7XYBSGoWkx5IAw/Y7BHmW5r6ryX3uvZh1CScIMb7S60/Vza/4KdxUBLmiDkJOSM3/m/UjcJ9l75XrA67qhBj2YPYfJ2ZOfxjda3dZ9MaQm9BU95LWSxBA4O8a4oPD/IZPelGsoLyp0EBrQG5BQm1GePvyyFHhmXt3aYn1OkhCQHG3A0kH9IPqHTUtMv6OL0cUO+v1qnIyizDb+5X2Tjj8ojIaQssoeqPXbNwd8re11UvGxnegVqOsIHoOS6e2OcVs2WD8uZsSeaih3Q6pwx/vjSj3NoghpfIi44P1FzJ+zt1zYAoLtOiUkF7e8SrEJ5IuiGfMIt5X90tTnlzuCY/1r0GoZm7fDUWyJg/xx7QdfiHc4+Q7xLmSemdOzd4hHVgeL2hnxqy8E6gxfPgVsSszVpGsi5InsPRun0DyxDf8NWLRuV880u7xzqC2R7f5vlBIU8ulKrbL5AhwqQ3lpoWqUnDBi/2mETyjK+XbkUk4van5/7pY7r8vJ+cMJZ0ihz/MqswgMy/Gv81MhMNX2mb/+SzyqHj8VfiT7pUlvE2iLXWsIjGJcQHoa60GwBV3Zs45BqmFzepysgYkmUHLF1bYxKKlJPpO1bTIPDiEfiwnVqtny1xx//YJLHhBY/NLneQ2IvmKLlx4QtEwRY4zd1Ez4lTF6sKLe36QEK3s8bXXTEjNAnh++bmDNRlzo5WZmuVBbaEMa7Iqhfc/uIuJ+iUfIJTpz/nLOE45vP0llcimk4bcLXv15ZBOyPwJehvP0jMOSmkudwGC2pf5gc=
Implement 'frame apply COMMAND', enhance 'thread apply COMMAND'
Compared to RFC, this handles all comments received from Eli and Simon,
and completes the changes so that it is (should be) ready for RFA.
This patch series :
* implements a new command
'frame apply [all | COUNT | -COUNT] [-FLAGS...] COMMAND'.
* enhance 'thread apply COMMAND' by adding a -FLAGS argument
* adds some shortcuts commands
* documents the above in gdb.texinfo and NEWS.
* adds a unit test for cli-utils.c
* adds test for 'frame apply'
* modify gdb.threads/pthreads.exp to test 'thread apply' -FLAGS argument
Th new command 'frame apply' allows to apply a COMMAND to a number of frames,
or to all frames.
The optional -FLAGS... argument allows to control what output to produce
and how to handle errors raised when applying COMMAND to a frame.
Some examples usages for this new command:
frame apply all info frame
Produce info frame for all frames
frame apply all p $sp
For each frame, print the location, followed by the frame sp
frame apply all -qq p $sp
Same as before, but -qq flags (q = quiet) indicate to only print
the frames sp.
frame apply all -vv p $sp
Same as before, but -vv flags (v = verbose) indicate to print
location and source line for each frame.
frame apply all p some_local_var_somewhere
Print some_local_var_somewhere in all frames. 'frame apply'
will abort as soon as the print command fails.
frame apply all -c p some_local_var_somewhere
Same as before, but -c flag (c = continue) means to
print the error and continue applying command in case the
print command fails.
frame apply all -s p some_local_var_somewhere
Same as before, but -s flag (s = silent) means to
be silent for frames where the print command fails.
In other words, this allows to 'search' the frame in which
some_local_var_somewhere can be printed.
'thread apply' command has been enhanced to also accepts a -FLAGS...
argument.
Some examples usages for this new argument:
thread apply all -s frame apply all -s p some_local_var_somewhere
Prints the thread id, frame location and some_local_var_somewhere
value in frames of threads that have such local var.
To make the life of the user easier, the most typical use cases
have shortcuts :
faas : shortcut for 'frame apply all -s'
taas : shortcut for 'thread apply all -s'
tfaas : shortcut for 'thread apply all -s frame apply all -s"
An example usage :
tfaas p some_local_var_somewhere
same as the longer:
'thread apply all -s frame apply all -s p some_local_var_somewhere'
gdb/ChangeLog
2018-05-21 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/cli-utils-selftests.c
* NEWS: Mention new commands. Mention change to 'thread apply'.
* cli-utils.c (number_or_range_parser::get_number): Only handle
numbers or convenience var as numbers.
(check_for_flags): New function.
(check_for_flags_vqcs): New function.
* cli-utils.h (check_for_flags): New function.
(check_for_flags_vqcs): New function.
* stack.c: (trailing_outermost_frame): New function, mostly
extracted from backtrace_command_1.
(backtrace_command_1): Update to call trailing_outermost_frame.
(frame_apply_command_count): New function.
(frame_apply_all_command): New function.
(frame_apply_command): New function.
(faas_command): New function.
(frame_cmd_list): New variable.
(_initialize_stack): Update to setup the new commands 'frame apply'
and 'faas'.
* thread.c (thr_try_catch_cmd): New function.
(thread_apply_all_command): Handle vqcs flags.
(thread_apply_command): Handle vqcs flags.
(taas_command): New function.
(tfaas_command): New function.
(_initialize_thread): Update to setup the new commands 'taas
and 'tfaas'. Change doc string for 'thread apply'.
* unittests/cli-utils-selftests.c: New file.
gdb/testsuite/ChangeLog
2018-05-21 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/frameapply.c: New file.
* gdb.base/frameapply.exp: New file.
* gdb.threads/pthreads/exp: Test vqcs FLAGS.
gdb/doc/ChangeLog
2018-05-21 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Debugging Programs with Multiple Threads):
Document changes to 'thread apply'. Document 'taas'.
Document 'tfaas'.
(Examining the Stack): Document 'frame apply'. Document 'faas'.