5
|
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
2 |
<html lang="en">
|
|
3 |
|
|
4 |
<head>
|
|
5 |
<meta http-equiv="Content-Language" content="en-us">
|
|
6 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
7 |
<title>Debugging your project</title>
|
|
8 |
<link rel="stylesheet" type="text/css" href="../help.css">
|
|
9 |
</head>
|
|
10 |
|
|
11 |
<body>
|
|
12 |
|
|
13 |
<h1>Debugging a project</h1>
|
|
14 |
|
|
15 |
<p>The debugger lets you control the execution of your program by setting
|
|
16 |
breakpoints, suspending executed programs, stepping through your code, and
|
|
17 |
examining the contents of variables.</p>
|
|
18 |
<p>To debug a project:</p>
|
|
19 |
<ol>
|
|
20 |
<li>Click <b>Run > Debug Configurations...</b>.<p>The Debug Configurations dialog opens.</li>
|
|
21 |
<li>Double-click <b>C/C++ Application</b>.</li>
|
|
22 |
<li>In the <b>Name</b> field, type <b>Hello World</b>.</li>
|
|
23 |
<p>You can now select this debug launch configuration by name the next time
|
|
24 |
that you debug this project.</p>
|
|
25 |
<li>In the <b>Project</b> box, type or choose your project, e.g. <b>HelloWorld</b>.
|
|
26 |
<br>
|
|
27 |
Your executable should be selected under "C/C++ Application."
|
|
28 |
<br>If not, the <b>Search Project</b> button should find the executable in the project.
|
|
29 |
<p> </p>
|
|
30 |
</li>
|
|
31 |
<ul>
|
|
32 |
<li>If you see the error "[Debugger]: No debugger available", select the Debugger tab
|
|
33 |
and choose a valid debugger for your platform (e.g. gdb/mi).
|
|
34 |
</li>
|
|
35 |
</ul>
|
|
36 |
<li>Click <b>Debug</b>.</li>
|
|
37 |
<p>You will be prompted to switch to the Debug Perspective. Click <b>Yes</b></p>
|
|
38 |
<p>You will now see the debug perspective with the hello.exe application window open.
|
|
39 |
The C/C++ editor repositions in the perspective.</p>
|
|
40 |
<ul>
|
|
41 |
<li>If you see an error in the editor "Can't find source file" you can use the buttons provided
|
|
42 |
to point to your source file, e.g. "Locate File."
|
|
43 |
</li>
|
|
44 |
</ul>
|
|
45 |
<li>In the left margin of the main.cpp window, double-click to set a
|
|
46 |
breakpoint on:<br>
|
|
47 |
cout << "You just entered"
|
|
48 |
<br>You'll see an icon there indicating the breakpoint is set.</br>
|
|
49 |
</li>
|
|
50 |
<li>Click <b>Run > Resume</b>.
|
|
51 |
<br>Or, you can use the <b>Resume</b> button (green arrow) on the toolbar <i>of the Debug View</i>
|
|
52 |
</li>
|
|
53 |
<li>When prompted, in the Console view, type a value other than 'm', and hit Enter/Return.<br>
|
|
54 |
The breakpoint will be hit.</li>
|
|
55 |
<li>In the <b>Variables</b> view, verify that the variable is not 'm'.</li>
|
|
56 |
<li>Click <b>Run > Resume</b>.</li>
|
|
57 |
<li>When prompted, again type a value other than 'm' in the Console view, and press Enter/Return.</li>
|
|
58 |
<p>The breakpoint will be hit.</p>
|
|
59 |
<li>In the <b>Variables</b> view, verify that the variable is not 'm'.</li>
|
|
60 |
<li>In the <b>Variables</b> view, right-click the input variable, and select <b>Change Value...</b>
|
|
61 |
and type <b>'m'</b> <i>between the single quotes</i> and hit <b>OK</b>.</li>
|
|
62 |
<li>Click <b>Run > Resume</b>.</li>
|
|
63 |
<p>The output in the hello.exe application window is:<br>
|
|
64 |
"You just entered m, you need to enter m to exit."
|
|
65 |
<li>The application terminates and the debug session ends. The debug
|
|
66 |
perspective remains open.</li>
|
|
67 |
</ol>
|
|
68 |
|
|
69 |
<p>To learn more about debugging, see the related debug conceptual topics.</p>
|
|
70 |
|
|
71 |
<p align="left"> <a href="cdt_w_build.htm">
|
|
72 |
<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> </p>
|
|
73 |
|
|
74 |
<p><img border="0" src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21">
|
|
75 |
<br>
|
|
76 |
<a href="../concepts/cdt_c_over_dbg.htm">Debug overview</a><br>
|
|
77 |
<a href="../concepts/cdt_c_dbg_info.htm">Debug information</a></p>
|
|
78 |
<p><img border="0" src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
|
|
79 |
<br>
|
|
80 |
<a href="../tasks/cdt_o_debug.htm">Debugging</a></p>
|
|
81 |
<p><img border="0" src="../images/ngref.gif" ALT="Related reference" width="143" height="21">
|
|
82 |
<br>
|
|
83 |
<a href="../reference/cdt_u_dbg_view.htm">Debug view</a><br>
|
|
84 |
<a href="../reference/cdt_u_dbg_view.htm">Debug launch controls</a><br>
|
|
85 |
</p>
|
|
86 |
<p>
|
|
87 |
<img src="../images/ng00_04a.gif" ALT="QNX Copyright Statement" >
|
|
88 |
</body>
|
|
89 |
|
|
90 |
</html> |