Linux commands that help me to create a correct environment for debugging

Georgy Buranov bio photo By Georgy Buranov

Linux commands that help me to create a correct environment for debugging

To begin with, I am rather inexperienced Linux developer. All 4 years of commercial development I have used Windows + Visual Studio only. Building software for many platforms is not common for me. So, I created a list of commands (as well as software) and other hints that help me to debug my software on Linux. When I say Linux, it 75% means Mac Os too.

And yes, I am using Ubuntu 8.10.

Gdb in Ctrl+X+A GUI mode.

Usually I am debugging code using Netbeans, but there are situations where I need to debug code on remote computer, but installing Netbeans or even set up gdbserver will take too much time. So, I just use Ctrl+X+A keys and gdb switches to simple GUI mode. Very useful


This programs shows library dependencies of some executable file. If the file is not executed for some reason, the first thing we need to check is ldd. In windows the LIB (included with VS) do something like the same.

gburanov@gburanov-ubuntu:~$ ldd /mnt/G:/Source/project/exe/lx/debug/english/schedmgr.exe =>  (0xb80b1000) => /lib/tls/i686/cmov/ (0xb806a000) => /lib/tls/i686/cmov/ (0xb8061000) => /usr/lib/ (0xb7f71000) => /lib/tls/i686/cmov/ (0xb7f6d000) => /lib/tls/i686/cmov/ (0xb7f47000) => /lib/ (0xb7f38000) => /lib/tls/i686/cmov/ (0xb7dda000)
 /lib/ (0xb8097000)


Shows who owns the file. In windows I always used Unlocker application for it (installed separately).

gburanov@gburanov-ubuntu:~$ fuser /mnt/G:/Source/project/exe/lx/debug/english/schedmgr.exe
/mnt/G:/Source/project/exe/lx/debug/english/schedmgr.exe: 17846e


Shows you the kernel bootup messages. Used together with grep. Example:

gburanov@gburanov-ubuntu:~$ dmesg | grep eth0
[    4.552705] eth0: registered as PCnet/PCI II 79C970A
[   79.763326] eth0: link up
[  300.200990] Inbound IN=eth0 OUT= MAC=00:0c:29:d1:4e:30:00:00:aa:9e:33:95:08:00 SRC= DST= LEN=83 TOS=0x00 PREC=0x00 TTL=30 ID=6445 PROTO=UDP SPT=161 DPT=42372 LEN=63
[  300.210026] Inbound IN=eth0 OUT= MAC=00:0c:29:d1:4e:30:00:14:38:da:c4:85:08:00 SRC= DST= LEN=83 TOS=0x00 PREC=0x00 TTL=64 ID=61780 PROTO=UDP SPT=161 DPT=42372 LEN=63
[  300.222510] Inbound IN=eth0 OUT= MAC=00:0c:29:d1:4e:30:00:00:aa:9c:e1:3b:08:00 SRC= DST= LEN=83 TOS=0x00 PREC=0x00 TTL=64 ID=4541 PROTO=UDP SPT=161 DPT=42372 LEN=63
[  311.040399] eth0: no IPv6 routers present

which, whereis, type

Which shows you the full path to the specific executable file, whereis do the same + shows you manuals and sources. Type shows you alias for the command

gburanov@gburanov-ubuntu:~$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
gburanov@gburanov-ubuntu:~$ which ls
gburanov@gburanov-ubuntu:~$ type ls
ls is aliased to `ls --color=auto'


Slocate is more generalised version of which and whereis. It performs a quick search over database with the list of all files. The database is updated using cron every day. Example:

gburanov@gburanov-ubuntu:~$ slocate trueimage
/home/gburanov/Acronis/ATI Echo 2/.trueimageconsole