在windows下調試ruby192

來源:互聯網
上載者:User

方案1:

使用wingdb + vc2010

1. 設定環境變數:(d:\Ruby187\other為我的zlib,openssl這些庫的目錄)

"C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"

set INCLUDE=%INCLUDE%d:\Ruby187\other\include;
set LIB=%LIB%d:\Ruby187\other\lib;

2. 產生Makefile

注意按這個目錄來,別進到win32目錄去了
D:\tmp\ruby-1.9.2-p180>win32\configure.bat --prefix=d:\tmp\rubydebug
        cl -nologo -MD rtname.c user32.lib -link > nul
Checking unicows.lib
Creating Makefile.new
"type `nmake' to make ruby."

3、修改makefile
OPTFLAGS = -W2 -wd4996  -Zm600
CFLAGS = /Od -MD $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG)
LDFLAGS = $(LDFLAGS) -Fm /DEBUG 

4、編譯、安裝

D:\tmp\ruby-1.9.2-p180\build>nmake

遇到下面這個錯語的話,將源碼刪除,再重新解壓編譯,不知道是什麼 問題。
NMAKE : fatal error U1045: spawn failed : Permission denied

編譯完成,可以安裝

D:\tmp\ruby-1.9.2-p180\build>nmake install

5、windbg啟動設定

"windbg.exe" -y C:\WINDOWS\Symbols;d:\tmp\ruby-1.9.2-p180;SRV*D:\symbols*http://msdl.microsoft.com/download/symbols

6、調試

啟動應用
Windbg提供了兩種方式來啟動應用,這裡以ruby的irb為例:
open executable:ruby -x "<path>\irb.bat",這時候我們可以很方便地在任何地方設定斷點,包括main函數。
也可以運行irb之後,在WinDbg裡選擇attach to a process, 在列出的進程中選擇ruby.exe。

第二種方案:

windbg+linux

(未寫完)

得到源碼之後,首先要對其進行編譯,不能採用預設的編譯方式,
要在執行./configure的時候加上如下參數
CFLAGS="-ggdb -g3 -gdwarf-2"
或者在Makefile中添加如下標誌參數:
optflags = -O
debugflags = -ggdb -g3 -gdwarf-2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.