for your eyes only
Knowledge Hurts – a blog of thoughts, things and stuff.

Debugging TCL scripts on ns2 – yes it works for ns 2.34!

As stated at http://www.isi.edu/nsnam/ns/ns-debugging.html ns2 is compatible with Don Libs’ Tcl debugger.

What that site doesn’t tell you is how to install it. There is a nice howto by tk424 here, but that wasn’t written for a recent version of ns2. All the same I recommend it, as it’s very useful. However I have contributed here a patch for the configure file of tcl-debug2 in order to make it compatible with recent versions of ns2. This was tested in ns2.34.

Ah, yes another thing. I am not going to go into as much detail as the howto above. Refer to it if you have questions. It’s totally fool proof.

The quick way is this.

  1. Download http://expect.nist.gov/tcl-debug/tcl-debug.tar.gz (apparently thats the most up-to-date version out there since dinosaurs populated the earth.) If that link does not work, try my mirror: http://www.box.net/shared/0fah87994s
  2. Untar it and move it to your ns-allinone-x.xx folder
  3. go into the ns-allinone-x.xx/tcl-debug-2.0 folder and try calling ./configure
  4. if that fails apply my patch from http://www.box.net/shared/20z8klbpjy and call ./configure again (applying the patch is as simple as calling “patch -p1 < tcl-debug-2.0-configure.patch”)
  5. call make
  6. you will get a file called “tcl-debug-2.0/libtcldbg.a” if everythings fine
  7. copy that to “ns-allinone-x.xx/ns-x.xx/lib”
  8. go to “ns-allinone-x.xx/ns-x.xx”
  9. do “./configure –with-tcldebug”
  10. call make (perhaps you have to make clean; make)
  11. insert the line “debug 1” at the line of your script that you wish to debug
  12. follow this PostScript document for instructions how to use the debugger

So… that’s about it. And with that tool installed, you will finally know what your _o?? reference that is in the backtrace of ns2 really stands for. Plus know the type of the object simply by using its OTcl handle _o??. Cool, isn’t it. Happy debugging!

Read on! Knowledge hurts.

Advertisements

17 Responses to “Debugging TCL scripts on ns2 – yes it works for ns 2.34!”

  1. Your patch file for tcldebug is not working in my ns-2.34. when i patch it, it takes time so long and can’t forward. Any idea pls?

    “little@little-laptop:~/ns/ns-allinone-2.34/tcl-debug-2.0$ patch -p1 > tcl-debug-2.0-configure.patch”

    thanks in advance!

  2. That’s an easy one!

    Your “>” should be a “<".

    By using the wrong direction of the parenthesis, you have put the output of patch into tcl-debug-2.0-configure.patch but the patch program has been waiting for your input in order to use it to patch something.
    Like that, you even have overwritten the patch file, so perhaps you'll have to redownload it before trying the corrected command…

    Good Luck!

  3. Hi !
    Thanks for your post. It is really helpful.

    How to know what is _oXXX ? I’ve put “debug 1” in my tcl script. Then I launched my simulation and dbg5 starts. I’ve got a Classifier::no-slot problem and I’d like to understand why with the debug. It writes _o31 no slot 90. How to know what is my _o31 ?

    Thanks.

    Jonathan.

  4. The _oXXX is called tcl handle.

    When you are in the debug mode, you can run any TCL command you like on your _oXXX handle.

    This can help you identifying the object by querying it until you are sure, what object it is.

    First of all, you could find out what type your tcl object is by typing:

    “_oXXX info class”

    Then you could use TCL functions of this object to find out more about it.

    For more information see also http://www.isi.edu/nsnam/ns/ns-debugging.html

  5. hello , thanx for help ..
    i was wondering if can i use this in cygwin ?

  6. I follow the instructions to install debugger, however I don’t know about the errors. Would anyone please help me

    [root@Munsub ns-2.34]# make
    make: *** No rule to make target `wpan/p802_15_4csmaca.o’, needed by `ns’. Stop.

    [root@Munsub Desktop]# ns f2.tcl
    warning: Script debugging disabled. Reconfigure with –with-tcldebug, and recompile.
    The expression value is: 15 and content of m is: {I am SFU Student}

    Thanks

  7. This link http://expect.nist.gov/tcl-debug/tcl-debug.tar.gz does not work and there is no other source for the tcl-debugger as well.
    Please upload the file if possible (coz the file that was once the most popular has become extinct like the dinosaur era), not getting even the first step right of the procedure mentioned is very frustrating.
    Else if there is any other site hosting the file pls let me know.

    Thanks .

  8. yes if someone manages to find the file please let us know..

  9. i finally found it here :

    http://web.tagus.ist.utl.pt/~pedro.estrela/ns2/files/tcl-debug-2.0.tar.gz

    (the aforementioned site was down for a couple of months , luckily it’s up again)

  10. Hi, I cant understand how to add your site into my rss reader. Can you help me, please! Thanks.

  11. hi, I tried your steps to install tcldebug, all is Ok but when I use debug 1, I had a warning error : script debug disabled. reconfigure –with-tcldebug and recompile. please help me, I use ns-2.34.
    thank’s.

  12. I have tried to load the tcldebug as given in your site. This is what I get.
    lambor@lambor-Inspiron-1545:~/NS/ns-allinone-2.34/tcl-debug-2.0$ ./configureloading cache ./config.cache
    checking for Tcl configuration… configure: warning: Can’t find Tcl configuration definitions
    ./configure: 630: .: #: not found
    lambor@lambor-Inspiron-1545:~/NS/ns-allinone-2.34/tcl-debug-2.0$ patch -p1 < tcl-debug-2.0-configure.patch
    bash: tcl-debug-2.0-configure.patch: No such file or directory.

    • I am also getting the error like below
      lambor@lambor-Inspiron-1545:~/NS/ns-allinone-2.34/tcl-debug-2.0$ ./configureloading cache ./config.cache
      checking for Tcl configuration… configure: warning: Can’t find Tcl configuration definitions
      ./configure: 630: .: #: not found
      lambor@lambor-Inspiron-1545:~/NS/ns-allinone-2.34/tcl-debug-2.0$ patch -p1 < tcl-debug-2.0-configure.patch
      bash: tcl-debug-2.0-configure.patch: No such file or directory.

  13. am having problems with ns2 installation
    sed: can’t read ./dltest/Makefile.in: No such file or directory
    creating tclConfig.sh
    make: *** No rule to make target `/home/admin/ns-allinone-2.28/tcl8.4.5/unix/dltest/Makefile.in’, needed by `Makefile’. Stop.
    tcl8.4.5 make failed! Exiting …

  14. please tell me whether the patch is fit to the ns2.35


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: