1

I noticed that when I use gdb I can use either

$ gdb ./main

or

$ gdb main

Is the current directory guaranteed to be in the search path of gdb?

OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87

1 Answers1

1

Yes. GDB will first try to access the file exactly as specified, so in this case as a relative path from the current directory. In both of these cases you'll find main. This will obviously also work if you give an absolute path, like: gdb /path/to/main.

If the file can't be found exactly as specified then GDB will search the environment $PATH just like a shell will, so gdb main will hunt for main along your $PATH, but gdb foo/main will not find main under foo along your $PATH.

Andrew
  • 3,770
  • 15
  • 22