1 % gdb 2 GNU gdb 6.4-debian 3 Copyright 2005 Free Software Foundation, Inc. 4 GDB is free software, covered by the GNU General Public License, and you are 5 welcome to change it and/or distribute copies of it under certain conditions.Type "show copying" to see the conditions. 6 There is absolutely no warranty for GDB. Type "show warranty" for details. 7 This GDB was configured as "i486-linux-gnu". 8 (gdb) shell pidof cat 9 4179 10 (gdb) attach 4179 11 Attaching to process 4179 12 Reading symbols from /bin/cat...(no debugging symbols found)...done. 13 Using host libthread_db library "/lib/tls/libthread_db.so.1". 14 (no debugging symbols found) 15 Reading symbols from /lib/tls/libc.so.6...(no debugging symbols found)...done. 16 Loaded symbols for /lib/tls/libc.so.6 17 Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done. 18 Loaded symbols for /lib/ld-linux.so.2 19 20 0xb7f4777e in read () from /lib/tls/libc.so.6 21 (gdb) info target 22 Symbols from "/bin/cat". 23 Unix child process: 24 Using the running image of attached process 4179. 25 While running this, GDB does not access memory from... 26 Local exec file: 27 `/bin/cat', file type elf32-i386. 28 Entry point: 0x8048be0 29 0x08048114 - 0x08048127 is .interp 30 0x08048128 - 0x08048148 is .note.ABI-tag 31 0x08048148 - 0x08048298 is .hash 32 0x08048298 - 0x08048568 is .dynsym 33 0x08048568 - 0x0804872f is .dynstr 34 0x08048730 - 0x0804878a is .gnu.version 35 0x0804878c - 0x080487ec is .gnu.version_r 36 0x080487ec - 0x0804880c is .rel.dyn 37 0x0804880c - 0x08048944 is .rel.plt 38 0x08048944 - 0x0804895b is .init 39 0x0804895c - 0x08048bdc is .plt 40 0x08048be0 - 0x0804ae74 is .text 41 0x0804ae74 - 0x0804ae8e is .fini 42 0x0804aea0 - 0x0804baef is .rodata 43 0x0804baf0 - 0x0804baf4 is .eh_frame 44 0x0804caf4 - 0x0804cafc is .ctors 45 0x0804cafc - 0x0804cb04 is .dtors 46 0x0804cb04 - 0x0804cb08 is .jcr 47 0x0804cb08 - 0x0804cbd0 is .dynamic 48 0x0804cbd0 - 0x0804cbd8 is .got 49 0x0804cbd8 - 0x0804cc80 is .got.plt 50 0x0804cc80 - 0x0804ccc0 is .data 51 0x0804ccc0 - 0x0804ce08 is .bss 52 0xb7e86174 - 0xb7e86194 is .note.ABI-tag in /lib/tls/libc.so.6 53 0xb7e86194 - 0xb7e8934c is .hash in /lib/tls/libc.so.6 54 0xb7e8934c - 0xb7e91a1c is .dynsym in /lib/tls/libc.so.6 55 0xb7e91a1c - 0xb7e96b6d is .dynstr in /lib/tls/libc.so.6 56 0xb7e96b6e - 0xb7e97c48 is .gnu.version in /lib/tls/libc.so.6 57 0xb7e97c48 - 0xb7e97eb8 is .gnu.version_d in /lib/tls/libc.so.6 58 0xb7e97eb8 - 0xb7e97f08 is .gnu.version_r in /lib/tls/libc.so.6 59 0xb7e97f08 - 0xb7e9abf8 is .rel.dyn in /lib/tls/libc.so.6 60 0xb7e9abf8 - 0xb7e9ac38 is .rel.plt in /lib/tls/libc.so.6 61 0xb7e9ac38 - 0xb7e9acc8 is .plt in /lib/tls/libc.so.6 62 0xb7e9acd0 - 0xb7f95bbf is .text in /lib/tls/libc.so.6 63 0xb7f95bc0 - 0xb7f96f3b is __libc_freeres_fn in /lib/tls/libc.so.6 64 0xb7f96f40 - 0xb7f97127 is __libc_thread_freeres_fn in /lib/tls/libc.so.6 65 0xb7f97140 - 0xb7fb1430 is .rodata in /lib/tls/libc.so.6 66 0xb7fb1430 - 0xb7fb1443 is .interp in /lib/tls/libc.so.6 67 0xb7fb1444 - 0xb7fb23c8 is .eh_frame_hdr in /lib/tls/libc.so.6 68 0xb7fb23c8 - 0xb7fb25fa is .gcc_except_table in /lib/tls/libc.so.6 69 0xb7fb3474 - 0xb7fb75e0 is .eh_frame in /lib/tls/libc.so.6 70 0xb7fb75e0 - 0xb7fb75e8 is .tdata in /lib/tls/libc.so.6 71 0xb7fb75e8 - 0xb7fb7608 is .tbss in /lib/tls/libc.so.6 72 0xb7fb75e8 - 0xb7fb75ec is .fini_array in /lib/tls/libc.so.6 73 0xb7fb75ec - 0xb7fb75fc is .ctors in /lib/tls/libc.so.6 74 0xb7fb75fc - 0xb7fb7604 is .dtors in /lib/tls/libc.so.6 75 0xb7fb7604 - 0xb7fb765c is __libc_subfreeres in /lib/tls/libc.so.6 76 0xb7fb765c - 0xb7fb7660 is __libc_atexit in /lib/tls/libc.so.6 77 0xb7fb7660 - 0xb7fb7668 is __libc_thread_subfreeres in /lib/tls/libc.so.6 78 0xb7fb7680 - 0xb7fb8d3c is .data.rel.ro in /lib/tls/libc.so.6 79 0xb7fb8d3c - 0xb7fb8e24 is .dynamic in /lib/tls/libc.so.6 80 0xb7fb8e24 - 0xb7fb8fdc is .got in /lib/tls/libc.so.6 81 0xb7fb8ff4 - 0xb7fb9020 is .got.plt in /lib/tls/libc.so.6 82 0xb7fb9020 - 0xb7fba048 is .data in /lib/tls/libc.so.6 83 0xb7fba060 - 0xb7fbcbbc is .bss in /lib/tls/libc.so.6 84 0xb7fcb0f4 - 0xb7fcb1cc is .hash in /lib/ld-linux.so.2 85 0xb7fcb1cc - 0xb7fcb3fc is .dynsym in /lib/ld-linux.so.2 86 0xb7fcb3fc - 0xb7fcb582 is .dynstr in /lib/ld-linux.so.2 87 0xb7fcb582 - 0xb7fcb5c8 is .gnu.version in /lib/ld-linux.so.2 88 0xb7fcb5c8 - 0xb7fcb66c is .gnu.version_d in /lib/ld-linux.so.2 89 0xb7fcb66c - 0xb7fcb714 is .rel.dyn in /lib/ld-linux.so.2 90 0xb7fcb714 - 0xb7fcb73c is .rel.plt in /lib/ld-linux.so.2 91 0xb7fcb73c - 0xb7fcb79c is .plt in /lib/ld-linux.so.2 92 0xb7fcb7a0 - 0xb7fdc45b is .text in /lib/ld-linux.so.2 93 0xb7fdc460 - 0xb7fdf7db is .rodata in /lib/ld-linux.so.2 94 0xb7fdf7dc - 0xb7fdf840 is .eh_frame_hdr in /lib/ld-linux.so.2 95 0xb7fdf840 - 0xb7fdfb98 is .eh_frame in /lib/ld-linux.so.2 96 0xb7fe0cc0 - 0xb7fe0f24 is .data.rel.ro in /lib/ld-linux.so.2 97 0xb7fe0f24 - 0xb7fe0fd4 is .dynamic in /lib/ld-linux.so.2 98 0xb7fe0fd4 - 0xb7fe0fe0 is .got in /lib/ld-linux.so.2 99 0xb7fe0ff4 - 0xb7fe1014 is .got.plt in /lib/ld-linux.so.2 100 0xb7fe1020 - 0xb7fe145c is .data in /lib/ld-linux.so.2 101 0xb7fe145c - 0xb7fe1504 is .bss in /lib/ld-linux.so.2 102 (gdb) info registers 103 eax 0xfffffe00 -512 104 ecx 0x804e000 134537216 105 edx 0x400 1024 106 ebx 0x0 0 107 esp 0xbf9decb8 0xbf9decb8 108 ebp 0xbf9dece8 0xbf9dece8 109 esi 0x804e000 134537216 110 edi 0x804e000 134537216 111 eip 0xb7f4777e 0xb7f4777e 112 eflags 0x246 582 113 cs 0x73 115 114 ss 0x7b 123 115 ds 0x7b 123 116 es 0x7b 123 117 fs 0x0 0 118 gs 0x33 51 119 (gdb) set debug target 1 120 (gdb) set debug infrun 1 121 (gdb) set debug lin-lwp 1 122 (gdb) p chdir("/etc") 123 child:target_xfer_partial (2, (null), 0x0, 0xbfd13bf0, 0xbf9decb4, 4) = 4, bytes = 05 00 00 00 124 child:target_xfer_partial (2, (null), 0x0, 0xbfd13bf0, 0xbf9decb0, 4) = 4, bytes = e0 8b 04 08 125 infrun: proceed (addr=0xb7eee850, signal=0, step=0) 126 child:target_xfer_partial (2, (null), 0x837a070, 0x0, 0x8048be0, 1) = 1, bytes = 31 127 child:target_xfer_partial (2, (null), 0x0, 0xbfd13b50, 0x8048be0, 1) = 1, bytes = cc 128 infrun: resume (step=0, signal=0) 129 infrun: wait_for_inferior 130 CW: waitpid 4183 received 未知のシグナル(0) (terminated) 131 CW: waitpid 4179 received トレース/ブレイクポイント トラップ (stopped) 132 infrun: infwait_normal_state 133 infrun: TARGET_WAITKIND_STOPPED 134 infrun: stop_pc = 0x8048be0 135 infrun: BPSTATE_WHAT_STOP_SILENT 136 infrun: stop_stepping 137 child:target_xfer_partial (2, (null), 0x0, 0xbfd13b40, 0x8048be0, 1) = 1, bytes = 31 138 child:target_xfer_partial (2, (null), 0x0, 0xbfd13da0, 0x804ec80, 1) = 1, bytes = 2f 139 child:target_xfer_partial (2, (null), 0x0, 0xbfd13da0, 0x804ec81, 1) = 1, bytes = 65 140 child:target_xfer_partial (2, (null), 0x0, 0xbfd13da0, 0x804ec82, 1) = 1, bytes = 74 141 child:target_xfer_partial (2, (null), 0x0, 0xbfd13da0, 0x804ec83, 1) = 1, bytes = 63 142 child:target_xfer_partial (2, (null), 0x0, 0xbfd13da0, 0x804ec84, 1) = 1, bytes = 00 143 child:target_xfer_partial (2, (null), 0x0, 0xbfd13fa0, 0xbf9decb4, 4) = 4, bytes = 80 ec 04 08 144 child:target_xfer_partial (2, (null), 0x0, 0xbfd13fa0, 0xbf9decb0, 4) = 4, bytes = e0 8b 04 08 145 infrun: proceed (addr=0xb7f47f10, signal=0, step=0) 146 child:target_xfer_partial (2, (null), 0x834bed8, 0x0, 0x8048be0, 1) = 1, bytes = 31 147 child:target_xfer_partial (2, (null), 0x0, 0xbfd13f00, 0x8048be0, 1) = 1, bytes = cc 148 infrun: resume (step=0, signal=0) 149 infrun: wait_for_inferior 150 CW: waitpid 4179 received トレース/ブレイクポイント トラップ (stopped) 151 infrun: infwait_normal_state 152 infrun: TARGET_WAITKIND_STOPPED 153 infrun: stop_pc = 0x8048be0 154 infrun: BPSTATE_WHAT_STOP_SILENT 155 infrun: stop_stepping 156 child:target_xfer_partial (2, (null), 0x0, 0xbfd13ef0, 0x8048be0, 1) = 1, bytes = 31 157 $1 = 0 158 (gdb) info symbol 0xb7eee850 159 malloc in section .text 160 (gdb) info symbol 0xb7f47f10 161 chdir in section .text 162 (gdb) p free(0x804ec80) 163 child:target_xfer_partial (2, (null), 0x0, 0xbfd13fa0, 0xbf9decb4, 4) = 4, bytes = 80 ec 04 08 164 child:target_xfer_partial (2, (null), 0x0, 0xbfd13fa0, 0xbf9decb0, 4) = 4, bytes = e0 8b 04 08 165 infrun: proceed (addr=0xb7eeca80, signal=0, step=0) 166 child:target_xfer_partial (2, (null), 0x834c348, 0x0, 0x8048be0, 1) = 1, bytes = 31 167 child:target_xfer_partial (2, (null), 0x0, 0xbfd13f00, 0x8048be0, 1) = 1, bytes = cc 168 infrun: resume (step=0, signal=0) 169 infrun: wait_for_inferior 170 CW: waitpid 4179 received トレース/ブレイクポイント トラップ (stopped) 171 infrun: infwait_normal_state 172 infrun: TARGET_WAITKIND_STOPPED 173 infrun: stop_pc = 0x8048be0 174 infrun: BPSTATE_WHAT_STOP_SILENT 175 infrun: stop_stepping 176 child:target_xfer_partial (2, (null), 0x0, 0xbfd13ef0, 0x8048be0, 1) = 1, bytes = 31 177 $2 = -1208244112 178 (gdb) detach 179 Detaching from program: /bin/cat, process 4179 180 (gdb) 181