ichikitakahiro % cd ~/src/firefly/hg/CbC/CbC_examples/ ichikitakahiro % ls Makefile test2.exe arg.c test_cs.c arg.exe test_cs.exe c-next.c test_csp1.c c-next.exe test_csp1.exe c-next1.c test_func2code.c code_segment_pointer_check test_func2code.exe conv1.c test_para.c conv1.exe test_para.exe fact-a.c test_para2.c fact-a.exe test_para2.exe fact-e.c test_para3.c goto.c test_para3.exe goto.exe test_para4.c loto6.c test_para4.exe loto6.exe test_tree.c quicksort test_tree.exe regexp tmp1.c stack1.c tmp1.exe stack1.exe tmp2.c test02.c tmp2.exe test02.exe tmp4.c test05.c tmp4.exe test05.exe tmpa.c test1.c tmpa.exe test1.exe too-long-argument.c test2.c too-long-argument.exe ichikitakahiro % make for exe in arg.exe conv1.exe fact-a.exe goto.exe loto6.exe stack1.exe test02.exe test05.exe test1.exe test2.exe test_cs.exe test_csp1.exe test_func2code.exe test_para2.exe test_para3.exe test_para4.exe test_para.exe test_tree.exe tmp1.exe tmp2.exe tmp4.exe tmpa.exe too-long-argument.exe c-next.exe ; do \ ./${exe} ; \ done #0017:arg1: 0 1 2 3 4 : 1 1 #0024:arg1: 1 2 3 4 0 : 1 1 #0035:args: 1 2 3 4 0 : 1 0 #0089:321=0 #0045:args3: 11 22 33 44 55 : 1 2 3 4 #0047:args3: args0 11 22 33 44 55 : args1 66 77 88 99 10 : 1 2 3 4 #0057:args4: 11 22 33 44 55 : 2 3 4 1 #0064:args5: 11 22 33 44 55 : 3 4 1 2 #0071:args6: 11 22 33 44 55 : 3 4 1 2 #0045:args3: 11 22 33 44 55 : 3 4 1 2 #0047:args3: args0 11 22 33 44 55 : args1 11 22 33 44 55 : 3 4 1 2 #0165:720 #0032:10! = 3628800 #0023:a2 1 a3 #0030:a3 2 a4 #0037:a4 3 a5 #0044:a5 4 a6 #0051:a6 5 a7 #0058:a7 6 a8 #0065:a8 7 a9 #0072:a9 8 xx 31-32-33-13-4-35 #0108:sp: 0 1 #0070:f0 1 sp: 0 #0072:f0 2 sp: ffffffe0 #0078:f0 3 sp: ffffffe0 #0042:f 0 sp: ffffffe0 #0046:f 1 sp: ffffffe0 #0048:f 2 sp: ffffffc8 #0114:13 1 test code test_goto: a = 20 test_code: return 10 main: ret = 0 in f01: 12 in f02: 13, 13.200000 in f01: 14 in cs01: 14 in end: #0115:sp: 0 1 #0075:f0 1 sp: 0 #0077:f0 2 sp: ffffffe0 #0083:f0 3 sp: ffffffe0 #0047:f 0 sp: ffffffe0 #0051:f 1 sp: ffffffe0 #0053:f 2 sp: ffffffc8 #0121:13 1 #0040:main bit: 1 #0041:main message: hogehoge #0026:initSender bit: 1 #0027:initSender message: hogehoge #0028:sender_bit: 0 #0017:bit: 1 #0018:message: hogehoge main start 10, 20, 30, 40 50, 60, 70, 80 90, 100, 110 cs_exit was called! function: a=10.010000, b=20.020000, c=30 csp = 5f71cc7. cs_cs0 : a=30, b=60, c=40, d=70. cs_exit : a=7500. in continuation: go code segment cs0 in cs0: x = 20, y = 400. in cs0: will exit with code 8000. cs_goto : a=10, b=20, c=30, d=40. cs_cs0 : a=20, b=30, c=40, d=10. cs_exit : a=3400. function : struct abc: a=10, b=20.020000, c=0, d=0xad struct def: d=30, f=0xbf struct abc: a=50, b=60.060000, c=1, d=0xed cs_goto : c=100 struct abc: a=10, b=20.020000, c=0, d=0xad struct def: d=30, f=0xbf struct abc: a=50, b=60.060000, c=1, d=0xed cs0 : c=100 struct abc: a=10, b=20.020000, c=0, d=0xad struct def: d=30, f=0xbf struct abc: a=50, b=60.060000, c=1, d=0xed cs_exit : a=1001. function: a=10, b=20, c=30, d=40, e=50, f=60, g=70, h=80, i=90, j=100 function: a=110, b=120, c=130, d=140, e=150, f=160, g=170, h=180, i=190, j=200 cs_goto : a=10, b=20, c=30, d=40, e=50, f=60, g=70, h=80, i=90, j=100 cs_goto : a=110, b=120, c=130, d=140, e=150, f=160, g=170, h=180, i=190, j=200 cs0 : a=20, b=30, c=40, d=50, e=60, f=10, g=10, h=10, i=10, j=10 cs0 : a=10, b=10, c=10, d=10, e=10, f=10, g=10, h=10, i=10, j=10 cs_exit : a=700. b=14003 it is in main. cs0 was called: a=11, b=22.200000, c=33, d=44. cs_exit was called: a=1610. t = 220.000000 test_goto __code cs1 was called. a = 2, b = 10.200000, c = 3, d = 4 #0087:main continue. #0089:main end. #0021:2: ./tmp2.exe #0032:3: ./tmp2.exe #0041:4: ./tmp2.exe #0012:1: ./tmp2.exe 1234 #0025:2: tmp4.exe #0037:3: i=123 j=456 k=789 av[0]=tmp4.exe p=tmp4.exe #0047:4: tmp4.exe #0057:5: tmp4.exe #0058:5: i=123 j=456 k=789 #0012:1: tmp4.exe 1234 #0014:charno:5 x,y:50.000000,30.000000 hp:100 #0045:0 0 #0026:15 #0092:main4 #0017:tcode2: f1=0,f2=1,f3=2,f4=3,f5=4,f6=5,f7=6,f8=7,f9=8,fa=9,fb=10,fc=11,fd=12,fe=13,ff=14 #0094:main2 #0028:tcode1: f1=0,f2=1,f3=2,f4=3,f5=4,f6=5,f7=6,f8=7,f9=8,fa=9,fb=10,fc=11,fd=12,fe=13,ff=14 #0096:main0 #0017:tcode2: f1=0,f2=1,f3=2,f4=3,f5=4,f6=5,f7=6,f8=7,f9=8,fa=9,fb=10,fc=11,fd=12,fe=13,ff=14 #0098:main1 #0028:tcode1: f1=0,f2=1,f3=2,f4=3,f5=4,f6=5,f7=6,f8=7,f9=8,fa=9,fb=10,fc=11,fd=12,fe=13,ff=14 ichikitakahiro % ls Makefile test2.exe arg.c test_cs.c arg.exe test_cs.exe c-next.c test_csp1.c c-next.exe test_csp1.exe c-next1.c test_func2code.c code_segment_pointer_check test_func2code.exe conv1.c test_para.c conv1.exe test_para.exe fact-a.c test_para2.c fact-a.exe test_para2.exe fact-e.c test_para3.c goto.c test_para3.exe goto.exe test_para4.c loto6.c test_para4.exe loto6.exe test_tree.c quicksort test_tree.exe regexp tmp1.c stack1.c tmp1.exe stack1.exe tmp2.c test02.c tmp2.exe test02.exe tmp4.c test05.c tmp4.exe test05.exe tmpa.c test1.c tmpa.exe test1.exe too-long-argument.c test2.c too-long-argument.exe ichikitakahiro % pwd /Users/ichikitakahiro/src/firefly/hg/CbC/CbC_examples ichikitakahiro % cd .. ichikitakahiro % ls CbC_examples CbC_gcc ichikitakahiro % cd .. ichikitakahiro % ls CbC Gears ichikitakahiro % cd ~/workspace ichikitakahiro % ls cr test ichikitakahiro % cd cr/test_space ichikitakahiro % ls a.out test.c tsts ichikitakahiro % vim test.c ichikitakahiro % vim ~/.vimrc ichikitakahiro % vim test.c ichikitakahiro % vim ~/.zshrc ichikitakahiro % $GCC_COMPILER gcc: fatal error: no input files compilation terminated. ichikitakahiro % vim ~/.zshrc ichikitakahiro % vim ~/.zshrc ichikitakahiro % . !$ . ~/.zshrc ichikitakahiro % $CBC_COMPILER -Wall test.c ichikitakahiro % ls a.out test.c tsts ichikitakahiro % ./a.out Hello i = 10 ichikitakahiro % $CBC_COMPILER -Wall -S test.c ichikitakahiro % ls a.out test.c test.s tsts ichikitakahiro % less test.s ichikitakahiro % $CBC_COMPILER -Wall -O0 -g test.c ichikitakahiro % ls -ltr total 80 -rwxr-xr-x 1 ichikitakahiro staff 12556 2 13 12:48 tsts -rw-r--r-- 1 ichikitakahiro staff 156 2 28 10:52 test.c -rw-r--r-- 1 ichikitakahiro staff 2293 2 28 10:57 test.s -rwxr-xr-x 1 ichikitakahiro staff 13044 2 28 11:05 a.out drwxr-xr-x 3 ichikitakahiro staff 96 2 28 11:05 a.out.dSYM ichikitakahiro % lldb a.out (lldb) target create "a.out" Current executable set to 'a.out' (x86_64). (lldb) b main Breakpoint 1: where = a.out`main + 4 at test.c:14:8, address = 0x0000000100000ee4 (lldb) process la Process 68542 launched: '/Users/ichikitakahiro/workspace/cr/test_space/a.out' (x86_64) Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100000ee4 a.out`main at test.c:14:8 11 } 12 13 int main(){ -> 14 goto CG1(); 15 } Target 0: (a.out) stopped. (lldb) dissas error: 'dissas' is not a valid command. (lldb) info reg error: 'info' is not a valid command. (lldb) register read General Purpose Registers: rax = 0x0000000100000ee0 a.out`main at test.c:13:11 rbx = 0x0000000000000000 rcx = 0x00007ffeefbff630 rdx = 0x00007ffeefbff520 rdi = 0x0000000000000001 rsi = 0x00007ffeefbff510 rbp = 0x00007ffeefbff4f0 rsp = 0x00007ffeefbff4f0 r8 = 0x0000000000000000 r9 = 0x0000000000000000 r10 = 0x0000000000000000 r11 = 0x0000000000000000 r12 = 0x0000000000000000 r13 = 0x0000000000000000 r14 = 0x0000000000000000 r15 = 0x0000000000000000 rip = 0x0000000100000ee4 a.out`main + 4 at test.c:14:8 rflags = 0x0000000000000246 cs = 0x000000000000002b fs = 0x0000000000000000 gs = 0x0000000000000000 (lldb) x/20i $rip -> 0x100000ee4: 48 81 ec 00 04 00 00 subq $0x400, %rsp ; imm = 0x400 0x100000eeb: b8 00 00 00 00 movl $0x0, %eax 0x100000ef0: e8 d0 ff ff ff callq 0x100000ec5 ; CG1 at test.c:8:13 0x100000ef5: 48 81 c4 00 04 00 00 addq $0x400, %rsp ; imm = 0x400 0x100000efc: 90 nop 0x100000efd: 90 nop 0x100000efe: c9 leave 0x100000eff: c3 retq 0x100000f00: ff 25 fa 10 00 00 jmpq *0x10fa(%rip) ; (void *)0x0000000100000f1c 0x100000f06: ff 25 fc 10 00 00 jmpq *0x10fc(%rip) ; (void *)0x0000000100000f26 0x100000f0c: 4c 8d 1d fd 10 00 00 leaq 0x10fd(%rip), %r11 ; _dyld_private 0x100000f13: 41 53 pushq %r11 0x100000f15: ff 25 e5 00 00 00 jmpq *0xe5(%rip) ; (void *)0x00007fff6f632578: dyld_stub_binder 0x100000f1b: 90 nop 0x100000f1c: 68 00 00 00 00 pushq $0x0 0x100000f21: e9 e6 ff ff ff jmp 0x100000f0c 0x100000f26: 68 0e 00 00 00 pushq $0xe 0x100000f2b: e9 dc ff ff ff jmp 0x100000f0c 0x100000f30: 69 20 3d 20 25 64 imull $0x6425203d, (%rax), %esp ; imm = 0x6425203D 0x100000f36: 0a 00 orb (%rax), %al (lldb) step i error: invalid thread index 'i'. (lldb) stepi Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100000eeb a.out`main at test.c:14:8 11 } 12 13 int main(){ -> 14 goto CG1(); 15 } Target 0: (a.out) stopped. (lldb) x/20i $rip -> 0x100000eeb: b8 00 00 00 00 movl $0x0, %eax 0x100000ef0: e8 d0 ff ff ff callq 0x100000ec5 ; CG1 at test.c:8:13 0x100000ef5: 48 81 c4 00 04 00 00 addq $0x400, %rsp ; imm = 0x400 0x100000efc: 90 nop 0x100000efd: 90 nop 0x100000efe: c9 leave 0x100000eff: c3 retq 0x100000f00: ff 25 fa 10 00 00 jmpq *0x10fa(%rip) ; (void *)0x0000000100000f1c 0x100000f06: ff 25 fc 10 00 00 jmpq *0x10fc(%rip) ; (void *)0x0000000100000f26 0x100000f0c: 4c 8d 1d fd 10 00 00 leaq 0x10fd(%rip), %r11 ; _dyld_private 0x100000f13: 41 53 pushq %r11 0x100000f15: ff 25 e5 00 00 00 jmpq *0xe5(%rip) ; (void *)0x00007fff6f632578: dyld_stub_binder 0x100000f1b: 90 nop 0x100000f1c: 68 00 00 00 00 pushq $0x0 0x100000f21: e9 e6 ff ff ff jmp 0x100000f0c 0x100000f26: 68 0e 00 00 00 pushq $0xe 0x100000f2b: e9 dc ff ff ff jmp 0x100000f0c 0x100000f30: 69 20 3d 20 25 64 imull $0x6425203d, (%rax), %esp ; imm = 0x6425203D 0x100000f36: 0a 00 orb (%rax), %al 0x100000f38: 48 65 gs (lldb) stepi Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100000ef0 a.out`main at test.c:14:8 11 } 12 13 int main(){ -> 14 goto CG1(); 15 } Target 0: (a.out) stopped. (lldb) x/20i $rip -> 0x100000ef0: e8 d0 ff ff ff callq 0x100000ec5 ; CG1 at test.c:8:13 0x100000ef5: 48 81 c4 00 04 00 00 addq $0x400, %rsp ; imm = 0x400 0x100000efc: 90 nop 0x100000efd: 90 nop 0x100000efe: c9 leave 0x100000eff: c3 retq 0x100000f00: ff 25 fa 10 00 00 jmpq *0x10fa(%rip) ; (void *)0x0000000100000f1c 0x100000f06: ff 25 fc 10 00 00 jmpq *0x10fc(%rip) ; (void *)0x0000000100000f26 0x100000f0c: 4c 8d 1d fd 10 00 00 leaq 0x10fd(%rip), %r11 ; _dyld_private 0x100000f13: 41 53 pushq %r11 0x100000f15: ff 25 e5 00 00 00 jmpq *0xe5(%rip) ; (void *)0x00007fff6f632578: dyld_stub_binder 0x100000f1b: 90 nop 0x100000f1c: 68 00 00 00 00 pushq $0x0 0x100000f21: e9 e6 ff ff ff jmp 0x100000f0c 0x100000f26: 68 0e 00 00 00 pushq $0xe 0x100000f2b: e9 dc ff ff ff jmp 0x100000f0c 0x100000f30: 69 20 3d 20 25 64 imull $0x6425203d, (%rax), %esp ; imm = 0x6425203D 0x100000f36: 0a 00 orb (%rax), %al 0x100000f38: 48 65 gs 0x100000f3a: 6c insb %dx, %es:(%rdi) (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into * frame #0: 0x0000000100000ef0 a.out`main at test.c:14:8 frame #1: 0x00007fff6f633cc9 libdyld.dylib`start + 1 (lldb) register read General Purpose Registers: rax = 0x0000000000000000 rbx = 0x0000000000000000 rcx = 0x00007ffeefbff630 rdx = 0x00007ffeefbff520 rdi = 0x0000000000000001 rsi = 0x00007ffeefbff510 rbp = 0x00007ffeefbff4f0 rsp = 0x00007ffeefbff0f0 r8 = 0x0000000000000000 r9 = 0x0000000000000000 r10 = 0x0000000000000000 r11 = 0x0000000000000000 r12 = 0x0000000000000000 r13 = 0x0000000000000000 r14 = 0x0000000000000000 r15 = 0x0000000000000000 rip = 0x0000000100000ef0 a.out`main + 16 at test.c:14:8 rflags = 0x0000000000000206 cs = 0x000000000000002b fs = 0x0000000000000000 gs = 0x0000000000000000 (lldb) stepi Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100000ec5 a.out`CG1 at test.c:8:13 5 printf("i = %d\n", i); 6 } 7 -> 8 __code CG1(){ 9 printf("Hello\n"); 10 goto CG2(); 11 } Target 0: (a.out) stopped. (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into * frame #0: 0x0000000100000ec5 a.out`CG1 at test.c:8:13 frame #1: 0x0000000100000ef5 a.out`main at test.c:14:8 frame #2: 0x00007fff6f633cc9 libdyld.dylib`start + 1 (lldb) register read General Purpose Registers: rax = 0x0000000000000000 rbx = 0x0000000000000000 rcx = 0x00007ffeefbff630 rdx = 0x00007ffeefbff520 rdi = 0x0000000000000001 rsi = 0x00007ffeefbff510 rbp = 0x00007ffeefbff4f0 rsp = 0x00007ffeefbff0e8 r8 = 0x0000000000000000 r9 = 0x0000000000000000 r10 = 0x0000000000000000 r11 = 0x0000000000000000 r12 = 0x0000000000000000 r13 = 0x0000000000000000 r14 = 0x0000000000000000 r15 = 0x0000000000000000 rip = 0x0000000100000ec5 a.out`CG1 at test.c:8:13 rflags = 0x0000000000000206 cs = 0x000000000000002b fs = 0x0000000000000000 gs = 0x0000000000000000 (lldb) x/20i $rip -> 0x100000ec5: 55 pushq %rbp 0x100000ec6: 48 89 e5 movq %rsp, %rbp 0x100000ec9: 48 8d 3d 68 00 00 00 leaq 0x68(%rip), %rdi ; "Hello" 0x100000ed0: e8 31 00 00 00 callq 0x100000f06 ; symbol stub for: puts 0x100000ed5: b8 00 00 00 00 movl $0x0, %eax 0x100000eda: 5d popq %rbp 0x100000edb: e9 bd ff ff ff jmp 0x100000e9d ; CG2 at test.c:3:13 0x100000ee0: 55 pushq %rbp 0x100000ee1: 48 89 e5 movq %rsp, %rbp 0x100000ee4: 48 81 ec 00 04 00 00 subq $0x400, %rsp ; imm = 0x400 0x100000eeb: b8 00 00 00 00 movl $0x0, %eax 0x100000ef0: e8 d0 ff ff ff callq 0x100000ec5 ; CG1 at test.c:8:13 0x100000ef5: 48 81 c4 00 04 00 00 addq $0x400, %rsp ; imm = 0x400 0x100000efc: 90 nop 0x100000efd: 90 nop 0x100000efe: c9 leave 0x100000eff: c3 retq 0x100000f00: ff 25 fa 10 00 00 jmpq *0x10fa(%rip) ; (void *)0x0000000100000f1c 0x100000f06: ff 25 fc 10 00 00 jmpq *0x10fc(%rip) ; (void *)0x0000000100000f26 0x100000f0c: 4c 8d 1d fd 10 00 00 leaq 0x10fd(%rip), %r11 ; _dyld_private (lldb) stepi Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100000ec6 a.out`CG1 at test.c:8:13 5 printf("i = %d\n", i); 6 } 7 -> 8 __code CG1(){ 9 printf("Hello\n"); 10 goto CG2(); 11 } Target 0: (a.out) stopped. (lldb) stepi Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100000ec9 a.out`CG1 at test.c:9:3 6 } 7 8 __code CG1(){ -> 9 printf("Hello\n"); 10 goto CG2(); 11 } 12 Target 0: (a.out) stopped. (lldb) Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100000ed0 a.out`CG1 at test.c:9:3 6 } 7 8 __code CG1(){ -> 9 printf("Hello\n"); 10 goto CG2(); 11 } 12 Target 0: (a.out) stopped. (lldb) x/20i $rip -> 0x100000ed0: e8 31 00 00 00 callq 0x100000f06 ; symbol stub for: puts 0x100000ed5: b8 00 00 00 00 movl $0x0, %eax 0x100000eda: 5d popq %rbp 0x100000edb: e9 bd ff ff ff jmp 0x100000e9d ; CG2 at test.c:3:13 0x100000ee0: 55 pushq %rbp 0x100000ee1: 48 89 e5 movq %rsp, %rbp 0x100000ee4: 48 81 ec 00 04 00 00 subq $0x400, %rsp ; imm = 0x400 0x100000eeb: b8 00 00 00 00 movl $0x0, %eax 0x100000ef0: e8 d0 ff ff ff callq 0x100000ec5 ; CG1 at test.c:8:13 0x100000ef5: 48 81 c4 00 04 00 00 addq $0x400, %rsp ; imm = 0x400 0x100000efc: 90 nop 0x100000efd: 90 nop 0x100000efe: c9 leave 0x100000eff: c3 retq 0x100000f00: ff 25 fa 10 00 00 jmpq *0x10fa(%rip) ; (void *)0x0000000100000f1c 0x100000f06: ff 25 fc 10 00 00 jmpq *0x10fc(%rip) ; (void *)0x0000000100000f26 0x100000f0c: 4c 8d 1d fd 10 00 00 leaq 0x10fd(%rip), %r11 ; _dyld_private 0x100000f13: 41 53 pushq %r11 0x100000f15: ff 25 e5 00 00 00 jmpq *0xe5(%rip) ; (void *)0x00007fff6f632578: dyld_stub_binder 0x100000f1b: 90 nop (lldb) stepi Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100000f06 a.out`puts a.out`puts: -> 0x100000f06 <+0>: jmpq *0x10fc(%rip) ; (void *)0x0000000100000f26 0x100000f0c: leaq 0x10fd(%rip), %r11 ; _dyld_private 0x100000f13: pushq %r11 0x100000f15: jmpq *0xe5(%rip) ; (void *)0x00007fff6f632578: dyld_stub_binder Target 0: (a.out) stopped. (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into * frame #0: 0x0000000100000f06 a.out`puts frame #1: 0x0000000100000ed5 a.out`CG1 at test.c:9:3 frame #2: 0x0000000100000ef5 a.out`main at test.c:14:8 frame #3: 0x00007fff6f633cc9 libdyld.dylib`start + 1 (lldb) fin Hello Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step out frame #0: 0x0000000100000ed5 a.out`CG1 at test.c:10:8 7 8 __code CG1(){ 9 printf("Hello\n"); -> 10 goto CG2(); 11 } 12 13 int main(){ Target 0: (a.out) stopped. (lldb) x/20i $rip -> 0x100000ed5: b8 00 00 00 00 movl $0x0, %eax 0x100000eda: 5d popq %rbp 0x100000edb: e9 bd ff ff ff jmp 0x100000e9d ; CG2 at test.c:3:13 0x100000ee0: 55 pushq %rbp 0x100000ee1: 48 89 e5 movq %rsp, %rbp 0x100000ee4: 48 81 ec 00 04 00 00 subq $0x400, %rsp ; imm = 0x400 0x100000eeb: b8 00 00 00 00 movl $0x0, %eax 0x100000ef0: e8 d0 ff ff ff callq 0x100000ec5 ; CG1 at test.c:8:13 0x100000ef5: 48 81 c4 00 04 00 00 addq $0x400, %rsp ; imm = 0x400 0x100000efc: 90 nop 0x100000efd: 90 nop 0x100000efe: c9 leave 0x100000eff: c3 retq 0x100000f00: ff 25 fa 10 00 00 jmpq *0x10fa(%rip) ; (void *)0x0000000100000f1c 0x100000f06: ff 25 fc 10 00 00 jmpq *0x10fc(%rip) ; (void *)0x00007fff6f6c2630: puts 0x100000f0c: 4c 8d 1d fd 10 00 00 leaq 0x10fd(%rip), %r11 ; _dyld_private 0x100000f13: 41 53 pushq %r11 0x100000f15: ff 25 e5 00 00 00 jmpq *0xe5(%rip) ; (void *)0x00007fff6f632578: dyld_stub_binder 0x100000f1b: 90 nop 0x100000f1c: 68 00 00 00 00 pushq $0x0 (lldb) stepi Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100000eda a.out`CG1 at test.c:11:1 8 __code CG1(){ 9 printf("Hello\n"); 10 goto CG2(); -> 11 } 12 13 int main(){ 14 goto CG1(); Target 0: (a.out) stopped. (lldb) Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100000edb a.out`CG1 at test.c:10:8 7 8 __code CG1(){ 9 printf("Hello\n"); -> 10 goto CG2(); 11 } 12 13 int main(){ Target 0: (a.out) stopped. (lldb) register read General Purpose Registers: rax = 0x0000000000000000 rbx = 0x0000000000000000 rcx = 0x00000001000cee6c dyld`_main_thread + 172 rdx = 0x0000000000000000 rdi = 0x00007fff95d4ebd8 __sFX + 216 rsi = 0x00000000000120a8 rbp = 0x00007ffeefbff4f0 rsp = 0x00007ffeefbff0e8 r8 = 0x00000000000130a8 r9 = 0x0000000000000000 r10 = 0x00007fff95d4ebf8 __sFX + 248 r11 = 0x00007fff95d4ebf0 __sFX + 240 r12 = 0x0000000000000000 r13 = 0x0000000000000000 r14 = 0x0000000000000000 r15 = 0x0000000000000000 rip = 0x0000000100000edb a.out`CG1 + 22 at test.c:10:8 rflags = 0x0000000000000206 cs = 0x000000000000002b fs = 0x0000000000000000 gs = 0x0000000000000000 (lldb) stepi Process 68542 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into frame #0: 0x0000000100000e9d a.out`CG2 at test.c:3:13 1 #include 2 -> 3 __code CG2(){ 4 int i = 10; 5 printf("i = %d\n", i); 6 } 7 Target 0: (a.out) stopped. (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = instruction step into * frame #0: 0x0000000100000e9d a.out`CG2 at test.c:3:13 frame #1: 0x0000000100000ef5 a.out`main at test.c:14:8 frame #2: 0x00007fff6f633cc9 libdyld.dylib`start + 1 (lldb) register read General Purpose Registers: rax = 0x0000000000000000 rbx = 0x0000000000000000 rcx = 0x00000001000cee6c dyld`_main_thread + 172 rdx = 0x0000000000000000 rdi = 0x00007fff95d4ebd8 __sFX + 216 rsi = 0x00000000000120a8 rbp = 0x00007ffeefbff4f0 rsp = 0x00007ffeefbff0e8 r8 = 0x00000000000130a8 r9 = 0x0000000000000000 r10 = 0x00007fff95d4ebf8 __sFX + 248 r11 = 0x00007fff95d4ebf0 __sFX + 240 r12 = 0x0000000000000000 r13 = 0x0000000000000000 r14 = 0x0000000000000000 r15 = 0x0000000000000000 rip = 0x0000000100000e9d a.out`CG2 at test.c:3:13 rflags = 0x0000000000000206 cs = 0x000000000000002b fs = 0x0000000000000000 gs = 0x0000000000000000 (lldb) exit Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] Y ichikitakahiro % ls a.out a.out.dSYM test.c test.s tsts ichikitakahiro % cp test2.c usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory ichikitakahiro % cp test.c test2.c ichikitakahiro % vim !$ vim test2.c ichikitakahiro % $CBC_COMPILER -Wall test2.c test2.c: In function 'CG1': test2.c:9:3: internal compiler error: tree check: expected function_type, have function_decl in convert_arguments, at c/c-typeck.c:3662 9 | goto CG2(); | ^~~~ libbacktrace could not find executable to open Please submit a full bug report, with preprocessed source if appropriate. See for instructions. ichikitakahiro % vim test2.c ichikitakahiro % $CBC_COMPILER -Wall test2.c ichikitakahiro % ./a.out Hello i = 20 ichikitakahiro % vim test2.c ichikitakahiro % $CBC_COMPILER -Wall test2.c test2.c: In function 'CG2': test2.c:5:27: error: expected ';' before '}' token 5 | printf("str = %s\n",str) | ^ | ; 6 | } | ~ test2.c: In function 'CG1': test2.c:10:16: error: 'Hello' undeclared (first use in this function); did you mean 'ftello'? 10 | goto CG2(20, Hello); | ^~~~~ | ftello test2.c:10:16: note: each undeclared identifier is reported only once for each function it appears in test2.c:10:22: error: expected code segment jump or '*' before ';' token 10 | goto CG2(20, Hello); | ^ ichikitakahiro % vim test2.c ichikitakahiro % $CBC_COMPILER -Wall test2.c ichikitakahiro % ./a.out Hello i = 20 str = Hello ichikitakahiro % $CBC_COMPILER -Wall -s test2.c ld: warning: option -s is obsolete and being ignored ichikitakahiro % $CBC_COMPILER -Wall -S test2.c ichikitakahiro % less test2.s ichikitakahiro % !v vim test2.c ichikitakahiro % $CBC_COMPILER -Wall test2.c ichikitakahiro % ./a.out Hello i = 20 str = 20 ichikitakahiro % vim test2.c ichikitakahiro % vim test2.c ichikitakahiro % $CBC_COMPILER -Wall -O0 -g test2.c ichikitakahiro % lldb a.out (lldb) target create "a.out" Current executable set to 'a.out' (x86_64). (lldb) b CG1 Breakpoint 1: where = a.out`CG1 + 8 at test2.c:9:3, address = 0x0000000100000eb3 (lldb) process ra invalid command 'process ra'. (lldb) process la Process 70508 launched: '/Users/ichikitakahiro/workspace/cr/test_space/a.out' (x86_64) Process 70508 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100000eb3 a.out`CG1 at test2.c:9:3 6 } 7 8 __code CG1(){ -> 9 printf("Hello\n"); 10 int i = 10; 11 goto CG2(20, &i); 12 } Target 0: (a.out) stopped. (lldb) n Hello Process 70508 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0000000100000ebf a.out`CG1 at test2.c:10:7 7 8 __code CG1(){ 9 printf("Hello\n"); -> 10 int i = 10; 11 goto CG2(20, &i); 12 } 13 Target 0: (a.out) stopped. (lldb) Process 70508 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0000000100000ec6 a.out`CG1 at test2.c:11:8 8 __code CG1(){ 9 printf("Hello\n"); 10 int i = 10; -> 11 goto CG2(20, &i); 12 } 13 14 int main(){ Target 0: (a.out) stopped. (lldb) p i (int) $0 = 10 (lldb) p &i (int *) $1 = 0x00007ffeefbff0dc (lldb) p (int*) 0x00007ffeefbff0dc (int *) $2 = 0x00007ffeefbff0dc (lldb) p *(int*) 0x00007ffeefbff0dc (int) $3 = 10 (lldb) s Process 70508 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step in frame #0: 0x0000000100000ed2 a.out`CG1 at test2.c:12:1 9 printf("Hello\n"); 10 int i = 10; 11 goto CG2(20, &i); -> 12 } 13 14 int main(){ 15 goto CG1(); Target 0: (a.out) stopped. (lldb) Process 70508 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step in frame #0: 0x0000000100000ed3 a.out`CG1 at test2.c:11:8 8 __code CG1(){ 9 printf("Hello\n"); 10 int i = 10; -> 11 goto CG2(20, &i); 12 } 13 14 int main(){ Target 0: (a.out) stopped. (lldb) Process 70508 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step in frame #0: 0x0000000100000e6a a.out`CG2(i=10, str=0x0000000000000000) at test2.c:3:27 1 #include 2 -> 3 __code CG2(int i,int* str){ 4 printf("i = %d\n", i); 5 printf("str = %d\n",*str); 6 } 7 Target 0: (a.out) stopped. (lldb) n Process 70508 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0000000100000e79 a.out`CG2(i=20, str=0x00007ffeefbff0dc) at test2.c:4:3 1 #include 2 3 __code CG2(int i,int* str){ -> 4 printf("i = %d\n", i); 5 printf("str = %d\n",*str); 6 } 7 Target 0: (a.out) stopped. (lldb) p &i (int *) $4 = 0x00007ffeefbff0dc (lldb) exit Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] Y ichikitakahiro % vim test2.c ichikitakahiro % $CBC_COMPILER -Wall test2.c ichikitakahiro % $CBC_COMPILER -Wall -O0 -g test2.c ichikitakahiro % ./a.out Hello i = 20 str = 10 ichikitakahiro % vim test2.c ichikitakahiro % lldb a.out (lldb) target create "a.out" Current executable set to 'a.out' (x86_64). (lldb) b CG1 Breakpoint 1: where = a.out`CG1 + 8 at test2.c:11:3, address = 0x0000000100000e90 (lldb) process ra invalid command 'process ra'. (lldb) process la Process 71421 launched: '/Users/ichikitakahiro/workspace/cr/test_space/a.out' (x86_64) Process 71421 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100000e90 a.out`CG1 at test2.c:11:3 8 } 9 10 __code CG1(){ -> 11 printf("Hello\n"); 12 // int i = 10; 13 int* i = malloc(sizeof(int)); 14 *i = 10; Target 0: (a.out) stopped. (lldb) n Hello Process 71421 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0000000100000e9c a.out`CG1 at test2.c:13:12 10 __code CG1(){ 11 printf("Hello\n"); 12 // int i = 10; -> 13 int* i = malloc(sizeof(int)); 14 *i = 10; 15 goto CG2(20, i); 16 } Target 0: (a.out) stopped. (lldb) n Process 71421 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0000000100000eaa a.out`CG1 at test2.c:14:6 11 printf("Hello\n"); 12 // int i = 10; 13 int* i = malloc(sizeof(int)); -> 14 *i = 10; 15 goto CG2(20, i); 16 } 17 Target 0: (a.out) stopped. (lldb) p i (int *) $0 = 0x0000000100404080 (lldb) p *i (int) $1 = 0 (lldb) n Process 71421 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0000000100000eb4 a.out`CG1 at test2.c:15:8 12 // int i = 10; 13 int* i = malloc(sizeof(int)); 14 *i = 10; -> 15 goto CG2(20, i); 16 } 17 18 int main(){ Target 0: (a.out) stopped. (lldb) p *i (int) $2 = 10 (lldb) p i (int *) $3 = 0x0000000100404080 (lldb) s Process 71421 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step in frame #0: 0x0000000100000ec0 a.out`CG1 at test2.c:16:1 13 int* i = malloc(sizeof(int)); 14 *i = 10; 15 goto CG2(20, i); -> 16 } 17 18 int main(){ 19 goto CG1(); Target 0: (a.out) stopped. (lldb) s Process 71421 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step in frame #0: 0x0000000100000ec1 a.out`CG1 at test2.c:15:8 12 // int i = 10; 13 int* i = malloc(sizeof(int)); 14 *i = 10; -> 15 goto CG2(20, i); 16 } 17 18 int main(){ Target 0: (a.out) stopped. (lldb) s Process 71421 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step in frame #0: 0x0000000100000e47 a.out`CG2(i=1, str=0x0000000000000000) at test2.c:5:27 2 #include 3 4 -> 5 __code CG2(int i,int* str){ 6 printf("i = %d\n", i); 7 printf("str = %d\n",*str); 8 } Target 0: (a.out) stopped. (lldb) n Process 71421 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0000000100000e56 a.out`CG2(i=20, str=0x0000000100404080) at test2.c:6:3 3 4 5 __code CG2(int i,int* str){ -> 6 printf("i = %d\n", i); 7 printf("str = %d\n",*str); 8 } 9 Target 0: (a.out) stopped. (lldb) p i (int) $4 = 20 (lldb) p &i (int *) $5 = 0x00007ffeefbff0dc (lldb) p str (int *) $6 = 0x0000000100404080 (lldb) p &str (int **) $7 = 0x00007ffeefbff0d0 (lldb) p *str (int) $8 = 10 (lldb) exit Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] Y ichikitakahiro % pwd /Users/ichikitakahiro/workspace/cr/test_space ichikitakahiro % ls a.out a.out.dSYM test.c test.s test2.c test2.s tsts ichikitakahiro % cp test.c test3.c ichikitakahiro % cat test2.c | pbcopy ichikitakahiro % ls a.out test.c test2.c test3.c a.out.dSYM test.s test2.s tsts ichikitakahiro % history 9211 ./a.out 9212 vim test2.c 9213 vim test2.c 9214 $CBC_COMPILER -Wall -O0 -g test2.c 9215 lldb a.out 9216 vim test2.c 9217 $CBC_COMPILER -Wall test2.c 9218 $CBC_COMPILER -Wall -O0 -g test2.c 9219 ./a.out 9220 vim test2.c 9221 lldb a.out 9222 pwd 9223 ls 9224 cp test.c test3.c 9225 cat test2.c | pbcopy 9226 ls