This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Factor out pointer printing code from c_val_print


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1c67f0326351d9c521692ceca92f93cb0de9bf2e

commit 1c67f0326351d9c521692ceca92f93cb0de9bf2e
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Thu Jul 9 11:18:12 2015 -0400

    Factor out pointer printing code from c_val_print
    
    gdb/ChangeLog:
    
    	* c-valprint.c (c_val_print): Factor out pointer printing code
    	to ...
    	(c_val_print_ptr): ... this new function.

Diff:
---
 gdb/ChangeLog    |  6 ++++++
 gdb/c-valprint.c | 63 ++++++++++++++++++++++++++++++++++----------------------
 2 files changed, 44 insertions(+), 25 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f2ac3a6..54f7374 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2015-07-09  Simon Marchi  <simon.marchi@ericsson.com>
 
+	* c-valprint.c (c_val_print): Factor out pointer printing code
+	to ...
+	(c_val_print_ptr): ... this new function.
+
+2015-07-09  Simon Marchi  <simon.marchi@ericsson.com>
+
 	* c-valprint.c (c_valprint): Factor our array printing code from
 	c_val_print to ...
 	(c_val_print_array): ... this new function.
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 9f9d999..4853575 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -334,6 +334,42 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+/* c_val_print helper for TYPE_CODE_PTR.  */
+
+static void
+c_val_print_ptr (struct type *type, const gdb_byte *valaddr,
+		 int embedded_offset, struct ui_file *stream, int recurse,
+		 const struct value *original_value,
+		 const struct value_print_options *options)
+{
+  if (options->format && options->format != 's')
+    {
+      val_print_scalar_formatted (type, valaddr, embedded_offset,
+				  original_value, options, 0, stream);
+    }
+  else if (options->vtblprint && cp_is_vtbl_ptr_type (type))
+    {
+      /* Print the unmangled name if desired.  */
+      /* Print vtable entry - we only get here if we ARE using
+	 -fvtable_thunks.  (Otherwise, look under
+	 TYPE_CODE_STRUCT.)  */
+      CORE_ADDR addr
+	= extract_typed_address (valaddr + embedded_offset, type);
+      struct gdbarch *gdbarch = get_type_arch (type);
+
+      print_function_pointer_address (options, gdbarch, addr, stream);
+    }
+  else
+    {
+      struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
+      struct type *elttype = check_typedef (unresolved_elttype);
+      CORE_ADDR addr = unpack_pointer (type, valaddr + embedded_offset);
+
+      print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr,
+			      embedded_offset, addr, stream, recurse, options);
+    }
+}
+
 /* See val_print for a description of the various parameters of this
    function; they are identical.  */
 
@@ -345,9 +381,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
 	     const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
-  struct type *elttype, *unresolved_elttype;
   struct type *unresolved_type = type;
-  CORE_ADDR addr;
 
   CHECK_TYPEDEF (type);
   switch (TYPE_CODE (type))
@@ -362,29 +396,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_PTR:
-      if (options->format && options->format != 's')
-	{
-	  val_print_scalar_formatted (type, valaddr, embedded_offset,
-				      original_value, options, 0, stream);
-	  break;
-	}
-      if (options->vtblprint && cp_is_vtbl_ptr_type (type))
-	{
-	  /* Print the unmangled name if desired.  */
-	  /* Print vtable entry - we only get here if we ARE using
-	     -fvtable_thunks.  (Otherwise, look under
-	     TYPE_CODE_STRUCT.)  */
-	  CORE_ADDR addr
-	    = extract_typed_address (valaddr + embedded_offset, type);
-
-	  print_function_pointer_address (options, gdbarch, addr, stream);
-	  break;
-	}
-      unresolved_elttype = TYPE_TARGET_TYPE (type);
-      elttype = check_typedef (unresolved_elttype);
-      addr = unpack_pointer (type, valaddr + embedded_offset);
-      print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr,
-			      embedded_offset, addr, stream, recurse, options);
+      c_val_print_ptr (type, valaddr, embedded_offset, stream, recurse,
+		       original_value, options);
       break;
 
     case TYPE_CODE_UNION:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]