|
Cross Debug on Linux and WineGDB, The GNU Debugger is the standard debugger for the GNU software system. You can debug binary compiled on MinGW Cross Compile environment in Linux, using the GDB built for the cross environment. However, you need not only cross GDB but also GDBserver for remote debug, since cross GDB on Linux can not execute Win32 binary. Compile with -g optionIn order to debug your application using GDB, you need to add -g option when you compile and link you application. If you are interested in detail debug option, please refer GCC manual (4.3.2). Bulding application with -g option $ i686-pc-mingw32-gcc -g sample.c -o smaple.exe Remote debug using WineUsually in remote debugging, copy of the application is to be run with GDBserver on the target platform, and also the application is to be loaded into GDB on the development workstation. In case of Fedora MinGW Cross Compiling environment, in stead of actual target platform, Microsoft Windows, Wine on Linux can be used without using copy of the application in debug, if Wine is available on your system.
figure : Remote Debug using GDBserver On the Wine as target platform, launch the application with GDBserver, while specifying the host and port for listening to an incoming TCP connection: >gdbserver localhost:60000 sample.exe note: port 60000 is used as example.
figure : launch sample.exe with GDBserver (Wine) On the Linux console, also launch the application with cross-target GDB: $ i686-pc-mingw32-gdb sample.exe At the GDB console, type: (gdb) target remote localhost:60000 (gdb) break main (gdb) continue
figure : launch sample.exe with cross GDB (Linux)
figure : start debugging at GDBserver (Wine) The process is stopped at main function, and then, you can debug the program with a remote GDB.
figure : set break point at main function (Linux) using DDDGNU DDD, Data Display Debugger is a graphical front-end for command-line debuggers for GDB and other debuggers. If you prefer using GUI rather than command-line operation in debugging, DDD would be a good tool for you. In order to start DDD with cross debugger for MinGW, add --debugger option to specify debugger name of MinGW shown in the following: start DDD with i686-pc-mingw32-gdb $ ddd --debugger i686-pc-mingw32-gdb & After starting DDD, open application file to debug on DDD by selecting menus "File" -> "Open Program...".
figure : DDD with i686-pc-mingw32-gdb On the Wine as target platform, launch the application with GDBserver as same way as above.
figure : launch sample.exe with GDBserver (Wine) In GDB command window on DDD, set remote target.
figure : set remote target on DDD Also, set break point at main function and do continue. Of course, you can manipulate same operation on the GUI.
figure : set break at main function on DDD Then you can debug the program with DDD.
figure : remote debug with DDD Related Links |