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

Bug 348159

Summary: Tracing console is not shown automatically
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, eclipse.sprigogin, pawel.1.piech
Version: 8.0Flags: eclipse.sprigogin: review+
Target Milestone: 8.0.1   
Hardware: PC   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 347245    
Attachments:
Description Flags
Temporary hack to fix the bigger issue
marc.khouzam: iplog-
Move preferences to dsf.gdb plugin and remove hack
marc.khouzam: iplog-
Git patch to move preferences to dsf.gdb plugin and remove hack marc.khouzam: iplog-

Description Marc Khouzam CLA 2011-06-02 21:45:04 EDT
I've noticed that the 'gdb traces' are no longer automatically being shown on Windows.

I traced the issue to the fact that TracingConsoleManager.startup reads the preference before that same preferences are defaulted in GdbPreferenceInitializer.

I don't know why this is happening now, and why on Windows.
Comment 1 Marc Khouzam CLA 2011-06-03 10:03:00 EDT
This is happening on Linux too!
Comment 2 Marc Khouzam CLA 2011-06-03 14:00:33 EDT
I've traced this bug to the changes for the "non-stop default preference" of bug 347245.

To reproduce:
1- have the gdb traces enabled in Preferences->C/C++->Debug->GDB
2- restart eclipse
3- launch a DSF-GDB debug session without doing anything else before.

This launch will will call LaunchUtils.getIsNonStopMode() which now calls LaunchUtils.getIsNonStopModeDefault(); this last method accesses the dsf.gdb.ui preferences.  At the same time the dsf.gdb.ui plugin isbeing started which will call TracingConsoleManager.startup() which will also access the dsf.gdb.ui preferences.

It seems the the first access to the preferences is planning on calling GdbPreferenceInitializer() but has not done so yet; for some reason, TracingConsoleManager.startup() now thinks everything is already initialized and gets the wrong preference.

Could this be a bug in the platform?
Comment 3 Marc Khouzam CLA 2011-06-03 14:07:04 EDT
Created attachment 197322 [details]
Temporary hack to fix the bigger issue

This patch removes the call to getIsNonStopModeDefault() to avoid this race condition.

The consequence is that:
 if the non-stop default preference is set to true
AND
 the user right-clicks on a project and chooses Debug As->C/C++ application AND there is no existing debug launch for this project
THEN
 that launch will use non-stop but without the NonStop RunControl service.  Basically, that launch instance will be bad.

To me, this is a much lesser problem than not having the 'gdb traces' enabled by default.

Since we are running out of time, I committing this and we'll see if we can fix the bad side effect in time.
Comment 4 CDT Genie CLA 2011-06-03 14:23:25 EDT
*** cdt cvs genie on behalf of mkhouzam ***
Bug 348159: Tracing console is not shown automatically.  Hack to get it working in time for Indigo.  Needs to be revisited.

[*] LaunchUtils.java 1.25 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java?root=Tools_Project&r1=1.24&r2=1.25
Comment 5 Marc Khouzam CLA 2011-06-08 10:52:13 EDT
The reason for the problem is that:

we currently read a preference in the start() method of the dsf.gdb.ui plugin, by calling TracingConsoleManager.startup().

1- The dsf.gdb plugin calls pref.getBoolean("dsf.gdb.ui", nonStopPref) in LaunchUtils.getIsNonStopModeDefault()
2- The dsf.gdb.UI plugin has to be started to get that preference, and will need to call the preferenceInitializer
3- But dsf.gdb.ui.start() actually calls pref.getBoolean("dsf.gdb.ui", tracingPref)
At this time, the prefInitializer has not been called yet, I assume because it is waiting for the plugin startup to be finished, so we get the wrong preference value (it does not try to call the prefInitializer itself).

I thought about putting the call to the preference store into a job so it will allow the plugin to finish its startup.  However I think that can lead to a race condition because that new job is on another thread and could still be run before the prefInitializer is run (the start() of a plugin is not on the UI thread).

It was suggested to move the entire preferences to dsf.gdb, as code does:
http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg22107.html
Comment 6 Marc Khouzam CLA 2011-06-08 16:08:18 EDT
Created attachment 197640 [details]
Move preferences to dsf.gdb plugin and remove hack

This patch moves the preferences to the dsf.gdb plugin, which allows them to be initialized without having to start the dsf.gdb.ui plugin.

The patch also removes the "Temporary hack to fix the bigger issue".

It will need to wait for Juno.
Comment 7 Marc Khouzam CLA 2011-06-27 16:40:23 EDT
Created attachment 198686 [details]
Git patch to move preferences to dsf.gdb plugin and remove hack

This is the git patch that moves the preference store for dsf.gdb.ui to dsf.gdb and removes the hack that I had to put to get the tracing console to show up.

I committed it to master and to 8_0
Comment 8 Marc Khouzam CLA 2011-06-27 16:40:59 EDT
Sergey, can you review?
Comment 9 Sergey Prigogin CLA 2011-06-27 16:52:45 EDT
Looks good to me.