aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser
diff options
context:
space:
mode:
Diffstat (limited to 'bruiser')
m---------bruiser/LuaJIT0
-rw-r--r--bruiser/bruiser.cpp245
2 files changed, 2 insertions, 243 deletions
diff --git a/bruiser/LuaJIT b/bruiser/LuaJIT
new file mode 160000
+Subproject 630ff3196a06353c6a7ccd1e9ac3958f4a8ca13
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp
index 12cbea0..d9c0f66 100644
--- a/bruiser/bruiser.cpp
+++ b/bruiser/bruiser.cpp
@@ -924,6 +924,7 @@ class LuaWrapper
#define LIST_GENERATOR(__x1) \
int List##__x1(lua_State* __ls)\
{\
+ assert(PushToLua.size() == 0);\
unsigned int InArgCnt = 0U;\
InArgCnt = lua_gettop(__ls);\
unsigned int returncount=0U;\
@@ -979,20 +980,6 @@ int LuaDispatch(lua_State* __ls)
/*Main*/
int main(int argc, const char **argv)
{
- int RunResult;
- bruiser::ShellHistory shHistory;
-
- std::regex listcommand("^list\\s");
- std::regex listfuncs("^list\\sfuncs$");
- std::regex listvars("^list\\svars$");
- std::regex listarrays("^list\\sarrays$");
- std::regex listrecords("^list\\srecords$");
- std::regex listclasses("^list\\sclasses$");
- std::regex liststructs("^list\\sstructs$$");
- std::regex listunions("^list\\sunions$$");
- std::regex dumplist("^list\\sdump\\s");
- std::smatch smresult;
-
/*gets the compilation database and options for the clang instances that we would later run*/
CommonOptionsParser op(argc, argv, BruiserCategory);
ClangTool Tool(op.getCompilations(), op.getSourcePathList());
@@ -1034,238 +1021,10 @@ int main(int argc, const char **argv)
linenoiseHistoryAdd(command);
linenoiseHistorySave(SHELL_HISTORY_FILE);
LE.RunChunk(command);
+ linenoiseFree(command);
}
/*end of bruiser main*/
-
- while((command = linenoise("bruiser>>")) != NULL)
- {
- linenoiseHistoryAdd(command);
- linenoiseHistorySave(SHELL_HISTORY_FILE);
-
- std::string dummy_string(command);
-
- shHistory.History.push_back(command);
-
- if (std::regex_search(dummy_string, smresult, listcommand))
- {
- if (std::regex_search(dummy_string, smresult, listfuncs))
- {
- RunResult = Tool.run(newFrontendActionFactory<LiveActionListFuncs>().get());
- continue;
- }
-
- if (std::regex_search(dummy_string, smresult, listvars))
- {
- RunResult = Tool.run(newFrontendActionFactory<LiveActionListVars>().get());
- continue;
- }
-
- if (std::regex_search(dummy_string, smresult, listarrays))
- {
- RunResult = Tool.run(newFrontendActionFactory<LiveActionListArrays>().get());
- continue;
- }
-
- if (std::regex_search(dummy_string, smresult, listclasses))
- {
- RunResult = Tool.run(newFrontendActionFactory<LiveActionListClasses>().get());
- continue;
- }
-
- if (std::regex_search(dummy_string, smresult, liststructs))
- {
- RunResult = Tool.run(newFrontendActionFactory<LiveActionListStructs>().get());
- continue;
- }
-
- if (std::regex_search(dummy_string, smresult, listunions))
- {
- RunResult = Tool.run(newFrontendActionFactory<LiveActionListUnions>().get());
- continue;
- }
-
- if (std::regex_search(dummy_string, smresult, listrecords))
- {
- NOT_IMPLEMENTED;
- continue;
- }
- }
-
- if (std::strcmp(command, "exit") == 0 || std::strcmp(command, "quit") == 0)
- {
- return 0;
- }
-
- if (std::strcmp(command, "m0") == 0)
- {
- BruiseRep.PrintToLog("bruiser exited with:");
- BruiseRep.PrintToLog(RunResult);
-
- bruiser::ReadM0 M0Rep;
- tinyxml2::XMLError XMLErr;
-
- XMLErr = M0Rep.LoadXMLDoc();
- if (XMLErr != XML_SUCCESS)
- {
- std::cout << RED << "could not load m0 xml report.\n" << NORMAL;
- std::cout << RED << "tinyxml2 returned " << XMLErr << NORMAL;
- return XMLErr;
- }
-
- XMLErr = M0Rep.ReadFirstElement();
- if (XMLErr != XML_SUCCESS)
- {
- std::cerr << RED << "could not read first element of m0 xml report.\n" << NORMAL;
- return XMLErr;
- }
-
- bruiser::SearchM0(M0Rep.getRootPointer());
- continue;
- }
-
- if (std::strcmp(command, "hijack main") == 0)
- {
-
- RunResult = Tool.run(newFrontendActionFactory<BruiserFrontendAction>().get());
- //std::cout << CYAN <<"hijacking main returned " << RunResult << "\n" << NORMAL;
- printf(CYAN"hijacking main returned %d", RunResult);
- printf(NORMAL"\n");
- continue;
- }
-
- if (std::strcmp(command, "list") == 0)
- {
-
- }
-
- if (std::strcmp(command, "clear") == 0)
- {
- linenoiseClearScreen();
- //std::cout << CLEAR;
- continue;
- }
-
- if (std::strcmp(command, "shell") == 0)
- {
- system("bash -i");
- continue;
- }
-
- if (std::strcmp(command, "help") == 0)
- {
-
- for (auto &iter : bruiser::CMDHelp)
- {
- printf(GREEN"%s:%s:%s",iter.name.c_str(),iter.proto.c_str(),iter.descr.c_str());
- printf(NORMAL"\n");
- }
-
- std::cout << NORMAL;
-
- continue;
- }
-
- if (std::strcmp(command, "history") == 0)
- {
- std::ifstream historyfile;
- historyfile.open(SHELL_HISTORY_FILE);
-
- std::string tempstring;
- unsigned int tempint = 0;
- while(std::getline(historyfile, tempstring))
- {
- printf(GREEN"%d - %s", tempint, tempstring.c_str());
- printf(NORMAL"\n");
-
- tempint++;
- }
-
- continue;
- }
-
- if (std::strcmp(command, "version") == 0)
- {
- PRINT_WITH_COLOR_LB(GREEN, "bruiser experimental version something.");
- PRINT_WITH_COLOR_LB(GREEN, "project mutator");
- PRINT_WITH_COLOR_LB(GREEN, "GPL v2.0");
- PRINT_WITH_COLOR_LB(GREEN, "bloodstalker 2017");
- continue;
- }
-
- if (std::strcmp(command, "runlua") == 0)
- {
- LuaEngine LE;
- LE.LoadEverylib();
- LE.Test();
- //LE.Cleanup();
- continue;
- }
-
-#if 1
- if (std::strcmp(command, "runluachain1") == 0)
- {
- LuaEngine LE;
- LE.LoadEverylib();
- LE.Test2();
- //LE.Cleanup();
- continue;
- }
-
- if (std::strcmp(command, "runluachain2") == 0)
- {
- LuaEngine LE;
- LE.LoadEverylib();
- LE.Test3();
- //LE.Cleanup();
- continue;
- }
-#endif
-
- if (command[0] == '!')
- {
- /*FIXME*/
- std::string cut_string;
- unsigned int command_number;
- cut_string = dummy_string.substr(1, dummy_string.length());
- command_number = std::stoi(cut_string, 0, 10);
-
- if (command_number > SHELL_HISTORY_SIZE - 1)
- {
- PRINT_WITH_COLOR_LB(RED, "the command number provided is bigger than SHELL_HISTORY_SIZE");
- }
- else
- {
- std::ifstream historyfile;
- historyfile.open(SHELL_HISTORY_FILE);
- std::string tempstring;
- unsigned int tempint = 0;
-
- while(std::getline(historyfile, tempstring))
- {
- if (tempint == command_number)
- {
- PRINT_WITH_COLOR_LB(NORMAL, tempstring.c_str());
- break;
- }
-
- tempint++;
- }
- }
-
- continue;
- }
-
- if (command != NULL)
- {
- printf(BLUE"unknown command. run help" NORMAL "\n");
- //PRINT_WITH_COLOR_LB(BLUE, "unknown command. run help");
- //std::cout << RED << "unknown command. run help.\n" << NORMAL;
- }
-
- linenoiseFree(command);
- } // end of while
-
return 0;
} //end of cli block