GDB cannot see the source file

When trying to debug the code, I tried to put break statements in the code via GDB, but for some reason GDB does not see the source file even though it is there. This is my first time using GDB, so I don't know if this is the right way. Below is the terminal message:

~$ cd ~/projects/bison/sandbox/2D-RZ_rodlet_10pellets
~/projects/bison/sandbox/2D-RZ_rodlet_10pellets$ gdb ../../bison-dbg
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 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-linux-gnu".
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 ../../bison-dbg...done.
(gdb) break ~/projects/bison/src/materials/NewMaterial.C:166
No source file named ~/projects/bison/src/materials/NewMaterial.C.
Make breakpoint pending on future shared library load? (y or [n])

      

I can find the original file as:

~/projects/bison/src/materials$ ls | grep New
NewMaterial.C
NewMaterial.C~
NewMaterial.x86_64-unknown-linux-gnu.dbg.lo
NewMaterial.x86_64-unknown-linux-gnu.dbg.lo.d
NewMaterial.x86_64-unknown-linux-gnu.opt.lo
NewMaterial.x86_64-unknown-linux-gnu.opt.lo.d

      

+1


source to share


1 answer


  1. Do not use filenames with a symbol ~

    . GDB does not extend them to your HOME location.
  2. Make sure your code is compiled with the flag -g

    .
  3. Try to use only the filename if it is not ambiguous, so:

    break NewMaterial.C:166
    
          

  4. If this is ambiguous, try using it with the path associated with the "compilation root" (for example, the root of the project, just as it was passed to the compiler).

  5. As a last resort, use the full path (but literally: full path, no characters ~

    ).


+1


source







All Articles