Reputation:
I am new to debugging an assembly code under gdb.Therefore, I have some question;
If it needs a value, how can I insert a value to see how it works for each case in switch statement?
ex: I couldnot give example on assembly so I give it in c.
scanf ( "%d",&y);
while ( y ) {
...
scanf( "%d", &x);
switch ( x ) {
case 1: ...
case 2: ...
case 3: ...
}
}
If I need, how can I know what value is stored in a register ?
I know some of you will say "go and read gdb tutorial or man page".But, I could not find any good tutorials, with example to explain how a command works. My brain only works when my eyes see example :)
Platform is Linux Tool is terminal/console
EDIT : Please give me a good website including good documentation, of course If you know
Give me documentation of "how to [catch] fish", "not how to eat fish"
Upvotes: 2
Views: 1306
Reputation: 43748
How can I run my assembly code without actually running it ?
Umm, err, what?!
If it needs a value, how can I insert a value to see how it works for each case in switch statement?
set whatever = some expression
Remember that registers have a $ sigil (e.g: $eax
).
If I need, how can I know what value is stored in a register ?
For all registers:
info reg
For a specific register
info reg $eax
or
p $eax
or
p/x $eax
etc...
How can I print out all display to my .txt file ? In other words, assume I have started my program and it runs with no break point and then I want print this display to .txt file. So, I can work on paper. As You know, paper is more powerful than computer :)
set logging file foobar.out
set logging on
Upvotes: 1
Reputation: 5722
Look at this page: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka12961.html - it's for ARM assembler, most should fit for all assemblers. You can set the program counter to the desired instruction, put values into registers, view registers, view memory etc. Don't print it out, we're out of trees almost already.
Upvotes: 1