From: Yasuhiro Endoh <quiver2k@ybb.ne.jp>
To: gdb@sources.redhat.com
Subject: Step into shared-library code of attached process
Date: Mon, 18 Jul 2005 16:54:00 -0000 [thread overview]
Message-ID: <42DBE026.7060409@ybb.ne.jp> (raw)
[-- Attachment #1: Type: text/plain, Size: 1449 bytes --]
Hello,
I'm trying to step into shared-library code of attached process. I can't
step into library-function at the first call. But I can step in the
function at the second call.
Can I step into library-function at the first the?
My Environments are:
CPU: Intel(R) Celeron(R) CPU 2.40GHz
OS: Fedora core 3
Kernel: 2.6.12 (kernel-2.6.12-1.1372_FC3)
gdb: 6.3
The followings are sample code:
void foo() {
printf("foo\n");
}
int main(int argc, char *argv[])
{
char buf[128];
printf("attach me(pid=%d)> ", getpid());
fgets(buf, sizeof(buf), stdin);
foo();
bar(); /* can't step-in */
bar();
bar();
return 0;
}
Here, function bar() is defined in the shared library libbar.so.
To step into bar, I took the followings:
1. This program prompts "attach me(pid=18130)>".
2. I attached the process with id 18130
3. I set a break point at "foo();" in main
4. I typed "info sharedlibrary"
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0xb7f6644c 0xb7f66564 Yes /home/yendoh/link/libbar.so
0x0088cc00 0x0097ccd0 Yes /lib/tls/libc.so.6
0x008197a0 0x0082b58f Yes /lib/ld-linux.so.2
5. continued
6. The process was breakd at "foo():", I could step-in foo().
7. I tried to step into "bar();" , but I couldn't step-in.
8. I could step-in the second and third call of bar().
I attached my-program. To run the program:
1. make
2. make run
Thanks,
Endoh
[-- Attachment #2: Makefile --]
[-- Type: text/plain, Size: 240 bytes --]
all: libbar.so sample
libbar.so: bar.c bar.h
gcc -o libbar.so -g -Wall -shared -fpic bar.c
sample: main.c bar.h libbar.so
gcc -o sample -g -Wall main.c -L. -lbar
clean:
rm -f sample libbar.so
run:
env LD_LIBRARY_PATH=`pwd` ./sample
[-- Attachment #3: bar.c --]
[-- Type: text/x-csrc, Size: 57 bytes --]
#include <stdio.h>
void bar() {
printf("bar\n");
}
[-- Attachment #4: bar.h --]
[-- Type: text/x-chdr, Size: 13 bytes --]
void bar();
[-- Attachment #5: main.c --]
[-- Type: text/x-csrc, Size: 313 bytes --]
#include <stdio.h>
#include <unistd.h>
#include "bar.h"
void foo() {
printf("foo\n");
}
int main(int argc, char *argv[])
{
char buf[128];
printf("attach me(pid=%d)> ", getpid());
fgets(buf, sizeof(buf), stdin);
foo();
bar(); /* can't step-in */
bar();
bar();
return 0;
}
reply other threads:[~2005-07-18 16:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42DBE026.7060409@ybb.ne.jp \
--to=quiver2k@ybb.ne.jp \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).