# 'Nautilus debugging tips?' スレッドのかなりいい加減な日本語訳 # # 翻訳者: Satoru SATOH # 原文: # http://lists.gnome.org/archives/nautilus-list/2004-October/msg00188.html # からはじまるスレッド # # Note: [] 内は訳注など。 # # Licence: そんなものはあるのかとも思うけれど一応。当然それぞれの # メールはそれぞれの人に属すだろうし、多分メール自体は nautilus-list # のもの? この訳は思い付きと現実逃避ででっちあげたものなので適当に。 # 何かまずかったら引っこめるかもしれません。 # * From: Jimmy Do * To: nautilus-list * Subject: Nautilus debugging tips? * Date: Tue, 12 Oct 2004 22:05:00 -0700 Hey everyone, やあ、みんな、 Initially, one of the toughest things about contributing to Nautilus was learning how to debug effectively. I've developed a pattern of debugging that works for me, but I was wondering if anyone has any further advice. 最初に Nautilus に貢献するのに一番大変なのは効率的なデバッグ方法を学ぶこと だったんだ。自分の場合うまくいくデバッグパターンをつくったんだけど、誰か もっとアドバイスくれないかなと思うんだけど。 Right now, here's what I do: まず僕がやっていること: 1. find a bug 2. locate the part of the source where I suspect the bug might be 3. look through the code and understand its paths of execution 4. open up a terminal 5. run: 'ps axu | grep nautilus' to get Nautilus' pid 6. run: 'gdb nautilus ' to debug the currently running nautilus process 7. debug by placing lots of breakpoints 8. edit the source code 9. compile & install the updated nautilus with 'make && make install' 10. restart nautilus: 'nautilus --quit' 11. repeat steps 5-10 until the bug is fixed 1. バグをみつける 2. ソースのバグってそうだと思う部分をみつける 3. コードを調べて実行パスを理解する 4. 端末を開く 5. 'ps axu | grep nautilus' を実行して Nautilus の PID (プロセス ID) をゲット 6. 'gdb nautilus ' を実行して今動いている Nautilus プロセスを デバッグ 7. ブレークポイントはりまくってデバッグ 8. ソースコードを編集 9. 'make && make install' として更新した nautilus をコンパイル、インストール 10. 'nautilus --quit' として nautilus を再起動 11. バグが直るまで 5 から 10 まで繰り返し Is this what most Nautilus developers do, or am I doing stuff the hard way? :) Nautilus 開発してる人はほとんどがこうしているのかな? あるいは、僕何か 難しいことやってしまってる? :) Thanks for any advice! I really appreciate it. アドバイスくれたらうれしい! まじで尊敬する。 Jimmy * Follow-Ups: o Re: Nautilus debugging tips? + From: Christian Schneider o Re: Nautilus debugging tips? + From: Alexander Larsson ------------------------------------------------------------------------------ * From: Christian Schneider * To: Jimmy Do * Cc: nautilus-list * Subject: Re: Nautilus debugging tips? * Date: Wed, 13 Oct 2004 10:24:59 +0200 One other step that will sure help in debugging. デバッグするのに確実に手助けになるであろう、もう一つ別のステップがあるよ。 Try 試してみて。 strace nautlius It tells you all system calls. While this isn´t exactly a debugger it will give you a rough overview what the programm is doing. I think tihs would be a nice step before running gdb. strace はすべてのシステムコールを教えてくれる。正確にはデバッガーじゃないけど、 プログラムが何やっているか大まかな外観を手に入れられる。 [strace 使うのは] gdb 走らせる前にいいステップになるだろうと僕は考えてる。 -- greets Christian Schneider http://www.liquid-reality.de ------------------------------------------------------------------------------ * From: Alexander Larsson * To: Jimmy Do * Cc: Nautilus * Subject: Re: Nautilus debugging tips? * Date: Wed, 13 Oct 2004 11:19:59 +0200 Some hints: いくつかヒント: * You don't have to make install each time. You can run nautilus from the build tree, just start src/nautilus. This is a libtool wrapper script that makes sure you use the libraries in the build-tree. (When you change e.g. a bonoboui xml file you have to install of course.) 毎回 `make install' する必要はないよ。ただ src/nautilus を起動すればビルド ツリーから nautilus を走らせることができる。libtool ラッパースクリプトが ビルドツリー内のライブラリを使うことを確実にしてくれているんだ。 (もちろん、例えば bonoboui xml ファイルを変更したのなら、インストールしなければ ならないよ。) * You don't have to rebuild all of nautilus each time. Often rebuilding by running make in libnautilus-private/ or src/ is enough 毎回 nautilus を全部ビルドし直す必要はないよ。大抵は libnautilus-private/ か src/ の中で make を走らせて再度ビルドするので十分。 * You don't have to connect to nautilus like that. Just run nautilus in the debugger like: "gdb nautilus" and then "run ". However, this requires nautilus to not already be running. You can get nautilus out of the session (so it doesn't restart automatically) by using "gnome-session-remove nautilus". そのように[nautilus の PID 調べて gdb でそのプロセスにアタッチ]して nautilus に 接続する必要はないよ。単に "gdb nautilus" それから "run " とかで デバッガの中で nautilus を実行するんだ。しかしこれには nautilus が既に実行 されていないことが必要となる。"gnome-session-remove nautilus" として nautilus をセッションの対象外 (そして自動的に再起動しない)にできるよ。 * When you want to understand a more complicated behaviour, I often use printf debugging. Just sprinkle g_print ("foo: doing bar\n") in the code and then watch the output when you run nautilus and do the think you're debugging. もっと複雑な振舞いを理解したいとき、僕はよく printf デバッグを使う。ただ コード中に g_print ("foo: doing bar\n") を散りばめて、そして nautilus を実行 したときのその出力を見て、デバッグするんだ。 * strace is a useful tool at times. Use "-f" to follow into threads, "- tt" to get good timestamps and "-o logfile" to avoid mixing stdout and the trace. strace はときには便利なツールだよ。"-f" でスレッドの中を追いかけていって、 "-tt" でじっくりタイムスタンプを手に入れて、"-o logfile" で stdout と トレースが混ぜこぜになるのを避けるんだ。 * Sometimes when you strace, you want to know when something happens. Just put in a call like access("Doing gazonk", 0) in the code. It'll show up with the string in the trace. strace しているとときどき何が起きているか知りたくなる。[そんなときは]ただ コードの中に access("Doing gazonk", 0) とかの呼出しを入れとくだけ。 トレースの中にその文字列が現われるはず。 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Alexander Larsson Red Hat, Inc alexl redhat com alla lysator liu se He's a maverick drug-addicted vampire hunter on the hunt for the last specimen of a great and near-mythical creature. She's a blind foul-mouthed socialite on her way to prison for a murder she didn't commit. They fight crime! * Follow-Ups: o Re: Nautilus debugging tips? + From: Dave Camp ------------------------------------------------------------------------------ * From: Dave Camp * To: Alexander Larsson * Cc: Nautilus * Subject: Re: Nautilus debugging tips? * Date: Wed, 13 Oct 2004 10:41:47 -0400 Two More: さらに二つ: * Setting the NAUTILUS_DEBUG environment variable to 1 will make all g_log warnings and criticals stop in gdb, and will stop nautilus from respawning. NAUTILUS_DEBUG 環境変数を 1 にしておくと、すべての g_log が警告、深刻なものと なって gdb で止まるようになり、nautilus が再起動するのを止められる。 * If you don't want g_log to break in the debugger but you want nautilus to stop respawning, you can unset SESSION_MANAGER in the shell you're running nautilus from. もし g_log でデバッガーがブレークするのを望まないで、けれども nautilus が 再起動するのを止めたいなら、nautilus を走らせているシェルで SESSION_MANAGER を アンセット(空にセット)できる。 -dave ## vim: set ai si sm tw=78 fileencoding=utf-8: