# gdb



## balanga (Jun 2, 2018)

gdb (v6.1.1) comes included with FreeBSD and is installed in/usr/bin. gdb (v8.1) is available as a PKG and gets installed in /usr/local/bin and comes later in the path. What is the recommended way of running gdb (v8.1) from the command line or from within emacs?


----------



## _martin (Jun 2, 2018)

There's no recommend way of doing it. You do have few options though:
- execute it specifying an absolute path, i.e. /usr/local/bin/gdb. 
- modify the PATH variable in your shell's profile to have /usr/local/bin before /usr/bin. 
- add the alias into your shell's profile (e.g. alias gdb8 as /usr/local/bin/gdb ).

And .. well, this is not recommended but I did it anyway. I renamed the /usr/bin/gdb to gdb.orig and created a symlink /usr/bin/gdb to point to /usr/local/bin/gdb. Why? I use several users when debugging/pwning something and I didn't want to setup the profile for each user. I'm lazy that way. Also the 'user experience' in gdb6 vs gdb8 is just .. well, I have no need to use gdb6. I kept it around if such situation emerges though.


----------



## balanga (Jun 2, 2018)

_martin said:


> And .. well, this is not recommended but I did it anyway. I renamed the /usr/bin/gdb to gdb.orig and created a symlink /usr/bin/gdb to point to /usr/local/bin/gdb. Why? I use several users when debugging/pwning something and I didn't want to setup the profile for each user. I'm lazy that way. Also the 'user experience' in gdb6 vs gdb8 is just .. well, I have no need to use gdb6. I kept it around if such situation emerges though.



I guess that sounds the most preferable for me. Thanks for the suggestion.

I found that using 6.1.1 gave me a 'Dwarf Error: wrong version in compilation unit header' which I was unable to solve. 8.1 does not display this error.


----------



## Deleted member 54719 (Jun 2, 2018)

I  most often use it from the command line to backtrace core dumps, as in

$ echo bt | gdb program core

I prefer a GUI debugger front end for any real debugging, and that would always be ddd for me.

BTW: read somewhere that gdb is becoming depricated in the next freeBSD version, but haven't investigated that point.


----------

