<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.gumstix.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Gustavs</id>
		<title>Gumstix User Wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.gumstix.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Gustavs"/>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php/Special:Contributions/Gustavs"/>
		<updated>2026-05-13T20:53:50Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.25.3</generator>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:LoginSuccess.png&amp;diff=4466</id>
		<title>File:LoginSuccess.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:LoginSuccess.png&amp;diff=4466"/>
				<updated>2010-08-05T16:43:28Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:LoginSuccess.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:TerminalWindow.png&amp;diff=4463</id>
		<title>File:TerminalWindow.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:TerminalWindow.png&amp;diff=4463"/>
				<updated>2010-08-05T16:35:51Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:TerminalWindow.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:Terminal.png&amp;diff=4458</id>
		<title>File:Terminal.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:Terminal.png&amp;diff=4458"/>
				<updated>2010-08-05T16:25:33Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:Terminal.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Terminal&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:Terminal.png&amp;diff=4457</id>
		<title>File:Terminal.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:Terminal.png&amp;diff=4457"/>
				<updated>2010-08-05T16:21:59Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:Terminal.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Terminal&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4393</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4393"/>
				<updated>2010-07-29T15:39:11Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial we will go over how to perform a basic debugging with GDB, the GNU debugger. This environment allows us to debug machine code. You will not be able to debug java programs with this unless you find a way to compile you java file into an executable that does not require a Java Virtual Machine.&lt;br /&gt;
*We will complete these tasks step by step&lt;br /&gt;
:*Installing the GDB debugger&lt;br /&gt;
:*Running the debugger&lt;br /&gt;
:*Learn how to set Breakpoints&lt;br /&gt;
:*Learn how to navigate the code in your program&lt;br /&gt;
:*Learn how to diagnose an error and how to fix it&lt;br /&gt;
&lt;br /&gt;
*Required Items&lt;br /&gt;
:*Overo COM with Expansion Board&lt;br /&gt;
:*Mini B to Standard A Cable&lt;br /&gt;
:*Bootable MicroSD card&lt;br /&gt;
:*5V Power Supply&lt;br /&gt;
&lt;br /&gt;
*Required Reading (things you should know, or tutorials that explain)&lt;br /&gt;
:*[[HelloWorld | HelloWorld in Python, C and C++]]&lt;br /&gt;
:*[[Eclipse on Gumstix for new users | Eclipse Tutorial]]&lt;br /&gt;
::*Although the majority of this tutorial regards Eclipse and Java programming, it contains useful information which leads to basic understanding of your Overo COM&lt;br /&gt;
&lt;br /&gt;
==Installing the GDB Debugger==&lt;br /&gt;
Before starting this, you should have Console access to your Overo COM and should know how to program and run a basic C++ program. If you do not know how to do this, see [[HelloWorld | HelloWorld in Python, C and C++]].&lt;br /&gt;
&lt;br /&gt;
To install the GDB debugger, run the following command in your command line:&lt;br /&gt;
 opkg update&lt;br /&gt;
 opkg install gdb&lt;br /&gt;
Once this has completed, you will have the GNU GDB debugger installed on your Overo COM&lt;br /&gt;
&lt;br /&gt;
==Creating the Test File==&lt;br /&gt;
Now that we have the debugging environment&lt;br /&gt;
&lt;br /&gt;
Run the following in your command line:&lt;br /&gt;
 nano broken.cpp&lt;br /&gt;
Then copy and paste the code from [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp |Broken.cpp] into your shell. When you copy and paste there will be two syntax errors that you must fix at the lines:&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following&lt;br /&gt;
 series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
and&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
Copying and pasting added an extra line break to these two lines, and we want to undo this by deleting one space at the beginning of each second line so it looks like this:&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
and&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
Now save and exit by pressing the following:&lt;br /&gt;
:*Ctrl + O&lt;br /&gt;
:*&amp;lt;Enter&amp;gt;&lt;br /&gt;
:*Ctrl + X&lt;br /&gt;
&lt;br /&gt;
==Compile and Run broken.cpp==&lt;br /&gt;
Now that we have our test file (broken.cpp) ready to go, it is time to run it. &lt;br /&gt;
&lt;br /&gt;
Compile the program to create an executable file (broken) by entering the following command:&lt;br /&gt;
 g++ -g broken.cpp -o broken&lt;br /&gt;
Then run it:&lt;br /&gt;
 ./broken&lt;br /&gt;
----&lt;br /&gt;
Note:&lt;br /&gt;
Use 'g++ -g broken.cpp -o broken' to compile. If you use g++ -o, g++ --ggdb -Wall, or any other method of compilation the debugging will not follow this tutorial exactly.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Enter any numbers into the program for x and n. Run it a couple times, you should notice that the answer is always the same: infinity. This is obviously wrong.&lt;br /&gt;
&lt;br /&gt;
Consider: x=1, n=1&lt;br /&gt;
(1^0)/0! + (1^1)/1!&lt;br /&gt;
1/1 + 1/1&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
NOT infinity&lt;br /&gt;
&lt;br /&gt;
==Debugging the Program==&lt;br /&gt;
Now, it is time that we debugged our program. &lt;br /&gt;
&lt;br /&gt;
First, you need to start the GDB environment by issuing the following command:&lt;br /&gt;
 gdb&lt;br /&gt;
You should see the following command line appear:&lt;br /&gt;
 (gdb)&lt;br /&gt;
Then, you need to 'tell' the debugger which file it is that we are debugging, do this by issuing the command:&lt;br /&gt;
 (gdb) exec-file broken&lt;br /&gt;
Now, it is time to run our program by issuing the command:&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
Notice that the program runs normally and again, gives us the answer inf. This is because the error we have is a computation error, and does not cause our program to crash. So, its time to set a Breakpoint in our program.&lt;br /&gt;
&lt;br /&gt;
===Setting a Breakpoint===&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A breakpoint is a point in the program at which the debugger will stop the code from executing. Then, you can choose to 'step' through the program line by line to 'see' exactly what the CPU is doing. This way, you can effectively watch the program execute and discover where the problem is!&lt;br /&gt;
----&lt;br /&gt;
Lets set a breakpoint within the program so that we can see what is going on. Lets start by setting a breakpoint at line 43. Do this with the following command:&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
----&lt;br /&gt;
Note:&lt;br /&gt;
If the program outputs: No symbol table is loaded.  Use the &amp;quot;file&amp;quot; command. Then use the following command:&lt;br /&gt;
 (gdb) file broken&lt;br /&gt;
This will set the file so that you can add a breakpoint without error&lt;br /&gt;
----&lt;br /&gt;
Line 43 is the following:&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
So the program will stop executing immediately before it executes the function ComputeSeriesValue(x, n).&lt;br /&gt;
&lt;br /&gt;
Now, lets run the program with our command:&lt;br /&gt;
 (gdb) run&lt;br /&gt;
Let's enter the values as x=2 and n=3, with an expected output value is 5. &lt;br /&gt;
Here is a snapshot of what the program should output at this point:&lt;br /&gt;
 This program is used to compute the value of the following series : &lt;br /&gt;
 (x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
 Please enter the value of x : 2&lt;br /&gt;
 Please enter an integer value for n : 3&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
The program has stopped at our breakpoint, line 43. &lt;br /&gt;
&lt;br /&gt;
===Stepping into a function===&lt;br /&gt;
Next, we are going to step into the function ComputeSeriesValue(x, n)&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
'Stepping' through a function allows us to go line by line, and see exactly what lines of code are being executed. This way we can manually diagnose the computation problem.&lt;br /&gt;
----&lt;br /&gt;
To start stepping, issue the following command&lt;br /&gt;
 (gdb) step&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A nice thing about the GDB Debugger is that it will save the last command you issued so that you don't need to type it over and over. This way you can keep stepping through the function by pressing &amp;lt;enter&amp;gt;. You do not need to retype 'step'&lt;br /&gt;
----&lt;br /&gt;
You should see the following outputted:&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
At this point, the program has gone to line 17, and is at the first line of the function ComputeSeriesValue, which sets the double seriesValue to 0.0.&lt;br /&gt;
&lt;br /&gt;
Now, we wish to use the 'next' function until we reach the function CompueFraction(). To do this, use the following commands:&lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt;&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) step&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
==Using Backtrace==&lt;br /&gt;
*If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
 (gdb) bt&lt;br /&gt;
 #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
 #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
----&lt;br /&gt;
Note: &lt;br /&gt;
Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
----&lt;br /&gt;
See the error?&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
&lt;br /&gt;
change the line&lt;br /&gt;
 int fact = 0;&lt;br /&gt;
to&lt;br /&gt;
 int fact =1;&lt;br /&gt;
and your all set!&lt;br /&gt;
&lt;br /&gt;
For another tutorial see:&lt;br /&gt;
http://www.cs.cmu.edu/~gilpin/tutorial/&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4387</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4387"/>
				<updated>2010-07-29T15:31:12Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial we will go over how to perform a basic debugging with GDB, the GNU debugger. This environment allows us to debug machine code. You will not be able to debug java programs with this unless you find a way to compile you java file into an executable that does not require a Java Virtual Machine.&lt;br /&gt;
*We will complete these tasks step by step&lt;br /&gt;
:*Installing the GDB debugger&lt;br /&gt;
:*Running the debugger&lt;br /&gt;
:*Learn how to set Breakpoints&lt;br /&gt;
:*Learn how to navigate the code in your program&lt;br /&gt;
:*Learn how to diagnose an error and how to fix it&lt;br /&gt;
&lt;br /&gt;
*Required Items&lt;br /&gt;
:*Overo COM with Expansion Board&lt;br /&gt;
:*Mini B to Standard A Cable&lt;br /&gt;
:*Bootable MicroSD card&lt;br /&gt;
:*5V Power Supply&lt;br /&gt;
&lt;br /&gt;
*Required Reading (things you should know, or tutorials that explain)&lt;br /&gt;
:*[[HelloWorld | HelloWorld in Python, C and C++]]&lt;br /&gt;
:*[[Eclipse on Gumstix for new users | Eclipse Tutorial]]&lt;br /&gt;
::*Although the majority of this tutorial regards Eclipse and Java programming, it contains useful information which leads to basic understanding of your Overo COM&lt;br /&gt;
&lt;br /&gt;
==Installing the GDB Debugger==&lt;br /&gt;
Before starting this, you should have Console access to your Overo COM and should know how to program and run a basic C++ program. If you do not know how to do this, see [[HelloWorld | HelloWorld in Python, C and C++]].&lt;br /&gt;
&lt;br /&gt;
To install the GDB debugger, run the following command in your command line:&lt;br /&gt;
 opkg update&lt;br /&gt;
 opkg install gdb&lt;br /&gt;
Once this has completed, you will have the GNU GDB debugger installed on your Overo COM&lt;br /&gt;
&lt;br /&gt;
==Creating the Test File==&lt;br /&gt;
Now that we have the debugging environment&lt;br /&gt;
&lt;br /&gt;
Run the following in your command line:&lt;br /&gt;
 nano broken.cpp&lt;br /&gt;
Then copy and paste the code from [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp |Broken.cpp] into your shell. When you copy and paste there will be two syntax errors that you must fix at the lines:&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following&lt;br /&gt;
 series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
and&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
Copying and pasting added an extra line break to these two lines, and we want to undo this by deleting one space at the beginning of each second line so it looks like this:&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
and&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
Now save and exit by pressing the following:&lt;br /&gt;
:*Ctrl + O&lt;br /&gt;
:*&amp;lt;Enter&amp;gt;&lt;br /&gt;
:*Ctrl + X&lt;br /&gt;
&lt;br /&gt;
==Compile and Run broken.cpp==&lt;br /&gt;
Now that we have our test file (broken.cpp) ready to go, it is time to run it. &lt;br /&gt;
&lt;br /&gt;
Compile the program to create an executable file (broken) by entering the following command:&lt;br /&gt;
 g++ -g broken.cpp -o broken&lt;br /&gt;
Then run it:&lt;br /&gt;
 ./broken&lt;br /&gt;
----&lt;br /&gt;
Note:&lt;br /&gt;
Use 'g++ -g broken.cpp -o broken' to compile. If you use g++ -o, g++ --ggdb -Wall, or any other method of compilation the debugging will not follow this tutorial exactly.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Enter any numbers into the program for x and n. Run it a couple times, you should notice that the answer is always the same: infinity. This is obviously wrong.&lt;br /&gt;
&lt;br /&gt;
Consider: x=1, n=1&lt;br /&gt;
(1^0)/0! + (1^1)/1!&lt;br /&gt;
1/1 + 1/1&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
NOT infinity&lt;br /&gt;
&lt;br /&gt;
==Debugging the Program==&lt;br /&gt;
Now, it is time that we debugged our program. &lt;br /&gt;
&lt;br /&gt;
First, you need to start the GDB environment by issuing the following command:&lt;br /&gt;
 gdb&lt;br /&gt;
You should see the following command line appear:&lt;br /&gt;
 (gdb)&lt;br /&gt;
Then, you need to 'tell' the debugger which file it is that we are debugging, do this by issuing the command:&lt;br /&gt;
 (gdb) exec-file broken&lt;br /&gt;
Now, it is time to run our program by issuing the command:&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
Notice that the program runs normally and again, gives us the answer inf. This is because the error we have is a computation error, and does not cause our program to crash. So, its time to set a Breakpoint in our program.&lt;br /&gt;
&lt;br /&gt;
===Setting a Breakpoint===&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A breakpoint is a point in the program at which the debugger will stop the code from executing. Then, you can choose to 'step' through the program line by line to 'see' exactly what the CPU is doing. This way, you can effectively watch the program execute and discover where the problem is!&lt;br /&gt;
----&lt;br /&gt;
Lets set a breakpoint within the program so that we can see what is going on. Lets start by setting a breakpoint at line 43. Do this with the following command:&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If the program outputs: No symbol table is loaded.  Use the &amp;quot;file&amp;quot; command. Then use the following command:&lt;br /&gt;
 (gdb) file broken&lt;br /&gt;
This will set the file so that you can add a breakpoint without error&lt;br /&gt;
----&lt;br /&gt;
Line 43 is the following:&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
So the program will stop executing immediately before it executes the function ComputeSeriesValue(x, n).&lt;br /&gt;
&lt;br /&gt;
Now, lets run the program with our command:&lt;br /&gt;
 (gdb) run&lt;br /&gt;
Let's enter the values as x=2 and n=3, with an expected output value is 5. &lt;br /&gt;
Here is a snapshot of what the program should output at this point:&lt;br /&gt;
 This program is used to compute the value of the following series : &lt;br /&gt;
 (x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
 Please enter the value of x : 2&lt;br /&gt;
 Please enter an integer value for n : 3&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
The program has stopped at our breakpoint, line 43. &lt;br /&gt;
&lt;br /&gt;
===Stepping into a function===&lt;br /&gt;
Next, we are going to step into the function ComputeSeriesValue(x, n)&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
'Stepping' through a function allows us to go line by line, and see exactly what lines of code are being executed. This way we can manually diagnose the computation problem.&lt;br /&gt;
----&lt;br /&gt;
To start stepping, issue the following command&lt;br /&gt;
 (gdb) step&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A nice thing about the GDB Debugger is that it will save the last command you issued so that you don't need to type it over and over. This way you can keep stepping through the function by pressing &amp;lt;enter&amp;gt;. You do not need to retype 'step'&lt;br /&gt;
----&lt;br /&gt;
You should see the following outputted:&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
At this point, the program has gone to line 17, and is at the first line of the function ComputeSeriesValue, which sets the double seriesValue to 0.0.&lt;br /&gt;
&lt;br /&gt;
Now, we wish to use the 'next' function until we reach the function CompueFraction(). To do this, use the following commands:&lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt;&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) step&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
==Using Backtrace==&lt;br /&gt;
*If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
 (gdb) bt&lt;br /&gt;
 #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
 #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
----&lt;br /&gt;
Note: &lt;br /&gt;
Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
----&lt;br /&gt;
See the error?&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
&lt;br /&gt;
change the line&lt;br /&gt;
 int fact = 0;&lt;br /&gt;
to&lt;br /&gt;
 int fact =1;&lt;br /&gt;
and your all set!&lt;br /&gt;
&lt;br /&gt;
For another tutorial see:&lt;br /&gt;
http://www.cs.cmu.edu/~gilpin/tutorial/&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4386</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4386"/>
				<updated>2010-07-29T15:18:38Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial we will go over how to perform a basic debugging with GDB, the GNU debugger. This environment allows us to debug machine code. You will not be able to debug java programs with this unless you find a way to compile you java file into an executable that does not require a Java Virtual Machine.&lt;br /&gt;
*We will complete these tasks step by step&lt;br /&gt;
:*Installing the GDB debugger&lt;br /&gt;
:*Running the debugger&lt;br /&gt;
:*Learn how to set Breakpoints&lt;br /&gt;
:*Learn how to navigate the code in your program&lt;br /&gt;
:*Learn how to diagnose an error and how to fix it&lt;br /&gt;
&lt;br /&gt;
*Required Items&lt;br /&gt;
:*Overo COM with Expansion Board&lt;br /&gt;
:*Mini B to Standard A Cable&lt;br /&gt;
:*Bootable MicroSD card&lt;br /&gt;
&lt;br /&gt;
*Required Reading (things you should know, or tutorials that explain)&lt;br /&gt;
:*[[HelloWorld | HelloWorld in Python, C and C++]]&lt;br /&gt;
:*[[Eclipse on Gumstix for new users | Eclipse Tutorial]]&lt;br /&gt;
::*Although the majority of this tutorial regards Eclipse and Java programming, it contains useful information which leads to basic understanding of your Overo COM&lt;br /&gt;
&lt;br /&gt;
==Installing the GDB Debugger==&lt;br /&gt;
Before starting this, you should have Console access to your Overo COM and should know how to program and run a basic C++ program. If you do not know how to do this, see [[HelloWorld | HelloWorld in Python, C and C++]].&lt;br /&gt;
&lt;br /&gt;
To install the GDB debugger, run the following command in your command line:&lt;br /&gt;
 opkg update&lt;br /&gt;
 opkg install gdb&lt;br /&gt;
Once this has completed, you will have the GNU GDB debugger installed on your Overo COM&lt;br /&gt;
&lt;br /&gt;
==Creating the Test File==&lt;br /&gt;
Now that we have the debugging environment&lt;br /&gt;
&lt;br /&gt;
Run the following in your command line:&lt;br /&gt;
 nano broken.cpp&lt;br /&gt;
Then copy and paste the code from [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp |Broken.cpp] into your shell. When you copy and paste there will be two syntax errors that you must fix at the lines:&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following&lt;br /&gt;
 series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
and&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
Copying and pasting added an extra line break to these two lines, and we want to undo this by deleting one space at the beginning of each second line so it looks like this:&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
and&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
Now save and exit by pressing the following:&lt;br /&gt;
:*Ctrl + O&lt;br /&gt;
:*&amp;lt;Enter&amp;gt;&lt;br /&gt;
:*Ctrl + X&lt;br /&gt;
&lt;br /&gt;
==Compile and Run broken.cpp==&lt;br /&gt;
Now that we have our test file (broken.cpp) ready to go, it is time to run it. &lt;br /&gt;
&lt;br /&gt;
Compile the program to create an executable file (broken) by entering the following command:&lt;br /&gt;
 g++ -g broken.cpp -o broken&lt;br /&gt;
Then run it:&lt;br /&gt;
 ./broken&lt;br /&gt;
----&lt;br /&gt;
Note:&lt;br /&gt;
Use 'g++ -g broken.cpp -o broken' to compile. If you use g++ -o, g++ --ggdb -Wall, or any other method of compilation the debugging will not follow this tutorial exactly.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Enter any numbers into the program for x and n. Run it a couple times, you should notice that the answer is always the same: infinity. This is obviously wrong.&lt;br /&gt;
&lt;br /&gt;
Consider: x=1, n=1&lt;br /&gt;
(1^0)/0! + (1^1)/1!&lt;br /&gt;
1/1 + 1/1&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
NOT infinity&lt;br /&gt;
&lt;br /&gt;
==Debugging the Program==&lt;br /&gt;
Now, it is time that we debugged our program. &lt;br /&gt;
&lt;br /&gt;
First, you need to start the GDB environment by issuing the following command:&lt;br /&gt;
 gdb&lt;br /&gt;
You should see the following command line appear:&lt;br /&gt;
 (gdb)&lt;br /&gt;
Then, you need to 'tell' the debugger which file it is that we are debugging, do this by issuing the command:&lt;br /&gt;
 (gdb) exec-file broken&lt;br /&gt;
Now, it is time to run our program by issuing the command:&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
Notice that the program runs normally and again, gives us the answer inf. This is because the error we have is a computation error, and does not cause our program to crash. So, its time to set a Breakpoint in our program.&lt;br /&gt;
&lt;br /&gt;
===Setting a Breakpoint===&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A breakpoint is a point in the program at which the debugger will stop the code from executing. Then, you can choose to 'step' through the program line by line to 'see' exactly what the CPU is doing. This way, you can effectively watch the program execute and discover where the problem is!&lt;br /&gt;
----&lt;br /&gt;
Lets set a breakpoint within the program so that we can see what is going on. Lets start by setting a breakpoint at line 43. Do this with the following command:&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If the program outputs: No symbol table is loaded.  Use the &amp;quot;file&amp;quot; command. Then use the following command:&lt;br /&gt;
 (gdb) file broken&lt;br /&gt;
This will set the file so that you can add a breakpoint without error&lt;br /&gt;
----&lt;br /&gt;
Line 43 is the following:&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
So the program will stop executing immediately before it executes the function ComputeSeriesValue(x, n).&lt;br /&gt;
&lt;br /&gt;
Now, lets run the program with our command:&lt;br /&gt;
 (gdb) run&lt;br /&gt;
Let's enter the values as x=2 and n=3, with an expected output value is 5. &lt;br /&gt;
Here is a snapshot of what the program should output at this point:&lt;br /&gt;
 This program is used to compute the value of the following series : &lt;br /&gt;
 (x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
 Please enter the value of x : 2&lt;br /&gt;
 Please enter an integer value for n : 3&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
The program has stopped at our breakpoint, line 43. &lt;br /&gt;
&lt;br /&gt;
===Stepping into a function===&lt;br /&gt;
Next, we are going to step into the function ComputeSeriesValue(x, n)&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
'Stepping' through a function allows us to go line by line, and see exactly what lines of code are being executed. This way we can manually diagnose the computation problem.&lt;br /&gt;
----&lt;br /&gt;
To start stepping, issue the following command&lt;br /&gt;
 (gdb) step&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A nice thing about the GDB Debugger is that it will save the last command you issued so that you don't need to type it over and over. This way you can keep stepping through the function by pressing &amp;lt;enter&amp;gt;. You do not need to retype 'step'&lt;br /&gt;
----&lt;br /&gt;
You should see the following outputted:&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
At this point, the program has gone to line 17, and is at the first line of the function ComputeSeriesValue, which sets the double seriesValue to 0.0.&lt;br /&gt;
&lt;br /&gt;
Now, we wish to use the 'next' function until we reach the function CompueFraction(). To do this, use the following commands:&lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt;&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) step&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
==Using Backtrace==&lt;br /&gt;
*If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
 (gdb) bt&lt;br /&gt;
 #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
 #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
----&lt;br /&gt;
Note: &lt;br /&gt;
Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
----&lt;br /&gt;
See the error?&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
&lt;br /&gt;
change the line&lt;br /&gt;
 int fact = 0;&lt;br /&gt;
to&lt;br /&gt;
 int fact =1;&lt;br /&gt;
and your all set!&lt;br /&gt;
&lt;br /&gt;
For another tutorial see:&lt;br /&gt;
http://www.cs.cmu.edu/~gilpin/tutorial/&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4385</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4385"/>
				<updated>2010-07-29T15:16:51Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial we will go over how to perform a basic debugging with GDB, the GNU debugger. This environment allows us to debug machine code. You will not be able to debug java programs with this unless you find a way to compile you java file into an executable that does not require a Java Virtual Machine.&lt;br /&gt;
*We will complete these tasks step by step&lt;br /&gt;
:*Installing the GDB debugger&lt;br /&gt;
:*Running the debugger&lt;br /&gt;
:*Learn how to set Breakpoints&lt;br /&gt;
:*Learn how to navigate the code in your program&lt;br /&gt;
:*Learn how to diagnose an error and how to fix it&lt;br /&gt;
&lt;br /&gt;
*Required Items&lt;br /&gt;
:*Overo COM with Expansion Board&lt;br /&gt;
:*Mini B to Standard A Cable&lt;br /&gt;
:*Bootable MicroSD card&lt;br /&gt;
&lt;br /&gt;
*Required Reading (things you should know, or tutorials that explain)&lt;br /&gt;
:*[[HelloWorld | HelloWorld in Python, C and C++]]&lt;br /&gt;
:*[[Eclipse on Gumstix for new users | Eclipse Tutorial]]&lt;br /&gt;
::*Although the majority of this tutorial regards Eclipse and Java programming, it contains useful information which leads to basic understanding of your Overo COM&lt;br /&gt;
&lt;br /&gt;
==Installing the GDB Debugger==&lt;br /&gt;
Before starting this, you should have Console access to your Overo COM and should know how to program and run a basic C++ program. If you do not know how to do this, see [HelloWorld | HelloWorld in Python, C and C++].&lt;br /&gt;
&lt;br /&gt;
To install the GDB debugger, run the following command in your command line:&lt;br /&gt;
 opkg update&lt;br /&gt;
 opkg install gdb&lt;br /&gt;
Once this has completed, you will have the GNU GDB debugger installed on your Overo COM&lt;br /&gt;
&lt;br /&gt;
==Creating the Test File==&lt;br /&gt;
Now that we have the debugging environment&lt;br /&gt;
&lt;br /&gt;
Run the following in your command line:&lt;br /&gt;
 nano broken.cpp&lt;br /&gt;
Then copy and paste the code from [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp |Broken.cpp] into your shell. When you copy and paste there will be two syntax errors that you must fix at the lines:&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following&lt;br /&gt;
 series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
and&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
Copying and pasting added an extra line break to these two lines, and we want to undo this by deleting one space at the beginning of each second line so it looks like this:&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
and&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
Now save and exit by pressing the following:&lt;br /&gt;
:*Ctrl + O&lt;br /&gt;
:*&amp;lt;Enter&amp;gt;&lt;br /&gt;
:*Ctrl + X&lt;br /&gt;
&lt;br /&gt;
==Compile and Run broken.cpp==&lt;br /&gt;
Now that we have our test file (broken.cpp) ready to go, it is time to run it. &lt;br /&gt;
&lt;br /&gt;
Compile the program to create an executable file (broken) by entering the following command:&lt;br /&gt;
 g++ -g broken.cpp -o broken&lt;br /&gt;
Then run it:&lt;br /&gt;
 ./broken&lt;br /&gt;
----&lt;br /&gt;
Note:&lt;br /&gt;
Use 'g++ -g broken.cpp -o broken' to compile. If you use g++ -o, g++ --ggdb -Wall, or any other method of compilation the debugging will not follow this tutorial exactly.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Enter any numbers into the program for x and n. Run it a couple times, you should notice that the answer is always the same: infinity. This is obviously wrong.&lt;br /&gt;
&lt;br /&gt;
Consider: x=1, n=1&lt;br /&gt;
(1^0)/0! + (1^1)/1!&lt;br /&gt;
1/1 + 1/1&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
NOT infinity&lt;br /&gt;
&lt;br /&gt;
==Debugging the Program==&lt;br /&gt;
Now, it is time that we debugged our program. &lt;br /&gt;
&lt;br /&gt;
First, you need to start the GDB environment by issuing the following command:&lt;br /&gt;
 gdb&lt;br /&gt;
You should see the following command line appear:&lt;br /&gt;
 (gdb)&lt;br /&gt;
Then, you need to 'tell' the debugger which file it is that we are debugging, do this by issuing the command:&lt;br /&gt;
 (gdb) exec-file broken&lt;br /&gt;
Now, it is time to run our program by issuing the command:&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
Notice that the program runs normally and again, gives us the answer inf. This is because the error we have is a computation error, and does not cause our program to crash. So, its time to set a Breakpoint in our program.&lt;br /&gt;
&lt;br /&gt;
===Setting a Breakpoint===&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A breakpoint is a point in the program at which the debugger will stop the code from executing. Then, you can choose to 'step' through the program line by line to 'see' exactly what the CPU is doing. This way, you can effectively watch the program execute and discover where the problem is!&lt;br /&gt;
----&lt;br /&gt;
Lets set a breakpoint within the program so that we can see what is going on. Lets start by setting a breakpoint at line 43. Do this with the following command:&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If the program outputs: No symbol table is loaded.  Use the &amp;quot;file&amp;quot; command. Then use the following command:&lt;br /&gt;
 (gdb) file broken&lt;br /&gt;
This will set the file so that you can add a breakpoint without error&lt;br /&gt;
----&lt;br /&gt;
Line 43 is the following:&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
So the program will stop executing immediately before it executes the function ComputeSeriesValue(x, n).&lt;br /&gt;
&lt;br /&gt;
Now, lets run the program with our command:&lt;br /&gt;
 (gdb) run&lt;br /&gt;
Let's enter the values as x=2 and n=3, with an expected output value is 5. &lt;br /&gt;
Here is a snapshot of what the program should output at this point:&lt;br /&gt;
 This program is used to compute the value of the following series : &lt;br /&gt;
 (x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
 Please enter the value of x : 2&lt;br /&gt;
 Please enter an integer value for n : 3&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
The program has stopped at our breakpoint, line 43. &lt;br /&gt;
&lt;br /&gt;
===Stepping into a function===&lt;br /&gt;
Next, we are going to step into the function ComputeSeriesValue(x, n)&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
'Stepping' through a function allows us to go line by line, and see exactly what lines of code are being executed. This way we can manually diagnose the computation problem.&lt;br /&gt;
----&lt;br /&gt;
To start stepping, issue the following command&lt;br /&gt;
 (gdb) step&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A nice thing about the GDB Debugger is that it will save the last command you issued so that you don't need to type it over and over. This way you can keep stepping through the function by pressing &amp;lt;enter&amp;gt;. You do not need to retype 'step'&lt;br /&gt;
----&lt;br /&gt;
You should see the following outputted:&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
At this point, the program has gone to line 17, and is at the first line of the function ComputeSeriesValue, which sets the double seriesValue to 0.0.&lt;br /&gt;
&lt;br /&gt;
Now, we wish to use the 'next' function until we reach the function CompueFraction(). To do this, use the following commands:&lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt;&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) step&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
==Using Backtrace==&lt;br /&gt;
*If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
 (gdb) bt&lt;br /&gt;
 #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
 #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
----&lt;br /&gt;
Note: &lt;br /&gt;
Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
----&lt;br /&gt;
See the error?&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
&lt;br /&gt;
change the line&lt;br /&gt;
 int fact = 0;&lt;br /&gt;
to&lt;br /&gt;
 int fact =1;&lt;br /&gt;
and your all set!&lt;br /&gt;
&lt;br /&gt;
For another tutorial see:&lt;br /&gt;
http://www.cs.cmu.edu/~gilpin/tutorial/&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4381</id>
		<title>Eclipse on Gumstix for new users</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4381"/>
				<updated>2010-07-28T22:19:54Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide provides step-by-step instructions for using the Eclipse Integrated Development Environment (IDE) to develop applications for the Gumstix COMs.&lt;br /&gt;
&lt;br /&gt;
We'll walk through these tasks:&lt;br /&gt;
:* setting up Eclipse&lt;br /&gt;
:* connection to your Gumstix system&lt;br /&gt;
:* creating a simple &amp;quot;Hello, World!&amp;quot; Python program&lt;br /&gt;
:* running a web server&lt;br /&gt;
:* installing new packages on your Gumstix&lt;br /&gt;
:* creating a small graphical Java application&lt;br /&gt;
:* remote debugging of your Java application&lt;br /&gt;
:* natively-compiling C/C++ code on your Gumstix&lt;br /&gt;
:* remote debugging C/C++ using the GDB server interface&lt;br /&gt;
&lt;br /&gt;
We will also explain how to set up a cross-compilation toolchain so you can develop C/C++ applications on your development computer and upload them to your Gumstix.&lt;br /&gt;
&lt;br /&gt;
Remember, Gumstix COMs are fully-fledged, albeit tiny, Linux systems so there are many tools we don't cover here.  For example, [http://wiki.openembedded.net/index.php/OpenEmbedded_Tools_for_Eclipse_(OTE) this document] explains how to use the powerful OpenEmbedded build system within Eclipse.&lt;br /&gt;
&lt;br /&gt;
Required Tools:&lt;br /&gt;
:* any Windows, Apple or Linux computer with a USB port&lt;br /&gt;
:* recent version of the Java Runtime Environment (available [http://java.sun.com/javase/downloads/index.jsp here])&lt;br /&gt;
:* a Gumstix COM running [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Downloading-pre-built-images/111.html up-to-date software]&lt;br /&gt;
:* any expansion board of the Gumstix Overo series, such as Chestnut or Tobi, that has both a USB console port and a 10/100 &lt;br /&gt;
:* Ethernet jack&lt;br /&gt;
:* a 5V power supply&lt;br /&gt;
:* an ethernet cable and internet connection&lt;br /&gt;
:* a mini-A to Standard-A USB cable&lt;br /&gt;
:* a [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Creating-a-bootable-microSD-card/111.html bootable microSD card] (only needed for native C/C++ compilation)&lt;br /&gt;
&lt;br /&gt;
Key Idea:&lt;br /&gt;
[[File:GumstixEclipse1.jpg|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Download Eclipse==&lt;br /&gt;
[http://www.eclipse.org/downloads/ Download] the Eclipse IDE for Java Developers for your Operating System: www.eclipse.org&lt;br /&gt;
&lt;br /&gt;
[[Image: GumstixEclipse2.jpg | thumb | left]]&lt;br /&gt;
&lt;br /&gt;
:* it is ''not'' necessary to install the Eclipse software; just double-click on the application once it has finished downloading&lt;br /&gt;
:* when prompted, choose a workspace folder in which you want to store your projects and your configuration information&lt;br /&gt;
:* then click through to the Eclipse workbench itself&lt;br /&gt;
&lt;br /&gt;
==Install Plugins==&lt;br /&gt;
For developers, a great variety of additional features can be added to Eclipse from various repositories of plug-ins known as ''Update Sites''.&lt;br /&gt;
To install a new plugin in Eclipse, first select the ''Update Site''.&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* select the Update Site for your version of Eclipse from the &amp;quot;Work with&amp;quot;dropdown menu&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse3.jpg]]&lt;br /&gt;
&lt;br /&gt;
:Note: If you are not sure which version of Eclipse you have, you can check by reopening Eclipse, it will be displayed on the loading screen.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If the update site is not available, you can add it by clicking the 'Add...' button on the right. For the Galileo release, you can use the URL http://dowload.eclipse.org/releases/galileo&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
As we are working with a remote system, we'll install the Remote System Explorer plugin.&lt;br /&gt;
:* search for the ''Remote System Explorer End-User Runtime'' plugin&lt;br /&gt;
:* select it for installation&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse4.jpg]]&lt;br /&gt;
&lt;br /&gt;
Still in Eclipse,&lt;br /&gt;
:* select &amp;quot;Next&amp;quot;.... twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
Once Eclipse has restarted, let's add two other useful plugins that allow connection to the console port of our Gumstix without needing a terminal emulator program such as kermit or TeraTerm.&lt;br /&gt;
From within Eclipse,&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software'''&lt;br /&gt;
:* search on &amp;quot;Target&amp;quot; to find the ''Target Manager Terminal''&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse5.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* select the ''Target Manager Terminal''&lt;br /&gt;
:* click &amp;quot;Next&amp;quot;&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
We'll also need to add a new update site by doing these steps in Eclipse:&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* click the &amp;quot;Add...&amp;quot; button&lt;br /&gt;
:* type ''http://rxtx.qbang.org/eclipse'' into the ''Location'' field and create a name&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse6.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* Click the &amp;quot;OK&amp;quot; button&lt;br /&gt;
Go into the sub-directory as shown below to select the ''RXTX End-User Runtime'' plugin that this site provides.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse7.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* click &amp;quot;Next&amp;quot; twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* click &amp;quot;OK&amp;quot; at the security warning window&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose the &amp;quot;Yes&amp;quot; button to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
==Connect Your Gumstix==&lt;br /&gt;
Now it is time to connect your Gumstix---let's get started by establishing a console connection.&lt;br /&gt;
:* mount your Gumstix COM down on to your expansion board&lt;br /&gt;
:* plug the mini-A USB plug into the port marked CONSOLE and end of the cable into a standard USB port on your computer&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Your computer should detect your Gumstix system when you first connect the USB cable, even though the power is not yet turned on. On Macintosh and Windows systems, a pop-up window should appear instructing you to download a new driver (do so) or notifying you that a USBserial device has been detected. If not, you can download drivers from [http://www.ftdichip.com/FTDrivers.htm this site]. Choose the &amp;quot;VCP&amp;quot; driver.&lt;br /&gt;
Once you have downloaded this driver, make sure to unplug and then replug the USB cable running from your computer to your Gumstix expansion board so the Gumstix will be recognized by your computer.&lt;br /&gt;
----&lt;br /&gt;
:* connect your Gumstix to the internet using an ethernet cable&lt;br /&gt;
    NOTE: You still have NOT plugged the power cable in to the &lt;br /&gt;
    Gumstix expansion board! This diagram shows the locations&lt;br /&gt;
    of the USB 'CONSOLE' port and the 'POWER' input port on a &lt;br /&gt;
    Summit board on which an Overo COM has been mounted.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse8.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* if you are booting from a microSD card, insert this card now until you hear it click in place.&lt;br /&gt;
Before applying power to the board, let's open up a connection to the console port.&lt;br /&gt;
In Eclipse,&lt;br /&gt;
:* navigate to '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;Terminal-&amp;gt;Terminal'''&lt;br /&gt;
:* click on the 'N' connection icon in the window that appears&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse9.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* make the connection using the following settings:&lt;br /&gt;
    Connection Type: Serial&lt;br /&gt;
    Port: &amp;lt;port to which your Gumstix is connected&amp;gt;&lt;br /&gt;
    Baud Rate: 115200&lt;br /&gt;
    Data Bits: 8&lt;br /&gt;
    Stop Bits: 1&lt;br /&gt;
    Parity: none&lt;br /&gt;
    Flow Control: none&lt;br /&gt;
    Timeout: 5&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
The port to which your Gumstix is connected will have a different name depending on your Host operating system.&lt;br /&gt;
:* On Windows, it should be ''USB-COM''&lt;br /&gt;
:* On Macintosh, it should be ''/dev/tty.usbserial-xxxxxxxx'' where ''xxxxxxxx'' is an arbitrary string of characters&lt;br /&gt;
:* On Linux, it should be ''/dev/ttyUSBx'' where ''x'' is a number.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse10.jpg]]&lt;br /&gt;
&lt;br /&gt;
*If this does not work, you can also get Console access to your Gumstix through a Terminal window. To do this on a Macintosh Operating System go [http://www.gumstix.net/wiki/index.php?title=Gaining_Console_Connection_via_Terminal here].For a Windows Operating System use the Command Prompt. The device will have the same name (USB-COM, /dev/cu..., /dev/tty.usb...).&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If you having a hard time find the device, you can search for it by doing a &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l /dev/tty.* (for Mac and Linux) &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l USB* (for Windows)&lt;br /&gt;
----&lt;br /&gt;
*Once you have found the device name, you can gain Console access with the screen command. If, for example, the device is /dev/tty.usb, issue the command:&lt;br /&gt;
 screen /dev/tty.usb 115200&lt;br /&gt;
*The 115200 on the end is important, it tells your computer the Baud Rate. If you do not enter 115200, you will not be able to read what the Remote System is outputting. Once you have issued this command, you will have Console access to your Overo via Terminal.&lt;br /&gt;
&lt;br /&gt;
*Now, it's time to apply power to the Gumstix expansion board so plug the 5V wall adapter into the power input jack on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
You should see text appear in this window; for now, just let the Gumstix boot. When prompted, you can log in to the root account. The default credentials are:&lt;br /&gt;
&lt;br /&gt;
'''Overo'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: &amp;lt;leave blank&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VerdexPro'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: gumstix&lt;br /&gt;
&lt;br /&gt;
==Write 'Hello, World' à la Python==&lt;br /&gt;
&lt;br /&gt;
You are going to write a basic Python program for the Gumstix directly on the Gumstix; this is known as native development. Also, Python is an interpreted language which means you can run your programs directly without any compilation.&lt;br /&gt;
&lt;br /&gt;
Once you have logged into your Gumstix, do these steps in the terminal window within Eclipse:&lt;br /&gt;
:* open an editor on the Gumstix by typing: 'nano hello.py'&lt;br /&gt;
:* type out this simple Python program: ''print &amp;quot;Hello, Gumstix!&amp;quot;''&lt;br /&gt;
:* press Ctrl+O, &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* then press Ctrl+X to save and exit.&lt;br /&gt;
:* run your program by typing: ''python hello.py''&lt;br /&gt;
:* check that you see the words &amp;quot;Hello, Gumstix!&amp;quot; appear&lt;br /&gt;
&lt;br /&gt;
If you see the words &amp;quot;Hello Gumstix&amp;quot;, then you have just written your first program on a Gumstix Overo computer.&lt;br /&gt;
&lt;br /&gt;
==Create a Web Site==&lt;br /&gt;
Each Gumstix comes with a built-in package manager called opkg. A package manager is a useful tool for installing software; you can install everything from media players to GPS mapping tools to the Firefox web browser. In this example, you'll use opkg tool to install a new application for your Gumstix: the Apache web server.&lt;br /&gt;
&lt;br /&gt;
To make your own Gumstix web site, type the following in the terminal window:&lt;br /&gt;
    opkg update 			&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install apache2		&amp;lt;Enter&amp;gt;&lt;br /&gt;
Before you start using Apache, which is now running, you'll need to find the IP address (internet address) of your Gumstix COM. To do this, type the following command into the terminal window:&lt;br /&gt;
    ifconfig | grep 'inet addr' 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
You should see something like this appear on your screen.&lt;br /&gt;
    inet addr: 10.0.1.73 Bcast: 192.168.0.255 Mask: 255.255.255.0&lt;br /&gt;
The IP address of your Gumstix is the first address shown: ''10.0.1.73'' in this case.&lt;br /&gt;
Now,&lt;br /&gt;
:* open up a web browser on your host computer&lt;br /&gt;
:* type that IP address of your Gumstix into the address bar&lt;br /&gt;
You should see something like this which is the default web site for Apache running on your Gumstix.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse11.jpg]]&lt;br /&gt;
&lt;br /&gt;
To make your web site say something more interesting, do the follow in your terminal window:&lt;br /&gt;
:* type: ''nano /usr/share/apache2/htdocs/index.html''&lt;br /&gt;
:* replace the words at the top of the screen &amp;quot;It Works&amp;quot; with the words &amp;quot;Gumstix Rocks!&amp;quot;&lt;br /&gt;
:* press 'Ctrl+O' &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* press 'Ctrl+X' to save and exit&lt;br /&gt;
:* refresh your web browser&lt;br /&gt;
&lt;br /&gt;
==Write a Java Application==&lt;br /&gt;
So far, you haven't actually used Eclipse other than as a console interface for your Gumstix. It is time to harness the power of Eclipse to write a small graphical Java application.&lt;br /&gt;
In Eclipse.&lt;br /&gt;
:* Navigate to '''File-&amp;gt; New-&amp;gt; Java Project''',&lt;br /&gt;
:* Name the project ''gumstix-java''&lt;br /&gt;
:* Select &amp;quot;Finish&amp;quot;&lt;br /&gt;
Once the project is created,&lt;br /&gt;
:* Select '''File-&amp;gt;New-&amp;gt;Class'''&lt;br /&gt;
:* Name your class ''Hello''&lt;br /&gt;
:* click &amp;quot;FINISH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add the following code to your class:&lt;br /&gt;
&lt;br /&gt;
    import javax.swing.JFrame;&lt;br /&gt;
    import javax.swing.JLabel;&lt;br /&gt;
    public class Hello {&lt;br /&gt;
    	public static void main(String [] args) {&lt;br /&gt;
    		JFrame frame = new JFrame(&amp;quot;hello&amp;quot;);&lt;br /&gt;
    		final JLabel label = new JLabel(&amp;quot;hello from Gumstix&amp;quot;);&lt;br /&gt;
    		frame.getContentPane().add(label);&lt;br /&gt;
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
    		frame.pack();&lt;br /&gt;
    		frame.setVisible(true);&lt;br /&gt;
    	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
You should get something that looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse12.jpg]]&lt;br /&gt;
&lt;br /&gt;
Press the green run button to test drive our application on our host machine.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Eclipse has many auto-completion features. Simply typing /:*&amp;lt;Enter&amp;gt; before a class creates a standard documentation block. Likewise, pressing &amp;lt;Ctrl&amp;gt;+&amp;lt;Space&amp;gt; provides context specific auto-completion options. Many other hints for speedy development are explained in the tutorials [http://www.eclipse.org/resources/?category=Getting%20Started here].&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Upload Code==&lt;br /&gt;
In Step 5 we discovered the IP address of our Gumstix. With this, we can connect to our Gumstix using the SSH protocol which allows us to rapidly transfer files. For this step, navigate to '''Window-&amp;gt;Open Perspective-&amp;gt;Other-&amp;gt;Remote System Explorer''' and click on the connection icon in the ''Remote Systems'' panel on the left. Select ''SSH without shells'' as the connection type and press Next. Put the internet address you found in Step 5 into the field marked ''Host Name'' and hit finish. To test that everything is working correctly, right-click on the terminal item list under your new connection and select ''Launch Terminal''. A console interface exactly like the USB console interface we set up in Step 3 should pop up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A 'Perspective' is an arrangement of windows and widgets, that is a specific view of the Eclipse workspace, designed for a particular task. If you wish to focus on any particular widget, double click the tab in Eclipse; return to the previous view by double-clicking again.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By installing the VNC viewer plugin, we can get a graphical interface to our Gumstix system. Do this by adding the ''Tools for mobile linux runtime'' plugin ('''Help-&amp;gt;Install New Software''') from the main update site. To use, select the VNC viewer widget from '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;VNC Category-&amp;gt;VNC''' and click on the ''New Connection'' icon in the VNC Viewer panel. Again, the ''Host'' is the internet address of your Gumstix board.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse13.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to upload our java code before we can run it. Switch back to the Java Perspective ('''Window-&amp;gt;Open Perspective-&amp;gt;Java''') and right-click on our Java file and selecting Export. Choose the option to export file to a remote file system and choose to upload your ''Hello.class'' file.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse14.jpg]]&lt;br /&gt;
&lt;br /&gt;
You will need to ''Browse'' to find your Gumstix board; you should upload this code to your home directory on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
==Debug a Java Application==&lt;br /&gt;
We can debug our java application remotely from Eclipse. To do this, we need a Java Virtual Machine capable of doing debugging. This time, the package we need isn't available in our package sources however we can fetch the package directly from a web site and install it using the same opkg package management tool.&lt;br /&gt;
    wget http://bugcommunity.com/downloads/files/phonemeadvanced- personal-debug_mr2-r1_armv6.ipk 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install -force-depends phoneme-advanced-personaldebug_mr2-r1_armv6.ipk &amp;lt;Enter&amp;gt;&lt;br /&gt;
Let's also update our Java libraries so we have access to the standard graphical libraries.&lt;br /&gt;
    opkg install classpath-gtk	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Next, let's start our Java code in debugging mode on the Overo:&lt;br /&gt;
    java-cdc -Xdebug -Xrunjwdp:transport=dHt_socket,server=y,suspend=y,address=1234 Hello	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Finally, let's connect to our debugging session by navigating in Eclipse to '''Run-&amp;gt;Debug Configurations''' and double-clicking on Remote Java Application to create a new configuration. Fill in the form as shown below using the internet address found in the previous step.&lt;br /&gt;
&lt;br /&gt;
==Install a native C/C++ SDK==&lt;br /&gt;
When we discussed Python and Java we noted that both are interpreted languages--- neither needs to be compiled. C and C++ code requires compilation which can be done natively---on the Gumstix itself---or on a development machine using a cross-compiler. To do native compilation, you need to install a compiler as well as any required libraries. You'll need to be booting from a microSD card as this installation takes approximately 75MB of space.&lt;br /&gt;
    $ echo 'src/gz angstrom-base http://www.angstromdistribution.org/feeds/unstable/ipk/glibc/armv7a/base'  &amp;gt; /etc/opkg/angstrom-base.conf&lt;br /&gt;
    $ opkg update&lt;br /&gt;
    $ opkg install task-native-sdk&lt;br /&gt;
Firstly, we are adding a new package repository to our package manager and updating our list of available packages before actually installing the complete package needed to do native development.&lt;br /&gt;
&lt;br /&gt;
Let's create either of the following files in Eclipse, upload the code and then compile on the Gumstix using our newly installed compiler.&lt;br /&gt;
&lt;br /&gt;
===C++: HelloWorld.cpp===&lt;br /&gt;
    #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
    using namespace std;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	cout &amp;lt;&amp;lt; &amp;quot;Gumstix runs on C++&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.cpp&lt;br /&gt;
    g++ -o hello hello.cpp	&amp;lt;enter&amp;gt;&lt;br /&gt;
    Gumstix runs on C++   	&amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===C: HelloWorld.c===&lt;br /&gt;
    #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	printf(&amp;quot;Gumstix runs on C\n&amp;quot;);&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.c&lt;br /&gt;
    gcc -o hello hello.c&lt;br /&gt;
    Gumstix runs on C&lt;br /&gt;
&lt;br /&gt;
&amp;lt;TODO: More exciting examples using on-board LEDs.&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using GDB as a remote debugger in C/C++==&lt;br /&gt;
These instructions will teach you how to download, install, and use the GDB debugger remotely on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;NOTE:	&lt;br /&gt;
remote system - a device that is being operated remotely (via SSH, USB Serial, etc). This means that it is a device that you are operating from a different system &lt;br /&gt;
(ie: if you are accessing the Overo COM via connection with your PC, then the Overo COM is a remote system).&lt;br /&gt;
For the purpose of this guide, the Overo COM will be the remote system.&lt;br /&gt;
&lt;br /&gt;
local host - the device that is being used to work on (ie: If you are working on your PC, that is the local host. If you then connect to another computer via VNC, &lt;br /&gt;
that is a remote system, and you laptop is still the localhost).&lt;br /&gt;
For the purpose of this guide, your Personal Computer will be the local host.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before starting, it is important to note there are many different ways to run a remote debugger. The most fundamental choice when debugging remotely is whether you want to:&lt;br /&gt;
:*Run the debugger on the remote system or&lt;br /&gt;
:*Run the debugger on the local host with a cross debugger on the remote system&lt;br /&gt;
&lt;br /&gt;
This guide will teach you how to download, install, and run the debugger on the remote system (choice A). If you wish to learn more about the cross debugger option, use Google. Also the wikipedia article on cross compilers (which operate in a very similar fashion) is very good, albeit a bit complicated. None of this is necessary in understanding the contents of this guide. &lt;br /&gt;
&lt;br /&gt;
For the purposes of this guide, we will be using the GDB: the GNU project debugger. As stated on their website:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it &lt;br /&gt;
crashed.&lt;br /&gt;
&lt;br /&gt;
GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:&lt;br /&gt;
- Start your program, specifying anything that might affect its behavior.&lt;br /&gt;
- Make your program stop on specified conditions.&lt;br /&gt;
- Examine what has happened, when your program has stopped.&lt;br /&gt;
- Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the reasons for using a debugger instead of trying to debug with the ‘brute force’ method of adding print statements throughout the entire program are enumerable, there are a few that stand out:&lt;br /&gt;
# The ability to ‘step’ through a program&lt;br /&gt;
#* The GDB debugger allows you to ‘step’ through a program. This means that instead of just executing the program and then leaving you with a final error message, it will execute one line at a time until the program crashes. This allows the user to see exactly where, and why, the program crashed. &lt;br /&gt;
# The ability to set breakpoints&lt;br /&gt;
#* The GDB debugger allows you to set breakpoints in the program. These are points where the CPU will stop executing the code and allow the user to decide whether to continue. This allows the user to explore what is ‘going on’ at certain points in the execution, something that otherwise is not possible. &lt;br /&gt;
# The ability to look at the Backtrace&lt;br /&gt;
#* This will show you where, and exactly why, your program crashed. Although SEGFAULT isn’t very useful, the backtrace will tell you what caused the SEGFAULT. Everything from what line, what variable, and even the address that variable was at.&lt;br /&gt;
&lt;br /&gt;
===Installing the GDB===&lt;br /&gt;
Once the Overo COM has been connected to the local host, you should have access to the following command line:&lt;br /&gt;
&amp;lt;pre&amp;gt;root@overo:~#	&amp;lt;/pre&amp;gt;&lt;br /&gt;
Although you are working on your local host, this command line is for the remote system. It is the same as if you opened up Terminal (for Mac, Linux) or XTerm (for Windows). You now have access and control of the remote system.&lt;br /&gt;
&lt;br /&gt;
Now there are some packages that must be downloaded and installed onto the Overo so that it can run the GDB environment. To do this issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;opkg update	 	&amp;lt;enter&amp;gt;&lt;br /&gt;
opkg install gdb 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This should spew out a bunch of text such as:&lt;br /&gt;
&amp;lt;pre&amp;gt;Downloading http://www.angstrom...&amp;lt;/pre&amp;gt;&lt;br /&gt;
Just let it run and once its done, you’ll have the GNU GDB debugger installed on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
===Creating a C/C++ Program to Debug===&lt;br /&gt;
Now, your Overo COM has a debugger installed and ready to use. However, this does not mean you are ready to go. There are two more things required before it is possible to use a GDB debugger.&lt;br /&gt;
:* A C/C++ program&lt;br /&gt;
:* A SDK to run the program on&lt;br /&gt;
To see how to install a SDK and write/run a simple program in C/C++, see [[#Install a native C/C++ SDK]]. &lt;br /&gt;
&lt;br /&gt;
Once you have a program ready, you first must create an executable file. Lets use for example the C++ program HelloWorld.cpp. To create the executable file HelloWorld, issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;g++ -o HelloWorld HelloWorld.cpp 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now, to run the program:&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
To do the same thing with a C program (HelloWorld.c), issue the command&lt;br /&gt;
&amp;lt;pre&amp;gt;gcc -o HelloWorld HelloWorld.c		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What this command does is uses the GNU compiler (either g++ or gcc) and creates an executable object (HelloWorld) out of the C or C++ program file (either HelloWorld.cpp or HelloWorld.c). You may name the executable whatever you like, but it is considered best practice to name it the same thing as the program file.&lt;br /&gt;
&lt;br /&gt;
===Debugging the Program===&lt;br /&gt;
Now that you have GDB installed and a C/C++ program ready to go, its time to debug. To open to GDB environment, run the following command&lt;br /&gt;
&amp;lt;pre&amp;gt;gdb						&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Some text should spit out, and the following command line should appear&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that the debugger is running, it is time to tell the debugger what program we want to debug. To do this, first we need to declare our HelloWorld file as an executable file. For this run the following command	&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) exec-file HelloWorld		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that we have an executable file ready to be debugged, its time to run the program&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) run HelloWorld			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
The debugger will now run your program. If the program has no syntax or logic errors, the program should run and end with the line:&lt;br /&gt;
Program exited normally.&lt;br /&gt;
If there are errors, or the program crashed, it is possible to extract the exact details of that crash  by issuing the back trace command.&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) bt			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once you are done you can quit by issuing the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) quit			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A complete list of commands in GDB:&lt;br /&gt;
www.yolinux.com/TUTORIALS/GDB-Commands.html&lt;br /&gt;
&lt;br /&gt;
====GDB Debugger Tutorial====&lt;br /&gt;
For a complete GDB Debugger tutorial (very good tutorial, comes with sample code they walk you through and extra errors for you to debug yourself!):&lt;br /&gt;
http://www.cs.cmu.edu/~gilpin/tutorial/&lt;br /&gt;
&lt;br /&gt;
Now you have a debugger up and running! Play around with it by putting errors into your program on purpose to see the powers of having a remote debugger!&lt;br /&gt;
&lt;br /&gt;
==Use a C/C++ cross-compiler==&lt;br /&gt;
In order to do C/C++ development on our host machine, we need to add in a plugin to Eclipse. Also, we need to download an appropriate cross-compilation toolchain. For now, I recommend the lovely instructions from&lt;br /&gt;
&lt;br /&gt;
http://www.designarm.com/quickstart-guide/linux-software/eclipse.html &amp;amp;&lt;br /&gt;
&lt;br /&gt;
http://www.bugcommunity.com/wiki/index.php/BUG_Kernel_Development_with_Eclipse&lt;br /&gt;
&lt;br /&gt;
===Further Reading===&lt;br /&gt;
:* Tutorials built into Eclipse&lt;br /&gt;
:* Bitbake commander&lt;br /&gt;
:* OpenEmebedded|Poky docs + Bitbake docs&lt;br /&gt;
:* Eclipse Plugin Tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:How_to_-_eclipse]]&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:LoginSuccess.png&amp;diff=4372</id>
		<title>File:LoginSuccess.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:LoginSuccess.png&amp;diff=4372"/>
				<updated>2010-07-28T22:02:27Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:TerminalWindow.png&amp;diff=4369</id>
		<title>File:TerminalWindow.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:TerminalWindow.png&amp;diff=4369"/>
				<updated>2010-07-28T21:33:24Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:TerminalWindow.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:TerminalWindow.png&amp;diff=4368</id>
		<title>File:TerminalWindow.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:TerminalWindow.png&amp;diff=4368"/>
				<updated>2010-07-28T21:31:50Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:TerminalWindow.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:Spotlight.png&amp;diff=4367</id>
		<title>File:Spotlight.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:Spotlight.png&amp;diff=4367"/>
				<updated>2010-07-28T21:31:00Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:Spotlight.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spotlight&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:Spotlight.png&amp;diff=4366</id>
		<title>File:Spotlight.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:Spotlight.png&amp;diff=4366"/>
				<updated>2010-07-28T21:30:58Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:Spotlight.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spotlight&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:Terminal.png&amp;diff=4365</id>
		<title>File:Terminal.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:Terminal.png&amp;diff=4365"/>
				<updated>2010-07-28T21:30:35Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:Terminal.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Terminal&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:Terminal.png&amp;diff=4364</id>
		<title>File:Terminal.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:Terminal.png&amp;diff=4364"/>
				<updated>2010-07-28T21:29:13Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:Terminal.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Terminal&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:TerminalWindow.png&amp;diff=4363</id>
		<title>File:TerminalWindow.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:TerminalWindow.png&amp;diff=4363"/>
				<updated>2010-07-28T21:28:20Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:TerminalWindow.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:TerminalWindow.png&amp;diff=4362</id>
		<title>File:TerminalWindow.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:TerminalWindow.png&amp;diff=4362"/>
				<updated>2010-07-28T21:28:12Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:Spotlight.png&amp;diff=4357</id>
		<title>File:Spotlight.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:Spotlight.png&amp;diff=4357"/>
				<updated>2010-07-28T19:39:14Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: uploaded a new version of &amp;quot;File:Spotlight.png&amp;quot;:&amp;amp;#32;Spotlight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spotlight&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:Terminal.png&amp;diff=4356</id>
		<title>File:Terminal.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:Terminal.png&amp;diff=4356"/>
				<updated>2010-07-28T19:34:34Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: Terminal&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Terminal&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=File:Spotlight.png&amp;diff=4355</id>
		<title>File:Spotlight.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=File:Spotlight.png&amp;diff=4355"/>
				<updated>2010-07-28T19:34:04Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: Spotlight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spotlight&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4353</id>
		<title>Eclipse on Gumstix for new users</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4353"/>
				<updated>2010-07-28T17:08:46Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide provides step-by-step instructions for using the Eclipse Integrated Development Environment (IDE) to develop applications for the Gumstix COMs.&lt;br /&gt;
&lt;br /&gt;
We'll walk through these tasks:&lt;br /&gt;
:* setting up Eclipse&lt;br /&gt;
:* connection to your Gumstix system&lt;br /&gt;
:* creating a simple &amp;quot;Hello, World!&amp;quot; Python program&lt;br /&gt;
:* running a web server&lt;br /&gt;
:* installing new packages on your Gumstix&lt;br /&gt;
:* creating a small graphical Java application&lt;br /&gt;
:* remote debugging of your Java application&lt;br /&gt;
:* natively-compiling C/C++ code on your Gumstix&lt;br /&gt;
:* remote debugging C/C++ using the GDB server interface&lt;br /&gt;
&lt;br /&gt;
We will also explain how to set up a cross-compilation toolchain so you can develop C/C++ applications on your development computer and upload them to your Gumstix.&lt;br /&gt;
&lt;br /&gt;
Remember, Gumstix COMs are fully-fledged, albeit tiny, Linux systems so there are many tools we don't cover here.  For example, [http://wiki.openembedded.net/index.php/OpenEmbedded_Tools_for_Eclipse_(OTE) this document] explains how to use the powerful OpenEmbedded build system within Eclipse.&lt;br /&gt;
&lt;br /&gt;
Required Tools:&lt;br /&gt;
:* any Windows, Apple or Linux computer with a USB port&lt;br /&gt;
:* recent version of the Java Runtime Environment (available [http://java.sun.com/javase/downloads/index.jsp here])&lt;br /&gt;
:* a Gumstix COM running [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Downloading-pre-built-images/111.html up-to-date software]&lt;br /&gt;
:* any expansion board of the Gumstix Overo series, such as Chestnut or Tobi, that has both a USB console port and a 10/100 &lt;br /&gt;
:* Ethernet jack&lt;br /&gt;
:* a 5V power supply&lt;br /&gt;
:* an ethernet cable and internet connection&lt;br /&gt;
:* a mini-A to Standard-A USB cable&lt;br /&gt;
:* a [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Creating-a-bootable-microSD-card/111.html bootable microSD card] (only needed for native C/C++ compilation)&lt;br /&gt;
&lt;br /&gt;
Key Idea:&lt;br /&gt;
[[File:GumstixEclipse1.jpg|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Download Eclipse==&lt;br /&gt;
[http://www.eclipse.org/downloads/ Download] the Eclipse IDE for Java Developers for your Operating System: www.eclipse.org&lt;br /&gt;
&lt;br /&gt;
[[Image: GumstixEclipse2.jpg | thumb | left]]&lt;br /&gt;
&lt;br /&gt;
:* it is ''not'' necessary to install the Eclipse software; just double-click on the application once it has finished downloading&lt;br /&gt;
:* when prompted, choose a workspace folder in which you want to store your projects and your configuration information&lt;br /&gt;
:* then click through to the Eclipse workbench itself&lt;br /&gt;
&lt;br /&gt;
==Install Plugins==&lt;br /&gt;
For developers, a great variety of additional features can be added to Eclipse from various repositories of plug-ins known as ''Update Sites''.&lt;br /&gt;
To install a new plugin in Eclipse, first select the ''Update Site''.&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* select the Update Site for your version of Eclipse from the &amp;quot;Work with&amp;quot;dropdown menu&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse3.jpg]]&lt;br /&gt;
&lt;br /&gt;
:Note: If you are not sure which version of Eclipse you have, you can check by reopening Eclipse, it will be displayed on the loading screen.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If the update site is not available, you can add it by clicking the 'Add...' button on the right. For the Galileo release, you can use the URL http://dowload.eclipse.org/releases/galileo&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
As we are working with a remote system, we'll install the Remote System Explorer plugin.&lt;br /&gt;
:* search for the ''Remote System Explorer End-User Runtime'' plugin&lt;br /&gt;
:* select it for installation&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse4.jpg]]&lt;br /&gt;
&lt;br /&gt;
Still in Eclipse,&lt;br /&gt;
:* select &amp;quot;Next&amp;quot;.... twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
Once Eclipse has restarted, let's add two other useful plugins that allow connection to the console port of our Gumstix without needing a terminal emulator program such as kermit or TeraTerm.&lt;br /&gt;
From within Eclipse,&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software'''&lt;br /&gt;
:* search on &amp;quot;Target&amp;quot; to find the ''Target Manager Terminal''&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse5.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* select the ''Target Manager Terminal''&lt;br /&gt;
:* click &amp;quot;Next&amp;quot;&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
We'll also need to add a new update site by doing these steps in Eclipse:&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* click the &amp;quot;Add...&amp;quot; button&lt;br /&gt;
:* type ''http://rxtx.qbang.org/eclipse'' into the ''Location'' field and create a name&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse6.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* Click the &amp;quot;OK&amp;quot; button&lt;br /&gt;
Go into the sub-directory as shown below to select the ''RXTX End-User Runtime'' plugin that this site provides.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse7.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* click &amp;quot;Next&amp;quot; twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* click &amp;quot;OK&amp;quot; at the security warning window&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose the &amp;quot;Yes&amp;quot; button to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
==Connect Your Gumstix==&lt;br /&gt;
Now it is time to connect your Gumstix---let's get started by establishing a console connection.&lt;br /&gt;
:* mount your Gumstix COM down on to your expansion board&lt;br /&gt;
:* plug the mini-A USB plug into the port marked CONSOLE and end of the cable into a standard USB port on your computer&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Your computer should detect your Gumstix system when you first connect the USB cable, even though the power is not yet turned on. On Macintosh and Windows systems, a pop-up window should appear instructing you to download a new driver (do so) or notifying you that a USBserial device has been detected. If not, you can download drivers from [http://www.ftdichip.com/FTDrivers.htm this site]. Choose the &amp;quot;VCP&amp;quot; driver.&lt;br /&gt;
Once you have downloaded this driver, make sure to unplug and then replug the USB cable running from your computer to your Gumstix expansion board so the Gumstix will be recognized by your computer.&lt;br /&gt;
----&lt;br /&gt;
:* connect your Gumstix to the internet using an ethernet cable&lt;br /&gt;
    NOTE: You still have NOT plugged the power cable in to the &lt;br /&gt;
    Gumstix expansion board! This diagram shows the locations&lt;br /&gt;
    of the USB 'CONSOLE' port and the 'POWER' input port on a &lt;br /&gt;
    Summit board on which an Overo COM has been mounted.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse8.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* if you are booting from a microSD card, insert this card now until you hear it click in place.&lt;br /&gt;
Before applying power to the board, let's open up a connection to the console port.&lt;br /&gt;
In Eclipse,&lt;br /&gt;
:* navigate to '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;Terminal-&amp;gt;Terminal'''&lt;br /&gt;
:* click on the 'N' connection icon in the window that appears&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse9.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* make the connection using the following settings:&lt;br /&gt;
    Connection Type: Serial&lt;br /&gt;
    Port: &amp;lt;port to which your Gumstix is connected&amp;gt;&lt;br /&gt;
    Baud Rate: 115200&lt;br /&gt;
    Data Bits: 8&lt;br /&gt;
    Stop Bits: 1&lt;br /&gt;
    Parity: none&lt;br /&gt;
    Flow Control: none&lt;br /&gt;
    Timeout: 5&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
The port to which your Gumstix is connected will have a different name depending on your Host operating system.&lt;br /&gt;
:* On Windows, it should be ''USB-COM''&lt;br /&gt;
:* On Macintosh, it should be ''/dev/tty.usbserial-xxxxxxxx'' where ''xxxxxxxx'' is an arbitrary string of characters&lt;br /&gt;
:* On Linux, it should be ''/dev/ttyUSBx'' where ''x'' is a number.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse10.jpg]]&lt;br /&gt;
&lt;br /&gt;
*If this does not work, you can also get Console access to your Gumstix through a Terminal window. To do this, open up a Terminal window (Terminal for Mac users, XTerm or X11 for Windows users). The device will have the same name (USB-COM, /dev/cu..., /dev/tty.usb...).&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If you having a hard time find the device, you can search for it by doing a &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l /dev/tty.* (for Mac and Linux) &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l USB* (for Windows)&lt;br /&gt;
----&lt;br /&gt;
*Once you have found the device name, you can gain Console access with the screen command. If, for example, the device is /dev/tty.usb, issue the command:&lt;br /&gt;
 screen /dev/tty.usb 115200&lt;br /&gt;
*The 115200 on the end is important, it tells your computer the Baud Rate. If you do not enter 115200, you will not be able to read what the Remote System is outputting. Once you have issued this command, you will have Console access to your Overo via Terminal.&lt;br /&gt;
&lt;br /&gt;
*Now, it's time to apply power to the Gumstix expansion board so plug the 5V wall adapter into the power input jack on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
You should see text appear in this window; for now, just let the Gumstix boot. When prompted, you can log in to the root account. The default credentials are:&lt;br /&gt;
&lt;br /&gt;
'''Overo'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: &amp;lt;leave blank&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VerdexPro'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: gumstix&lt;br /&gt;
&lt;br /&gt;
==Write 'Hello, World' à la Python==&lt;br /&gt;
&lt;br /&gt;
You are going to write a basic Python program for the Gumstix directly on the Gumstix; this is known as native development. Also, Python is an interpreted language which means you can run your programs directly without any compilation.&lt;br /&gt;
&lt;br /&gt;
Once you have logged into your Gumstix, do these steps in the terminal window within Eclipse:&lt;br /&gt;
:* open an editor on the Gumstix by typing: 'nano hello.py'&lt;br /&gt;
:* type out this simple Python program: ''print &amp;quot;Hello, Gumstix!&amp;quot;''&lt;br /&gt;
:* press Ctrl+O, &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* then press Ctrl+X to save and exit.&lt;br /&gt;
:* run your program by typing: ''python hello.py''&lt;br /&gt;
:* check that you see the words &amp;quot;Hello, Gumstix!&amp;quot; appear&lt;br /&gt;
&lt;br /&gt;
If you see the words &amp;quot;Hello Gumstix&amp;quot;, then you have just written your first program on a Gumstix Overo computer.&lt;br /&gt;
&lt;br /&gt;
==Create a Web Site==&lt;br /&gt;
Each Gumstix comes with a built-in package manager called opkg. A package manager is a useful tool for installing software; you can install everything from media players to GPS mapping tools to the Firefox web browser. In this example, you'll use opkg tool to install a new application for your Gumstix: the Apache web server.&lt;br /&gt;
&lt;br /&gt;
To make your own Gumstix web site, type the following in the terminal window:&lt;br /&gt;
    opkg update 			&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install apache2		&amp;lt;Enter&amp;gt;&lt;br /&gt;
Before you start using Apache, which is now running, you'll need to find the IP address (internet address) of your Gumstix COM. To do this, type the following command into the terminal window:&lt;br /&gt;
    ifconfig | grep 'inet addr' 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
You should see something like this appear on your screen.&lt;br /&gt;
    inet addr: 10.0.1.73 Bcast: 192.168.0.255 Mask: 255.255.255.0&lt;br /&gt;
The IP address of your Gumstix is the first address shown: ''10.0.1.73'' in this case.&lt;br /&gt;
Now,&lt;br /&gt;
:* open up a web browser on your host computer&lt;br /&gt;
:* type that IP address of your Gumstix into the address bar&lt;br /&gt;
You should see something like this which is the default web site for Apache running on your Gumstix.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse11.jpg]]&lt;br /&gt;
&lt;br /&gt;
To make your web site say something more interesting, do the follow in your terminal window:&lt;br /&gt;
:* type: ''nano /usr/share/apache2/htdocs/index.html''&lt;br /&gt;
:* replace the words at the top of the screen &amp;quot;It Works&amp;quot; with the words &amp;quot;Gumstix Rocks!&amp;quot;&lt;br /&gt;
:* press 'Ctrl+O' &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* press 'Ctrl+X' to save and exit&lt;br /&gt;
:* refresh your web browser&lt;br /&gt;
&lt;br /&gt;
==Write a Java Application==&lt;br /&gt;
So far, you haven't actually used Eclipse other than as a console interface for your Gumstix. It is time to harness the power of Eclipse to write a small graphical Java application.&lt;br /&gt;
In Eclipse.&lt;br /&gt;
:* Navigate to '''File-&amp;gt; New-&amp;gt; Java Project''',&lt;br /&gt;
:* Name the project ''gumstix-java''&lt;br /&gt;
:* Select &amp;quot;Finish&amp;quot;&lt;br /&gt;
Once the project is created,&lt;br /&gt;
:* Select '''File-&amp;gt;New-&amp;gt;Class'''&lt;br /&gt;
:* Name your class ''Hello''&lt;br /&gt;
:* click &amp;quot;FINISH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add the following code to your class:&lt;br /&gt;
&lt;br /&gt;
    import javax.swing.JFrame;&lt;br /&gt;
    import javax.swing.JLabel;&lt;br /&gt;
    public class Hello {&lt;br /&gt;
    	public static void main(String [] args) {&lt;br /&gt;
    		JFrame frame = new JFrame(&amp;quot;hello&amp;quot;);&lt;br /&gt;
    		final JLabel label = new JLabel(&amp;quot;hello from Gumstix&amp;quot;);&lt;br /&gt;
    		frame.getContentPane().add(label);&lt;br /&gt;
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
    		frame.pack();&lt;br /&gt;
    		frame.setVisible(true);&lt;br /&gt;
    	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
You should get something that looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse12.jpg]]&lt;br /&gt;
&lt;br /&gt;
Press the green run button to test drive our application on our host machine.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Eclipse has many auto-completion features. Simply typing /:*&amp;lt;Enter&amp;gt; before a class creates a standard documentation block. Likewise, pressing &amp;lt;Ctrl&amp;gt;+&amp;lt;Space&amp;gt; provides context specific auto-completion options. Many other hints for speedy development are explained in the tutorials [http://www.eclipse.org/resources/?category=Getting%20Started here].&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Upload Code==&lt;br /&gt;
In Step 5 we discovered the IP address of our Gumstix. With this, we can connect to our Gumstix using the SSH protocol which allows us to rapidly transfer files. For this step, navigate to '''Window-&amp;gt;Open Perspective-&amp;gt;Other-&amp;gt;Remote System Explorer''' and click on the connection icon in the ''Remote Systems'' panel on the left. Select ''SSH without shells'' as the connection type and press Next. Put the internet address you found in Step 5 into the field marked ''Host Name'' and hit finish. To test that everything is working correctly, right-click on the terminal item list under your new connection and select ''Launch Terminal''. A console interface exactly like the USB console interface we set up in Step 3 should pop up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A 'Perspective' is an arrangement of windows and widgets, that is a specific view of the Eclipse workspace, designed for a particular task. If you wish to focus on any particular widget, double click the tab in Eclipse; return to the previous view by double-clicking again.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By installing the VNC viewer plugin, we can get a graphical interface to our Gumstix system. Do this by adding the ''Tools for mobile linux runtime'' plugin ('''Help-&amp;gt;Install New Software''') from the main update site. To use, select the VNC viewer widget from '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;VNC Category-&amp;gt;VNC''' and click on the ''New Connection'' icon in the VNC Viewer panel. Again, the ''Host'' is the internet address of your Gumstix board.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse13.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to upload our java code before we can run it. Switch back to the Java Perspective ('''Window-&amp;gt;Open Perspective-&amp;gt;Java''') and right-click on our Java file and selecting Export. Choose the option to export file to a remote file system and choose to upload your ''Hello.class'' file.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse14.jpg]]&lt;br /&gt;
&lt;br /&gt;
You will need to ''Browse'' to find your Gumstix board; you should upload this code to your home directory on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
==Debug a Java Application==&lt;br /&gt;
We can debug our java application remotely from Eclipse. To do this, we need a Java Virtual Machine capable of doing debugging. This time, the package we need isn't available in our package sources however we can fetch the package directly from a web site and install it using the same opkg package management tool.&lt;br /&gt;
    wget http://bugcommunity.com/downloads/files/phonemeadvanced- personal-debug_mr2-r1_armv6.ipk 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install -force-depends phoneme-advanced-personaldebug_mr2-r1_armv6.ipk &amp;lt;Enter&amp;gt;&lt;br /&gt;
Let's also update our Java libraries so we have access to the standard graphical libraries.&lt;br /&gt;
    opkg install classpath-gtk	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Next, let's start our Java code in debugging mode on the Overo:&lt;br /&gt;
    java-cdc -Xdebug -Xrunjwdp:transport=dHt_socket,server=y,suspend=y,address=1234 Hello	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Finally, let's connect to our debugging session by navigating in Eclipse to '''Run-&amp;gt;Debug Configurations''' and double-clicking on Remote Java Application to create a new configuration. Fill in the form as shown below using the internet address found in the previous step.&lt;br /&gt;
&lt;br /&gt;
==Install a native C/C++ SDK==&lt;br /&gt;
When we discussed Python and Java we noted that both are interpreted languages--- neither needs to be compiled. C and C++ code requires compilation which can be done natively---on the Gumstix itself---or on a development machine using a cross-compiler. To do native compilation, you need to install a compiler as well as any required libraries. You'll need to be booting from a microSD card as this installation takes approximately 75MB of space.&lt;br /&gt;
    $ echo 'src/gz angstrom-base http://www.angstromdistribution.org/feeds/unstable/ipk/glibc/armv7a/base'  &amp;gt; /etc/opkg/angstrom-base.conf&lt;br /&gt;
    $ opkg update&lt;br /&gt;
    $ opkg install task-native-sdk&lt;br /&gt;
Firstly, we are adding a new package repository to our package manager and updating our list of available packages before actually installing the complete package needed to do native development.&lt;br /&gt;
&lt;br /&gt;
Let's create either of the following files in Eclipse, upload the code and then compile on the Gumstix using our newly installed compiler.&lt;br /&gt;
&lt;br /&gt;
===C++: HelloWorld.cpp===&lt;br /&gt;
    #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
    using namespace std;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	cout &amp;lt;&amp;lt; &amp;quot;Gumstix runs on C++&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.cpp&lt;br /&gt;
    g++ -o hello hello.cpp	&amp;lt;enter&amp;gt;&lt;br /&gt;
    Gumstix runs on C++   	&amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===C: HelloWorld.c===&lt;br /&gt;
    #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	printf(&amp;quot;Gumstix runs on C\n&amp;quot;);&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.c&lt;br /&gt;
    gcc -o hello hello.c&lt;br /&gt;
    Gumstix runs on C&lt;br /&gt;
&lt;br /&gt;
&amp;lt;TODO: More exciting examples using on-board LEDs.&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using GDB as a remote debugger in C/C++==&lt;br /&gt;
These instructions will teach you how to download, install, and use the GDB debugger remotely on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;NOTE:	&lt;br /&gt;
remote system - a device that is being operated remotely (via SSH, USB Serial, etc). This means that it is a device that you are operating from a different system &lt;br /&gt;
(ie: if you are accessing the Overo COM via connection with your PC, then the Overo COM is a remote system).&lt;br /&gt;
For the purpose of this guide, the Overo COM will be the remote system.&lt;br /&gt;
&lt;br /&gt;
local host - the device that is being used to work on (ie: If you are working on your PC, that is the local host. If you then connect to another computer via VNC, &lt;br /&gt;
that is a remote system, and you laptop is still the localhost).&lt;br /&gt;
For the purpose of this guide, your Personal Computer will be the local host.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before starting, it is important to note there are many different ways to run a remote debugger. The most fundamental choice when debugging remotely is whether you want to:&lt;br /&gt;
:*Run the debugger on the remote system or&lt;br /&gt;
:*Run the debugger on the local host with a cross debugger on the remote system&lt;br /&gt;
&lt;br /&gt;
This guide will teach you how to download, install, and run the debugger on the remote system (choice A). If you wish to learn more about the cross debugger option, use Google. Also the wikipedia article on cross compilers (which operate in a very similar fashion) is very good, albeit a bit complicated. None of this is necessary in understanding the contents of this guide. &lt;br /&gt;
&lt;br /&gt;
For the purposes of this guide, we will be using the GDB: the GNU project debugger. As stated on their website:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it &lt;br /&gt;
crashed.&lt;br /&gt;
&lt;br /&gt;
GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:&lt;br /&gt;
- Start your program, specifying anything that might affect its behavior.&lt;br /&gt;
- Make your program stop on specified conditions.&lt;br /&gt;
- Examine what has happened, when your program has stopped.&lt;br /&gt;
- Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the reasons for using a debugger instead of trying to debug with the ‘brute force’ method of adding print statements throughout the entire program are enumerable, there are a few that stand out:&lt;br /&gt;
# The ability to ‘step’ through a program&lt;br /&gt;
#* The GDB debugger allows you to ‘step’ through a program. This means that instead of just executing the program and then leaving you with a final error message, it will execute one line at a time until the program crashes. This allows the user to see exactly where, and why, the program crashed. &lt;br /&gt;
# The ability to set breakpoints&lt;br /&gt;
#* The GDB debugger allows you to set breakpoints in the program. These are points where the CPU will stop executing the code and allow the user to decide whether to continue. This allows the user to explore what is ‘going on’ at certain points in the execution, something that otherwise is not possible. &lt;br /&gt;
# The ability to look at the Backtrace&lt;br /&gt;
#* This will show you where, and exactly why, your program crashed. Although SEGFAULT isn’t very useful, the backtrace will tell you what caused the SEGFAULT. Everything from what line, what variable, and even the address that variable was at.&lt;br /&gt;
&lt;br /&gt;
===Installing the GDB===&lt;br /&gt;
Once the Overo COM has been connected to the local host, you should have access to the following command line:&lt;br /&gt;
&amp;lt;pre&amp;gt;root@overo:~#	&amp;lt;/pre&amp;gt;&lt;br /&gt;
Although you are working on your local host, this command line is for the remote system. It is the same as if you opened up Terminal (for Mac, Linux) or XTerm (for Windows). You now have access and control of the remote system.&lt;br /&gt;
&lt;br /&gt;
Now there are some packages that must be downloaded and installed onto the Overo so that it can run the GDB environment. To do this issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;opkg update	 	&amp;lt;enter&amp;gt;&lt;br /&gt;
opkg install gdb 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This should spew out a bunch of text such as:&lt;br /&gt;
&amp;lt;pre&amp;gt;Downloading http://www.angstrom...&amp;lt;/pre&amp;gt;&lt;br /&gt;
Just let it run and once its done, you’ll have the GNU GDB debugger installed on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
===Creating a C/C++ Program to Debug===&lt;br /&gt;
Now, your Overo COM has a debugger installed and ready to use. However, this does not mean you are ready to go. There are two more things required before it is possible to use a GDB debugger.&lt;br /&gt;
:* A C/C++ program&lt;br /&gt;
:* A SDK to run the program on&lt;br /&gt;
To see how to install a SDK and write/run a simple program in C/C++, see [[#Install a native C/C++ SDK]]. &lt;br /&gt;
&lt;br /&gt;
Once you have a program ready, you first must create an executable file. Lets use for example the C++ program HelloWorld.cpp. To create the executable file HelloWorld, issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;g++ -o HelloWorld HelloWorld.cpp 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now, to run the program:&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
To do the same thing with a C program (HelloWorld.c), issue the command&lt;br /&gt;
&amp;lt;pre&amp;gt;gcc -o HelloWorld HelloWorld.c		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What this command does is uses the GNU compiler (either g++ or gcc) and creates an executable object (HelloWorld) out of the C or C++ program file (either HelloWorld.cpp or HelloWorld.c). You may name the executable whatever you like, but it is considered best practice to name it the same thing as the program file.&lt;br /&gt;
&lt;br /&gt;
===Debugging the Program===&lt;br /&gt;
Now that you have GDB installed and a C/C++ program ready to go, its time to debug. To open to GDB environment, run the following command&lt;br /&gt;
&amp;lt;pre&amp;gt;gdb						&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Some text should spit out, and the following command line should appear&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that the debugger is running, it is time to tell the debugger what program we want to debug. To do this, first we need to declare our HelloWorld file as an executable file. For this run the following command	&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) exec-file HelloWorld		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that we have an executable file ready to be debugged, its time to run the program&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) run HelloWorld			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
The debugger will now run your program. If the program has no syntax or logic errors, the program should run and end with the line:&lt;br /&gt;
Program exited normally.&lt;br /&gt;
If there are errors, or the program crashed, it is possible to extract the exact details of that crash  by issuing the back trace command.&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) bt			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once you are done you can quit by issuing the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) quit			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A complete list of commands in GDB:&lt;br /&gt;
www.yolinux.com/TUTORIALS/GDB-Commands.html&lt;br /&gt;
&lt;br /&gt;
====GDB Debugger Tutorial====&lt;br /&gt;
For a complete GDB Debugger tutorial (very good tutorial, comes with sample code they walk you through and extra errors for you to debug yourself!):&lt;br /&gt;
http://www.cs.cmu.edu/~gilpin/tutorial/&lt;br /&gt;
&lt;br /&gt;
Now you have a debugger up and running! Play around with it by putting errors into your program on purpose to see the powers of having a remote debugger!&lt;br /&gt;
&lt;br /&gt;
==Use a C/C++ cross-compiler==&lt;br /&gt;
In order to do C/C++ development on our host machine, we need to add in a plugin to Eclipse. Also, we need to download an appropriate cross-compilation toolchain. For now, I recommend the lovely instructions from&lt;br /&gt;
&lt;br /&gt;
http://www.designarm.com/quickstart-guide/linux-software/eclipse.html &amp;amp;&lt;br /&gt;
&lt;br /&gt;
http://www.bugcommunity.com/wiki/index.php/BUG_Kernel_Development_with_Eclipse&lt;br /&gt;
&lt;br /&gt;
===Further Reading===&lt;br /&gt;
:* Tutorials built into Eclipse&lt;br /&gt;
:* Bitbake commander&lt;br /&gt;
:* OpenEmebedded|Poky docs + Bitbake docs&lt;br /&gt;
:* Eclipse Plugin Tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:How_to_-_eclipse]]&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4352</id>
		<title>Eclipse on Gumstix for new users</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4352"/>
				<updated>2010-07-28T17:01:45Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide provides step-by-step instructions for using the Eclipse Integrated Development Environment (IDE) to develop applications for the Gumstix COMs.&lt;br /&gt;
&lt;br /&gt;
We'll walk through these tasks:&lt;br /&gt;
:* setting up Eclipse&lt;br /&gt;
:* connection to your Gumstix system&lt;br /&gt;
:* creating a simple &amp;quot;Hello, World!&amp;quot; Python program&lt;br /&gt;
:* running a web server&lt;br /&gt;
:* installing new packages on your Gumstix&lt;br /&gt;
:* creating a small graphical Java application&lt;br /&gt;
:* remote debugging of your Java application&lt;br /&gt;
:* natively-compiling C/C++ code on your Gumstix&lt;br /&gt;
:* remote debugging C/C++ using the GDB server interface&lt;br /&gt;
&lt;br /&gt;
We will also explain how to set up a cross-compilation toolchain so you can develop C/C++ applications on your development computer and upload them to your Gumstix.&lt;br /&gt;
&lt;br /&gt;
Remember, Gumstix COMs are fully-fledged, albeit tiny, Linux systems so there are many tools we don't cover here.  For example, [http://wiki.openembedded.net/index.php/OpenEmbedded_Tools_for_Eclipse_(OTE) this document] explains how to use the powerful OpenEmbedded build system within Eclipse.&lt;br /&gt;
&lt;br /&gt;
Required Tools:&lt;br /&gt;
:* any Windows, Apple or Linux computer with a USB port&lt;br /&gt;
:* recent version of the Java Runtime Environment (available [http://java.sun.com/javase/downloads/index.jsp here])&lt;br /&gt;
:* a Gumstix COM running [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Downloading-pre-built-images/111.html up-to-date software]&lt;br /&gt;
:* any expansion board of the Gumstix Overo series, such as Chestnut or Tobi, that has both a USB console port and a 10/100 &lt;br /&gt;
:* Ethernet jack&lt;br /&gt;
:* a 5V power supply&lt;br /&gt;
:* an ethernet cable and internet connection&lt;br /&gt;
:* a mini-A to Standard-A USB cable&lt;br /&gt;
:* a [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Creating-a-bootable-microSD-card/111.html bootable microSD card] (only needed for native C/C++ compilation)&lt;br /&gt;
&lt;br /&gt;
Key Idea:&lt;br /&gt;
[[File:GumstixEclipse1.jpg|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Download Eclipse==&lt;br /&gt;
[http://www.eclipse.org/downloads/ Download] the Eclipse IDE for Java Developers for your Operating System: www.eclipse.org&lt;br /&gt;
&lt;br /&gt;
[[Image: GumstixEclipse2.jpg | thumb | left]]&lt;br /&gt;
&lt;br /&gt;
:* it is ''not'' necessary to install the Eclipse software; just double-click on the application once it has finished downloading&lt;br /&gt;
:* when prompted, choose a workspace folder in which you want to store your projects and your configuration information&lt;br /&gt;
:* then click through to the Eclipse workbench itself&lt;br /&gt;
&lt;br /&gt;
==Install Plugins==&lt;br /&gt;
For developers, a great variety of additional features can be added to Eclipse from various repositories of plug-ins known as ''Update Sites''.&lt;br /&gt;
To install a new plugin in Eclipse, first select the ''Update Site''.&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* select the Update Site for your version of Eclipse from the &amp;quot;Work with&amp;quot;dropdown menu&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse3.jpg]]&lt;br /&gt;
&lt;br /&gt;
:Note: If you are not sure which version of Eclipse you have, you can check by reopening Eclipse, it will be displayed on the loading screen.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If the update site is not available, you can add it by clicking the 'Add...' button on the right. For the Galileo release, you can use the URL http://dowload.eclipse.org/releases/galileo&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
As we are working with a remote system, we'll install the Remote System Explorer plugin.&lt;br /&gt;
:* search for the ''Remote System Explorer End-User Runtime'' plugin&lt;br /&gt;
:* select it for installation&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse4.jpg]]&lt;br /&gt;
&lt;br /&gt;
Still in Eclipse,&lt;br /&gt;
:* select &amp;quot;Next&amp;quot;.... twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
Once Eclipse has restarted, let's add two other useful plugins that allow connection to the console port of our Gumstix without needing a terminal emulator program such as kermit or TeraTerm.&lt;br /&gt;
From within Eclipse,&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software'''&lt;br /&gt;
:* search on &amp;quot;Target&amp;quot; to find the ''Target Manager Terminal''&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse5.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* select the ''Target Manager Terminal''&lt;br /&gt;
:* click &amp;quot;Next&amp;quot;&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
We'll also need to add a new update site by doing these steps in Eclipse:&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* click the &amp;quot;Add...&amp;quot; button&lt;br /&gt;
:* type ''http://rxtx.qbang.org/eclipse'' into the ''Location'' field and create a name&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse6.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* Click the &amp;quot;OK&amp;quot; button&lt;br /&gt;
Go into the sub-directory as shown below to select the ''RXTX End-User Runtime'' plugin that this site provides.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse7.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* click &amp;quot;Next&amp;quot; twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* click &amp;quot;OK&amp;quot; at the security warning window&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose the &amp;quot;Yes&amp;quot; button to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
==Connect Your Gumstix==&lt;br /&gt;
Now it is time to connect your Gumstix---let's get started by establishing a console connection.&lt;br /&gt;
:* mount your Gumstix COM down on to your expansion board&lt;br /&gt;
:* plug the mini-A USB plug into the port marked CONSOLE and end of the cable into a standard USB port on your computer&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Your computer should detect your Gumstix system when you first connect the USB cable, even though the power is not yet turned on. On Macintosh and Windows systems, a pop-up window should appear instructing you to download a new driver (do so) or notifying you that a USBserial device has been detected. If not, you can download drivers from [http://www.ftdichip.com/FTDrivers.htm this site]. Choose the &amp;quot;VCP&amp;quot; driver.&lt;br /&gt;
Once you have downloaded this driver, make sure to unplug and then replug the USB cable running from your computer to your Gumstix expansion board so the Gumstix will be recognized by your computer.&lt;br /&gt;
----&lt;br /&gt;
:* connect your Gumstix to the internet using an ethernet cable&lt;br /&gt;
    NOTE: You still have NOT plugged the power cable in to the &lt;br /&gt;
    Gumstix expansion board! This diagram shows the locations&lt;br /&gt;
    of the USB 'CONSOLE' port and the 'POWER' input port on a &lt;br /&gt;
    Summit board on which an Overo COM has been mounted.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse8.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* if you are booting from a microSD card, insert this card now until you hear it click in place.&lt;br /&gt;
Before applying power to the board, let's open up a connection to the console port.&lt;br /&gt;
In Eclipse,&lt;br /&gt;
:* navigate to '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;Terminal-&amp;gt;Terminal'''&lt;br /&gt;
:* click on the 'N' connection icon in the window that appears&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse9.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* make the connection using the following settings:&lt;br /&gt;
    Connection Type: Serial&lt;br /&gt;
    Port: &amp;lt;port to which your Gumstix is connected&amp;gt;&lt;br /&gt;
    Baud Rate: 115200&lt;br /&gt;
    Data Bits: 8&lt;br /&gt;
    Stop Bits: 1&lt;br /&gt;
    Parity: none&lt;br /&gt;
    Flow Control: none&lt;br /&gt;
    Timeout: 5&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
The port to which your Gumstix is connected will have a different name depending on your Host operating system.&lt;br /&gt;
:* On Windows, it should be ''USB-COM''&lt;br /&gt;
:* On Macintosh, it should be ''/dev/tty.usbserial-xxxxxxxx'' where ''xxxxxxxx'' is an arbitrary string of characters&lt;br /&gt;
:* On Linux, it should be ''/dev/ttyUSBx'' where ''x'' is a number.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse10.jpg]]&lt;br /&gt;
&lt;br /&gt;
*If this does not work, you can also get Console access to your Gumstix through a Terminal window. To do this, open up a Terminal window (Terminal for Mac users, cmd for Windows users). To open terminal for windows go into the search bar in the start menu, and type cmp, the first option is the terminal window. The device will have the same name (USB-COM, /dev/cu..., /dev/tty.usb...).&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If you having a hard time find the device, you can search for it by doing a &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l /dev/tty.* (for Mac and Linux) &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l USB* (for Windows)&lt;br /&gt;
----&lt;br /&gt;
*Once you have found the device name, you can gain Console access with the screen command. If, for example, the device is /dev/tty.usb, issue the command:&lt;br /&gt;
 screen /dev/tty.usb 115200&lt;br /&gt;
*The 115200 on the end is important, it tells your computer the Baud Rate. If you do not enter 115200, you will not be able to read what the Remote System is outputting. Once you have issued this command, you will have Console access to your Overo via Terminal.&lt;br /&gt;
&lt;br /&gt;
*Now, it's time to apply power to the Gumstix expansion board so plug the 5V wall adapter into the power input jack on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
You should see text appear in this window; for now, just let the Gumstix boot. When prompted, you can log in to the root account. The default credentials are:&lt;br /&gt;
&lt;br /&gt;
'''Overo'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: &amp;lt;leave blank&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VerdexPro'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: gumstix&lt;br /&gt;
&lt;br /&gt;
==Write 'Hello, World' à la Python==&lt;br /&gt;
&lt;br /&gt;
You are going to write a basic Python program for the Gumstix directly on the Gumstix; this is known as native development. Also, Python is an interpreted language which means you can run your programs directly without any compilation.&lt;br /&gt;
&lt;br /&gt;
Once you have logged into your Gumstix, do these steps in the terminal window within Eclipse:&lt;br /&gt;
:* open an editor on the Gumstix by typing: 'nano hello.py'&lt;br /&gt;
:* type out this simple Python program: ''print &amp;quot;Hello, Gumstix!&amp;quot;''&lt;br /&gt;
:* press Ctrl+O, &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* then press Ctrl+X to save and exit.&lt;br /&gt;
:* run your program by typing: ''python hello.py''&lt;br /&gt;
:* check that you see the words &amp;quot;Hello, Gumstix!&amp;quot; appear&lt;br /&gt;
&lt;br /&gt;
If you see the words &amp;quot;Hello Gumstix&amp;quot;, then you have just written your first program on a Gumstix Overo computer.&lt;br /&gt;
&lt;br /&gt;
==Create a Web Site==&lt;br /&gt;
Each Gumstix comes with a built-in package manager called opkg. A package manager is a useful tool for installing software; you can install everything from media players to GPS mapping tools to the Firefox web browser. In this example, you'll use opkg tool to install a new application for your Gumstix: the Apache web server.&lt;br /&gt;
&lt;br /&gt;
To make your own Gumstix web site, type the following in the terminal window:&lt;br /&gt;
    opkg update 			&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install apache2		&amp;lt;Enter&amp;gt;&lt;br /&gt;
Before you start using Apache, which is now running, you'll need to find the IP address (internet address) of your Gumstix COM. To do this, type the following command into the terminal window:&lt;br /&gt;
    ifconfig | grep 'inet addr' 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
You should see something like this appear on your screen.&lt;br /&gt;
    inet addr: 10.0.1.73 Bcast: 192.168.0.255 Mask: 255.255.255.0&lt;br /&gt;
The IP address of your Gumstix is the first address shown: ''10.0.1.73'' in this case.&lt;br /&gt;
Now,&lt;br /&gt;
:* open up a web browser on your host computer&lt;br /&gt;
:* type that IP address of your Gumstix into the address bar&lt;br /&gt;
You should see something like this which is the default web site for Apache running on your Gumstix.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse11.jpg]]&lt;br /&gt;
&lt;br /&gt;
To make your web site say something more interesting, do the follow in your terminal window:&lt;br /&gt;
:* type: ''nano /usr/share/apache2/htdocs/index.html''&lt;br /&gt;
:* replace the words at the top of the screen &amp;quot;It Works&amp;quot; with the words &amp;quot;Gumstix Rocks!&amp;quot;&lt;br /&gt;
:* press 'Ctrl+O' &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* press 'Ctrl+X' to save and exit&lt;br /&gt;
:* refresh your web browser&lt;br /&gt;
&lt;br /&gt;
==Write a Java Application==&lt;br /&gt;
So far, you haven't actually used Eclipse other than as a console interface for your Gumstix. It is time to harness the power of Eclipse to write a small graphical Java application.&lt;br /&gt;
In Eclipse.&lt;br /&gt;
:* Navigate to '''File-&amp;gt; New-&amp;gt; Java Project''',&lt;br /&gt;
:* Name the project ''gumstix-java''&lt;br /&gt;
:* Select &amp;quot;Finish&amp;quot;&lt;br /&gt;
Once the project is created,&lt;br /&gt;
:* Select '''File-&amp;gt;New-&amp;gt;Class'''&lt;br /&gt;
:* Name your class ''Hello''&lt;br /&gt;
:* click &amp;quot;FINISH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add the following code to your class:&lt;br /&gt;
&lt;br /&gt;
    import javax.swing.JFrame;&lt;br /&gt;
    import javax.swing.JLabel;&lt;br /&gt;
    public class Hello {&lt;br /&gt;
    	public static void main(String [] args) {&lt;br /&gt;
    		JFrame frame = new JFrame(&amp;quot;hello&amp;quot;);&lt;br /&gt;
    		final JLabel label = new JLabel(&amp;quot;hello from Gumstix&amp;quot;);&lt;br /&gt;
    		frame.getContentPane().add(label);&lt;br /&gt;
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
    		frame.pack();&lt;br /&gt;
    		frame.setVisible(true);&lt;br /&gt;
    	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
You should get something that looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse12.jpg]]&lt;br /&gt;
&lt;br /&gt;
Press the green run button to test drive our application on our host machine.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Eclipse has many auto-completion features. Simply typing /:*&amp;lt;Enter&amp;gt; before a class creates a standard documentation block. Likewise, pressing &amp;lt;Ctrl&amp;gt;+&amp;lt;Space&amp;gt; provides context specific auto-completion options. Many other hints for speedy development are explained in the tutorials [http://www.eclipse.org/resources/?category=Getting%20Started here].&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Upload Code==&lt;br /&gt;
In Step 5 we discovered the IP address of our Gumstix. With this, we can connect to our Gumstix using the SSH protocol which allows us to rapidly transfer files. For this step, navigate to '''Window-&amp;gt;Open Perspective-&amp;gt;Other-&amp;gt;Remote System Explorer''' and click on the connection icon in the ''Remote Systems'' panel on the left. Select ''SSH without shells'' as the connection type and press Next. Put the internet address you found in Step 5 into the field marked ''Host Name'' and hit finish. To test that everything is working correctly, right-click on the terminal item list under your new connection and select ''Launch Terminal''. A console interface exactly like the USB console interface we set up in Step 3 should pop up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A 'Perspective' is an arrangement of windows and widgets, that is a specific view of the Eclipse workspace, designed for a particular task. If you wish to focus on any particular widget, double click the tab in Eclipse; return to the previous view by double-clicking again.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By installing the VNC viewer plugin, we can get a graphical interface to our Gumstix system. Do this by adding the ''Tools for mobile linux runtime'' plugin ('''Help-&amp;gt;Install New Software''') from the main update site. To use, select the VNC viewer widget from '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;VNC Category-&amp;gt;VNC''' and click on the ''New Connection'' icon in the VNC Viewer panel. Again, the ''Host'' is the internet address of your Gumstix board.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse13.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to upload our java code before we can run it. Switch back to the Java Perspective ('''Window-&amp;gt;Open Perspective-&amp;gt;Java''') and right-click on our Java file and selecting Export. Choose the option to export file to a remote file system and choose to upload your ''Hello.class'' file.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse14.jpg]]&lt;br /&gt;
&lt;br /&gt;
You will need to ''Browse'' to find your Gumstix board; you should upload this code to your home directory on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
==Debug a Java Application==&lt;br /&gt;
We can debug our java application remotely from Eclipse. To do this, we need a Java Virtual Machine capable of doing debugging. This time, the package we need isn't available in our package sources however we can fetch the package directly from a web site and install it using the same opkg package management tool.&lt;br /&gt;
    wget http://bugcommunity.com/downloads/files/phonemeadvanced- personal-debug_mr2-r1_armv6.ipk 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install -force-depends phoneme-advanced-personaldebug_mr2-r1_armv6.ipk &amp;lt;Enter&amp;gt;&lt;br /&gt;
Let's also update our Java libraries so we have access to the standard graphical libraries.&lt;br /&gt;
    opkg install classpath-gtk	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Next, let's start our Java code in debugging mode on the Overo:&lt;br /&gt;
    java-cdc -Xdebug -Xrunjwdp:transport=dHt_socket,server=y,suspend=y,address=1234 Hello	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Finally, let's connect to our debugging session by navigating in Eclipse to '''Run-&amp;gt;Debug Configurations''' and double-clicking on Remote Java Application to create a new configuration. Fill in the form as shown below using the internet address found in the previous step.&lt;br /&gt;
&lt;br /&gt;
==Install a native C/C++ SDK==&lt;br /&gt;
When we discussed Python and Java we noted that both are interpreted languages--- neither needs to be compiled. C and C++ code requires compilation which can be done natively---on the Gumstix itself---or on a development machine using a cross-compiler. To do native compilation, you need to install a compiler as well as any required libraries. You'll need to be booting from a microSD card as this installation takes approximately 75MB of space.&lt;br /&gt;
    $ echo 'src/gz angstrom-base http://www.angstromdistribution.org/feeds/unstable/ipk/glibc/armv7a/base'  &amp;gt; /etc/opkg/angstrom-base.conf&lt;br /&gt;
    $ opkg update&lt;br /&gt;
    $ opkg install task-native-sdk&lt;br /&gt;
Firstly, we are adding a new package repository to our package manager and updating our list of available packages before actually installing the complete package needed to do native development.&lt;br /&gt;
&lt;br /&gt;
Let's create either of the following files in Eclipse, upload the code and then compile on the Gumstix using our newly installed compiler.&lt;br /&gt;
&lt;br /&gt;
===C++: HelloWorld.cpp===&lt;br /&gt;
    #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
    using namespace std;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	cout &amp;lt;&amp;lt; &amp;quot;Gumstix runs on C++&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.cpp&lt;br /&gt;
    g++ -o hello hello.cpp	&amp;lt;enter&amp;gt;&lt;br /&gt;
    Gumstix runs on C++   	&amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===C: HelloWorld.c===&lt;br /&gt;
    #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	printf(&amp;quot;Gumstix runs on C\n&amp;quot;);&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.c&lt;br /&gt;
    gcc -o hello hello.c&lt;br /&gt;
    Gumstix runs on C&lt;br /&gt;
&lt;br /&gt;
&amp;lt;TODO: More exciting examples using on-board LEDs.&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using GDB as a remote debugger in C/C++==&lt;br /&gt;
These instructions will teach you how to download, install, and use the GDB debugger remotely on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;NOTE:	&lt;br /&gt;
remote system - a device that is being operated remotely (via SSH, USB Serial, etc). This means that it is a device that you are operating from a different system &lt;br /&gt;
(ie: if you are accessing the Overo COM via connection with your PC, then the Overo COM is a remote system).&lt;br /&gt;
For the purpose of this guide, the Overo COM will be the remote system.&lt;br /&gt;
&lt;br /&gt;
local host - the device that is being used to work on (ie: If you are working on your PC, that is the local host. If you then connect to another computer via VNC, &lt;br /&gt;
that is a remote system, and you laptop is still the localhost).&lt;br /&gt;
For the purpose of this guide, your Personal Computer will be the local host.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before starting, it is important to note there are many different ways to run a remote debugger. The most fundamental choice when debugging remotely is whether you want to:&lt;br /&gt;
:*Run the debugger on the remote system or&lt;br /&gt;
:*Run the debugger on the local host with a cross debugger on the remote system&lt;br /&gt;
&lt;br /&gt;
This guide will teach you how to download, install, and run the debugger on the remote system (choice A). If you wish to learn more about the cross debugger option, use Google. Also the wikipedia article on cross compilers (which operate in a very similar fashion) is very good, albeit a bit complicated. None of this is necessary in understanding the contents of this guide. &lt;br /&gt;
&lt;br /&gt;
For the purposes of this guide, we will be using the GDB: the GNU project debugger. As stated on their website:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it &lt;br /&gt;
crashed.&lt;br /&gt;
&lt;br /&gt;
GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:&lt;br /&gt;
- Start your program, specifying anything that might affect its behavior.&lt;br /&gt;
- Make your program stop on specified conditions.&lt;br /&gt;
- Examine what has happened, when your program has stopped.&lt;br /&gt;
- Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the reasons for using a debugger instead of trying to debug with the ‘brute force’ method of adding print statements throughout the entire program are enumerable, there are a few that stand out:&lt;br /&gt;
# The ability to ‘step’ through a program&lt;br /&gt;
#* The GDB debugger allows you to ‘step’ through a program. This means that instead of just executing the program and then leaving you with a final error message, it will execute one line at a time until the program crashes. This allows the user to see exactly where, and why, the program crashed. &lt;br /&gt;
# The ability to set breakpoints&lt;br /&gt;
#* The GDB debugger allows you to set breakpoints in the program. These are points where the CPU will stop executing the code and allow the user to decide whether to continue. This allows the user to explore what is ‘going on’ at certain points in the execution, something that otherwise is not possible. &lt;br /&gt;
# The ability to look at the Backtrace&lt;br /&gt;
#* This will show you where, and exactly why, your program crashed. Although SEGFAULT isn’t very useful, the backtrace will tell you what caused the SEGFAULT. Everything from what line, what variable, and even the address that variable was at.&lt;br /&gt;
&lt;br /&gt;
===Installing the GDB===&lt;br /&gt;
Once the Overo COM has been connected to the local host, you should have access to the following command line:&lt;br /&gt;
&amp;lt;pre&amp;gt;root@overo:~#	&amp;lt;/pre&amp;gt;&lt;br /&gt;
Although you are working on your local host, this command line is for the remote system. It is the same as if you opened up Terminal (for Mac, Linux) or XTerm (for Windows). You now have access and control of the remote system.&lt;br /&gt;
&lt;br /&gt;
Now there are some packages that must be downloaded and installed onto the Overo so that it can run the GDB environment. To do this issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;opkg update	 	&amp;lt;enter&amp;gt;&lt;br /&gt;
opkg install gdb 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This should spew out a bunch of text such as:&lt;br /&gt;
&amp;lt;pre&amp;gt;Downloading http://www.angstrom...&amp;lt;/pre&amp;gt;&lt;br /&gt;
Just let it run and once its done, you’ll have the GNU GDB debugger installed on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
===Creating a C/C++ Program to Debug===&lt;br /&gt;
Now, your Overo COM has a debugger installed and ready to use. However, this does not mean you are ready to go. There are two more things required before it is possible to use a GDB debugger.&lt;br /&gt;
:* A C/C++ program&lt;br /&gt;
:* A SDK to run the program on&lt;br /&gt;
To see how to install a SDK and write/run a simple program in C/C++, see [[#Install a native C/C++ SDK]]. &lt;br /&gt;
&lt;br /&gt;
Once you have a program ready, you first must create an executable file. Lets use for example the C++ program HelloWorld.cpp. To create the executable file HelloWorld, issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;g++ -o HelloWorld HelloWorld.cpp 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now, to run the program:&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
To do the same thing with a C program (HelloWorld.c), issue the command&lt;br /&gt;
&amp;lt;pre&amp;gt;gcc -o HelloWorld HelloWorld.c		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What this command does is uses the GNU compiler (either g++ or gcc) and creates an executable object (HelloWorld) out of the C or C++ program file (either HelloWorld.cpp or HelloWorld.c). You may name the executable whatever you like, but it is considered best practice to name it the same thing as the program file.&lt;br /&gt;
&lt;br /&gt;
===Debugging the Program===&lt;br /&gt;
Now that you have GDB installed and a C/C++ program ready to go, its time to debug. To open to GDB environment, run the following command&lt;br /&gt;
&amp;lt;pre&amp;gt;gdb						&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Some text should spit out, and the following command line should appear&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that the debugger is running, it is time to tell the debugger what program we want to debug. To do this, first we need to declare our HelloWorld file as an executable file. For this run the following command	&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) exec-file HelloWorld		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that we have an executable file ready to be debugged, its time to run the program&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) run HelloWorld			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
The debugger will now run your program. If the program has no syntax or logic errors, the program should run and end with the line:&lt;br /&gt;
Program exited normally.&lt;br /&gt;
If there are errors, or the program crashed, it is possible to extract the exact details of that crash  by issuing the back trace command.&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) bt			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once you are done you can quit by issuing the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) quit			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A complete list of commands in GDB:&lt;br /&gt;
www.yolinux.com/TUTORIALS/GDB-Commands.html&lt;br /&gt;
&lt;br /&gt;
====GDB Debugger Tutorial====&lt;br /&gt;
For a complete GDB Debugger tutorial (very good tutorial, comes with sample code they walk you through and extra errors for you to debug yourself!):&lt;br /&gt;
http://www.cs.cmu.edu/~gilpin/tutorial/&lt;br /&gt;
&lt;br /&gt;
Now you have a debugger up and running! Play around with it by putting errors into your program on purpose to see the powers of having a remote debugger!&lt;br /&gt;
&lt;br /&gt;
==Use a C/C++ cross-compiler==&lt;br /&gt;
In order to do C/C++ development on our host machine, we need to add in a plugin to Eclipse. Also, we need to download an appropriate cross-compilation toolchain. For now, I recommend the lovely instructions from&lt;br /&gt;
&lt;br /&gt;
http://www.designarm.com/quickstart-guide/linux-software/eclipse.html &amp;amp;&lt;br /&gt;
&lt;br /&gt;
http://www.bugcommunity.com/wiki/index.php/BUG_Kernel_Development_with_Eclipse&lt;br /&gt;
&lt;br /&gt;
===Further Reading===&lt;br /&gt;
:* Tutorials built into Eclipse&lt;br /&gt;
:* Bitbake commander&lt;br /&gt;
:* OpenEmebedded|Poky docs + Bitbake docs&lt;br /&gt;
:* Eclipse Plugin Tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:How_to_-_eclipse]]&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4348</id>
		<title>Eclipse on Gumstix for new users</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4348"/>
				<updated>2010-07-28T16:22:51Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide provides step-by-step instructions for using the Eclipse Integrated Development Environment (IDE) to develop applications for the Gumstix COMs.&lt;br /&gt;
&lt;br /&gt;
We'll walk through these tasks:&lt;br /&gt;
:* setting up Eclipse&lt;br /&gt;
:* connection to your Gumstix system&lt;br /&gt;
:* creating a simple &amp;quot;Hello, World!&amp;quot; Python program&lt;br /&gt;
:* running a web server&lt;br /&gt;
:* installing new packages on your Gumstix&lt;br /&gt;
:* creating a small graphical Java application&lt;br /&gt;
:* remote debugging of your Java application&lt;br /&gt;
:* natively-compiling C/C++ code on your Gumstix&lt;br /&gt;
:* remote debugging C/C++ using the GDB server interface&lt;br /&gt;
&lt;br /&gt;
We will also explain how to set up a cross-compilation toolchain so you can develop C/C++ applications on your development computer and upload them to your Gumstix.&lt;br /&gt;
&lt;br /&gt;
Remember, Gumstix COMs are fully-fledged, albeit tiny, Linux systems so there are many tools we don't cover here.  For example, [http://wiki.openembedded.net/index.php/OpenEmbedded_Tools_for_Eclipse_(OTE) this document] explains how to use the powerful OpenEmbedded build system within Eclipse.&lt;br /&gt;
&lt;br /&gt;
Required Tools:&lt;br /&gt;
:* any Windows, Apple or Linux computer with a USB port&lt;br /&gt;
:* recent version of the Java Runtime Environment (available [http://java.sun.com/javase/downloads/index.jsp here])&lt;br /&gt;
:* a Gumstix COM running [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Downloading-pre-built-images/111.html up-to-date software]&lt;br /&gt;
:* any expansion board of the Gumstix Overo series, such as Chestnut or Tobi, that has both a USB console port and a 10/100 &lt;br /&gt;
:* Ethernet jack&lt;br /&gt;
:* a 5V power supply&lt;br /&gt;
:* an ethernet cable and internet connection&lt;br /&gt;
:* a mini-A to Standard-A USB cable&lt;br /&gt;
:* a [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Creating-a-bootable-microSD-card/111.html bootable microSD card] (only needed for native C/C++ compilation)&lt;br /&gt;
&lt;br /&gt;
Key Idea:&lt;br /&gt;
[[File:GumstixEclipse1.jpg|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Download Eclipse==&lt;br /&gt;
[http://www.eclipse.org/downloads/ Download] the Eclipse IDE for Java Developers for your Operating System: www.eclipse.org&lt;br /&gt;
&lt;br /&gt;
[[Image: GumstixEclipse2.jpg | thumb | left]]&lt;br /&gt;
&lt;br /&gt;
:* it is ''not'' necessary to install the Eclipse software; just double-click on the application once it has finished downloading&lt;br /&gt;
:* when prompted, choose a workspace folder in which you want to store your projects and your configuration information&lt;br /&gt;
:* then click through to the Eclipse workbench itself&lt;br /&gt;
&lt;br /&gt;
==Install Plugins==&lt;br /&gt;
For developers, a great variety of additional features can be added to Eclipse from various repositories of plug-ins known as ''Update Sites''.&lt;br /&gt;
To install a new plugin in Eclipse, first select the ''Update Site''.&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* select the Update Site for your version of Eclipse from the &amp;quot;Work with&amp;quot;dropdown menu&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse3.jpg]]&lt;br /&gt;
&lt;br /&gt;
:Note: If you are not sure which version of Eclipse you have, you can check by reopening Eclipse, it will be displayed on the loading screen.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If the update site is not available, you can add it by clicking the 'Add...' button on the right. For the Galileo release, you can use the URL http://dowload.eclipse.org/releases/galileo&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
As we are working with a remote system, we'll install the Remote System Explorer plugin.&lt;br /&gt;
:* search for the ''Remote System Explorer End-User Runtime'' plugin&lt;br /&gt;
:* select it for installation&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse4.jpg]]&lt;br /&gt;
&lt;br /&gt;
Still in Eclipse,&lt;br /&gt;
:* select &amp;quot;Next&amp;quot;.... twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
Once Eclipse has restarted, let's add two other useful plugins that allow connection to the console port of our Gumstix without needing a terminal emulator program such as kermit or TeraTerm.&lt;br /&gt;
From within Eclipse,&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software'''&lt;br /&gt;
:* search on &amp;quot;Target&amp;quot; to find the ''Target Manager Terminal''&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse5.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* select the ''Target Manager Terminal''&lt;br /&gt;
:* click &amp;quot;Next&amp;quot;&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
We'll also need to add a new update site by doing these steps in Eclipse:&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* click the &amp;quot;Add...&amp;quot; button&lt;br /&gt;
:* type ''http://rxtx.qbang.org/eclipse'' into the ''Location'' field and create a name&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse6.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* Click the &amp;quot;OK&amp;quot; button&lt;br /&gt;
Go into the sub-directory as shown below to select the ''RXTX End-User Runtime'' plugin that this site provides.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse7.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* click &amp;quot;Next&amp;quot; twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* click &amp;quot;OK&amp;quot; at the security warning window&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose the &amp;quot;Yes&amp;quot; button to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
==Connect Your Gumstix==&lt;br /&gt;
Now it is time to connect your Gumstix---let's get started by establishing a console connection.&lt;br /&gt;
:* mount your Gumstix COM down on to your expansion board&lt;br /&gt;
:* plug the mini-A USB plug into the port marked CONSOLE and end of the cable into a standard USB port on your computer&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Your computer should detect your Gumstix system when you first connect the USB cable, even though the power is not yet turned on. On Macintosh and Windows systems, a pop-up window should appear instructing you to download a new driver (do so) or notifying you that a USBserial device has been detected. If not, you can download drivers from [http://www.ftdichip.com/FTDrivers.htm this site]. Choose the &amp;quot;VCP&amp;quot; driver.&lt;br /&gt;
Once you have downloaded this driver, make sure to unplug and then replug the USB cable running from your computer to your Gumstix expansion board so the Gumstix will be recognized by your computer.&lt;br /&gt;
----&lt;br /&gt;
:* connect your Gumstix to the internet using an ethernet cable&lt;br /&gt;
    NOTE: You still have NOT plugged the power cable in to the &lt;br /&gt;
    Gumstix expansion board! This diagram shows the locations&lt;br /&gt;
    of the USB 'CONSOLE' port and the 'POWER' input port on a &lt;br /&gt;
    Summit board on which an Overo COM has been mounted.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse8.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* if you are booting from a microSD card, insert this card now until you hear it click in place.&lt;br /&gt;
Before applying power to the board, let's open up a connection to the console port.&lt;br /&gt;
In Eclipse,&lt;br /&gt;
:* navigate to '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;Terminal-&amp;gt;Terminal'''&lt;br /&gt;
:* click on the 'N' connection icon in the window that appears&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse9.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* make the connection using the following settings:&lt;br /&gt;
    Connection Type: Serial&lt;br /&gt;
    Port: &amp;lt;port to which your Gumstix is connected&amp;gt;&lt;br /&gt;
    Baud Rate: 115200&lt;br /&gt;
    Data Bits: 8&lt;br /&gt;
    Stop Bits: 1&lt;br /&gt;
    Parity: none&lt;br /&gt;
    Flow Control: none&lt;br /&gt;
    Timeout: 5&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
The port to which your Gumstix is connected will have a different name depending on your Host operating system.&lt;br /&gt;
:* On Windows, it should be ''USB-COM''&lt;br /&gt;
:* On Macintosh, it should be ''/dev/tty.usbserial-xxxxxxxx'' where ''xxxxxxxx'' is an arbitrary string of characters&lt;br /&gt;
:* On Linux, it should be ''/dev/ttyUSBx'' where ''x'' is a number.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse10.jpg]]&lt;br /&gt;
&lt;br /&gt;
*If this does not work, you can also get Console access to your Gumstix through a Terminal window. To do this, open up a Terminal window (Terminal for Mac users, XTerm or X11 for Windows users). The device will have the same name (USB-COM, /dev/cu..., /dev/tty.usb...).&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If you having a hard time find the device, you can search for it by doing a &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l /dev/tty.* (for Mac and Linux) &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l USB* (for Windows)&lt;br /&gt;
----&lt;br /&gt;
*Once you have found the device name, you can gain Console access with the screen command. If, for example, the device is /dev/tty.usb, issue the command:&lt;br /&gt;
 screen /dev/tty.usb 115200&lt;br /&gt;
*The 115200 on the end is important, it tells your computer the Baud Rate. If you do not enter 115200, you will not be able to read what the Remote System is outputting. Once you have issued this command, you will have Console access to your Overo via Terminal.&lt;br /&gt;
&lt;br /&gt;
*Now, it's time to apply power to the Gumstix expansion board so plug the 5V wall adapter into the power input jack on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
You should see text appear in this window; for now, just let the Gumstix boot. When prompted, you can log in to the root account. The default credentials are:&lt;br /&gt;
&lt;br /&gt;
'''Overo'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: &amp;lt;leave blank&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VerdexPro'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: gumstix&lt;br /&gt;
&lt;br /&gt;
==Write 'Hello, World' à la Python==&lt;br /&gt;
&lt;br /&gt;
You are going to write a basic Python program for the Gumstix directly on the Gumstix; this is known as native development. Also, Python is an interpreted language which means you can run your programs directly without any compilation.&lt;br /&gt;
&lt;br /&gt;
Once you have logged into your Gumstix, do these steps in the terminal window within Eclipse:&lt;br /&gt;
:* open an editor on the Gumstix by typing: 'nano hello.py'&lt;br /&gt;
:* type out this simple Python program: ''print &amp;quot;Hello, Gumstix!&amp;quot;''&lt;br /&gt;
:* press Ctrl+O, &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* then press Ctrl+X to save and exit.&lt;br /&gt;
:* run your program by typing: ''python hello.py''&lt;br /&gt;
:* check that you see the words &amp;quot;Hello, Gumstix!&amp;quot; appear&lt;br /&gt;
&lt;br /&gt;
If you see the words &amp;quot;Hello Gumstix&amp;quot;, then you have just written your first program on a Gumstix Overo computer.&lt;br /&gt;
&lt;br /&gt;
==Create a Web Site==&lt;br /&gt;
Each Gumstix comes with a built-in package manager called opkg. A package manager is a useful tool for installing software; you can install everything from media players to GPS mapping tools to the Firefox web browser. In this example, you'll use opkg tool to install a new application for your Gumstix: the Apache web server.&lt;br /&gt;
&lt;br /&gt;
To make your own Gumstix web site, type the following in the terminal window:&lt;br /&gt;
    opkg update 			&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install apache2		&amp;lt;Enter&amp;gt;&lt;br /&gt;
Before you start using Apache, which is now running, you'll need to find the IP address (internet address) of your Gumstix COM. To do this, type the following command into the terminal window:&lt;br /&gt;
    ifconfig | grep 'inet addr' 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
You should see something like this appear on your screen.&lt;br /&gt;
    inet addr: 10.0.1.73 Bcast: 192.168.0.255 Mask: 255.255.255.0&lt;br /&gt;
The IP address of your Gumstix is the first address shown: ''10.0.1.73'' in this case.&lt;br /&gt;
Now,&lt;br /&gt;
:* open up a web browser on your host computer&lt;br /&gt;
:* type that IP address of your Gumstix into the address bar&lt;br /&gt;
You should see something like this which is the default web site for Apache running on your Gumstix.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse11.jpg]]&lt;br /&gt;
&lt;br /&gt;
To make your web site say something more interesting, do the follow in your terminal window:&lt;br /&gt;
:* type: ''nano /usr/share/apache2/htdocs/index.html''&lt;br /&gt;
:* replace the words at the top of the screen &amp;quot;It Works&amp;quot; with the words &amp;quot;Gumstix Rocks!&amp;quot;&lt;br /&gt;
:* press 'Ctrl+O' &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* press 'Ctrl+X' to save and exit&lt;br /&gt;
:* refresh your web browser&lt;br /&gt;
&lt;br /&gt;
==Write a Java Application==&lt;br /&gt;
So far, you haven't actually used Eclipse other than as a console interface for your Gumstix. It is time to harness the power of Eclipse to write a small graphical Java application.&lt;br /&gt;
In Eclipse.&lt;br /&gt;
:* Navigate to '''File-&amp;gt; New-&amp;gt; Java Project''',&lt;br /&gt;
:* Name the project ''gumstix-java''&lt;br /&gt;
:* Select &amp;quot;Finish&amp;quot;&lt;br /&gt;
Once the project is created,&lt;br /&gt;
:* Select '''File-&amp;gt;New-&amp;gt;Class'''&lt;br /&gt;
:* Name your class ''Hello''&lt;br /&gt;
:* click &amp;quot;FINISH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add the following code to your class:&lt;br /&gt;
&lt;br /&gt;
    import javax.swing.JFrame;&lt;br /&gt;
    import javax.swing.JLabel;&lt;br /&gt;
    public class Hello {&lt;br /&gt;
    	public static void main(String [] args) {&lt;br /&gt;
    		JFrame frame = new JFrame(&amp;quot;hello&amp;quot;);&lt;br /&gt;
    		final JLabel label = new JLabel(&amp;quot;hello from Gumstix&amp;quot;);&lt;br /&gt;
    		frame.getContentPane().add(label);&lt;br /&gt;
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
    		frame.pack();&lt;br /&gt;
    		frame.setVisible(true);&lt;br /&gt;
    	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
You should get something that looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse12.jpg]]&lt;br /&gt;
&lt;br /&gt;
Press the green run button to test drive our application on our host machine.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Eclipse has many auto-completion features. Simply typing /:*&amp;lt;Enter&amp;gt; before a class creates a standard documentation block. Likewise, pressing &amp;lt;Ctrl&amp;gt;+&amp;lt;Space&amp;gt; provides context specific auto-completion options. Many other hints for speedy development are explained in the tutorials [http://www.eclipse.org/resources/?category=Getting%20Started here].&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Upload Code==&lt;br /&gt;
In Step 5 we discovered the IP address of our Gumstix. With this, we can connect to our Gumstix using the SSH protocol which allows us to rapidly transfer files. For this step, navigate to '''Window-&amp;gt;Open Perspective-&amp;gt;Other-&amp;gt;Remote System Explorer''' and click on the connection icon in the ''Remote Systems'' panel on the left. Select ''SSH without shells'' as the connection type and press Next. Put the internet address you found in Step 5 into the field marked ''Host Name'' and hit finish. To test that everything is working correctly, right-click on the terminal item list under your new connection and select ''Launch Terminal''. A console interface exactly like the USB console interface we set up in Step 3 should pop up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A 'Perspective' is an arrangement of windows and widgets, that is a specific view of the Eclipse workspace, designed for a particular task. If you wish to focus on any particular widget, double click the tab in Eclipse; return to the previous view by double-clicking again.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By installing the VNC viewer plugin, we can get a graphical interface to our Gumstix system. Do this by adding the ''Tools for mobile linux runtime'' plugin ('''Help-&amp;gt;Install New Software''') from the main update site. To use, select the VNC viewer widget from '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;VNC Category-&amp;gt;VNC''' and click on the ''New Connection'' icon in the VNC Viewer panel. Again, the ''Host'' is the internet address of your Gumstix board.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse13.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to upload our java code before we can run it. Switch back to the Java Perspective ('''Window-&amp;gt;Open Perspective-&amp;gt;Java''') and right-click on our Java file and selecting Export. Choose the option to export file to a remote file system and choose to upload your ''Hello.class'' file.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse14.jpg]]&lt;br /&gt;
&lt;br /&gt;
You will need to ''Browse'' to find your Gumstix board; you should upload this code to your home directory on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
==Debug a Java Application==&lt;br /&gt;
We can debug our java application remotely from Eclipse. To do this, we need a Java Virtual Machine capable of doing debugging. This time, the package we need isn't available in our package sources however we can fetch the package directly from a web site and install it using the same opkg package management tool.&lt;br /&gt;
    wget http://bugcommunity.com/downloads/files/phonemeadvanced- personal-debug_mr2-r1_armv6.ipk 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install -force-depends phoneme-advanced-personaldebug_mr2-r1_armv6.ipk &amp;lt;Enter&amp;gt;&lt;br /&gt;
Let's also update our Java libraries so we have access to the standard graphical libraries.&lt;br /&gt;
    opkg install classpath-gtk	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Next, let's start our Java code in debugging mode on the Overo:&lt;br /&gt;
    java-cdc -Xdebug -Xrunjwdp:transport=dHt_socket,server=y,suspend=y,address=1234 Hello	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Finally, let's connect to our debugging session by navigating in Eclipse to '''Run-&amp;gt;Debug Configurations''' and double-clicking on Remote Java Application to create a new configuration. Fill in the form as shown below using the internet address found in the previous step.&lt;br /&gt;
&lt;br /&gt;
==Install a native C/C++ SDK==&lt;br /&gt;
When we discussed Python and Java we noted that both are interpreted languages--- neither needs to be compiled. C and C++ code requires compilation which can be done natively---on the Gumstix itself---or on a development machine using a cross-compiler. To do native compilation, you need to install a compiler as well as any required libraries. You'll need to be booting from a microSD card as this installation takes approximately 75MB of space.&lt;br /&gt;
    $ echo 'src/gz angstrom-base http://www.angstromdistribution.org/feeds/unstable/ipk/glibc/armv7a/base'  &amp;gt; /etc/opkg/angstrom-base.conf&lt;br /&gt;
    $ opkg update&lt;br /&gt;
    $ opkg install task-native-sdk&lt;br /&gt;
Firstly, we are adding a new package repository to our package manager and updating our list of available packages before actually installing the complete package needed to do native development.&lt;br /&gt;
&lt;br /&gt;
Let's create either of the following files in Eclipse, upload the code and then compile on the Gumstix using our newly installed compiler.&lt;br /&gt;
&lt;br /&gt;
===C++: HelloWorld.cpp===&lt;br /&gt;
    #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
    using namespace std;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	cout &amp;lt;&amp;lt; &amp;quot;Gumstix runs on C++&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.cpp&lt;br /&gt;
    g++ -o hello hello.cpp	&amp;lt;enter&amp;gt;&lt;br /&gt;
    Gumstix runs on C++   	&amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===C: HelloWorld.c===&lt;br /&gt;
    #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	printf(&amp;quot;Gumstix runs on C\n&amp;quot;);&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.c&lt;br /&gt;
    gcc -o hello hello.c&lt;br /&gt;
    Gumstix runs on C&lt;br /&gt;
&lt;br /&gt;
&amp;lt;TODO: More exciting examples using on-board LEDs.&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using GDB as a remote debugger in C/C++==&lt;br /&gt;
These instructions will teach you how to download, install, and use the GDB debugger remotely on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;NOTE:	&lt;br /&gt;
remote system - a device that is being operated remotely (via SSH, USB Serial, etc). This means that it is a device that you are operating from a different system &lt;br /&gt;
(ie: if you are accessing the Overo COM via connection with your PC, then the Overo COM is a remote system).&lt;br /&gt;
For the purpose of this guide, the Overo COM will be the remote system.&lt;br /&gt;
&lt;br /&gt;
local host - the device that is being used to work on (ie: If you are working on your PC, that is the local host. If you then connect to another computer via VNC, &lt;br /&gt;
that is a remote system, and you laptop is still the localhost).&lt;br /&gt;
For the purpose of this guide, your Personal Computer will be the local host.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before starting, it is important to note there are many different ways to run a remote debugger. The most fundamental choice when debugging remotely is whether you want to:&lt;br /&gt;
:*Run the debugger on the remote system or&lt;br /&gt;
:*Run the debugger on the local host with a cross debugger on the remote system&lt;br /&gt;
&lt;br /&gt;
This guide will teach you how to download, install, and run the debugger on the remote system (choice A). If you wish to learn more about the cross debugger option, use Google. Also the wikipedia article on cross compilers (which operate in a very similar fashion) is very good, albeit a bit complicated. None of this is necessary in understanding the contents of this guide. &lt;br /&gt;
&lt;br /&gt;
For the purposes of this guide, we will be using the GDB: the GNU project debugger. As stated on their website:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it &lt;br /&gt;
crashed.&lt;br /&gt;
&lt;br /&gt;
GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:&lt;br /&gt;
- Start your program, specifying anything that might affect its behavior.&lt;br /&gt;
- Make your program stop on specified conditions.&lt;br /&gt;
- Examine what has happened, when your program has stopped.&lt;br /&gt;
- Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the reasons for using a debugger instead of trying to debug with the ‘brute force’ method of adding print statements throughout the entire program are enumerable, there are a few that stand out:&lt;br /&gt;
# The ability to ‘step’ through a program&lt;br /&gt;
#* The GDB debugger allows you to ‘step’ through a program. This means that instead of just executing the program and then leaving you with a final error message, it will execute one line at a time until the program crashes. This allows the user to see exactly where, and why, the program crashed. &lt;br /&gt;
# The ability to set breakpoints&lt;br /&gt;
#* The GDB debugger allows you to set breakpoints in the program. These are points where the CPU will stop executing the code and allow the user to decide whether to continue. This allows the user to explore what is ‘going on’ at certain points in the execution, something that otherwise is not possible. &lt;br /&gt;
# The ability to look at the Backtrace&lt;br /&gt;
#* This will show you where, and exactly why, your program crashed. Although SEGFAULT isn’t very useful, the backtrace will tell you what caused the SEGFAULT. Everything from what line, what variable, and even the address that variable was at.&lt;br /&gt;
&lt;br /&gt;
===Installing the GDB===&lt;br /&gt;
Once the Overo COM has been connected to the local host, you should have access to the following command line:&lt;br /&gt;
&amp;lt;pre&amp;gt;root@overo:~#	&amp;lt;/pre&amp;gt;&lt;br /&gt;
Although you are working on your local host, this command line is for the remote system. It is the same as if you opened up Terminal (for Mac, Linux) or XTerm (for Windows). You now have access and control of the remote system.&lt;br /&gt;
&lt;br /&gt;
Now there are some packages that must be downloaded and installed onto the Overo so that it can run the GDB environment. To do this issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;opkg update	 	&amp;lt;enter&amp;gt;&lt;br /&gt;
opkg install gdb 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This should spew out a bunch of text such as:&lt;br /&gt;
&amp;lt;pre&amp;gt;Downloading http://www.angstrom...&amp;lt;/pre&amp;gt;&lt;br /&gt;
Just let it run and once its done, you’ll have the GNU GDB debugger installed on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
===Creating a C/C++ Program to Debug===&lt;br /&gt;
Now, your Overo COM has a debugger installed and ready to use. However, this does not mean you are ready to go. There are two more things required before it is possible to use a GDB debugger.&lt;br /&gt;
:* A C/C++ program&lt;br /&gt;
:* A SDK to run the program on&lt;br /&gt;
To see how to install a SDK and write/run a simple program in C/C++, see [[#Install a native C/C++ SDK]]. &lt;br /&gt;
&lt;br /&gt;
Once you have a program ready, you first must create an executable file. Lets use for example the C++ program HelloWorld.cpp. To create the executable file HelloWorld, issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;g++ -o HelloWorld HelloWorld.cpp 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now, to run the program:&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
To do the same thing with a C program (HelloWorld.c), issue the command&lt;br /&gt;
&amp;lt;pre&amp;gt;gcc -o HelloWorld HelloWorld.c		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What this command does is uses the GNU compiler (either g++ or gcc) and creates an executable object (HelloWorld) out of the C or C++ program file (either HelloWorld.cpp or HelloWorld.c). You may name the executable whatever you like, but it is considered best practice to name it the same thing as the program file.&lt;br /&gt;
&lt;br /&gt;
===Debugging the Program===&lt;br /&gt;
Now that you have GDB installed and a C/C++ program ready to go, its time to debug. To open to GDB environment, run the following command&lt;br /&gt;
&amp;lt;pre&amp;gt;gdb						&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Some text should spit out, and the following command line should appear&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that the debugger is running, it is time to tell the debugger what program we want to debug. To do this, first we need to declare our HelloWorld file as an executable file. For this run the following command	&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) exec-file HelloWorld		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that we have an executable file ready to be debugged, its time to run the program&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) run HelloWorld			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
The debugger will now run your program. If the program has no syntax or logic errors, the program should run and end with the line:&lt;br /&gt;
Program exited normally.&lt;br /&gt;
If there are errors, or the program crashed, it is possible to extract the exact details of that crash  by issuing the back trace command.&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) bt			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once you are done you can quit by issuing the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) quit			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A complete list of commands in GDB:&lt;br /&gt;
www.yolinux.com/TUTORIALS/GDB-Commands.html&lt;br /&gt;
&lt;br /&gt;
====GDB Debugger Tutorial====&lt;br /&gt;
For a complete GDB Debugger tutorial (very good tutorial, comes with sample code they walk you through and extra errors for you to debug yourself!):&lt;br /&gt;
http://www.cs.cmu.edu/~gilpin/tutorial/&lt;br /&gt;
&lt;br /&gt;
Now you have a debugger up and running! Play around with it by putting errors into your program on purpose to see the powers of having a remote debugger!&lt;br /&gt;
&lt;br /&gt;
==Use a C/C++ cross-compiler==&lt;br /&gt;
In order to do C/C++ development on our host machine, we need to add in a plugin to Eclipse. Also, we need to download an appropriate cross-compilation toolchain. For now, I recommend the lovely instructions from&lt;br /&gt;
&lt;br /&gt;
http://www.designarm.com/quickstart-guide/linux-software/eclipse.html &amp;amp;&lt;br /&gt;
&lt;br /&gt;
http://www.bugcommunity.com/wiki/index.php/BUG_Kernel_Development_with_Eclipse&lt;br /&gt;
&lt;br /&gt;
===Further Reading===&lt;br /&gt;
:* Tutorials built into Eclipse&lt;br /&gt;
:* Bitbake commander&lt;br /&gt;
:* OpenEmebedded|Poky docs + Bitbake docs&lt;br /&gt;
:* Eclipse Plugin Tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:How_to_-_eclipse]]&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4347</id>
		<title>Eclipse on Gumstix for new users</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4347"/>
				<updated>2010-07-28T16:22:19Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide provides step-by-step instructions for using the Eclipse Integrated Development Environment (IDE) to develop applications for the Gumstix COMs.&lt;br /&gt;
&lt;br /&gt;
We'll walk through these tasks:&lt;br /&gt;
:* setting up Eclipse&lt;br /&gt;
:* connection to your Gumstix system&lt;br /&gt;
:* creating a simple &amp;quot;Hello, World!&amp;quot; Python program&lt;br /&gt;
:* running a web server&lt;br /&gt;
:* installing new packages on your Gumstix&lt;br /&gt;
:* creating a small graphical Java application&lt;br /&gt;
:* remote debugging of your Java application&lt;br /&gt;
:* natively-compiling C/C++ code on your Gumstix&lt;br /&gt;
:* remote debugging C/C++ using the GDB server interface&lt;br /&gt;
&lt;br /&gt;
We will also explain how to set up a cross-compilation toolchain so you can develop C/C++ applications on your development computer and upload them to your Gumstix.&lt;br /&gt;
&lt;br /&gt;
Remember, Gumstix COMs are fully-fledged, albeit tiny, Linux systems so there are many tools we don't cover here.  For example, [http://wiki.openembedded.net/index.php/OpenEmbedded_Tools_for_Eclipse_(OTE) this document] explains how to use the powerful OpenEmbedded build system within Eclipse.&lt;br /&gt;
&lt;br /&gt;
Required Tools:&lt;br /&gt;
:* any Windows, Apple or Linux computer with a USB port&lt;br /&gt;
:* recent version of the Java Runtime Environment (available [http://java.sun.com/javase/downloads/index.jsp here])&lt;br /&gt;
:* a Gumstix COM running [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Downloading-pre-built-images/111.html up-to-date software]&lt;br /&gt;
:* any expansion board of the Gumstix Overo series, such as Chestnut or Tobi, that has both a USB console port and a 10/100 &lt;br /&gt;
:* Ethernet jack&lt;br /&gt;
:* a 5V power supply&lt;br /&gt;
:* an ethernet cable and internet connection&lt;br /&gt;
:* a mini-A to Standard-A USB cable&lt;br /&gt;
:* a [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Creating-a-bootable-microSD-card/111.html bootable microSD card] (only needed for native C/C++ compilation)&lt;br /&gt;
&lt;br /&gt;
Key Idea:&lt;br /&gt;
[[File:GumstixEclipse1.jpg|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Download Eclipse==&lt;br /&gt;
[http://www.eclipse.org/downloads/ Download] the Eclipse IDE for Java Developers for your Operating System: www.eclipse.org&lt;br /&gt;
&lt;br /&gt;
[[Image: GumstixEclipse2.jpg | thumb | left]]&lt;br /&gt;
&lt;br /&gt;
:* it is ''not'' necessary to install the Eclipse software; just double-click on the application once it has finished downloading&lt;br /&gt;
:* when prompted, choose a workspace folder in which you want to store your projects and your configuration information&lt;br /&gt;
:* then click through to the Eclipse workbench itself&lt;br /&gt;
&lt;br /&gt;
==Install Plugins==&lt;br /&gt;
For developers, a great variety of additional features can be added to Eclipse from various repositories of plug-ins known as ''Update Sites''.&lt;br /&gt;
To install a new plugin in Eclipse, first select the ''Update Site''.&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* select the Update Site for your version of Eclipse from the &amp;quot;Work with&amp;quot;dropdown menu&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse3.jpg]]&lt;br /&gt;
&lt;br /&gt;
:Note: If you are not sure which version of Eclipse you have, you can check by reopening Eclipse, it will be displayed on the loading screen.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If the update site is not available, you can add it by clicking the 'Add...' button on the right. For the Galileo release, you can use the URL http://dowload.eclipse.org/releases/galileo&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
As we are working with a remote system, we'll install the Remote System Explorer plugin.&lt;br /&gt;
:* search for the ''Remote System Explorer End-User Runtime'' plugin&lt;br /&gt;
:* select it for installation&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse4.jpg]]&lt;br /&gt;
&lt;br /&gt;
Still in Eclipse,&lt;br /&gt;
:* select &amp;quot;Next&amp;quot;.... twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
Once Eclipse has restarted, let's add two other useful plugins that allow connection to the console port of our Gumstix without needing a terminal emulator program such as kermit or TeraTerm.&lt;br /&gt;
From within Eclipse,&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software'''&lt;br /&gt;
:* search on &amp;quot;Target&amp;quot; to find the ''Target Manager Terminal''&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse5.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* select the ''Target Manager Terminal''&lt;br /&gt;
:* click &amp;quot;Next&amp;quot;&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
We'll also need to add a new update site by doing these steps in Eclipse:&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* click the &amp;quot;Add...&amp;quot; button&lt;br /&gt;
:* type ''http://rxtx.qbang.org/eclipse'' into the ''Location'' field and create a name&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse6.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* Click the &amp;quot;OK&amp;quot; button&lt;br /&gt;
Go into the sub-directory as shown below to select the ''RXTX End-User Runtime'' plugin that this site provides.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse7.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* click &amp;quot;Next&amp;quot; twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* click &amp;quot;OK&amp;quot; at the security warning window&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose the &amp;quot;Yes&amp;quot; button to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
==Connect Your Gumstix==&lt;br /&gt;
Now it is time to connect your Gumstix---let's get started by establishing a console connection.&lt;br /&gt;
:* mount your Gumstix COM down on to your expansion board&lt;br /&gt;
:* plug the mini-A USB plug into the port marked CONSOLE and end of the cable into a standard USB port on your computer&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Your computer should detect your Gumstix system when you first connect the USB cable, even though the power is not yet turned on. On Macintosh and Windows systems, a pop-up window should appear instructing you to download a new driver (do so) or notifying you that a USBserial device has been detected. If not, you can download drivers from [http://www.ftdichip.com/FTDrivers.htm this site]. Choose the &amp;quot;VCP&amp;quot; driver.&lt;br /&gt;
Once you have downloaded this driver, make sure to unplug and then replug the USB cable running from your computer to your Gumstix expansion board so the Gumstix will be recognized by your computer.&lt;br /&gt;
----&lt;br /&gt;
:* connect your Gumstix to the internet using an ethernet cable&lt;br /&gt;
    NOTE: You still have NOT plugged the power cable in to the &lt;br /&gt;
 Gumstix expansion board! This diagram shows the locations&lt;br /&gt;
    of the USB 'CONSOLE' port and the 'POWER' input port on a &lt;br /&gt;
 Summit board on which an Overo COM has been mounted.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse8.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* if you are booting from a microSD card, insert this card now until you hear it click in place.&lt;br /&gt;
Before applying power to the board, let's open up a connection to the console port.&lt;br /&gt;
In Eclipse,&lt;br /&gt;
:* navigate to '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;Terminal-&amp;gt;Terminal'''&lt;br /&gt;
:* click on the 'N' connection icon in the window that appears&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse9.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* make the connection using the following settings:&lt;br /&gt;
    Connection Type: Serial&lt;br /&gt;
    Port: &amp;lt;port to which your Gumstix is connected&amp;gt;&lt;br /&gt;
    Baud Rate: 115200&lt;br /&gt;
    Data Bits: 8&lt;br /&gt;
    Stop Bits: 1&lt;br /&gt;
    Parity: none&lt;br /&gt;
    Flow Control: none&lt;br /&gt;
    Timeout: 5&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
The port to which your Gumstix is connected will have a different name depending on your Host operating system.&lt;br /&gt;
:* On Windows, it should be ''USB-COM''&lt;br /&gt;
:* On Macintosh, it should be ''/dev/tty.usbserial-xxxxxxxx'' where ''xxxxxxxx'' is an arbitrary string of characters&lt;br /&gt;
:* On Linux, it should be ''/dev/ttyUSBx'' where ''x'' is a number.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse10.jpg]]&lt;br /&gt;
&lt;br /&gt;
*If this does not work, you can also get Console access to your Gumstix through a Terminal window. To do this, open up a Terminal window (Terminal for Mac users, XTerm or X11 for Windows users). The device will have the same name (USB-COM, /dev/cu..., /dev/tty.usb...).&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If you having a hard time find the device, you can search for it by doing a &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l /dev/tty.* (for Mac and Linux) &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l USB* (for Windows)&lt;br /&gt;
----&lt;br /&gt;
*Once you have found the device name, you can gain Console access with the screen command. If, for example, the device is /dev/tty.usb, issue the command:&lt;br /&gt;
 screen /dev/tty.usb 115200&lt;br /&gt;
*The 115200 on the end is important, it tells your computer the Baud Rate. If you do not enter 115200, you will not be able to read what the Remote System is outputting. Once you have issued this command, you will have Console access to your Overo via Terminal.&lt;br /&gt;
&lt;br /&gt;
*Now, it's time to apply power to the Gumstix expansion board so plug the 5V wall adapter into the power input jack on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
You should see text appear in this window; for now, just let the Gumstix boot. When prompted, you can log in to the root account. The default credentials are:&lt;br /&gt;
&lt;br /&gt;
'''Overo'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: &amp;lt;leave blank&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VerdexPro'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: gumstix&lt;br /&gt;
&lt;br /&gt;
==Write 'Hello, World' à la Python==&lt;br /&gt;
&lt;br /&gt;
You are going to write a basic Python program for the Gumstix directly on the Gumstix; this is known as native development. Also, Python is an interpreted language which means you can run your programs directly without any compilation.&lt;br /&gt;
&lt;br /&gt;
Once you have logged into your Gumstix, do these steps in the terminal window within Eclipse:&lt;br /&gt;
:* open an editor on the Gumstix by typing: 'nano hello.py'&lt;br /&gt;
:* type out this simple Python program: ''print &amp;quot;Hello, Gumstix!&amp;quot;''&lt;br /&gt;
:* press Ctrl+O, &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* then press Ctrl+X to save and exit.&lt;br /&gt;
:* run your program by typing: ''python hello.py''&lt;br /&gt;
:* check that you see the words &amp;quot;Hello, Gumstix!&amp;quot; appear&lt;br /&gt;
&lt;br /&gt;
If you see the words &amp;quot;Hello Gumstix&amp;quot;, then you have just written your first program on a Gumstix Overo computer.&lt;br /&gt;
&lt;br /&gt;
==Create a Web Site==&lt;br /&gt;
Each Gumstix comes with a built-in package manager called opkg. A package manager is a useful tool for installing software; you can install everything from media players to GPS mapping tools to the Firefox web browser. In this example, you'll use opkg tool to install a new application for your Gumstix: the Apache web server.&lt;br /&gt;
&lt;br /&gt;
To make your own Gumstix web site, type the following in the terminal window:&lt;br /&gt;
    opkg update 			&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install apache2		&amp;lt;Enter&amp;gt;&lt;br /&gt;
Before you start using Apache, which is now running, you'll need to find the IP address (internet address) of your Gumstix COM. To do this, type the following command into the terminal window:&lt;br /&gt;
    ifconfig | grep 'inet addr' 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
You should see something like this appear on your screen.&lt;br /&gt;
    inet addr: 10.0.1.73 Bcast: 192.168.0.255 Mask: 255.255.255.0&lt;br /&gt;
The IP address of your Gumstix is the first address shown: ''10.0.1.73'' in this case.&lt;br /&gt;
Now,&lt;br /&gt;
:* open up a web browser on your host computer&lt;br /&gt;
:* type that IP address of your Gumstix into the address bar&lt;br /&gt;
You should see something like this which is the default web site for Apache running on your Gumstix.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse11.jpg]]&lt;br /&gt;
&lt;br /&gt;
To make your web site say something more interesting, do the follow in your terminal window:&lt;br /&gt;
:* type: ''nano /usr/share/apache2/htdocs/index.html''&lt;br /&gt;
:* replace the words at the top of the screen &amp;quot;It Works&amp;quot; with the words &amp;quot;Gumstix Rocks!&amp;quot;&lt;br /&gt;
:* press 'Ctrl+O' &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* press 'Ctrl+X' to save and exit&lt;br /&gt;
:* refresh your web browser&lt;br /&gt;
&lt;br /&gt;
==Write a Java Application==&lt;br /&gt;
So far, you haven't actually used Eclipse other than as a console interface for your Gumstix. It is time to harness the power of Eclipse to write a small graphical Java application.&lt;br /&gt;
In Eclipse.&lt;br /&gt;
:* Navigate to '''File-&amp;gt; New-&amp;gt; Java Project''',&lt;br /&gt;
:* Name the project ''gumstix-java''&lt;br /&gt;
:* Select &amp;quot;Finish&amp;quot;&lt;br /&gt;
Once the project is created,&lt;br /&gt;
:* Select '''File-&amp;gt;New-&amp;gt;Class'''&lt;br /&gt;
:* Name your class ''Hello''&lt;br /&gt;
:* click &amp;quot;FINISH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add the following code to your class:&lt;br /&gt;
&lt;br /&gt;
    import javax.swing.JFrame;&lt;br /&gt;
    import javax.swing.JLabel;&lt;br /&gt;
    public class Hello {&lt;br /&gt;
    	public static void main(String [] args) {&lt;br /&gt;
    		JFrame frame = new JFrame(&amp;quot;hello&amp;quot;);&lt;br /&gt;
    		final JLabel label = new JLabel(&amp;quot;hello from Gumstix&amp;quot;);&lt;br /&gt;
    		frame.getContentPane().add(label);&lt;br /&gt;
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
    		frame.pack();&lt;br /&gt;
    		frame.setVisible(true);&lt;br /&gt;
    	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
You should get something that looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse12.jpg]]&lt;br /&gt;
&lt;br /&gt;
Press the green run button to test drive our application on our host machine.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Eclipse has many auto-completion features. Simply typing /:*&amp;lt;Enter&amp;gt; before a class creates a standard documentation block. Likewise, pressing &amp;lt;Ctrl&amp;gt;+&amp;lt;Space&amp;gt; provides context specific auto-completion options. Many other hints for speedy development are explained in the tutorials [http://www.eclipse.org/resources/?category=Getting%20Started here].&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Upload Code==&lt;br /&gt;
In Step 5 we discovered the IP address of our Gumstix. With this, we can connect to our Gumstix using the SSH protocol which allows us to rapidly transfer files. For this step, navigate to '''Window-&amp;gt;Open Perspective-&amp;gt;Other-&amp;gt;Remote System Explorer''' and click on the connection icon in the ''Remote Systems'' panel on the left. Select ''SSH without shells'' as the connection type and press Next. Put the internet address you found in Step 5 into the field marked ''Host Name'' and hit finish. To test that everything is working correctly, right-click on the terminal item list under your new connection and select ''Launch Terminal''. A console interface exactly like the USB console interface we set up in Step 3 should pop up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A 'Perspective' is an arrangement of windows and widgets, that is a specific view of the Eclipse workspace, designed for a particular task. If you wish to focus on any particular widget, double click the tab in Eclipse; return to the previous view by double-clicking again.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By installing the VNC viewer plugin, we can get a graphical interface to our Gumstix system. Do this by adding the ''Tools for mobile linux runtime'' plugin ('''Help-&amp;gt;Install New Software''') from the main update site. To use, select the VNC viewer widget from '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;VNC Category-&amp;gt;VNC''' and click on the ''New Connection'' icon in the VNC Viewer panel. Again, the ''Host'' is the internet address of your Gumstix board.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse13.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to upload our java code before we can run it. Switch back to the Java Perspective ('''Window-&amp;gt;Open Perspective-&amp;gt;Java''') and right-click on our Java file and selecting Export. Choose the option to export file to a remote file system and choose to upload your ''Hello.class'' file.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse14.jpg]]&lt;br /&gt;
&lt;br /&gt;
You will need to ''Browse'' to find your Gumstix board; you should upload this code to your home directory on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
==Debug a Java Application==&lt;br /&gt;
We can debug our java application remotely from Eclipse. To do this, we need a Java Virtual Machine capable of doing debugging. This time, the package we need isn't available in our package sources however we can fetch the package directly from a web site and install it using the same opkg package management tool.&lt;br /&gt;
    wget http://bugcommunity.com/downloads/files/phonemeadvanced- personal-debug_mr2-r1_armv6.ipk 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install -force-depends phoneme-advanced-personaldebug_mr2-r1_armv6.ipk &amp;lt;Enter&amp;gt;&lt;br /&gt;
Let's also update our Java libraries so we have access to the standard graphical libraries.&lt;br /&gt;
    opkg install classpath-gtk	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Next, let's start our Java code in debugging mode on the Overo:&lt;br /&gt;
    java-cdc -Xdebug -Xrunjwdp:transport=dHt_socket,server=y,suspend=y,address=1234 Hello	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Finally, let's connect to our debugging session by navigating in Eclipse to '''Run-&amp;gt;Debug Configurations''' and double-clicking on Remote Java Application to create a new configuration. Fill in the form as shown below using the internet address found in the previous step.&lt;br /&gt;
&lt;br /&gt;
==Install a native C/C++ SDK==&lt;br /&gt;
When we discussed Python and Java we noted that both are interpreted languages--- neither needs to be compiled. C and C++ code requires compilation which can be done natively---on the Gumstix itself---or on a development machine using a cross-compiler. To do native compilation, you need to install a compiler as well as any required libraries. You'll need to be booting from a microSD card as this installation takes approximately 75MB of space.&lt;br /&gt;
    $ echo 'src/gz angstrom-base http://www.angstromdistribution.org/feeds/unstable/ipk/glibc/armv7a/base'  &amp;gt; /etc/opkg/angstrom-base.conf&lt;br /&gt;
    $ opkg update&lt;br /&gt;
    $ opkg install task-native-sdk&lt;br /&gt;
Firstly, we are adding a new package repository to our package manager and updating our list of available packages before actually installing the complete package needed to do native development.&lt;br /&gt;
&lt;br /&gt;
Let's create either of the following files in Eclipse, upload the code and then compile on the Gumstix using our newly installed compiler.&lt;br /&gt;
&lt;br /&gt;
===C++: HelloWorld.cpp===&lt;br /&gt;
    #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
    using namespace std;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	cout &amp;lt;&amp;lt; &amp;quot;Gumstix runs on C++&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.cpp&lt;br /&gt;
    g++ -o hello hello.cpp	&amp;lt;enter&amp;gt;&lt;br /&gt;
    Gumstix runs on C++   	&amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===C: HelloWorld.c===&lt;br /&gt;
    #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	printf(&amp;quot;Gumstix runs on C\n&amp;quot;);&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.c&lt;br /&gt;
    gcc -o hello hello.c&lt;br /&gt;
    Gumstix runs on C&lt;br /&gt;
&lt;br /&gt;
&amp;lt;TODO: More exciting examples using on-board LEDs.&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using GDB as a remote debugger in C/C++==&lt;br /&gt;
These instructions will teach you how to download, install, and use the GDB debugger remotely on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;NOTE:	&lt;br /&gt;
remote system - a device that is being operated remotely (via SSH, USB Serial, etc). This means that it is a device that you are operating from a different system &lt;br /&gt;
(ie: if you are accessing the Overo COM via connection with your PC, then the Overo COM is a remote system).&lt;br /&gt;
For the purpose of this guide, the Overo COM will be the remote system.&lt;br /&gt;
&lt;br /&gt;
local host - the device that is being used to work on (ie: If you are working on your PC, that is the local host. If you then connect to another computer via VNC, &lt;br /&gt;
that is a remote system, and you laptop is still the localhost).&lt;br /&gt;
For the purpose of this guide, your Personal Computer will be the local host.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before starting, it is important to note there are many different ways to run a remote debugger. The most fundamental choice when debugging remotely is whether you want to:&lt;br /&gt;
:*Run the debugger on the remote system or&lt;br /&gt;
:*Run the debugger on the local host with a cross debugger on the remote system&lt;br /&gt;
&lt;br /&gt;
This guide will teach you how to download, install, and run the debugger on the remote system (choice A). If you wish to learn more about the cross debugger option, use Google. Also the wikipedia article on cross compilers (which operate in a very similar fashion) is very good, albeit a bit complicated. None of this is necessary in understanding the contents of this guide. &lt;br /&gt;
&lt;br /&gt;
For the purposes of this guide, we will be using the GDB: the GNU project debugger. As stated on their website:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it &lt;br /&gt;
crashed.&lt;br /&gt;
&lt;br /&gt;
GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:&lt;br /&gt;
- Start your program, specifying anything that might affect its behavior.&lt;br /&gt;
- Make your program stop on specified conditions.&lt;br /&gt;
- Examine what has happened, when your program has stopped.&lt;br /&gt;
- Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the reasons for using a debugger instead of trying to debug with the ‘brute force’ method of adding print statements throughout the entire program are enumerable, there are a few that stand out:&lt;br /&gt;
# The ability to ‘step’ through a program&lt;br /&gt;
#* The GDB debugger allows you to ‘step’ through a program. This means that instead of just executing the program and then leaving you with a final error message, it will execute one line at a time until the program crashes. This allows the user to see exactly where, and why, the program crashed. &lt;br /&gt;
# The ability to set breakpoints&lt;br /&gt;
#* The GDB debugger allows you to set breakpoints in the program. These are points where the CPU will stop executing the code and allow the user to decide whether to continue. This allows the user to explore what is ‘going on’ at certain points in the execution, something that otherwise is not possible. &lt;br /&gt;
# The ability to look at the Backtrace&lt;br /&gt;
#* This will show you where, and exactly why, your program crashed. Although SEGFAULT isn’t very useful, the backtrace will tell you what caused the SEGFAULT. Everything from what line, what variable, and even the address that variable was at.&lt;br /&gt;
&lt;br /&gt;
===Installing the GDB===&lt;br /&gt;
Once the Overo COM has been connected to the local host, you should have access to the following command line:&lt;br /&gt;
&amp;lt;pre&amp;gt;root@overo:~#	&amp;lt;/pre&amp;gt;&lt;br /&gt;
Although you are working on your local host, this command line is for the remote system. It is the same as if you opened up Terminal (for Mac, Linux) or XTerm (for Windows). You now have access and control of the remote system.&lt;br /&gt;
&lt;br /&gt;
Now there are some packages that must be downloaded and installed onto the Overo so that it can run the GDB environment. To do this issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;opkg update	 	&amp;lt;enter&amp;gt;&lt;br /&gt;
opkg install gdb 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This should spew out a bunch of text such as:&lt;br /&gt;
&amp;lt;pre&amp;gt;Downloading http://www.angstrom...&amp;lt;/pre&amp;gt;&lt;br /&gt;
Just let it run and once its done, you’ll have the GNU GDB debugger installed on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
===Creating a C/C++ Program to Debug===&lt;br /&gt;
Now, your Overo COM has a debugger installed and ready to use. However, this does not mean you are ready to go. There are two more things required before it is possible to use a GDB debugger.&lt;br /&gt;
:* A C/C++ program&lt;br /&gt;
:* A SDK to run the program on&lt;br /&gt;
To see how to install a SDK and write/run a simple program in C/C++, see [[#Install a native C/C++ SDK]]. &lt;br /&gt;
&lt;br /&gt;
Once you have a program ready, you first must create an executable file. Lets use for example the C++ program HelloWorld.cpp. To create the executable file HelloWorld, issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;g++ -o HelloWorld HelloWorld.cpp 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now, to run the program:&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
To do the same thing with a C program (HelloWorld.c), issue the command&lt;br /&gt;
&amp;lt;pre&amp;gt;gcc -o HelloWorld HelloWorld.c		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What this command does is uses the GNU compiler (either g++ or gcc) and creates an executable object (HelloWorld) out of the C or C++ program file (either HelloWorld.cpp or HelloWorld.c). You may name the executable whatever you like, but it is considered best practice to name it the same thing as the program file.&lt;br /&gt;
&lt;br /&gt;
===Debugging the Program===&lt;br /&gt;
Now that you have GDB installed and a C/C++ program ready to go, its time to debug. To open to GDB environment, run the following command&lt;br /&gt;
&amp;lt;pre&amp;gt;gdb						&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Some text should spit out, and the following command line should appear&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that the debugger is running, it is time to tell the debugger what program we want to debug. To do this, first we need to declare our HelloWorld file as an executable file. For this run the following command	&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) exec-file HelloWorld		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that we have an executable file ready to be debugged, its time to run the program&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) run HelloWorld			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
The debugger will now run your program. If the program has no syntax or logic errors, the program should run and end with the line:&lt;br /&gt;
Program exited normally.&lt;br /&gt;
If there are errors, or the program crashed, it is possible to extract the exact details of that crash  by issuing the back trace command.&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) bt			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once you are done you can quit by issuing the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) quit			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A complete list of commands in GDB:&lt;br /&gt;
www.yolinux.com/TUTORIALS/GDB-Commands.html&lt;br /&gt;
&lt;br /&gt;
====GDB Debugger Tutorial====&lt;br /&gt;
For a complete GDB Debugger tutorial (very good tutorial, comes with sample code they walk you through and extra errors for you to debug yourself!):&lt;br /&gt;
http://www.cs.cmu.edu/~gilpin/tutorial/&lt;br /&gt;
&lt;br /&gt;
Now you have a debugger up and running! Play around with it by putting errors into your program on purpose to see the powers of having a remote debugger!&lt;br /&gt;
&lt;br /&gt;
==Use a C/C++ cross-compiler==&lt;br /&gt;
In order to do C/C++ development on our host machine, we need to add in a plugin to Eclipse. Also, we need to download an appropriate cross-compilation toolchain. For now, I recommend the lovely instructions from&lt;br /&gt;
&lt;br /&gt;
http://www.designarm.com/quickstart-guide/linux-software/eclipse.html &amp;amp;&lt;br /&gt;
&lt;br /&gt;
http://www.bugcommunity.com/wiki/index.php/BUG_Kernel_Development_with_Eclipse&lt;br /&gt;
&lt;br /&gt;
===Further Reading===&lt;br /&gt;
:* Tutorials built into Eclipse&lt;br /&gt;
:* Bitbake commander&lt;br /&gt;
:* OpenEmebedded|Poky docs + Bitbake docs&lt;br /&gt;
:* Eclipse Plugin Tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:How_to_-_eclipse]]&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4346</id>
		<title>Eclipse on Gumstix for new users</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Eclipse_on_Gumstix_for_new_users&amp;diff=4346"/>
				<updated>2010-07-28T16:08:29Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide provides step-by-step instructions for using the Eclipse Integrated Development Environment (IDE) to develop applications for the Gumstix COMs.&lt;br /&gt;
&lt;br /&gt;
We'll walk through these tasks:&lt;br /&gt;
:* setting up Eclipse&lt;br /&gt;
:* connection to your Gumstix system&lt;br /&gt;
:* creating a simple &amp;quot;Hello, World!&amp;quot; Python program&lt;br /&gt;
:* running a web server&lt;br /&gt;
:* installing new packages on your Gumstix&lt;br /&gt;
:* creating a small graphical Java application&lt;br /&gt;
:* remote debugging of your Java application&lt;br /&gt;
:* natively-compiling C/C++ code on your Gumstix&lt;br /&gt;
:* remote debugging C/C++ using the GDB server interface&lt;br /&gt;
&lt;br /&gt;
We will also explain how to set up a cross-compilation toolchain so you can develop C/C++ applications on your development computer and upload them to your Gumstix.&lt;br /&gt;
&lt;br /&gt;
Remember, Gumstix COMs are fully-fledged, albeit tiny, Linux systems so there are many tools we don't cover here.  For example, [http://wiki.openembedded.net/index.php/OpenEmbedded_Tools_for_Eclipse_(OTE) this document] explains how to use the powerful OpenEmbedded build system within Eclipse.&lt;br /&gt;
&lt;br /&gt;
Required Tools:&lt;br /&gt;
:* any Windows, Apple or Linux computer with a USB port&lt;br /&gt;
:* recent version of the Java Runtime Environment (available [http://java.sun.com/javase/downloads/index.jsp here])&lt;br /&gt;
:* a Gumstix COM running [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Downloading-pre-built-images/111.html up-to-date software]&lt;br /&gt;
:* any expansion board of the Gumstix Overo series, such as Chestnut or Tobi, that has both a USB console port and a 10/100 &lt;br /&gt;
:* Ethernet jack&lt;br /&gt;
:* a 5V power supply&lt;br /&gt;
:* an ethernet cable and internet connection&lt;br /&gt;
:* a mini-A to Standard-A USB cable&lt;br /&gt;
:* a [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Creating-a-bootable-microSD-card/111.html bootable microSD card] (only needed for native C/C++ compilation)&lt;br /&gt;
&lt;br /&gt;
Key Idea:&lt;br /&gt;
[[File:GumstixEclipse1.jpg|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Download Eclipse==&lt;br /&gt;
[http://www.eclipse.org/downloads/ Download] the Eclipse IDE for Java Developers for your Operating System: www.eclipse.org&lt;br /&gt;
&lt;br /&gt;
[[Image: GumstixEclipse2.jpg | thumb | left]]&lt;br /&gt;
&lt;br /&gt;
:* it is ''not'' necessary to install the Eclipse software; just double-click on the application once it has finished downloading&lt;br /&gt;
:* when prompted, choose a workspace folder in which you want to store your projects and your configuration information&lt;br /&gt;
:* then click through to the Eclipse workbench itself&lt;br /&gt;
&lt;br /&gt;
==Install Plugins==&lt;br /&gt;
For developers, a great variety of additional features can be added to Eclipse from various repositories of plug-ins known as ''Update Sites''.&lt;br /&gt;
To install a new plugin in Eclipse, first select the ''Update Site''.&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* select the Update Site for your version of Eclipse from the &amp;quot;Work with&amp;quot;dropdown menu&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse3.jpg]]&lt;br /&gt;
&lt;br /&gt;
:Note: If you are not sure which version of Eclipse you have, you can check by reopening Eclipse, it will be displayed on the loading screen.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If the update site is not available, you can add it by clicking the 'Add...' button on the right. For the Galileo release, you can use the URL http://dowload.eclipse.org/releases/galileo&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
As we are working with a remote system, we'll install the Remote System Explorer plugin.&lt;br /&gt;
:* search for the ''Remote System Explorer End-User Runtime'' plugin&lt;br /&gt;
:* select it for installation&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse4.jpg]]&lt;br /&gt;
&lt;br /&gt;
Still in Eclipse,&lt;br /&gt;
:* select &amp;quot;Next&amp;quot;.... twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
Once Eclipse has restarted, let's add two other useful plugins that allow connection to the console port of our Gumstix without needing a terminal emulator program such as kermit or TeraTerm.&lt;br /&gt;
From within Eclipse,&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software'''&lt;br /&gt;
:* search on &amp;quot;Target&amp;quot; to find the ''Target Manager Terminal''&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse5.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* select the ''Target Manager Terminal''&lt;br /&gt;
:* click &amp;quot;Next&amp;quot;&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose &amp;quot;Yes&amp;quot; to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
We'll also need to add a new update site by doing these steps in Eclipse:&lt;br /&gt;
:* navigate to '''Help-&amp;gt;Install New Software...'''&lt;br /&gt;
:* click the &amp;quot;Add...&amp;quot; button&lt;br /&gt;
:* type ''http://rxtx.qbang.org/eclipse'' into the ''Location'' field and create a name&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse6.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* Click the &amp;quot;OK&amp;quot; button&lt;br /&gt;
Go into the sub-directory as shown below to select the ''RXTX End-User Runtime'' plugin that this site provides.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse7.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* click &amp;quot;Next&amp;quot; twice&lt;br /&gt;
:* select the radio button to &amp;quot;ACCEPT&amp;quot; the terms of the license agreement&lt;br /&gt;
:* click &amp;quot;OK&amp;quot; at the security warning window&lt;br /&gt;
:* click &amp;quot;Finish&amp;quot; to complete installation&lt;br /&gt;
:* choose the &amp;quot;Yes&amp;quot; button to restart Eclipse for the changes to take effect&lt;br /&gt;
&lt;br /&gt;
==Connect Your Gumstix==&lt;br /&gt;
Now it is time to connect your Gumstix---let's get started by establishing a console connection.&lt;br /&gt;
:* mount your Gumstix COM down on to your expansion board&lt;br /&gt;
:* plug the mini-A USB plug into the port marked CONSOLE and end of the cable into a standard USB port on your computer&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Your computer should detect your Gumstix system when you first connect the USB cable, even though the power is not yet turned on. On Macintosh and Windows systems, a pop-up window should appear instructing you to download a new driver (do so) or notifying you that a USBserial device has been detected. If not, you can download drivers from [http://www.ftdichip.com/FTDrivers.htm this site]. Choose the &amp;quot;VCP&amp;quot; driver.&lt;br /&gt;
Once you have downloaded this driver, make sure to unplug and then replug the USB cable running from your computer to your Gumstix expansion board so the Gumstix will be recognized by your computer.&lt;br /&gt;
----&lt;br /&gt;
:* connect your Gumstix to the internet using an ethernet cable&lt;br /&gt;
    NOTE: You still have NOT plugged the power cable in to the Gumstix expansion board! This diagram shows the locations&lt;br /&gt;
    of the USB 'CONSOLE' port and the 'POWER' input port on a Summit board on which an Overo COM has been mounted.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse8.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* if you are booting from a microSD card, insert this card now until you hear it click in place.&lt;br /&gt;
Before applying power to the board, let's open up a connection to the console port.&lt;br /&gt;
In Eclipse,&lt;br /&gt;
:* navigate to '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;Terminal-&amp;gt;Terminal'''&lt;br /&gt;
:* click on the 'N' connection icon in the window that appears&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse9.jpg]]&lt;br /&gt;
&lt;br /&gt;
:* make the connection using the following settings:&lt;br /&gt;
    Connection Type: Serial&lt;br /&gt;
    Port: &amp;lt;port to which your Gumstix is connected&amp;gt;&lt;br /&gt;
    Baud Rate: 115200&lt;br /&gt;
    Data Bits: 8&lt;br /&gt;
    Stop Bits: 1&lt;br /&gt;
    Parity: none&lt;br /&gt;
    Flow Control: none&lt;br /&gt;
    Timeout: 5&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
The port to which your Gumstix is connected will have a different name depending on your Host operating system.&lt;br /&gt;
:* On Windows, it should be ''USB-COM''&lt;br /&gt;
:* On Macintosh, it should be ''/dev/tty.usbserial-xxxxxxxx'' where ''xxxxxxxx'' is an arbitrary string of characters&lt;br /&gt;
:* On Linux, it should be ''/dev/ttyUSBx'' where ''x'' is a number.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse10.jpg]]&lt;br /&gt;
&lt;br /&gt;
*If this does not work, you can also get Console access to your Gumstix through a Terminal window. To do this, open up a Terminal window (Terminal for Mac users, XTerm or X11 for Windows users). The device will have the same name (USB-COM, /dev/cu..., /dev/tty.usb...).&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
If you having a hard time find the device, you can search for it by doing a &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l /dev/tty.* (for Mac and Linux) &amp;lt;br&amp;gt;&lt;br /&gt;
:*ls -l USB* (for Windows)&lt;br /&gt;
----&lt;br /&gt;
*Once you have found the device name, you can gain Console access with the screen command. If, for example, the device is /dev/tty.usb, issue the command:&lt;br /&gt;
 screen /dev/tty.usb 115200&lt;br /&gt;
*The 115200 on the end is important, it tells your computer the Baud Rate. If you do not enter 115200, you will not be able to read what the Remote System is outputting. Once you have issued this command, you will have Console access to your Overo via Terminal.&lt;br /&gt;
&lt;br /&gt;
*Now, it's time to apply power to the Gumstix expansion board so plug the 5V wall adapter into the power input jack on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
You should see text appear in this window; for now, just let the Gumstix boot. When prompted, you can log in to the root account. The default credentials are:&lt;br /&gt;
&lt;br /&gt;
'''Overo'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: &amp;lt;leave blank&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''VerdexPro'''&lt;br /&gt;
&lt;br /&gt;
username: root&lt;br /&gt;
&lt;br /&gt;
password: gumstix&lt;br /&gt;
&lt;br /&gt;
==Write 'Hello, World' à la Python==&lt;br /&gt;
&lt;br /&gt;
You are going to write a basic Python program for the Gumstix directly on the Gumstix; this is known as native development. Also, Python is an interpreted language which means you can run your programs directly without any compilation.&lt;br /&gt;
&lt;br /&gt;
Once you have logged into your Gumstix, do these steps in the terminal window within Eclipse:&lt;br /&gt;
:* open an editor on the Gumstix by typing: 'nano hello.py'&lt;br /&gt;
:* type out this simple Python program: ''print &amp;quot;Hello, Gumstix!&amp;quot;''&lt;br /&gt;
:* press Ctrl+O, &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* then press Ctrl+X to save and exit.&lt;br /&gt;
:* run your program by typing: ''python hello.py''&lt;br /&gt;
:* check that you see the words &amp;quot;Hello, Gumstix!&amp;quot; appear&lt;br /&gt;
&lt;br /&gt;
If you see the words &amp;quot;Hello Gumstix&amp;quot;, then you have just written your first program on a Gumstix Overo computer.&lt;br /&gt;
&lt;br /&gt;
==Create a Web Site==&lt;br /&gt;
Each Gumstix comes with a built-in package manager called opkg. A package manager is a useful tool for installing software; you can install everything from media players to GPS mapping tools to the Firefox web browser. In this example, you'll use opkg tool to install a new application for your Gumstix: the Apache web server.&lt;br /&gt;
&lt;br /&gt;
To make your own Gumstix web site, type the following in the terminal window:&lt;br /&gt;
    opkg update 			&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install apache2		&amp;lt;Enter&amp;gt;&lt;br /&gt;
Before you start using Apache, which is now running, you'll need to find the IP address (internet address) of your Gumstix COM. To do this, type the following command into the terminal window:&lt;br /&gt;
    ifconfig | grep 'inet addr' 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
You should see something like this appear on your screen.&lt;br /&gt;
    inet addr: 10.0.1.73 Bcast: 192.168.0.255 Mask: 255.255.255.0&lt;br /&gt;
The IP address of your Gumstix is the first address shown: ''10.0.1.73'' in this case.&lt;br /&gt;
Now,&lt;br /&gt;
:* open up a web browser on your host computer&lt;br /&gt;
:* type that IP address of your Gumstix into the address bar&lt;br /&gt;
You should see something like this which is the default web site for Apache running on your Gumstix.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse11.jpg]]&lt;br /&gt;
&lt;br /&gt;
To make your web site say something more interesting, do the follow in your terminal window:&lt;br /&gt;
:* type: ''nano /usr/share/apache2/htdocs/index.html''&lt;br /&gt;
:* replace the words at the top of the screen &amp;quot;It Works&amp;quot; with the words &amp;quot;Gumstix Rocks!&amp;quot;&lt;br /&gt;
:* press 'Ctrl+O' &amp;lt;Enter&amp;gt;&lt;br /&gt;
:* press 'Ctrl+X' to save and exit&lt;br /&gt;
:* refresh your web browser&lt;br /&gt;
&lt;br /&gt;
==Write a Java Application==&lt;br /&gt;
So far, you haven't actually used Eclipse other than as a console interface for your Gumstix. It is time to harness the power of Eclipse to write a small graphical Java application.&lt;br /&gt;
In Eclipse.&lt;br /&gt;
:* Navigate to '''File-&amp;gt; New-&amp;gt; Java Project''',&lt;br /&gt;
:* Name the project ''gumstix-java''&lt;br /&gt;
:* Select &amp;quot;Finish&amp;quot;&lt;br /&gt;
Once the project is created,&lt;br /&gt;
:* Select '''File-&amp;gt;New-&amp;gt;Class'''&lt;br /&gt;
:* Name your class ''Hello''&lt;br /&gt;
:* click &amp;quot;FINISH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add the following code to your class:&lt;br /&gt;
&lt;br /&gt;
    import javax.swing.JFrame;&lt;br /&gt;
    import javax.swing.JLabel;&lt;br /&gt;
    public class Hello {&lt;br /&gt;
    	public static void main(String [] args) {&lt;br /&gt;
    		JFrame frame = new JFrame(&amp;quot;hello&amp;quot;);&lt;br /&gt;
    		final JLabel label = new JLabel(&amp;quot;hello from Gumstix&amp;quot;);&lt;br /&gt;
    		frame.getContentPane().add(label);&lt;br /&gt;
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);&lt;br /&gt;
    		frame.pack();&lt;br /&gt;
    		frame.setVisible(true);&lt;br /&gt;
    	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
You should get something that looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse12.jpg]]&lt;br /&gt;
&lt;br /&gt;
Press the green run button to test drive our application on our host machine.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
Eclipse has many auto-completion features. Simply typing /:*&amp;lt;Enter&amp;gt; before a class creates a standard documentation block. Likewise, pressing &amp;lt;Ctrl&amp;gt;+&amp;lt;Space&amp;gt; provides context specific auto-completion options. Many other hints for speedy development are explained in the tutorials [http://www.eclipse.org/resources/?category=Getting%20Started here].&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==Upload Code==&lt;br /&gt;
In Step 5 we discovered the IP address of our Gumstix. With this, we can connect to our Gumstix using the SSH protocol which allows us to rapidly transfer files. For this step, navigate to '''Window-&amp;gt;Open Perspective-&amp;gt;Other-&amp;gt;Remote System Explorer''' and click on the connection icon in the ''Remote Systems'' panel on the left. Select ''SSH without shells'' as the connection type and press Next. Put the internet address you found in Step 5 into the field marked ''Host Name'' and hit finish. To test that everything is working correctly, right-click on the terminal item list under your new connection and select ''Launch Terminal''. A console interface exactly like the USB console interface we set up in Step 3 should pop up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Hint:&lt;br /&gt;
A 'Perspective' is an arrangement of windows and widgets, that is a specific view of the Eclipse workspace, designed for a particular task. If you wish to focus on any particular widget, double click the tab in Eclipse; return to the previous view by double-clicking again.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By installing the VNC viewer plugin, we can get a graphical interface to our Gumstix system. Do this by adding the ''Tools for mobile linux runtime'' plugin ('''Help-&amp;gt;Install New Software''') from the main update site. To use, select the VNC viewer widget from '''Window-&amp;gt;Show View-&amp;gt;Other-&amp;gt;VNC Category-&amp;gt;VNC''' and click on the ''New Connection'' icon in the VNC Viewer panel. Again, the ''Host'' is the internet address of your Gumstix board.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse13.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to upload our java code before we can run it. Switch back to the Java Perspective ('''Window-&amp;gt;Open Perspective-&amp;gt;Java''') and right-click on our Java file and selecting Export. Choose the option to export file to a remote file system and choose to upload your ''Hello.class'' file.&lt;br /&gt;
&lt;br /&gt;
[[File:GumstixEclipse14.jpg]]&lt;br /&gt;
&lt;br /&gt;
You will need to ''Browse'' to find your Gumstix board; you should upload this code to your home directory on the Gumstix.&lt;br /&gt;
&lt;br /&gt;
==Debug a Java Application==&lt;br /&gt;
We can debug our java application remotely from Eclipse. To do this, we need a Java Virtual Machine capable of doing debugging. This time, the package we need isn't available in our package sources however we can fetch the package directly from a web site and install it using the same opkg package management tool.&lt;br /&gt;
    wget http://bugcommunity.com/downloads/files/phonemeadvanced- personal-debug_mr2-r1_armv6.ipk 	&amp;lt;Enter&amp;gt;&lt;br /&gt;
    opkg install -force-depends phoneme-advanced-personaldebug_mr2-r1_armv6.ipk &amp;lt;Enter&amp;gt;&lt;br /&gt;
Let's also update our Java libraries so we have access to the standard graphical libraries.&lt;br /&gt;
    opkg install classpath-gtk	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Next, let's start our Java code in debugging mode on the Overo:&lt;br /&gt;
    java-cdc -Xdebug -Xrunjwdp:transport=dHt_socket,server=y,suspend=y,address=1234 Hello	&amp;lt;Enter&amp;gt;&lt;br /&gt;
Finally, let's connect to our debugging session by navigating in Eclipse to '''Run-&amp;gt;Debug Configurations''' and double-clicking on Remote Java Application to create a new configuration. Fill in the form as shown below using the internet address found in the previous step.&lt;br /&gt;
&lt;br /&gt;
==Install a native C/C++ SDK==&lt;br /&gt;
When we discussed Python and Java we noted that both are interpreted languages--- neither needs to be compiled. C and C++ code requires compilation which can be done natively---on the Gumstix itself---or on a development machine using a cross-compiler. To do native compilation, you need to install a compiler as well as any required libraries. You'll need to be booting from a microSD card as this installation takes approximately 75MB of space.&lt;br /&gt;
    $ echo 'src/gz angstrom-base http://www.angstromdistribution.org/feeds/unstable/ipk/glibc/armv7a/base'  &amp;gt; /etc/opkg/angstrom-base.conf&lt;br /&gt;
    $ opkg update&lt;br /&gt;
    $ opkg install task-native-sdk&lt;br /&gt;
Firstly, we are adding a new package repository to our package manager and updating our list of available packages before actually installing the complete package needed to do native development.&lt;br /&gt;
&lt;br /&gt;
Let's create either of the following files in Eclipse, upload the code and then compile on the Gumstix using our newly installed compiler.&lt;br /&gt;
&lt;br /&gt;
===C++: HelloWorld.cpp===&lt;br /&gt;
    #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
    using namespace std;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	cout &amp;lt;&amp;lt; &amp;quot;Gumstix runs on C++&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.cpp&lt;br /&gt;
    g++ -o hello hello.cpp	&amp;lt;enter&amp;gt;&lt;br /&gt;
    Gumstix runs on C++   	&amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===C: HelloWorld.c===&lt;br /&gt;
    #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
    int main () {&lt;br /&gt;
    	printf(&amp;quot;Gumstix runs on C\n&amp;quot;);&lt;br /&gt;
    	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Save the file and issue the following commands to compile and run HelloWorld.c&lt;br /&gt;
    gcc -o hello hello.c&lt;br /&gt;
    Gumstix runs on C&lt;br /&gt;
&lt;br /&gt;
&amp;lt;TODO: More exciting examples using on-board LEDs.&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using GDB as a remote debugger in C/C++==&lt;br /&gt;
These instructions will teach you how to download, install, and use the GDB debugger remotely on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;NOTE:	&lt;br /&gt;
remote system - a device that is being operated remotely (via SSH, USB Serial, etc). This means that it is a device that you are operating from a different system &lt;br /&gt;
(ie: if you are accessing the Overo COM via connection with your PC, then the Overo COM is a remote system).&lt;br /&gt;
For the purpose of this guide, the Overo COM will be the remote system.&lt;br /&gt;
&lt;br /&gt;
local host - the device that is being used to work on (ie: If you are working on your PC, that is the local host. If you then connect to another computer via VNC, &lt;br /&gt;
that is a remote system, and you laptop is still the localhost).&lt;br /&gt;
For the purpose of this guide, your Personal Computer will be the local host.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before starting, it is important to note there are many different ways to run a remote debugger. The most fundamental choice when debugging remotely is whether you want to:&lt;br /&gt;
:*Run the debugger on the remote system or&lt;br /&gt;
:*Run the debugger on the local host with a cross debugger on the remote system&lt;br /&gt;
&lt;br /&gt;
This guide will teach you how to download, install, and run the debugger on the remote system (choice A). If you wish to learn more about the cross debugger option, use Google. Also the wikipedia article on cross compilers (which operate in a very similar fashion) is very good, albeit a bit complicated. None of this is necessary in understanding the contents of this guide. &lt;br /&gt;
&lt;br /&gt;
For the purposes of this guide, we will be using the GDB: the GNU project debugger. As stated on their website:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it &lt;br /&gt;
crashed.&lt;br /&gt;
&lt;br /&gt;
GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:&lt;br /&gt;
- Start your program, specifying anything that might affect its behavior.&lt;br /&gt;
- Make your program stop on specified conditions.&lt;br /&gt;
- Examine what has happened, when your program has stopped.&lt;br /&gt;
- Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the reasons for using a debugger instead of trying to debug with the ‘brute force’ method of adding print statements throughout the entire program are enumerable, there are a few that stand out:&lt;br /&gt;
# The ability to ‘step’ through a program&lt;br /&gt;
#* The GDB debugger allows you to ‘step’ through a program. This means that instead of just executing the program and then leaving you with a final error message, it will execute one line at a time until the program crashes. This allows the user to see exactly where, and why, the program crashed. &lt;br /&gt;
# The ability to set breakpoints&lt;br /&gt;
#* The GDB debugger allows you to set breakpoints in the program. These are points where the CPU will stop executing the code and allow the user to decide whether to continue. This allows the user to explore what is ‘going on’ at certain points in the execution, something that otherwise is not possible. &lt;br /&gt;
# The ability to look at the Backtrace&lt;br /&gt;
#* This will show you where, and exactly why, your program crashed. Although SEGFAULT isn’t very useful, the backtrace will tell you what caused the SEGFAULT. Everything from what line, what variable, and even the address that variable was at.&lt;br /&gt;
&lt;br /&gt;
===Installing the GDB===&lt;br /&gt;
Once the Overo COM has been connected to the local host, you should have access to the following command line:&lt;br /&gt;
&amp;lt;pre&amp;gt;root@overo:~#	&amp;lt;/pre&amp;gt;&lt;br /&gt;
Although you are working on your local host, this command line is for the remote system. It is the same as if you opened up Terminal (for Mac, Linux) or XTerm (for Windows). You now have access and control of the remote system.&lt;br /&gt;
&lt;br /&gt;
Now there are some packages that must be downloaded and installed onto the Overo so that it can run the GDB environment. To do this issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;opkg update	 	&amp;lt;enter&amp;gt;&lt;br /&gt;
opkg install gdb 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
This should spew out a bunch of text such as:&lt;br /&gt;
&amp;lt;pre&amp;gt;Downloading http://www.angstrom...&amp;lt;/pre&amp;gt;&lt;br /&gt;
Just let it run and once its done, you’ll have the GNU GDB debugger installed on your Overo COM.&lt;br /&gt;
&lt;br /&gt;
===Creating a C/C++ Program to Debug===&lt;br /&gt;
Now, your Overo COM has a debugger installed and ready to use. However, this does not mean you are ready to go. There are two more things required before it is possible to use a GDB debugger.&lt;br /&gt;
:* A C/C++ program&lt;br /&gt;
:* A SDK to run the program on&lt;br /&gt;
To see how to install a SDK and write/run a simple program in C/C++, see [[#Install a native C/C++ SDK]]. &lt;br /&gt;
&lt;br /&gt;
Once you have a program ready, you first must create an executable file. Lets use for example the C++ program HelloWorld.cpp. To create the executable file HelloWorld, issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;g++ -o HelloWorld HelloWorld.cpp 	&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now, to run the program:&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
To do the same thing with a C program (HelloWorld.c), issue the command&lt;br /&gt;
&amp;lt;pre&amp;gt;gcc -o HelloWorld HelloWorld.c		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./HelloWorld				&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What this command does is uses the GNU compiler (either g++ or gcc) and creates an executable object (HelloWorld) out of the C or C++ program file (either HelloWorld.cpp or HelloWorld.c). You may name the executable whatever you like, but it is considered best practice to name it the same thing as the program file.&lt;br /&gt;
&lt;br /&gt;
===Debugging the Program===&lt;br /&gt;
Now that you have GDB installed and a C/C++ program ready to go, its time to debug. To open to GDB environment, run the following command&lt;br /&gt;
&amp;lt;pre&amp;gt;gdb						&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Some text should spit out, and the following command line should appear&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb)&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that the debugger is running, it is time to tell the debugger what program we want to debug. To do this, first we need to declare our HelloWorld file as an executable file. For this run the following command	&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) exec-file HelloWorld		&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now that we have an executable file ready to be debugged, its time to run the program&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) run HelloWorld			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
The debugger will now run your program. If the program has no syntax or logic errors, the program should run and end with the line:&lt;br /&gt;
Program exited normally.&lt;br /&gt;
If there are errors, or the program crashed, it is possible to extract the exact details of that crash  by issuing the back trace command.&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) bt			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once you are done you can quit by issuing the command:&lt;br /&gt;
&amp;lt;pre&amp;gt;(gdb) quit			&amp;lt;enter&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A complete list of commands in GDB:&lt;br /&gt;
www.yolinux.com/TUTORIALS/GDB-Commands.html&lt;br /&gt;
&lt;br /&gt;
====GDB Debugger Tutorial====&lt;br /&gt;
For a complete GDB Debugger tutorial (very good tutorial, comes with sample code they walk you through and extra errors for you to debug yourself!):&lt;br /&gt;
http://www.cs.cmu.edu/~gilpin/tutorial/&lt;br /&gt;
&lt;br /&gt;
Now you have a debugger up and running! Play around with it by putting errors into your program on purpose to see the powers of having a remote debugger!&lt;br /&gt;
&lt;br /&gt;
==Use a C/C++ cross-compiler==&lt;br /&gt;
In order to do C/C++ development on our host machine, we need to add in a plugin to Eclipse. Also, we need to download an appropriate cross-compilation toolchain. For now, I recommend the lovely instructions from&lt;br /&gt;
&lt;br /&gt;
http://www.designarm.com/quickstart-guide/linux-software/eclipse.html &amp;amp;&lt;br /&gt;
&lt;br /&gt;
http://www.bugcommunity.com/wiki/index.php/BUG_Kernel_Development_with_Eclipse&lt;br /&gt;
&lt;br /&gt;
===Further Reading===&lt;br /&gt;
:* Tutorials built into Eclipse&lt;br /&gt;
:* Bitbake commander&lt;br /&gt;
:* OpenEmebedded|Poky docs + Bitbake docs&lt;br /&gt;
:* Eclipse Plugin Tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:How_to_-_eclipse]]&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4333</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4333"/>
				<updated>2010-07-27T21:36:44Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will go over how to perform a basic debugging with GDB.&lt;br /&gt;
:We will complete these tasks step by step&lt;br /&gt;
:*Installing the GDB debugger&lt;br /&gt;
:*Running the debugger&lt;br /&gt;
:*Learning how to set Breakpoints&lt;br /&gt;
:*Learning how to navigate the code in your program&lt;br /&gt;
:*Learning how to diagnose and error and how to fix it&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''NOTE:''' Before you continue make sure you have GDB installed. To install GDB complete the tasks below&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# opkg update	 	&amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# opkg install gdb 	&amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Download the test program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]'''&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in! (around line #30)&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
:::The 3rd line in this section of code will drop down one line in your terminal, and look something like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
:::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2. Compile the program and execute the program.'''&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:note: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger'''&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43'''&lt;br /&gt;
(if GDB is not your command line do as follows)&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''5. Now, we start to run the program in the debugger.'''&lt;br /&gt;
&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function'''&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.'''&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
     &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: &amp;quot;step&amp;quot; lets you get a closer look at each function and line, while &amp;quot;next&amp;quot; skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''9. Where are we?'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''10. Watching changes We can go through the program (using the next command) and examine the values using the print command.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
    &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
     &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:::::This tutorial was based from http://cs.baylor.edu/~donahoo/tools/gdb/tutorial.html&lt;br /&gt;
::::::If you have any questions please visit their site&lt;br /&gt;
== [[Headline text]] ==&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4332</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4332"/>
				<updated>2010-07-27T21:35:57Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will go over how to perform a basic debugging with GDB.&lt;br /&gt;
:We will complete these tasks step by step&lt;br /&gt;
:*Installing the GDB debugger&lt;br /&gt;
:*Running the debugger&lt;br /&gt;
:*Learning how to set Breakpoints&lt;br /&gt;
:*Learning how to navigate the code in your program&lt;br /&gt;
:*Learning how to diagnose and error and how to fix it&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''NOTE:''' Before you continue make sure you have GDB installed. To install GDB complete the tasks below&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# opkg update	 	&amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# opkg install gdb 	&amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]'''&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in! (around line #30)&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
:::The 3rd line in this section of code will drop down one line in your terminal, and look something like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
:::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2. Compile the program and execute the program.'''&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:note: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger'''&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43'''&lt;br /&gt;
(if GDB is not your command line do as follows)&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''5. Now, we start to run the program in the debugger.'''&lt;br /&gt;
&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function'''&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.'''&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
     &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: &amp;quot;step&amp;quot; lets you get a closer look at each function and line, while &amp;quot;next&amp;quot; skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''9. Where are we?'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''10. Watching changes We can go through the program (using the next command) and examine the values using the print command.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
    &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
     &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output. &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:::::This tutorial was based from http://cs.baylor.edu/~donahoo/tools/gdb/tutorial.html&lt;br /&gt;
::::::If you have any questions please visit their site&lt;br /&gt;
== [[Headline text]] ==&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4329</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4329"/>
				<updated>2010-07-27T21:26:10Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will go over how to perform a basic debugging with GDB.&lt;br /&gt;
:We will complete these tasks step by step&lt;br /&gt;
:*Installing the GDB debugger&lt;br /&gt;
:*Running the debugger&lt;br /&gt;
:*Learning how to set Breakpoints&lt;br /&gt;
:*Learning how to navigate the code in your program&lt;br /&gt;
:*Learning how to diagnose and error and how to fix it&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''NOTE:''' Before you continue make sure you have GDB installed. To install GDB complete the tasks below&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# opkg update	 	&amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# opkg install gdb 	&amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]'''&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in! (around line #30)&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
:::The 3rd line in this section of code will drop down one line in your terminal, and look something like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
:::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2. Compile the program and execute the program.'''&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:note: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger'''&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43'''&lt;br /&gt;
(if GDB is not your command line do as follows)&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''5. Now, we start to run the program in the debugger.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function'''&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.'''&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
     &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: &amp;quot;step&amp;quot; lets you get a closer look at each function and line, while &amp;quot;next&amp;quot; skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''9. Where are we?'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''10. Watching changes We can go through the program (using the next command) and examine the values using the print command.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
    &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
     &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4327</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4327"/>
				<updated>2010-07-27T21:00:26Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will go over how to perform a basic debugging with GDB.&lt;br /&gt;
:We will complete these tasks step by step&lt;br /&gt;
:*Installing the GDB debugger&lt;br /&gt;
:*Running the debugger&lt;br /&gt;
:*How to set Breakpoints&lt;br /&gt;
:*How to navigate the code in your program&lt;br /&gt;
:*How to diagnose and error and how to fix it&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''NOTE:''' Before you continue make sure you have GDB installed. To install GDB complete the tasks below&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# opkg update	 	&amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# opkg install gdb 	&amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]'''&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in! (around line #30)&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
:::The 3rd line in this section of code will drop down one line in your code, and look something like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
:::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2. Compile the program and execute the program.'''&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger'''&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43'''&lt;br /&gt;
(if GDB is not your command line do as follows)&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''5. Now, we start to run the program in the debugger.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function'''&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.'''&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
     &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''9. Where are we?'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''10. Watching changes We can step through the program (using the next command) and examine the values using the print command.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
    &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
     &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4326</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4326"/>
				<updated>2010-07-27T20:46:13Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]'''&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in! (around line #30)&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
:::The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
::::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2. Compile the program and execute the program.'''&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger'''&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43'''&lt;br /&gt;
(if GDB is not your command line do as follows)&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''5. Now, we start to run the program in the debugger.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function'''&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.'''&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
     &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''9. Where are we?'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''10. Watching changes We can step through the program (using the next command) and examine the values using the print command.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
    &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
     &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4325</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4325"/>
				<updated>2010-07-27T18:55:08Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in! (around line #30)&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
:::The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
::::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
     &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
    &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
     &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4324</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4324"/>
				<updated>2010-07-27T18:54:48Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in! (around line #30)&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
:::The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
::::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
     &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
    &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
     &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4323</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4323"/>
				<updated>2010-07-27T18:54:08Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in! (around line #30)&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
:::The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
::::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
     &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
    &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
     &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4322</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4322"/>
				<updated>2010-07-27T18:53:05Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in! (around line #30)&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
:::The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
::::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
     &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
    &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
     &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4321</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4321"/>
				<updated>2010-07-27T18:51:22Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in! (around line #30)&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
  &lt;br /&gt;
:::The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
::::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4320</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4320"/>
				<updated>2010-07-27T18:50:20Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in!&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
  &lt;br /&gt;
:::The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
::::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4319</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4319"/>
				<updated>2010-07-27T18:49:44Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
:::::NOTE: The code below is the area that the Error occurs in!&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
  &lt;br /&gt;
:::'''The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...'''&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
::::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4318</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4318"/>
				<updated>2010-07-27T18:48:52Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
 &lt;br /&gt;
  int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
  &lt;br /&gt;
:::'''The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...'''&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
::::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4317</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4317"/>
				<updated>2010-07-27T18:48:23Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
 &lt;br /&gt;
int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
  &lt;br /&gt;
:::'''The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...'''&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
&lt;br /&gt;
::::To fix this you have to bring all of the code back onto a single line. It should end up looking like this.&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4316</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4316"/>
				<updated>2010-07-27T18:46:50Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
:::'''WARNING'''&lt;br /&gt;
::::If you copy and paste this code you will get an error!&lt;br /&gt;
::::To fix this error please follow these directions.&lt;br /&gt;
 &lt;br /&gt;
int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;This program is used to compute the value of the following series : &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Please enter the value of x : &amp;quot; ;&lt;br /&gt;
  &lt;br /&gt;
:::'''The line with several points &amp;quot;........&amp;quot; will drop down one line in your code and look someting like this...'''&lt;br /&gt;
&lt;br /&gt;
 cout &amp;lt;&amp;lt; &amp;quot;(x^0)/0! + (x^1)/1&lt;br /&gt;
&lt;br /&gt;
! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ....&lt;br /&gt;
 .... + (x^n)/n! &amp;quot; &amp;lt;&amp;lt; endl&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4315</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4315"/>
				<updated>2010-07-27T18:41:56Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
&lt;br /&gt;
:Complete the following steps:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
::This puts a breakpoint at line 43 in the program's code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4312</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4312"/>
				<updated>2010-07-27T18:37:24Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp Broken.cpp]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
:Complete the following steps&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4309</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4309"/>
				<updated>2010-07-27T18:36:31Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program http://cs.baylor.edu/~donahoo/tools/gdb/broken.cpp &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
:Complete the following steps&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4306</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4306"/>
				<updated>2010-07-27T18:35:19Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [www.brokenprogram.com] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
:Complete the following steps&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4305</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4305"/>
				<updated>2010-07-27T18:34:42Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [www.brokenprogram.com] &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
:Complete the following steps&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
---- &lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
----  &lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4304</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4304"/>
				<updated>2010-07-27T18:33:24Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [www.brokenprogram.com] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
:Complete the following steps&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: Now is the time to put in any commands you left out before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4303</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4303"/>
				<updated>2010-07-27T18:32:13Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [www.brokenprogram.com] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line do as follows&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb&lt;br /&gt;
	 &lt;br /&gt;
:Complete the following steps&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: if you left any commands out before or want to put one in, do it now&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4302</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4302"/>
				<updated>2010-07-27T18:29:57Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Download the sample program [www.brokenprogram.com] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. This only starts the debugger; it does not start running the program in the debugger. Look at the source code and set a breakpoint at line 43 &lt;br /&gt;
(if GDB is not your command line, i.e. (gdb), type) --&amp;gt;  gdb&lt;br /&gt;
	 &lt;br /&gt;
:Complete the following steps&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
5. Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:HINT: if you left any commands out before or want to put one in, do it now&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. &lt;br /&gt;
The expected output value is 5. &lt;br /&gt;
The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
7. Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
9. Where are we?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
10. Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      &lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	<entry>
		<id>https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4301</id>
		<title>Remote Debugging with GDB</title>
		<link rel="alternate" type="text/html" href="https://wiki.gumstix.com/index.php?title=Remote_Debugging_with_GDB&amp;diff=4301"/>
				<updated>2010-07-27T18:22:13Z</updated>
		
		<summary type="html">&lt;p&gt;Gustavs: New Debugging Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Tutorial for Debugging a program with a logical error'''&lt;br /&gt;
&lt;br /&gt;
:This sample program has some logical errors. The program is supposed to output the summation of &lt;br /&gt;
:(X^0)/0! + (X^1)/1! + (X^2)/2! + (X^3)/3! + (X^4)/4! + ... + (X^n)/n!, given x and n as inputs. &lt;br /&gt;
:However the program outputs a value of infinity, regardless of the inputs. We will take you step by step :through the debugging process and trace the errors:&lt;br /&gt;
&lt;br /&gt;
# Download the sample program [www.brokenprogram.com] &lt;br /&gt;
&lt;br /&gt;
# Compile the program and execute the program.&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# g++ -g broken.cpp -o broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
 root@overo:~# ./broken  &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
hint: Do not type “g++ -o broken broken.cpp”&lt;br /&gt;
&lt;br /&gt;
# In this program no matter the input the output always is infinity. The -g option is important because it enables meaningful GDB debugging.  Start the debugger&lt;br /&gt;
&lt;br /&gt;
 root@overo:~# gdb broken &amp;lt;enter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# This only starts the debugger; it does not start running the program in the debugger. Look at the source :code and set a breakpoint at line 43 &lt;br /&gt;
:(if GDB is not your command line, i.e. (gdb), type) --&amp;gt;  gdb&lt;br /&gt;
	 &lt;br /&gt;
Complete the following steps&lt;br /&gt;
&lt;br /&gt;
 (gdb) b 43&lt;br /&gt;
&lt;br /&gt;
Doing that will make this appear below&lt;br /&gt;
&lt;br /&gt;
 double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
# Now, we start to run the program in the debugger.&lt;br /&gt;
&lt;br /&gt;
 (gdb) run&lt;br /&gt;
&lt;br /&gt;
# Note: If you still need to supply the command-line arguments for the execution of the program, simply include them after the run command, just as normally done on the command line. The program starts running and asks us for the input.&lt;br /&gt;
&lt;br /&gt;
:HINT: if you left any commands out before or want to put one in, do it now&lt;br /&gt;
&lt;br /&gt;
Let's enter the values as x=2 and n=3. The expected output value is 5. The following is a snapshot of the program running in the debugger:&lt;br /&gt;
&lt;br /&gt;
:This program is used to compute the value of the following series : &lt;br /&gt;
:(x^0)/0! + (x^1)/1! + (x^2)/2! + (x^3)/3! + (x^4)/4! + ........ + (x^n)/n! &lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
::Please enter the value of x : 2&lt;br /&gt;
&lt;br /&gt;
::Please enter an integer value for n : 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Breakpoint 1, main () at broken.cpp:43&lt;br /&gt;
 43  double seriesValue = ComputeSeriesValue(x, n);&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
# Note that the program execution stopped at our first (and only) breakpoint. Step into the ComputeSeriesValue() function&lt;br /&gt;
      &lt;br /&gt;
To step into a function call, we use the following command:&lt;br /&gt;
&lt;br /&gt;
 (gdb) step&lt;br /&gt;
&lt;br /&gt;
 ComputeSeriesValue (x=2, n=3) at broken.cpp:17&lt;br /&gt;
 17  double seriesValue=0.0;&lt;br /&gt;
&lt;br /&gt;
# At this point, the program control is at the first statement of the function ComputeSeriesValue (x=2, n=3) Next let's step through the program until we get into ComputeFactorial.&lt;br /&gt;
To stay on track follow these commands carefully.&lt;br /&gt;
      &lt;br /&gt;
 (gdb) next&lt;br /&gt;
 18  double xpow=1;&lt;br /&gt;
 (gdb) n&lt;br /&gt;
 20  for (int k = 0; k &amp;lt;= n; k++) {&lt;br /&gt;
 (gdb) &amp;lt;enter&amp;gt; &lt;br /&gt;
 21    seriesValue += xpow / ComputeFactorial(k) ;&lt;br /&gt;
 (gdb) s&lt;br /&gt;
 ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
 7  int fact=0;&lt;br /&gt;
&lt;br /&gt;
:Note: Step lets you get a closer look at each function and line, while next skips over whole functions to the next one. &lt;br /&gt;
&lt;br /&gt;
:Here we use n and s instead of next and step, respectively. If the command is simply a repeat of the previous command, you can just hit return, which will execute the last command. Finally, we step (with s) into ComputeFactorial(). (If we'd used next, it would have stepped over ComputeFactorial.)&lt;br /&gt;
   &lt;br /&gt;
# Where are we?&lt;br /&gt;
&lt;br /&gt;
:If you want to know where you are in the program's execution (and how, to some extent, you got there), you can view the contents of the stack using the backtrace command as follows:&lt;br /&gt;
&lt;br /&gt;
      (gdb) bt&lt;br /&gt;
      #0  ComputeFactorial (number=0) at broken.cpp:7&lt;br /&gt;
      #1  0x08048907 in ComputeSeriesValue (x=3, n=2) at broken.cpp:21&lt;br /&gt;
      #2  0x08048a31 in main () at broken.cpp:43&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Note: Backtrace lets you see where you have been and what you have done, in the case you get lost or confused it is very useful.&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
# Watching changes We can step through the program (using the next command) and examine the values using the print command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:Once again, follow these commands carefully in order to stay on track.&lt;br /&gt;
      (gdb) next&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      10    fact = fact * j;&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      9  for (int j = 0; j &amp;lt;= number; j++) {&lt;br /&gt;
      (gdb) print fact&lt;br /&gt;
      $2 = 0&lt;br /&gt;
      (gdb) n&lt;br /&gt;
      13  return fact;&lt;br /&gt;
      (gdb) quit&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
:Try to find the error.&lt;br /&gt;
::HINT: Look inside the “print fact” command&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The print command (abbreviated p) reveals that the value of fact never changes. Note that the function is returning a value of 0 for the function call ComputeFactorial(number=0). This is an ERROR! The answer will always equal zero.&lt;br /&gt;
&lt;br /&gt;
By taking a closer look at the values printed above, we realize that we are computing fact=fact * j where fact has been initialized to 0, (0 = 0 * j); fact should have been initialized to 1. We quit GDB with the quit command. Next we need to change the following line:&lt;br /&gt;
      &lt;br /&gt;
 (gdb) quit&lt;br /&gt;
&lt;br /&gt;
:int fact = 1;&lt;br /&gt;
::HINT: It is near the top of the program’s code.&lt;br /&gt;
&lt;br /&gt;
Recompile the code and run it, you will get the expected output.&lt;/div&gt;</summary>
		<author><name>Gustavs</name></author>	</entry>

	</feed>