From a6aefc990eb7791b2221b8b1b1fa588c7514787f Mon Sep 17 00:00:00 2001 From: Ethereal Date: Sun, 27 Feb 2011 20:00:32 -0700 Subject: [PATCH] Time for a little redesign of the Visualizer. Basically, the idea is that the current system of using one DataStore per module across every DataInput is kind of . . . not a good one. The new plan is to use one DataStore per DataInput and set up a composite DataStore that Viewports can access. That way, it is possible to set up a visualization that only takes data from a selection of data sources. Surprisingly, only minor modifications to the framework will be required. The module artisans, of course, will need to be changed dramatically, but still. Better now than later. --- SConstruct | 1 + modules/cpuTime/src/artisan/DataStore.h | 1 + modules/memory/src/artisan/DataStore.cpp | 37 ++++++++++++++++++++++++++++++++ modules/memory/src/artisan/DataStore.h | 23 ++++++++++++++++++++ modules/memory/src/artisan/Interface.cpp | 17 +++++++++++++++ modules/memory/src/artisan/Interface.h | 18 ++++++++++++++++ modules/memory/src/artisan/Viewport.cpp | 17 +++++++++++++++ modules/memory/src/artisan/Viewport.h | 14 ++++++++++++ tests/mallocTest5.c | 13 +++++++++++ 9 files changed, 141 insertions(+) create mode 100644 modules/memory/src/artisan/DataStore.cpp create mode 100644 modules/memory/src/artisan/DataStore.h create mode 100644 modules/memory/src/artisan/Interface.cpp create mode 100644 modules/memory/src/artisan/Interface.h create mode 100644 modules/memory/src/artisan/Viewport.cpp create mode 100644 modules/memory/src/artisan/Viewport.h create mode 100644 tests/mallocTest5.c diff --git a/SConstruct b/SConstruct index af26bfb..acb5e6a 100644 --- a/SConstruct +++ b/SConstruct @@ -67,3 +67,4 @@ Export("qtEnv") SConscript("build/SConscript") SConscript("src/SConscript", variant_dir=".build", duplicate=0) SConscript("modules/SConscript") +SConscript("tests/SConscript") diff --git a/modules/cpuTime/src/artisan/DataStore.h b/modules/cpuTime/src/artisan/DataStore.h index 55bced0..4cf3f24 100644 --- a/modules/cpuTime/src/artisan/DataStore.h +++ b/modules/cpuTime/src/artisan/DataStore.h @@ -23,4 +23,5 @@ public: QListIterator > iterator() { return QListIterator >(m_dataList); } }; + #endif diff --git a/modules/memory/src/artisan/DataStore.cpp b/modules/memory/src/artisan/DataStore.cpp new file mode 100644 index 0000000..397d98c --- /dev/null +++ b/modules/memory/src/artisan/DataStore.cpp @@ -0,0 +1,37 @@ +#include "DataStore.h" + +#include "util/MessageSystem.h" +#include "artisan/gviewport/RectObject.h" + +DataStore::DataStore() { + m_data = new Artisan::GViewport::Data(); +} + +DataStore::~DataStore() { + +} + +void DataStore::process(Comm::Packet *packet) { + uint8_t type = packet->data()[0]; + + if(type == 0) Message(Warning, "Unknown memory packet type . . ."); + else if(type == 1) { + Message(Debug, "calloc() packet . . ."); + } + else if(type == 2) { + uint64_t *data = reinterpret_cast(packet->data() + 1); + Message(Debug, "malloc() packet . . ."); + uint64_t timestamp = data[0]; + uint64_t address = data[1]; + uint64_t size = data[2]; + Artisan::GViewport::Object *object = new Artisan::GViewport::RectObject( + Artisan::GViewport::Rect(timestamp, -1, address, address+size)); + m_data->addObject(object); + } + else if(type == 3) { + Message(Debug, "free() packet . . ."); + } + else if(type == 4) { + Message(Debug, "realloc() packet . . ."); + } +} diff --git a/modules/memory/src/artisan/DataStore.h b/modules/memory/src/artisan/DataStore.h new file mode 100644 index 0000000..54456ba --- /dev/null +++ b/modules/memory/src/artisan/DataStore.h @@ -0,0 +1,23 @@ +#ifndef AesalonArtisan_memory_DataStore_H +#define AesalonArtisan_memory_DataStore_H + +#include +#include +#include + +#include "artisan/DataStore.h" +#include "artisan/gviewport/Data.h" + +class DataStore : public Artisan::DataStore { +private: + Artisan::GViewport::Data *m_data; +public: + DataStore(); + virtual ~DataStore(); + + Artisan::GViewport::Data *data() const { return m_data; } + + virtual void process(Comm::Packet *packet); +}; + +#endif diff --git a/modules/memory/src/artisan/Interface.cpp b/modules/memory/src/artisan/Interface.cpp new file mode 100644 index 0000000..20d32b1 --- /dev/null +++ b/modules/memory/src/artisan/Interface.cpp @@ -0,0 +1,17 @@ +#include "Interface.h" + +#include "Viewport.h" + +InstantiateArtisan(Interface) + +Interface::Interface() { + m_storage = new DataStore(); +} + +Interface::~Interface() { + +} + +Artisan::Viewport *Interface::createViewport() { + return new Viewport(m_storage->data()); +} diff --git a/modules/memory/src/artisan/Interface.h b/modules/memory/src/artisan/Interface.h new file mode 100644 index 0000000..6b3d141 --- /dev/null +++ b/modules/memory/src/artisan/Interface.h @@ -0,0 +1,18 @@ +#ifndef AesalonArtisan_memory_Interface_H +#define AesalonArtisan_memory_Interface_H + +#include "artisan/Interface.h" +#include "DataStore.h" + +class Interface : public Artisan::Interface { +private: + DataStore *m_storage; +public: + Interface(); + virtual ~Interface(); + + virtual Artisan::DataStore *dataStore() { return m_storage; } + virtual Artisan::Viewport *createViewport(); +}; + +#endif diff --git a/modules/memory/src/artisan/Viewport.cpp b/modules/memory/src/artisan/Viewport.cpp new file mode 100644 index 0000000..46db70e --- /dev/null +++ b/modules/memory/src/artisan/Viewport.cpp @@ -0,0 +1,17 @@ +#include "Viewport.h" + +#include "util/MessageSystem.h" + +Viewport::Viewport(Artisan::GViewport::Data *data) : Artisan::GViewport::BasicViewport(data) { + Artisan::GViewport::TreeType::Bound bound = data->tree().bounds(); + setViewport(Artisan::GViewport::Rect( + bound.range(0).start(), bound.range(0).end(), + bound.range(1).start(), bound.range(1).end())); + + Message(Debug, "Data range: " << bound.range(0).start() << " to " << bound.range(0).end() << ", " + << bound.range(1).start() << " to " << bound.range(1).end()); +} + +Viewport::~Viewport() { + +} diff --git a/modules/memory/src/artisan/Viewport.h b/modules/memory/src/artisan/Viewport.h new file mode 100644 index 0000000..044eb62 --- /dev/null +++ b/modules/memory/src/artisan/Viewport.h @@ -0,0 +1,14 @@ +#ifndef AesalonArtisan_memory_Viewport_H +#define AesalonArtisan_memory_Viewport_H + +#include "artisan/Viewport.h" +#include "artisan/gviewport/BasicViewport.h" + +class Viewport : public Artisan::GViewport::BasicViewport { +public: + Viewport(Artisan::GViewport::Data *data); + virtual ~Viewport(); +}; + + +#endif diff --git a/tests/mallocTest5.c b/tests/mallocTest5.c new file mode 100644 index 0000000..a94853c --- /dev/null +++ b/tests/mallocTest5.c @@ -0,0 +1,13 @@ +#include +#include + +int main(int argc, char *argv[]) { + int i; + for(i = 0; i < 5; i ++) { + char *block = malloc(sizeof(char) * 1024); + printf("---- mallocTest: block address: %p\n", block); + free(block); + } + return 0; +} + -- 2.11.4.GIT