|
CCTLib
Calling-context and data-object attribution library for Intel Pin
|
#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <iostream>#include <unistd.h>#include <assert.h>#include <string.h>#include <sys/mman.h>#include <sstream>#include <functional>#include <unordered_set>#include <vector>#include <unordered_map>#include <algorithm>#include <sys/time.h>#include <sys/resource.h>#include "pin.H"#include "pin_isa_compat.H"
Include dependency graph for cache_client.cpp:Go to the source code of this file.
Classes | |
| struct | Cache_t |
| struct | Stats_t |
| struct | AddrValPair |
| struct | RedSpyThreadData |
| struct | RedSpyAnalysis< AccessLen, bufferOffset > |
| struct | RedSpyInstrument< readBufferSlotIndex > |
Functions | |
| static INT32 | Usage () |
| RedSpyThreadData * | ClientGetTLS (const THREADID threadId) |
| void | CacheFlush () |
| static void | OnEvict (void **addr) |
| static void | HandleOneCacheLine (void **address, bool isWrite) |
| static void | OnAccess (void **address, uint64_t accessLen, bool isWrite) |
| static void | ClientInit (int argc, char *argv[]) |
| static VOID | RecordValueBeforeLargeWrite (void *addr, UINT32 accessLen, uint32_t bufferOffset, THREADID threadId) |
| static VOID | CheckAfterLargeWrite (UINT32 accessLen, uint32_t bufferOffset, THREADID threadId) |
| static int | GetNumWriteOperandsInIns (INS ins, UINT32 &whichOp) |
| static VOID | InstrumentInsCallback (INS ins, VOID *v) |
| size_t | getPeakRSS () |
| static VOID | FiniFunc (INT32 code, VOID *v) |
| static VOID | ImageUnload (IMG img, VOID *v) |
| static void | HandleSysCall (THREADID threadIndex, CONTEXT *ctxt, SYSCALL_STANDARD std, VOID *v) |
| VOID | Update (uint32_t bytes, THREADID threadId) |
| static void | InstrumentTrace (TRACE trace, void *f) |
| static VOID | ThreadFiniFunc (THREADID threadId, const CONTEXT *ctxt, INT32 code, VOID *v) |
| static void | InitThreadData (RedSpyThreadData *tdata) |
| static VOID | ThreadStart (THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v) |
| int | main (int argc, char *argv[]) |
Variables | |
| static FILE * | gTraceFile |
| static TLS_KEY | client_tls_key |
| static RedSpyThreadData * | gSingleThreadedTData |
| thread_local Stats_t | stats |
| thread_local Cache_t | cache [CACHE_NUM_LINES] |
| #define CACHE_INDEX_BITS (20) |
Definition at line 38 of file cache_client.cpp.
| #define CACHE_LINE_BASE | ( | addr | ) | ((size_t)(addr) & (~CACHE_LINE_MASK)) |
Definition at line 42 of file cache_client.cpp.
| #define CACHE_LINE_BITS (6) |
Definition at line 37 of file cache_client.cpp.
| #define CACHE_LINE_INDEX | ( | address | ) | (((size_t)(address) & (CACHE_SZ - 1)) >> CACHE_LINE_BITS) |
Definition at line 47 of file cache_client.cpp.
| #define CACHE_LINE_MASK (CACHE_LINE_SZ - 1) |
Definition at line 41 of file cache_client.cpp.
| #define CACHE_LINE_SZ (1L << CACHE_LINE_BITS) |
Definition at line 40 of file cache_client.cpp.
| #define CACHE_NUM_LINES (CACHE_SZ / CACHE_LINE_SZ) |
Definition at line 44 of file cache_client.cpp.
| #define CACHE_SZ (1L << (CACHE_LINE_BITS + CACHE_INDEX_BITS)) |
Definition at line 39 of file cache_client.cpp.
| #define CACHE_TAG | ( | address | ) | (((size_t)address) & CACHE_TAG_MASK) |
Definition at line 46 of file cache_client.cpp.
| #define CACHE_TAG_MASK (~CACHE_LINE_MASK) |
Definition at line 45 of file cache_client.cpp.
| #define GET_TAG | ( | address | ) | (cache[CACHE_LINE_INDEX(((size_t)address))].tag) |
Definition at line 51 of file cache_client.cpp.
| #define HANDLE_CASE | ( | NUM, | |
| BUFFER_INDEX, | |||
| HAS_FALLTHRU | |||
| ) |
Definition at line 341 of file cache_client.cpp.
| #define HANDLE_LARGE | ( | HAS_FALLTHRU | ) |
Definition at line 347 of file cache_client.cpp.
| #define IS_VALID | ( | address | ) | (cache[CACHE_LINE_INDEX(((size_t)address))].isInUse && (cache[CACHE_LINE_INDEX(((size_t)address))].tag == CACHE_TAG(((size_t)address)))) |
Definition at line 48 of file cache_client.cpp.
| #define MAX_FILE_PATH (1000) |
Definition at line 191 of file cache_client.cpp.
| #define MAX_WRITE_OP_LENGTH (512) |
Definition at line 55 of file cache_client.cpp.
| #define MAX_WRITE_OPS_IN_INS (8) |
Definition at line 56 of file cache_client.cpp.
| #define SET_INUSE | ( | address | ) | (cache[CACHE_LINE_INDEX(((size_t)address))].isInUse = true) |
Definition at line 50 of file cache_client.cpp.
Definition at line 49 of file cache_client.cpp.
| #define WAS_DIFFERENT | ( | address | ) | (cache[CACHE_LINE_INDEX(((size_t)address))].wasDifferent) |
Definition at line 52 of file cache_client.cpp.
| void CacheFlush | ( | ) |
Definition at line 119 of file cache_client.cpp.
References cache, CACHE_NUM_LINES, and Cache_t::isInUse.
Referenced by HandleSysCall(), and ImageUnload().
|
inlinestatic |
Definition at line 318 of file cache_client.cpp.
References AddrValPair::address, RedSpyThreadData::buffer, RedSpyThreadData::bytesRedundant, CACHE_LINE_BASE, CACHE_LINE_SZ, ClientGetTLS(), AddrValPair::value, and WAS_DIFFERENT.
|
inline |
Definition at line 93 of file cache_client.cpp.
References client_tls_key, and gSingleThreadedTData.
Referenced by RedSpyAnalysis< AccessLen, bufferOffset >::__attribute__(), CheckAfterLargeWrite(), RecordValueBeforeLargeWrite(), ThreadFiniFunc(), and Update().
|
static |
Definition at line 194 of file cache_client.cpp.
References CACHE_SZ, gTraceFile, and MAX_FILE_PATH.
Referenced by main().
|
static |
Definition at line 453 of file cache_client.cpp.
References Stats_t::dirtyEvicts, Stats_t::evicts, getPeakRSS(), gTraceFile, Stats_t::sameData, stats, and Stats_t::unchanged.
Referenced by main().
|
static |
Definition at line 351 of file cache_client.cpp.
Referenced by InstrumentInsCallback().
| size_t getPeakRSS | ( | ) |
Definition at line 446 of file cache_client.cpp.
Referenced by FiniFunc(), and PinCCTLib::PrintStats().
|
inlinestatic |
Definition at line 163 of file cache_client.cpp.
References address, cache, CACHE_LINE_INDEX, IS_VALID, Cache_t::isDirty, OnEvict(), and SET_INUSE.
Referenced by OnAccess().
|
static |
|
static |
Definition at line 457 of file cache_client.cpp.
References CacheFlush().
|
static |
Definition at line 491 of file cache_client.cpp.
References RedSpyThreadData::bytesRedundant, and RedSpyThreadData::bytesWritten.
Referenced by ThreadStart().
|
static |
Definition at line 383 of file cache_client.cpp.
References GetNumWriteOperandsInIns(), and OnAccess().
Referenced by main().
|
static |
Definition at line 473 of file cache_client.cpp.
References INS_MemoryWriteSize(), and Update().
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 506 of file cache_client.cpp.
References client_tls_key, ClientInit(), FiniFunc(), HandleSysCall(), InstrumentInsCallback(), InstrumentTrace(), ThreadFiniFunc(), ThreadStart(), and Usage().
|
inlinestatic |
Definition at line 174 of file cache_client.cpp.
References address, CACHE_LINE_INDEX, CACHE_LINE_SZ, and HandleOneCacheLine().
Referenced by InstrumentInsCallback().
|
inlinestatic |
Definition at line 126 of file cache_client.cpp.
References address, cache, CACHE_LINE_INDEX, CACHE_LINE_MASK, CACHE_LINE_SZ, Stats_t::dirtyEvicts, Stats_t::evicts, GET_TAG, Cache_t::isDirty, Cache_t::isInUse, Stats_t::sameData, SET_TAG, stats, Stats_t::unchanged, Cache_t::value, and WAS_DIFFERENT.
Referenced by HandleOneCacheLine().
|
inlinestatic |
Definition at line 312 of file cache_client.cpp.
References AddrValPair::address, RedSpyThreadData::buffer, ClientGetTLS(), and AddrValPair::value.
|
static |
Definition at line 486 of file cache_client.cpp.
References RedSpyThreadData::bytesRedundant, RedSpyThreadData::bytesWritten, ClientGetTLS(), and gTraceFile.
Referenced by main().
|
static |
Definition at line 496 of file cache_client.cpp.
References client_tls_key, gSingleThreadedTData, and InitThreadData().
Referenced by main().
|
inline |
Definition at line 467 of file cache_client.cpp.
References RedSpyThreadData::bytesWritten, and ClientGetTLS().
Referenced by InstrumentTrace().
|
static |
Definition at line 28 of file cache_client.cpp.
Referenced by main().
| thread_local Cache_t cache[CACHE_NUM_LINES] |
Definition at line 116 of file cache_client.cpp.
Referenced by CacheFlush(), HandleOneCacheLine(), and OnEvict().
|
static |
Definition at line 89 of file cache_client.cpp.
Referenced by ClientGetTLS(), main(), and ThreadStart().
|
static |
Definition at line 90 of file cache_client.cpp.
Referenced by ClientGetTLS(), and ThreadStart().
|
static |
Definition at line 34 of file cache_client.cpp.
Referenced by ClientInit(), FiniFunc(), and ThreadFiniFunc().
| thread_local Stats_t stats |
Definition at line 113 of file cache_client.cpp.
Referenced by FiniFunc(), and OnEvict().