1989 lines
84 KiB
HTML
1989 lines
84 KiB
HTML
<HTML>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<!-- Created on November, 11 2002 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="SEC92"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_12.html#SEC91"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC93"> > </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#SEC119"> >> </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_35.html#SEC643">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::SEC92::-->
|
|
<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="IDX461"></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#SEC93">12.1 Switching between source languages</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC97">12.2 Displaying the language</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC98">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#SEC101">12.4 Supported languages</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
</TABLE></BLOCKQUOTE>
|
|
<P>
|
|
|
|
<A NAME="Setting"></A>
|
|
<HR SIZE="6">
|
|
<A NAME="SEC93"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC94"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC97"> >> </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_35.html#SEC643">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::SEC93::-->
|
|
<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#SEC97">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#SEC94">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#SEC95">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#SEC96">12.1.3 Having GDB infer the source language</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
</TABLE></BLOCKQUOTE>
|
|
<P>
|
|
|
|
<A NAME="Filenames"></A>
|
|
<HR SIZE="6">
|
|
<A NAME="SEC94"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC93"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC95"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC93"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC97"> >> </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_35.html#SEC643">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::SEC94::-->
|
|
<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>`.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>`.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#SEC97">Displaying the language</A>.
|
|
</P><P>
|
|
|
|
<A NAME="Manually"></A>
|
|
<HR SIZE="6">
|
|
<A NAME="SEC95"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC94"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC96"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC96"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC93"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC97"> >> </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_35.html#SEC643">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::SEC95::-->
|
|
<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="IDX462"></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="SEC96"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC95"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC97"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC93"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC97"> >> </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_35.html#SEC643">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::SEC96::-->
|
|
<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="SEC97"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC96"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC98"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC98"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">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::SEC97::-->
|
|
<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>
|
|
|
|
<A NAME="IDX463"></A>
|
|
<A NAME="IDX464"></A>
|
|
<A NAME="IDX465"></A>
|
|
<DL COMPACT>
|
|
<DT><CODE>show language</CODE>
|
|
<DD>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>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#SEC45">Information about a frame</A>, to identify the other
|
|
information listed here.
|
|
<P>
|
|
|
|
<DT><CODE>info source</CODE>
|
|
<DD>Display the source language of this source file.
|
|
See section <A HREF="gdb_14.html#SEC119">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>
|
|
|
|
<A NAME="IDX466"></A>
|
|
<A NAME="IDX467"></A>
|
|
<DL COMPACT>
|
|
<DT><CODE>set extension-language <VAR>.ext</VAR> <VAR>language</VAR></CODE>
|
|
<DD>Set source files with extension <VAR>.ext</VAR> to be assumed to be in
|
|
the source language <VAR>language</VAR>.
|
|
<P>
|
|
|
|
<DT><CODE>info extensions</CODE>
|
|
<DD>List all the filename extensions and the associated languages.
|
|
</DL>
|
|
<P>
|
|
|
|
<A NAME="Checks"></A>
|
|
<HR SIZE="6">
|
|
<A NAME="SEC98"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC97"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC99"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC101"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC101"> >> </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_35.html#SEC643">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::SEC98::-->
|
|
<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#SEC101">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#SEC99">12.3.1 An overview of type checking</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC100">12.3.2 An overview of range checking</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
</TABLE></BLOCKQUOTE>
|
|
<P>
|
|
|
|
<A NAME="IDX468"></A>
|
|
<A NAME="IDX469"></A>
|
|
<A NAME="Type Checking"></A>
|
|
<HR SIZE="6">
|
|
<A NAME="SEC99"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC98"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC100"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC101"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC98"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC101"> >> </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_35.html#SEC643">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::SEC99::-->
|
|
<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#SEC101">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="IDX470"></A>
|
|
<A NAME="IDX471"></A>
|
|
<A NAME="IDX472"></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#SEC101">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="IDX473"></A>
|
|
<A NAME="IDX474"></A>
|
|
<A NAME="Range Checking"></A>
|
|
<HR SIZE="6">
|
|
<A NAME="SEC100"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC99"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC101"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC101"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC98"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC101"> >> </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_35.html#SEC643">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::SEC100::-->
|
|
<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#SEC101">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="IDX475"></A>
|
|
<A NAME="IDX476"></A>
|
|
<A NAME="IDX477"></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#SEC101">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="Support"></A>
|
|
<HR SIZE="6">
|
|
<A NAME="SEC101"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC100"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC102"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">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::SEC101::-->
|
|
<P>
|
|
|
|
GDB supports C, C<TT>++</TT>, Fortran, Java,
|
|
assembly, and Modula-2.
|
|
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#SEC54">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#SEC102">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#SEC110">12.4.2 Modula-2</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
</TABLE></BLOCKQUOTE>
|
|
<P>
|
|
|
|
<A NAME="C"></A>
|
|
<HR SIZE="6">
|
|
<A NAME="SEC102"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.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_13.html#SEC92"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC101"> Up </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"> <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_35.html#SEC643">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::SEC102::-->
|
|
<P>
|
|
|
|
<A NAME="IDX478"></A>
|
|
<A NAME="IDX479"></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="IDX480"></A>
|
|
<A NAME="IDX481"></A>
|
|
<A NAME="IDX482"></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 stabs debugging
|
|
format. You can select that format explicitly with the <CODE>g++</CODE>
|
|
command-line options <SAMP>`-gstabs'</SAMP> or <SAMP>`-gstabs+'</SAMP>. See
|
|
section `Options for Debugging Your Program or GNU CC' in <CITE>Using GNU CC</CITE>, for more information.
|
|
</P><P>
|
|
|
|
<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC103">12.4.1.1 C and C<TT>++</TT> operators</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC104">12.4.1.2 C and C<TT>++</TT> constants</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC105">12.4.1.3 C<TT>++</TT> expressions</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC106">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#SEC107">12.4.1.5 C and C<TT>++</TT> type and range checks</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC108">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#SEC109">12.4.1.7 GDB features for C<TT>++</TT></A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
</TABLE></BLOCKQUOTE>
|
|
<P>
|
|
|
|
<A NAME="C Operators"></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#SEC92"> << </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#SEC110"> >> </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_35.html#SEC643">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::SEC103::-->
|
|
<P>
|
|
|
|
<A NAME="IDX483"></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#SEC54">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>
|
|
(or, if you prefer, simply <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#SEC54">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>
|
|
|
|
<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC104">12.4.1.2 C and C<TT>++</TT> constants</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
</TABLE></BLOCKQUOTE>
|
|
<P>
|
|
|
|
<A NAME="C Constants"></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#SEC105"> << </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#SEC110"> >> </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_35.html#SEC643">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::SEC104::-->
|
|
<P>
|
|
|
|
<A NAME="IDX484"></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>
|
|
|
|
<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC105">12.4.1.3 C<TT>++</TT> expressions</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC106">12.4.1.4 C and C<TT>++</TT> defaults</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC107">12.4.1.5 C and C<TT>++</TT> type and range checks</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
</TABLE>
|
|
|
|
<br>
|
|
<TABLE BORDER=0 CELLSPACING=0>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC108">12.4.1.6 GDB and C</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
</TABLE></BLOCKQUOTE>
|
|
<P>
|
|
|
|
<A NAME="C plus plus expressions"></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#SEC102"> Up </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"> <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_35.html#SEC643">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::SEC105::-->
|
|
<P>
|
|
|
|
<A NAME="IDX485"></A>
|
|
GDB expression handling can interpret most C<TT>++</TT> expressions.
|
|
</P><P>
|
|
|
|
<A NAME="IDX486"></A>
|
|
<A NAME="IDX487"></A>
|
|
<A NAME="IDX488"></A>
|
|
<A NAME="IDX489"></A>
|
|
<A NAME="IDX490"></A>
|
|
<A NAME="IDX491"></A>
|
|
<A NAME="IDX492"></A>
|
|
<A NAME="IDX493"></A>
|
|
<A NAME="IDX494"></A>
|
|
<BLOCKQUOTE>
|
|
<EM>Warning:</EM> GDB can only debug C<TT>++</TT> code if you use the
|
|
proper compiler. Typically, C<TT>++</TT> debugging depends on the use of
|
|
additional debugging information in the symbol table, and thus requires
|
|
special support. In particular, if your compiler generates a.out, MIPS
|
|
ECOFF, RS/6000 XCOFF, or ELF with stabs extensions to the
|
|
symbol table, these facilities are all available. (With GNU CC,
|
|
you can use the <SAMP>`-gstabs'</SAMP> option to request stabs debugging
|
|
extensions explicitly.) Where the object code format is standard
|
|
COFF or DWARF in ELF, on the other hand, most of the C<TT>++</TT>
|
|
support in GDB does <EM>not</EM> work.
|
|
</BLOCKQUOTE>
|
|
<P>
|
|
|
|
<OL>
|
|
|
|
<A NAME="IDX495"></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="IDX496"></A>
|
|
<A NAME="IDX497"></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="IDX498"></A>
|
|
<A NAME="IDX499"></A>
|
|
<A NAME="IDX500"></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#SEC109">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#SEC14">Command completion</A>.
|
|
</P><P>
|
|
|
|
<A NAME="IDX501"></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#SEC55">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="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#SEC107"> << </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#SEC110"> >> </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_35.html#SEC643">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::SEC106::-->
|
|
<P>
|
|
|
|
<A NAME="IDX502"></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#SEC96">Having GDB infer the source language</A>,
|
|
for further details.
|
|
</P><P>
|
|
|
|
<A NAME="C Checks"></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_13.html#SEC110"> >> </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_35.html#SEC643">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::SEC107::-->
|
|
<P>
|
|
|
|
<A NAME="IDX503"></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="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#SEC109"> << </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#SEC110"> >> </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_35.html#SEC643">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::SEC108::-->
|
|
<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#SEC54">Expressions</A>.
|
|
</P><P>
|
|
|
|
<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC109">12.4.1.7 GDB features for C<TT>++</TT></A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
</TABLE></BLOCKQUOTE>
|
|
<P>
|
|
|
|
<A NAME="Debugging C plus plus"></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#SEC92"> << </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#SEC110"> >> </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_35.html#SEC643">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::SEC109::-->
|
|
<P>
|
|
|
|
<A NAME="IDX504"></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="IDX505"></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#SEC36">Breakpoint menus</A>.
|
|
<P>
|
|
|
|
<A NAME="IDX506"></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#SEC29">Setting breakpoints</A>.
|
|
<P>
|
|
|
|
<A NAME="IDX507"></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#SEC31">Setting catchpoints</A>.
|
|
<P>
|
|
|
|
<A NAME="IDX508"></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#SEC119">Examining the Symbol Table</A>.
|
|
<P>
|
|
|
|
<A NAME="IDX509"></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#SEC60">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#SEC60">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#SEC60">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="IDX510"></A>
|
|
<A NAME="IDX511"></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#SEC105">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>
|
|
|
|
<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#SEC14">Command completion</A>, for details on how to do this.
|
|
</DL>
|
|
<P>
|
|
|
|
<A NAME="Modula-2"></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#SEC92"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC101"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H3> 12.4.2 Modula-2 </H3>
|
|
<!--docid::SEC110::-->
|
|
<P>
|
|
|
|
<A NAME="IDX512"></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="IDX513"></A>
|
|
<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC111">12.4.2.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#SEC112">12.4.2.2 Built-in functions and procedures</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC113">12.4.2.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#SEC114">12.4.2.4 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#SEC115">12.4.2.5 Deviations from standard Modula-2</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC116">12.4.2.6 Modula-2 type and range checks</A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC117">12.4.2.7 The scope operators <CODE>::</CODE> and <CODE>.</CODE></A></TD><TD> </TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
|
|
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_13.html#SEC118">12.4.2.8 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="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#SEC92"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC110"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H4> 12.4.2.1 Operators </H4>
|
|
<!--docid::SEC111::-->
|
|
<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#SEC54">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> Sets 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="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#SEC113"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC110"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H4> 12.4.2.2 Built-in functions and procedures </H4>
|
|
<!--docid::SEC112::-->
|
|
<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>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="IDX514"></A>
|
|
<A NAME="M2 Constants"></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#SEC114"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC110"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H4> 12.4.2.3 Constants </H4>
|
|
<!--docid::SEC113::-->
|
|
<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#SEC104">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 Defaults"></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#SEC110"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H4> 12.4.2.4 Modula-2 defaults </H4>
|
|
<!--docid::SEC114::-->
|
|
<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#SEC96">Having GDB set the language automatically</A>, for further details.
|
|
</P><P>
|
|
|
|
<A NAME="Deviations"></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#SEC110"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H4> 12.4.2.5 Deviations from standard Modula-2 </H4>
|
|
<!--docid::SEC115::-->
|
|
<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="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#SEC110"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H4> 12.4.2.6 Modula-2 type and range checks </H4>
|
|
<!--docid::SEC116::-->
|
|
<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="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#SEC110"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H4> 12.4.2.7 The scope operators <CODE>::</CODE> and <CODE>.</CODE> </H4>
|
|
<!--docid::SEC117::-->
|
|
<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="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_14.html#SEC119"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC110"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H4> 12.4.2.8 GDB and Modula-2 </H4>
|
|
<!--docid::SEC118::-->
|
|
<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#SEC54">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="IDX515"></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="Symbols"></A>
|
|
<HR SIZE="6">
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_13.html#SEC92"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_14.html#SEC119"> >> </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_35.html#SEC643">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>November, 11 2002</I>
|
|
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
|
|
"><I>texi2html</I></A>
|
|
|
|
</BODY>
|
|
</HTML>
|