* Step into shared-library code of attached process
@ 2005-07-18 16:54 Yasuhiro Endoh
0 siblings, 0 replies; only message in thread
From: Yasuhiro Endoh @ 2005-07-18 16:54 UTC (permalink / raw)
To: gdb
[-- 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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-07-18 16:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-18 16:54 Step into shared-library code of attached process Yasuhiro Endoh
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).