åæžã
Diablo IVã§äœæ¥ãããšãã¯ããã¹ãŠã®ã³ãŒããWindowsã§èšè¿°ããŠãããããŸããŸãªãã©ãããã©ãŒã çšã«ã³ã³ãã€ã«ããŸããããã¯ãLinuxãå®è¡ãããµãŒããŒã«ãåœãŠã¯ãŸããŸãã ïŒã³ãŒãã«ã¯æ¡ä»¶ä»ãã³ã³ãã€ã«ãã£ã¬ã¯ãã£ããå«ãŸããŠãããå¿ èŠã«å¿ããŠãç¹å®ã®ãã©ãããã©ãŒã çšã«ç¹å¥ã«èšè¿°ããããã©ã°ã¡ã³ããå«ãŸããŠããŸããïŒç§ãã¡ã®äœæ¥ã¯å€ãã®çç±ã§ãã®ããã«æ§æãããŠããŸããæå§ãã«ãç§ãã¡ã®ããŒã ã®äž»èŠãªå°éã¹ãã«ã¯Windowsã§ããç§ãã¡ã®ãµãŒããŒããã°ã©ããŒã§ãããWindowséçºã«æã粟éããŠããŸããããŒã ã®ãã¹ãŠã®ããã°ã©ããŒãåãããŒã«ãšåãç¥èããŒã¹ã䜿çšã§ããããšãé«ãè©äŸ¡ããŠããŸãã
Windowsã§éçºãè¡ããã1ã€ã®æãéèŠãªçç±ã¯ãVisualStudioãæäŸããé«æ©èœã§ä¿¡é Œæ§ã®é«ãããŒã«ã»ãããå©çšã§ããããšã§ãããããŠãLinuxã§äœããéçºããŠãããšããŠããLinuxã®äžçã«ã¯VisualStudioãšæ¯èŒã§ãããã®ã¯äœããªããšèšããŸãã
確ãã«ããã®ããããµãŒããŒãã¯ã©ãã·ã¥ãããšãã«çºçããããã€ãã®åé¡ã«çŽé¢ããã¡ã¢ãªãã³ãããããã°ããå¿ èŠããããŸãã倱æããä»®æ³ãã·ã³ïŒããæ£ç¢ºã«ã¯ã³ã³ããïŒã«ãªã¢ãŒãã§ãã°ã€ã³ããæ©èœããããŸããgdbãå®è¡ããŠãäœãèµ·ãã£ãã®ãã調ã¹ãããšãã§ããŸãããããããã®ã¢ãããŒãã«ã¯å€ãã®æ¬ ç¹ããããŸããããšãã°ããœãŒã¹ã³ãŒããšäžç·ã«ãã€ããªããããã€ããŸããããã®çµæãä»®æ³ãã·ã³ãŸãã¯ã³ã³ãããæäœããå ŽåããœãŒã¹ã³ãŒãã¯gdbã»ãã·ã§ã³ã§äœ¿çšã§ããŸããã
ãã1ã€ã®åé¡ã¯ãgdbèªäœã«ãããŸããäºå®ããã®ããŒã«ãå®æçã«äœ¿çšããªããšãèªåã«åã£ãã¬ãã«ã§ç¿åŸããããšãã§ããŸãããç°¡åã«èšãã°ãéçºè ã¯äœ¿ãæ £ããããŒã«ã䜿çšããŠã³ãŒãããããã°ããããšãããšããªãã§ãããã gdbãããç¥ã£ãŠããéçºè ã¯2ã3人ã ããªã®ã§ãåé¡ãçºçããå Žåã¯ãéçºè ãåé¡ãæ¢ããŸãããããŠãããã¯ããã°ã©ããŒã«ãšã£ãŠã¯ãŒã¯ããŒãã®æé©ãªåæ£ãšã¯èšããŸããã
ç§ãã¡ã¯åžžã«ãçŽæçãªLinuxã³ãŒãããããã°ããæ¹æ³ãèŠã€ããããšæã£ãŠããŸããããã®ããã䜿ãæ £ããç°å¢ã§ãã®åé¡ãæ£ç¢ºã«è§£æ±ºã§ããæ°ããVisualStudioæ©èœã䜿çšã§ããããšã«ãšãŠãè奮ããŠããŸãããããŠããã®ãããã§ç§ãã¡ã®å€¢ãå®çŸãããšèšã£ãŠãéèšã§ã¯ãããŸããã
ã³ãŒãã®ãããã°ããã»ã¹ã«ã€ããŠ
Visual Studioã§ã®Linuxã³ãŒãã®ãããã°ã¯ãLinuxçšã®Windowsãµãã·ã¹ãã ïŒWSLïŒãã·ã¹ãã ã«ã€ã³ã¹ããŒã«ãããŠããå ŽåããŸãã¯Linuxãžã®æ¥ç¶ãæ¥ç¶ãããŒãžã£ãŒã§æ§æãããŠããå Žåã«ã®ã¿å¯èœ ã§ãããã¹ãŠã®ããã¯ãšã³ãéçºè ã¯ããããžã§ã¯ãããããã€ãããã£ã¹ããªãã¥ãŒã·ã§ã³ã䜿çšããŠWSLãã€ã³ã¹ããŒã«ããŠããŸããç§ãæžããã¹ã¯ãªãããå®è¡ããŠãWSLã§ãµãŒããŒãæ§ç¯ããããã«å¿ èŠãªãã¹ãŠã®éçºããŒã«ãšãµããŒãã©ã€ãã©ãªãã€ã³ã¹ããŒã«ããŸãã
ïŒã¡ã€ã³ãããã¯ããå°ãé¢ããŸããWSLã¯ãéçºè ãLinuxãã«ãã®å€æŽããã¹ãã§ãããçŸåããæé«ã®ç°å¢ã§ãããšããçµè«ã«éããããšã匷調ããããšæããŸãããã®äœæ¥ã¹ããŒã ã¯éåžžã«äŸ¿å©ã«èŠããŸãã WSLã«åãæ¿ããã³ãã³ã
cd
ãäœ¿çš ããŠå ±æã³ãŒããã£ã¬ã¯ããªã«ç§»åããããããçŽæ¥ãããžã§ã¯ãããã«ãããŸããããã¯ãä»®æ³ãã·ã³ãã³ã³ããã䜿çšãããããã¯ããã«åªãããœãªã¥ãŒã·ã§ã³ã§ããCMakeã䜿çšããŠãããžã§ã¯ãããã«ãããå Žåã¯ã次ã䜿çšããããšãã§ããŸããWSLã®çµã¿èŸŒã¿ VisualStudioãµããŒããïŒ
ç§ãã¡ã®ã¢ã»ã³ããªã«ã€ããŠå°ãã話ãããŸããç§ãã¡ã¯Windowsã§ã³ãŒããéçºãããã®OSã§åäœããããã«èšèšããããµãŒããŒã®WindowsããŒãžã§ã³ãæã£ãŠããŸããããã¯ãéåžžã®ãããžã§ã¯ãæ©èœã§äœæ¥ãããšãã«åœ¹ç«ã¡ãŸãããã ãããµãŒããŒåŽã®ã³ãŒããLinuxã«ãããã€ããŠãããããLinuxã§ã®ãã«ããå¿ èŠã§ãã Linuxã¢ã»ã³ããªã¯ããã«ããã¡ãŒã ã§äœæãããŸãã Linuxã³ã³ãã¥ãŒã¿ãŒã§å®è¡ããããã«ãã·ã¹ãã ã䜿çšããŸãããã®å©ããåããŠããµãŒããŒãããžã§ã¯ããšå¯Ÿå¿ããã³ã³ãããŒãçµã¿ç«ãŠãããåŸã§ãããã€ãããŸãã Linuxãã€ããªã¯ãã³ã³ããã«ã®ã¿ãããã€ãããŸããéåžžãéçºè ã¯ãããã®ã³ã³ããã«ã¢ã¯ã»ã¹ã§ããŸããã
ã€ã³ãã©ã¹ãã©ã¯ãã£å ã®ãµãŒããŒã®1ã€ã«é害ãçºçãããšãç¹å¥ãªã¹ã¯ãªããã«ãã£ãŠãããéç¥ãããŸãããã®åŸããã³ããã¡ã€ã«ãå ±æãããã¯ãŒã¯ãã©ã«ããŒã«æžã蟌ãŸããŸãã LinuxãŸãã¯VisualStudioã§ãããã®ãã¡ã€ã«ããããã°ããã«ã¯ãåäœããããã°ã©ã ãå¿ èŠã§ãããããã°ãããšãã¯ããããã€ãããã³ã³ããã§äœ¿çšãããŠãããã®ãšãŸã£ããåãå ±æã©ã€ãã©ãªã䜿çšãããšäŸ¿å©ã§ãããããã®ãã¡ã€ã«ãååŸããã«ã¯ãå¥ã®ã¹ã¯ãªããã䜿çšããŸãããŸãããã³ããããŒã«ã«ãã·ã³ã«ã³ããŒããŠãããã¹ã¯ãªãããå®è¡ããŠããã®ãã³ãã«é¢ããæ å ±ãæž¡ããŸããã¹ã¯ãªããã¯ããã¹ããããããŒãžã§ã³ã®ã³ãŒãçšã«ãã«ããããDockerã³ã³ãããŒãããŠã³ããŒããããããããµãŒããŒã®å®è¡å¯èœãã¡ã€ã«ãšç¹å®ã®äžè¬çãªã©ã³ã¿ã€ã ã©ã€ãã©ãªãæœåºããŸããããã¯ãã¹ãŠgdbã«å¿ èŠã§ãã ïŒããã¯ãgdbã䜿çšããå Žåã次ã®å Žåã«çºçããå¯èœæ§ã®ããäºææ§ã®åé¡ãåé¿ããŸãã·ã¹ãã ã®WSLããŒãžã§ã³ããããã€ãããLinuxããŒãžã§ã³ãšå®å šã«åãã§ãªãå ŽåãïŒãããã°ã»ãã·ã§ã³ãèšå®ããã¹ã¯ãªããã¯ãã«ããŒã¿ãæžã蟌ã¿ãŸãã
~/.gdbinit
ãå ±æã©ã€ãã©ãªãã·ã¹ãã ã©ã€ãã©ãªã§ããããšã瀺ããŸãã
次ã«ãVisual Studioã«ç§»åããããã§æ¥œãã¿ãå§ãŸããŸãã WindowsããŒãžã§ã³ã®ãµãŒããŒçšã®ãã«ããœãªã¥ãŒã·ã§ã³ãããŠã³ããŒãããŠããŸãã次ã«ãã³ãã³ãã䜿çšããŠæ°ãããããã°ãã€ã¢ãã°ãéã
Debug -> Other Debug Targets -> Debug Linux Core Dump with Native Only
ãŸãããã§ãã¯ããã¯ã¹
Debug on WSL
ããªã³ã«ããŠããã³ããã¡ã€ã«ãšãµãŒããŒãã€ããªïŒWSLã察象ãšããŠããŸãïŒïŒãžã®ãã¹ãå ¥åããŸãããã®åŸããã¿ã³
Debug
ãæŒã㊠äœãèµ·ãã£ãŠããããèŠãŠãã ããã
VisualStudioã§ãããã°ãéå§
ããVisualStudioã¯ãWSLã§gdbãèªåçã«èµ·åããŸããã·ã¹ãã ããã°ããã®éãã£ã¹ã¯ãæäœããåŸã倱æããããã°ã©ã ã®ã³ãŒã«ã¹ã¿ãã¯ã衚瀺ãããåœä»€ãã€ã³ã¿ã察å¿ããã³ãŒãè¡ã«èšå®ãããŸããããã¯æ¬åœã«åæ¢ãªæ°ããäžçã§ãïŒ
次ã«ãé害èªäœã®ç¹å®ã«ã€ããŠèª¬æããŸããé©åãªã€ãã³ããã€ã³ã¿ãŒã»ããããŠããã€ãã®ãµãŒãã¹æé ãå®è¡ãããã©ãŒã«ããã³ãã©ãŒããããŸãããããã£ãŠãé害èªäœã«é¢ããæ å ±ã¯ãã·ã³ã°ã«ã¹ã¬ãããµãŒããŒã®ã³ãŒã«ã¹ã¿ãã¯ã®ããæ·±ãå Žæã«ãããŸãããã ããäžéšã®ãµãŒããŒã¯ãã«ãã¹ã¬ããåãããŠããŸãããŸããã¯ã©ãã·ã¥ã¯ã©ã®ã¹ã¬ããã§ãçºçããå¯èœæ§ããããŸããé害ãã³ãã©ãŒã¯ãé害ã®ãããã¡ã€ã«ã®ã³ãŒããšè¡çªå·ã«é¢ããæ å ±ããã°ã«èšé²ããŸãããããã£ãŠããã®ããŒã¿ã調ã¹ããšãæåã®æããããåŸãããŸãããã®ã³ãŒãã®å®è¡ã«å¯Ÿå¿ããã³ãŒã«ã¹ã¿ãã¯å ã®å Žæãæ¢ããŠããŸãã
æãã€ãŸãæ°é±éåã¯ãgdbã䜿çšããŠãã¹ãŠã®ã¹ã¬ãããããã¯ãã¬ãŒã¹ããçµæã®ãªã¹ããã¹ãã£ã³ããŠãã³ãŒã«ã¹ã¿ãã¯ãã¯ã©ãã·ã¥ããå¯èœæ§ãæãé«ãã¹ã¬ãããèŠã€ããŠããŸãããããšãã°ãã¹ã¬ãããäŒæ¢ç¶æ ã«ãã£ãå Žåãããããã¯ã©ãã·ã¥ããŸããã§ãããã¹ãªãŒãç¶æ ã®ã¹ã¬ãããåŠçããŠãããã¬ãŒã ãšæ å ±ãæ°åãè¶ ããã¹ã¿ãã¯ãå¿ èŠã§ãã次ã«ãåé¡ãäœã§ããããç解ããããã«ãã³ãŒãã調ã¹ãå¿ èŠããããŸããåçŽãªãã®ã§ããã°ãã³ãŒãã§ããã«ç¢ºèªã§ããŸããããè€éãªåé¡ã«çŽé¢ããå Žåã¯ãgdbã®æ©èœãå©çšããŠããã»ã¹ã®ç¶æ ã調æ»ããå¿ èŠããããŸãã
ããããVisual Studioã¯ã以åãããã¯ããã«åŒ·åãªæ©èœãæäŸããŸãããã«ãã¹ã¬ããç°å¢ã§ã¯ããããã°ã»ãã·ã§ã³ã§ãŠã£ã³ããŠãéã
Threads
ãã¹ã¬ãããã¯ãªãã¯ããŠã¹ã¿ãã¯ã衚瀺ã§ããŸãããã ããããã¯gdbã§äœ¿çšãããã¢ãããŒããšéåžžã«ãã䌌ãŠããŸãããããã£ãŠãããšãã°50ã¹ã¬ãããåŠç¿ããå¿ èŠãããå Žåãããã¯ããªãæéã®ãããéå±ãªäœæ¥ã«ãªãå¯èœæ§ããããŸãã幞ããVisual Studioã«ã¯ããã®ã¿ã¹ã¯ãã¯ããã«ç°¡åã«ããããŒã«ããããŸããããã¯ParallelStacksãŠã£ã³ã㊠ã§ãã
確ãã«ãErica SweetãšåœŒå¥³ã®ããŒã ãParallel Stacksã«ã€ããŠæããŠããããŸã§ãç§ãã¡ã®ã»ãšãã©ã¯ParallelStacksã«ã€ããŠç¥ããŸããã§ããããããã°ã»ãã·ã§ã³äžã«ã³ãã³ããå®è¡ããå Žå
Debug -> Windows -> Parallel Stacks
-æ°ãããŠã£ã³ããŠãéãã調æ»äžã®ããã»ã¹ã®åã¹ã¬ããã®ã³ãŒã«ã¹ã¿ãã¯ã«é¢ããæ å ±ã衚瀺ãããŸããããã¯ãããã»ã¹ç©ºéå šäœã®é³¥ç°å³ã®ãããªãã®ã§ããä»»æã®ã¹ã¬ããã®ä»»æã®ã¹ã¿ãã¯ãã¬ãŒã ãããã«ã¯ãªãã¯ã§ããŸãããã®åŸãVisualStudioã¯ãœãŒã¹ã³ãŒããŠã£ã³ããŠãšã³ãŒã«ã¹ã¿ãã¯ãŠã£ã³ããŠã®äž¡æ¹ã§ãã®ãã¬ãŒã ã«ãžã£ã³ãããŸããããã¯ãæéãç¯çŽããã®ã«å€§ãã«åœ¹ç«ã¡ãŸãã
ã¯ã©ãã·ã¥ãµã€ãã®è¿ãã«ã³ãŒãã衚瀺ãããããããŠã¹ãQuickWatchããŸãã¯å€ãã®VisualStudioããŒã«ã®ããããã䜿çšããŠå€æ°ã調ã¹ãããšãã§ããŸãããã¡ããããªãªãŒã¹ãã«ãã§ã¯ãå€ãã®å€æ°ãæé©åãããŠããŸãããåæã«ãå€ãã¯æé©åãããŠããŸãããVisual Studioã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšãããšãgdbã䜿çšããåãããã¯ããã«é«éã«åé¡ãç¹å®ã§ããŸãã
çµæ
ç§ãã¡ã®ããŒã ã¯ãç§ãã¡ãéçºããŠããç°å¢ã§ããVisualStudioã§Linuxãã³ãããããã°ã§ããããšãå¬ããæããŸããç§ãã¡ã«ãšã£ãŠãããã¯å€§ããªæ¹åã§ããããã«ããããããŸã§ä»¥äžã«å€ãã®éçºè ãå®éã®åé¡ã蚺æã§ããããã«ãªããŸããããã«ãããç§ãã¡å šå¡ãVisualStudioã®åŒ·åãªãããã°ããŒã«ãå©çšã§ããããã«ãªããŸããäœæ¥ç°å¢ã®æºåãå®äºããããæåéãæ°åã§VisualStudioã®ãããã°ã»ãã·ã§ã³ã«åå ã§ããŸãããã®æ©èœã«ãããåé¡ã®çºèŠé床ãšäœæ¥ã®å¹çãå€§å¹ ã«åäžããŸãããšãªã«ãšåœŒå¥³ã®ããŒã ã®å©ãã«æè¬ããŸãã
Visual Studioã§æã圹ç«ã€ãã®ã¯äœã§ããïŒ