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 59 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 23: Line 23:
* develop software in the Linux environment using the C language
* develop software in the Linux environment using the C language
* install software to the tablet device
* install software to the tablet device
-
* [[root access|gain root access]] to the device
+
* gain root access to the device
* install ssh to the device
* install ssh to the device
* configure repositories in the <code>/etc/apt/sources.list</code> file
* configure repositories in the <code>/etc/apt/sources.list</code> file
Line 33: Line 33:
To follow the debugging examples you need to have the following:
To follow the debugging examples you need to have the following:
-
* [[Documentation/Maemo_5_Final_SDK_Installation|Maemo SDK installed on a Linux PC]]
+
* Maemo SDK installed on a Linux PC
* Nokia Internet Tablet device running [[Open development/Maemo roadmap/Fremantle|Maemo 5]].
* Nokia Internet Tablet device running [[Open development/Maemo roadmap/Fremantle|Maemo 5]].
* USB cable to connect the device with the Linux PC
* USB cable to connect the device with the Linux PC
* Internet access both for the tablet and for the Linux PC
* Internet access both for the tablet and for the Linux PC
* USB networking (or WLAN) set up between the Linux PC and the device
* USB networking (or WLAN) set up between the Linux PC and the device
-
* root login access to the device over [[SSH]]
+
* root login access to the device over ssh
-
* package <code>maemo-sdk-debug</code> installed
+
* package maemo-sdk-debug installed
-
* [[terminal|xterm]] installed on the device
+
* xterm installed on the device
-
* SSH software installed on the device
+
* ssh software installed on the device
== General Notes on Debugging ==
== General Notes on Debugging ==
Line 49: Line 49:
When debugging the ARM architecture, pay attention to the following issues:
When debugging the ARM architecture, pay attention to the following issues:
-
* To make backtraces work properly on the ARM side, the debug packages need to be installed for the libraries the application is using. Profiling and debugging (gdb) tools require the code to have either framepointers or debugging symbols to unwind the stack. This is necessary for showing backtraces or call graphs.
+
* To make backtraces work properly on the ARM side, the dbg packages need to be installed for the libraries the application is using. Profiling and debugging (gdb) tools require the code to have either framepointers or debugging symbols to unwind the stack. This is necessary for showing backtraces or call graphs.
-
* C language functions with the <code>__attribute__((__noreturn__))</code> statement need to be compiled with the gcc option: <code>-mapcs-frame</code> otherwise the compiler excludes their function frame. On Maemo, the Glib and C library noreturn functions like <code>abort()</code> already have this. Without a function frame, gdb cannot backtrace through "noreturn" functions.
+
* C language functions with the <code>__attribute__((__noreturn__))</code> statement need to be compiled with the gcc option: <code>-mapcs-frame</code> otherwise the compiler excludes their function frame. Maemo Glib and C-library noreturn functions like <code>abort()</code> already have this. Without a function frame, gdb cannot backtrace through "noreturn" functions.
* In addition, for gdb to be able to display the correct function names during debugging, it also needs to have access to the debug symbols. Without them, gdb shows the preceding exported function name for a given address.
* In addition, for gdb to be able to display the correct function names during debugging, it also needs to have access to the debug symbols. Without them, gdb shows the preceding exported function name for a given address.
Line 71: Line 71:
=== Setting up Environment ===
=== Setting up Environment ===
-
Both the Internet Tablet device, described in section [[Documentation/Maemo PC Connectivity Tutorial|Maemo PC Connectivity]], and the Scratchbox environment, described in section [[../../Development Environment/Maemo SDK|Maemo SDK]], need to be set up.
+
Both the Internet Tablet device, described in section [[../../Development Environment/Maemo PC Connectivity|Maemo PC Connectivity]], and the Scratchbox environment, described in section [[../../Development Environment/Maemo SDK|Maemo SDK]], need to be set up.
=== Preparing Scratchbox Environment for Debugging ===
=== Preparing Scratchbox Environment for Debugging ===
Line 526: Line 526:
</pre>
</pre>
-
In this example, the standard <code>export DEB_BUILD_OPTIONS=debug,nostrip</code> environment variable is used, but there might be source packages that do not support these debug,nostrip options. In that case, one must make sure that the source is compiled with <code>-g</code> flag (usually this option can be added to the <code>CFLAGS</code> variable in the <code>debian/rules</code> file), and that the produced binaries will not be stripped. In the long run, it is better to modify the source package to generate a separate debug symbol (<code>-dbg</code>) package. This requires modifying both the <code>debian/rules</code> and <code>debian/control</code> files. In fact, maemopad already builds a separate debug package, but this example makes no use of it to demonstrate the simpler case.
+
In this example, the standard export DEB_BUILD_OPTIONS=debug,nostrip environment variable is used, but there might be source packages that do not support these debug,nostrip options. In that case, one must make sure that the source is compiled with <code>-g</code> flag (usually this option can be added to the <code>CFLAGS</code> variable in the <code>debian/rules</code> file), and that the produced binaries will not be stripped. In the long run, it is better to modify the source package to generate a separate debug symbol (<code>-dbg</code>) package. This requires modifying both the <code>debian/rules</code> and <code>debian/control</code> files. In fact, maemopad already builds a separate debug package, but this example makes no use of it to demonstrate the simpler case.
Line 719: Line 719:
Because the breakpoint is now cleared, you can use the application normally under <code>Xephyr</code>.
Because the breakpoint is now cleared, you can use the application normally under <code>Xephyr</code>.
-
 
-
===== Alternative method for starting gdb =====
 
-
 
-
Rather than starting the application framework, followed by gdb, it is possible to do both at the same time by passing an extra argument to the <code>af-sb-init.sh</code> script. For example:
 
-
af-sb-init.sh start --gdb=my_app
 
-
where <code>my_app</code> is the application to debug.
 
== Debugging Hildon Desktop Plug-ins ==
== Debugging Hildon Desktop Plug-ins ==
Line 947: Line 941:
=== Installing Valgrind Tool ===
=== Installing Valgrind Tool ===
-
Installing Valgrind is simple. Log in to Scratchbox and run the following commands:
+
Installing Valgrind is simple. Log in on Scratchbox and run the following commands:
<ol>
<ol>
<li> Get Valgrind from the repository:  
<li> Get Valgrind from the repository:  
Line 961: Line 955:
</pre>  
</pre>  
-
The Maemo version of valgrind depends on the <code>libc6-dbg</code> package. On desktop Linux, some of the debug symbols are included in the libc6 library itself. If the debug symbols are missing from the libraries, Valgrind cannot match the error suppressions to the internal library functions. In the Maemo <code>libc6</code> case, it would show lots of errors for the dynamic linker.
 
-
If using a non-Maemo version of valgrind, the following environment variable needs to be set before valgrinding programs using Glib:
+
{{ambox|text=The maemo Valgrind version depends on the libc6-dbg. On the desktop Linux, some of the debug symbols are included in the libc6 library itself. If the debug symbols are missing from the libraries, Valgrind cannot match the error suppressions to the internal library functions. In the maemo <code>libc6</code> case, it would show lots of errors for the dynamic linker.
-
[sbox-FREMANTLE_X86: ~] > export G_SLICE="always-malloc"
+
If using a non-maemo version of Valgrind, the following environment variable needs to be set before valgrinding programs using Glib:
-
Without this, valgrind will report bogus leaks from Glib. The GNOME wiki has [http://live.gnome.org/Valgrind more information on the use of valgrind with Glib].
+
<code>
 +
[sbox-FREMANTLE_X86: ~] > export \
 +
G_SLICE="always-malloc"
 +
</code>
 +
 
 +
Without this, Valgrind will report bogus leaks from Glib.}}
</li>
</li>
Line 1,064: Line 1,062:
Valgrind also tells the lines in the code where these allocations that are not freed are performed. In this example, the lines in question are 48 and 26.
Valgrind also tells the lines in the code where these allocations that are not freed are performed. In this example, the lines in question are 48 and 26.
-
 
-
==== Alternative method for starting Valgrind ====
 
-
 
-
[[#Alternative method for starting gdb|As with gdb]], Valgrind can be started together with the application framework, which is especially useful for graphical applications that must normally be run with <code>run-standalone.sh</code>. For example, to start the application framework an an application <code>my_app</code> underValgrind:
 
-
af-sb-init.sh start --valgrind=my_app
 
-
If other Valgrind frontends are required, they can be set with the environment variables:
 
-
* <code>VALGRINDCMD</code>: the command you want to run inside valgrind
 
-
* <code>VALGRIND</code>: the valgrind command and parameters, including the frontend to use
 
-
For example, to run <code>massif</code> on <code>maemo-af-desktop</code>:
 
-
VALGRINDCMD="maemo-af-desktop" VALGRIND="valgrind --tool=massif --num-callers=50 \
 
-
        --trace-children=yes --depth=5 --format=html -log-file=/tmp/massif \
 
-
        --alloc-fn=g_malloc --alloc-fn=g_malloc0 --alloc-fn=g_realloc \
 
-
        --alloc-fn=g_slice_alloc --alloc-fn=g_try_malloc \
 
-
        --alloc-fn=g_slice_alloc0" af-sb-init.sh start
 
-
...
 
-
af-sb-init.sh stop
 
=== Official Valgrind Manual ===
=== Official Valgrind Manual ===
Line 1,246: Line 1,228:
</ol>
</ol>
See also <code>dh_strip (1)</code> and <code>debhelper (7)</code> manual pages for details about the helper scripts.
See also <code>dh_strip (1)</code> and <code>debhelper (7)</code> manual pages for details about the helper scripts.
 +
 +
 +
If the package has any functions that have the <code>noreturn</code> GCC attribute, you need to make sure that the objects containing those are compiled with <code>-mapcs-frame</code> (or remove the noreturn attribute). This is needed for backtraces containing them to be debuggable when the binaries are optimized, the debug symbols are not enough for them. By default GCC omits frame pointer when code is optimized.
== Using and Installing DBG Packages ==
== Using and Installing DBG Packages ==

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: