17
17
import org .eclipse .php .internal .debug .core .preferences .PHPDebugCorePreferenceNames ;
18
18
import org .eclipse .php .internal .debug .core .preferences .PHPDebuggersRegistry ;
19
19
import org .eclipse .php .internal .debug .core .zend .communication .DebuggerCommunicationDaemon ;
20
+ import org .eclipse .php .internal .debug .core .zend .debugger .ZendDebuggerSettingsUtil ;
20
21
import org .eclipse .php .internal .server .core .Server ;
21
22
import org .zend .php .server .core .utils .ServerUtils ;
22
23
import org .zend .sdklib .SdkException ;
@@ -45,9 +46,6 @@ public class DebugModeManager {
45
46
46
47
public static final String FILTER_SEPARATOR = "," ; //$NON-NLS-1$
47
48
48
- private static final String CLIENT_HOST_KEY = "org.eclipse.php.debug.coreclient_ip" ; //$NON-NLS-1$
49
- private static final String DEBUG_PLUGIN_ID = "org.eclipse.php.debug.core" ; //$NON-NLS-1$
50
-
51
49
private static DebugModeManager manager ;
52
50
53
51
private Map <IZendTarget , Boolean > targets ;
@@ -67,22 +65,17 @@ public IStatus startDebugMode(IZendTarget target) {
67
65
ZendDebugMode debugMode = new ZendDebugMode (target .getId ());
68
66
Map <String , String > options = new HashMap <String , String >();
69
67
debugMode .setFilters (getFilters (target ));
70
- AbstractDebuggerConfiguration debuggerConfiguration = PHPDebuggersRegistry
71
- .getDebuggerConfiguration (DebuggerCommunicationDaemon .ZEND_DEBUGGER_ID );
72
- if (debuggerConfiguration != null ) {
73
- int port = debuggerConfiguration .getPort ();
74
- options .put (DEBUG_PORT , String .valueOf (port ));
75
- options .put (DEBUG_HOST , getDebugHosts (target ));
76
- Server server = ServerUtils .getServer (target );
77
- if (server != null ) {
78
- if (shouldStopAtFirstLine ()) {
79
- options .put (DEBUG_STOP , "1" ); //$NON-NLS-1$
80
- }
81
- } else {
68
+ options .put (DEBUG_PORT , String .valueOf (getDebugPort (target )));
69
+ options .put (DEBUG_HOST , getDebugHosts (target ));
70
+ Server server = ServerUtils .getServer (target );
71
+ if (server != null ) {
72
+ if (shouldStopAtFirstLine ()) {
82
73
options .put (DEBUG_STOP , "1" ); //$NON-NLS-1$
83
74
}
84
- debugMode .setOptions (options );
75
+ } else {
76
+ options .put (DEBUG_STOP , "1" ); //$NON-NLS-1$
85
77
}
78
+ debugMode .setOptions (options );
86
79
State result = State .ERROR ;
87
80
try {
88
81
result = debugMode .start ();
@@ -165,13 +158,39 @@ private String getDebugHosts(IZendTarget target) {
165
158
return LOCALHOST ;
166
159
}
167
160
IEclipsePreferences prefs = InstanceScope .INSTANCE
168
- .getNode (DEBUG_PLUGIN_ID );
169
- String clientHosts = prefs .get (CLIENT_HOST_KEY , (String ) null );
161
+ .getNode (PHPDebugPlugin .ID );
162
+ String clientHosts = prefs .get (PHPDebugCorePreferenceNames .CLIENT_IP ,
163
+ (String ) null );
170
164
if (clientHosts == null ) {
171
165
IEclipsePreferences defaultPrefs = DefaultScope .INSTANCE
172
- .getNode (DEBUG_PLUGIN_ID );
173
- clientHosts = defaultPrefs .get (CLIENT_HOST_KEY , (String ) null );
166
+ .getNode (PHPDebugPlugin .ID );
167
+ clientHosts = defaultPrefs .get (
168
+ PHPDebugCorePreferenceNames .CLIENT_IP , (String ) null );
174
169
}
170
+ Server server = ServerUtils .getServer (target );
171
+ // Get server individual hosts list if any
172
+ String customHosts = ZendDebuggerSettingsUtil .getDebugHosts (server );
173
+ if (customHosts != null )
174
+ clientHosts = customHosts ;
175
+ return clientHosts ;
176
+ }
177
+
178
+ private int getDebugPort (IZendTarget target ) {
179
+ IEclipsePreferences prefs = InstanceScope .INSTANCE
180
+ .getNode (PHPDebugPlugin .ID );
181
+ int clientHosts = prefs .getInt (
182
+ PHPDebugCorePreferenceNames .ZEND_DEBUG_PORT , -1 );
183
+ if (clientHosts == -1 ) {
184
+ IEclipsePreferences defaultPrefs = DefaultScope .INSTANCE
185
+ .getNode (PHPDebugPlugin .ID );
186
+ clientHosts = defaultPrefs .getInt (
187
+ PHPDebugCorePreferenceNames .ZEND_DEBUG_PORT , -1 );
188
+ }
189
+ Server server = ServerUtils .getServer (target );
190
+ // Get server individual hosts list if any
191
+ int customPort = ZendDebuggerSettingsUtil .getDebugPort (server );
192
+ if (customPort != -1 )
193
+ clientHosts = customPort ;
175
194
return clientHosts ;
176
195
}
177
196
0 commit comments