Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-debug-dev] determining which breakpoint was hit

> What are you trying to achieve ?

I'm trying to write a plugin that can automate a task to be performed
after a specified breakpoint (from the user's Breakpoint View) is hit,
during a debug session. I want to do it generically for all debug
models. So I'm up at the Eclipse Debug interfaces like IBreakpoint. I
did this, and it works with JDT using the IThread.getBreakpoints() call,
which is the only documented way I see to find out which breakpoint a
thread is suspended at, but CDT (1.2 at least) just returns null in that
function.

In the messing with internals I shouldn't be messing with department:
The BreakpointHit object can point me to the Breakpoint object, but I
need the CBreakpoint (that implements IBreakpoint). From what I can
tell, the CBreakpointManager is the only thing that knows about the
mappings between CDI breakpoints and CBreakpoints, and its method
getBreakpoint() will give me what I want. And the only public way to get
that manager is the CDebugTarget.getAdapter call, but for that I have to
know ICBreakpointManager.class(), which I guess I can do with a
CDT-dependent plugin. So that should work as a nasty temporary solution.
:)

The real solution requires a change to CDT...

From the documentation of IThread.getBreakpoints:

"Returns the breakpoints that caused this thread to suspend, or an empty
collection if this thread is not suspended or was not suspended by a
breakpoint. Usually a single breakpoint will be returned, but this
collection can contain more than one breakpoint if two breakpoints are
at the same location in a program."

In GDB I guess all threads get suspended when a breakpoint is hit? So it
might be valid by this description to return the same breakpoint from
all IThreads. This would be quite easy to do given the data I see being
maintained already. If you wanted to be more elegant and only mention
the breakpoint in the thread where the breakpoint actually occurred,
that might be harder (I don't know off-hand if GDB even reports that?).

I apologize if I'm not making much sense as I'm a CDT newbie.

Geoff

[My opinions do not necessarily reflect those of my employer.]


Back to the top