繁体   English   中英

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

[英]GDB can't debug the go program within cgo code

示例文件

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);
}

执行代码

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

谁能帮助我解决这个问题,非常感谢。

我的环境:

  • Ubuntu 11.04 i386
  • gdb 7.6
  • 去1.1

当前存在一个与此有关的未解决错误: https : //code.google.com/p/go/issues/detail?id=5221

使用gdb调试cgo在1.0中可用,但在1.1中已被破坏。 正在努力。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM