This is the mail archive of the gdb-patches@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]

[COMMITTED PATCH] Fix dumping of function arguments.


Hi.

I noticed that the output for function arguments in "mt print type foo"
was not properly aligned, and hard to read (e.g., not numbered).
Function arguments also don't have names but that's because gdb
ignores argument names when reading the dwarf.
That's a separate bug, and there's no reason not to print the name:
it's helpful to the reader to at least know it is NULL.

2014-11-23  Doug Evans  <xdje42@gmail.com>

	* gdbtypes.c (print_args): Renamed from print_arg_types.  Print arg
	number and name if present.  All callers updated.
	(dump_fn_fieldlists): Fix indentation of args.

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b921c64..976d56f 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3509,14 +3509,18 @@ print_bit_vector (B_TYPE *bits, int nbits)
    situation.  */
 
 static void
-print_arg_types (struct field *args, int nargs, int spaces)
+print_args (struct field *args, int nargs, int spaces)
 {
   if (args != NULL)
     {
       int i;
 
       for (i = 0; i < nargs; i++)
-	recursive_dump_type (args[i].type, spaces + 2);
+	{
+	  printfi_filtered (spaces, "[%d] name '%s'\n", i,
+			    args[i].name != NULL ? args[i].name : "<NULL>");
+	  recursive_dump_type (args[i].type, spaces + 2);
+	}
     }
 }
 
@@ -3574,11 +3578,9 @@ dump_fn_fieldlists (struct type *type, int spaces)
 	  gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), 
 				  gdb_stdout);
 	  printf_filtered ("\n");
-
-	  print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx),
-			   TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, 
-							     overload_idx)),
-			   spaces);
+	  print_args (TYPE_FN_FIELD_ARGS (f, overload_idx),
+		      TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, overload_idx)),
+		      spaces + 8 + 2);
 	  printfi_filtered (spaces + 8, "fcontext ");
 	  gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx),
 				  gdb_stdout);


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