This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

gprof w/ shared libraries?



[ please CC replies to me ]

I'm wondering if it's possible in any way to use gprof with a shared
library that is loaded at run time into another executable, which is
not compiled with -pg.  I've come across monstartup and friends, and
managed to actually come up with code that doesn't segfault, but it
doesn't produce reasonable results.

gprof hello.so gmon.out

Is the problem that it won't like what it finds in hello.so (it
doesn't crash or indicate an error)?  Is the problem in my use of
monstartup and _mcleanup?:

void Guardian () {
}

void Baz();

void Bar()
{
    int i = 0;
    while (i < 2)
    {
	Baz();
	i++;
    }
    printf("\n");
}

void Baz()
{
    printf("hello world");
}

int DoHello()
{
    int foo = 0;
    monstartup ((u_long) Guardian, (u_long) etext);
    while (foo < 10) {
	Bar();
	foo ++;
    }
    _mcleanup();
}

DoHello is called after a dlopen and dlsym in the main executable.

I'm attempting this on a Debian/GNU Linux powerpc system.

Thoughts?  Thankyou for your time,
-- 
David N. Welton
   Consulting: http://www.dedasys.com/
Free Software: http://people.debian.org/~davidw/
   Apache Tcl: http://tcl.apache.org/
     Personal: http://www.efn.org/~davidw/


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