LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-07-2004, 04:48 PM   #1
mobetterlinux
LQ Newbie
 
Registered: Oct 2004
Posts: 2

Rep: Reputation: 0
linux gdb loading shared libraries?


Running Red Hat Linux 2.1AS, GNU gdb 6.1.
Need to debug a shared library that is loaded via dlopen.
According to the gdb help, 'shar REGEX' says:
"Load shared object library symbols for files matching REGEXP"

But, when I try it (using a shared library in the current directory),
I get the following error:
"No loaded shared libraries match the pattern `my lib name'"

'shar' with no REGEX lists the libraries that are already loaded.

From the help, I thought 'shar' would load the library in the arg. From the error,
it looks like it only lists what is loaded.

What I'm trying to do is to set a breakpoint at the entry point in a shared
library. Since the library is not yet loaded I can't breakpoint
the entry point. The only way that I have to do it currently is to break at
the dlopen and step in (which is causing me some trouble
with the symbols).

I am guessing that I am supposed to do something before the 'shar'
which I thought might be 'add-symbol-file' but that doesn't seem to
make a difference.

Anyone have any suggestions on this?
tks
MBL

Last edited by mobetterlinux; 10-07-2004 at 04:49 PM.
 
Old 10-07-2004, 05:24 PM   #2
mobetterlinux
LQ Newbie
 
Registered: Oct 2004
Posts: 2

Original Poster
Rep: Reputation: 0
I just answered my own question, here's what you do:

* gdb a.out
* break main
* run
(at breakpoint)
* set env LD_PRELOAD=./SHARED_LIBRARY_NAME
* break FUNCTION_NAME
(the following prompt should appear
Function "FUNCTION_NAME" not defined.
Make breakpoint pending on future shared library load? (y or [n])
(answer yes)
y
* cont

(program should continue and stop at the breakpoint)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error while loading shared libraries: libstdc++.so.5: cannot open shared object file: Franziss Linux - Newbie 10 06-28-2010 05:47 AM
Urgent !!! rpm: error while loading shared libraries: libelf.so.1: cannot open shared tinaa Linux - Software 5 12-02-2008 03:19 PM
error while loading shared libraries: libdb-4.1.so: cannot open shared object file putquery8581 Linux - Software 1 10-01-2004 07:03 AM
mplayer: error while loading shared libraries: libdvdread.so.3: cannot open shared ob Bruce Hill Slackware 6 12-11-2003 08:34 AM
linux init error in loading shared shared libraries akaran Linux - Software 1 05-28-2003 04:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration