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