Editing Documentation/Maemo 5 Developer Guide/Kernel and Debugging Guide/Maemo Debugging Guide
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
Warning: This page is 60 kilobytes long; some browsers may have problems editing pages approaching or longer than 32kb. Please consider breaking the page into smaller sections.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 155: | Line 155: | ||
The example apps are: | The example apps are: | ||
- | * <code>gdb_example.c</code> is a very simple C application that has some functions that call each other in a row. This is used here to demonstrate how to get backtraces. | + | * the <code>gdb_example.c</code> is a very simple C application that has some functions that call each other in a row. This is used here to demonstrate how to get backtraces. |
- | * <code>gdb_example2.c</code> is a simple variant of the <code>gdb_example.c</code> that has some additional <code>sleep()</code> calls. This is used to demonstrate simple core dump debugging. | + | * the <code>gdb_example2.c</code> is a simple variant of the <code>gdb_example.c</code> that has some additional <code>sleep()</code> calls. This is used to demonstrate simple core dump debugging. |
Next, compile the small <code>gdb_example.c</code> file as shown below, and start the gdb debugger. This simple example shows how to set breakpoints, and how to get a backtrace from the program. Backtrace tells what functions have been called and what parameters have been used. | Next, compile the small <code>gdb_example.c</code> file as shown below, and start the gdb debugger. This simple example shows how to set breakpoints, and how to get a backtrace from the program. Backtrace tells what functions have been called and what parameters have been used. | ||
Line 166: | Line 166: | ||
[sbox-FREMANTLE_x86: ~/src/gdb_example] > gcc gdb_example.c -o gdb_example -g -O2 -Wall | [sbox-FREMANTLE_x86: ~/src/gdb_example] > gcc gdb_example.c -o gdb_example -g -O2 -Wall | ||
</pre> | </pre> | ||
+ | {{ambox|text=N.B. It is recommended to compile debug binaries with options -g -O2 -Wall, although only -g is necessary as that leaves debugging information in the binaries. Sometimes optimizations (-O2) might cause trouble for gdb, leaving it out can help in that case. However, without optimization flags the compiler does not give out as many possible warnings as some of them are found in optimization analysis.}} | ||
- | + | {{ambox|text=N.B. Production binaries should be compiled with -O2 -Wall. Without optimizations the size and execution time of the binaries might increase a lot. However, typically production binaries are Debian-packaged and should be compiled with -g -O2 -Wall, stripping the debug symbols into a separate package to facilitate debugging. See section [[#Making a Debian Debug Package]].}} | |
</li> | </li> | ||
Learn more about Contributing to the wiki.