GDB's disassemble command is nice for short C identifiers, e.g. main. For long, mangled C++ identifiers the verbosity is overkill. For example, using icpc I see results like
(gdb) disassemble 0x49de2f 0x49de5b
Dump of assembler code from 0x49de2f to 0x49de5b:
0x000000000049de2f <_ZN5pecos8suzerain16fftw_multi_开发者_StackOverflow社区array6detail18c2c_buffer_processIPA2_dPKSt7complexIdEilNS2_26complex_copy_differentiateIS4_EEEEvT_T1_T2_T0_SD_SE_RKT3_+167>: mov 0x18(%rsp),%rsi
Displays that long are annoying in the CLI. They make GDB's TUI assembly display all but useless.
Is there a way to tell GDB to show a truncated identifier? Say clip all but 50 characters?
Current GDB from CVS behaves the way you want when it knows that there is only one function in the disassembly:
(gdb) disas 0x000000000040071c
Dump of assembler code for function _ZNKSt8_Rb_treeIPiSt4pairIKS0_S0_ESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE21_M_get_Node_allocatorEv:
0x000000000040071c <+0>: push %rbp
0x000000000040071d <+1>: mov %rsp,%rbp
0x0000000000400720 <+4>: mov %rdi,-0x8(%rbp)
0x0000000000400724 <+8>: mov -0x8(%rbp),%rax
0x0000000000400728 <+12>: leaveq
0x0000000000400729 <+13>: retq
End of assembler dump.
When GDB can't know whether or not disassembly will cross function boundary, it still prints the "long" form:
(gdb) disas 0x000000000040071c 0x000000000040071c+1
Dump of assembler code from 0x40071c to 0x40071d:
0x000000000040071c <_ZNKSt8_Rb_treeIPiSt4pairIKS0_S0_ESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE21_M_get_Node_allocatorEv+0>: push %rbp
End of assembler dump.
Here is the patch which introduced the "short form".
This doesn't really answer your question, but you might be able to at least demangle things to make them a little less ugly:
set print asm-demangle on
精彩评论