Lines 14-36
Link Here
|
14 |
import org.eclipse.cdt.utils.spawner.ProcessFactory; |
14 |
import org.eclipse.cdt.utils.spawner.ProcessFactory; |
15 |
|
15 |
|
16 |
public class Addr2line { |
16 |
public class Addr2line { |
|
|
17 |
private String[] args; |
17 |
private Process addr2line; |
18 |
private Process addr2line; |
18 |
private BufferedReader stdout; |
19 |
private BufferedReader stdout; |
19 |
private BufferedWriter stdin; |
20 |
private BufferedWriter stdin; |
20 |
private String lastaddr, lastsymbol, lastline; |
21 |
private String lastaddr, lastsymbol, lastline; |
21 |
|
22 |
|
22 |
public Addr2line(String command, String file) throws IOException { |
23 |
public Addr2line(String command, String[] params, String file) throws IOException { |
23 |
String[] args = {command, "-C", "-f", "-e", file}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
24 |
init(command, params, file); |
24 |
addr2line = ProcessFactory.getFactory().exec(args); |
|
|
25 |
stdin = new BufferedWriter(new OutputStreamWriter(addr2line.getOutputStream())); |
26 |
stdout = new BufferedReader(new InputStreamReader(addr2line.getInputStream())); |
27 |
} |
25 |
} |
28 |
|
26 |
|
|
|
27 |
public Addr2line(String command, String file) throws IOException { |
28 |
this(command, new String[0], file); |
29 |
} |
30 |
|
29 |
public Addr2line(String file) throws IOException { |
31 |
public Addr2line(String file) throws IOException { |
30 |
this("addr2line", file); //$NON-NLS-1$ |
32 |
this("addr2line", file); //$NON-NLS-1$ |
31 |
} |
33 |
} |
32 |
|
34 |
|
33 |
private void getOutput(String address) throws IOException { |
35 |
protected void init(String command, String[] params, String file) throws IOException { |
|
|
36 |
if (params == null || params.length == 0) { |
37 |
args = new String[] {command, "-C", "-f", "-e", file}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
38 |
} else { |
39 |
args = new String[params.length + 1]; |
40 |
args[0] = command; |
41 |
System.arraycopy(params, 0, args, 1, params.length); |
42 |
} |
43 |
addr2line = ProcessFactory.getFactory().exec(args); |
44 |
stdin = new BufferedWriter(new OutputStreamWriter(addr2line.getOutputStream())); |
45 |
stdout = new BufferedReader(new InputStreamReader(addr2line.getInputStream())); |
46 |
} |
47 |
|
48 |
protected void getOutput(String address) throws IOException { |
34 |
if ( address.equals(lastaddr) == false ) { |
49 |
if ( address.equals(lastaddr) == false ) { |
35 |
stdin.write(address + "\n"); //$NON-NLS-1$ |
50 |
stdin.write(address + "\n"); //$NON-NLS-1$ |
36 |
stdin.flush(); |
51 |
stdin.flush(); |