【问题标题】:Debugging 32 bit binary in cygwin windows compiled with mingw-w64在使用 mingw-w64 编译的 cygwin windows 中调试 32 位二进制文​​件
【发布时间】:2018-03-19 02:51:57
【问题描述】:

我正在尝试使用 gdb 来调试 mingw-w64 编译的 32 位二进制文​​件。 但是,gdb 给出了许多警告并且没有显示任何堆栈跟踪。 怎样才能正常调试这个过程?

以下是一些相关细节:

  • 此 GDB 配置为“x86_64-pc-cygwin”。
  • GNU gdb (GDB) (Cygwin 7.10.1-1) 7.10.1
  • 我正在编译 wxWidgets 库并用它构建我的程序。但这应该与这个问题无关,除了 --host=i686-w64-mingw32 --build=i686-pc-cygwin 标志与 wxWidgets configure 一起使用。

ashish@DESKTOP-133N35M /cygdrive/c/Users/ashish/work/reachit

$ gdb program.exe
GNU gdb (GDB) (Cygwin 7.10.1-1) 7.10.1
Copyright (C) 2015 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-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from program.exe...done.
(gdb) b ReachItButton::OnChar(wxKeyEvent&)
Breakpoint 1 at 0x734672: file binReach.cpp, line 49.
(gdb) r
Starting program: /cygdrive/c/Users/ashish/work/reachit/program.exe
[New Thread 6148.0x184]
warning: `/cygdrive/c/Windows/SYSTEM32/ntdll.dll': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/cygdrive/c/Windows/System32/wow64.dll': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: `/cygdrive/c/Windows/System32/wow64win.dll': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
warning: dll path for "WOW64_IMAGE_SECTION" can not be evaluated
warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
Do you need "set solib-search-path" or "set sysroot"?
warning: dll path for "WOW64_IMAGE_SECTION" can not be evaluated
warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
Do you need "set solib-search-path" or "set sysroot"?
warning: dll path for "NOT_AN_IMAGE" can not be evaluated
warning: Could not load shared library symbols for NOT_AN_IMAGE.
Do you need "set solib-search-path" or "set sysroot"?
warning: dll path for "NOT_AN_IMAGE" can not be evaluated
warning: Could not load shared library symbols for NOT_AN_IMAGE.
Do you need "set solib-search-path" or "set sysroot"?
warning: `/cygdrive/c/Windows/System32/wow64cpu.dll': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
[New Thread 6148.0x2b4]
[New Thread 6148.0x314]
[New Thread 6148.0x103c]
12:33:26: mylog In ReachItPanel :
12:33:28: mylog In ReachItButton.. onChar
gdb: unknown target exception 0x4000001f at 0x734672

Program received signal ?, Unknown signal.
0x0009dfe8 in ?? ()
(gdb) bt
#0  0x0009dfe8 in ?? ()
#1  0x00000000 in ?? ()
(gdb) q
A debugging session is active.

        Inferior 1 [process 6148] will be killed.

Quit anyway? (y or n) y

ashish@DESKTOP-133N35M /cygdrive/c/Users/ashish/work/reachit
$

在 config.log 中,我给出了 gcc/configue:-C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=i686-w64-mingw32

/cygdrive/i/szsz/tmpp/cygwin64/mingw64-i686/mingw64-i686-gcc-5.4.0-4.x86_64/src/gcc-5.4.0/configure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/mingw64-i686/mi
ngw64-i686-gcc-5.4.0-4.x86_64/src/gcc-5.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/mingw64-i686-gcc --htmldir=/usr/
share/doc/mingw64-i686-gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=i686-w64-mingw32 --without-libiconv-prefix --without-libintl-prefix --with-sysr
oot=/usr/i686-w64-mingw32/sys-root --with-build-sysroot=/usr/i686-w64-mingw32/sys-root --disable-multilib --disable-win32-registry --enable-languages=c,ada,c++,fortran,lto,
objc,obj-c++ --enable-fully-dynamic-string --enable-graphite --enable-libgomp --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-version-specific-ru
ntime-libs --with-dwarf2 --with-gnu-ld --with-gnu-as --with-tune=generic --with-cloog-include=/usr/include/cloog-isl --with-system-zlib --enable-threads=posix --libexecdir=
/usr/lib

Gdb 是 64 位,二进制是 32 位。 我可以尝试使用 64 位二进制文​​件,但我不确定为什么 mingw-w64 g++ 编译器不生成 64 位二进制文​​件。

cygwin 是 64 位的。

我已经编译了二进制文件:

 i686-w64-mingw32-g++ -ggdb -O0  binReach.cpp `wx-config --cxxflags 
 --libs std` -Wall -o program -static-libgcc -static-libstdc++ -Wl,
 -Bstatic,-lstdc++,-lpthread -Wl,-Bdynamic

【问题讨论】:

  • 我想我遇到了这个问题:virtuallyfun.superglobalmegacorp.com/2015/10/04/… 但我在 cygwin64 中找不到任何 gdb32.exe
  • 要生成 32 位目标,您应该在 wxWidgets 构建和程序中使用 -m32 标志。
  • @Ripi2 二进制文件已经是 32 位的了。我需要它是 64 位的。
  • 那么标志是-m64
  • @Ripi2 我想我发现我需要x86_64-mingw32-g++ 来编译到 64 位.. 但我也会尝试你的建议。

标签: gdb cygwin 64-bit wxwidgets mingw-w64


【解决方案1】:

使用 32 位 gdb 进行调试:http://www.equation.com/servlet/equation.cmd?fa=gdb

【讨论】:

    【解决方案2】:

    您必须分别下载 32 位和 64 位的 gdb。 因为根据mingw-64的todo list,gcc multilib 版本已经完成,但是gdb multilib 版本还在进行中,所以你不能使用单个gdb 来调试32bit 和64bit,你可能以后可以使用它。

    【讨论】:

      猜你喜欢
      • 2021-02-14
      • 2020-04-28
      • 1970-01-01
      • 2013-11-10
      • 2015-05-26
      • 1970-01-01
      • 1970-01-01
      • 2013-08-02
      • 1970-01-01
      相关资源
      最近更新 更多