使用cdb调试c ++程序时如何设置断点和显示源代码? [英] how to set breakpoint and show source code when using cdb to debug c++ programs?

查看:853
本文介绍了使用cdb调试c ++程序时如何设置断点和显示源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么bp主要失败?
如何将源代码列为gdb的list命令?



这个问题不一样用于根据行设置断点的CDB命令数字



似乎cdb可以用于windbg,但是可以使用cdb有点类似于gdb吗?

解决方案

cdb允许3个不同的命令设置断点:$ b​​ $ b bp,bm和bu


  1. bp接受数字地址的参数

  2. bm接受在已加载的模块中是文本符号的参数

  3. bu接受可能或可能不加载的模块中的文本符号的参数。

要设置主要的断点,我们可以猜测Image00390000实际上是hello.exe(有时cdb无法恢复你所期望的名称)。您可以使用以下命令:

  bm Image00390000!main 

这假设main真的是符号名,加载了符号。您可以使用:

  lmvm Image00390000 //检查符号是否加载
x Image00390000!* main * // lists所有符号,主要在名称


why bp main failed? how to list source code as gdb's list command does?

this question is not the same as CDB command for setting a breakpoint based on a line number

seems cdb can be used with windbg, but is that possible to use cdb a bit similar to gdb?

解决方案

cdb allows 3 different commands to set breakpoints: bp, bm, and bu

  1. bp accepts arguments that are numeric addresses
  2. bm accepts arguments that are textual symbols in a module that is already loaded
  3. bu accepts arguments that are textual symbols in modules that may or may not be loaded yet.

To Set a breakpoint at main we can guess Image00390000 is actually hello.exe (Sometimes cdb fails to recover the name you would expect). You can use the command:

bm Image00390000!main

This assumes that main really is the symbol name, and that symbols are loaded. You can use:

lmvm Image00390000 //to check if symbols are loaded
x Image00390000!*main* //lists all symbols that have main anywhere in the name

这篇关于使用cdb调试c ++程序时如何设置断点和显示源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆