Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 355833

Summary: [breakpoints] Thread filter effectively disables a breakpoint at the next session
Product: [Tools] CDT Reporter: Marc Khouzam <marc.khouzam>
Component: cdt-debug-dsf-gdbAssignee: Marc Khouzam <marc.khouzam>
Status: RESOLVED FIXED QA Contact: Marc Khouzam <marc.khouzam>
Severity: normal    
Priority: P3 CC: cdtdoug, john, nobody, pawel.1.piech
Version: 7.0.1Flags: marc.khouzam: review? (nobody)
Target Milestone: 8.0.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Cleanup of thread filtering (master branch)
marc.khouzam: iplog-
Cleanup of thread filtering (8_0 branch) marc.khouzam: iplog-

Description Marc Khouzam CLA 2011-08-25 09:39:23 EDT
1- start a debugging session
2- create a breakpoint
3- open breakpoint properties for that breakpoint
4- select filter but don't change anything else
5- press ok or cancel
6- stop the debug session
7- start the same debug session
=> the breakpoint will not be installed on the target.
=> the filter bp properties page shows that all threads are _unselected_

The problem seems to be that the thread filtering mechanism is using the old process instead of the new one, and since it does not exist, no current threads are selected.

This is not related to multi-process changes, since I am able to reproduce this on the 7.0 branch.
Comment 1 Marc Khouzam CLA 2011-09-01 07:47:10 EDT
Probably related to Bug 355828
Comment 2 Marc Khouzam CLA 2011-09-01 11:21:24 EDT
From bug 349736 comment 16 Mikhail wrote:

> > Opening and closing the filter dialog seems to mark the breakpoint as deleted.
> > It is still active in the current session but will not be set if the session is
> > terminated and restarted. In the dialog it is shown as disabled for the entire
> > target.
> 
> This is happening for a program with one thread only. Seems to work fine for
> multiple threads.

I'm seeing the problem all the time, single-threaded, multi-threaded, even compiling without pthreads.
Comment 3 Marc Khouzam CLA 2011-09-02 14:09:07 EDT
Created attachment 202687 [details]
Cleanup of thread filtering (master branch)

Originally in DSF-GDB, the IBreakpointsTargetDMContext was the gdb node itself.  This didn't match the code of CBreakpointGdbThreadsFilterExtension which expected a container (this class was more future proof).  Therefore, some hacking had been done to figure out which container matched the IBreakpointsTargetDMContext.

With multi-process, IBreakpointsTargetDMContext is now the IContainerDMContext.  Therefore, we can now handle the thread filtering cleanly and mimic the solution done in CDI.

The attached patch cleans up the logic for thread filtering.  The main points are:
1- up the dsf.gdb.ui version from 2.2 to 2.3
2- Use IDsfBreakpointExtension instead of the specialized CBreakpointGdbThreadsFilterExtension.  This simply makes searching for usage of the methods easier.
3- In MIBreakpointsManager we update the targetFilter list as follows:
  a) when creating a new breakpoint: add the container to the target filter
  b) when starting a new session, for each existing breakpoint, we add the container to the target filter
  c) when shutting down a debug session, remove the container from the target filter
  d) when deleting a breakpoint: remove the container from the target filter
  e) fetch the filter for the container matching the IBreakpointsTargetDMContext to know if thread filters are active.
4- add some javadoc

I will commit to master.
I will make a different patch to avoid API changes for cdt_8_0
Comment 4 Marc Khouzam CLA 2011-09-02 14:21:56 EDT
Created attachment 202690 [details]
Cleanup of thread filtering (8_0 branch)

Same patch for 8_0 except:
1- the version of dsf.gdb.ui goes from 2.2.0 to 2.2.1.
2- I forgot to update the pom.xml file (which I will also do for master)
3- No replacing CBreakpointGdbThreadsFilterExtension with IDsfBreakpointExtension to avoid changing APIs.

I'll commit this to cdt_8_0
Comment 5 Marc Khouzam CLA 2011-09-02 14:27:52 EDT
Fixed.
Mikhail, can you review?
Comment 6 Marc Khouzam CLA 2011-09-02 14:30:34 EDT
BTW, thread filtering still does not work with GDB 7.0 and 7.1.  See Bug 356488
Comment 7 CDT Genie CLA 2011-09-02 15:23:01 EDT
*** cdt git genie on behalf of Marc Khouzam ***

    Bug 355833: Thread filter effectively disables a breakpoint at the next session

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=59d5eafbf610a5afab095923dcd02cbefffe1d02
Comment 8 CDT Genie CLA 2011-09-02 15:23:03 EDT
*** cdt git genie on behalf of Marc Khouzam ***

    Bug 355833: Thread filter effectively disables a breakpoint at the next session

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=82dfb619edb5e7c17d8c71872ddcb84d530eaa7f