1

While trying to debug a code I tried to put break statements in the code through GDB, but for some reasons GDB doesn't see the source file although it's there. I am using GDB for the first time, so I don't know if that 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 locate the source 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
9
  • Try giving full path from the root. gdb is not able to locate the file. Full path may help here. Commented Jul 21, 2015 at 15:20
  • Have you compiled with debug option? Commented Jul 21, 2015 at 15:22
  • Provided full path but didn't work; gives same error message. Yes, I compiled in debugging mode: METHOD=dbg make But this was done outside gdb. Commented Jul 21, 2015 at 15:40
  • Can you share the full path here. the path starts from the root? Commented Jul 21, 2015 at 16:15
  • To get debug mode, compile the code with -g option. Commented Jul 21, 2015 at 16:18

1 Answer 1

1
  1. Do not use file names with the ~ character. GDB does not expand them to your HOME location.
  2. Make sure your code get compiled with the -g flag.
  3. Try to use only the file name, if it's not ambiguous, so:

    break NewMaterial.C:166
    
  4. If it is ambiguous, try to use it with the path related to the "compiling root" (e.g. project root, just as it was passed to the compiler).

  5. As a last resort - use the full path (but literally: the full path, no ~ characters).
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.