]> git.siccegge.de Git - frida/frida.git/blob - src/core/InformationManager.cxx
Move Function/BasicBlock to core and clean up includes
[frida/frida.git] / src / core / InformationManager.cxx
1 #include "InformationManager.hxx"
2 #include "disassembler/llvm/LLVMDisassembler.hxx"
3 #include "core/Function.hxx"
4 #include "core/BasicBlock.hxx"
5
6 #include "gui/qt.hxx"
7 #include <quazip/quazip.h>
8 #include <quazip/quazipfile.h>
9
10 void InformationManager::reset(const std::string& filename) {
11 disassembler.reset(createLLVMDisassembler(filename, this));
12 if (disassembler.get() != NULL)
13 disassembler.get()->start();
14 }
15
16 void InformationManager::save(const QString& filename) {
17 QuaZip zip(filename);
18 zip.open(QuaZip::mdCreate);
19 zip.setComment("FRIDA 0.0");
20 QuaZipFile outZipFile(&zip);
21
22 for (Function* fun : functions) {
23 QuaZipNewInfo zipinfo(fun->getName().c_str());
24 zipinfo.setPermissions(static_cast<QFile::Permissions>(0x6444));
25 outZipFile.open(QIODevice::WriteOnly, zipinfo);
26 QXmlStreamWriter stream(&outZipFile);
27 stream.setAutoFormatting(true);
28 stream.setAutoFormattingIndent(-1);
29 stream.writeStartDocument();
30 stream.writeStartElement("function");
31 stream.writeAttribute("name", fun->getName().c_str());
32 stream.writeAttribute("entry", QString::number(fun->getStartAddress(), 16));
33
34 for (auto& blockentry : fun->blocks()) {
35 stream.writeStartElement("block");
36 stream.writeAttribute("id", blockentry.second->getName().c_str());
37 stream.writeTextElement("start", QString::number(blockentry.second->getStartAddress(), 16));
38 stream.writeTextElement("end", QString::number(blockentry.second->getEndAddress(), 16));
39 if (0 != blockentry.second->getNextBlock(0))
40 stream.writeTextElement("next", QString::number(blockentry.second->getNextBlock(0), 16));
41 if (0 != blockentry.second->getNextBlock(1))
42 stream.writeTextElement("next", QString::number(blockentry.second->getNextBlock(1), 16));
43 stream.writeEndElement(); // "block"
44 }
45
46 stream.writeEndElement(); // "function"
47 stream.writeEndDocument();
48 outZipFile.close();
49 }
50
51 zip.close();
52 }