diff options
author | Pedro Alves <palves@redhat.com> | 2016-01-15 21:46:23 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-01-15 21:46:23 +0000 |
commit | 71ef29a86b252a4780517fc9b2bf9f7d3dd2d991 (patch) | |
tree | 6906fc0e6297b079fa951857e19f15aefd7143cc /gdb/cli | |
parent | 3f5b7598805c8253c43c989a540a2408c8b685ad (diff) | |
download | gdb-71ef29a86b252a4780517fc9b2bf9f7d3dd2d991.zip gdb-71ef29a86b252a4780517fc9b2bf9f7d3dd2d991.tar.gz gdb-71ef29a86b252a4780517fc9b2bf9f7d3dd2d991.tar.bz2 |
Star wildcard ranges (e.g., "info thread 2.*")
Add support for specifying "all threads of inferior N", by writing "*"
as thread number/range in thread ID lists.
E.g., "info threads 2.*" or "thread apply 2.* bt".
gdb/ChangeLog:
2016-01-15 Pedro Alves <palves@redhat.com>
* NEWS: Mention star wildcard ranges.
* cli/cli-utils.c (get_number_or_range): Check state->in_range first.
(number_range_setup_range): New function.
* cli/cli-utils.h (number_range_setup_range): New declaration.
* thread.c (thread_apply_command): Support star TID ranges.
* tid-parse.c (tid_range_parser_finished)
(tid_range_parser_string, tid_range_parser_skip)
(get_tid_or_range, get_tid_or_range): Handle
TID_RANGE_STATE_STAR_RANGE.
(tid_range_parser_star_range): New function.
* tid-parse.h (enum tid_range_state) <TID_RANGE_STATE_STAR_RANGE>:
New value.
(tid_range_parser_star_range): New declaration.
gdb/doc/ChangeLog:
2016-01-15 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Threads) <thread ID lists>: Document star ranges.
gdb/testsuite/ChangeLog:
2016-01-15 Pedro Alves <palves@redhat.com>
* gdb.multi/tids.exp: Test star wildcard ranges.
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-utils.c | 47 | ||||
-rw-r--r-- | gdb/cli/cli-utils.h | 8 |
2 files changed, 38 insertions, 17 deletions
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index a68b67d..0946db0 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -134,7 +134,21 @@ init_number_or_range (struct get_number_or_range_state *state, int get_number_or_range (struct get_number_or_range_state *state) { - if (*state->string != '-') + if (state->in_range) + { + /* All number-parsing has already been done. Return the next + integer value (one greater than the saved previous value). + Do not advance the token pointer until the end of range is + reached. */ + + if (++state->last_retval == state->end_value) + { + /* End of range reached; advance token pointer. */ + state->string = state->end_ptr; + state->in_range = 0; + } + } + else if (*state->string != '-') { /* Default case: state->string is pointing either to a solo number, or to the first number of a range. */ @@ -165,27 +179,26 @@ get_number_or_range (struct get_number_or_range_state *state) state->in_range = 1; } } - else if (! state->in_range) - error (_("negative value")); else - { - /* state->string points to the '-' that betokens a range. All - number-parsing has already been done. Return the next - integer value (one greater than the saved previous value). - Do not advance the token pointer until the end of range - is reached. */ - - if (++state->last_retval == state->end_value) - { - /* End of range reached; advance token pointer. */ - state->string = state->end_ptr; - state->in_range = 0; - } - } + error (_("negative value")); state->finished = *state->string == '\0'; return state->last_retval; } +/* See documentation in cli-utils.h. */ + +void +number_range_setup_range (struct get_number_or_range_state *state, + int start_value, int end_value, const char *end_ptr) +{ + gdb_assert (start_value > 0); + + state->in_range = 1; + state->end_ptr = end_ptr; + state->last_retval = start_value - 1; + state->end_value = end_value; +} + /* Accept a number and a string-form list of numbers such as is accepted by get_number_or_range. Return TRUE if the number is in the list. diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h index ebf11f2..a31fff5 100644 --- a/gdb/cli/cli-utils.h +++ b/gdb/cli/cli-utils.h @@ -90,6 +90,14 @@ extern void init_number_or_range (struct get_number_or_range_state *state, extern int get_number_or_range (struct get_number_or_range_state *state); +/* Setups STATE such that get_number_or_range returns numbers in range + START_VALUE to END_VALUE. When get_number_or_range returns + END_VALUE, the STATE string is advanced to END_PTR. */ + +extern void number_range_setup_range (struct get_number_or_range_state *state, + int start_value, int end_value, + const char *end_ptr); + /* Accept a number and a string-form list of numbers such as is accepted by get_number_or_range. Return TRUE if the number is in the list. |