% lldb ./gets2 (lldb) target create "./gets2" Current executable set to '/Users/user/cs59/gets2' (arm64). (lldb) dis -n main gets2`main: gets2[0x100003ed4] <+0>: sub sp, sp, #0x30 ; =0x30 gets2[0x100003ed8] <+4>: stp x29, x30, [sp, #0x20] gets2[0x100003edc] <+8>: add x29, sp, #0x20 ; =0x20 gets2[0x100003ee0] <+12>: adrp x8, 1 gets2[0x100003ee4] <+16>: ldr x8, [x8] gets2[0x100003ee8] <+20>: ldr x8, [x8] gets2[0x100003eec] <+24>: stur x8, [x29, #-0x8] gets2[0x100003ef0] <+28>: str wzr, [sp, #0x4] gets2[0x100003ef4] <+32>: add x0, sp, #0x8 ; =0x8 gets2[0x100003ef8] <+36>: mov w8, #0xa gets2[0x100003efc] <+40>: str w8, [sp, #0x14] gets2[0x100003f00] <+44>: bl 0x100003f64 ; symbol stub for: gets gets2[0x100003f04] <+48>: ldr w8, [sp, #0x14] gets2[0x100003f08] <+52>: str w8, [sp] gets2[0x100003f0c] <+56>: ldr w8, [sp] gets2[0x100003f10] <+60>: tbnz w8, #0x1f, 0x100003f2c ; <+88> gets2[0x100003f14] <+64>: ldr w8, [sp] gets2[0x100003f18] <+68>: subs w8, w8, #0x1 ; =0x1 gets2[0x100003f1c] <+72>: str w8, [sp] gets2[0x100003f20] <+76>: add x0, sp, #0x8 ; =0x8 gets2[0x100003f24] <+80>: bl 0x100003f70 ; symbol stub for: puts gets2[0x100003f28] <+84>: b 0x100003f0c ; <+56> gets2[0x100003f2c] <+88>: adrp x8, 1 gets2[0x100003f30] <+92>: ldr x8, [x8] gets2[0x100003f34] <+96>: ldr x8, [x8] gets2[0x100003f38] <+100>: ldur x9, [x29, #-0x8] gets2[0x100003f3c] <+104>: subs x8, x8, x9 gets2[0x100003f40] <+108>: b.ne 0x100003f54 ; <+128> gets2[0x100003f44] <+112>: mov w0, #0x2a gets2[0x100003f48] <+116>: ldp x29, x30, [sp, #0x20] gets2[0x100003f4c] <+120>: add sp, sp, #0x30 ; =0x30 gets2[0x100003f50] <+124>: ret gets2[0x100003f54] <+128>: bl 0x100003f58 ; symbol stub for: __stack_chk_fail (lldb) b 0x100003f04 Breakpoint 1: address = 0x0000000100003f04 (lldb) br l Current breakpoints: 1: address = 0x0000000100003f04, locations = 1 1.1: address = 0x0000000100003f04, unresolved, hit count = 0 (lldb) b main Breakpoint 2: where = gets2`main, address = 0x0000000100003ed4 (lldb) br l Current breakpoints: 1: address = 0x0000000100003f04, locations = 1 1.1: address = 0x0000000100003f04, unresolved, hit count = 0 2: name = 'main', locations = 1 2.1: where = gets2`main, address = gets2[0x0000000100003ed4], unresolved, hit count = 0 (lldb) br del 1 1 breakpoints deleted; 0 breakpoint locations disabled. (lldb) b 0x100003f04 Breakpoint 3: address = 0x0000000100003f04 (lldb) br l Current breakpoints: 2: name = 'main', locations = 1 2.1: where = gets2`main, address = gets2[0x0000000100003ed4], unresolved, hit count = 0 3: address = 0x0000000100003f04, locations = 1 3.1: address = 0x0000000100003f04, unresolved, hit count = 0 (lldb) br del 3 1 breakpoints deleted; 0 breakpoint locations disabled. (lldb) r Process 88708 launched: '/Users/user/cs59/gets2' (arm64) Process 88708 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1 frame #0: 0x0000000100003ed4 gets2`main gets2`main: -> 0x100003ed4 <+0>: sub sp, sp, #0x30 ; =0x30 0x100003ed8 <+4>: stp x29, x30, [sp, #0x20] 0x100003edc <+8>: add x29, sp, #0x20 ; =0x20 0x100003ee0 <+12>: adrp x8, 1 Target 0: (gets2) stopped. (lldb) b 0x100003f04 Breakpoint 4: where = gets2`main + 48, address = 0x0000000100003f04 (lldb) br l Current breakpoints: 2: name = 'main', locations = 1, resolved = 1, hit count = 1 2.1: where = gets2`main, address = 0x0000000100003ed4, resolved, hit count = 1 4: address = gets2[0x0000000100003f04], locations = 1, resolved = 1, hit count = 0 4.1: where = gets2`main + 48, address = 0x0000000100003f04, resolved, hit count = 0 (lldb) c Process 88708 resuming warning: this program uses gets(), which is unsafe. AAAAAAAAAAAAAA Process 88708 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 4.1 frame #0: 0x0000000100003f04 gets2`main + 48 gets2`main: -> 0x100003f04 <+48>: ldr w8, [sp, #0x14] 0x100003f08 <+52>: str w8, [sp] 0x100003f0c <+56>: ldr w8, [sp] 0x100003f10 <+60>: tbnz w8, #0x1f, 0x100003f2c ; <+88> Target 0: (gets2) stopped. (lldb) x $sp 0x16fdff720: 00 00 00 00 00 00 00 00 41 41 41 41 41 41 41 41 ........AAAAAAAA 0x16fdff730: 41 41 41 41 41 41 00 00 0c 00 ca c5 2f 86 7e 2e AAAAAA....../.~. (lldb) r There is a running process, kill it and restart?: [Y/n] y Process 88708 exited with status = 9 (0x00000009) Process 88714 launched: '/Users/user/cs59/gets2' (arm64) Process 88714 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1 frame #0: 0x0000000100003ed4 gets2`main gets2`main: -> 0x100003ed4 <+0>: sub sp, sp, #0x30 ; =0x30 0x100003ed8 <+4>: stp x29, x30, [sp, #0x20] 0x100003edc <+8>: add x29, sp, #0x20 ; =0x20 0x100003ee0 <+12>: adrp x8, 1 Target 0: (gets2) stopped. (lldb) disas -n main gets2`main: -> 0x100003ed4 <+0>: sub sp, sp, #0x30 ; =0x30 0x100003ed8 <+4>: stp x29, x30, [sp, #0x20] 0x100003edc <+8>: add x29, sp, #0x20 ; =0x20 0x100003ee0 <+12>: adrp x8, 1 0x100003ee4 <+16>: ldr x8, [x8] 0x100003ee8 <+20>: ldr x8, [x8] 0x100003eec <+24>: stur x8, [x29, #-0x8] 0x100003ef0 <+28>: str wzr, [sp, #0x4] 0x100003ef4 <+32>: add x0, sp, #0x8 ; =0x8 0x100003ef8 <+36>: mov w8, #0xa 0x100003efc <+40>: str w8, [sp, #0x14] 0x100003f00 <+44>: bl 0x100003f64 ; symbol stub for: gets 0x100003f04 <+48>: ldr w8, [sp, #0x14] 0x100003f08 <+52>: str w8, [sp] 0x100003f0c <+56>: ldr w8, [sp] 0x100003f10 <+60>: tbnz w8, #0x1f, 0x100003f2c ; <+88> 0x100003f14 <+64>: ldr w8, [sp] 0x100003f18 <+68>: subs w8, w8, #0x1 ; =0x1 0x100003f1c <+72>: str w8, [sp] 0x100003f20 <+76>: add x0, sp, #0x8 ; =0x8 0x100003f24 <+80>: bl 0x100003f70 ; symbol stub for: puts 0x100003f28 <+84>: b 0x100003f0c ; <+56> 0x100003f2c <+88>: adrp x8, 1 0x100003f30 <+92>: ldr x8, [x8] 0x100003f34 <+96>: ldr x8, [x8] 0x100003f38 <+100>: ldur x9, [x29, #-0x8] 0x100003f3c <+104>: subs x8, x8, x9 0x100003f40 <+108>: b.ne 0x100003f54 ; <+128> 0x100003f44 <+112>: mov w0, #0x2a 0x100003f48 <+116>: ldp x29, x30, [sp, #0x20] 0x100003f4c <+120>: add sp, sp, #0x30 ; =0x30 0x100003f50 <+124>: ret 0x100003f54 <+128>: bl 0x100003f58 ; symbol stub for: __stack_chk_fail (lldb) b 0x100003efc Breakpoint 5: where = gets2`main + 40, address = 0x0000000100003efc (lldb) br l Current breakpoints: 2: name = 'main', locations = 1, resolved = 1, hit count = 2 2.1: where = gets2`main, address = 0x0000000100003ed4, resolved, hit count = 2 4: address = gets2[0x0000000100003f04], locations = 1, resolved = 1, hit count = 1 4.1: where = gets2`main + 48, address = 0x0000000100003f04, resolved, hit count = 1 5: address = gets2[0x0000000100003efc], locations = 1, resolved = 1, hit count = 0 5.1: where = gets2`main + 40, address = 0x0000000100003efc, resolved, hit count = 0 (lldb) c Process 88714 resuming Process 88714 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 5.1 frame #0: 0x0000000100003efc gets2`main + 40 gets2`main: -> 0x100003efc <+40>: str w8, [sp, #0x14] 0x100003f00 <+44>: bl 0x100003f64 ; symbol stub for: gets 0x100003f04 <+48>: ldr w8, [sp, #0x14] 0x100003f08 <+52>: str w8, [sp] Target 0: (gets2) stopped. (lldb) si Process 88714 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100003f00 gets2`main + 44 gets2`main: -> 0x100003f00 <+44>: bl 0x100003f64 ; symbol stub for: gets 0x100003f04 <+48>: ldr w8, [sp, #0x14] 0x100003f08 <+52>: str w8, [sp] 0x100003f0c <+56>: ldr w8, [sp] Target 0: (gets2) stopped. (lldb) x $sp 0x16fdff720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0x16fdff730: 00 00 00 00 0a 00 00 00 20 00 09 f7 40 e4 f4 de ........ ...@... (lldb) c Process 88714 resuming warning: this program uses gets(), which is unsafe. AAAAAAAAAAAAAAA Process 88714 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 4.1 frame #0: 0x0000000100003f04 gets2`main + 48 gets2`main: -> 0x100003f04 <+48>: ldr w8, [sp, #0x14] 0x100003f08 <+52>: str w8, [sp] 0x100003f0c <+56>: ldr w8, [sp] 0x100003f10 <+60>: tbnz w8, #0x1f, 0x100003f2c ; <+88> Target 0: (gets2) stopped. (lldb) x $sp 0x16fdff720: 00 00 00 00 00 00 00 00 41 41 41 41 41 41 41 41 ........AAAAAAAA 0x16fdff730: 41 41 41 41 41 41 41 00 20 00 09 f7 40 e4 f4 de AAAAAAA. ...@... (lldb) x/w $sp 0x16fdff720: 0x00000000 (lldb) x/10w $sp 0x16fdff720: 0x00000000 0x00000000 0x41414141 0x41414141 0x16fdff730: 0x41414141 0x00414141 0xf7090020 0xdef4e440 0x16fdff740: 0x6fdff760 0x00000001 (lldb) r There is a running process, kill it and restart?: [Y/n] y Process 88714 exited with status = 9 (0x00000009) Process 88751 launched: '/Users/user/cs59/gets2' (arm64) Process 88751 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1 frame #0: 0x0000000100003ed4 gets2`main gets2`main: -> 0x100003ed4 <+0>: sub sp, sp, #0x30 ; =0x30 0x100003ed8 <+4>: stp x29, x30, [sp, #0x20] 0x100003edc <+8>: add x29, sp, #0x20 ; =0x20 0x100003ee0 <+12>: adrp x8, 1 Target 0: (gets2) stopped. (lldb) c Process 88751 resuming Process 88751 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 5.1 frame #0: 0x0000000100003efc gets2`main + 40 gets2`main: -> 0x100003efc <+40>: str w8, [sp, #0x14] 0x100003f00 <+44>: bl 0x100003f64 ; symbol stub for: gets 0x100003f04 <+48>: ldr w8, [sp, #0x14] 0x100003f08 <+52>: str w8, [sp] Target 0: (gets2) stopped. (lldb) x/10w $sp 0x16fdff720: 0x00000000 0x00000000 0x00000000 0x00000000 0x16fdff730: 0x00000000 0x00000000 0x88e70072 0x7242c3cf 0x16fdff740: 0x6fdff760 0x00000001 (lldb) si Process 88751 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100003f00 gets2`main + 44 gets2`main: -> 0x100003f00 <+44>: bl 0x100003f64 ; symbol stub for: gets 0x100003f04 <+48>: ldr w8, [sp, #0x14] 0x100003f08 <+52>: str w8, [sp] 0x100003f0c <+56>: ldr w8, [sp] Target 0: (gets2) stopped. (lldb) x/10w $sp 0x16fdff720: 0x00000000 0x00000000 0x00000000 0x00000000 0x16fdff730: 0x00000000 0x0000000a 0x88e70072 0x7242c3cf 0x16fdff740: 0x6fdff760 0x00000001 (lldb) c Process 88751 resuming warning: this program uses gets(), which is unsafe. AAAAAAAAAAA Process 88751 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 4.1 frame #0: 0x0000000100003f04 gets2`main + 48 gets2`main: -> 0x100003f04 <+48>: ldr w8, [sp, #0x14] 0x100003f08 <+52>: str w8, [sp] 0x100003f0c <+56>: ldr w8, [sp] 0x100003f10 <+60>: tbnz w8, #0x1f, 0x100003f2c ; <+88> Target 0: (gets2) stopped. (lldb) x/10w $sp 0x16fdff720: 0x00000000 0x00000000 0x41414141 0x41414141 0x16fdff730: 0x00414141 0x0000000a 0x88e70072 0x7242c3cf 0x16fdff740: 0x6fdff760 0x00000001 (lldb) r There is a running process, kill it and restart?: [Y/n] y Process 88751 exited with status = 9 (0x00000009) Process 88760 launched: '/Users/user/cs59/gets2' (arm64) Process 88760 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1 frame #0: 0x0000000100003ed4 gets2`main gets2`main: -> 0x100003ed4 <+0>: sub sp, sp, #0x30 ; =0x30 0x100003ed8 <+4>: stp x29, x30, [sp, #0x20] 0x100003edc <+8>: add x29, sp, #0x20 ; =0x20 0x100003ee0 <+12>: adrp x8, 1 Target 0: (gets2) stopped. (lldb) c Process 88760 resuming Process 88760 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 5.1 frame #0: 0x0000000100003efc gets2`main + 40 gets2`main: -> 0x100003efc <+40>: str w8, [sp, #0x14] 0x100003f00 <+44>: bl 0x100003f64 ; symbol stub for: gets 0x100003f04 <+48>: ldr w8, [sp, #0x14] 0x100003f08 <+52>: str w8, [sp] Target 0: (gets2) stopped. (lldb) c Process 88760 resuming warning: this program uses gets(), which is unsafe. AAAAAAAAAAAAA Process 88760 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 4.1 frame #0: 0x0000000100003f04 gets2`main + 48 gets2`main: -> 0x100003f04 <+48>: ldr w8, [sp, #0x14] 0x100003f08 <+52>: str w8, [sp] 0x100003f0c <+56>: ldr w8, [sp] 0x100003f10 <+60>: tbnz w8, #0x1f, 0x100003f2c ; <+88> Target 0: (gets2) stopped. (lldb) x/10w $sp 0x16fdff720: 0x00000000 0x00000000 0x41414141 0x41414141 0x16fdff730: 0x41414141 0x00000041 0x4ea900db 0xaddb0a7c 0x16fdff740: 0x6fdff760 0x00000001 (lldb) c Process 88760 resuming AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA AAAAAAAAAAAAA Process 88760 exited with status = 42 (0x0000002a) (lldb) ^D % fg [1] + continued emacs gets.c zsh: suspended emacs gets.c % lldb ./gets2 (lldb) target create "./gets2" Current executable set to '/Users/user/cs59/gets2' (arm64). (lldb) b main Breakpoint 1: where = gets2`main, address = 0x0000000100003ed4 (lldb) dis -n main gets2`main: gets2[0x100003ed4] <+0>: sub sp, sp, #0x30 ; =0x30 gets2[0x100003ed8] <+4>: stp x29, x30, [sp, #0x20] gets2[0x100003edc] <+8>: add x29, sp, #0x20 ; =0x20 gets2[0x100003ee0] <+12>: adrp x8, 1 gets2[0x100003ee4] <+16>: ldr x8, [x8] gets2[0x100003ee8] <+20>: ldr x8, [x8] gets2[0x100003eec] <+24>: stur x8, [x29, #-0x8] gets2[0x100003ef0] <+28>: str wzr, [sp, #0x4] gets2[0x100003ef4] <+32>: add x0, sp, #0x8 ; =0x8 gets2[0x100003ef8] <+36>: mov w8, #0xa gets2[0x100003efc] <+40>: str w8, [sp, #0x14] gets2[0x100003f00] <+44>: bl 0x100003f64 ; symbol stub for: gets gets2[0x100003f04] <+48>: ldr w8, [sp, #0x14] gets2[0x100003f08] <+52>: str w8, [sp] gets2[0x100003f0c] <+56>: ldr w8, [sp] gets2[0x100003f10] <+60>: tbnz w8, #0x1f, 0x100003f2c ; <+88> gets2[0x100003f14] <+64>: ldr w8, [sp] gets2[0x100003f18] <+68>: subs w8, w8, #0x1 ; =0x1 gets2[0x100003f1c] <+72>: str w8, [sp] gets2[0x100003f20] <+76>: add x0, sp, #0x8 ; =0x8 gets2[0x100003f24] <+80>: bl 0x100003f70 ; symbol stub for: puts gets2[0x100003f28] <+84>: b 0x100003f0c ; <+56> gets2[0x100003f2c] <+88>: adrp x8, 1 gets2[0x100003f30] <+92>: ldr x8, [x8] gets2[0x100003f34] <+96>: ldr x8, [x8] gets2[0x100003f38] <+100>: ldur x9, [x29, #-0x8] gets2[0x100003f3c] <+104>: subs x8, x8, x9 gets2[0x100003f40] <+108>: b.ne 0x100003f54 ; <+128> gets2[0x100003f44] <+112>: mov w0, #0x2a gets2[0x100003f48] <+116>: ldp x29, x30, [sp, #0x20] gets2[0x100003f4c] <+120>: add sp, sp, #0x30 ; =0x30 gets2[0x100003f50] <+124>: ret gets2[0x100003f54] <+128>: bl 0x100003f58 ; symbol stub for: __stack_chk_fail