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 ); } }
void RemovePoint( brkp *bp ) { brkp **owner; for( owner = &BrkList; ; owner = &(*owner)->next ) { if( ( *owner ) == bp ) { RecordBreakEvent( bp, B_CLEAR ); FreeCmdList( bp->cmds ); _Free( bp->condition ); _Free( bp->source_line ); _Free( bp->image_name ); _Free( bp->mod_name ); _Free( bp->sym_name ); *owner = bp->next; DbgUpdate( UP_BREAK_CHANGE ); FiniMappableAddr( &bp->loc ); _Free( bp ); break; } } }
OVL_EXTERN bool DoneCapture( inp_data_handle _cmds, inp_rtn_action action ) { cmd_list *cmds = _cmds; const char *old; switch( action ) { case INP_RTN_INIT: ReScan( cmds->buff ); return( true ); case INP_RTN_EOL: return( false ); case INP_RTN_FINI: FreeCmdList( cmds ); old = ReScan( LIT_ENG( Empty ) ); StdOutNew(); ReScan( old ); if( CaptureOk ) { WndTmpFileInspect( FileName ); } return( true ); } return( false ); }
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 ); } }