Author Topic: gdb doesn't link to source  (Read 6855 times)

Offline sydnytt

  • Single posting newcomer
  • *
  • Posts: 8
gdb doesn't link to source
« on: August 19, 2020, 09:58:24 am »
Hello, i'm having problems with my debugger. even with a fresh install the debugger fails to highlight the breakpoints. it does stop at breakpoints, only without any information about the line number or source file.

Using Codeblocks 20.03, compĂ­ling with -g.

even using the default console app right after a fresh install, with a breakpoint on line 7:
Code
cout << "Hello world!" << endl;

gives me this output:
Code
[debug]Starting program: C:\codeblocks\prj\work\bin\Debug\work.exe 

Child process PID: 2848

[debug][New Thread 2848.0x2484]
[debug][New Thread 2848.0x2b98]
[debug]Thread 1 received signal ?, Unknown signal.
[debug]0x0009df38 in ?? ()
[debug]>>>>>>cb_gdb:

In ?? () ()

[debug]> bt 30
[debug]#0  0x0009df38 in ?? ()
[debug]#1  0x00000000 in ?? ()
[debug]>>>>>>cb_gdb:

I suspected it could have something to do with permissions, but i tried a couple of different users, in different project folders, and changed ownership of files.

been looking around online for some time now but found nothing.


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: gdb doesn't link to source
« Reply #1 on: August 19, 2020, 11:28:05 am »
Are you sure you are compiling and running the debug version of your project?
What is in the build log if you make a rebuild? Is the -g present?

Are your compiler and debugger compatible? the right version?
Does the compiler, debugger and your program have the same bit version (all 64bit, or all 32bit)?

Offline sydnytt

  • Single posting newcomer
  • *
  • Posts: 8
Re: gdb doesn't link to source
« Reply #2 on: August 19, 2020, 12:03:02 pm »
thanks for replying!

rebuild log:
Code
-------------- Build: Debug in example (compiler: GNU GCC Compiler)---------------

g++.exe -Wall -fexceptions -g  -c C:\codeblocks\prj\example\main.cpp -o obj\Debug\main.o
g++.exe  -o bin\Debug\example.exe obj\Debug\main.o   
Output file is bin\Debug\example.exe with size 1.50 MB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

gdb and g++ are (default after install) both 64bit.

It seems however that my program is 32bit
I cannot compile with the -m64 flag:
Code
C:\codeblocks\prj\example\main.cpp:1:0: sorry, unimplemented: 64-bit mode not compiled in

is this the problem? mingw64 not included in codeblocks installer?




Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: gdb doesn't link to source
« Reply #3 on: August 19, 2020, 12:42:49 pm »
This should only be a problem that you can not stop the debugee...

can you post a full log of the debugger?
You have to turn it on in Settings->Debugger->Full log

Offline sydnytt

  • Single posting newcomer
  • *
  • Posts: 8
Re: gdb doesn't link to source
« Reply #4 on: August 19, 2020, 12:50:59 pm »
alright, here is full debug log:

Code
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\codeblocks\prj\work\
Adding source dir: C:\codeblocks\prj\work\
Adding source dir: C:\codeblocks\prj\example\
Adding source dir: C:\codeblocks\prj\example\
Adding file: C:\codeblocks\prj\example\bin\Debug\example.exe
Changing directory to: C:/codeblocks/prj/example/.
Set variable: PATH=.;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\CodeBlocks\MinGW;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Common Files\Propellerhead Software\ReWire;C:\Program Files\Common Files\Propellerhead Software\ReWire;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\120\DTS\Binn;C:\Users\alex\AppData\Local\Microsoft\WindowsApps

[debug]Command-line: C:\codeblocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/codeblocks/prj/example/bin/Debug/example.exe
[debug]Working dir : C:\codeblocks\prj\example

Starting debugger: C:\codeblocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/codeblocks/prj/example/bin/Debug/example.exe
done

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

Setting breakpoints

[debug]Reading symbols from C:/codeblocks/prj/example/bin/Debug/example.exe...
[debug]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:/codeblocks/prj/work/
[debug]Source directories searched: C:/codeblocks/prj/work;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> directory C:/codeblocks/prj/example/
[debug]Source directories searched: C:/codeblocks/prj/example;C:/codeblocks/prj/work;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:\codeblocks\prj\example\bin\Debug\example.exe

Child process PID: 11844

[debug][New Thread 11844.0x2cf8]
[debug][New Thread 11844.0x3708]
[debug][Thread 11844.0x3708 exited with code 0]
[debug][Inferior 1 (process 11844) exited normally]
[debug]>>>>>>cb_gdb:

[Inferior 1 (process 11844) exited normally]

[debug]> quit

Debugger finished with status 0

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: gdb doesn't link to source
« Reply #5 on: August 19, 2020, 12:57:19 pm »
And the log with a breakpoint?

Offline sydnytt

  • Single posting newcomer
  • *
  • Posts: 8
Re: gdb doesn't link to source
« Reply #6 on: August 19, 2020, 01:11:28 pm »
oh sorry:
Code
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\codeblocks\prj\work\
Adding source dir: C:\codeblocks\prj\work\
Adding source dir: C:\codeblocks\prj\example\
Adding source dir: C:\codeblocks\prj\example\
Adding file: C:\codeblocks\prj\example\bin\Debug\example.exe
Changing directory to: C:/codeblocks/prj/example/.
Set variable: PATH=.;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\CodeBlocks\MinGW;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Common Files\Propellerhead Software\ReWire;C:\Program Files\Common Files\Propellerhead Software\ReWire;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\120\DTS\Binn;C:\Users\alex\AppData\Local\Microsoft\WindowsApps

[debug]Command-line: C:\codeblocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/codeblocks/prj/example/bin/Debug/example.exe
[debug]Working dir : C:\codeblocks\prj\example

Starting debugger: C:\codeblocks\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/codeblocks/prj/example/bin/Debug/example.exe
done

[debug]Reading symbols from C:/codeblocks/prj/example/bin/Debug/example.exe...
[debug]done.
[debug](gdb)
[debug]> set prompt >>>>>>cb_gdb:

Setting breakpoints

[debug]>>>>>>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:/codeblocks/prj/work/
[debug]Source directories searched: C:/codeblocks/prj/work;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> directory C:/codeblocks/prj/example/
[debug]Source directories searched: C:/codeblocks/prj/example;C:/codeblocks/prj/work;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/codeblocks/prj/example/main.cpp:7"
[debug]Breakpoint 2 at 0x401366: file C:\codeblocks\prj\example\main.cpp, line 7.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:\codeblocks\prj\example\bin\Debug\example.exe

Child process PID: 2768

[debug][New Thread 2768.0x3088]
[debug][New Thread 2768.0x1d20]
[debug]Thread 1 received signal ?, Unknown signal.
[debug]0x0009df38 in ?? ()
[debug]>>>>>>cb_gdb:

In ?? () ()

[debug]> bt 30
[debug]#0  0x0009df38 in ?? ()
[debug]#1  0x00000000 in ?? ()
[debug]>>>>>>cb_gdb:

Continuing...

[debug]> cont
[debug]Continuing.
[debug][Thread 2768.0x1d20 exited with code 1073741855]
[debug][Inferior 1 (process 2768) exited with code 010000000037]
[debug]>>>>>>cb_gdb:

[Inferior 1 (process 2768) exited with code 010000000037]

[debug]> quit

Debugger finished with status 0

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: gdb doesn't link to source
« Reply #7 on: August 19, 2020, 01:33:12 pm »
Hmmm.... all i can find have two root causes:
1) Bug in GDB (I know that version 8.1 is buggy as hell, i use 8.3 )
2) Bitness of executable and gdb do not match...

I do not understand how 2) can happen in an compiler installation with codeblocks... We never had this problem before and quite some people use GDB+ Codeblocks with the standard installation.  It should compile to 64 bit without the -m64 bit flag... The same is for 1)...

Have you installed your own compiler?

maybe someone else can help you here...
You can try to update gdb to 8.3 and newer and/or you can try to use the same bitness for everything...
You can also try to install your own compiler: http://mingw-w64.org/doku.php/download/mingw-builds

Code
[debug]Thread 1 received signal ?, Unknown signal.
i really think this has to do with bitness.. gdb should know the break signal for a breakpoint...

Offline sydnytt

  • Single posting newcomer
  • *
  • Posts: 8
Re: gdb doesn't link to source
« Reply #8 on: August 19, 2020, 01:49:06 pm »
Haven't installed any other compiler than the one included in the package. Will try updating GDB, then getting mingw64, will post results.
And it couldn't be a permissions thing? it would let me know if file access denied etc?


Thanks for your help!

« Last Edit: August 19, 2020, 01:54:55 pm by sydnytt »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: gdb doesn't link to source
« Reply #9 on: August 19, 2020, 02:36:57 pm »
Quote
And it couldn't be a permissions thing? it would let me know if file access denied etc?
Yes.. you would not come this far...

Offline sydnytt

  • Single posting newcomer
  • *
  • Posts: 8
Re: gdb doesn't link to source
« Reply #10 on: August 19, 2020, 02:45:53 pm »
After i downloaded and installed mingw-w64 and directing codeblocks to the new exe's, the problem is no more.

Some of the mingw64 files are in mingw/bin in the codeblocks dir, however it did not help to use them.

Thank you for your help! Haven't done any of this for years.



Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: gdb doesn't link to source
« Reply #11 on: August 19, 2020, 02:47:20 pm »
Quote
the problem is no more.
glad to hear :)

don't forget to update also the gdb path, if you haven't it done already



Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: gdb doesn't link to source
« Reply #12 on: August 19, 2020, 09:34:04 pm »
Hmmm.... all i can find have two root causes:
1) Bug in GDB (I know that version 8.1 is buggy as hell, i use 8.3 )
2) Bitness of executable and gdb do not match...

I do not understand how 2) can happen in an compiler installation with codeblocks... We never had this problem before and quite some people use GDB+ Codeblocks with the standard installation.  It should compile to 64 bit without the -m64 bit flag... The same is for 1)...

FYI: Based on the paths the OP installed an 32 bit version of Code::Blocks with MinGW.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sydnytt

  • Single posting newcomer
  • *
  • Posts: 8
Re: gdb doesn't link to source
« Reply #13 on: August 19, 2020, 11:38:55 pm »
Quote
FYI: Based on the paths the OP installed an 32 bit version of Code::Blocks with MinGW.

Tim S.

downloaded package named codeblocks-20.03mingw-setup.exe, as opposed to codeblocks-20.03mingw-32bit-setup.exe

below links in download page:
Quote
NOTE: The codeblocks-20.03mingw-setup.exe file includes additionally the GCC/G++/GFortran compiler and GDB debugger from MinGW-W64 project (version 8.1.0, 32/64 bit, SEH).

if you are referring to the PATH=.. part of the log, it does point to the older version of codeblocks 17.xx (install package for that version is also not specifically named as 32bit, however, codeblocks.exe is 32).
However, all the programs running in the logs i posted are from the 20.03 package (C:\codeblocks). 20.03 installed all the tools for 64bit, but did not allow me to compile 64bit.

Anyway, it's all working now. Thanks!


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: gdb doesn't link to source
« Reply #14 on: August 20, 2020, 11:12:16 am »
Code
Set variable: PATH=.;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\CodeBlocks\MinGW;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Common Files\Propellerhead Software\ReWire;C:\Program Files\Common Files\Propellerhead Software\ReWire;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\120\DTS\Binn;C:\Users\alex\AppData\Local\Microsoft\WindowsApps

FYI: Based on the above line you was using the 32 bit MinGW installed with the 32 bit Code::Blocks.
That was why you had issues doing an 64 bit build/debug.

In the future for this type of problems, make sure you have at most one mingw GCC compiler in the PATH!
Edit: And, make sure the toolchain settings is pointing to the correct MinGW GCC compiler.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org