utraceとacid

今月のLinux Kernl Watchによると,RedHatRoland McGrath氏がptraceの代替となるutraceというシステムコールを開発中とのこと.ptraceに関しては,アーキテクチャごとに実装具合が違っていたり,マルチスレッドとの整合性がいまいちだったり,不満を聞くことが多いシステムコールである.
utraceの詳細には立ち入らない,というか全然調べてないのだけど,Dave Miller氏のblogによると,面白そうなサンプルモジュールがあるようだ.関係する部分を引用する.

There is a sample kernel utrace module provided on Roland's page that provides Plan 9 like semantics. Way back when I first read up on Plan 9 I thought the coolest thing was that programs didn't crash, they just froze when they got a segfault or something and waited for someone to come around and debug them. I thought this was brilliant! Roland's sample module implements this, you just pass in the pid you're interested in and that pid's process group will get the Plan 9 semantics. The process will suspend instead of dying, but if you give it a SIGCONT it would continue on and process that fatal signal as normal.

Linuxでも,「コアがない」で書いたようなセマンティクスを実現できるのだ.つまり,プロセスがSEGVを起こしても,すぐにコアを吐いて終了ではなく,凍結状態(Plan9ではBrokenと呼ばれる)にして,デバッガからアタッチできるようになる.さらに,Plan9のデバッガであるacidは,マルチアーキテクチャ,リモートデバッグがちゃんと考慮されているけど*1,utraceが一般的になると,Linuxにもそんな開発環境が実現できるかもしれない.
utraceのパッチはここから手に入る.

*1:アーキテクチャに関係なく,リモートホストの/procをローカルにimportし,acidからアタッチして,デバッグできる.UNIXだと,まず/procをNFSでmountする時点で,無理だよね.