SlideShare a Scribd company logo
Advanced debugging
techniques
Patrick Allaert
phpDay Verona 2015, Italy
About me
● Patrick Allaert
● Founder of Libereco and co-founder of catchy.io
● Playing with PHP/Linux for +15 years
● eZ Publish core developer
● Author of the APM PHP extension
● @patrick_allaert
● patrickallaert@php.net
● http://github.com/patrickallaert/
● http://patrickallaert.blogspot.com/
Debugging what?
● PHP execution:
● XDebug
● PHPdbg
● phptrace
● System
● system calls: strace
● library calls: ltrace
● FS notifications: inotify
● Networking
● Wireshark
● MySQL Proxy
Before we start...
The most powerful debugging
technique is...
The most powerful debugging
technique is...
Rubber duck debugging!
Rubber duck debugging!
● You have an issue!
Rubber duck debugging!
● You have an issue!
● Decide to bring it on Stack Overflow
Rubber duck debugging!
● You have an issue!
● Decide to bring it on Stack Overflow
● Write down your question
Rubber duck debugging!
● You have an issue!
● Decide to bring it on Stack Overflow
● Write down your question
● Realize that it doesn't make any sense
Rubber duck debugging!
● You have an issue!
● Decide to bring it on Stack Overflow
● Write down your question
● Realize that it doesn't make any sense
● Rethink how to ask it with enough information
Rubber duck debugging!
● You have an issue!
● Decide to bring it on Stack Overflow
● Write down your question
● Realize that it doesn't make any sense
● Rethink how to ask it with enough information
● Realize that you are attacking the problem from a
wrong perspective
Rubber duck debugging!
● You have an issue!
● Decide to bring it on Stack Overflow
● Write down your question
● Realize that it doesn't make any sense
● Rethink how to ask it with enough information
● Realize that you are attacking the problem from a
wrong perspective
● Start again from scratch and find your solution
Rubber duck debugging!
Rubber duck debugging!
Rubber duck debugging!
Rubber duck debugging!
Rubber duck debugging!
Rubber duck debugging!
Debugging PHP
PHPdbg
● Super powerful and native PHP debugger,
included by default starting PHP 5.6
Advanced debugging techniques (PHP)
Advanced debugging techniques (PHP)
PHPdbg: List source code
PHPdbg: List opcodes
PHPdbg: debugging
phptrace
● Low overhead tracing tool composed of a PHP extension and a command line tool
php -r 'for ($i = 0; $i < 100; $i++) usleep(10000);' &
./phptrace -p $!
1431763911.194806 usleep(10000) at [Command line code:1]
1431763911.204932 usleep => NULL wt: 0.010126 ct: 0.000000
1431763911.204950 usleep(10000) at [Command line code:1]
1431763911.215045 usleep => NULL wt: 0.010095 ct: 0.000000
1431763911.215056 usleep(10000) at [Command line code:1]
1431763911.225177 usleep => NULL wt: 0.010121 ct: 0.000000
1431763911.225192 usleep(10000) at [Command line code:1]
phptrace
● First version of phptrace released YESTERDAY!
https://pecl.php.net/package/trace
System debugging
strace
● Let's you trace any system calls done by a program
● $ strace <program to run>
● $ strace -p <pid> [-f]
● Use -e <category> to filter the type of syscall to
catch.
● Use -c for a summary of the system calls performed.
ltrace
● Let's you trace any library call
● Watch out, this might be very verbose!
● $ ltrace <program to run>
● $ ltrace -p <pid> [-f]
● Use -l <library> to filter on a specific library.
Inotify
● Native Linux FS notification mechanism
MySQL Proxy
● Sits between a client and a server and let's you do
what you want thanks to lua scripting.
● Examples:
● Printing:
– all queries
– the ones not using an index
– the slow ones
● Graphing the most frequent queries / used tables
● Simulate a heavy loaded (read:“slow”) DB
● https://github.com/patrickallaert/MySQL-Proxy-scripts-for-devs
Wireshark
● Catches network traffic and analyze it
● Hundreds of protocols
Thanks
Don't forget to rate this talk on https://joind.in/14562
Stay in touch!
@patrick_allaert
patrickallaert@php.net

More Related Content

PDF
Essential debugging php debugging techniques, tips & tricks
PDF
Voicecon - Mashups with Tropo.com
PDF
CodePolitan Webinar: The Rise of PHP
PDF
The Power Of Refactoring (PHPNW)
PDF
The Power of Refactoring
PDF
The PHP Way Of TDD - Think First, Code Later
ZIP
Test
PDF
Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)
Essential debugging php debugging techniques, tips & tricks
Voicecon - Mashups with Tropo.com
CodePolitan Webinar: The Rise of PHP
The Power Of Refactoring (PHPNW)
The Power of Refactoring
The PHP Way Of TDD - Think First, Code Later
Test
Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)

What's hot (20)

PDF
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
PDF
Definitive Guide to Working With Exceptions in Java
ODP
Device Emulation with OSGi and Flash
PPTX
Leveraging Continuous Integration For Fun And Profit!
PDF
Lightning talk teaching php to kids with atk
PDF
Developing Quality Web Application
PDF
Enterprise PHP Development - ZendCon 2008
PPTX
Functional Patterns with Java8 @Bucharest Java User Group
PDF
PDF
Introduction to saucelabs
PDF
Even better debugging; Equipped yourself with powerful tools.
PDF
Myphp-busters: symfony framework (PHPCon.it)
PDF
Myphp-busters: symfony framework
PPTX
Handling error & exception in php
PDF
Typed Drupal - A great combination of Drupal 8 and PHP 7
PDF
Php exceptions
KEY
Re-imaginging CakePHP
KEY
Gearman Introduction
PPT
Perlbal Tutorial
PDF
Bugs found in GCC with the help of PVS-Studio
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Definitive Guide to Working With Exceptions in Java
Device Emulation with OSGi and Flash
Leveraging Continuous Integration For Fun And Profit!
Lightning talk teaching php to kids with atk
Developing Quality Web Application
Enterprise PHP Development - ZendCon 2008
Functional Patterns with Java8 @Bucharest Java User Group
Introduction to saucelabs
Even better debugging; Equipped yourself with powerful tools.
Myphp-busters: symfony framework (PHPCon.it)
Myphp-busters: symfony framework
Handling error & exception in php
Typed Drupal - A great combination of Drupal 8 and PHP 7
Php exceptions
Re-imaginging CakePHP
Gearman Introduction
Perlbal Tutorial
Bugs found in GCC with the help of PVS-Studio
Ad

Viewers also liked (18)

PDF
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PDF
Intro to Debugging PHP with Xdebug
PDF
La métrique, ce n'est pas que pour le devops
PDF
Maitriser les structures de données PHP 102 - Forum Paris 2012
PDF
Debugging PHP With Xdebug
PDF
Create your own PHP extension, step by step - phpDay 2012 Verona
PDF
Masterizing PHP Data Structure 102 - PHPUK 2012
PDF
Magento 2 Development Best Practices
PDF
Masterizing php data structure 102
PPTX
PPTX
Debugging Effectively - PHP UK 2017
PPTX
A World Without PHP
PDF
Functional Structures in PHP
PDF
Driving Design through Examples
PDF
Tactical DDD (just better OOP?) - PHPBenelux 2017
PPTX
Docker for Developers - Sunshine PHP
PPTX
Brownfield Domain Driven Design
PDF
reveal.js 3.0.0
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
Intro to Debugging PHP with Xdebug
La métrique, ce n'est pas que pour le devops
Maitriser les structures de données PHP 102 - Forum Paris 2012
Debugging PHP With Xdebug
Create your own PHP extension, step by step - phpDay 2012 Verona
Masterizing PHP Data Structure 102 - PHPUK 2012
Magento 2 Development Best Practices
Masterizing php data structure 102
Debugging Effectively - PHP UK 2017
A World Without PHP
Functional Structures in PHP
Driving Design through Examples
Tactical DDD (just better OOP?) - PHPBenelux 2017
Docker for Developers - Sunshine PHP
Brownfield Domain Driven Design
reveal.js 3.0.0
Ad

Similar to Advanced debugging techniques (PHP) (20)

PDF
How Badoo Saved $1M Switching to PHP7 - Nikolay Krapivnyy - PHPDay Verona 2016
PDF
Debugging and Profiling PHP Applications
PDF
Php through the eyes of a hoster phpbnl11
ODP
IPC 2013 - High Performance PHP with HipHop
PDF
PHP 7.1 : elegance of our legacy
PDF
Php through the eyes of a hoster
PDF
Practical intro to PhpSpec
PDF
More about PHP
PPSX
Setting advanced PHP development environment
PDF
CLI, the other SAPI
PDF
[Community Open Camp] 給 PHP 開發者的 VS Code 指南
PPT
Php training100%placement-in-mumbai
KEY
Prepare for PHP Test Fest 2009
ODP
The why and how of moving to PHP 5.5/5.6
PDF
20 PHP Static Analysis and Documentation Generators #burningkeyboards
PDF
Php performance-talk
PDF
Laravel level 0 (introduction)
PDF
Debugging PySpark - PyCon US 2018
DOC
Article 01 What Is Php
PPTX
Php 7 hhvm and co
How Badoo Saved $1M Switching to PHP7 - Nikolay Krapivnyy - PHPDay Verona 2016
Debugging and Profiling PHP Applications
Php through the eyes of a hoster phpbnl11
IPC 2013 - High Performance PHP with HipHop
PHP 7.1 : elegance of our legacy
Php through the eyes of a hoster
Practical intro to PhpSpec
More about PHP
Setting advanced PHP development environment
CLI, the other SAPI
[Community Open Camp] 給 PHP 開發者的 VS Code 指南
Php training100%placement-in-mumbai
Prepare for PHP Test Fest 2009
The why and how of moving to PHP 5.5/5.6
20 PHP Static Analysis and Documentation Generators #burningkeyboards
Php performance-talk
Laravel level 0 (introduction)
Debugging PySpark - PyCon US 2018
Article 01 What Is Php
Php 7 hhvm and co

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Machine learning based COVID-19 study performance prediction
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Cloud computing and distributed systems.
PDF
Modernizing your data center with Dell and AMD
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Advanced IT Governance
PPT
Teaching material agriculture food technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Spectral efficient network and resource selection model in 5G networks
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Big Data Technologies - Introduction.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Approach and Philosophy of On baking technology
Network Security Unit 5.pdf for BCA BBA.
Machine learning based COVID-19 study performance prediction
Advanced Soft Computing BINUS July 2025.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Cloud computing and distributed systems.
Modernizing your data center with Dell and AMD
NewMind AI Monthly Chronicles - July 2025
Advanced IT Governance
Teaching material agriculture food technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

Advanced debugging techniques (PHP)

  • 2. About me ● Patrick Allaert ● Founder of Libereco and co-founder of catchy.io ● Playing with PHP/Linux for +15 years ● eZ Publish core developer ● Author of the APM PHP extension ● @patrick_allaert ● patrickallaert@php.net ● http://github.com/patrickallaert/ ● http://patrickallaert.blogspot.com/
  • 3. Debugging what? ● PHP execution: ● XDebug ● PHPdbg ● phptrace ● System ● system calls: strace ● library calls: ltrace ● FS notifications: inotify ● Networking ● Wireshark ● MySQL Proxy
  • 5. The most powerful debugging technique is...
  • 6. The most powerful debugging technique is... Rubber duck debugging!
  • 7. Rubber duck debugging! ● You have an issue!
  • 8. Rubber duck debugging! ● You have an issue! ● Decide to bring it on Stack Overflow
  • 9. Rubber duck debugging! ● You have an issue! ● Decide to bring it on Stack Overflow ● Write down your question
  • 10. Rubber duck debugging! ● You have an issue! ● Decide to bring it on Stack Overflow ● Write down your question ● Realize that it doesn't make any sense
  • 11. Rubber duck debugging! ● You have an issue! ● Decide to bring it on Stack Overflow ● Write down your question ● Realize that it doesn't make any sense ● Rethink how to ask it with enough information
  • 12. Rubber duck debugging! ● You have an issue! ● Decide to bring it on Stack Overflow ● Write down your question ● Realize that it doesn't make any sense ● Rethink how to ask it with enough information ● Realize that you are attacking the problem from a wrong perspective
  • 13. Rubber duck debugging! ● You have an issue! ● Decide to bring it on Stack Overflow ● Write down your question ● Realize that it doesn't make any sense ● Rethink how to ask it with enough information ● Realize that you are attacking the problem from a wrong perspective ● Start again from scratch and find your solution
  • 21. PHPdbg ● Super powerful and native PHP debugger, included by default starting PHP 5.6
  • 27. phptrace ● Low overhead tracing tool composed of a PHP extension and a command line tool php -r 'for ($i = 0; $i < 100; $i++) usleep(10000);' & ./phptrace -p $! 1431763911.194806 usleep(10000) at [Command line code:1] 1431763911.204932 usleep => NULL wt: 0.010126 ct: 0.000000 1431763911.204950 usleep(10000) at [Command line code:1] 1431763911.215045 usleep => NULL wt: 0.010095 ct: 0.000000 1431763911.215056 usleep(10000) at [Command line code:1] 1431763911.225177 usleep => NULL wt: 0.010121 ct: 0.000000 1431763911.225192 usleep(10000) at [Command line code:1]
  • 28. phptrace ● First version of phptrace released YESTERDAY! https://pecl.php.net/package/trace
  • 30. strace ● Let's you trace any system calls done by a program ● $ strace <program to run> ● $ strace -p <pid> [-f] ● Use -e <category> to filter the type of syscall to catch. ● Use -c for a summary of the system calls performed.
  • 31. ltrace ● Let's you trace any library call ● Watch out, this might be very verbose! ● $ ltrace <program to run> ● $ ltrace -p <pid> [-f] ● Use -l <library> to filter on a specific library.
  • 32. Inotify ● Native Linux FS notification mechanism
  • 33. MySQL Proxy ● Sits between a client and a server and let's you do what you want thanks to lua scripting. ● Examples: ● Printing: – all queries – the ones not using an index – the slow ones ● Graphing the most frequent queries / used tables ● Simulate a heavy loaded (read:“slow”) DB ● https://github.com/patrickallaert/MySQL-Proxy-scripts-for-devs
  • 34. Wireshark ● Catches network traffic and analyze it ● Hundreds of protocols
  • 35. Thanks Don't forget to rate this talk on https://joind.in/14562 Stay in touch! @patrick_allaert patrickallaert@php.net