【问题标题】:How do I get gdb working with D programs under linux?如何让 gdb 在 linux 下与 D 程序一起工作?
【发布时间】:2009-10-17 06:18:05
【问题描述】:

我有一个修补过的gdb 6.8,但我无法进行任何调试。鉴于此测试文件:

import std.stdio;

void main()
{
    float f = 3.0;
    int i = 1;
    writeln(f, " ", i);
    f += cast(float)(i / 10.0);
    writeln(f, " ", i);
    i++;
    f += cast(float)(i / 10.0);
    writeln(f, " ", i);
    i += 2;
    f += cast(float)(i / 5.0);
    writeln(f, " ", i);
}

并尝试在命令行上调试:

bash-4.0 [d]$ dmd -g test.d  # '-gc' shows the same behaviour.
bash-4.0 [d]$ ~/src/gdb-6.8/gdb/gdb test
GNU gdb 6.8
Copyright (C) 2008 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 "i686-pc-linux-gnu"...
(gdb) list
1 ../sysdeps/i386/elf/start.S: No such file or directory.
 in ../sysdeps/i386/elf/start.S

并使用 Eclipse 调试项目

使用-gc

Dwarf Error: Cannot find DIE at 0x134e4 referenced from DIE at 0x12bd4 [in module /home/bernard/projects/drl/drl.i386]
(gdb) Dwarf Error: Cannot find DIE at 0x1810 referenced from DIE at 0x1b8 [in module /home/bernard/projects/drl/drl.i386]

使用-g

(gdb) Die: DW_TAG_<unknown> (abbrev = 7, offset = 567)
 has children: FALSE
 attributes:
  DW_AT_byte_size (DW_FORM_data1) constant: 4
  DW_AT_type (DW_FORM_ref4) constant ref: 561 (adjusted)
  DW_AT_containing_type (DW_FORM_ref4) constant ref: 539 (adjusted)
Dwarf Error: Cannot find type of die [in module /home/bernard/projects/drl/drl.i386]

我在 Digital Mars 新闻组上看到过不少这样的帖子,但似乎都被忽略了。任何人都可以了解情况吗?

我知道 ZeroBUGS,但我真的很想让 gdb 工作。

更新:

感谢 luca_,在 IRC(freenode,#D)上,我得到了简单的案例(一个文件):

(gdb) list Dmain
1 void main()
2 {
3     float f = 3.0;
4     int i = 1;
5     f += cast(float)(i / 10.0);
6     i++;
7     f += cast(float)(i / 10.0);
8     i += 2;
9     f += cast(float)(i / 5.0);
10 }
(gdb) break  3

不幸的是,我的由多个文件组成的项目因 DWARF 错误而终止。

编辑:

截至 2.036(我认为),DMD 生成的 GDB 调试信息是正确的,应该可以按预期工作。

【问题讨论】:

    标签: linux debugging gdb d


    【解决方案1】:

    您可能偶然发现了一个 GDB 错误,该错误最近已修复 here

    要获得修复,您必须从 CVS Head 构建 GDB。如何获得它的说明是here

    如果这不能解决问题,可能是由于GDB 中的另一个错误,或者可能是dmd 发出了不正确的DWARF 调试信息。我建议在 GDB bugzilla 中打开一个错误并附加您的小型可执行文件(以及它需要的所有运行时库)。

    【讨论】:

    • 不幸的是,CVS Head 也出现了同样的问题。这:d.puremagic.com/issues/show_bug.cgi?id=1079 让我觉得这可能是 gdb 的问题。也就是说,ZeroBUGS 工作(或工作——它不会在这台机器上运行(而且,Descent 不支持它,因此希望让 gdb 工作)),所以它可能是 gdb。我可能必须学习 DWARF 和 dmd 和 gdb,然后看看我能做什么。没有调试会影响大问题。我什至无法获得堆栈跟踪(如果幸运的话,可能会出现最顶层的函数)!谢谢你的信息。让我有更多可以看的地方。
    【解决方案2】:

    答案似乎是使用GDC,如果你能忍受回到 D 2.015(这是 D2,我不知道 D1 的东西有多旧)。 GDB 效果很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 2023-02-02
      相关资源
      最近更新 更多