diff mbox

[1/9] Add test for modifiable DWARF locations

Message ID m3zifk8r8d.fsf@oc1027705133.ibm.com
State New
Headers show

Commit Message

Andreas Arnez April 13, 2017, 11:46 a.m. UTC
On Thu, Apr 13 2017, Yao Qi wrote:

> Andreas Arnez <arnez@linux.vnet.ibm.com> writes:
>
>> This adds a test for read/write access to variables with various types of
>> DWARF locations.  It uses register- and memory locations and composite
>> locations with register- and memory pieces.
>
> The last line should be put into the introduction comment of
> gdb.dwarf2/var-access.exp.

OK.

[...]

>> +# Make some DWARF for the test.
>> +
>> +set asm_file [standard_output_file $srcfile2]
>> +Dwarf::assemble $asm_file {
>> +    global srcdir subdir srcfile
>> +    global dwarf_regnum regname
>> +
>> +    set main_func \
>> +	[function_range main [list ${srcdir}/${subdir}/$srcfile]]
>
>> +
>> +	    DW_TAG_subprogram {
>> +		{name "main"}
>> +		{DW_AT_external 1 flag}
>> +		{low_pc [lindex $main_func 0] DW_FORM_addr}
>> +		{high_pc [lindex $main_func 1] DW_FORM_udata}
>
> You can use MACRO_AT_func, it can replace name, low_pc and high_pc.
> Also, you don't need to call function_range above.

Right, I missed that, thanks.

>
>> +	    } {
>> +		# Simple memory location.
>> +		DW_TAG_variable {
>> +		    {name "a"}
>> +		    {type :$array_a8_label}
>> +		    {location {
>> +			addr $buf_var
>> +		    } SPECIAL_expr}
>> +		}
>> +		# Memory pieces.
>
> Nit: we can also describe where are these pieces in comments, like
>
>                 # Memory pieces, two bytes from &buf[0], and two
>                 # bytes from &buf[2].

The other way around ;-)

>
>> +		DW_TAG_variable {
>> +		    {name "s1"}
>> +		    {type :$struct_s_label}
>> +		    {location {
>> +			addr $buf_var
>> +			plus_uconst 2
>> +			piece 2
>> +			addr $buf_var
>> +			piece 2
>> +		    } SPECIAL_expr}
>> +		}
>> +		# Register- and memory pieces.
>
> Likewise.
>
> OK with the changes.

Thanks, updated the patch with the delta patch below.  Also updated the
follow-on patches with similar comments for the composite locations in
var-access.exp.

--
Andreas
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.dwarf2/var-access.exp b/gdb/testsuite/gdb.dwarf2/var-access.exp
index ee93b93..4d6c9ca 100644
--- a/gdb/testsuite/gdb.dwarf2/var-access.exp
+++ b/gdb/testsuite/gdb.dwarf2/var-access.exp
@@ -13,7 +13,9 @@ 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test reading/writing variables with non-trivial DWARF locations.
+# Test reading/writing variables with non-trivial DWARF locations.  In
+# particular the test uses register- and memory locations as well as
+# composite locations with register- and memory pieces.
 
 load_lib dwarf.exp
 
@@ -51,8 +53,6 @@  Dwarf::assemble $asm_file {
     global srcdir subdir srcfile
     global dwarf_regnum regname
 
-    set main_func \
-	[function_range main [list ${srcdir}/${subdir}/$srcfile]]
     set buf_var [gdb_target_symbol buf]
 
     cu {} {
@@ -112,10 +112,8 @@  Dwarf::assemble $asm_file {
 	    }
 
 	    DW_TAG_subprogram {
-		{name "main"}
+		{MACRO_AT_func { main ${srcdir}/${subdir}/${srcfile} }}
 		{DW_AT_external 1 flag}
-		{low_pc [lindex $main_func 0] DW_FORM_addr}
-		{high_pc [lindex $main_func 1] DW_FORM_udata}
 	    } {
 		# Simple memory location.
 		DW_TAG_variable {
@@ -125,7 +123,8 @@  Dwarf::assemble $asm_file {
 			addr $buf_var
 		    } SPECIAL_expr}
 		}
-		# Memory pieces.
+		# Memory pieces: two bytes from &buf[2], and two bytes
+		# from &buf[0].
 		DW_TAG_variable {
 		    {name "s1"}
 		    {type :$struct_s_label}
@@ -137,7 +136,8 @@  Dwarf::assemble $asm_file {
 			piece 2
 		    } SPECIAL_expr}
 		}
-		# Register- and memory pieces.
+		# Register- and memory pieces: one byte each from r0,
+		# &buf[4], r1, and &buf[5].
 		DW_TAG_variable {
 		    {name "s2"}
 		    {type :$struct_s_label}