SlideShare a Scribd company logo
Xdebug from A to X
           By
    Gennady Feldman
      Aug 25, 2009
Agenda
► Installation
► Error  Handling
► Debugging
► Profiling
► Function Traces
Xdebug Features
► Variable  display
► Stack Traces
► Profiling PHP Scripts
► Remote Debugging
► Function Traces
► Code Coverage Analysis*


* Not covered in this presentation.
Installing
► Xdebug   is a PHP extension. (written in C)
► Xdebug is Open Source so you could
  download and build/install it yourself.
► Almost every Linux distro today provides an
  Xdebug binary package.
► Binaries are also available for Windows from
  http://xdebug.org website.
Installing (Part 2)
► On   Ubuntu 9.04:
   apt-get install php5-xdebug
► On   Mandriva:
   urpmi php5-xdebug
► Using   PEAR/PECL:
   pecl install xdebug
   pecl upgrade xdebug
Installing (Part 3)
► Toenable xdebug add the fullpath to
 xdebug.so:
  zend_extension=/usr/lib/php5/20060613+lfs/xdebug.so
   To php.ini or
   To conf.d/xdebug.ini file
► Youcould also setup system wide defaults
 as well through the ini file.
Installing (Part 4)
► Check   that Xdebug is installed via:
   php –v
   php –m
   php –ri xdebug
► Check  phpinfo() report and look for xdebug
  section.
► You might need to restart your web server.
Error Handling (display_errors off)
Error Handling (display_errors on)
Error Handling (display_errors On w/
              xdebug)
Error Handling (display_errors on w/
              Xdebug)
Error Handling (My .htaccess)
  php_flag    xdebug.collect_vars  on
  php_value    xdebug.collect_params 4
  php_flag    xdebug.dump_globals    on
  php_value    xdebug.dump.SERVER      REQUEST_URI
  php_value    xdebug.dump.GET       *
  php_value    xdebug.dump.POST       *
  php_value    xdebug.dump.COOKIE       *
  php_flag    xdebug.show_local_vars on


► Documentation:  http://www.xdebug.org/doc/
► Also check phpinfo(), specifically Xdebug section
Remote Debugging
► XDebug   has Remove Debugging support
  through GDB (old) and DBGP (new)
  protocols.
► You will need a client that can speak one of
  these protocols.
► You will need to adjust Xdebug settings on
  the server to enable remote debugging.
► You can also debug CLI scripts.
Remote Debugging (Clients)
►   Dev-PHP (IDE: Windows)
►   Eclipse plugin, which has been submitted as an enhancement for the PDT (IDE).
►   Emacs plugin (Editor Plugin).
►   ActiveState's Komodo (IDE: Windows, Linux, Mac; Commercial).
►   MacGDBP - Standalone Mac client.
►   NetBeans (IDE: Windows, Linux, Mac OS X and Solaris.
►   Notepad++ plugin (IDE: Windows).
►   WaterProof's PHPEdit (IDE, from version 2.10: Windows; Commercial).
►   Anchor System's Peggy (IDE: Windows, Japanese; Commercial).
►   MP Software's phpDesigner (IDE: Windows, Commercial).
►   PHPEclipse (Editor Plugin).
►   Protoeditor (Editor: Linux).
►   tsWebeditor (Editor: Windows).
►   Xored's TrueStudio IDE (IDE; Commercial).
►   VIM plugin (Tutorial) (Editor Plugin).
►   jcx software's VS.Php (MS Visual Studio Plugin; Commercial).
►   XDebugClient - Standalone Windows client.

* Source: http://www.xdebug.org/docs/remote
Remote Debugging (Server)
►   Need to enable remote debugging on the server:
       php_value   xdebug.remote_enable 1
       php_value   xdebug.remote_host 192.168.1.105
       php_value   xdebug.remote_port 9000
       php_value   xdebug.remote_mode req
►   remote_host - takes a hostname or IP address (There’s a
    patch from Facebook devs to remove this restriction)
►   remote_mode – controls when the remote debugging
    starts:
     req - at the beginning of the script
     jit - upon an error condition
Remote Debugging (Starting)
► xdebug_break(  )
► XDEBUG_SESSION_START variable passed
  via GET or POST sets XDEBUG_SESSION
  cookie.
► XDebug Helper Firefox Addon:
  https://addons.mozilla.org/en-
  US/firefox/addon/3960
Profiling
► Xdebug's   built-in profiler generates
  cachegrind files.
► You will need a tool that can read and
  visualize cachegrind files.
► You will need to adjust some XDebug
  settings in order to enable profiling on the
  server.
Profiling (Starting)
► Need   to enable profiling on the server:
  php_value   xdebug.profiler_enabled 1
  php_value   xdebug.profiler_append 1
  php_value   xdebug.profiler_enable_trigger 1
  php_value   xdebug.profiler_output_dir /tmp
  php_value   xdebug.profiler_output_name cachegrind.out.%p


► You  need to set xdebug.profiler_enable_trigger if
  you want to trigger the profiling yourself.
► You can trigger profiling via XDEBUG_PROFILE
  variable passed via GET or POST (or via XDebug
  Helper Firefox Addon) sets XDEBUG_PROFILE
  cookie.
WebGrind




http://code.google.com/p/webgrind/
WinCacheGrind




http://sourceforge.net/projects/wincachegrind/
MacCallGrind




http://www.maccallgrind.com/
KCacheGrind




http://kcachegrind.sourceforge.net/
Function Traces
► Xdebug    allows you to log all function calls,
  including parameters and return values to a
  file in different formats.
► Function trace files contain a timeline and
  record of each function call in PHP including
  file and line number.
► It’s a great way to see exactly what’s going
  on. (At times a bit too much detail)
Function Traces
Function Traces (VIM Syntax)
►   Xdebug package comes with a VIM syntax
    highlight file.
►   Copy the xt.vim file to ~/.vim/syntax
►   Edit, or create, ~/.vim/filetype.vim and add the
    following lines:
       augroup filetypedetect
       au BufNewFile,BufRead *.xt setf xt
       augroup END


* Xdebug Documentation: http://www.xdebug.org/docs/execution_trace
Function Traces
► Function   trace files come in two formats:
   Human readable (lots of options here)
    ►php_value xdebug.show_mem_delta 1
    ►php_value xdebug.collect_return 1
    ►php_value xdebug.collect_params 4
   Machine readable
    ►php_value   xdebug.trace_format   1
   HTML format.
XDebug Trace Options
php_value   xdebug.auto_trace          0
php_value   xdebug.collect_includes    1
php_value   xdebug.collect_return      1
php_value   xdebug.collect_params      4
php_value   xdebug.show_mem_delta      1
php_value   xdebug.trace_options       0
php_value   xdebug.trace_output_dir    /tmp
php_value   xdebug.trace_output_name   trace.%c
Function Traces (Tips)
► Be  careful when using auto_trace option for
  big projects.
► Files can get very big. I saw cases of >1 Gig
► Turn Off VIM syntax highlighter for very big
  files.
► You can also trigger start/stop of tracing via
  PHP.
Function Traces (Starting)
► xdebug_start_trace($filename,            $options);
   XDEBUG_TRACE_APPEND (1)
    ►makes   the trace file open in append mode rather
      than overwrite mode
   XDEBUG_TRACE_COMPUTERIZED (2)
    ►creates a trace file with the format as described
      under 1 "xdebug.trace_format".
   XDEBUG_TRACE_HTML (4)
    ►creates   a trace file as an HTML table
► xdebug_stop_trace();
Contact Me
Gennady    Feldman
E-mail:     gena01@gena01.com
Website:    http://www.gena01.com
Blog:       http://www.gena01.com/blog
Twitter:    http://twitter.com/gena01

More Related Content

What's hot

OpenCV installation in windows visual studio
OpenCV installation in windows visual studioOpenCV installation in windows visual studio
OpenCV installation in windows visual studio
Peter Jose
 
Docker deploy
Docker deployDocker deploy
Docker deploy
Eric Ahn
 
Xdebug as a Drupal debugging tool
Xdebug as a Drupal debugging toolXdebug as a Drupal debugging tool
Xdebug as a Drupal debugging tool
Vladimir Melnic
 
LCA2014 - Introduction to Go
LCA2014 - Introduction to GoLCA2014 - Introduction to Go
LCA2014 - Introduction to Go
dreamwidth
 
New Security of Go modules and vulnerability scanning in GoCenter
New Security of Go modules and vulnerability scanning in GoCenterNew Security of Go modules and vulnerability scanning in GoCenter
New Security of Go modules and vulnerability scanning in GoCenter
Deep Datta
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
Sam Keen
 
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCode
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCodeSecurity of Go Modules and Vulnerability Scanning in GoCenter and VSCode
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCode
Deep Datta
 
Docker e postgresql
Docker e postgresqlDocker e postgresql
Docker e postgresql
Fernando Ike
 
Security of Go Modules and Vulnerability Scanning in VSCode
Security of Go Modules and Vulnerability Scanning in VSCodeSecurity of Go Modules and Vulnerability Scanning in VSCode
Security of Go Modules and Vulnerability Scanning in VSCode
Deep Datta
 
Security of go modules and vulnerability scanning in go center (1)
Security of go modules and vulnerability scanning in go center (1)Security of go modules and vulnerability scanning in go center (1)
Security of go modules and vulnerability scanning in go center (1)
Deep Datta
 
Kettunen, miaubiz fuzzing at scale and in style
Kettunen, miaubiz   fuzzing at scale and in styleKettunen, miaubiz   fuzzing at scale and in style
Kettunen, miaubiz fuzzing at scale and in styleDefconRussia
 
Security of Go Modules and Vulnerability Scanning in GoCenter and VS Code
Security of Go Modules and Vulnerability Scanning in GoCenter and VS CodeSecurity of Go Modules and Vulnerability Scanning in GoCenter and VS Code
Security of Go Modules and Vulnerability Scanning in GoCenter and VS Code
Deep Datta
 
Advanced Debugging with WinDbg and SOS
Advanced Debugging with WinDbg and SOSAdvanced Debugging with WinDbg and SOS
Advanced Debugging with WinDbg and SOS
Sasha Goldshtein
 
わかった気になるgitit-0.8
わかった気になるgitit-0.8わかった気になるgitit-0.8
わかった気になるgitit-0.8
Kiwamu Okabe
 
Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer  Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer
Mediovski Technology
 
Installation of lammps-5Nov14 on Mac OS X Yosemite
Installation of lammps-5Nov14 on Mac OS X YosemiteInstallation of lammps-5Nov14 on Mac OS X Yosemite
Installation of lammps-5Nov14 on Mac OS X Yosemite
first name chibaf
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
OWASP Kyiv
 
Openwrt frontend backend
Openwrt frontend backendOpenwrt frontend backend
Openwrt frontend backend
晓东 杜
 

What's hot (19)

OpenCV installation in windows visual studio
OpenCV installation in windows visual studioOpenCV installation in windows visual studio
OpenCV installation in windows visual studio
 
Docker deploy
Docker deployDocker deploy
Docker deploy
 
Xdebug as a Drupal debugging tool
Xdebug as a Drupal debugging toolXdebug as a Drupal debugging tool
Xdebug as a Drupal debugging tool
 
LCA2014 - Introduction to Go
LCA2014 - Introduction to GoLCA2014 - Introduction to Go
LCA2014 - Introduction to Go
 
New Security of Go modules and vulnerability scanning in GoCenter
New Security of Go modules and vulnerability scanning in GoCenterNew Security of Go modules and vulnerability scanning in GoCenter
New Security of Go modules and vulnerability scanning in GoCenter
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCode
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCodeSecurity of Go Modules and Vulnerability Scanning in GoCenter and VSCode
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCode
 
Docker e postgresql
Docker e postgresqlDocker e postgresql
Docker e postgresql
 
Security of Go Modules and Vulnerability Scanning in VSCode
Security of Go Modules and Vulnerability Scanning in VSCodeSecurity of Go Modules and Vulnerability Scanning in VSCode
Security of Go Modules and Vulnerability Scanning in VSCode
 
Security of go modules and vulnerability scanning in go center (1)
Security of go modules and vulnerability scanning in go center (1)Security of go modules and vulnerability scanning in go center (1)
Security of go modules and vulnerability scanning in go center (1)
 
Virtual domains
Virtual domainsVirtual domains
Virtual domains
 
Kettunen, miaubiz fuzzing at scale and in style
Kettunen, miaubiz   fuzzing at scale and in styleKettunen, miaubiz   fuzzing at scale and in style
Kettunen, miaubiz fuzzing at scale and in style
 
Security of Go Modules and Vulnerability Scanning in GoCenter and VS Code
Security of Go Modules and Vulnerability Scanning in GoCenter and VS CodeSecurity of Go Modules and Vulnerability Scanning in GoCenter and VS Code
Security of Go Modules and Vulnerability Scanning in GoCenter and VS Code
 
Advanced Debugging with WinDbg and SOS
Advanced Debugging with WinDbg and SOSAdvanced Debugging with WinDbg and SOS
Advanced Debugging with WinDbg and SOS
 
わかった気になるgitit-0.8
わかった気になるgitit-0.8わかった気になるgitit-0.8
わかった気になるgitit-0.8
 
Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer  Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer
 
Installation of lammps-5Nov14 on Mac OS X Yosemite
Installation of lammps-5Nov14 on Mac OS X YosemiteInstallation of lammps-5Nov14 on Mac OS X Yosemite
Installation of lammps-5Nov14 on Mac OS X Yosemite
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
 
Openwrt frontend backend
Openwrt frontend backendOpenwrt frontend backend
Openwrt frontend backend
 

Similar to Xdebug from a to x

Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008phpbarcelona
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
Duke Dao
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Bastian Feder
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Bastian Feder
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
julien pauli
 
Xdebug
XdebugXdebug
Xdebug
Bryce Embry
 
Introduction to Xdebug
Introduction to XdebugIntroduction to Xdebug
Introduction to Xdebug
Abid Malik
 
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Francisco José Seva Mora
 
PHP: Debugger, Profiler and more
PHP: Debugger, Profiler and morePHP: Debugger, Profiler and more
PHP: Debugger, Profiler and more
Võ Duy Tuấn
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
Ddev workshop t3dd18
Ddev workshop t3dd18Ddev workshop t3dd18
Ddev workshop t3dd18
Jigal van Hemert
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201ylefebvre
 
Eclipse HandsOn Workshop
Eclipse HandsOn WorkshopEclipse HandsOn Workshop
Eclipse HandsOn Workshop
Bastian Feder
 
Professional deployment
Professional deploymentProfessional deployment
Professional deployment
Ivelina Dimova
 
Diagnosing WordPress: What to do when things go wrong
Diagnosing WordPress: What to do when things go wrongDiagnosing WordPress: What to do when things go wrong
Diagnosing WordPress: What to do when things go wrong
WordCamp Sydney
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick RethansBachkoutou Toutou
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
Stein Inge Morisbak
 
Php Debugger
Php DebuggerPhp Debugger
Php Debugger
guest8cd374
 

Similar to Xdebug from a to x (20)

Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
 
Xdebug
XdebugXdebug
Xdebug
 
Introduction to Xdebug
Introduction to XdebugIntroduction to Xdebug
Introduction to Xdebug
 
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)Xdebug and Drupal8 tests (PhpUnit and Simpletest)
Xdebug and Drupal8 tests (PhpUnit and Simpletest)
 
PHP: Debugger, Profiler and more
PHP: Debugger, Profiler and morePHP: Debugger, Profiler and more
PHP: Debugger, Profiler and more
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Ddev workshop t3dd18
Ddev workshop t3dd18Ddev workshop t3dd18
Ddev workshop t3dd18
 
PHP selber bauen
PHP selber bauenPHP selber bauen
PHP selber bauen
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201
 
Eclipse HandsOn Workshop
Eclipse HandsOn WorkshopEclipse HandsOn Workshop
Eclipse HandsOn Workshop
 
Professional deployment
Professional deploymentProfessional deployment
Professional deployment
 
Diagnosing WordPress: What to do when things go wrong
Diagnosing WordPress: What to do when things go wrongDiagnosing WordPress: What to do when things go wrong
Diagnosing WordPress: What to do when things go wrong
 
Php myadmin
Php myadminPhp myadmin
Php myadmin
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick Rethans
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
Php Debugger
Php DebuggerPhp Debugger
Php Debugger
 

Recently uploaded

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 

Recently uploaded (20)

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 

Xdebug from a to x

  • 1. Xdebug from A to X By Gennady Feldman Aug 25, 2009
  • 2. Agenda ► Installation ► Error Handling ► Debugging ► Profiling ► Function Traces
  • 3. Xdebug Features ► Variable display ► Stack Traces ► Profiling PHP Scripts ► Remote Debugging ► Function Traces ► Code Coverage Analysis* * Not covered in this presentation.
  • 4. Installing ► Xdebug is a PHP extension. (written in C) ► Xdebug is Open Source so you could download and build/install it yourself. ► Almost every Linux distro today provides an Xdebug binary package. ► Binaries are also available for Windows from http://xdebug.org website.
  • 5. Installing (Part 2) ► On Ubuntu 9.04:  apt-get install php5-xdebug ► On Mandriva:  urpmi php5-xdebug ► Using PEAR/PECL:  pecl install xdebug  pecl upgrade xdebug
  • 6. Installing (Part 3) ► Toenable xdebug add the fullpath to xdebug.so: zend_extension=/usr/lib/php5/20060613+lfs/xdebug.so  To php.ini or  To conf.d/xdebug.ini file ► Youcould also setup system wide defaults as well through the ini file.
  • 7. Installing (Part 4) ► Check that Xdebug is installed via:  php –v  php –m  php –ri xdebug ► Check phpinfo() report and look for xdebug section. ► You might need to restart your web server.
  • 12. Error Handling (My .htaccess) php_flag xdebug.collect_vars on php_value xdebug.collect_params 4 php_flag xdebug.dump_globals on php_value xdebug.dump.SERVER REQUEST_URI php_value xdebug.dump.GET * php_value xdebug.dump.POST * php_value xdebug.dump.COOKIE * php_flag xdebug.show_local_vars on ► Documentation: http://www.xdebug.org/doc/ ► Also check phpinfo(), specifically Xdebug section
  • 13. Remote Debugging ► XDebug has Remove Debugging support through GDB (old) and DBGP (new) protocols. ► You will need a client that can speak one of these protocols. ► You will need to adjust Xdebug settings on the server to enable remote debugging. ► You can also debug CLI scripts.
  • 14. Remote Debugging (Clients) ► Dev-PHP (IDE: Windows) ► Eclipse plugin, which has been submitted as an enhancement for the PDT (IDE). ► Emacs plugin (Editor Plugin). ► ActiveState's Komodo (IDE: Windows, Linux, Mac; Commercial). ► MacGDBP - Standalone Mac client. ► NetBeans (IDE: Windows, Linux, Mac OS X and Solaris. ► Notepad++ plugin (IDE: Windows). ► WaterProof's PHPEdit (IDE, from version 2.10: Windows; Commercial). ► Anchor System's Peggy (IDE: Windows, Japanese; Commercial). ► MP Software's phpDesigner (IDE: Windows, Commercial). ► PHPEclipse (Editor Plugin). ► Protoeditor (Editor: Linux). ► tsWebeditor (Editor: Windows). ► Xored's TrueStudio IDE (IDE; Commercial). ► VIM plugin (Tutorial) (Editor Plugin). ► jcx software's VS.Php (MS Visual Studio Plugin; Commercial). ► XDebugClient - Standalone Windows client. * Source: http://www.xdebug.org/docs/remote
  • 15. Remote Debugging (Server) ► Need to enable remote debugging on the server:  php_value xdebug.remote_enable 1  php_value xdebug.remote_host 192.168.1.105  php_value xdebug.remote_port 9000  php_value xdebug.remote_mode req ► remote_host - takes a hostname or IP address (There’s a patch from Facebook devs to remove this restriction) ► remote_mode – controls when the remote debugging starts:  req - at the beginning of the script  jit - upon an error condition
  • 16. Remote Debugging (Starting) ► xdebug_break( ) ► XDEBUG_SESSION_START variable passed via GET or POST sets XDEBUG_SESSION cookie. ► XDebug Helper Firefox Addon: https://addons.mozilla.org/en- US/firefox/addon/3960
  • 17. Profiling ► Xdebug's built-in profiler generates cachegrind files. ► You will need a tool that can read and visualize cachegrind files. ► You will need to adjust some XDebug settings in order to enable profiling on the server.
  • 18. Profiling (Starting) ► Need to enable profiling on the server: php_value xdebug.profiler_enabled 1 php_value xdebug.profiler_append 1 php_value xdebug.profiler_enable_trigger 1 php_value xdebug.profiler_output_dir /tmp php_value xdebug.profiler_output_name cachegrind.out.%p ► You need to set xdebug.profiler_enable_trigger if you want to trigger the profiling yourself. ► You can trigger profiling via XDEBUG_PROFILE variable passed via GET or POST (or via XDebug Helper Firefox Addon) sets XDEBUG_PROFILE cookie.
  • 23. Function Traces ► Xdebug allows you to log all function calls, including parameters and return values to a file in different formats. ► Function trace files contain a timeline and record of each function call in PHP including file and line number. ► It’s a great way to see exactly what’s going on. (At times a bit too much detail)
  • 25. Function Traces (VIM Syntax) ► Xdebug package comes with a VIM syntax highlight file. ► Copy the xt.vim file to ~/.vim/syntax ► Edit, or create, ~/.vim/filetype.vim and add the following lines: augroup filetypedetect au BufNewFile,BufRead *.xt setf xt augroup END * Xdebug Documentation: http://www.xdebug.org/docs/execution_trace
  • 26. Function Traces ► Function trace files come in two formats:  Human readable (lots of options here) ►php_value xdebug.show_mem_delta 1 ►php_value xdebug.collect_return 1 ►php_value xdebug.collect_params 4  Machine readable ►php_value xdebug.trace_format 1  HTML format.
  • 27. XDebug Trace Options php_value xdebug.auto_trace 0 php_value xdebug.collect_includes 1 php_value xdebug.collect_return 1 php_value xdebug.collect_params 4 php_value xdebug.show_mem_delta 1 php_value xdebug.trace_options 0 php_value xdebug.trace_output_dir /tmp php_value xdebug.trace_output_name trace.%c
  • 28. Function Traces (Tips) ► Be careful when using auto_trace option for big projects. ► Files can get very big. I saw cases of >1 Gig ► Turn Off VIM syntax highlighter for very big files. ► You can also trigger start/stop of tracing via PHP.
  • 29. Function Traces (Starting) ► xdebug_start_trace($filename, $options);  XDEBUG_TRACE_APPEND (1) ►makes the trace file open in append mode rather than overwrite mode  XDEBUG_TRACE_COMPUTERIZED (2) ►creates a trace file with the format as described under 1 "xdebug.trace_format".  XDEBUG_TRACE_HTML (4) ►creates a trace file as an HTML table ► xdebug_stop_trace();
  • 30. Contact Me Gennady Feldman E-mail: gena01@gena01.com Website: http://www.gena01.com Blog: http://www.gena01.com/blog Twitter: http://twitter.com/gena01