之前在Leopard (Mac OS X 10.5.X)的時候,都是靠Macports在討生活的,大部份我常用的ports都還Maintain的不錯,但到了Snow Leopard (Mac OS X 10.6.X) 的年代,發現許多ports都被發的bug都一直掛著沒人維護,小弟只好自力救濟了。像是著名的GDB神器,在console底下,只要下個 port search gdb ,就會出現這麼樣一個東西:gdb @6.8 (devel)
6.8版,還蠻新的嘛。接著再下 sudo port install gdb ,就會出現底下不堪入目的畫面
GDB: The GNU Project Debugger---> Computing dependencies for gdb
哪泥......macports裡頭竟然連gdb的檔案都沒放了,不再是萬能的了,此時只好靠萬能的”source code”以及"gcc"了,心想只要有心,沒有porting不過來呀...科科,就是這"灌C"的威力。先來抓個最新版的weekly build的GDB來嚐鮮一下
---> Verifying checksum(s) for gdb
Error: Target org.macports.checksum returned: Could not open file: /opt/local/var/macports/distfiles/gdb/gdb-6.8.tar.bz2
Error: Status 1 encountered during processing.wget ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-7.0.50.20091110.tar.bz2
接著, bunzip2 gdb-*.tar.bz2 解開這壓縮檔。重點戲來了,configure一下,藍色字是key point,記得加,這是在Snow Leopard上編gdb成功的關鍵: $ ./configure --disable-werror --build=x86_64-apple-darwin10 --prefix=/Users/kent/usr
這個時候build成功了,很開心的跑 gdb ./hello ,我想應該會出現
$ make && make installGNU gdb (GDB) 7.0.50.20091110
心想,搓屎…怎麼會這樣,找不到debug symbol..囧rz。(後來發現,好像每次都會出現,但還是可以正常使用,先不管…堪用),再接著執行
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin10".
For bug reporting instructions, please see:
Reading symbols from /Users/kent/RD1-2/practice/GDB/gdb-samples/hello...(no debugging symbols found)...done.
(gdb) (gdb) b main
後來求助於Google,似乎是權限的關係,假使你當初就用root權限安裝的話,就沒這問題了。若你和我一樣喜歡安裝在個人目錄下(有代--prefix=/Users/xxx/參數),記得將gdb作個權限相關設定
Breakpoint 1 at 0x100000f0c: file hello.c, line 6.
(gdb) run
Starting program: /Users/kent/RD1-2/practice/GDB/gdb-samples/hello
Unable to find Mach task port for process-id 80958: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
(gdb) $ sudo chgrp procmod /yourpath/gdb
$ sudo chmod g+s /yourpath/gdb
前一篇有個網友提到的擾人的"^M"符號的問題,果然從gdb v6.3.5升到gdb v7.0之後就迎刃而解了,照慣例,抓張圖吧。
Tags Cloud
My Secret Notebook (我的火星文記事本)
mm0NiDU82M4jV6t2RBCBrz25cuC9sjNwAuamtlEmcM1VguTu
hVs5vX7xayeXoDLwLRIsXDdxVSYNoZecdMY16+hwqpbgm2ch
78a90t0Gr9zL74TcZYwjdl3BbmnCRBJjD88dRHxdcPqIiDGp
zWe9q/XdSxe6yXKdh/hwQJ+D+o6XPWboby+RmoOtn9wmdQnN
o8h7BKWLQQMO+5XEV0RDZmUO3X7ADN8bzC8JmhP1BVP2V80d
Fs3ohWPSt7UBKnHCwI5tyeakRQihDKCzfiP7F0J+spSxCSlR
PqAj0w88PWB2ax8Y2++K/XMFHF6VuSeRhSMCaExmTTLqngxc
WlEA551OvUriquyW8QQc6jVg8lQn4m4H78QgUPvc2F3LsYKm
fd9HLa+mXrnTgh4SfgyUmS84BZdoGpMbfM4OpuWgFVZcN2e/
uKhuJm7md4G0wyo7efCLPwWWWqxZG8yzwQAHDQr5p/3xZeX4
qjMXzpXiwCqLzTGbZPqx9XMDqtrardSQNAw3dJgxgWALNzyu
/OOiDZGnobvYgDXDRuMQHo1k7gvSR7J+SNIbw7cd4696ChIL
c97GW+hdMcpTOcK9dhIKK8tXDJxiM7OSA28KCN4Wn3N1iJ9y
w4Y6W4GqbSiRxrze5zwOGeG5SbvrYvJ4LSDgND6fszdE43uk
PoPKYyfg3r4JcwrcqDJXcv1jWDuLi1swUK8lXhLLA7Ahfl8a
r+3IJJ4bnUASn9UiEMRZsOKJvK83A/TVZTS5QTz9etA60x7T
67VlH432PnH/ktoaE1XmqhbFgZ7v9UD7ujgxFMYvJ7Y9dNcI
bd3iUVa9EmudYLEuw4Otze1lLL3NQgUb+NNjgKx7r6bUHdmZ
WW7V9g==
My Flickr
[+/-] |
[Mac/Snow Leopard] build GDB v7.0 from source |
[+/-] |
[VimGdb = vim + gdb] build vim from source with vimgdb patch |
我想對於vim和gdb的搭配,最完美的組合莫過於vimgdb這個patch了。前一陣子在苦腦怎麼樣的環境會讓我操作gdb這個神器最順手呢?! 讓我能夠remote debugging在ARM開發板上的程式得心應手呢 ^^ ?! 先來張snapshot吧!
※你看,在PTT->LinuxDev版上,連宅色夫(jserv)大神都推薦,沒道理不用呀...囧rz
在X11(X-Window)的底下的話,DDD, Insight都還算順手,但這時就得在PC上跑個X Server (推薦 Xming: X Server for Windows),有點太浪費資源了,有時只為解個小bug,我想不用出動ddd, insight這種機絲吧。
在Console底下的話,我想 gdb --tui 或是 cgdb 就蠻好用了,但身為一個VIMer,若能將gdb整進vim就更完美了,果然你想到的東西,別人都想過了...也作好了...XD! Great,有現成的就直接拿來用啦。用過之後,越來越順手,反應速度當然也比ddd,insight這些x11的app快些,果然還是CLI模式順手呀。
Clewn(for gVim) / vimGdb(for Vim) 官網:
http://clewn.sourceforge.net/index.html
安裝過程很簡單,只要三個部驟。首先,去vim官網抓這包source code (vim-7.2.tar.bz2),接著抓vimgdb(for vim72)這個patch檔。最後就是先解開以上兩包,再上patch啦。官網教學在此,小結如下:
1. tar xjf vim-7.2.tar.bz2
2. tar xzf vimgdb72-1.14.tar.gz
3. patch -d vim72 --backup -p0 < vimgdb/vim72.diff
4. cd vim72
#重點是configure時,記得加上--enable-gdb這個參數
5. ./configure --enable-cscope --enable-gdb --enable-multibyte --disable-gui --enable-gui=no --without-x --disable-gpm --disable-nls --with-tlib=ncurses --enable-pythoninterp --prefix=/home/kent/usr/
6. make && make install
NOTE: 在Ubuntu 9.10 和 Snow Leopard (Mac OS X 10.6.2)底下build這vim時遇到了一個問題,build出來的vim,一跑起來就出現 *** buffer overflow detected ***: ./vim terminated ,後來Google之後,也有人遇到這個問題,後來繼續追下去,追到GNU gcc的bugzilla去了,有人發了一個bug給gcc : vim crashes on startup when compiled with -O3 but works with -O2,裡頭提到產生這問題的關鍵點,記錄一下,或許以後會遇到,最終這個bug被歸類為 "RESOLVED INVALID"
===============================================
NOTE: In Ubuntu 8.10 and later versions, -D_FORTIFY_SOURCE=2
is set by default, and is activated when -O is set to 2 or higher.
This enables additional compile-time and run-time checks for several
libc functions. To disable, specify either -U_FORTIFY_SOURCE or
-D_FORTIFY_SOURCE=0.
===============================================
The difference between -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2
is e.g. for
struct S { struct T { char buf[5]; int x; } t; char buf[20]; } var;
With -D_FORTIFY_SOURCE=1,
strcpy (&var.t.buf[1], "abcdefg");
is not considered an overflow (object is whole VAR), while
with -D_FORTIFY_SOURCE=2
strcpy (&var.t.buf[1], "abcdefg");
will be considered a buffer overflow.
============================================
所以,在 Ubuntu 及 Snow Leopard 底下,若要build vim from source的話,請記得加上 CFLAGS="-O3 -D_FORTIFY_SOURCE=1",將我常用的configure參數記錄如下:
./configure --enable-multibyte --enable-cscope --disable-gui --enable-gdb --prefix=/Users/kent/usr/ CFLAGS="-O3 -D_FORTIFY_SOURCE=1"
[+/-] |
[Apple] Magic Mouse |
登登登登…新玩具 Magic Mouse 來啦,感謝本公司同事macglee大大熱情贊助,遠從日本空運回國,台灣還沒上市。在還沒被弄髒之前,趕緊來幫它Take a picture,雖然它的設計應該很難髒掉,一直都會閃亮亮....來個偽開箱文唄
這隻魔術鼠還挺好用的,使用前記得"洗手"...囧,再加個鼠墊,因為用雙指作"左撥、右撥"的那個手勢,若手指黏黏的話,加上老鼠沒穿NIKE球鞋,抓地力不怎麼好,一撥…整隻就跟著跑掉了.....其它的部分都令人很滿意,加上沒有上一代老前輩 "Mighty Mouse"必需常清G"點"的困擾,對我來說更有吸引力,贊啦!.官網:http://www.apple.com/magicmouse/
[+/-] |
[Cool] Wordle |
蠻有趣的一個Service,是用Java Applet寫的,真是難得呀...run起來的反應速度還挺快的,比想像中順多了...。官網在這 http://www.wordle.net/ ,簡介如下:
Wordle is a toy for generating “word clouds” from text that you provide. The clouds give greater prominence to words that appear more frequently in the source text. You can tweak your clouds with different fonts, layouts, and color schemes. The images you create with Wordle are yours to use however you like. You can print them out, or save them to the Wordle gallery to share with your friends.
.Wordle - Kaie's Blog :
.Wordle - VIVOTEK :