From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id ADF673857C4D for ; Fri, 8 Apr 2022 13:49:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ADF673857C4D X-IronPort-AV: E=McAfee;i="6400,9594,10310"; a="242189589" X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="242189589" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 06:49:18 -0700 X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="571493194" Received: from labpcdell3650-003.iul.intel.com (HELO localhost) ([172.28.49.87]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 06:49:17 -0700 From: Nils-Christian Kempke To: gdb-patches@sourceware.org Subject: [PATCH v2 11/11] gdb/doc: add section about fortran intrinsic functions and types Date: Fri, 8 Apr 2022 15:49:00 +0200 Message-Id: <20220408134900.2635299-2-nils-christian.kempke@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220408134900.2635299-1-nils-christian.kempke@intel.com> References: <20220408134900.2635299-1-nils-christian.kempke@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2022 13:49:24 -0000 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 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