尊龙凯时人生就是搏

gdbµ÷ÊÔÆ÷µÄʹÓÃÒªÁìºÍ±àÒë°ì·¨

ʹÓÃgdbµ÷ÊÔÆ÷µÄÒªÁ죺Æô¶¯gdb£ºÊäÈëgdbºó¸ú¿ÉÖ´ÐÐÎļþ¡£ÉèÖöϵ㣺ʹÓÃbreakÏÂÁîÔÚÌض¨Ðд¦ÉèÖöϵã¡£ÔËÐгÌÐò£ºÊ¹ÓÃrunÏÂÁîÔËÐгÌÐò£¬ÔÚÓöµ½¶ÏµãʱÔÝÍ£¡£¼ì²é±äÁ¿£ºÊ¹ÓÃprintÏÂÁî´òÓ¡±äÁ¿Öµ¡£µ¥²½Ö´ÐУºÊ¹ÓÃstepÏÂÁîÖðÐÐÖ´ÐгÌÐò¡£Éó²éŲÓÃÕ»£ºÊ¹ÓÃbacktraceÏÂÁîÉó²éÄ¿½ñŲÓÃÕ»¡£¼ÌÐøÖ´ÐУºÊ¹ÓÃcontinueÏÂÁî¼ÌÐø³ÌÐòÖ´ÐС£

gdbµ÷ÊÔÆ÷µÄʹÓÃÒªÁìºÍ±àÒë°ì·¨

gdbµ÷ÊÔÆ÷ʹÓÃÒªÁì

  1. Æô¶¯gdb£ºÔÚÏÂÁîÐÐÖÐÊäÈëgdbºó¸úÒªµ÷ÊԵĿÉÖ´ÐÐÎļþ¡£
  2. ¶ÏµãÉèÖãºÊ¹ÓÃbreakÏÂÁîÔÚÒª×èÖ¹Ö´ÐеÄÐд¦ÉèÖöϵã¡£
  3. ÔËÐгÌÐò£ºÊ¹ÓÃrunÏÂÁîÔËÐгÌÐò£¬³ÌÐò½«ÔÚÓöµ½¶Ïµã´¦ÔÝÍ£¡£
  4. ¼ì²é±äÁ¿£ºÊ¹ÓÃprintÏÂÁî´òÓ¡±äÁ¿Öµ¡£
  5. µ¥²½Ö´ÐУºÊ¹ÓÃstepÏÂÁîÖðÐÐÖ´ÐгÌÐò¡£
  6. Éó²éŲÓÃÕ»£ºÊ¹ÓÃbacktraceÏÂÁîÉó²éÄ¿½ñŲÓÃÕ»¡£
  7. ¼ÌÐøÖ´ÐУºÊ¹ÓÃcontinueÏÂÁî¼ÌÐø³ÌÐòÖ´ÐС£

±àÒë°ì·¨

  1. ±àдԴ´úÂ룺ʹÓÃÈκÎÎı¾±à¼­Æ÷£¨ÈçVim»òVisual Studio Code£©±àдC»òC++Ô´´úÂëÎļþ£¨ÀýÈçmain.c£©¡£
  2. ±àÒëÔ´´úÂ룺ʹÓÃgcc»òclang±àÒëÆ÷£¨ÀýÈ磺gcc main.c -o main£©¡£
  3. Á´½ÓÄ¿µÄÎļþ£ºÈôÊÇÔ´´úÂëÎļþÒÀÀµÓÚÍⲿ¿â»òÆäËûÄ¿µÄÎļþ£¬ÔòÐèҪʹÓÃÁ´½ÓÆ÷£¨Èçld£©Á´½ÓËüÃÇ£¨ÀýÈ磺ld -o main main.o lib.a£©¡£

ʾÀý

ÒÔÏÂÊÇgdbµ÷ÊԻỰµÄʾÀý£º

$ gdb main
(gdb) break 12
Breakpoint 1 at 0x100001234: file main.c, line 12.
(gdb) run
Breakpoint 1, main () at main.c:12
12      int main(int argc, char *argv[]) {
(gdb) print argc
$1 = 1
(gdb) step
13      printf("Hello, world!\n");
(gdb) continue
Continuing.
Program exited with code 0.

µÇ¼ºó¸´ÖÆ

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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