1 Reply Latest reply on Jun 23, 2008 7:37 PM by mmorearty

    Can you "call" the debugger?

      New at Flex programming so gimme a break if it's a stupid question.

      Short form: is there any way to "call" the Flex debugger from a running Flex application?

      Long form:

      Breakpoints and watchpoints and suchlike are all very well (I use 'em, I love 'em), but a handy capability is to be able to call the debugger "programmatically", more or less "as if" the executing code had hit a breakpoint.

      Years ago, using the debugger in Turbo C++, the language implementation allowed you to insert in-line assembly code anywhere you wanted to. If I was having some particularly difficult phase-of-the-moon debugging problem that would only evidence itself after 10,000 iterations or something, I could write an arbitrarily complex conditional statement that generated a debugging interrupt when the appropriate conditions were met. It would look something like:

      if (this && that && the-other-thing && some-other-thing-over-there && file-exists-on-disk && who-knows-what-else && It_Is(Tuesday))
      asm int 3h

      When the arbitrarily complex collection of conditions in the code were met, voilà, the interrupt 3h would execute, and the debugger would pop forward like magic, just exactly when I wanted it to, the call stack and variables and everything all just right to help find the problem. You didn't even have to remove the 'int 3h' from the production code if you didn't want to since it was essentially a no-op when a debugger wasn't present. (Bad practice, but true...)

      The advantages over watchpoints were the fact that the conditional statements could be arbitrarily complex, essentially anything that you could express programmatically. You could even say something like "but don't do a break if I happen to be holding down the shift key at the moment". Additionally, watchpoints are usually computationally expensive because the machine is having to "watch" some memory location or something, inserting countless thousands of lines of executable code to do the watching in between all of your statements. This methodology runs at flank speed up until the point you need the break to happen. The only thing it's not really good for are looking for corruptions that are happening as side effects of something else.

      So... is there anyway to call the Flex debugger from a running flex application?