acidã¾ãç¥è
acidã¯acmeãã使ã
ãgdb豆知識ãã§ããgdbãemacsãã使ãã®ãæ£ãã姿ã説ãèªããã¦ãããPlan9ã®å ´åãç¹å¥ãªé£æºããªããã¦ãããããããªããã©ãããã§ã¯ãacidãacmeãã使ãã¨ä¾¿å©ãã¨ãã話ãæ¸ããã¨æããå ·ä½çã«ã¯ãã¹ã¿ãã¯ãã¬ã¼ã¹ããã¨ã次ã®ããã«ã¢ãã¬ã¹ã¨ä¸ç·ã«ã½ã¼ã¹ã®ãã¡ã¤ã«åã¨è¡çªå·ã表示ãããã
acid: stk() pread()+0x7 /sys/src/libc/9syscall/pread.s:5 read(fd=0x4,buf=0x2f428,n=0x200)+0x2f /sys/src/libc/9sys/read.c:7 Read(fd=0x4,buf=0x2f428,cnt=0x200)+0x1f /sys/src/cmd/rc/plan9.c:500 emptybuf(f=0x2f418)+0x2a /sys/src/cmd/rc/io.c:250 rchr(b=0x2f418)+0x19 /sys/src/cmd/rc/io.c:71 getnext()+0x54 /sys/src/cmd/rc/lex.c:68 nextc()+0x10 /sys/src/cmd/rc/lex.c:35 yylex()+0x8 /sys/src/cmd/rc/lex.c:179 yylex1()+0x8 /sys/src/cmd/rc/syn.y:224 yyparse()+0xa7e /sys/src/cmd/rc/syn.y:316 Xrdcmds()+0x75 /sys/src/cmd/rc/exec.c:838 main(argc=0x1,argv=0x7fffefb4)+0x349 /sys/src/cmd/rc/exec.c:184 _main+0x31 /sys/src/libc/386/main9.s:16
ããã§ã©ãã§ã好ããªãã¡ã¤ã«åãå³ã¯ãªãã¯ããã°ã該å½ããç®æã®ã½ã¼ã¹ã³ã¼ãã表示ããããä¸ã®ã¹ã¯ãªã¼ã³ã·ã§ãããacmeã®ã¦ã£ã³ãã¦ã§å·¦ã®ã«ã©ã ã§acidãå®è¡ãã¦ãããå³ã®ã«ã©ã ã«å¯¾å¿ããã½ã¼ã¹ã³ã¼ãã表示ããã¦ãããããã ãã®ããã§ãacidãacmeãã使ãæ¹ã便å©ãéã«ç´ ã§ä½¿ãå©ç¹ã¯æãæµ®ãã°ãªã*1ã
ã³ã³ãã¤ã«æã®ãªãã·ã§ã³
kenccã«ã¯-gãªãã·ã§ã³ãªãã¦ãªãã®ã§ãæ°ã«ããå¿ è¦ã¯ãªããåçç¡ç¨ã§ãããã°æ å ±ãä»ãã¦æ¥ãã
acidã®èµ·åæ¹æ³
acmeããèµ·åããå ´åã¯ãwinã³ãã³ãã§ã·ã§ã«ãèµ·åãã¦*2ãacidãå®è¡ããã
$ acid /bin/ls /bin/ls:386 plan 9 executable /sys/lib/acid/port /sys/lib/acid/386
å®è¡ã®éå§
ã³ãã³ãã©ã¤ã³å¼æ°ãprogargså¤æ°ã«è¨å®ããnew()ã§ããã»ã¹ãèµ·åãããnew()ã¯mainé¢æ°ã®å é ã§åæã«æ¢ã¾ãã
acid: progargs="/" acid: new() 3508350: system call _main SUBL $0x48,SP 3508350: breakpoint main+0x3 MOVL $bin(SB),AX
ãã¬ã¼ã¯ãã¤ã³ãã®è¨å®
bpset()ã§ãã¬ã¼ã¯ãã¤ã³ããè¨å®ããbpdel()ã§åé¤ãããbptab()ã§ãã¬ã¼ã¯ãã¤ã³ãä¸è¦§ã表示ããã
acid: bpset(ls) acid: bptab() 0x000012c7 ls SUBL $0x28,SP
å®è¡ã®åéã¯cont()ããã¬ã¼ã¯ãã¤ã³ãã¾ã§å®è¡ãé²ãã
acid: cont() 3508350: breakpoint ls SUBL $0x28,SP
PCãæãã¦ããã¢ãã¬ã¹ã®ã½ã¼ã¹ã³ã¼ããè¦ãããã°src()ã
acid: src(*PC) /sys/src/cmd/ls.c:87 82 output(); 83 exits(errs? "errors" : 0); 84 } 85 86 int >87 ls(char *s, int multi) 88 { 89 int fd; 90 long i, n; 91 char *p; 92 Dir *db;
regs()ã§ã¬ã¸ã¹ã¿ã®å¤ãããã
acid: regs() PC 0x00001023 main+0x3 /sys/src/cmd/ls.c:53 SP 0x7fffef40 ECODE 0x80100429 EFLAG 0x00000202 CS 0x00000023 DS 0x0000001b SS 0x0000001b GS 0x0000001b FS 0x0000001b ES 0x0000001b TRAP 0x00000003 exception 3 AX 0x7fffefb4 BX 0x7fffbce5 CX 0x7fffcd6c DX 0x00000004 DI 0x00033130 SI 0x00000000 BP 0x7fffbc58
ã¨ããã§ãnewãregsã®å¾ã®æ¬å¼§ã¯ä½ã ï¼é¢æ°ã£ã½ããã¨æã£ã人ã¯ããã©ããacidã¯åãªããããã¬ã«ã¨ã©ã¾ããªããè¨èªå¦çç³»ã ã¨ãè¨ãããnew()ãregs()ãã¹ã¿ãã¯ãã¬ã¼ã¹ã®stk()ãªã©ãå¤ãã®æ©è½ã¯acidæ¬ä½ã«çµã¿è¾¼ã¾ãã¦ããããã§ã¯ãªããå¤é¨ã©ã¤ãã©ãªï¼ã¹ã¯ãªããï¼ã¨ãã¦å®ç¾ããã¦ããããã®è¾ºã®è©±ã¯ãacid(1)ãããtrussライブラリããåç §ããããã
ã¡ãªã¿ã«Plan9ã§ã¯ãã¬ã¸ã¹ã¿ã¯ãã¼ã¿ã»ã°ã¡ã³ãã®ç¹å®ã®ã¢ãã¬ã¹ã«ãããã³ã°ããã¦ãããä¾ãã°ãPCï¼ããã°ã©ã ã«ã¦ã³ã¿ï¼ã¯ã0x38ã«ãããã³ã°ããã¦ããããã®ããgdbã®ããã«ã¬ã¸ã¹ã¿ãåç §ããã¨ãã«$ããã¬ãã£ãã¯ã¹ããå¿ è¦ã¯ãªããä»ã®ã·ã³ãã«ã¨åæ§ã«æ±ããï¼å¤æ°ã®åç §ãåæ§ã«$ããã¬ãã£ãã¯ããå¿ è¦ããªããacidã®ã·ã³ã¿ãã¯ã¹ã¯ã·ã§ã«ã§ã¯ãªãCã£ã½ãï¼ãã¢ãã¬ã¹xã«æ ¼ç´ãããå¤ãåç §ããã¨ãã¯*xã¨æ¸ãã
acid: PC 0x00000038 acid: *PC 0x00001023
å¤æ°ã®ãã©ã¼ããã
ãã¡ããå¤æ°ã®ãã©ã¼ããããæå®ãã¦ã表示ã§ãããä¾ãã°ãé¢æ°mainã®å é ã®å½ä»¤ã調ã¹ããã¨ãèãã¦ã¿ãããæ£ç¢ºã«ã¯*fmt(x, 'i')ã¨æ¸ãã®ã ãã©ãx\iãã·ã³ã¿ãã¯ã¹ã·ã¥ã¬ã¼ã«ãªã£ã¦ããã®ã§ãé常ã¯ãã¡ãã使ãã°ããã
acid: main 0x00001020 acid: *fmt(main, 'i') SUBL $0x24,SP acid: main\i SUBL $0x24,SP
ãã¨ä½¿ãã®ã¯ããããªã¨ããï¼
acid: print("hex=", 65\x, " dec=", 65\d, " oct=", 65\o, " char=", 65\c) hex=0x0041 dec=65 oct=000000000101 char=A
対å¿ãã¦ãããã©ã¼ãããã¯æ¬¡ã®éãã
8-bit integer: c (char), C (char or decimal), b (unsigned hex)
16-bit integer: r (Rune), x (hex), d (decimal), u (unsigned), o (octal), q (signed octal)
32-bit integer: B (binary), X (hex), D (decimal), U (unsigned), O (octal), Q (signed octal)
64-bit integer: V (decimal), Y (unsigned hex), Z (unsigned)
address-sized integer (pointer): a or A (symbol), W (hex)
string: s (NUL-terminated chars), R (NUL-terminated Runes)
machine instruction: i (Plan 9 syntax), I (alternate syntax)
floating point: f, g (32-bit), F, G (64-bit), 3, 8 (80-bit)
ã¹ã¿ãã¯ã®èª¿æ»
gdbï¼adbã§ãidbã§ããããã©ï¼ã ã¨ãframeãupãdownãªããã使ã£ã¦ã¹ã¿ãã¯ãã¬ã¼ã ãå·»ãæ»ããå¤æ°ã®å¤ã調ã¹ããã©ãacidã«åçã®æ©è½ã¯ç¨æããã¦ããªãã
ã§ã¯ãã©ããã¦ãããã¨ããã¨ãlstk()ã§ã¹ã¿ãã¯ä¸ã®ãã¼ã«ã«å¤æ°ã®å¤ã表示ãããã¨ãã§ãããã¾ãã*func:varã¨æ¸ãã°ã¹ã¿ãã¯ãã¬ã¼ã ã®æå funcå ã®å¤æ°varã®å¤ãåç §ã§ãããããã¯ãããã°ã¹ã¿ã¤ã«ã«é¢ããã®ã§ãããªãæ¸æããæ £ãã®åé¡ãªã®ããªãï¼
acid: lstk() ls(s=0xda95,multi=0x0)+0x0 /sys/src/cmd/ls.c:87 db=0x4d fd=0x0 n=0x51 main(argv=0x7fffefb8,argc=0x0)+0xb9 /sys/src/cmd/ls.c:79 _argc=0x0 _args=0x0 i=0x0 _main+0x31 /sys/src/libc/386/main9.s:16
çµäº
çµäºã¯deleteãããªãã¦ctrl-dããããå¿ããã¨ã·ã§ã«ã«æ»ããªããªã£ã¦å°ãã
ï¼ãã¾ãï¼ä½¿ã£ããã¨ã®ãªãã³ãã³ã
æ®æ®µä½¿ãã³ãã³ãã¯æ±ºã¾ã£ã¦ãã¦ã大åã®ã³ãã³ãã¯åå¨ããç¥ããªãã
*1:ã¡ãªã¿ã«gdbã®å ´åãï¼Emacsããå®è¡ããªãã¦ãï¼ctrl-a/Aã§è©²å½é¨åã®ã½ã¼ã¹ã³ã¼ããåç §ã§ãããã¨ãç¥ã£ã¦ããã¨å½¹ã«ç«ã¤ãããããªãã
*2:ã¦ã£ã³ãã¦ã®ã©ãã§ãããã®ã§winã¨æã¡è¾¼ãã§ããããä¸å¤®ã¯ãªãã¯ã