如何使用gdb在Linux下使用D程序? [英] How do I get gdb working with D programs under linux?

查看:129
本文介绍了如何使用gdb在Linux下使用D程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个修补的 gdb 6.8,但我无法让任何调试工作。给定这个测试文件:

I have a patched gdb 6.8, but I can't get any debugging to work. Given this test file:

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

And debugging a project with 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]

我在数字火星新闻组看到了很多这样的帖子,但都看起来被忽略了。任何人都可以了解情况吗?

I've seen quite a few posts like this on the Digital Mars newsgroup, but all are seemingly ignored. Can anyone shed some light on the situation?

我知道ZeroBUGS,但我真的想得到 gdb 工作

I know of ZeroBUGS, but I really want to get gdb working.

更新:

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

Thanks to luca_, on IRC (freenode, #D), I got the simple case (one file) working:

(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错误。

Unfortunately, my project made up of multiple files dies with a DWARF error.

编辑:

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

As of 2.036 (I think), the GDB debugging information produced by DMD is correct, and should work as expected.

推荐答案

您可能已经绊倒了一个 GDB 错误,最近修正了这里

You may have stumbled on a GDB bug, which was recently fixed here.

要获得修复,您必须从CVS头构建 GDB 。有关如何获取的说明,请此处

To get the fix, you would have to build GDB from CVS Head. Instructions on how to get it are here.

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

If that doesn't fix the problem, it may be due to another bug in GDB, or it may be that dmd emits incorrect DWARF debug info. I suggest opening a bug in GDB bugzilla and attaching your small executable (and all runtime libraries it requires).

这篇关于如何使用gdb在Linux下使用D程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆