how to set breakpoint and show source code when using cdb to debug c++ programs?

六眼飞鱼酱① 提交于 2019-12-26 18:23:21

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/30011043/how-to-set-breakpoint-and-show-source-code-when-using-cdb-to-debug-c-programs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!