Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » how eclipse synchronizes its views?
how eclipse synchronizes its views? [message #995653] Sun, 30 December 2012 19:47 Go to next message
ben agai is currently offline ben agaiFriend
Messages: 36
Registered: July 2012
Member
hello, i have a general question about how eclipse synchronizes all its views.

when i debug c code in eclipse it is done with the gdb debugger, it means that the Variables view ,for example, is using the gdb as it's resource.
eclipse has many more views like 'registersView','DisassemblyView', 'BreakpointsView' etc.

my question is: if all the views are open and each on of them is using the gdb as its resource, how does eclipse synchronize each of the view's commands that are sent to the gdb?
how each of the views know when to send it's commands or wait till the other finishes it's own commands sending?

i have posted it in JDT, and have been told to post it here.

any help is appreciated.

thanks.
Re: how eclipse synchronizes its views? [message #997085 is a reply to message #995653] Thu, 03 January 2013 15:19 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
This seems like an implementation question. I'm not sure what you are really looking to find out, but here goes: in the current integration of GDB into CDT, all commands sent to GDB go through a single class (ICommandControlService) and answers returned accordingly. To make sure all views are synchronized, we use an event model where events are sent to the views to indicate something has happened, and then the view decides if it should refresh its content or not.

I hope this helps

Marc
Re: how eclipse synchronizes its views? [message #997120 is a reply to message #997085] Thu, 03 January 2013 19:45 Go to previous messageGo to next message
ben agai is currently offline ben agaiFriend
Messages: 36
Registered: July 2012
Member
hi, thank you so much for your reply.

i have read the source code of the variablesView, breakPointsView etc, and correct me if im wrong, but it seems that eclipse's views are using the IDebugContextListener interface to be noted that something has happened, which means the views receive a debugContextEvent, right?.

i have looked about the implemention of the fire function at the AbstractDebugContextProvider class, and i saw that for each listener that the function calls it's debugContextChanged(event) method it uses a SafeRunner which ,if i'm not wrong is like a thread, and if it works like a thread how can the views be synchronized?.

i thought that if there are ,for example, 5 views registered as debugContextListener, as long as the first view's debugContextChanged(event) method is'nt over the next view's debugContextChanged(event) method wo'nt be called, is'nt that how it works?

pleas correct me if im wrong about any of my assumptions.

thank you so much for your help.
Re: how eclipse synchronizes its views? [message #997477 is a reply to message #997085] Mon, 07 January 2013 17:30 Go to previous messageGo to next message
ben agai is currently offline ben agaiFriend
Messages: 36
Registered: July 2012
Member
i see that no one replys to my questions, is there any more detail needed that will help understand my question?
Re: how eclipse synchronizes its views? [message #997493 is a reply to message #997120] Mon, 07 January 2013 19:15 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
> i have read the source code of the variablesView, breakPointsView etc,
> and correct me if im wrong, but it seems that eclipse's views are using
> the IDebugContextListener interface to be noted that something has
> happened, which means the views receive a debugContextEvent, right?.

Yes, although that is not the only trigger.
The actual mechanism used in CDT is pretty complicated and I'm not familiar enough with it that I can explain well.

> i have looked about the implemention of the fire function at the
> AbstractDebugContextProvider class, and i saw that for each listener that
> the function calls it's debugContextChanged(event) method it uses a
> SafeRunner which ,if i'm not wrong is like a thread, and if it works
> like a thread how can the views be synchronized?.

I don't think it works like a thread. If you look at the implementation of SafeRunning.run, you will see all it does is catch exceptions, but runs the code in the current thread.

> i thought that if there are ,for example, 5 views registered as
> debugContextListener, as long as the first view's
> debugContextChanged(event) method is'nt over the next view's
> debugContextChanged(event) method wo'nt be called, is'nt that how it works?

Looks like it, yes.

Marc
Re: how eclipse synchronizes its views? [message #997582 is a reply to message #997493] Tue, 08 January 2013 13:11 Go to previous messageGo to next message
ben agai is currently offline ben agaiFriend
Messages: 36
Registered: July 2012
Member
thank you so much for your reply marc.

i have encountered a problem which i think with your help can be solved.

i created a plug-in which sends commands to the gdb when the debugged process is suspended.
in order to know when the target is suspended my plug-in listens for debugEvents and when i receive SUSPEND event i know the debugged process is suspended and then i send commands to the gdb.

my problem is that sometimes when the debugged process is suspended, me and, for example, the variablesView are sending commands to the gdb simultaneously which causes the gdb, for some reason, not to answer to my commands.

the only solution i came up with is instead of listening to debugEvents i will listen to debugContextEvents as the VariablesView does and then only when my debugContextChanged(debugContextEvent event) method is complete, the variablesView will start sending commands to the gdb.

what do you think of my solution?, if you have any advices please share them with me.

thanks a lot, ben.
Re: how eclipse synchronizes its views? [message #997595 is a reply to message #997582] Tue, 08 January 2013 14:10 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member

> the only solution i came up with is instead of listening to debugEvents i will listen to debugContextEvents
> as the VariablesView does and then only when my debugContextChanged(debugContextEvent event) method is complete,
> the variablesView will start sending commands to the gdb.

I don't think this is right. You should not have to worry about synchronizing the views. What others view
do should not affect your code.


> my problem is that sometimes when the debugged process is suspended, me and, for example,
> the variablesView are sending commands to the gdb simultaneously which causes the gdb,
> for some reason, not to answer to my commands.

You must be doing something wrong here. How are you sending your commands?

Marc
Re: how eclipse synchronizes its views? [message #997677 is a reply to message #997595] Tue, 08 January 2013 14:31 Go to previous messageGo to next message
ben agai is currently offline ben agaiFriend
Messages: 36
Registered: July 2012
Member
i get the debugger session output stream in order to send commands to the gdb.

and i get it this way:

ICDISession session = null;
OutputStream outSession = null;
session =((CDebugTarget)events[index].getSource()).getCDISession();
outSession = session.getSessionProcess().getOutputStream();

and then i send commands like this:
try{
outSession.write("help\r\n".getBytes());
outSession.flush();
}
catch(Exception es){
text.append("felt in write Exception\n");
text.append(es.toString()+"\n");
}

Re: how eclipse synchronizes its views? [message #997700 is a reply to message #997677] Tue, 08 January 2013 15:13 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
This is the older CDI integration of GDB. CDT has moved to using DSF, although CDI is still available. You are welcomed to keep using CDI if you want, but you may have more trouble getting support for it. In my case, I know almost nothing about it.

Marc
Re: how eclipse synchronizes its views? [message #997730 is a reply to message #997700] Tue, 08 January 2013 16:06 Go to previous messageGo to next message
ben agai is currently offline ben agaiFriend
Messages: 36
Registered: July 2012
Member
can the way i send commands to the gdb override other commands in the stream or make some of the commands be ignored by the gdb?

marc, can you show me other way of sending commands to the gdb?

thanks.

[Updated on: Tue, 08 January 2013 16:06]

Report message to a moderator

Re: how eclipse synchronizes its views? [message #997734 is a reply to message #997730] Tue, 08 January 2013 16:19 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
> can the way i send commands to the gdb override other commands in the stream or make some of the commands be ignored by the gdb?

I'm not sure. But it seems so.

> marc, can you show me other way of sending commands to the gdb?

If you want to use DSF instead of CDI, then don't look at the plugins
o.e.cdt.debug.mi
o.e.cdt.debug.mi.ui
which are the CDI plugins, but instead focus on:
o.e.cdt.dsf.gdb
o.e.cdt.dsf.gdb.ui
o.e.cdt.dsf
o.e.cdt.dsf.ui

Search for places that call ICommandControl.queueCommand() for how to send a new command to GDB.

Marc

Re: how eclipse synchronizes its views? [message #997808 is a reply to message #997734] Tue, 08 January 2013 19:35 Go to previous message
ben agai is currently offline ben agaiFriend
Messages: 36
Registered: July 2012
Member
thanks, marc.

i have searched about the plug-ins you gave me, but for some reason did'nt find information that explains the use or how to use the plug-ins to talk with the gdb.

i have lookd at the ICommandControl interface which seems to control the commands that are sent to the gdb, and control their result.
the problem is that there are many classes implementing this interface:
AbstractMIControl, BufferedCommandControl, GDBControl, GDBControl_7_0, MIVariableManager, PDACommandControl.

and i dont know which one i need, or how to send commands to the gdb through any of them.

can you help me on that matter?

thanks in advance, ben.
Previous Topic:debugContextEvent information
Next Topic:C++11 Inferring "auto" type fails for "vector"
Goto Forum:
  


Current Time: Fri Apr 19 10:41:59 GMT 2024

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

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

Back to the top