|
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 "pin.H"#include "pin_isa_compat.H"#include "cctlib.H"
Include dependency graph for redspy_client.cpp:Go to the source code of this file.
Classes | |
| struct | AddrValPair |
| struct | RedSpyThreadData |
| struct | UnrolledLoop< start, end, incr > |
| struct | UnrolledLoop< end, end, incr > |
| struct | UnrolledConjunction< start, end, incr > |
| struct | UnrolledConjunction< end, end, incr > |
| struct | RedSpyAnalysis< AccessLen, bufferOffset > |
| struct | RedSpyInstrument< readBufferSlotIndex > |
| struct | RedundacyData |
Macros | |
| #define | PAGE_OFFSET_BITS (16LL) |
| #define | PAGE_OFFSET(addr) (addr & 0xFFFF) |
| #define | PAGE_OFFSET_MASK (0xFFFF) |
| #define | PAGE_SIZE (1 << PAGE_OFFSET_BITS) |
| #define | PTR_SIZE (sizeof(struct Status*)) |
| #define | LEVEL_1_PAGE_TABLE_BITS (20) |
| #define | LEVEL_1_PAGE_TABLE_ENTRIES (1 << LEVEL_1_PAGE_TABLE_BITS) |
| #define | LEVEL_1_PAGE_TABLE_SIZE (LEVEL_1_PAGE_TABLE_ENTRIES * PTR_SIZE) |
| #define | LEVEL_2_PAGE_TABLE_BITS (12) |
| #define | LEVEL_2_PAGE_TABLE_ENTRIES (1 << LEVEL_2_PAGE_TABLE_BITS) |
| #define | LEVEL_2_PAGE_TABLE_SIZE (LEVEL_2_PAGE_TABLE_ENTRIES * PTR_SIZE) |
| #define | LEVEL_1_PAGE_TABLE_SLOT(addr) (((addr) >> (LEVEL_2_PAGE_TABLE_BITS + PAGE_OFFSET_BITS)) & 0xfffff) |
| #define | LEVEL_2_PAGE_TABLE_SLOT(addr) (((addr) >> (PAGE_OFFSET_BITS)) & 0xFFF) |
| #define | READ_ACTION (0) |
| #define | WRITE_ACTION (0xff) |
| #define | ONE_BYTE_READ_ACTION (0) |
| #define | TWO_BYTE_READ_ACTION (0) |
| #define | FOUR_BYTE_READ_ACTION (0) |
| #define | EIGHT_BYTE_READ_ACTION (0) |
| #define | ONE_BYTE_WRITE_ACTION (0xff) |
| #define | TWO_BYTE_WRITE_ACTION (0xffff) |
| #define | FOUR_BYTE_WRITE_ACTION (0xffffffff) |
| #define | EIGHT_BYTE_WRITE_ACTION (0xffffffffffffffff) |
| #define | IS_ACCESS_WITHIN_PAGE_BOUNDARY(accessAddr, accessLen) (PAGE_OFFSET((accessAddr)) <= (PAGE_OFFSET_MASK - (accessLen))) |
| #define | MAX_REDUNDANT_CONTEXTS_TO_LOG (1000) |
| #define | THREAD_MAX (1024) |
| #define | ENCODE_ADDRESS_AND_ACCESS_LEN(addr, len) ((addr) | (((uint64_t)(len)) << 48)) |
| #define | DECODE_ADDRESS(addrAndLen) ((addrAndLen) & ((1L << 48) - 1)) |
| #define | DECODE_ACCESS_LEN(addrAndLen) ((addrAndLen) >> 48) |
| #define | MAX_WRITE_OP_LENGTH (512) |
| #define | MAX_WRITE_OPS_IN_INS (8) |
| #define | WINDOW_ENABLE 1000000 |
| #define | WINDOW_DISABLE 1000000000 |
| #define | DECODE_DEAD(data) static_cast<ContextHandle_t>(((data)&0xffffffffffffffff) >> 32) |
| #define | DECODE_KILL(data) (static_cast<ContextHandle_t>((data)&0x00000000ffffffff)) |
| #define | MAKE_CONTEXT_PAIR(a, b) (((uint64_t)(a) << 32) | ((uint64_t)(b))) |
| #define | HANDLE_CASE(NUM, BUFFER_INDEX) |
Functions | |
| RedSpyThreadData * | ClientGetTLS (const THREADID threadId) |
| static INT32 | Usage () |
| static void | ClientInit (int argc, char *argv[]) |
| static uint8_t * | GetOrCreateShadowBaseAddress (uint64_t address) |
| static void | AddToRedTable (uint64_t key, uint16_t value, THREADID threadId) |
| static VOID | RecordValueBeforeLargeWrite (void *addr, UINT32 accessLen, uint32_t bufferOffset, THREADID threadId) |
| static VOID | CheckAfterLargeWrite (UINT32 accessLen, uint32_t bufferOffset, uint32_t opaqueHandle, THREADID threadId) |
| static int | GetNumWriteOperandsInIns (INS ins, UINT32 &whichOp) |
| static VOID | InstrumentInsCallback (INS ins, VOID *v, const uint32_t opaqueHandle) |
| static bool | RedundacyCompare (const struct RedundacyData &first, const struct RedundacyData &second) |
| static void | PrintRedundancyPairs (THREADID threadId) |
| static void | HPCRunRedundancyPairs (THREADID threadId) |
| static VOID | ImageUnload (IMG img, VOID *v) |
| static VOID | ThreadFiniFunc (THREADID threadid, const CONTEXT *ctxt, INT32 code, VOID *v) |
| static VOID | FiniFunc (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 | |
| __thread long long | NUM_INS = 0 |
| __thread bool | Sample_flag = true |
| int | redspy_metric_id = 0 |
| static TLS_KEY | client_tls_key |
| static FILE * | gTraceFile |
| static uint8_t ** | gL1PageTable [LEVEL_1_PAGE_TABLE_SIZE] |
| static const uint64_t | READ_ACCESS_STATES [] = { 0, ONE_BYTE_READ_ACTION, TWO_BYTE_READ_ACTION, 0, FOUR_BYTE_READ_ACTION, 0, 0, 0, EIGHT_BYTE_READ_ACTION} |
| static const uint64_t | WRITE_ACCESS_STATES [] = { 0, ONE_BYTE_WRITE_ACTION, TWO_BYTE_WRITE_ACTION, 0, FOUR_BYTE_WRITE_ACTION, 0, 0, 0, EIGHT_BYTE_WRITE_ACTION} |
| static const uint8_t | OVERFLOW_CHECK [] = { 0, 0, 0, 1, 2, 3, 4, 5, 6} |
| static unordered_map< uint64_t, uint64_t > | RedMap [THREAD_MAX] |
| #define DECODE_ACCESS_LEN | ( | addrAndLen | ) | ((addrAndLen) >> 48) |
Definition at line 73 of file redspy_client.cpp.
| #define DECODE_ADDRESS | ( | addrAndLen | ) | ((addrAndLen) & ((1L << 48) - 1)) |
Definition at line 72 of file redspy_client.cpp.
| #define DECODE_DEAD | ( | data | ) | static_cast<ContextHandle_t>(((data)&0xffffffffffffffff) >> 32) |
Definition at line 83 of file redspy_client.cpp.
| #define DECODE_KILL | ( | data | ) | (static_cast<ContextHandle_t>((data)&0x00000000ffffffff)) |
Definition at line 84 of file redspy_client.cpp.
| #define EIGHT_BYTE_READ_ACTION (0) |
Definition at line 57 of file redspy_client.cpp.
| #define EIGHT_BYTE_WRITE_ACTION (0xffffffffffffffff) |
Definition at line 62 of file redspy_client.cpp.
| #define ENCODE_ADDRESS_AND_ACCESS_LEN | ( | addr, | |
| len | |||
| ) | ((addr) | (((uint64_t)(len)) << 48)) |
Definition at line 71 of file redspy_client.cpp.
| #define FOUR_BYTE_READ_ACTION (0) |
Definition at line 56 of file redspy_client.cpp.
| #define FOUR_BYTE_WRITE_ACTION (0xffffffff) |
Definition at line 61 of file redspy_client.cpp.
| #define HANDLE_CASE | ( | NUM, | |
| BUFFER_INDEX | |||
| ) |
Definition at line 432 of file redspy_client.cpp.
| #define IS_ACCESS_WITHIN_PAGE_BOUNDARY | ( | accessAddr, | |
| accessLen | |||
| ) | (PAGE_OFFSET((accessAddr)) <= (PAGE_OFFSET_MASK - (accessLen))) |
Definition at line 65 of file redspy_client.cpp.
| #define LEVEL_1_PAGE_TABLE_BITS (20) |
Definition at line 38 of file redspy_client.cpp.
| #define LEVEL_1_PAGE_TABLE_ENTRIES (1 << LEVEL_1_PAGE_TABLE_BITS) |
Definition at line 39 of file redspy_client.cpp.
| #define LEVEL_1_PAGE_TABLE_SIZE (LEVEL_1_PAGE_TABLE_ENTRIES * PTR_SIZE) |
Definition at line 40 of file redspy_client.cpp.
| #define LEVEL_1_PAGE_TABLE_SLOT | ( | addr | ) | (((addr) >> (LEVEL_2_PAGE_TABLE_BITS + PAGE_OFFSET_BITS)) & 0xfffff) |
Definition at line 46 of file redspy_client.cpp.
| #define LEVEL_2_PAGE_TABLE_BITS (12) |
Definition at line 42 of file redspy_client.cpp.
| #define LEVEL_2_PAGE_TABLE_ENTRIES (1 << LEVEL_2_PAGE_TABLE_BITS) |
Definition at line 43 of file redspy_client.cpp.
| #define LEVEL_2_PAGE_TABLE_SIZE (LEVEL_2_PAGE_TABLE_ENTRIES * PTR_SIZE) |
Definition at line 44 of file redspy_client.cpp.
| #define LEVEL_2_PAGE_TABLE_SLOT | ( | addr | ) | (((addr) >> (PAGE_OFFSET_BITS)) & 0xFFF) |
Definition at line 47 of file redspy_client.cpp.
Definition at line 87 of file redspy_client.cpp.
| #define MAX_REDUNDANT_CONTEXTS_TO_LOG (1000) |
Definition at line 68 of file redspy_client.cpp.
| #define MAX_WRITE_OP_LENGTH (512) |
Definition at line 76 of file redspy_client.cpp.
| #define MAX_WRITE_OPS_IN_INS (8) |
Definition at line 77 of file redspy_client.cpp.
| #define ONE_BYTE_READ_ACTION (0) |
Definition at line 54 of file redspy_client.cpp.
| #define ONE_BYTE_WRITE_ACTION (0xff) |
Definition at line 59 of file redspy_client.cpp.
| #define PAGE_OFFSET | ( | addr | ) | (addr & 0xFFFF) |
Definition at line 30 of file redspy_client.cpp.
| #define PAGE_OFFSET_BITS (16LL) |
Definition at line 29 of file redspy_client.cpp.
| #define PAGE_OFFSET_MASK (0xFFFF) |
Definition at line 31 of file redspy_client.cpp.
| #define PAGE_SIZE (1 << PAGE_OFFSET_BITS) |
Definition at line 34 of file redspy_client.cpp.
| #define PTR_SIZE (sizeof(struct Status*)) |
Definition at line 37 of file redspy_client.cpp.
| #define READ_ACTION (0) |
Definition at line 51 of file redspy_client.cpp.
| #define THREAD_MAX (1024) |
Definition at line 69 of file redspy_client.cpp.
| #define TWO_BYTE_READ_ACTION (0) |
Definition at line 55 of file redspy_client.cpp.
| #define TWO_BYTE_WRITE_ACTION (0xffff) |
Definition at line 60 of file redspy_client.cpp.
| #define WINDOW_DISABLE 1000000000 |
Definition at line 80 of file redspy_client.cpp.
| #define WINDOW_ENABLE 1000000 |
Definition at line 79 of file redspy_client.cpp.
| #define WRITE_ACTION (0xff) |
Definition at line 52 of file redspy_client.cpp.
|
inlinestatic |
Definition at line 201 of file redspy_client.cpp.
Referenced by CheckAfterLargeWrite(), and RedSpyAnalysis< AccessLen, bufferOffset >::if().
|
inlinestatic |
Definition at line 374 of file redspy_client.cpp.
References AddrValPair::address, AddToRedTable(), RedSpyThreadData::buffer, ClientGetTLS(), PinCCTLib::GetContextHandle(), GetOrCreateShadowBaseAddress(), MAKE_CONTEXT_PAIR, PAGE_OFFSET, Sample_flag, PinCCTLib::status, and AddrValPair::value.
Referenced by RedSpyInstrument< readBufferSlotIndex >::switch().
|
inline |
Definition at line 110 of file redspy_client.cpp.
References client_tls_key.
Referenced by RedSpyAnalysis< AccessLen, bufferOffset >::__attribute__(), CheckAfterLargeWrite(), PrintRedundancyPairs(), and RecordValueBeforeLargeWrite().
|
static |
Definition at line 156 of file redspy_client.cpp.
References gTraceFile, and MAX_FILE_PATH.
Referenced by main().
|
static |
Definition at line 682 of file redspy_client.cpp.
Referenced by main().
|
static |
Definition at line 439 of file redspy_client.cpp.
Referenced by InstrumentInsCallback().
|
static |
Definition at line 183 of file redspy_client.cpp.
References address, gL1PageTable, LEVEL_1_PAGE_TABLE_SLOT, LEVEL_2_PAGE_TABLE_SIZE, LEVEL_2_PAGE_TABLE_SLOT, and PAGE_SIZE.
Referenced by CheckAfterLargeWrite(), and RedSpyAnalysis< AccessLen, bufferOffset >::if().
|
static |
Definition at line 635 of file redspy_client.cpp.
References DECODE_DEAD, DECODE_KILL, MAX_REDUNDANT_CONTEXTS_TO_LOG, PinCCTLib::newCCT_hpcrun_build_cct(), RedMap, redspy_metric_id, and RedundacyCompare().
Referenced by ThreadFiniFunc().
|
static |
Definition at line 664 of file redspy_client.cpp.
References gTraceFile, PrintRedundancyPairs(), and RedMap.
Referenced by main().
|
static |
Definition at line 687 of file redspy_client.cpp.
References RedSpyThreadData::bytesWritten.
Referenced by ThreadStart().
|
static |
Definition at line 476 of file redspy_client.cpp.
References GetNumWriteOperandsInIns().
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 699 of file redspy_client.cpp.
References client_tls_key, ClientInit(), FiniFunc(), gTraceFile, PinCCTLib::hpcrun_create_metric(), ImageUnload(), PinCCTLib::init_hpcrun_format(), InstrumentInsCallback(), INTERESTING_INS_MEMORY_ACCESS, PinCCTLib::PinCCTLibInit(), redspy_metric_id, ThreadFiniFunc(), ThreadStart(), and Usage().
|
static |
Definition at line 581 of file redspy_client.cpp.
References ClientGetTLS(), DECODE_DEAD, DECODE_KILL, RedundacyData::frequency, gTraceFile, PinCCTLib::IsSameSourceLine(), MAX_REDUNDANT_CONTEXTS_TO_LOG, PinCCTLib::PrintFullCallingContext(), RedMap, and RedundacyCompare().
Referenced by ImageUnload().
|
inlinestatic |
Definition at line 350 of file redspy_client.cpp.
References AddrValPair::address, RedSpyThreadData::buffer, RedSpyThreadData::bytesWritten, ClientGetTLS(), NUM_INS, Sample_flag, AddrValPair::value, WINDOW_DISABLE, and WINDOW_ENABLE.
Referenced by RedSpyInstrument< readBufferSlotIndex >::switch().
|
inlinestatic |
Definition at line 577 of file redspy_client.cpp.
References RedundacyData::frequency.
Referenced by HPCRunRedundancyPairs(), and PrintRedundancyPairs().
|
static |
Definition at line 676 of file redspy_client.cpp.
References HPCRunRedundancyPairs(), and PinCCTLib::newCCT_hpcrun_selection_write().
Referenced by main().
|
static |
Definition at line 691 of file redspy_client.cpp.
References client_tls_key, and InitThreadData().
Referenced by main().
|
static |
Definition at line 146 of file redspy_client.cpp.
Referenced by main().
|
static |
Definition at line 107 of file redspy_client.cpp.
Referenced by ClientGetTLS(), main(), and ThreadStart().
|
static |
Definition at line 153 of file redspy_client.cpp.
Referenced by GetOrCreateShadowBaseAddress().
|
static |
Definition at line 152 of file redspy_client.cpp.
Referenced by ClientInit(), ImageUnload(), main(), and PrintRedundancyPairs().
| __thread long long NUM_INS = 0 |
Definition at line 89 of file redspy_client.cpp.
Referenced by RedSpyAnalysis< AccessLen, bufferOffset >::__attribute__(), and RecordValueBeforeLargeWrite().
|
static |
Definition at line 198 of file redspy_client.cpp.
|
static |
Definition at line 196 of file redspy_client.cpp.
|
static |
Definition at line 200 of file redspy_client.cpp.
Referenced by AddToRedTable(), HPCRunRedundancyPairs(), ImageUnload(), and PrintRedundancyPairs().
| int redspy_metric_id = 0 |
Definition at line 104 of file redspy_client.cpp.
Referenced by HPCRunRedundancyPairs(), and main().
| __thread bool Sample_flag = true |
Definition at line 90 of file redspy_client.cpp.
Referenced by RedSpyAnalysis< AccessLen, bufferOffset >::__attribute__(), CheckAfterLargeWrite(), and RecordValueBeforeLargeWrite().
|
static |
Definition at line 197 of file redspy_client.cpp.