]>
git.siccegge.de Git - frida/frida.git/blob - src/core/Function.cxx
1 #include "Function.hxx"
2 #include "BasicBlock.hxx"
3 #include "core/events/RenameFunctionEvent.hxx"
4 #include "InformationManager.hxx"
7 Function::Function(uint64_t start_address
, bool dynamic
, InformationManager
* manager
)
8 : start_address(start_address
)
13 void Function::setName(const std::string
& new_name
) {
15 RenameFunctionEvent
event(new_name
, this, start_address
);
16 Q_EMIT manager
->renameFunctionEvent(&event
);
19 void Function::serialize(QXmlStreamWriter
& stream
) {
20 stream
.writeStartElement("function");
21 stream
.writeAttribute("name", getName().c_str());
22 stream
.writeAttribute("entry", QString::number(getStartAddress(), 16));
23 stream
.writeAttribute("dynamic", dynamic
? "yes" : "no");
25 for (auto& blockentry
: blocks()) {
26 blockentry
.second
->serialize(stream
);
29 stream
.writeEndElement(); // "function"
32 Function
* Function::deserialize(QXmlStreamReader
& stream
, InformationManager
* manager
) {
33 Q_ASSERT(stream
.name() == "function");
35 QString name
= stream
.attributes().value("name").toString();
36 bool dynamic
= stream
.attributes().value("dynamic").toString() == "yes";
37 uint64_t entry
= stream
.attributes().value("entry").toULongLong(NULL
, 16);
38 Function
* fun
= manager
->newFunction(entry
);
40 while (QXmlStreamReader::NoToken
!= stream
.readNext()) {
41 while (QXmlStreamReader::Characters
== stream
.tokenType() &&
42 stream
.isWhitespace())
44 if (QXmlStreamReader::EndElement
== stream
.tokenType())
47 if (stream
.name() == "block") {
48 BasicBlock
* block
= BasicBlock::deserialize(stream
, manager
);
49 fun
->addBasicBlock(block
);
55 fun
->name
= name
.toStdString();
56 fun
->dynamic
= dynamic
;
57 manager
->finishFunction(fun
);