×ðÁú¿­Ê±

vscodeÖÐÔõôԶ³Ìgdbµ÷ÊÔ£¿ÒªÁìÏê½â

vscodeÖÐÔõôԶ³Ìgdbµ÷ÊÔ£¿ÏÂÃ汾ƪÎÄÕ¸ø¸÷ÈËÏÈÈÝÒ»ÏÂvscodeÔ¶³Ìgdbµ÷ÊÔµÄÒªÁ죬ϣÍû¶Ô¸÷ÈËÓÐËù×ÊÖú£¡

×î½üÔÚͬʵݲÀûÏ£¬ÊµÑéÁËÓà vscode ×ö gdb µ÷ÊÔ£¬ÓÃÍêÖ®ºó£¬¡°ÕæÏ㡱¡£

»°Î´¼¸Ëµ£¬±¾ÎÄҪʵÏÖµÄÊÇ£ºÔÚ windows ¶ËÔ¶³Ìµ÷ÊÔ linux ЧÀÍÆ÷ºÍ arm ǶÈëʽÉè±¹ØÁ¬Ä c++ ´úÂ룬¶Ô gdb µ÷ÊÔµÄÉèÖü°Ê¹ÓþÙÐÐÒ»¸öÕûÀí¡£

1¡¢Ô¶³ÌÅþÁ¬

Ê×ÏÈÐèҪʵÏÖÔ¶³ÌÅþÁ¬Ð§ÀÍÆ÷£¬ÔÚ²å¼þ¿âÖÐËÑË÷ ¡°remote-ssh¡±£¬Ë«»÷ÏÂÔØ×°Öü´¿É£¨ÏÂͼÖÐÎÒÒÑ×°Öúã©£¬×°ÖúÃÖ®ºóÔÚ²à±ßÀ¸·ºÆðÔ¶³Ì×ÊÔ´ÖÎÀíÆ÷¡£¡¾ÍƼöѧϰ£ºvscode½Ì³Ì¡¢±à³Ì½Ìѧ¡¿

µã»÷ £« ºÅ£¬ÔÚµ¯³öµÄÏÂÁî´°¿ÚÖÐÊäÈë ssh ÉÏ°¶Ö¸Áƾ֤ÌáÐÑ£¬ÊäÈëÃÜÂ벢ȷÈÏ£¬¼´¿ÉÅþÁ¬ÀÖ³É

2¡¢ÉèÖà GDB ÇéÐÎ

ÔÚЧÀͶ˽¨ÉèÒ»¸ö c++ ´úÂ룬ÕâÀïÒÔ¡¶LinuxÖ®C++»ñȡϵͳÓû§Ãû¡·ÖеĴúÂëΪÀý£¬ºÜ¼òÆÓ

#include <unistd.h>
#include <pwd.h>
#include <iostream>
 
int main()
{
	struct passwd* pwd;
	uid_t userid;
	userid = getuid();
	pwd = getpwuid(userid);
 
	std::cout pw_name pw_passwd pw_uid pw_gid pw_gecos pw_dir pw_shell <p>±àÒëÒªÁìÈçÏ£¬×¢ÖØÒ»¶¨Òª¼ÓÉÏ -g Ö¸Á²»È»ÎÞ·¨ gdb µ÷ÊÔ</p>
<pre class="brush:php;toolbar:false">g++ -g test.cpp -o test

µÇ¼ºó¸´ÖÆ

È»ºóµã»÷ Îļþ-·­¿ªÎļþ¼Ð£¬ÕÒµ½½¨ÉèµÄ´úÂë·¾¶£¬È·¶¨ºó£¬ÔÚ×ó²àµÄ×ÊÔ´ÖÎÀíÆ÷¿ÉÒÔ¿´µ½´úÂëÎļþ¡£

µÚÒ»´ÎÔËÐÐÐèҪװÖà c++ µÄÀ©Õ¹£¬ÔÚÀ©Õ¹Ò³ÃæÖУ¬×°Öà C/C++ 

 Í¬Ê±ËÑË÷ GDB Debug ²¢×°ÖÃ

vscodeÖÐÔõôԶ³Ìgdbµ÷ÊÔ£¿ÒªÁìÏê½â

 ×°ÖúÃÖ®ºó£¬µã»÷¡°ÔËÐк͵÷ÊÔ¡±°´Å¥£¬¡°½¨Éè launch.json¡± Îļþ£¬

vscodeÖÐÔõôԶ³Ìgdbµ÷ÊÔ£¿ÒªÁìÏê½â

 Ñ¡Ôñ C++(GDB/LLDB£©Ï×Ô¶¯ÌìÉú launch.json Îļþ£¬ÄÚÈÝÈçÏÂ

{
    // Ê¹ÓàIntelliSense Ïà֪Ȥ¹ØÊôÐÔ¡£ 
    // ÐüÍ£ÒÔÉó²éÏÖÓÐÊôÐÔµÄÐÎò¡£
    // ÓûÏàʶ¸ü¶àÐÅÏ¢£¬Çë»á¼û: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": []
}

µÇ¼ºó¸´ÖÆ

ƾ֤ϱߵÄÄÚÈÝ£¬¶ÔÓ¦µÄÐÞ¸ÄÒ»ÏÂ

{
    // Ê¹ÓàIntelliSense Ïà֪Ȥ¹ØÊôÐÔ¡£ 
    // ÐüÍ£ÒÔÉó²éÏÖÓÐÊôÐÔµÄÐÎò¡£
    // ÓûÏàʶ¸ü¶àÐÅÏ¢£¬Çë»á¼û: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Æô¶¯", //ÉèÖÃÃû³Æ£¬ÏÔʾÔÚÉèÖÃÏÂÀ­²Ëµ¥ÖÐ
            "type": "cppdbg", //ÉèÖÃÀàÐÍ
            "request": "launch", //ÇëÇóÉèÖÃÀàÐÍ£¬¿ÉÒÔÊÇÆô¶¯»òÕßÊǸ½¼Ó
            "program": "${workspaceFolder}/test", //³ÌÐò¿ÉÖ´ÐÐÎļþµÄÍêÕû·¾¶£¬${workspaceFolder}ÌåÏÖÔ¶³ÌÅþÁ¬µÄ³õʼ·¾¶
            "args": [], //ת´ï¸ø³ÌÐòµÄÏÂÁîÐвÎÊý
            "stopAtEntry": false,//¿ÉÑ¡²ÎÊý£¬ÈôÊÇΪtrue,µ÷ÊÔ³ÌÐòÓ¦¸ÃÔÚÈë¿Ú£¨main£©´¦×èÖ¹
            "cwd": "${workspaceFolder}", //Ä¿µÄµÄÊÂÇéĿ¼
            "environment": [], //ÌåÏÖÒªÔ¤ÉèµÄÇéÐαäÁ¿
            "externalConsole": false,//ÈôÊÇΪtrue£¬ÔòΪµ÷ÊÔ¹¤¾ßÆô¶¯¿ØÖÆ̨
            "MIMode": "gdb",//ÒªÅþÁ¬µ½µÄ¿ØÖÆ̨Æô¶¯³ÌÐò
            "setupCommands": [ //ΪÁË×°Öûù´¡µ÷ÊÔ³ÌÐò¶øÖ´ÐеÄÒ»¸ö»ò¶à¸öGDB/LLDBÏÂÁî
                {
                    "description": "Ϊ gdb ÆôÓÃÕûÆë´òÓ¡",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

µÇ¼ºó¸´ÖÆ

ÖÁ´ËÇéÐÎÉèÖÃÍê±Ï

3¡¢GDB µ÷ÊÔÒªÁì

ÔÚÔ´´úÂëÖÐÖ±½Óµã»÷ÐÐÊý×ó²à£¬¼´¿ÉÔöÌí¶Ïµã£¬ÉèÖúöϵãÖ®ºó£¬µã»÷¡°ÔËÐк͵÷ÊÔ¡±–£¨gdb£©Æô¶¯£¬ÈçÏÂ

vscodeÖÐÔõôԶ³Ìgdbµ÷ÊÔ£¿ÒªÁìÏê½â

¼´¿É½øÈëµ÷ÊÔÒ³Ãæ

vscodeÖÐÔõôԶ³Ìgdbµ÷ÊÔ£¿ÒªÁìÏê½â

¿ÉÒÔÔÚ±äÁ¿ÇøÖ±½Ó¿´µ½±äÁ¿Öµ£¬Íê³Éµ÷ÊÔÄ¿µÄ¡£

³£Óõĵ÷ÊÔ°´¼üÈçÏÂ

F5    ×îÏȵ÷ÊÔF10   µ¥²½Ìø¹ýF11   µ¥³ÌÐòÊÔshift + F11   µ¥²½Ìø³öctrl + shift + F5  ÖØÆôµ÷ÊÔshift + F5  ×èÖ¹µ÷ÊÔ

4¡¢ÎÊÌâ»ã×Ü

ÈôÊÇ֮ǰÅþÁ¬¹ýij̨װ±¸£¬ºóÐøÌæ»»×°±¸ÊÇͳһ¸öIP£¬»òÕß˵װ±¸ÖØ×°¹ýϵͳ£¬µ«IPû±ä£¬ÖØÁ¬µÄʱ¼ä»á±¨´í£¬Ôµ¹ÊÔ­ÓÉÊÇÖ÷»ú½«Ð§ÀÍÆ÷ IP ÁÐΪknown_host

vscodeÖÐÔõôԶ³Ìgdbµ÷ÊÔ£¿ÒªÁìÏê½â

 ÎÒÃÇÕÒµ½ÐÞ¸Äɾ³ý¸Ã IP È»ºóÖØÁ¬¼´¿É

vscodeÖÐÔõôԶ³Ìgdbµ÷ÊÔ£¿ÒªÁìÏê½â

¸ü¶à¹ØÓÚVSCodeµÄÏà¹Ø֪ʶ£¬Çë»á¼û£ºvscode»ù´¡½Ì³Ì£¡

ÒÔÉϾÍÊÇvscodeÖÐÔõôԶ³Ìgdbµ÷ÊÔ£¿ÒªÁìÏê½âµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

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

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

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