[PATCH] Propagate record_print_flags

Simon Marchi simon.marchi@ericsson.com
Thu Mar 1 13:48:00 GMT 2018


These flags are returned as an int by get_call_history_modifiers, and
get cast back to record_print_flags in the btrace code.  Instead, we can
make the arguments of that type from start to end.

gdb/ChangeLog:

	* record.c (get_call_history_modifiers): Return a
	record_print_flags.
	(cmd_record_call_history): Adjust.
	* record-btrace.c (record_btrace_call_history): Adjust.
	(record_btrace_call_history_range): Adjust.
	(record_btrace_call_history_from): Adjust.
	* target-debug.h (target_debug_print_record_print_flags): New.
	* target-delegates.c: Re-generate.
	* target.c (target_call_history): Change flags type.
	(target_call_history_from): Likewise.
	(target_call_history_range): Likewise.
	* target.h (struct target_ops) <target_call_history>: Likewise.
	(target_call_history_from): Likewise.
	(target_call_history_range): Likewise.
---
 gdb/record-btrace.c    | 16 +++++++---------
 gdb/record.c           | 15 +++++----------
 gdb/target-debug.h     |  2 ++
 gdb/target-delegates.c | 24 ++++++++++++------------
 gdb/target.c           |  6 +++---
 gdb/target.h           | 14 ++++++++------
 6 files changed, 37 insertions(+), 40 deletions(-)

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 2464672..d9a1dc5 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1074,14 +1074,14 @@ btrace_call_history (struct ui_out *uiout,
 /* The to_call_history method of target record-btrace.  */
 
 static void
-record_btrace_call_history (struct target_ops *self, int size, int int_flags)
+record_btrace_call_history (struct target_ops *self, int size,
+			    record_print_flags flags)
 {
   struct btrace_thread_info *btinfo;
   struct btrace_call_history *history;
   struct btrace_call_iterator begin, end;
   struct ui_out *uiout;
   unsigned int context, covered;
-  record_print_flags flags = (enum record_print_flag) int_flags;
 
   uiout = current_uiout;
   ui_out_emit_tuple tuple_emitter (uiout, "insn history");
@@ -1095,7 +1095,7 @@ record_btrace_call_history (struct target_ops *self, int size, int int_flags)
     {
       struct btrace_insn_iterator *replay;
 
-      DEBUG ("call-history (0x%x): %d", int_flags, size);
+      DEBUG ("call-history (0x%x): %d", (int) flags, size);
 
       /* If we're replaying, we start at the replay position.  Otherwise, we
 	 start at the tail of the trace.  */
@@ -1130,7 +1130,7 @@ record_btrace_call_history (struct target_ops *self, int size, int int_flags)
       begin = history->begin;
       end = history->end;
 
-      DEBUG ("call-history (0x%x): %d, prev: [%u; %u)", int_flags, size,
+      DEBUG ("call-history (0x%x): %d, prev: [%u; %u)", (int) flags, size,
 	     btrace_call_number (&begin), btrace_call_number (&end));
 
       if (size < 0)
@@ -1163,21 +1163,20 @@ record_btrace_call_history (struct target_ops *self, int size, int int_flags)
 static void
 record_btrace_call_history_range (struct target_ops *self,
 				  ULONGEST from, ULONGEST to,
-				  int int_flags)
+				  record_print_flags flags)
 {
   struct btrace_thread_info *btinfo;
   struct btrace_call_iterator begin, end;
   struct ui_out *uiout;
   unsigned int low, high;
   int found;
-  record_print_flags flags = (enum record_print_flag) int_flags;
 
   uiout = current_uiout;
   ui_out_emit_tuple tuple_emitter (uiout, "func history");
   low = from;
   high = to;
 
-  DEBUG ("call-history (0x%x): [%u; %u)", int_flags, low, high);
+  DEBUG ("call-history (0x%x): [%u; %u)", (int) flags, low, high);
 
   /* Check for wrap-arounds.  */
   if (low != from || high != to)
@@ -1213,10 +1212,9 @@ record_btrace_call_history_range (struct target_ops *self,
 static void
 record_btrace_call_history_from (struct target_ops *self,
 				 ULONGEST from, int size,
-				 int int_flags)
+				 record_print_flags flags)
 {
   ULONGEST begin, end, context;
-  record_print_flags flags = (enum record_print_flag) int_flags;
 
   context = abs (size);
   if (context == 0)
diff --git a/gdb/record.c b/gdb/record.c
index 9a47614..cd83b99 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -615,14 +615,11 @@ cmd_record_insn_history (const char *arg, int from_tty)
 
 /* Read function-call-history modifiers from an argument string.  */
 
-static int
+static record_print_flags
 get_call_history_modifiers (const char **arg)
 {
-  int modifiers;
-  const char *args;
-
-  modifiers = 0;
-  args = *arg;
+  record_print_flags modifiers = 0;
+  const char *args = *arg;
 
   if (args == NULL)
     return modifiers;
@@ -672,13 +669,11 @@ get_call_history_modifiers (const char **arg)
 static void
 cmd_record_call_history (const char *arg, int from_tty)
 {
-  int flags, size;
-
   require_record_target ();
 
-  flags = get_call_history_modifiers (&arg);
+  record_print_flags flags = get_call_history_modifiers (&arg);
 
-  size = command_size_to_target_size (record_call_history_size);
+  int size = command_size_to_target_size (record_call_history_size);
 
   if (arg == NULL || *arg == 0 || strcmp (arg, "+") == 0)
     target_call_history (size, flags);
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index d7fc001..71d1a3f 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -172,6 +172,8 @@
   target_debug_do_print (host_address_to_string (X.data ()))
 #define target_debug_print_inferior_p(inf) \
   target_debug_do_print (host_address_to_string (inf))
+#define target_debug_print_record_print_flags(X) \
+  target_debug_do_print (plongest (X))
 
 static void
 target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status)
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index c7ebdbf..2c5787f 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -3961,20 +3961,20 @@ debug_insn_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2,
 }
 
 static void
-delegate_call_history (struct target_ops *self, int arg1, int arg2)
+delegate_call_history (struct target_ops *self, int arg1, record_print_flags arg2)
 {
   self = self->beneath;
   self->to_call_history (self, arg1, arg2);
 }
 
 static void
-tdefault_call_history (struct target_ops *self, int arg1, int arg2)
+tdefault_call_history (struct target_ops *self, int arg1, record_print_flags arg2)
 {
   tcomplain ();
 }
 
 static void
-debug_call_history (struct target_ops *self, int arg1, int arg2)
+debug_call_history (struct target_ops *self, int arg1, record_print_flags arg2)
 {
   fprintf_unfiltered (gdb_stdlog, "-> %s->to_call_history (...)\n", debug_target.to_shortname);
   debug_target.to_call_history (&debug_target, arg1, arg2);
@@ -3983,25 +3983,25 @@ debug_call_history (struct target_ops *self, int arg1, int arg2)
   fputs_unfiltered (", ", gdb_stdlog);
   target_debug_print_int (arg1);
   fputs_unfiltered (", ", gdb_stdlog);
-  target_debug_print_int (arg2);
+  target_debug_print_record_print_flags (arg2);
   fputs_unfiltered (")\n", gdb_stdlog);
 }
 
 static void
-delegate_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+delegate_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, record_print_flags arg3)
 {
   self = self->beneath;
   self->to_call_history_from (self, arg1, arg2, arg3);
 }
 
 static void
-tdefault_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+tdefault_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, record_print_flags arg3)
 {
   tcomplain ();
 }
 
 static void
-debug_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int arg3)
+debug_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, record_print_flags arg3)
 {
   fprintf_unfiltered (gdb_stdlog, "-> %s->to_call_history_from (...)\n", debug_target.to_shortname);
   debug_target.to_call_history_from (&debug_target, arg1, arg2, arg3);
@@ -4012,25 +4012,25 @@ debug_call_history_from (struct target_ops *self, ULONGEST arg1, int arg2, int a
   fputs_unfiltered (", ", gdb_stdlog);
   target_debug_print_int (arg2);
   fputs_unfiltered (", ", gdb_stdlog);
-  target_debug_print_int (arg3);
+  target_debug_print_record_print_flags (arg3);
   fputs_unfiltered (")\n", gdb_stdlog);
 }
 
 static void
-delegate_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+delegate_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, record_print_flags arg3)
 {
   self = self->beneath;
   self->to_call_history_range (self, arg1, arg2, arg3);
 }
 
 static void
-tdefault_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+tdefault_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, record_print_flags arg3)
 {
   tcomplain ();
 }
 
 static void
-debug_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, int arg3)
+debug_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2, record_print_flags arg3)
 {
   fprintf_unfiltered (gdb_stdlog, "-> %s->to_call_history_range (...)\n", debug_target.to_shortname);
   debug_target.to_call_history_range (&debug_target, arg1, arg2, arg3);
@@ -4041,7 +4041,7 @@ debug_call_history_range (struct target_ops *self, ULONGEST arg1, ULONGEST arg2,
   fputs_unfiltered (", ", gdb_stdlog);
   target_debug_print_ULONGEST (arg2);
   fputs_unfiltered (", ", gdb_stdlog);
-  target_debug_print_int (arg3);
+  target_debug_print_record_print_flags (arg3);
   fputs_unfiltered (")\n", gdb_stdlog);
 }
 
diff --git a/gdb/target.c b/gdb/target.c
index db7c09b..197e7ff 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3809,7 +3809,7 @@ target_insn_history_range (ULONGEST begin, ULONGEST end,
 /* See target.h.  */
 
 void
-target_call_history (int size, int flags)
+target_call_history (int size, record_print_flags flags)
 {
   current_target.to_call_history (&current_target, size, flags);
 }
@@ -3817,7 +3817,7 @@ target_call_history (int size, int flags)
 /* See target.h.  */
 
 void
-target_call_history_from (ULONGEST begin, int size, int flags)
+target_call_history_from (ULONGEST begin, int size, record_print_flags flags)
 {
   current_target.to_call_history_from (&current_target, begin, size, flags);
 }
@@ -3825,7 +3825,7 @@ target_call_history_from (ULONGEST begin, int size, int flags)
 /* See target.h.  */
 
 void
-target_call_history_range (ULONGEST begin, ULONGEST end, int flags)
+target_call_history_range (ULONGEST begin, ULONGEST end, record_print_flags flags)
 {
   current_target.to_call_history_range (&current_target, begin, end, flags);
 }
diff --git a/gdb/target.h b/gdb/target.h
index e8972ca..de56213 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1217,7 +1217,7 @@ struct target_ops
     /* Print a function trace of the recorded execution trace.
        If SIZE < 0, print abs (SIZE) preceding functions; otherwise, print SIZE
        succeeding functions.  */
-    void (*to_call_history) (struct target_ops *, int size, int flags)
+    void (*to_call_history) (struct target_ops *, int size, record_print_flags flags)
       TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Print a function trace of the recorded execution trace starting
@@ -1225,13 +1225,13 @@ struct target_ops
        If SIZE < 0, print abs (SIZE) functions before FROM; otherwise, print
        SIZE functions after FROM.  */
     void (*to_call_history_from) (struct target_ops *,
-				  ULONGEST begin, int size, int flags)
+				  ULONGEST begin, int size, record_print_flags flags)
       TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Print a function trace of an execution trace section from function BEGIN
        (inclusive) to function END (inclusive).  */
     void (*to_call_history_range) (struct target_ops *,
-				   ULONGEST begin, ULONGEST end, int flags)
+				   ULONGEST begin, ULONGEST end, record_print_flags flags)
       TARGET_DEFAULT_NORETURN (tcomplain ());
 
     /* Nonzero if TARGET_OBJECT_LIBRARIES_SVR4 may be read with a
@@ -2492,13 +2492,15 @@ extern void target_insn_history_range (ULONGEST begin, ULONGEST end,
 				       gdb_disassembly_flags flags);
 
 /* See to_call_history.  */
-extern void target_call_history (int size, int flags);
+extern void target_call_history (int size, record_print_flags flags);
 
 /* See to_call_history_from.  */
-extern void target_call_history_from (ULONGEST begin, int size, int flags);
+extern void target_call_history_from (ULONGEST begin, int size,
+				      record_print_flags flags);
 
 /* See to_call_history_range.  */
-extern void target_call_history_range (ULONGEST begin, ULONGEST end, int flags);
+extern void target_call_history_range (ULONGEST begin, ULONGEST end,
+				       record_print_flags flags);
 
 /* See to_prepare_to_generate_core.  */
 extern void target_prepare_to_generate_core (void);
-- 
2.7.4



More information about the Gdb-patches mailing list