public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] fort_dyn_array: add basic fortran dyn array support
@ 2016-02-08 13:47 Walfred Tedeschi
  2016-02-09 11:36 ` Joel Brobecker
  0 siblings, 1 reply; 18+ messages in thread
From: Walfred Tedeschi @ 2016-02-08 13:47 UTC (permalink / raw)
  To: qiyaoltc, Joel Brobecker, Heckel, Bernhard, Walfred Tedeschi,
	keven.boell
  Cc: gdb-patches

 > Keven Boell <keven.boell@linux.intel.com> writes:
 >
 >> Fortran provide types whose values may be dynamically allocated
 >> or associated with a variable under explicit program control.
 >> The purpose of this commit is
 >>   * to read allocated/associated DWARF tags and store them in
 >>     the dynamic property list of main_type.
 >>   * enable GDB to print the value of a dynamic array in Fortran
 >>     in case the type is allocated or associated (pointer to
 >>     dynamic array).
 >>
 >> Examples:
 >> (gdb) p vla_not_allocated
 >> $1 = <not allocated>
 >>
 >> (gdb) p vla_allocated
 >> $1 = (1, 2, 3)
 >>
 >> (gdb) p vla_ptr_not_associated
 >> $1 = <not associated>
 >>
 >> (gdb) p vla_ptr_associated
 >> $1 = (1, 2, 3)
 >>
 >> Add basic test coverage for most dynamic array use-cases
 >> in Fortran.
 >> The commit contains the following tests:
 >>   * Ensure that values of Fortran dynamic arrays
 >>     can be evaluated correctly in various ways and states.
 >>   * Ensure that Fortran primitives can be evaluated
 >>     correctly when used as a dynamic array.
 >>   * Dynamic arrays passed to subroutines and handled
 >>     in different ways inside the routine.
 >>   * Ensure that the ptype of dynamic arrays in
 >>     Fortran can be printed in GDB correctly.
 >>   * Ensure that dynamic arrays in different states
 >>     (allocated/associated) can be evaluated.
 >>   * Dynamic arrays passed to functions and returned from
 >>     functions.
 >>   * History values of dynamic arrays can be accessed and
 >>     printed again with the correct values.
 >>   * Dynamic array evaluations using MI protocol.
 >>   * Sizeof output of dynamic arrays in various states.
 >>
 >> The patch was tested using the test suite on Ubuntu 12.04 64bit.
 >
 > Hi Keven,
 > The test cases added by this commit fail on some other OS and targets,
 > see this thread, 
https://sourceware.org/ml/gdb-testers/2015-q4/msg02136.html
 > can you take a look?
 >

Hi Yao, Joel,

I don't think I will be able to fix the failures on the mentioned 
hosts/targets before you
create the branch, as I need to replicate the environment on my end 
first to start investigating.
Therefore I suggest to revert the change for now. Sorry if this caused 
any inconvenience.


Joel and Yao,

Bernhard and I we have investigated the issues reported. Issues were 
reproduced by using the newest GCC.  Looks like the issues are 
independent from the target at first sight.

Issues could be divided into 3 categories:

1.  Issue root causes to GCC 5.x and Fortran "associated" intrinsic. 
Compiler is not reporting the “Associated property correctly. (see test 
case 1)
Affected tests:
gdb.fortran/vla-ptype.exp: ptype pvla not initialized
gdb.fortran/vla-value.exp: print undefined pvla
gdb.fortran/vla-value.exp: print non-associated &pvla
gdb.fortran/vla-value.exp: print undefined pvla(1,3,8)
gdb.mi/mi-vla-fortran.exp: evaluate not associated vla
gdb.mi/mi-vla-fortran.exp: create local variable pvla2_not_associated
gdb.mi/mi-vla-fortran.exp: info type variable pvla2_not_associated

2.  Test issues. Test take into account that array created is 
initialized by default. Initialization depends on the compiler also 
Fortran standard does not state the need for initialization.
Affected tests:
gdb.mi/mi-vla-fortran.exp: evaluate allocated vla

3.  GCC or GDB error. Breakpoint is completely off, breakpoint on return 
line is triggered before the execution of the functions body. Deeper 
investigation should be done to define the real issue.
Affected tests:
gdb.cp/vla-cxx.exp


Snippets of what is not working properly are presented below:
---------------------

1.
   program vla

   real, target, allocatable :: vla1 (:, :, :)
   real, pointer :: pvla (:, :, :)
   logical :: l
   logical :: is_associated
   integer location
   allocate (vla1 (10,10,10))
   l = allocated(vla1)
   vla1(:, :, :) = 1311

   is_associated = .FALSE.

   is_associated = associated(pvla)   !!! <--  HERE: Compiler reports 
pvla as associated, it should not be.

   location = LOC(pvla)
   write (*,*) "pvla is associated: ", is_associated
   write (*,*) "Location of pvla is: ",location

   pvla => vla1                        ! is associated here!
   l = associated(pvla)



end program vla

We intend to add a GCC defect in bugzilla. Do you agree?

---------------------



2.

Source file: gdb.mi/VLA.F90

   real, pointer :: pvla2 (:, :)

   logical :: l



   allocate (vla1 (5))

   vla1(:) = 0;  	      !!! Missing line: Test consider that array is 
initialized, but standard does not enforce that.

   l = allocated(vla1)



   vla1(:) = 1

   vla1(2) = 42

   vla1(4) = 24


-> We are going to prepare a patch for that.

---------------------
3.
Compile & run: gdb.cp/vlx-cxx

       Execute in GDB

break 48

run

next

              Next shows beginning of “main” and not the code where the 
breakpoint was hit.



Reading symbols from ../gdb/testsuite/gdb.cp/vla-cxx...done.

(gdb) b 48

Breakpoint 1 at 0x4005ae: file ../../../gdb/testsuite/gdb.cp/vla-cxx.cc, 
line 48.

(gdb) r

Starting program: ../gdb/testsuite/gdb.cp/vla-cxx



Breakpoint 1, main (argc=1, argv=0x7fffffffda28)

     at ../../../gdb/testsuite/gdb.cp/vla-cxx.cc:48

48             return vla[2];

(gdb) n

36             int z = 3;

(gdb) n

38             int vla[z];



->We will investigate the root cause here. GDB or debug information is 
wrong here.



Thanks and regards,
Bernhard & Fred
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 18+ messages in thread
* [PATCH 0/2] fort_dyn_array: Enable basic Fortran dynamic array support
@ 2015-07-01 12:42 Keven Boell
  2015-07-01 12:42 ` [PATCH 1/2] fort_dyn_array: add basic fortran dyn " Keven Boell
  0 siblings, 1 reply; 18+ messages in thread
From: Keven Boell @ 2015-07-01 12:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Keven Boell

This patch series add basic Fortran dynamic array support to gdb.

It allows the user to evaluate a dynamic array like an ordinary static array
e.g. print its elements instead of printing the pointer to the array.
In addition the size of a dynamic array can be retrieved with gdbs builtin
sizeof operator.

	1| integer, allocatable :: ary(:)
	2| allocate(ary(5))
	3| ary(:) = 42

	(gdb) print ary
	$1 = (42, 42, 42, 42, 42)

	(gdb) print sizeof (ary)
	$2 = 20

	(gdb) ptype ary
	type = integer(kind=4) (5)

This series is a follow up for the following C99 variable length array
support series:
	https://sourceware.org/ml/gdb-patches/2013-12/msg00625.html

Keven Boell (2):
  fort_dyn_array: add basic fortran dyn array support
  fort_dyn_array: add basic test coverage

 gdb/dwarf2loc.c                                    |   11 ++
 gdb/dwarf2loc.h                                    |    4 +
 gdb/dwarf2read.c                                   |   16 ++
 gdb/f-typeprint.c                                  |   20 +++
 gdb/gdbtypes.c                                     |   33 +++-
 gdb/gdbtypes.h                                     |   28 +++
 gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp      |   65 +++++++
 gdb/testsuite/gdb.fortran/vla-datatypes.exp        |   82 +++++++++
 gdb/testsuite/gdb.fortran/vla-datatypes.f90        |   51 ++++++
 gdb/testsuite/gdb.fortran/vla-history.exp          |   62 +++++++
 gdb/testsuite/gdb.fortran/vla-ptr-info.exp         |   32 ++++
 gdb/testsuite/gdb.fortran/vla-ptype-sub.exp        |   87 ++++++++++
 gdb/testsuite/gdb.fortran/vla-ptype.exp            |   96 +++++++++++
 gdb/testsuite/gdb.fortran/vla-sizeof.exp           |   46 +++++
 gdb/testsuite/gdb.fortran/vla-sub.f90              |   82 +++++++++
 .../gdb.fortran/vla-value-sub-arbitrary.exp        |   35 ++++
 gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp |   49 ++++++
 gdb/testsuite/gdb.fortran/vla-value-sub.exp        |   90 ++++++++++
 gdb/testsuite/gdb.fortran/vla-value.exp            |  148 ++++++++++++++++
 gdb/testsuite/gdb.fortran/vla.f90                  |   56 ++++++
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp            |  182 ++++++++++++++++++++
 gdb/testsuite/gdb.mi/vla.f90                       |   42 +++++
 gdb/valarith.c                                     |    9 +-
 gdb/valprint.c                                     |   36 ++++
 gdb/valprint.h                                     |    4 +
 25 files changed, 1360 insertions(+), 6 deletions(-)
 create mode 100644 gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla-datatypes.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla-datatypes.f90
 create mode 100644 gdb/testsuite/gdb.fortran/vla-history.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla-ptr-info.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla-ptype.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla-sizeof.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla-sub.f90
 create mode 100644 gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla-value-sub.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla-value.exp
 create mode 100644 gdb/testsuite/gdb.fortran/vla.f90
 create mode 100644 gdb/testsuite/gdb.mi/mi-vla-fortran.exp
 create mode 100644 gdb/testsuite/gdb.mi/vla.f90

-- 
1.7.9.5

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

end of thread, other threads:[~2016-02-09 15:14 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 13:47 [PATCH 1/2] fort_dyn_array: add basic fortran dyn array support Walfred Tedeschi
2016-02-09 11:36 ` Joel Brobecker
2016-02-09 15:14   ` Walfred Tedeschi
  -- strict thread matches above, loose matches on Subject: below --
2015-07-01 12:42 [PATCH 0/2] fort_dyn_array: Enable basic Fortran dynamic " Keven Boell
2015-07-01 12:42 ` [PATCH 1/2] fort_dyn_array: add basic fortran dyn " Keven Boell
2015-07-21 18:05   ` Joel Brobecker
2015-08-05 13:41     ` Keven Boell
2015-08-05 13:47     ` Keven Boell
2015-08-05 20:23       ` Joel Brobecker
2015-08-06 11:42         ` keven.boell
2015-08-20 12:52           ` Joel Brobecker
2015-10-09 11:37             ` Keven Boell
2015-10-22  9:59               ` Joel Brobecker
2016-01-20 10:19               ` Yao Qi
2016-01-22  7:22                 ` Keven Boell
2016-01-22 12:40                   ` Joel Brobecker
2016-01-22 15:25                     ` Yao Qi
2016-01-26 12:34                       ` Joel Brobecker
     [not found]             ` <5613D0DC.3040908@linux.intel.com>
2015-10-22  9:59               ` 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).