X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fmain.cxx;h=24ddf7a2ad24aca695601d0d6b8d0906b4a5350e;hp=ec768919f111040e48e6e05f4875afd3760ee831;hb=fd85e36ca37c93139dc7bf8d06cf71bc5a225321;hpb=988726af7276c31122cd2e27adae87aa8b4049ad diff --git a/src/main.cxx b/src/main.cxx index ec76891..24ddf7a 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -1,23 +1,91 @@ -#include "include.hxx" +#include "disassembler/llvm/include_llvm.hxx" -#include #include -#include "Binary.hxx" +#include +#if QT_VERSION > QT_VERSION_CHECK(5, 2, 0) +#define ARGPARSE +#endif -using std::cout; -using std::cin; -using std::cerr; +#ifdef ARGPARSE +#include +#endif +#include + +#include "log4cxx/logger.h" +#include "log4cxx/basicconfigurator.h" + +#include "gui/Mainwindow.hxx" +#include "core/InformationManager.hxx" +#include "disassembler/llvm/LLVMDisassembler.hxx" +#include "Config.hxx" int main(int argc, char** argv) { - llvm::InitializeAllTargetInfos(); - llvm::InitializeAllTargetMCs(); - llvm::InitializeAllAsmParsers(); - llvm::InitializeAllDisassemblers(); + QApplication app(argc, argv); + + log4cxx::BasicConfigurator::configure(); + log4cxx::LoggerPtr _logger(log4cxx::Logger::getLogger("main")); + +#ifdef ARGPARSE + QCommandLineParser parser; +#endif + + QApplication::setApplicationName("frida"); + QApplication::setApplicationVersion("0.0"); + QApplication::addLibraryPath(CONFIG_LIBDIR "/frida/plugins/Interpreter"); +#ifdef ARGPARSE + parser.addHelpOption(); + parser.addVersionOption(); + + QCommandLineOption loglevelOption("loglevel", "Control verbosity of logging", "FATAL|ERROR|WARN|INFO|DEBUG|TRACE"); + loglevelOption.setDefaultValue("INFO"); + parser.addOption(loglevelOption); + + parser.addPositionalArgument("filename", QCoreApplication::translate("main", "File to disassemble.")); + + parser.process(app); +#endif + + log4cxx::LevelPtr level = log4cxx::Level::getInfo(); +#ifdef ARGPARSE + if (parser.value(loglevelOption) != "") { + std::string levelstring = parser.value(loglevelOption).toStdString(); + if (levelstring == "FATAL") + level = log4cxx::Level::getFatal(); + if (levelstring == "ERROR") + level = log4cxx::Level::getError(); + if (levelstring == "WARN") + level = log4cxx::Level::getWarn(); + if (levelstring == "INFO") + level = log4cxx::Level::getInfo(); + if (levelstring == "DEBUG") + level = log4cxx::Level::getDebug(); + if (levelstring == "TRACE") + level = log4cxx::Level::getTrace(); + } +#endif + log4cxx::Logger::getRootLogger()->setLevel(level); + + InformationManager iman; + + LOG4CXX_DEBUG(_logger, "Initializing LLVM"); + llvm::InitializeAllTargetInfos(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllAsmParsers(); + llvm::InitializeAllDisassemblers(); + + LOG4CXX_DEBUG(_logger, "Initializing Qt"); - Binary bin(argv[1]); - bin.disassemble(); + std::string filename = ""; +#ifdef ARGPARSE + if (! parser.positionalArguments().isEmpty()) { + filename = parser.positionalArguments().at(0).toStdString(); + } +#endif - bin.disassemble_functions(); + Mainwindow m(&iman); + m.show(); + iman.reset(filename); + return app.exec(); }