Index: tools/testing/dart/test_runner.dart |
diff --git a/tools/testing/dart/test_runner.dart b/tools/testing/dart/test_runner.dart |
index d9e8d132253ae435c97d3e29f39c16932fd51ab5..6cf97f014fc1db7aea38d747b8abfc91d07dee57 100644 |
--- a/tools/testing/dart/test_runner.dart |
+++ b/tools/testing/dart/test_runner.dart |
@@ -1900,33 +1900,75 @@ class RunningProcess { |
timeoutHandler() async { |
timedOut = true; |
if (process != null) { |
- var executable, arguments; |
+ var executable; |
if (io.Platform.isLinux) { |
executable = 'eu-stack'; |
- arguments = ['-p ${process.pid}']; |
} else if (io.Platform.isMacOS) { |
// Try to print stack traces of the timed out process. |
// `sample` is a sampling profiler but we ask it sample for 1 |
// second with a 4 second delay between samples so that we only |
// sample the threads once. |
executable = '/usr/bin/sample'; |
- arguments = ['${process.pid}', '1', '4000', '-mayDie']; |
} else if (io.Platform.isWindows) { |
bool is_x64 = command.executable.contains("X64") || |
command.executable.contains("SIMARM64"); |
executable = configuration['win_sdk_path'] + |
"\\Debuggers\\" + (is_x64 ? "x64" : "x86") + "\\cdb.exe"; |
diagnostics.add("Using $executable to print stack traces"); |
- arguments = ['-p', '${process.pid}', '-c', '!uniqstack;qd']; |
+ } else { |
+ diagnostics.add("Capturing stack traces on" |
+ "${io.Platform.operatingSystem} not supported"); |
} |
- |
if (executable != null) { |
zra
2017/02/09 22:00:46
This is all getting complicated enough that it pro
|
- try { |
- var result = await io.Process.run(executable, arguments); |
- diagnostics.addAll(result.stdout.split('\n')); |
- diagnostics.addAll(result.stderr.split('\n')); |
- } catch (error) { |
- diagnostics.add("Unable to capture stack traces: $error"); |
+ var pid_list = [process.pid]; |
+ var lines; |
+ var start_line = 0; |
+ if (io.Platform.isLinux || io.Platform.isMacOS) { |
+ var result = await io.Process.run("pgrep", |
+ ["-P", "${pid_list[0]}"], |
+ runInShell: true); |
+ lines = result.stdout.split('\n'); |
+ } else if (io.Platform.isWindows) { |
+ var result = await io.Process.run("wmic", |
+ ["process", "where" , "(ParentProcessId=${pid_list[0]})", |
+ "get", "ProcessId"], |
+ runInShell: true); |
+ lines = result.stdout.split('\n'); |
+ // Skip first line containing header "ProcessId". |
+ start_line = 1; |
+ } else { |
+ assert(false); |
+ } |
+ if (lines.length > start_line) { |
+ for (int i = start_line; i < lines.length; ++i) { |
+ var pid = int.parse(lines[i], onError: (source) => null); |
+ if (pid != null) pid_list.add(pid); |
+ } |
+ } else { |
+ diagnostics.add("Could not find child pids"); |
+ diagnostics.addAll(lines); |
+ } |
+ |
+ diagnostics.add("Process list including children: $pid_list"); |
+ for (pid in pid_list) { |
+ var arguments; |
+ if (io.Platform.isLinux) { |
+ arguments = ['-p $pid']; |
+ } else if (io.Platform.isMacOS) { |
+ arguments = ['$pid', '1', '4000', '-mayDie']; |
+ } else if (io.Platform.isWindows) { |
+ arguments = ['-p', '$pid', '-c', '!uniqstack;qd']; |
+ } else { |
+ assert(false); |
+ } |
+ diagnostics.add("Trying to capture stack trace for pid $pid"); |
+ try { |
+ var result = await io.Process.run(executable, arguments); |
+ diagnostics.addAll(result.stdout.split('\n')); |
+ diagnostics.addAll(result.stderr.split('\n')); |
+ } catch (error) { |
+ diagnostics.add("Unable to capture stack traces: $error"); |
+ } |
} |
} |