public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 00/13] C99 variable length array support
@ 2013-12-04 14:20 Sanimir Agovic
  2013-12-04 14:20 ` [PATCH v3 02/13] type: add c99 " Sanimir Agovic
                   ` (14 more replies)
  0 siblings, 15 replies; 25+ messages in thread
From: Sanimir Agovic @ 2013-12-04 14:20 UTC (permalink / raw)
  To: tromey, palves, xdje42; +Cc: gdb-patches, keven.boell

Hello,

this patch series (v3) 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 <repeats 42 times>}

    (gdb) print sizeof ary
    $2 = 168

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. IIF 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/

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

 -Sanimir & Keven

Sanimir Agovic (13):
  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
  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                           |  13 +-
 gdb/c-typeprint.c                        |   6 +-
 gdb/cp-valprint.c                        |   2 +
 gdb/d-valprint.c                         |   1 +
 gdb/dwarf2loc.c                          | 105 +++++++++++
 gdb/dwarf2loc.h                          |  26 +++
 gdb/dwarf2read.c                         | 211 +++++++++++++++++-----
 gdb/eval.c                               |  10 +-
 gdb/findvar.c                            |   3 +
 gdb/gdbtypes.c                           | 299 ++++++++++++++++++++++++-------
 gdb/gdbtypes.h                           |  63 +++++--
 gdb/jv-valprint.c                        |   1 +
 gdb/parse.c                              |   3 +-
 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.dwarf2/count.exp       | 106 +++++++++++
 gdb/testsuite/gdb.mi/mi-vla-c99.exp      |  82 +++++++++
 gdb/testsuite/gdb.mi/vla.c               |  35 ++++
 gdb/valops.c                             |   3 +
 gdb/value.c                              |  12 +-
 24 files changed, 1287 insertions(+), 136 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.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.3.1

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2014-01-17  2:23 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-04 14:20 [PATCH v3 00/13] C99 variable length array support Sanimir Agovic
2013-12-04 14:20 ` [PATCH v3 02/13] type: add c99 " Sanimir Agovic
2013-12-04 14:20 ` [PATCH v3 01/13] vla: introduce new bound type abstraction adapt uses Sanimir Agovic
2013-12-04 14:21 ` [PATCH v3 06/13] vla: print "dynamic length" for unresolved dynamic bounds Sanimir Agovic
2013-12-04 14:21 ` [PATCH v3 08/13] vla: resolve dynamic bounds if value contents is a constant byte-sequence Sanimir Agovic
2013-12-04 14:21 ` [PATCH v3 12/13] test: basic c99 vla tests for C primitives Sanimir Agovic
2013-12-04 14:21 ` [PATCH v3 04/13] vla: enable sizeof operator for indirection Sanimir Agovic
2013-12-04 14:21 ` [PATCH v3 03/13] vla: enable sizeof operator to work with variable length arrays Sanimir Agovic
2013-12-04 14:21 ` [PATCH v3 07/13] vla: support for DW_AT_count Sanimir Agovic
2013-12-04 14:22 ` [PATCH v3 11/13] test: evaluate pointers to C99 vla correctly Sanimir Agovic
2013-12-04 14:22 ` [PATCH v3 10/13] test: multi-dimensional c99 vla Sanimir Agovic
2013-12-04 14:22 ` [PATCH v3 09/13] test: cover subranges with present DW_AT_count attribute Sanimir Agovic
2013-12-04 14:22 ` [PATCH v3 06/13] vla: print "variable length" for unresolved dynamic bounds Sanimir Agovic
2013-12-04 14:23 ` [PATCH v3 13/13] test: add mi vla test Sanimir Agovic
2013-12-04 14:23 ` [PATCH v3 05/13] vla: update type from newly created value Sanimir Agovic
2013-12-06  7:36   ` Doug Evans
2013-12-16 15:21     ` Agovic, Sanimir
2013-12-16 17:58       ` Doug Evans
2014-01-15 11:41 ` [PATCH v3 00/13] C99 variable length array support Joel Brobecker
2014-01-15 16:15   ` Tom Tromey
2014-01-15 17:54     ` Joel Brobecker
2014-01-15 18:00       ` Tom Tromey
2014-01-16 17:00   ` Agovic, Sanimir
2014-01-16 17:30     ` Tom Tromey
2014-01-17  2:23       ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).