jtagemul.c File Reference

#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <netdb.h>
#include "jtagsock.h"
#include "gdbrdp.h"
#include "cmdparser.h"
#include "mips32.h"

Include dependency graph for jtagemul.c:

Go to the source code of this file.

Defines

#define PORTNUM   50010

Functions

int cmd_gdbserver (int argc, char **argv)
static int cmd_quitgdb (int argc, char **argv)
void ctrl_c_op (int signo)
 mycmd_init (quitgdb, cmd_quitgdb,"quitgdb [n]","quitgdb n>1 force quit")
 mycmd_init (gdbserver, cmd_gdbserver,"gdbserver","gdbserver [port],\tenv:compareasid,comparedata,quitgdb")

Variables

int config_gdbserver_quitgdb


Define Documentation

#define PORTNUM   50010

Definition at line 62 of file jtagemul.c.

Referenced by cmd_gdbserver().


Function Documentation

int cmd_gdbserver ( int  argc,
char **  argv 
)

Definition at line 77 of file jtagemul.c.

References config_gdbserver_quitgdb, dMIPS32_EJTAG_WAIT_FOR_CONTINUE, fGDBRDP_Handler(), fJTAGSOCK_Establish(), fJTAGSOCK_GetConnection(), fMIPS32_Init(), force_acc(), PORTNUM, ui_ejtag_state, and ui_last_signal.

00078 {
00079         int i_socket, i_currentsocket, i_flags;
00080         int port = argc > 1 ? strtoul(argv[1],0,0) :PORTNUM;
00081 
00082 //      signal(SIGPIPE,ctrl_c_op);
00083         setbuffer(stdout,0,0);
00084         setbuffer(stderr,0,0);
00085 
00086         fMIPS32_Init();
00087         // Establish connection to port
00088         i_socket = fJTAGSOCK_Establish(port);
00089         if (i_socket < 0)
00090         {
00091                 // Establish failed.
00092                 perror("fJTAGSOCK_Establish failed.");
00093                 exit(1);
00094         }
00095 
00096 
00097         config_gdbserver_quitgdb = 0;
00098         // Forever
00099         for (;;)
00100         {
00101                 if(config_gdbserver_quitgdb)break;
00102                 printf("Attached to port %d, waiting for gdb.\nyou can also input command on console\n",port);
00103 
00104                 i_flags = fcntl(i_socket, F_GETFL, 0); 
00105                 i_flags |= O_NONBLOCK;
00106                 fcntl(i_socket, F_SETFL, i_flags); 
00107                 // Wait for a connection to occur
00108                 i_currentsocket = fJTAGSOCK_GetConnection(i_socket);
00109                 if (i_currentsocket < 0)
00110                 {
00111                         perror("fJTAGSOCK_GetConnection failed.");
00112                         close(i_socket);
00113                         return 2;
00114                 }
00115 
00116                 // Change the socket to non-blocking
00117                 i_flags = fcntl(i_currentsocket, F_GETFL, 0); 
00118                 i_flags |= O_NONBLOCK;
00119                 fcntl(i_currentsocket, F_SETFL, i_flags); 
00120 
00121                 printf("GDB successfully attached.\r\n");
00122 
00123                 force_acc();
00124                 ui_ejtag_state=dMIPS32_EJTAG_WAIT_FOR_CONTINUE;
00125                 ui_last_signal=SIGTRAP;
00126 
00127                 // Run the GDB Remote Debugging Protocol handler (the guts)
00128                 fGDBRDP_Handler(i_currentsocket);
00129         }
00130 
00131         // Should never reach here
00132         close(i_socket);
00133         close(i_currentsocket);
00134         return(1);
00135 }

Here is the call graph for this function:

static int cmd_quitgdb ( int  argc,
char **  argv 
) [static]

Definition at line 136 of file jtagemul.c.

References config_gdbserver_quitgdb.

00137 {
00138 extern int config_gdbserver_quitgdb;
00139 if(argc > 1)
00140  config_gdbserver_quitgdb = strtoul(argv[1],0,0);
00141 else
00142  config_gdbserver_quitgdb = 1;
00143  return 0;
00144 }

void ctrl_c_op ( int  signo  ) 

Definition at line 71 of file jtagemul.c.

00072 {
00073         printf("kkkkkkkkkkkkkkkkkkkk\n");
00074         signal(SIGPIPE,SIG_IGN);
00075 }

mycmd_init ( quitgdb  ,
cmd_quitgdb  ,
"quitgdb "  [n],
"quitgdb   n,
1 force quit"   
)

mycmd_init ( gdbserver  ,
cmd_gdbserver  ,
"gdbserver"  ,
"  gdbserver[port],
\tenv:compareasid  ,
comparedata  ,
quitgdb"   
)


Variable Documentation

Definition at line 100 of file gdbrdp.c.


Generated on Fri Nov 5 07:24:49 2010 for ejtag debug tools for loongson 232 cpu by  doxygen 1.5.6