Minor changes here and there.
[aesalon.git] / src / monitor / InformerMarshal.cpp
blob903c021283330478457f7d6b128e20f350fba20a
1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file src/monitor/InformerMarshal.cpp
8 */
10 #include "monitor/InformerMarshal.h"
11 #include "util/MessageSystem.h"
12 #include "informer/PacketFormat.h"
13 #include "monitor/MarshalList.h"
14 #include "monitor/Coordinator.h"
15 #include "config/GlobalVault.h"
16 #include "util/StringTo.h"
18 namespace Monitor {
20 InformerMarshal::InformerMarshal() {
24 InformerMarshal::~InformerMarshal() {
28 Comm::Packet *InformerMarshal::marshal(Comm::Packet *packet) {
29 Informer::PacketType type = static_cast<Informer::PacketType>(packet->data()[0]);
31 Message(Debug, "type: " << type);
33 switch(type) {
34 case Informer::ModuleLoaded: {
35 moduleLoaded(packet);
36 break;
38 case Informer::FileLoaded: {
39 fileLoaded(packet);
40 packet = NULL;
41 break;
43 case Informer::NewProcess: {
44 Message(Fatal, "Informer::NewProcess handling NYI.");
45 break;
47 case Informer::NewThread: {
48 Message(Fatal, "Informer::NewThread handling NYI.");
49 break;
51 case Informer::ThreadExiting: {
52 Message(Fatal, "Informer::ThreadExiting handling NYI.");
53 break;
55 case Informer::ProcessExiting: {
56 Message(Fatal, "Informer::ProcessExiting handling NYI.");
57 break;
61 return packet;
64 void InformerMarshal::moduleLoaded(Comm::Packet *packet) {
65 /* NOTE: the +3 is +1 for the type byte, +2 for the module ID#. (unused in the monitor) */
66 std::string name = reinterpret_cast<char *>(packet->data() + 3);
67 MarshalList *list = Coordinator::instance()->marshalList();
69 Message(Debug, "Marshal name: \"" << name << "\"");
71 list->loadMarshal(name);
74 void InformerMarshal::fileLoaded(Comm::Packet *packet) {
75 uint64_t baseAddress = *reinterpret_cast<uint64_t *>(packet->data() + 1);
76 uint64_t fileOffset = *reinterpret_cast<uint64_t *>(packet->data() + 9);
77 std::string name = reinterpret_cast<char *>(packet->data() + 17);
79 Coordinator::instance()->resolver()->parse(name, baseAddress);
82 } // namespace Monitor