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>");
41 qRegisterMetaType
<uint64_t>("uint64_t");
43 parser
.addHelpOption();
44 parser
.addVersionOption();
46 QCommandLineOption
loglevelOption("loglevel", "Control verbosity of logging", "FATAL|ERROR|WARN|INFO|DEBUG|TRACE");
47 loglevelOption
.setDefaultValue("INFO");
48 parser
.addOption(loglevelOption
);
50 parser
.addPositionalArgument("filename", QCoreApplication::translate("main", "File to disassemble."));
55 log4cxx::LevelPtr level
= log4cxx::Level::getInfo();
57 if (parser
.value(loglevelOption
) != "") {
58 std::string levelstring
= parser
.value(loglevelOption
).toStdString();
59 if (levelstring
== "FATAL")
60 level
= log4cxx::Level::getFatal();
61 if (levelstring
== "ERROR")
62 level
= log4cxx::Level::getError();
63 if (levelstring
== "WARN")
64 level
= log4cxx::Level::getWarn();
65 if (levelstring
== "INFO")
66 level
= log4cxx::Level::getInfo();
67 if (levelstring
== "DEBUG")
68 level
= log4cxx::Level::getDebug();
69 if (levelstring
== "TRACE")
70 level
= log4cxx::Level::getTrace();
73 log4cxx::Logger::getRootLogger()->setLevel(level
);
76 InformationManager iman
;
78 LOG4CXX_DEBUG(_logger
, "Initializing LLVM");
79 llvm::InitializeAllTargetInfos();
80 llvm::InitializeAllTargetMCs();
81 llvm::InitializeAllAsmParsers();
82 llvm::InitializeAllDisassemblers();
84 LOG4CXX_DEBUG(_logger
, "Initializing Qt");
86 std::string filename
= "";
88 if (! parser
.positionalArguments().isEmpty()) {
89 filename
= parser
.positionalArguments().at(0).toStdString();