2

example files

src/test.go

package main
import (
  . "clib"
)
func main() {
  a := "123";
  b := "456";
  c := "789";
  println(a,b,c);
  Output("ABC");
}

src/clib/clib.h

#ifndef CLIB
void output(char* str);
#endif

src/clib/clib.c

#include "clib.h"
#include <stdio.h>
void output(char* str)
{
    printf("%s\n", str);
}

src/clib/clib.go

package clib
/*
#cgo CFLAGS:-g
#include "clib.h"
*/
import "C"
func Output(s string) {
  p := C.CString(s);
  C.output(p);
}

exec code

go build -gcflags "-N -l" test.go
gdb ./test
b 10
r
info locals  // <- every variable's value is wrong!

Who can help me solve this problem, thank you very much.

My Environment:

  • ubuntu 11.04 i386
  • gdb 7.6
  • go 1.1

1 Answer 1

4

There is currently an open bug regarding this: https://code.google.com/p/go/issues/detail?id=5221

Debugging cgo with gdb worked in 1.0 but is currently broken in 1.1. It's being worked on.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.