Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

How to tel if IDE debugger is atatched.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
colin - 04 Jan 2008 19:18 GMT
Hi,

Im still trying to sort out whats cuasing the difference when the debugger
is attatched...

Ive finsihed re writting a lot of the code and although its a heck of a
lot faster it still gives the same visual diferences,
at least now it finishes a run in just second or two as oposed to nearly a
minute.

How can you tell if the debugger is atatched when you run it from the visual
C# express ?
ie either f5 or ctrl-f5, ive entered a command line parameter
"debuger_atatched" but this
is used both for f5 and ctrlf5 is used, the only way I can make it know the
diference is to
run it from outside the IDE with no parameters.

Is there any other way ?

im thinking of dumping everything when the debuger is atatched and doing a
compare when it isnt
or visa versa...

thanks

Colin =^.^=
Peter Duniho - 04 Jan 2008 20:33 GMT
> [...]
> How can you tell if the debugger is atatched when you run it from the  
> visual C# express ?

The debugger is always attached when you run it from the IDE.

Could you explain what you're trying to do more clearly?  Is there  
something about the Debugger.IsAttached property that doesn't fulfill the  
need?

> im thinking of dumping everything when the debuger is atatched and doing  
> a
> compare when it isnt or visa versa...

Why not just dump all the data you want to compare all the time (in a  
special debugging build, of course).  Then run once with the debugger,  
save the data, run again without the debugger, save the data, then compare  
the two collections of saved data.

Why is knowing whether the debugger is attached or not important?

Pete
Jon Skeet [C# MVP] - 04 Jan 2008 20:47 GMT
> > [...]
> > How can you tell if the debugger is atatched when you run it from the  
> > visual C# express ?
>
> The debugger is always attached when you run it from the IDE.

No, that's not true. If you use Ctrl+F5 instead of F5 (Start without
Debugging instead of Start Debugging), the program runs without the
debugger being attached. You can't break into it, stop it or anything
like that - it's a completely separate process.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Peter Duniho - 04 Jan 2008 21:34 GMT
>> The debugger is always attached when you run it from the IDE.
>
> No, that's not true. If you use Ctrl+F5 instead of F5 (Start without
> Debugging instead of Start Debugging), the program runs without the
> debugger being attached. You can't break into it, stop it or anything
> like that - it's a completely separate process.

Ah.  Duh.  Completely forgot about that (never use it myself :) ).

Thanks,
Pete
colin - 04 Jan 2008 21:27 GMT
>> [...]
>> How can you tell if the debugger is atatched when you run it from the
[quoted text clipped - 5 lines]
> something about the Debugger.IsAttached property that doesn't fulfill the
> need?

ah thats does it, duno why i didnt think to look for something like that :)

>> im thinking of dumping everything when the debuger is atatched and doing
>> a
[quoted text clipped - 6 lines]
>
> Why is knowing whether the debugger is attached or not important?

to at least save it in different files for a start,
then hopefully compare it in the program,
so I can see where its not doing exactly the same thing ...
can I re atatch the debugger ?

Colin =^.^=
Peter Duniho - 04 Jan 2008 21:37 GMT
> [...]
>> Why is knowing whether the debugger is attached or not important?
>
> to at least save it in different files for a start,
> then hopefully compare it in the program,
> so I can see where its not doing exactly the same thing ...

I would personally not worry about checking for the debugger being  
attached, and just save the files twice, renaming the first one before I  
run the program again to generate the second one.  Since the code is  
diagnostic-only, why complicate things by introducing a new dependency?

Of course, it would be important to write the data out as text.  But if  
you do that, it should be very easy to do a direct comparison (I'd  
probably use Windiff, which comes with Visual Studio, as it will detect  
and display all of the differences for you in an easy-to-use UI).

> can I re atatch the debugger ?

You should be able to attach to the process from within VS, yes...and as  
far as I know, the Debugger.IsAttached property will update to reflect the  
current state.

But you'll find out soon enough if that's not true, assuming you do go  
ahead and include debugger-attached-specific code.  :)

Pete
colin - 05 Jan 2008 13:49 GMT
>> [...]
>>> Why is knowing whether the debugger is attached or not important?
[quoted text clipped - 7 lines]
> run the program again to generate the second one.  Since the code is
> diagnostic-only, why complicate things by introducing a new dependency?

I didnt think of that but having the name indicate wether its attached is
reassuring.

> Of course, it would be important to write the data out as text.  But if
> you do that, it should be very easy to do a direct comparison (I'd
> probably use Windiff, which comes with Visual Studio, as it will detect
> and display all of the differences for you in an easy-to-use UI).

I added more and more data to the dump,
only finding a few diferences in floats of +/- 1 to 3 in the last of 7
digits,
but then noticed Xna.Framework.Ray.IntersectPlane was returning null in one
but not the other,
wich affected wether it thought surfaces were hidden or not wich explains
the visual differences.

it does a ray trace from a point wich is intended to be inside the model to
the point of interest
then checks that ray against every surface to determine if its behind that
surface or not.
there didnt seem to be a pattern so I dumped every call to it.

so I now have 2 x 45mb of data to compare,
Windiff has been churning cpu time for the last 1/2 hour trying to expand
the comparisons
lol... although the windiff I have came with Visual studio v6
I also have WinMerge but that spends ages at 100% cpu too

>> can I re atatch the debugger ?
>
[quoted text clipped - 4 lines]
> But you'll find out soon enough if that's not true, assuming you do go
> ahead and include debugger-attached-specific code.  :)

bah i have the express version seems its not available ...
no wonder I cldnt find it.

Colin =^.^=
Pedro Luna Montalvo - 05 Jan 2008 02:17 GMT
Check the property:  System.Diagnostics.Debugger.IsAttached.

Pedro Luna,
Gye, Ecu

"colin" <colin.rowe1@ntworld.NOSPAM.com> escribió en el mensaje de
noticias:eEvfj.2391$a61.2230@newsfe3-win.ntli.net...
> Hi,
>
[quoted text clipped - 23 lines]
>
> Colin =^.^=

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.