Example #1
0
static void     ModMenuItem( a_window *wnd, unsigned id, int row, int piece )
{
    address     addr;
    mod_handle  handle;
    mod_window  *mod = WndMod( wnd );

    piece=piece;

    handle = NO_MOD;
    addr = NilAddr;
    if( ModListNumRows( ModList( mod ) ) != 0 && row >= 0 ) {
        handle =  ModListMod( ModList( mod ), row );
        if( handle != NO_MOD ) {
            addr = ModFirstAddr( handle );
        }
    }
    switch( id ) {
    case MENU_INITIALIZE:
        WndMenuGrayAll( wnd );
        if( handle != NO_MOD ) {
            WndMenuEnable( wnd, MENU_MODULES_BREAK_SET_ALL, TRUE );
            WndMenuEnable( wnd, MENU_MODULES_BREAK_CLEAR_ALL, TRUE );
            WndMenuEnable( wnd, MENU_MODULES_ASSEMBLY, !IS_NIL_ADDR( addr ) );
            WndMenuEnable( wnd, MENU_MODULES_FUNCTIONS, TRUE );
            if( ModHasSourceInfo( handle ) ) {
                WndMenuEnable( wnd, MENU_MODULES_SOURCE, TRUE );
            }
        }
        WndMenuEnable( wnd, MENU_MODULES_SHOW_ALL, TRUE );
        WndMenuCheck( wnd, MENU_MODULES_SHOW_ALL, mod->all_modules );
        break;
    case MENU_MODULES_BREAK_SET_ALL:
        BreakAllModEntries( handle );
        break;
    case MENU_MODULES_BREAK_CLEAR_ALL:
        ClearAllModBreaks( handle );
        break;
    case MENU_MODULES_SOURCE:
        if( IS_NIL_ADDR( addr ) ) {
            ModName( handle, TxtBuff, TXT_LEN );
            WndFileInspect( TxtBuff, FALSE );
        } else {
            WndSrcInspect( addr );
        }
        break;
    case MENU_MODULES_ASSEMBLY:
        WndAsmInspect( addr );
        break;
    case MENU_MODULES_FUNCTIONS:
        WndFuncInspect( handle );
        break;
    case MENU_MODULES_SHOW_ALL:
        mod->all_modules = !mod->all_modules;
        ModInit( wnd );
        break;
    }
}
Example #2
0
extern void     GlobMenuItem( a_window *wnd, unsigned id, int row, int piece )
{
    glob_window *glob = WndGlob( wnd );
    address     addr;
    char        buff[TXT_LEN];

    piece=piece;
    addr = NameListAddr( NameList( glob ), row );
    switch( id ) {
    case MENU_INITIALIZE:
        if( IS_NIL_ADDR( addr ) ) {
            WndMenuGrayAll( wnd );
        } else {
            WndMenuEnableAll( wnd );
        }
        WndMenuEnable( wnd, MENU_GLOB_D2_ONLY, TRUE );
        WndMenuCheck( wnd, MENU_GLOB_D2_ONLY, glob->d2_only );
        break;
    case MENU_GLOB_INSPECT_MEMORY:
        WndAddrInspect( addr );
        break;
    case MENU_GLOB_WATCH:
        NameListName( NameList( glob ), row, buff, SN_QUALIFIED );
        WndVarInspect( buff );
        break;
    case MENU_GLOB_D2_ONLY:
        glob->d2_only = !glob->d2_only;
        GlobInit( wnd );
        break;
    default:
        break;
    }
}
Example #3
0
void SkipToAddr( address addr )
{
    if( IS_NIL_ADDR( addr ) ) return;
    if( !AdvMachState( ACTION_MODIFY_IP ) ) return;
    RecordSetRegIP( addr );
    DbgUpdate( UP_CSIP_CHANGE | UP_REG_CHANGE );
}
Example #4
0
static void RepMenuItem( a_window *wnd, gui_ctl_id id, int row, int piece )
{
    event_record        *ev;

    ev = RepGetEvent( row );
    wnd=wnd;piece=piece;
    switch( id ) {
    case MENU_INITIALIZE:
        WndMenuGrayAll( wnd );
        if( ev != NULL ) {
            WndMenuEnable( wnd, MENU_REPLAY_GOTO, true );
            if( !IS_NIL_ADDR( ev->ip ) ) {
                WndMenuEnable( wnd, MENU_REPLAY_SOURCE, true );
                WndMenuEnable( wnd, MENU_REPLAY_ASSEMBLY, true );
            }
        }
        break;
    case MENU_REPLAY_SOURCE:
        WndSrcInspect( ev->ip );
        break;
    case MENU_REPLAY_ASSEMBLY:
        WndAsmInspect( ev->ip );
        break;
    case MENU_REPLAY_GOTO:
        ReplayTo( ev );
        break;
    }
}
Example #5
0
void GoToAddr( address addr )
{
    if( IS_NIL_ADDR( addr ) ) return;
    SetTempBreak( addr );
    Go( TRUE );
    NullStatus( &UserTmpBrk );
}
Example #6
0
static void     FuncMenuItem( a_window *wnd, gui_ctl_id id, int row, int piece )
{
    address     addr;
    func_window *func = WndFunc( wnd );

    piece=piece;
    addr = ( row == WND_NO_ROW ) ? NilAddr : NameListAddr( NameList( func ), row );
    switch( id ) {
    case MENU_INITIALIZE:
        if( IS_NIL_ADDR( addr ) ) {
            WndMenuGrayAll( wnd );
        } else {
            WndMenuEnableAll( wnd );
            WndMenuEnable( wnd, MENU_FUNCTIONS_SOURCE, HasLineInfo( addr ) );
        }
        WndMenuEnable( wnd, MENU_FUNCTIONS_D2_ONLY, TRUE );
        WndMenuCheck( wnd, MENU_FUNCTIONS_D2_ONLY, func->d2_only );
        break;
    case MENU_FUNCTIONS_SOURCE:
        WndSrcInspect( addr );
        break;
    case MENU_FUNCTIONS_ASSEMBLY:
        WndAsmInspect( addr );
        break;
    case MENU_FUNCTIONS_BREAK:
        DlgBreak( addr );
        break;
    case MENU_FUNCTIONS_D2_ONLY:
        func->d2_only = !func->d2_only;
        FuncNewOptions( wnd );
        break;
    }
}
Example #7
0
extern  bool    SrcMoveDot( a_window *wnd, address addr )
{
    unsigned    line;
    mod_handle  mod;
    file_window *file;
    DIPHDL( cue, ch );

    if( wnd == NULL ) return( FALSE );
    file = WndFile( wnd );
    if( file->mod == NO_MOD && !file->track ) return( FALSE );
    if( IS_NIL_ADDR( addr ) ) {
        WndScrollAbs( wnd, 0 );
        return( FALSE );
    }
    DeAliasAddrMod( addr, &mod );
    if( DeAliasAddrCue( mod, addr, ch ) == SR_NONE ) {
        if( LineCue( mod, 0, 0, 0, ch ) == SR_NONE ) return( FALSE );
    }
    line = CueLine( ch );
    if( mod != file->mod || CueFileId( ch ) != file->file_id ) {
        if( !file->track ) return( FALSE );
        FileTrack( wnd, ch );
    }
    --line;
    WndScrollAbs( wnd, line ); //
    WndMoveCurrent( wnd, line, PIECE_SOURCE );
    FileSetDotAddr( wnd, addr );
    FileSetTitle( wnd, CueMod( ch ) );
    return( TRUE );
}
Example #8
0
static  a_window        *DoWndSrcInspect( address addr, bool existing )
{
    a_window    *wnd;
//    bool        nil;
    mod_handle  mod;
    DIPHDL( cue, ch );
    a_window    *active;

    active = WndFindActive();
//    nil = false;
    if( IS_NIL_ADDR( addr ) ) {
//        nil = true;
        addr = Context.execution;
    }
    wnd = NULL;
    if( existing ) {
        wnd = WndFindExisting( WND_SOURCE );
    }
    if( wnd == NULL ) {
        if( DeAliasAddrMod( addr, &mod ) == SR_NONE
         || DeAliasAddrCue( mod, addr, ch ) == SR_NONE ) {
            ch = NULL;
        }
        wnd = DoWndSrcOpen( ch, existing );
    }
    if( !SrcMoveDot( wnd, addr ) || !SrcHasFileOpen( wnd ) ) {
        if( active != NULL ) WndRestoreToFront( active );
        return( NULL );
    }
    return( wnd );
}
Example #9
0
static void RecordBreakEvent( brkp *bp, brk_event event )
{
    GetBPCmd( bp, event, TxtBuff, TXT_LEN );
    RecordEvent( TxtBuff );
    if( event == B_SET && !IS_NIL_ADDR( bp->loc.addr ) ) {
        GetBPAddrText( bp, TxtBuff );
        DUIStatusText( TxtBuff );
    }
}
Example #10
0
static void FileNotify( a_window *wnd, wnd_row row, int piece )
{
    file_window *file = WndFile( wnd );
    address     addr;

    piece = piece;
    addr = GetRowAddr( file, row, FALSE );
    if( IS_NIL_ADDR( addr ) ) return;
    FileSetDotAddr( wnd, addr );
}
Example #11
0
static void AsmSetFirst( a_window *wnd, address addr, bool use_first_source )
{
    int                 row,rows;
    asm_window          *asw = WndAsm( wnd );
    char                chr;
    mad_disasm_data     *dd;
    unsigned            addr_len;
    DIPHDL( cue, ch );

    _AllocA( dd, asw->ddsize );


    if( IS_NIL_ADDR( addr ) || ProgPeek( addr, &chr, 1 ) != 1 ) {
        addr = NilAddr;
    }
    asw->ins[ 0 ].addr = addr;
    asw->ins[ 0 ].line = 0;
    addr_len = AddrToString( &addr, MAF_OFFSET, TxtBuff, TXT_LEN ) - TxtBuff;
    if( addr_len != asw->addr_len ) {
        asw->addr_len = addr_len;
        AsmResize( wnd ); // recusively calls this routine!
        WndZapped( wnd );
        return;
    }
    rows = WndRows( wnd );
    for( row = 0; row < rows; ++row ) {
        asw->ins[ row ].addr = addr;
        if( IS_NIL_ADDR( addr ) ) continue;
        if( ExactCueAt( asw, addr, ch ) ) {
            if( row != 0 || use_first_source ) {
                asw->ins[ row ].addr = addr;
                asw->ins[ row ].line = CueLine( ch );
                ++row;
                if( row >= rows ) break;
            }
        }
        asw->ins[ row ].addr = addr;
        asw->ins[ row ].line = 0;
        if( MADDisasm( dd, &addr, 0 ) != MS_OK ) {
            addr = NilAddr;
        }
    }
}
Example #12
0
void GoToReturn( void )
{
    address     ra;

    ra = ReturnAddress();
    if( !IS_NIL_ADDR( ra ) ) {
        GoToAddr( ra );
    } else {
        Error( ERR_NONE, LIT( ERR_NO_RETURN_ADDRESS ) );
    }
}
Example #13
0
brkp *FindBreak( address addr )
{
    brkp    *bp;

    if( IS_NIL_ADDR( addr ) ) return( NULL );
    for( bp = BrkList; bp != NULL; bp = bp->next ) {
        if( ( AddrComp( bp->loc.addr, addr ) == 0 ) ) {
            return( bp );
        }
    }
    return( NULL );
}
Example #14
0
static void BreakOnAddress( void *_s )
/***********************************************/
{
    tmp_break_struct *s = _s;

    if( IS_NIL_ADDR( s->addr )
     || !BreakWrite( s->addr,
                    FindMADTypeHandle( MAS_MEMORY|MTK_INTEGER, s->size ),
                     s->comment ) ) {
        Error( ERR_NONE, LIT_ENG( ERR_NOT_WATCH_SIZE ) );
    }
}
Example #15
0
static void FileSetDotAddr( a_window *wnd, address addr )
{
    file_window *file = WndFile( wnd );

    if( AddrComp( file->dotaddr, addr ) == 0 ) return;
    file->dotaddr = addr;
    if( IS_NIL_ADDR( addr ) ) return;
    if( wnd == WndFindActive() ) {
        AsmMoveDot( file->asw, addr );
        SetCodeDot( addr );
    }
}
Example #16
0
extern void ToggleBreak( address addr )
{
    brkp        *bp;

    if( IS_NIL_ADDR( addr ) ) return;
    bp = FindBreak( addr );
    if( bp == NULL ) {
        AddBreak( addr );
    } else if( bp->status.b.active ) {
        ActPoint( bp, FALSE );
    } else {
        RemovePoint( bp );
    }
}
Example #17
0
OVL_EXTERN brkp *TogglePoint( memory_expr def_seg )
{
    brkp        *bp;
    address     addr;

    bp = PointBreak( def_seg, &addr );
    if( IS_NIL_ADDR( addr ) ) {
        Error( ERR_NONE, LIT_ENG( ERR_NO_SUCH_POINT ) );
        return( NULL );
    } else {
        ToggleBreak( addr );
        return( bp );
    }
}
Example #18
0
static  void    FileModify( a_window *wnd, int row, int piece )
{
    file_window *file = WndFile( wnd );
    address     addr;

    if( piece == PIECE_BREAK ) {
        addr = GetRowAddr( file, row, TRUE );
        if( IS_NIL_ADDR( addr ) ) return;
        file->toggled_break = ( ( WndFlags & UP_BREAK_CHANGE ) == 0 );
        ToggleBreak( addr );
        WndRowDirty( wnd, row );
    } else {
        WndFirstMenuItem( wnd, row, piece );
    }
}
Example #19
0
inspect_type WndGetExprSPInspectType( address *paddr )
{
    sym_info    info;
    DIPHDL( sym, sh );

    LValue( ExprSP );
    *paddr = NilAddr;
    if( ExprSP->info.kind == TK_FUNCTION ) {
        ExprValue( ExprSP );
        *paddr = ExprSP->v.addr;
        PopEntry();
        return( INSP_CODE );
    } else if( (ExprSP->flags & SF_LOCATION) && ExprSP->th != NULL && !IsInternalMod( TypeMod( ExprSP->th ) ) ) {
        if( ExprSP->v.loc.num == 1 && ExprSP->v.loc.e[0].type == LT_ADDR ) {
            *paddr = ExprSP->v.loc.e[0].u.addr;
        }
        PopEntry();
        return( INSP_DATA );
    } else {
        if( (ExprSP->flags & SF_LOCATION) && ExprSP->v.loc.e[0].type == LT_ADDR ) {
            *paddr = ExprSP->v.loc.e[0].u.addr;
        } else if( ExprSP->info.kind == TK_ADDRESS
                || ExprSP->info.kind == TK_POINTER ) {
            *paddr = ExprSP->v.addr;
        }
        if( !IS_NIL_ADDR( (*paddr) ) ) {
            AddrFloat( paddr );
            if( DeAliasAddrSym( NO_MOD, *paddr, sh ) != SR_NONE ) {
                SymInfo( sh, ExprSP->lc, &info );
                PopEntry();
                switch( info.kind ) {
                case SK_CODE:
                case SK_PROCEDURE:
                    return( INSP_CODE );
                    break;
                default:
                    return( INSP_RAW_DATA );
                    break;
                }
            }
        }
    }
    ExprValue( ExprSP );
    MakeMemoryAddr( TRUE, EXPR_DATA, paddr );
    return( INSP_RAW_DATA );
}
Example #20
0
extern  a_window        *WndAsmInspect( address addr )
{
    a_window    *wnd;
    bool        nil;

    nil = false;
    if( IS_NIL_ADDR( addr ) ) {
        nil = true;
        addr = Context.execution;
    }
    wnd = WndFindExisting( WND_ASSEMBLY );
    if( nil && wnd != NULL ) return( wnd );
    if( wnd == NULL ) {
        wnd = DoWndAsmOpen( addr, true );
    }
    AsmMoveDot( wnd, addr );
    return( wnd );
}
Example #21
0
void GetBPText( brkp *bp, char *buff )
{
    unsigned    max;

    //MAD: might be a different mad then when break set
    max = ~0;
    if( IS_BP_EXECUTE( bp->th ) ) {
        if( bp->source_line != NULL ) {
            strcpy( buff, bp->source_line );
        } else {
            if( IS_NIL_ADDR( bp->loc.addr ) ) {
                strcpy( buff, LIT_ENG( Quest_Marks ) );
            } else {
                UnAsm( bp->loc.addr, buff, max );
            }
        }
    } else {
        MADTypeHandleToString( CurrRadix, bp->th, &bp->item, buff, &max );
    }
}
Example #22
0
static void AsmSetDotAddr( a_window *wnd, address addr )
{
    mod_handle  mod;
    asm_window  *asw = WndAsm( wnd );

    if( AddrComp( asw->dotaddr, addr ) != 0 ) {
        WndRowDirty( wnd, -TITLE_SIZE );
        asw->dotaddr = addr;
        DeAliasAddrMod( addr, &mod );
        if( mod != asw->mod ) {
            DbgUpdate( UP_OPEN_CHANGE );
            asw->mod = mod;
            AsmSetTitle( wnd );
        }
        if( IS_NIL_ADDR( addr ) ) return;
        if( wnd == WndFindActive() ) {
            SrcMoveDot( asw->src, addr );
            SetCodeDot( addr );
        }
    }
}
Example #23
0
static  bool    FileGetLine( a_window *wnd, int row, int piece,
                             wnd_line_piece *line )
{
    int         len;
    file_window *file = WndFile( wnd );
    address     addr;
    brkp        *bp;
    bool        curr;
    DIPHDL( cue, ch );

    line->text = LIT_ENG( Empty );
    if( file->viewhndl == NULL && ModHasInfo( file->mod, HK_CUE ) != DS_OK ) {
        return( false );
    }
    curr = ( row == file->active && ContextMod == file->mod );
    switch( piece ) {
    case PIECE_BREAK:
        line->tabstop = false;
        if( row >= file->eof )
            return( false );
        if( file->mod == NO_MOD )
            return( true );
        addr = NilAddr;
        if( !WndDoingSearch ) { // too expensive
            addr = GetRowAddr( file, row, true );
        }
        if( !IS_NIL_ADDR( addr ) ) {
            bp = FindBreakByLine( file->mod, file->file_id, row+1 );
            FileBreakGadget( wnd, line, curr, bp );
        }
        return( true );
    case PIECE_SOURCE:
        line->text = TxtBuff;
        line->extent = WND_MAX_EXTEND;
        if( curr )
            line->attr = WND_STANDOUT;
        if( file->mod != NO_MOD ) {
            line->indent = MaxGadgetLength;
        }
        if( file->viewhndl == NULL ) {
            Format( TxtBuff, LIT_DUI( No_Source_Line ), row+1 );
            if( LineCue( file->mod, file->file_id, 0, 0, ch ) != SR_NONE ) {
                if( (CueAdjust( ch, -1, ch ) & DS_ERR) ) {
                    file->eof = CueLine( ch );
                }
            }
            return( true );
        }
        len = FReadLine( file->viewhndl, row+1, 0, TxtBuff, MAX_LINE_LEN );
        if( len < 0 ) {
            file->eof = row;
            return( false );
        }
        if( len == MAX_LINE_LEN ) {
            StrCopy( " ...", TxtBuff + MAX_LINE_LEN );
        } else {
            TxtBuff[len] = NULLCHAR;
        }
        if( row >= file->rows ) {
            file->rows = row + 1;
            file->rows_offset = FLastOffset( file->viewhndl );
        }
        return( true );
    default:
        return( false );
    }
}
Example #24
0
static void     FileMenuItem( a_window *wnd, gui_ctl_id id, int row, int piece )
{
    address     addr;
    mod_handle  mod;
    bool        has_addr;
    bool        has_popitem;
    file_window *file = WndFile( wnd );

    piece=piece;
    addr = GetRowAddr( file, row, id != MENU_FILE_ASSEMBLY );
    has_addr = !IS_NIL_ADDR( addr );
    switch( id ) {
    case MENU_INITIALIZE:
        has_popitem = ( *WndPopItem( wnd ) != NULLCHAR );
        if( has_popitem && !ScanSelectedExpr( WndPopItem( wnd ) ) ) {
            has_popitem = false;
        }
        WndMenuEnable( wnd, MENU_FILE_SHOW, true );
        WndMenuEnable( wnd, MENU_FILE_SHOW_ADDRESS, true );
        WndMenuEnable( wnd, MENU_FILE_SHOW_MODULE, true );
        WndMenuEnable( wnd, MENU_FILE_FUNCTIONS, file->mod != NO_MOD );
        WndMenuEnable( wnd, MENU_FILE_HOME, true );
        addr = GetRowAddr( file, row, false );
        WndMenuEnable( wnd, MENU_FILE_ASSEMBLY, !IS_NIL_ADDR( addr ) );
        WndMenuEnable( wnd, MENU_FILE_WATCH, has_popitem );
        WndMenuEnable( wnd, MENU_FILE_INSPECT, has_popitem );
        WndMenuEnable( wnd, MENU_FILE_STEP_INTO, file->mod != NO_MOD && has_popitem );
        WndMenuEnable( wnd, MENU_FILE_BREAK, has_popitem );
        WndMenuEnable( wnd, MENU_FILE_RUN, has_addr );
        WndMenuEnable( wnd, MENU_FILE_SKIP_TO_CURSOR, has_addr );
        break;
    case MENU_FILE_RUN:
        GoToAddr( addr );
        break;
    case MENU_FILE_SKIP_TO_CURSOR:
        SkipToAddr( addr );
        break;
    case MENU_FILE_BREAK:
        BreakOnSelected( WndPopItem( wnd ) );
        break;
    case MENU_FILE_HOME:
        GoHome();
        break;
    case MENU_FILE_SHOW_MODULE:
        mod = file->mod;
        if( DlgModName( LIT_DUI( New_Module ), &mod ) ) {
            WndModInspect( mod );
        }
        break;
    case MENU_FILE_SHOW_ADDRESS:
        if( DlgCodeAddr( LIT_DUI( New_Addr ), &addr ) ) {
            WndSrcInspect( addr );
        }
        break;
    case MENU_FILE_STEP_INTO:
        StepIntoFunction( WndPopItem( wnd ) );
        break;
    case MENU_FILE_INSPECT:
        WndInspect( WndPopItem( wnd ) );
        break;
    case MENU_FILE_WATCH:
        WndVarInspect( WndPopItem( wnd ) );
        break;
    case MENU_FILE_SEARCH:
        WndSaveToHistory( SrchHistory, WndPopItem( wnd ) );
        DbgWndSearch( wnd, false, DlgSearch( wnd, SrchHistory ) );
        break;
    case MENU_FILE_ASSEMBLY:
        AsmWndFind( file->asw, addr, file->track );
        break;
    case MENU_FILE_LINE:
        GotoLine( wnd );
        break;
    case MENU_FILE_FUNCTIONS:
        WndFuncInspect( file->mod );
        break;
    }
}