]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/arm-ds5-gator.git/blob - daemon/SessionData.cpp
gator-driver: Revert #error about lack of CONFIG_PERF_EVENTS
[android-sdk/arm-ds5-gator.git] / daemon / SessionData.cpp
1 /**
2  * Copyright (C) ARM Limited 2010-2012. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
9 #include <string.h>
10 #include "SessionData.h"
11 #include "SessionXML.h"
12 #include "Logging.h"
13 extern void handleException();
15 SessionData* gSessionData = NULL;
17 SessionData::SessionData() {
18         initialize();
19 }
21 SessionData::~SessionData() {
22 }
24 void SessionData::initialize() {
25         mWaitingOnCommand = false;
26         mSessionIsActive = false;
27         mLocalCapture = false;
28         mOneShot = false;
29         strcpy(mCoreName, "unknown");
30         mConfigurationXMLPath = NULL;
31         mSessionXMLPath = NULL;
32         mEventsXMLPath = NULL;
33         mAPCDir = NULL;
34         mSampleRate = 0;
35         mDuration = 0;
36         mBytes = 0;
37         mBacktraceDepth = 0;
38         mTotalBufferSize = 0;
39         mCores = 1;
41         initializeCounters();
42 }
44 void SessionData::initializeCounters() {
45         // PMU Counters
46         for (int i = 0; i < MAX_PERFORMANCE_COUNTERS; i++) {
47                 mPerfCounterType[i][0] = 0;
48                 mPerfCounterTitle[i][0] = 0;
49                 mPerfCounterName[i][0] = 0;
50                 mPerfCounterDescription[i][0] = 0;
51                 mPerfCounterOperation[i][0] = 0;
52                 mPerfCounterAlias[i][0] = 0;
53                 mPerfCounterDisplay[i][0] = 0;
54                 mPerfCounterUnits[i][0] = 0;
55                 mPerfCounterEnabled[i] = 0;
56                 mPerfCounterEvent[i] = 0;
57                 mPerfCounterColor[i] = 0;
58                 mPerfCounterKey[i] = 0;
59                 mPerfCounterCount[i] = 0;
60                 mPerfCounterPerCPU[i] = false;
61                 mPerfCounterEBSCapable[i] = false;
62                 mPerfCounterLevel[i] = false;
63                 mPerfCounterAverageSelection[i] = false;
64         }
65 }
67 void SessionData::parseSessionXML(char* xmlString) {
68         SessionXML session(xmlString);
69         session.parse();
71         // Parameter error checking
72         if (session.parameters.output_path == 0 && session.parameters.target_path == 0) {
73                 logg->logError(__FILE__, __LINE__, "No capture path (target or host) was provided.");
74                 handleException();
75         } else if (gSessionData->mLocalCapture && session.parameters.target_path == 0) {
76                 logg->logError(__FILE__, __LINE__, "Missing target_path tag in session xml required for a local capture.");
77                 handleException();
78         }
80         // Set session data values
81         if (strcmp(session.parameters.sample_rate, "high") == 0) {
82                 gSessionData->mSampleRate = 10000;
83         } else if (strcmp(session.parameters.sample_rate, "normal") == 0) {
84                 gSessionData->mSampleRate = 1000;
85         } else if (strcmp(session.parameters.sample_rate, "low") == 0) {
86                 gSessionData->mSampleRate = 100;
87         } else {
88                 gSessionData->mSampleRate = 0;
89         }
90         gSessionData->mBacktraceDepth = session.parameters.call_stack_unwinding == true ? 128 : 0;
91         gSessionData->mDuration = session.parameters.duration;
93         // Determine buffer size (in MB) based on buffer mode
94         gSessionData->mOneShot = true;
95         if (strcmp(session.parameters.buffer_mode, "streaming") == 0) {
96                 gSessionData->mOneShot = false;
97                 gSessionData->mTotalBufferSize = 1;
98         } else if (strcmp(session.parameters.buffer_mode, "small") == 0) {
99                 gSessionData->mTotalBufferSize = 1;
100         } else if (strcmp(session.parameters.buffer_mode, "normal") == 0) {
101                 gSessionData->mTotalBufferSize = 4;
102         } else if (strcmp(session.parameters.buffer_mode, "large") == 0) {
103                 gSessionData->mTotalBufferSize = 16;
104         } else {
105                 logg->logError(__FILE__, __LINE__, "Invalid value for buffer mode in session xml.");
106                 handleException();
107         }
109         gSessionData->mImages = session.parameters.images;
110         gSessionData->mTargetPath = session.parameters.target_path;
111         gSessionData->mTitle = session.parameters.title;