Discussion:
Break based on function access
(too old to reply)
Jack
2007-08-23 09:02:32 UTC
Permalink
Hello,
I've got a slightly complicated question.
Is that if I want a breakpoint to suspend execution only when certain
function calls it.
For example
void new()
{
go(); <<<<< breakpoint here
}

void a()
{
new();
}

void b()
{
new();
}


If I want "a" to suspend the execution, but not with "b", what can I do to
achieve this?
Thanks
Jack
David Lowndes
2007-08-23 10:25:25 UTC
Permalink
Post by Jack
I've got a slightly complicated question.
Is that if I want a breakpoint to suspend execution only when certain
function calls it.
For example
void new()
{
go(); <<<<< breakpoint here
}
void a()
{
new();
}
void b()
{
new();
}
If I want "a" to suspend the execution, but not with "b", what can I do to
achieve this?
I don't think there's any easy way of adding a condition logic to a
breakpoint such that it can check the call stack.

Why not put the breakpoint inside a()?

Dave
Jack
2007-08-23 10:47:40 UTC
Permalink
Post by David Lowndes
I don't think there's any easy way of adding a condition logic to a
breakpoint such that it can check the call stack.
Why not put the breakpoint inside a()?
Hi Dave:
Let me explain.
The initial notion of doing this was that I gave every function a
breakpoint. Time after time again stepping in and out those functionsn, I
felt a bit tedious. After I understood what "a" does, I'd like to skip
that.... actually I should reformat my reasoning

Just let's say i had a breakpoint in every function, after i pressed on F5
from c(), it would break into a(), i understood what that function does, I
disabled the breakpoint at "a",

void a()
{
// does a little work
}

void c()
{
a();
// blah blah blah
}

void d()
{
a();
// blah again
}

that is if "c" first calls, I shall let it stop for the time being. After i
grab the idea, i disabled the breakpoint, however when "d" calls, i don't
want to skip that just like what happens to c(). i'd like to see what
happens when "d" calls (such as watching the arguments etc).... so that d()
will suspend execution at a() again, but not c() anymore because I already
know how a() interacts with c(), but not a() with d()....

hope this makes sense
Thanks
Jack
David Lowndes
2007-08-23 18:39:43 UTC
Permalink
Post by Jack
hope this makes sense
Yes, but as I said before, I don't know how you'd achieve that other
than by putting breakpoints on each of the callers.

Dave
Ben Voigt [C++ MVP]
2007-09-12 13:43:24 UTC
Permalink
Post by David Lowndes
Post by Jack
hope this makes sense
Yes, but as I said before, I don't know how you'd achieve that other
than by putting breakpoints on each of the callers.
Yes, just use step into instead of run.
Post by David Lowndes
Dave
Loading...