尊龙凯时人生就是博

ÏêϸÐÎògdbµ÷ÊÔ³ÌÐòµÄÈ«Àú³Ì

gdb µ÷ÊÔ³ÌÐòÈ«Àú³ÌÏê½â£ºÆô¶¯ gdb ²¢¶ÁÈë³ÌÐò£¨file ÏÂÁ¡£ÉèÖöϵ㣨break ÏÂÁ¡£ÔËÐгÌÐò£¨run ÏÂÁ¡£µ÷ÊÔÀú³Ì£ºnext (n) Ö´ÐÐÏÂÒ»ÌõÓï¾ä¡£step (s) ½øÈ뺯Êý¡£continue (c) ÔËÐе½ÏÂÒ»¸ö¶Ïµã¡£list (l) ÏÔʾĿ½ñÔ´´úÂë¡£info locals (locals) ÏÔʾ¾Ö²¿±äÁ¿¡£print ´òÓ¡±äÁ¿Öµ¡£backtrace (bt) ÏÔʾŲÓÃÕ»¡£¼ì²é±äÁ¿£¨print ÏÂÁ¡£Ð޸ıäÁ¿£¨set ÏÂÁ¡£Í˳ö gdb£¨quit ÏÂÁ¡£

gdbµ÷ÊÔ³ÌÐòÈ«Àú³ÌÏê½â

ÏÈÈÝ

gdb£¨GNU DeBugger£©ÊÇÒ»¸öÇ¿Ê¢µÄµ÷ÊÔÆ÷ £¬¿ÉÓÃÓÚÕï¶ÏºÍµ÷ÊÔÅÌËã»ú³ÌÐò¡£±¾ÎĽ«ÏêϸÐÎòʹÓà gdb µ÷ÊÔ³ÌÐòµÄÈ«Àú³Ì¡£

1. Æô¶¯ gdb

  • ·­¿ªÖն˻òÏÂÁîÌáÐÑ·û¡£
  • ÊäÈë gdb ºó¸úÒªµ÷ÊԵijÌÐòÃû³Æ £¬ÀýÈ磺
$ gdb ./my_program

µÇ¼ºó¸´ÖÆ

2. ¶ÁÈë³ÌÐò

  • gdb ÌáÐÑ·û (gdb) ·ºÆðºó £¬ÊäÈë file ÏÂÁî¶ÁÈëÒªµ÷ÊԵijÌÐò¡£
  • ÀýÈ磺
(gdb) file my_program

µÇ¼ºó¸´ÖÆ

3. ÉèÖöϵã

  • ÔÚ³ÌÐòÖÐÉèÖöϵã £¬ÒÔ±ãÔÚÌض¨Ðлòº¯Êý´¦ÔÝÍ£Ö´ÐС£
  • ÊäÈë break ÏÂÁîºó¸úÐкŻòº¯ÊýÃû £¬ÀýÈ磺
(gdb) break 10
(gdb) break my_function

µÇ¼ºó¸´ÖÆ

4. ÔËÐгÌÐò

  • ÊäÈë run ÏÂÁîÆô¶¯³ÌÐò¡£
  • ÀýÈ磺
(gdb) run

µÇ¼ºó¸´ÖÆ

5. µ÷ÊÔÀú³Ì

Ò»µ©³ÌÐòÔڶϵ㴦ÔÝÍ£Ö´ÐÐ £¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐе÷ÊÔ£º

  • next (n)£ºÖ´ÐÐÏÂÒ»ÌõÓï¾ä¡£
  • step (s)£ºÖ´ÐÐÏÂÒ»ÌõÓï¾ä²¢½øÈ뺯Êý¡£
  • continue (c)£º¼ÌÐøÔËÐгÌÐòÖ±µ½ÏÂÒ»¸ö¶Ïµã»ò³ÌÐò¿¢Ê¡£
  • list (l)£ºÏÔʾĿ½ñÔ´´úÂëÖÜΧ¼¸ÐС£
  • info locals (locals)£ºÏÔʾĿ½ñ¿ÍÕ»Ö¡Öеľֲ¿±äÁ¿¡£
  • print£º´òÓ¡±äÁ¿»ò±í´ïʽµÄÖµ¡£
  • backtrace (bt)£ºÏÔʾŲÓÃÕ»¡£

6. ¼ì²é±äÁ¿

¿ÉÒÔʹÓà print ÏÂÁî¼ì²é±äÁ¿µÄÖµ¡£ÀýÈ磺

(gdb) print my_variable

µÇ¼ºó¸´ÖÆ

7. Ð޸ıäÁ¿

¿ÉÒÔʹÓà set ÏÂÁîÐ޸ıäÁ¿µÄÖµ¡£ÀýÈ磺

(gdb) set my_variable = 100

µÇ¼ºó¸´ÖÆ

8. Í˳ö gdb

µ÷ÊÔÍê³Éºó £¬ÊäÈë quit ÏÂÁîÍ˳ö gdb¡£

ÒÔÉϾÍÊÇÏêϸÐÎògdbµ÷ÊÔ³ÌÐòµÄÈ«Àú³ÌµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ