[RFA,02/10] Change backtrace_command_1 calling to use flags
Commit Message
The next patch will add more flags to backtrace_command_1; and rather
than add another boolean argument, this patch changes it to accept a
flags value.
ChangeLog
2017-04-25 Tom Tromey <tom@tromey.com>
* stack.c (backtrace_command_1): Remove "show_locals" parameter,
add "flags".
(backtrace_command): Remove "fulltrace", add "flags".
---
gdb/ChangeLog | 6 ++++++
gdb/stack.c | 15 ++++++---------
2 files changed, 12 insertions(+), 9 deletions(-)
Comments
On 25/04/17 20:41, Tom Tromey wrote:
> The next patch will add more flags to backtrace_command_1; and rather
> than add another boolean argument, this patch changes it to accept a
> flags value.
Patch LGTM.
Cheers,
Phil
On 04/25/2017 08:41 PM, Tom Tromey wrote:
> @@ -1891,7 +1889,7 @@ backtrace_command (char *arg, int from_tty)
> if (subset_compare (this_arg, "no-filters"))
> filters = false;
> else if (subset_compare (this_arg, "full"))
> - fulltrace = true;
> + flags |= PRINT_LOCALS;
> else
> {
> /* Not a recognized argument, so stop. */
> @@ -1906,8 +1904,7 @@ backtrace_command (char *arg, int from_tty)
> arg = NULL;
> }
>
> - backtrace_command_1 (arg, fulltrace /* show_locals */,
> - !filters /* no frame-filters */, from_tty);
> + backtrace_command_1 (arg, flags, !filters /* no frame-filters */, from_tty);
> }
>
Looks fine.
(We should really make enum frame_filter_flags be an enum-flags.)
Thanks,
Pedro Alves
@@ -1,5 +1,11 @@
2017-04-25 Tom Tromey <tom@tromey.com>
+ * stack.c (backtrace_command_1): Remove "show_locals" parameter,
+ add "flags".
+ (backtrace_command): Remove "fulltrace", add "flags".
+
+2017-04-25 Tom Tromey <tom@tromey.com>
+
* stack.c (backtrace_command): Rewrite command line parsing.
2017-04-25 Yao Qi <yao.qi@linaro.org>
@@ -1714,7 +1714,7 @@ frame_info (char *addr_exp, int from_tty)
frames. */
static void
-backtrace_command_1 (char *count_exp, int show_locals, int no_filters,
+backtrace_command_1 (char *count_exp, int flags, int no_filters,
int from_tty)
{
struct frame_info *fi;
@@ -1795,11 +1795,9 @@ backtrace_command_1 (char *count_exp, int show_locals, int no_filters,
if (! no_filters)
{
- int flags = PRINT_LEVEL | PRINT_FRAME_INFO | PRINT_ARGS;
enum ext_lang_frame_args arg_type;
- if (show_locals)
- flags |= PRINT_LOCALS;
+ flags |= PRINT_LEVEL | PRINT_FRAME_INFO | PRINT_ARGS;
if (!strcmp (print_frame_arguments, "scalars"))
arg_type = CLI_SCALAR_VALUES;
@@ -1827,7 +1825,7 @@ backtrace_command_1 (char *count_exp, int show_locals, int no_filters,
the frame->prev field gets set to NULL in that case). */
print_frame_info (fi, 1, LOCATION, 1, 0);
- if (show_locals)
+ if ((flags & PRINT_LOCALS) != 0)
{
struct frame_id frame_id = get_frame_id (fi);
@@ -1868,7 +1866,7 @@ backtrace_command_1 (char *count_exp, int show_locals, int no_filters,
static void
backtrace_command (char *arg, int from_tty)
{
- bool fulltrace = false;
+ int flags = 0;
bool filters = true;
if (arg)
@@ -1891,7 +1889,7 @@ backtrace_command (char *arg, int from_tty)
if (subset_compare (this_arg, "no-filters"))
filters = false;
else if (subset_compare (this_arg, "full"))
- fulltrace = true;
+ flags |= PRINT_LOCALS;
else
{
/* Not a recognized argument, so stop. */
@@ -1906,8 +1904,7 @@ backtrace_command (char *arg, int from_tty)
arg = NULL;
}
- backtrace_command_1 (arg, fulltrace /* show_locals */,
- !filters /* no frame-filters */, from_tty);
+ backtrace_command_1 (arg, flags, !filters /* no frame-filters */, from_tty);
}
/* Iterate over the local variables of a block B, calling CB with