www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Windows Stack Traces: Function Names?

reply dsimcha <dsimcha yahoo.com> writes:
I've noticed that stack trace support has been added for Windows in the 
latest DMD release.  However, it seems to only print function addresses 
(basically useless) instead of function names like it does on Linux.  Is 
there a way to enable function names being printed on Windows? 
(Compiling w/ debugging symbols doesn't seem to do it.)
May 26 2011
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Thu, 26 May 2011 16:14:23 +0300, dsimcha <dsimcha yahoo.com> wrote:

 I've noticed that stack trace support has been added for Windows in the  
 latest DMD release.  However, it seems to only print function addresses  
 (basically useless) instead of function names like it does on Linux.  Is  
 there a way to enable function names being printed on Windows?  
 (Compiling w/ debugging symbols doesn't seem to do it.)
Function names work for me when using -g or -gc. I recall that you need a recent version of dbghelp.dll to see the function names. -- Best regards, Vladimir mailto:vladimir thecybershadow.net
May 26 2011
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
Join the club!

You can run cv2pdb on the exe via "cv2pdb main.exe main.exe", and the
names will show up. Installing new versions of dbhelp.dll didn't work
for me.
May 26 2011
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Thu, 26 May 2011 17:00:57 +0300, Andrej Mitrovic  
<andrej.mitrovich gmail.com> wrote:

 Join the club!

 You can run cv2pdb on the exe via "cv2pdb main.exe main.exe", and the
 names will show up. Installing new versions of dbhelp.dll didn't work
 for me.
Works for me without cv2pdb: C:\Temp\D\StackTrace> type test.d void test() { throw new Exception("aoeu"); } void main() { test(); } C:\Temp\D\StackTrace> dmd -g test C:\Temp\D\StackTrace> test object.Exception test.d(3): aoeu ---------------- C:\Temp\D\StackTrace\test.d(8): _Dmain ---------------- C:\Temp\D\StackTrace> which dbghelp.dll Found in PATH: C:\Windows\System32\dbghelp.dll C:\Temp\D\StackTrace> sigcheck C:\Windows\System32\dbghelp.dll Sigcheck v1.70 - File version and signature viewer Copyright (C) 2004-2010 Mark Russinovich Sysinternals - www.sysinternals.com c:\windows\system32\dbghelp.dll: Verified: Signed Signing date: 13:08 2008.01.19 Publisher: Microsoft Corporation Description: Windows Image Helper Product: Microsoftо Windowsо Operating System Version: 6.0.6001.18000 File version: 6.0.6001.18000 (longhorn_rtm.080118-1840) -- Best regards, Vladimir mailto:vladimir thecybershadow.net
May 26 2011
next sibling parent reply dsimcha <dsimcha yahoo.com> writes:
== Quote from Vladimir Panteleev (vladimir thecybershadow.net)'s article
 On Thu, 26 May 2011 17:00:57 +0300, Andrej Mitrovic
 <andrej.mitrovich gmail.com> wrote:
 Join the club!

 You can run cv2pdb on the exe via "cv2pdb main.exe main.exe", and the
 names will show up. Installing new versions of dbhelp.dll didn't work
 for me.
Works for me without cv2pdb: C:\Temp\D\StackTrace> type test.d void test() { throw new Exception("aoeu"); } void main() { test(); } C:\Temp\D\StackTrace> dmd -g test C:\Temp\D\StackTrace> test object.Exception test.d(3): aoeu ---------------- C:\Temp\D\StackTrace\test.d(8): _Dmain ---------------- C:\Temp\D\StackTrace> which dbghelp.dll Found in PATH: C:\Windows\System32\dbghelp.dll C:\Temp\D\StackTrace> sigcheck C:\Windows\System32\dbghelp.dll Sigcheck v1.70 - File version and signature viewer Copyright (C) 2004-2010 Mark Russinovich Sysinternals - www.sysinternals.com c:\windows\system32\dbghelp.dll: Verified: Signed Signing date: 13:08 2008.01.19 Publisher: Microsoft Corporation Description: Windows Image Helper Product: Microsoftо Windowsо Operating System Version: 6.0.6001.18000 File version: 6.0.6001.18000 (longhorn_rtm.080118-1840)
I get the following out of sigcheck: c:\windows\system32\dbghelp.dll: Verified: Signed Signing date: 11:17 PM 7/13/2009 Publisher: Microsoft Corporation Description: Windows Image Helper Product: Microsoft« Windows« Operating System Version: 6.1.7600.16385 File version: 6.1.7600.16385 (win7_rtm.090713-1255)
May 26 2011
parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
C:\>type test.d
void test()
{
       throw new Exception("aoeu");
}

void main()
{
       test();
}

C:\>dmd -g test

C:\>test
object.Exception test.d(3): aoeu
----------------
40D18C
40D003
402058
402704
402743
40233F
411FD1
----------------

C:\>which dbghelp.dll
C:\WINDOWS\system32\dbghelp.dll

C:\>sigcheck C:\WINDOWS\system32\dbghelp.dll

Sigcheck v1.66 - File version and signature viewer
Copyright (C) 2004-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

c:\windows\system32\dbghelp.dll:
        Verified:       Signed
        Signing date:   22:27 01/02/2010
        Publisher:      Microsoft Corporation
        Description:    Windows Image Helper
        Product:        Debugging Tools for Windows(R)
        Version:        6.12.0002.633
        File version:   6.12.0002.633 (debuggers(dbg).100201-1203)
May 26 2011
prev sibling parent reply dsimcha <dsimcha yahoo.com> writes:
Ok, got it.  I think I've found out why different people keep getting different
results.  If I compile and link in one step, everything works, i.e.:

dmd -g test.d
test

If I compile and link in separate steps, which is the default for my IDE, it
doesn't work, i.e.:

dmd -c -g test.d
dmd test.obj
test

Unless there's a good reason why this shouldn't work, I'll be filing a bug
report.
 BTW, the binary produced by the second method is ~90k smaller than the one
produced by the first method, so it's probably missing some information.
May 26 2011
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Thu, 26 May 2011 17:51:40 +0300, dsimcha <dsimcha yahoo.com> wrote:

 If I compile and link in separate steps, which is the default for my  
 IDE, it
 doesn't work, i.e.:
I believe you need to pass -g to dmd when linking, too. -- Best regards, Vladimir mailto:vladimir thecybershadow.net
May 26 2011
parent reply dsimcha <dsimcha yahoo.com> writes:
== Quote from Vladimir Panteleev (vladimir thecybershadow.net)'s article
 On Thu, 26 May 2011 17:51:40 +0300, dsimcha <dsimcha yahoo.com> wrote:
 If I compile and link in separate steps, which is the default for my
 IDE, it
 doesn't work, i.e.:
I believe you need to pass -g to dmd when linking, too.
Dead on. Thanks!!
May 26 2011
parent dsimcha <dsimcha yahoo.com> writes:
== Quote from dsimcha (dsimcha yahoo.com)'s article
 == Quote from Vladimir Panteleev (vladimir thecybershadow.net)'s article
 On Thu, 26 May 2011 17:51:40 +0300, dsimcha <dsimcha yahoo.com> wrote:
 If I compile and link in separate steps, which is the default for my
 IDE, it
 doesn't work, i.e.:
I believe you need to pass -g to dmd when linking, too.
Dead on. Thanks!!
...It still doesn't seem to work when optimization (the -O flag) is enabled, though.
May 26 2011