title: GDB can't debug the go program within cgo code
body: <h1>example files</h1>
  
  <h2>src/test.go</h2>
  
  <pre><code>package main
  import (
    . "clib"
  )
  func main() {
    a := "123";
    b := "456";
    c := "789";
    println(a,b,c);
    Output("ABC");
  }
  </code></pre>
  
  <h2>src/clib/clib.h</h2>
  
  <pre><code>#ifndef CLIB
  void output(char* str);
  #endif
  </code></pre>
  
  <h2>src/clib/clib.c</h2>
  
  <pre><code>#include "clib.h"
  #include &lt;stdio.h&gt;
  void output(char* str)
  {
      printf("%s\n", str);
  }
  </code></pre>
  
  <h2>src/clib/clib.go</h2>
  
  <pre><code>package clib
  /*
  #cgo CFLAGS:-g
  #include "clib.h"
  */
  import "C"
  func Output(s string) {
    p := C.CString(s);
    C.output(p);
  }
  </code></pre>
  
  <h1>exec code</h1>
  
  <pre><code>go build -gcflags "-N -l" test.go
  gdb ./test
  b 10
  r
  info locals  // &lt;- every variable's value is wrong!
  </code></pre>
  
  <hr>
  
  <p>Who can help me solve this problem, thank you very much.</p>
  
  <p>My Environment:</p>
  
  <ul>
  <li>ubuntu 11.04 i386</li>
  <li>gdb 7.6</li>
  <li>go 1.1</li>
  </ul>