Golang:无法使用 C 库让 gdb 为 Go 程序工作

2024-01-15

平台是 Mac OS X Mavericks,我从 ports 安装 gdb 并签了字 https://sourceware.org/gdb/wiki/BuildingOnDarwin。对于简单的程序,它工作得很好,但是当我尝试使用 C 库的程序时,它无法加载符号。例如,如果我尝试 Go GLFW 绑定中的 FSAA 示例,我会得到以下输出:

~/g/s/g/g/e/g/fsaa > ggdb main
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin13.0.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/nils/gocode/src/github.com/go-gl/examples/glfw/fsaa/main...
warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/attriblocation.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/buffer.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/color.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/framebuffer.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/gl.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/matrix.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/object.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/program.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/renderbuffer.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/shader.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/texture.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/transformfeedback.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/uniformlocation.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/vertex.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/gl/_obj/vertexarray.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/glu/_obj/_cgo_export.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/glu/_obj/callback.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/glu/_obj/callback.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/glu/_obj/glu.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build184019101/github.com/go-gl/glu/_obj/tesselator.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build432883021/runtime/cgo/_obj/gcc_amd64.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build432883021/runtime/cgo/_obj/gcc_darwin_amd64.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build432883021/runtime/cgo/_obj/gcc_setenv.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build432883021/runtime/cgo/_obj/gcc_util.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build883630526/github.com/go-gl/glfw/_obj/_cgo_export.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build883630526/github.com/go-gl/glfw/_obj/callback.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build883630526/github.com/go-gl/glfw/_obj/callback.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build883630526/github.com/go-gl/glfw/_obj/glfw.cgo2.o': can't open to read symbols: No such file or directory.

warning: `/var/folders/rp/jyw8rd7j4hn10vyk5yjyfvw80000gn/T/go-build883630526/github.com/go-gl/glfw/_obj/image.cgo2.o': can't open to read symbols: No such file or directory.
(no debugging symbols found)...done.
(gdb) list
No symbol table is loaded.  Use the "file" command.
(gdb) 

我从后备箱里拿到了我的Go版本,go version says:

go version devel +f9af8b83c78c Fri Oct 25 23:00:22 2013 +0300 darwin/amd64

GDB版本是7.6。我不想介入 C 库,我只想调试我的 Go 代码。有任何想法吗?


你正在经历问题 5221 https://code.google.com/p/go/issues/detail?id=5221。一个相关的问题是this one https://stackoverflow.com/questions/17148279/gdb-cant-debug-the-go-program-within-cgo-code.

对于 ELF 文件,此问题已部分修复,但对于 Mach 格式仍然存在问题 你正在使用的。所以我想你必须等待 go 1.3 或来自tip的适当修复 解决这个问题。

基本上问题是您用于编译的链接器.c文件不解压 来自对象的调试信息(.o) 文件但引用它们。因为它们在之后被删除 构建过程,gdb 无法读取它们。

作为解决方法,您可以尝试运行go build -work for go-glfw以便构建 目录不会被删除,并且目标文件仍然可以访问。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Golang:无法使用 C 库让 gdb 为 Go 程序工作 的相关文章

  • 如何对结构切片而不是切片结构进行范围调整

    稍微玩了一下 Go HTML 模板后 我发现的所有循环模板中对象的示例都是将切片结构传递给模板 有点像这个示例 type UserList struct Id int Name string var templates template M
  • 在 QtCreator 中调试时如何查看 qDebug 消息

    我正在从 Eclipse CDT 带有 Qt 集成插件 过渡到 QtCreator 2 0 但仍有一件事困扰着我 QtCreator 当我在 QtCreator 中调试时 我在Application output tab直到我停止正在调试的
  • 获取局部变量

    当从已部署的应用程序获取堆栈跟踪作为错误报告时 获取实际变量值以重建抛出异常之前的系统状态也会很有帮助 类似的事情在 Java 中可行吗 如何才能做到这一点 干杯 最大限度 我很确定您无法获取堆栈跟踪中的局部变量 因为输出是从 StackT
  • 如何在 Go 中获取给定月份的第一个星期一?

    我正在尝试获取给定月份的第一个星期一 我能想到的最好方法是循环前 7 天 然后返回 Weekday Monday 有一个更好的方法吗 通过查看时间的 Weekday 您可以计算出第一个星期一 package main import fmt
  • 如何检查 MVC cshtml 页面中的调试模式

    如何检查 MVC cshtml 页面中的调试模式 此代码在 cshtml 页面中不起作用 bool isRelease false if DEBUG isRelease false else isRelease true endif if
  • 如何使用 std::string 创建条件断点

    假设我有这个功能 std string Func1 std string myString do some string processing std string newString Func2 myString return newSt
  • 如何在 Go 中使用与包同名的变量名?

    文件或目录的常见变量名称是 path 不幸的是 这也是 Go 中包的名称 此外 在 DoIt 中更改路径作为参数名称 如何编译此代码 package main import path os func main DoIt file txt f
  • 管理多租户 ArangoDB 连接

    我使用 ArangoDB Go 使用 go driver 并且需要实现多租户 这意味着每个客户都将在单独的数据库中拥有他的数据 我想要弄清楚的是如何使这种多租户发挥作用 我知道为每个请求创建一个新的数据库连接是不可持续的 这意味着我必须维护
  • 我的 Delphi 11.1 调试器在 x64 项目上突然变得非常缓慢;大约一周前还可以。有什么想法吗?

    更新 拔掉网络 电缆和wifi 会导致 几乎 恢复正常的调试速度 已尝试禁用防火墙没有任何变化 但没有网络恢复正常服务 更新 2 所有 Windows x64 版本都存在缓慢问题 而不仅仅是单个大型项目 如果我构建并调试 32 位 Wind
  • 打印任何类型的数组和列表的通用方法[重复]

    这个问题在这里已经有答案了 每当我调试一段涉及整数 双精度 字符串等数组或列表的代码时 有时我更喜欢打印它们 我为此所做的是为不同类型编写重载的 printArray printList 方法 for e g 我可能有这 3 种方法来打印各
  • Golang:如何在HTTP客户端的TLS配置中指定证书

    我有一个证书文件 该位置是 usr abc my crt我想将该证书用于我的 tls 配置 以便我的 http 客户端在与其他服务器通信时使用该证书 我当前的代码如下 mTLSConfig tls Config CipherSuites u
  • 为什么 GDB 调试器不断冻结 Xcode 4?

    这真是一个奇怪的错误 我正在开发一个使用相机源的 iPhone 项目 并通过 OpenGL 着色器运行它以对其应用效果 然而 每次我在代码中简单地创建一个新的 GLfloat 时 调试器都会在启动时冻结 我无法复制和粘贴文本 因为整个 XC
  • 内存转储格式类似于 gdb 中的 xxd

    我正在尝试检查一个缓冲区 其中包含二进制格式的消息 但也包含字符串数据 作为示例 我正在使用以下 C 代码 int main void char buf 100 x01 x02 x03 x04String Data xAA xBB xCC
  • 多个生产者,单个消费者:所有 goroutine 都在睡觉 - 死锁

    在继续工作之前 我一直遵循检查通道中是否有任何内容的模式 func consume msg lt chan message for if m ok lt msg ok fmt Println More messages m else bre
  • 如何调试apache虚拟主机配置?

    我的 apache 虚拟主机配置再次出现问题 使用默认配置而不是我的特定配置 问题不在于配置错误 而在于如何解决它 有人有好的建议可以快速解决此类问题吗 更多信息 默认的conf文件是这样的 NameVirtualHost
  • Brunch 源映射:在 Chrome 开发工具中未命中断点

    我正在使用 Brunch 中内置的默认源映射 我看到文件很好 但无法在源映射文件中命中断点 使用 Javascript 访问调试器debugger 有效 这让我相信早午餐方面出了问题 这是我的 brunch config js module
  • 我使用go语言打印到POS打印机,但打印出的中文字符很糟糕。 (英语没问题)

    我在用着this https github com alexbrainman printer去打包 一切都很好 但汉字打印得很差 我不擅长这种低级 硬件 编码的事情 所以有人提示我如何纠正我的代码 更新代码 func main testWi
  • Golang 结构的 XML 和 JSON 标签?

    我有一个可以根据 HTTP 请求标头输出为 JSON 或 XML 的应用程序 我可以通过将正确的标签添加到我正在使用的结构中来实现正确的输出 但我不知道如何为 JSON 和 XML 指定标签 例如 序列化以纠正 XML type Foo s
  • Golang http 写入响应,无需等待完成

    我正在构建一个应用程序 该应用程序构建 pdf 文件并在收到请求时将其返回给客户端 由于其中一些 pdf 文件可能需要一些时间才能生成 我想在客户端运行时定期将某种状态更新发送回客户端 当完成 pdf 文件的构建后 它也应该返回给客户 类似
  • 在pycharm中调试python代码

    这个问题类似于this https stackoverflow com questions 10240018 how to use pycharm to debug python script一 我正在尝试调试pyethapp https

随机推荐