static bool FuncGetLine( a_window *wnd, int row, int piece, wnd_line_piece *line ) { address addr; func_window *func = WndFunc( wnd ); if( row >= NameListNumRows( NameList( func ) ) ) return( FALSE ); addr = NameListAddr( NameList( func ), row ); switch( piece ) { case PIECE_BREAK: FileBreakGadget( wnd, line, FALSE, FindBreak( addr ) ); return( TRUE ); case PIECE_NAME: line->indent = MaxGadgetLength; line->text = TxtBuff; line->extent = WND_MAX_EXTEND; FuncGetSourceName( wnd, row ); return( TRUE ); case PIECE_DEMANGLED: if( NameListName( NameList( func ), row, TxtBuff, SN_DEMANGLED ) == 0 ) { return( FALSE ); } line->text = TxtBuff; line->use_prev_attr = TRUE; line->indent = MaxGadgetLength + func->max_name + 2 * WndAvgCharX( wnd ); return( TRUE ); default: return( FALSE ); } }
void BreakAllModEntries( mod_handle handle ) { name_list list; address addr; int i; bool have_mod_cue; sym_info sinfo; DIPHDL( cue, ch ); DIPHDL( cue, ch_mod ); NameListInit( &list, WF_CODE ); NameListAddModules( &list, handle, false, true ); have_mod_cue = FindFirstCue( handle, ch_mod ); for( i = 0; i < NameListNumRows( &list ); ++i ) { addr = NameListAddr( &list, i ); SymInfo( NameListHandle( &list, i ), NULL, &sinfo ); if( !sinfo.is_global && !sinfo.is_public ) continue; if( have_mod_cue && DeAliasAddrCue( handle, addr, ch ) != SR_NONE ) { if( CueFileId( ch ) != CueFileId( ch_mod ) ) { continue; } } if( FindBreak( addr ) != NULL ) { continue; } AddBreak( addr ); } NameListFree( &list ); }
bool BreakWrite( address addr, mad_type_handle th, const char *comment ) { brkp *bp; mad_type_info mti; bool ok_to_try = true; if( IS_BP_EXECUTE( th ) ) return( false ); MADTypeInfo( th, &mti ); switch( mti.b.bits / BITS_PER_BYTE ) { case 8: if( !Is8ByteBreakpointsSupported() ) { ok_to_try = false; } // fall down case 1: case 2: case 4: if( ok_to_try ) { if( FindBreak( addr ) != NULL ) { Error( ERR_NONE, LIT_ENG( ERR_POINT_EXISTS ) ); } bp = AddPoint( addr, th, false ); if( bp == NULL ) return( true ); bp->source_line = DupStr( comment ); RecordBreakEvent( bp, B_SET ); return( true ); } // fall down default: return( false ); } }
bool BreakWrite( address addr, mad_type_handle th, char *comment ) { brkp *bp; mad_type_info mti; bool ok_to_try = TRUE; if( th == MAD_NIL_TYPE_HANDLE ) return( FALSE ); MADTypeInfo( th, &mti ); switch( mti.b.bits / BITS_PER_BYTE ) { case 8: if( !Supports8ByteBreakpoints ) ok_to_try = FALSE; case 1: case 2: case 4: if( ok_to_try ) { if( FindBreak( addr ) != NULL ) { Error( ERR_NONE, LIT( ERR_POINT_EXISTS ) ); } bp = AddPoint( addr, th, FALSE ); if( bp == NULL ) return( TRUE ); bp->source_line = DupStr( comment ); RecordBreakEvent( bp, B_SET ); return( TRUE ); } default: return( FALSE ); } }
/******************************** * Interactive command line * debugger ********************************/ void Runtime::Debugger::ProcessInstruction(StackInstr* instr, long ip, StackFrame** call_stack, long call_stack_pos, StackFrame* frame) { if(frame->method->GetClass()) { const int line_num = instr->GetLineNumber(); const wstring &file_name = frame->method->GetClass()->GetFileName(); // wcout << L"### file=" << file_name << L", line=" << line_num << L" ###" << endl; if((line_num > -1 && (cur_line_num != line_num || cur_file_name != file_name)) && // break point (FindBreak(line_num, file_name) || // step command (is_next || (is_jmp_out && call_stack_pos < cur_call_stack_pos)) || // next line (is_next_line && ((cur_frame && frame->method == cur_frame->method) || (call_stack_pos < cur_call_stack_pos))))) { // set current line cur_line_num = line_num; cur_file_name = file_name; cur_frame = frame; cur_call_stack = call_stack; cur_call_stack_pos = call_stack_pos; is_jmp_out = is_next_line = false; // prompt for input const wstring &long_name = cur_frame->method->GetName(); int end_index = long_name.find_last_of(':'); const wstring &cls_mthd_name = long_name.substr(0, end_index); // show break info int mid_index = cls_mthd_name.find_last_of(':'); const wstring &cls_name = cls_mthd_name.substr(0, mid_index); const wstring &mthd_name = cls_mthd_name.substr(mid_index + 1); wcout << L"break: file='" << file_name << L":" << line_num << L"', method='" << cls_name << L"->" << mthd_name << L"(..)'" << endl; // prompt for break command Command* command; wcout << L"> "; do { wstring line; getline(wcin, line); if(line.size() > 0) { command = ProcessCommand(line); wcout << L"> "; } else { command = NULL; } } while(!command || (command->GetCommandType() != CONT_COMMAND && command->GetCommandType() != NEXT_COMMAND && command->GetCommandType() != NEXT_LINE_COMMAND && command->GetCommandType() != JUMP_OUT_COMMAND)); } } }
bool RemoveBreak( address addr ) { brkp *bp; bp = FindBreak( addr ); if( bp == NULL ) return( FALSE ); RemovePoint( bp ); return( TRUE ); }
bool RemoveBreak( address addr ) { brkp *bp; bp = FindBreak( addr ); if( bp == NULL ) return( false ); RemovePoint( bp ); return( true ); }
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 ); } }