{"id":177,"date":"2011-03-25T13:23:54","date_gmt":"2011-03-25T21:23:54","guid":{"rendered":"http:\/\/zhanxw.com\/blog\/?p=177"},"modified":"2011-03-25T13:25:27","modified_gmt":"2011-03-25T21:25:27","slug":"gdb-%e4%bd%bf%e7%94%a8%e7%bb%8f%e9%aa%8c%ef%bc%88%e4%ba%8c%ef%bc%89","status":"publish","type":"post","link":"https:\/\/zhanxw.com\/blog\/2011\/03\/gdb-%e4%bd%bf%e7%94%a8%e7%bb%8f%e9%aa%8c%ef%bc%88%e4%ba%8c%ef%bc%89\/","title":{"rendered":"GDB \u4f7f\u7528\u7ecf\u9a8c\uff08\u4e8c\uff09"},"content":{"rendered":"<p>GDB \u4f7f\u7528\u7ecf\u9a8c\uff08\u4e8c\uff09<br \/>\nHints of using GDB inside Emacs<\/p>\n<p>\u7ee7\u7eed\u524d\u6587<a href=\"http:\/\/zhanxw.com\/blog\/2011\/03\/gdb-%E4%BD%BF%E7%94%A8%E7%BB%8F%E9%AA%8C\/\">GDB \u4f7f\u7528\u7ecf\u9a8c<\/a>\uff0c \u8fd9\u91cc\u4ecb\u7ecd\u5728Emacs\u4e2d\u4f7f\u7528GDB\u7684\u4e00\u70b9\u7ecf\u9a8c\u3002<\/p>\n<p><strong>(1) GDB many windows mode <\/strong> \u30101\u3011<\/p>\n<p>\u5728M-x gdb \u542f\u52a8Emacs \u4e2d\u7684GDB mode \u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5 M-x gdb-many-windows\uff0c \u5c06GDB comand\uff08GDB \u547d\u4ee4\uff09\u3001local variable\uff08\u5c40\u90e8\u53d8\u91cf\uff09\u3001source code\uff08\u6e90\u7a0b\u5e8f\u4ee3\u7801\uff09\u3001stack\uff08\u5806\uff0c\u7528\u4e8e\u68c0\u67e5\u51fd\u6570\u8c03\u7528\u7684\u5c42\u6570\uff09\u3001breakpoints\uff08\u6240\u6709\u5df2\u7ecf\u8bbe\u7f6e\u7684\u65ad\u70b9\uff09\u8fd95\u4e2a\u6709\u7528\u7684\u7a97\u53e3\u6392\u5217\u8d77\u6765\u3002<\/p>\n<p>\u5982\u679c\u60f3\u5c11\u6253\u51e0\u4e2a\u952e\uff0c\u53ef\u4ee5\u628a\u4e0b\u9762\u7684\u4ee3\u7801\u653e\u5230~\/.emacs\uff0c\u8fd9\u6837\u4ee5\u540eM-x gmw \u5c31\u7b49\u4e8e\u662fM-x gdb-many-windows\u4e86\u3002<\/p>\n<p>(defun gmw ()<br \/>\n  &quot;start gdb-many-windows&quot;<br \/>\n  (gdb-many-windows))<\/p>\n<p><strong>(2) \u5feb\u6377\u952e Short cuts <\/strong><\/p>\n<p>\u5728GDB\u4e2d\uff0c \u5e38\u7528\u7684\u547d\u4ee4\u5305\u62eccontinue, next\u7b49\u7b49\u3002\u5728Eamcs\u4e2d\u7684\u5feb\u6377\u952e\u56e0\u7a97\u53e3\u7684\u4e0d\u540c\u800c\u4e0d\u540c\u3002\u4f8b\u5982\uff0c\u5728GDB command\u7a97\u53e3\uff0cnext \u7684\u5feb\u6377\u952e\u662fC-x C-a C-n\uff0c\u800c\u5728source code\u7a97\u53e3\uff0c next\u7684\u5feb\u6377\u952e\u662fC-c C-n\u3002\u4f46\u6211\u4eec\u53ef\u4ee5\u603b\u7ed3\u89c4\u5f8b\u4e3a\u57fa\u672c\u547d\u4ee4\u90fd\u662fprefix + key \u7684\u5f62\u5f0f\u3002<\/p>\n<p>\u5728GDB command \u7a97\u53e3\u7684prefix \u90fd\u662f\uff1aC-c<br \/>\n\u5728source code \u7a97\u53e3\u7684prefix \u90fd\u662f\uff1aC-x C-a <\/p>\n<p>key\u5bf9\u5e94\u4e8enext\u547d\u4ee4\u662f\uff1a C-n<br \/>\nkey\u5bf9\u5e94\u4e8estep\u547d\u4ee4\u662f\uff1a C-s<br \/>\nkey\u5bf9\u5e94\u4e8euntil\u547d\u4ee4\u662f\uff1a C-u<br \/>\nkey\u5bf9\u5e94\u4e8econtinue\u547d\u4ee4\u662f\uff1a C-r<br \/>\nkey\u5bf9\u5e94\u4e8efinish\u547d\u4ee4\u662f\uff1a C-f<br \/>\nkey\u5bf9\u5e94\u4e8ewatch expression\u547d\u4ee4\u662f\uff1a C-w  (\u5149\u6807\u6240\u5728\u7684\u53d8\u91cf\u4f1a\u88abwatch\uff0c\u4f1a\u51fa\u73b0\u53e6\u5916\u4e00\u4e2a\u7a97\u53e3\u663e\u793a\u8be5\u53d8\u91cf)<br \/>\nkey\u5bf9\u5e94\u4e8eprint expression\u547d\u4ee4\u662f\uff1a C-p  \uff08\u9700\u8981\u5148mark\u4e00\u4e2aregion\uff0c\u8fd9\u4e2aregion\u8868\u793a\u7684expression\u8868\u8fbe\u5f0f\u4f1a\u88ab\u6253\u5370\u51fa\u6765\uff09<br \/>\nkey\u5bf9\u5e94\u4e8etemporary breakpoint\uff08\u4e34\u65f6\u65ad\u70b9\uff09\u547d\u4ee4\u662f\uff1a C-t<br \/>\nkey\u5bf9\u5e94\u4e8edelete breakpoint\uff08\u5220\u9664\u65ad\u70b9\uff09\u547d\u4ee4\u662f\uff1a C-d \uff08\u5982\u679c\u5f53\u524d\u884c\u6709\u65ad\u70b9\uff0c\u5219\u5220\u9664\u4e4b\uff09<\/p>\n<p><strong> (3) Enable tools tips <\/strong>\u30102\u3011<\/p>\n<p>\u5728Visual Studio\u4e2d\u53e6\u4e00\u4e2a\u6709\u7528\u7684\u529f\u80fd\u662f\uff1a\u5f53\u9f20\u6807\u79fb\u52a8\u5230\u4e00\u4e2a\u53d8\u91cf\u4e0a\u65f6\uff0c\u8fd9\u4e2a\u53d8\u91cf\u7684\u503c\u4f1a\u901a\u8fc7tooltip\u7684\u65b9\u5f0f\u663e\u793a\u51fa\u6765\u3002<br \/>\n\u8fd9\u4e2a\u529f\u80fd\u5728GDB\u4e2d\u4e5f\u80fd\u5b9e\u73b0\u3002<br \/>\n\u5728GUD\u83dc\u5355\u4e2d\u9009\u4e2d&#8221;Show GUD tooltips&#8221;\u5373\u53ef\u3002\u4f7f\u7528\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p><a href=\"http:\/\/zhanxw.com\/blog\/wp-content\/uploads\/2011\/03\/20110325_GDB.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/zhanxw.com\/blog\/wp-content\/uploads\/2011\/03\/20110325_GDB-300x187.png\" alt=\"\" title=\"20110325_GDB\" width=\"300\" height=\"187\" class=\"alignnone size-medium wp-image-178\" srcset=\"https:\/\/zhanxw.com\/blog\/wp-content\/uploads\/2011\/03\/20110325_GDB-300x187.png 300w, https:\/\/zhanxw.com\/blog\/wp-content\/uploads\/2011\/03\/20110325_GDB-1024x640.png 1024w, https:\/\/zhanxw.com\/blog\/wp-content\/uploads\/2011\/03\/20110325_GDB.png 1280w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u30101\u3011<a href=\"http:\/\/emacs-fu.blogspot.com\/2009\/02\/fancy-debugging-with-gdb.html\">Fancy Debugging<\/a><br \/>\n\u30102\u3011<a href=\"http:\/\/www.gnu.org\/software\/emacs\/manual\/html_node\/emacs\/Tooltips.html\">Tooltips <\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>GDB \u4f7f\u7528\u7ecf\u9a8c\uff08\u4e8c\uff09 Hints of using GDB inside Emacs \u7ee7\u7eed\u524d\u6587GDB \u4f7f\u7528\u7ecf\u9a8c\uff0c \u8fd9\u91cc\u4ecb\u7ecd\u5728Emacs\u4e2d\u4f7f\u7528GDB\u7684\u4e00\u70b9\u7ecf\u9a8c\u3002 (1) GDB many windows mode \u30101\u3011 \u5728M-x gdb \u542f\u52a8Emacs \u4e2d\u7684GDB mode \u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5 M-x gdb-many-windows\uff0c \u5c06GDB comand\uff08GDB \u547d\u4ee4\uff09\u3001local variable\uff08\u5c40\u90e8\u53d8\u91cf\uff09\u3001source code\uff08\u6e90\u7a0b\u5e8f\u4ee3\u7801\uff09\u3001stack\uff08\u5806\uff0c\u7528\u4e8e\u68c0\u67e5\u51fd\u6570\u8c03\u7528\u7684\u5c42\u6570\uff09\u3001breakpoints\uff08\u6240\u6709\u5df2\u7ecf\u8bbe\u7f6e\u7684\u65ad\u70b9\uff09\u8fd95\u4e2a\u6709\u7528\u7684\u7a97\u53e3\u6392\u5217\u8d77\u6765\u3002 \u5982\u679c\u60f3\u5c11\u6253\u51e0\u4e2a\u952e\uff0c\u53ef\u4ee5\u628a\u4e0b\u9762\u7684\u4ee3\u7801\u653e\u5230~\/.emacs\uff0c\u8fd9\u6837\u4ee5\u540eM-x gmw \u5c31\u7b49\u4e8e\u662fM-x gdb-many-windows\u4e86\u3002 (defun gmw () &quot;start gdb-many-windows&quot; (gdb-many-windows)) (2) \u5feb\u6377\u952e Short cuts \u5728GDB\u4e2d\uff0c \u5e38\u7528\u7684\u547d\u4ee4\u5305\u62eccontinue, next\u7b49\u7b49\u3002\u5728Eamcs\u4e2d\u7684\u5feb\u6377\u952e\u56e0\u7a97\u53e3\u7684\u4e0d\u540c\u800c\u4e0d\u540c\u3002\u4f8b\u5982\uff0c\u5728GDB command\u7a97\u53e3\uff0cnext \u7684\u5feb\u6377\u952e\u662fC-x C-a C-n\uff0c\u800c\u5728source code\u7a97\u53e3\uff0c next\u7684\u5feb\u6377\u952e\u662fC-c C-n\u3002\u4f46\u6211\u4eec\u53ef\u4ee5\u603b\u7ed3\u89c4\u5f8b\u4e3a\u57fa\u672c\u547d\u4ee4\u90fd\u662fprefix + [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[33,41],"class_list":["post-177","post","type-post","status-publish","format-standard","hentry","category-code","tag-emacs","tag-gdb"],"_links":{"self":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/comments?post=177"}],"version-history":[{"count":0,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/177\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/media?parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/categories?post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/tags?post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}