<HTML> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!-- Created on March, 27 2008 by texi2html 1.64 --> <!-- Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) Karl Berry <karl@freefriends.org> Olaf Bachmann <obachman@mathematik.uni-kl.de> and many others. Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de> Send bugs and suggestions to <texi2html@mathematik.uni-kl.de> --> <HEAD> <TITLE>Debugging with GDB: Languages</TITLE> <META NAME="description" CONTENT="Debugging with GDB: Languages"> <META NAME="keywords" CONTENT="Debugging with GDB: Languages"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META NAME="Generator" CONTENT="texi2html 1.64"> </HEAD> <BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"> <A NAME="SEC102"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_12.html#SEC101"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC103"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC6"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC146"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H1> 12. Using GDB with Different Languages </H1> <!--docid::SEC102::--> <P> Although programming languages generally have common aspects, they are rarely expressed in the same manner. For instance, in ANSI C, dereferencing a pointer <CODE>p</CODE> is accomplished by <CODE>*p</CODE>, but in Modula-2, it is accomplished by <CODE>p^</CODE>. Values can also be represented (and displayed) differently. Hex numbers in C appear as <SAMP>`0x1ae'</SAMP>, while in Modula-2 they appear as <SAMP>`1AEH'</SAMP>. </P><P> <A NAME="IDX568"></A> Language-specific information is built into GDB for some languages, allowing you to express operations like the above in your program's native language, and allowing GDB to output values in a manner consistent with the syntax of your program's native language. The language you use to build expressions is called the <EM>working language</EM>. </P><P> <BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC103">12.1 Switching Between Source Languages</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Switching between source languages</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC107">12.2 Displaying the Language</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Displaying the language</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC108">12.3 Type and Range Checking</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Type and range checks</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC111">12.4 Supported Languages</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Supported languages</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC145">12.5 Unsupported Languages</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Unsupported languages</TD></TR> </TABLE></BLOCKQUOTE> <P> <A NAME="Setting"></A> <HR SIZE="6"> <A NAME="SEC103"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC104"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC107"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H2> 12.1 Switching Between Source Languages </H2> <!--docid::SEC103::--> <P> There are two ways to control the working language--either have GDB set it automatically, or select it manually yourself. You can use the <CODE>set language</CODE> command for either purpose. On startup, GDB defaults to setting the language automatically. The working language is used to determine how expressions you type are interpreted, how values are printed, etc. </P><P> In addition to the working language, every source file that GDB knows about has its own working language. For some object file formats, the compiler might indicate which language a particular source file is in. However, most of the time GDB infers the language from the name of the file. The language of a source file controls whether C<TT>++</TT> names are demangled--this way <CODE>backtrace</CODE> can show each frame appropriately for its own language. There is no way to set the language of a source file from within GDB, but you can set the language associated with a filename extension. See section <A HREF="gdb_13.html#SEC107">Displaying the Language</A>. </P><P> This is most commonly a problem when you use a program, such as <CODE>cfront</CODE> or <CODE>f2c</CODE>, that generates C but is written in another language. In that case, make the program use <CODE>#line</CODE> directives in its C output; that way GDB will know the correct language of the source code of the original program, and will display that source code, not the generated C code. </P><P> <BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC104">12.1.1 List of Filename Extensions and Languages</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Filename extensions and languages.</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC105">12.1.2 Setting the Working Language</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Setting the working language manually</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC106">12.1.3 Having GDB Infer the Source Language</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Having GDB infer the source language</TD></TR> </TABLE></BLOCKQUOTE> <P> <A NAME="Filenames"></A> <HR SIZE="6"> <A NAME="SEC104"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC103"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC105"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC103"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC107"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.1.1 List of Filename Extensions and Languages </H3> <!--docid::SEC104::--> <P> If a source file name ends in one of the following extensions, then GDB infers that its language is the one indicated. </P><P> <DL COMPACT> <DT><TT>`.ada'</TT> <DD><DT><TT>`.ads'</TT> <DD><DT><TT>`.adb'</TT> <DD><DT><TT>`.a'</TT> <DD>Ada source file. <P> <DT><TT>`.c'</TT> <DD>C source file <P> <DT><TT>`.C'</TT> <DD><DT><TT>`.cc'</TT> <DD><DT><TT>`.cp'</TT> <DD><DT><TT>`.cpp'</TT> <DD><DT><TT>`.cxx'</TT> <DD><DT><TT>`.c++'</TT> <DD>C<TT>++</TT> source file <P> <DT><TT>`.m'</TT> <DD>Objective-C source file <P> <DT><TT>`.f'</TT> <DD><DT><TT>`.F'</TT> <DD>Fortran source file <P> <DT><TT>`.mod'</TT> <DD>Modula-2 source file <P> <DT><TT>`.s'</TT> <DD><DT><TT>`.S'</TT> <DD>Assembler source file. This actually behaves almost like C, but GDB does not skip over function prologues when stepping. </DL> <P> In addition, you may set the language associated with a filename extension. See section <A HREF="gdb_13.html#SEC107">Displaying the Language</A>. </P><P> <A NAME="Manually"></A> <HR SIZE="6"> <A NAME="SEC105"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC104"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC106"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC106"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC103"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC107"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.1.2 Setting the Working Language </H3> <!--docid::SEC105::--> <P> If you allow GDB to set the language automatically, expressions are interpreted the same way in your debugging session and your program. </P><P> <A NAME="IDX569"></A> If you wish, you may set the language manually. To do this, issue the command <SAMP>`set language <VAR>lang</VAR>'</SAMP>, where <VAR>lang</VAR> is the name of a language, such as <CODE>c</CODE> or <CODE>modula-2</CODE>. For a list of the supported languages, type <SAMP>`set language'</SAMP>. </P><P> Setting the language manually prevents GDB from updating the working language automatically. This can lead to confusion if you try to debug a program when the working language is not the same as the source language, when an expression is acceptable to both languages--but means different things. For instance, if the current source file were written in C, and GDB was parsing Modula-2, a command such as: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>print a = b + c </FONT></pre></td></tr></table></P><P> might not have the effect you intended. In C, this means to add <CODE>b</CODE> and <CODE>c</CODE> and place the result in <CODE>a</CODE>. The result printed would be the value of <CODE>a</CODE>. In Modula-2, this means to compare <CODE>a</CODE> to the result of <CODE>b+c</CODE>, yielding a <CODE>BOOLEAN</CODE> value. </P><P> <A NAME="Automatically"></A> <HR SIZE="6"> <A NAME="SEC106"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC105"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC107"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC103"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC107"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.1.3 Having GDB Infer the Source Language </H3> <!--docid::SEC106::--> <P> To have GDB set the working language automatically, use <SAMP>`set language local'</SAMP> or <SAMP>`set language auto'</SAMP>. GDB then infers the working language. That is, when your program stops in a frame (usually by encountering a breakpoint), GDB sets the working language to the language recorded for the function in that frame. If the language for a frame is unknown (that is, if the function or block corresponding to the frame was defined in a source file that does not have a recognized extension), the current working language is not changed, and GDB issues a warning. </P><P> This may not seem necessary for most programs, which are written entirely in one source language. However, program modules and libraries written in one source language can be used by a main program written in a different source language. Using <SAMP>`set language auto'</SAMP> in this case frees you from having to set the working language manually. </P><P> <A NAME="Show"></A> <HR SIZE="6"> <A NAME="SEC107"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC106"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC108"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC108"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC146"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H2> 12.2 Displaying the Language </H2> <!--docid::SEC107::--> <P> The following commands help you find out which language is the working language, and also what language source files were written in. </P><P> <DL COMPACT> <DT><CODE>show language</CODE> <DD><A NAME="IDX570"></A> Display the current working language. This is the language you can use with commands such as <CODE>print</CODE> to build and compute expressions that may involve variables in your program. <P> <DT><CODE>info frame</CODE> <DD><A NAME="IDX571"></A> Display the source language for this frame. This language becomes the working language if you use an identifier from this frame. See section <A HREF="gdb_7.html#SEC50">Information about a Frame</A>, to identify the other information listed here. <P> <DT><CODE>info source</CODE> <DD><A NAME="IDX572"></A> Display the source language of this source file. See section <A HREF="gdb_14.html#SEC146">Examining the Symbol Table</A>, to identify the other information listed here. </DL> <P> In unusual circumstances, you may have source files with extensions not in the standard list. You can then set the extension associated with a language explicitly: </P><P> <DL COMPACT> <DT><CODE>set extension-language <VAR>ext</VAR> <VAR>language</VAR></CODE> <DD><A NAME="IDX573"></A> Tell GDB that source files with extension <VAR>ext</VAR> are to be assumed as written in the source language <VAR>language</VAR>. <P> <DT><CODE>info extensions</CODE> <DD><A NAME="IDX574"></A> List all the filename extensions and the associated languages. </DL> <P> <A NAME="Checks"></A> <HR SIZE="6"> <A NAME="SEC108"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC107"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC109"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H2> 12.3 Type and Range Checking </H2> <!--docid::SEC108::--> <P> <BLOCKQUOTE> <EM>Warning:</EM> In this release, the GDB commands for type and range checking are included, but they do not yet have any effect. This section documents the intended facilities. </BLOCKQUOTE> <P> Some languages are designed to guard you against making seemingly common errors through a series of compile- and run-time checks. These include checking the type of arguments to functions and operators, and making sure mathematical overflows are caught at run time. Checks such as these help to ensure a program's correctness once it has been compiled by eliminating type mismatches, and providing active checks for range errors when your program is running. </P><P> GDB can check for conditions like the above if you wish. Although GDB does not check the statements in your program, it can check expressions entered directly into GDB for evaluation via the <CODE>print</CODE> command, for example. As with the working language, GDB can also decide whether or not to check automatically based on your program's source language. See section <A HREF="gdb_13.html#SEC111">Supported Languages</A>, for the default settings of supported languages. </P><P> <BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC109">12.3.1 An Overview of Type Checking</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">An overview of type checking</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC110">12.3.2 An Overview of Range Checking</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">An overview of range checking</TD></TR> </TABLE></BLOCKQUOTE> <P> <A NAME="IDX575"></A> <A NAME="IDX576"></A> <A NAME="Type Checking"></A> <HR SIZE="6"> <A NAME="SEC109"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC108"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC110"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC108"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.3.1 An Overview of Type Checking </H3> <!--docid::SEC109::--> <P> Some languages, such as Modula-2, are strongly typed, meaning that the arguments to operators and functions have to be of the correct type, otherwise an error occurs. These checks prevent type mismatch errors from ever causing any run-time problems. For example, </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>1 + 2 => 3 but error--> 1 + 2.3 </FONT></pre></td></tr></table></P><P> The second example fails because the <CODE>CARDINAL</CODE> 1 is not type-compatible with the <CODE>REAL</CODE> 2.3. </P><P> For the expressions you use in GDB commands, you can tell the GDB type checker to skip checking; to treat any mismatches as errors and abandon the expression; or to only issue warnings when type mismatches occur, but evaluate the expression anyway. When you choose the last of these, GDB evaluates expressions like the second example above, but also issues a warning. </P><P> Even if you turn type checking off, there may be other reasons related to type that prevent GDB from evaluating an expression. For instance, GDB does not know how to add an <CODE>int</CODE> and a <CODE>struct foo</CODE>. These particular type errors have nothing to do with the language in use, and usually arise from expressions, such as the one described above, which make little sense to evaluate anyway. </P><P> Each language defines to what degree it is strict about type. For instance, both Modula-2 and C require the arguments to arithmetical operators to be numbers. In C, enumerated types and pointers can be represented as numbers, so that they are valid arguments to mathematical operators. See section <A HREF="gdb_13.html#SEC111">Supported Languages</A>, for further details on specific languages. </P><P> GDB provides some additional commands for controlling the type checker: </P><P> <A NAME="IDX577"></A> <A NAME="IDX578"></A> <DL COMPACT> <DT><CODE>set check type auto</CODE> <DD>Set type checking on or off based on the current working language. See section <A HREF="gdb_13.html#SEC111">Supported Languages</A>, for the default settings for each language. <P> <DT><CODE>set check type on</CODE> <DD><DT><CODE>set check type off</CODE> <DD>Set type checking on or off, overriding the default setting for the current working language. Issue a warning if the setting does not match the language default. If any type mismatches occur in evaluating an expression while type checking is on, GDB prints a message and aborts evaluation of the expression. <P> <DT><CODE>set check type warn</CODE> <DD>Cause the type checker to issue warnings, but to always attempt to evaluate the expression. Evaluating the expression may still be impossible for other reasons. For example, GDB cannot add numbers and structures. <P> <DT><CODE>show type</CODE> <DD>Show the current setting of the type checker, and whether or not GDB is setting it automatically. </DL> <P> <A NAME="IDX579"></A> <A NAME="IDX580"></A> <A NAME="Range Checking"></A> <HR SIZE="6"> <A NAME="SEC110"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC109"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC108"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.3.2 An Overview of Range Checking </H3> <!--docid::SEC110::--> <P> In some languages (such as Modula-2), it is an error to exceed the bounds of a type; this is enforced with run-time checks. Such range checking is meant to ensure program correctness by making sure computations do not overflow, or indices on an array element access do not exceed the bounds of the array. </P><P> For expressions you use in GDB commands, you can tell GDB to treat range errors in one of three ways: ignore them, always treat them as errors and abandon the expression, or issue warnings but evaluate the expression anyway. </P><P> A range error can result from numerical overflow, from exceeding an array index bound, or when you type a constant that is not a member of any type. Some languages, however, do not treat overflows as an error. In many implementations of C, mathematical overflow causes the result to "wrap around" to lower values--for example, if <VAR>m</VAR> is the largest integer value, and <VAR>s</VAR> is the smallest, then </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre><VAR>m</VAR> + 1 => <VAR>s</VAR> </FONT></pre></td></tr></table></P><P> This, too, is specific to individual languages, and in some cases specific to individual compilers or machines. See section <A HREF="gdb_13.html#SEC111">Supported Languages</A>, for further details on specific languages. </P><P> GDB provides some additional commands for controlling the range checker: </P><P> <A NAME="IDX581"></A> <A NAME="IDX582"></A> <DL COMPACT> <DT><CODE>set check range auto</CODE> <DD>Set range checking on or off based on the current working language. See section <A HREF="gdb_13.html#SEC111">Supported Languages</A>, for the default settings for each language. <P> <DT><CODE>set check range on</CODE> <DD><DT><CODE>set check range off</CODE> <DD>Set range checking on or off, overriding the default setting for the current working language. A warning is issued if the setting does not match the language default. If a range error occurs and range checking is on, then a message is printed and evaluation of the expression is aborted. <P> <DT><CODE>set check range warn</CODE> <DD>Output messages when the GDB range checker detects a range error, but attempt to evaluate the expression anyway. Evaluating the expression may still be impossible for other reasons, such as accessing memory that the process does not own (a typical example from many Unix systems). <P> <DT><CODE>show range</CODE> <DD>Show the current setting of the range checker, and whether or not it is being set automatically by GDB. </DL> <P> <A NAME="Supported Languages"></A> <HR SIZE="6"> <A NAME="SEC111"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC110"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC112"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H2> 12.4 Supported Languages </H2> <!--docid::SEC111::--> <P> GDB supports C, C<TT>++</TT>, Objective-C, Fortran, Java, Pascal, assembly, Modula-2, and Ada. Some GDB features may be used in expressions regardless of the language you use: the GDB <CODE>@</CODE> and <CODE>::</CODE> operators, and the <SAMP>`{type}addr'</SAMP> construct (see section <A HREF="gdb_9.html#SEC60">Expressions</A>) can be used with the constructs of any supported language. </P><P> The following sections detail to what degree each source language is supported by GDB. These sections are not meant to be language tutorials or references, but serve only as a reference guide to what the GDB expression parser accepts, and what input and output formats should look like for different languages. There are many good books written on each of these languages; please look to these for a language reference or tutorial. </P><P> <BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC112">12.4.1 C and C<TT>++</TT></A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC121">12.4.2 Objective-C</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC124">12.4.3 Fortran</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC128">12.4.4 Pascal</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC129">12.4.5 Modula-2</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC139">12.4.6 Ada</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR> </TABLE></BLOCKQUOTE> <P> <A NAME="C"></A> <HR SIZE="6"> <A NAME="SEC112"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC113"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.4.1 C and C<TT>++</TT> </H3> <!--docid::SEC112::--> <P> <A NAME="IDX583"></A> <A NAME="IDX584"></A> </P><P> Since C and C<TT>++</TT> are so closely related, many features of GDB apply to both languages. Whenever this is the case, we discuss those languages together. </P><P> <A NAME="IDX585"></A> <A NAME="IDX586"></A> <A NAME="IDX587"></A> The C<TT>++</TT> debugging facilities are jointly implemented by the C<TT>++</TT> compiler and GDB. Therefore, to debug your C<TT>++</TT> code effectively, you must compile your C<TT>++</TT> programs with a supported C<TT>++</TT> compiler, such as GNU <CODE>g++</CODE>, or the HP ANSI C<TT>++</TT> compiler (<CODE>aCC</CODE>). </P><P> For best results when using GNU C<TT>++</TT>, use the DWARF 2 debugging format; if it doesn't work on your system, try the stabs+ debugging format. You can select those formats explicitly with the <CODE>g++</CODE> command-line options <SAMP>`-gdwarf-2'</SAMP> and <SAMP>`-gstabs+'</SAMP>. See section `Options for Debugging Your Program or GCC' in <CITE>Using the GNU Compiler Collection (GCC)</CITE>. </P><P> <BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC113">12.4.1.1 C and C<TT>++</TT> Operators</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">C and C<TT>++</TT> operators</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC114">12.4.1.2 C and C<TT>++</TT> Constants</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">C and C<TT>++</TT> constants</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC115">12.4.1.3 C<TT>++</TT> Expressions</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">C<TT>++</TT> expressions</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC116">12.4.1.4 C and C<TT>++</TT> Defaults</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Default settings for C and C<TT>++</TT></TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC117">12.4.1.5 C and C<TT>++</TT> Type and Range Checks</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">C and C<TT>++</TT> type and range checks</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC118">12.4.1.6 GDB and C</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC119">12.4.1.7 GDB Features for C<TT>++</TT></A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">GDB features for C<TT>++</TT></TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC120">12.4.1.8 Decimal Floating Point format</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Numbers in Decimal Floating Point format</TD></TR> </TABLE></BLOCKQUOTE> <P> <A NAME="C Operators"></A> <HR SIZE="6"> <A NAME="SEC113"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC112"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC114"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC112"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.1.1 C and C<TT>++</TT> Operators </H4> <!--docid::SEC113::--> <P> <A NAME="IDX588"></A> </P><P> Operators must be defined on values of specific types. For instance, <CODE>+</CODE> is defined on numbers, but not on structures. Operators are often defined on groups of types. </P><P> For the purposes of C and C<TT>++</TT>, the following definitions hold: </P><P> <UL> <LI> <EM>Integral types</EM> include <CODE>int</CODE> with any of its storage-class specifiers; <CODE>char</CODE>; <CODE>enum</CODE>; and, for C<TT>++</TT>, <CODE>bool</CODE>. <P> <LI> <EM>Floating-point types</EM> include <CODE>float</CODE>, <CODE>double</CODE>, and <CODE>long double</CODE> (if supported by the target platform). <P> <LI> <EM>Pointer types</EM> include all types defined as <CODE>(<VAR>type</VAR> *)</CODE>. <P> <LI> <EM>Scalar types</EM> include all of the above. <P> </UL> <P> The following operators are supported. They are listed here in order of increasing precedence: </P><P> <DL COMPACT> <DT><CODE>,</CODE> <DD>The comma or sequencing operator. Expressions in a comma-separated list are evaluated from left to right, with the result of the entire expression being the last expression evaluated. <P> <DT><CODE>=</CODE> <DD>Assignment. The value of an assignment expression is the value assigned. Defined on scalar types. <P> <DT><CODE><VAR>op</VAR>=</CODE> <DD>Used in an expression of the form <CODE><VAR>a</VAR> <VAR>op</VAR>= <VAR>b</VAR></CODE>, and translated to <CODE><VAR>a</VAR> = <VAR>a op b</VAR></CODE>. <CODE><VAR>op</VAR>=</CODE> and <CODE>=</CODE> have the same precedence. <VAR>op</VAR> is any one of the operators <CODE>|</CODE>, <CODE>^</CODE>, <CODE>&</CODE>, <CODE><<</CODE>, <CODE>>></CODE>, <CODE>+</CODE>, <CODE>-</CODE>, <CODE>*</CODE>, <CODE>/</CODE>, <CODE>%</CODE>. <P> <DT><CODE>?:</CODE> <DD>The ternary operator. <CODE><VAR>a</VAR> ? <VAR>b</VAR> : <VAR>c</VAR></CODE> can be thought of as: if <VAR>a</VAR> then <VAR>b</VAR> else <VAR>c</VAR>. <VAR>a</VAR> should be of an integral type. <P> <DT><CODE>||</CODE> <DD>Logical OR. Defined on integral types. <P> <DT><CODE>&&</CODE> <DD>Logical AND. Defined on integral types. <P> <DT><CODE>|</CODE> <DD>Bitwise OR. Defined on integral types. <P> <DT><CODE>^</CODE> <DD>Bitwise exclusive-OR. Defined on integral types. <P> <DT><CODE>&</CODE> <DD>Bitwise AND. Defined on integral types. <P> <DT><CODE>==, !=</CODE> <DD>Equality and inequality. Defined on scalar types. The value of these expressions is 0 for false and non-zero for true. <P> <DT><CODE><, >, <=, >=</CODE> <DD>Less than, greater than, less than or equal, greater than or equal. Defined on scalar types. The value of these expressions is 0 for false and non-zero for true. <P> <DT><CODE><<, >></CODE> <DD>left shift, and right shift. Defined on integral types. <P> <DT><CODE>@</CODE> <DD>The GDB "artificial array" operator (see section <A HREF="gdb_9.html#SEC60">Expressions</A>). <P> <DT><CODE>+, -</CODE> <DD>Addition and subtraction. Defined on integral types, floating-point types and pointer types. <P> <DT><CODE>*, /, %</CODE> <DD>Multiplication, division, and modulus. Multiplication and division are defined on integral and floating-point types. Modulus is defined on integral types. <P> <DT><CODE>++, --</CODE> <DD>Increment and decrement. When appearing before a variable, the operation is performed before the variable is used in an expression; when appearing after it, the variable's value is used before the operation takes place. <P> <DT><CODE>*</CODE> <DD>Pointer dereferencing. Defined on pointer types. Same precedence as <CODE>++</CODE>. <P> <DT><CODE>&</CODE> <DD>Address operator. Defined on variables. Same precedence as <CODE>++</CODE>. <P> For debugging C<TT>++</TT>, GDB implements a use of <SAMP>`&'</SAMP> beyond what is allowed in the C<TT>++</TT> language itself: you can use <SAMP>`&(&<VAR>ref</VAR>)'</SAMP> to examine the address where a C<TT>++</TT> reference variable (declared with <SAMP>`&<VAR>ref</VAR>'</SAMP>) is stored. </P><P> <DT><CODE>-</CODE> <DD>Negative. Defined on integral and floating-point types. Same precedence as <CODE>++</CODE>. <P> <DT><CODE>!</CODE> <DD>Logical negation. Defined on integral types. Same precedence as <CODE>++</CODE>. <P> <DT><CODE>~</CODE> <DD>Bitwise complement operator. Defined on integral types. Same precedence as <CODE>++</CODE>. <P> <DT><CODE>., -></CODE> <DD>Structure member, and pointer-to-structure member. For convenience, GDB regards the two as equivalent, choosing whether to dereference a pointer based on the stored type information. Defined on <CODE>struct</CODE> and <CODE>union</CODE> data. <P> <DT><CODE>.*, ->*</CODE> <DD>Dereferences of pointers to members. <P> <DT><CODE>[]</CODE> <DD>Array indexing. <CODE><VAR>a</VAR>[<VAR>i</VAR>]</CODE> is defined as <CODE>*(<VAR>a</VAR>+<VAR>i</VAR>)</CODE>. Same precedence as <CODE>-></CODE>. <P> <DT><CODE>()</CODE> <DD>Function parameter list. Same precedence as <CODE>-></CODE>. <P> <DT><CODE>::</CODE> <DD>C<TT>++</TT> scope resolution operator. Defined on <CODE>struct</CODE>, <CODE>union</CODE>, and <CODE>class</CODE> types. <P> <DT><CODE>::</CODE> <DD>Doubled colons also represent the GDB scope operator (see section <A HREF="gdb_9.html#SEC60">Expressions</A>). Same precedence as <CODE>::</CODE>, above. </DL> <P> If an operator is redefined in the user code, GDB usually attempts to invoke the redefined version instead of using the operator's predefined meaning. </P><P> <A NAME="C Constants"></A> <HR SIZE="6"> <A NAME="SEC114"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC113"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC115"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC115"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC112"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.1.2 C and C<TT>++</TT> Constants </H4> <!--docid::SEC114::--> <P> <A NAME="IDX589"></A> </P><P> GDB allows you to express the constants of C and C<TT>++</TT> in the following ways: </P><P> <UL> <LI> Integer constants are a sequence of digits. Octal constants are specified by a leading <SAMP>`0'</SAMP> (i.e. zero), and hexadecimal constants by a leading <SAMP>`0x'</SAMP> or <SAMP>`0X'</SAMP>. Constants may also end with a letter <SAMP>`l'</SAMP>, specifying that the constant should be treated as a <CODE>long</CODE> value. <P> <LI> Floating point constants are a sequence of digits, followed by a decimal point, followed by a sequence of digits, and optionally followed by an exponent. An exponent is of the form: <SAMP>`e[[+]|-]<VAR>nnn</VAR>'</SAMP>, where <VAR>nnn</VAR> is another sequence of digits. The <SAMP>`+'</SAMP> is optional for positive exponents. A floating-point constant may also end with a letter <SAMP>`f'</SAMP> or <SAMP>`F'</SAMP>, specifying that the constant should be treated as being of the <CODE>float</CODE> (as opposed to the default <CODE>double</CODE>) type; or with a letter <SAMP>`l'</SAMP> or <SAMP>`L'</SAMP>, which specifies a <CODE>long double</CODE> constant. <P> <LI> Enumerated constants consist of enumerated identifiers, or their integral equivalents. <P> <LI> Character constants are a single character surrounded by single quotes (<CODE>'</CODE>), or a number--the ordinal value of the corresponding character (usually its ASCII value). Within quotes, the single character may be represented by a letter or by <EM>escape sequences</EM>, which are of the form <SAMP>`\<VAR>nnn</VAR>'</SAMP>, where <VAR>nnn</VAR> is the octal representation of the character's ordinal value; or of the form <SAMP>`\<VAR>x</VAR>'</SAMP>, where <SAMP>`<VAR>x</VAR>'</SAMP> is a predefined special character--for example, <SAMP>`\n'</SAMP> for newline. <P> <LI> String constants are a sequence of character constants surrounded by double quotes (<CODE>"</CODE>). Any valid character constant (as described above) may appear. Double quotes within the string must be preceded by a backslash, so for instance <SAMP>`"a\"b'c"'</SAMP> is a string of five characters. <P> <LI> Pointer constants are an integral value. You can also write pointers to constants using the C operator <SAMP>`&'</SAMP>. <P> <LI> Array constants are comma-separated lists surrounded by braces <SAMP>`{'</SAMP> and <SAMP>`}'</SAMP>; for example, <SAMP>`{1,2,3}'</SAMP> is a three-element array of integers, <SAMP>`{{1,2}, {3,4}, {5,6}}'</SAMP> is a three-by-two array, and <SAMP>`{&"hi", &"there", &"fred"}'</SAMP> is a three-element array of pointers. </UL> <P> <A NAME="C Plus Plus Expressions"></A> <HR SIZE="6"> <A NAME="SEC115"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC114"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC116"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC116"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC112"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.1.3 C<TT>++</TT> Expressions </H4> <!--docid::SEC115::--> <P> <A NAME="IDX590"></A> GDB expression handling can interpret most C<TT>++</TT> expressions. </P><P> <A NAME="IDX591"></A> <A NAME="IDX592"></A> <A NAME="IDX593"></A> <A NAME="IDX594"></A> <BLOCKQUOTE> <EM>Warning:</EM> GDB can only debug C<TT>++</TT> code if you use the proper compiler and the proper debug format. Currently, GDB works best when debugging C<TT>++</TT> code that is compiled with GCC 2.95.3 or with GCC 3.1 or newer, using the options <SAMP>`-gdwarf-2'</SAMP> or <SAMP>`-gstabs+'</SAMP>. DWARF 2 is preferred over stabs+. Most configurations of GCC emit either DWARF 2 or stabs+ as their default debug format, so you usually don't need to specify a debug format explicitly. Other compilers and/or debug formats are likely to work badly or not at all when using GDB to debug C<TT>++</TT> code. </BLOCKQUOTE> <P> <OL> <A NAME="IDX595"></A> <LI> Member function calls are allowed; you can use expressions like <P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>count = aml->GetOriginal(x, y) </FONT></pre></td></tr></table></P><P> <A NAME="IDX596"></A> <A NAME="IDX597"></A> <LI> While a member function is active (in the selected stack frame), your expressions have the same namespace available as the member function; that is, GDB allows implicit references to the class instance pointer <CODE>this</CODE> following the same rules as C<TT>++</TT>. <P> <A NAME="IDX598"></A> <A NAME="IDX599"></A> <A NAME="IDX600"></A> <LI> You can call overloaded functions; GDB resolves the function call to the right definition, with some restrictions. GDB does not perform overload resolution involving user-defined type conversions, calls to constructors, or instantiations of templates that do not exist in the program. It also cannot handle ellipsis argument lists or default arguments. <P> It does perform integral conversions and promotions, floating-point promotions, arithmetic conversions, pointer conversions, conversions of class objects to base classes, and standard conversions such as those of functions or arrays to pointers; it requires an exact match on the number of function arguments. </P><P> Overload resolution is always performed, unless you have specified <CODE>set overload-resolution off</CODE>. See section <A HREF="gdb_13.html#SEC119">GDB Features for C<TT>++</TT></A>. </P><P> You must specify <CODE>set overload-resolution off</CODE> in order to use an explicit function signature to call an overloaded function, as in <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>p 'foo(char,int)'('x', 13) </FONT></pre></td></tr></table></P><P> The GDB command-completion facility can simplify this; see <A HREF="gdb_4.html#SEC16">Command Completion</A>. </P><P> <A NAME="IDX601"></A> <LI> GDB understands variables declared as C<TT>++</TT> references; you can use them in expressions just as you do in C<TT>++</TT> source--they are automatically dereferenced. <P> In the parameter list shown when GDB displays a frame, the values of reference variables are not displayed (unlike other variables); this avoids clutter, since references are often used for large structures. The <EM>address</EM> of a reference variable is always shown, unless you have specified <SAMP>`set print address off'</SAMP>. </P><P> <LI> GDB supports the C<TT>++</TT> name resolution operator <CODE>::</CODE>---your expressions can use it just as expressions in your program do. Since one scope may be defined in another, you can use <CODE>::</CODE> repeatedly if necessary, for example in an expression like <SAMP>`<VAR>scope1</VAR>::<VAR>scope2</VAR>::<VAR>name</VAR>'</SAMP>. GDB also allows resolving name scope by reference to source files, in both C and C<TT>++</TT> debugging (see section <A HREF="gdb_9.html#SEC61">Program Variables</A>). </OL> <P> In addition, when used with HP's C<TT>++</TT> compiler, GDB supports calling virtual functions correctly, printing out virtual bases of objects, calling functions in a base subobject, casting objects, and invoking user-defined operators. </P><P> <A NAME="C Defaults"></A> <HR SIZE="6"> <A NAME="SEC116"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC115"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC117"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC117"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC112"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.1.4 C and C<TT>++</TT> Defaults </H4> <!--docid::SEC116::--> <P> <A NAME="IDX602"></A> </P><P> If you allow GDB to set type and range checking automatically, they both default to <CODE>off</CODE> whenever the working language changes to C or C<TT>++</TT>. This happens regardless of whether you or GDB selects the working language. </P><P> If you allow GDB to set the language automatically, it recognizes source files whose names end with <TT>`.c'</TT>, <TT>`.C'</TT>, or <TT>`.cc'</TT>, etc, and when GDB enters code compiled from one of these files, it sets the working language to C or C<TT>++</TT>. See section <A HREF="gdb_13.html#SEC106">Having GDB Infer the Source Language</A>, for further details. </P><P> <A NAME="C Checks"></A> <HR SIZE="6"> <A NAME="SEC117"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC116"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC118"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC118"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC112"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.1.5 C and C<TT>++</TT> Type and Range Checks </H4> <!--docid::SEC117::--> <P> <A NAME="IDX603"></A> </P><P> By default, when GDB parses C or C<TT>++</TT> expressions, type checking is not used. However, if you turn type checking on, GDB considers two variables type equivalent if: </P><P> <UL> <LI> The two variables are structured and have the same structure, union, or enumerated tag. <P> <LI> The two variables have the same type name, or types that have been declared equivalent through <CODE>typedef</CODE>. <P> </UL> <P> Range checking, if turned on, is done on mathematical operations. Array indices are not checked, since they are often used to index a pointer that is not itself an array. </P><P> <A NAME="Debugging C"></A> <HR SIZE="6"> <A NAME="SEC118"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC117"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC119"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC119"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC112"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.1.6 GDB and C </H4> <!--docid::SEC118::--> <P> The <CODE>set print union</CODE> and <CODE>show print union</CODE> commands apply to the <CODE>union</CODE> type. When set to <SAMP>`on'</SAMP>, any <CODE>union</CODE> that is inside a <CODE>struct</CODE> or <CODE>class</CODE> is also printed. Otherwise, it appears as <SAMP>`{...}'</SAMP>. </P><P> The <CODE>@</CODE> operator aids in the debugging of dynamic arrays, formed with pointers and a memory allocation function. See section <A HREF="gdb_9.html#SEC60">Expressions</A>. </P><P> <A NAME="Debugging C Plus Plus"></A> <HR SIZE="6"> <A NAME="SEC119"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC118"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC120"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC120"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC112"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.1.7 GDB Features for C<TT>++</TT> </H4> <!--docid::SEC119::--> <P> <A NAME="IDX604"></A> </P><P> Some GDB commands are particularly useful with C<TT>++</TT>, and some are designed specifically for use with C<TT>++</TT>. Here is a summary: </P><P> <DL COMPACT> <A NAME="IDX605"></A> <DT><CODE>breakpoint menus</CODE> <DD>When you want a breakpoint in a function whose name is overloaded, GDB breakpoint menus help you specify which function definition you want. See section <A HREF="gdb_6.html#SEC40">Breakpoint Menus</A>. <P> <A NAME="IDX606"></A> <DT><CODE>rbreak <VAR>regex</VAR></CODE> <DD>Setting breakpoints using regular expressions is helpful for setting breakpoints on overloaded functions that are not members of any special classes. See section <A HREF="gdb_6.html#SEC33">Setting Breakpoints</A>. <P> <A NAME="IDX607"></A> <DT><CODE>catch throw</CODE> <DD><DT><CODE>catch catch</CODE> <DD>Debug C<TT>++</TT> exception handling using these commands. See section <A HREF="gdb_6.html#SEC35">Setting Catchpoints</A>. <P> <A NAME="IDX608"></A> <DT><CODE>ptype <VAR>typename</VAR></CODE> <DD>Print inheritance relationships as well as other information for type <VAR>typename</VAR>. See section <A HREF="gdb_14.html#SEC146">Examining the Symbol Table</A>. <P> <A NAME="IDX609"></A> <DT><CODE>set print demangle</CODE> <DD><DT><CODE>show print demangle</CODE> <DD><DT><CODE>set print asm-demangle</CODE> <DD><DT><CODE>show print asm-demangle</CODE> <DD>Control whether C<TT>++</TT> symbols display in their source form, both when displaying code as C<TT>++</TT> source and when displaying disassemblies. See section <A HREF="gdb_9.html#SEC66">Print Settings</A>. <P> <DT><CODE>set print object</CODE> <DD><DT><CODE>show print object</CODE> <DD>Choose whether to print derived (actual) or declared types of objects. See section <A HREF="gdb_9.html#SEC66">Print Settings</A>. <P> <DT><CODE>set print vtbl</CODE> <DD><DT><CODE>show print vtbl</CODE> <DD>Control the format for printing virtual function tables. See section <A HREF="gdb_9.html#SEC66">Print Settings</A>. (The <CODE>vtbl</CODE> commands do not work on programs compiled with the HP ANSI C<TT>++</TT> compiler (<CODE>aCC</CODE>).) <P> <A NAME="IDX610"></A> <A NAME="IDX611"></A> <DT><CODE>set overload-resolution on</CODE> <DD>Enable overload resolution for C<TT>++</TT> expression evaluation. The default is on. For overloaded functions, GDB evaluates the arguments and searches for a function whose signature matches the argument types, using the standard C<TT>++</TT> conversion rules (see <A HREF="gdb_13.html#SEC115">C<TT>++</TT> Expressions</A>, for details). If it cannot find a match, it emits a message. <P> <DT><CODE>set overload-resolution off</CODE> <DD>Disable overload resolution for C<TT>++</TT> expression evaluation. For overloaded functions that are not class member functions, GDB chooses the first function of the specified name that it finds in the symbol table, whether or not its arguments are of the correct type. For overloaded functions that are class member functions, GDB searches for a function whose signature <EM>exactly</EM> matches the argument types. <P> <A NAME="IDX612"></A> <DT><CODE>show overload-resolution</CODE> <DD>Show the current setting of overload resolution. <P> <DT><CODE>Overloaded symbol names</CODE> <DD>You can specify a particular definition of an overloaded symbol, using the same notation that is used to declare such symbols in C<TT>++</TT>: type <CODE><VAR>symbol</VAR>(<VAR>types</VAR>)</CODE> rather than just <VAR>symbol</VAR>. You can also use the GDB command-line word completion facilities to list the available choices, or to finish the type list for you. See section <A HREF="gdb_4.html#SEC16">Command Completion</A>, for details on how to do this. </DL> <P> <A NAME="Decimal Floating Point"></A> <HR SIZE="6"> <A NAME="SEC120"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC119"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC112"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.1.8 Decimal Floating Point format </H4> <!--docid::SEC120::--> <P> GDB can examine, set and perform computations with numbers in decimal floating point format, which in the C language correspond to the <CODE>_Decimal32</CODE>, <CODE>_Decimal64</CODE> and <CODE>_Decimal128</CODE> types as specified by the extension to support decimal floating-point arithmetic. </P><P> There are two encodings in use, depending on the architecture: BID (Binary Integer Decimal) for x86 and x86-64, and DPD (Densely Packed Decimal) for PowerPC. GDB will use the appropriate encoding for the configured target. </P><P> Because of a limitation in <TT>`libdecnumber'</TT>, the library used by GDB to manipulate decimal floating point numbers, it is not possible to convert (using a cast, for example) integers wider than 32-bit to decimal float. </P><P> In addition, in order to imitate GDB's behaviour with binary floating point computations, error checking in decimal float operations ignores underflow, overflow and divide by zero exceptions. </P><P> In the PowerPC architecture, GDB provides a set of pseudo-registers to inspect <CODE>_Decimal128</CODE> values stored in floating point registers. See <A HREF="gdb_19.html#SEC219">PowerPC</A> for more details. </P><P> <A NAME="Objective-C"></A> <HR SIZE="6"> <A NAME="SEC121"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC120"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC122"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.4.2 Objective-C </H3> <!--docid::SEC121::--> <P> <A NAME="IDX613"></A> This section provides information about some commands and command options that are useful for debugging Objective-C code. See also <A HREF="gdb_14.html#SEC146">info classes</A>, and <A HREF="gdb_14.html#SEC146">info selectors</A>, for a few more commands specific to Objective-C support. </P><P> <BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC122">12.4.2.1 Method Names in Commands</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC123">12.4.2.2 The Print Command With Objective-C</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR> </TABLE></BLOCKQUOTE> <P> <A NAME="Method Names in Commands"></A> <HR SIZE="6"> <A NAME="SEC122"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC123"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.2.1 Method Names in Commands </H4> <!--docid::SEC122::--> <P> The following commands have been extended to accept Objective-C method names as line specifications: </P><P> <A NAME="IDX614"></A> <A NAME="IDX615"></A> <A NAME="IDX616"></A> <A NAME="IDX617"></A> <A NAME="IDX618"></A> <UL> <LI><CODE>clear</CODE> <LI><CODE>break</CODE> <LI><CODE>info line</CODE> <LI><CODE>jump</CODE> <LI><CODE>list</CODE> </UL> <P> A fully qualified Objective-C method name is specified as </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>-[<VAR>Class</VAR> <VAR>methodName</VAR>] </FONT></pre></td></tr></table></P><P> where the minus sign is used to indicate an instance method and a plus sign (not shown) is used to indicate a class method. The class name <VAR>Class</VAR> and method name <VAR>methodName</VAR> are enclosed in brackets, similar to the way messages are specified in Objective-C source code. For example, to set a breakpoint at the <CODE>create</CODE> instance method of class <CODE>Fruit</CODE> in the program currently being debugged, enter: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>break -[Fruit create] </FONT></pre></td></tr></table></P><P> To list ten program lines around the <CODE>initialize</CODE> class method, enter: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>list +[NSText initialize] </FONT></pre></td></tr></table></P><P> In the current version of GDB, the plus or minus sign is required. In future versions of GDB, the plus or minus sign will be optional, but you can use it to narrow the search. It is also possible to specify just a method name: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>break create </FONT></pre></td></tr></table></P><P> You must specify the complete method name, including any colons. If your program's source files contain more than one <CODE>create</CODE> method, you'll be presented with a numbered list of classes that implement that method. Indicate your choice by number, or type <SAMP>`0'</SAMP> to exit if none apply. </P><P> As another example, to clear a breakpoint established at the <CODE>makeKeyAndOrderFront:</CODE> method of the <CODE>NSWindow</CODE> class, enter: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>clear -[NSWindow makeKeyAndOrderFront:] </FONT></pre></td></tr></table></P><P> <A NAME="The Print Command with Objective-C"></A> <HR SIZE="6"> <A NAME="SEC123"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC122"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC121"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.2.2 The Print Command With Objective-C </H4> <!--docid::SEC123::--> <P> The print command has also been extended to accept methods. For example: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>print -[<VAR>object</VAR> hash] </FONT></pre></td></tr></table></P><P> <A NAME="IDX619"></A> <A NAME="IDX620"></A> will tell GDB to send the <CODE>hash</CODE> message to <VAR>object</VAR> and print the result. Also, an additional command has been added, <CODE>print-object</CODE> or <CODE>po</CODE> for short, which is meant to print the description of an object. However, this command may only work with certain Objective-C libraries that have a particular hook function, <CODE>_NSPrintForDebugger</CODE>, defined. </P><P> <A NAME="Fortran"></A> <HR SIZE="6"> <A NAME="SEC124"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC123"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC125"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC128"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC128"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.4.3 Fortran </H3> <!--docid::SEC124::--> <P> GDB can be used to debug programs written in Fortran, but it currently supports only the features of Fortran 77 language. </P><P> <A NAME="IDX621"></A> Some Fortran compilers (GNU Fortran 77 and Fortran 95 compilers among them) append an underscore to the names of variables and functions. When you debug programs compiled by those compilers, you will need to refer to variables and functions with a trailing underscore. </P><P> <BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC125">12.4.3.1 Fortran Operators and Expressions</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Fortran operators and expressions</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC126">12.4.3.2 Fortran Defaults</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Default settings for Fortran</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC127">12.4.3.3 Special Fortran Commands</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Special GDB commands for Fortran</TD></TR> </TABLE></BLOCKQUOTE> <P> <A NAME="Fortran Operators"></A> <HR SIZE="6"> <A NAME="SEC125"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC126"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC128"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC128"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.3.1 Fortran Operators and Expressions </H4> <!--docid::SEC125::--> <P> <A NAME="IDX622"></A> </P><P> Operators must be defined on values of specific types. For instance, <CODE>+</CODE> is defined on numbers, but not on characters or other non- arithmetic types. Operators are often defined on groups of types. </P><P> <DL COMPACT> <DT><CODE>**</CODE> <DD>The exponentiation operator. It raises the first operand to the power of the second one. <P> <DT><CODE>:</CODE> <DD>The range operator. Normally used in the form of array(low:high) to represent a section of array. </DL> <P> <A NAME="Fortran Defaults"></A> <HR SIZE="6"> <A NAME="SEC126"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC125"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC127"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC127"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC128"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.3.2 Fortran Defaults </H4> <!--docid::SEC126::--> <P> <A NAME="IDX623"></A> </P><P> Fortran symbols are usually case-insensitive, so GDB by default uses case-insensitive matches for Fortran symbols. You can change that with the <SAMP>`set case-insensitive'</SAMP> command, see <A HREF="gdb_14.html#SEC146">13. Examining the Symbol Table</A>, for the details. </P><P> <A NAME="Special Fortran Commands"></A> <HR SIZE="6"> <A NAME="SEC127"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC126"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC128"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC128"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC124"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC128"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.3.3 Special Fortran Commands </H4> <!--docid::SEC127::--> <P> <A NAME="IDX624"></A> </P><P> GDB has some commands to support Fortran-specific features, such as displaying common blocks. </P><P> <DL COMPACT> <A NAME="IDX625"></A> <A NAME="IDX626"></A> <DT><CODE>info common [<VAR>common-name</VAR>]</CODE> <DD>This command prints the values contained in the Fortran <CODE>COMMON</CODE> block whose name is <VAR>common-name</VAR>. With no argument, the names of all <CODE>COMMON</CODE> blocks visible at the current program location are printed. </DL> <P> <A NAME="Pascal"></A> <HR SIZE="6"> <A NAME="SEC128"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC127"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.4.4 Pascal </H3> <!--docid::SEC128::--> <P> <A NAME="IDX627"></A> Debugging Pascal programs which use sets, subranges, file variables, or nested functions does not currently work. GDB does not support entering expressions, printing values, or similar features using Pascal syntax. </P><P> The Pascal-specific command <CODE>set print pascal_static-members</CODE> controls whether static members of Pascal objects are displayed. See section <A HREF="gdb_9.html#SEC66">pascal_static-members</A>. </P><P> <A NAME="Modula-2"></A> <HR SIZE="6"> <A NAME="SEC129"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC128"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC130"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.4.5 Modula-2 </H3> <!--docid::SEC129::--> <P> <A NAME="IDX628"></A> </P><P> The extensions made to GDB to support Modula-2 only support output from the GNU Modula-2 compiler (which is currently being developed). Other Modula-2 compilers are not currently supported, and attempting to debug executables produced by them is most likely to give an error as GDB reads in the executable's symbol table. </P><P> <A NAME="IDX629"></A> <BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC130">12.4.5.1 Operators</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Built-in operators</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC131">12.4.5.2 Built-in Functions and Procedures</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Built-in functions and procedures</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC132">12.4.5.3 Constants</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Modula-2 constants</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC133">12.4.5.4 Modula-2 Types</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Modula-2 types</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC134">12.4.5.5 Modula-2 Defaults</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Default settings for Modula-2</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC135">12.4.5.6 Deviations from Standard Modula-2</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Deviations from standard Modula-2</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC136">12.4.5.7 Modula-2 Type and Range Checks</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Modula-2 type and range checks</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC137">12.4.5.8 The Scope Operators <CODE>::</CODE> and <CODE>.</CODE></A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">The scope operators <CODE>::</CODE> and <CODE>.</CODE></TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC138">12.4.5.9 GDB and Modula-2</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR> </TABLE></BLOCKQUOTE> <P> <A NAME="M2 Operators"></A> <HR SIZE="6"> <A NAME="SEC130"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC131"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.5.1 Operators </H4> <!--docid::SEC130::--> <P> Operators must be defined on values of specific types. For instance, <CODE>+</CODE> is defined on numbers, but not on structures. Operators are often defined on groups of types. For the purposes of Modula-2, the following definitions hold: </P><P> <UL> <LI> <EM>Integral types</EM> consist of <CODE>INTEGER</CODE>, <CODE>CARDINAL</CODE>, and their subranges. <P> <LI> <EM>Character types</EM> consist of <CODE>CHAR</CODE> and its subranges. <P> <LI> <EM>Floating-point types</EM> consist of <CODE>REAL</CODE>. <P> <LI> <EM>Pointer types</EM> consist of anything declared as <CODE>POINTER TO <VAR>type</VAR></CODE>. <P> <LI> <EM>Scalar types</EM> consist of all of the above. <P> <LI> <EM>Set types</EM> consist of <CODE>SET</CODE> and <CODE>BITSET</CODE> types. <P> <LI> <EM>Boolean types</EM> consist of <CODE>BOOLEAN</CODE>. </UL> <P> The following operators are supported, and appear in order of increasing precedence: </P><P> <DL COMPACT> <DT><CODE>,</CODE> <DD>Function argument or array index separator. <P> <DT><CODE>:=</CODE> <DD>Assignment. The value of <VAR>var</VAR> <CODE>:=</CODE> <VAR>value</VAR> is <VAR>value</VAR>. <P> <DT><CODE><, ></CODE> <DD>Less than, greater than on integral, floating-point, or enumerated types. <P> <DT><CODE><=, >=</CODE> <DD>Less than or equal to, greater than or equal to on integral, floating-point and enumerated types, or set inclusion on set types. Same precedence as <CODE><</CODE>. <P> <DT><CODE>=, <>, #</CODE> <DD>Equality and two ways of expressing inequality, valid on scalar types. Same precedence as <CODE><</CODE>. In GDB scripts, only <CODE><></CODE> is available for inequality, since <CODE>#</CODE> conflicts with the script comment character. <P> <DT><CODE>IN</CODE> <DD>Set membership. Defined on set types and the types of their members. Same precedence as <CODE><</CODE>. <P> <DT><CODE>OR</CODE> <DD>Boolean disjunction. Defined on boolean types. <P> <DT><CODE>AND, &</CODE> <DD>Boolean conjunction. Defined on boolean types. <P> <DT><CODE>@</CODE> <DD>The GDB "artificial array" operator (see section <A HREF="gdb_9.html#SEC60">Expressions</A>). <P> <DT><CODE>+, -</CODE> <DD>Addition and subtraction on integral and floating-point types, or union and difference on set types. <P> <DT><CODE>*</CODE> <DD>Multiplication on integral and floating-point types, or set intersection on set types. <P> <DT><CODE>/</CODE> <DD>Division on floating-point types, or symmetric set difference on set types. Same precedence as <CODE>*</CODE>. <P> <DT><CODE>DIV, MOD</CODE> <DD>Integer division and remainder. Defined on integral types. Same precedence as <CODE>*</CODE>. <P> <DT><CODE>-</CODE> <DD>Negative. Defined on <CODE>INTEGER</CODE> and <CODE>REAL</CODE> data. <P> <DT><CODE>^</CODE> <DD>Pointer dereferencing. Defined on pointer types. <P> <DT><CODE>NOT</CODE> <DD>Boolean negation. Defined on boolean types. Same precedence as <CODE>^</CODE>. <P> <DT><CODE>.</CODE> <DD><CODE>RECORD</CODE> field selector. Defined on <CODE>RECORD</CODE> data. Same precedence as <CODE>^</CODE>. <P> <DT><CODE>[]</CODE> <DD>Array indexing. Defined on <CODE>ARRAY</CODE> data. Same precedence as <CODE>^</CODE>. <P> <DT><CODE>()</CODE> <DD>Procedure argument list. Defined on <CODE>PROCEDURE</CODE> objects. Same precedence as <CODE>^</CODE>. <P> <DT><CODE>::, .</CODE> <DD>GDB and Modula-2 scope operators. </DL> <P> <BLOCKQUOTE> <EM>Warning:</EM> Set expressions and their operations are not yet supported, so GDB treats the use of the operator <CODE>IN</CODE>, or the use of operators <CODE>+</CODE>, <CODE>-</CODE>, <CODE>*</CODE>, <CODE>/</CODE>, <CODE>=</CODE>, , <CODE><></CODE>, <CODE>#</CODE>, <CODE><=</CODE>, and <CODE>>=</CODE> on sets as an error. </BLOCKQUOTE> <P> <A NAME="Built-In Func/Proc"></A> <HR SIZE="6"> <A NAME="SEC131"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC130"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC132"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC132"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.5.2 Built-in Functions and Procedures </H4> <!--docid::SEC131::--> <P> Modula-2 also makes available several built-in procedures and functions. In describing these, the following metavariables are used: </P><P> <DL COMPACT> <DT><VAR>a</VAR> <DD>represents an <CODE>ARRAY</CODE> variable. <P> <DT><VAR>c</VAR> <DD>represents a <CODE>CHAR</CODE> constant or variable. <P> <DT><VAR>i</VAR> <DD>represents a variable or constant of integral type. <P> <DT><VAR>m</VAR> <DD>represents an identifier that belongs to a set. Generally used in the same function with the metavariable <VAR>s</VAR>. The type of <VAR>s</VAR> should be <CODE>SET OF <VAR>mtype</VAR></CODE> (where <VAR>mtype</VAR> is the type of <VAR>m</VAR>). <P> <DT><VAR>n</VAR> <DD>represents a variable or constant of integral or floating-point type. <P> <DT><VAR>r</VAR> <DD>represents a variable or constant of floating-point type. <P> <DT><VAR>t</VAR> <DD>represents a type. <P> <DT><VAR>v</VAR> <DD>represents a variable. <P> <DT><VAR>x</VAR> <DD>represents a variable or constant of one of many types. See the explanation of the function for details. </DL> <P> All Modula-2 built-in procedures also return a result, described below. </P><P> <DL COMPACT> <DT><CODE>ABS(<VAR>n</VAR>)</CODE> <DD>Returns the absolute value of <VAR>n</VAR>. <P> <DT><CODE>CAP(<VAR>c</VAR>)</CODE> <DD>If <VAR>c</VAR> is a lower case letter, it returns its upper case equivalent, otherwise it returns its argument. <P> <DT><CODE>CHR(<VAR>i</VAR>)</CODE> <DD>Returns the character whose ordinal value is <VAR>i</VAR>. <P> <DT><CODE>DEC(<VAR>v</VAR>)</CODE> <DD>Decrements the value in the variable <VAR>v</VAR> by one. Returns the new value. <P> <DT><CODE>DEC(<VAR>v</VAR>,<VAR>i</VAR>)</CODE> <DD>Decrements the value in the variable <VAR>v</VAR> by <VAR>i</VAR>. Returns the new value. <P> <DT><CODE>EXCL(<VAR>m</VAR>,<VAR>s</VAR>)</CODE> <DD>Removes the element <VAR>m</VAR> from the set <VAR>s</VAR>. Returns the new set. <P> <DT><CODE>FLOAT(<VAR>i</VAR>)</CODE> <DD>Returns the floating point equivalent of the integer <VAR>i</VAR>. <P> <DT><CODE>HIGH(<VAR>a</VAR>)</CODE> <DD>Returns the index of the last member of <VAR>a</VAR>. <P> <DT><CODE>INC(<VAR>v</VAR>)</CODE> <DD>Increments the value in the variable <VAR>v</VAR> by one. Returns the new value. <P> <DT><CODE>INC(<VAR>v</VAR>,<VAR>i</VAR>)</CODE> <DD>Increments the value in the variable <VAR>v</VAR> by <VAR>i</VAR>. Returns the new value. <P> <DT><CODE>INCL(<VAR>m</VAR>,<VAR>s</VAR>)</CODE> <DD>Adds the element <VAR>m</VAR> to the set <VAR>s</VAR> if it is not already there. Returns the new set. <P> <DT><CODE>MAX(<VAR>t</VAR>)</CODE> <DD>Returns the maximum value of the type <VAR>t</VAR>. <P> <DT><CODE>MIN(<VAR>t</VAR>)</CODE> <DD>Returns the minimum value of the type <VAR>t</VAR>. <P> <DT><CODE>ODD(<VAR>i</VAR>)</CODE> <DD>Returns boolean TRUE if <VAR>i</VAR> is an odd number. <P> <DT><CODE>ORD(<VAR>x</VAR>)</CODE> <DD>Returns the ordinal value of its argument. For example, the ordinal value of a character is its ASCII value (on machines supporting the ASCII character set). <VAR>x</VAR> must be of an ordered type, which include integral, character and enumerated types. <P> <DT><CODE>SIZE(<VAR>x</VAR>)</CODE> <DD>Returns the size of its argument. <VAR>x</VAR> can be a variable or a type. <P> <DT><CODE>TRUNC(<VAR>r</VAR>)</CODE> <DD>Returns the integral part of <VAR>r</VAR>. <P> <DT><CODE>TSIZE(<VAR>x</VAR>)</CODE> <DD>Returns the size of its argument. <VAR>x</VAR> can be a variable or a type. <P> <DT><CODE>VAL(<VAR>t</VAR>,<VAR>i</VAR>)</CODE> <DD>Returns the member of the type <VAR>t</VAR> whose ordinal value is <VAR>i</VAR>. </DL> <P> <BLOCKQUOTE> <EM>Warning:</EM> Sets and their operations are not yet supported, so GDB treats the use of procedures <CODE>INCL</CODE> and <CODE>EXCL</CODE> as an error. </BLOCKQUOTE> <P> <A NAME="IDX630"></A> <A NAME="M2 Constants"></A> <HR SIZE="6"> <A NAME="SEC132"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC131"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC133"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC133"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.5.3 Constants </H4> <!--docid::SEC132::--> <P> GDB allows you to express the constants of Modula-2 in the following ways: </P><P> <UL> <LI> Integer constants are simply a sequence of digits. When used in an expression, a constant is interpreted to be type-compatible with the rest of the expression. Hexadecimal integers are specified by a trailing <SAMP>`H'</SAMP>, and octal integers by a trailing <SAMP>`B'</SAMP>. <P> <LI> Floating point constants appear as a sequence of digits, followed by a decimal point and another sequence of digits. An optional exponent can then be specified, in the form <SAMP>`E[+|-]<VAR>nnn</VAR>'</SAMP>, where <SAMP>`[+|-]<VAR>nnn</VAR>'</SAMP> is the desired exponent. All of the digits of the floating point constant must be valid decimal (base 10) digits. <P> <LI> Character constants consist of a single character enclosed by a pair of like quotes, either single (<CODE>'</CODE>) or double (<CODE>"</CODE>). They may also be expressed by their ordinal value (their ASCII value, usually) followed by a <SAMP>`C'</SAMP>. <P> <LI> String constants consist of a sequence of characters enclosed by a pair of like quotes, either single (<CODE>'</CODE>) or double (<CODE>"</CODE>). Escape sequences in the style of C are also allowed. See section <A HREF="gdb_13.html#SEC114">C and C<TT>++</TT> Constants</A>, for a brief explanation of escape sequences. <P> <LI> Enumerated constants consist of an enumerated identifier. <P> <LI> Boolean constants consist of the identifiers <CODE>TRUE</CODE> and <CODE>FALSE</CODE>. <P> <LI> Pointer constants consist of integral values only. <P> <LI> Set constants are not yet supported. </UL> <P> <A NAME="M2 Types"></A> <HR SIZE="6"> <A NAME="SEC133"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC132"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC134"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC134"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.5.4 Modula-2 Types </H4> <!--docid::SEC133::--> <P> Currently GDB can print the following data types in Modula-2 syntax: array types, record types, set types, pointer types, procedure types, enumerated types, subrange types and base types. You can also print the contents of variables declared using these type. This section gives a number of simple source code examples together with sample GDB sessions. </P><P> The first example contains the following section of code: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>VAR s: SET OF CHAR ; r: [20..40] ; </FONT></pre></td></tr></table></P><P> and you can request GDB to interrogate the type and value of <CODE>r</CODE> and <CODE>s</CODE>. </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>(gdb) print s {'A'..'C', 'Z'} (gdb) ptype s SET OF CHAR (gdb) print r 21 (gdb) ptype r [20..40] </FONT></pre></td></tr></table></P><P> Likewise if your source code declares <CODE>s</CODE> as: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>VAR s: SET ['A'..'Z'] ; </FONT></pre></td></tr></table></P><P> then you may query the type of <CODE>s</CODE> by: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>(gdb) ptype s type = SET ['A'..'Z'] </FONT></pre></td></tr></table></P><P> Note that at present you cannot interactively manipulate set expressions using the debugger. </P><P> The following example shows how you might declare an array in Modula-2 and how you can interact with GDB to print its type and contents: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>VAR s: ARRAY [-10..10] OF CHAR ; </FONT></pre></td></tr></table></P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>(gdb) ptype s ARRAY [-10..10] OF CHAR </FONT></pre></td></tr></table></P><P> Note that the array handling is not yet complete and although the type is printed correctly, expression handling still assumes that all arrays have a lower bound of zero and not <CODE>-10</CODE> as in the example above. </P><P> Here are some more type related Modula-2 examples: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>TYPE colour = (blue, red, yellow, green) ; t = [blue..yellow] ; VAR s: t ; BEGIN s := blue ; </FONT></pre></td></tr></table></P><P> The GDB interaction shows how you can query the data type and value of a variable. </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>(gdb) print s $1 = blue (gdb) ptype t type = [blue..yellow] </FONT></pre></td></tr></table></P><P> In this example a Modula-2 array is declared and its contents displayed. Observe that the contents are written in the same way as their <CODE>C</CODE> counterparts. </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>VAR s: ARRAY [1..5] OF CARDINAL ; BEGIN s[1] := 1 ; </FONT></pre></td></tr></table></P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>(gdb) print s $1 = {1, 0, 0, 0, 0} (gdb) ptype s type = ARRAY [1..5] OF CARDINAL </FONT></pre></td></tr></table></P><P> The Modula-2 language interface to GDB also understands pointer types as shown in this example: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>VAR s: POINTER TO ARRAY [1..5] OF CARDINAL ; BEGIN NEW(s) ; s^[1] := 1 ; </FONT></pre></td></tr></table></P><P> and you can request that GDB describes the type of <CODE>s</CODE>. </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>(gdb) ptype s type = POINTER TO ARRAY [1..5] OF CARDINAL </FONT></pre></td></tr></table></P><P> GDB handles compound types as we can see in this example. Here we combine array types, record types, pointer types and subrange types: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>TYPE foo = RECORD f1: CARDINAL ; f2: CHAR ; f3: myarray ; END ; myarray = ARRAY myrange OF CARDINAL ; myrange = [-2..2] ; VAR s: POINTER TO ARRAY myrange OF foo ; </FONT></pre></td></tr></table></P><P> and you can ask GDB to describe the type of <CODE>s</CODE> as shown below. </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>(gdb) ptype s type = POINTER TO ARRAY [-2..2] OF foo = RECORD f1 : CARDINAL; f2 : CHAR; f3 : ARRAY [-2..2] OF CARDINAL; END </FONT></pre></td></tr></table></P><P> <A NAME="M2 Defaults"></A> <HR SIZE="6"> <A NAME="SEC134"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC133"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC135"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC135"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.5.5 Modula-2 Defaults </H4> <!--docid::SEC134::--> <P> If type and range checking are set automatically by GDB, they both default to <CODE>on</CODE> whenever the working language changes to Modula-2. This happens regardless of whether you or GDB selected the working language. </P><P> If you allow GDB to set the language automatically, then entering code compiled from a file whose name ends with <TT>`.mod'</TT> sets the working language to Modula-2. See section <A HREF="gdb_13.html#SEC106">Having GDB Infer the Source Language</A>, for further details. </P><P> <A NAME="Deviations"></A> <HR SIZE="6"> <A NAME="SEC135"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC134"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC136"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC136"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.5.6 Deviations from Standard Modula-2 </H4> <!--docid::SEC135::--> <P> A few changes have been made to make Modula-2 programs easier to debug. This is done primarily via loosening its type strictness: </P><P> <UL> <LI> Unlike in standard Modula-2, pointer constants can be formed by integers. This allows you to modify pointer variables during debugging. (In standard Modula-2, the actual address contained in a pointer variable is hidden from you; it can only be modified through direct assignment to another pointer variable or expression that returned a pointer.) <P> <LI> C escape sequences can be used in strings and characters to represent non-printable characters. GDB prints out strings with these escape sequences embedded. Single non-printable characters are printed using the <SAMP>`CHR(<VAR>nnn</VAR>)'</SAMP> format. <P> <LI> The assignment operator (<CODE>:=</CODE>) returns the value of its right-hand argument. <P> <LI> All built-in procedures both modify <EM>and</EM> return their argument. </UL> <P> <A NAME="M2 Checks"></A> <HR SIZE="6"> <A NAME="SEC136"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC135"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC137"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC137"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.5.7 Modula-2 Type and Range Checks </H4> <!--docid::SEC136::--> <P> <BLOCKQUOTE> <EM>Warning:</EM> in this release, GDB does not yet perform type or range checking. </BLOCKQUOTE> <P> GDB considers two Modula-2 variables type equivalent if: </P><P> <UL> <LI> They are of types that have been declared equivalent via a <CODE>TYPE <VAR>t1</VAR> = <VAR>t2</VAR></CODE> statement <P> <LI> They have been declared on the same line. (Note: This is true of the GNU Modula-2 compiler, but it may not be true of other compilers.) </UL> <P> As long as type checking is enabled, any attempt to combine variables whose types are not equivalent is an error. </P><P> Range checking is done on all mathematical operations, assignment, array index bounds, and all built-in functions and procedures. </P><P> <A NAME="M2 Scope"></A> <HR SIZE="6"> <A NAME="SEC137"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC136"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC138"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC138"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.5.8 The Scope Operators <CODE>::</CODE> and <CODE>.</CODE> </H4> <!--docid::SEC137::--> <P> There are a few subtle differences between the Modula-2 scope operator (<CODE>.</CODE>) and the GDB scope operator (<CODE>::</CODE>). The two have similar syntax: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre> <VAR>module</VAR> . <VAR>id</VAR> <VAR>scope</VAR> :: <VAR>id</VAR> </FONT></pre></td></tr></table></P><P> where <VAR>scope</VAR> is the name of a module or a procedure, <VAR>module</VAR> the name of a module, and <VAR>id</VAR> is any declared identifier within your program, except another module. </P><P> Using the <CODE>::</CODE> operator makes GDB search the scope specified by <VAR>scope</VAR> for the identifier <VAR>id</VAR>. If it is not found in the specified scope, then GDB searches all scopes enclosing the one specified by <VAR>scope</VAR>. </P><P> Using the <CODE>.</CODE> operator makes GDB search the current scope for the identifier specified by <VAR>id</VAR> that was imported from the definition module specified by <VAR>module</VAR>. With this operator, it is an error if the identifier <VAR>id</VAR> was not imported from definition module <VAR>module</VAR>, or if <VAR>id</VAR> is not an identifier in <VAR>module</VAR>. </P><P> <A NAME="GDB/M2"></A> <HR SIZE="6"> <A NAME="SEC138"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC137"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC129"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.5.9 GDB and Modula-2 </H4> <!--docid::SEC138::--> <P> Some GDB commands have little use when debugging Modula-2 programs. Five subcommands of <CODE>set print</CODE> and <CODE>show print</CODE> apply specifically to C and C<TT>++</TT>: <SAMP>`vtbl'</SAMP>, <SAMP>`demangle'</SAMP>, <SAMP>`asm-demangle'</SAMP>, <SAMP>`object'</SAMP>, and <SAMP>`union'</SAMP>. The first four apply to C<TT>++</TT>, and the last to the C <CODE>union</CODE> type, which has no direct analogue in Modula-2. </P><P> The <CODE>@</CODE> operator (see section <A HREF="gdb_9.html#SEC60">Expressions</A>), while available with any language, is not useful with Modula-2. Its intent is to aid the debugging of <EM>dynamic arrays</EM>, which cannot be created in Modula-2 as they can in C or C<TT>++</TT>. However, because an address can be specified by an integral constant, the construct <SAMP>`{<VAR>type</VAR>}<VAR>adrexp</VAR>'</SAMP> is still useful. </P><P> <A NAME="IDX631"></A> In GDB scripts, the Modula-2 inequality operator <CODE>#</CODE> is interpreted as the beginning of a comment. Use <CODE><></CODE> instead. </P><P> <A NAME="Ada"></A> <HR SIZE="6"> <A NAME="SEC139"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC138"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC140"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC111"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H3> 12.4.6 Ada </H3> <!--docid::SEC139::--> <P> The extensions made to GDB for Ada only support output from the GNU Ada (GNAT) compiler. Other Ada compilers are not currently supported, and attempting to debug executables produced by them is most likely to be difficult. </P><P> <A NAME="IDX632"></A> <BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC140">12.4.6.1 Introduction</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">General remarks on the Ada syntax and semantics supported by Ada mode in GDB.</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC141">12.4.6.2 Omissions from Ada</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Restrictions on the Ada expression syntax.</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC142">12.4.6.3 Additions to Ada</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Extensions of the Ada expression syntax.</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC143">12.4.6.4 Stopping at the Very Beginning</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Debugging the program during elaboration.</TD></TR> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC144">12.4.6.5 Known Peculiarities of Ada Mode</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP">Known peculiarities of Ada mode.</TD></TR> </TABLE></BLOCKQUOTE> <P> <A NAME="Ada Mode Intro"></A> <HR SIZE="6"> <A NAME="SEC140"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC141"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.6.1 Introduction </H4> <!--docid::SEC140::--> <P> The Ada mode of GDB supports a fairly large subset of Ada expression syntax, with some extensions. The philosophy behind the design of this subset is </P><P> <UL> <LI> That GDB should provide basic literals and access to operations for arithmetic, dereferencing, field selection, indexing, and subprogram calls, leaving more sophisticated computations to subprograms written into the program (which therefore may be called from GDB). <P> <LI> That type safety and strict adherence to Ada language restrictions are not particularly important to the GDB user. <P> <LI> That brevity is important to the GDB user. </UL> <P> Thus, for brevity, the debugger acts as if there were implicit <CODE>with</CODE> and <CODE>use</CODE> clauses in effect for all user-written packages, making it unnecessary to fully qualify most names with their packages, regardless of context. Where this causes ambiguity, GDB asks the user's intent. </P><P> The debugger will start in Ada mode if it detects an Ada main program. As for other languages, it will enter Ada mode when stopped in a program that was translated from an Ada source file. </P><P> While in Ada mode, you may use `<TT>--</TT>' for comments. This is useful mostly for documenting command files. The standard GDB comment (<SAMP>`#'</SAMP>) still works at the beginning of a line in Ada mode, but not in the middle (to allow based literals). </P><P> The debugger supports limited overloading. Given a subprogram call in which the function symbol has multiple definitions, it will use the number of actual parameters and some information about their types to attempt to narrow the set of definitions. It also makes very limited use of context, preferring procedures to functions in the context of the <CODE>call</CODE> command, and functions to procedures elsewhere. </P><P> <A NAME="Omissions from Ada"></A> <HR SIZE="6"> <A NAME="SEC141"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC140"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC142"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC142"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.6.2 Omissions from Ada </H4> <!--docid::SEC141::--> <P> Here are the notable omissions from the subset: </P><P> <UL> <LI> Only a subset of the attributes are supported: <P> <UL> <LI> <TT>'First</TT>, <TT>'Last</TT>, and <TT>'Length</TT> on array objects (not on types and subtypes). <P> <LI> <TT>'Min</TT> and <TT>'Max</TT>. <P> <LI> <TT>'Pos</TT> and <TT>'Val</TT>. <P> <LI> <TT>'Tag</TT>. <P> <LI> <TT>'Range</TT> on array objects (not subtypes), but only as the right operand of the membership (<CODE>in</CODE>) operator. <P> <LI> <TT>'Access</TT>, <TT>'Unchecked_Access</TT>, and <TT>'Unrestricted_Access</TT> (a GNAT extension). <P> <LI> <TT>'Address</TT>. </UL> <P> <LI> The names in <CODE>Characters.Latin_1</CODE> are not available and concatenation is not implemented. Thus, escape characters in strings are not currently available. <P> <LI> Equality tests (<SAMP>`='</SAMP> and <SAMP>`/='</SAMP>) on arrays test for bitwise equality of representations. They will generally work correctly for strings and arrays whose elements have integer or enumeration types. They may not work correctly for arrays whose element types have user-defined equality, for arrays of real values (in particular, IEEE-conformant floating point, because of negative zeroes and NaNs), and for arrays whose elements contain unused bits with indeterminate values. <P> <LI> The other component-by-component array operations (<CODE>and</CODE>, <CODE>or</CODE>, <CODE>xor</CODE>, <CODE>not</CODE>, and relational tests other than equality) are not implemented. <P> <LI> <A NAME="IDX633"></A> <A NAME="IDX634"></A> <A NAME="IDX635"></A> There is limited support for array and record aggregates. They are permitted only on the right sides of assignments, as in these examples: <P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>set An_Array := (1, 2, 3, 4, 5, 6) set An_Array := (1, others => 0) set An_Array := (0|4 => 1, 1..3 => 2, 5 => 6) set A_2D_Array := ((1, 2, 3), (4, 5, 6), (7, 8, 9)) set A_Record := (1, "Peter", True); set A_Record := (Name => "Peter", Id => 1, Alive => True) </FONT></pre></td></tr></table></P><P> Changing a discriminant's value by assigning an aggregate has an undefined effect if that discriminant is used within the record. However, you can first modify discriminants by directly assigning to them (which normally would not be allowed in Ada), and then performing an aggregate assignment. For example, given a variable <CODE>A_Rec</CODE> declared to have a type such as: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>type Rec (Len : Small_Integer := 0) is record Id : Integer; Vals : IntArray (1 .. Len); end record; </FONT></pre></td></tr></table></P><P> you can assign a value with a different size of <CODE>Vals</CODE> with two assignments: </P><P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>set A_Rec.Len := 4 set A_Rec := (Id => 42, Vals => (1, 2, 3, 4)) </FONT></pre></td></tr></table></P><P> As this example also illustrates, GDB is very loose about the usual rules concerning aggregates. You may leave out some of the components of an array or record aggregate (such as the <CODE>Len</CODE> component in the assignment to <CODE>A_Rec</CODE> above); they will retain their original values upon assignment. You may freely use dynamic values as indices in component associations. You may even use overlapping or redundant component associations, although which component values are assigned in such cases is not defined. </P><P> <LI> Calls to dispatching subprograms are not implemented. <P> <LI> The overloading algorithm is much more limited (i.e., less selective) than that of real Ada. It makes only limited use of the context in which a subexpression appears to resolve its meaning, and it is much looser in its rules for allowing type matches. As a result, some function calls will be ambiguous, and the user will be asked to choose the proper resolution. <P> <LI> The <CODE>new</CODE> operator is not implemented. <P> <LI> Entry calls are not implemented. <P> <LI> Aside from printing, arithmetic operations on the native VAX floating-point formats are not supported. <P> <LI> It is not possible to slice a packed array. </UL> <P> <A NAME="Additions to Ada"></A> <HR SIZE="6"> <A NAME="SEC142"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC141"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC143"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC143"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.6.3 Additions to Ada </H4> <!--docid::SEC142::--> <P> As it does for other languages, GDB makes certain generic extensions to Ada (see section <A HREF="gdb_9.html#SEC60">8.1 Expressions</A>): </P><P> <UL> <LI> If the expression <VAR>E</VAR> is a variable residing in memory (typically a local variable or array element) and <VAR>N</VAR> is a positive integer, then <CODE><VAR>E</VAR>@<VAR>N</VAR></CODE> displays the values of <VAR>E</VAR> and the <VAR>N</VAR>-1 adjacent variables following it in memory as an array. In Ada, this operator is generally not necessary, since its prime use is in displaying parts of an array, and slicing will usually do this in Ada. However, there are occasional uses when debugging programs in which certain debugging information has been optimized away. <P> <LI> <CODE><VAR>B</VAR>::<VAR>var</VAR></CODE> means "the variable named <VAR>var</VAR> that appears in function or file <VAR>B</VAR>." When <VAR>B</VAR> is a file name, you must typically surround it in single quotes. <P> <LI> The expression <CODE>{<VAR>type</VAR>} <VAR>addr</VAR></CODE> means "the variable of type <VAR>type</VAR> that appears at address <VAR>addr</VAR>." <P> <LI> A name starting with <SAMP>`$'</SAMP> is a convenience variable (see section <A HREF="gdb_9.html#SEC68">8.9 Convenience Variables</A>) or a machine register (see section <A HREF="gdb_9.html#SEC69">8.10 Registers</A>). </UL> <P> In addition, GDB provides a few other shortcuts and outright additions specific to Ada: </P><P> <UL> <LI> The assignment statement is allowed as an expression, returning its right-hand operand as its value. Thus, you may enter <P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>set x := y + 3 print A(tmp := y + 1) </FONT></pre></td></tr></table></P><P> <LI> The semicolon is allowed as an "operator," returning as its value the value of its right-hand operand. This allows, for example, complex conditional breaks: <P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>break f condition 1 (report(i); k += 1; A(k) > 100) </FONT></pre></td></tr></table></P><P> <LI> Rather than use catenation and symbolic character names to introduce special characters into strings, one may instead use a special bracket notation, which is also used to print strings. A sequence of characters of the form <SAMP>`["<VAR>XX</VAR>"]'</SAMP> within a string or character literal denotes the (single) character whose numeric encoding is <VAR>XX</VAR> in hexadecimal. The sequence of characters <SAMP>`["""]'</SAMP> also denotes a single quotation mark in strings. For example, <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre> "One line.["0a"]Next line.["0a"]" </FONT></pre></td></tr></table>contains an ASCII newline character (<CODE>Ada.Characters.Latin_1.LF</CODE>) after each period. <P> <LI> The subtype used as a prefix for the attributes <TT>'Pos</TT>, <TT>'Min</TT>, and <TT>'Max</TT> is optional (and is ignored in any case). For example, it is valid to write <P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>print 'max(x, y) </FONT></pre></td></tr></table></P><P> <LI> When printing arrays, GDB uses positional notation when the array has a lower bound of 1, and uses a modified named notation otherwise. For example, a one-dimensional array of three integers with a lower bound of 3 might print as <P> <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>(3 => 10, 17, 1) </FONT></pre></td></tr></table></P><P> That is, in contrast to valid Ada, only the first component has a <CODE>=></CODE> clause. </P><P> <LI> You may abbreviate attributes in expressions with any unique, multi-character subsequence of their names (an exact match gets preference). For example, you may use <TT>a'len</TT>, <TT>a'gth</TT>, or <TT>a'lh</TT> in place of <TT>a'length</TT>. <P> <LI> <A NAME="IDX636"></A> Since Ada is case-insensitive, the debugger normally maps identifiers you type to lower case. The GNAT compiler uses upper-case characters for some of its internal identifiers, which are normally of no interest to users. For the rare occasions when you actually have to look at them, enclose them in angle brackets to avoid the lower-case mapping. For example, <TABLE><tr><td> </td><td class=smallexample><FONT SIZE=-1><pre>gdb print <JMPBUF_SAVE>[0] </FONT></pre></td></tr></table><P> <LI> Printing an object of class-wide type or dereferencing an access-to-class-wide value will display all the components of the object's specific type (as indicated by its run-time tag). Likewise, component selection on such a value will operate on the specific type of the object. <P> </UL> <P> <A NAME="Stopping Before Main Program"></A> <HR SIZE="6"> <A NAME="SEC143"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC142"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC144"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC144"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.6.4 Stopping at the Very Beginning </H4> <!--docid::SEC143::--> <P> <A NAME="IDX637"></A> It is sometimes necessary to debug the program during elaboration, and before reaching the main procedure. As defined in the Ada Reference Manual, the elaboration code is invoked from a procedure called <CODE>adainit</CODE>. To run your program up to the beginning of elaboration, simply use the following two commands: <CODE>tbreak adainit</CODE> and <CODE>run</CODE>. </P><P> <A NAME="Ada Glitches"></A> <HR SIZE="6"> <A NAME="SEC144"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC143"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC139"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC145"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H4> 12.4.6.5 Known Peculiarities of Ada Mode </H4> <!--docid::SEC144::--> <P> Besides the omissions listed previously (see section <A HREF="gdb_13.html#SEC141">12.4.6.2 Omissions from Ada</A>), we know of several problems with and limitations of Ada mode in GDB, some of which will be fixed with planned future releases of the debugger and the GNU Ada compiler. </P><P> <UL> <LI> Currently, the debugger has insufficient information to determine whether certain pointers represent pointers to objects or the objects themselves. Thus, the user may have to tack an extra <CODE>.all</CODE> after an expression to get it printed properly. <P> <LI> Static constants that the compiler chooses not to materialize as objects in storage are invisible to the debugger. <P> <LI> Named parameter associations in function argument lists are ignored (the argument lists are treated as positional). <P> <LI> Many useful library packages are currently invisible to the debugger. <P> <LI> Fixed-point arithmetic, conversions, input, and output is carried out using floating-point arithmetic, and may give results that only approximate those on the host machine. <P> <LI> The type of the <TT>'Address</TT> attribute may not be <CODE>System.Address</CODE>. <P> <LI> The GNAT compiler never generates the prefix <CODE>Standard</CODE> for any of the standard symbols defined by the Ada language. GDB knows about this: it will strip the prefix from names when you use it, and will never look for a name you have so qualified among local symbols, nor match against symbols in other packages or subprograms. If you have defined entities anywhere in your program other than parameters and local variables whose simple names match names in <CODE>Standard</CODE>, GNAT's lack of qualification here can cause confusion. When this happens, you can usually resolve the confusion by qualifying the problematic names with package <CODE>Standard</CODE> explicitly. </UL> <P> <A NAME="Unsupported Languages"></A> <HR SIZE="6"> <A NAME="SEC145"></A> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC144"> < </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC146"> > </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> Up </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC146"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <H2> 12.5 Unsupported Languages </H2> <!--docid::SEC145::--> <P> <A NAME="IDX638"></A> <A NAME="IDX639"></A> In addition to the other fully-supported programming languages, GDB also provides a pseudo-language, called <CODE>minimal</CODE>. It does not represent a real programming language, but provides a set of capabilities close to what the C or assembly languages provide. This should allow most simple operations to be performed while debugging an application that uses a language currently not supported by GDB. </P><P> If the language is set to <CODE>auto</CODE>, GDB will automatically select this language if the current frame corresponds to an unsupported language. </P><P> <A NAME="Symbols"></A> <HR SIZE="6"> <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> << </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC146"> >> </A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD> </TR></TABLE> <BR> <FONT SIZE="-1"> <address> <p>Please send FSF & GNU inquiries & questions to <a href="mailto:gnu@gnu.org">gnu@gnu.org</a>. There are also <a href="http://www.gnu.org/home.html#ContactInfo">other ways to contact</a> the FSF.</p> <p>These pages are maintained by <a href="http://www.gnu.org/software/gdb/">the GDB developers</a>.</p> <p>Copyright Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.</p> <p>Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.</p> </address> This document was generated by <I>GDB Administrator</I> on <I>March, 27 2008</I> using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html "><I>texi2html</I></A> </BODY> </HTML>