How to debug the Common Printing Dialog

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    How to debug the Common Printing Dialog - Presentation Transcript

    1. Debugging of CPD Naruhiko Ogasawara OpenPrinting Japan Koedo LUG Offline Meeting June 13th, 2009
    2. What is OpenPrinting?  *nix の印刷関連の標準化を行う団体  The Linux Foundation の下部組織  Manager: Till Kamppeter  元 Mandriva Linux の印刷オタク  Foomatic という印刷ミドルウェアの開発者  主な業績  Open Printing Vector Printing (OPVP)  PDF Print Path  Automatic Driver Downloading  Common Printing Dialog (CPD)
    3. What's Common Printing Dialog?  Desktop OS ではプリンタの印刷設定について OS 側が用意するのが普通  アプリケーションはどのプリンタについても同じように実 装することができる  プリンタベンダは統一された方法でベンダ独自の機能 をユーザに見せることができる  *nix にはこれまでそういう仕組みがなかった  GTK+ / KDE それぞれ持っているが、互換性がない  それを解消するのが Common Printing Dialog
    4. Demonstration
    5. Problem of CPD  No Human Resource  思想は高邁だが、実装する人間がコミュニティに存在し ない  Google Summer of Code だより  Enough Usability Testing?  既存の UI とかなり異なる User Experience  それ自体はいいとして、ちゃんと検証しているのか?  BUG !  BUG !  BUG !  結局人がいないので、サンプル実装はバグだらけ
    6. Debug Hacks!  私は長らく Windows プログラマであった  *nix についてはよくしらない  技術者と言うより政治屋  社内で *nix についてどう対応していくかを考えて関連 部署を説得するのが仕事  それじゃつまらん!  ということで本を 買いました。
    7. Debugging CPD (KDE ver.)  CPD の KDE バージョンはプリントキューが一個 もないと Qt がクラッシュするというナイス不具合 がある  半年ぐらい前にバグレポしたのにちっとも治らない  せっかくなのでこれをデバッグしてみよう!  とかいってるうちに開発が進んでしまった (6/11 にごっ そりコミットされた) ので、このネタはもう古いです。しく しく。  コンパイルなどなどについてはブログ見てください http://d.hatena.ne.jp/naruoga/20090527/1243382202
    8. Debugging CPD (KDE ver.) (2)  とりあえずデーモンもどきを起動して、ダイアログア プリを gdb で起動してえいっと実行 $ kde4­dialog/kde4­cpd & $ gdb kde4­dialog/view­dialog GNU gdb 6.8­debian Copyright (C) 2008 Free Software Foundation, Inc. <snip> This GDB was configured as \"i486­linux­gnu\"... (gdb) run Starting program: /home/naruhiko/common­printing­dialog/build/kde4­ dialog/view­dialog  [Thread debugging using libthread_db enabled] [New Thread 0xb5f19940 (LWP 19299)] ASSERT failure in QVector<T>::operator[]: \"index out of range\", file  /usr/include/qt4/QtCore/qvector.h, line 335 Program received signal SIGABRT, Aborted. [Switching to Thread 0xb5f19940 (LWP 19299)] 0xb800b422 in __kernel_vsyscall () 
    9. Debugging CPD (KDE ver.) (3)  Qt の QVector クラスの [] オペレータで死んでる  でもまさかこんな基本クラスがバグってるとは考え にくい  呼出側があやしい!> Backtrace ! (gdb) bt #0  0xb800b422 in __kernel_vsyscall () #1  0xb66286d0 in raise () from /lib/tls/i686/cmov/libc.so.6 #2  0xb662a098 in abort () from /lib/tls/i686/cmov/libc.so.6 #3  0xb7658595 in qt_message_output () from /usr/lib/libQtCore.so.4 #4  0xb7658681 in qFatal () from /usr/lib/libQtCore.so.4 #5  0xb765872c in qt_assert_x () from /usr/lib/libQtCore.so.4 #6  0x08064941 in QVector<CommonPrinting::CUPSDestination>::operator[] (     this=0xa0aef84, i=0) at /usr/include/qt4/QtCore/qvector.h:335 #7  0x0805dc40 in CPDialogWidget::initWidgets (this=0xa0aef50)     at /home/naruhiko/common­printing­dialog/kde4­ dialog/cpd_dialog_widget.cpp:861 ...
    10. Debugging CPD (KDE ver.) (4)  人の書いたプログラムなのでロジックを追いたい  そこでメソッドの先頭に breakpoint して再実行 (gdb) b CPDialogWidget::initWidgets() Breakpoint 1 at 0x805db19: file /home/naruhiko/common­printing­dialog/kde4­dialog/ cpd_dialog_widget.cpp, line 855. (gdb) run Starting program: /home/naruhiko/common­printing­dialog/build/kde4­dialog/view­ dialog  [Thread debugging using libthread_db enabled] [New Thread 0xb5eac940 (LWP 19668)] [Switching to Thread 0xb5eac940 (LWP 19668)] Breakpoint 1, CPDialogWidget::initWidgets (this=0x892b120)     at /home/naruhiko/common­printing­dialog/kde4­dialog/cpd_dialog_widget.cpp:855 <snip> 861 currentPrinter = &(printers[0]); (gdb) n ASSERT failure in QVector<T>::operator[]: \"index out of range\", file /usr/include/ qt4/QtCore/qvector.h, line 335 Program received signal SIGABRT, Aborted. 0xb7f9e422 in __kernel_vsyscall ()
    11. Debugging CPD (KDE ver.) (5)  printers[0] の呼び出しで死んでるらしい  この人 (printers) は何者?  ちょっと上を見れば分かる 857 printers = CUPSSupport::getDests(); (gdb) n 858 for(int i = 0; i < printers.size(); i++) { (gdb) print printers $1 = {{p = 0x8070670, d = 0x8070670}} (gdb) print printers.size() $2 = 0  CUPSSupport クラスは見てないけど、多分 Destination ( 印刷先 ) を列挙してベクタに返す  だから size == 0 になるのも当然
    12. Debugging CPD (KDE ver.) (6)  Qt のドキュメントをチェック  http://doc.trolltech.com/4.5/qvector.html#operator-5b-5d T & QVector::operator[] ( int i ) Returns the item at index position i as a modifiable reference. i must be a valid index position in the vector (i.e., 0 <= i < size()).  size() == 0 のときに operator [] 呼んじゃダメ  だからこのコードの場合 size() == 0 ならアラート 出して終了するのが一番簡単
    13. Conclusion  エンジニアを引退した私でも gdb でデバッグでき た! しかも楽しい!  やってみようと思わせた Debug Hacks 素晴らしい  今度はもっと複雑なバグを追っかけてみたい  CPD 自体ははやいとこ品質あげてほしいので、こ うやってちょこちょこ手伝えたら楽しいかも  Printing の標準化は人手が足りないので、こういう ことに興味がある人ぜひ参加してくださいなっ。
    SlideShare Zeitgeist 2009

    + Naruhiko  OgasawaraNaruhiko Ogasawara Nominate

    custom

    524 views, 1 favs, 1 embeds more stats

    This presentation show very very introduction of de more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 524
      • 517 on SlideShare
      • 7 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 1
    Most viewed embeds
    • 7 views on http://d.hatena.ne.jp

    more

    All embeds
    • 7 views on http://d.hatena.ne.jp

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories