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 ChangeLog ada-valprint.c testsuite/Cha ...


CVSROOT:	/cvs/src
Module name:	src
Changes by:	brobecke@sourceware.org	2012-02-29 19:33:02

Modified files:
	gdb            : ChangeLog ada-valprint.c 
	gdb/testsuite  : ChangeLog 
Added files:
	gdb/testsuite/gdb.ada: aliased_array.exp 
	gdb/testsuite/gdb.ada/aliased_array: foo.adb pck.adb pck.ads 

Log message:
	[Ada] Handle reference to array descriptors
	
	This patch is to help handle aliased array variables, such as:
	
	type Bounded is array (Integer range <>) of Integer;
	function New_Bounded (Low, High : Integer) return Bounded;
	BT : aliased Bounded := New_Bounded (Low => 1, High => 3);
	
	In that case, the compiler describes variable "BT" as a reference
	to a thin pointer, and GDB is unable to print its value:
	
	(gdb) p bt
	$1 =
	
	The problems starts when ada_value_print deconstructs the struct
	value into contents and address in order to call val_print. It
	turns out in this case that "bt" is not an lval. In the debug
	information, this variable's location is described as:
	
	.uleb128 0xd    # (DIE (0xe0) DW_TAG_variable)
	.ascii "bt\0"   # DW_AT_name
	[...]
	.byte   0x6     # DW_AT_location
	.byte   0x91    # DW_OP_fbreg
	.sleb128 -56
	.byte   0x6     # DW_OP_deref
	.byte   0x23    # DW_OP_plus_uconst
	.uleb128 0x8
	.byte   0x9f    # DW_OP_stack_value
	
	So, when ada_value_print passes the bt's (value) address, it passes
	in effect a meaningless address. The problem continues shortly after
	when ada_val_print_1 re-creates the value from the contents and address.
	The value has become an lval_memory, with a null address.
	
	As a result, we trigger a memory error later on, while trying to
	read the array bounds in order to transform our value into a simple
	array.
	
	To avoid the problem entirely, the fix is to coerce references before
	transforming array descriptors into simple arrays.
	
	gdb/ChangeLog:
	
	* ada-valprint.c (ada_val_print_1): If our value is a reference
	to an array descriptor, dereference it before converting it
	to a simple array.
	
	gdb/testsuite/ChangeLog:
	
	* gdb.ada/aliased_array: New testcase.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13882&r2=1.13883
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ada-valprint.c.diff?cvsroot=src&r1=1.85&r2=1.86
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3102&r2=1.3103
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.ada/aliased_array.exp.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.ada/aliased_array/foo.adb.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.ada/aliased_array/pck.adb.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.ada/aliased_array/pck.ads.diff?cvsroot=src&r1=NONE&r2=1.1


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