From 4900200ac1d772694506dd7b8d631cb4a0eb4774 Mon Sep 17 00:00:00 2001 From: Ethereal Date: Sat, 8 Jan 2011 21:51:18 -0700 Subject: [PATCH] Encountered a very weird bug whilst testing the communication code. For some reason, as soon as the Informer attempts to read from the zoneUsageData memory map, things go . . . haywire. A bus error ensues. I have no clue why this is occuring. --- include/common/PolisherInterface.h | 4 ++-- modules/informer/src/collector/informer.c | 18 ++++++++++++++++++ monitor/src/Coordinator.cpp | 3 --- monitor/src/analyzer/ElfAnalyzer.cpp | 4 ++-- monitor/src/module/Module.cpp | 3 --- monitor/src/program/ZoneReader.cpp | 6 ++++++ 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/include/common/PolisherInterface.h b/include/common/PolisherInterface.h index aaed957..9016241 100644 --- a/include/common/PolisherInterface.h +++ b/include/common/PolisherInterface.h @@ -21,14 +21,14 @@ class PolisherInterface { public: virtual ~PolisherInterface() {} - virtual NetworkPacket *polish(SHMPacketHeader_t *header, void *data) = 0; + virtual void polish(SHMPacketHeader_t *header, void *data) = 0; }; } // namespace Common extern "C" { -Common::PolisherInterface *AP_Instantiate(); +Common::PolisherInterface *AM_InstantiatePolisher(); } // extern "C" diff --git a/modules/informer/src/collector/informer.c b/modules/informer/src/collector/informer.c index 4f799b8..eacb812 100644 --- a/modules/informer/src/collector/informer.c +++ b/modules/informer/src/collector/informer.c @@ -134,6 +134,13 @@ void __attribute__((constructor)) AI_Construct() { AI_InformerData.threadList[0] = self; AI_ContinueCollection(self); + + printf("Starting packet . . .\n"); + AI_StartPacket(0); + printf("Reserving space . . .\n"); + AI_PacketSpace(32); + printf("Ending packet . . .\n"); + AI_EndPacket(); } void __attribute__((destructor)) AI_Destruct() { @@ -159,6 +166,12 @@ static void AI_SetupZoneUse() { PROT_READ | PROT_WRITE, MAP_SHARED, AI_InformerData.shmFd, (AI_InformerData.shmHeader->configDataSize + 1)*AesalonPageSize); + printf("zoneUseData: %p\n", AI_InformerData.zoneUseData); + printf("\tsize: %x\n", AI_InformerData.shmHeader->zoneUsagePages*AesalonPageSize); + printf("\toffset: %x\n", (AI_InformerData.shmHeader->configDataSize + 1)*AesalonPageSize); + printf("\tfd: %i\n", AI_InformerData.shmFd); + printf("\tfirst byte: %p\n", &AI_InformerData.zoneUseData[0]); + /* +1 for the header. */ AI_InformerData.shmHeader->zonePageOffset = AI_InformerData.shmHeader->zoneUsagePages + AI_InformerData.shmHeader->configDataSize + 1; @@ -167,6 +180,7 @@ static void AI_SetupZoneUse() { static void AI_SetupZone() { /* Check if more memory is required. */ while(AI_InformerData.shmHeader->zoneCount >= AI_InformerData.shmHeader->zonesAllocated) { + printf("Allocating more memory . . .\n"); /* Allocate more memory. */ sem_wait(&AI_InformerData.shmHeader->resizeSemaphore); if(AI_InformerData.shmHeader->zoneCount >= AI_InformerData.shmHeader->zonesAllocated) { @@ -177,10 +191,14 @@ static void AI_SetupZone() { sem_post(&AI_InformerData.shmHeader->resizeSemaphore); } + printf("Looking for zone . . . (allocated zones: %i)\n", AI_InformerData.shmHeader->zonesAllocated); + uint32_t i; for(i = 0; i < AI_InformerData.shmHeader->zonesAllocated; i ++) { + printf("looping . . .\n"); if(AI_ZoneAvailable(i)) break; } + printf("Zone ID: %i\n", i); AI_MarkZone(i); AI_Zone = mmap(NULL, (AI_InformerData.shmHeader->zonePageOffset + i*AI_InformerData.shmHeader->zoneSize)*AesalonPageSize, diff --git a/monitor/src/Coordinator.cpp b/monitor/src/Coordinator.cpp index 1fa97f3..c050254 100644 --- a/monitor/src/Coordinator.cpp +++ b/monitor/src/Coordinator.cpp @@ -57,9 +57,6 @@ void Coordinator::run() { return; } else { - Config::Vault *executable = Analyzer::ExecutableAnalyzer::analyzeExecutable(m_argv[m_argcOffset]); - std::cout << "address of main(): " << std::hex << executable->get("\"main\":address") << std::dec << std::endl; - Module::Loader moduleLoader; moduleLoader.loadModules(); Program::SharedMemory sharedMemory; diff --git a/monitor/src/analyzer/ElfAnalyzer.cpp b/monitor/src/analyzer/ElfAnalyzer.cpp index 51eabfd..c50e999 100644 --- a/monitor/src/analyzer/ElfAnalyzer.cpp +++ b/monitor/src/analyzer/ElfAnalyzer.cpp @@ -119,9 +119,9 @@ void ElfAnalyzer::parseElf() { template void ElfAnalyzer::parseSymbols(SymbolHeader *symbols, int symbolCount, const char *stringTable) { for(int i = 0; i < symbolCount; i ++) { - std::cout << "Parsing symbol \"" << stringTable + symbols[i].st_name << "\" . . .\n"; + /*std::cout << "Parsing symbol \"" << stringTable + symbols[i].st_name << "\" . . .\n";*/ m_vault->set( - Common::StreamAsString() << "\"" << stringTable + symbols[i].st_name << "\":address", + Common::StreamAsString() << "\"" << stringTable + symbols[i].st_name << "\":value", Common::StreamAsString() << symbols[i].st_value); m_vault->set( Common::StreamAsString() << "\"" << stringTable + symbols[i].st_name << "\":size", diff --git a/monitor/src/module/Module.cpp b/monitor/src/module/Module.cpp index b34696c..4934722 100644 --- a/monitor/src/module/Module.cpp +++ b/monitor/src/module/Module.cpp @@ -57,9 +57,6 @@ void Module::loadPreprocessor() { std::string path = Coordinator::instance()->vault()->get(m_moduleName + ":root") + ppPath; - std::cout << "moduleName: \"" << m_moduleName << "\"\n"; - std::cout << "Trying to open shared library \"" << path << "\"\n"; - m_preprocessorHandle = dlopen(path.c_str(), RTLD_LOCAL | RTLD_NOW); if(m_preprocessorHandle == NULL) return; diff --git a/monitor/src/program/ZoneReader.cpp b/monitor/src/program/ZoneReader.cpp index a987a0e..b6c9a76 100644 --- a/monitor/src/program/ZoneReader.cpp +++ b/monitor/src/program/ZoneReader.cpp @@ -94,6 +94,12 @@ void *ZoneReader::run(void *voidInstance) { zoneHeader->head = ZoneDataOffset + overSize; } + + std::cout << "Received packet:" << std::endl; + std::cout << "\tsize: " << packetSize << std::endl; + std::cout << "\tmoduleID: " << packetHeader->moduleID << std::endl; + std::cout << "\tPID: " << zoneHeader->processID << std::endl; + std::cout << "\tTID: " << zoneHeader->threadID << std::endl; /* TODO: process packet. Data is in packetData, size of packet is packetSize, and header is packetHeader. */ /* Other associated information such as the PID and TID of the source are in zoneHeader. */ } -- 2.11.4.GIT