1 #include "disassembler/llvm/include_llvm.hxx"
5 #include <QApplication>
6 #if QT_VERSION > QT_VERSION_CHECK(5, 2, 0)
11 #include <QCommandLineParser>
15 #include "log4cxx/logger.h"
16 #include "log4cxx/basicconfigurator.h"
18 #include "gui/Mainwindow.hxx"
19 #include "core/InformationManager.hxx"
20 #include "disassembler/llvm/LLVMDisassembler.hxx"
23 int main(int argc
, char** argv
)
25 QApplication
app(argc
, argv
);
27 log4cxx::BasicConfigurator::configure();
28 log4cxx::LoggerPtr
_logger(log4cxx::Logger::getLogger("main"));
31 QCommandLineParser parser
;
34 QApplication::setApplicationName("frida");
35 QApplication::setApplicationVersion("0.0");
36 QApplication::addLibraryPath(CONFIG_LIBDIR
"/frida/plugins/Interpreter");
38 parser
.addHelpOption();
39 parser
.addVersionOption();
41 QCommandLineOption
loglevelOption("loglevel", "Control verbosity of logging", "FATAL|ERROR|WARN|INFO|DEBUG|TRACE");
42 loglevelOption
.setDefaultValue("INFO");
43 parser
.addOption(loglevelOption
);
45 parser
.addPositionalArgument("filename", QCoreApplication::translate("main", "File to disassemble."));
50 log4cxx::LevelPtr level
= log4cxx::Level::getInfo();
52 if (parser
.value(loglevelOption
) != "") {
53 std::string levelstring
= parser
.value(loglevelOption
).toStdString();
54 if (levelstring
== "FATAL")
55 level
= log4cxx::Level::getFatal();
56 if (levelstring
== "ERROR")
57 level
= log4cxx::Level::getError();
58 if (levelstring
== "WARN")
59 level
= log4cxx::Level::getWarn();
60 if (levelstring
== "INFO")
61 level
= log4cxx::Level::getInfo();
62 if (levelstring
== "DEBUG")
63 level
= log4cxx::Level::getDebug();
64 if (levelstring
== "TRACE")
65 level
= log4cxx::Level::getTrace();
68 log4cxx::Logger::getRootLogger()->setLevel(level
);
70 InformationManager iman
;
72 LOG4CXX_DEBUG(_logger
, "Initializing LLVM");
73 llvm::InitializeAllTargetInfos();
74 llvm::InitializeAllTargetMCs();
75 llvm::InitializeAllAsmParsers();
76 llvm::InitializeAllDisassemblers();
78 LOG4CXX_DEBUG(_logger
, "Initializing Qt");
80 std::string filename
= "";
82 if (! parser
.positionalArguments().isEmpty()) {
83 filename
= parser
.positionalArguments().at(0).toStdString();