Thread overview
Line numbers in backtraces (2017)
Oct 31, 2017
Tobias Pankrath
Oct 31, 2017
Moritz Maxeiner
Nov 01, 2017
Tobias Pankrath
Nov 01, 2017
Moritz Maxeiner
Nov 02, 2017
Tobias Pankrath
Nov 02, 2017
Moritz Maxeiner
October 31, 2017
Hi,

I'm using ArchLinux and the recent DMD from the Arch repositories and my backtraces show no line numbers. I now that is an old issue, but I'm back to D after a long pause and I thought that this used to work out of the box.

My backtraces look likes this:

> ??:? pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, const(char[])) [0xab5c9566]
> ??:? pure @safe bool std.exception.enforce!(Exception, bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0xab5c94e2]


I've found this StackOverflow Question from 2011 [1] and if I remember correctly this could be fixed by adding -L--export-dynamic which already is part of my dmd.conf

cat /etc/dmd.conf
> [Environment32]
> DFLAGS=-I/usr/include/dlang/dmd -L-L/usr/lib32 -L--export-dynamic -fPIC
> 
> [Environment64]
> DFLAGS=-I/usr/include/dlang/dmd -L-L/usr/lib -L--export-dynamic -fPIC

which is in fact read by dmd:
> % dmd -v
> DMD64 D Compiler v2.076.1
> Copyright (c) 1999-2017 by Digital Mars written by Walter Bright
> 
> Documentation: http://dlang.org/
> Config file: /etc/dmd.conf

How do I get useful back traces back?


Thanks,
Tobias

[1] https://stackoverflow.com/questions/8209494/how-to-show-line-numbers-in-d-backtraces
October 31, 2017
On Tuesday, 31 October 2017 at 11:04:57 UTC, Tobias Pankrath wrote:
> [...]
>> ??:? pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, const(char[])) [0xab5c9566]
>> ??:? pure @safe bool std.exception.enforce!(Exception, bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0xab5c94e2]
>
>
> I've found this StackOverflow Question from 2011 [1] and if I remember correctly this could be fixed by adding -L--export-dynamic which already is part of my dmd.conf
>
> [...]
>
> [1] https://stackoverflow.com/questions/8209494/how-to-show-line-numbers-in-d-backtraces

Does using dmd's `-g` option (compile with debug symbols) not work[1]?

[1] This is also what the answer in your linked SO post suggest?
November 01, 2017
On Tuesday, 31 October 2017 at 11:21:30 UTC, Moritz Maxeiner wrote:
> On Tuesday, 31 October 2017 at 11:04:57 UTC, Tobias Pankrath wrote:
>> [...]
>>> ??:? pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, const(char[])) [0xab5c9566]
>>> ??:? pure @safe bool std.exception.enforce!(Exception, bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0xab5c94e2]
>>
>>
>> I've found this StackOverflow Question from 2011 [1] and if I remember correctly this could be fixed by adding -L--export-dynamic which already is part of my dmd.conf
>>
>> [...]
>>
>> [1] https://stackoverflow.com/questions/8209494/how-to-show-line-numbers-in-d-backtraces
>
> Does using dmd's `-g` option (compile with debug symbols) not work[1]?
>
> [1] This is also what the answer in your linked SO post suggest?

Of course I've tried this.
November 01, 2017
On Wednesday, 1 November 2017 at 06:44:44 UTC, Tobias Pankrath wrote:
> On Tuesday, 31 October 2017 at 11:21:30 UTC, Moritz Maxeiner wrote:
>> On Tuesday, 31 October 2017 at 11:04:57 UTC, Tobias Pankrath wrote:
>>> [...]
>>>> ??:? pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, const(char[])) [0xab5c9566]
>>>> ??:? pure @safe bool std.exception.enforce!(Exception, bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0xab5c94e2]
>>>
>>>
>>> I've found this StackOverflow Question from 2011 [1] and if I remember correctly this could be fixed by adding -L--export-dynamic which already is part of my dmd.conf
>>>
>>> [...]
>>>
>>> [1] https://stackoverflow.com/questions/8209494/how-to-show-line-numbers-in-d-backtraces
>>
>> Does using dmd's `-g` option (compile with debug symbols) not work[1]?
>>
>> [1] This is also what the answer in your linked SO post suggest?
>
> Of course I've tried this.

Including Phobos? Your posted backtrace looks to me like templates instantiated within Phobos, so I think you'd need Phobos with debug symbols for those lines.
November 02, 2017
> Including Phobos? Your posted backtrace looks to me like templates instantiated within Phobos, so I think you'd need Phobos with debug symbols for those lines.

---
int main(string[] argv)
{
  return argv[1].length > 0;
}
---

> ~ [i] % rdmd -g -debug test.d
> core.exception.RangeError@test.d(3): Range violation
> ----------------

No difference when I compile with 'dmd -g -debug' and run in manually.

November 02, 2017
On Thursday, 2 November 2017 at 19:05:46 UTC, Tobias Pankrath wrote:
>> Including Phobos? Your posted backtrace looks to me like templates instantiated within Phobos, so I think you'd need Phobos with debug symbols for those lines.
>
> ---
> int main(string[] argv)
> {
>   return argv[1].length > 0;
> }
> ---
>
>> ~ [i] % rdmd -g -debug test.d
>> core.exception.RangeError@test.d(3): Range violation
>> ----------------
>
> No difference when I compile with 'dmd -g -debug' and run in manually.

That Error is thrown from within druntime. If you want to see line numbers for backtraces locations within druntime, you need to compile druntime with debug symbols.
Also `-debug` only changes conditional compilation behaviour[1].

[1] https://dlang.org/spec/version.html#DebugCondition