[Guardsoft-cvs] guard/src/dbgsrv dbgsrv_idb.c,1.1,1.2
Brought to you by:
jarrah
|
From: Greg W. <ja...@us...> - 2005-05-02 00:06:30
|
Update of /cvsroot/guardsoft/guard/src/dbgsrv In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19507 Modified Files: dbgsrv_idb.c Log Message: Support new backend interface. NOTE: THIS HAS NOT BEEN TESTED. Index: dbgsrv_idb.c =================================================================== RCS file: /cvsroot/guardsoft/guard/src/dbgsrv/dbgsrv_idb.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dbgsrv_idb.c 7 Feb 2004 18:48:17 -0000 1.1 --- dbgsrv_idb.c 2 May 2005 00:06:21 -0000 1.2 *************** *** 80,100 **** } ! dbgstat IDBStatus; ! int IDBPid = 0; ! int IDBDBGIn; ! int IDBDBGOut; ! int MPArch; ! int IDBSynced = 0; ! int ExtIDB = 0; ! char * IDBInit = NULL; ! char * IDBRunArgs = NULL; ! char * IDBRunStdIn = NULL; ! char * IDBRunStdOut = NULL; ! char * IDBRedirStr = NULL; ! char * IDBCurrentDataType = NULL; ! int IDBCurrLine = 0; ! dbgbp_t * IDBCurrBP = (dbgbp_t *)NULL; ! list_t * IDBBP; ! char * IDBProgMain; extern int Shutdown; --- 80,100 ---- } ! static dbgstat IDBStatus; ! static int IDBPid = 0; ! static int IDBDBGIn; ! static int IDBDBGOut; ! static int MPArch; ! static int IDBSynced = 0; ! static char * IDBInit = NULL; ! static char * IDBRunArgs = NULL; ! static char * IDBRedirStr = NULL; ! static char * IDBCurrentDataType = NULL; ! static int IDBCurrLine = 0; ! static dbgbp_t * IDBCurrBP = (dbgbp_t *)NULL; ! static list_t * IDBBP; ! static char * IDBProgMain; ! #ifdef sun ! static char * IODevName = NULL; ! #endif /* sun */ extern int Shutdown; *************** *** 157,160 **** --- 157,164 ---- dbgbackend_sw DbgBackendIDB = { + InitIDB, + IDBFillBuffer, + IDBBufferReady, + IDBProgIOHook, DbgIDBSetLineBreak, DbgIDBSetFuncBreak, *************** *** 179,184 **** DbgIDBAttach, DbgIDBIDBFinish, - IDBFillBuffer, - IDBBufferReady, IDBDbgReadyForCmd, IDBDbgOK, --- 183,186 ---- *************** *** 1465,1478 **** signal(SIGPIPE, IDBFinish); - if ( args != NULL ) - { - e = DbgIDBSetArgs(args); - - if ( e->ev_event != DBGEV_OK ) - return e; - - FreeEvent(e); - } - if ( (IDBInit = IDBSetupDbg(arch, slave)) == NULL ) { --- 1467,1470 ---- *************** *** 1546,1551 **** } dbgevent_t * ! DbgIDBInvoke(char *host, int cb, char *proto, char *prog, char *args, char **env, int arch, char *slave, int *dbgfd) { dbgevent_t * e; --- 1538,1605 ---- } + + extern int AllocPty(int *, char **, char**); + extern int AllocFifo(int *, char **, char**); + dbgevent_t * ! InitIDB(int *dfd, int *iofd) ! { ! char * master; ! char * slave; ! dbgevent_t * e; ! ! /* ! ** 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(iofd, &master, &slave) < 0 ! && ! AllocFifo(iofd, &master, &slave) < 0 ! ) ! *iofd = -1; ! ! /* TODO Check if env is really needed */ ! if ( (e = StartDebugger(NULL, slave)) != (dbgevent_t *)NULL ) ! return e; ! ! *dfd = DBGIn; ! ! #ifdef sun ! IODevName = master; ! #endif /* sun */ ! ! return (dbgevent_t *)NULL;; ! } ! ! #ifdef sun ! /* ! ** It appears (in 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 ! IDBProgIOHook(int fd) ! { ! if ( IODevName == NULL ) ! return -1; ! ! (void)close(fd); ! ! if ( (fd = open(IODevName, O_RDWR, 0600)) < 0 ) ! { ! perror(IODevName); ! return -1; ! } ! ! return fd; ! } ! #endif /* sun */ ! ! dbgevent_t * ! DbgIDBInvoke(char *host, int cb, char *proto, char *prog, char *args, char **env, int arch) { dbgevent_t * e; *************** *** 1553,1558 **** DPRINT(fprintf(stderr, "*** DbgInvoke\n")); ! if ( (e = IDBStartDebugger(prog, args, env, arch, slave)) != (dbgevent_t *)NULL ) ! return e; switch ( arch ) --- 1607,1611 ---- DPRINT(fprintf(stderr, "*** DbgInvoke\n")); ! MPArch = arch; switch ( arch ) *************** *** 1578,1582 **** */ dbgevent_t * ! DbgIDBAttach(int pid, char *prog, char *args, char **env, int arch, char *slave, int *dbgfd) { dbgevent_t * e; --- 1631,1635 ---- */ dbgevent_t * ! DbgIDBAttach(int pid, char *prog, char *args, char **env, int arch) { dbgevent_t * e; *************** *** 1584,1589 **** DPRINT(fprintf(stderr, "*** DbgAttach\n")); ! if ( (e = IDBStartDebugger(prog, args, env, arch, slave)) != (dbgevent_t *)NULL ) ! return e; switch ( arch ) --- 1637,1641 ---- DPRINT(fprintf(stderr, "*** DbgAttach\n")); ! MPArch = arch; switch ( arch ) *************** *** 1633,1636 **** --- 1685,1694 ---- { IDBSendCmd("quit"); + + #ifdef sun + if ( IODevName != NULL ) + (void)unlink(IODevName); + #endif /* sun */ + } |