[Guardsoft-cvs] guard/src/dbgsrv dbgsrv.c,1.43,1.44
Brought to you by:
jarrah
|
From: Greg W. <ja...@us...> - 2005-05-01 16:27:11
|
Update of /cvsroot/guardsoft/guard/src/dbgsrv In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25431 Modified Files: dbgsrv.c Log Message: Added OpenMPI support. Redefined some backend routines to work with GDB MI. Index: dbgsrv.c =================================================================== RCS file: /cvsroot/guardsoft/guard/src/dbgsrv/dbgsrv.c,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** dbgsrv.c 7 Jan 2004 02:29:47 -0000 1.43 --- dbgsrv.c 1 May 2005 16:27:02 -0000 1.44 *************** *** 86,89 **** --- 86,92 ---- { "p4slave", MPARCH_P4SLAVE }, #endif /* P4 */ + #ifdef OMPI + { "ompi", MPARCH_OMPI }, + #endif /* OMPI */ { "unknown", MPARCH_UNKNOWN } }; *************** *** 98,102 **** int Shutdown = 0; int WDT = 0; - int CleanupIO = 0; dbgevent_t * (*AsyncRtn)() = (dbgevent_t * (*)())NULL; --- 101,104 ---- *************** *** 105,111 **** int AsyncProg; int DbgFD; ! int IOBackendFD; int IOClientFD; - char * IODevName; void Usage(void); --- 107,112 ---- int AsyncProg; int DbgFD; ! int IOBackendFD = -1; int IOClientFD; void Usage(void); *************** *** 115,119 **** char * MakeStr(int, char*[]); int FindMPArch(char *); ! void SetupProgIO(int *, char **, char **, int *, int *); int DoProgIO(int *, int); int AllocPty(int *, char **, char **); --- 116,120 ---- char * MakeStr(int, char*[]); int FindMPArch(char *); ! int SetupProgIO(int *, int *); int DoProgIO(int *, int); int AllocPty(int *, char **, char **); *************** *** 136,140 **** char * host = NULL; int procnum = -1; ! int port; int pnum; int pid = -1; --- 137,141 ---- char * host = NULL; int procnum = -1; ! int port = -1; int pnum; int pid = -1; *************** *** 144,148 **** char * prog; char * args; - char * slave; dbgev evt; dbgevent_t * e; --- 145,148 ---- *************** *** 352,355 **** --- 352,374 ---- #endif /* P4 */ + #ifdef OMPI + case MPARCH_OMPI: + { + char * ps; + + if + ( + (ps = getenv("OMPI_MCA_pcmclient_env_procid")) == NULL + || + sscanf(ps, "%d", &procnum) != 1 + ) + { + fprintf(stderr, "OMPI: could not find process number\n"); + exit(1); + } + } + break; + #endif /* OMPI */ + case MPARCH_SERIAL: procnum = 0; *************** *** 364,372 **** exit(1); ! SetupProgIO(&IOBackendFD, &IODevName, &slave, &IOClientFD, &port); #ifdef P4 if ( arch == MPARCH_P4SLAVE ) ! e = DbgBackendSW->dbg_attach(pid, prog, args, env, arch, slave, &DbgFD); else { --- 383,401 ---- exit(1); ! if ( (e = DbgBackendSW->dbg_init(&DbgFD, &IOBackendFD)) != NULL ) ! { ! InvokeCallBack(host, cb, hname, pnum, procnum, port, e); ! EndServer(1); ! } ! ! if ( IOBackendFD != -1 && SetupProgIO(&IOClientFD, &port) < 0 ) ! { ! fprintf(stderr, "Could not setup program IO channel\n"); ! IOBackendFD = -1; ! } #ifdef P4 if ( arch == MPARCH_P4SLAVE ) ! e = DbgBackendSW->dbg_attach(pid, prog, args, env, arch); else { *************** *** 378,382 **** } ! e = DbgBackendSW->dbg_invoke(host, cb, proto, prog, args, env, arch, slave, &DbgFD); #ifdef P4 } --- 407,411 ---- } ! e = DbgBackendSW->dbg_invoke(host, cb, proto, prog, args, env, arch); #ifdef P4 } *************** *** 461,465 **** if ( AsyncRtn != (dbgevent_t * (*)())NULL ) { ! if ( AsyncRtn == ASYNC_FORCE || DbgBackendSW->dbg_bufferready() ) { if ( AsyncRtn != ASYNC_FORCE ) --- 490,505 ---- if ( AsyncRtn != (dbgevent_t * (*)())NULL ) { ! if ! ( ! DbgBackendSW->dbg_bufferready == NULL ! || ! AsyncRtn == ASYNC_FORCE ! || ! ( ! DbgBackendSW->dbg_bufferready != NULL ! && ! DbgBackendSW->dbg_bufferready() ! ) ! ) { if ( AsyncRtn != ASYNC_FORCE ) *************** *** 515,519 **** FD_CLR(DbgFD, readfds); ! if ( !DbgBackendSW->dbg_fillbuffer(DbgFD) ) { (void)close(DbgFD); --- 555,559 ---- FD_CLR(DbgFD, readfds); ! if ( !DbgBackendSW->dbg_read(DbgFD) ) { (void)close(DbgFD); *************** *** 578,584 **** DbgEndProto(); - if ( CleanupIO ) - (void)unlink(IODevName); - exit(stat); } --- 618,621 ---- *************** *** 678,686 **** /* ! ** Allocate an I/O channel for the backend, and if successful, create and bind ! ** a socket for the client to connect to. */ ! void ! SetupProgIO(int *bfd, char **master, char **slave, int *cfd, int *port) { #ifdef _AIX --- 715,722 ---- /* ! ** Create and bind a socket for the client to connect to. */ ! int ! SetupProgIO(int *cfd, int *port) { #ifdef _AIX *************** *** 691,723 **** struct sockaddr_in in; - *slave = NULL; - *port = -1; - - /* - ** Try allocating a pty for backend i/o first. If this fails then - ** we use a fifo. Note that using a fifo restricts us to output only. - */ - if ( AllocPty(bfd, master, slave) < 0 ) - { - CleanupIO = 1; - - if ( AllocFifo(bfd, master, slave) < 0 ) - { - /* - ** XXX should return a warning to user that there is - ** no i/o, but continue anyway. - */ - fprintf(stderr, "could not setup backend i/o...\n"); - *bfd = -1; - return; - } - } - if ( (*cfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { perror("socket"); ! (void)close(*bfd); ! *bfd = -1; ! return; } --- 727,734 ---- struct sockaddr_in in; if ( (*cfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { perror("socket"); ! return -1; } *************** *** 729,736 **** { perror("bind"); - (void)close(*bfd); (void)close(*cfd); ! *bfd = -1; ! return; } --- 740,745 ---- { perror("bind"); (void)close(*cfd); ! return -1; } *************** *** 740,747 **** { perror("getsockname"); - (void)close(*bfd); (void)close(*cfd); ! *bfd = -1; ! return; } --- 749,754 ---- { perror("getsockname"); (void)close(*cfd); ! return -1; } *************** *** 749,762 **** listen(*cfd, 5); } /* ** Transfer data from backend to socket connected to client. - ** - ** Note: It appears (Solaris 2.5) that if the slave - ** closes its pty before the master has time to read - ** the current data, then we get EIO's until the - ** slave opens the pty again. The only way to stop this - ** seems to be to close and reopen the master side. */ int --- 756,765 ---- listen(*cfd, 5); + + return 0; } /* ** Transfer data from backend to socket connected to client. */ int *************** *** 770,782 **** if ( errno == EIO ) { ! #if defined(sun) ! (void)close(*in); ! ! if ( (*in = open(IODevName, O_RDWR, 0600)) < 0 ) ! { ! perror(IODevName); return 0; - } - #endif /* sun */ return 1; --- 773,783 ---- if ( errno == EIO ) { ! if ! ( ! DbgBackendSW->dbg_progio_hook ! && ! (*in = DbgBackendSW->dbg_progio_hook(*in)) < 0 ! ) return 0; return 1; |