This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [wwwdocs] segfault.html


On Thu, 16 Jan 2003 10:21:24 -0800, Janis Johnson wrote:

> o  The DOCTYPE stuff isn't included in the files that are in
>    wwwdocs/htdocs, but is added by a tool before they are copied to
>    the web pages.

> o  The web pages themselves don't specify styles; Gerald can provide
>    more information about that.

> o  Web pages don't generally say who wrote them, although that info
>    can be in the CVS log.

> o  The title is rather long; how about "How to Debug a GCC Seg Fault."

How is this version?



<html>
  <head>
    <title>
      How to debug a GCC Segmentation fault
    </title>
  </head>
  <body>
    <h1>
      How to debug a GCC Segmentation fault
    </h1>
    <hr />
    <p>
      Configure GCC with <code>--enable-checking</code>.&nbsp; Compile
it with
      <code>-g</code> so that you can use gdb.
    </p>
    <p>
      Compile your test case with <code>-v -da -Q</code>.
    </p>
    <ul>
      <li>
        <code>-Q</code> will show which function in the test case is
causing
        it to crash.
      </li>
      <li>
        <code>-v</code> shows how `cc1' was invoked (useful for
invoking cc1
        manually in gdb).
      </li>
      <li>
        <code>-da</code> dumps the RTL to a file after each stage.
      </li>
    </ul>
    <p>
      Next, use gdb to get a stack trace.&nbsp; Compile the compiler
with
      debugging enabled (<code>-g</code>), use the <code>-v</code>
option to see how cc1 is getting
      invoked, and then do
    </p>
     
    <div style="margin-left: 40px;">
      bash$ <code>gdb cc1</code><br />
       gdb&gt; <code>run &lt;arguments&gt;</code><br />
       &hellip; (it will stop at the Seg fault)<br />
       gdb&gt; <code>where</code><br />
       &hellip;<br />
       gdb&gt; <code>list</code>
    </div>
     
    <p>
      Print out the values of interesting variables (e.g. the ones in
the
      statement which got a segmentation fault).
    </p>
    <p>
      You can use the <code>pt</code> and <code>pr</code> macros from
the
      gdbinit.in file to display them.&nbsp; For example, if there is a
value
      of type <code>tree</code> named <code>t</code>, and a value of
type
      <code>rtx</code> named <code>r</code>, you can use these
commands:
    </p>
     
    <div style="margin-left: 40px;">
      gdb&gt; <code>source .gdbinit</code><br />
       gdb&gt; <code>print t</code><br />
       gdb&gt; <code>pt</code><br />
       gdb&gt; <code>print r</code><br />
       gdb&gt; <code>pr</code><br />
       gdb&gt; <code>pt</code><br />
    </div>
  </body>
</html>




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]