Author Topic: Inconsistent breakpoint behavior  (Read 3906 times)

0 Members and 1 Guest are viewing this topic.

SEANT

  • Bull Frog
  • Posts: 345
Inconsistent breakpoint behavior
« on: December 25, 2008, 03:50:22 AM »
I have a general question about debugging with VS 2005 and AutoCAD.  Does anyone else suffer the situation where a breakpoint will work correctly on a first debug, but will cause a break back at the first line of code on subsequent runs?

Up till now I’ve just considered it a VS quirk.  It has started to become a pain in the ass, however, so I’d like to do something other than just live with it.  I’d appreciate any suggestions before I go mucking about in Tools – Options – Debugging.
Sean Tessier
AutoCAD 2016 Mechanical

pkohut

  • Guest
Re: Inconsistent breakpoint behavior
« Reply #1 on: December 25, 2008, 04:52:28 AM »
Tend to see wierd behavior when stepping through try catch blocks.  It's fine,
just tracks wrong in the debugger.  Could that be it?

Paul

SEANT

  • Bull Frog
  • Posts: 345
Re: Inconsistent breakpoint behavior
« Reply #2 on: December 25, 2008, 05:27:35 AM »
I think I know what you’re getting at; the dev environment is very staccato like through the Try/Catch.

An example of the situation I’m investigating; with a CommandMethod ("test") and nothing more than one “static public void Tester()” and a break point set at, say, ¾ of the way down – a first run would break at the appropriate point.  If the command test is invoked again, VS requires stepping through Tester() from its first line.  I’m starting to wear out my F8 key.  :?
Sean Tessier
AutoCAD 2016 Mechanical

pkohut

  • Guest
Re: Inconsistent breakpoint behavior
« Reply #3 on: December 25, 2008, 06:14:37 AM »
Sure your not trying to debug a release build   :roll:  Not that I've ever
tried to do that, not even the other day  :ugly:

pkohut

  • Guest
Re: Inconsistent breakpoint behavior
« Reply #4 on: December 25, 2008, 06:22:23 AM »
I think I know what you’re getting at; the dev environment is very staccato like through the Try/Catch.

An example of the situation I’m investigating; with a CommandMethod ("test") and nothing more than one “static public void Tester()” and a break point set at, say, ¾ of the way down – a first run would break at the appropriate point.  If the command test is invoked again, VS requires stepping through Tester() from its first line.  I’m starting to wear out my F8 key.  :?


Can you post just enough code to reproduce the problem?  I tried what you suggesting in C# but don't see the
behavior you describe.

SEANT

  • Bull Frog
  • Posts: 345
Re: Inconsistent breakpoint behavior
« Reply #5 on: December 25, 2008, 08:12:49 AM »
Sure your not trying to debug a release build   :roll:  Not that I've ever
tried to do that, not even the other day  :ugly:

That sounds like something I'd do, but no.  I have to assume there's something amiss with my setup.  This behavior is so annoying it would be hard to miss.

Here is a basic test routine (The routine currently in the works deals with twist angles in pviewports, but that is another matter entirely).  The two screen shots below would be how the dev environment appears directly after two consecutive calls to the “test” command, the second requiring F8 through all the Prompts.

Code: [Select]
using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;

Code: [Select]
[CommandMethod("test")]
        static public void tester()
        {
            Double ang;
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptPointOptions ppo = new PromptPointOptions("\nSpecify base point:  ");
            PromptPointResult ppr = ed.GetPoint(ppo);
            if (ppr.Status != PromptStatus.OK) return;
            PromptAngleOptions pao = new PromptAngleOptions("Specify base angle: ");
            pao.BasePoint = ppr.Value;
            pao.UseBasePoint = true;
            PromptDoubleResult pdr = ed.GetAngle(pao);     
            ang = pdr.Value;
            pao.Message = "Specify second angle: ";
            pdr = ed.GetAngle(pao);
            ang = pdr.Value - ang;
            ang = ang/Math.PI * 180;
            ed.WriteMessage ("\nAngle: " + ang.ToString() + " Degrees.");
        }
« Last Edit: December 25, 2008, 08:16:59 AM by SEANT »
Sean Tessier
AutoCAD 2016 Mechanical

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Inconsistent breakpoint behavior
« Reply #6 on: December 25, 2008, 10:38:59 AM »

worked as expected for me in AC2008 with VS2008 net3.5.

only thing I needed to do was change
Document doc = Application.DocumentManager.MdiActiveDocument;
to
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
with this using statement
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
'cause I tested it in a solution that used a form and I was getting this
Error 'Application' is an ambiguous reference between 'System.Windows.Forms.Application' and 'Autodesk.AutoCAD.ApplicationServices.Application'   

It's a while since I've played with vs2005 .. but, you mention F8 .. step into is F11 in VS2008
how are you completing the first run through ?

.. Just worked out the problem ..
you must be stepping through ALL the way.When you get to the last bracket ( or anytime prior) hit F5 to continue ; that should fix it.



kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

TonyT

  • Guest
Re: Inconsistent breakpoint behavior
« Reply #7 on: December 25, 2008, 10:47:56 AM »
I have a general question about debugging with VS 2005 and AutoCAD.  Does anyone else suffer the situation where a breakpoint will work correctly on a first debug, but will cause a break back at the first line of code on subsequent runs?

Up till now I’ve just considered it a VS quirk.  It has started to become a pain in the ass, however, so I’d like to do something other than just live with it.  I’d appreciate any suggestions before I go mucking about in Tools – Options – Debugging.


Are you using start (F5) or step-into (F11) ?

How are you loading your assembly?  

Are you sure there's no other 'stale' copies of your assembly in
the PATH or in the AutoCAD folder, that may be getting loaded
instead of the one you expect to be loaded?

My suspicion is that the assembly you're loading is not the
same version that the .pdb file was generated for.

I'm also assuming you're haven't changed any settings in
your project properties (like don't generate debug info, or
turning on code optimization in a debug build).

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Inconsistent breakpoint behavior
« Reply #8 on: December 25, 2008, 11:56:59 AM »
I get that behavior with 2008 only after changing the code while stepping through. If you can't fix it just hit f5 again to bring you to your break point

pkohut

  • Guest
Re: Inconsistent breakpoint behavior
« Reply #9 on: December 25, 2008, 04:36:36 PM »

Are you sure there's no other 'stale' copies of your assembly in
the PATH or in the AutoCAD folder, that may be getting loaded
instead of the one you expect to be loaded?

My suspicion is that the assembly you're loading is not the
same version that the .pdb file was generated for.


I think this could be the winner.

SEANT

  • Bull Frog
  • Posts: 345
Re: Inconsistent breakpoint behavior
« Reply #10 on: December 25, 2008, 08:09:35 PM »
.. Just worked out the problem ..
you must be stepping through ALL the way.When you get to the last bracket ( or anytime prior) hit F5 to continue ; that should fix it.



I hope everyone had a good holiday.  I did, plus I find here the solution to the problem.  I was stepping through (F8 in VS 2005) to the last bracket.  The F5 continue was key.

I appreciate all the responces, however, as I suspect each one includes a solution to problems with similar symptoms.  I am still a bit green . . . . concievably, some of those responces were based on my having a reasonable handle on the Dev. Env.  :?  Sorry about that.

« Last Edit: December 26, 2008, 06:08:05 AM by SEANT »
Sean Tessier
AutoCAD 2016 Mechanical