mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
132 lines
No EOL
6.2 KiB
HTML
132 lines
No EOL
6.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<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>
|
|
|
|
<div role="main"><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>
|
|
<h2>To debug a project:</h2>
|
|
<ol>
|
|
<li>Click the <strong>Run > Debug Configurations...</strong> menu option.<br>
|
|
<br>
|
|
<p>The <strong>Debug</strong> <strong>Configurations</strong> dialog opens.<br>
|
|
<br>
|
|
<img src="../images/cdt_w_debug_configurations_01.png" alt="Debug Configurations dialog" width="873" height="662"><br>
|
|
<br>
|
|
</li>
|
|
<li>Double-click <strong>C/C++ Application</strong> to create a new launch configuration.<br>
|
|
<br>
|
|
<img src="../images/cdt_w_debug_configurations_02.png" alt="C/C++ Application debug configuration" width="763" height="601"><br>
|
|
<br>
|
|
<p>If a project is selected in the <a href="../reference/cdt_u_project_explorer_view.htm">Project Explorer</a> view the following data is automatically entered, take a moment to verify its accuracy or change as needed. <br>
|
|
<br>
|
|
</p>
|
|
<ol style="list-style-type: lower-alpha;">
|
|
<li>In the <strong>Name</strong> edit box, type the project name, like <strong>Hello World</strong>.<br>
|
|
<br>
|
|
You can now select this debug launch configuration by name the next time
|
|
that you debug this project.<br>
|
|
<br>
|
|
</li>
|
|
<li>In the <strong>C/C++ Application</strong> edit box, type the name of the executable if its not already entered. <br>
|
|
<br>
|
|
If not, click the <strong>Search Project</strong> button to locate the executable in the project.<br>
|
|
<br>
|
|
</li>
|
|
<li>
|
|
<p>In the <strong>Project</strong> edit box, type or choose your project, e.g. <strong>HelloWorld</strong>.<br>
|
|
</p>
|
|
<p> </p>
|
|
<p><strong>NOTE</strong> If you see the error "<span class="typewriter">[Debugger]: No debugger available</span>", select the <strong>Debugger</strong> tab
|
|
and choose a valid debugger for your platform (e.g. <span class="typewriter">gdb/mi</span>). <br>
|
|
<br>
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
<li>Click <strong>Debug</strong>.<br><br>
|
|
<p>You may be prompted to switch to the <strong>Debug</strong> perspective. Click <strong>Yes</strong></p><br>
|
|
<p>The <strong>Debug</strong> perspective appears with the <span class="typewriter">helloworld.exe</span> application window open.
|
|
The C/C++ editor repositions in the perspective.</p>
|
|
|
|
<br>
|
|
<p> <strong>NOTE:</strong> If you see the error "<span class="typewriter">Can't find source file</span>" in the editor view, use the <strong>Locate File</strong> button
|
|
to locate your source file.<br>
|
|
</p>
|
|
<br>
|
|
</li>
|
|
|
|
<li>In the left margin of the <span class="typewriter">main.cpp</span> window, double-click to set a
|
|
breakpoint on:<br>
|
|
<br>
|
|
<span class="typewriter">cout << <q>You just entered</q>
|
|
</span><br>
|
|
<br>
|
|
You'll see a blue circle (<img src="../images/icon_breakpoint_obj.gif" alt="Breakpoint" width="16" height="16">) there indicating the breakpoint is set.</br>
|
|
<br>
|
|
<br>
|
|
</li>
|
|
<li>Click <strong>Run > Resume</strong>.
|
|
<br>
|
|
<br>
|
|
Or, you can use the <strong>Resume</strong> button (<img src="../images/icon_db_resume.png" alt="Resume" width="19" height="14">) on the toolbar of the <strong>Debug</strong> view
|
|
.<br>
|
|
<br>
|
|
</li>
|
|
<li>When prompted, in the <strong>Console</strong> view, type a value other than 'm', and press Enter.<br>
|
|
<br>
|
|
The breakpoint will be hit.<br>
|
|
<br>
|
|
</li>
|
|
<li>In the <strong>Variables</strong> view, verify that the variable is not 'm'.<br>
|
|
<br>
|
|
</li>
|
|
<li>Click <strong>Run > Resume</strong>.<br>
|
|
<br>
|
|
</li>
|
|
<li>When prompted, again type a value other than 'm' in the <a href="../reference/cdt_u_console_view.htm">Console</a> view, and press Enter.
|
|
<p>The breakpoint will be hit.</p></li>
|
|
<li>In the <strong>Variables</strong> view, verify that the variable is not 'm'.<br>
|
|
<br>
|
|
</li>
|
|
<li>In the <strong>Variables</strong> view, right-click the input variable, and select <strong>Change Value...</strong>
|
|
and type <strong>'m'</strong> <em>between the single quotes</em> and hit <strong>OK</strong>.<br>
|
|
<br>
|
|
</li>
|
|
<li>Click <strong>Run > Resume</strong>.
|
|
<p>The output in the <span class="typewriter">helloworld.exe</span> application window is: "<span class="typewriter">Thank you. Exiting.</span>"
|
|
</p></li>
|
|
<li>The application terminates and the debug session ends. The <strong>Debug</strong> perspective remains open.</li>
|
|
</ol>
|
|
<p>To learn more about debugging, see the related debug conceptual topics.</p>
|
|
|
|
<p> <a href="cdt_w_build.htm">
|
|
<img src="../images/ngback.gif" width="16" height="16" alt="Back icon"></a><strong> <a href="cdt_w_build.htm">Back: Building a project</a></strong> </p>
|
|
|
|
<p><img 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 src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
|
|
<br>
|
|
<a href="../tasks/cdt_o_debug.htm">Debugging</a></p>
|
|
<p><img 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>
|
|
</p>
|
|
<p>
|
|
<img src="../images/ng00_04a.gif" ALT="QNX Copyright Statement" >
|
|
</div></body>
|
|
|
|
</html> |