Need to enable GDB for debugging Multithreaded Application in BBxM

180 views
Skip to first unread message

Santhosh

unread,
Mar 2, 2011, 1:57:32 AM3/2/11
to Beagle Board, santh...@jasmin-infotech.com
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.

Max Galemin

unread,
Mar 2, 2011, 5:57:03 PM3/2/11
to Beagle Board
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.

Santhosh

unread,
Mar 4, 2011, 1:11:58 AM3/4/11
to Beagle Board
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.

Max Galemin

unread,
Mar 4, 2011, 4:47:20 PM3/4/11
to Beagle Board
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.

Jason Kridner

unread,
Mar 4, 2011, 7:01:08 PM3/4/11
to beagl...@googlegroups.com, Beagle Board
On Mar 4, 2011, at 4:47 PM, Max Galemin <maksim....@gmail.com> wrote:

> 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?

> --
> You received this message because you are subscribed to the Google Groups "Beagle Board" group.
> To post to this group, send email to beagl...@googlegroups.com.
> To unsubscribe from this group, send email to beagleboard...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/beagleboard?hl=en.
>

Santhosh

unread,
Mar 5, 2011, 2:25:52 AM3/5/11
to Beagle Board, 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.

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.



On Mar 5, 5:01 am, Jason Kridner <jkrid...@beagleboard.org> wrote:

Max Galemin

unread,
Mar 5, 2011, 6:45:14 PM3/5/11
to Beagle Board
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.

robert.berger

unread,
Mar 6, 2011, 10:20:51 AM3/6/11
to Beagle Board
Hi Santhosh,

On Mar 5, 9:25 am, Santhosh <santhosh.ragha...@gmail.com> wrote:
> 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

--
Robert Berger
Embedded Software Specialist

Reliable Embedded Systems
Consulting Training Engineering
Tel.: (+30) 697 593 3428
Fax.:(+30) 210 684 7881
URL: http://www.reliableembeddedsystems.com

davemilter

unread,
Mar 6, 2011, 5:37:51 AM3/6/11
to Beagle Board
On 4 мар, 09:11, Santhosh <santhosh.ragha...@gmail.com> wrote:
> 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
>

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.
Reply all
Reply to author
Forward
0 new messages