1 #include "disassembler/llvm/include_llvm.hxx"
5 #include <QApplication>
6 #if QT_VERSION > QT_VERSION_CHECK(5, 2, 0)
11 #include <QCommandLineParser>
17 #include "log4cxx/logger.h"
18 #include "log4cxx/basicconfigurator.h"
20 #include "gui/Mainwindow.hxx"
21 #include "core/InformationManager.hxx"
22 #include "core/Settings.hxx"
23 #include "disassembler/llvm/LLVMDisassembler.hxx"
26 int main(int argc
, char** argv
)
28 QApplication
app(argc
, argv
);
30 log4cxx::BasicConfigurator::configure();
31 log4cxx::LoggerPtr
_logger(log4cxx::Logger::getLogger("main"));
34 QCommandLineParser parser
;
37 QApplication::setApplicationName("frida");
38 QApplication::setApplicationVersion("0.2+");
39 QApplication::addLibraryPath(CONFIG_LIBDIR
"/frida/plugins/Interpreter");
40 qRegisterMetaType
<QVector
<int> >("QVector<int>");
42 parser
.addHelpOption();
43 parser
.addVersionOption();
45 QCommandLineOption
loglevelOption("loglevel", "Control verbosity of logging", "FATAL|ERROR|WARN|INFO|DEBUG|TRACE");
46 loglevelOption
.setDefaultValue("INFO");
47 parser
.addOption(loglevelOption
);
49 parser
.addPositionalArgument("filename", QCoreApplication::translate("main", "File to disassemble."));
54 log4cxx::LevelPtr level
= log4cxx::Level::getInfo();
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();
72 log4cxx::Logger::getRootLogger()->setLevel(level
);
75 InformationManager iman
;
77 LOG4CXX_DEBUG(_logger
, "Initializing LLVM");
78 llvm::InitializeAllTargetInfos();
79 llvm::InitializeAllTargetMCs();
80 llvm::InitializeAllAsmParsers();
81 llvm::InitializeAllDisassemblers();
83 LOG4CXX_DEBUG(_logger
, "Initializing Qt");
85 std::string filename
= "";
87 if (! parser
.positionalArguments().isEmpty()) {
88 filename
= parser
.positionalArguments().at(0).toStdString();