gdbµ÷ÊÔÏÂÁî
gdb µ÷ÊÔÏÂÁîÓÐÒÔϳ£ÓÃÏÂÁstart£ºÆô¶¯³ÌÐò²¢×îÏȵ÷ÊÔbreak£ºÉèÖöϵãrun£ºÔËÐе½¶Ïµã´¦next£ºÖ´ÐÐÏÂÒ»ÐдúÂëstep£º½øÈ뺯Êý²¢Ö´ÐеÚÒ»ÐдúÂëfinish£º¼ÌÐøÖ´ÐÐÄ¿½ñº¯Êý£¬Ö±µ½·µ»Øprint£º´òÓ¡±í´ïʽ»ò±äÁ¿µÄÖµ
gdb µ÷ÊÔÏÂÁî
gdb£¨GNU µ÷ÊÔÆ÷£©ÊÇÒ»¸öÇ¿Ê¢µÄ¹¤¾ß£¬ÓÃÓÚµ÷ÊÔ C/C++ ³ÌÐò¡£ËüÌṩÁËһϵÁÐÏÂÁ¿ÉÒÔ×ÊÖúÄúÉîÈëÆÊÎö³ÌÐòµÄÖ´ÐÐÀú³Ì¡£
³£ÓÃÏÂÁî
- start£ºÆô¶¯³ÌÐò²¢×îÏȵ÷ÊÔ¡£
- break£ºÔÚÖ¸¶¨ÐÐÉèÖöϵ㡣
- run£ºÖ´ÐгÌÐò²¢ÔËÐе½¶Ïµã´¦¡£
- next£ºÖ´ÐÐÏÂÒ»ÐдúÂë¡£
- step£º½øÈ뺯Êý²¢Ö´ÐеÚÒ»ÐдúÂë¡£
- finish£º¼ÌÐøÖ´ÐÐÄ¿½ñº¯Êý£¬Ö±µ½·µ»Ø¡£
- print£º´òÓ¡±í´ïʽ»ò±äÁ¿µÄÖµ¡£
- set£ºÉèÖûòÐ޸ijÌÐò±äÁ¿¡£
- watch£º¼àÊÓ±í´ïʽ»ò±äÁ¿µÄÖµµÄת±ä¡£
- backtrace£º´òÓ¡Ä¿½ñº¯ÊýŲÓÿÍÕ»¡£
¸ß¼¶ÏÂÁî
- disassemble£º·´»ã±à³ÌÐò´úÂë¡£
- info£ºÏÔʾ³ÌÐò»òµ÷ÊÔ״̬µÄÐÅÏ¢¡£
- location£ºÏÔʾĿ½ñº¯Êý»òÐкš£
- file£ºÇл»Ä¿½ñµ÷ÊÔÔ´Îļþ¡£
- script£ºÖ´ÐÐÍⲿ gdb ¾ç±¾¡£
- Python£ºÆôÓà Python ½»»¥Ä£Ê½¡£
Ó÷¨
ҪʹÓà gdb£¬ÇëÔÚÏÂÁîÐÐÖÐÊäÈëÒÔÏÂÏÂÁ
gdb [program-name] [arguments]
µÇ¼ºó¸´ÖÆ
ÀýÈ磬Ҫµ÷ÊÔÃûΪ “my_program” µÄ¶þ½øÖÆÎļþ£¬ÇëÔËÐÐÒÔÏÂÏÂÁ
gdb my_program
µÇ¼ºó¸´ÖÆ
gdb ½«Æô¶¯²¢¼ÓÔسÌÐò¡£È»ºó£¬Äú¿ÉÒÔʹÓÃÉÏÊöÏÂÁîÀ´µ÷ÊÔ³ÌÐò¡£
ÒÔÉϾÍÊÇgdbµ÷ÊÔÏÂÁîµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡
ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£