blob: 55c5cb957aacd61338f76fb2e8c7b457c6f6f693 [file] [log] [blame]
<html lang="en">
<head>
<title>Setting - Debugging with GDB</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Debugging with GDB">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Languages.html#Languages" title="Languages">
<link rel="next" href="Show.html#Show" title="Show">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Free Software'' and ``Free Software Needs
Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom.''-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
<link rel="stylesheet" type="text/css" href="../cs.css">
</head>
<body>
<div class="node">
<a name="Setting"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Show.html#Show">Show</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Languages.html#Languages">Languages</a>
<hr>
</div>
<h3 class="section">15.1 Switching Between Source Languages</h3>
<p>There are two ways to control the working language&mdash;either have <span class="sc">gdb</span>
set it automatically, or select it manually yourself. You can use the
<code>set language</code> command for either purpose. On startup, <span class="sc">gdb</span>
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>In addition to the working language, every source file that
<span class="sc">gdb</span> 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 <span class="sc">gdb</span> infers the
language from the name of the file. The language of a source file
controls whether C<tt>++</tt> names are demangled&mdash;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 <span class="sc">gdb</span>, but you can
set the language associated with a filename extension. See <a href="Show.html#Show">Displaying the Language</a>.
<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
<span class="sc">gdb</span> will know the correct language of the source code of the original
program, and will display that source code, not the generated C code.
<ul class="menu">
<li><a accesskey="1" href="Filenames.html#Filenames">Filenames</a>: Filename extensions and languages.
<li><a accesskey="2" href="Manually.html#Manually">Manually</a>: Setting the working language manually
<li><a accesskey="3" href="Automatically.html#Automatically">Automatically</a>: Having <span class="sc">gdb</span> infer the source language
</ul>
</body></html>