[BGL] setting a breakpoint in an algorithm visitor
p.156 of the BGL book: "... visitors are passed by value..." I was attempting to set a breakpoint in a visitor event handler (that I know is executing) but the breakpoint is seemingly ignored by my debugger. This is because the visitor I construct and subsequently pass to the algorithm is not the object that is actually dispatched by the algorithm. Correct? Using the Intel compiler under MS DevStudio 6 on Windows, I inserted a ::DebugBreak() (asm int 3) into the visitor and *do* hit that but only have assembly language and not source to step through at that point. Why are visitors passed to algorithms by value? Any suggestions for debugging visitor code at the C++ source level and not in assembly? - Regards Chris
Hi Chris, On Mon, 16 Sep 2002, Chris Russell wrote: cdr> p.156 of the BGL book: "... visitors are passed by value..." cdr> cdr> I was attempting to set a breakpoint in a visitor event handler (that cdr> I know is executing) but the breakpoint is seemingly ignored by my cdr> debugger. This is because the visitor I construct and subsequently cdr> pass to the algorithm is not the object that is actually dispatched cdr> by the algorithm. Correct? Using the Intel compiler under MS Yes, that is correct. cdr> DevStudio 6 on Windows, I inserted a ::DebugBreak() (asm int 3) into cdr> the visitor and *do* hit that but only have assembly language and not cdr> source to step through at that point. cdr> cdr> Why are visitors passed to algorithms by value? Any suggestions for Well, visitors are like functors, and the STL passes functors by-value. There are some non-trivial reasons for that decision that I don't have time to go into now. cdr> debugging visitor code at the C++ source level and not in assembly? cdr> Sorry, I don't have a lot of experience with that debugger. Regards, Jeremy ---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
... "debugging visitor code at the C++ source level and not in assembly?"
I've moved the code I want to debug into a little scrap class that I
instantiate along with the visitor, and subsequently pass into the visitor's
constructor by reference. The event handler dispatches through the reference
back into my non-copied object so I can debug it at the source level and not
in assembly. This seems to be working okay and once I'm satisfied, I'll just
fold the operational code back into the visitor and eliminate the scrap
class entirely.
----- Original Message -----
From: "Jeremy Siek"
participants (2)
-
Chris Russell
-
Jeremy Siek