Shaiju P Nair
2009-07-11 08:40:47 UTC
Hi All
We have implemented cdt-cdi based multicore debug support and
occasionally we are seeing a race condition while break points are inserted
during a multi-core debug session. When a breakpoint is inserted that gets
planted on both targets ,but occasionally one of them is getting deleted .
CBreakpointManager's breakpointsChanged() and
doHandleLocationBreakpointCreatedEvent() are the two methods involved in
this issue . Even though cdt currently does not have multicore debug support
this race condition can be simulated using two launches at the same time.
So I am explaining using two launches.
1. Put a breakpoint inside CBreakpointManagers's
doHandleLocationBreakpointCreatedEvent method at Line No 550 (where
BreakpointProblems.removeProblemsForResolvedBreakpoint(breakpoint,
getDebugTarget().getInternalID()) is there )
2.From CDT runtime launch any program for debug two time ( Now two
launches are active which is similar to a multi core debug situation) I am
suggesting same program because same breakpoint becomes valid for both.
3.Now put a breakpoint in the c program that we just launched (say in
main.c at line 190 )
4. Now in the eclipse debug view you can see two threads waiting at the
breakpoint we planted earlier . They are two CBreakpointManager's of two
launches . Lets say L1 CBreakpointManager and L2 CBreakpointManager
5. Resume any one thread and after few seconds the other too. Now if you
look at the debug trace you can see one of targets breakpoint got removed.
------------------------------------------------------------------------------------------------------------------------------------------------------------------
[1,247,289,996,214] 113-break-insert main.c:190
[1,247,289,996,217]
113^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0804\
87aa",func="main",file="../src/main.c",fullname="/home/ide/workspaces/eclipse/ws_cdt_cdi_mi_head_run\
time/VariableS/src/main.c",line="190",times="0"}
[1,247,289,996,217] (gdb)
[1,247,289,996,262] 114-break-insert main.c:190
[1,247,289,996,266]
114^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0804\
87aa",func="main",file="../src/main.c",fullname="/home/ide/workspaces/eclipse/ws_cdt_cdi_mi_head_run\
time/VariableS/src/main.c",line="190",times="0"}
[1,247,289,996,267] (gdb)
[1,247,290,007,586] 115-break-delete 2
[1,247,290,007,588] 115^done
[1,247,290,007,589] (gdb)
------------------------------------------------------------------------------------------------------------------------------------------------------------------
When one thread is resumed say L1 CBreakpointManger it updates the
breakpoint by setting the target filter and fires breakpoint
updated event. Both of the CBreakpintMangers recives this event, and process
it in breakpointsChanged() method,where it checks for breakpoints target
filter to see this breakpoint should be removed or not .
CBreakpointManager Line no 355 ICDebugTarget[] tfs =
getFilterExtension(b).getTargetFilters();
Now the L1 's breakpointsChanged() can find the respective target and it
will not remove . But L2's breakpointsChanged() will not find the respective
target as L2's doHandleLocationBreakpointCreatedEvent() is not finished
setting the target list in the breakpoint (CBreakpointManager Line no 551
getFilterExtension(breakpoint).setTargetFilter( getDebugTarget() ); ) . So
it adds this breakpoint to the remove list.
I know in vanila cdt this won't be a big issue , but did anyone else who
have multicore launch face this ?
The obvious and easy solution is to synchronize access. But can anyone
suggest better solution ?
Thanks
Shaiju.P
We have implemented cdt-cdi based multicore debug support and
occasionally we are seeing a race condition while break points are inserted
during a multi-core debug session. When a breakpoint is inserted that gets
planted on both targets ,but occasionally one of them is getting deleted .
CBreakpointManager's breakpointsChanged() and
doHandleLocationBreakpointCreatedEvent() are the two methods involved in
this issue . Even though cdt currently does not have multicore debug support
this race condition can be simulated using two launches at the same time.
So I am explaining using two launches.
1. Put a breakpoint inside CBreakpointManagers's
doHandleLocationBreakpointCreatedEvent method at Line No 550 (where
BreakpointProblems.removeProblemsForResolvedBreakpoint(breakpoint,
getDebugTarget().getInternalID()) is there )
2.From CDT runtime launch any program for debug two time ( Now two
launches are active which is similar to a multi core debug situation) I am
suggesting same program because same breakpoint becomes valid for both.
3.Now put a breakpoint in the c program that we just launched (say in
main.c at line 190 )
4. Now in the eclipse debug view you can see two threads waiting at the
breakpoint we planted earlier . They are two CBreakpointManager's of two
launches . Lets say L1 CBreakpointManager and L2 CBreakpointManager
5. Resume any one thread and after few seconds the other too. Now if you
look at the debug trace you can see one of targets breakpoint got removed.
------------------------------------------------------------------------------------------------------------------------------------------------------------------
[1,247,289,996,214] 113-break-insert main.c:190
[1,247,289,996,217]
113^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0804\
87aa",func="main",file="../src/main.c",fullname="/home/ide/workspaces/eclipse/ws_cdt_cdi_mi_head_run\
time/VariableS/src/main.c",line="190",times="0"}
[1,247,289,996,217] (gdb)
[1,247,289,996,262] 114-break-insert main.c:190
[1,247,289,996,266]
114^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0804\
87aa",func="main",file="../src/main.c",fullname="/home/ide/workspaces/eclipse/ws_cdt_cdi_mi_head_run\
time/VariableS/src/main.c",line="190",times="0"}
[1,247,289,996,267] (gdb)
[1,247,290,007,586] 115-break-delete 2
[1,247,290,007,588] 115^done
[1,247,290,007,589] (gdb)
------------------------------------------------------------------------------------------------------------------------------------------------------------------
When one thread is resumed say L1 CBreakpointManger it updates the
breakpoint by setting the target filter and fires breakpoint
updated event. Both of the CBreakpintMangers recives this event, and process
it in breakpointsChanged() method,where it checks for breakpoints target
filter to see this breakpoint should be removed or not .
CBreakpointManager Line no 355 ICDebugTarget[] tfs =
getFilterExtension(b).getTargetFilters();
Now the L1 's breakpointsChanged() can find the respective target and it
will not remove . But L2's breakpointsChanged() will not find the respective
target as L2's doHandleLocationBreakpointCreatedEvent() is not finished
setting the target list in the breakpoint (CBreakpointManager Line no 551
getFilterExtension(breakpoint).setTargetFilter( getDebugTarget() ); ) . So
it adds this breakpoint to the remove list.
I know in vanila cdt this won't be a big issue , but did anyone else who
have multicore launch face this ?
The obvious and easy solution is to synchronize access. But can anyone
suggest better solution ?
Thanks
Shaiju.P