About Me

My photo
Computer Science & Engineering Student @NIT Durgapur,Senior

Saturday, February 19, 2011

GNU debugger(GDB)


Gdb is a debugger for C (and C++). It allows you to do things like run the program up to a certain point then stop and print out the values of certain variables at that point, or step through the program one line at a time and print out the values of each variable after executing each line. It uses a command line interface.

Quick tutorial for using the debugger .
A.Compiling a program(using debugging symbol):
1.C program:gcc -g -o pnm pnm.c
(just add -g symbol in the compilation command whatever command u use to compile normally)
2.C++ program:g++ -g -o pnm pnm.cpp
(replace gcc with g++)
3.Assembly language:two commands
->as -gstabs -o pnm.o pnm.s
->ld -o pnm pnm.o
(Just add -gstabs to the normal compilation command to load with debugging symbols)
Here "pnm" satands for your program file name
B.Running the program compiled:(For all above language)
->./pnm
C.Start the debugger
->gdb program_name
This only starts the debugger; it does not start running the program in the debugger

D.Look at the source code and set a breakpoint  a line number(say x).
->b  x
or   break x
or   b main                       //to set break point at the initiation of program
E.Now, start to run the program in the debugger.
->run
F.To move forward(means to execute next line)
->next
G.To know the value of variables while debugging
->print variable_name
H.To run the program normally upto the next breakpoint
->continue
I.To delete a breakpoint
->delete line_number
J.To print a some source code around a line number:
->list line_number
K.To run a shell command inside the debugger
->SHELL command
L.To exit from debugger
->q

Hope this tutorial help you learn basics of GNU Debugger.





Sunday, February 13, 2011

8085 Microprocessor Simulator(windows)

This is the best simulator i found in the internet and it works perfectly same as the Microprocessor kit in lab.
Morever the installation of  the software also contains the Instruction set along with the corresponding opcodes.Hope you wll enjoy using this simulator
Documentation of the software:http://www.vikaspatel.org/8085.htm
FETCHING A PROGRAM:
->First Press the "Reset" key and then  "exmMem" key and enter the starting adress.
(here the "memExm" key works like "SUB" key in the real machine.)
->Press "Next" key and enter the instructions subsequently.
EXECUTING A PROGRAM:
->Press "Reset" key.
->Press "Go" key.
->Enter the strating adress of the program.
->Press the "Exec" key.
If in the display "E" appers ,that means program executed succesfully.