From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24534 invoked by alias); 6 Feb 2014 16:27:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 24524 invoked by uid 89); 6 Feb 2014 16:27:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga01.intel.com Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Feb 2014 16:27:50 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 06 Feb 2014 08:27:40 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 06 Feb 2014 08:27:39 -0800 Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [172.28.50.210]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s16GRcE9031067; Thu, 6 Feb 2014 16:27:38 GMT Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [127.0.0.1]) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8) with ESMTP id s16GRbX9025294; Thu, 6 Feb 2014 17:27:38 +0100 Received: (from sagovic@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id s16GRaLM025293; Thu, 6 Feb 2014 17:27:36 +0100 From: Sanimir Agovic To: tromey@redhat.com, brobecker@adacore.com Cc: keven.boell@intel.com, gdb-patches@sourceware.org Subject: [PATCH v5 00/15] C99 variable length array support Date: Thu, 06 Feb 2014 16:27:00 -0000 Message-Id: <1391704056-25246-1-git-send-email-sanimir.agovic@intel.com> X-IsSubscribed: yes X-SW-Source: 2014-02/txt/msg00097.txt.bz2 Hello, this patch series (v5) add C99 variable length support to gdb. It allows the user to evaluate a vla like an ordinary static array e.g. print its elements instead of printing the pointer to the array. In addition the size of a vla can be retrieved with gdbs builtin sizeof operator. 1| void foo (size_t n) { 2| int ary[n]; 3| memset(ary, 0, sizeof(ary)); 4| } (gdb) print ary $1 = {0 } (gdb) print sizeof ary $2 = 168 Changes in v5 ============= All patches are reviewed by Tom Tromey and Joel Brobecker except for: - New #1, renamed create_range_type to create_static_range_type as requested in https://sourceware.org/ml/gdb-patches/2013-12/msg00682.html - Modified #3, handle ref/expr/const attribute in a better way, removing the need to alter the dwarf expression by pushing a dw_op_deref to the ops. This addresses https://sourceware.org/ml/gdb-patches/2013-11/msg00785.html - Modified #8, the semantic of dw_at_count attribute is now handled in resolve_dynamic_bound instead during dwarf parsing. A change triggered by patch #3 - New #10, handles sizeof sideffect as requested in https://sourceware.org/ml/gdb-patches/2014-01/msg00732.html Changes in v4 ============= - Documented side effect of value_at, value_at_lazy, value_from_pointer, value_from_contents_and_address - Removed usage of copy_type_recursive and instead use copy_type selective Changes in v3 ============= - Add line breaks to long test expressions. - Add side effect check for sizeof/ptype/whatis to vla-datatypes.exp. - Add test file for subranges with present DW_AT_count attribute. - Add introduction comments to all new functions. - Add patch which deals with value contents with constant byte-sequence. It will be squashed once the series is approved. - Deal with location lists in case we reference a die in DW_AT_location. This fixes the crash Pedro was mentioning in: https://sourceware.org/ml/gdb-patches/2013-11/msg00646.html - Renamed struct dwarf2_bound to dynamic_prop and remove all references to dwarf2 entities in gdbtypes.[c,h] introduced by this patch series. - Addressed various coding style issues. - Fixed typo in commit log. Changes in v2 ============= - Removed patch 05/10: allow side effects for sizeof argument - New patch: support for DW_AT_count - Replaced undefined_low, high with DWARF_UNDEFINED - Add varobj testcase to mi test - Fixed commit log - Various small issues mentioned in patches 01/10 and 02/10 Some technical background ========================= Dwarf allows certain attributes e.g upper/lower bound to be computed dynamically. To support this feature with the current gdb type-system types are "normalized". This means types with dynamic properties are converted to types with static properties. To convert a type with dynamic properties into one with static properties access to inferior memory is needed. Therefore we hooked into the following value constructors value_at/value_at_lazy/value_from_contents_and_address as they require an inferior address in addition to a type to instantiate a value. If the passed type has dynamic properties we resolve the bounds and thus the type is modified, not in place but rather by a new copy. Given the following code snippet: struct value *val = value_at (my_vla_type, at_address); Before this was always true: TYPE_LENGTH (value_type (val)) == TYPE_LENGTH (my_vla_type) This is not the case after applying this patch series. Type normalization is done in the mentioned value constructors and might change the value type. Some documentation, examples as well as a github branch with support for c99 and Fortran variable length arrays is availabel at http://intel-gdb.github.io/ -Sanimir & Keven Sanimir Agovic (15): refactoring: rename create_range_type to create_static_range_type vla: introduce new bound type abstraction adapt uses type: add c99 variable length array support vla: enable sizeof operator to work with variable length arrays vla: enable sizeof operator for indirection vla: update type from newly created value vla: print "variable length" for unresolved dynamic bounds vla: support for DW_AT_count vla: resolve dynamic bounds if value contents is a constant byte-sequence vla: evaluate operand of sizeof if its type is a vla test: cover subranges with present DW_AT_count attribute test: multi-dimensional c99 vla. test: evaluate pointers to C99 vla correctly. test: basic c99 vla tests for C primitives test: add mi vla test gdb/ada-lang.c | 35 ++-- gdb/c-typeprint.c | 6 +- gdb/coffread.c | 4 +- gdb/cp-valprint.c | 2 + gdb/d-valprint.c | 1 + gdb/dwarf2loc.c | 116 +++++++++++ gdb/dwarf2loc.h | 24 +++ gdb/dwarf2read.c | 153 +++++++++----- gdb/eval.c | 50 ++++- gdb/f-exp.y | 9 +- gdb/findvar.c | 3 + gdb/gdbtypes.c | 320 ++++++++++++++++++++++++------ gdb/gdbtypes.h | 79 ++++++-- gdb/jv-valprint.c | 1 + gdb/m2-valprint.c | 2 +- gdb/mdebugread.c | 4 +- gdb/parse.c | 3 +- gdb/stabsread.c | 11 +- gdb/testsuite/gdb.base/vla-datatypes.c | 86 ++++++++ gdb/testsuite/gdb.base/vla-datatypes.exp | 138 +++++++++++++ gdb/testsuite/gdb.base/vla-multi.c | 55 +++++ gdb/testsuite/gdb.base/vla-multi.exp | 48 +++++ gdb/testsuite/gdb.base/vla-ptr.c | 63 ++++++ gdb/testsuite/gdb.base/vla-ptr.exp | 52 +++++ gdb/testsuite/gdb.base/vla-sideeffect.c | 42 ++++ gdb/testsuite/gdb.base/vla-sideeffect.exp | 88 ++++++++ gdb/testsuite/gdb.dwarf2/count.exp | 106 ++++++++++ gdb/testsuite/gdb.mi/mi-vla-c99.exp | 82 ++++++++ gdb/testsuite/gdb.mi/vla.c | 35 ++++ gdb/valops.c | 31 ++- gdb/valprint.c | 2 +- gdb/value.c | 18 +- 32 files changed, 1489 insertions(+), 180 deletions(-) create mode 100644 gdb/testsuite/gdb.base/vla-datatypes.c create mode 100644 gdb/testsuite/gdb.base/vla-datatypes.exp create mode 100644 gdb/testsuite/gdb.base/vla-multi.c create mode 100644 gdb/testsuite/gdb.base/vla-multi.exp create mode 100644 gdb/testsuite/gdb.base/vla-ptr.c create mode 100644 gdb/testsuite/gdb.base/vla-ptr.exp create mode 100644 gdb/testsuite/gdb.base/vla-sideeffect.c create mode 100644 gdb/testsuite/gdb.base/vla-sideeffect.exp create mode 100644 gdb/testsuite/gdb.dwarf2/count.exp create mode 100644 gdb/testsuite/gdb.mi/mi-vla-c99.exp create mode 100644 gdb/testsuite/gdb.mi/vla.c -- 1.8.4.2