Below is a sample program that was in the test and it walks you though how to use gdb for viewing the CPU resisters and such.
1 /*
2 * gdbExample1.c
3 * Subtracts one from user integer.
4 * Demonstrate use of gdb to examine registers, etc.
5 * Bob Plantz - 5 June 2009
6 */
7
8 #include <stdio.h>
9
10 int main(void)
11 {
12 register int wye;
13 int *ptr;
14 int ex;
15
16 ptr = &ex;
17 ex = 305441741;
18 wye = -1;
19 printf("Enter an integer: ");
20 scanf("%i", ptr);
21 wye += *ptr;
22 printf("The result is %i\n", wye);
23
24 return 0;
25 }
Here is how I compiled the program then used gdb to control the
execution of the program and observe the register contents.
b$ gcc -g -O0 -Wall -fno-asynchronous-unwind-tables \
> -fno-stack-protector -o gdbExample1 gdbExample1.c
I was using the n command and I want to display the rip record at the begining of each line. But I was not sure how to display ir for each line? I know "I R rip "will display for entire program but I want to display it for each line.
Also which statements are C statements in this program and how can i find out how many machine code bytes are in each C statement?
Thanks in advanced>

New Topic/Question
Reply




MultiQuote


|