View Both Assembly and C code

前端 未结 3 1033
情歌与酒
情歌与酒 2021-01-30 04:06

Do we have a way to view assembly and c code both using gdb.

disassemble function_name shows only assembly, I was trying to find a way to easliy map c code to assembly.

3条回答
  •  再見小時候
    2021-01-30 04:57

    Try disassemble /m.

    Refer to http://sourceware.org/gdb/current/onlinedocs/gdb/Machine-Code.html#Machine-Code

    The format is similar to that of objdump -S, and intermixes source with disassembly. Sample output excerpt:

    10      int i = 0;
    => 0x0000000000400536 <+9>: movl   $0x0,-0x14(%rbp)
    
    11      while (1) {
    12          i++;
       0x000000000040053d <+16>:    addl   $0x1,-0x14(%rbp)
    

提交回复
热议问题