How to use gdb to debug php
Today I'll show you how to debug php using gdb. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.
Introduction to debugging php with gdb gdb is a code debugging tool for c language
There are four main forms of gdb that can be used to debug php, python, mysql, etc.: after startup, use the attach pid tracker gdb [options] [executable-file [core-file or process-id]] gdb [options]-- args executable-file [inferior-arguments.] gdb [options] [--python |-P] script-file [script-arguments.] Common debug command attach pid
Example: if you debug mysql code to a trace
1. First find mysql to ID:10111.
two。 Then attach 10111 to track mysql
Layout
Show source code / assembly instructions
Layout names are: src: Displays source and command windows. Show the source code asm: Displays disassembly and command windows. Display assembly instructions split: Displays source, disassembly and command windows. Display source code and assembly instruction regs: Displays register window. If existing layout is source/command or assembly/command, the register window is displayed. If the source/assembly/command (split) is displayed, the register window is displayed with the window that has current logical focusbreak
B increase breakpoint
Info b displays breakpoint information
Delete num deletes the specified breakpoint
Continue [num]
C num executes to num breakpoints, num can be left empty = 1 by default
Next [num]
When n num executes to the following num line, num can be left empty with default = 1 and will not enter inside the function.
Step [num]
S num executes to the following num line, num can be left empty with default = 1, and does not enter inside the function.
Backtrace
Bt views the current call stack
Print [value]
P value prints variable information
Help
Help layout to see how commands are used
Debug php code 1. Add a new php file