在 Ubuntu 9.10 Apache2 安装上运行 gdb

在 Ubuntu 9.10 Apache2 安装上运行 gdb

我正在尝试运行 gdb 来调试我的 Ubuntu 9.10 Apache2 安装,但遇到了一些问题:

  1. Ubuntu 为 Apache2 安装的软件包似乎不包含调试符号;是否有我应该用于开发/调试的不同版本的软件包?

  2. 当我尝试运行 gdb 时,出现错误,似乎是由于缺少某些环境变量导致的。我是否应该将其他选项传递给“run”以使其正常工作?

以下是调试器会话的输出:

root@aj-ubuntu:/usr/sbin# gdb apache2
GNU gdb (GDB) 7.0-ubuntu
Copyright (C) 2009 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-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/sbin/apache2...(no debugging symbols found)...done.
(gdb) run -X
Starting program: /usr/sbin/apache2 -X
[Thread debugging using libthread_db enabled]
apache2: bad user name ${APACHE_RUN_USER}

Program exited with code 01.
(gdb)

提前致谢,-aj

答案1

对于第一个 Ubuntu,运行符号服务器: https://lists.ubuntu.com/archives/ubuntu-devel-announce/2006-September/000195.html

对于第二个看起来像是 apache 配置问题的问题,apache 在由 init 脚本启动时是否正常运行?

答案2

您需要在直接调用二进制文件之前设置环境变量。如果您想在基于 Debian 的发行版中从 sudo 执行此操作,您可以使用:

source /etc/apache2/envvars
sudo -E gdb /usr/sbin/apache2

答案3

在 bash 中运行该命令source /etc/apache2/envvars为我加载了必要的变量。

答案4

apache2.conf 中有一些使用环境变量的设置。在 apache2 启动之前使用“. /etc/apache2/envvars”

相关内容