Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Fix for 53323, Extensibility of Addr2line/CPPFilt/Objdump

Hi,

attached the patch to solve the problems described in #53323 extending the 
implementation of Addr2line/CPPFilt and Objdump.

Best regards,

--
Uwe
mailto: uwe@xxxxxxx
Index: Addr2line.java
===================================================================
retrieving revision 1.5
diff -u -r1.5 Addr2line.java
--- Addr2line.java	26 Feb 2004 23:10:24 -0000	1.5
+++ Addr2line.java	27 Feb 2004 21:44:22 -0000
@@ -14,23 +14,38 @@
 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();
Index: CPPFilt.java
===================================================================
retrieving revision 1.4
diff -u -r1.4 CPPFilt.java
--- CPPFilt.java	26 Feb 2004 23:10:24 -0000	1.4
+++ CPPFilt.java	27 Feb 2004 21:44:22 -0000
@@ -14,20 +14,34 @@
 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 {
Index: Objdump.java
===================================================================
retrieving revision 1.2
diff -u -r1.2 Objdump.java
--- Objdump.java	26 Feb 2004 23:10:24 -0000	1.2
+++ Objdump.java	27 Feb 2004 21:44:23 -0000
@@ -50,7 +50,7 @@
 		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 {

Back to the top