Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfc] Ada simplification: ada_val_print_1
@ 2009-05-14 11:37 Ulrich Weigand
  2009-05-15 14:48 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2009-05-14 11:37 UTC (permalink / raw)
  To: gdb-patches, brobecker

Hello,

another problematic Ada case: ada_val_print_1 initializes a static type
variable to the result of "make_pointer_type" -- which (implicitly today,
but explicitly in the future) depends on an architecture to determine
the size of a pointer.  This could break in a multi-arch scenario.

The whole logic there seems to have the sole purpose of printing a
character string stored at some memory location as a result of an
inferior call.  We do have a routine val_print_string that should be
able to do just that, without the need to create a dummy type ...

Joel, is this OK?

Bye,
Ulrich



ChangeLog:

	* ada-valprint.c (ada_val_print_1): Use val_print_string to print
	result of ada_vax_float_print_function inferior call.


Index: gdb-head/gdb/ada-valprint.c
===================================================================
--- gdb-head.orig/gdb/ada-valprint.c
+++ gdb-head/gdb/ada-valprint.c
@@ -739,22 +739,10 @@ ada_val_print_1 (struct type *type, cons
 	  struct value *func = ada_vax_float_print_function (type);
 	  if (func != 0)
 	    {
-	      static struct type *parray_of_char = NULL;
-	      struct value *printable_val;
-
-	      if (parray_of_char == NULL)
-		parray_of_char =
-		  make_pointer_type
-		  (create_array_type
-		   (NULL, builtin_type_true_char,
-		    create_range_type (NULL, builtin_type_int32, 0, 32)), NULL);
-
-	      printable_val =
-		value_ind (value_cast (parray_of_char,
-				       call_function_by_hand (func, 1,
-							      &val)));
-
-	      fprintf_filtered (stream, "%s", value_contents (printable_val));
+	      CORE_ADDR addr;
+	      addr = value_as_address (call_function_by_hand (func, 1, &val));
+	      val_print_string (builtin_type_true_char,
+				addr, -1, stream, options);
 	      return 0;
 	    }
 	  /* No special printing function.  Do as best we can.  */
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [rfc] Ada simplification: ada_val_print_1
  2009-05-14 11:37 [rfc] Ada simplification: ada_val_print_1 Ulrich Weigand
@ 2009-05-15 14:48 ` Joel Brobecker
  2009-05-18 13:52   ` Ulrich Weigand
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2009-05-15 14:48 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: gdb-patches

> 	* ada-valprint.c (ada_val_print_1): Use val_print_string to print
> 	result of ada_vax_float_print_function inferior call.

Looks good to me.

Thanks, Ulrich.
-- 
Joel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [rfc] Ada simplification: ada_val_print_1
  2009-05-15 14:48 ` Joel Brobecker
@ 2009-05-18 13:52   ` Ulrich Weigand
  0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2009-05-18 13:52 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Joel Brobecker wrote:
> > 	* ada-valprint.c (ada_val_print_1): Use val_print_string to print
> > 	result of ada_vax_float_print_function inferior call.
> 
> Looks good to me.

I've checked this in as well.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-18 13:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-14 11:37 [rfc] Ada simplification: ada_val_print_1 Ulrich Weigand
2009-05-15 14:48 ` Joel Brobecker
2009-05-18 13:52   ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox