Script started on Thu Sep 11 10:22:09 2003 linux2% nasm -f elf toupper.asm linux2% ld toupper.o linux2% a.out Enter string: aBcdEF Original: aBcdEF Convert: ABCDEF linux2% linux2% a.out Enter string: Read error linux2% more ~/.gdbinit set disassembly-flavor intel linux2% linux2% gdb a.out GNU gdb Red Hat Linux (5.2-2) Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux"... (no debugging symbols found)... (gdb) (gdb) run Starting program: /afs/umbc.edu/users/c/h/chang/home/asm/a.out Enter string: abcDEF Original: abcDEF Convert: ABCDEF Program exited normally. (gdb) break *start Breakpoint 1 at 0x8048081 (gdb) run Starting program: /afs/umbc.edu/users/c/h/chang/home/asm/a.out Breakpoint 1, 0x08048081 in start () (gdb) disas Dump of assembler code for function start: 0x8048081 : mov eax,0x4 0x8048086 : mov ebx,0x1 0x804808b : mov ecx,0x804915c 0x8048090 : mov edx,0xe 0x8048095 : int 0x80 0x8048097 : mov eax,0x3 0x804809c : mov ebx,0x0 0x80480a1 : mov ecx,0x804918c 0x80480a6 : mov edx,0x100 0x80480ab : int 0x80 0x80480ad : mov ds:0x804938c,eax 0x80480b2 : cmp eax,0x0 0x80480b5 : jg 0x80480d2 0x80480b7 : mov eax,0x4 0x80480bc : mov ebx,0x1 0x80480c1 : mov ecx,0x804917e 0x80480c6 : mov edx,0xc 0x80480cb : int 0x80 0x80480cd : jmp 0x804814f End of assembler dump. (gdb) stepi 0x08048086 in start () (gdb) info registers eax 0x4 4 ecx 0x0 0 edx 0x0 0 ebx 0x0 0 esp 0xbffffb50 0xbffffb50 ebp 0x0 0x0 esi 0x0 0 edi 0x0 0 eip 0x8048086 0x8048086 eflags 0x346 838 cs 0x23 35 ss 0x2b 43 ds 0x2b 43 es 0x2b 43 fs 0x0 0 gs 0x0 0 fctrl 0x37f 895 fstat 0x0 0 ftag 0xffff 65535 fiseg 0x0 0 fioff 0x0 0 foseg 0x0 0 fooff 0x0 0 fop 0x0 0 xmm0 {f = {0x0, 0x0, 0x0, 0x0}} {f = {0, 0, 0, 0}} xmm1 {f = {0x0, 0x0, 0x0, 0x0}} {f = {0, 0, 0, 0}} xmm2 {f = {0x0, 0x0, 0x0, 0x0}} {f = {0, 0, 0, 0}} xmm3 {f = {0x0, 0x0, 0x0, 0x0}} {f = {0, 0, 0, 0}} xmm4 {f = {0x0, 0x0, 0x0, 0x0}} {f = {0, 0, 0, 0}} xmm5 {f = {0x0, 0x0, 0x0, 0x0}} {f = {0, 0, 0, 0}} xmm6 {f = {0x0, 0x0, 0x0, 0x0}} {f = {0, 0, 0, 0}} xmm7 {f = {0x0, 0x0, 0x0, 0x0}} {f = {0, 0, 0, 0}} mxcsr 0x1f80 8064 orig_eax 0xffffffff -1 (gdb) print $eax $1 = 4 (gdb) stepi 0x0804808b in start () (gdb) print $ebs $2 = void (gdb) print $ebx $3 = 1 (gdb) display/i $eip 1: x/i $eip 0x804808b : mov ecx,0x804915c (gdb) print $ecx $4 = 0 (gdb) stepi 0x08048090 in start () 1: x/i $eip 0x8048090 : mov edx,0xe (gdb) print $ecx $5 = 134517084 (gdb) print/x $ecx $6 = 0x804915c (gdb) x &msg1 0x804915c : 0x65746e45 (gdb) x/c &msg1 0x804915c : 69 'E' (gdb) x/12c &msg1 0x804915c : 69 'E' 110 'n' 116 't' 101 'e' 114 'r' 32 ' ' 115 's' 116 't' 0x8049164 : 114 'r' 105 'i' 110 'n' 103 'g' (gdb) x/16c &msg1 0x804915c : 69 'E' 110 'n' 116 't' 101 'e' 114 'r' 32 ' ' 115 's' 116 't' 0x8049164 : 114 'r' 105 'i' 110 'n' 103 'g' 58 ':' 32 ' ' 79 'O' 114 'r' (gdb) disas start read_OK Dump of assembler code from 0x8048081 to 0x80480d2: 0x8048081 : mov eax,0x4 0x8048086 : mov ebx,0x1 0x804808b : mov ecx,0x804915c 0x8048090 : mov edx,0xe 0x8048095 : int 0x80 0x8048097 : mov eax,0x3 0x804809c : mov ebx,0x0 0x80480a1 : mov ecx,0x804918c 0x80480a6 : mov edx,0x100 0x80480ab : int 0x80 0x80480ad : mov ds:0x804938c,eax 0x80480b2 : cmp eax,0x0 0x80480b5 : jg 0x80480d2 0x80480b7 : mov eax,0x4 0x80480bc : mov ebx,0x1 0x80480c1 : mov ecx,0x804917e 0x80480c6 : mov edx,0xc 0x80480cb : int 0x80 0x80480cd : jmp 0x804814f End of assembler dump. (gdb) break *start+44 Breakpoint 2 at 0x80480ad (gdb) cont Continuing. Enter string: abC Breakpoint 2, 0x080480ad in start () 1: x/i $eip 0x80480ad : mov ds:0x804938c,eax (gdb) print $eax $7 = 4 (gdb) x/4c &buf 0x804918c : 97 'a' 98 'b' 67 'C' 10 '\n' (gdb) stepi 0x080480b2 in start () 1: x/i $eip 0x80480b2 : cmp eax,0x0 (gdb) x &rlen 0x804938c : 4 '\004' (gdb) x/x &rlen 0x804938c : 0x04 (gdb) x/t &rlen 0x804938c : 00000100 (gdb) x/d &rlen 0x804938c : 4 (gdb) break *L1_init Breakpoint 3 at 0x80480d2 (gdb) break *L1_top Breakpoint 4 at 0x80480e2 (gdb) display $ecx 2: $ecx = 134517132 (gdb) display/x $esi 3: /x $esi = 0x0 (gdb) display/x $edi 4: /x $edi = 0x0 (gdb) display/c $eax 5: /c $eax = 4 '\004' (gdb) cont Continuing. Breakpoint 3, 0x080480d2 in read_OK () 5: /c $eax = 4 '\004' 4: /x $edi = 0x0 3: /x $esi = 0x0 2: $ecx = 134517132 1: x/i $eip 0x80480d2 : mov ecx,ds:0x804938c (gdb) si 0x080480d8 in read_OK () 5: /c $eax = 4 '\004' 4: /x $edi = 0x0 3: /x $esi = 0x0 2: $ecx = 4 1: x/i $eip 0x80480d8 : mov esi,0x804918c (gdb) si 0x080480dd in read_OK () 5: /c $eax = 4 '\004' 4: /x $edi = 0x0 3: /x $esi = 0x804918c 2: $ecx = 4 1: x/i $eip 0x80480dd : mov edi,0x804928c (gdb) si Breakpoint 4, 0x080480e2 in L1_top () 5: /c $eax = 4 '\004' 4: /x $edi = 0x804928c 3: /x $esi = 0x804918c 2: $ecx = 4 1: x/i $eip 0x80480e2 : mov al,BYTE PTR [esi] (gdb) si 0x080480e4 in L1_top () 5: /c $eax = 97 'a' 4: /x $edi = 0x804928c 3: /x $esi = 0x804918c 2: $ecx = 4 1: x/i $eip 0x80480e4 : inc esi (gdb) si 0x080480e5 in L1_top () 5: /c $eax = 97 'a' 4: /x $edi = 0x804928c 3: /x $esi = 0x804918d 2: $ecx = 4 1: x/i $eip 0x80480e5 : cmp al,0x61 (gdb) si 0x080480e7 in L1_top () 5: /c $eax = 97 'a' 4: /x $edi = 0x804928c 3: /x $esi = 0x804918d 2: $ecx = 4 1: x/i $eip 0x80480e7 : jb 0x80480ef (gdb) si 0x080480e9 in L1_top () 5: /c $eax = 97 'a' 4: /x $edi = 0x804928c 3: /x $esi = 0x804918d 2: $ecx = 4 1: x/i $eip 0x80480e9 : cmp al,0x7a (gdb) si 0x080480eb in L1_top () 5: /c $eax = 97 'a' 4: /x $edi = 0x804928c 3: /x $esi = 0x804918d 2: $ecx = 4 1: x/i $eip 0x80480eb : ja 0x80480ef (gdb) si 0x080480ed in L1_top () 5: /c $eax = 97 'a' 4: /x $edi = 0x804928c 3: /x $esi = 0x804918d 2: $ecx = 4 1: x/i $eip 0x80480ed : and al,0xdf (gdb) si 0x080480ef in L1_cont () 5: /c $eax = 65 'A' 4: /x $edi = 0x804928c 3: /x $esi = 0x804918d 2: $ecx = 4 1: x/i $eip 0x80480ef : mov BYTE PTR [edi],al (gdb) cont Continuing. Breakpoint 4, 0x080480e2 in L1_top () 5: /c $eax = 65 'A' 4: /x $edi = 0x804928d 3: /x $esi = 0x804918d 2: $ecx = 3 1: x/i $eip 0x80480e2 : mov al,BYTE PTR [esi] (gdb) cont Continuing. Breakpoint 4, 0x080480e2 in L1_top () 5: /c $eax = 66 'B' 4: /x $edi = 0x804928e 3: /x $esi = 0x804918e 2: $ecx = 2 1: x/i $eip 0x80480e2 : mov al,BYTE PTR [esi] (gdb) undisplay 4 (gdb) undisplay 3 (gdb) si 0x080480e4 in L1_top () 5: /c $eax = 67 'C' 2: $ecx = 2 1: x/i $eip 0x80480e4 : inc esi (gdb) cont Continuing. Breakpoint 4, 0x080480e2 in L1_top () 5: /c $eax = 67 'C' 2: $ecx = 1 1: x/i $eip 0x80480e2 : mov al,BYTE PTR [esi] (gdb) cont Continuing. Original: abC Convert: ABC Program exited normally. (gdb) run Starting program: /afs/umbc.edu/users/c/h/chang/home/asm/a.out Breakpoint 1, 0x08048081 in start () 5: /c $eax = 0 '\0' 2: $ecx = 0 1: x/i $eip 0x8048081 : mov eax,0x4 (gdb) cont Continuing. Enter string: ABC^D Breakpoint 2, 0x080480ad in start () 5: /c $eax = 3 '\003' 2: $ecx = 134517132 1: x/i $eip 0x80480ad : mov ds:0x804938c,eax (gdb) x/5c &buf 0x804918c : 65 'A' 66 'B' 67 'C' 0 '\0' 0 '\0' (gdb) quit The program is running. Exit anyway? (y or n) y linux2% exit exit Script done on Thu Sep 11 10:45:57 2003