SlideShare a Scribd company logo
1 of 13
Download to read offline
Debugging of CPD



   Naruhiko Ogasawara
   OpenPrinting Japan

Koedo LUG Offline Meeting
    June 13th, 2009
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)
What's Common Printing Dialog?

   Desktop OS ではプリンタの印刷設定について
    OS 側が用意するのが普通
       アプリケーションはどのプリンタについても同じように実
        装することができる
       プリンタベンダは統一された方法でベンダ独自の機能
        をユーザに見せることができる
   *nix にはこれまでそういう仕組みがなかった
       GTK+ / KDE それぞれ持っているが、互換性がない
   それを解消するのが Common Printing Dialog
Demonstration
Problem of CPD

   No Human Resource
       思想は高邁だが、実装する人間がコミュニティに存在し
        ない
       Google Summer of Code だより
   Enough Usability Testing?
       既存の UI とかなり異なる User Experience
       それ自体はいいとして、ちゃんと検証しているのか?
   BUG !  BUG !  BUG !
       結局人がいないので、サンプル実装はバグだらけ
Debug Hacks!

   私は長らく Windows プログラマであった
   *nix についてはよくしらない
       技術者と言うより政治屋
       社内で *nix についてどう対応していくかを考えて関連
        部署を説得するのが仕事
   それじゃつまらん!
       ということで本を
        買いました。
Debugging CPD (KDE ver.)

   CPD の KDE バージョンはプリントキューが一個
    もないと Qt がクラッシュするというナイス不具合
    がある
   半年ぐらい前にバグレポしたのにちっとも治らない
   せっかくなのでこれをデバッグしてみよう!
       とかいってるうちに開発が進んでしまった (6/11 にごっ
        そりコミットされた) ので、このネタはもう古いです。しく
        しく。
   コンパイルなどなどについてはブログ見てください
        http://d.hatena.ne.jp/naruoga/20090527/1243382202
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 quot;i486­linux­gnuquot;...
    (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[]: quot;index out of rangequot;, file 
    /usr/include/qt4/QtCore/qvector.h, line 335

    Program received signal SIGABRT, Aborted.
    [Switching to Thread 0xb5f19940 (LWP 19299)]
    0xb800b422 in __kernel_vsyscall () 
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
    ...
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[]: quot;index out of rangequot;, file /usr/include/
    qt4/QtCore/qvector.h, line 335

    Program received signal SIGABRT, Aborted.
    0xb7f9e422 in __kernel_vsyscall ()
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 になるのも当然
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 ならアラート
    出して終了するのが一番簡単
Conclusion

   エンジニアを引退した私でも gdb でデバッグでき
    た! しかも楽しい!
       やってみようと思わせた Debug Hacks 素晴らしい
   今度はもっと複雑なバグを追っかけてみたい
   CPD 自体ははやいとこ品質あげてほしいので、こ
    うやってちょこちょこ手伝えたら楽しいかも
   Printing の標準化は人手が足りないので、こういう
    ことに興味がある人ぜひ参加してくださいなっ。

More Related Content

More from Naruhiko Ogasawara

Happy Software Freedom Day! (Koedo Linux Users Group, Tokyo, Japan)
Happy Software Freedom Day! (Koedo Linux Users Group, Tokyo, Japan)Happy Software Freedom Day! (Koedo Linux Users Group, Tokyo, Japan)
Happy Software Freedom Day! (Koedo Linux Users Group, Tokyo, Japan)Naruhiko Ogasawara
 
宣伝:SeleniumConf Tokyo 2019やりますよ!
宣伝:SeleniumConf Tokyo 2019やりますよ!宣伝:SeleniumConf Tokyo 2019やりますよ!
宣伝:SeleniumConf Tokyo 2019やりますよ!Naruhiko Ogasawara
 
Using latest LibreOffice on openSUSE Leap 15 - by modern packaging systems
Using latest LibreOffice on openSUSE Leap 15 - by modern packaging systemsUsing latest LibreOffice on openSUSE Leap 15 - by modern packaging systems
Using latest LibreOffice on openSUSE Leap 15 - by modern packaging systemsNaruhiko Ogasawara
 
The Document Foundationについて
The Document FoundationについてThe Document Foundationについて
The Document FoundationについてNaruhiko Ogasawara
 
LibreOffice: The Office Suite with Mixing Bowl Culture
LibreOffice: The Office Suite with Mixing Bowl CultureLibreOffice: The Office Suite with Mixing Bowl Culture
LibreOffice: The Office Suite with Mixing Bowl CultureNaruhiko Ogasawara
 
Make It Better Together: コミュニティを主体としたLibreOffice翻訳 / : Community-centered Lib...
Make It Better Together: コミュニティを主体としたLibreOffice翻訳 / : Community-centered Lib...Make It Better Together: コミュニティを主体としたLibreOffice翻訳 / : Community-centered Lib...
Make It Better Together: コミュニティを主体としたLibreOffice翻訳 / : Community-centered Lib...Naruhiko Ogasawara
 
Hospital days in czech / チェコで入院した話
Hospital days in czech / チェコで入院した話Hospital days in czech / チェコで入院した話
Hospital days in czech / チェコで入院した話Naruhiko Ogasawara
 
openSUSEユーザーに向けたLibreOffice入門 / Introduction of LibreOffice for openSUSE users
openSUSEユーザーに向けたLibreOffice入門 / Introduction of LibreOffice for openSUSE usersopenSUSEユーザーに向けたLibreOffice入門 / Introduction of LibreOffice for openSUSE users
openSUSEユーザーに向けたLibreOffice入門 / Introduction of LibreOffice for openSUSE usersNaruhiko Ogasawara
 
Webブラウザで動くOSSオフィスソフト、LibreOffice Onlineの中身に迫る / LibreOffice Online Implementa...
Webブラウザで動くOSSオフィスソフト、LibreOffice Onlineの中身に迫る / LibreOffice Online Implementa...Webブラウザで動くOSSオフィスソフト、LibreOffice Onlineの中身に迫る / LibreOffice Online Implementa...
Webブラウザで動くOSSオフィスソフト、LibreOffice Onlineの中身に迫る / LibreOffice Online Implementa...Naruhiko Ogasawara
 
LibreOfficeの最新動向 / LibreOffice current status
LibreOfficeの最新動向 / LibreOffice current statusLibreOfficeの最新動向 / LibreOffice current status
LibreOfficeの最新動向 / LibreOffice current statusNaruhiko Ogasawara
 
Vertical Writing: typical use-cases and current status in LibreOffice
Vertical Writing: typical use-cases and current status in LibreOfficeVertical Writing: typical use-cases and current status in LibreOffice
Vertical Writing: typical use-cases and current status in LibreOfficeNaruhiko Ogasawara
 
LibreOffice, the free office productive suite and it's status of accessibilit...
LibreOffice, the free office productive suite and it's status of accessibilit...LibreOffice, the free office productive suite and it's status of accessibilit...
LibreOffice, the free office productive suite and it's status of accessibilit...Naruhiko Ogasawara
 
小江戸らぐ 第154回飯能河原BBQオフ(春の宴)にいて
小江戸らぐ 第154回飯能河原BBQオフ(春の宴)にいて小江戸らぐ 第154回飯能河原BBQオフ(春の宴)にいて
小江戸らぐ 第154回飯能河原BBQオフ(春の宴)にいてNaruhiko Ogasawara
 
LibreOffice UI/ ヘルプ翻訳の基礎知識
LibreOffice UI/ ヘルプ翻訳の基礎知識LibreOffice UI/ ヘルプ翻訳の基礎知識
LibreOffice UI/ ヘルプ翻訳の基礎知識Naruhiko Ogasawara
 
OpenStreetMap+MongoDBで地図情報を検索してみたい!
OpenStreetMap+MongoDBで地図情報を検索してみたい!OpenStreetMap+MongoDBで地図情報を検索してみたい!
OpenStreetMap+MongoDBで地図情報を検索してみたい!Naruhiko Ogasawara
 
LibreOffice Conference 2014 Bern, Switzerland Report (in Japanese)
LibreOffice Conference 2014 Bern, Switzerland Report (in Japanese)LibreOffice Conference 2014 Bern, Switzerland Report (in Japanese)
LibreOffice Conference 2014 Bern, Switzerland Report (in Japanese)Naruhiko Ogasawara
 
ソフトウェアの自由って? & ベルン写真集 & Document Liberation Project紹介 / What's Software Freed...
ソフトウェアの自由って? & ベルン写真集 & Document Liberation Project紹介 / What's Software Freed...ソフトウェアの自由って? & ベルン写真集 & Document Liberation Project紹介 / What's Software Freed...
ソフトウェアの自由って? & ベルン写真集 & Document Liberation Project紹介 / What's Software Freed...Naruhiko Ogasawara
 
MongoDB very basic (Japanese) / MongoDB基礎の基礎
MongoDB very basic (Japanese) / MongoDB基礎の基礎MongoDB very basic (Japanese) / MongoDB基礎の基礎
MongoDB very basic (Japanese) / MongoDB基礎の基礎Naruhiko Ogasawara
 

More from Naruhiko Ogasawara (20)

Happy Software Freedom Day! (Koedo Linux Users Group, Tokyo, Japan)
Happy Software Freedom Day! (Koedo Linux Users Group, Tokyo, Japan)Happy Software Freedom Day! (Koedo Linux Users Group, Tokyo, Japan)
Happy Software Freedom Day! (Koedo Linux Users Group, Tokyo, Japan)
 
宣伝:SeleniumConf Tokyo 2019やりますよ!
宣伝:SeleniumConf Tokyo 2019やりますよ!宣伝:SeleniumConf Tokyo 2019やりますよ!
宣伝:SeleniumConf Tokyo 2019やりますよ!
 
Using latest LibreOffice on openSUSE Leap 15 - by modern packaging systems
Using latest LibreOffice on openSUSE Leap 15 - by modern packaging systemsUsing latest LibreOffice on openSUSE Leap 15 - by modern packaging systems
Using latest LibreOffice on openSUSE Leap 15 - by modern packaging systems
 
The Document Foundationについて
The Document FoundationについてThe Document Foundationについて
The Document Foundationについて
 
告知 ー OSnuC Kawagoe 2018
告知 ー OSnuC Kawagoe 2018告知 ー OSnuC Kawagoe 2018
告知 ー OSnuC Kawagoe 2018
 
LibreOffice: The Office Suite with Mixing Bowl Culture
LibreOffice: The Office Suite with Mixing Bowl CultureLibreOffice: The Office Suite with Mixing Bowl Culture
LibreOffice: The Office Suite with Mixing Bowl Culture
 
Make It Better Together: コミュニティを主体としたLibreOffice翻訳 / : Community-centered Lib...
Make It Better Together: コミュニティを主体としたLibreOffice翻訳 / : Community-centered Lib...Make It Better Together: コミュニティを主体としたLibreOffice翻訳 / : Community-centered Lib...
Make It Better Together: コミュニティを主体としたLibreOffice翻訳 / : Community-centered Lib...
 
Hospital days in czech / チェコで入院した話
Hospital days in czech / チェコで入院した話Hospital days in czech / チェコで入院した話
Hospital days in czech / チェコで入院した話
 
openSUSEユーザーに向けたLibreOffice入門 / Introduction of LibreOffice for openSUSE users
openSUSEユーザーに向けたLibreOffice入門 / Introduction of LibreOffice for openSUSE usersopenSUSEユーザーに向けたLibreOffice入門 / Introduction of LibreOffice for openSUSE users
openSUSEユーザーに向けたLibreOffice入門 / Introduction of LibreOffice for openSUSE users
 
Webブラウザで動くOSSオフィスソフト、LibreOffice Onlineの中身に迫る / LibreOffice Online Implementa...
Webブラウザで動くOSSオフィスソフト、LibreOffice Onlineの中身に迫る / LibreOffice Online Implementa...Webブラウザで動くOSSオフィスソフト、LibreOffice Onlineの中身に迫る / LibreOffice Online Implementa...
Webブラウザで動くOSSオフィスソフト、LibreOffice Onlineの中身に迫る / LibreOffice Online Implementa...
 
LibreOfficeの最新動向 / LibreOffice current status
LibreOfficeの最新動向 / LibreOffice current statusLibreOfficeの最新動向 / LibreOffice current status
LibreOfficeの最新動向 / LibreOffice current status
 
Vertical Writing: typical use-cases and current status in LibreOffice
Vertical Writing: typical use-cases and current status in LibreOfficeVertical Writing: typical use-cases and current status in LibreOffice
Vertical Writing: typical use-cases and current status in LibreOffice
 
LibreOffice, the free office productive suite and it's status of accessibilit...
LibreOffice, the free office productive suite and it's status of accessibilit...LibreOffice, the free office productive suite and it's status of accessibilit...
LibreOffice, the free office productive suite and it's status of accessibilit...
 
小江戸らぐ 第154回飯能河原BBQオフ(春の宴)にいて
小江戸らぐ 第154回飯能河原BBQオフ(春の宴)にいて小江戸らぐ 第154回飯能河原BBQオフ(春の宴)にいて
小江戸らぐ 第154回飯能河原BBQオフ(春の宴)にいて
 
LibreOffice UI/ ヘルプ翻訳の基礎知識
LibreOffice UI/ ヘルプ翻訳の基礎知識LibreOffice UI/ ヘルプ翻訳の基礎知識
LibreOffice UI/ ヘルプ翻訳の基礎知識
 
LibreOffice in Eastern Asia
LibreOffice in Eastern AsiaLibreOffice in Eastern Asia
LibreOffice in Eastern Asia
 
OpenStreetMap+MongoDBで地図情報を検索してみたい!
OpenStreetMap+MongoDBで地図情報を検索してみたい!OpenStreetMap+MongoDBで地図情報を検索してみたい!
OpenStreetMap+MongoDBで地図情報を検索してみたい!
 
LibreOffice Conference 2014 Bern, Switzerland Report (in Japanese)
LibreOffice Conference 2014 Bern, Switzerland Report (in Japanese)LibreOffice Conference 2014 Bern, Switzerland Report (in Japanese)
LibreOffice Conference 2014 Bern, Switzerland Report (in Japanese)
 
ソフトウェアの自由って? & ベルン写真集 & Document Liberation Project紹介 / What's Software Freed...
ソフトウェアの自由って? & ベルン写真集 & Document Liberation Project紹介 / What's Software Freed...ソフトウェアの自由って? & ベルン写真集 & Document Liberation Project紹介 / What's Software Freed...
ソフトウェアの自由って? & ベルン写真集 & Document Liberation Project紹介 / What's Software Freed...
 
MongoDB very basic (Japanese) / MongoDB基礎の基礎
MongoDB very basic (Japanese) / MongoDB基礎の基礎MongoDB very basic (Japanese) / MongoDB基礎の基礎
MongoDB very basic (Japanese) / MongoDB基礎の基礎
 

Recently uploaded

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

How to debug the Common Printing Dialog

  • 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
  • 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 quot;i486­linux­gnuquot;... (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[]: quot;index out of rangequot;, 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[]: quot;index out of rangequot;, 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 の標準化は人手が足りないので、こういう ことに興味がある人ぜひ参加してくださいなっ。