From patchwork Thu Apr 13 11:46:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 20028 Received: (qmail 99261 invoked by alias); 13 Apr 2017 11:46:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 98247 invoked by uid 89); 13 Apr 2017 11:46:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=1238, 1377 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Apr 2017 11:46:48 +0000 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3DBhm25019833 for ; Thu, 13 Apr 2017 07:46:48 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 29t1rjhvb7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 13 Apr 2017 07:46:47 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Apr 2017 12:46:46 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 13 Apr 2017 12:46:45 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3DBkiM439976966; Thu, 13 Apr 2017 11:46:44 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 469A5A404D; Thu, 13 Apr 2017 12:45:53 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 158DAA4053; Thu, 13 Apr 2017 12:45:53 +0100 (BST) Received: from oc1027705133.ibm.com (unknown [9.152.212.162]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 13 Apr 2017 12:45:53 +0100 (BST) From: Andreas Arnez To: Yao Qi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/9] Add test for modifiable DWARF locations References: <1491586736-21296-1-git-send-email-arnez@linux.vnet.ibm.com> <1491586736-21296-2-git-send-email-arnez@linux.vnet.ibm.com> <86mvbkaelr.fsf@gmail.com> Date: Thu, 13 Apr 2017 13:46:42 +0200 In-Reply-To: <86mvbkaelr.fsf@gmail.com> (Yao Qi's message of "Thu, 13 Apr 2017 09:36:32 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17041311-0040-0000-0000-0000036888DC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041311-0041-0000-0000-000024F2FA10 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-13_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704130099 X-IsSubscribed: yes On Thu, Apr 13 2017, Yao Qi wrote: > Andreas Arnez 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 --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 . -# 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}