|
CCTLib
Calling-context and data-object attribution library for Intel Pin
|
#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <atomic>#include <malloc.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 <list>#include "pin.H"#include "pin_isa_compat.H"#include "cctlib.H"#include "shadow_memory.H"#include <xmmintrin.h>#include <immintrin.h>#include "xed-interface.h"#include "xed-common-hdrs.h"#include <google/sparse_hash_map>#include <google/dense_hash_map>
Include dependency graph for loadspy_client.cpp:Go to the source code of this file.
Classes | |
| struct | RedSpyThreadData |
| struct | UnrolledLoop< start, end, incr > |
| struct | UnrolledLoop< end, end, incr, conditional, approx > |
| struct | UnrolledConjunction< start, end, incr > |
| struct | UnrolledConjunction< end, end, incr > |
| struct | RedSpyAnalysis< AccessLen, bufferOffset > |
| struct | LoadSpyInstrument |
| struct | RedundacyData |
Macros | |
| #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 | MAX_REG_LENGTH (64) |
| #define | MAX_SIMD_LENGTH (64) |
| #define | MAX_SIMD_REGS (32) |
| #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 | delta 0.01 |
| #define | HANDLE_CASE(T, ACCESS_LEN, IS_APPROX) INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RedSpyAnalysis<T, (ACCESS_LEN), (IS_APPROX)>::CheckNByteValueAfterRead, IARG_MEMORYOP_EA, memOp, IARG_UINT32, opaqueHandle, IARG_THREAD_ID, IARG_INST_PTR, IARG_END) |
| #define | HANDLE_LARGE() INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)CheckAfterLargeRead, IARG_MEMORYOP_EA, memOp, IARG_MEMORYREAD_SIZE, IARG_UINT32, opaqueHandle, IARG_THREAD_ID, IARG_END) |
Functions | |
| RedSpyThreadData * | ClientGetTLS (const THREADID threadId) |
| static INT32 | Usage () |
| static void | ClientInit (int argc, char *argv[]) |
| static void | AddToRedTable (uint64_t key, uint16_t value, THREADID threadId) __attribute__((always_inline |
| static void | AddToApproximateRedTable (uint64_t key, uint16_t value, THREADID threadId) __attribute__((always_inline |
| static bool | IsOkToApproximate (xed_decoded_inst_t &xedd) |
| static bool | IsFloatInstructionAndOkToApproximate (ADDRINT ip) |
| static bool | IsFloatInstructionOld (ADDRINT ip) |
| static uint16_t | FloatOperandSize (ADDRINT ip, uint32_t oper) |
| static VOID | CheckAfterLargeRead (void *addr, UINT32 accessLen, uint32_t opaqueHandle, THREADID threadId) |
| static int | GetNumReadOperandsInIns (INS ins, UINT32 &whichOp) |
| static bool | INS_IsIgnorable (INS ins) |
| static VOID | InstrumentInsCallback (INS ins, VOID *v, const uint32_t opaqueHandle) |
| VOID | Update (uint32_t bytes, THREADID threadId) |
| static void | InstrumentTrace (TRACE trace, void *f) |
| static bool | RedundacyCompare (const struct RedundacyData &first, const struct RedundacyData &second) |
| static void | PrintRedundancyPairs (THREADID threadId) |
| static void | PrintApproximationRedundancyPairs (THREADID threadId) |
| static void | HPCRunRedundancyPairs (THREADID threadId) |
| static void | HPCRunApproxRedundancyPairs (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) |
| uint64_t | computeMetricVal (void *metric) |
| int | main (int argc, char *argv[]) |
Variables | |
| ConcurrentShadowMemory< uint8_t, ContextHandle_t > | sm |
| struct { | |
| char dummy1 [128] | |
| xed_state_t xedState | |
| char dummy2 [128] | |
| } | LoadSpyGlobals |
| int | redload_metric_id = 0 |
| int | redload_approx_metric_id = 0 |
| uint64_t | grandTotBytesLoad |
| uint64_t | grandTotBytesRedLoad |
| uint64_t | grandTotBytesApproxRedLoad |
| static TLS_KEY | client_tls_key |
| static RedSpyThreadData * | gSingleThreadedTData |
| static FILE * | gTraceFile |
| 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] |
| static unordered_map< uint64_t, uint64_t > | ApproxRedMap [THREAD_MAX] |
| static void | flatten |
| #define DECODE_ACCESS_LEN | ( | addrAndLen | ) | ((addrAndLen) >> 48) |
Definition at line 65 of file loadspy_client.cpp.
| #define DECODE_ADDRESS | ( | addrAndLen | ) | ((addrAndLen) & ((1L << 48) - 1)) |
Definition at line 64 of file loadspy_client.cpp.
| #define DECODE_DEAD | ( | data | ) | static_cast<ContextHandle_t>(((data)&0xffffffffffffffff) >> 32) |
Definition at line 83 of file loadspy_client.cpp.
| #define DECODE_KILL | ( | data | ) | (static_cast<ContextHandle_t>((data)&0x00000000ffffffff)) |
Definition at line 84 of file loadspy_client.cpp.
| #define delta 0.01 |
Definition at line 89 of file loadspy_client.cpp.
| #define EIGHT_BYTE_READ_ACTION (0) |
Definition at line 49 of file loadspy_client.cpp.
| #define EIGHT_BYTE_WRITE_ACTION (0xffffffffffffffff) |
Definition at line 54 of file loadspy_client.cpp.
| #define ENCODE_ADDRESS_AND_ACCESS_LEN | ( | addr, | |
| len | |||
| ) | ((addr) | (((uint64_t)(len)) << 48)) |
Definition at line 63 of file loadspy_client.cpp.
| #define FOUR_BYTE_READ_ACTION (0) |
Definition at line 48 of file loadspy_client.cpp.
| #define FOUR_BYTE_WRITE_ACTION (0xffffffff) |
Definition at line 53 of file loadspy_client.cpp.
| #define HANDLE_CASE | ( | T, | |
| ACCESS_LEN, | |||
| IS_APPROX | |||
| ) | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)RedSpyAnalysis<T, (ACCESS_LEN), (IS_APPROX)>::CheckNByteValueAfterRead, IARG_MEMORYOP_EA, memOp, IARG_UINT32, opaqueHandle, IARG_THREAD_ID, IARG_INST_PTR, IARG_END) |
Definition at line 860 of file loadspy_client.cpp.
| #define HANDLE_LARGE | ( | ) | INS_InsertPredicatedCall(ins, IPOINT_BEFORE, (AFUNPTR)CheckAfterLargeRead, IARG_MEMORYOP_EA, memOp, IARG_MEMORYREAD_SIZE, IARG_UINT32, opaqueHandle, IARG_THREAD_ID, IARG_END) |
Definition at line 863 of file loadspy_client.cpp.
| #define IS_ACCESS_WITHIN_PAGE_BOUNDARY | ( | accessAddr, | |
| accessLen | |||
| ) | (PAGE_OFFSET((accessAddr)) <= (PAGE_OFFSET_MASK - (accessLen))) |
Definition at line 57 of file loadspy_client.cpp.
Definition at line 87 of file loadspy_client.cpp.
| #define MAX_REDUNDANT_CONTEXTS_TO_LOG (1000) |
Definition at line 60 of file loadspy_client.cpp.
| #define MAX_REG_LENGTH (64) |
Definition at line 70 of file loadspy_client.cpp.
| #define MAX_SIMD_LENGTH (64) |
Definition at line 72 of file loadspy_client.cpp.
| #define MAX_SIMD_REGS (32) |
Definition at line 73 of file loadspy_client.cpp.
| #define MAX_WRITE_OP_LENGTH (512) |
Definition at line 68 of file loadspy_client.cpp.
| #define MAX_WRITE_OPS_IN_INS (8) |
Definition at line 69 of file loadspy_client.cpp.
| #define ONE_BYTE_READ_ACTION (0) |
Definition at line 46 of file loadspy_client.cpp.
| #define ONE_BYTE_WRITE_ACTION (0xff) |
Definition at line 51 of file loadspy_client.cpp.
| #define READ_ACTION (0) |
Definition at line 43 of file loadspy_client.cpp.
| #define THREAD_MAX (1024) |
Definition at line 61 of file loadspy_client.cpp.
| #define TWO_BYTE_READ_ACTION (0) |
Definition at line 47 of file loadspy_client.cpp.
| #define TWO_BYTE_WRITE_ACTION (0xffff) |
Definition at line 52 of file loadspy_client.cpp.
| #define WRITE_ACTION (0xff) |
Definition at line 44 of file loadspy_client.cpp.
|
inlinestatic |
Definition at line 220 of file loadspy_client.cpp.
References ApproxRedMap, and value.
Referenced by UnrolledLoop< start, end, incr >::__attribute__(), UnrolledLoop< start, end, incr >::if(), and RedSpyAnalysis< AccessLen, bufferOffset >::if().
|
inlinestatic |
Definition at line 204 of file loadspy_client.cpp.
Referenced by UnrolledLoop< start, end, incr >::__attribute__(), CheckAfterLargeRead(), UnrolledLoop< start, end, incr >::if(), and RedSpyAnalysis< AccessLen, bufferOffset >::if().
|
inlinestatic |
Definition at line 820 of file loadspy_client.cpp.
References AddToRedTable(), PinCCTLib::GetContextHandle(), MAKE_CONTEXT_PAIR, PAGE_OFFSET, and sm.
|
inline |
Definition at line 147 of file loadspy_client.cpp.
References client_tls_key, and gSingleThreadedTData.
Referenced by RedSpyAnalysis< AccessLen, bufferOffset >::__attribute__(), PrintApproximationRedundancyPairs(), PrintRedundancyPairs(), ThreadFiniFunc(), and Update().
|
static |
Definition at line 166 of file loadspy_client.cpp.
References gTraceFile, LoadSpyGlobals, and MAX_FILE_PATH.
Referenced by main().
| uint64_t computeMetricVal | ( | void * | metric | ) |
Definition at line 1378 of file loadspy_client.cpp.
References PinCCTLib::metric.
|
static |
Definition at line 1328 of file loadspy_client.cpp.
References ApproxRedMap, grandTotBytesApproxRedLoad, grandTotBytesLoad, grandTotBytesRedLoad, gTraceFile, RedMap, and THREAD_MAX.
Referenced by main().
|
inlinestatic |
Definition at line 558 of file loadspy_client.cpp.
References ip, and LoadSpyGlobals.
Referenced by LoadSpyInstrument::if().
|
static |
Definition at line 869 of file loadspy_client.cpp.
Referenced by InstrumentInsCallback().
|
static |
Definition at line 1274 of file loadspy_client.cpp.
References ApproxRedMap, DECODE_DEAD, DECODE_KILL, MAX_REDUNDANT_CONTEXTS_TO_LOG, PinCCTLib::newCCT_hpcrun_build_cct(), redload_approx_metric_id, and RedundacyCompare().
Referenced by ThreadFiniFunc().
|
static |
Definition at line 1246 of file loadspy_client.cpp.
References DECODE_DEAD, DECODE_KILL, MAX_REDUNDANT_CONTEXTS_TO_LOG, PinCCTLib::newCCT_hpcrun_build_cct(), redload_metric_id, RedMap, and RedundacyCompare().
Referenced by ThreadFiniFunc().
|
static |
Definition at line 1303 of file loadspy_client.cpp.
References ApproxRedMap, gTraceFile, PrintApproximationRedundancyPairs(), PrintRedundancyPairs(), and RedMap.
Referenced by main().
|
static |
Definition at line 1354 of file loadspy_client.cpp.
References RedSpyThreadData::bytesLoad, RedSpyThreadData::numIns, and RedSpyThreadData::sampleFlag.
Referenced by ThreadStart().
|
inlinestatic |
Definition at line 956 of file loadspy_client.cpp.
References INS_IsMaskedJump().
Referenced by InstrumentInsCallback(), and InstrumentTrace().
|
static |
Definition at line 980 of file loadspy_client.cpp.
References GetNumReadOperandsInIns(), and INS_IsIgnorable().
Referenced by main().
|
static |
Definition at line 1080 of file loadspy_client.cpp.
References INS_IsIgnorable(), INS_MemoryReadSize(), and Update().
Referenced by main().
|
inlinestatic |
Definition at line 264 of file loadspy_client.cpp.
References ip, IsOkToApproximate(), and LoadSpyGlobals.
|
inlinestatic |
Definition at line 328 of file loadspy_client.cpp.
References ip, and LoadSpyGlobals.
|
inlinestatic |
Definition at line 246 of file loadspy_client.cpp.
Referenced by IsFloatInstructionAndOkToApproximate().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 1384 of file loadspy_client.cpp.
References client_tls_key, ClientInit(), FiniFunc(), gTraceFile, PinCCTLib::hpcrun_create_metric(), ImageUnload(), PinCCTLib::init_hpcrun_format(), InstrumentInsCallback(), InstrumentTrace(), INTERESTING_INS_ALL, PinCCTLib::PinCCTLibInit(), redload_approx_metric_id, redload_metric_id, ThreadFiniFunc(), ThreadStart(), and Usage().
|
static |
Definition at line 1178 of file loadspy_client.cpp.
References ApproxRedMap, ClientGetTLS(), DECODE_DEAD, DECODE_KILL, delta, RedundacyData::frequency, grandTotBytesApproxRedLoad, gTraceFile, PinCCTLib::HaveSameCallerPrefix(), PinCCTLib::IsSameSourceLine(), MAX_REDUNDANT_CONTEXTS_TO_LOG, PinCCTLib::PrintFullCallingContext(), and RedundacyCompare().
Referenced by ImageUnload().
|
static |
Definition at line 1111 of file loadspy_client.cpp.
References ClientGetTLS(), DECODE_DEAD, DECODE_KILL, RedundacyData::frequency, grandTotBytesRedLoad, gTraceFile, PinCCTLib::HaveSameCallerPrefix(), PinCCTLib::IsSameSourceLine(), MAX_REDUNDANT_CONTEXTS_TO_LOG, PinCCTLib::PrintFullCallingContext(), RedMap, and RedundacyCompare().
Referenced by ImageUnload().
|
inlinestatic |
Definition at line 1107 of file loadspy_client.cpp.
References RedundacyData::frequency.
Referenced by HPCRunApproxRedundancyPairs(), HPCRunRedundancyPairs(), PrintApproximationRedundancyPairs(), and PrintRedundancyPairs().
|
static |
Definition at line 1319 of file loadspy_client.cpp.
References ClientGetTLS(), grandTotBytesLoad, HPCRunApproxRedundancyPairs(), HPCRunRedundancyPairs(), and PinCCTLib::newCCT_hpcrun_selection_write().
Referenced by main().
|
static |
Definition at line 1365 of file loadspy_client.cpp.
References client_tls_key, gSingleThreadedTData, and InitThreadData().
Referenced by main().
|
inline |
Definition at line 1074 of file loadspy_client.cpp.
References RedSpyThreadData::bytesLoad, and ClientGetTLS().
Referenced by InstrumentTrace().
|
static |
Definition at line 157 of file loadspy_client.cpp.
Referenced by main().
|
static |
Definition at line 201 of file loadspy_client.cpp.
Referenced by AddToApproximateRedTable(), FiniFunc(), HPCRunApproxRedundancyPairs(), ImageUnload(), and PrintApproximationRedundancyPairs().
|
static |
Definition at line 143 of file loadspy_client.cpp.
Referenced by ClientGetTLS(), main(), and ThreadStart().
| char dummy1[128] |
Definition at line 98 of file loadspy_client.cpp.
| char dummy2[128] |
Definition at line 100 of file loadspy_client.cpp.
| static void flatten |
Definition at line 203 of file loadspy_client.cpp.
| uint64_t grandTotBytesApproxRedLoad |
Definition at line 140 of file loadspy_client.cpp.
Referenced by FiniFunc(), and PrintApproximationRedundancyPairs().
| uint64_t grandTotBytesLoad |
Definition at line 138 of file loadspy_client.cpp.
Referenced by FiniFunc(), and ThreadFiniFunc().
| uint64_t grandTotBytesRedLoad |
Definition at line 139 of file loadspy_client.cpp.
Referenced by FiniFunc(), and PrintRedundancyPairs().
|
static |
Definition at line 144 of file loadspy_client.cpp.
Referenced by ClientGetTLS(), and ThreadStart().
|
static |
Definition at line 163 of file loadspy_client.cpp.
Referenced by ClientInit(), FiniFunc(), ImageUnload(), main(), PrintApproximationRedundancyPairs(), and PrintRedundancyPairs().
| struct { ... } LoadSpyGlobals |
Referenced by ClientInit(), FloatOperandSize(), IsFloatInstructionAndOkToApproximate(), and IsFloatInstructionOld().
|
static |
Definition at line 198 of file loadspy_client.cpp.
|
static |
Definition at line 196 of file loadspy_client.cpp.
| int redload_approx_metric_id = 0 |
Definition at line 135 of file loadspy_client.cpp.
Referenced by HPCRunApproxRedundancyPairs(), and main().
| int redload_metric_id = 0 |
Definition at line 134 of file loadspy_client.cpp.
Referenced by HPCRunRedundancyPairs(), and main().
|
static |
Definition at line 200 of file loadspy_client.cpp.
Referenced by AddToRedTable(), FiniFunc(), HPCRunRedundancyPairs(), ImageUnload(), and PrintRedundancyPairs().
| ConcurrentShadowMemory<uint8_t, ContextHandle_t> sm |
Definition at line 95 of file loadspy_client.cpp.
Referenced by UnrolledLoop< start, end, incr >::__attribute__(), and CheckAfterLargeRead().
|
static |
Definition at line 197 of file loadspy_client.cpp.
| xed_state_t xedState |
Definition at line 99 of file loadspy_client.cpp.