SlideShare une entreprise Scribd logo
1  sur  35
Télécharger pour lire hors ligne
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
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

Contenu connexe

Tendances

Device Emulation with OSGi and Flash
Device Emulation with OSGi and FlashDevice Emulation with OSGi and Flash
Device Emulation with OSGi and Flash
georgemesesan
 

Tendances (20)

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

En vedette

En vedette (18)

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

Similaire à Advanced debugging techniques (PHP)

Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
Combell NV
 
Debugging PySpark - PyCon US 2018
Debugging PySpark -  PyCon US 2018Debugging PySpark -  PyCon US 2018
Debugging PySpark - PyCon US 2018
Holden Karau
 
Article 01 What Is Php
Article 01   What Is PhpArticle 01   What Is Php
Article 01 What Is Php
drperl
 

Similaire à Advanced debugging techniques (PHP) (20)

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

Dernier

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
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

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
  • 22.
  • 23.
  • 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