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]

src/gdb ada-lang.c ada-lang.h ada-valprint.c v ...


CVSROOT:	/cvs/src
Module name:	src
Changes by:	brobecke@sourceware.org	2010-04-20 22:26:57

Modified files:
	gdb            : ada-lang.c ada-lang.h ada-valprint.c valprint.c 
	                 ChangeLog 
	gdb/testsuite  : ChangeLog 
Added files:
	gdb/testsuite/gdb.ada: dyn_loc.exp 
	gdb/testsuite/gdb.ada/dyn_loc: p.adb pack.adb pack.ads 

Log message:
	Wrong value printed by info locals for dynamic object.
	
	The problem is printing the wrong value for dynamic local variables
	when using the "info locals" command. Consider the following code:
	
	procedure Print (I1 : Positive; I2 : Positive) is
	type My_String is array (I1 .. I2) of Character;
	I : My_String := (others => 'A');
	S : String (1 .. I2 + 3) := (others => ' ');
	begin
	S (I1 .. I2) := String (I); --  BREAK
	Put_Line (S);
	end Print;
	
	After the debugger stopped at BREAK, we try printing all local variables.
	Here is what we get:
	
	(gdb) info locals
	i = "["00"]["00"]"
	s = "["00"]["00"]["00"]["00"]["00"]["00"]["00"]["00"]"
	
	Curiously, printing their value using the "print" command works:
	
	(gdb) print i
	$1 = "AA"
	(gdb) print s
	$2 = "        "
	
	We traced the problem to trying to get the contents of a variable
	(call to value_contents) before "fix'ing" it.  For those not familiar
	with the Ada language support, "fixing" a value consists of swapping
	the value's dynamic type with a static version that is appropriate
	for our actual value.  As a result, the dynamic type was used to
	determine the value size, which is zero, and thus the value contents
	was empty.
	
	gdb/ChangeLog:
	
	* valprint.c (common_val_print): Fix the value before extracting
	its contents.
	* ada-lang.c (ada_to_fixed_value): Make this function extern.
	* ada-lang.h (ada_to_fixed_value): New function declaration.
	* ada-valprint.c (ada_value_print): Use ada_to_fixed_value
	to avoid code duplication and fix a bug in the handling of
	fixed types contents.
	
	gdb/testsuite/ChangeLog:
	
	* gdb.ada/dyn_loc: New testcase.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ada-lang.c.diff?cvsroot=src&r1=1.253&r2=1.254
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ada-lang.h.diff?cvsroot=src&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ada-valprint.c.diff?cvsroot=src&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/valprint.c.diff?cvsroot=src&r1=1.90&r2=1.91
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11649&r2=1.11650
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.ada/dyn_loc.exp.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.ada/dyn_loc/p.adb.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.ada/dyn_loc/pack.adb.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.ada/dyn_loc/pack.ads.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2240&r2=1.2241


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