gdb hacks 第 6 åãåå㯠IA-32 㧠gdb ããããã°ã¬ã¸ã¹ã¿ãã©ã®ããã«æ´»ç¨ãã¦ããããè¦ã¾ãããä»åã¯ãããã°ã¬ã¸ã¹ã¿ãããã»ã¹ãèªåèªèº«ã§å©ç¨ããæ¹æ³ã«ã¤ãã¦èãã¦ã¿ã¾ãã IA-32 ã®ãããã°ã¬ã¸ã¹ã¿ DR0-DR7 ã¸ã®ã¢ã¯ã»ã¹ã¯ããªã¢ã«ã¢ã¼ãã¾ãã¯ç¹æ¨©é ä½ 0 ã®ãããã¯ãã¢ã¼ãã§ãã許ããã¦ãã¾ãããLinux ã§ã¯ ptrace ã·ã¹ãã ã³ã¼ã«ã使ã£ã¦ã«ã¼ãã«ã«èªã¿æ¸ããã¦ããããã¨ã«ãªãã¾ãã ããããªããããã»ã¹ã¯èªåèªèº«ã«å¯¾ã㦠ptrace ãããã¨ã¯ã§ãã¾ãããããã§ãèªåã®ãããã°ã¬ã¸ã¹ã¿ã«ã¢ã¯ã»ã¹ãããå ´å㯠fork ã使ã£ã¦åããã»ã¹ã« ptrace ããã¦ãããã¾ãã ã¨ãããããããã°ã¬ã¸ã¹ã¿ã«å¤ãè¨å®ããé¢æ°ãæ¸ãã¦ã¿ã¾ã (ã¨ã©ã¼ãã§ãã¯ãªã©ã¯ãããããã§ãã®ã§æ³¨æãã¦ãã ãã)ã #include <sys/user.h>
gdb hacks 第 5 åãããã»ããµã®ä¸ã«ã¯ãããã°æ¯æ´æ©è½ããã¼ãã¦ã§ã¢ã§æã¤ãã®ããããä¾ãã° IA-32 ã¢ã¼ããã¯ãã£ã§ã¯ 8 æ¬ã®ãããã°ã¬ã¸ã¹ã¿ (DR0-DR7) ã¨ãããã®ãç¨æããã¦ãã¾ããgdb ã¯ãããã©ã®ããã«ä½¿ç¨ãã¦ããããè¦ã¦ã¿ã¾ãã IA-32 ã®ãããã°æ©è½ã«ã¤ãã¦ã¯ Intel ã®ããã¥ã¢ã« IA-32 Intel® Architecture Software Developer's Manual, Volume 3B: System Programming Guide, Part 2 ã® CHAPTER 18 Debugging and Performance Monitoring ã«å®å ¨ãªè§£èª¬ãããã¾ãã ã¯ããã£ã¦èª¬æããã¨ãDR0-DR3 ã® 4 ã¤ã®ã¬ã¸ã¹ã¿ã§æå®ãããªãã¢ã¢ãã¬ã¹ã®ç¤ºãã¡ã¢ãªé åã«ããã»ããµã®ã¢ã¯ã»ã¹ãããã¨ãINT 1
gdb hacks 第 4 åãåå㯠gdb é»åã§ä½¿ããããã«ãªã£ãæ°å¦é¢æ°ã®ãã£ãæªãã«ã¤ãã¦ä¸æºãè¿°ã¹ã¾ãããããããä¸é¨è§£æ±ºããæ¹æ³ãæãã¤ããã®ã§ã¾ã¨ãã¦ããã¾ãã å½å㯠sqrt ã¨ãã£ãé¢æ°ã·ã³ãã«ã«æ°ããªåæ å ±ãè¨å®ããæ¹æ³ãããã®ã§ã¯ãªããã¨æããgdb ã®ã½ã¼ã¹ãªã©ã調ã¹ã¦ããã®ã§ãããã©ãããããªé½åã®ããæ¹æ³ã¯ãªããããªã®ã§ãããããã¦å¥ã®æ¹æ³ãèãã¾ããã gdb ã§ã¯ convenience variable ã¨ãã $ ã§å§ã¾ãä»»æã®ååã®å¤æ°ã使ããã¨ãã§ãã¾ãã®ã§ãããã«é¢æ°ã·ã³ãã«ã®ã¢ãã¬ã¹ãé¢æ°ãã¤ã³ã¿åã§ãã£ã¹ããã¦ä»£å ¥ãã¦ã¿ã¾ãã (gdb) set $sqrt = (double (*)(double)) sqrt (gdb) set $pow = (double (*)(double, double)) pow (gdb) ptype $s
gdb hacks 第 3 åãä»åã¯ä»¥ä¸ã®ãããã¯ãæ±ãã¾ãã gdb ãé»åã®ä»£ããã«ä½¿ã gdb ãæ±ãã·ã³ãã«ã®åæ å ± çè 㯠gdb ãé»å代ããã«ãã使ã£ã¦ãã¾ãã以ä¸ã®ããã«åºåãã©ã¼ããããæ軽ã«æå®ã§ãããã¨ãC ã®è¡¨ç¾å¼ããã®ã¾ã¾ä½¿ãããã¨ãåã®è¨ç®çµæãç°¡åã«åç §ã§ãããã¨ãªã©ãä»ã®é»åããã°ã©ã ã«ã¯ãªãé åãããã¾ããbc ã irb ã¨æ¯è¼ãã¦ã gdb ã¯ããããã°ã©ãåãã®é»åãªã®ã§ã¯ãªããã¨æãã¾ãã % gdb (gdb) p 123+456+789 $1 = 1368 (gdb) p 123+0456+0x789 $2 = 2354 (gdb) p/o $2 $3 = 04462 (gdb) p/x $3 $4 = 0x932 (gdb) p/t $4 $5 = 100100110010 (gdb) p/x 'a' $6 = 0x61 (gdb) p/c
gdb hacks 第 2 åãä»åã¯ä»¥ä¸ã®ãããã¯ãæ±ãã¾ãã gdb ãé¢æ°ã®å¼ã³åºãã§ã¿ã¼ã²ããããã»ã¹ä¸ã«ä½æãããã¼ã¿æ§é gdb ã¨ã¿ã¼ã²ããããã»ã¹ã¨ã®éä¿¡ã観å¯ããæ¹æ³ ãµã³ãã«ãããã°ã»ãã·ã§ã³ã®ãã°ã gdb_target_debug.txt ã«ç¨æãã¦ãã¾ãã®ã§åç §ãã¦ãã ãããå®é¨ç°å¢ã¯ä¾ã«ãã£ã¦ i386 ã® Debian GNU/Linux (sid) ã§ãã gdb ã¨ã¿ã¼ã²ããããã»ã¹ã¨ã®ããã¨ãã¯ã以ä¸ã®ããã« 3 ã¤ã»ã©ãããã°ã¹ã¤ãããæå¹ã«ããã¨è¦³å¯ãããã¨ãã§ãã¾ã (infrun ãããã°ã¹ã¤ãã㯠gdb 6.4 以éãã使ãã¾ã)ã 119 (gdb) set debug target 1 120 (gdb) set debug infrun 1 121 (gdb) set debug lin-lwp 1 122 (gdb) p chdir(
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}