News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Debugging with mingw64 impossible

Started by pozzugno, February 24, 2019, 08:39:49 AM

Previous topic - Next topic

pozzugno

I installed mingw64 under c:\mingw64.

In the compiler setting I copied "GNU GCC Compiler" configuration and renamed it to "mingw64". I changed "Compiler's installation directory" to c:\mingw64 and changed all programs (for example, C compiler is x86_64-w64-mingw32-gcc.exe).

In Settings->Debugger I copied Default configuration to a new one, renamed to mingw64. I changed the Executable path to C:\mingw64\bin\gdb.exe.

Again in Settings->Compiler I changed Debugger to mingw64.

I created a new Hello world project that uses mingw64 compiler. Compilation is fine and the program works well.

If I set a breakpoint inside a while loop and start debugging, the program halts to the breakpoint. If I press F8 (Start/Continue), the program halts again the breakpoint (it's in a while), so all is ok.

The problem happens if start debugging without any breakpoints and, during execution, I set a new breakpoint. The Debugger Log says:

Trying to interrupt process with pid: 7472; child pid: 7472 gdb pid: 7708
Continuing...


however the program will not halt anymore. It seems the debugger has lost the connection with the process. When I terminate the process, the debugger says:

[Inferior 1 (process 7464) exited with code 030000000472]
The program is not being run.
Debugger finished with status 0


This is the full log:

Active debugger config: GDB/CDB debugger:mingw64
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Temp\work_git\xxx\
Adding source dir: C:\Temp\work_git\xxx\
Adding file: C:\Temp\work_git\xxx\bin\Debug\xxx.exe
Changing directory to: C:/Temp/work_git/xxx/.
Set variable: PATH=.;C:\mingw64\bin;C:\mingw64;C:\MinGW\bin;C:\MinGW;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Users\Giuseppe\AppData\Local\Microsoft\WindowsApps

[debug]Command-line: C:\mingw64\bin\gdb.exe -nx -fullname -quiet  -args C:/Temp/work_git/xxx/bin/Debug/xxx.exe
[debug]Working dir : C:\Temp\work_git\xxx

Starting debugger: C:\mingw64\bin\gdb.exe -nx -fullname -quiet  -args C:/Temp/work_git/xxx/bin/Debug/xxx.exe
done

[debug]> set prompt >>>>>>cb_gdb:

Setting breakpoints

[debug]Reading symbols from C:/Temp/work_git/xxx/bin/Debug/xxx.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 8.1
[debug]Copyright (C) 2018 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "x86_64-w64-mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 8.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 200
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory C:/Temp/work_git/xxx/
[debug]Source directories searched: C:/Temp/work_git/xxx;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:\Temp\work_git\xxx\bin\Debug\xxx.exe

Child process PID: 4020

[debug][New Thread 4020.0x7c8]
[debug][New Thread 4020.0x1f4c]

Trying to interrupt process with pid: 4020; child pid: 4020 gdb pid: 7756
Continuing...

[debug][New Thread 4020.0x1ecc]
[debug][Thread 4020.0x1ecc exited with code 3221225547]
[debug][Thread 4020.0x1f4c exited with code 3221225786]
[debug][Inferior 1 (process 4020) exited with code 030000000472]
[debug]>>>>>>cb_gdb:

[Inferior 1 (process 4020) exited with code 030000000472]

[debug]> break "C:/Temp/work_git/xxx/main.c:10"
[debug]Breakpoint 2 at 0x40156b: file C:\Temp\work_git\xxx\main.c, line 10.
[debug]>>>>>>cb_gdb:
[debug]> cont
[debug]The program is not being run.
[debug]>>>>>>cb_gdb:

The program is not being run.

[debug]> quit

Debugger finished with status 0


Codeblocks version is 17.12.

pozzugno

Ah, another thing. If I changed the Project's Compiler to GNU GCC Compiler (that points to c:\mingw that is the original 32-bits compiler), everything is fine.

pozzugno

Maybe the problem could be that my C::B (downloaded from here) is 32-bits and I'm debugging a 64-bits program?

Mistahboom

Yeah, that's probably what the issue is ^-^
Downloading from the official website is probably the safest route haha
Yes! I'm learning as well and I'm rigidly following tutorials on Youtube and random articles, that I find online. I didn't experiment with any other compiler, and the teacher I follow recommended that default compiler.

pozzugno

Quote from: Mistahboom on February 24, 2019, 09:36:43 AM
Yeah, that's probably what the issue is ^-^
Downloading from the official website is probably the safest route haha
Yes! I'm learning as well and I'm rigidly following tutorials on Youtube and random articles, that I find online. I didn't experiment with any other compiler, and the teacher I follow recommended that default compiler.
I know, but I need mingw64 to compile mbedTLS libraries (mingw32 doesn't work without patches and someone suggests mingw64 should be the toolchain to use to compile mbedTLS).

Now I don't know if it's better to try patching mbedTLS to compile with mingw32 or compiling CodeBlocks for 64-bits architecture (I don't think CodeBlocks binaries for Windows are available).

pozzugno

I think I've solved with -m32 compiler (and linker) option for mingw64. Of course, I set mingw32 gdb.exe as the debugger executable of mingw64 compiler.

Maybe I will create two compilers settings in C::B: "mingw64 -m32" (that creates 32-bits executables, with -m32 options) and "mingw64" (that creates 64-bits executables).