how to set breakpoint and show source code when us

2019-09-21 09:20发布

问题:

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