1. 程式人生 > >tcl-debug-2.0 安裝除錯 NS2.34

tcl-debug-2.0 安裝除錯 NS2.34

1、./configure --prefix=/path

prefix選項是配置安裝的路徑,如果不配置該選項,安裝後可執行檔案預設放在/usr/local/bin,庫檔案預設放在/usr/local/lib,配置檔案預設放在/usr/local/etc,其它的資原始檔放在/usr/local/share,比較凌亂。

如果配置prefix,如:./configure --prefix=/usr/local/test可以把所有資原始檔放在/usr/local/test的路徑中,不會雜亂。

2、./configure --with ssl=/path

./configure 這個指令碼是開發者提供的,with-ssl 這個選項的行為也是開發者定義的。

一般情況下開發者會列舉幾個常見的 ssl 路徑在 configure 腳本里面,這樣如果使用者不輸入 with-ssl 引數的時候 configure 指令碼能一定程度上自動探測到系統裡面的 ssl 庫所在位置。

也有一種情況是開發者預設讓 with-ssl 這個引數關閉,也就是說使用者必須使用這個引數 configure 指令碼才會去檢測 ssl 庫的位置。

為 with-ssl 加上一個路徑的這種用法,configure指令碼會忽略掉自動探測 ssl 位置的那段邏輯,直接使用使用者輸入的路徑。

        tcl 安裝 configure 其他引數詳解見此貼:https://blog.csdn.net/linuxarmsummary/article/details/10947715

3、安裝 tcl-debug-2.0

https://blog.csdn.net/linuxarmsummary/article/details/10947715

https://blog.csdn.net/bill_chuang/article/details/8811591

https://blog.csdn.net/flyuniverse_shell/article/details/5956618

https://www.cnblogs.com/helloWaston/p/4544875.html

(1)下載 tcl-debug-2.0 到 /home/ns-allinone-2.34 目錄下,並解壓,執行

$cd /home/ns-allinone-2.34/tcl-debug-2.0

$./configure --prefix=/home/ns-allinone-2.34/ns-2.34 --with-tcl=/home/ns-allinone-2.34/tcl8.4.18/unix/

$make

(2)拷貝生成的庫檔案 libtcldbg.a 到 /home/ns-allinone-2.34/ns-2.34/lib 目錄下

$cp libtcldbg.a /home/ns-allinone-2.34/ns-2.34/lib

(3) 進入ns-2.34目錄下面,即 /home/pengyu/ns-allinone-2.34/ns-2.34
(4) 重新配置NS-2以便啟用tcl-debug.
      $ ./configure --with-tcldebug=/home/pengyu/ns-allinone-2.34/tcl-debug-2.0

      出現過以下兩行則表示配置成功:

      checking for libtcldbg... -L/home/share/ns-allinone-2.33/tcl-debug-2.0 -ltcldbg
      checking dmalloc... not requested with --with-dmalloc

(5)刪除以前的編譯紀錄
           $ make clean
(6)重新編譯NS-2
          $ make   
         現在tcl-debug已經嵌入到NS-2的可執行檔案"ns.exe"中去了
(7)檢查NS-2是否能夠正常執行。隨便選擇一個指令碼測試一下就可以了
         $ ns  example.tcl

4、ns2 make 出現下面情況

make[1]: Entering directory `/home/ns-allinone-2.34/ns-2.34/indep-utils/cmu-scen-gen/setdest'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/ns-allinone-2.34/ns-2.34/indep-utils/cmu-scen-gen/setdest'
make[1]: Entering directory `/home/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/dec'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/dec'
make[1]: Entering directory `/home/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/epa'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/epa'
make[1]: Entering directory `/home/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/nlanr'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/nlanr'
make[1]: Entering directory `/home/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/ucb'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/ucb'

 

該現象不影響使用,程式能跑。。。此貼已解決此問題:https://blog.csdn.net/zhf100404218/article/details/51152817

5、檢查tcl-debug是否能夠正常工作。
    你可以通過新增debug 1在你的指令碼中設定斷點。示例如下:
    (1)從目錄~ns/tcl/ex directory 裡面選擇一個指令碼, 如:wireless-test.tcl,
        利用文字編輯器編輯該指令碼:
        set ns_  [new Simulator]
        debug 1;  # 在這個位置新增這麼一行程式碼
        set chan [new $opt(chan)]

    (2)執行 wireless-test.tcl
         $ ns wireless-test.tcl
        
    執行指令碼之後,如果你成功安裝,程式會停在斷點處,並會出現以下資訊提示:
         2: lappend auto_path $dbg_library
         dbg2.0>

使用:

在NS2中除錯TCL/OTCL指令碼了。設斷點的方法是,直接在指令碼檔案中相應的位置加上debug 1。一些基本的命令如下:
s 單步執行(進入程序)
n 單步執行(不進入程序)
c 繼續
r 繼續執行直到從過程中返回
u 轉至上級作用域
d 轉至下級作用域
w 列出呼叫棧
b 設定,清除或顯示斷點
h 幫助

執行指令碼,就會在相應的斷點位置停下來,可以使用puts命令來列印輸出各種變數的值。info也是一個我常用的命令。
info exists 
info class //查詢一個物件的類名
info instances //查詢一個類的所有例項
info instprocs //查詢一個類的所有例項過程
info vars
info superclass/subclass //查詢一個類的超類/子類

 

6、gdb除錯C++部分

如果系統不自帶gdb,則先安裝,安裝好後需要修改$NS_HOME/ns-2.34中的Makefile檔案,使得編譯後的可執行檔案帶除錯資訊
將原來檔案中的
CCOPT =  -Wall -Wno-write-strings 
中間新增-g,即
CCOPT =  -Wall -g -Wno-write-strings 
然後重新編譯
make clean
make

使用時,
#cd $NS_HOME/ns-2.34
#gdb ns
#gdb>run test.tcl
然後如果要在某個原始檔中新增斷點
(gdb)>b mac/mac-sensor.cc (注意,這裡是原始檔,不是可執行檔案)
(gdb)>b mac/wireless-phy.cc
(gdb)>run XXX.tcl