I'm trying to debug an apache module on RHEL and the optimization is getting in the way. I tried deleting the '-O2' from EXTRA_CFLAGS
in apache_2.2.4/build/config_vars.mk, b
ut it didn't help. APXS is sufficiently complex (and my perl sufficiently poor) that I'm at a loss as to how to figure out how this flag is getting set.
我正在尝试在RHEL上调试apache模块,并且优化正在阻碍。我尝试在apache_2.2.4 / build / config_vars.mk中删除EXTRA_CFLAGS中的'-O2',但它没有帮助。 APXS足够复杂(我的perl足够差)我不知道如何弄清楚这个标志是如何设置的。
Since odd things are happening, I'd like to turn optimization off for all of apache, not just the modules (yes, several) we add.
由于奇怪的事情正在发生,我想关闭所有apache的优化,而不仅仅是我们添加的模块(是的,几个)。
Anybody know how to turn off the optimizer? (so the debugger can work nicely).
有谁知道如何关闭优化器? (所以调试器可以很好地工作)。
TIA.
4 个解决方案
#1
Marko's answer is close, but -g only provides debugging symbols and does not disable the optimizer (which is sometimes a PITA for debugging).
Marko的答案很接近,但-g只提供调试符号,并且不会禁用优化器(有时候它是用于调试的PITA)。
When I'm debugging my mod_epp module, I use:
当我调试我的mod_epp模块时,我使用:
Build apache with: ./configure --enable-maintainer-mode --prefix=/usr/local/apache2 Build/install the module with: /usr/local/apache2/bin/apxs -Wc,-O0 -c -i mod_epp.c
使用以下命令构建apache:./ configure --enable-maintainer-mode --prefix = / usr / local / apache2使用以下命令构建/安装模块:/ usr / local / apache2 / bin / apxs -Wc,-O0 -c -i mod_epp.c
This leads to both -O2 and -O0 given to gcc, where -O0 wins.
这导致给予gcc的-O2和-O0,其中-O0获胜。
#2
Look in your config_var.mk file again
再次查看config_var.mk文件
the apxs program collates all these entries as CFLAGS
apxs程序将所有这些条目整理为CFLAGS
SHLTCFLAGS CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS
SHLTCFLAGS CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS
Your -O2 must be in one of them.
你的-O2必须在其中一个。
Also, my config_var.mk is in /usr/lib/httpd/build/config_vars.mk on a RHEL5 machine i know
另外,我的config_var.mk位于RHEL5机器上的/usr/lib/httpd/build/config_vars.mk中我知道
#3
mod_auth_foo.c: ${APXS} "-Wc,${AM_CFLAGS} ${DEFAULT_INCLUDES} ${CFLAGS}" -c mod_auth_foo.c ${AM_LDFLAGS} ${mod_auth_foo_LDFLAGS} ${mod_auth_foo_LIBADD}
is what I use in Makefile.am
for an apache module, and this does properly propagate -O0 -ggdb3
that I set via configure CFLAGS="-O0 -ggdb3"
. The resulting make output would be
我在Makefile.am中用于apache模块,这确实传播了我通过configure CFLAGS =“ - O0 -ggdb3”设置的-O0 -ggdb3。生成的make输出将是
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fPIC -Wall -fno-strict-aliasing -DLDAP_DEPRECATED -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/apache2 -I/usr/include/apr-1 -I/usr/include/apr-1 -D_FILE_OFFSET_BITS=64 -D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes -Winline -Wformat=2 -pipe -I.. -I.. -O0 -ggdb3 -c -o mod_auth_foo.lo mod_auth_foo.c && touch mod_auth_foo.slo
, which looks about right.
/ usr / lib64 / apr-1 / build / libtool --silent --mode = compile gcc -prefer-pic -fmessage-length = 0 -O2 -Wall -D_FORTIFY_SOURCE = 2 -fstack-protector -funwind-tables -fasynchronous- unwind-tables -g -fPIC -Wall -fno-strict-aliasing -DLDAP_DEPRECATED -DLINUX = 2 -D_REENTRANT -D_GNU_SOURCE -pthread -I / usr / include / apache2 -I / usr / include / apr-1 -I / usr / include / apr-1 -D_FILE_OFFSET_BITS = 64 -D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes -Winline -Wformat = 2 -pipe -I .. -I。 。-O0 -ggdb3 -c -o mod_auth_foo.lo mod_auth_foo.c && touch mod_auth_foo.slo,看起来很正确。
No modification of Apache files was required.
不需要修改Apache文件。
#4
It should be enough for debugging if you add '-Wc,-g' parameter.
如果添加'-Wc,-g'参数,它应该足以进行调试。
#1
Marko's answer is close, but -g only provides debugging symbols and does not disable the optimizer (which is sometimes a PITA for debugging).
Marko的答案很接近,但-g只提供调试符号,并且不会禁用优化器(有时候它是用于调试的PITA)。
When I'm debugging my mod_epp module, I use:
当我调试我的mod_epp模块时,我使用:
Build apache with: ./configure --enable-maintainer-mode --prefix=/usr/local/apache2 Build/install the module with: /usr/local/apache2/bin/apxs -Wc,-O0 -c -i mod_epp.c
使用以下命令构建apache:./ configure --enable-maintainer-mode --prefix = / usr / local / apache2使用以下命令构建/安装模块:/ usr / local / apache2 / bin / apxs -Wc,-O0 -c -i mod_epp.c
This leads to both -O2 and -O0 given to gcc, where -O0 wins.
这导致给予gcc的-O2和-O0,其中-O0获胜。
#2
Look in your config_var.mk file again
再次查看config_var.mk文件
the apxs program collates all these entries as CFLAGS
apxs程序将所有这些条目整理为CFLAGS
SHLTCFLAGS CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS
SHLTCFLAGS CFLAGS NOTEST_CPPFLAGS EXTRA_CPPFLAGS EXTRA_CFLAGS
Your -O2 must be in one of them.
你的-O2必须在其中一个。
Also, my config_var.mk is in /usr/lib/httpd/build/config_vars.mk on a RHEL5 machine i know
另外,我的config_var.mk位于RHEL5机器上的/usr/lib/httpd/build/config_vars.mk中我知道
#3
mod_auth_foo.c: ${APXS} "-Wc,${AM_CFLAGS} ${DEFAULT_INCLUDES} ${CFLAGS}" -c mod_auth_foo.c ${AM_LDFLAGS} ${mod_auth_foo_LDFLAGS} ${mod_auth_foo_LIBADD}
is what I use in Makefile.am
for an apache module, and this does properly propagate -O0 -ggdb3
that I set via configure CFLAGS="-O0 -ggdb3"
. The resulting make output would be
我在Makefile.am中用于apache模块,这确实传播了我通过configure CFLAGS =“ - O0 -ggdb3”设置的-O0 -ggdb3。生成的make输出将是
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fPIC -Wall -fno-strict-aliasing -DLDAP_DEPRECATED -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/apache2 -I/usr/include/apr-1 -I/usr/include/apr-1 -D_FILE_OFFSET_BITS=64 -D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes -Winline -Wformat=2 -pipe -I.. -I.. -O0 -ggdb3 -c -o mod_auth_foo.lo mod_auth_foo.c && touch mod_auth_foo.slo
, which looks about right.
/ usr / lib64 / apr-1 / build / libtool --silent --mode = compile gcc -prefer-pic -fmessage-length = 0 -O2 -Wall -D_FORTIFY_SOURCE = 2 -fstack-protector -funwind-tables -fasynchronous- unwind-tables -g -fPIC -Wall -fno-strict-aliasing -DLDAP_DEPRECATED -DLINUX = 2 -D_REENTRANT -D_GNU_SOURCE -pthread -I / usr / include / apache2 -I / usr / include / apr-1 -I / usr / include / apr-1 -D_FILE_OFFSET_BITS = 64 -D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes -Winline -Wformat = 2 -pipe -I .. -I。 。-O0 -ggdb3 -c -o mod_auth_foo.lo mod_auth_foo.c && touch mod_auth_foo.slo,看起来很正确。
No modification of Apache files was required.
不需要修改Apache文件。
#4
It should be enough for debugging if you add '-Wc,-g' parameter.
如果添加'-Wc,-g'参数,它应该足以进行调试。