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 "core/Settings.hxx"
21 #include "disassembler/llvm/LLVMDisassembler.hxx"
24 int main(int argc
, char** argv
)
26 QApplication
app(argc
, argv
);
28 log4cxx::BasicConfigurator::configure();
29 log4cxx::LoggerPtr
_logger(log4cxx::Logger::getLogger("main"));
32 QCommandLineParser parser
;
35 QApplication::setApplicationName("frida");
36 QApplication::setApplicationVersion("0.0");
37 QApplication::addLibraryPath(CONFIG_LIBDIR
"/frida/plugins/Interpreter");
39 parser
.addHelpOption();
40 parser
.addVersionOption();
42 QCommandLineOption
loglevelOption("loglevel", "Control verbosity of logging", "FATAL|ERROR|WARN|INFO|DEBUG|TRACE");
43 loglevelOption
.setDefaultValue("INFO");
44 parser
.addOption(loglevelOption
);
46 parser
.addPositionalArgument("filename", QCoreApplication::translate("main", "File to disassemble."));
51 log4cxx::LevelPtr level
= log4cxx::Level::getInfo();
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();
69 log4cxx::Logger::getRootLogger()->setLevel(level
);
72 InformationManager iman
;
74 LOG4CXX_DEBUG(_logger
, "Initializing LLVM");
75 llvm::InitializeAllTargetInfos();
76 llvm::InitializeAllTargetMCs();
77 llvm::InitializeAllAsmParsers();
78 llvm::InitializeAllDisassemblers();
80 LOG4CXX_DEBUG(_logger
, "Initializing Qt");
82 std::string filename
= "";
84 if (! parser
.positionalArguments().isEmpty()) {
85 filename
= parser
.positionalArguments().at(0).toStdString();