fbpx

How do you do debug using primitive Linux or UNIX using GDB? C++ job interview hint

(Last Updated On: May 14, 2010)

How do you do debug using primitive Linux or UNIX using GDB? C++ job interview hint
GDB is old but I have heard some more advanced interviews do ask these questions so be prepared on how to do the basics within GDB at a shell command line at a Linux terminal session. It is meant for C++ debugging and make sure you set your GCC compile mode to debug to enable this.
As you would, you need to enter on the shell command line:
GDB interaction:
Gdb convdoll
This will load up your biary n execute program. .
break main
This will set breakpoint in your method like main.
run convdoll
Once set, you need execute program the program using ‘run’.
next
This will then move to the next call within your executable file.
print userInput
This will display any variable values GDB may have access to the point at which it is executing.
There are numerous settings in which you would want to run GDB. If you have a process which is being run by your program , it may strangely hang. All you need to do is the get the process id (PID) it is running on. This can be known by executing ‘ps –ef|grep xxx’ where xxx is your program that hung.
gdb convdoll 9198
9198 would obviously be the process id you want to query on.
Sometimes C++ programs that leak memory may terminate abnormally and generate core files. You can always run through the program’s session by debugging it with GDB. Just do on the command line against a dumped core file.
gdb /system/location/convdoll core
Hope this helps you get past those gnarly questions posed at c++ job interview.

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Subscribe For Latest Updates

Sign up to best of business news, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.

NOTE!

Check NEW site on stock forex and ETF analysis and automation

Scroll to Top