]>
git.siccegge.de Git - frida/frida.git/blob - core/InformationManager.cxx
1 #include "InformationManager.hxx"
2 #include "disassembler/llvm/LLVMDisassembler.hxx"
3 #include "core/Function.hxx"
4 #include "core/BasicBlock.hxx"
7 #include <quazip/quazip.h>
8 #include <quazip/quazipfile.h>
10 InformationManager::~InformationManager() {
11 for (BasicBlock
* b
: blocks
)
14 for (Function
* f
: functions
)
18 void InformationManager::reset(const std::string
& filename
) {
19 disassembler
.reset(createLLVMDisassembler(filename
, this));
20 if (disassembler
.get() != NULL
)
21 disassembler
.get()->start();
24 void InformationManager::save(const QString
& filename
) {
26 zip
.open(QuaZip::mdCreate
);
27 zip
.setComment("FRIDA 0.0");
28 QuaZipFile
outZipFile(&zip
);
30 for (Function
* fun
: functions
) {
31 QuaZipNewInfo
zipinfo(fun
->getName().c_str());
32 zipinfo
.setPermissions(static_cast<QFile::Permissions
>(0x6444));
33 outZipFile
.open(QIODevice::WriteOnly
, zipinfo
);
34 QXmlStreamWriter
stream(&outZipFile
);
35 stream
.setAutoFormatting(true);
36 stream
.setAutoFormattingIndent(-1);
37 stream
.writeStartDocument();
38 stream
.writeStartElement("function");
39 stream
.writeAttribute("name", fun
->getName().c_str());
40 stream
.writeAttribute("entry", QString::number(fun
->getStartAddress(), 16));
42 for (auto& blockentry
: fun
->blocks()) {
43 stream
.writeStartElement("block");
44 stream
.writeAttribute("id", blockentry
.second
->getName().c_str());
45 stream
.writeTextElement("start", QString::number(blockentry
.second
->getStartAddress(), 16));
46 stream
.writeTextElement("end", QString::number(blockentry
.second
->getEndAddress(), 16));
47 if (0 != blockentry
.second
->getNextBlock(0))
48 stream
.writeTextElement("next", QString::number(blockentry
.second
->getNextBlock(0), 16));
49 if (0 != blockentry
.second
->getNextBlock(1))
50 stream
.writeTextElement("next", QString::number(blockentry
.second
->getNextBlock(1), 16));
51 stream
.writeEndElement(); // "block"
54 stream
.writeEndElement(); // "function"
55 stream
.writeEndDocument();
62 void InformationManager::signal_new_function(Function
* fun
) {
63 functions
.insert(fun
);
64 for (auto b
: fun
->blocks())
65 blocks
.insert(b
.second
);
66 new_function_signal(fun
);