diff options
author | Pedro Alves <palves@redhat.com> | 2016-10-17 14:11:28 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-10-17 14:39:38 +0100 |
commit | de7db413748240947ad43350eca0e9953fcf03d7 (patch) | |
tree | 2439363f29fb528cf2795d3edce8e09b2a22ef8d /gdb/NEWS | |
parent | 081b482ccf08f412a060f0269901ef5941a79444 (diff) | |
download | binutils-gdb-users/palves/cxx-eliminate-cleanups-v2.tar.gz |
Support an "unlimited" number of user-defined argumentsusers/palves/cxx-eliminate-cleanups-v2
I recently wrote a user-defined command that would benefit from
supporting an unlimited number of arguments:
http://palves.net/list-active-signal-handlers-with-gdb/
However, we currently only support up to 10 arguments passed to
user-defined commands ($arg0..$arg9).
I can't find a good reason for that, other than "old code with hard
coded limits". This patch removes that limit and modernizes the code
along the way:
- Makes the user_args struct a real C++ class that uses std::vector
for storage.
- Removes the "next" pointer from within user_args and uses a
std::vector to maintain a stack instead.
- Adds a new RAII-based scoped_user_args_level class to help
push/pop user args in the stack instead of using a cleanup.
I also needed a way to convert a number to a std::string, so I added a
new utility for that, gdb::to_string.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* NEWS: Mention that user commands now accept an unlimited number
of arguments.
* cli/cli-script.c: Include <vector>.
(struct string_view): New type.
(MAXUSERARGS): Delete.
(struct user_args): Now a C++ class.
(user_args_stack): New.
(struct scoped_user_args_level): New type.
(execute_user_command): Use scoped_user_args_level. Adjust to
call insert_user_args instead of insert_args.
(arg_cleanup): Delete.
(setup_user_args): Deleted, and refactored as ...
(user_args::user_args): ... this new constructor. Limit of number
of arguments removed.
(insert_args): Delete.
(insert_user_args) New.
(user_args::insert_args): New, bits based on old insert_args with
limit of number of arguments eliminated.
* common/common-utils.h: Include <sstream>.
(gdb::to_string): New.
gdb/doc/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.texinfo (User-defined Commands): Limit on number of
arguments passed to user-defined commands removed; update.
Diffstat (limited to 'gdb/NEWS')
-rw-r--r-- | gdb/NEWS | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -17,6 +17,9 @@ * Support for Java programs compiled with gcj has been removed. +* User commands now accept an unlimited number of arguments. + Previously, only up to 10 was accepted. + * New targets Synopsys ARC arc*-*-elf32 |