This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Step into shared-library code of attached process


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



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
#include <stdio.h>

void bar() {
    printf("bar\n");
}

void bar();

#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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]