Some GDB help please

I have a command prompt program that I want to step through, step by step and be able to see whats in each register. Is there a simple way to do this without the source and without setting a breakpoint? I'd like to see each assembly line too.

I remember I knew how to do it back a few semesters ago, now I need help.
LVL 2
LinkyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brettmjohnsonCommented:
> I want to step through, step by step
(gdb) step
  or
(gdb) next


> and be able to see whats in each register.
(gdb) info registers


> I'd like to see each assembly line too.
(gdb) disassemble

LinkyAuthor Commented:
I get "No Frame selected." when I do "disassemble". Step and next it says, "The program is not being run."
DineshJolaniaCommented:
Linky ,
How can you disassmeble , when your program is not running itself. LOL

before running your program ,
(gdb) stop in main
(gdb) set args       // the args which you supply for exe
(gdb) run
step by step in Assembly
(gdb)stepi
INfo registers
(gdb) info registers.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yuriskCommented:
FEw points to clarify:
1) You can't step through program execution nor see the registers contents without setting breakpoint -> running the program, this would allow you to read the assembly lines as well  providing to the GDB options to do it;

2) to see the disassembled code of the program (in full, few lines, few mnemonics, whatever) you don't need to run the program, enough :
#objdump -d filename

SideNote - you didn't specified what you're trying to achieve, may be some other ideas would come up.
DineshJolaniaCommented:
objdump does not shows the source code in assembly. It shows only the source file names, functions names (mangled /demangled ones ).
(gdb) stop in main
will halt the program at the very first line of main.
(gdb) stepi
will go to next instruction in assembly code.
stepi stands for step instruction.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.