[RFA v2 02/13] Change backtrace_command_1 calling to use flags

Tom Tromey
2017-08-14T03:41:01Z

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-08-13 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(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a754b7d..bd18b53 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2017-08-13 Tom Tromey <tom@tromey.com>

+ * stack.c (backtrace_command_1): Remove "show_locals" parameter,
+ add "flags".
+ (backtrace_command): Remove "fulltrace", add "flags".
+
+2017-08-13 Tom Tromey <tom@tromey.com>
+
* stack.c (backtrace_command): Rewrite command line parsing.

2017-08-11 Pedro Alves <palves@redhat.com>
diff --git a/gdb/stack.c b/gdb/stack.c
index 30d16cb..be83f6d 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -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)
@@ -1889,7 +1887,7 @@ backtrace_command (char *arg, int from_tty)
if (subset_compare (this_arg.get (), "no-filters"))
filters = false;
else if (subset_compare (this_arg.get (), "full"))
- fulltrace = true;
+ flags |= PRINT_LOCALS;
else
{
/* Not a recognized argument, so stop. */
@@ -1902,8 +1900,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
--
2.9.4