예제 #1
0
static  bool    HaveHitBP( brkp *bp )
{
    if( !bp->status.b.active ) return( FALSE );
    if( !bp->status.b.in_place ) return( FALSE );
    if( !SectIsLoaded( bp->loc.addr.sect_id, OVL_MAP_EXE ) ) return( FALSE );
    if( AddrComp( bp->loc.addr, GetRegIP() ) != 0 ) return( FALSE );
    return( TRUE );
}
예제 #2
0
void MakeRunThdCurr( thread_state *thd )
{
    unsigned    err;

    if( !AdvMachState( ACTION_THREAD_CHANGE ) ) return;
    if( RemoteSetRunThreadWithErr( thd->tid, &err ) == 0 ) {
        Error( ERR_NONE, LIT( ERR_NO_MAKE_CURR_THREAD ), thd->tid, err );
    }
    DbgRegs->tid = thd->tid;
    ReadDbgRegs();
    SetCodeDot( GetRegIP() );
    DbgUpdate( UP_REG_CHANGE | UP_CSIP_CHANGE | UP_THREAD_STATE );
}
예제 #3
0
mad_status MADIMPENTRY( UnexpectedBreak )( mad_registers *mr, char *buff, size_t *buff_size_p )
{
    address     a;
    union {
        byte            b[9];
        addr32_ptr      a32;
        addr48_ptr      a48;
    }           data;
    size_t      buff_size;
    size_t      len;

    buff_size = *buff_size_p;
    *buff_size_p = 0;
    if( buff_size > 0 )
        buff[0] = '\0';
    a = GetRegIP( mr );
    memset( &data, 0, sizeof( data ) );
    MCReadMem( a, sizeof( data.b ), data.b );
    if( data.b[0] != BRK_POINT )
        return( MS_FAIL );
    mr->x86.cpu.eip += 1;
    if( data.b[1] != JMP_SHORT )
        return( MS_OK );
    if( memcmp( data.b + 3, "WVIDEO", 6 ) != 0 )
        return( MS_OK );
    a = GetRegSP( mr );
    MCReadMem( a, sizeof( addr_ptr ), &data );
    if( BIG_SEG( a ) ) {
        a.mach = data.a48;
    } else {
        ConvAddr32ToAddr48( data.a32, a.mach );
    }
    len = 0;
    while( MCReadMem( a, sizeof( data.b[0] ), data.b ) != 0 ) {
        a.mach.offset++;
        if( len + 1 < buff_size )
            buff[len] = data.b[0];
        if( data.b[0] == '\0' )
            break;
        ++len;
    }
    *buff_size_p = len;
    if( buff_size > 0 ) {
        --buff_size;
        if( buff_size > len )
            buff_size = len;
        buff[buff_size] = '\0';
    }
    return( MS_OK );
}
예제 #4
0
static bool InsertOneBP( brkp *bp, bool force )
{
    bool    at_ip;

    at_ip = false;
    if( bp->status.b.active ) {
        if( !force && AddrComp( bp->loc.addr, GetRegIP() ) == 0 ) {
            at_ip = true;
        } else if( SectIsLoaded( bp->loc.addr.sect_id, OVL_MAP_EXE ) ) {
            bp->status.b.in_place = true;
            bp->item.ud = RemoteSetBreak( bp->loc.addr );
        }
    }
    return( at_ip );
}
예제 #5
0
mad_status              DIGENTRY MIUnexpectedBreak( mad_registers *mr, unsigned *maxp, char *buff )
{
    address     a;
    union {
        byte            b[9];
        addr32_ptr      a32;
        addr48_ptr      a48;
    }           data;
    unsigned    max;
    unsigned    len;

    max = *maxp;
    *maxp = 0;
    if( max > 0 )
        buff[0] = '\0';
    a = GetRegIP( mr );
    memset( &data, 0, sizeof( data ) );
    MCReadMem( a, sizeof( data.b ), &data );
    if( data.b[0] != BRK_POINT )
        return( MS_FAIL );
    mr->x86.cpu.eip += 1;
    if( data.b[1] != JMP_SHORT )
        return( MS_OK );
    if( memcmp( &data.b[3], "WVIDEO", 6 ) != 0 )
        return( MS_OK );
    a = GetRegSP( mr );
    MCReadMem( a, sizeof( addr_ptr ), &data );
    if( BIG_SEG( a ) ) {
        a.mach = data.a48;
    } else {
        ConvAddr32ToAddr48( data.a32, a.mach );
    }
    len = 0;
    for( ;; ) {
        if( MCReadMem( a, sizeof( data.b[0] ), &data.b[0] ) == 0 )
            break;
        a.mach.offset++;
        if( len < max )
            buff[len] = data.b[0];
        if( data.b[0] == '\0' )
            break;
        ++len;
    }
    if( max > 0 )
        buff[max] = '\0';
    *maxp = len;
    return( MS_OK );
}
예제 #6
0
unsigned Execute( bool tracing, bool do_flip )
{
    unsigned    conditions;
    bool        stack_cmds;
    static unsigned executing = 0;

    if( !CheckStackPos() )
        return( COND_USER );
    if( !AdvMachState( ACTION_EXECUTE ) )
        return( COND_USER );

    if( executing == 0 ) {
        ++executing;
        HookNotify( true, HOOK_EXEC_START );
        --executing;
    }

    /* get rid of useless pending input information */
    for( ;; ) {
        if( CurrToken != T_LINE_SEPARATOR )
            break;
        if( InpStack == NULL )
            break;
        if( InpStack->type & (INP_HOLD|INP_STOP_PURGE) )
            break;
        if( InpStack->rtn( InpStack->handle, INP_RTN_EOL ) )
            continue;
        PopInpStack();
    }
    _SwitchOff( SW_TRAP_CMDS_PUSHED );
    conditions = ExecProg( tracing, do_flip, true );
    SetCodeDot( GetRegIP() );
    stack_cmds = true;
    if( tracing && (conditions & COND_BREAK) )
        stack_cmds = false;
    if( ReportTrap( conditions, stack_cmds ) ) {
        _SwitchOn( SW_TRAP_CMDS_PUSHED );
    }
    if( executing == 0 ) {
        ++executing;
        HookNotify( true, HOOK_EXEC_END );
        --executing;
    }
    if( conditions & COND_TERMINATE ) {
        HookNotify( true, HOOK_PROG_END );
    }
    return( conditions );
}
예제 #7
0
void MakeThdCurr( thread_state *thd )
{
    error_handle    errh;

    if( !AdvMachState( ACTION_THREAD_CHANGE ) )
        return;
    // NYI - PUI - record the thread change?
    WriteDbgRegs();
    if( RemoteSetThreadWithErr( thd->tid, &errh ) == 0 ) {
        Error( ERR_NONE, LIT_ENG( ERR_NO_MAKE_CURR_THREAD ), thd->tid, errh );
    }
    DbgRegs->tid = thd->tid;
    ReadDbgRegs();
    SetCodeDot( GetRegIP() );
    DbgUpdate( UP_REG_CHANGE | UP_CSIP_CHANGE | UP_THREAD_STATE );
}
예제 #8
0
mad_type_handle DIGENTRY MITypeDefault( mad_type_kind tk, mad_address_format af, const mad_registers *mr, const address *ap )
{
    int         big;

    if( tk & MAS_IO ) {
        switch( tk & MTK_ALL ) {
        case MTK_BASIC:
        case MTK_INTEGER:
            return( X86T_BYTE );
        case MTK_ADDRESS:
            return( X86T_N16_PTR );
        }
        return( MAD_NIL_TYPE_HANDLE );
    }
    if( ap != NULL ) {
        big = BIG_SEG( *ap );
    } else if( mr != NULL ) {
        big = BIG_SEG( GetRegIP( mr ) );
    } else {
        big = ( ( MCSystemConfig()->cpu & X86_CPU_MASK ) >= X86_386);
    }
    switch( tk & MTK_ALL ) {
    case MTK_BASIC:
        return( X86T_BYTE );
    case MTK_INTEGER:
        return( big ? X86T_DWORD : X86T_WORD );
    case MTK_ADDRESS:
        if( big ) {
            return( (af == MAF_OFFSET) ? X86T_N32_PTR : X86T_F32_PTR );
        } else {
            return( (af == MAF_OFFSET) ? X86T_N16_PTR : X86T_F16_PTR );
        }
    case MTK_FLOAT:
        return( X86T_DOUBLE );
    }
    return( MAD_NIL_TYPE_HANDLE );
}
예제 #9
0
mad_status DIGENTRY MIDisasmInsNext( mad_disasm_data *dd, const mad_registers *mr, address *next )
{
    mad_disasm_control  dc;

    *next = GetRegIP( mr );
    next->mach.offset += dd->ins.size;
    dc = DisasmControl( dd, mr );
    if( (dc & MDC_TAKEN_MASK) == MDC_TAKEN_NOT ) {
        return( MS_OK );
    }
    switch( dc & MDC_TYPE_MASK ) {
    case MDC_SYSCALL:
        return( MS_FAIL );
    case MDC_JUMP:
    case MDC_CALL:
        switch( dd->ins.op[ OP_1 ].type & DO_MASK ) {
        case DO_ABSOLUTE:
            next->mach.segment = dd->ins.op[ OP_1 ].extra;
            /* fall through */
        case DO_RELATIVE:
            next->mach.offset = dd->ins.op[ OP_1 ].value;
            break;
        case DO_REG:
            next->mach.offset = RegValue( mr, dd->ins.op[ OP_1 ].base );
            break;
        default:
            /* memory indirect jump/call */
            DoDisasmMemRefWalk( dd, FindCallTarget, mr, &DbgAddr );

            if( dd->ins.flags.u.x86 & DIF_X86_OPND_LONG ) {
                next->mach.offset = GetDataLong();
                if( dd->ins.op[ OP_1 ].ref_type == DRT_X86_FARPTR48 ) {
                    next->mach.segment = (unsigned_16)GetDataWord();
                }
            } else {
                next->mach.offset = (unsigned_16)GetDataWord();
                if( dd->ins.op[ OP_1 ].ref_type == DRT_X86_FARPTR32 ) {
                    next->mach.segment = (unsigned_16)GetDataWord();
                }
            }
            break;
        }
        break;
    case MDC_SYSRET:
    case MDC_RET:
        DbgAddr = GetRegSP( mr );
        if( dd->ins.flags.u.x86 & DIF_X86_OPND_LONG ) {
            next->mach.offset = GetDataLong();
        } else {
            next->mach.offset = (unsigned_16)GetDataWord();
        }
        switch( dd->ins.type ) {
        case DI_X86_retf:
        case DI_X86_retf2:
            next->mach.segment = (unsigned_16)GetDataWord();
            break;
        default:
            break;
        }
        break;
    }
    return( MS_OK );
}
예제 #10
0
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 );
}
예제 #11
0
void    GetMADTypeDefault( mad_type_kind mtk, mad_type_info *mti )
{
    GetMADTypeDefaultAt( GetRegIP(), mtk, mti );
}