diff options
author | Pawel Moll <pawel.moll@arm.com> | 2011-09-30 11:57:10 +0100 |
---|---|---|
committer | Pawel Moll <pawel.moll@arm.com> | 2011-10-04 10:34:25 +0100 |
commit | 8fc69a3638ca8d08111c161b1487868cb42cd888 (patch) | |
tree | fd55a22f7a950d1d625efdad8553e719c0fa7db5 /daemon/SessionData.cpp | |
parent | 3f0b05d287e7df2160ea80f14c69444b73b74ed8 (diff) |
gator-daemon: ARM DS-5.7 Streamline gator daemon sourcesDS-5.7
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Diffstat (limited to 'daemon/SessionData.cpp')
-rw-r--r-- | daemon/SessionData.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/daemon/SessionData.cpp b/daemon/SessionData.cpp new file mode 100644 index 0000000..0672804 --- /dev/null +++ b/daemon/SessionData.cpp @@ -0,0 +1,101 @@ +/** + * Copyright (C) ARM Limited 2010-2011. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +typedef unsigned long long uint64_t; +#include <string.h> +#include "SessionData.h" +#include "ReadSession.h" +#include "Logging.h" +extern void handleException(); + +SessionData gSessionData; + +SessionData::SessionData() { + initialize(); +} + +SessionData::~SessionData() { +} + +void SessionData::initialize() { + mWaitingOnCommand = false; + mSessionIsActive = false; + mLocalCapture = false; + mOneShot = false; + strcpy(mCoreName, "unknown"); + apcDir = NULL; + mSampleRate = 0; + mDuration = 0; + mBytes = 0; + mBacktraceDepth = 0; + mTotalBufferSize = 0; + mCores = 1; +} + +void SessionData::initializeCounters() { + // PMU Counters + for (int i = 0; i < MAX_PERFORMANCE_COUNTERS; i++) { + mPerfCounterType[i][0] = 0; + mPerfCounterTitle[i][0] = 0; + mPerfCounterName[i][0] = 0; + mPerfCounterDescription[i][0] = 0; + mPerfCounterEnabled[i] = 0; + mPerfCounterEvent[i] = 0; + mPerfCounterColor[i] = 0; + mPerfCounterKey[i] = 0; + mPerfCounterCount[i] = 0; + mPerfCounterOperation[i][0] = 0; + mPerfCounterPerCPU[i] = false; + mPerfCounterEBSCapable[i] = false; + } +} + +void SessionData::parseSessionXML(char* xmlString) { + ReadSession session(xmlString); + session.parse(); + + // Parameter error checking + if (session.parameters.output_path == 0 && session.parameters.target_path == 0) { + logg->logError(__FILE__, __LINE__, "No capture path (target or host) was provided."); + handleException(); + } else if (gSessionData.mLocalCapture && session.parameters.target_path == 0) { + logg->logError(__FILE__, __LINE__, "Missing target_path tag in session xml required for a local capture."); + handleException(); + } + + // Set session data values + if (strcmp(session.parameters.sample_rate, "high") == 0) { + gSessionData.mSampleRate = 10000; + } else if (strcmp(session.parameters.sample_rate, "normal") == 0) { + gSessionData.mSampleRate = 1000; + } else { // "low" + gSessionData.mSampleRate = 100; + } + gSessionData.mBacktraceDepth = session.parameters.call_stack_unwinding == true ? 128 : 0; + gSessionData.mDuration = session.parameters.duration; + + // Determine buffer size (in MB) based on buffer mode + gSessionData.mOneShot = true; + if (strcmp(session.parameters.buffer_mode, "streaming") == 0) { + gSessionData.mOneShot = false; + gSessionData.mTotalBufferSize = 1; + } else if (strcmp(session.parameters.buffer_mode, "small") == 0) { + gSessionData.mTotalBufferSize = 1; + } else if (strcmp(session.parameters.buffer_mode, "normal") == 0) { + gSessionData.mTotalBufferSize = 4; + } else if (strcmp(session.parameters.buffer_mode, "large") == 0) { + gSessionData.mTotalBufferSize = 16; + } else { + logg->logError(__FILE__, __LINE__, "Invalid value for buffer mode in session xml."); + handleException(); + } + + gSessionData.images = session.parameters.images; + gSessionData.target_path = session.parameters.target_path; + gSessionData.title = session.parameters.title; +} |