请问如何开启openresty的gdb调试模式?

277 views
Skip to first unread message

雨师

unread,
Jul 15, 2016, 5:04:14 AM7/15/16
to openresty
Hello。
在网络上一直没搜索到openresty的调试模式,感觉按照nginx的调试,仅修改auto/cc/conf中ngx_compile_opt选项后,好像有些地方会出现<value optimized out>的情况。
在openresty的configare中又没有找到相关开关...
请问有没有办法打开gdb的调试?

YuanSheng Wang

unread,
Jul 15, 2016, 8:24:15 AM7/15/16
to open...@googlegroups.com
看看这里:

在 openresty 的 configure 阶段,有 debug 参数的。

➜  openresty-1.9.15.1rc1 ./configure --help | grep debug
  --with-debug                       enable debug logging
 

--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html



--

YuanSheng Wang
---------------------------------------
OpenResty lover ^_^

Yichun Zhang (agentzh)

unread,
Jul 16, 2016, 1:20:45 AM7/16/16
to openresty
Hello!
如果你只是想禁掉 C 编译器优化的话,直接在 ./configure OpenResty 的时候指定 --with-cc-opt="-O0"
选项就好了(这对 nginx 的 ./configure 也同样适用)。

Regards,
-agentzh

Yichun Zhang (agentzh)

unread,
Jul 16, 2016, 1:23:37 AM7/16/16
to openresty
Hello!

2016-07-15 5:24 GMT-07:00 YuanSheng Wang:
> 在 openresty 的 configure 阶段,有 debug 参数的。
>
> ➜ openresty-1.9.15.1rc1 ./configure --help | grep debug
> --with-debug enable debug logging
>

值得一提的是,这里的 --with-debug 选项只是启用 nginx 的调试日志 [1],和 C
编译器的优化选项无关(OpenResty 默认是 -O2)。是 C 编译器的优化导致某些函数参数或局部变量被优化掉,从而在 gdb
调试时出现 <value optimized out> 这样的提示。

Regards,
-agentzh

[1] 当然,OpenResty 的 --with-debug 选项还会同时启用 LuaJIT 的断言检查和 API
check,但同样不会影响到 C 编译器的优化选项。

YuanSheng Wang

unread,
Jul 18, 2016, 8:29:13 AM7/18/16
to open...@googlegroups.com
看来我理解错问题了,知识有限,差点带歪,抱歉抱歉。
 
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html

Ming

unread,
Jul 18, 2016, 10:33:30 PM7/18/16
to open...@googlegroups.com
简单一点,你可以直接从仓库下载 OpenResty 的 debug 版本:openresty-debug,文档在:

Reply all
Reply to author
Forward
0 new messages