duanli0453 2013-06-17 05:09
浏览 191
已采纳

GDB无法在cgo代码中调试go程序

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
", 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条回答 默认 最新

  • dqwh1219 2013-06-17 05:13
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部