* [PATCH v2 00/11] Improve Fortran intrinsic types and procedures @ 2022-04-08 13:48 Nils-Christian Kempke 2022-04-08 13:49 ` [PATCH v2 11/11] gdb/doc: add section about fortran intrinsic functions and types Nils-Christian Kempke 0 siblings, 1 reply; 4+ messages in thread From: Nils-Christian Kempke @ 2022-04-08 13:48 UTC (permalink / raw) To: gdb-patches Hi! Please find attached the second version of my patch series. V1 can be found here: https://sourceware.org/pipermail/gdb-patches/2022-March/186473.html Changes since v1: - [Patch 07/11]: Fixed a type in the commit message. - [Patch 09/11]: I added two temps to keep the order of argument evaluation defined as pointed out by Tom in https://sourceware.org/pipermail/gdb-patches/2022-April/187577.html - [Patch 11/11]: I adapted the patch according to Eli's comments: https://sourceware.org/pipermail/gdb-patches/2022-March/186490.html I did not attach patch 07 and 09 as one is a commit message typo and the other one Tom also approved without re-review. So, this is mostly about a re-review for [Patch 11/11]. Thanks! Nils Nils-Christian Kempke (11): gdb/f-lang: add Integer*1 to Fortran builtin types gdb/f-lang: remove hidden ^L characters gdb/fortran: fix complex type in Fortran builtin types gdb/fortran: reformat build_fortran_types in f-lang.c gdb/fortran: change default logical type to builtin_logical gdb/fortran: clean-up Fortran intrinsic types gdb/fortran: Change GDB print for fortran default types gdb/fortran: rename f77_keywords to f_keywords gdb/fortran: rewrite intrinsic handling and add some missing overloads gdb/fortran/testsuite: add complex from integers test gdb/doc: add section about fortran intrinsic functions and types gdb/doc/gdb.texinfo | 147 +++++++- gdb/f-exp.h | 182 +++++++-- gdb/f-exp.y | 397 ++++++++++++++------ gdb/f-lang.c | 267 +++++++++---- gdb/f-lang.h | 7 +- gdb/std-operator.def | 10 +- gdb/testsuite/gdb.fortran/complex.exp | 10 +- gdb/testsuite/gdb.fortran/complex.f90 | 7 +- gdb/testsuite/gdb.fortran/intrinsics.exp | 46 ++- gdb/testsuite/gdb.fortran/lbound-ubound.F90 | 49 ++- gdb/testsuite/gdb.fortran/lbound-ubound.exp | 29 +- gdb/testsuite/gdb.fortran/size.exp | 84 ++++- gdb/testsuite/gdb.fortran/size.f90 | 213 ++++++++--- gdb/testsuite/gdb.fortran/type-kinds.exp | 2 + gdb/testsuite/gdb.fortran/types.exp | 34 +- 15 files changed, 1164 insertions(+), 320 deletions(-) -- 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 11/11] gdb/doc: add section about fortran intrinsic functions and types 2022-04-08 13:48 [PATCH v2 00/11] Improve Fortran intrinsic types and procedures Nils-Christian Kempke @ 2022-04-08 13:49 ` Nils-Christian Kempke 2022-04-08 19:44 ` Eli Zaretskii 0 siblings, 1 reply; 4+ messages in thread From: Nils-Christian Kempke @ 2022-04-08 13:49 UTC (permalink / raw) To: gdb-patches The earlier version of this document had no sections about the available Fortran intrinsic functions or the Fortran builtin types. I added two sections 'Fortran intrinsics' and 'Fortran types' to document the available Fortran language features. --- gdb/doc/gdb.texinfo | 147 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 137 insertions(+), 10 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index e4685cd995..7459a48e29 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -17176,8 +17176,8 @@ vector data types. @subsection Fortran @cindex Fortran-specific support in @value{GDBN} -@value{GDBN} can be used to debug programs written in Fortran, but it -currently supports only the features of Fortran 77 language. +@value{GDBN} can be used to debug programs written in Fortran. Note, that not +all Fortran language features are available yet. @cindex trailing underscore, in Fortran symbols Some Fortran compilers (@sc{gnu} Fortran 77 and Fortran 95 compilers @@ -17187,11 +17187,74 @@ will need to refer to variables and functions with a trailing underscore. @menu -* Fortran Operators:: Fortran operators and expressions * Fortran Defaults:: Default settings for Fortran +* Fortran Types:: Fortran builtin types +* Fortran Operators:: Fortran operators and expressions +* Fortran Intrinsics:: Fortran intrinsic functions * Special Fortran Commands:: Special @value{GDBN} commands for Fortran @end menu +@node Fortran Defaults +@subsubsection Fortran Defaults + +@cindex Fortran Defaults + +Fortran symbols are usually case-insensitive, so @value{GDBN} by +default uses case-insensitive matches for Fortran symbols. You can +change that with the @samp{set case-insensitive} command, see +@ref{Symbols}, for the details. + +@node Fortran Types +@subsubsection Fortran Types + +@cindex Fortran Types + +In Fortran the primitive data-types have an associated @code{KIND} type +parameter, written as @samp{@var{type}*@var{kindparam}}, +@samp{@var{type}*@var{kindparam}}, or in the @value{GDBN}-only dialect +@samp{@var{type}_@var{kindparam}}. A concrete example would be +@samp{@code{Real*4}}, @samp{@code{Real(kind=4)}}, and @samp{@code{Real_4}}. +The kind of a type can be retrieved by using the intrinsic function +@code{KIND}, see @ref{Fortran Intrinsics}. + +Generally, the actual implementation of the @code{KIND} type parameter is +compiler specific. In @value{GDBN} the kind parameter is implemented in +accordance to its use in the @sc{gnu} gfortran compiler. Here, the kind +parameter for a given @var{type} specifies its size in memory - a Fortran +@code{Integer*4} or @code{Integer(kind=4)} would be an integer type occupying 4 +bytes of memory. An exception to this rule is the @code{Complex} type for +which the kind of the type does not specify its entire size, but the size of +each of the two @code{Real}'s it is composed of. A @code{Complex*4} would thus +consist of two @code{Real*4}s and occupy 8 bytes of memory. + +For every type there is also a default kind associated with it, e.g. +@code{Integer} in @value{GDBN} will internally be an @code{Integer*4} (see the +table below for default types). The default types are the same as in @sc{gnu} +compilers but note, that the @sc{gnu} default types can actually be changed by +compiler flags such as @option{-fdefault-integer-8} and +@option{-fdefault-real-8}. + +Not every kind parameter is valid for every type and in @value{GDBN} the +following type kinds are available. + +@table @code +@item Integer +@code{Integer*1}, @code{Integer*2}, @code{Integer*4}, @code{Integer*8}, and +@code{Integer} = @code{Integer*4}. + +@item Logical +@code{Locigal*1}, @code{Locigal*2}, @code{Locigal*4}, @code{Locigal*8}, and +@code{Locigal} = @code{Locigal*4}. + +@item Real +@code{Real*4}, @code{Real*8}, @code{Real*16}, and @code{Real} = @code{Real*4}. + +@item Complex +@code{Complex*4}, @code{Complex*8}, @code{Complex*16}, and @code{Complex} = +@code{Complex*4}. + +@end table + @node Fortran Operators @subsubsection Fortran Operators and Expressions @@ -17221,15 +17284,79 @@ to set breakpoints on subroutines nested in modules or in other subroutines (internal subroutines). @end table -@node Fortran Defaults -@subsubsection Fortran Defaults +@node Fortran Intrinsics +@subsubsection Fortran Intrinsics -@cindex Fortran Defaults +@cindex Fortran Intrinsics -Fortran symbols are usually case-insensitive, so @value{GDBN} by -default uses case-insensitive matches for Fortran symbols. You can -change that with the @samp{set case-insensitive} command, see -@ref{Symbols}, for the details. +Fortran provides a large set of intrinsic procedures. @value{GDBN} implements +an incomplete subset of those procedures and their overloads. Some of these +procedures take an optional @code{KIND} parameter, see @ref{Fortran Types}. + +@table @code +@item ABS(@var{a}) +Computes the absolute value of its argument @var{a}. Currently not supported +for @code{Complex} arguments. + +@item ALLOCATE(@var{array}) +Returns whether @var{array} is allocated or not. + +@item ASSOCIATED(@var{pointer} [, @var{target}]) +Returns the association status of the pointer @var{pointer} or if @var{target} +is present whether @var{pointer} is associated with the target @var{target}. + +@item CEILING(@var{a} [, @var{kind}]) +Computes the least integer greater than or equal to @var{a}. The optional +parameter @var{kind} specifies the kind of the return type +@code{Integer(@var{kind})}. + +@item CMPLX(@var{X} [, @var{Y} [, @var{kind}]]) +Returns a complex number where @var{x} is converted to the real component. If +@var{y} is present it is converted to the imaginary component. If @var{y} is +not present then the imaginary component is set to @code{0.0} except if @var{x} +itself is of @code{Complex} type. The optional parameter @var{kind} specifies +the kind of the return type @code{Complex(@var{kind})}. + +@item FLOOR(@var{a} [, @var{kind}]) +Computes the greatest integer less than or equal to @var{A}. The optional +parameter @var{kind} specifies the kind of the return type +@code{Integer(@var{kind})}. + +@item KIND(@var{a}) +Returns the kind value of the argument @var{a}, see @ref{Fortran Types}. + +@item LBOUND(@var{array} [, @var{dim} [, @var{kind}]]) +Returns the lower bounds of an @var{array}, or a single lower bound along the +@var{dim} dimension if present. The optional parameter @var{kind} specifies +the kind of the return type @code{Integer(@var{kind})}. + +@item LOC(@var{x}) +Returns the address of @var{x} as an @code{Integer}. + +@item MOD(@var{a}, @var{p}) +Computes the remainder of the division of @var{a} by @var{p}. + +@item MODULO(@var{a}, @var{p}) +Computes the @var{a} modulo @var{p}. + +@item RANK(@var{a}) +Returns the rank of a scalar or array (scalars have rank @code{0}). + +@item SHAPE(@var{a}) +Returns the shape of a scalar or array (scalars have shape @samp{@code{()}}). + +@item SIZE(@var{array}[, @var{dim} [, @var{kind}]]) +Returns the extent of @var{array} along a specified dimension @var{dim}, or the +total number of elements in @var{array} if @var{dim} is absent. The optional +parameter @var{kind} specifies the kind of the return type +@code{Integer(@var{kind})}. + +@item UBOUND(@var{array} [, @var{dim} [, @var{kind}]]) +Returns the upper bounds of an @var{array}, or a single lower bound along the +@var{dim} dimension if present. The optional parameter @var{kind} specifies +the kind of the return type @code{Inteder(@var{kind})}. + +@end table @node Special Fortran Commands @subsubsection Special Fortran Commands -- 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 11/11] gdb/doc: add section about fortran intrinsic functions and types 2022-04-08 13:49 ` [PATCH v2 11/11] gdb/doc: add section about fortran intrinsic functions and types Nils-Christian Kempke @ 2022-04-08 19:44 ` Eli Zaretskii 2022-04-11 7:18 ` Kempke, Nils-Christian 0 siblings, 1 reply; 4+ messages in thread From: Eli Zaretskii @ 2022-04-08 19:44 UTC (permalink / raw) To: Nils-Christian Kempke; +Cc: gdb-patches > From: Nils-Christian Kempke <nils-christian.kempke@intel.com> > Cc: eliz@gnu.org, > Nils-Christian Kempke <nils-christian.kempke@intel.com> > Date: Fri, 8 Apr 2022 15:49:00 +0200 > > The earlier version of this document had no sections about the > available Fortran intrinsic functions or the Fortran builtin types. > > I added two sections 'Fortran intrinsics' and 'Fortran types' to > document the available Fortran language features. > --- > gdb/doc/gdb.texinfo | 147 +++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 137 insertions(+), 10 deletions(-) Thanks. > +@node Fortran Defaults > +@subsubsection Fortran Defaults > + > +@cindex Fortran Defaults > + > +Fortran symbols are usually case-insensitive, so @value{GDBN} by > +default uses case-insensitive matches for Fortran symbols. You can > +change that with the @samp{set case-insensitive} command, see > +@ref{Symbols}, for the details. Does such a short text justify a full @node? Why not make it part of another node, for example the top-level @subsection about Fortran? > +Generally, the actual implementation of the @code{KIND} type parameter is > +compiler specific. In @value{GDBN} the kind parameter is implemented in > +accordance to its use in the @sc{gnu} gfortran compiler. Here, the kind ^^^^^^^^^^^^^ "In accordance with". Also, "gfortran" is the name of a command, so please give it the @command markup. > +parameter for a given @var{type} specifies its size in memory - a Fortran ^ Please use "--" or even "---" there, they produce a nicer hyphen in the manual. > +For every type there is also a default kind associated with it, e.g. You need a @: after "e.g.", so that the period is not treated as the end of a sentence. > +@item Logical > +@code{Locigal*1}, @code{Locigal*2}, @code{Locigal*4}, @code{Locigal*8}, and > +@code{Locigal} = @code{Locigal*4}. Typos: "Locigal" should be "Logical". > +@item ASSOCIATED(@var{pointer} [, @var{target}]) > +Returns the association status of the pointer @var{pointer} or if @var{target} > +is present whether @var{pointer} is associated with the target @var{target}. Punctuation: "or, if @var{target} is present, whether ..." > +@item CMPLX(@var{X} [, @var{Y} [, @var{kind}]]) > +Returns a complex number where @var{x} is converted to the real component. If > +@var{y} is present it is converted to the imaginary component. If @var{y} is "x" and "y" should have consistent letter-case (I think they all should be lower-case). > +@item FLOOR(@var{a} [, @var{kind}]) > +Computes the greatest integer less than or equal to @var{A}. The optional Likewise for "a". > +@item UBOUND(@var{array} [, @var{dim} [, @var{kind}]]) > +Returns the upper bounds of an @var{array}, or a single lower bound along the ^^^^^ "upper", I guess? ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2 11/11] gdb/doc: add section about fortran intrinsic functions and types 2022-04-08 19:44 ` Eli Zaretskii @ 2022-04-11 7:18 ` Kempke, Nils-Christian 0 siblings, 0 replies; 4+ messages in thread From: Kempke, Nils-Christian @ 2022-04-11 7:18 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches Hi Eli, Thanks for looking at the documentation. > From: Eli Zaretskii <eliz@gnu.org> > Sent: Friday, April 8, 2022 9:44 PM > > +@node Fortran Defaults > > +@subsubsection Fortran Defaults > > + > > +@cindex Fortran Defaults > > + > > +Fortran symbols are usually case-insensitive, so @value{GDBN} by > > +default uses case-insensitive matches for Fortran symbols. You can > > +change that with the @samp{set case-insensitive} command, see > > +@ref{Symbols}, for the details. > > Does such a short text justify a full @node? Why not make it part of > another node, for example the top-level @subsection about Fortran? > Yeah - I think initially I thought this would become longer and then left it. But yes, for the few lines I will move it and adapt the commit message accordingly. > > +Generally, the actual implementation of the @code{KIND} type > parameter is > > +compiler specific. In @value{GDBN} the kind parameter is implemented > in > > +accordance to its use in the @sc{gnu} gfortran compiler. Here, the kind > ^^^^^^^^^^^^^ > "In accordance with". > > Also, "gfortran" is the name of a command, so please give it the > @command markup. > > > +parameter for a given @var{type} specifies its size in memory - a Fortran > ^ > Please use "--" or even "---" there, they produce a nicer hyphen in > the manual. > > > +For every type there is also a default kind associated with it, e.g. > > You need a @: after "e.g.", so that the period is not treated as the > end of a sentence. > > > +@item Logical > > +@code{Locigal*1}, @code{Locigal*2}, @code{Locigal*4}, > @code{Locigal*8}, and > > +@code{Locigal} = @code{Locigal*4}. > > Typos: "Locigal" should be "Logical". Sorry for this one.. > > +@item ASSOCIATED(@var{pointer} [, @var{target}]) > > +Returns the association status of the pointer @var{pointer} or if > @var{target} > > +is present whether @var{pointer} is associated with the target > @var{target}. > > Punctuation: "or, if @var{target} is present, whether ..." > > > +@item CMPLX(@var{X} [, @var{Y} [, @var{kind}]]) > > +Returns a complex number where @var{x} is converted to the real > component. If > > +@var{y} is present it is converted to the imaginary component. If @var{y} > is > > "x" and "y" should have consistent letter-case (I think they all > should be lower-case). > > > +@item FLOOR(@var{a} [, @var{kind}]) > > +Computes the greatest integer less than or equal to @var{A}. The > optional > > Likewise for "a". > > > +@item UBOUND(@var{array} [, @var{dim} [, @var{kind}]]) > > +Returns the upper bounds of an @var{array}, or a single lower bound > along the > ^^^^^ > "upper", I guess? Yes.. Thanks! I will fix these and send another version. Cheers, Nils Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-11 7:18 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-04-08 13:48 [PATCH v2 00/11] Improve Fortran intrinsic types and procedures Nils-Christian Kempke 2022-04-08 13:49 ` [PATCH v2 11/11] gdb/doc: add section about fortran intrinsic functions and types Nils-Christian Kempke 2022-04-08 19:44 ` Eli Zaretskii 2022-04-11 7:18 ` Kempke, Nils-Christian
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).