IDE profiler help

bridged with qnx.development_tools
Post Reply
roscoh

IDE profiler help

Post by roscoh » Tue Apr 19, 2005 7:54 am

Hi,

I'm trying to use the application profiler in Momentics 6.3.0 - PE IDE
on windows using qconn on a remote x86 target machine, and would like
some verification if I'm going about it the right way.

When I tried profiling my multi-threaded application, the profiler
view shows the same function three times as having the highest number
of calls, called from three different functions. When in fact that
function isn't actually being called at all! ( eg. if I place a
breakpoint in the function it never halts) and when I look at call
information the call graph is confusing showing a large call stack
with sequential functions that don't call each other, as well as
functions that aren't getting called etc.

The other strange feature of the profiler is the thread processor
usage view won't display while the application is being profiled.
When I click on the thread processor usage tab, the view is displayed
for a brief moment then the console view is displayed on top.

I questioned whether the profiler wasn't handling multiple threads so
I created a single threaded C++ application which is attached below,
to test out the profiler. The result of the profiler on this input
suprised me, as the call information shows three function calls, all
labeled main, while there is no mention of the class members being
called! I was expecting to see evidenc of A::OrderN being called etc.
I've tried disabling optimisation, disabling stripping debug info from
the downloaded application etc. all with no avail.

I was hoping that somebody who has had some success with the IDE
profiler using a remote target, could give me some help in it's
proper usage.

Regards, Ross



------ main.cpp --------

#include <cstdlib>
#include <iostream>

//trivial class with a public and private interface
class A
{
public:
void OrderN(int limit)
{
for( int i = 0 ; i < limit ; ++i)
{
DoPrivateStuff(i);
}
}

private:

void DoPrivateStuff(int i)
{
m_num = i*i;
}

float m_num;
};


//trivial class with a public and private interface
class B
{
public:
void OrderNSquared(int limit)
{
for( int i = 0 ; i < limit ; ++i)
{
for( int j = 0 ; j < limit ; ++j)
{
DoPrivateStuff(i*j);
}
}
}

private:

void DoPrivateStuff(int i)
{
m_num = i*i;
}

float m_num;
};



int main(int argc, char *argv[]) {

//try creating objects and invoking calls to their member
functions

A a;
B b;

a.OrderN(100);
b.OrderNSquared(100);

return EXIT_SUCCESS;
}

----------------------------------------

Chris Herborth

Re: IDE profiler help

Post by Chris Herborth » Tue Apr 19, 2005 5:18 pm

roscoh wrote:
I'm trying to use the application profiler in Momentics 6.3.0 - PE IDE
on windows using qconn on a remote x86 target machine, and would like
some verification if I'm going about it the right way.
I'd suggest downloading and installing the free Momentics 6.3.0 service
pack (http://www.qnx.com/download/index.html under Products and
Updates), it fixes a number of application profiling problems.

[...]
I was hoping that somebody who has had some success with the IDE
profiler using a remote target, could give me some help in it's
proper usage.
[... main.cpp ...]
I tried with your posted source code and got reasonable-looking results
in the Application Profiler. Let us know if 6.3.0SP1 gives you better
behaviour.

--
Chris Herborth (cherborth@qnx.com)
Never send a monster to do the work of an evil scientist.

roscoh

re:IDE profiler help

Post by roscoh » Wed Apr 20, 2005 5:54 am

I'd suggest downloading and installing the free Momentics 6.3.0
service pack
I've done this for both my developement environment (windows) and the
target (neutrino) and it doesn't appear to make any difference. I
think there has to be something wrong in the way I'm using the
application profiler.

I would like to be able to see A & B 's member functions in the
call information. Is this reasonable? Below is a screen capture of
the output that I get, as you can see there is no mention of any
other function calls past main?


http://www.acfr.usyd.edu.au/homepages/p ... Output.jpg


Your help is greatly appreciated.

Regards, Ross

roscoh

Re: IDE profiler help

Post by roscoh » Wed Apr 20, 2005 7:54 am

I've just tried profiling my application using gprof and get the
expected results.

So I'm confused as to where the problem lies! I think I've ruled out
any qconn problems by running the application stand alone, and
profiling the gmon.out file generated. I get exactly the same result
as profiling the running application using qconn (shown in previous
post).

I've gone through the IDE project settings several times following the
simple documentation, checking that the application binary constains
sufficient information for profiling, but gprof works so this must be
the case.

So there is a (configuration?) problem with how the executable
generates gmon.out, which is more than likely the same problem with
how qconn uses the debugger to profile the application while it runs.
However, this problem doesn't stop gprof from working!

Any ideas?

Cheers, Ross

Steve Reid

Re: IDE profiler help

Post by Steve Reid » Wed Apr 20, 2005 1:27 pm

roscoh <r.hennessy@acfr.usyd.edu-dot-au.no-spam.invalid> wrote:
Any ideas?
The SP1 release notes include this:

Line numbers in the Memory Analysis, Application Profiler, and Code
Coverage tools are incorrect on SH and MIPS targets. On x86, PowerPC,
and ARM targets, the line numbers are off by 1 if you use the stabs
debugging format. (Ref# 21198, 21412)

Workaround: For x86, PowerPC, and ARM targets, use the DWARF debugging
format, by adding -gdwarf-2 option to the compile flags.

Could this be the problem?

------------------------------------------
Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems
------------------------------------------

Chris Herborth

Re: IDE profiler help

Post by Chris Herborth » Wed Apr 20, 2005 5:06 pm

roscoh wrote:
I would like to be able to see A & B 's member functions in the
call information. Is this reasonable? Below is a screen capture of
the output that I get, as you can see there is no mention of any
other function calls past main?

http://www.acfr.usyd.edu.au/homepages/p ... Output.jpg
Hmm, that does look odd. A few things to check:

1) if you're using a QNX C++ project, make sure the "Build with
Profiling" option is checked on the Project's QNX C/C++ Project page (on
the Options tab)

2) turn off optimisation (I just tried the single-threaded code you
posted yesterday with -O3 instead of -O0... all I see in the Call
Information pane is main() and some housekeeping initialization
functions, no method calls at all)

If you're compiling with optimization on, I suspect #2 is your problem.

--
Chris Herborth (cherborth@qnx.com)
Never send a monster to do the work of an evil scientist.

roscoh

re:IDE profiler help

Post by roscoh » Fri Apr 22, 2005 1:54 am

I tried the -gdwarf-2 option, which didn't change the result, which is
expected since there is no mention of either of the classes members
being called (eg. not an off by 1 error).
make sure the "Build with Profiling" option is checked
Yep, this is part of the documentation on profiling that I have been
folowing.
turn off optimisation (I just tried the single-threaded code you
posted yesterday with -O3 instead of -O0... all I see in the Call
Information pane is main() and some housekeeping initialization
functions, no method calls at all)
I also had thought about this and tried it with no effect.

I'm thinking it must be a configuration problem with the debug
session, since the actual executable can be profiled using gprof!

Any other ideas?

Regards, Ross

Post Reply

Return to “qnx.development_tools”