1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00
cdt/doc/org.eclipse.cdt.doc.user/getting_started/cdt_w_debug.htm
2009-06-16 21:38:17 +00:00

90 lines
No EOL
4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Debugging your project</title>
<link rel="stylesheet" type="text/css" href="../help.css">
</head>
<body>
<h1>Debugging a project</h1>
<p>The debugger lets you control the execution of your program by setting
breakpoints, suspending executed programs, stepping through your code, and
examining the contents of variables.</p>
<p>To debug a project:</p>
<ol>
<li>Click <b>Run &gt; Debug Configurations...</b>.<p>The Debug Configurations dialog opens.</li>
<li>Double-click <b>C/C++ Application</b>.</li>
<li>In the <b>Name</b> field, type <b>Hello World</b>.</li>
<p>You can now select this debug launch configuration by name the next time
that you debug this project.</p>
<li>In the <b>Project</b> box, type or choose your project, e.g. <b>HelloWorld</b>.
<br>
Your executable should be selected under "C/C++ Application."
<br>If not, the <b>Search Project</b> button should find the executable in the project.
<p>&nbsp;</p>
</li>
<ul>
<li>If you see the error "[Debugger]: No debugger available", select the Debugger tab
and choose a valid debugger for your platform (e.g. gdb/mi).
</li>
</ul>
<li>Click <b>Debug</b>.</li>
<p>You will be prompted to switch to the Debug Perspective. Click <b>Yes</b></p>
<p>You will now see the debug perspective with the hello.exe application window open.
The C/C++ editor repositions in the perspective.</p>
<ul>
<li>If you see an error in the editor "Can't find source file" you can use the buttons provided
to point to your source file, e.g. "Locate File."
</li>
</ul>
<li>In the left margin of the main.cpp window, double-click to set a
breakpoint on:<br>
&nbsp;cout &lt;&lt; &quot;You just entered&quot;
<br>You'll see an icon there indicating the breakpoint is set.</br>
</li>
<li>Click <b>Run &gt; Resume</b>.
<br>Or, you can use the <b>Resume</b> button (green arrow) on the toolbar <i>of the Debug View</i>
</li>
<li>When prompted, in the Console view, type a value other than 'm', and hit Enter/Return.<br>
The breakpoint will be hit.</li>
<li>In the <b>Variables</b> view, verify that the variable is not 'm'.</li>
<li>Click <b>Run &gt; Resume</b>.</li>
<li>When prompted, again type a value other than 'm' in the Console view, and press Enter/Return.</li>
<p>The breakpoint will be hit.</p>
<li>In the <b>Variables</b> view, verify that the variable is not 'm'.</li>
<li>In the <b>Variables</b> view, right-click the input variable, and select <b>Change Value...</b>
and type <b>'m'</b> <i>between the single quotes</i> and hit <b>OK</b>.</li>
<li>Click <b>Run &gt; Resume</b>.</li>
<p>The output in the hello.exe application window is:<br>
&nbsp;&quot;You just entered m, you need to enter m to exit.&quot;
<li>The application terminates and the debug session ends. The debug
perspective remains open.</li>
</ol>
<p>To learn more about debugging, see the related debug conceptual topics.</p>
<p align="left"> <a href="cdt_w_build.htm">
<img border="0" src="../images/ngback.gif" width="16" height="16" alt="Back icon"></a><b> <a href="cdt_w_build.htm">Back: Building a project</a></b>&nbsp;&nbsp;&nbsp; </p>
<p><img border="0" src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21">
<br>
<a href="../concepts/cdt_c_over_dbg.htm">Debug overview</a><br>
<a href="../concepts/cdt_c_dbg_info.htm">Debug information</a></p>
<p><img border="0" src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
<br>
<a href="../tasks/cdt_o_debug.htm">Debugging</a></p>
<p><img border="0" src="../images/ngref.gif" ALT="Related reference" width="143" height="21">
<br>
<a href="../reference/cdt_u_dbg_view.htm">Debug view</a><br>
<a href="../reference/cdt_u_dbg_view.htm">Debug launch controls</a><br>
&nbsp;</p>
<p>
<img src="../images/ng00_04a.gif" ALT="QNX Copyright Statement" >
</body>
</html>