gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Breakpoint on first instruction in program


From: Bob Plantz
Subject: Breakpoint on first instruction in program
Date: Wed, 20 Jun 2012 10:38:29 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

I am using the following assembly language program (doNothingProg.s) for instruction purposes:

        .text
        .globl  main
        .type   main, @function
main:
        pushq   %rbp        # save caller's frame pointer
        movq    %rsp, %rbp  # establish our frame pointer
        movl    $0, %eax    # return 0 to caller
        movq    %rbp, %rsp  # restore stack pointer
        popq    %rbp        # restore caller's frame pointer
        ret                 # back to caller

I want to set a breakpoint at the first instruction (pushq %rbp) so students can see how the stack frame is created.

I am running Ubuntu 12.04.

Under a previous version ( GNU gdb 6.8-debian) I could do this.
Under the current version (GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04) when I set the breakpoint on that line then run the program, it actually breaks at the third instruction (movl $0, %eax).

I understand that the first two instructions are the prologue to the actual "work" of this function, and since gdb is intended for higher level languages, but it is possible to make a mistake in the prologue in assembly language.

Is there any way to get gdb to honor my request for a breakpoint on the first instruction of the program? Again, my main goal here is to allow students to single step through the stack frame set up.

--Bob Plantz




reply via email to

[Prev in Thread] Current Thread [Next in Thread]