How to debug ns3 code with eclipse

973 views
Skip to first unread message

TSuai

unread,
Dec 28, 2015, 8:36:25 AM12/28/15
to ns-3-users
Hello:
 I have studied ns for some days, and I've done everything with the official instructions how to config ns3 with eclipse(ns3 wiki), but I still can debug my code with eclipse.
I set a breakpoint in my code which I was sure to be call. but when click dubeg button of eclipse, it done nothing but to end, my breakpoint just bi skipped.can some body help me?
thanks

Tommaso Pecorella

unread,
Dec 28, 2015, 10:52:08 AM12/28/15
to ns-3-users
Hi,

double check that the breakpoint is active (sometimes eclipse fails in setting up them) and that the code is actually called. It wouldn't be the first time that a similar thing happens (and it did happen to me too).
Try placing a cost just before the breakpoint, and see if it is printed...

Cheers,

T.

TSuai

unread,
Dec 28, 2015, 10:31:34 PM12/28/15
to ns-3-users
thanks for you reply.
1. I'v done what you siad and I'm sure my code is called, but it still can't work.
2. instead, I try to debug with the waf command(./waf --command-template="gdb %s" --run demo), and my code is simply to print a "helloword". I want to set a breakpoint at the cout statement,but it said that "no debugging symbols found", I think the problem is the "-g" options of g++ command,  am I right? but i dont't know how to do with this? as the following

Reading symbols from /root/AAA/ns3projcets/ns-allinone-3.24.1/ns-3.24.1/build/scratch/demo...(no debugging symbols found)...done.

在 2015年12月28日星期一 UTC+8下午11:52:08,Tommaso Pecorella写道:

Tommaso Pecorella

unread,
Dec 29, 2015, 3:46:56 AM12/29/15
to ns-3-users
Hi,

make sure you did configure waf with the debug option (-d debug) and that you did include the library path in eclipse. Search the ns-3 wiki for an outdated, but still valid, eclipse configuration guideline.

Cheers,

T.

TSuai

unread,
Dec 29, 2015, 9:01:13 AM12/29/15
to ns-3-users
Thanks for you help, Tommaso Pecorella!
It works.

在 2015年12月29日星期二 UTC+8下午4:46:56,Tommaso Pecorella写道:

Yubo Liu

unread,
Dec 13, 2016, 12:05:12 AM12/13/16
to ns-3-users
Hi, Mr. T

I met the same problem with you. I have tried many ways to solve it, but all failed. Could you give me any more details about your solution?

在 2015年12月29日星期二 UTC+8下午10:01:13,Mr. T写道:

HM

unread,
Dec 27, 2018, 2:42:55 PM12/27/18
to ns-3-users
I have configured debugger based on wiki, library is also set. Debugger just runs the whole program and prints out result instead of stopping at (toggled) breakpoint. I set /usr/local/bin/gdb in GDB debugger field under "debugger" tab. I wrote the full path to my test execution file vanet-routing-compare ".../ns-allinone-3.26/ns-3.26/build/scratch/vanet-routing-compare" in C/C++ application field under "Main" tab. I think every other thing is set in the correct way. Anything missed ?

HM

Noel Farrugia

unread,
Dec 29, 2018, 4:49:24 AM12/29/18
to ns-3-users
Try and debug it using gdb from the command line maybe it will output some information that will help you solve the problem.

HM

unread,
Jan 7, 2019, 2:17:57 PM1/7/19
to ns-3-users
The same happens there in terminal, it ignores my breakpoints, there should be something wrong with my application path and .cc code. In Eclipse debug configuration, I set c++ application "ns3.26/build/scratch/APPNAME" which is an executable file (created by waf), however, I set my breakpoints in "ns3.26/scratch/APPNAME.cc". I tried LLDB debugger as well. The same issue exists with LLDB. Am I right in setting up my "debug configuration" ? I just put the code in scratch folder under ns3.26 folder and ./waf it (by eclipse or command). 

Noel Farrugia

unread,
Jan 8, 2019, 4:18:05 AM1/8/19
to ns-3-...@googlegroups.com

Is gdb from the terminal outputting some kind of error or message?

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/oW6HJO_X6Qc/unsubscribe.
To unsubscribe from this group and all its topics, 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 https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

HM

unread,
Jan 9, 2019, 1:12:19 PM1/9/19
to ns-3-users
No error, it just runs the whole program and quit. The program runs good. I am trying debugger on one of NS-3 examples. But it ignores breakpoints. 
What I do in terminal shell is:

$ gdb

then
(gdb) file /.../ns-allinone-3.26/ns-3.26/build/scratch/test
then

(gdb) break /.../ns-allinone-3.26/ns-3.26/scratch/test.cc:2494

No symbol table is loaded.  Use the "file" command.

Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (/.../ns-allinone-3.26/ns-3.26/scratch/test.cc:2494) pending.

then

(gdb) run

Starting program: /.../ns-allinone-3.26/ns-3.26/build/scratch/test 

[New Thread 0x2203 of process 36870]


and it prints out all the results and quit. So it ignores pausing at line 2494 from which I would like to step in. I already configured my ./waf with -d debug argument.

On the other side, after configuring LLDB in eclipse and switching to debug mode it pops up a new tab "Main ()" as can be seen in the image below and by stepping in, debug console shows it is moving over different lines in some other files. I have no idea where it goes through. It doesn't stop at my breakpoint line.

Screenshot 2019-01-09 13.03.28.png

Noel Farrugia

unread,
Jan 10, 2019, 3:56:27 AM1/10/19
to ns-3-...@googlegroups.com

GDB is clearly telling you that no symbol table is loaded. Make sure that you’re building ns3 in debug mode. Once that is done, use the command ./waf shell before running gdb because that will set the necessary environment variables for ns3 to run. If that works, check what environments the ./waf shell command is setting and replicate them.

image001.png
Reply all
Reply to author
Forward
0 new messages