Gdb 在使用mingw-w64编译的cygwin windows中调试32位二进制文件

Gdb 在使用mingw-w64编译的cygwin windows中调试32位二进制文件,gdb,cygwin,64-bit,wxwidgets,mingw-w64,Gdb,Cygwin,64 Bit,Wxwidgets,Mingw W64,我正在尝试使用gdb调试mingw-w64编译的32位二进制文件。 然而,gdb给出了许多警告,并且不显示任何堆栈跟踪。 如何正常调试此过程 以下是一些相关细节: 此GDB配置为“x86_64-pc-cygwin” GNU gdb(gdb)(Cygwin 7.10.1-1)7.10.1 我正在编译wxWidgets库并用它构建我的程序。但这与这个问题无关,除了wxWidgets配置使用了--host=i686-w64-mingw32--build=i686 pc cygwin标志 ashi

我正在尝试使用gdb调试mingw-w64编译的32位二进制文件。 然而,gdb给出了许多警告,并且不显示任何堆栈跟踪。 如何正常调试此过程

以下是一些相关细节:

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

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
$
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

从以下位置使用32位gdb进行调试:

您必须分别下载32位和64位的gdb。
因为根据mingw-64,gcc多库版本已经完成,但gdb多库版本仍在进行中,所以不能使用单个gdb同时调试32位和64位,你可以在将来使用它。

我想我碰到了这个问题:但我在Cygwin64中找不到任何gdb32.exe来生成32位目标,你应该在wxWidgets构建和你的程序中使用
-m32
标志。@Ripi2二进制文件已经是32位了。我需要它是64位。然后标志是
-m64
@Ripi2我想我想我需要
x86\u 64-mingw32-g++
来编译到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