gdbÔõÑùµ÷ÊÔ gdbµ÷ÊÔµÄ×¢ÖØÊÂÏî
ʹÓà gdb µ÷ÊÔ c/c++ ³ÌÐòʱ£¬Çë×¢ÖØ£º±àÒë³ÌÐòʱʹÓà -g Ñ¡ÏÉèÖ÷ûºÅ·¾¶£¬²¢ÆôÓà core dump¡£µ÷Ê԰취Ϊ£ºÆô¶¯ gdb£¬¼ÓÔØ¿ÉÖ´ÐÐÎļþ£¬ÉèÖöϵ㣬ÔËÐгÌÐò£¬Öð²½Ö´ÐУ¬¼ì²é±äÁ¿£¬¼ì²éŲÓÿÍÕ»£¬Í˳ö gdb¡£
gdb µ÷ÊÔ
GDB£¨GNU µ÷ÊÔÆ÷£©ÊÇÒ»¸öÊ¢ÐÐÇÒÇ¿Ê¢µÄ¹¤¾ß£¬ÓÃÓÚµ÷ÊÔ C ºÍ C++ ³ÌÐò¡£Ëü¿ÉÒÔ×ÊÖúÄúʶ±ð¹ýʧ¡¢¸ú×Ù³ÌÐòÖ´Ðкͼì²é±äÁ¿Öµ¡£
gdb µ÷ÊÔµÄ×¢ÖØÊÂÏî
ÔÚʹÓà gdb µ÷ÊÔ³ÌÐòʱ£¬Çë×¢ÖØÒÔÏÂÊÂÏ
- ʹÓõ÷ÊÔÐÅÏ¢±àÒë³ÌÐò£ºÊ¹Óà -g Ñ¡Ïî±àÒë³ÌÐò£¬ÒÔ±ã gdb ¿ÉÒÔ»á¼ûµ÷ÊÔÐÅÏ¢¡£
- ÆôÓà core dump£ºÔÊÐí³ÌÐòÔÚÍß½âʱÌìÉú core dump£¬ÒÔ×ÊÖú gdb Õï¶ÏÎÊÌâ¡£
- ÉèÖ÷ûºÅ·¾¶£º¼û¸æ gdb ¿ÉÒÔÔÚÄÇÀïÕÒµ½³ÌÐòµÄ·ûºÅÎļþ¡£
- ʹÓöϵ㣺ÔÚ´úÂëÖÐÉèÖöϵãÒÔÔÚÌض¨µã×èÖ¹³ÌÐòÖ´ÐС£
- ¼ì²é±äÁ¿£ºÊ¹Óà print ºÍ watch ÏÂÁî¼ì²é±äÁ¿µÄÖµºÍת±ä¡£
- ŲÓÿÍÕ»£ºÊ¹Óà bt ºÍ backtrace ÏÂÁîÏàʶº¯ÊýŲÓÿÍÕ»¡£
- Öð²½Ö´ÐгÌÐò£ºÊ¹Óà step¡¢next ºÍ continue ÏÂÁîÖð²½Ö´ÐгÌÐò¡£
- ÇëÎñ±ØʹÓÃ×ÊÖúϵͳ£ºgdb ÌṩÁËÆÕ±éµÄ×ÊÖúÎĵµ£¬¿ÉÒÔͨ¹ý help ÏÂÁî»á¼û¡£
Ïêϸ°ì·¨
- Æô¶¯ gdb£ºÔÚÖÕ¶ËÖÐÔËÐÐ gdb ÏÂÁî²¢Ö¸¶¨Òªµ÷ÊԵijÌÐò×÷Ϊ²ÎÊý¡£
- ¼ÓÔØ¿ÉÖ´ÐÐÎļþ£ºÊ¹Óà file ÏÂÁî¼ÓÔØ¿ÉÖ´ÐÐÎļþ¡£
- ÉèÖöϵ㣺ʹÓà break ÏÂÁîÔÚ´úÂëÖÐÉèÖöϵ㡣
- ÔËÐгÌÐò£ºÊ¹Óà run ÏÂÁîÔËÐгÌÐò¡£
- Ö´ÐÐÖð³ÌÐòÊÔ£ºÊ¹Óà step »ò next ÏÂÁîÖð²½Ö´ÐгÌÐò¡£
- ¼ì²é±äÁ¿£ºÊ¹Óà print ÏÂÁî¼ì²é±äÁ¿µÄÖµ¡£
- ¼ì²éŲÓÿÍÕ»£ºÊ¹Óà bt »ò backtrace ÏÂÁîÉó²éŲÓÿÍÕ»¡£
- Í˳ö gdb£ºÍ˳ö gdb£¬ÇëʹÓà quit ÏÂÁî¡£
ÒÔÉϾÍÊÇgdbÔõÑùµ÷ÊÔ gdbµ÷ÊÔµÄ×¢ÖØÊÂÏîµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡
ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£