www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21864] New: Line numbers and file names wrong in stack trace

https://issues.dlang.org/show_bug.cgi?id=21864

          Issue ID: 21864
           Summary: Line numbers and file names wrong in stack trace for
                    Dward debug info
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

As reported https://github.com/dlang/dmd/pull/12466#issuecomment-826404674

Followup to https://issues.dlang.org/show_bug.cgi?id=20460

it's actually quite easy to reproduce, but you need two modules at least.

module test20460a;

import test20460b;

void main ()
{
    foo(); // L7
}

int bar ()
{
    throw new Exception("Hello"); // L12
}
module test20460b;

import test20460a;

void foo ()
{
    // Some comment so that the call is at L8
    bar();
}
Currently, if I try to compile and run this (with upstream DMD):

% dmd --version
DMD64 D Compiler v2.096.0

Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved
written by Walter Bright
% dmd -g test20460a.d test20460b.d
% ./test20460a
object.Exception test20460a.d(12): Hello
----------------
test20460a.d:12 int test20460a.bar() [0x108407227]
test20460a.d:13 void test20460b.foo() [0x108407238]
test20460a.d:7 _Dmain [0x1084071ac]
Notice that multiple things are wrong:

Only test20460*a*.d shows up in the trace, but the second frame is in
test20460*b*.d;
Except for the first (the one in main), line number are wrong;

--
Apr 25