Is it possible to get gdb to disassemble machine code interactively. For example:
(gdb) [disassemble command] 0x58 0xef 0x22
If I give the above command gdb should interpret the hex values as machine code and g开发者_StackOverflowive me back the disassembly. The commands which I know of only disassemble a portion of the memory of the loaded program.
GDB can't do that directly, but you can come pretty close:
cat > t.c <<EOF
char buf[512];
int main() { return 0; }
EOF
gcc -g t.c -o t
gdb -q ./t
Reading symbols from /tmp/t...done.
(gdb) b main
Breakpoint 1 at 0x8048352: file t.c, line 2.
(gdb) r
Breakpoint 1, main () at t.c:2
2 int main() { return 0; }
(gdb) set buf[0] = 0x58
(gdb) set buf[1] = 0xef
(gdb) set buf[2] = 0x22
(gdb) x/i buf
0x8049560 <buf>: pop %eax
(gdb) q
精彩评论