extern void ProcCapture( void ) { cmd_list *cmds; const char *start; size_t len; const char *old; char *p; char *end; if( !ScanItem( false, &start, &len ) ) Error( ERR_NONE, LIT_ENG( ERR_WANT_COMMAND_LIST ) ); ReqEOC(); cmds = AllocCmdList( start, len ); end = FileName + sizeof( FileName ); p = FileName + PREFIX_LEN; p = CnvULongHex( TaskId, p, end - p ); *p++ = RemFile.ext_separator; p = CnvULongDec( FileNum++, p, end - p ); *p = NULLCHAR; old = ReScan( FileName+PREFIX_LEN ); StdOutNew(); ReScan( old ); cmds->use++; CaptureOk = true; PushInpStack( cmds, DoneCapture, false ); TypeInpStack( INP_CAPTURED ); FreeCmdList( cmds ); }
static void PushInitCmdList( void ) { cmd_list *cmds; if( InitCmdList != NULL ) { cmds = AllocCmdList( InitCmdList, strlen( InitCmdList ) ); _Free( InitCmdList ); InitCmdList = NULL; PushCmdList( cmds ); FreeCmdList( cmds ); } }
bool DispBPMsg( bool stack_cmds ) { brkp *bp; brkp *next; char *p; bool ret; cmd_list *cmds; ret = false; for( bp = BrkList; bp != NULL; bp = bp->next ) { if( !bp->status.b.hit ) continue; if( !bp->status.b.silent ) { p = GetBPAddrText( bp, TxtBuff ); if( !IS_BP_EXECUTE( bp->th ) ) { p = StrCopy( " - ", p ); p = StrVal( LIT_ENG( OldVal ), bp, p ); GetWPVal( bp ); p = StrVal( LIT_ENG( NewVal ), bp, p ); *p = NULLCHAR; } DUIInfoBox( TxtBuff ); } if( stack_cmds && bp->status.b.resume ) { cmds = AllocCmdList( "go/keep", sizeof( "go/keep" ) ); PushCmdList( cmds ); TypeInpStack( INP_HOOK ); FreeCmdList( cmds ); ret = true; } if( stack_cmds && ( bp->cmds != NULL ) && bp->status.b.use_cmds ) { bp->status.b.cmds_pushed = true; PushCmdList( bp->cmds ); TypeInpStack( INP_BREAK_POINT ); ret = true; } } for( bp = BrkList; bp != NULL; bp = next ) { next = bp->next; if( bp->status.b.autodestruct ) { DUIRemoveBreak( bp ); } } if( UserTmpBrk.status.b.hit ) { p = Format( TxtBuff, LIT_ENG( Break_on_execute ) ); Format( p, BrkFmt(), UserTmpBrk.loc.addr ); DUIDlgTxt( TxtBuff ); } return( ret ); }
void SetBPPatch( brkp *bp, char *patch ) { char *end; end = StrCopy( patch, StrCopy( " ", StrCopy( GetCmdName( CMD_DO ), TxtBuff ) ) ); if( bp->cmds != NULL ) { FreeCmdList( bp->cmds ); } if( patch == NULL || patch[0] == '\0' ) { bp->cmds = NULL; } else { bp->cmds = AllocCmdList( TxtBuff, end - TxtBuff ); } bp->status.b.use_cmds = ( bp->cmds != NULL ); }
void ProcIf( void ) { const char *start; size_t len; const char *true_start; size_t true_len; unsigned_64 res; cmd_list *cmd; bool have_true; true_len = 0; have_true = false; for( ;; ) { if( have_true ) { ChkExpr(); U64Clear( res ); } else { res = ReqU64Expr(); } if( !ScanQuote( &start, &len ) ) { Error( ERR_LOC, LIT_ENG( ERR_WANT_COMMAND_LIST ) ); } if( U64Test( &res ) != 0 ) { true_start = start; true_len = len; have_true = true; } if( ScanCmd( ElseifTab ) < 0 ) { break; } } ScanCmd( ElseTab ); /* optional else */ if( ScanQuote( &start, &len ) && !have_true ) { true_start = start; true_len = len; } ReqEOC(); if( true_len != 0 ) { cmd = AllocCmdList( true_start, true_len ); PushCmdList( cmd ); CopyInpFlags(); FreeCmdList( cmd ); } }
void ProcWhile( void ) { char *start; unsigned len; unsigned_64 res; cmd_list *cmd; res = ReqU64Expr(); if( !ScanQuote( &start, &len ) || len == 0 ) { Error( ERR_LOC, LIT( ERR_WANT_COMMAND_LIST ) ); } ReqEOC(); if( U64Test( &res ) != 0 ) { cmd = AllocCmdList( start, len ); ReScan( CmdStart ); PushCmdList( cmd ); CopyInpFlags(); FreeCmdList( cmd ); } }
bool SetMsgText( char *message, unsigned *conditions ) /****************************************************/ { char *equal,*comma1,*comma2; address addr,buff_addr; long buff_len; size_t sym_len; long num_returns; cmd_list *cmds; #define IS_DEBUGGER_COMMAND(m,x) (memcmp( m, DEBUGGER_COMMAND( x ), sizeof( DEBUGGER_COMMAND( x ) ) - 1 ) == 0) #define DEBUGGER_COMMAND_SKIP(m,x) m += sizeof( DEBUGGER_COMMAND( x ) ) - 1 if( IS_DEBUGGER_COMMAND( message, THREADID ) ) { DEBUGGER_COMMAND_SKIP( message, THREADID ); equal = strchr( message, '=' ); if( equal == NULL ) return( true ); *equal = NULLCHAR; CheckForNewThreads( false ); NameThread( strtoul( message, NULL, 16 ), equal + 1 ); return( false ); } else if( IS_DEBUGGER_COMMAND( message, SETTRUE ) ) { DEBUGGER_COMMAND_SKIP( message, SETTRUE ); if( DlgScanDataAddr( message, &addr ) ) { ProgPoke( addr, "\x1", 1 ); } return( false ); } else if( IS_DEBUGGER_COMMAND( message, EXECUTE ) ) { DEBUGGER_COMMAND_SKIP( message, EXECUTE ); if( InCall == 0 ) { cmds = AllocCmdList( "go/keep", sizeof( "go/keep" ) - 1 ); PushCmdList( cmds ); TypeInpStack( INP_HOOK ); FreeCmdList( cmds ); } cmds = AllocCmdList( message, strlen( message ) ); PushCmdList( cmds ); TypeInpStack( INP_HOOK ); FreeCmdList( cmds ); *conditions |= COND_STOP; return( false ); } else if( IS_DEBUGGER_COMMAND( message, MESSAGE ) ) { DEBUGGER_COMMAND_SKIP( message, MESSAGE ); AddMessageText( message ); return( false ); } else if( IS_DEBUGGER_COMMAND( message, LOOKUP ) ) { DEBUGGER_COMMAND_SKIP( message, LOOKUP ); comma1 = strchr( message, ',' ); if( comma1 == NULL ) return( true ); *comma1++ = NULLCHAR; comma2 = strchr( comma1, ',' ); if( comma2 == NULL ) return( true ); *comma2++ = NULLCHAR; if( !DlgScanDataAddr( message, &addr ) ) return( true ); if( !DlgScanDataAddr( comma1, &buff_addr ) ) return( true ); if( !DlgScanLong( comma2, &buff_len ) ) return( true ); CnvNearestAddr( addr, TxtBuff, TXT_LEN ); sym_len = strlen( TxtBuff ) + 1; if( sym_len > buff_len ) { sym_len = (size_t)buff_len; TxtBuff[sym_len - 1] = NULLCHAR; } ProgPoke( buff_addr, TxtBuff, sym_len ); return( false ); } else if( IS_DEBUGGER_COMMAND( message, LOADMODULE ) ) { DEBUGGER_COMMAND_SKIP( message, LOADMODULE ); comma1 = strchr( message, ',' ); if( comma1 == NULL ) return( true ); *comma1++ = NULLCHAR; if( !DlgScanDataAddr( message, &addr ) ) return( true ); SymUserModLoad( comma1, &addr ); return( false ); } else if( IS_DEBUGGER_COMMAND( message, UNLOADMODULE ) ) { DEBUGGER_COMMAND_SKIP( message, UNLOADMODULE ); SymUserModUnload( message ); return( false ); } else if( IS_DEBUGGER_COMMAND( message, BREAKRETURN ) ) { DEBUGGER_COMMAND_SKIP( message, BREAKRETURN ); if( !DlgScanLong( message, &num_returns ) ) return( true ); // TODO: do something with num_returns value return( false ); } else { AddMessageText( message ); return( true ); } #undef IS_DEBUGGER_COMMAND #undef DEBUGGER_COMMAND_SKIP }
bool SetMsgText( char *message, unsigned *conditions ) /****************************************************/ { char *equal,*comma1,*comma2; address addr,buff_addr; long buff_len,sym_len; long num_returns; cmd_list *cmds; if( memcmp( message, DEBUGGER_THREADID_COMMAND, sizeof( DEBUGGER_THREADID_COMMAND ) - 1 ) == 0 ) { message += sizeof( DEBUGGER_THREADID_COMMAND ) - 1; equal = strchr( message, '=' ); if( equal == NULL ) return( TRUE ); *equal = '\0'; CheckForNewThreads( FALSE ); NoCRLF( equal + 1 ); NameThread( strtoul( message, NULL, 16 ), equal + 1 ); return( FALSE ); } else if( memcmp( message, DEBUGGER_SETTRUE_COMMAND, sizeof( DEBUGGER_SETTRUE_COMMAND ) - 1 ) == 0 ) { unsigned old = NewCurrRadix( 16 ); NoCRLF( message ); if( DlgScanDataAddr( message + sizeof( DEBUGGER_SETTRUE_COMMAND ) - 1, &addr ) ) { ProgPoke( addr, "\x1", 1 ); } NewCurrRadix( old ); return( FALSE ); } else if( memcmp( message, DEBUGGER_EXECUTE_COMMAND, sizeof( DEBUGGER_EXECUTE_COMMAND ) - 1 ) == 0 ) { message += sizeof( DEBUGGER_EXECUTE_COMMAND ) - 1; NoCRLF( message ); if( InCall == 0 ) { cmds = AllocCmdList( "go/keep", strlen( "go/keep" ) ); PushCmdList( cmds ); TypeInpStack( INP_HOOK ); FreeCmdList( cmds ); } cmds = AllocCmdList( message, strlen( message ) ); PushCmdList( cmds ); TypeInpStack( INP_HOOK ); FreeCmdList( cmds ); *conditions |= COND_STOP; return( FALSE ); } else if( memcmp( message, DEBUGGER_MESSAGE_COMMAND, sizeof( DEBUGGER_MESSAGE_COMMAND ) - 1 ) == 0 ) { message += sizeof( DEBUGGER_MESSAGE_COMMAND ) - 1; NoCRLF( message ); AddMessageText( message ); return( FALSE ); } else if( memcmp( message, DEBUGGER_LOOKUP_COMMAND, sizeof( DEBUGGER_LOOKUP_COMMAND ) - 1 ) == 0 ) { message += sizeof( DEBUGGER_LOOKUP_COMMAND ) - 1; comma1 = strchr( message, ',' ); if( comma1 == NULL ) return( TRUE ); *comma1++ = '\0'; comma2 = strchr( comma1, ',' ); if( comma2 == NULL ) return( TRUE ); *comma2++ = '\0'; NoCRLF( comma2 ); if( !DlgScanDataAddr( message, &addr ) ) return( TRUE ); if( !DlgScanDataAddr( comma1, &buff_addr ) ) return( TRUE ); if( !DlgScanLong( comma2, &buff_len ) ) return( TRUE ); CnvNearestAddr( addr, TxtBuff, TXT_LEN ); sym_len = strlen( TxtBuff ) + 1; if( sym_len > buff_len ) { TxtBuff[buff_len - 1] = '\0'; sym_len = buff_len; } ProgPoke( buff_addr, TxtBuff, sym_len ); return( FALSE ); } else if( memcmp( message, DEBUGGER_LOADMODULE_COMMAND, sizeof( DEBUGGER_LOADMODULE_COMMAND ) - 1 ) == 0 ) { message += sizeof( DEBUGGER_LOADMODULE_COMMAND ) - 1; comma1 = strchr( message, ',' ); if( comma1 == NULL ) return( TRUE ); *comma1++ = '\0'; NoCRLF( comma1 ); if( !DlgScanDataAddr( message, &addr ) ) return( TRUE ); SymUserModLoad( comma1, &addr ); return( FALSE ); } else if( memcmp( message, DEBUGGER_UNLOADMODULE_COMMAND, sizeof( DEBUGGER_UNLOADMODULE_COMMAND ) - 1 ) == 0 ) { message += sizeof( DEBUGGER_UNLOADMODULE_COMMAND ) - 1; NoCRLF( message ); SymUserModUnload( message ); return( FALSE ); } else if( memcmp( message, DEBUGGER_BREAKRETURN_COMMAND, sizeof( DEBUGGER_BREAKRETURN_COMMAND ) - 1 ) == 0 ) { message += sizeof( DEBUGGER_BREAKRETURN_COMMAND ) - 1; NoCRLF( message ); if( !DlgScanLong( message, &num_returns ) ) return( TRUE ); // TODO: do something with num_returns value return( FALSE ); } else { AddMessageText( message ); return( TRUE ); } }
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 ); }