bool GlobalScripts::readRecord (ESM::ESMReader& reader, int32_t type) { if (type==ESM::REC_GSCR) { ESM::GlobalScript script; script.load (reader); std::map<std::string, std::pair<bool, Locals> >::iterator iter = mScripts.find (script.mId); if (iter==mScripts.end()) { if (const ESM::Script *scriptRecord = mStore.get<ESM::Script>().search (script.mId)) { std::pair<bool, Locals> data (false, Locals()); data.second.configure (*scriptRecord); iter = mScripts.insert (std::make_pair (script.mId, data)).first; } else // script does not exist anymore return true; } iter->second.first = script.mRunning!=0; iter->second.second.read (script.mLocals, script.mId); return true; } return false; }
void Pdb::Data() { switch(tab.Get()) { case TAB_AUTOS: Autos(); break; case TAB_LOCALS: Locals(); break; case TAB_THIS: This(); break; case TAB_WATCHES: Watches(); break; case TAB_EXPLORER: Explorer(); break; case TAB_MEMORY: memory.Refresh(); break; } }
int directive( int i, long direct ) /* Handle all directives */ { int ret; /* no expansion on the following */ switch( direct ) { case T_MASM: Options.mode &= ~MODE_IDEAL; return( NOT_ERROR ); case T_IDEAL: Options.mode |= MODE_IDEAL; return( NOT_ERROR ); case T_DOT_286C: direct = T_DOT_286; case T_DOT_8086: case T_DOT_186: case T_DOT_286: case T_DOT_286P: case T_DOT_386: case T_DOT_386P: case T_DOT_486: case T_DOT_486P: case T_DOT_586: case T_DOT_586P: case T_DOT_686: case T_DOT_686P: case T_DOT_8087: case T_DOT_287: case T_DOT_387: case T_DOT_NO87: case T_DOT_K3D: case T_DOT_MMX: case T_DOT_XMM: case T_DOT_XMM2: case T_DOT_XMM3: if( Options.mode & MODE_IDEAL ) { AsmError( UNKNOWN_DIRECTIVE ); return( ERROR ); } else { ret = cpu_directive(direct); if( Parse_Pass != PASS_1 ) ret = NOT_ERROR; return( ret ); } case T_P286N: direct = T_P286; case T_P8086: case T_P186: case T_P286: case T_P286P: case T_P386: case T_P386P: case T_P486: case T_P486P: case T_P586: case T_P586P: case T_P686: case T_P686P: case T_P8087: case T_P287: case T_P387: case T_PK3D: case T_PMMX: case T_PXMM: case T_PXMM2: case T_PXMM3: ret = cpu_directive(direct); if( Parse_Pass != PASS_1 ) ret = NOT_ERROR; return( ret ); case T_DOT_DOSSEG: if( Options.mode & MODE_IDEAL ) { AsmError( UNKNOWN_DIRECTIVE ); return( ERROR ); } case T_DOSSEG: Globals.dosseg = TRUE; return( NOT_ERROR ); case T_PUBLIC: /* special case - expanded inside iff it is an EQU to a symbol */ return( Parse_Pass == PASS_1 ? PubDef(i+1) : NOT_ERROR ); case T_ELSE: case T_ELSEIF: case T_ELSEIF1: case T_ELSEIF2: case T_ELSEIFB: case T_ELSEIFDEF: case T_ELSEIFE: case T_ELSEIFNB: case T_ELSEIFNDEF: case T_ELSEIFDIF: case T_ELSEIFDIFI: case T_ELSEIFIDN: case T_ELSEIFIDNI: case T_ENDIF: case T_IF: case T_IF1: case T_IF2: case T_IFB: case T_IFDEF: case T_IFE: case T_IFNB: case T_IFNDEF: case T_IFDIF: case T_IFDIFI: case T_IFIDN: case T_IFIDNI: return( conditional_assembly_directive( i ) ); case T_DOT_ERR: case T_DOT_ERRB: case T_DOT_ERRDEF: case T_DOT_ERRDIF: case T_DOT_ERRDIFI: case T_DOT_ERRE: case T_DOT_ERRIDN: case T_DOT_ERRIDNI: case T_DOT_ERRNB: case T_DOT_ERRNDEF: case T_DOT_ERRNZ: if( Options.mode & MODE_IDEAL ) { AsmError( UNKNOWN_DIRECTIVE ); return( ERROR ); } case T_ERR: case T_ERRIFB: case T_ERRIFDEF: case T_ERRIFDIF: case T_ERRIFDIFI: case T_ERRIFE: case T_ERRIFIDN: case T_ERRIFIDNI: case T_ERRIFNDEF: return( conditional_error_directive( i ) ); case T_ENDS: if( Definition.struct_depth != 0 ) return( StructDef( i ) ); // else fall through to T_SEGMENT case T_SEGMENT: return( Parse_Pass == PASS_1 ? SegDef(i) : SetCurrSeg(i) ); case T_GROUP: return( Parse_Pass == PASS_1 ? GrpDef(i) : NOT_ERROR ); case T_PROC: return( ProcDef( i, TRUE ) ); case T_ENDP: return( ProcEnd(i) ); case T_ENUM: return( EnumDef( i ) ); case T_DOT_CODE: case T_DOT_STACK: case T_DOT_DATA: case T_DOT_DATA_UN: case T_DOT_FARDATA: case T_DOT_FARDATA_UN: case T_DOT_CONST: if( Options.mode & MODE_IDEAL ) { AsmError( UNKNOWN_DIRECTIVE ); return( ERROR ); } case T_CODESEG: case T_STACK: case T_DATASEG: case T_UDATASEG: case T_FARDATA: case T_UFARDATA: case T_CONST: return( SimSeg(i) ); case T_WARN: case T_NOWARN: return( NOT_ERROR ); /* Not implemented yet */ case T_DOT_ALPHA: case T_DOT_SEQ: case T_DOT_LIST: case T_DOT_LISTALL: case T_DOT_LISTIF: case T_DOT_LISTMACRO: case T_DOT_LISTMACROALL: case T_DOT_NOLIST: case T_DOT_XLIST: case T_DOT_TFCOND: case T_DOT_SFCOND: case T_DOT_LFCOND: case T_DOT_CREF: case T_DOT_XCREF: case T_DOT_NOCREF: case T_DOT_SALL: case T_PAGE: case T_TITLE: case T_SUBTITLE: case T_SUBTTL: if( Options.mode & MODE_IDEAL ) { AsmError( UNKNOWN_DIRECTIVE ); return( ERROR ); } AsmWarn( 4, IGNORING_DIRECTIVE ); return( NOT_ERROR ); case T_DOT_BREAK: case T_DOT_CONTINUE: case T_DOT_ELSE: case T_DOT_ENDIF: case T_DOT_ENDW: case T_DOT_IF: case T_DOT_RADIX: case T_DOT_REPEAT: case T_DOT_UNTIL: case T_DOT_WHILE: if( Options.mode & MODE_IDEAL ) { AsmError( UNKNOWN_DIRECTIVE ); return( ERROR ); } case T_ECHO: case T_HIGH: case T_HIGHWORD: case T_LOW: case T_LOWWORD: case T_ADDR: case T_BOUND: case T_CASEMAP: case T_INVOKE: case T_LROFFSET: case T_OPATTR: case T_OPTION: case T_POPCONTEXT: case T_PUSHCONTEXT: case T_PROTO: case T_THIS: case T_WIDTH: if( Options.mode & MODE_IDEAL ) { AsmError( UNKNOWN_DIRECTIVE ); return( ERROR ); } case T_CATSTR: case T_MASK: case T_PURGE: case T_RECORD: case T_TYPEDEF: case T_UNION: AsmError( NOT_SUPPORTED ); return( ERROR ); case T_ORG: ExpandTheWorld( 0, FALSE, TRUE ); break; case T_TEXTEQU: /* TEXTEQU */ if( Options.mode & MODE_IDEAL ) { AsmError( UNKNOWN_DIRECTIVE ); return( ERROR ); } case T_EQU2: /* = */ case T_EQU: /* EQU */ /* expand any constants and simplify any expressions */ ExpandTheConstant( 0, FALSE, TRUE ); break; case T_NAME: /* no expand parameters */ break; case T_DOT_STARTUP: case T_DOT_EXIT: if( Options.mode & MODE_IDEAL ) { AsmError( UNKNOWN_DIRECTIVE ); return( ERROR ); } case T_STARTUPCODE: case T_EXITCODE: default: /* expand any constants in all other directives */ ExpandAllConsts( 0, FALSE ); break; } switch( direct ) { case T_ALIAS: if( Parse_Pass == PASS_1 ) return( AddAlias( i ) ); return( NOT_ERROR ); case T_EXTERN: if( Options.mode & MODE_IDEAL ) { break; } case T_EXTRN: return( Parse_Pass == PASS_1 ? ExtDef( i+1, FALSE ) : NOT_ERROR ); case T_COMM: return( Parse_Pass == PASS_1 ? CommDef(i+1) : NOT_ERROR ); case T_EXTERNDEF: if( Options.mode & MODE_IDEAL ) { break; } case T_GLOBAL: return( Parse_Pass == PASS_1 ? ExtDef( i+1, TRUE ) : NOT_ERROR ); case T_DOT_MODEL: if( Options.mode & MODE_IDEAL ) { break; } case T_MODEL: return( Model(i) ); case T_INCLUDE: return( Include(i+1) ); case T_INCLUDELIB: return( Parse_Pass == PASS_1 ? IncludeLib(i+1) : NOT_ERROR ); case T_ASSUME: return( SetAssume(i) ); case T_END: return( ModuleEnd(Token_Count) ); case T_EQU: return( DefineConstant( i-1, FALSE, FALSE ) ); case T_EQU2: return( DefineConstant( i-1, TRUE, FALSE ) ); case T_TEXTEQU: return( DefineConstant( i-1, TRUE, TRUE ) ); case T_MACRO: return( MacroDef(i, FALSE ) ); case T_ENDM: return( MacroEnd( FALSE ) ); case T_EXITM: return( MacroEnd( TRUE ) ); case T_ARG: return( Parse_Pass == PASS_1 ? ArgDef(i) : NOT_ERROR ); case T_USES: return( Parse_Pass == PASS_1 ? UsesDef(i) : NOT_ERROR ); case T_LOCAL: return( Parse_Pass == PASS_1 ? LocalDef(i) : NOT_ERROR ); case T_COMMENT: if( Options.mode & MODE_IDEAL ) break; return( Comment( START_COMMENT, i ) ); case T_STRUCT: if( Options.mode & MODE_IDEAL ) { break; } case T_STRUC: return( StructDef( i ) ); case T_NAME: return( Parse_Pass == PASS_1 ? NameDirective(i) : NOT_ERROR ); case T_LABEL: return( LabelDirective( i ) ); case T_ORG: return( OrgDirective( i ) ); case T_ALIGN: case T_EVEN: return( AlignDirective( direct, i ) ); case T_FOR: if( Options.mode & MODE_IDEAL ) { break; } case T_IRP: return( ForDirective ( i+1, IRP_WORD ) ); case T_FORC: if( Options.mode & MODE_IDEAL ) { break; } case T_IRPC: return( ForDirective ( i+1, IRP_CHAR ) ); case T_REPEAT: if( Options.mode & MODE_IDEAL ) { break; } case T_REPT: return( ForDirective ( i+1, IRP_REPEAT ) ); case T_DOT_STARTUP: case T_DOT_EXIT: case T_STARTUPCODE: case T_EXITCODE: return( Startup ( i ) ); case T_LOCALS: case T_NOLOCALS: return( Locals( i ) ); } AsmError( UNKNOWN_DIRECTIVE ); return( ERROR ); }
void caml_debugger(enum event_kind event) { int frame_number; value * frame; intnat i, pos; value val; if (dbg_socket == -1) return; /* Not connected to a debugger. */ /* Reset current frame */ frame_number = 0; frame = caml_extern_sp + 1; /* Report the event to the debugger */ switch(event) { case PROGRAM_START: /* Nothing to report */ goto command_loop; case EVENT_COUNT: putch(dbg_out, REP_EVENT); break; case BREAKPOINT: putch(dbg_out, REP_BREAKPOINT); break; case PROGRAM_EXIT: putch(dbg_out, REP_EXITED); break; case TRAP_BARRIER: putch(dbg_out, REP_TRAP); break; case UNCAUGHT_EXC: putch(dbg_out, REP_UNCAUGHT_EXC); break; } caml_putword(dbg_out, caml_event_count); if (event == EVENT_COUNT || event == BREAKPOINT) { caml_putword(dbg_out, caml_stack_high - frame); caml_putword(dbg_out, (Pc(frame) - caml_start_code) * sizeof(opcode_t)); } else { /* No PC and no stack frame associated with other events */ caml_putword(dbg_out, 0); caml_putword(dbg_out, 0); } caml_flush(dbg_out); command_loop: /* Read and execute the commands sent by the debugger */ while(1) { switch(getch(dbg_in)) { case REQ_SET_EVENT: pos = caml_getword(dbg_in); Assert (pos >= 0); Assert (pos < caml_code_size); caml_set_instruction(caml_start_code + pos / sizeof(opcode_t), EVENT); break; case REQ_SET_BREAKPOINT: pos = caml_getword(dbg_in); Assert (pos >= 0); Assert (pos < caml_code_size); caml_set_instruction(caml_start_code + pos / sizeof(opcode_t), BREAK); break; case REQ_RESET_INSTR: pos = caml_getword(dbg_in); Assert (pos >= 0); Assert (pos < caml_code_size); pos = pos / sizeof(opcode_t); caml_set_instruction(caml_start_code + pos, caml_saved_code[pos]); break; case REQ_CHECKPOINT: #ifndef _WIN32 i = fork(); if (i == 0) { close_connection(); /* Close parent connection. */ open_connection(); /* Open new connection with debugger */ } else { caml_putword(dbg_out, i); caml_flush(dbg_out); } #else caml_fatal_error("error: REQ_CHECKPOINT command"); exit(-1); #endif break; case REQ_GO: caml_event_count = caml_getword(dbg_in); return; case REQ_STOP: exit(0); break; case REQ_WAIT: #ifndef _WIN32 wait(NULL); #else caml_fatal_error("Fatal error: REQ_WAIT command"); exit(-1); #endif break; case REQ_INITIAL_FRAME: frame = caml_extern_sp + 1; /* Fall through */ case REQ_GET_FRAME: caml_putword(dbg_out, caml_stack_high - frame); if (frame < caml_stack_high){ caml_putword(dbg_out, (Pc(frame) - caml_start_code) * sizeof(opcode_t)); }else{ caml_putword (dbg_out, 0); } caml_flush(dbg_out); break; case REQ_SET_FRAME: i = caml_getword(dbg_in); frame = caml_stack_high - i; break; case REQ_UP_FRAME: i = caml_getword(dbg_in); if (frame + Extra_args(frame) + i + 3 >= caml_stack_high) { caml_putword(dbg_out, -1); } else { frame += Extra_args(frame) + i + 3; caml_putword(dbg_out, caml_stack_high - frame); caml_putword(dbg_out, (Pc(frame) - caml_start_code) * sizeof(opcode_t)); } caml_flush(dbg_out); break; case REQ_SET_TRAP_BARRIER: i = caml_getword(dbg_in); caml_trap_barrier = caml_stack_high - i; break; case REQ_GET_LOCAL: i = caml_getword(dbg_in); putval(dbg_out, Locals(frame)[i]); caml_flush(dbg_out); break; case REQ_GET_ENVIRONMENT: i = caml_getword(dbg_in); putval(dbg_out, Field(Env(frame), i)); caml_flush(dbg_out); break; case REQ_GET_GLOBAL: i = caml_getword(dbg_in); putval(dbg_out, Field(caml_global_data, i)); caml_flush(dbg_out); break; case REQ_GET_ACCU: putval(dbg_out, *caml_extern_sp); caml_flush(dbg_out); break; case REQ_GET_HEADER: val = getval(dbg_in); caml_putword(dbg_out, Hd_val(val)); caml_flush(dbg_out); break; case REQ_GET_FIELD: val = getval(dbg_in); i = caml_getword(dbg_in); if (Tag_val(val) != Double_array_tag) { putch(dbg_out, 0); putval(dbg_out, Field(val, i)); } else { double d = Double_field(val, i); putch(dbg_out, 1); caml_really_putblock(dbg_out, (char *) &d, 8); } caml_flush(dbg_out); break; case REQ_MARSHAL_OBJ: val = getval(dbg_in); safe_output_value(dbg_out, val); caml_flush(dbg_out); break; case REQ_GET_CLOSURE_CODE: val = getval(dbg_in); caml_putword(dbg_out, (Code_val(val)-caml_start_code) * sizeof(opcode_t)); caml_flush(dbg_out); break; case REQ_SET_FORK_MODE: caml_debugger_fork_mode = caml_getword(dbg_in); break; } } }