[Guardsoft-cvs] guard/src/dbgsrv dbgsrv_gdb.c,1.60,1.61
Brought to you by:
jarrah
|
From: Greg W. <ja...@us...> - 2005-05-01 16:27:49
|
Update of /cvsroot/guardsoft/guard/src/dbgsrv In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25876 Modified Files: dbgsrv_gdb.c Log Message: New backend support. Index: dbgsrv_gdb.c =================================================================== RCS file: /cvsroot/guardsoft/guard/src/dbgsrv/dbgsrv_gdb.c,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** dbgsrv_gdb.c 7 Jan 2004 02:29:47 -0000 1.60 --- dbgsrv_gdb.c 1 May 2005 16:27:40 -0000 1.61 *************** *** 98,101 **** --- 98,104 ---- dbgevent_t Event; char * ProgMain; + #ifdef sun + char * IODevName = NULL; + #endif /* sun */ extern int Shutdown; *************** *** 106,113 **** dbgevent_t * WaitEvent(dbgevent_t *); int SetCurrentLine(int); - void FreeFrame(dbgframe_t *); - void FreeLocation(dbgloc_t *); void Finish(int); ! dbgevent_t * InitDbg(char *); #ifdef P4 dbgevent_t * InitP4Dbg(char *, int, char *, char *, char *, char **); --- 109,114 ---- dbgevent_t * WaitEvent(dbgevent_t *); int SetCurrentLine(int); void Finish(int); ! dbgevent_t * InitDbg(char *, char *); #ifdef P4 dbgevent_t * InitP4Dbg(char *, int, char *, char *, char *, char **); *************** *** 115,119 **** #endif /* P4 */ dbgevent_t * GetPid(int *); ! char * SetupDbg(int, char *); void SendCmd(char *, ...); #ifdef notdef --- 116,120 ---- #endif /* P4 */ dbgevent_t * GetPid(int *); ! char * SetupDbg(char *); void SendCmd(char *, ...); #ifdef notdef *************** *** 140,143 **** --- 141,148 ---- void InitRegex(void); + dbgevent_t * InitGDB(int *, int *); + #ifdef sun + int ProgIOHookGDB(int fd); + #endif /* sun */ dbgevent_t * DbgGDBSetLineBreak(char *, int); dbgevent_t * DbgGDBSetFuncBreak(char *, char *); *************** *** 159,168 **** dbgevent_t * DbgGDBQuit(void); dbgevent_t * DbgGDBInterrupt(char *, int); ! dbgevent_t * DbgGDBInvoke(char *, int, char *, char *, char *, char **, int, char *, int *); ! dbgevent_t * DbgGDBAttach(int, char *, char *, char **, int, char *, int *); void DbgGDBFinish(void); dbgbackend_sw DbgBackendGDB = { DbgGDBSetLineBreak, DbgGDBSetFuncBreak, --- 164,181 ---- dbgevent_t * DbgGDBQuit(void); dbgevent_t * DbgGDBInterrupt(char *, int); ! dbgevent_t * DbgGDBInvoke(char *, int, char *, char *, char *, char **, int); ! dbgevent_t * DbgGDBAttach(int, char *, char *, char **, int); void DbgGDBFinish(void); dbgbackend_sw DbgBackendGDB = { + InitGDB, + FillBuffer, + BufferReady, + #ifdef sun + ProgIOHookGDB, + #else /* sun */ + NULL, + #endif /* sun */ DbgGDBSetLineBreak, DbgGDBSetFuncBreak, *************** *** 187,192 **** DbgGDBAttach, DbgGDBFinish, - FillBuffer, - BufferReady, DbgReadyForCmd, DbgOK, --- 200,203 ---- *************** *** 1490,1494 **** */ dbgevent_t * ! StartDebugger(char *prog, char *args, char **env, int arch, char *slave) { int p[2]; --- 1501,1505 ---- */ dbgevent_t * ! StartDebugger(char **env, char *slave) { int p[2]; *************** *** 1520,1534 **** signal(SIGPIPE, Finish); ! if ( args != NULL ) ! { ! e = DbgGDBSetArgs(args); ! ! if ( e->ev_event != DBGEV_OK ) ! return e; ! ! FreeEvent(e); ! } ! ! if ( (GDBInit = SetupDbg(arch, slave)) == NULL ) { EVENT_ERROR(e, DBGERR_TEMP, ""); --- 1531,1535 ---- signal(SIGPIPE, Finish); ! if ( (GDBInit = SetupDbg(slave)) == NULL ) { EVENT_ERROR(e, DBGERR_TEMP, ""); *************** *** 1599,1612 **** } dbgevent_t * ! DbgGDBInvoke(char *host, int cb, char *proto, char *prog, char *args, char **env, int arch, char *slave, int *dbgfd) { dbgevent_t * e; ! DPRINT(fprintf(stderr, "*** DbgInvoke\n")); ! if ( (e = StartDebugger(prog, args, env, arch, slave)) != (dbgevent_t *)NULL ) return e; switch ( arch ) { --- 1600,1673 ---- } + extern int AllocPty(int *, char **, char**); + extern int AllocFifo(int *, char **, char**); + dbgevent_t * ! InitGDB(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 + ProgIOHookGDB(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 * + DbgGDBInvoke(char *host, int cb, char *proto, char *prog, char *args, char **env, int arch) + { + dbgevent_t * e; + + DPRINT(fprintf(stderr, "*** DbgInvoke\n")); + + MPArch = arch; + switch ( arch ) { *************** *** 1618,1625 **** default: ! e = InitDbg(prog); } - *dbgfd = DBGIn; Status = DBGSTAT_STOPPED; --- 1679,1685 ---- default: ! e = InitDbg(prog, args); } Status = DBGSTAT_STOPPED; *************** *** 1631,1635 **** */ dbgevent_t * ! DbgGDBAttach(int pid, char *prog, char *args, char **env, int arch, char *slave, int *dbgfd) { dbgevent_t * e; --- 1691,1695 ---- */ dbgevent_t * ! DbgGDBAttach(int pid, char *prog, char *args, char **env, int arch) { dbgevent_t * e; *************** *** 1637,1642 **** DPRINT(fprintf(stderr, "*** DbgAttach\n")); ! if ( (e = StartDebugger(prog, args, env, arch, slave)) != (dbgevent_t *)NULL ) ! return e; switch ( arch ) --- 1697,1701 ---- DPRINT(fprintf(stderr, "*** DbgAttach\n")); ! MPArch = arch; switch ( arch ) *************** *** 1653,1657 **** } - *dbgfd = DBGIn; Status = DBGSTAT_STOPPED; --- 1712,1715 ---- *************** *** 1686,1689 **** --- 1744,1752 ---- { SendCmd("quit"); + + #ifdef sun + if ( IODevName != NULL ) + (void)unlink(IODevName); + #endif /* sun */ } *************** *** 2094,2098 **** */ char * ! SetupDbg(int arch, char *slave) { FILE * fp; --- 2157,2161 ---- */ char * ! SetupDbg(char *slave) { FILE * fp; *************** *** 2125,2130 **** fclose(fp); - MPArch = arch; - return file; } --- 2188,2191 ---- *************** *** 2183,2187 **** */ dbgevent_t * ! InitDbg(char *prog) { dbgevent_t * e; --- 2244,2248 ---- */ dbgevent_t * ! InitDbg(char *prog, char *args) { dbgevent_t * e; *************** *** 2199,2202 **** --- 2260,2273 ---- FreeEvent(e); + if ( args != NULL ) + { + e = DbgGDBSetArgs(args); + + if ( e->ev_event != DBGEV_OK ) + return e; + + FreeEvent(e); + } + /* ** Check for fortran. |