仅在命令行中设置 Xdebug 断点 [英] Setting Xdebug breakpoints solely in command line

查看:38
本文介绍了仅在命令行中设置 Xdebug 断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 PHP 维护脚本而苦苦挣扎,我正在寻找一种仅在命令行中使用 xdebug 的方法(如 gdb old-school),但我不知道如何设置断点,请执行一步-进入,跳过并继续.Xdebug 已启动并运行,正如 phpinfo(); 所说.

I'm struggling with a PHP maintenance script and I was looking for a way to use xdebug solely in command line (like gdb old-school), but I couldn't figure out how to set a breakpoint, do a step-into, step-over and continue. Xdebug is up and running, as phpinfo(); says.

我找到了很多关于如何使用 Eclipse 和其他工具执行此操作的文档,但没有关于 CLI 的文档.有人可以帮我吗?我的环境是 Centos 6 和 Bash.

I found a lot of documentation regarding how to do this using Eclipse and other tools, but none to CLI. Could anyone help me? My environment is Centos 6 and Bash.

感谢任何帮助.

谢谢!

推荐答案

这其实是可以的.在 Xdebug 源下载中,您会找到一个名为debugclient"的目录.在此目录中,您将找到一个非常 简单的客户端,它接受原始 DBGP 命令,并以 XML 形式提供输出.要编译,请运行:

This is actually possible. In the Xdebug source downloads, you will find a directory called "debugclient". In this directory you will find a very simple client accepting raw DBGP commands, and giving output as XML. To compile, you run:

  • apt-get install libedit-dev(或等效)
  • ./buildconf
  • ./configure --with-libedit
  • 制作

然后您可以使用 ./debugclient 运行二进制文件.

You can then run the binary with ./debugclient.

然后在不同的 shell 上运行以下命令:

On a different shell, you then run the following:

  • 导出 XDEBUG_CONFIG="idekey=dr"
  • php -dxdebug.remote_enable=1 yourscript.php

debugclient 看到此连接,然后您可以发出直接 DBGP 命令.例如,对于断点,您可以设置:

The debugclient sees this connection, and you then can issue direct DBGP commands. For a breakpoint, you can for example set:

breakpoint_set -i 1 -t line -f file:///path/to/yourscript.php -n 42

-i 1 必须是递增的数字,-f 是文件,-n 是行号.设置断点后,您可以运行 run -i 2 前进到该行.对于所有其他命令,我建议您参阅位于 http://xdebug.org/docs- 的 DBGP 文档dbgp.php

the -i 1 is required to be an increasing number, -f is the file and -n the line number. After setting the breakpoint you can then run run -i 2 to advance to that line. For all other commands, I'd refer you to the DBGP documentation at http://xdebug.org/docs-dbgp.php

这篇关于仅在命令行中设置 Xdebug 断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆