Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Switching to debug perspective on suspend
Switching to debug perspective on suspend [message #313978] Thu, 29 March 2007 11:16 Go to next message
Eclipse UserFriend
Originally posted by: matt.querix.com

Hi all,

I have just implemented debugging for our language in Eclipse. When a
program hits a breakpoint and suspends in my language, the user is not
asked whether they would like to switch the the Debug Perspective as
they are when a Java application or Eclipse application (run time
workbench) suspends. How do I implement this?

Thanks in advance

Matt D.
Re: Switching to debug perspective on suspend [message #313982 is a reply to message #313978] Thu, 29 March 2007 12:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mike.morearty.com

Probably your code is not broadcasting the right debug event. If you are
on Eclipse 3.2, take a look at LaunchSuspendTrigger.handleDebugEvents() --
that is the function that is listening for debug events, and switching to
the debug perspective when a suspend event comes in.

In that function, you can see that the conditions that must be true for it
to trigger are:

1. event.getKind() == DebugEvent.SUSPEND
2. event.isEvaluation() is false
3. event.getDetail() != DebugEvent.STEP_END
4. event.getSource() is an instance of IAdaptable, and can be adapted to
ILaunch
5. after adapting to ILaunch, the result must be equal to member variable
fLaunch. It isn't immediately obvious how that member variable is
initialized, but if you declare your IThread implementation to extend the
Eclipse helper class DebugElement, then I think you'll be in good shape:

class MyThread extends DebugElement implements IThread {
public MyThread(MyDebugTarget target) {
super(target);
}
}

By passing in an IDebugTarget to the DebugElement constructor,
DebugElement knows how to correctly create DebugEvents that point to the
right Launch. (You need to make sure your MyDebugTarget.getLaunch()
function returns the right value. One thing to be careful about: Even if
MyDebugTarget also extends DebugElement, you still need to have
MyDebugTarget override getLaunch(), because if you don't, you'll get into
an infinite loop, where the superclass DebugElement.getLaunch() calls
getDebugTarget().getLaunch().)

Once you do that, MyThread will inherit a public helper function
fireSuspendEvent(int detail), which will create a DebugEvent with the
correct values.

- Mike Morearty, Adobe Flex Builder


Matt Dickie wrote:

> Hi all,

> I have just implemented debugging for our language in Eclipse. When a
> program hits a breakpoint and suspends in my language, the user is not
> asked whether they would like to switch the the Debug Perspective as
> they are when a Java application or Eclipse application (run time
> workbench) suspends. How do I implement this?

> Thanks in advance

> Matt D.
Re: Switching to debug perspective on suspend [message #313998 is a reply to message #313982] Fri, 30 March 2007 10:32 Go to previous message
Eclipse UserFriend
Originally posted by: matt.querix.com

Thanks Mike,

The debug events were fired fine. The problem was that my thread class
didn't adapt to ILaunch. My debug element class didn't extends
DebugElement as that class is new in 3.1 and therefore not mentioned in
the debugger article - this provides some adapters for you. I have now
extended DebugElement and it works.

Thanks

Matt D.

Mike Morearty wrote:
> Probably your code is not broadcasting the right debug event. If you
> are on Eclipse 3.2, take a look at
> LaunchSuspendTrigger.handleDebugEvents() -- that is the function that is
> listening for debug events, and switching to the debug perspective when
> a suspend event comes in.
>
> In that function, you can see that the conditions that must be true for
> it to trigger are:
>
> 1. event.getKind() == DebugEvent.SUSPEND
> 2. event.isEvaluation() is false
> 3. event.getDetail() != DebugEvent.STEP_END
> 4. event.getSource() is an instance of IAdaptable, and can be adapted to
> ILaunch
> 5. after adapting to ILaunch, the result must be equal to member
> variable fLaunch. It isn't immediately obvious how that member variable
> is initialized, but if you declare your IThread implementation to extend
> the Eclipse helper class DebugElement, then I think you'll be in good
> shape:
>
> class MyThread extends DebugElement implements IThread {
> public MyThread(MyDebugTarget target) {
> super(target);
> }
> }
>
> By passing in an IDebugTarget to the DebugElement constructor,
> DebugElement knows how to correctly create DebugEvents that point to the
> right Launch. (You need to make sure your MyDebugTarget.getLaunch()
> function returns the right value. One thing to be careful about: Even
> if MyDebugTarget also extends DebugElement, you still need to have
> MyDebugTarget override getLaunch(), because if you don't, you'll get
> into an infinite loop, where the superclass DebugElement.getLaunch()
> calls getDebugTarget().getLaunch().)
>
> Once you do that, MyThread will inherit a public helper function
> fireSuspendEvent(int detail), which will create a DebugEvent with the
> correct values.
>
> - Mike Morearty, Adobe Flex Builder
>
>
> Matt Dickie wrote:
>
>> Hi all,
>
>
>> I have just implemented debugging for our language in Eclipse. When a
>> program hits a breakpoint and suspends in my language, the user is not
>> asked whether they would like to switch the the Debug Perspective as
>> they are when a Java application or Eclipse application (run time
>> workbench) suspends. How do I implement this?
>
>
>> Thanks in advance
>
>
>> Matt D.
>
>
>
Previous Topic:custom ContentMergeViewer
Next Topic:Multiple Cheatsheet Categories
Goto Forum:
  


Current Time: Sun Nov 09 16:15:22 EST 2025

Powered by FUDForum. Page generated in 0.04630 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top