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