Hi All,
i found java code for execute a command with gdb. the command is
executed by the java application.
java application as follows:
------------------------------------------------------------------------------------------------------
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
/**
*
* @author nuwan
*/
public class Debugger extends Thread{
public void run(){
Process p = null;
try {
p = Runtime.getRuntime().exec("gdb a.out --interpreter=console");
new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
new Thread(new SyncPipe(p.getInputStream(), System.out)).start();
PrintWriter stdin = new PrintWriter(p.getOutputStream());
stdin.flush();
stdin.println("target remote localhost:3333");
stdin.flush();
System.out.println("=====================================");
stdin.println("monitor irscan stm32.tap 0x00");
stdin.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}
class SyncPipe implements Runnable
{
public SyncPipe(InputStream istrm, OutputStream ostrm) {
istrm_ = istrm;
ostrm_ = ostrm;
}
public void run() {
try
{
int length;
byte[] buffer = new byte[1024];
for ( length = 0; (length = istrm_.read(buffer)) != -1; ){
ostrm_.write(buffer, 0, length);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
private final OutputStream ostrm_;
private final InputStream istrm_;
public static void main(String []args ){
Debugger d=new Debugger();
d.run();
}
}
=============================================
output of java program is :
------------------------------------------------------------------------------------------------
=====================================
a.out: No such file or directory.
GNU gdb (GDB) 7.0-ubuntu
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(gdb) Remote debugging using localhost:3333
0x00000000 in ?? ()
Invalid command argument
Tap: stm32.tap unknown
in procedure 'irscan'
(gdb) (gdb) BUILD STOPPED (total time: 2 seconds)
=============================================
when i run this command IRSCAN command;
in OPENOCD ;
if the command successfully executed 1 will be displayed
else 0 will be displayed and the error is printed at the console.
Question is ;
i want to identify and sepeate the message output
i want to know whether the command is successfully executed or not?
How to seperate the openocd server response and what is the format of
openocd server response? if there is any references please help me to
find it.
Thank you
Nuwan
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel