somersetgraham | 15 Jun 2012 10:57
Favicon

gdb and python


Hi
I have just started using a python enabled gdb with Qt code and eclipse.
At times gdb(7.4) crashes when the variables window is displayed. I think
this must be something to do with gsb not knowing what type a variable is.

Has anyone else experienced this and is there a fix?

Thanks

Graham
--

-- 
View this message in context: http://old.nabble.com/gdb-and-python-tp34016836p34016836.html
Sent from the Gnu - gdb - General mailing list archive at Nabble.com.

Bob Plantz | 20 Jun 2012 19:38

Breakpoint on first instruction in program

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

         .text
         .globl  main
         .type   main,  <at> 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 
(Continue reading)

Adam Beneschan | 20 Jun 2012 22:39

Re: Breakpoint on first instruction in program


> I am using the following assembly language program (doNothingProg.s) for 
> instruction purposes:
> 
>          .text
>          .globl  main
>          .type   main,  <at> 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.

break *&main

                                -- Adam

Iurie | 20 Jun 2012 23:28
Picon

Re: Breakpoint on first instruction in program

that is the gdb command?

On 20 June 2012 21:39, Adam Beneschan <adam <at> irvine.com> wrote:

> I am using the following assembly language program (doNothingProg.s) for
> instruction purposes:
>
>          .text
>          .globl  main
>          .type   main, <at> 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.

break *&main

                               -- Adam



Adam Beneschan | 20 Jun 2012 23:33

Re: Breakpoint on first instruction in program


break *&main

> that is the gdb command?

Yes.  "break main" will break at the instruction past the prologue,
but "break *&main" just uses &main, which is the address of main, as
the breakpoint address.  I've tested this, but I can't say for certain
it will work with every version of gdb.

                                -- Adam

Iurie | 20 Jun 2012 23:47
Picon

Re: Breakpoint on first instruction in program

thanks for the answer, and after that how do i see how the stack frame is created.?

On 20 June 2012 22:33, Adam Beneschan <adam <at> irvine.com> wrote:

break *&main

> that is the gdb command?

Yes.  "break main" will break at the instruction past the prologue,
but "break *&main" just uses &main, which is the address of main, as
the breakpoint address.  I've tested this, but I can't say for certain
it will work with every version of gdb.

                               -- Adam

Adam Beneschan | 21 Jun 2012 00:02

Re: Breakpoint on first instruction in program


> thanks for the answer, and after that how do i see how the stack frame is
> created.?

"stepi" steps through each instruction.  "info reg" shows the
registers, so you can use this after each step to watch how they
change.  "info reg ebp esp" will just show you those two registers
specifically.  If ESP is, say, BFFFF830, I use this command to dump 8
words at that address:

x/8xw 0xbffff380

That's all I know.  If there's some clever way to define a macro
command to step an instruction and display the top of the stack all in
one command, someone else will have to help with that.

                                -- Adam

Bob Plantz | 21 Jun 2012 06:09
Picon

Re: Breakpoint on first instruction in program

On 6/20/2012 1:39 PM, Adam Beneschan wrote:
>   
>> I am using the following assembly language program (doNothingProg.s) for
>> instruction purposes:
>>
>>           .text
>>           .globl  main
>>           .type   main,  <at> 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.
> break *&main
>
>                                  -- Adam
Thank you for the response Adam.

Actually, break *main worked for me. (Or just br *main). I'm not in 
Linux right now, but I will double check next time I log in.

I found this by using info gdb and some looking around. As usual, the 
answer is in the documentation, as I often told my students. :-[

--Bob

Iurie | 21 Jun 2012 12:46
Picon

Re: Breakpoint on first instruction in program

Hi Bob,
what course u are teaching out there? give me the link to it, perhaps i will learn there something useful as i am also a student. 

On 21 June 2012 05:09, Bob Plantz <plantz <at> ieee.org> wrote:
On 6/20/2012 1:39 PM, Adam Beneschan wrote:
 
I am using the following assembly language program (doNothingProg.s) for
instruction purposes:

         .text
         .globl  main
         .type   main, <at> 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.
break *&main

                                -- Adam
Thank you for the response Adam.

Actually, break *main worked for me. (Or just br *main). I'm not in Linux right now, but I will double check next time I log in.

I found this by using info gdb and some looking around. As usual, the answer is in the documentation, as I often told my students. :-[

--Bob



Bob Plantz | 21 Jun 2012 17:41
Picon

Re: Breakpoint on first instruction in program

On 06/21/2012 03:46 AM, Iurie wrote:
Hi Bob,
what course u are teaching out there? give me the link to it, perhaps i will learn there something useful as i am also a student. 

I retired from teaching in 2004, but I keep my book, Introduction to Computer Architecture, updated. It is available on my web site: bob.cs.sonoma.edu

I checked info gdb. Under Source->Specify Location I found an entry for `*ADDRESS'. Apparently, the *ADDRESS form is for C, C++, Java, Objective-C, Fortran, minimal, and assembly. The *&ADDRESS' form is for Pascal and Modula-2. However, it seems that gdb is forgiving between these two forms. And, from my personal experience, this can differ between versions and can change over time.

--Bob



On 21 June 2012 05:09, Bob Plantz <plantz <at> ieee.org> wrote:
On 6/20/2012 1:39 PM, Adam Beneschan wrote:
 
I am using the following assembly language program (doNothingProg.s) for
instruction purposes:

         .text
         .globl  main
         .type   main, <at> 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.
break *&main

                                -- Adam
Thank you for the response Adam.

Actually, break *main worked for me. (Or just br *main). I'm not in Linux right now, but I will double check next time I log in.

I found this by using info gdb and some looking around. As usual, the answer is in the documentation, as I often told my students. :-[

--Bob





Gmane