www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Integrated Debugger

reply "David Barrett" <dbarrett quinthar.com> writes:
I see there are a bunch of IDEs that give syntax highlighting, intellisense,
and so on.  However, I can't find any that offer integrated debugging.

Does any IDE offer integrated debugging, including:
- Breakpoints
- Watches
- Run/Break/Step In/Step Over/Step Out
- ... etc ...

In my dream world I could install some Visual Studio plug-in, and it'd allow
me to develop in C++ and D, compile both into a single executable, and debug
all together.

Next best would be using Visual Studio for just D programming, even if I
can't seamlessly switch between C++ and D.

Next best would be some IDE that that lets me code, compile, and debug all
in one.

Basically, I'm not a fan of command-line debuggers, nor am I fan of *no*
debugger.

Any suggestions for a Visual Studio C++ programmer like me who wants to
switch to D?

-david
Jul 07 2004
parent reply Regan Heath <regan netwin.co.nz> writes:
------------EdizWzxElU9qhgsYnVEhOZ
Content-Type: text/plain; format=flowed; charset=iso-8859-15
Content-Transfer-Encoding: 8bit

On Wed, 7 Jul 2004 20:49:19 -0600, David Barrett <dbarrett quinthar.com> 
wrote:
 I see there are a bunch of IDEs that give syntax highlighting, 
 intellisense,
 and so on.  However, I can't find any that offer integrated debugging.

 Does any IDE offer integrated debugging, including:
 - Breakpoints
 - Watches
 - Run/Break/Step In/Step Over/Step Out
 - ... etc ...

 In my dream world I could install some Visual Studio plug-in, and it'd 
 allow
 me to develop in C++ and D, compile both into a single executable, and 
 debug
 all together.

 Next best would be using Visual Studio for just D programming, even if I
 can't seamlessly switch between C++ and D.

 Next best would be some IDE that that lets me code, compile, and debug 
 all
 in one.

 Basically, I'm not a fan of command-line debuggers, nor am I fan of *no*
 debugger.

 Any suggestions for a Visual Studio C++ programmer like me who wants to
 switch to D?

You can use Visual Studio to debug D binaries. It does not know about the inbuilt D arrays but with some knowledge of how they work you can get it to look at them. Attached are 2 files. 1. Instructions for using VC with D. (compiled from various sources: Arcane Jill, Myself, and Alan De Smet - http://www.highprogrammer.com/alan/windev/visualstudio.html) 2. Syntax highlighting data file. Use #1 it will tell you where to put #2. Let me know what you think. Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ ------------EdizWzxElU9qhgsYnVEhOZ Content-Disposition: attachment; filename=msvc-howto.txt Content-Type: text/plain; name=msvc-howto.txt Content-Transfer-Encoding: 8bit [syntax highlighting] 1. Save usertype.dat in C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin 2. Edit this key HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs/Language Settings\C/C++ FileExtensions=cpp;cxx;c;h;hxx;hpp;inl;tlh;tli;rc;rc2;cp add d to the list i.e. HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs/Language Settings\C/C++ FileExtensions=cpp;cxx;c;h;hxx;hpp;inl;tlh;tli;rc;rc2;cp;d [projects] 1. Create an MSDEV "Utility" project - these are like normal projects but they do not do the link step. 2. Create a folder in the project, set file extension to 'd' 3. Add your .d source files to this project. 4. Edit project settings, select the folder you created, define the following "Custom Build" settings: Commands: D:\D\dmd\bin\dmd.exe -c "$(InputPath)" -g -gt -debug -od"$(IntDir)" Output: $(IntDir)\$(InputName).obj 4. Edit project settings, click project name at top of tree on left, in the post-build section add the command d:\D\dmd\bin\dmd.exe -g "$(IntDir)\*.obj" -of"$(OutDir)\main.exe" [debug D arrays] First, you have to get your numbers displayed in hex, not in decimal. In this case 35518073867862116 happens to be 0x7E2F800000000064. So the high half - 0x7E2F8000 - is the address of the array in memory, and the low half - 0x00000064 - is the number of elements in the array. ------------EdizWzxElU9qhgsYnVEhOZ Content-Disposition: attachment; filename=usertype.dat Content-Type: application/octet-stream; name=usertype.dat Content-Transfer-Encoding: 8bit module import export interface mixin unittest debug version synchronized override invariant delegate deprecated abstract cast super align alias asm body inout out in foreach finally final assert with bit real cent byte ubyte ushort uint ulong ucent ireal ifloat idouble wchar dchar creal cfloat cdouble null is ------------EdizWzxElU9qhgsYnVEhOZ--
Jul 07 2004
parent reply "David Barrett" <dbarrett quinthar.com> writes:
Thanks for the fast response; this is a huge help.

You list one way to get at the array by manually casting the high DWORD to a
(char*) pointer.  That works great, thanks for the tip.  However, that
sounds painful to do while seriously debugging.  Have you found any nifty
macros or tips to streamline the process?

Likewise, any tricks on how to manually dereference structs/classes?  Or
even better, any ideas on how to make it understand them automatically?

Thank again, this is a *huge* help.

-david

"Regan Heath" <regan netwin.co.nz> wrote in message
news:opsasuxieh5a2sq9 digitalmars.com...
 On Wed, 7 Jul 2004 20:49:19 -0600, David Barrett <dbarrett quinthar.com>
 wrote:
 I see there are a bunch of IDEs that give syntax highlighting,
 intellisense,
 and so on.  However, I can't find any that offer integrated debugging.

 Does any IDE offer integrated debugging, including:
 - Breakpoints
 - Watches
 - Run/Break/Step In/Step Over/Step Out
 - ... etc ...

 In my dream world I could install some Visual Studio plug-in, and it'd
 allow
 me to develop in C++ and D, compile both into a single executable, and
 debug
 all together.

 Next best would be using Visual Studio for just D programming, even if I
 can't seamlessly switch between C++ and D.

 Next best would be some IDE that that lets me code, compile, and debug
 all
 in one.

 Basically, I'm not a fan of command-line debuggers, nor am I fan of *no*
 debugger.

 Any suggestions for a Visual Studio C++ programmer like me who wants to
 switch to D?

You can use Visual Studio to debug D binaries. It does not know about the inbuilt D arrays but with some knowledge of how they work you can get it to look at them. Attached are 2 files. 1. Instructions for using VC with D. (compiled from various sources: Arcane Jill, Myself, and Alan De Smet - http://www.highprogrammer.com/alan/windev/visualstudio.html) 2. Syntax highlighting data file. Use #1 it will tell you where to put #2. Let me know what you think. Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Jul 07 2004
next sibling parent reply "David Barrett" <dbarrett quinthar.com> writes:
Ok, I've answered the manual part of my class/struct dereferencing question.
In the D spec on the "D Application Binary Interface" page
(http://www.digitalmars.com/d/abi.html) it shows the layout of classes in
memory:

# Classes
# An object consists of:
#	offset	contents
#	------  --------
#	0:	pointer to vtable
#	4:	monitor
#	8...	non-static members

So you can manually offset the D pointer to get to the attribute you want.
Same thing for structs (without the vtable or monitor).

Unfortunately, that's still a big pain.  It'd be great to somehow convince
the Visual Studio debugger to at least dereference D structs (which are laid
out in memory exactly like C), or even D classes.

Any ideas how to automate the dereferencing for painless debugging?

-david

"David Barrett" <dbarrett quinthar.com> wrote in message
news:ccifjm$a6$1 digitaldaemon.com...
 Thanks for the fast response; this is a huge help.

 You list one way to get at the array by manually casting the high DWORD to

 (char*) pointer.  That works great, thanks for the tip.  However, that
 sounds painful to do while seriously debugging.  Have you found any nifty
 macros or tips to streamline the process?

 Likewise, any tricks on how to manually dereference structs/classes?  Or
 even better, any ideas on how to make it understand them automatically?

 Thank again, this is a *huge* help.

 -david

 "Regan Heath" <regan netwin.co.nz> wrote in message
 news:opsasuxieh5a2sq9 digitalmars.com...
 On Wed, 7 Jul 2004 20:49:19 -0600, David Barrett <dbarrett quinthar.com>
 wrote:
 I see there are a bunch of IDEs that give syntax highlighting,
 intellisense,
 and so on.  However, I can't find any that offer integrated debugging.

 Does any IDE offer integrated debugging, including:
 - Breakpoints
 - Watches
 - Run/Break/Step In/Step Over/Step Out
 - ... etc ...

 In my dream world I could install some Visual Studio plug-in, and it'd
 allow
 me to develop in C++ and D, compile both into a single executable, and
 debug
 all together.

 Next best would be using Visual Studio for just D programming, even if



 can't seamlessly switch between C++ and D.

 Next best would be some IDE that that lets me code, compile, and debug
 all
 in one.

 Basically, I'm not a fan of command-line debuggers, nor am I fan of



 debugger.

 Any suggestions for a Visual Studio C++ programmer like me who wants



 switch to D?

You can use Visual Studio to debug D binaries. It does not know about


 inbuilt D arrays but with some knowledge of how they work you can get it
 to look at them.

 Attached are 2 files.

 1. Instructions for using VC with D. (compiled from various sources:
 Arcane Jill, Myself, and Alan De Smet -
 http://www.highprogrammer.com/alan/windev/visualstudio.html)

 2. Syntax highlighting data file.

 Use #1 it will tell you where to put #2. Let me know what you think.

 Regan.

 --
 Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/


Jul 07 2004
parent reply Regan Heath <regan netwin.co.nz> writes:
On Wed, 7 Jul 2004 21:48:57 -0600, David Barrett <dbarrett quinthar.com> 
wrote:
 Ok, I've answered the manual part of my class/struct dereferencing 
 question.
 In the D spec on the "D Application Binary Interface" page
 (http://www.digitalmars.com/d/abi.html) it shows the layout of classes in
 memory:

 # Classes
 # An object consists of:
 #	offset	contents
 #	------  --------
 #	0:	pointer to vtable
 #	4:	monitor
 #	8...	non-static members

 So you can manually offset the D pointer to get to the attribute you 
 want.
 Same thing for structs (without the vtable or monitor).

 Unfortunately, that's still a big pain.  It'd be great to somehow 
 convince
 the Visual Studio debugger to at least dereference D structs (which are 
 laid
 out in memory exactly like C), or even D classes.

 Any ideas how to automate the dereferencing for painless debugging?

Sorry, no, Arcane Jill might have some ideas I believe she uses this more than I do. I gave up due to the above problems and I simply use printf now, so far I have not had to debug a large application, otherwise I'm sure I'd be at my wits end using printf all the time. Regan.
 -david

 "David Barrett" <dbarrett quinthar.com> wrote in message
 news:ccifjm$a6$1 digitaldaemon.com...
 Thanks for the fast response; this is a huge help.

 You list one way to get at the array by manually casting the high DWORD 
 to

 (char*) pointer.  That works great, thanks for the tip.  However, that
 sounds painful to do while seriously debugging.  Have you found any 
 nifty
 macros or tips to streamline the process?

 Likewise, any tricks on how to manually dereference structs/classes?  Or
 even better, any ideas on how to make it understand them automatically?

 Thank again, this is a *huge* help.

 -david

 "Regan Heath" <regan netwin.co.nz> wrote in message
 news:opsasuxieh5a2sq9 digitalmars.com...
 On Wed, 7 Jul 2004 20:49:19 -0600, David Barrett 

 wrote:
 I see there are a bunch of IDEs that give syntax highlighting,
 intellisense,
 and so on.  However, I can't find any that offer integrated 


 Does any IDE offer integrated debugging, including:
 - Breakpoints
 - Watches
 - Run/Break/Step In/Step Over/Step Out
 - ... etc ...

 In my dream world I could install some Visual Studio plug-in, and 


 allow
 me to develop in C++ and D, compile both into a single executable, 


 debug
 all together.

 Next best would be using Visual Studio for just D programming, even 



 can't seamlessly switch between C++ and D.

 Next best would be some IDE that that lets me code, compile, and 


 all
 in one.

 Basically, I'm not a fan of command-line debuggers, nor am I fan of



 debugger.

 Any suggestions for a Visual Studio C++ programmer like me who wants



 switch to D?

You can use Visual Studio to debug D binaries. It does not know about


 inbuilt D arrays but with some knowledge of how they work you can get 

 to look at them.

 Attached are 2 files.

 1. Instructions for using VC with D. (compiled from various sources:
 Arcane Jill, Myself, and Alan De Smet -
 http://www.highprogrammer.com/alan/windev/visualstudio.html)

 2. Syntax highlighting data file.

 Use #1 it will tell you where to put #2. Let me know what you think.

 Regan.

 --
 Using M2, Opera's revolutionary e-mail client: 



-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 07 2004
parent "David Barrett" <dbarrett quinthar.com> writes:
"Regan Heath" <regan netwin.co.nz> wrote in message
news:opsaszk3it5a2sq9 digitalmars.com...
 On Wed, 7 Jul 2004 21:48:57 -0600, David Barrett <dbarrett quinthar.com>
 wrote:
 Any ideas how to automate the dereferencing for painless debugging?

Sorry, no, Arcane Jill might have some ideas I believe she uses this more than I do. I gave up due to the above problems and I simply use printf now, so far I have not had to debug a large application, otherwise I'm sure I'd be at my wits end using printf all the time.

Heh, thanks. I'm not sure how the debugger "learns" what's inside of a class -- if it does it somehow through debug data embedded in the EXE, or if it gleans it from Intellisense of the source code. If it's the former, maybe there's some way to generate some sort of stub C++ structs/classes that are compiled into the app just so the debugger can figure out what to do with the D symbols. If it's the latter, maybe those same stub files could be compiled and picked up by Intellisense, again fooling the debugger to think that the D classes compiled into the EXE are actually C++ classes that it understands. Regardless, thanks for the great start. -david
Jul 07 2004
prev sibling parent reply Arcane Jill <Arcane_member pathlink.com> writes:
In article <ccifjm$a6$1 digitaldaemon.com>, David Barrett says...
Likewise, any tricks on how to manually dereference structs/classes?  Or

Two methods. They're both nasty kludges, but they do the job. Method 1. Make it explicit. Add some extra lines to your source code. That is, to see inside class c or struct s, just make some extra local variables: # debug int dbg_x = c.x; # debug char[] dbg_y = s.y; etc. Okay, it's nasty and hacky, but if your code's going wrong somewhere inside a given function, this method WILL allow you to find out where and how. Method 2. Study the D ABI. Understand how structs and classes are laid out in memory, and then use the VS memory window for manual inspection. Once you've found the address of the thing for which you are looking, you can write a fiercely complicated expression in the expressions pane to let you see the value (though that's not really necessary for ints of course, unless you want to see the value in decimal). This is not guaranteed to work, in general, because the D compiler is allowed to re-order the elements of a class. But after you've done it a few times, you get to know the "habits" of the compiler and the GC allocator, and things do become relatively easy. Jill
Jul 08 2004
next sibling parent "David Barrett" <dbarrett quinthar.com> writes:
"Arcane Jill" <Arcane_member pathlink.com> wrote in message
news:ccit1v$l2g$1 digitaldaemon.com...
 In article <ccifjm$a6$1 digitaldaemon.com>, David Barrett says...
Likewise, any tricks on how to manually dereference structs/classes?  Or

Two methods. They're both nasty kludges, but they do the job.

Ya, that's what I was afraid of. I'm wondering if there's some way to leverage Visual Studio's automatic debugger dereferencing. For example, maybe have a pre-compile step that generates C header files for all D classes/structs, such that I can manually cast each D pointer to a corresponding C struct for easy debugging. Basically, I *really* want to use D as I think it'll be a faster way to write high-quality code. But even if C++ is a "worse" language than D, C++ has much better tools. Do you find yourself using D because it's really cool, or because it actually improves productivity? The lack of a truly integrated debugger still, unfortunately, puts it into the "really cool" camp for me. -david
Jul 08 2004
prev sibling parent "Alex Besogonov" <alexy izh.com> writes:
Good <time-of-day>!

"Arcane Jill" <Arcane_member pathlink.com> wrote in message
news:ccit1v$l2g$1 digitaldaemon.com...
 Two methods. They're both nasty kludges, but they do the job.
 Method 1. Make it explicit.
 Method 2. Study the D ABI.

There's a file "VISUAL_STUDIO_DIR\Common7\Packages\ Debugger\autoexp.dat" where you can write custom type expansion macroses. I use it to make VS debugger understand std::string&Co from STLPort. Maybe it can be used to help debugging D applications? BTW, has anybody started ANTLR grammar of D? -- With respect, Alex Besogonov (alexy izh.com)
Jul 08 2004