2008/03/17

316綠營大遊行

這不是政治文,這絕對不是政治文。

我的老闆是一位政治狂熱份子,每天的信箱總是會有固定幾封信是他寄來的,內容不外呼是馬19如何、國民黨又做什麼該死的事、要不然就是中國是如何的不好。不討論事實是如何,但這些行為多少都會有種催眠的效果。

前幾天他更進一步的展現他的熱情,他邀請我們參加316大遊行,而我再過幾個月就要碩士口試,他的邀請就如同拿著刀子抵著我的脖子笑笑問我「你要不要來參加遊行」,「ok」,我只能很無耐的回答。姑且不論我是否是綠營支持者,但我是個阿宅,阿宅是不會參加這種活動的。

當天早上,為了這個活動我從台北趕到新竹,回到新竹先吃個飯,吃完就睏了,睡了個小覺,睡到正爽,有個該死的電話吵醒了我,打開手機一看,心頭一涼「幹!!是老闆」,老闆很熱切的以為我到了找不到他們,還跟我說他們在那裡,我只能用很慌張的聲音說我還在路上>_<。掛上了電話,我只用了1分鐘的時間,整裝衝出了家門,一路狂飆到集合地,在路上己經有很多人集結了,在騎車的時候,阿妮一直跟別人比讚,大家都會回應我們,還滿好玩的。跟老師的集結地離學校有點遠,我騎了近20分鐘才到,到那還找了一下才找到他們。

找到他們後,他們已經開始在往下一站的地方走了,而且不斷地跟遇到的人擊掌,擊掌的時候,還會說「加油」或「當選」之類的,因為我們走了好長一段距離,擊掌擊到手好酸,除了手酸外,一直在看跟我擊掌的是不是正妹,這應該是唯一的樂趣。

整個活動大概就降,多多少少有一點感動到,但除了感動,究竟誰當選對我最好,不是台灣不是其他人,而是我。這是我投下這一票所思考的,在心中我已經有了答案。

2008/03/15

Gnucash: A personal finance tracking program

一個在Linux下的資金管理程式。

有興趣的人可以看以下介紹:
  • http://blog.xuite.net/michaelr/linux/16188248
  • http://blog.xuite.net/michaelr/linux/16196502
  • http://blog.xuite.net/michaelr/linux/16196596
  • http://blog.xuite.net/michaelr/linux/16196657

2008/03/12

Profiling tool: Valgrind with cachegrind

以下摘自官網:
Valgrind is an award-winning instrumentation framework for building dynamic analysis tools. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tools.
其中有個extension(skin)叫做cachegrind可用來做profile,而且還有qt-based的結果顯示介面,我做了個擷圖如下:

測試程式是apache。

在ubuntu上安裝這些軟體很方便,全部都apt-get就行。感謝製作軟體、維護套件庫的大家。

Ref.
Valgrind http://valgrind.org/

Profiling Apache 1.3.34 using GProf

因為某些原因必需profile apache 1.3.34,其中與一般使用gprof不同的是編譯時要加特別的參數,我將過程紀錄如下,其中有些是pseudo code。

$ tar xvf apache1_3_34.tbz
$ cd apache
$ ./configure --prefix=/home/fcwu/apache/working --enable-module=rewrite --enable-module=proxy
$ cat replace_cflags.sh
1 #!/bin/bash
2
3 TMP=`mktemp`
4 REPLACE="-pg -DGPROF -g -DNO_USE_SIGACTION -fno-stack-protector -fno-stack-protector-all"
5 #REPLACE="-pg -DGPROF -g -DNO_USE_SIGACTION -fno-stack-protector"
6 #REPLACE="-pg -DGPROF -g -DNO_USE_SIGACTION "
7
8 for file in `find src/ -name "Makefile"` ; do
9 echo "[Replace file=$file]"
10 grep -nH "^CFLAGS=" $file
11 sed "s/^CFLAGS=/& $REPLACE /" $file > $TMP
12 cp $TMP $file
13 grep -nH "^CFLAGS=" $file
14 done
15
16 rm -f $TMP
$ ./replace_cflags
$ make
$ cd src
$ gcc -static -pg -g -DLINUX=22 -DHAVE_SET_DUMPABLE -DNO_DBM_REWRITEMAP -DUSE_HSREGEX -g -pg `./apaci` -rdynamic -o httpd buildmark.o modules.o modules/standard/mod_env.o modules/standard/mod_log_config.o modules/standard/mod_mime.o modules/standard/mod_negotiation.o modules/standard/mod_status.o modules/standard/mod_include.o modules/standard/mod_autoindex.o modules/standard/mod_dir.o modules/standard/mod_cgi.o modules/standard/mod_asis.o modules/standard/mod_imap.o modules/standard/mod_actions.o modules/standard/mod_userdir.o modules/standard/mod_alias.o modules/standard/mod_access.o modules/standard/mod_auth.o modules/standard/mod_setenvif.o main/alloc.o main/buff.o main/http_config.o main/http_core.o main/http_log.o main/http_main.o main/http_protocol.o main/http_request.o main/http_vhost.o main/util.o main/util_date.o main/util_script.o main/util_uri.o main/util_md5.o main/rfc1413.o os/unix/os.o os/unix/os-inline.o ap/ap_cpystrn.o ap/ap_execve.o ap/ap_fnmatch.o ap/ap_getpass.o ap/ap_md5c.o ap/ap_signal.o ap/ap_slack.o ap/ap_snprintf.o ap/ap_sha1.o ap/ap_checkpass.o ap/ap_base64.o ap/ap_ebcdic.o ap/ap_strtol.o regex/regcomp.o regex/regexec.o regex/regerror.o regex/regfree.o \
modules/proxy/proxy_cache.o modules/proxy/proxy_connect.o modules/proxy/proxy_ftp.o modules/proxy/proxy_http.o modules/proxy/proxy_util.o modules/proxy/mod_proxy.o \
modules/standard/mod_rewrite.o \
-lm -lcrypt -lexpat -ldl -fno-stack-protector
$ make install
$ cd ~/apache/working/bin/
$ ./httpd -X -f /home/fcwu/apache/working/conf/httpd.conf
testing it
$ gprof ./httpd ../logs/gmon.out

其中有個重點是在編譯apache時,要用幾個特別的define值:"-DGPROF -DNO_USE_SIGACTION"。而為了讓gprof能work要加-pg的編譯參數,再為了讓時間的結果跑出來,必需用static的方式把所有的library以靜態的方式將所有想profile的部分編入(這就是我gcc很長長長的那一行)。

另外有些小技巧像是find的使用,我在測時intensively使用,像是:
find ~ -name "gmon.out" -exec ls -al {} \;
find ~ -name "gmon.out" -exec rm -i {} \;

2008/03/07

Busy and painful work

太久沒更新blog了,主要是因為忙著寫我的SocketTracker for thesis以及Chapter 1。

寫程式是件愉快的事,而且上個禮拜解決很多好玩的問題,像是記錄在system call被呼叫時,user program最後執行EIP位置,以及一些kernel hacking。

另一件事,寫Chapter 1就是件痛苦的事,真的很痛苦,一週我才有辦法寫個4面左右,問題不是出在英文,而是我這個人天生話少,一打開word又是坐在電腦前,什麼都不想做。
( 我不是想用word寫論文,而是範本就是給我word,如果要換成openoffice會很麻煩,而且老師也不好review)

接下來還要繼續痛苦下去。

除此之外,最近打算參加2個talk。一個是jserv給的快快樂樂學GDB,另一個是OSDC的conference。