X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fcore%2FInformationManager.cxx;h=485aacd9868a954b350d5c43a958de71a72c8b75;hp=e1571892349336ab5d0cc94f1d64104d64428d68;hb=3a4fade0292b9b8776c6195467b70a8f25a3b1c7;hpb=546b89382dd61b664c216ad7668ec783f0ad094c diff --git a/src/core/InformationManager.cxx b/src/core/InformationManager.cxx index e157189..485aacd 100644 --- a/src/core/InformationManager.cxx +++ b/src/core/InformationManager.cxx @@ -5,6 +5,7 @@ #include "core/BasicBlock.hxx" #include "core/Comment.hxx" #include "core/events/NewFunctionEvent.hxx" +#include "core/events/ChangeCommentEvent.hxx" #include "gui/qt.hxx" #include @@ -72,10 +73,21 @@ void InformationManager::load(const std::string& filename) { file.open(QIODevice::ReadOnly); if(info.name != "binary") { - QXmlStreamReader reader(&file); - assert(QXmlStreamReader::StartDocument == reader.readNext()); - assert(QXmlStreamReader::StartElement == reader.readNext()); - Function * fun = Function::deserialize(reader, this); + if (info.name.startsWith("comment:")) { + QXmlStreamReader reader(&file); + auto starttoken = reader.readNext(); + auto elementtoken = reader.readNext(); + assert(QXmlStreamReader::StartDocument == starttoken); + assert(QXmlStreamReader::StartElement == elementtoken); + Comment::deserialize(reader, this); + } else { + QXmlStreamReader reader(&file); + auto starttoken = reader.readNext(); + auto elementtoken = reader.readNext(); + assert(QXmlStreamReader::StartDocument == starttoken); + assert(QXmlStreamReader::StartElement == elementtoken); + Function::deserialize(reader, this); + } } file.close(); } @@ -116,6 +128,23 @@ void InformationManager::save(const std::string& filename) { stream.writeEndDocument(); outZipFile.close(); } + for (auto commentpair : comments) { + Comment* comment = commentpair.second; + if (!comment->isLocal()) { + QuaZipNewInfo zipinfo(QString("comment:%1").arg(comment->getAddress(), 0, 16)); + zipinfo.setPermissions(static_cast(0x6444)); + outZipFile.open(QIODevice::WriteOnly, zipinfo); + QXmlStreamWriter stream(&outZipFile); + stream.setAutoFormatting(true); + stream.setAutoFormattingIndent(-1); + stream.writeStartDocument(); + + comment->serialize(stream); + + stream.writeEndDocument(); + outZipFile.close(); + } + } zip.close(); } @@ -160,6 +189,22 @@ std::map::const_iterator InformationManager::endBasicBloc return blocks.end(); } +/* ********************************* + * Accessors for the Comments map + */ +std::pair< + std::multimap::const_iterator, + std::multimap::const_iterator> +InformationManager::getComments(uint64_t address) { + return comments.equal_range(address); +} + +std::multimap::const_iterator InformationManager::beginComments() { + return comments.begin(); +} +std::multimap::const_iterator InformationManager::endComments() { + return comments.end(); +} /* ********************************* * Accessors for the Interpreter map @@ -210,7 +255,7 @@ Comment* InformationManager::newGlobalComment(uint64_t address) { } Comment* InformationManager::newLocalComment(uint64_t address, Function* f) { - Comment* comment = new Comment(address, this); + Comment* comment = new Comment(address, f, this); comments.insert(std::make_pair(address, comment)); return comment; } @@ -228,7 +273,10 @@ void InformationManager::finishFunction(Function* fun) { void InformationManager::finishBasicBlock(BasicBlock*) { } -void InformationManager::finnishComment(Comment* c) { +void InformationManager::finishComment(Comment* c) { + LOG4CXX_DEBUG(logger, "Finishing comment " << c->getAddress()); + ChangeCommentEvent event(c->getAddress(), c->getLocation(), c); + dispatch(&event); } void InformationManager::deleteFunction(Function* f) {