Layout names are:
src : Displays source and command windows. 显示源码
asm : Displays disassembly and command windows. 显示汇编指令
split : Displays source, disassembly and command windows. 显示源码和汇编指令
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 focus
break
b 增加断点
info b 显示断点信息
delete num 删除指定断点
continue [num]
c num 执行到num个断点,num可以不填默认=1
next [num]
n num 执行到下num行,num可以不填默认=1,不进入函数内部
step [num]
s num 执行到下num行,num可以不填默认=1,不进入函数内部
backtrace
bt 查看当前调用栈
print [value]
p value 打印变量信息
help
help layout 查看命令如何使用
调试php代码
1. 新增一个php文件
<?php
echo date('Y-m-d', strtotime("last day of +2month", strtotime('2020-05-31')));
[root@test ~]# gdb
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-115.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) attach 1127
Attaching to process 1127
Reading symbols from /usr/local/php/sbin/php-fpm...done.
Reading symbols from /usr/lib64/libcrypt.so.1...Reading symbols
from /usr/lib/debug/usr/lib64/libcrypt-2.17.so.debug...done.
done.