On 02/01/2012 07:38 PM, Frank wrote:

> I have a short script that generates an instruction-by-instruction
> execution trace of a program. However, as the script executes the
> "stepi" command in a loop, GDB displays several lines of disassembled
> machine code at each step instead of just the precise intruction being
> executed (which is indicated by a =>). I understand this is precisely
> what is desired in most cases, but I would like to get GDB to only
> display the line being executed (this makes for a smaller execution
> log file).
> 
> So, is there a way to control the number of context lines given when
> stepping through disassembled code? An environmental variable or
> control parameter of some sort? Much appreciated if you have the
> answer.


There's no such knob.

But instead of disassemble-next-line, you can do:

(gdb) display /i $pc

This only prints the insn at the current PC, but, also prints "1: x/i $pc" at
every step.

The best solution I can think of is to use the hook-stop (a hook that runs
every time the program stops)

(gdb) define hook-stop
> x/i $pc
>end

(gdb) si
=> 0x455197 <main+19>:  movq   $0x0,(%rax)
0x0000000000455197      29        memset (&args, 0, sizeof args);
(gdb) <enter>
=> 0x45519e <main+26>:  movq   $0x0,0x8(%rax)
0x000000000045519e      29        memset (&args, 0, sizeof args);
(gdb) <enter>
=> 0x4551a6 <main+34>:  movq   $0x0,0x10(%rax)
0x00000000004551a6      29        memset (&args, 0, sizeof args);
(gdb) <enter>
=> 0x4551ae <main+42>:  movq   $0x0,0x18(%rax)
0x00000000004551ae      29        memset (&args, 0, sizeof args);
(gdb)

-- 
Pedro Alves

_______________________________________________
bug-gdb mailing list
bug-gdb@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-gdb

Reply via email to