mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
[291877] Potential deadlock because traces were using the executor.
This commit is contained in:
parent
271832d5e4
commit
42ae2748df
1 changed files with 32 additions and 40 deletions
|
@ -79,7 +79,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
||||||
|
|
||||||
// MI did not always support the --thread/--frame options
|
// MI did not always support the --thread/--frame options
|
||||||
// This boolean is used to know if we should use -thread-select and -stack-select-frame instead
|
// This boolean is used to know if we should use -thread-select and -stack-select-frame instead
|
||||||
private boolean fUseThreadAndFrameOptions;
|
private final boolean fUseThreadAndFrameOptions;
|
||||||
// currentStackLevel and currentThreadId are only necessary when
|
// currentStackLevel and currentThreadId are only necessary when
|
||||||
// we must use -thread-select and -stack-select-frame
|
// we must use -thread-select and -stack-select-frame
|
||||||
private int fCurrentStackLevel = -1;
|
private int fCurrentStackLevel = -1;
|
||||||
|
@ -142,14 +142,14 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
||||||
* to disable tracing.
|
* to disable tracing.
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
protected void setMITracingStream(OutputStream tracingStream) {
|
protected synchronized void setMITracingStream(OutputStream tracingStream) {
|
||||||
fTracingStream = tracingStream;
|
fTracingStream = tracingStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the MI tracing stream.
|
* Returns the MI tracing stream.
|
||||||
*/
|
*/
|
||||||
private OutputStream getMITracingStream() {
|
private synchronized OutputStream getMITracingStream() {
|
||||||
return fTracingStream;
|
return fTracingStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,26 +564,22 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
||||||
fOutputStream.flush();
|
fOutputStream.flush();
|
||||||
|
|
||||||
GdbPlugin.debug(GdbPlugin.getDebugTime() + MI_TRACE_IDENTIFIER + str);
|
GdbPlugin.debug(GdbPlugin.getDebugTime() + MI_TRACE_IDENTIFIER + str);
|
||||||
getExecutor().execute(new DsfRunnable() {
|
if (getMITracingStream() != null) {
|
||||||
public void run() {
|
try {
|
||||||
if (getMITracingStream() != null) {
|
String message = GdbPlugin.getDebugTime() + " " + str; //$NON-NLS-1$
|
||||||
try {
|
while (message.length() > 100) {
|
||||||
String message = GdbPlugin.getDebugTime() + " " + str; //$NON-NLS-1$
|
String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$
|
||||||
while (message.length() > 100) {
|
message = message.substring(100);
|
||||||
String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$
|
getMITracingStream().write(partial.getBytes());
|
||||||
message = message.substring(100);
|
|
||||||
getMITracingStream().write(partial.getBytes());
|
|
||||||
}
|
|
||||||
getMITracingStream().write(message.getBytes());
|
|
||||||
} catch (IOException e) {
|
|
||||||
// The tracing stream could be closed at any time
|
|
||||||
// since the user can set a preference to turn off
|
|
||||||
// this tracing.
|
|
||||||
setMITracingStream(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
getMITracingStream().write(message.getBytes());
|
||||||
|
} catch (IOException e) {
|
||||||
|
// The tracing stream could be closed at any time
|
||||||
|
// since the user can set a preference to turn off
|
||||||
|
// this tracing.
|
||||||
|
setMITracingStream(null);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Shutdown thread in case of IO error.
|
// Shutdown thread in case of IO error.
|
||||||
|
@ -618,26 +614,22 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
||||||
GdbPlugin.debug(GdbPlugin.getDebugTime() + MI_TRACE_IDENTIFIER + line + "\n"); //$NON-NLS-1$
|
GdbPlugin.debug(GdbPlugin.getDebugTime() + MI_TRACE_IDENTIFIER + line + "\n"); //$NON-NLS-1$
|
||||||
|
|
||||||
final String finalLine = line;
|
final String finalLine = line;
|
||||||
getExecutor().execute(new DsfRunnable() {
|
if (getMITracingStream() != null) {
|
||||||
public void run() {
|
try {
|
||||||
if (getMITracingStream() != null) {
|
String message = GdbPlugin.getDebugTime() + " " + finalLine + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
try {
|
while (message.length() > 100) {
|
||||||
String message = GdbPlugin.getDebugTime() + " " + finalLine + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$
|
||||||
while (message.length() > 100) {
|
message = message.substring(100);
|
||||||
String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$
|
getMITracingStream().write(partial.getBytes());
|
||||||
message = message.substring(100);
|
}
|
||||||
getMITracingStream().write(partial.getBytes());
|
getMITracingStream().write(message.getBytes());
|
||||||
}
|
} catch (IOException e) {
|
||||||
getMITracingStream().write(message.getBytes());
|
// The tracing stream could be closed at any time
|
||||||
} catch (IOException e) {
|
// since the user can set a preference to turn off
|
||||||
// The tracing stream could be closed at any time
|
// this tracing.
|
||||||
// since the user can set a preference to turn off
|
setMITracingStream(null);
|
||||||
// this tracing.
|
|
||||||
setMITracingStream(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
processMIOutput(line);
|
processMIOutput(line);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue