How to break on assembly instruction at a given address in gdb?

92,328

Solution 1

try break *0x0000000000400448

Solution 2

Another way:

break *main+4

This will add a breakpoint at 0x000000000040044c
I think this is easier than writing the whole address!

Share:
92,328

Related videos on Youtube

compile-fan
Author by

compile-fan

Updated on July 08, 2022

Comments

  • compile-fan
    compile-fan almost 2 years
    0x0000000000400448 <main+0>:    push   %rbp
    0x0000000000400449 <main+1>:    mov    %rsp,%rbp
    0x000000000040044c <main+4>:    mov    $0x6,%eax
    0x0000000000400451 <main+9>:    leaveq 
    0x0000000000400452 <main+10>:   retq   
    

    I tried:

    breaki 0x0000000000400448
    

    but it seems that there not such command.

    Does gdb have such a feature?

    • phil294
      phil294 almost 7 years
      why breaki? is that a typo?
    • Per Lundberg
      Per Lundberg over 6 years
      @Blauhirn Perhaps as a supposed analogy with stepi and nexti, which are used for single-stepping at the instruction level.
  • Laurent G
    Laurent G about 13 years
    Probably because * is required to specify an address. see sourceware.org/gdb/current/onlinedocs/gdb/…
  • user202729
    user202729 almost 6 years
    And of course you can remove the leading zeroes and abbreviate break, give b *0x400448.
  • Dan Anderson
    Dan Anderson almost 5 years
    To disambiguate with function or data named 0x0000000000400448 (unusual as that would be!)
  • ifexploit
    ifexploit over 4 years
    @compile-fan break *address Set a breakpoint at address address. You can use this to set breakpoints in parts of your program which do not have debugging information or source files. ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_28.html I was debugging a assembly code and reached here for the same question which you asked.

Related