u936293
u936293

Reputation: 16264

gdb guide for the DEBUG user

I am very familiar with DEBUG.COM from DOS. I have just gotten the need to use gdb but I am stuck. I am sure gdb is much more versatile and powerful, but I just need to step through a piece of code (not generated by any particular language) efficiently and with good visibility of registers and selected memory locations. What are the gdb equivalent of DEBUG's:

U - unassemble (from select memory location)
D - dump
R - shows (selected) registers
T - executes instruction at current IP
P - step over

gdb seems to require run as the first step before I can even inspect the registers. But I would like to see what the first instruction is before I want to run. I can't put a break point at the first instruction if I don't know where it is. It's a chicken and egg problem for me. I must be missing something basic.

Upvotes: 0

Views: 93

Answers (1)

Tom Tromey
Tom Tromey

Reputation: 22569

I don't know DEBUG, but maybe I can help with your gdb questions. You're probably best off reading a gdb tutorial, though. Also you can see more details for any command using the gdb help command, e.g., help disassemble.

Your questions seem focused on low-level, assembly debugging. gdb is a multi-level debugger, by which I mean it can work at various levels; I would say that fundamentally it is a source-level debugger, but it can function ok at the assembly level as well.

  • unassemble. gdb equivalent is probably disassemble.

  • dump. I don't know what this does. If it dumps memory, then you want the gdb x command.

  • R. Try info regs, or you can print just a selected register using the name, like print $rax.

  • T. To step a single assembly instruction, si.

  • P. See the gdb ni command.

For the first instruction, you need to know some details about the platform. On Linux the first instruction is at _start, so you would break *_start.

Upvotes: 1

Related Questions