Planet ITRS

January 27, 2012

C99 好用的語法

之前只有用到 C99 的 loop initial declarations (在 for 的初始化部份宣告變數), 看 Scott 提到才知道有其它好東西, 順便來掃一下 C99 的功能

stdbool.h

定義 bool、true、false, 實際上是將 bool 對應到 C99 定義 _Bool

stdint.h

定義了整數範圍、int16_t、int32_t、int64_t 等型別, 再也不用查 short/int/long 等在 32/64 bit OS 上的大小為多少。

designated initializers

可攜又易讀的初始化 (ref.)

// array
int widths[] = { [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 };
// struct
struct point { int x, y; };
struct point p = { .y = yvalue, .x = xvalue };

像要用建表實作 isspace() 的話, 這樣寫超清楚的:

bool myisspace(int ch) {
    static bool whitespace[256] = {
        [' '] = true, ['\t'] = true, ['\f'] = true,
        ['\n'] = true, ['\r'] = true
    };

    if (ch < 0 || ch >= 256)
        return false;
    return whitespace[ch];
}

其它

像 snprintf、inline、variable-length array (例如 int array[n]) 也很實用。

by fcamel (noreply@blogger.com) at January 27, 2012 04:52 AM

fcamel 說 Where is stdbool.h? - 原來有 stdbool.h 這種東西啊, 看 nohup 的原始碼才知道cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png

fcamel 說 Where is stdbool.h? - 原來有 stdbool.h 這種東西啊, 看 nohup 的原始碼才知道
cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png

by fcamel at January 27, 2012 02:44 AM

January 26, 2012

signal 小知識

TLPI 長知識。

先送 SIGTERM 再送 SIGKILL 砍程式

若程式有照標準寫, 可能會有 SIGTERM 的 handler, 在收到這 signal 時做些清理動作 (砍暫存檔、釋放資源等), 再自我了結。而 SIGKILL 就直接掛了。所以, 先給人家一個機會掛得優雅一些, 若對方拒絕的話, 再狠一點直接掛了它。

附帶一提, ctrl + c 是送出 SIGINT。

SIGHUP 的行為

terminal 斷線 (hangup) 時, terminal 的主控 process 會收到 SIGHUP。而它的預設行為是終結程式, 所以關掉 terminal 時, 裡面的程式會直接結束。

bash 和 ksh 在結束的時候會送 SIGHUP 給背景程式, 若背景程式也沒寫 SIGHUP handler, 那它們也會一起結束。這是關掉 terminal, 全部程式會一起結束的原因。

要避免這個行為, 可用 nohup 執行程式, 它會做 I/O 重導、執行 signal (SIGHUP, SIG_IGN), 然後執行目標程式。或是用 bash 的 disown -h, 再放到背景跑, 或用 gdb attach process, 再輸入 handle SIGHUP nopass

用 SIGQUIT 產生 core dump

在 terminal 按 ctrl + \ 時會送出 SIGQUIT 給前景程式, 這個 signal 的作用是要就該程式自我了結並產生 core dump。當然, 一些設定要先設好, 才會有 core dump

這有許多好處:

  • 程式進無窮迴圈時按 ctrl + \, 再用 gdb 列 backtrace 看卡在那。雖說直接 用 gdb attach 也 ok。若高中練 ACM 知道這個方法, 可省下一些除錯時間 (遠目)。
  • 方便測試 core dump 設定, 不用另寫個小程式故意寫入不合法的位置。

by fcamel (noreply@blogger.com) at January 26, 2012 07:44 PM

《三月的獅子》語錄

出自 64 話:
「只要願意相信, 夢想就能實現」
這或許是真的吧
但是欠缺了一句

「只要願意相信, 並持續努力的話, 夢想就能實現」
---------- 這才是真理


或著更應該說

「比其他的對手花多一小時, 每天都持續努力, 做到這程度夢想就有相當大的機率」 實---現


作為至理名言, 愈短愈好
--- 但是這也太言簡意駭了吧


這樣一來簡直就變成
「只須袖手以待」「只須去相信」
就可以實現夢想的意思了嘛

把這句話削減到這個地步的傢伙
到底在想什麼啊
我很想問問他
為什麼要削減成這樣
看這部作品有種壓盡全身的空氣, 重重地全吐出來的感覺。希望往後的日子裡, 能一直保有這種感受。

by fcamel (noreply@blogger.com) at January 26, 2012 05:42 PM

fcamel 說 0rz.tw/C2Pfb 看三月的獅子真的有那種壓盡全身的空氣, 重重地全吐出來的感覺, 比全力一擊還要更嚴苛的感受

fcamel 說 0rz.tw/C2Pfb 看三月的獅子真的有那種壓盡全身的空氣, 重重地全吐出來的感覺, 比全力一擊還要更嚴苛的感受

by fcamel at January 26, 2012 04:41 PM

fcamel 說 埃西亞商會: 不保護產權嗎? - 精闢的分析和生動的生活例子, 像電影院之於下載電影, 網路遊戲收費轉型, 還有&quot;賣不了漫畫給台灣人,賣你玩具總可以吧?&quot; XD

fcamel 說 埃西亞商會: 不保護產權嗎? - 精闢的分析和生動的生活例子, 像電影院之於下載電影, 網路遊戲收費轉型, 還有"賣不了漫畫給台灣人,賣你玩具總可以吧?" XD

by fcamel at January 26, 2012 03:59 PM

fcamel 說 3月的獅子 43 回的反差效果太強了!! 若一口氣從前面讀下來會更感人吧

fcamel 說 3月的獅子 43 回的反差效果太強了!! 若一口氣從前面讀下來會更感人吧

by fcamel at January 26, 2012 03:29 PM

fcamel 說 人腦只有一個 CPU, 長期來看, 愈少 context switch, 產能愈好, 應該盡可能做一件事就做到一個段落再進行下一個。更何況人腦多做 context switch 會更累, 之後速度會更慢, 成本更高

fcamel 說 人腦只有一個 CPU, 長期來看, 愈少 context switch, 產能愈好, 應該盡可能做一件事就做到一個段落再進行下一個。更何況人腦多做 context switch 會更累, 之後速度會更慢, 成本更高

by fcamel at January 26, 2012 10:36 AM

fcamel says [中字] 日本豐田汽車 多啦a夢 CM 第四彈 技安:我的妹妹哪有那麼可愛 XD

fcamel says [中字] 日本豐田汽車 多啦a夢 CM 第四彈[中字] 日本豐田汽車 多啦a夢 CM 第四彈 技安:我的妹妹哪有那麼可愛 XD

by fcamel at January 26, 2012 07:07 AM

January 25, 2012

Python 的特別之處 (1)

從新手的眼中來看 Python,比較能看出 Python 和其它語言不同之處。最近有機會幫別人快速上手 Python,就順便整理一下我從中發覺 Python 較為突出的優點。

list、dictionary and string

平時 coding 最常用到的 container 就是 list 和 dictionary,另外也會常用到字串操作,Python 提供方便的方法來操作它們。string 可看成一個有實作 list 介面的類別,一些常用操作像是 slice:"abcd"[1:3] 回傳 "bc";負數的索引: "abcd"[-1] 回傳 "d";直接和 for-loop 整合在一起:

In [1]: for ch in "abcd":
....: print ch
....:
a
b
c
d

讓存取這些常用資料型態輕鬆許多。

iterator

使用 iterator 比傳統的 for (i=0; i<n; i++) 來得清楚,Python 針對 iterator 下了不少工夫,提供好用的輔助函式,像是 enumerate 補足需要用到 index 的情況:

In [2]: for i, n in enumerate([1, 3, 5]):
....: print i, n
....:
0 1
1 3
2 5

使用 zip 整合多個 list:

In [3]: names = ["John", "Marry", "Tom"]
In [4]: sexes = ["Male", "Female", "Male"]
In [5]: for name, sex in zip(names, sexes):
....: print name, sex
....:
John Male
Marry Female
Tom Male

map, filter and reduce

任何使用過 map 的人,都會喜歡 map 輕巧的用法,來看幾個例子:

In [1]: map(int, ["12", "37", "999"])
Out[1]: [12, 37, 999]
In [2]: map(str, [12, 37, 999])
Out[2]: ['12', '37', '999']

int 是一個函式,將傳入的物件轉成整數;str 則是轉成字串。使用 map 可以將一個 iterator 轉為另一種 list。

另一個常見的情境是,從一個 list 裡篩選出需要的物件,比方說只留下偶數:

In [1]: numbers = [1, 2, 3, 4, 5]
In [2]: filter(lambda x: x % 2 == 0, numbers)
Out[2]: [2, 4]

或像 filter(lambda s: s.endswith('.py'), file_names) 只留下結尾為 ".py" 的字串。

除 map 和 filter 的重心放在轉換 list 之外,reduce 則是將 list 匯整成一個物件。有了這些函式,就能任意的操作 list,用以匯整或擴散資料容器。

比方說將一串數字加起來:

In [1]: numbers = [1, 2, 3, 4, 5]
In [2]: reduce(lambda x, y: x + y, numbers, 0)
Out[2]: 15

上面這個例子可以用內建的 sum 取代,來看另一個複雜點的例子,將一串 0、1 值合成一個整數:

In [1]: bits = [0, 1, 0, 0, 1]  # bits[i] 的值表示 2^i 的系數

In [2]: reduce(lambda x, (i, b): x | (b << i), enumerate(bits), 0)
Out[2]: 18

list comprehension

map 和 filter 雖然方便,要用到 lambda 或是混合使用時就沒那麼好讀了。Python 提供一個重量級的武器 list comprehension 來解決這問題。比方說留下偶數並乘以三再加一:

In [1]: numbers = [1, 2, 3, 4, 5]

In [2]: [n * 3 + 1 for n in numbers if n % 2 == 0]
Out[2]: [7, 13]

綜合以上的語法,可以輕鬆地寫出易懂的 quick sort

def qsort(numbers):
if len(numbers) <= 1:
return numbers
pivot = numbers[0]
rest = numbers[1:]
smaller = [n for n in rest if n <= pivot]
larger = [n for n in rest if n > pivot]
return qsort(smaller) + [pivot] + qsort(larger)

對於習慣 C、C++、Java 世界的人來說,應該不曾看過這麼直覺易懂的 quick sort 吧。

tuple

tuple 是一個很妙的資料結構,它和 list 的主要差別是它是唯讀的,Python 裡鮮少有這種唯讀物件。不過它較易發覺的好處是被用在 Python 的 parallel assignment 和函式傳回值。

於是在 Python 裡可以這麼寫:

a, b = b, a # swap

Python 在看到 b, a 時會產生一個 tuple 表示 (b, a),再透過 tuple 達到 parallel assignment

函式也可以一次「傳回多個結果」:

In [1]: def divide_and_mode(a, b):
...: if b == 0:
...: return None, None
...: return a / b, a % b
...:

In [2]: divide_and_mode(7, 3)
Out[2]: (2, 1)

In [3]: a, b = divide_and_mode(7, 3)

In [4]: a
Out[4]: 2

In [5]: b
Out[5]: 1

原理一樣是先轉成 tuple 再傳回,再視等號左側放什麼,決定要存成 tuple 或做 parallel assignment

2012-01-25 更新

應該沒什麼力氣更新續篇,在這裡簡短描述一下,有興趣的人可以找看看相關介紹。

with

在 Python 2.6 後,支援用 with 管理資源。像讀檔案可以用 with 的方式寫:


# 印出所有使用者的 id
with open('/etc/passwd') as fr:
for line in fr:
print line.split(':')[0]

在進入 with 的 block 前,會呼叫 file object 的 __enter__ 以獲得 file descriptor;在離開 block 前會呼叫 __exit__ 關掉 file descriptor。即使中間呼叫了 sys.exit() 或丟出 exception,仍會執行到 __exit__,不用擔心會漏關。方便用在許多情境 (比方說 lock / unlock、自動 flush output buffer),易讀易用。

內建常用函式庫

除上述的基本資料結構和 string 外,還有 sqlitejson等。

簡單不易出錯的語法

舉幾個寫 C 可能發生的問題,但在 Python 的語法下則不會發生:

if (condition);
{
// BUG!! 這裡的程式一定會被執行
}
if (x < 60)
number_of_fail++;
total_fail_score += x; // BUG!! 這行每次都會執行

另外,由於 Python 的 condition 只能是 expression,不能是 assignment。不會有 if (x -= 3 < 0) 這種 bug。

by fcamel (noreply@blogger.com) at January 25, 2012 04:15 PM

January 24, 2012

fcamel 說 哈哈, 看 TLPI 3.6.1 知道 man feature_test_macros 有說明跨平台 API 如何用 feature test macro 決定支援那些功能 (先影響引入的標頭檔), 解開之前的疑問了 tinyurl.com/7czur2k

fcamel 說 哈哈, 看 TLPI 3.6.1 知道 man feature_test_macros 有說明跨平台 API 如何用 feature test macro 決定支援那些功能 (先影響引入的標頭檔), 解開之前的疑問了 tinyurl.com/7czur2k

by fcamel at January 24, 2012 06:48 PM

fcamel 說 之前看到一些很硬的好書時, 會想說每天翻個三四頁, 一年下來總會讀完吧。雖說實際執行起來相當困難, 也從沒完全落實過。但在 TLPI 的情況, 即使真的落實了, 還是讀不完 XD

fcamel 說 之前看到一些很硬的好書時, 會想說每天翻個三四頁, 一年下來總會讀完吧。雖說實際執行起來相當困難, 也從沒完全落實過。但在 TLPI 的情況, 即使真的落實了, 還是讀不完 XD

by fcamel at January 24, 2012 04:15 PM

January 23, 2012

日常 4

這幾天隨意讀書, 所知進展許多。滿足求知欲之後, 想到 Steve Wozniak 的那句話「我是一個工程師, 會把人放在心裡的工程師」, 不經沉思了起來。雖說是沉思, 也只是對自己做做樣子, 腦裡到沒有真的在想什麼。

憶起在冬天漫步的往事, 回顧當年的文章, 才發覺許多記憶已失落不返, 慶幸當時有留個痕跡。

回頭翻之前的舊文, 寫於 2007-12-26 的這段話:

寫這種文章時, 隨著時空交錯,
又會有種渺小感, 想起以前寫的文章
http://fcamel-fc.blogspot.com/2006/10/blog-post_22.html

看了看當時的感受, 頗有意思的,
現在住的地方, 最大的缺點大概是天空太小, 沒有好景觀,
昨天從浩然走往活動中心時,
被正中間的圓月嚇到了

由浩然的最低處仰頭看,
整個天空溢出了視野,
薄紗般的雲貼在天空之下,
在那之後是透出光暉的明月

我停下腳步, 仰頭注視著偶然一角透出的美景,
很想拿個廣角鏡頭拍下, 將溢出視野的天空一起補入一張畫面裡

過了一會兒, 景色已映入心裡, 激盪的餘波退去後,
我抬起單腳, 繼續往活動中心走去

出社會的變化, 一言難盡。在無形中過渡到另一種生活後, 才驚覺逝去不回的東西。寫此文時的背景樂是 cs 推薦的鱷魚的眼淚, 沒注意歌詞, 音樂到是頗契合這個時間點的氣息。

by fcamel (noreply@blogger.com) at January 23, 2012 07:28 PM

fcamel 說 在滿足求知欲之後, 想到 Steve Wozniak 的那句話「我是一個工程師, 會把人放在心裡的工程師」, 新年的深夜真是思考人生的好時機

fcamel 說 在滿足求知欲之後, 想到 Steve Wozniak 的那句話「我是一個工程師, 會把人放在心裡的工程師」, 新年的深夜真是思考人生的好時機

by fcamel at January 23, 2012 06:59 PM

打開 core dump 和使用 cgdb 檢查程式掛點原因

前置動作

首先, 用 gcc/g++ 編程式時記得加 -g 以加入除錯資訊。

接著要讓程式掛掉時可以寫入 core dump, Ubuntu 預設是關著的。執行 ulimit -c unlimited 允許產生無限大小的 core dump, 之後執行程式掛掉時才會產生 core dump。我是直接將這加到 ~/.bashrc 裡。

預設 core dump 的檔名可能不合使用, 參考《setting the core dump name schema》得知, 可用 echo "core.%e.%p.%t" | sudo tee /proc/sys/kernel/core_pattern 改變 core dump 的檔名, 這樣檔名會記錄是程式名稱、PID、發生的時間。在 multi-process 或 multi-thread 時特別有用。若希望每次開機都會生效, 則要在 /etc/sysctl.conf 加入 kernel.core_pattern = core.%e.%p.%t

另外 core pattern 也可以是 "| PROGRAM", 這樣會將 core dump 導到 PROGRAM 的標準輸入, 可以自己寫 PROGRAM 做控制。像是 core dump 太頻繁時, 取樣留下幾個就好, 以免一下就塞爆硬碟。同樣的, %e 那些參數也可以接在 PROGRAM 後當參數用, 像是 "| PROGRAM core.%e.%p.%t", 自己的 PROGRAM 就能從 argv[1] 裡取得適合的檔名。

檢查 backtrace

$ gdb PROGRAM

然後在 gdb 內執行

core core.PROGRAM.PID.TIMESTAMP

接著就能用 bt N 看最底層 N 個 call stack 為何, 也就是所謂的命案現場啦。然後可用 up, do, l 等指令切換 call stack 和列出週圍程式。

在和 gdb 相處一段時間後, 覺得這樣在 stack 之間移動很方便, 但看週圍的程式太辛苦了, 還是會開另一個視窗用 VIM 看完整一些的程式。

看到 jserv 建議使用 cgdb, 試了發現, 人生...啊不, 是視窗變彩色的了!! 不只有彩色的程式碼, 還外加類 VI 的瀏覽方式, 相當順手。

目前有用到的功能如下:

  • 按 i、ESC 在程式碼視窗和 gdb 命令列之間切換。
  • 程式碼視窗裡可用 VI 的部份指令移動行數; 回到命令列後和 gdb 完全相容, 可按上下鍵選用之前的指令。
  • 在程式碼視窗按空白鍵加減 break point。

官網文件有詳細的說明, 之後來掃一遍, 看有什麼好東西可用。

by fcamel (noreply@blogger.com) at January 23, 2012 06:21 PM

fcamel 說 對照自己喜歡的漫畫、日劇, 發覺我似乎偏好追求自我實現的作品, 像是蜂蜜與四葉草、三月的獅子、交響情人夢、大和拜金女 (歐介多少有一些啦)。看了都會有種雄雄的熱血爆發出來, 並帶有一層孤寂感

fcamel 說 對照自己喜歡的漫畫、日劇, 發覺我似乎偏好追求自我實現的作品, 像是蜂蜜與四葉草、三月的獅子、交響情人夢、大和拜金女 (歐介多少有一些啦)。看了都會有種雄雄的熱血爆發出來, 並帶有一層孤寂感

by fcamel at January 23, 2012 05:04 PM

fcamel 說 高中第一次看 linux programming 時, 一直沒看懂 session 那章, 現在看 TLPI 2.14 的簡介, 卻覺得直覺易懂

fcamel 說 高中第一次看 linux programming 時, 一直沒看懂 session 那章, 現在看 TLPI 2.14 的簡介, 卻覺得直覺易懂

by fcamel at January 23, 2012 02:22 PM

ITRS Wiki

Electronics Retailers

Online Retailers:

← Older revision Revision as of 12:38, 23 January 2012
Line 1: Line 1:
== Online Retailers ==
== Online Retailers ==
-
* http://www.digikey.com/
+
* http://www.digikey.com/ Digikey
-
* http://taiwan02.rs-online.com/web/
+
* http://taiwan02.rs-online.com/web/ RS-Online
-
* http://www.sparkfun.com
+
* http://www.sparkfun.com Sparkfun
-
* https://www.adafruit.com
+
* https://www.adafruit.com AdaFruit
* http://www.terasic.com.tw (友晶科技) FPGA and extensions boards, based in Hsin Chu
* http://www.terasic.com.tw (友晶科技) FPGA and extensions boards, based in Hsin Chu
 +
* http://www.pololu.com/ Pololu
 +
* http://aroboto.com/shop/ 藝科資訊
 +
* http://www.twarm.com/commerce/ 德源科技
 +
* http://class.ruten.com.tw/user/index00.php?s=cyberchen78 陳生電子
 +
* http://class.ruten.com.tw/user/index00.php?s=lilan-1 秋葉原電子
== Brick and Mortar (near Taipei unless otherwise noted) ==
== Brick and Mortar (near Taipei unless otherwise noted) ==

by Rickchung at January 23, 2012 12:38 PM


駱嘉濠

在 Linux 下開發 C/C++ 的新手指南

新加入一個專案,最先面對的課題是如何正確地編譯和執行專案,可從 "It works on my machine" 如此地風行,印證這件事的困難性;再來則是閱讀負責工作相關的程式碼。至於發揮程式語言的特性,運用高階設計模式等,都是另開新專案或熟悉狀況後才有機會發揮。

過去數年沉浸在愉快的 scripting language 和開發新專案中,一直沒踏入這殘酷的世界。這篇記錄在這樣的情境下,可能需要的技能,結算一下這一個多月的心得,全都是血淚談啊 ...。

系統工具

熟悉作業系統的安裝套件是首要之務,這樣才知道如何補足需要的 header、library,或是安裝含 debug symbol 版的函式庫以執行 gdb 觀察程式或除錯。參見《自行編譯含 debug symbol 的套件 (package)》了解 Ubuntu/Debian 下的套件命名規則。

在未安裝套件的情況下,可用

  • aptitude search SUBSTRING # 找套件
  • aptitude show PACKAGE # 顯示套件用途
  • apt-file search X # 找出 X 包在那個套件裡,找 header 時很有用。

注意在用 apt-file 前要先跑 sudo apt-file update,不然搜不出東西來。

對於已安裝套件,可用

  • dpkg --search SUBSTRING # 找出安裝在那個套件,已知 header 時,適合用來找 library
  • dpkg -L PACKAGE # 列出套件內容,可用來找 header、library
  • locate SUBSTRING # 我比較常用它找 header 的位置,再觀看 header 內容

執行 locate 前記得先執行 sudo updatedb,原因同 apt-file。

其它參考資料: How To Manage Packages Using apt-get, apt-cache, apt-file and dpkg Commands ( With 13 Practical Examples )

編譯

連結

這一塊是我目前最頭痛的地方,大多卡在這裡。一些粗淺心得:

之後還需抽時間補充相關知識,像是 ldconfig 如何運作。

執行

光只是讀程式碼就像大海撈針一樣,不太有效率。可從動態執行過程找出主要執行的路徑,再專注相關的程式碼。

1. strace 和 ltrace

srace 是分析執行行為的強大工具,google 一下會看到很多別人的個案心得,看看再自己試一試,很快能上手,不知能發揮它多少功能。這裡列自己用的兩個小案例:

反而是 ltrace 一直都想不到使用它的時機,也沒找到好的個案心得文。

2. gdb

gdb 的重要性不需多說明,之前的幾則心得:

強烈建議使用 cgdb,簡易安裝 + 無痛上手,瞬間省下大量操作和讀碼的時間。

3. 打開除錯功能

依照開發者的習性,一定會留後門讓自己方便除錯,從這角度下手也可省下不少時間:

4. 載入函式庫

除以上所言外,我另外有找過畫出程式流程的靜態和動態分析工具,像是畫 call graph 或是 C 的 cflow。不過 C++ 的靜態分析效果很糟,就沒花太多時間研究。目前用 strace 和 gdb 覺得已夠用了,不知用工具產生 call graph、class 相依圖或其它東西,是否會更有幫助。待有需求看整體的程式時再來試試。

閱讀程式碼

聽了大家的建議後,做了一些實際操作,而有些心得:

Eclipse CDT 雖然方便,後來我還是用 gj 居多。原因有幾點:

  • 我已很習慣用 vim + screen 做事,gj 最合這個情境
  • id-utils 真的是超級快
  • 我針對自己的需求更新 gj 多次,愈用愈順手

另外 ack 也滿方便的,懶得建 index 或是想比對子字串時,可直接使用。當然 id-utils 也支援子字串比對,只是暫時懶得為此修改 gj 的程式,目前大部份需求是找完整的 symbol。

熟悉 Linux 系統程式

在基本工具都上手後,打算每天抽一點時間加減讀一點相關知識。一兩年下來應該會有不錯的成果。目前打算讀《The Linux Programming Interface》,年假時試看看效果如何。

這一個月的心得以了解 /proc 為主,對觀察 CPU 用量、RAM 用量、載入那些函式庫、multi-thread、程式執行狀態等都很有幫助:

結論

即使大概知道有那些東西,還是需要實際動手的經驗,才會真的學進去。一個月下來進步了不少,不過對於要面對的戰役,還有一大段路要趕上,還有很多很多要學的。

by fcamel (noreply@blogger.com) at January 23, 2012 12:07 PM


駱嘉濠's fcamel 技術隨手記

Linux 的 capability

昨天看 TLPI ch39 才知道 Linux 有 capability 可依項目授權, 不用像以前那樣, 使用 setuid 一次大放送。像 passwd 就是 setuid 的典型使用情境, 要讓所有使用者能改自己的密碼, 所以他們要有權限存取密碼檔, 但又不能讓使用者做超出他們該做的事。於是, 使用 setuid 的程式需要很小心地設計, 避免給太多權限, 或是被 cracker 攻破取得 root 權限。

看到 capability 如此地威, 不禁納悶有多少程式有使用 capability, Scott 提供一個不錯的找法: 用 package 管理套件找出有那些程式依賴 capability 的套件, 就知道了。Ubuntu 對應的指令是 apt-rdepends -r libcap2, 也不算少, 有 100 多個套件用到 libcap2。

by fcamel (noreply@blogger.com) at January 23, 2012 11:57 AM


駱嘉濠's plurk

fcamel 說 剛在電影院看完陣頭, 畫面不錯, 聲音很讚, 劇情 ok (單薄), 整體來說值得去電影院看。最近又看太多爽片了, 想找些舊得經典劇情片之類的來看, 也許會來看 Rain Man 吧

fcamel 說 剛在電影院看完陣頭, 畫面不錯, 聲音很讚, 劇情 ok (單薄), 整體來說值得去電影院看。最近又看太多爽片了, 想找些舊得經典劇情片之類的來看, 也許會來看 Rain Man 吧

by fcamel at January 23, 2012 11:05 AM

fcamel 說 Aptitude vs Apt-Get | marvinlemos.net, 多熟悉幾個 apt-* 指令後, 再來重查一次為啥有人較支持 aptitude

fcamel 說 Aptitude vs Apt-Get | marvinlemos.net, 多熟悉幾個 apt-* 指令後, 再來重查一次為啥有人較支持 aptitude

by fcamel at January 23, 2012 11:03 AM


駱嘉濠's fcamel 技術隨手記

用 strace 找出 Ubuntu 如何提示未安裝的指令

在 Ubuntu 下執行指令後, 若沒有安裝指令的話, 會出現提示:

$ apt-rdepends
The program 'apt-rdepends' is currently not installed.  You can install it by typing:
sudo apt-get install apt-rdepends

但若直接用 bash 執行, 卻不會有這效果:

$ bash -c apt-rdepends
bash: apt-rdepends: command not found

以前覺得很好奇, Ubuntu 怎麼做到這件事的, 知道 strace 以後, 追這類原因簡單許多, 只要有輸入和輸出訊息, 就可夾擊出一些線索。

  • 在 terminal 1 輸入 echo $$ 取得該 bash 的 PID
  • 在 terminal 2 輸入 sudo strace -obash.trace -f -s512 -p PID
    • -obash.trace 表示將輸出存到 bash.trace, 訊息很多, 通常都會寫到檔案裡
    • -s512 表示輸出訊息最多到 512, 預設行寬有點短, 之後不方便找輸出的訊息
    • -f 表示一起追蹤 child process, 這點很重要, 沒加 -f 就追不到 bash 使用的其它子程序, 而關鍵就在 bash 叫起的子程序
    • -p PID 表示追踪其它 process, 照理說同一個使用者不用 root 權限應該也能看, 不知為啥不通
  • 在 terminal 1 輸入 apt-rdepends, 因為 strace 有用 "-f", 速度會慢很多。等待指令完成
  • 在 terminal 2 按 Ctrl+C 中斷 strace, 觀察 bash.trace

搜一下 "apt-rdepends" 會看到 bash 在嘗試各種 path 後都找不到檔案:

16520 stat("/home/fcamel/bin/apt-rdepends", 0x...) = -1 ENOENT...
16520 stat("/usr/local/sbin/apt-rdepends", 0x...) = -1 ENOENT...
16520 stat("/usr/local/bin/apt-rdepends", 0x...) = -1 ENOENT...
16520 stat("/usr/sbin/apt-rdepends", 0x...) = -1 ENOENT...
16520 stat("/usr/bin/apt-rdepends", 0x...) = -1 ENOENT...
16520 stat("/sbin/apt-rdepends", 0x...) = -1 ENOENT...
16520 stat("/bin/apt-rdepends", 0x...) = -1 ENOENT...
16520 stat("/usr/games/apt-rdepends", 0x...) = -1 ENOENT...
16520 stat("/home/fcamel/bin/apt-rdepends", 0x...) = -1 ENOENT...
16520 stat("/home/fcamel/bin/apt-rdepends", 0x...) = -1 ENOENT...

之後在別的 child process 呼叫外部程式執行 /usr/lib/command-not-found:

16877 execve("/usr/bin/python", ["/usr/bin/python", "/usr/lib/command-not-found", "--", "apt-rdepends"], [/* 38 vars */]) = 0

若想研究怎麼找出該裝的套件, 可以研究 "/usr/lib/command-not-found"。若想研究 bash 如何判斷在有 terminal 的情況下要多找安裝的指令, 可以自己編含 debug symbol 的 bash, 再用 gdb 找出相關位置, 再讀附近的原始碼。這樣一來, 至少知道需要追的時候該如何進行, 剩下就是增加經驗提昇追程式的速度了。

2012-01-23 更新

wens 提醒, 原來是用 bash 的 hook 做的, 見 /etc/bash.bashrc 了解設定, man bash 在 COMMAND EXECUTION 那節有說明。

by fcamel (noreply@blogger.com) at January 23, 2012 10:55 AM


駱嘉濠's plurk

fcamel 說 fcamel 技術隨手記: 用 strace 找出 Ubuntu 如何提示未安裝的指令

by fcamel at January 23, 2012 06:08 AM

ITRS Wiki

Electronics Retailers

← Older revision Revision as of 00:37, 23 January 2012
(5 intermediate revisions not shown)
Line 3: Line 3:
* http://taiwan02.rs-online.com/web/
* http://taiwan02.rs-online.com/web/
* http://www.sparkfun.com
* http://www.sparkfun.com
 +
* https://www.adafruit.com
 +
* http://www.terasic.com.tw (友晶科技) FPGA and extensions boards, based in Hsin Chu
-
== Brick and Mortar ==
+
== Brick and Mortar (near Taipei unless otherwise noted) ==
-
* [http://www.Ls3c.com.tw 良興電子資訊商場] 2393-0899 ; 0800-655-588 ;
+
* [http://www.Ls3c.com.tw 良興電子資訊商場] 2393-0899 ; 0800-655-588
* [http://www.JIN-HUA.com.tw 今華電子有限公司] 2392-1111
* [http://www.JIN-HUA.com.tw 今華電子有限公司] 2392-1111
* [http://demo.metadigi.com.tw/sun26/ 源達科技] 2369-6662
* [http://demo.metadigi.com.tw/sun26/ 源達科技] 2369-6662
* [http://mesun.myweb.hinet.net 明鄉企業] 2322-1954 2322-3703
* [http://mesun.myweb.hinet.net 明鄉企業] 2322-1954 2322-3703
 +
 +
== PCB Fab ==
 +
* [http://ekits.miife.com/blog/ Miife Corporation] (米飛科技), [mailto:Chris.Hsu@miife.com Chris Hsu]
 +
 +
 +
== See Also ==
 +
* [[Building Hardware]]

by Scott.tsai at January 23, 2012 12:37 AM

January 22, 2012

fcamel 說 看 TLPI ch39 才知道有 capability, 以前覺得 set-u-id 的機制很妙, 但也有小小的疑問, 這種作法是否會給太多權限, 似乎要很小心。果然就有更細微的調整機制, 不知是否已普及地被使用

fcamel 說 看 TLPI ch39 才知道有 capability, 以前覺得 set-u-id 的機制很妙, 但也有小小的疑問, 這種作法是否會給太多權限, 似乎要很小心。果然就有更細微的調整機制, 不知是否已普及地被使用

by fcamel at January 22, 2012 07:04 PM

ACPI

Created page with "* [https://lwn.net/Articles/391230/ lwn.net: Writing a WMI Driver by Corentin Chary], June 2010 * https://wiki.ubuntu.com/Kernel/Reference/WMI * http://glucik.blogspot.com/2011/1..."

New page

* [https://lwn.net/Articles/391230/ lwn.net: Writing a WMI Driver by Corentin Chary], June 2010
* https://wiki.ubuntu.com/Kernel/Reference/WMI
* http://glucik.blogspot.com/2011/12/mof-decompilation.html
* http://xf.iksaif.net/dev/wmidump.html ([https://github.com/iksaif/wmidump github:wmidump])

by Scott.tsai at January 22, 2012 05:35 PM

fcamel 說 林志炫真是很妙的一個人, 欣賞他的執著和熱情 林志炫TerryLin「沒離開過」新歌MV

fcamel 說 林志炫真是很妙的一個人, 欣賞他的執著和熱情 林志炫TerryLin「沒離開過」新歌MV林志炫TerryLin「沒離開過」新歌MV

by fcamel at January 22, 2012 05:26 PM

fcamel 說 讀書時背景樂用交響情人夢 OST, 沉浸在古典樂一陣子後, 忽然穿插個《普莉與頃太》 OP, 實在是.......很奇妙的感受

fcamel 說 讀書時背景樂用交響情人夢 OST, 沉浸在古典樂一陣子後, 忽然穿插個《普莉與頃太》 OP, 實在是.......很奇妙的感受

by fcamel at January 22, 2012 03:02 PM

fcamel 說 看 TLPI ch1 才知道 POSIX 要唸成「趴吱克司」, 不是「波細克司」

fcamel 說 看 TLPI ch1 才知道 POSIX 要唸成「趴吱克司」, 不是「波細克司」

by fcamel at January 22, 2012 02:35 PM

fcamel 說 發佈新聞應該說 &quot;release news&quot; 還是 &quot;publish news&quot; 或是有其它更適合的詞?

fcamel 說 發佈新聞應該說 "release news" 還是 "publish news" 或是有其它更適合的詞?

by fcamel at January 22, 2012 12:43 PM


駱嘉濠's fcamel 技術隨手記

gdb 如何找到 debug symbol

先前在《追踪 glibc 裡的程式》提到自己如何亂試, 試出讓 gdb 讀到 debug symbol。昨天聽 Scott 說明, 才知道背後是怎麼一回事。

在 Ubuntu 下以 libm 為例, 在 /lib/x86_64-linux-gnu/libm-2.13.so 裡面, 先看一些相關的 section header:

$ objdump -h /lib/x86_64-linux-gnu/libm-2.13.so | grep gnu
/lib/x86_64-linux-gnu/libm-2.13.so:     file format elf64-x86-64
  0 .note.gnu.build-id 00000024  0000000000000238  0000000000000238  00000238  2**2
  2 .gnu.hash     00000fa4  0000000000000280  0000000000000280  00000280  2**3
  5 .gnu.version  00000298  00000000000038da  00000000000038da  000038da  2**1
  6 .gnu.version_d 0000005c  0000000000003b78  0000000000003b78  00003b78  2**3
  7 .gnu.version_r 00000030  0000000000003bd8  0000000000003bd8  00003bd8  2**3
 27 .gnu_debuglink 00000014  0000000000000000  0000000000000000  000840e4  2**0

幾個重點

  • .note.gnu.build-id 表示 binary id, 之後用來比對 debug symbol 是否出自 shared lib。看起來 Fedora 在找 debug symbol 時, 有用到 binary id; 而 Ubuntu 沒有的樣子, 我用 hexedit 亂改這個 section 的值, 仍能找到 debug symbol
  • .gnu_debuglink 指向包含 debug symbol 的檔案, 若用 hexedit 改掉它的值, 執行 gdb /lib/x86_64-linux-gnu/libm-2.13.so, gdb 會表示找不到 libm 的 debug symbol
  • 可用 objdump -s -j .gnu_debuglink /lib/x86_64-linux-gnu/libm-2.13.so 顯示 section 內容

若用 LD_PRELOAD=/usr/lib/debug/lib/x86_64-linux-gnu/libm-2.13.so ANY_PROGRAM 執行程式, 結果會 segmentation fault, 所以我推測 Ubuntu 下 X-dbg 裡包的檔案, 可能和 Fedora 一樣, 只有 debug symbol 而不是完整 strip 前的函式庫。不知要如何確認該檔案裡只有 debug symbol 沒有實際的 object code。

至於確認原本的 binary (object file / shared lib / executable) 是否有編入 debug symbol, 除了用 objdump -S 再找看看有沒有出現程式碼外, 更簡單的作法是用 objdump -h | grep debug:

$ objdump -h /usr/lib/debug/lib/x86_64-linux-gnu/libm-2.13.so | grep debug
/usr/lib/debug/lib/x86_64-linux-gnu/libm-2.13.so:     file format elf64-x86-64
 28 .debug_aranges 00004770  0000000000000000  0000000000000000  000002b0  2**4
 29 .debug_pubnames 00002e44  0000000000000000  0000000000000000  00004a20  2**0
 30 .debug_info   000318ee  0000000000000000  0000000000000000  00007864  2**0
 31 .debug_abbrev 00010fc3  0000000000000000  0000000000000000  00039152  2**0
 32 .debug_line   00018c20  0000000000000000  0000000000000000  0004a115  2**0
 33 .debug_str    000041bc  0000000000000000  0000000000000000  00062d35  2**0
 34 .debug_loc    00062bc5  0000000000000000  0000000000000000  00066ef1  2**0
 35 .debug_pubtypes 00003a11  0000000000000000  0000000000000000  000c9ab6  2**0
 36 .debug_ranges 00003e30  0000000000000000  0000000000000000  000cd4c7  2**0

有上述 section 的話, 表示有含 debug symbols。

備註

1. hexedit 基本指令

  • F1: 等同於 man hexedit
  • F4: 跳到 offset, 對照 objdump -h X 看倒數第二欄使用
  • TAB: 切換 hexadecimal 或 ascii 區, 之後取代內容或搜尋, 和這有關
  • 直接在 byte 上打字取代
  • /: 找字串
  • ctrl+c / ctrl+x: 離開 / 存檔離開

2. 見《The DWARF Debugging Standard》了解 debug 資訊如何存在檔案, 只是留著備忘, 目前應該沒必要去讀。

3. 若是自己編含 debug symbol 的函式庫, 就不是上述那一回事了, 而是直接編進目前的函式庫裡。

4. 《Separate Debug Files - Debugging with GDB》說明 gdb 如何支援分離 debug symbol 到另一個檔案, 另外 man strip 或 man objcopy, 可在 "--only-keep-debug" 的部份看到相關說明。看來要知道到底各個 distribution 怎麼做這事, 去看該 distribution 官方的說明會比較確實。之後再看看吧。

by fcamel (noreply@blogger.com) at January 22, 2012 09:25 AM


駱嘉濠's plurk

fcamel 說 plurk 通了, 結果 facebook 那邊沒通的樣子

fcamel 說 plurk 通了, 結果 facebook 那邊沒通的樣子

by fcamel at January 22, 2012 08:59 AM

fcamel 說 Index Files - Debugging with GDB - 看到 gdb 有 index file 很開心的想來試用, 結果是 gdb 7.3+ 的功能, 看來要等 Ubuntu 12.04 出來後再試了

fcamel 說 Index Files - Debugging with GDB - 看到 gdb 有 index file 很開心的想來試用, 結果是 gdb 7.3+ 的功能, 看來要等 Ubuntu 12.04 出來後再試了

by fcamel at January 22, 2012 08:57 AM

fcamel 說 fcamel 技術隨手記: gdb 如何找到 debug symbol - 自己動手操作個幾次後就愈來愈有 fu 了, 不過疑問也會愈來愈多 XD

fcamel 說 fcamel 技術隨手記: gdb 如何找到 debug symbol - 自己動手操作個幾次後就愈來愈有 fu 了, 不過疑問也會愈來愈多 XD

by fcamel at January 22, 2012 08:53 AM


駱嘉濠's fcamel 技術隨手記

追踪 glibc 裡的程式

這篇是一堆試誤心得的中間記錄, 使用的版本是 Ubuntu 11.04。

失敗的作法

  • 在 link 時, 用 -L/usr/lib/debug/lib/x86_64-linux-gnu/ 改變 link 到的 libc.so, 但沒有效果。用 strace -e open 觀察 gcc 做的事, 發現是因為 /usr/lib/debug/lib/x86_64-linux-gnu/ 下沒有 libc.so, 而是 libc-2.13.so。之前沒學清楚 -L 和 -l 的細節, 耍笨。
  • man ld.so 得知可用 LD_LIBRARY_PATH 或 LD_PRELOAD 在執行期換掉 libc.so, 但是也沒有效果。用 LD_PRELOAD 換成 debug 版 libc.so 時, 跑 gdb 會 segmentation fault

成功的作法

前置作業

  • $ sudo aptitude install libc6-dbg # 取得有 debug symbol 的 libc.so
  • $ apt-get source libc6-dev # 取得原始碼目錄 eglibc-2.13

執行

  1. $ gcc myprog.c -g -o myprog
  2. $ gdb myprog
  3. $ directory /path/to/eglibc-2.13/stdio-common/
  4. $ start # 跑到 main 就停下來

然後 gdb 會神奇地去找含 debug symbol 的 libc, 後面就可以用 step 進入 glibc 的函式。不知這個行為寫在那裡, 或許可以從 gdb 原始碼找出來吧。

若有進入但說找不到原始碼, 表示沒有告知 gdb 正確的原始碼位置, 到 eglibc-2.13 下找一找, 再回來用 directory 設位置。

另外在用到 sqrt()、log() 時也是如此, 照一樣的編法 gcc myprog.c -g -lm -o myprog, 然後在 start 後, gdb 會去找 debug 版的 libm.so。不過要記得多執行 directory /path/to/eglibc-2.13/math 載入 math 的原始碼, gdb 才能列出原本的程式。用 ldd 觀察 myprog 也驗證原本的執行檔將 libc 和 libm 連到沒有 debug symbol 的版本。

另外試了直接和 debug 版的 libc.so 或 libm.so 編在一起 (gcc myprog.c -g /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.13.so), 但是一跑就會 segmentation fault。

另外有些函式好像是用組語寫的, 看不懂它們的行為, step into sqrt 沒有效果。

結論

要觀察 glibc 的行為, 要做以下的事:

  • 裝 libc6-dbg, 取得含 debug symbol 的 shared lib
  • 用 apt-get source libc6-dev 取得原始碼。由於 glibc 裡有多個 shared lib, 要先 grep 找看看想觀察的程式放在那個目錄下, 跑 gdb 時再用 directory 載入該目錄, 相對路徑才會對。

2012-01-10 更新: 補充觀察 gdb 找 debug lib 的行為

一樣可以用老招 strace -e open 跑 gdb 看出背後發生的事, 以下是沒有裝 libc6-dbg 跑出的訊息:

$ strace -e open -o gdb.trace gdb myprog
然後執行 tail -f gdb.trace | grep libc 觀察行為。

以下是執行 start 以前的訊息:

open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY) = 3
open("/lib/libcrypto.so.0.9.8", O_RDONLY) = 3
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)

以下是執行 start 以後的訊息:

open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY) = 6
open("/lib/x86_64-linux-gnu/libc-2.13.so", O_RDONLY) = 7
open("/lib/x86_64-linux-gnu/.debug/libc-2.13.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug//lib/x86_64-linux-gnu/libc-2.13.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.13.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc-2.13.so-gdb.py", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.13.so-gdb.py", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/gdb/auto-load/lib/x86_64-linux-gnu/libc-2.13.so-gdb.py", O_RDONLY) = -1 ENOENT (No such file or directory)
可以看出 gdb 不論如何, 都會試著載入 debug 版的函式庫, 來執行目標程式。找不到的時候, 自然就是用沒有 debug symbol 的函式庫。

2012-01-22 更新

《gdb 如何找到 debug symbol》有進一步說明。

by fcamel (noreply@blogger.com) at January 22, 2012 08:47 AM

ITRS Wiki

Open Hardware Projects

← Older revision Revision as of 07:34, 22 January 2012
Line 20: Line 20:
== Arduino Layout Done in PCB ==
== Arduino Layout Done in PCB ==
* [http://jeffrey.co.in/gnudino/ gnudino]
* [http://jeffrey.co.in/gnudino/ gnudino]
 +
 +
== See Also ==
 +
* [[FPGA]]

by Scott.tsai at January 22, 2012 07:34 AM


駱嘉濠's plurk

fcamel 說 Avahi - +Scott Tsai 推薦的軟體, service discovery on a local network, 有多個 VM 需要互連時應該滿方便的, 備忘

fcamel 說 Avahi - +Scott Tsai 推薦的軟體, service discovery on a local network, 有多個 VM 需要互連時應該滿方便的, 備忘

by fcamel at January 22, 2012 05:56 AM

fcamel 說 test plus plurk 2

fcamel 說 test plus plurk 2

by fcamel at January 22, 2012 05:55 AM

fcamel 說 test plus plurk https://plus.google.com/111353793049965752735/posts/7Z9ffd7dNdT ()

by fcamel at January 22, 2012 05:53 AM


駱嘉濠's fcamel 雜記

日常 2

每當聽著費曼的故事時, 都會感染到他豐富的生活色彩, 想到他在最後斷氣的前一刻, 要求醫生讓他自然死亡, 他想體會看看是怎麼一回事。想著想著, 又有種嚮往而思索著生活這事。

想起中國文人常寫詩詞述及自己神遊和古人建交, 長年聽著看著費曼的故事, 也有著相似的感受, 像個多年好友一般, 難以言喻的感受。

by fcamel (noreply@blogger.com) at January 22, 2012 04:59 AM

ITRS Wiki

Linkers and Loaders

← Older revision Revision as of 04:44, 22 January 2012
(One intermediate revision not shown)
Line 16: Line 16:
== See Also ==
== See Also ==
 +
* [[Symbol Versioning]]
* [[System Programming]]
* [[System Programming]]

by Scott.tsai at January 22, 2012 04:44 AM

Symbol Versioning

Created page with "* [http://www.akkadia.org/drepper/symbol-versioning Ulrich Dropper: ELF Symbol Versioning] * [http://www.airs.com/blog/archives/220 Ian Lance Taylor: Combining Versions] * http:/..."

New page

* [http://www.akkadia.org/drepper/symbol-versioning Ulrich Dropper: ELF Symbol Versioning]
* [http://www.airs.com/blog/archives/220 Ian Lance Taylor: Combining Versions]
* http://www.trevorpounds.com/blog/?tag=symbol-versioning: Linking to Older Versioned Symbols (glibc), Versioning Symbols for Shared Libraries (glibc)
* [http://sourceware.org/binutils/docs/ld/VERSION.html GNU LD Manual: VERSION Command]
* [http://www.airs.com/blog/archives/50 Ian Lance Taylor: Linkers part 13: Symbol Versions Redux]

== See Also ==
[[Linkers and Loaders]]

by Scott.tsai at January 22, 2012 04:43 AM

January 21, 2012

日常 3

剛才發文才發現有 girl friend 這個 tag, 可惜沒有早幾年轉發到 blog 來自表, 多留些記錄。在 2010 自表兩篇文章後, 總算在一年後有所行動而有結果。

如同自我實現一般, 只是開啟另一扇門, 門後面的路還有得走的。如同多數的事一般, 之前的想像和行動後的感受極少雷同, 不同之處不好不壞, 就是些新鮮體會, 整體來說是往好的方向發展吧。

by fcamel (noreply@blogger.com) at January 21, 2012 06:24 PM

日常

偶而會想和過去的自己分享一些現在的體悟, 無形中轉將這些想法傳遞給學弟。今天聽到邱向學弟提到, 玩得開心就好, 才想起當初自己也是如此, 不該塞太多想法給他們。

若真能回去和自己分享現在的心得, 當時的我大概也不會買單吧。現在想想, 以前那樣沒目標地玩技術, 也滿不錯的, 忽然又覺得沒什麼想和過去自己說的話。反到是現在要多思考如何活得更精彩。

想起火鳳的那句: 「精彩不亮麗, 起落是無常」, 不怎麼相關, 就剛好想到而已。

by fcamel (noreply@blogger.com) at January 21, 2012 06:12 PM


駱嘉濠's plurk

fcamel 說 每當聽著費曼的故事時, 都會感染到他豐富的生活色彩,想到他在最後斷氣的前一刻, 要求醫生讓他自然死亡, 他想體會看看是怎麼一回事。想著想著, 又有種嚮往而思索著生活這事。

fcamel 說 每當聽著費曼的故事時, 都會感染到他豐富的生活色彩,想到他在最後斷氣的前一刻, 要求醫生讓他自然死亡, 他想體會看看是怎麼一回事。想著想著, 又有種嚮往而思索著生活這事。

by fcamel at January 21, 2012 06:10 PM

fcamel 說 偶而會想和過去的自己分享一些現在的體悟, 無形中轉將這些想法傳遞給學弟。今天聽到邱向學弟提到, 玩得開心就好, 才想起當初自己也是如此, 無須焦急。

fcamel 說 偶而會想和過去的自己分享一些現在的體悟, 無形中轉將這些想法傳遞給學弟。今天聽到邱向學弟提到, 玩得開心就好, 才想起當初自己也是如此, 無須焦急。

by fcamel at January 21, 2012 05:57 PM

January 20, 2012

Conferences

← Older revision Revision as of 21:49, 20 January 2012
(2 intermediate revisions not shown)
Line 1: Line 1:
 +
== 2012 ==
 +
* [http://linux.conf.au/programme/schedule/monday linux.conf.au 2012]([http://www.youtube.com/user/linuxconfau2012 YouTube channel]), Jan 16, Ballarat, Australia
 +
== 2011 ==
== 2011 ==
* [http://www.llvm.org/devmtg/2011-11/ 2011 LLVM Developers' Meeting] November 18, 2011, San Jose, CA
* [http://www.llvm.org/devmtg/2011-11/ 2011 LLVM Developers' Meeting] November 18, 2011, San Jose, CA

by Scott.tsai at January 20, 2012 09:49 PM

Printed Circuit Board Layout

← Older revision Revision as of 21:19, 20 January 2012
(One intermediate revision not shown)
Line 1: Line 1:
= PCB Layout =
= PCB Layout =
-
== Getting Started With PCB ==
+
* [http://linux.conf.au/wiki/index.php/Tutorials/Design_your_own_Printed_Circuit_Board_using_FOSS linux.conf.au 2012 tutorial: Designing your own PCB using FOSS]: uses KiCad
-
* http://www.delorie.com/pcb/docs/gs/
+
* [http://www.delorie.com/pcb/docs/gs/ delorie.com: Getting Started with PCB]
-
 
+
* [http://www.geda.seul.org/talks/IgniteBoston_2009.pdf Stuart Brorson -- Hardware design and the gEDA Project from Ignite Boston 5]([http://cachefly.oreilly.com/ignite/boston/07_StuartBrorson.mov video])
-
== Stuart Brorson -- Hardware design and the gEDA Project from Ignite Boston 5 ==
+
* [http://my.so-net.net.tw/cross_hong/protel99se_video_2005.html Protel 99se 教學]
-
* [http://cachefly.oreilly.com/ignite/boston/07_StuartBrorson.mov video], [http://www.geda.seul.org/talks/IgniteBoston_2009.pdf slides]
+
* [http://www.matwei.de/doku.php?id=en:eagle3d:eagle3d Eagle3D: translate the 2D-layout into a 3-dimensional view.]
-
 
+
-
== Protel 99se 教學==
+
-
* http://my.so-net.net.tw/cross_hong/protel99se_video_2005.html
+
== Eagle Cad: export gerber files ==
== Eagle Cad: export gerber files ==
Line 17: Line 14:
# http://turbocrazy.tistory.com/entry/Eagle-CAD-PCB-Gerber-file-%EB%A7%8C%EB%93%A4%EA%B8%B0
# http://turbocrazy.tistory.com/entry/Eagle-CAD-PCB-Gerber-file-%EB%A7%8C%EB%93%A4%EA%B8%B0
# http://www.interq.or.jp/japan/se-inoue/e_eagle44.htm
# http://www.interq.or.jp/japan/se-inoue/e_eagle44.htm
-
 
-
== Eagle3D ==
 
-
* [http://www.matwei.de/doku.php?id=en:eagle3d:eagle3d translate the 2D-layout into a 3-dimensional view.]
 
== See Also ==
== See Also ==
-
* [[BuildingHardware|電路板製作]]
+
* [[Building Hardware]]: 電路板製作

by Scott.tsai at January 20, 2012 09:19 PM

Skype Under Fedora

← Older revision Revision as of 04:41, 20 January 2012
(One intermediate revision not shown)
Line 1: Line 1:
-
== Skype 2.2 under Fedora 16 x86_64 ==
 
-
* yum -y install libXScrnSaver-1.2.1-2.fc15.i686 qt-x11.i686 qt.i686
 
-
* remain as below
 
== Skype 2.1+ ==
== Skype 2.1+ ==
* http://www.skype.com/download/skype/linux/
* http://www.skype.com/download/skype/linux/
-
* Works out of the box on Fedora x86_64 with pulseaudio
+
* Install dependencies '''yum -y install libXScrnSaver.i686 qt-x11.i686 qt.i686'''. (Skype unwisely disabled RPM shared library dependency auto generation)
-
* Use "gnome-volume-control" to configure your microphone volume
+
* Works out of the box with pulseaudio. Use '''gnome-control-center sound''' to configure your microphone ('''gnome-volume-control''' in gnome 2.x).
-
* to use webcam: http://dougsland.livejournal.com/106700.html
+
* Webcam support: http://dougsland.livejournal.com/106700.html
 +
 
== Old and Obsolete Skype 2.0 ==
== Old and Obsolete Skype 2.0 ==
=== Installing Skype 2.0 ===
=== Installing Skype 2.0 ===

by Scott.tsai at January 20, 2012 04:41 AM

January 19, 2012

Skype Under Fedora

← Older revision Revision as of 20:04, 19 January 2012
Line 1: Line 1:
-
== Skype 2.2 under Fedora 16 x86_64 ==
 
-
* yum -y install libXScrnSaver-1.2.1-2.fc15.i686 qt-x11.i686 qt.i686
 
-
* remain as below
 
== Skype 2.1+ ==
== Skype 2.1+ ==
* http://www.skype.com/download/skype/linux/
* http://www.skype.com/download/skype/linux/
-
* Works out of the box on Fedora x86_64 with pulseaudio
+
* Install dependencies '''yum -y install libXScrnSaver.i686 qt-x11.i686 qt.i686'''. (Skype unwisely disabled RPM shared library dependency auto generation)
-
* Use "gnome-volume-control" to configure your microphone volume
+
* Works out of the box with pulseaudio. Use '''gnome-volume-control''' to configure your microphone.
-
* to use webcam: http://dougsland.livejournal.com/106700.html
+
* Webcam support: http://dougsland.livejournal.com/106700.html
 +
 
== Old and Obsolete Skype 2.0 ==
== Old and Obsolete Skype 2.0 ==
=== Installing Skype 2.0 ===
=== Installing Skype 2.0 ===

by Scott.tsai at January 19, 2012 08:04 PM

Skype Under Fedora

← Older revision Revision as of 19:57, 19 January 2012
Line 1: Line 1:
 +
== Skype 2.2 under Fedora 16 x86_64 ==
 +
* yum -y install libXScrnSaver-1.2.1-2.fc15.i686 qt-x11.i686 qt.i686
 +
* remain as below
== Skype 2.1+ ==
== Skype 2.1+ ==
* http://www.skype.com/download/skype/linux/
* http://www.skype.com/download/skype/linux/

by Learner at January 19, 2012 07:57 PM


駱嘉濠's plurk

fcamel 說 看到主 blog 大家對 C/C++ 新手指南的回響出乎意料的高, 比之前的文章都高了不少 (python、unit test、problem solving 都哭哭), 或許反映出這類文章較為實用, 或是比較容易引起共鳴吧?

fcamel 說 看到主 blog 大家對 C/C++ 新手指南的回響出乎意料的高, 比之前的文章都高了不少 (python、unit test、problem solving 都哭哭), 或許反映出這類文章較為實用, 或是比較容易引起共鳴吧?

by fcamel at January 19, 2012 05:00 PM


駱嘉濠's fcamel 技術隨手記

iPad 升級到 iOS 5

不知是否因為和 command 一樣人品不好, 用 Apple 的產品總遇到一堆鳥事, 讓我對 Apple 產品難以建立好感。

照官網和 google 大部份人的說法來看, 就 iTunes 升到 10.5, 將 iPad 接上去, 在 iTunes 裡按 check for update 即可。但 iTunes 回報 This version of the iPad software (4.2) is the current version

有人提到可嘗試手動升級, 下載好 firmware 檔後, 照著指示手動選檔案 restore, 結果出現 "this device isn't eligible for the requested build"。google 看到有許多人提到類似問題, 但有些是 jail break 造成的, 提到的解法看來也不適用於我的情況, 況且我用的 iPad 應該沒 JB。

最後在 restore mode 下, 成功地升到 iOS 5.x 了, 太感謝這個影片, 操作方式講解得非常清楚: 《How to Enter DFU Mode | Restore Mode - Get Out of DFU Mode | Restore Mode - Fast, Safe & Easy - YouTube》

by fcamel (noreply@blogger.com) at January 19, 2012 02:07 PM


駱嘉濠's plurk

fcamel 說 出第二版了! &gt;&gt;&gt; 操作介面設計模式 第二版books.gotop.com.tw/bookdetails.aspx?Types=v&amp;bn=A266

fcamel 說 出第二版了! >>> 操作介面設計模式 第二版
books.gotop.com.tw/bookdetails.aspx?Types=v&bn=A266

by fcamel at January 19, 2012 09:08 AM