Need to enable GDB for debugging Multithreaded Application in BBxM

Hi all,

I am very new to Beagle Board xM. Please find below the detailed
description of the problem.

We are working with a Beagle Board xM A3 & B versions with the default
uImage provided in the MMC card. We have a multithreaded application
compiled for BBxM & when we are running we are getting Segmentation
faults.

We are unable to find/trace the reasons for the Segmentation fault as
it is occurring inconsistently in different scenarios.

We are able to observe that even inclusion of some lines of code or
even a inclusion of a debug information like printf creates a
Segmentation fault in a different module(suspecting any compilation
issue).

Can anyone let us know how to debug these Segmentation faults.

We thought of using GDB tool for easy debugging but the default Beagle
Board xM uImage is not supporting the gdb executable required.

Can anyone let me know how to solve these issues & in order to take it
forward suggest me other ways of debugging these issue in the default
uImage provided in BBxM.

Hi Santhosh,

Gdb is not a part of linux kernel (uImage), it's an user space
application. Basically, all you need is just to cross-compile gdb and
then:

1. Enable generating coredumps:

ulimit -c unlimited

2. Run you application and wait for segmentation fault.

3. Find "core" file in the folder you are running your app from.

4. Open core file with gdb:

gdb <path_to_your_app> <path_to_coredump_file>

For example:

gbd /home/santhosh/app/appbin /home/santhosh/app/core

5. In gdb cli type "bt":

(gdb) bt

6. See the call stack before crashing. The upper function will be the
last call before segmentation fault.

Cheers,
Max.

Hi Max,

Thanks for the input.

Currently I was able to enable the coredump & are able to see the core
file built once the segmentation fault has occured. But I am not able
to add gdb. If possible can you send me procedure to get gdb user
application & cross-compiling to BBxM board.

When we enter gdb in the target root,as it is not enabled it is
listing as below
-sh: gdb: not found

Even we tried to download the gdb package on the target BBxM board
itself using the opkg command as below
root:~> opkg install gdb
Unknown package 'gdb'.
Collected errors:
* opkg_install_cmd: Cannot install package gdb.

Am I missing any options or any procedure which I am doing wrongly.

Hi Santhosh,

The easiest way is to download and install gdb manually:

http://www.angstrom-distribution.org/repo/?pkgname=gdb

Please note that you need package for "armv7a" architecture.

Cheers,
Max.

Hi Santhosh,

The easiest way is to download and install gdb manually:

http://www.angstrom-distribution.org/repo/?pkgname=gdb

Please note that you need package for "armv7a" architecture.

Did you do 'opkg update' first to download the feed data?

Hi,

Yes I tried opkg update & then followed by opkg install gdb. but here
gdb was getting failed.

ok I will try installing the gdb manually as suggested by Max & see
whether I am able to back trace the problem.

A standalone application is working but when the same is included in a
multi threaded application it is resulting in segmentation faults. Can
it be because of different compiler options used in different
application.

Moreover, I want to know whether usage of STRIP symbols of application
could cause any runtime issue. Because the objdump of the application
shows in many functions with declaration as "undefined instruction
with some address". But if I dont strip the application then I could
see this undefined instruction disappering in many function.

I am not using any specific processor commands it is just C code.

Is there any other ways of debugging this Segmentation fault.

Hi Santhosh,

I don't think you have all these issues because of compiler flags or
symbols in object files. Probably there are some bugs in IPC/
synchronisation/pointers/etc.

You can also try Valgring (http://valgrind.org/). But you have to
cross-compile it:

http://maxgalemin.blogspot.com/2010/10/how-to-build-valgrind-360-for.html

See User Manual (http://valgrind.org/docs/manual/manual.html) for
details.

P.S. But gdb is the easiest solution...

Cheers,
Max.

If you have core dump, why you need gdb on BBxM? You can copy
core dump to host, and use gdb from cross compilation toolchain.

Hi Santhosh,

Hi,

Yes I tried opkg update & then followed by opkg install gdb. but here
gdb was getting failed.

ok I will try installing the gdb manually as suggested by Max & see
whether I am able to back trace the problem.

A standalone application is working but when the same is included in a
multi threaded application it is resulting in segmentation faults. Can
it be because of different compiler options used in different
application.

Is your application top secret, or can you show us the code?
Did you ever try running it on an x86 PC? Does it show the same
problems?
It should be quite easy to get gdb running on a PC and debug the core
dump.

Moreover, I want to know whether usage of STRIP symbols of application
could cause any runtime issue. Because the objdump of the application
shows in many functions with declaration as "undefined instruction
with some address". But if I dont strip the application then I could
see this undefined instruction disappering in many function.

Usually strip does not do anything bad, but you can just run the app
un-stripped and see what happens.

I am not using any specific processor commands it is just C code.

Is there any other ways of debugging this Segmentation fault.

As I said above source code might help to make a code review.
... given enough eyeballs all bugs are shallow ...

Regards,

Robert