【问题标题】:GDB can't debug the go program within cgo codeGDB 无法在 cgo 代码中调试 go 程序
【发布时间】:2013-06-17 23:53:08
【问题描述】:

示例文件

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

【问题讨论】:

    标签: debugging gdb go cgo


    【解决方案1】:

    目前有一个未解决的错误:https://code.google.com/p/go/issues/detail?id=5221

    使用 gdb 调试 cgo 在 1.0 中工作,但目前在 1.1 中被破坏。正在处理中。

    【讨论】:

      猜你喜欢
      • 2018-11-20
      • 1970-01-01
      • 1970-01-01
      • 2019-07-25
      • 1970-01-01
      • 2013-12-21
      • 2021-02-20
      • 2021-12-22
      相关资源
      最近更新 更多