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]

[RFC] examine for TYPE_CODE_REF in pascal language PR 11349


  Trying to fix bug report PR 11349,
http://sourceware.org/bugzilla/show_bug.cgi?id=11349
I finally found this:

  -inside x_command, a TYPE_CODE_REF generates a call 
to value_ind, but this generates possibly several dereferencing
if the target type is also a pointer.
  In Free Pascal, with dwarf debug format,
variables passed as 'var' are considered as TYPE_CODE_REF.
  if the variable itself is an ansistring,
this type is simply a type  pointing to a CHAR.

  the function DOIT has one parameter 'by var' called S
of type ANSISTRING.
  If I try to examine as a string this variable
(gdb) x /s S
as S type is a TYPE_CODE_REF, value_ind is called,
but this dereferences the type twice so that we end up with a 
single CHAR value:
hence the error
0x74:    <Address 0x74 out of bounds>

  If I replace value_ind by coerce_ref, everything 
works as I want it for pascal, but I was wandering if
this is not also what other languages would expect.
(gdb) x /s S
0x408094 <$TEST_GDB_BUG_11349$_Ld3>:     'test'

  I do not know what is the expectation for C language
here, and I don't even know how to generate code that 
has variables of type TYPE_CODE_REF from C source.
  Should this change be extended to other languages
or to all languages?

 


Pierre Muller
Pascal language support maintainer for GDB


 
2010-04-30  Pierre Muller  <muller@ics.u-strasbg.fr>

	* printcmd.c (x_command): Only dereference once implicitly for
	TYPE_CODE_REF type for pascal language.

Index: src/gdb/printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.176
diff -u -p -r1.176 printcmd.c
--- src/gdb/printcmd.c	22 Apr 2010 23:15:41 -0000	1.176
+++ src/gdb/printcmd.c	30 Apr 2010 13:12:45 -0000
@@ -1420,7 +1420,12 @@ x_command (char *exp, int from_tty)
       old_chain = make_cleanup (free_current_contents, &expr);
       val = evaluate_expression (expr);
       if (TYPE_CODE (value_type (val)) == TYPE_CODE_REF)
-	val = value_ind (val);
+	{
+	  if (current_language->la_language == language_pascal)
+	    val = coerce_ref (val);
+	  else
+	    val = value_ind (val);
+	}
       /* In rvalue contexts, such as this, functions are coerced into
          pointers to functions.  This makes "x/i main" work.  */
       if (/* last_format == 'i'  && */ 


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