diff options
Diffstat (limited to 'tools/gator/daemon/Buffer.h')
-rw-r--r-- | tools/gator/daemon/Buffer.h | 99 |
1 files changed, 67 insertions, 32 deletions
diff --git a/tools/gator/daemon/Buffer.h b/tools/gator/daemon/Buffer.h index b3c8d78cf758..50237771860c 100644 --- a/tools/gator/daemon/Buffer.h +++ b/tools/gator/daemon/Buffer.h @@ -1,5 +1,5 @@ /** - * Copyright (C) ARM Limited 2013. All rights reserved. + * Copyright (C) ARM Limited 2013-2014. 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 @@ -9,54 +9,89 @@ #ifndef BUFFER_H #define BUFFER_H -#include <stddef.h> #include <stdint.h> #include <semaphore.h> +#include "k/perf_event.h" + class Sender; +enum { + FRAME_SUMMARY = 1, + FRAME_BLOCK_COUNTER = 5, + FRAME_EXTERNAL = 10, + FRAME_PERF_ATTRS = 11, + FRAME_PERF = 12, +}; + class Buffer { public: static const size_t MAXSIZE_PACK32 = 5; static const size_t MAXSIZE_PACK64 = 10; - Buffer (int32_t core, int32_t buftype, const int size, sem_t *const readerSem); - ~Buffer (); + Buffer(int32_t core, int32_t buftype, const int size, sem_t *const readerSem); + ~Buffer(); + + void write(Sender *sender); + + int bytesAvailable() const; + int contiguousSpaceAvailable() const; + void commit(const uint64_t time); + void check(const uint64_t time); - void write (Sender * sender); + void frame(); - int bytesAvailable () const; - void commit (const uint64_t time); - void check (const uint64_t time); + // Summary messages + void summary(const int64_t timestamp, const int64_t uptime, const int64_t monotonicDelta, const char *const uname); + void coreName(const int core, const int cpuid, const char *const name); - void frame (); + // Block Counter messages + bool eventHeader(uint64_t curr_time); + bool eventTid(int tid); + void event(int32_t key, int32_t value); + void event64(int64_t key, int64_t value); - bool eventHeader (uint64_t curr_time); - bool eventTid (int tid); - void event (int32_t key, int32_t value); - void event64 (int64_t key, int64_t value); + // Perf Attrs messages + void pea(const struct perf_event_attr *const pea, int key); + void keys(const int count, const __u64 *const ids, const int *const keys); + void format(const int length, const char *const format); + void maps(const int pid, const int tid, const char *const maps); + void comm(const int pid, const int tid, const char *const image, const char *const comm); - void setDone (); - bool isDone () const; + void setDone(); + bool isDone() const; + + // Prefer a new member to using these functions if possible + char *getWritePos() { return mBuf + mWritePos; } + void advanceWrite(int bytes) { mWritePos = (mWritePos + bytes) & /*mask*/(mSize - 1); } + + static void writeLEInt(unsigned char *buf, int v) { + buf[0] = (v >> 0) & 0xFF; + buf[1] = (v >> 8) & 0xFF; + buf[2] = (v >> 16) & 0xFF; + buf[3] = (v >> 24) & 0xFF; + } private: - bool commitReady () const; - bool checkSpace (int bytes); - - void packInt (int32_t x); - void packInt64 (int64_t x); - - const int32_t core; - const int32_t buftype; - const int size; - int readPos; - int writePos; - int commitPos; - bool available; - bool done; - char *const buf; - uint64_t commitTime; - sem_t *const readerSem; + bool commitReady() const; + bool checkSpace(int bytes); + + void packInt(int32_t x); + void packInt64(int64_t x); + void writeBytes(const void *const data, size_t count); + void writeString(const char *const str); + + const int32_t mCore; + const int32_t mBufType; + const int mSize; + int mReadPos; + int mWritePos; + int mCommitPos; + bool mAvailable; + bool mIsDone; + char *const mBuf; + uint64_t mCommitTime; + sem_t *const mReaderSem; // Intentionally unimplemented Buffer(const Buffer &); |