diff options
| author | bloodstalker <thabogre@gmail.com> | 2017-04-30 07:06:41 +0000 | 
|---|---|---|
| committer | bloodstalker <thabogre@gmail.com> | 2017-04-30 07:06:41 +0000 | 
| commit | a16260d14500493546ef519a0603071caa0c82bd (patch) | |
| tree | 24a90482cf17ce7fc886fd3a7404d351c4eb05e0 | |
| parent | added type inferencing from function parameter passing (diff) | |
| download | mutator-a16260d14500493546ef519a0603071caa0c82bd.tar.gz mutator-a16260d14500493546ef519a0603071caa0c82bd.zip | |
added some excuse of a shell functionality
| -rw-r--r-- | bruiser/bruiser.cpp | 118 | 
1 files changed, 94 insertions, 24 deletions
| diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp index 4ab1307..fbf5935 100644 --- a/bruiser/bruiser.cpp +++ b/bruiser/bruiser.cpp @@ -39,6 +39,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.*  #include "clang/Rewrite/Core/Rewriter.h"  #include "llvm/Support/raw_ostream.h"  #include "llvm/IR/Function.h" +/*other*/ +#include "ncurses/curses.h"  /**********************************************************************************************************************/  /*used namespaces*/  using namespace llvm; @@ -47,6 +49,11 @@ using namespace clang::ast_matchers;  using namespace clang::driver;  using namespace clang::tooling;  /**********************************************************************************************************************/ +#define __DBG_1 +#if 0 +#undef __DBG_1 +#endif +/**********************************************************************************************************************/  /*global vars*/  static llvm::cl::OptionCategory BruiserCategory("Empty"); @@ -189,7 +196,7 @@ class IfBreaker : public MatchFinder::MatchCallback          const ast_type_traits::DynTypedNode DynNode = ast_type_traits::DynTypedNode::create<clang::Expr>(*EXP);          bruiser::TypeInfo TIProto(&DynNode); -        const clang::Type* CTP = TIProto.getTypeInfo(MR.Context); +        const clang::Type* CTP [[maybe_unused]] = TIProto.getTypeInfo(MR.Context);          NameFinder::runDeclRefExprMatcher DRENameMatcher(Rewrite); @@ -214,8 +221,8 @@ class IfBreaker : public MatchFinder::MatchCallback          const clang::Type* LTP = LQT.getTypePtr();          const clang::Type* RTP = RQT.getTypePtr(); -        const clang::Type* CLTP = MR.Context->getCanonicalType(LTP); -        const clang::Type* CRTP = MR.Context->getCanonicalType(RTP); +        const clang::Type* CLTP [[maybe_unused]] = MR.Context->getCanonicalType(LTP); +        const clang::Type* CRTP [[maybe_unused]] = MR.Context->getCanonicalType(RTP);        }      } @@ -313,34 +320,97 @@ private:  /*Main*/  int main(int argc, const char **argv)   { -  CommonOptionsParser op(argc, argv, BruiserCategory); -  ClangTool Tool(op.getCompilations(), op.getSourcePathList()); +  int RunResult; +  bruiser::ShellHistory shHistory; +  int InKey; -  int RunResult = Tool.run(newFrontendActionFactory<BruiserFrontendAction>().get()); +  { +    char command[130]; +    while(true) +    { +      std::cout << ">>"; +      InKey = getch(); +      std::cin.getline(command, sizeof(command)); +      shHistory.History.push_back(command); +#if defined(__DBG_1) +      std::cout << shHistory.History.size() << "\n"; +      std::cout << shHistory.History.capacity() << "\n"; +#endif + +      if (InKey == KEY_UP) +      { +        //std::cout << shHistory.History[]; +        std::cout << "caught key_up"; +      } +      else if(InKey == KEY_DOWN) +      { +        std::cout << "caught key_down"; +      } -  BruiseRep.PrintToLog("bruiser exited with:"); -  BruiseRep.PrintToLog(RunResult); +      if (std::strcmp(command, "exit") == 0 || std::strcmp(command, "quit") == 0) +      { +        return 0; +        continue; +      } -  bruiser::ReadM0 M0Rep; -  tinyxml2::XMLError XMLErr; +      if (std::strcmp(command, "m0") == 0) +      { +        BruiseRep.PrintToLog("bruiser exited with:"); +        BruiseRep.PrintToLog(RunResult); -  XMLErr = M0Rep.LoadXMLDoc(); -  if (XMLErr != XML_SUCCESS) -  { -    std::cerr << "could not load m0 xml report.\n"; -    return XMLErr; -  } +        bruiser::ReadM0 M0Rep; +        tinyxml2::XMLError XMLErr; -  XMLErr = M0Rep.ReadFirstElement(); -  if (XMLErr != XML_SUCCESS) -  { -    std::cerr << "could not read first element of m0 xml report.\n"; -    return 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; +        } -  bruiser::SearchM0(M0Rep.getRootPointer()); +        XMLErr = M0Rep.ReadFirstElement(); +        if (XMLErr != XML_SUCCESS) +        { +          std::cerr << RED << "could not read first element of m0 xml report.\n" << NORMAL; +          return XMLErr; +        } -  return RunResult; +        bruiser::SearchM0(M0Rep.getRootPointer()); +        continue; +      } + +      if (std::strcmp(command, "hijack main") == 0) +      { +        CommonOptionsParser op(argc, argv, BruiserCategory); +        ClangTool Tool(op.getCompilations(), op.getSourcePathList()); + +        RunResult = Tool.run(newFrontendActionFactory<BruiserFrontendAction>().get()); +        std::cout << CYAN <<"hijacking main returned " << RunResult << "\n"; +        continue; +      } + +      if (std::strcmp(command, "clear") == 0) +      { +        std::cout << CLEAR; +        continue; +      } + +      if (std::strcmp(command, "shell") == 0) +      { +        system("bash -t"); +        continue; +      } + +      if (std::strcmp(command, "help") == 0) +      { +        std::cout << BROWN << "not implemented yet.\n" << NORMAL; +        continue; +      } + +      std::cout << RED << "unknown command. run help.\n" << NORMAL; +    } +  }  }  /*last line interntionally left blank.*/ | 
