void goto_check(const namespacet &ns, optionst &options, goto_functionst &goto_functions) { goto_checkt goto_check(ns, options); for (goto_functionst::function_mapt::iterator it = goto_functions.function_map.begin(); it != goto_functions.function_map.end(); it++) { goto_check.goto_check(it->second.body); } }
void show_defs( const indext &index, const optionst &options, std::ostream &out, message_handlert &message_handler) { for(indext::file_to_functiont::const_iterator file_it=index.file_to_function.begin(); file_it!=index.file_to_function.end(); file_it++) { // read the file goto_modelt model; read_goto_binary(index.full_path(file_it->first), model, message_handler); // add the properties goto_check(options, model); model.goto_functions.update(); label_properties(model.goto_functions); const namespacet ns(model.symbol_table); const std::set<irep_idt> &functions=file_it->second; // now do all functions from model for(std::set<irep_idt>::const_iterator fkt_it=functions.begin(); fkt_it!=functions.end(); fkt_it++) { const irep_idt &id=*fkt_it; const goto_functionst::function_mapt::const_iterator m_it= model.goto_functions.function_map.find(id); assert(m_it!=model.goto_functions.function_map.end()); const goto_functionst::goto_functiont *index_fkt= &m_it->second; out << ">>>> Function " << id << " in " << file_it->first << std::endl; show_defs(*index_fkt, ns, out); out << std::endl; } } }
void show_properties( const indext &index, const optionst &options, std::ostream &out, message_handlert &message_handler) { for(indext::file_to_functiont::const_iterator file_it=index.file_to_function.begin(); file_it!=index.file_to_function.end(); file_it++) { // read the file goto_modelt model; read_goto_binary(index.full_path(file_it->first), model, message_handler); // add the properties goto_check(options, model); model.goto_functions.update(); label_properties(model.goto_functions); show_properties(model, ui_message_handlert::PLAIN); } }
bool symex_parseoptionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) { try { namespacet ns(symbol_table); // do partial inlining status() << "Partial Inlining" << eom; goto_partial_inline(goto_functions, ns, ui_message_handler); // add generic checks status() << "Generic Property Instrumentation" << eom; goto_check(ns, options, goto_functions); // recalculate numbers, etc. goto_functions.update(); // add loop ids goto_functions.compute_loop_numbers(); // if we aim to cover, replace // all assertions by false to prevent simplification if(cmdline.isset("cover-assertions")) make_assertions_false(goto_functions); // show it? if(cmdline.isset("show-loops")) { show_loop_ids(get_ui(), goto_functions); return true; } // show it? if(cmdline.isset("show-goto-functions")) { goto_functions.output(ns, std::cout); return true; } } catch(const char *e) { error(e); return true; } catch(const std::string e) { error(e); return true; } catch(int) { return true; } catch(std::bad_alloc) { error() << "Out of memory" << eom; return true; } return false; }
int preparet::get_async_modules() { if(goto_functions.function_map.empty()) { // see if we have a "main" if(context.symbols.find("main")==context.symbols.end()) { error("failed to find entry point -- please provide a model"); return 1; } status("Generating GOTO Program"); goto_convert( context, goto_functions, get_message_handler()); } // we no longer need any parse trees or language files clear_parse(); // finally add the library status("Adding CPROVER library"); link_to_library( context, goto_functions, get_message_handler()); if(cmdline.isset("show-goto-functions")) { goto_functions.output(ns, std::cout); return 0; } unsigned functions=goto_functions.function_map.size(); unsigned instructions=0; forall_goto_functions(it, goto_functions) instructions+=it->second.body.instructions.size(); status(i2string(functions)+" functions, "+ i2string(instructions)+" instructions."); if(cmdline.isset("string-abstraction")) string_instrumentation( context, get_message_handler(), goto_functions); status("Removing function pointers"); remove_function_pointers(ns, goto_functions, cmdline.isset("pointer-check")); status("Removing unused functions"); remove_unused_functions( goto_functions, get_message_handler()); // Boom requies full inlining. bool boom= !cmdline.isset("modelchecker") || std::string(cmdline.getval("modelchecker"))=="boom"; // OSWALDO if(cmdline.isset("full-inlining") || boom) { status("Full inlining"); satabs_inline( goto_functions, ns, get_message_handler()); } else { // partially inline functions status("Partial inlining"); satabs_partial_inline( goto_functions, ns, get_message_handler()); // we do this again, to remove all the functions that are inlined now remove_unused_functions( goto_functions, get_message_handler()); status("Adjusting functions"); prepare_functions( context, goto_functions, get_message_handler()); // show it? if(cmdline.isset("show-adjusted-functions")) { goto_functions.output(ns, std::cout); return 0; } } // add loop ids goto_functions.compute_loop_numbers(); add_failed_symbols(context); // add generic checks goto_check(ns, options, goto_functions); if(cmdline.isset("string-abstraction")) { status("String Abstraction"); string_abstraction( context, get_message_handler(), goto_functions); } goto_functions.compute_location_numbers(); #if 0 // obsoleted by goto_check if(cmdline.isset("pointer-check") || cmdline.isset("show-value-sets")) { status("Pointer Analysis"); value_set_analysist value_set_analysis(ns); value_set_analysis(goto_functions); // show it? if(cmdline.isset("show-value-sets")) { show_value_sets(get_ui(), goto_functions, value_set_analysis); return 0; } if(cmdline.isset("pointer-check")) { status("Adding Pointer Checks"); // add pointer checks pointer_checks( goto_functions, context, options, value_set_analysis); } } #endif goto_functions.compute_location_numbers(); // label claims label_claims(goto_functions); // set claim if(cmdline.isset("claim")) set_claims( goto_functions, cmdline.get_values("claim")); // reachability slice? if(!cmdline.isset("no-slicing")) reachability_slicer(goto_functions); // show it? if(cmdline.isset("show-final-program")) { goto_functions.output(ns, std::cout); return 0; } return -1; // proceed! }
int preparet::get_async_modules() { if(goto_functions.function_map.empty()) { // see if we have a "main" if(context.symbols.find("main")==context.symbols.end()) { error("failed to find entry point -- please provide a model"); return 1; } status("Generating GOTO Program"); goto_convert( context, options, goto_functions, get_message_handler()); } if(cmdline.isset("show-goto-functions")) { goto_functions.output(ns, std::cout); return 0; } unsigned functions=goto_functions.function_map.size(); unsigned instructions=0; forall_goto_functions(it, goto_functions) instructions+=it->second.body.instructions.size(); status(i2string(functions)+" functions, "+ i2string(instructions)+" instructions."); if(cmdline.isset("string-abstraction")) string_instrumentation( context, get_message_handler(), goto_functions); status("Removing function pointers"); remove_function_pointers(ns, goto_functions); status("Removing unused functions"); remove_unused_functions( goto_functions, get_message_handler()); if(cmdline.isset("full-inlining")) { status("Full inlining"); satabs_inline( goto_functions, ns, get_message_handler()); } else { // partially inline functions status("Partial inlining"); satabs_partial_inline( goto_functions, ns, get_message_handler()); // we do this again, to remove all the functions that are inlined now remove_unused_functions( goto_functions, get_message_handler()); status("Adjusting functions"); prepare_functions( context, goto_functions, get_message_handler()); // show it? if(cmdline.isset("show-adjusted-functions")) { goto_functions.output(ns, std::cout); return 0; } } // add loop ids goto_functions.compute_loop_numbers(); // show it? if(cmdline.isset("show-loops")) { show_loop_numbers(get_ui(), goto_functions); return 0; } add_failed_symbols(context); // add generic checks goto_check(ns, options, goto_functions); if(cmdline.isset("string-abstraction")) { status("String Abstraction"); string_abstraction( context, get_message_handler(), goto_functions); } goto_functions.compute_location_numbers(); if(cmdline.isset("pointer-check") || cmdline.isset("show-value-sets") || cmdline.isset("data-race-check")) { status("Pointer Analysis"); value_set_analysist value_set_analysis(ns); value_set_analysis(goto_functions); // show it? if(cmdline.isset("show-value-sets")) { show_value_sets(get_ui(), goto_functions, value_set_analysis); return 0; } if(cmdline.isset("pointer-check")) { status("Adding Pointer Checks"); // add pointer checks pointer_checks( goto_functions, context, options, value_set_analysis); } if(cmdline.isset("data-race-check")) { status("Adding Data Race Checks"); add_race_assertions( value_set_analysis, context, goto_functions); value_set_analysis. update(goto_functions); } } goto_functions.compute_location_numbers(); #if 0 // do invariant propagation if(!cmdline.isset("no-invariant-sets")) { status("Invariant Propagation"); invariant_propagation( goto_functions); } else invariant_propagation.initialize( goto_functions); if(cmdline.isset("show-invariant-sets")) { invariant_propagation.output( goto_functions, std::cout); return 0; } // simplify if(!cmdline.isset("no-invariant-sets")) invariant_propagation.simplify( goto_functions); #endif // set claim if(cmdline.isset("claim")) set_claims( goto_functions, cmdline.get_values("claim")); // slice if(!cmdline.isset("no-slicing")) slicer(goto_functions); // show it? if(cmdline.isset("show-final-program")) { goto_functions.output(ns, std::cout); return 0; } return -1; // proceed! }
bool symex_parse_optionst::process_goto_program(const optionst &options) { try { // we add the library status() << "Adding CPROVER library" << eom; link_to_library(goto_model, ui_message_handler); // do partial inlining status() << "Partial Inlining" << eom; goto_partial_inline(goto_model, ui_message_handler); // add generic checks status() << "Generic Property Instrumentation" << eom; goto_check(options, goto_model); // remove stuff remove_complex(goto_model); remove_vector(goto_model); remove_virtual_functions(goto_model); // recalculate numbers, etc. goto_model.goto_functions.update(); // add loop ids goto_model.goto_functions.compute_loop_numbers(); if(cmdline.isset("cover")) { std::string criterion=cmdline.get_value("cover"); coverage_criteriont c; if(criterion=="assertion" || criterion=="assertions") c=coverage_criteriont::ASSERTION; else if(criterion=="path" || criterion=="paths") c=coverage_criteriont::PATH; else if(criterion=="branch" || criterion=="branches") c=coverage_criteriont::BRANCH; else if(criterion=="location" || criterion=="locations") c=coverage_criteriont::LOCATION; else if(criterion=="decision" || criterion=="decisions") c=coverage_criteriont::DECISION; else if(criterion=="condition" || criterion=="conditions") c=coverage_criteriont::CONDITION; else if(criterion=="mcdc") c=coverage_criteriont::MCDC; else if(criterion=="cover") c=coverage_criteriont::COVER; else { error() << "unknown coverage criterion" << eom; return true; } status() << "Instrumenting coverge goals" << eom; instrument_cover_goals(symbol_table, goto_model.goto_functions, c); goto_model.goto_functions.update(); } // show it? if(cmdline.isset("show-loops")) { show_loop_ids(get_ui(), goto_model.goto_functions); return true; } // show it? if(cmdline.isset("show-goto-functions")) { const namespacet ns(goto_model.symbol_table); goto_model.goto_functions.output(ns, std::cout); return true; } } catch(const char *e) { error() << e << eom; return true; } catch(const std::string e) { error() << e << eom; return true; } catch(int) { return true; } catch(std::bad_alloc) { error() << "Out of memory" << eom; return true; } return false; }
void player_drop(int d) { char buf[200]; if (PINFO(d).style!=-1) { PINFO(d).style=-1; if (d<MAX_PLAYER) rooms[myroom].numplayer--; else rooms[myroom].numspectator--; kill_msg(d); } switch(RINFO.status) { case INROOM_STOP: break; case INROOM_NIGHT: check_win(); break; case INROOM_DAY: if (d==RINFO.victim) { sprintf (buf, "\x1b[1;32m%d %s\x1b[m: \x1b[1;31mOver.\x1b[m", d + 1, PINFO(d).nick); send_msg (-1, buf); goto_check(); } break; case INROOM_CHECK: if (d==RINFO.turn) { sprintf (buf, "\x1b[1;32m%d %s\x1b[m: \x1b[1;31mOver.\x1b[m", d + 1, PINFO(d).nick); send_msg (-1, buf); while (1) { RINFO.turn++; if (RINFO.turn>=MAX_PLAYER) RINFO.turn=0; if (RINFO.turn==RINFO.victim) break; if (PINFO(RINFO.turn).style!=-1 && (PINFO(RINFO.turn).flag & PEOPLE_ALIVE) ) break; } if (RINFO.turn!=RINFO.victim) { sprintf (buf,"请\33[32;1m %d %s \33[m发言", RINFO.turn + 1, PINFO(RINFO.turn).nick); send_msg (-1, buf); send_msg (RINFO.turn, "请\x1b[31;1m上下移动光标\x1b[m,在您怀疑的对象上"); send_msg (RINFO.turn, "按\33[31;1mCtrl+S\33[m指证"); send_msg (RINFO.turn, "指证完后,用\33[31;1mCtrl+T\33[m结束发言"); if (PINFO(RINFO.turn).flag & PEOPLE_KILLER) send_msg (RINFO.turn, "\33[31;1m把光标移到自己位置上,用Ctrl+S可自杀\33[m"); } else { RINFO.round=1; goto_defence(); } } break; case INROOM_DEFENCE: if (d==RINFO.turn) { sprintf (buf, "\x1b[1;32m%d %s\x1b[m: \x1b[1;31mOver.\x1b[m", d + 1, PINFO(d).nick); send_msg (-1, buf); while (1) { if (RINFO.round%2) RINFO.turn--; else RINFO.turn++; if (RINFO.turn>=MAX_PLAYER) RINFO.turn=0; if (RINFO.turn<0) RINFO.turn=MAX_PLAYER-1; if (RINFO.turn==RINFO.victim) break; if (PINFO(RINFO.turn).style!=-1 && (PINFO(RINFO.turn).flag & PEOPLE_ALIVE) && (PINFO(RINFO.turn).flag & PEOPLE_VOTED)) break; } if (RINFO.turn!=RINFO.victim) { sprintf (buf,"请\33[32;1m %d %s \33[m辩护", RINFO.turn + 1, PINFO(RINFO.turn).nick); send_msg (-1, buf); send_msg (RINFO.turn, "辩护完后,用\33[31;1mCtrl+T\33[m结束"); if (PINFO(RINFO.turn).flag & PEOPLE_KILLER) send_msg (RINFO.turn, "\33[31;1m把光标移到自己位置上,用Ctrl+S可自杀\33[m"); } else { goto_vote(); } } break; case INROOM_VOTE: vote_result(); break; case INROOM_DARK: if (d==RINFO.victim) { sprintf (buf, "\x1b[1;32m%d %s\x1b[m: \x1b[1;31mOver.\x1b[m", d + 1, PINFO(d).nick); send_msg (-1, buf); goto_night(); } break; } }
void goto_check(const namespacet &ns, optionst &options, goto_programt &goto_program) { goto_checkt goto_check(ns, options); goto_check.goto_check(goto_program); }
bool cbmc_parseoptionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) { try { namespacet ns(context); if(cmdline.isset("string-abstraction")) string_instrumentation( context, get_message_handler(), goto_functions); status("Function Pointer Removal"); remove_function_pointers(ns, goto_functions, cmdline.isset("pointer-check")); status("Partial Inlining"); // do partial inlining goto_partial_inline(goto_functions, ns, ui_message_handler); status("Generic Property Instrumentation"); // add generic checks goto_check(ns, options, goto_functions); if(cmdline.isset("string-abstraction")) { status("String Abstraction"); string_abstraction(context, get_message_handler(), goto_functions); } // add failed symbols // needs to be done before pointer analysis add_failed_symbols(context); if(cmdline.isset("pointer-check") || cmdline.isset("show-value-sets")) { status("Pointer Analysis"); value_set_analysist value_set_analysis(ns); value_set_analysis(goto_functions); // show it? if(cmdline.isset("show-value-sets")) { show_value_sets(get_ui(), goto_functions, value_set_analysis); return true; } status("Adding Pointer Checks"); // add pointer checks pointer_checks( goto_functions, context, options, value_set_analysis); } // recalculate numbers, etc. goto_functions.update(); // add loop ids goto_functions.compute_loop_numbers(); // if we aim to cover, replace // all assertions by false to prevent simplification if(cmdline.isset("cover-assertions")) make_assertions_false(goto_functions); // show it? if(cmdline.isset("show-loops")) { show_loop_numbers(get_ui(), goto_functions); return true; } // show it? if(cmdline.isset("show-goto-functions")) { goto_functions.output(ns, std::cout); return true; } } catch(const char *e) { error(e); return true; } catch(const std::string e) { error(e); return true; } catch(int) { return true; } catch(std::bad_alloc) { error("Out of memory"); return true; } return false; }
//char * joker2q[9]= {"一张", "一对", "三张", "四张" , "五张", "六张", "七张", "八张", "九张"}; void start_game_joker2() { int total; int i,j; int joker2[JOKER2_NUM]; char buf[80]; total=start_game_preparation(); if (total<4 || total >4) { send_msg (-1,"桥牌只能4个人玩"); kill_msg (-1); return; } //分拨 j=0; // RINFO.deadnum=0;//标记出完人数 // RINFO.deadpointer=0; // RINFO.mulenum=-1; //标记头供是哪一方的 for (i=0; i<MAX_PLAYER; i++) { PINFO(i).flag=PEOPLE_ALIVE; if (j%2) { PINFO(i).flag |=PEOPLE_POLICE; RINFO.polices[(int)(j/2)]=i; } else { PINFO(i).flag |=PEOPLE_KILLER; RINFO.killers[(int)(j/2)]=i; } RINFO.mulelist[i]=j;//mulelist标记人的顺序号,对应牌堆 mulelist 编号->座位 RINFO.secretvotelist[j]=i; //secretvotelist, 座位->编号 j++; RINFO.deadlist[i]=-1; //deadlist记录出完顺序 } //发牌 for (i=0; i<JOKER2_NUM; i++) joker2[i]=i; random_sort (joker2, JOKER2_NUM); for (j=0; j<JOKER2_PER_PERSON; j++) { for (i=0; i<JOKER2_PERSON; i++) { RINFO.seq_action[i][j]=(char)joker2[i*JOKER2_PER_PERSON+j]; //红桃4在谁手里? if (joker2[i*JOKER2_PER_PERSON+j] == 16 ) RINFO.numvoted=i; } } send_msg(mypos, "注意,设定杀手数为1可以禁止聊天, 设置警察数可以控制超时时间为10(n+1)秒"); kill_msg(mypos); send_msg(-1,"\33[31;1m游戏开始了,人群中出现了52张扑克牌。\33[m"); send_msg(-1, "\33[31;1m请双方看牌。\33[m"); // send_msg(-1, " 出牌方法是直接输入字符串并回车。例如,单个的\"3\"代"); // send_msg(-1, "表一张3,\"qq\"代表一对Q,\"239\"则代表用百搭2和3与9组"); // send_msg(-1, "成的三张9。特殊的,用e表示小王,r代表大王, t或者0则代"); // send_msg(-1, "表10。大小写可以任意。"); // send_msg(-1, "\33[31;1m下面请红桃4先出牌。\33[m"); kill_msg(-1); for(i=0; i<JOKER2_PERSON; i++) { // PINFO(i).vnum=JOKER2_PER_PERSON; joker2_sort_by_suit(RINFO.seq_action[i], PINFO(RINFO.secretvotelist[i]).vnum); joker2_showdeck(i, RINFO.secretvotelist[i]); } // RINFO.lastturntime=bbstime(NULL); goto_check(); }
bool cbmc_parse_optionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) { try { namespacet ns(symbol_table); // Remove inline assembler; this needs to happen before // adding the library. remove_asm(symbol_table, goto_functions); // add the library status() << "Adding CPROVER library (" << config.ansi_c.arch << ")" << eom; link_to_library(symbol_table, goto_functions, ui_message_handler); if(cmdline.isset("string-abstraction")) string_instrumentation( symbol_table, get_message_handler(), goto_functions); // remove function pointers status() << "Function Pointer Removal" << eom; remove_function_pointers(symbol_table, goto_functions, cmdline.isset("pointer-check")); // full slice? if(cmdline.isset("full-slice")) { status() << "Performing a full slice" << eom; full_slicer(goto_functions, ns); } // do partial inlining status() << "Partial Inlining" << eom; goto_partial_inline(goto_functions, ns, ui_message_handler); // remove returns, gcc vectors, complex remove_returns(symbol_table, goto_functions); remove_vector(symbol_table, goto_functions); remove_complex(symbol_table, goto_functions); // add generic checks status() << "Generic Property Instrumentation" << eom; goto_check(ns, options, goto_functions); if(cmdline.isset("string-abstraction")) { status() << "String Abstraction" << eom; string_abstraction(symbol_table, get_message_handler(), goto_functions); } // add failed symbols // needs to be done before pointer analysis add_failed_symbols(symbol_table); // recalculate numbers, etc. goto_functions.update(); // add loop ids goto_functions.compute_loop_numbers(); // if we aim to cover assertions, replace // all assertions by false to prevent simplification if(cmdline.isset("cover") && cmdline.get_value("cover")=="assertions") make_assertions_false(goto_functions); // show it? if(cmdline.isset("show-loops")) { show_loop_ids(get_ui(), goto_functions); return true; } // show it? if(cmdline.isset("show-goto-functions")) { goto_functions.output(ns, std::cout); return true; } } catch(const char *e) { error() << e << eom; return true; } catch(const std::string e) { error() << e << eom; return true; } catch(int) { return true; } catch(std::bad_alloc) { error() << "Out of memory" << eom; return true; } return false; }