October 16, 2012
I have some C/C++ code which handles windows SEH exceptions and can output (in debug mode) a stack trace, for example:

This process has performed an illegal operation and has to close.
Exception code:       0xC0000005
Exception flags:      0x00000000
Exception address:    0x00401CEF
Number of parameters: 2
Exception info [0]:   0x00000001
Exception info [1]:   0x00000000
Call stack:
Address  Frame
00401CEF 0018FF44 main+5F
00401169 0018FF88 __tmainCRTStartup+10F
755833AA 0018FF94 BaseThreadInitThunk+12
77B69EF2 0018FFD4 RtlInitializeExceptionChain+63
77B69EC5 0018FFEC RtlInitializeExceptionChain+36

D binaries (on windows), compiled in debug mode, produce something similar:

object.Error: Access Violation
----------------
0x0040BE00
0x0040BC8B
0x77B8B459 in LdrRemoveLoadAsDataTable
0x77B8B42B in LdrRemoveLoadAsDataTable
0x77B40133 in KiUserExceptionDispatcher
0x0040254E
0x00402170
0x0041369D
0x755833AA in BaseThreadInitThunk
0x77B69EF2 in RtlInitializeExceptionChain
0x77B69EC5 in RtlInitializeExceptionChain
----------------

But, it doesn't output symbol names for the D functions.  Does anyone know why not?  Is there some reason it cannot?  Perhaps the debug information in the binary is incomplete.. IIRC that was an issue in the past and may still be.

I managed to wind my way through the code and find the stacktrace.d module with the StackTrace class which appears to be producing the stack trace.  Comparing it to my own, the major difference is on the StackWalk call I pass FunctionTableAccessRoutine and GetModuleBaseRoutine routines (3rd and 2nd to last parameters) .. I'm guessing there is some reason this wont work in D, can anyone enlighten me?

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
October 16, 2012
Am 16.10.2012 18:38, schrieb Regan Heath:> I have some C/C++ code which handles windows SEH exceptions and can
> output (in debug mode) a stack trace, for example:
>
> But, it doesn't output symbol names for the D functions.  Does anyone
> know why not?  Is there some reason it cannot?  Perhaps the debug
> information in the binary is incomplete.. IIRC that was an issue in the
> past and may still be.
>
> I managed to wind my way through the code and find the stacktrace.d
> module with the StackTrace class which appears to be producing the stack
> trace.  Comparing it to my own, the major difference is on the StackWalk
> call I pass FunctionTableAccessRoutine and GetModuleBaseRoutine routines
> (3rd and 2nd to last parameters) .. I'm guessing there is some reason
> this wont work in D, can anyone enlighten me?
>
> R
>

You could use cv2pdb to convert the debugging symbols into the pdb format, then the stackwaler will always be able to resolve the stack.

Also it helps when you compile with -gs (Always emmit stackframe) although that should only make a difference in release mode.

Depending on your version of the dbghelp.dll, which comes with the windows sdk, or visual studio, it will also correctlry resolve cv smybols. I have windows 7 64 bit service pack 1 with visual studio 2010 installed and the D stacktracking correctly resolves cv symbols for me.

Kind Regards
Benjamin Thaut
October 17, 2012
On Tue, 16 Oct 2012 17:52:38 +0100, Benjamin Thaut <code@benjamin-thaut.de> wrote:

> Am 16.10.2012 18:38, schrieb Regan Heath:> I have some C/C++ code which handles windows SEH exceptions and can
>  > output (in debug mode) a stack trace, for example:
>  >
>  > But, it doesn't output symbol names for the D functions.  Does anyone
>  > know why not?  Is there some reason it cannot?  Perhaps the debug
>  > information in the binary is incomplete.. IIRC that was an issue in the
>  > past and may still be.
>  >
>  > I managed to wind my way through the code and find the stacktrace.d
>  > module with the StackTrace class which appears to be producing the stack
>  > trace.  Comparing it to my own, the major difference is on the StackWalk
>  > call I pass FunctionTableAccessRoutine and GetModuleBaseRoutine routines
>  > (3rd and 2nd to last parameters) .. I'm guessing there is some reason
>  > this wont work in D, can anyone enlighten me?
>  >
>  > R
>  >
>
> You could use cv2pdb to convert the debugging symbols into the pdb format, then the stackwaler will always be able to resolve the stack.

So, the problem in my case is that dbghelp.dll doesn't understand the DMD CodeView (CV) debug information?

Ahh.. I think I've figured out where I've been going wrong.  It's been a while since I worked with any D and I was not passing the -g or -gc compile flags, only -debug, duh!

I figured this out when cv2pdb complained .. "no codeview debug entries found"

But, now I cannot compile.. (DMD32 D Compiler v2.060)

C:\>dmd -g -debug crash.d

OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Error 118: Filename Expected
Path=..etc..

Adding -v shows a linker command of:
C:\Development\D\dmd2\windows\bin\link.exe crash,,nul,user32+kernel32/co/noi;

The input file crash.obj is present, and a quick test removing the /co (debug information)
C:\Development\D\dmd2\windows\bin\link.exe crash,,nul,user32+kernel32/co/noi;

works fine.. any ideas where this is going wrong?

> Depending on your version of the dbghelp.dll, which comes with the windows sdk, or visual studio, it will also correctlry resolve cv smybols. I have windows 7 64 bit service pack 1 with visual studio 2010 installed and the D stacktracking correctly resolves cv symbols for me.

Interesting.  I searched and found 13 different versions of dbghelp.dll installed on my system.  I have windows 7 64 bit SP1 with VS2010 installed and it's not working for me.  I suspect in my case it's using one of the other 12 dlls.

In my VS2010 folder(s) I found 3 dbghelp.dll's all version 6.12.2.633, does that match yours?

In c:\Windows\System32 SysWOW64 and the winsxs folders the version is 6.1.7601.17514, which looks older but has a newer date on it.

I also found version 6.1.7600.16385 in the winsxs folders.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
October 17, 2012
I didn't go through the trouble and find out which version of dbghelp.dll exactly supports cv debugging symbols, but I know it depends on that. So I can not help you there.

The linker line looks fine, looks the same for me but works (also with dmd 2.060)

Did you modify your sc.ini file?

Kind Regards
Benjamin Thaut

October 17, 2012
On Wed, 17 Oct 2012 12:17:14 +0100, Benjamin Thaut <code@benjamin-thaut.de> wrote:

> I didn't go through the trouble and find out which version of dbghelp.dll exactly supports cv debugging symbols, but I know it depends on that. So I can not help you there.
>
> The linker line looks fine, looks the same for me but works (also with dmd 2.060)
>
> Did you modify your sc.ini file?

Nope.  But I have just got it working.  Something in my PATH variable is causing it trouble.  If I set PATH to only the dmd2\windows\bin folder everything works.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
October 17, 2012
On Wed, 17 Oct 2012 12:43:27 +0100, Regan Heath <regan@netmail.co.nz> wrote:

> On Wed, 17 Oct 2012 12:17:14 +0100, Benjamin Thaut <code@benjamin-thaut.de> wrote:
>
>> I didn't go through the trouble and find out which version of dbghelp.dll exactly supports cv debugging symbols, but I know it depends on that. So I can not help you there.
>>
>> The linker line looks fine, looks the same for me but works (also with dmd 2.060)
>>
>> Did you modify your sc.ini file?
>
> Nope.  But I have just got it working.  Something in my PATH variable is causing it trouble.  If I set PATH to only the dmd2\windows\bin folder everything works.

Ok.  Figured it all out.  OPTLINK doesn't like a PATH with + in it.

C:\TEMP>dmd -g -debug crash.d

C:\TEMP>set path=%path%;+

C:\TEMP>dmd -g -debug crash.d
OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Error 118: Filename Expected
Path=C:\Development\D\dmd2\windows\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Intel\DMIX;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\NTRU Cryptosystems\NTRU TCG Software Stack\bin\;C:\Program Files\NTRU Cryptosystems\NTRU TCG Software Stack\bin\;C:\Program Files\Wave Systems Corp\Gemalto\Access Client\v5\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Windows
Live\Shared;C:\Program Files (x86)\NASM;c:\Development;c:\Utils;c:\Utils\bind;C:\Program Files\TortoiseSVN\bin;C:\Program Files\SlikSvn\bin;;+
^
--- errorlevel 1

But, only if you compile with -g because this still works:

C:\TEMP>dmd -debug crash.d

Weird, huh.

Where do OPTLINK bugs get reported?

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
October 17, 2012
Am 17.10.2012 13:56, schrieb Regan Heath:
> On Wed, 17 Oct 2012 12:43:27 +0100, Regan Heath <regan@netmail.co.nz>
> wrote:
>
>> On Wed, 17 Oct 2012 12:17:14 +0100, Benjamin Thaut
>> <code@benjamin-thaut.de> wrote:
>>
>>> I didn't go through the trouble and find out which version of
>>> dbghelp.dll exactly supports cv debugging symbols, but I know it
>>> depends on that. So I can not help you there.
>>>
>>> The linker line looks fine, looks the same for me but works (also
>>> with dmd 2.060)
>>>
>>> Did you modify your sc.ini file?
>>
>> Nope.  But I have just got it working.  Something in my PATH variable
>> is causing it trouble.  If I set PATH to only the dmd2\windows\bin
>> folder everything works.
>
> Ok.  Figured it all out.  OPTLINK doesn't like a PATH with + in it.
>
> C:\TEMP>dmd -g -debug crash.d
>
> C:\TEMP>set path=%path%;+
>
> C:\TEMP>dmd -g -debug crash.d
> OPTLINK (R) for Win32  Release 8.00.12
> Copyright (C) Digital Mars 1989-2010  All rights reserved.
> http://www.digitalmars.com/ctg/optlink.html
> OPTLINK : Error 118: Filename Expected
> Path=C:\Development\D\dmd2\windows\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
> Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program
> Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files
> (x86)\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program
> Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program
> Files\Intel\DMIX;c:\Program Files (x86)\ATI
> Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\NTRU
> Cryptosystems\NTRU TCG Software Stack\bin\;C:\Program Files\NTRU
> Cryptosystems\NTRU TCG Software Stack\bin\;C:\Program Files\Wave Systems
> Corp\Gemalto\Access Client\v5\;C:\Program Files (x86)\Common Files\Roxio
> Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio
> Shared\10.0\DLLShared\;c:\Program Files (x86)\Microsoft SQL
> Server\90\Tools\binn\;C:\Program Files (x86)\Windows
> Live\Shared;C:\Program Files
> (x86)\NASM;c:\Development;c:\Utils;c:\Utils\bind;C:\Program
> Files\TortoiseSVN\bin;C:\Program Files\SlikSvn\bin;;+
> ^
> --- errorlevel 1
>
> But, only if you compile with -g because this still works:
>
> C:\TEMP>dmd -debug crash.d
>
> Weird, huh.
>
> Where do OPTLINK bugs get reported?
>
> R
>

At the same place where all the other bugs get reported: http://d.puremagic.com/issues/enter_bug.cgi?product=D

So does the stacktrace work now?

Kind Regards
Benjamin Thaut
October 17, 2012
On 10/17/12, Regan Heath <regan@netmail.co.nz> wrote:
> Where do OPTLINK bugs get reported?

Existing bug: http://d.puremagic.com/issues/show_bug.cgi?id=4831
October 17, 2012
On Wed, 17 Oct 2012 13:02:45 +0100, Benjamin Thaut <code@benjamin-thaut.de> wrote:

> Am 17.10.2012 13:56, schrieb Regan Heath:
>> On Wed, 17 Oct 2012 12:43:27 +0100, Regan Heath <regan@netmail.co.nz>
>> wrote:
>>
>>> On Wed, 17 Oct 2012 12:17:14 +0100, Benjamin Thaut
>>> <code@benjamin-thaut.de> wrote:
>>>
>>>> I didn't go through the trouble and find out which version of
>>>> dbghelp.dll exactly supports cv debugging symbols, but I know it
>>>> depends on that. So I can not help you there.
>>>>
>>>> The linker line looks fine, looks the same for me but works (also
>>>> with dmd 2.060)
>>>>
>>>> Did you modify your sc.ini file?
>>>
>>> Nope.  But I have just got it working.  Something in my PATH variable
>>> is causing it trouble.  If I set PATH to only the dmd2\windows\bin
>>> folder everything works.
>>
>> Ok.  Figured it all out.  OPTLINK doesn't like a PATH with + in it.
>>
>> C:\TEMP>dmd -g -debug crash.d
>>
>> C:\TEMP>set path=%path%;+
>>
>> C:\TEMP>dmd -g -debug crash.d
>> OPTLINK (R) for Win32  Release 8.00.12
>> Copyright (C) Digital Mars 1989-2010  All rights reserved.
>> http://www.digitalmars.com/ctg/optlink.html
>> OPTLINK : Error 118: Filename Expected
>> Path=C:\Development\D\dmd2\windows\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
>> Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program
>> Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files
>> (x86)\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program
>> Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program
>> Files\Intel\DMIX;c:\Program Files (x86)\ATI
>> Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\NTRU
>> Cryptosystems\NTRU TCG Software Stack\bin\;C:\Program Files\NTRU
>> Cryptosystems\NTRU TCG Software Stack\bin\;C:\Program Files\Wave Systems
>> Corp\Gemalto\Access Client\v5\;C:\Program Files (x86)\Common Files\Roxio
>> Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio
>> Shared\10.0\DLLShared\;c:\Program Files (x86)\Microsoft SQL
>> Server\90\Tools\binn\;C:\Program Files (x86)\Windows
>> Live\Shared;C:\Program Files
>> (x86)\NASM;c:\Development;c:\Utils;c:\Utils\bind;C:\Program
>> Files\TortoiseSVN\bin;C:\Program Files\SlikSvn\bin;;+
>> ^
>> --- errorlevel 1
>>
>> But, only if you compile with -g because this still works:
>>
>> C:\TEMP>dmd -debug crash.d
>>
>> Weird, huh.
>>
>> Where do OPTLINK bugs get reported?
>>
>> R
>>
>
> At the same place where all the other bugs get reported: http://d.puremagic.com/issues/enter_bug.cgi?product=D

Thanks, I see Andrej found an existing bug for it.

> So does the stacktrace work now?

Yep :)  Thanks for all your help.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
Top | Discussion index | About this forum | D home