[Guardsoft-cvs] guard/src/dbgsrv dbgsrv_gdbmi.c,1.3,1.4
Brought to you by:
jarrah
|
From: Greg W. <ja...@us...> - 2005-05-02 19:31:33
|
Update of /cvsroot/guardsoft/guard/src/dbgsrv In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17399 Modified Files: dbgsrv_gdbmi.c Log Message: Send source line when necessary. This should be depreciated and replaced with source management in the client. Index: dbgsrv_gdbmi.c =================================================================== RCS file: /cvsroot/guardsoft/guard/src/dbgsrv/dbgsrv_gdbmi.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dbgsrv_gdbmi.c 1 May 2005 23:51:46 -0000 1.3 --- dbgsrv_gdbmi.c 2 May 2005 19:31:18 -0000 1.4 *************** *** 224,227 **** --- 224,266 ---- } + char * + LookupLine(char *file, int line) + { + size_t len; + char * lp; + char * ret; + FILE * fp; + + if ( file == NULL ) + return NULL; + + if ( (fp = fopen(file, "r")) == NULL ) + return NULL; + + while ( line-- > 0 ) + lp = fgetln(fp, &len); + + if ( lp == NULL ) + { + fclose(fp); + return NULL; + } + + /* + ** Remove newline if it exists. + */ + if ( lp[len-1] == '\n' ) + len--; + + ret = (char *)Alloc(sizeof(char *) * len + 1); + + memcpy(ret, lp, len); + ret[len] = '\0'; + + fclose(fp); + + return ret; + } + dbgevent_t * AsyncStep(void *arg) *************** *** 237,242 **** e = NewEvent(DBGEV_STEP); e->ev_step_lno = CurrFrame->frame_loc.loc_line; - e->ev_step_line = NULL; e->ev_step_frame = DupFrame(CurrFrame); return e; --- 276,281 ---- e = NewEvent(DBGEV_STEP); e->ev_step_lno = CurrFrame->frame_loc.loc_line; e->ev_step_frame = DupFrame(CurrFrame); + e->ev_step_line = LookupLine(CurrFrame->frame_loc.loc_file, CurrFrame->frame_loc.loc_line); return e; *************** *** 258,263 **** e = NewEvent(DBGEV_SIGNAL); e->ev_sig_type = sig; - e->ev_sig_line = NULL; e->ev_sig_frame = DupFrame(CurrFrame); return e; --- 297,302 ---- e = NewEvent(DBGEV_SIGNAL); e->ev_sig_type = sig; e->ev_sig_frame = DupFrame(CurrFrame); + e->ev_sig_line = LookupLine(CurrFrame->frame_loc.loc_file, CurrFrame->frame_loc.loc_line); return e; *************** *** 523,527 **** bp->bp_loc.loc_line = bpt->line; ! bp->bp_stmt = NULL; /* todo */ /* --- 562,566 ---- bp->bp_loc.loc_line = bpt->line; ! bp->bp_stmt = LookupLine(bpt->file, bpt->line); /* *************** *** 586,591 **** ** List source code. ** ! ** XXX a better way to do this might be to create a socket ! ** to the client and just ship the stuff across. */ dbgevent_t * --- 625,629 ---- ** List source code. ** ! ** This function should be depreciated. */ dbgevent_t * |