我们在 VMWare 中运行 Linux Debian。使用 gdb 调试时,如果尝试跨过 memset/memcmp/strcmp 等...,gdb 会返回以下错误:
Cannot find bounds of current function
我们不会尝试跨入那些 c 函数,而只是跨过它们。有任何想法吗?
编辑:
我添加了导致问题的示例代码和编译标志。它可能与在 64 位机器上运行 32 位可执行文件有关。
版本是:
$ uname -a
Linux lavilinux 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with- bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)
$ gdb --version
GNU gdb (GDB) 7.4.1-debian
...
This GDB was configured as "x86_64-linux-gnu".
示例失败代码:main.cpp
#include <string>
#include "string.h"
#include "stdio.h"
char* rb_my_exe;
int
main(int argc, char* argv[])
{
if (strcmp(argv[0], "isgreat") == 0)
printf("Hello World!\n");
return 0;
}
我编译它的方式:
$ g++ -g -fexceptions -m32 -fstrict-aliasing -c -o main.o main.cpp
$ g++ -static -m32 -o main main.o
gdb 中的结果:
(gdb) start
Temporary breakpoint 1 at 0x80482dd: file main.cpp, line 9.
Starting program: /tmp/compile/main
Temporary breakpoint 1, main (argc=1, argv=0xffffd2d4) at main.cpp:9
9 if (strcmp(argv[0], "isgreat") == 0)
(gdb) n
0x080481b0 in ?? ()
(gdb) bt
#0 0x080481b0 in ?? ()
#1 0x0804849f in __libc_start_main ()
#2 0x080481e1 in _start ()
(gdb)
有任何想法吗?