{"id":474,"date":"2025-12-23T10:40:02","date_gmt":"2025-12-23T02:40:02","guid":{"rendered":"https:\/\/www.garfield-blog.top\/?p=474"},"modified":"2025-12-23T10:43:13","modified_gmt":"2025-12-23T02:43:13","slug":"%e3%80%90%e5%b7%a5%e5%85%b7%e4%bd%bf%e7%94%a8%e3%80%91vscodegdb%e5%ae%9e%e7%8e%b0%e5%8f%af%e8%a7%86%e5%8c%96%e8%b0%83%e8%af%95","status":"publish","type":"post","link":"https:\/\/www.garfield-blog.top\/?p=474","title":{"rendered":"\u3010\u5de5\u5177\u4f7f\u7528\u3011VSCode+GDB\u5b9e\u73b0\u53ef\u89c6\u5316\u8c03\u8bd5"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u914d\u7f6e\u73af\u5883<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5b89\u88c5\u5fae\u8f6f\u5b98\u65b9\u63d0\u4f9b\u7684<code>C\/C++<\/code>\u63d2\u4ef6<\/li>\n\n\n\n<li>\u914d\u7f6e\u5c06\u6587\u4ef6<code>launch.json<\/code>\u6539\u4e3a\u5982\u4e0b <\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \/\/ \u4f7f\u7528 IntelliSense \u4e86\u89e3\u76f8\u5173\u5c5e\u6027\u3002 \n    \/\/ \u60ac\u505c\u4ee5\u67e5\u770b\u73b0\u6709\u5c5e\u6027\u7684\u63cf\u8ff0\u3002\n    \/\/ \u6b32\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u8bbf\u95ee: https:\/\/go.microsoft.com\/fwlink\/?linkid=830387\n    \"version\": \"0.2.0\",\n    \"configurations\": &#91;\n        {\n            \"name\": \"(gdb) \u542f\u52a8\", \/\/\u914d\u7f6e\u540d\u79f0\uff0c\u663e\u793a\u5728\u914d\u7f6e\u4e0b\u62c9\u83dc\u5355\u4e2d\n            \"type\": \"cppdbg\", \/\/\u914d\u7f6e\u7c7b\u578b\n            \"request\": \"launch\", \/\/\u8bf7\u6c42\u914d\u7f6e\u7c7b\u578b\uff0c\u53ef\u4ee5\u662f\u542f\u52a8\u6216\u8005\u662f\u9644\u52a0\n            \"program\": \"${fileDirname}\/a.out\", \/\/\u7a0b\u5e8f\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5b8c\u6574\u8def\u5f84\uff0c${workspaceFolder}\u8868\u793a\u8fdc\u7a0b\u8fde\u63a5\u7684\u521d\u59cb\u8def\u5f84\n            \"args\": &#91;], \/\/\u4f20\u9012\u7ed9\u7a0b\u5e8f\u7684\u547d\u4ee4\u884c\u53c2\u6570\n            \"stopAtEntry\": true, \/\/\u53ef\u9009\u53c2\u6570\uff0c\u5982\u679c\u4e3atrue,\u8c03\u8bd5\u7a0b\u5e8f\u5e94\u8be5\u5728\u5165\u53e3\uff08main\uff09\u5904\u505c\u6b62\n            \"cwd\": \"${workspaceFolder}\", \/\/\u7528\u4e8e\u67e5\u627e\u4f9d\u8d56\u9879\u548c\u5176\u4ed6\u6587\u4ef6\u7684\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\n            \"environment\": &#91;], \/\/\u8868\u793a\u8981\u9884\u8bbe\u7684\u73af\u5883\u53d8\u91cf\n            \"externalConsole\": false, \/\/\u5982\u679c\u4e3atrue\uff0c\u5219\u4e3a\u8c03\u8bd5\u5bf9\u8c61\u542f\u52a8\u63a7\u5236\u53f0\n            \"MIMode\": \"gdb\", \/\/\u8981\u8fde\u63a5\u5230\u7684\u63a7\u5236\u53f0\u542f\u52a8\u7a0b\u5e8f\n            \"setupCommands\": &#91; \/\/\u4e3a\u4e86\u5b89\u88c5\u57fa\u7840\u8c03\u8bd5\u7a0b\u5e8f\u800c\u6267\u884c\u7684\u4e00\u4e2a\u6216\u591a\u4e2aGDB\/LLDB\u547d\u4ee4\n                {\n                    \"description\": \"\u5f00\u542fpretty-printer\",\n                    \"text\": \"-enable-pretty-printing\",\n                    \"ignoreFailures\": true\n                },\n                {\n                    \"description\": \"\u8bbe\u7f6e\u53cd\u6c47\u7f16\u98ce\u683c\u4e3ainter\",\n                    \"text\": \"-gdb-set disassembly-flavor intel\",\n                    \"ignoreFailures\": true\n                }\n            ]\n        }\n    ]\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u8c03\u8bd5\u65f6\u51fa\u73b0<code>Module containing this breakpoint has not yet loaded or the breakpoint address could not be obtained.<\/code>\u7684\u63d0\u793a\uff0c\u8bf7\u5728<code>gcc<\/code>\u7f16\u8bd1\u65f6\u6dfb\u52a0<code>-g<\/code>\u53c2\u6570<\/li>\n\n\n\n<li>\u5982\u679c\u8c03\u8bd5\u65f6\u63d0\u793a\u65e0\u6cd5\u627e\u5230\u5bf9\u5e94\u7684\u52a8\u6001\u5e93\uff0c\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u4fee\u6539\u73af\u5883\u53d8\u91cf<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  export LD_LIBRARY_PATH=\/path\/to\/your\/libs:$LD_LIBRARY_PATH<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u53ef\u5c06\u53f3\u952e\u53d8\u91cf\u6dfb\u52a0\u5230\u76d1\u89c6\uff0c\u5728\u76d1\u89c6\u4e2d\u53ef\u4f7f\u7528<code>gdb<\/code>\u547d\u4ee4\u67e5\u770b\u6570\u7ec4\u7ed3\u6784\u4f53\u7b49\u5143\u7d20\u7684\u503c \u4f8b\u5982\u53ef\u5728\u76d1\u89c6\u4e2d\u624b\u52a8\u6dfb\u52a0<code>*r@10<\/code>\u6765\u76d1\u89c6\u6570\u7ec4<code>r<\/code>\u7684\u524d<code>10<\/code>\u4f4d\u5143\u7d20<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/www.garfield-blog.top\/wp-content\/uploads\/2025\/12\/\u76d1\u89c6\u6570\u7ec4\u5185\u5bb9.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1253\" height=\"553\" data-original=\"https:\/\/www.garfield-blog.top\/wp-content\/uploads\/2025\/12\/\u76d1\u89c6\u6570\u7ec4\u5185\u5bb9.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-476\"  sizes=\"auto, (max-width: 1253px) 100vw, 1253px\" \/><\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u5982\u4f55\u8c03\u8bd5\u5e93\u51fd\u6570<\/h2>\n\n\n\n<p>\u5728\u8c03\u8bd5\u65f6\u5982\u679c\u5355\u6b65\u6267\u884c\u9047\u5230\u5e93\u51fd\u6570<code>srand(time(NULL));<\/code>\u5219GDB\u4f1a\u63d0\u793a\u65e0\u6cd5\u52a0\u8f7d\u6e90\u6587\u4ef6 <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/www.garfield-blog.top\/wp-content\/uploads\/2025\/12\/\u65e0\u6cd5\u52a0\u8f7d\u6e90\u6587\u4ef6.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1413\" height=\"736\" data-original=\"https:\/\/www.garfield-blog.top\/wp-content\/uploads\/2025\/12\/\u65e0\u6cd5\u52a0\u8f7d\u6e90\u6587\u4ef6.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-477\"  sizes=\"auto, (max-width: 1413px) 100vw, 1413px\" \/><\/div><\/figure>\n\n\n\n<p>\u6b64\u65f6\u4ee3\u7801\u4e2d\u7684<code>time(NULL)<\/code>\u51fd\u6570\u6307\u5411<code>libc.so.6<\/code>\u5e93\uff0c\u7531\u4e8e\u5728<code>GDB<\/code>\u914d\u7f6e\u8def\u5f84\u4e2d\u4e0d\u5b58\u5728\u5bf9\u5e94\u7248\u672c\u7684<code>glibc<\/code>\u6e90\u4ee3\u7801\u6240\u4ee5\u65e0\u6cd5\u6b63\u5e38\u8df3\u8f6c\u81f3\u51fd\u6570\u5b9a\u4e49\u5904<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\/lib\/x86_64-linux-gnu\/libc.so.6\u662fLinux\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u52a8\u6001\u94fe\u63a5\u5e93\uff0c\u5168\u79f0\u4e3aC\u6807\u51c6\u5e93\u3002\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6240\u6709\u4f7f\u7528C\u8bed\u8a00\u7f16\u5199\u7684\u7a0b\u5e8f\u90fd\u9700\u8981\u4f7f\u7528C\u6807\u51c6\u5e93\u63d0\u4f9b\u7684\u51fd\u6570\u3001\u53d8\u91cf\u548c\u5e38\u91cf\u3002C\u6807\u51c6\u5e93\u7684\u4e3b\u8981\u529f\u80fd\u5305\u62ec\u6587\u4ef6\u64cd\u4f5c\u3001\u5b57\u7b26\u4e32\u64cd\u4f5c\u3001\u6570\u5b66\u8ba1\u7b97\u3001\u5185\u5b58\u7ba1\u7406\u3001\u65f6\u95f4\u5904\u7406\u3001\u7f51\u7edc\u901a\u4fe1\u7b49\u65b9\u9762\u3002C\u6807\u51c6\u5e93\u662fLinux\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u4e00\u9879\u6838\u5fc3\u7ec4\u4ef6\uff0c\u5bf9\u4e8e\u5f00\u53d1Linux\u5e94\u7528\u7a0b\u5e8f\u975e\u5e38\u91cd\u8981\u3002\/lib\/x86_64-linux-gnu\/libc.so.6\u8fd9\u4e2a\u6587\u4ef6\u662fC\u6807\u51c6\u5e93\u7684\u672c\u5730\u52a8\u6001\u94fe\u63a5\u5e93\uff0c\u4e5f\u5c31\u662f\u6240\u8c13\u7684libc\u5e93\u3002\u5728\u8fd0\u884cLinux\u7a0b\u5e8f\u65f6\uff0c\u5982\u679c\u53d1\u73b0\u7a0b\u5e8f\u9700\u8981\u7528\u5230C\u6807\u51c6\u5e93\u4e2d\u7684\u51fd\u6570\u6216\u53d8\u91cf\uff0c\u5c31\u4f1a\u81ea\u52a8\u8c03\u7528\u8be5\u5e93\u4e2d\u76f8\u5e94\u7684\u4ee3\u7801\u6765\u5b8c\u6210\u64cd\u4f5c<\/p>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n<\/blockquote>\n\n\n\n<p>\u901a\u8fc7<code>ldd --version<\/code>\u3001\u76f4\u63a5\u6267\u884c\u5bf9\u5e94\u7684<code>libc.so.6<\/code>\u6587\u4ef6\u90fd\u53ef\u4ee5\u627e\u5230\u81ea\u8eab\u7cfb\u7edf\u7684<code>libc.so.6<\/code>\u5bf9\u5e94\u7684glibc\u7248\u672c\u662f\u591a\u5c11<\/p>\n\n\n\n<p>\u4e0b\u8f7d\u5bf9\u5e94\u7248\u672c\u7684<code>glibc<\/code>\u6e90\u4ee3\u7801\uff0c\u5e76\u5c06\u6e90\u4ee3\u7801\u76ee\u5f55\u653e\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684<code>\"cwd\": \"${workspaceFolder}\/glibc-2.31\",<\/code>\u4e2d\uff0c\u6b64\u65f6\u518d\u4f7f\u7528gdb\u8c03\u8bd5\u9047\u5230\u5e93\u51fd\u6570\u65f6\u4fbf\u4f1a\u8df3\u8f6c\u81f3<code>glibc<\/code>\u6e90\u7801\u4e2d\u5bf9\u5e94\u7684\u51fd\u6570\u5b9e\u73b0<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/www.garfield-blog.top\/wp-content\/uploads\/2025\/12\/time\u51fd\u6570\u8c03\u8bd5.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1370\" height=\"764\" data-original=\"https:\/\/www.garfield-blog.top\/wp-content\/uploads\/2025\/12\/time\u51fd\u6570\u8c03\u8bd5.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-475\"  sizes=\"auto, (max-width: 1370px) 100vw, 1370px\" \/><\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u914d\u7f6e\u73af\u5883 \u5982\u4f55\u8c03\u8bd5\u5e93\u51fd\u6570 \u5728\u8c03\u8bd5\u65f6\u5982\u679c\u5355\u6b65\u6267\u884c\u9047\u5230\u5e93\u51fd\u6570srand(time(NULL));\u5219GDB\u4f1a\u63d0\u793a\u65e0\u6cd5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[12],"tags":[],"class_list":["post-474","post","type-post","status-publish","format-standard","hentry","category-12"],"_links":{"self":[{"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/posts\/474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=474"}],"version-history":[{"count":5,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/posts\/474\/revisions"}],"predecessor-version":[{"id":483,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=\/wp\/v2\/posts\/474\/revisions\/483"}],"wp:attachment":[{"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garfield-blog.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}