FAQ
look at this code:
package main

//#include <stdio.h>
/*
void Print(int i){
         printf("result:%d\n",i);
}
*/
import "C"


func A() {
         a := 1
         b := 2
         c := 4
         C.Print((C.int)(a+b+c))
}

func main() {
         a := 1
         b := 2
         c := 3
         A() //gdb n command will step into this function
         C.Print((C.int)(a+b+c))
}


when i'm using gdb to debug this code, i find that the n command can't step
over any function, it will step into the function directly, it makes me
hard to debug while using cgo in golang.

anyone met this problem? OS: centos 6 or suse10, gcc 4.1.2 x86_64

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • StalkR at Sep 8, 2013 at 6:52 pm
    Disassembly indeed shows a call:
    => 0x401284 <main.main+52>: call 0x401200 <main.A>
    Same here on debian amd64, gdb 7.3, gcc 4.7.2: next enters main.A.
    Removing cgo (replace with fmt.Println) and I can next the call.

    For your debugging you can try this https://github.com/gdbinit/Gdbinit it's
    quite nice and in particular has a "stepo" (step over) command that works
    by setting a temporary breakpoint after the next instruction. Works nicely
    here.

    On Sat, Sep 7, 2013 at 4:32 PM, Allan Xu wrote:

    look at this code:
    package main

    //#include <stdio.h>
    /*
    void Print(int i){
    printf("result:%d\n",i);
    }
    */
    import "C"


    func A() {
    a := 1
    b := 2
    c := 4
    C.Print((C.int)(a+b+c))
    }

    func main() {
    a := 1
    b := 2
    c := 3
    A() //gdb n command will step into this function
    C.Print((C.int)(a+b+c))
    }


    when i'm using gdb to debug this code, i find that the n command can't
    step over any function, it will step into the function directly, it makes
    me hard to debug while using cgo in golang.

    anyone met this problem? OS: centos 6 or suse10, gcc 4.1.2 x86_64

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Sep 8, 2013 at 9:57 pm
    Please raise an issue.
    On Mon, Sep 9, 2013 at 4:51 AM, StalkR wrote:
    Disassembly indeed shows a call:
    => 0x401284 <main.main+52>: call 0x401200 <main.A>
    Same here on debian amd64, gdb 7.3, gcc 4.7.2: next enters main.A.
    Removing cgo (replace with fmt.Println) and I can next the call.

    For your debugging you can try this https://github.com/gdbinit/Gdbinit it's
    quite nice and in particular has a "stepo" (step over) command that works by
    setting a temporary breakpoint after the next instruction. Works nicely
    here.

    On Sat, Sep 7, 2013 at 4:32 PM, Allan Xu wrote:

    look at this code:
    package main

    //#include <stdio.h>
    /*
    void Print(int i){
    printf("result:%d\n",i);
    }
    */
    import "C"


    func A() {
    a := 1
    b := 2
    c := 4
    C.Print((C.int)(a+b+c))
    }

    func main() {
    a := 1
    b := 2
    c := 3
    A() //gdb n command will step into this function
    C.Print((C.int)(a+b+c))
    }


    when i'm using gdb to debug this code, i find that the n command can't
    step over any function, it will step into the function directly, it makes me
    hard to debug while using cgo in golang.

    anyone met this problem? OS: centos 6 or suse10, gcc 4.1.2 x86_64

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 7, '13 at 2:32p
activeSep 8, '13 at 9:57p
posts3
users3
websitegolang.org

3 users in discussion

Dave Cheney: 1 post Allan Xu: 1 post StalkR: 1 post

People

Translate

site design / logo © 2021 Grokbase