]>
git.siccegge.de Git - frida/frida.git/blob - src/core/BasicBlock.cxx
1 #include "BasicBlock.hxx"
3 #include "core/InformationManager.hxx"
8 void BasicBlock::serialize(QXmlStreamWriter
& stream
) {
9 stream
.writeStartElement("block");
10 stream
.writeAttribute("id", getName().c_str());
11 stream
.writeTextElement("start", QString::number(getStartAddress(), 16));
12 stream
.writeTextElement("end", QString::number(getEndAddress(), 16));
13 if (0 != getNextBlock(0))
14 stream
.writeTextElement("next", QString::number(getNextBlock(0), 16));
15 if (0 != getNextBlock(1))
16 stream
.writeTextElement("next", QString::number(getNextBlock(1), 16));
17 stream
.writeEndElement(); // "block"
20 BasicBlock
* BasicBlock::deserialize(QXmlStreamReader
& stream
, InformationManager
* manager
) {
21 Q_ASSERT(stream
.name() == "block");
23 QString name
= stream
.attributes().value("id").toString();
24 uint64_t start_address(0), end_address(0), next_blocks
[2] = {0, 0};
28 while (QXmlStreamReader::NoToken
!= stream
.readNext()) {
29 while (QXmlStreamReader::Characters
== stream
.tokenType() &&
30 stream
.isWhitespace())
32 if (QXmlStreamReader::EndElement
== stream
.tokenType())
35 if(QXmlStreamReader::StartElement
!= stream
.tokenType())
38 if (stream
.name() == "start") {
40 if (QXmlStreamReader::Characters
!= stream
.tokenType())
43 start_address
= stream
.text().toULongLong(NULL
, 16);
46 if(QXmlStreamReader::EndElement
!= stream
.tokenType())
49 if (stream
.name() == "end") {
51 if (QXmlStreamReader::Characters
!= stream
.tokenType())
54 end_address
= stream
.text().toULongLong(NULL
, 16);
57 if(QXmlStreamReader::EndElement
!= stream
.tokenType())
60 if (stream
.name() == "next") {
62 if (QXmlStreamReader::Characters
!= stream
.tokenType())
65 uint64_t newblock
= stream
.text().toULongLong(NULL
, 16);
68 if (next_blocks
[0] == 0) {
69 next_blocks
[0] = newblock
;
71 if (0 != next_blocks
[1])
73 next_blocks
[1] = newblock
;
76 if(QXmlStreamReader::EndElement
!= stream
.tokenType())
81 block
= manager
->newBasicBlock(start_address
);
82 block
->end_address
= end_address
;
83 block
->next_blocks
[0] = next_blocks
[0];
84 block
->next_blocks
[1] = next_blocks
[1];
86 assert(stream
.name() == "block");
87 assert(block
->getName() == name
.toStdString());
89 manager
->finishBasicBlock(block
);