From 183e1ab4037dc47207b757384eef052a27ce1bcf Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Mon, 1 Mar 2004 15:19:49 +0000 Subject: [PATCH] PR 53323 fix --- core/org.eclipse.cdt.core/ChangeLog | 9 ++++++ .../org/eclipse/cdt/utils/Addr2line.java | 27 ++++++++++++++---- .../utils/org/eclipse/cdt/utils/CPPFilt.java | 28 ++++++++++++++----- .../utils/org/eclipse/cdt/utils/Objdump.java | 2 +- 4 files changed, 52 insertions(+), 14 deletions(-) diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index d69f6b8e547..c0dc82d4a13 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,12 @@ +2004-03-01 Alain Magloire + + Patch from Uwe Stieber + PR #53323 extending the implementation of Addr2line/CPPFilt and Objdump. + + * utils/org/eclipse/cdt/utils/Addr2line.java + * utils/org/eclipse/cdt/utils/CPPFil.java + * utils/org/eclipse/cdt/utils/Objdump.java + 2004-02-29 Alain Magloire Performance improvements in the Deltaprocessing diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr2line.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr2line.java index 07022858373..4530ee68553 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr2line.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr2line.java @@ -14,23 +14,38 @@ import java.io.OutputStreamWriter; import org.eclipse.cdt.utils.spawner.ProcessFactory; public class Addr2line { + private String[] args; private Process addr2line; private BufferedReader stdout; private BufferedWriter stdin; private String lastaddr, lastsymbol, lastline; - public Addr2line(String command, String file) throws IOException { - String[] args = {command, "-C", "-f", "-e", file}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - addr2line = ProcessFactory.getFactory().exec(args); - stdin = new BufferedWriter(new OutputStreamWriter(addr2line.getOutputStream())); - stdout = new BufferedReader(new InputStreamReader(addr2line.getInputStream())); + public Addr2line(String command, String[] params, String file) throws IOException { + init(command, params, file); } + public Addr2line(String command, String file) throws IOException { + this(command, new String[0], file); + } + public Addr2line(String file) throws IOException { this("addr2line", file); //$NON-NLS-1$ } - private void getOutput(String address) throws IOException { + protected void init(String command, String[] params, String file) throws IOException { + if (params == null || params.length == 0) { + args = new String[] {command, "-C", "-f", "-e", file}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } else { + args = new String[params.length + 1]; + args[0] = command; + System.arraycopy(params, 0, args, 1, params.length); + } + addr2line = ProcessFactory.getFactory().exec(args); + stdin = new BufferedWriter(new OutputStreamWriter(addr2line.getOutputStream())); + stdout = new BufferedReader(new InputStreamReader(addr2line.getInputStream())); + } + + protected void getOutput(String address) throws IOException { if ( address.equals(lastaddr) == false ) { stdin.write(address + "\n"); //$NON-NLS-1$ stdin.flush(); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CPPFilt.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CPPFilt.java index 3ebc6dd782b..bd398805612 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CPPFilt.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CPPFilt.java @@ -14,22 +14,36 @@ import java.io.OutputStreamWriter; import org.eclipse.cdt.utils.spawner.ProcessFactory; public class CPPFilt { + private String[] args; private Process cppfilt; private BufferedReader stdout; private BufferedWriter stdin; - public CPPFilt(String command) throws IOException { - String[] args = {command}; - cppfilt = ProcessFactory.getFactory().exec(args); - //cppfilt = new Spawner(args); - stdin = new BufferedWriter(new OutputStreamWriter(cppfilt.getOutputStream())); - stdout = new BufferedReader(new InputStreamReader(cppfilt.getInputStream())); + public CPPFilt(String command, String[] params) throws IOException { + init(command, params); } - + + public CPPFilt(String command) throws IOException { + this(command, new String[0]); + } + public CPPFilt() throws IOException { this("c++filt"); //$NON-NLS-1$ } + protected void init(String command, String[] params) throws IOException { + if (params == null || params.length == 0) { + args = new String[] {command}; + } else { + args = new String[params.length + 1]; + args[0] = command; + System.arraycopy(params, 0, args, 1, params.length); + } + cppfilt = ProcessFactory.getFactory().exec(args); + stdin = new BufferedWriter(new OutputStreamWriter(cppfilt.getOutputStream())); + stdout = new BufferedReader(new InputStreamReader(cppfilt.getInputStream())); + } + public String getFunction(String symbol) throws IOException { stdin.write(symbol + "\n"); //$NON-NLS-1$ stdin.flush(); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Objdump.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Objdump.java index acb6e7a42c8..54abacef5b7 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Objdump.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Objdump.java @@ -50,7 +50,7 @@ public class Objdump { this("objdump", new String[0], file); //$NON-NLS-1$ } - void init(String command, String[] params, String file) throws IOException { + protected void init(String command, String[] params, String file) throws IOException { if (params == null || params.length == 0) { args = new String[] { command, "-C", "-x", "-S", file }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } else {