diff options
author | Wainer dos Santos Moschetta | 2015-10-12 15:54:48 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2015-10-13 10:45:39 +0000 |
commit | f12867a3c4e4b0ade70358ba428aa0e35adc3d5e (patch) | |
tree | 05123c2a6e517cc3f56f44de793816bfebca5d68 /perf | |
parent | 39192a02820fc09dab1094c6f439e20ddbe80801 (diff) | |
download | org.eclipse.linuxtools-f12867a3c4e4b0ade70358ba428aa0e35adc3d5e.tar.gz org.eclipse.linuxtools-f12867a3c4e4b0ade70358ba428aa0e35adc3d5e.tar.xz org.eclipse.linuxtools-f12867a3c4e4b0ade70358ba428aa0e35adc3d5e.zip |
Bug 477829 - fix to perf hangs when obtaining sources line
Some versions of perf annotate hangs while waiting for an input,
and as workaround to avoid that behavior you can redirect input
from an empty file (or /dev/null).
Change-Id: I10b0e248e19603b5d8d0b4937a15a827096f0471
Signed-off-by: Wainer dos Santos Moschetta <wainersm@linux.vnet.ibm.com>
Reviewed-on: https://git.eclipse.org/r/58012
Tested-by: Hudson CI
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'perf')
2 files changed, 32 insertions, 5 deletions
diff --git a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java index 92f9394c31..bf9a8c2445 100644 --- a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java +++ b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java @@ -324,9 +324,10 @@ public class ModelTest extends AbstractTest { "symbol", "resources/defaultevent-data/perf.data", false); String[] expectedString = new String[] { PerfPlugin.PERF_COMMAND, - "annotate", "-d", "dso", "-s", "symbol", "-l", "-P", + "annotate", "--stdio", "-d", "dso", "-s", "symbol", "-l", "-P", "--vmlinux", "/boot/kernel", "-m", "-i", - "resources/defaultevent-data/perf.data" }; + "resources/defaultevent-data/perf.data", + "<", "/dev/null" }; assertArrayEquals(expectedString, annotateString); } diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java index d1d7d1e7ff..3b84a0cb94 100644 --- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java +++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java @@ -314,7 +314,7 @@ public class PerfCore { if (oldPerfVersion) { base.addAll( Arrays.asList( new String[]{PerfPlugin.PERF_COMMAND, "annotate", "-s", symbol, "-l", "-P"} ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } else { - base.addAll( Arrays.asList( new String[]{PerfPlugin.PERF_COMMAND, "annotate", "-d", dso, "-s", symbol, "-l", "-P"} ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + base.addAll( Arrays.asList( new String[]{PerfPlugin.PERF_COMMAND, "annotate", "--stdio", "-d", dso, "-s", symbol, "-l", "-P"} ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ } if (config != null) { try { @@ -332,6 +332,12 @@ public class PerfCore { } } catch (CoreException e) { } } + /* + * Some versions of perf annotate hangs while waiting for an input. + * Redirect input from an empty file (or /dev/null) to avoid that behavior. + */ + base.add("<"); //$NON-NLS-1$ + base.add("/dev/null"); //$NON-NLS-1$ //(Annotate string per symbol) return base.toArray( new String[base.size()] ); @@ -536,8 +542,28 @@ public class PerfCore { } try { - if(project==null) p = Runtime.getRuntime().exec(annotateCmd); - else p = RuntimeProcessFactory.getFactory().exec(annotateCmd, project); + if(project==null) { + p = Runtime.getRuntime().exec(annotateCmd); + } else { + StringBuffer sb = new StringBuffer(); + ArrayList<String> al = new ArrayList<>(); + /* + * Wrap the whole Perf annotate line as a single argument of sh command + * so that any IO redirection will take effect. Change to working directory before run perf annotate. + * It results on a command string as 'sh', '-c', 'cd <workindir> && perf annotate <args> < /dev/null' + */ + al.add("sh"); //$NON-NLS-1$ + al.add("-c"); //$NON-NLS-1$ + if(workingDir != null) { + sb.append("cd " + workingDir.toOSString() + " && "); //$NON-NLS-1$ //$NON-NLS-2$ + } + for(int i=0; i<annotateCmd.length; i++) { + sb.append(annotateCmd[i]); + sb.append(" "); //$NON-NLS-1$ + } + al.add(sb.toString()); + p = RuntimeProcessFactory.getFactory().exec(al.toArray(new String[]{}), project); + } input = new BufferedReader(new InputStreamReader(p.getInputStream())); error = new BufferedReader(new InputStreamReader(p.getErrorStream())); } catch (IOException e) { |