void ProcFlip( void ) { const char *old; uint_16 wait; wait = 0; if( !ScanEOC() ) { old = ScanPos(); switch( ScanCmd( "ON\0OFf\0" ) ) { case 0: ReqEOC(); _SwitchOn( SW_FLIP ); return; case 1: ReqEOC(); _SwitchOff( SW_FLIP ); return; default: ReScan( old ); wait = (uint_16)ReqExpr(); ReqEOC(); break; } } Flip( wait ); }
unsigned OptExpr( unsigned def_val ) { if( CurrToken == T_COMMA || CurrToken == T_LEFT_BRACE || ScanEOC() ) return( def_val ); return( ReqExpr() ); }
void ProcFlip( void ) { char *old; unsigned wait; unsigned cmd; wait = 0; if( !ScanEOC() ) { old = ScanPos(); cmd = ScanCmd( OnOffNameTab ); switch( cmd ) { case 1: ReqEOC(); _SwitchOn( SW_FLIP ); return; case 2: ReqEOC(); _SwitchOff( SW_FLIP ); return; default: ReScan( old ); wait = ReqExpr(); ReqEOC(); break; } } Flip( wait ); }
void ProcInvoke( void ) { char *fstart; unsigned flen; char *start; char_ring *parmlist; char_ring **owner; char_ring *path; unsigned len; if( !ScanItem( TRUE, &fstart, &flen ) ) Error( ERR_LOC, LIT( ERR_WANT_FILENAME ) ); parmlist = NULL; owner = &parmlist; while( !ScanEOC() ) { ScanItem( TRUE, &start, &len ); _Alloc( path, sizeof( char_ring ) + len ); if( path == NULL ) { FreeRing( parmlist ); Error( ERR_NONE, LIT( ERR_NO_MEMORY ) ); } memcpy( path->name, start, len ); path->name[ len ] = NULLCHAR; path->next = NULL; *owner = path; owner = &path->next; } Invoke( fstart, (int)flen, parmlist ); }
static void MemMod( mad_type_handle mth, mad_type_kind mas ) { item_mach item; item_type ops; address addr; mad_type_info mti; ops = IT_ERR | IT_INC; if( mas & MAS_IO ) { ops |= IT_IO; addr.mach.offset = ReqExpr(); } else { addr = GetDataDot(); OptMemAddr( EXPR_DATA, &addr ); } if( CurrToken == T_COMMA ) Scan(); MADTypeInfo( mth, &mti ); while( !ScanEOC() ) { if( !( ops & IT_IO ) ) { SetDataDot( addr ); } if( CurrToken != T_COMMA ) { NormalExpr(); ToItemMAD( ExprSP, &item, &mti ); PopEntry(); if( CurrToken != T_COMMA && !ScanEOC() ) { Error( ERR_LOC, LIT_ENG( ERR_WANT_EOC ) ); } ItemPutMAD( &addr, &item, ops, mth ); } if( CurrToken == T_COMMA ) { Scan(); } } if( !(ops & IT_IO) ) { DbgUpdate( UP_MEM_CHANGE | UP_CODE_ADDR_CHANGE | UP_REG_CHANGE ); } }
static void DoProcBreak( void ) { int cmd; if( CurrToken == T_DIV ) { Scan(); cmd = ScanCmd( PointNameTab ); BPJmpTab[ cmd ].rtn( BPJmpTab[ cmd ].type ); } else if( ScanEOC() ) { ShowBPs(); } else { SetBreak( EXPR_CODE ); } }
void ProcLog( void ) { if( ScanEOC() ) { LogEnd(); } else if( CurrToken == T_GT ) { Scan(); LogAppend(); } else if( CurrToken == T_DIV ) { Scan(); (*LogJmpTab[ ScanCmd( LogNameTab ) ])(); } else { LogStart(); } }
bool ScanItem( bool blank_delim, char **start, unsigned *len ) { if( ScanEOC() ) { *start = NULL; *len = 0; return( FALSE ); } if( ScanQuote( start, len ) ) return( TRUE ); *start = TokenStart; for( ;; ) { if( blank_delim && isspace( *ScanPtr ) ) break; if( *ScanPtr == ';' ) break; if( *ScanPtr == NULLCHAR ) break; ++ScanPtr; } *len = ScanPtr - TokenStart; Scan(); return( TRUE ); }
void ProcLog( void ) { int cmd; if( ScanEOC() ) { LogEnd(); } else if( CurrToken == T_GT ) { Scan(); LogAppend(); } else if( CurrToken == T_DIV ) { Scan(); cmd = ScanCmd( LogNameTab ); if( cmd < 0 ) { BadLog(); } else { (*LogJmpTab[cmd])(); } } else { LogStart(); } }
void ProcDisplay( void ) { wnd_class_wv wndclass; mad_radix old_radix; if( ScanEOC() ) { while( HookPendingPush() ); PushRefresh(); return; } old_radix = NewCurrRadix( 10 ); switch( ScanCmd( MiscTab ) ) { case MISC_TOOL: ProcTool(); break; case MISC_STATUS: ProcStatus(); break; default: wndclass = ReqWndName(); ProcSize( wndclass ); } NewCurrRadix( old_radix ); }
void ProcGo( void ) { address start; address stop; bool have_start; bool have_stop; bool have_keep; bool doflip; bool flip_on; bool until; unsigned conditions; int count; have_keep = FALSE; doflip = TRUE; until = FALSE; while( CurrToken == T_DIV ) { Scan(); switch( ScanCmd( GoOptionTab ) ) { case KEEP: have_keep = TRUE; break; case NOFLIP: doflip = FALSE; break; case UNTIL: until = TRUE; break; default: Error( ERR_LOC, LIT( ERR_BAD_OPTION ), GetCmdName( CMD_GO ) ); } } if( !have_keep ) TraceKill(); NullStatus( &DbgTmpBrk ); start = GetRegIP(); have_stop = FALSE; have_start = FALSE; if( !ScanEOC() ) { stop = start; ReqMemAddr( EXPR_GIVEN, &stop ); if( CurrToken == T_COMMA ) { start = stop; have_start = TRUE; Scan(); if( !ScanEOC() ) { ReqMemAddr( EXPR_GIVEN, &stop ); have_stop = TRUE; } } else { have_stop = TRUE; } } ReqEOC(); count = 0; do { if( have_stop ) { if( have_keep ) { if( UserTmpBrk.status.b.has_address ) { NullStatus( &UserTmpBrk ); UserTmpBrk.status.b.has_address = TRUE; } else { NullStatus( &UserTmpBrk ); } Error( ERR_NONE, LIT( ERR_INCONSISTENT_GO ) ); } SetTempBreak( stop ); } else if( have_keep ) { if( UserTmpBrk.status.b.has_address ) { UserTmpBrk.status.b.active = TRUE; } } else { NullStatus( &UserTmpBrk ); } if( have_start ) { RecordSetRegIP( start ); } flip_on = _IsOn( SW_FLIP ); if( !doflip ) { _SwitchOff( SW_FLIP ); } conditions = Go( doflip ); if( flip_on ) _SwitchOn( SW_FLIP ); if( UserTmpBrk.status.b.has_address ) { NullStatus( &UserTmpBrk ); UserTmpBrk.status.b.has_address = TRUE; } else { NullStatus( &UserTmpBrk ); } } while( until && (conditions & COND_BREAK) && AddrComp( stop, GetRegIP() ) != 0 && ++count < 100 ); }
void ProcCall( void ) { mad_string ctype; int parm; const char *results; address start; const char *old; location_list ll; dig_type_info ti; dig_type_info *pti; char *p; const mad_reg_info **parm_reg; if( CurrToken == T_DIV ) { Scan(); ctype = ScanCall(); if( ctype == MAD_MSTR_NIL ) { Error( ERR_LOC, LIT_ENG( ERR_BAD_CALL_TYPE ) ); } } else { ctype = DefCallType; } CallExpr( &start ); if( _IsOff( SW_HAVE_SET_CALL ) ) { FiniCall(); p = TxtBuff; *p++ = '('; parm_reg = MADCallParmRegList( ctype, start ); for( parm = 0; parm_reg[parm] != NULL; ++parm ) { if( parm > 0 ) { *p++ = ','; } p = StrCopy( parm_reg[parm]->name, p ); } *p++ = ')'; StrCopy( MADCallReturnReg( ctype, start )->name, p ); old = ReScan( TxtBuff ); DoCallSet(); ReScan( old ); } parm = 0; results = DefReturn; if( CurrToken == T_LEFT_PAREN ) { Scan(); if( CurrToken != T_RIGHT_PAREN ) { for( ; ; ) { pti = &ti; if( CurrToken == T_DIV ) { Scan(); if( CurrToken == T_DIV ) { Scan(); /* on stack */ LocationCreate( &ll, LT_INTERNAL, NULL ); pti = NULL; } else { GetLocation( &ll, pti ); } } else { if( DefParms[parm] == NULL ) { /* on stack */ LocationCreate( &ll, LT_INTERNAL, NULL ); pti = NULL; } else { old = ReScan( DefParms[parm] ); GetLocation( &ll, pti ); ReScan( old ); } } PushLocation( &ll, pti ); NormalExpr(); SwapStack( 1 ); ++parm; if( CurrToken != T_COMMA ) break; Scan(); } } Recog( T_RIGHT_PAREN ); results = ScanPos(); if( CurrToken == T_DIV ) { Scan(); } else if( ScanEOC() ) { results = DefReturn; } else { /* syntax check */ ChkPrintList(); } } ReqEOC(); FreezeRegs(); if( PerformExplicitCall( start, ctype, parm ) && results != NULL ) { old = ReScan( results ); if( Spawn( CallResults ) == 0 ) { ReScan( old ); } } UnFreezeRegs(); FreePgmStack( false ); }
void OptMemAddr( memory_expr def_seg, address *def_val ) { if( CurrToken == T_COMMA || ScanEOC() ) return; ReqMemAddr( def_seg, def_val ); }
static brkp *SetPoint( memory_expr def_seg, mad_type_handle th ) { brkp *bp; const char *start; size_t len; address loc; cmd_list *cmds; char *condition; long countdown; bool resume; bool active; int index; mad_type_info mti; unsigned old; bool unmapped; bool mapaddress; bool symaddress; char *image_name; char *mod_name; char *sym_name; long cue_diff; long addr_diff; int cmd; resume = false; index = 0; active = true; unmapped = false; mapaddress = false; symaddress = false; while( CurrToken == T_DIV ) { Scan(); cmd = ScanCmd( PointNameTab ); if( cmd < 0 ) break; switch( cmd ) { case B_RESUME: resume = true; break; case B_UNRESUME: resume = false; break; case B_ACTIVATE: active = true; break; case B_DEACTIVATE: active = false; break; case B_UNMAPPED: unmapped = true; break; case B_MAPADDRESS: mapaddress = true; ScanItem( true, &start, &len ); image_name = DupStrLen( start, len ); loc.mach.segment = ReqLongExpr(); loc.mach.offset = ReqLongExpr(); ReqComma(); break; case B_SYMADDRESS: symaddress = true; ScanItem( true, &start, &len ); image_name = DupStrLen( start, len ); ScanItem( true, &start, &len ); mod_name = DupStrLen( start, len ); ScanItem( true, &start, &len ); sym_name = DupStrLen( start, len ); cue_diff = ReqLongExpr(); addr_diff = ReqLongExpr(); loc = NilAddr; ReqComma(); break; case B_INDEX: old = NewCurrRadix( 10 ); index = ReqExpr(); NewCurrRadix( old ); ReqComma(); break; /* fall thru */ default: Error( ERR_LOC, LIT_ENG( ERR_BAD_OPTION ), GetCmdName( CMD_BREAK ) ); break; } } if( !unmapped ) { ReqMemAddr( def_seg, &loc ); } for( bp = BrkList; bp != NULL; bp = bp->next ) { if( AddrComp( bp->loc.addr, loc ) == 0 ) { Error( ERR_NONE, LIT_ENG( ERR_POINT_EXISTS ) ); } } cmds = NULL; condition = NULL; countdown = 0; if( ScanQuote( &start, &len ) ) { if( len != 0 ) cmds = AllocCmdList( start, len ); if( ScanQuote( &start, &len ) ) { if( len != 0 ) condition = DupStrLen( start, len ); if( !ScanEOC() ) { countdown = ReqExpr(); } } } ReqEOC(); if( !IS_BP_EXECUTE( th ) ) { MADTypeInfo( th, &mti ); switch( mti.b.bits / BITS_PER_BYTE ) { case 1: case 2: case 4: break; case 8: if( Is8ByteBreakpointsSupported() ) break; default: Error( ERR_NONE, LIT_ENG( ERR_NOT_WATCH_SIZE ) ); break; } } bp = AddPoint( loc, th, unmapped ); if( bp == NULL ) return( NULL ); bp->status.b.unmapped = unmapped; if( mapaddress ) { bp->loc.image_name = image_name; } if( symaddress ) { bp->image_name = image_name; bp->mod_name = mod_name; bp->sym_name = sym_name; bp->cue_diff = cue_diff; bp->addr_diff = addr_diff; } bp->cmds = cmds; if( cmds != NULL ) bp->status.b.use_cmds = true; bp->condition = condition; if( condition != NULL ) bp->status.b.use_condition = true; SetBPCountDown( bp, countdown ); bp->status.b.resume = resume; bp->status.b.active = active; if( index != 0 ) bp->index = index; RecordBreakEvent( bp, B_SET ); return( bp ); }
void FlushEOC( void ) { while( !ScanEOC() ) Scan(); }
void ReqEOC( void ) { if( !ScanEOC() ) Error( ERR_LOC, LIT( ERR_WANT_EOC ) ); }
static void DoCallSet( void ) { mad_string ctype; int parm; int i; const char *start; struct { union { const char *arg; char *start; } u; unsigned len; } new_parms[MAX_PARMS]; location_list ll; dig_type_info ti; if( CurrToken == T_DIV ) { Scan(); ctype = ScanCall(); if( ctype == MAD_MSTR_NIL ) { Error( ERR_LOC, LIT_ENG( ERR_BAD_CALL_TYPE ) ); } } else { ctype = DefCallType; } if( CurrToken == T_LEFT_PAREN ) { parm = 0; Scan(); if( CurrToken != T_RIGHT_PAREN ) { for( ;; ) { if( parm >= MAX_PARMS ) Error( ERR_LOC, LIT_ENG( ERR_TOO_MANY_PARMS ) ); new_parms[parm].u.arg = ScanPos(); GetLocation( &ll, &ti ); new_parms[parm].len = ScanPos() - new_parms[parm].u.arg; ++parm; if( CurrToken != T_COMMA ) break; Scan(); } } Recog( T_RIGHT_PAREN ); } else { parm = -1; } start = ScanPos(); if( CurrToken == T_DIV ) { Scan(); } else if( ScanEOC() ) { start = NULL; } else { /* syntax check */ ChkPrintList(); } ReqEOC(); if( start != NULL ) { char *new_return; i = ScanPos() - start; new_return = DbgMustAlloc( i + 1 ); memcpy( new_return, start, i ); new_return[i] = NULLCHAR; _Free( DefReturn ); DefReturn = new_return; } if( parm >= 0 ) { for( i = 0; i < parm; ++i ) { char *new_arg; _Alloc( new_arg, new_parms[i].len + 1 ); if( new_arg == NULL ) { parm = i; for( i = 0; i < parm; ++i ) { _Free( new_parms[i].u.start ); } parm = 0; Error( ERR_NONE, LIT_ENG( ERR_NO_MEMORY_FOR_EXPR ) ); break; } else { memcpy( new_arg, new_parms[i].u.arg, new_parms[i].len ); new_arg[new_parms[i].len] = NULLCHAR; new_parms[i].u.start = new_arg; } } FreeParms(); for( i = 0; i < parm; ++i ) { DefParms[i] = new_parms[i].u.start; } } DefCallType = ctype; }