How do I run NS3 via gdb in emacs?

258 views
Skip to first unread message

David Taylor

unread,
Feb 8, 2011, 1:11:39 PM2/8/11
to ns-3-users
How do I run NS3 via gdb in emacs? I can't get it to work... Thanks!

scolfield

unread,
Feb 8, 2011, 1:17:24 PM2/8/11
to ns-3-...@googlegroups.com
Well, you can to call shell command inside of emacs with M-x shell
and later, execute waf with gdb.
--
scolfield


On Tue, Feb 8, 2011 at 15:11, David Taylor <david.tay...@gmail.com> wrote:
How do I run NS3 via gdb in emacs? I can't get it to work... Thanks!

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.


Rafal Mielniczuk

unread,
Feb 28, 2011, 3:23:24 PM2/28/11
to ns-3-...@googlegroups.com
> Well, you can to call shell command inside of emacs with M-x shell
> and later, execute waf with gdb.
> --
> scolfield
>
>
> On Tue, Feb 8, 2011 at 15:11, David Taylor
<david.tay...@gmail.com>wrote:
>
> > How do I run NS3 via gdb in emacs? I can't get it to work... Thanks!
> >
> > --

Hello,
I do not think that this way of running gdb in emacs is somehow more
usable than running gdb in a normal shell. You can debug ns3 simulation under
emacs+gdb by attaching to a running simulation.

Just run your simulation with the use of "./waf --run simulation_name" as you
did it before. Next check the PID of process created by waf. If you grep for
the name of your simulation you will get at least a list of two processes, the
first one is the waf process and the second is the process of your simulation,
you need the PID of the second.

Next run emacs, type M-x gdb RET gdb --annotate=3 RET attach PID RET.
You can yet set some breakpoints. To attach to a process you have to have
rights to send a signal to it, also sudo emacs may help you.

--
Regards,
Rafal Mielniczuk

David Taylor

unread,
Mar 1, 2011, 2:48:43 AM3/1/11
to ns-3-users
Thanks, but I'm not sure how to make your way work.

I am using "ps -ef | grep name" to find the pid of the process... The
problem is that my simulation runs and finishes within less than a
second... So how do I capture it's PID?

I am currently using the other method mentioned here, via ./waf
shell... It works fine that way. But I am still interested if you can
explain your method. Thanks!

On Feb 28, 10:23 pm, Rafal Mielniczuk <rafal.mielnic...@htwg-
konstanz.de> wrote:
> > Well, you can to call shell command inside of emacs with M-x shell
> > and later, execute waf with gdb.
> > --
> > scolfield
>
> > On Tue, Feb 8, 2011 at 15:11, David Taylor
>
> <david.taylor.cy...@gmail.com>wrote:

Rafal Mielniczuk

unread,
Mar 1, 2011, 3:51:20 AM3/1/11
to ns-3-...@googlegroups.com
> Thanks, but I'm not sure how to make your way work.
>
> I am using "ps -ef | grep name" to find the pid of the process... The
> problem is that my simulation runs and finishes within less than a
> second... So how do I capture it's PID?
>
> I am currently using the other method mentioned here, via ./waf
> shell... It works fine that way. But I am still interested if you can
> explain your method. Thanks!
>
Hello,

with my simulation there where no problems because it was long. Maybe you
can add something like that before the simulation start:

int i = 1;
while(i){
sleep(5);
}

Next after attaching with gdb to process you may change the value of i with
set i=0. I have not tested it but it should work for you.

Can you explain more precisely how you use this combination of ./waf and
shell. Maybe my emacs configuration is somehow broken and I can not get this
way to work.


Regards,
Rafal Mielniczuk

David Taylor

unread,
Mar 1, 2011, 4:35:02 AM3/1/11
to ns-3-...@googlegroups.com
You run "./waf shell" and then launch emacs from the shell ("emacs file_name"). In emacs: Meta-x gdb RET gdb --annotate=3 build/debug/scratch/app_name RET (that path should point to the executable u are trying to debug...). 

I'll try your suggestion later... Thanks.



Regards,
Rafal Mielniczuk

David Taylor

unread,
Mar 1, 2011, 5:26:34 AM3/1/11
to ns-3-users
I can't get the flag to reset... Typing "set i=0" in gdb does not
work. BTW, I am printing the pid directly from within the script using
getpid().

Rafal Mielniczuk

unread,
Mar 1, 2011, 5:58:34 AM3/1/11
to ns-3-...@googlegroups.com
> I can't get the flag to reset... Typing "set i=0" in gdb does not
> work. BTW, I am printing the pid directly from within the script using
> getpid().
>
> On Mar 1, 11:35 am, David Taylor <david.taylor.cy...@gmail.com> wrote:
> > You run "./waf shell" and then launch emacs from the shell ("emacs
> > file_name"). In emacs: Meta-x gdb RET gdb --annotate=3
> > build/debug/scratch/app_name RET (that path should point to the executable
u
> > are trying to debug...).
> >
Hello,

it should be "set var i = 0".

I've tried the way of running the simulation described by you and I think
it is better than mine. You don't need to modify the simulation.

Thanks.

Regards,
Rafal Mielniczuk

Reply all
Reply to author
Forward
0 new messages