]> git.siccegge.de Git - frida/frida.git/blob - src/main.cxx
Add settings Class
[frida/frida.git] / src / main.cxx
1 #include "disassembler/llvm/include_llvm.hxx"
2
3 #include <climits>
4
5 #include <QApplication>
6 #if QT_VERSION > QT_VERSION_CHECK(5, 2, 0)
7 #define ARGPARSE
8 #endif
9
10 #ifdef ARGPARSE
11 #include <QCommandLineParser>
12 #endif
13 #include <QTextEdit>
14
15 #include "log4cxx/logger.h"
16 #include "log4cxx/basicconfigurator.h"
17
18 #include "gui/Mainwindow.hxx"
19 #include "core/InformationManager.hxx"
20 #include "core/Settings.hxx"
21 #include "disassembler/llvm/LLVMDisassembler.hxx"
22 #include "Config.hxx"
23
24 int main(int argc, char** argv)
25 {
26 QApplication app(argc, argv);
27
28 log4cxx::BasicConfigurator::configure();
29 log4cxx::LoggerPtr _logger(log4cxx::Logger::getLogger("main"));
30
31 #ifdef ARGPARSE
32 QCommandLineParser parser;
33 #endif
34
35 QApplication::setApplicationName("frida");
36 QApplication::setApplicationVersion("0.0");
37 QApplication::addLibraryPath(CONFIG_LIBDIR "/frida/plugins/Interpreter");
38 #ifdef ARGPARSE
39 parser.addHelpOption();
40 parser.addVersionOption();
41
42 QCommandLineOption loglevelOption("loglevel", "Control verbosity of logging", "FATAL|ERROR|WARN|INFO|DEBUG|TRACE");
43 loglevelOption.setDefaultValue("INFO");
44 parser.addOption(loglevelOption);
45
46 parser.addPositionalArgument("filename", QCoreApplication::translate("main", "File to disassemble."));
47
48 parser.process(app);
49 #endif
50
51 log4cxx::LevelPtr level = log4cxx::Level::getInfo();
52 #ifdef ARGPARSE
53 if (parser.value(loglevelOption) != "") {
54 std::string levelstring = parser.value(loglevelOption).toStdString();
55 if (levelstring == "FATAL")
56 level = log4cxx::Level::getFatal();
57 if (levelstring == "ERROR")
58 level = log4cxx::Level::getError();
59 if (levelstring == "WARN")
60 level = log4cxx::Level::getWarn();
61 if (levelstring == "INFO")
62 level = log4cxx::Level::getInfo();
63 if (levelstring == "DEBUG")
64 level = log4cxx::Level::getDebug();
65 if (levelstring == "TRACE")
66 level = log4cxx::Level::getTrace();
67 }
68 #endif
69 log4cxx::Logger::getRootLogger()->setLevel(level);
70
71 Settings settings;
72 InformationManager iman;
73
74 LOG4CXX_DEBUG(_logger, "Initializing LLVM");
75 llvm::InitializeAllTargetInfos();
76 llvm::InitializeAllTargetMCs();
77 llvm::InitializeAllAsmParsers();
78 llvm::InitializeAllDisassemblers();
79
80 LOG4CXX_DEBUG(_logger, "Initializing Qt");
81
82 std::string filename = "";
83 #ifdef ARGPARSE
84 if (! parser.positionalArguments().isEmpty()) {
85 filename = parser.positionalArguments().at(0).toStdString();
86 }
87 #endif
88
89 Mainwindow m(&iman);
90 m.show();
91 iman.reset(filename);
92 return app.exec();
93 }