Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Regarding shared library and GDB

5 views
Skip to first unread message

sunil

unread,
Sep 27, 2007, 3:03:40 AM9/27/07
to sunil.k...@wipro.com
Hi,


Am interested to debug one shared library using GDB.This shared
libarry is used by a binary (for which i doesn't have the code).I am
aware about at what point of time the library will be called.
Can i debug that library iusing GDB.If yes please let me know the
steps how to proceed further.


Regards
Sunil.

dan.od...@gmail.com

unread,
Sep 27, 2007, 4:25:51 AM9/27/07
to


hi
afaik, you can't properly debug it until you'll have this library
compiled with debug info.

Vakayil Thobias

unread,
Sep 27, 2007, 7:41:23 AM9/27/07
to

use the command truss to execute your application to see the libraries
which are calling.

sunil

unread,
Sep 27, 2007, 8:51:03 AM9/27/07
to

yes I compiled the library properly.
My problem is unable to caught the library using gdb while application
executing the library.

Sunil.

Paul Pluzhnikov

unread,
Sep 27, 2007, 11:05:46 AM9/27/07
to
sunil <suni...@gmail.com> writes:

> On Sep 27, 1:25 pm, dan.odega...@gmail.com wrote:

>> > Can i debug that library iusing GDB.

Yes.

> My problem is unable to caught the library using gdb while application
> executing the library.

You are not making much sense, and you are not explaining your
difficulty. After reading this:

http://catb.org/~esr/faqs/smart-questions.html

ask your question again, but explain exactly what you are doing
and what you observe gdb do (and what you expected it to do).

My guess is that the library is loaded dynamically into your app,
and so when you try to set breakpoint in it, the breakpoint is
never set (or never fires).

If so, there are several ways to deal with this.
Commands you'll want to try:

set stop-on-solib-events 1 # stop after every DSO load
info shared # see when your library is loaded.
# Once it is, you can set breakpoints in it.

Alternatively, if you are on x86, insert a breakpoint instruction
into the place in your library where you want gdb to stop:

__asm__ __volatile__ ("int3");

However, this will cause the app to die with 'Trace/breakpoint trap'
when run outside of gdb.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

el...@no.spam

unread,
Sep 27, 2007, 8:09:34 PM9/27/07
to
In article <1190876620....@n39g2000hsh.googlegroups.com>,
sunil <suni...@gmail.com> wrote:

>Am interested to debug one shared library using GDB.

Have you considered static linking while you debug?

--
http://www.spinics.net/lists/

Andrei Voropaev

unread,
Sep 28, 2007, 3:16:27 AM9/28/07
to
On 2007-09-27, sunil <suni...@gmail.com> wrote:
>> On Sep 27, 11:03 am, sunil <sunil....@gmail.com> wrote:

>> > Am interested to debug one shared library using GDB.This shared
>> > libarry is used by a binary (for which i doesn't have the code).I am

[...]


> yes I compiled the library properly.
> My problem is unable to caught the library using gdb while application
> executing the library.

Strange. Why can't you catch it? Start gdb with the program. Before
issuing "run" set break point in your library function. gdb will tell
you that it does not exist and ask if you want that to be a "pending"
break point. Answer "yes". Now issue "run" comman. When the library is
loaded, gdb will try to find the specified function in it and set the
break point for you there.


--
Minds, like parachutes, function best when open

sunil

unread,
Nov 2, 2007, 7:14:55 AM11/2/07
to
On Sep 28, 12:16 pm, Andrei Voropaev <avo...@mail.ru> wrote:

Hi,

Thanks for your replies, Now am able to set the break point in my
library and facing a different problem.
I will explain my scenario one more time.

Am trying to debug a shared library which is built by me.Thsi one is
used by one application for which I doesn't have the code. I know when
this library will be called after starting the application(by giving a
call from the clien to that server my .so will be called) at the
samtime am not fully aware about the input parameters for the
application to start.(Generally this apllication will be called from
shell scripts).Thats the reason I am vebugging the running process by
taking the pid.

After starting the gdb using PID of that running process ,I can find
my library in the loaded shared library list.Even I can set the
breakpoint for the functions of my shared library. After calling my
shared library using the client the program,the gdb is able to stop
the execution at the break point. But the problem is even after
pressing the list or next command of gdb it is throwing the errors as
below
======================================
(gdb) b CCAAuthentication
Breakpoint 1 at 0xfcfe55f8
(gdb) b xauthn_initialize
Breakpoint 2 at 0xfcfe32a0
(gdb) c
Continuing.
[LWP 17 exited]
[LWP 16 exited]
[New LWP 517 ]
[New Thread 517 (LWP 517)]
[Switching to Thread 517 (LWP 517)]

Breakpoint 2, 0xfcfe32a0 in xauthn_initialize () from /idam/CDAS/
libcode/libxauthn.so
(gdb) ls
Undefined command: "ls". Try "help".
(gdb) l
1 ./libgcc2.c: No such file or directory.
in ./libgcc2.c
(gdb) n
Single stepping until exit from function xauthn_initialize,
which has no line number information.


0xfcfe61d8 in __1cNpdxauthn_init6FpnKpam_handle_iippkc_L_ () from /
idam/CDAS/libcode/libxauthn.so
(gdb)
Single stepping until exit from function
__1cNpdxauthn_init6FpnKpam_handle_iippkc_L_,
which has no line number information.
0xfcfe6138 in __1cRcheck_initialized6FpnKpam_handle_iippkc_L_ () from /
idam/CDAS/libcode/libxauthn.so
(gdb)
Single stepping until exit from function
__1cRcheck_initialized6FpnKpam_handle_iippkc_L_,
which has no line number information.
0xfcfe624c in pam_sm_authenticate () from /idam/CDAS/libcode/
libxauthn.so
(gdb)
===================================================

Even i set the path to my code using the DIR command of gdb.
If anybody knows about this error please let me know.

Regards
Sunil

Paul Pluzhnikov

unread,
Nov 2, 2007, 10:52:05 AM11/2/07
to
sunil <suni...@gmail.com> writes:

> Thanks for your replies, Now am able to set the break point in my
> library and facing a different problem.

If you have a different problem, you generally should post a new
message, not a followup to your previous one.

>> > yes I compiled the library properly.

No, you didn't.

> (gdb) b CCAAuthentication
> Breakpoint 1 at 0xfcfe55f8
> (gdb) b xauthn_initialize
> Breakpoint 2 at 0xfcfe32a0

The output above means that neither function was compiled with
debug info (with '-g' flag). Without such info, source-level
debugging will not be available.

> If anybody knows about this error please let me know.

We told you already: compile with '-g'.

Andrei Voropaev

unread,
Nov 4, 2007, 10:22:22 AM11/4/07
to
On 2007-11-02, sunil <suni...@gmail.com> wrote:
[...]

> (gdb) c
> Continuing.
> [LWP 17 exited]
> [LWP 16 exited]
> [New LWP 517 ]
> [New Thread 517 (LWP 517)]
> [Switching to Thread 517 (LWP 517)]
[...]

Others pointed out already, that you don't have debugging info in your
library. I just wanted to tell you that since you are debugging
multithreaded application you should read the section on multithreading
in gdb documentation. Basically, you should be aware that multiple
threads can be stopped at your breakpoint and it will be confusing to
follow all of them. GDB allows to set break point for single thread
only. See documentation.

sunil

unread,
Nov 5, 2007, 1:30:18 AM11/5/07
to
On Nov 4, 8:22 pm, Andrei Voropaev <avo...@mail.ru> wrote:

Paul & Andrei

thanks for u'r help. I enabled the debugging flag while linking rather
than compiling stage.
Thats the reason I wan unable to debug my code.Once again thanking you
guys a lo for u'r kind help.

Regards
Sunil

0 new messages