Author Topic: codeblocks cross compiler MinGW and gdb  (Read 10545 times)

Offline perosoft

  • Single posting newcomer
  • *
  • Posts: 9
codeblocks cross compiler MinGW and gdb
« on: February 23, 2011, 02:32:38 pm »

i'm using codeblocks for linux, and trying to work on windows projects.
settings are made like in this guide:
http://ccpssolutions.com/nogdusforums/index.php?topic=380.0
all are fine, i built the project, program is working, but when i try to debug i got this error.
--------------------------------------------------------------------------
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: /media/xp/working.win/TaxeComune/
Adding source dir: /media/xp/
Changing directory to: /media/xp/working.win/TaxeComune
Adding file: Debug/TaxeComune
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.3
Error creating process D:\working.win\TaxeComune/Debug/TaxeComune, (error 2)
----------------------------------------------------------------------------
it's seems to be problems with program path.
how can i solve that, to get '\' instead of '/'
i can't find in codeblocks settings nothing about target path for debugger.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: codeblocks cross compiler MinGW and gdb
« Reply #1 on: February 23, 2011, 02:39:02 pm »
Enable this option: Settings -> Compiler & Debugger -> Debugger -> Display debugger's log
And see the real communication between C::B and gdb.exe.
If you can't comprehend the log, you can post it here using code tags.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline perosoft

  • Single posting newcomer
  • *
  • Posts: 9
Re: codeblocks cross compiler MinGW and gdb
« Reply #2 on: February 23, 2011, 04:59:18 pm »
thanks for answer !

that is debuger log in codeblocks

LD_LIBRARY_PATH=.:
Command-line: /usr/bin/i686-pc-mingw32msvc-gdb -nx -fullname  -quiet -args Debug/TaxeComune
Working dir : /media/xp/working.win/TaxeComune/
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set disassembly-flavor intel
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined.
>>>>>>cb_gdb:
> source /usr/share/codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> cd /media/xp/working.win/TaxeComune
>>>>>>cb_gdb:
> directory /media/xp/working.win/TaxeComune/
>>>>>>cb_gdb:
> directory /media/xp/
>>>>>>cb_gdb:
> run
Error creating process D:\working.win\TaxeComune/Debug/TaxeComune, (error 2)
>>>>>>cb_gdb:
> quit
wine: Unhandled page fault on read access to 0x00000000 at address 0x5211d0 (thread 0009), starting debugger...
Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x005211d0).
Register dump:
 CS:0073 SS:007b DS:007b ES:007b FS:0033 GS:003b
 EIP:005211d0 ESP:0084f4a0 EBP:0084f4b8 EFLAGS:00210202(  R- --  I   - - - )
 EAX:00000000 EBX:000027a8 ECX:00000004 EDX:00000001
 ESI:00000000 EDI:000027a8
Stack dump:
0x0084f4a0:  776f646e 79735c73 00000000 00000000
0x0084f4b0:  00000000 00000000 0084f818 00532aa0
0x0084f4c0:  0087ed70 0000000c 00000000 00000000
0x0084f4d0:  0084f5cc 00000000 00000050 625c7767
0x0084f4e0:  633b6e69 694d5c3a 1b2cd593 7379736d
0x0084f4f0:  302e315c 7bc71851 00000007 00000020
Backtrace:
=>0 0x005211d0 in gdb (+0x1211d0) (0x0084f4b8)
  1 0x00532aa0 in gdb (+0x132a9f) (0x0084f818)
  2 0x005151fd in gdb (+0x1151fc) (0x0084f878)
  3 0x00408290 in gdb (+0x828f) (0x0084f898)
  4 0x004034f5 in gdb (+0x34f4) (0x0084f8c8)
  5 0x00402250 in gdb (+0x224f) (0x0084f948)
  6 0x0040241a in gdb (+0x2419) (0x0084f978)
  7 0x004035c5 in gdb (+0x35c4) (0x0084f9a8)
  8 0x004027cd in gdb (+0x27cc) (0x0084f9e8)
  9 0x004249f2 in gdb (+0x249f1) (0x0084fa08)
  10 0x00424e51 in gdb (+0x24e50) (0x0084fa48)
  11 0x00484755 in gdb (+0x84754) (0x0084fa68)
  12 0x00484453 in gdb (+0x84452) (0x0084fa88)
  13 0x00484965 in gdb (+0x84964) (0x0084fab8)
  14 0x00402250 in gdb (+0x224f) (0x0084fb38)
  15 0x0040241a in gdb (+0x2419) (0x0084fb68)
  16 0x004844a4 in gdb (+0x844a3) (0x0084fb88)
  17 0x004012eb in gdb (+0x12ea) (0x0084fb98)
  18 0x00402250 in gdb (+0x224f) (0x0084fc18)
  19 0x0040241a in gdb (+0x2419) (0x0084fc48)
  20 0x004019a4 in gdb (+0x19a3) (0x0084fd38)
  21 0x00402250 in gdb (+0x224f) (0x0084fdb8)
  22 0x0040241a in gdb (+0x2419) (0x0084fde8)
  23 0x004020a3 in gdb (+0x20a2) (0x0084fe08)
  24 0x004012db in gdb (+0x12da) (0x0084fe48)
  25 0x004011e7 in gdb (+0x11e6) (0x0084fe80)
  26 0x00401238 in gdb (+0x1237) (0x0084fe90)
  27 0x7b858bdc call_process_entry+0xb() in kernel32 (0x0084fea8)
  28 0x7b8598c1 ExitProcess+0xce0() in kernel32 (0x0084fee8)
  29 0x7bc725b0 call_thread_func+0xb() in ntdll (0x0084fef8)
  30 0x7bc75231 call_thread_entry_point+0x70() in ntdll (0x0084ffc8)
  31 0x7bc4a44b call_dll_entry_point+0x62a() in ntdll (0x0084ffe8)
  32 0x7039151d wine_call_on_stack+0x1c() in libwine.so.1 (0x00000000)
0x005211d0: movl   0x0(%esi),%ecx
Modules:
Module   Address         Debug info   Name (89 modules)
PE     250000-  334000   Deferred        tk84
PE     340000-  35e000   Deferred        itcl32
PE     360000-  36f000   Deferred        itk32
PE     400000-  64a000   Export          gdb
PE   10000000-100a5000   Deferred        tcl84
ELF   68000000-6801f000   Deferred        ld-linux.so.2
ELF   6801f000-6803a000   Deferred        libpthread.so.0
ELF   6803a000-681c4000   Deferred        libc.so.6
ELF   681c4000-681c9000   Deferred        libdl.so.2
ELF   681c9000-681f3000   Deferred        libm.so.6
ELF   681f3000-68200000   Deferred        libnss_files.so.2
ELF   68200000-68262000   Deferred        advapi32<elf>
  \-PE   68210000-68262000   \               advapi32
ELF   68262000-68346000   Deferred        comdlg32<elf>
  \-PE   68270000-68346000   \               comdlg32
ELF   68346000-68552000   Deferred        shell32<elf>
  \-PE   68350000-68552000   \               shell32
ELF   68552000-6856f000   Deferred        libgcc_s.so.1
ELF   6856f000-685da000   Deferred        shlwapi<elf>
  \-PE   68580000-685da000   \               shlwapi
ELF   685da000-68720000   Deferred        user32<elf>
  \-PE   685f0000-68720000   \               user32
ELF   68720000-687b7000   Deferred        gdi32<elf>
  \-PE   68730000-687b7000   \               gdi32
ELF   687b7000-687f0000   Deferred        winspool<elf>
  \-PE   687c0000-687f0000   \               winspool
ELF   687f0000-68805000   Deferred        psapi<elf>
  \-PE   68800000-68805000   \               psapi
ELF   68805000-6881f000   Deferred        wsock32<elf>
  \-PE   68810000-6881f000   \               wsock32
ELF   6881f000-68839000   Deferred        libresolv.so.2
ELF   68839000-6885b000   Deferred        imm32<elf>
  \-PE   68840000-6885b000   \               imm32
ELF   6885b000-688ed000   Deferred        libfreetype.so.6
ELF   688ed000-68922000   Deferred        libfontconfig.so.1
ELF   68922000-6894a000   Deferred        libexpat.so.1
ELF   6894a000-68952000   Deferred        libsm.so.6
ELF   68952000-6896c000   Deferred        libice.so.6
ELF   6896c000-6897d000   Deferred        libxext.so.6
ELF   6897d000-68ab4000   Deferred        libx11.so.6
ELF   68ab4000-68ab9000   Deferred        libuuid.so.1
ELF   68ab9000-68ad7000   Deferred        libxcb.so.1
ELF   68ad7000-68ada000   Deferred        libxau.so.6
ELF   68ada000-68add000   Deferred        libxinerama.so.1
ELF   68add000-68ae2000   Deferred        libxxf86vm.so.1
ELF   68ae2000-68aeb000   Deferred        libxrender.so.1
ELF   68aeb000-68af3000   Deferred        libxrandr.so.2
ELF   68af3000-68af6000   Deferred        libxcomposite.so.1
ELF   68af6000-68afb000   Deferred        libxfixes.so.3
ELF   68afb000-68c1f000   Deferred        ole32<elf>
  \-PE   68b10000-68c1f000   \               ole32
ELF   68c1f000-68c9b000   Deferred        rpcrt4<elf>
  \-PE   68c30000-68c9b000   \               rpcrt4
ELF   68c9b000-68cee000   Deferred        libcups.so.2
ELF   68cee000-68d26000   Deferred        libgssapi_krb5.so.2
ELF   68d26000-68df7000   Deferred        libkrb5.so.3
ELF   68df7000-68e1e000   Deferred        libk5crypto.so.3
ELF   68e1e000-68e22000   Deferred        libcom_err.so.2
ELF   68e22000-68ecb000   Deferred        libgnutls.so.26
ELF   68ecb000-68f47000   Deferred        libgcrypt.so.11
ELF   68f47000-68f4b000   Deferred        libgpg-error.so.0
ELF   68f4b000-68f58000   Deferred        libavahi-common.so.3
ELF   68f58000-68f69000   Deferred        libavahi-client.so.3
ELF   68f69000-68f99000   Deferred        libcrypt.so.1
ELF   68f99000-68fae000   Deferred        libz.so.1
ELF   68fae000-68fc0000   Deferred        libtasn1.so.3
ELF   68fc0000-6900b000   Deferred        libdbus-1.so.3
ELF   6900b000-69014000   Deferred        librt.so.1
ELF   69014000-69061000   Deferred        libfreebl3.so
ELF   69061000-69080000   Deferred        libselinux.so.1
ELF   69175000-69178000   Deferred        libkeyutils.so.1
ELF   6a965000-6aa18000   Deferred        winex11<elf>
  \-PE   6a970000-6aa18000   \               winex11
ELF   70388000-704cb000   Export          libwine.so.1
PE   71590000-71617000   Deferred        comctl32
ELF   72eca000-72efc000   Deferred        ws2_32<elf>
  \-PE   72ed0000-72efc000   \               ws2_32
ELF   74491000-744aa000   Deferred        version<elf>
  \-PE   744a0000-744aa000   \               version
ELF   755be000-755c8000   Deferred        libxcursor.so.1
PE   78000000-78044000   Deferred        msvcrt
ELF   795ef000-795f9000   Deferred        libkrb5support.so.0
ELF   7b800000-7b992000   Export          kernel32<elf>
  \-PE   7b810000-7b992000   \               kernel32
ELF   7bac1000-7bae3000   Deferred        iphlpapi<elf>
  \-PE   7bad0000-7bae3000   \               iphlpapi
ELF   7bc00000-7bcc9000   Export          ntdll<elf>
  \-PE   7bc10000-7bcc9000   \               ntdll
ELF   7bf00000-7bf03000   Deferred        <wine-loader>
Threads:
process  tid      prio (all id:s are in hex)
00000008 (D) Z:\opt\insight\bin\gdb.exe
   00000009    0 <==
0000000e services.exe
   00000016    0
   00000015    0
   00000014    0
   00000010    0
   0000000f    0
00000011 winedevice.exe
   00000018    0
   00000017    0
   00000013    0
   00000012    0
00000019 explorer.exe
   0000001a    0
Backtrace:
=>0 0x005211d0 in gdb (+0x1211d0) (0x0084f4b8)
  1 0x00532aa0 in gdb (+0x132a9f) (0x0084f818)
  2 0x005151fd in gdb (+0x1151fc) (0x0084f878)
  3 0x00408290 in gdb (+0x828f) (0x0084f898)
  4 0x004034f5 in gdb (+0x34f4) (0x0084f8c8)
  5 0x00402250 in gdb (+0x224f) (0x0084f948)
  6 0x0040241a in gdb (+0x2419) (0x0084f978)
  7 0x004035c5 in gdb (+0x35c4) (0x0084f9a8)
  8 0x004027cd in gdb (+0x27cc) (0x0084f9e8)
  9 0x004249f2 in gdb (+0x249f1) (0x0084fa08)
  10 0x00424e51 in gdb (+0x24e50) (0x0084fa48)
  11 0x00484755 in gdb (+0x84754) (0x0084fa68)
  12 0x00484453 in gdb (+0x84452) (0x0084fa88)
  13 0x00484965 in gdb (+0x84964) (0x0084fab8)
  14 0x00402250 in gdb (+0x224f) (0x0084fb38)
  15 0x0040241a in gdb (+0x2419) (0x0084fb68)
  16 0x004844a4 in gdb (+0x844a3) (0x0084fb88)
  17 0x004012eb in gdb (+0x12ea) (0x0084fb98)
  18 0x00402250 in gdb (+0x224f) (0x0084fc18)
  19 0x0040241a in gdb (+0x2419) (0x0084fc48)
  20 0x004019a4 in gdb (+0x19a3) (0x0084fd38)
  21 0x00402250 in gdb (+0x224f) (0x0084fdb8)
  22 0x0040241a in gdb (+0x2419) (0x0084fde8)
  23 0x004020a3 in gdb (+0x20a2) (0x0084fe08)
  24 0x004012db in gdb (+0x12da) (0x0084fe48)
  25 0x004011e7 in gdb (+0x11e6) (0x0084fe80)
  26 0x00401238 in gdb (+0x1237) (0x0084fe90)
  27 0x7b858bdc call_process_entry+0xb() in kernel32 (0x0084fea8)
  28 0x7b8598c1 ExitProcess+0xce0() in kernel32 (0x0084fee8)
  29 0x7bc725b0 call_thread_func+0xb() in ntdll (0x0084fef8)
  30 0x7bc75231 call_thread_entry_point+0x70() in ntdll (0x0084ffc8)
  31 0x7bc4a44b call_dll_entry_point+0x62a() in ntdll (0x0084ffe8)
  32 0x7039151d wine_call_on_stack+0x1c() in libwine.so.1 (0x00000000)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: codeblocks cross compiler MinGW and gdb
« Reply #3 on: February 23, 2011, 05:13:05 pm »
Add .exe to the generated executable. (Project -> Properties -> Build targets ->...)

And please use code tags next time when pasting long logs, it is a bit more readable... ("[ code ]your log [/ code ]", without the spaces between the [])

BTW, your chance of success is minimal, C::B behaves differently on linux and on windows. For example the stop button won't work (99.9%), because on windows C::B uses a Win32 api to tell the process to stop, on linux it uses SIGINT. Probably it is better to use some kind of virtual machine or C::B running under wine (I don't know if it works, never tried it)
« Last Edit: February 23, 2011, 05:16:42 pm by oBFusCATed »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline perosoft

  • Single posting newcomer
  • *
  • Posts: 9
Re: codeblocks cross compiler MinGW and gdb
« Reply #4 on: February 23, 2011, 06:03:00 pm »
added .exe to target, same result.
using gbd from MinGW windows distribution is working for sample console programs but it hang on windows aplications.
and "Abort" button is working in both cases.

Offline perosoft

  • Single posting newcomer
  • *
  • Posts: 9
Re: codeblocks cross compiler MinGW and gdb
« Reply #5 on: February 23, 2011, 06:17:25 pm »
the ideea was to use codeblocks in windows for developing linux and windows aplications based on GTK++.
but without a reliable debugger for MinGW cross platform compiler i can't do that.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: codeblocks cross compiler MinGW and gdb
« Reply #6 on: February 23, 2011, 06:40:59 pm »
the ideea was to use codeblocks in windows for developing linux and windows aplications based on GTK++.
but without a reliable debugger for MinGW cross platform compiler i can't do that.
You mean linux in the bolded text aren't you?

You can debug most of the issues using the linux's debugger under linux and if there is a problem in windows (wine) use gdb from the command line inside wine.
But I'm pretty sure you'll need a real window install (VM or native) to do real testing or debugging.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline perosoft

  • Single posting newcomer
  • *
  • Posts: 9
Re: codeblocks cross compiler MinGW and gdb
« Reply #7 on: February 23, 2011, 06:47:36 pm »
yes, sorry for my mistake.
codeblocks for linux in linux.
for linux applications is a great tool.
i'm going to wait a good dbg in MinGW cross platform distribution.
until then i'm using openwatcon in wine for windows aplication.
is work fine, but is not working well with GTK++.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: codeblocks cross compiler MinGW and gdb
« Reply #8 on: February 23, 2011, 10:53:36 pm »
yes, sorry for my mistake.
codeblocks for linux in linux.
for linux applications is a great tool.
i'm going to wait a good dbg in MinGW cross platform distribution.
until then i'm using openwatcon in wine for windows aplication.
is work fine, but is not working well with GTK++.

You can try this solution: http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux#Debugging .
It does not work perfectly, but it is worth a try.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: codeblocks cross compiler MinGW and gdb
« Reply #9 on: February 23, 2011, 11:26:59 pm »
Jens: Does stopping the debugger works, I'm sure it doesn't, but wine could do some trickery and make it work.
Also I don't know how we could make C::B to use the win32 api function (DebugBreakProcess) needed to stop the debugger :(

Probably a standalone breaker + simple script ("wine cb_break_debug").
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: codeblocks cross compiler MinGW and gdb
« Reply #10 on: February 23, 2011, 11:46:57 pm »
Jens: Does stopping the debugger works, I'm sure it doesn't, but wine could do some trickery and make it work.
Also I don't know how we could make C::B to use the win32 api function (DebugBreakProcess) needed to stop the debugger :(

Probably a standalone breaker + simple script ("wine cb_break_debug").
6.8.50 stops, 7.x does not even start.

Offline perosoft

  • Single posting newcomer
  • *
  • Posts: 9
Re: codeblocks cross compiler MinGW and gdb
« Reply #11 on: February 24, 2011, 08:38:40 am »
using
http://wiki.codeblocks.org/index.php?title=Cross_Compiling_wxWidgets_Applications_on_Linux#Debugging
is working fine with console programs, trying to debug a windows program gdb hang, at
Code
      hStatic = CreateWindow( "static",
                              "",
                              WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER,
                              0, 0, 0, 0,
                              hwnd,
                              NULL,
                              //hInstance,
                              hInst,
                              NULL );
debugger windows:
Code
#0 (	0x6831b60a in ??() (??:??)
#1 ( 0x6831c09c in ??() (??:??)
#2 ( 0x6831c289 in ??() (??:??)
#3 ( 0x6831c92d in ??() (??:??)
#4 ( 0x6831f28a in ??() (??:??)
#5 ( 0x6831fc67 in ??() (??:??)
#6 ( 0x68bec7c0 in ??() (??:??)
#7 ( 0x68d88d4d in ??() (??:??)
#8 ( 0x68d8b77f in ??() (??:??)
#9 ( 0x68d8bb2c in ??() (??:??)
#10 ( 0x68beb512 in ??() (??:??)
#11 ( 0x68c1b91d in ??() (??:??)
#12 ( 0x68c1bcba in ??() (??:??)
#13 ( 0x68c1128a in ??() (??:??)
#14 ( 0x68c0a91d in ??() (??:??)
#15 ( 0x68c0c524 in ??() (??:??)
#16 ( 0x6838b3af in ??() (??:??)
#17 ( 0x68396e81 in ??() (??:??)
#18 ( 0x68396f2b in ??() (??:??)
#19 ( 0x6838f76f in ??() (??:??)
#20 ( 0x683896a4 in ??() (??:??)
#21 0x4a76dd WindowProcedure(hwnd=0x10054, message=1, wParam=0, lParam=10812028) (/media/xp/working.win/TaxeComune/main.cpp:490)
#22 ( 0x68397a5a in ??() (??:??)
#23 ( 0x6839830d in ??() (??:??)
#24 ( 0x6839ac40 in ??() (??:??)
#25 ( 0x6835e830 in ??() (??:??)
#26 ( 0x68363682 in ??() (??:??)
#27 ( 0x68363a9e in ??() (??:??)
#28 ( 0x6838fedd in ??() (??:??)
#29 ( 0x683896a4 in ??() (??:??)

Offline perosoft

  • Single posting newcomer
  • *
  • Posts: 9
Re: codeblocks cross compiler MinGW and gdb
« Reply #12 on: February 24, 2011, 11:12:26 am »
installed codeblocks 10.05 in wine, sorry but same problem with the mingw debugger, is not working.
i was really interested about mingw compiler, but is not working under wine, and mingw cross platform is not working under linux.
for both creating, compiling projects in c/c++ is working, but debugging no.

switching back to the old openwatcom compiler.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: codeblocks cross compiler MinGW and gdb
« Reply #13 on: February 24, 2011, 11:17:21 am »
It works here, if I use your codesnippet to create a child window on a toplevel window.