×ðÁú¿­Ê±¹ÙÍøµÇ¼

gdbµ÷ÊÔÏÂÁîµÄʹÓü°×ܽá

gdbÊÇÒ»¸öÓÃÓÚµ÷ÊÔ³ÌÐòµÄÇ¿Ê¢¹¤¾ß£¬¿ÉÈÃÓû§Öð²½Ö´ÐдúÂ룬¼ì²é±äÁ¿ÖµºÍÄÚ´æÄÚÈÝ£¬ÒÔ¼°ÉèÖöϵãºÍÊÓ²ìµã¡£³£ÓÃÏÂÁî°üÀ¨£ºÆô¶¯gdb£ºgdb program_nameÔËÐгÌÐò£ºrun argsÉèÖöϵ㣺break line_number/function_nameɾ³ý¶Ïµã£ºdelete break_numberµ¥²½Ö´ÐУºnext/step¼ì²é±äÁ¿£ºprint variable_name/display variable_nameÄÚ´æ¼ì²é£ºx/n format address/x/s address·´»ã

gdbµ÷ÊÔÏÂÁîµÄʹÓÃ

ʲôÊÇgdb£¿

gdb£¨GNUµ÷ÊÔÆ÷£©ÊÇÒ»ÖÖÇ¿Ê¢µÄ¹¤¾ß£¬ÓÃÓÚµ÷ÊÔC¡¢C++ºÍ»ã±àÓïÑÔ³ÌÐò¡£ËüÔÊÐí³ÌÐòÔ±Öð²½Ö´ÐдúÂ룬¼ì²é±äÁ¿ÖµºÍÄÚ´æÄÚÈÝ£¬ÒÔ¼°ÉèÖöϵãºÍÊÓ²ìµã¡£

³£ÓÃgdbÏÂÁî

Æô¶¯gdb

  • gdb program_name

ÔËÐгÌÐò

  • run args

ÉèÖöϵã

  • break line_number
  • break function_name

ɾ³ý¶Ïµã

  • delete break_number

µ¥²½Ö´ÐÐ

  • next£ºÖ´ÐÐÏÂÒ»ÐдúÂë¡£
  • step£º½øÈ뺯Êý£¬Ö´ÐÐÏÂÒ»ÐдúÂë¡£

¼ì²é±äÁ¿

  • print variable_name
  • display variable_name£ºÒ»Á¬ÏÔʾ±äÁ¿Öµ¡£

ÄÚ´æ¼ì²é

  • x/n format address£ºÏÔʾÄÚ´æÖеÄn¸öµ¥Î»¡£
  • x/s address£ºÏÔʾÄÚ´æÖеÄ×Ö·û´®¡£

·´»ã±à

  • disassemble function_name

ÊÓ²ìµã

  • watch variable_name£ºµ±±äÁ¿Öµ±¬·¢×ª±äʱ×èÖ¹Ö´ÐС£

ÆäËûÓÐÓÃÏÂÁî

  • list£ºÏÔʾĿ½ñÖÜΧ´úÂë¡£
  • info£ºÏÔʾµ÷ÊÔ³ÌÐòÐÅÏ¢¡£
  • help£º»ñÈ¡ÏÂÁî×ÊÖú¡£

ʹÓÃʾÀý

Òªµ÷ÊÔÒ»¸öÃûΪmy_programµÄC³ÌÐò£º

  1. Æô¶¯gdb£ºgdb my_program
  2. ÉèÖöϵ㣺break main
  3. ÔËÐгÌÐò£ºrun
  4. ÖðÐÐÖ´ÐУºnext
  5. ¼ì²é±äÁ¿£ºprint a
  6. ɾ³ý¶Ïµã£ºdelete 1

ÒÔÉϾÍÊÇgdbµ÷ÊÔÏÂÁîµÄʹÓü°×ܽáµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ