void mono_gc_disable (void) { #ifdef HAVE_GC_ENABLE GC_disable (); #else g_assert_not_reached (); #endif }
static void PlayBlock( struct Blocks *block, Place *place, bool do_loop ){ // GC isn't used in the player thread, but the player thread sometimes holds pointers to gc-allocated memory. //while(GC_is_disabled()==false){ //printf("Calling gc_disable: %d\n",GC_dont_gc); while(GC_dont_gc<=0){ GC_disable(); } pc->initplaying=true; pc->playpos=0; pc->play_id++; if(do_loop==true) pc->playtype=PLAYBLOCK; else pc->playtype=PLAYBLOCK_NONLOOP; pc->block=block; root->curr_block=pc->block->l.num; printf("Play block. root->curr_block: %d. Block: %p\n",root->curr_block,pc->block); //abort(); fflush(stdout); #if !USE_OPENGL pc->isplaying=true; (*Ptask2MtaskCallBack)(); #endif pc->isplaying=false; PATCH_reset_time(); InitPEQclock(); InitPEQ_LPB(pc->block,place); InitPEQ_Signature(pc->block,place); InitPEQ_Beat(pc->block,place); InitPEQrealline(block,place); InitPEQline(block,place); InitPEQblock(block,place); InitAllPEQnotes(block,place); StartPlayer(); // An OS spesific function. pc->isplaying=true; pc->initplaying=false; }
void org_xmlvm_runtime_FinalizerNotifier_preventGarbageCollection___boolean(JAVA_BOOLEAN n1) { //XMLVM_BEGIN_NATIVE[org_xmlvm_runtime_FinalizerNotifier_preventGarbageCollection___boolean] #ifndef XMLVM_NO_GC if (n1) { // Disable garbage collection. Even GC_gcollect calls will be ineffective. GC_disable(); } else { // Reenable garbage collection. GC_disable() and GC_enable() calls // nest. Garbage collection is enabled if the number of calls to both // functions is equal. GC_enable(); } #endif //XMLVM_END_NATIVE }
static void PlaySong( Place *place, int playpos ){ debug("haaasfdfsafsa, root->song->length: %d\n\n\n",root->song->length); pc->initplaying=true; struct Blocks *block=BL_GetBlockFromPos(playpos); printf("Play song. blocknum:%d. Block: %p\n",block->l.num, block); pc->playpos=playpos; pc->play_id++; root->curr_playlist=playpos; pc->playtype=PLAYSONG; pc->block=block; root->curr_block=block->l.num; #if !USE_OPENGL pc->isplaying=true; (*Ptask2MtaskCallBack)(); #endif pc->isplaying=false; PATCH_reset_time(); InitPEQclock(); InitPEQ_LPB(pc->block,place); InitPEQ_Signature(pc->block,place); InitPEQ_Beat(pc->block,place); InitPEQrealline(block,place); InitPEQline(block,place); InitPEQblock(block,place); InitAllPEQnotes(block,place); StartPlayer(); // An OS spesific function. pc->isplaying=true; pc->initplaying=false; // GC isn't used in the player thread, but the player thread sometimes holds pointers to gc-allocated memory. while(GC_is_disabled()==false) GC_disable(); }
static bool Load_CurrPos_org(struct Tracker_Windows *window, const wchar_t *filename){ bool ret = false; // So many things happen here, that we should turn off garbage collection while loading. // // For instance, the instrument widget contains pointers (which are unreachable from the GC) to Patch // and PatchData objects. The instrument widget is updated after setting a new root, so it may access // that memory while a new song is loaded (since we don't have control over what Qt may do while we // access it). Not unlikely to be other similar situations. if(0){ GC_disable(); } PlayStop(); if(Undo_are_you_shure_questionmark()==false) goto exit; if(filename==NULL) filename=GFX_GetLoadFileName(window,NULL,"Select file to load", NULL, NULL); if(filename==NULL) goto exit; if (STRING_ends_with(filename,".MMD2") || STRING_ends_with(filename,".MMD3") || STRING_ends_with(filename,".MMD") || STRING_ends_with(filename,".mmd2") || STRING_ends_with(filename,".mmd3") || STRING_ends_with(filename,".mmd") ) { mmp2filename=filename; ret = Load(STRING_create("new_song.rad")); } else { OS_set_loading_path(filename); { ret = Load(filename); } OS_unset_loading_path(); GFX_SetWindowTitle(root->song->tracker_windows, filename); GFX_EditorWindowToFront(root->song->tracker_windows); struct WBlocks *wblock = root->song->tracker_windows->wblock; GFX_update_instrument_patch_gui(wblock->wtrack->track->patch); DrawUpTrackerWindow(root->song->tracker_windows); fprintf(stderr,"Got here (loading finished)\n"); } exit: if(0){ GC_enable(); } if(mmp2filename!=NULL) { LoadMMP2(root->song->tracker_windows, mmp2filename); mmp2filename=NULL; } if (ret) ResetUndo(); return ret; }
int main(int argc, char** argv) { /* getopt parsing */ static struct option longopts[] = { { "debug", 0, NULL, 'd' }, { "file", 1, NULL, 'f' }, { "help", 0, NULL, 'h' }, { "verbose", 0, NULL, 'v' }, { "quiet", 0, NULL, 'q' }, { "script", 0, NULL, 's' }, { "args", 0, NULL, 'a' }, { NULL, 0, NULL, 0 } }; /* Parse commandline options */ char * filename = NULL; bool echo = true; int threads = 1; int ch; opterr = 0; while ((ch = getopt_long(argc, argv, "df:hj:vqas", longopts, NULL)) != -1) { // don't parse args past '--args' if(ch == 'a') break; switch (ch) { case 'd': debug++; break; case 'f': filename = optarg; break; case 'v': verbose++; break; case 'q': echo = false; break; case 'j': if(0 != strcmp("-",optarg)) { threads = atoi(optarg); } break; case 'h': default: usage(); exit(-1); break; } } d_message(1,NULL,"Command option processing complete"); /* Start garbage collector */ GC_INIT(); GC_disable(); /* Initialize execution state */ State state(threads, argc, argv); state.verbose = verbose; Thread& thread = state.getMainThread(); /* Load built in & base functions */ try { registerCoreFunctions(state); registerCoerceFunctions(state); loadLibrary(thread, "library", "core"); } catch(RiposteException& e) { e_message("Error", e.kind().c_str(), e.what().c_str()); } dumpWarnings(thread, std::cout); /* Either execute the specified file or read interactively from stdin */ int rc; if(filename != NULL) { std::ifstream in(filename); rc = run(state, in, std::cout, false, echo); } else { info(state, std::cout); rc = run(state, std::cin, std::cout, true, echo); } /* Session over */ fflush(stdout); fflush(stderr); return rc; }
/** * The main function for the command line mode. Parses switches and runs decompile(filename). * * \return Zero on success, nonzero on faillure. */ int Boomerang::commandLine(int argc, const char **argv) { printf("Boomerang %s\n", VERSION); // Display a version and date (mainly for release versions) if (argc < 2) usage(); progPath = argv[0]; size_t j = progPath.rfind('/'); // Chop off after the last slash if (j == (size_t)-1) j = progPath.rfind('\\'); // .. or reverse slash if (j != (size_t)-1) { // Do the chop; keep the trailing slash or reverse slash progPath = progPath.substr(0, j+1); } else { progPath = "./"; // Just assume the current directory } #ifdef _MSC_VER // For the console mode version; Windows GUI will override in windows.cpp // As a special case for MSVC testing, make the program path the parent of the dir with the .exe j = progPath.find("ebug\\", progPath.length() - (4+1)); if (j != std::string::npos) j--; // Point to the 'd' or 'D' if (j == std::string::npos) { j = progPath.rfind("elease\\", progPath.length() - (6+1)); if (j != std::string::npos) j--; // Point to the 'r' or 'R' } if (j != std::string::npos) progPath = progPath.substr(0, j); // Chop off "Release\" or "Debug\" SetCurrentDirectoryA(progPath.c_str()); // Note: setcwd() doesn't seem to work #endif outputPath = progPath + "output/"; // Default output path (can be overridden with -o below) // Parse switches on command line if ((argc == 2) && (strcmp(argv[1], "-h") == 0)) { help(); return 1; } if (argc == 3 && !strcmp(argv[1], "-h") && !strcmp(argv[2], "cmd")) { helpcmd(); return 1; } int kmd = 0; for (int i=1; i < argc; i++) { if (argv[i][0] != '-' && i == argc - 1) break; if (argv[i][0] != '-') usage(); switch (argv[i][1]) { case '-': break; // No effect: ignored case 'h': help(); break; case 'v': vFlag = true; break; case 'x': dumpXML = true; break; case 'X': experimental = true; std::cout << "Warning: experimental code active!\n"; break; case 'r': printRtl = true; break; case 't': traceDecoder = true; break; case 'T': if (argv[i][2] == 'c') { conTypeAnalysis = true; // -Tc: use old constraint-based type analysis dfaTypeAnalysis = false; } else if (argv[i][2] == 'd') dfaTypeAnalysis = true; // -Td: use data-flow-based type analysis (now default) break; case 'g': if(argv[i][2]=='d') dotFile = argv[++i]; else if(argv[i][2]=='c') generateCallGraph=true; else if(argv[i][2]=='s') { generateSymbols=true; stopBeforeDecompile=true; } break; case 'o': { outputPath = argv[++i]; char lastCh = outputPath[outputPath.size()-1]; if (lastCh != '/' && lastCh != '\\') outputPath += '/'; // Maintain the convention of a trailing slash break; } case 'p': if (argv[i][2] == 'a') { propOnlyToAll = true; std::cerr << " * * Warning! -pa is not implemented yet!\n"; } else { if (++i == argc) { usage(); return 1; } sscanf(argv[i], "%i", &numToPropagate); } break; case 'n': switch(argv[i][2]) { case 'b': noBranchSimplify = true; break; case 'c': noDecodeChildren = true; break; case 'd': noDataflow = true; break; case 'D': noDecompile = true; break; case 'l': noLocals = true; break; case 'n': noRemoveNull = true; break; case 'P': noPromote = true; break; case 'p': noParameterNames = true; break; case 'r': noRemoveLabels = true; break; case 'R': noRemoveReturns = true; break; case 'g': noGlobals = true; break; case 'G': #ifndef NO_GARBAGE_COLLECTOR GC_disable(); #endif break; default: help(); } break; case 'E': noDecodeChildren = true; // Fall through case 'e': { ADDRESS addr; int n; decodeMain = false; if (++i == argc) { usage(); return 1; } if (argv[i][0] == '0' && argv[i+1][1] == 'x') { n = sscanf(argv[i], "0x%x", &addr); } else { n = sscanf(argv[i], "%i", &addr); } if (n != 1) { std::cerr << "bad address: " << argv[i] << std::endl; exit(1); } entrypoints.push_back(addr); } break; case 's': { if (argv[i][2] == 'f') { symbolFiles.push_back(argv[i+1]); i++; break; } ADDRESS addr; int n; if (++i == argc) { usage(); return 1; } if (argv[i][0] == '0' && argv[i+1][1] == 'x') { n = sscanf(argv[i], "0x%x", &addr); } else { n = sscanf(argv[i], "%i", &addr); } if (n != 1) { std::cerr << "bad address: " << argv[i+1] << std::endl; exit(1); } const char *nam = argv[++i]; symbols[addr] = nam; } break; case 'd': switch(argv[i][2]) { case 'a': printAST = true; break; case 'c': debugSwitch = true; break; case 'd': debugDecoder = true; break; case 'g': debugGen = true; break; case 'l': debugLiveness = true; break; case 'p': debugProof = true; break; case 's': stopAtDebugPoints = true; break; case 't': // debug type analysis debugTA = true; break; case 'u': // debug unused locations (including returns and parameters now) debugUnused = true; break; default: help(); } break; case 'm': if (++i == argc) { usage(); return 1; } sscanf(argv[i], "%i", &maxMemDepth); break; case 'i': if (argv[i][2] == 'c') decodeThruIndCall = true; // -ic; if (argv[i][2] == 'w') // -iw if (ofsIndCallReport) { std::string fname = getOutputPath() + "indirect.txt"; ofsIndCallReport = new std::ofstream(fname.c_str()); } break; case 'L': if (argv[i][2] == 'D') #if USE_XML loadBeforeDecompile = true; #else std::cerr << "LD command not enabled since compiled without USE_XML\n"; #endif break; case 'S': if (argv[i][2] == 'D') #if USE_XML saveBeforeDecompile = true; #else std::cerr << "SD command not enabled since compiled without USE_XML\n"; #endif else { sscanf(argv[++i], "%i", &minsToStopAfter); } break; case 'k': kmd = 1; break; case 'P': progPath = argv[++i]; if (progPath[progPath.length()-1] != '\\') progPath += "\\"; break; case 'a': assumeABI = true; break; case 'l': if (++i == argc) { usage(); return 1; } sscanf(argv[i], "%i", &propMaxDepth); break; default: help(); } }