Re: How to enable profiling while compiling ns3.18 code

224 views
Skip to first unread message

Hajime Tazaki

unread,
Nov 13, 2013, 10:19:55 PM11/13/13
to ns-3-...@googlegroups.com

Hi,

as far as I know, ns-3 doesn't have an option to create pg
option-ed binaries.

easier way to do it without concerning any headers and
libraries dependencies is to modify waf build script,
wscript.
you can modify 'wscript' file by hands and add '-pg' option
to compile and link flags.

you can refer how --enable-gcov option is handled and add
proper options to compiler/linker.

http://code.nsnam.org/ns-3-dev/file/b4e0285d2f22/wscript#l300
# though this option is now broken for a while.
https://www.nsnam.org/bugzilla/show_bug.cgi?id=1583

I think the followings are what you need to edit.

env.append_value('CCFLAGS', '-pg')
env.append_value('CXXFLAGS', '-pg')
env.append_value('LINKFLAGS', '-pg')




-- Hajime

At Wed, 13 Nov 2013 16:00:47 -0800 (PST),
negs wrote:
>
> [1 <text/plain; ISO-8859-1 (7bit)>]
> I am using NS3.18 running on a redhat 4.4.6-4. I have gcc version 4.4.6.
> Recently, i added a new feature to my code and the simulation has become
> really slow.I want to use the gnuprof tool to check what part of the code
> is the cause of slow speed.
> I usually build a cc file using the command - ./waf --run filename and it
> works fine. According to the instructions mentioned on the gnuprof page -
> http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html and
> http://www.ibm.com/developerworks/library/l-gnuprof.html , i need to simply
> specify `-pg' in addition to the usual options. The same option, `-pg',
> alters either compilation or linking to do what is necessary for profiling
> but when i use the command "./waf --run filename -pg" i get the following
> error - "waf:error:no such option : -g"
>
> And when i try the command "gcc filename.cc -pg -o filename" i get a lot of
> errors stating many variables in the file have not been declared.
>
> If i build with waf everything builds but i am unable to use gnuprof and
> when i try to compile with gcc giving -pg option i get errors.
> Could you please tell me how i could use gnuprof with waf or how i could
> use gcc without getting the errors?
> Hoa can i enable profiling while comipiling my ns3.18 code?
>
> --
> You received this message because you are subscribed to the Google Groups "ns-3-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
> To post to this group, send email to ns-3-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ns-3-users.
> For more options, visit https://groups.google.com/groups/opt_out.
> [2 <text/html; ISO-8859-1 (quoted-printable)>]
>

negs

unread,
Nov 15, 2013, 1:47:20 PM11/15/13
to ns-3-...@googlegroups.com
Hi,

I tried it but it still doesn't work. i edited the wscript in the folder ns-3.18. Following is the edit i made :

if Options.options.enable_gcov:
        env['GCOV_ENABLED'] = True
        env.append_value('CCFLAGS','-pg')
        env.append_value('CCFLAGS','-pg')
        env.append_value('CXXFLAGS','-pg')
        env.append_value('CXXFLAGS','-pg')
        env.append_value('LINKFLAGS','-pg')

After making the edit and saving it i ran the command - " ./waf -pg " but i still get the same error message- " waf:  error: no such option -g"

Hajime Tazaki

unread,
Nov 22, 2013, 9:46:02 AM11/22/13
to ns-3-...@googlegroups.com

At Fri, 15 Nov 2013 10:47:20 -0800 (PST),
negs wrote:
>
> Hi,
>
> I tried it but it still doesn't work. i edited the wscript in the folder
> ns-3.18. Following is the edit i made :
>
> if Options.options.enable_gcov:
> env['GCOV_ENABLED'] = True
> env.append_value('CCFLAGS','-pg')
> env.append_value('CCFLAGS','-pg')
> env.append_value('CXXFLAGS','-pg')
> env.append_value('CXXFLAGS','-pg')
> env.append_value('LINKFLAGS','-pg')
>
> After making the edit and saving it i ran the command - " ./waf -pg " but i
> still get the same error message- " waf: error: no such option -g"

the condition "Options.options.enable_gcov" is for the
option of waf (i.e., "./waf configure --enable-gcov" makes
the condition true).

so what you should do with the above edit is:

% ./waf configure --enable-gcov

then build it

% ./waf

then run your script.

% ./waf --run your-script-name

-- Hajime
> > an email to ns-3-users+...@googlegroups.com <javascript:>.
> > > To post to this group, send email to ns-3-...@googlegroups.com<javascript:>.
Reply all
Reply to author
Forward
0 new messages