Debugging with GDB

 我来答
爱尚淘数码17
2022-06-25 · TA获得超过2823个赞
知道小有建树答主
回答量:3672
采纳率:100%
帮助的人:197万
展开全部

To debug, you must generate debugging info when compiling , and this requires you to pass the -g option to the compiler. If you don't know why, just think of how you debug with visual studio. ( FAQ之 Debug单步调试 )

I'll illustrate how to debug with GDB with a simple C program.

I run the compiler with release mode and debug mode, respectively. Accordingly, executable file are named with release and debug. As it shown in the picture above, the release version is smaller than the debug one, which is resulted from the lack of debug info.

To start the debugging, type gdb exe_name . Note the name here is the debugged executable file, not the source code.

break to set breakpoints, e.g., break 20 to set at the 20th line.

the command is run

You can type continue to let the program go on.

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
纳糯三维科技(上海)
2024-07-01 广告
作为Nanoscribe公司专家级资深用户,麻省理工、加州理工和苏黎世联邦理工学院合作,在高影响因子科学期刊Nature Materials上发表了“Supersonic impact resilience of nanoarchitect... 点击进入详情页
本回答由纳糯三维科技(上海)提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式