(Created page with "コンポーネントやライブラリなどは kDebug(1234) などのようにデバッグエリアナンバーを使うようにアドバイスされています。このた...") |
(Created page with "<tt>qDebug()</tt> を使ってはいけないということだけははっきり覚えておいて下さい。それはリリース時に無効になりません。また、<tt>...") |
||
| Line 106: | Line 106: | ||
For more information, about this, see [http://www.kdedevelopers.org/node/3171 Allen Winter's blog post]. | For more information, about this, see [http://www.kdedevelopers.org/node/3171 Allen Winter's blog post]. | ||
| − | + | <tt>qDebug()</tt> を使ってはいけないということだけははっきり覚えておいて下さい。それはリリース時に無効になりません。また、<tt>assert()</tt> や <tt>kFatal()</tt> を使うことも避けて下さい。それらは何かアプリケーションないでまずいことが起きた場合、アプリをクラッシュさせてしまいます。決してユーザーにとって良いものではないのです。エラーを発見する良い方法は <tt>kWarning()</tt> や <tt>kError()</tt> を使って下さい。そして、できる限りそのエラーから回復させて下さい。 | |
To get timestamps with your debug output, which are useful for debugging multi-threaded, networked and asynchronous operations, <tt>export KDE_DEBUG_TIMESTAMP=1</tt> before running your app. Since KDE SC 4.5. | To get timestamps with your debug output, which are useful for debugging multi-threaded, networked and asynchronous operations, <tt>export KDE_DEBUG_TIMESTAMP=1</tt> before running your app. Since KDE SC 4.5. | ||
KDE_DEBUG 環境変数を1に設定してください。
To get Dr Konqi back, unset the KDE_DEBUG environment variable.
Example:
export KDE_DEBUG=1
unset KDE_DEBUG
Edit file $KDEHOME/share/config/drkonqirc and add the following:
[drkonqi] ConfigName=developer
core ファイルとはアプリケーションがクラッシュしたときのメモリイメージです。これを使うことによって、どの変数がセットされていたり、どこでアプリがクラッシュしたかを知ることができます。
いくつかのディストリビューションでは core ファイルの生成を不可にしています。生成できるようにするには ulimit -c unlimited を実行してください。
いったん core ファイルが手に入ったら、"gdb appname core" で調べることができます。これで gdb は与えられたアプリケーション用に core ファイル上でオープンできます。gdb のプロンプトが出たら、bt というコマンドが役に立ちます。これはクラッシュのバックトレースを生成することができます。gdb の使い方についてもっと情報がほしいなら、こちらのページを見て下さい。
Check this page and kdesdk, there are a bunch of useful scripts there.
Check out kdesdk, and add this line to your ~/.gdbinit :
source /path/to/kde/sources/kdesdk/scripts/kde-devel-gdb
Then in gdb you can do printqstring myqstring to see its contents.
For instance, QString myqstring = QString::fromLatin1("contents"); can be examined using
(gdb) printqstring myqstring $1 = "content"
See the kde-devel-gdb file for the other macros it defines.
You must stop just after the main to load the debugging symbols of the shared library. After that, you can debug normally. One can go as far as creating a gdb macro, to stop right after the part was loaded. For kword, by example, I use:
define startkword
break main
run
break 'KoDocument::KoDocument(int, QWidget *, char const *,
QObject *, char const *, bool)' cont
Here are some steps that you can use to troubleshoot why your signal/slot connection is not working (your slot does not get called for some reason).
1) Verify that the connect() doesn't print a warning to the console at runtime.
If it does, check that you wrote Q_OBJECT, that the parameter names are not in the connect, that the parameter types are compatible, and that the slot is defined, and that the moc was compiled.
1b) Or you can just check to see what connect() returns as a bool. Although this won't give you the error message. 2) Verify that the signal is indeed emitted 3) Verify that the receiver isn't already deleted at that time 4) Verify that emitter->signalsBlocked() returns false
kDebug() を使うとよいでしょう。
#include <kdebug.h> kDebug() << "KMyApp just started";
文法は cout とほとんど同じで、多くのネイティブな型を "<<" の間に使えます。これはデバッグメッセージを出力しますが、リリース時に(--disable-debug で)自動的に無効にすることができます。もし、メッセージをリリース中も出力したいならば、それらは警告やエラーなので kWarning() や kError() を使って下さい。
コンポーネントやライブラリなどは kDebug(1234) などのようにデバッグエリアナンバーを使うようにアドバイスされています。このためには、kdelibs/kdecore/kdebug.area にその数字が登録されていなければいけません。デバッグエリアのお陰で、特定のエリアナンバーのデバッグ出力を無効にすることができます。そのためには kdebugdialog という kdebase の一部であるプログラムを使います。kdebugdialog --fullmode によってまた、デバッグ出力のログをどこに取るか制御することもできます。普段、スタンドアローンなアプリケーションのためにエリアナンバーを登録することは、そのアプリケーションが複雑で出力をいくつかのエリアに分割したいと思うことが無ければ、必要ありません。
It is possible to omit the debug area number when calling kDebug by adding the following code to your top-level CMakeLists.txt:
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=XXXX)
For more information, about this, see Allen Winter's blog post.
qDebug() を使ってはいけないということだけははっきり覚えておいて下さい。それはリリース時に無効になりません。また、assert() や kFatal() を使うことも避けて下さい。それらは何かアプリケーションないでまずいことが起きた場合、アプリをクラッシュさせてしまいます。決してユーザーにとって良いものではないのです。エラーを発見する良い方法は kWarning() や kError() を使って下さい。そして、できる限りそのエラーから回復させて下さい。
To get timestamps with your debug output, which are useful for debugging multi-threaded, networked and asynchronous operations, export KDE_DEBUG_TIMESTAMP=1 before running your app. Since KDE SC 4.5.