|
CCTLib
Calling-context and data-object attribution library for Intel Pin
|
#include <stdio.h>#include <atomic>#include <stdlib.h>#include <map>#include <list>#include <stdint.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/shm.h>#include <semaphore.h>#include <sys/stat.h>#include <fcntl.h>#include <iostream>#include <locale>#include <unistd.h>#include <sys/syscall.h>#include <assert.h>#include <sys/mman.h>#include <exception>#include <sys/time.h>#include <signal.h>#include <string.h>#include <setjmp.h>#include <sstream>#include <pthread.h>#include "pin.H"#include "pin_isa_compat.H"#include "cctlib.H"#include "shadow_memory.H"
Include dependency graph for omp_datarace_client.cpp:Go to the source code of this file.
Classes | |
| struct | LabelSegment |
| class | Label |
| class | LabelIterator |
| class | ThreadData_t |
Macros | |
| #define | MAX_FILE_PATH (200) |
| #define | ENTER_RANK(phase) (((phase) + 1) & 0xfffffffffffffffe) |
| #define | EXIT_RANK(phase) ((phase)&0xfffffffffffffffe) |
| #define | MAX_REGIONS (1 << 20) |
| #define | OMP_RUMTIMR_LIB_NAME "/home/xl10/support/gcc-4.7-install/lib64/libgomp.so.1" |
| #define | LINUX_LD_NAME "/lib64/ld-linux-x86-64.so.2" |
| #define | MAX_SKIP_IMAGES (2) |
| #define | MASTER_BEGIN_FN_NAME "gomp_datarace_master_begin_dynamic_work" |
| #define | DYNAMIC_BEGIN_FN_NAME "gomp_datarace_begin_dynamic_work" |
| #define | DYNAMIC_END_FN_NAME "gomp_datarace_master_end_dynamic_work" |
| #define | ORDERED_ENTER_FN_NAME "gomp_datarace_begin_ordered_section" |
| #define | ORDERED_EXIT_FN_NAME "gomp_datarace_end_ordered_section" |
| #define | CRITICAL_ENTER_FN_NAME "gomp_datarace_begin_critical" |
| #define | CRITICAL_EXIT_FN_NAME "gomp_datarace_end_critical" |
Typedefs | |
| using | VersionInfo_t = struct VersionInfo_t { union { volatile atomic< uint64_t > readStart |
| using | DataraceInfo_t = struct DataraceInfo_t { VersionInfo_t versionInfo |
| using | ExtendedDataraceInfo_t = struct ExtendedDataraceInfo_t { DataraceInfo_t *shadowAddress |
| using | FP_MASTER = void(*)(uint64_t, long) |
| using | FP_WORKER = void(*)(uint64_t, long, long) |
| using | FP_WORKER_END = void(*)() |
| using | FP_ORDERED_ENTER = void(*)(uint64_t) |
| using | FP_ORDERED_EXIT = void(*)(uint64_t) |
| using | FP_CRITICAL_ENTER = void(*)(void *) |
| using | FP_CRITICAL_EXIT = void(*)(void *) |
Enumerations | |
| enum | LabelCreationType { CREATE_FIRST , CREATE_AFTER_FORK , CREATE_AFTER_JOIN , CREATE_AFTER_BARRIER , CREATE_AFTER_ENTERING_ORDERED_SECTION , CREATE_AFTER_EXITING_ORDERED_SECTION } |
| enum | AccessType { READ_ACCESS = 0 , WRITE_ACCESS = 1 , READ_ACCESS = 0 , WRITE_ACCESS = 1 } |
Functions | |
| ThreadData_t * | GetTLS (THREADID threadid) |
| static uint64_t | GetReadStartForLoc (const DataraceInfo_t *const shadowAddress) |
| static uint64_t | GetReadEndForLoc (const DataraceInfo_t *const shadowAddress) |
| static uint64_t | GetWriteStartForLoc (const DataraceInfo_t *const shadowAddress) |
| static uint64_t | GetWriteEndForLoc (const DataraceInfo_t *const shadowAddress) |
| static volatile atomic< uint64_t > * | GetWriteStartAddressForLoc (DataraceInfo_t *const shadowAddress) |
| static void | UpdateShadowDataAtShadowAddress (DataraceInfo_t *shadowAddress, const DataraceInfo_t &info) |
| static void | ReadShadowData (DataraceInfo_t *info, DataraceInfo_t *shadowAddress) |
| static bool | IsConsistentSpapshot (const DataraceInfo_t *const info) |
| void | ReadShadowMemory (DataraceInfo_t *shadowAddress, DataraceInfo_t *info) |
| static bool | TryWriteShadowMemory (DataraceInfo_t *shadowAddress, const DataraceInfo_t &info) |
| static Label * | GetMyLabel (THREADID threadId) |
| static void | SetMyLabel (THREADID threadId, Label *label) |
| static void | UpdateLabel (Label **oldLabel, Label *newLabel) |
| static void | UpdateContext (ContextHandle_t *oldCtxt, ContextHandle_t ctxt) |
| static void | CommitChangesToShadowMemory (Label *oldLabel, Label *newLabel) |
| static bool | HappensBefore (const Label *const oldLabel, const Label *const newLabel) |
| static bool | IsLeftOf (const Label *const newLabel, const Label *const oldLabel) |
| static bool | MaximizesExitRank (const Label *const newLabel, const Label *const oldLabel) |
| static void | DumpRaceInfo (ContextHandle_t oldCtxt, Label *oldLbl, ContextHandle_t newCtxt, Label *newLbl) |
| static void | CheckRead (DataraceInfo_t *shadowAddress, Label *myLabel, uint32_t opaqueHandle, THREADID threadId) |
| static void | CheckWrite (DataraceInfo_t *shadowAddress, Label *myLabel, uint32_t opaqueHandle, THREADID threadId) |
| static void | ExecuteOffsetSpanPhaseProtocol (DataraceInfo_t *status, Label *myLabel, bool accessType, uint32_t opaqueHandle, THREADID threadId) |
| static VOID | CheckRace (VOID *addr, uint32_t accessLen, bool accessType, uint32_t opaqueHandle, THREADID threadId) |
| static bool | IsIgnorableIns (INS ins) |
| void | new_MASTER_BEGIN_FN_NAME (uint64_t region_id, long span, THREADID threadid) |
| void | new_DYNAMIC_BEGIN_FN_NAME (uint64_t region_id, long span, long iter, THREADID threadid) |
| void | new_DYNAMIC_END_FN_NAME (THREADID threadId) |
| void | new_ORDERED_ENTER_FN_NAME (uint64_t region_id, THREADID threadId) |
| void | new_ORDERED_EXIT_FN_NAME (uint64_t region_id, THREADID threadId) |
| void | new_CRITICAL_ENTER_FN_NAME (void *name, THREADID threadid) |
| void | new_CRITICAL_EXIT_FN_NAME (void *name, THREADID threadid) |
| VOID | Overrides (IMG img, VOID *v) |
| static VOID | InstrumentInsCallback (INS ins, VOID *v, const uint32_t opaqueHandle) |
| static INT32 | Usage () |
| VOID | ThreadStart (THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v) |
| static VOID | InstrumentImageLoad (IMG img, VOID *v) |
| void | InitDataRaceSpy (int argc, char *argv[]) |
| int | main (int argc, char *argv[]) |
Variables | |
| static const LabelSegment | defaultExtension = {} |
| static FILE * | gTraceFile |
| static const char * | HW_LOCK = "HW_LOCK" |
| static Label ** | gRegionIdToMasterLabelMap |
| static TLS_KEY | tls_key |
| static ADDRINT | gSkipImageAddressRanges [MAX_SKIP_IMAGES][2] |
| static int | gNumCurSkipImages |
| static string | skipImages [] = {OMP_RUMTIMR_LIB_NAME, LINUX_LD_NAME} |
| volatile atomic< uint64_t > | writeEnd |
| union { | |
| volatile atomic< uint64_t > writeStart | |
| volatile atomic< uint64_t > readEnd | |
| }; | |
| Label * | read1 |
| ContextHandle_t | read1Context |
| Label * | read2 |
| ContextHandle_t | read2Context |
| Label * | write1 |
| ContextHandle_t | write1Context |
| ConcurrentShadowMemory< DataraceInfo_t > | sm |
| DataraceInfo_t | data |
| #define CRITICAL_ENTER_FN_NAME "gomp_datarace_begin_critical" |
Definition at line 736 of file omp_datarace_client.cpp.
| #define CRITICAL_EXIT_FN_NAME "gomp_datarace_end_critical" |
Definition at line 737 of file omp_datarace_client.cpp.
| #define DYNAMIC_BEGIN_FN_NAME "gomp_datarace_begin_dynamic_work" |
Definition at line 732 of file omp_datarace_client.cpp.
| #define DYNAMIC_END_FN_NAME "gomp_datarace_master_end_dynamic_work" |
Definition at line 733 of file omp_datarace_client.cpp.
| #define ENTER_RANK | ( | phase | ) | (((phase) + 1) & 0xfffffffffffffffe) |
Definition at line 44 of file omp_datarace_client.cpp.
| #define EXIT_RANK | ( | phase | ) | ((phase)&0xfffffffffffffffe) |
Definition at line 48 of file omp_datarace_client.cpp.
| #define LINUX_LD_NAME "/lib64/ld-linux-x86-64.so.2" |
Definition at line 89 of file omp_datarace_client.cpp.
| #define MASTER_BEGIN_FN_NAME "gomp_datarace_master_begin_dynamic_work" |
Definition at line 731 of file omp_datarace_client.cpp.
| #define MAX_FILE_PATH (200) |
Definition at line 40 of file omp_datarace_client.cpp.
| #define MAX_REGIONS (1 << 20) |
Definition at line 50 of file omp_datarace_client.cpp.
| #define MAX_SKIP_IMAGES (2) |
Definition at line 90 of file omp_datarace_client.cpp.
| #define OMP_RUMTIMR_LIB_NAME "/home/xl10/support/gcc-4.7-install/lib64/libgomp.so.1" |
Definition at line 88 of file omp_datarace_client.cpp.
| #define ORDERED_ENTER_FN_NAME "gomp_datarace_begin_ordered_section" |
Definition at line 734 of file omp_datarace_client.cpp.
| #define ORDERED_EXIT_FN_NAME "gomp_datarace_end_ordered_section" |
Definition at line 735 of file omp_datarace_client.cpp.
| using DataraceInfo_t = struct DataraceInfo_t { VersionInfo_t versionInfo |
Definition at line 118 of file omp_datarace_client.cpp.
| using ExtendedDataraceInfo_t = struct ExtendedDataraceInfo_t { DataraceInfo_t* shadowAddress |
Definition at line 143 of file omp_datarace_client.cpp.
| using FP_CRITICAL_ENTER = void (*)(void*) |
Definition at line 749 of file omp_datarace_client.cpp.
| using FP_CRITICAL_EXIT = void (*)(void*) |
Definition at line 750 of file omp_datarace_client.cpp.
| using FP_MASTER = void (*)(uint64_t, long) |
Definition at line 744 of file omp_datarace_client.cpp.
| using FP_ORDERED_ENTER = void (*)(uint64_t) |
Definition at line 747 of file omp_datarace_client.cpp.
| using FP_ORDERED_EXIT = void (*)(uint64_t) |
Definition at line 748 of file omp_datarace_client.cpp.
| using FP_WORKER = void (*)(uint64_t, long, long) |
Definition at line 745 of file omp_datarace_client.cpp.
| using FP_WORKER_END = void (*)() |
Definition at line 746 of file omp_datarace_client.cpp.
| using VersionInfo_t = struct VersionInfo_t { union { volatile atomic<uint64_t> readStart |
Definition at line 102 of file omp_datarace_client.cpp.
| enum AccessType |
| Enumerator | |
|---|---|
| READ_ACCESS | |
| WRITE_ACCESS | |
| READ_ACCESS | |
| WRITE_ACCESS | |
Definition at line 63 of file omp_datarace_client.cpp.
| enum LabelCreationType |
| Enumerator | |
|---|---|
| CREATE_FIRST | |
| CREATE_AFTER_FORK | |
| CREATE_AFTER_JOIN | |
| CREATE_AFTER_BARRIER | |
| CREATE_AFTER_ENTERING_ORDERED_SECTION | |
| CREATE_AFTER_EXITING_ORDERED_SECTION | |
Definition at line 54 of file omp_datarace_client.cpp.
|
inlinestatic |
Definition at line 677 of file omp_datarace_client.cpp.
References ExecuteOffsetSpanPhaseProtocol(), GetMyLabel(), PAGE_OFFSET, PAGE_OFFSET_MASK, sm, and PinCCTLib::status.
Referenced by InstrumentInsCallback().
|
inlinestatic |
Definition at line 564 of file omp_datarace_client.cpp.
References CommitChangesToShadowMemory(), DumpRaceInfo(), PinCCTLib::GetContextHandle(), HappensBefore(), IsLeftOf(), MaximizesExitRank(), ReadShadowMemory(), TryWriteShadowMemory(), UpdateContext(), and UpdateLabel().
Referenced by ExecuteOffsetSpanPhaseProtocol().
|
inlinestatic |
Definition at line 618 of file omp_datarace_client.cpp.
References CommitChangesToShadowMemory(), DumpRaceInfo(), PinCCTLib::GetContextHandle(), HappensBefore(), Label::PrintLabel(), ReadShadowMemory(), TryWriteShadowMemory(), UpdateContext(), and UpdateLabel().
Referenced by ExecuteOffsetSpanPhaseProtocol().
Definition at line 430 of file omp_datarace_client.cpp.
References Label::DecrementRef(), and Label::IncrementRef().
Referenced by CheckRead(), and CheckWrite().
|
inlinestatic |
Definition at line 552 of file omp_datarace_client.cpp.
References gTraceFile, PinCCTLib::PrintFullCallingContext(), and Label::PrintLabel().
Referenced by CheckRead(), and CheckWrite().
|
inlinestatic |
Definition at line 668 of file omp_datarace_client.cpp.
References CheckRead(), CheckWrite(), PinCCTLib::status, and WRITE_ACCESS.
Referenced by CheckRace().
|
inlinestatic |
Definition at line 413 of file omp_datarace_client.cpp.
References ThreadData_t::GetLabel(), and GetTLS().
Referenced by CheckRace(), new_DYNAMIC_END_FN_NAME(), new_MASTER_BEGIN_FN_NAME(), new_ORDERED_ENTER_FN_NAME(), and new_ORDERED_EXIT_FN_NAME().
|
inlinestatic |
Definition at line 326 of file omp_datarace_client.cpp.
Referenced by ReadShadowMemory().
|
inlinestatic |
Definition at line 321 of file omp_datarace_client.cpp.
Referenced by ReadShadowMemory().
| ThreadData_t* GetTLS | ( | THREADID | threadid | ) |
Definition at line 314 of file omp_datarace_client.cpp.
References tls_key.
Referenced by GetMyLabel(), and SetMyLabel().
|
inlinestatic |
Definition at line 336 of file omp_datarace_client.cpp.
|
inlinestatic |
Definition at line 340 of file omp_datarace_client.cpp.
Referenced by TryWriteShadowMemory().
|
inlinestatic |
Definition at line 331 of file omp_datarace_client.cpp.
Definition at line 437 of file omp_datarace_client.cpp.
References ENTER_RANK, EXIT_RANK, LabelIterator::NextSegment(), LabelSegment::offset, LabelSegment::phase, and LabelSegment::span.
Referenced by CheckRead(), and CheckWrite().
| void InitDataRaceSpy | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 990 of file omp_datarace_client.cpp.
References gRegionIdToMasterLabelMap, gTraceFile, InstrumentImageLoad(), MAX_FILE_PATH, MAX_REGIONS, ThreadStart(), and tls_key.
Referenced by main().
|
inlinestatic |
Definition at line 977 of file omp_datarace_client.cpp.
References gNumCurSkipImages, gSkipImageAddressRanges, MAX_SKIP_IMAGES, and skipImages.
Referenced by InitDataRaceSpy().
|
static |
Definition at line 925 of file omp_datarace_client.cpp.
References CheckRace(), HW_LOCK, IsIgnorableIns(), new_CRITICAL_ENTER_FN_NAME(), new_CRITICAL_EXIT_FN_NAME(), READ_ACCESS, and WRITE_ACCESS.
Referenced by main().
|
inlinestatic |
Definition at line 368 of file omp_datarace_client.cpp.
Referenced by ReadShadowMemory().
|
inlinestatic |
Definition at line 711 of file omp_datarace_client.cpp.
References gNumCurSkipImages, and gSkipImageAddressRanges.
Referenced by InstrumentInsCallback().
Definition at line 494 of file omp_datarace_client.cpp.
References LabelIterator::NextSegment(), LabelSegment::offset, and LabelSegment::span.
Referenced by CheckRead().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 1026 of file omp_datarace_client.cpp.
References gTraceFile, InitDataRaceSpy(), InstrumentInsCallback(), INTERESTING_INS_MEMORY_ACCESS, Overrides(), PinCCTLib::PinCCTLibInit(), and Usage().
|
inlinestatic |
Definition at line 520 of file omp_datarace_client.cpp.
References EXIT_RANK, LabelIterator::NextSegment(), LabelSegment::offset, LabelSegment::phase, and LabelSegment::span.
Referenced by CheckRead().
| void new_CRITICAL_ENTER_FN_NAME | ( | void * | name, |
| THREADID | threadid | ||
| ) |
Definition at line 809 of file omp_datarace_client.cpp.
Referenced by InstrumentInsCallback(), and Overrides().
| void new_CRITICAL_EXIT_FN_NAME | ( | void * | name, |
| THREADID | threadid | ||
| ) |
Definition at line 817 of file omp_datarace_client.cpp.
Referenced by InstrumentInsCallback(), and Overrides().
| void new_DYNAMIC_BEGIN_FN_NAME | ( | uint64_t | region_id, |
| long | span, | ||
| long | iter, | ||
| THREADID | threadid | ||
| ) |
Definition at line 766 of file omp_datarace_client.cpp.
References CREATE_AFTER_FORK, gRegionIdToMasterLabelMap, LabelSegment::offset, LabelSegment::phase, SetMyLabel(), and LabelSegment::span.
Referenced by Overrides().
| void new_DYNAMIC_END_FN_NAME | ( | THREADID | threadId | ) |
Definition at line 784 of file omp_datarace_client.cpp.
References CREATE_AFTER_JOIN, GetMyLabel(), and SetMyLabel().
Referenced by Overrides().
| void new_MASTER_BEGIN_FN_NAME | ( | uint64_t | region_id, |
| long | span, | ||
| THREADID | threadid | ||
| ) |
Definition at line 753 of file omp_datarace_client.cpp.
References GetMyLabel(), gRegionIdToMasterLabelMap, MAX_REGIONS, and SetMyLabel().
Referenced by Overrides().
| void new_ORDERED_ENTER_FN_NAME | ( | uint64_t | region_id, |
| THREADID | threadId | ||
| ) |
Definition at line 793 of file omp_datarace_client.cpp.
References CREATE_AFTER_ENTERING_ORDERED_SECTION, GetMyLabel(), and SetMyLabel().
Referenced by Overrides().
| void new_ORDERED_EXIT_FN_NAME | ( | uint64_t | region_id, |
| THREADID | threadId | ||
| ) |
Definition at line 801 of file omp_datarace_client.cpp.
References CREATE_AFTER_EXITING_ORDERED_SECTION, GetMyLabel(), and SetMyLabel().
Referenced by Overrides().
| VOID Overrides | ( | IMG | img, |
| VOID * | v | ||
| ) |
Definition at line 826 of file omp_datarace_client.cpp.
References CRITICAL_ENTER_FN_NAME, CRITICAL_EXIT_FN_NAME, DYNAMIC_BEGIN_FN_NAME, DYNAMIC_END_FN_NAME, MASTER_BEGIN_FN_NAME, new_CRITICAL_ENTER_FN_NAME(), new_CRITICAL_EXIT_FN_NAME(), new_DYNAMIC_BEGIN_FN_NAME(), new_DYNAMIC_END_FN_NAME(), new_MASTER_BEGIN_FN_NAME(), new_ORDERED_ENTER_FN_NAME(), new_ORDERED_EXIT_FN_NAME(), ORDERED_ENTER_FN_NAME, and ORDERED_EXIT_FN_NAME.
Referenced by main().
|
inlinestatic |
Definition at line 358 of file omp_datarace_client.cpp.
Referenced by ReadShadowMemory().
|
inline |
Definition at line 373 of file omp_datarace_client.cpp.
References GetReadEndForLoc(), GetReadStartForLoc(), IsConsistentSpapshot(), and ReadShadowData().
Referenced by CheckRead(), and CheckWrite().
|
inlinestatic |
Definition at line 418 of file omp_datarace_client.cpp.
References GetTLS(), and ThreadData_t::SetLabel().
Referenced by new_DYNAMIC_BEGIN_FN_NAME(), new_DYNAMIC_END_FN_NAME(), new_MASTER_BEGIN_FN_NAME(), new_ORDERED_ENTER_FN_NAME(), and new_ORDERED_EXIT_FN_NAME().
| VOID ThreadStart | ( | THREADID | threadid, |
| CONTEXT * | ctxt, | ||
| INT32 | flags, | ||
| VOID * | v | ||
| ) |
Definition at line 964 of file omp_datarace_client.cpp.
References tls_key.
Referenced by InitDataRaceSpy().
|
inlinestatic |
Definition at line 401 of file omp_datarace_client.cpp.
References GetWriteStartAddressForLoc(), and UpdateShadowDataAtShadowAddress().
Referenced by CheckRead(), and CheckWrite().
|
inlinestatic |
Definition at line 426 of file omp_datarace_client.cpp.
Referenced by CheckRead(), and CheckWrite().
Definition at line 422 of file omp_datarace_client.cpp.
Referenced by CheckRead(), and CheckWrite().
|
inlinestatic |
Definition at line 345 of file omp_datarace_client.cpp.
Referenced by TryWriteShadowMemory().
|
static |
Definition at line 959 of file omp_datarace_client.cpp.
Referenced by main().
| union { ... } |
| DataraceInfo_t data |
Definition at line 145 of file omp_datarace_client.cpp.
Referenced by AddToApproximateRedTable(), AddToRedTable(), anonymous_namespace{rbtree_test.cpp}::TEST(), and updateDataList().
|
static |
Definition at line 81 of file omp_datarace_client.cpp.
|
static |
Definition at line 92 of file omp_datarace_client.cpp.
Referenced by InstrumentImageLoad(), and IsIgnorableIns().
|
static |
Definition at line 84 of file omp_datarace_client.cpp.
Referenced by InitDataRaceSpy(), new_DYNAMIC_BEGIN_FN_NAME(), and new_MASTER_BEGIN_FN_NAME().
|
static |
Definition at line 91 of file omp_datarace_client.cpp.
Referenced by InstrumentImageLoad(), and IsIgnorableIns().
|
static |
Definition at line 82 of file omp_datarace_client.cpp.
Referenced by DumpRaceInfo(), InitDataRaceSpy(), main(), and Label::PrintLabel().
|
static |
Definition at line 83 of file omp_datarace_client.cpp.
Referenced by InstrumentInsCallback().
| Label* read1 |
Definition at line 123 of file omp_datarace_client.cpp.
| ContextHandle_t read1Context |
Definition at line 125 of file omp_datarace_client.cpp.
| Label* read2 |
Definition at line 128 of file omp_datarace_client.cpp.
| ContextHandle_t read2Context |
Definition at line 130 of file omp_datarace_client.cpp.
| volatile atomic<uint64_t> readEnd |
Definition at line 109 of file omp_datarace_client.cpp.
|
static |
Definition at line 93 of file omp_datarace_client.cpp.
Referenced by InstrumentImageLoad().
Definition at line 138 of file omp_datarace_client.cpp.
Referenced by CheckRace().
|
static |
Definition at line 86 of file omp_datarace_client.cpp.
Referenced by GetTLS(), InitDataRaceSpy(), and ThreadStart().
| Label* write1 |
Definition at line 133 of file omp_datarace_client.cpp.
| ContextHandle_t write1Context |
Definition at line 135 of file omp_datarace_client.cpp.
| volatile atomic<uint64_t> writeEnd |
Definition at line 105 of file omp_datarace_client.cpp.
| volatile atomic<uint64_t> writeStart |
Definition at line 108 of file omp_datarace_client.cpp.