CCTLib
Calling-context and data-object attribution library for Intel Pin
footprint_client2.cpp File Reference
#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 <sys/time.h>
#include <sstream>
#include "pin.H"
#include "cctlib.H"
#include <unordered_set>
#include <vector>
#include <unordered_map>
#include <algorithm>
+ Include dependency graph for footprint_client2.cpp:

Go to the source code of this file.

Classes

struct  node_metric_t
 
struct  sort_format_t
 

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(void*))
 
#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 MAX_FOOTPRINT_CONTEXTS_TO_LOG   (1000)
 
#define THREAD_MAX   (1024)
 

Functions

static INT32 Usage ()
 
void ClientInit (int argc, char *argv[])
 
uint8_t * GetOrCreateShadowBaseAddress (uint64_t address)
 
bool CheckDependence (uint64_t curAddr, uint64_t prevAddr)
 
VOID MemFunc (THREADID id, void *addr, bool rwFlag, UINT32 refSize)
 
VOID InstrumentInsCallback (INS ins, VOID *v, const uint32_t slot)
 
void DecodingFootPrint (const THREADID threadid, ContextHandle_t myHandle, ContextHandle_t parentHandle, void **myMetric, void **parentMetric)
 
void MergeFootPrint (const THREADID threadid, ContextHandle_t myHandle, ContextHandle_t parentHandle, void **myMetric, void **parentMetric)
 
bool FootPrintCompare (const struct sort_format_t &first, const struct sort_format_t &second)
 
void PrintTopFootPrintPath (THREADID threadid)
 
VOID ThreadFiniFunc (THREADID threadid, const CONTEXT *ctxt, INT32 code, VOID *v)
 
VOID FiniFunc (INT32 code, VOID *v)
 
int main (int argc, char *argv[])
 

Variables

uint8_t ** gL1PageTable [LEVEL_1_PAGE_TABLE_SIZE]
 
unordered_map< uint32_t, struct node_metric_thmap_vector [THREAD_MAX]
 
FILE * gTraceFile
 
struct timeval tv1
 
__thread struct timeval tv2
 
__thread struct timeval tv3
 

Macro Definition Documentation

◆ LEVEL_1_PAGE_TABLE_BITS

#define LEVEL_1_PAGE_TABLE_BITS   (20)

Definition at line 38 of file footprint_client2.cpp.

◆ LEVEL_1_PAGE_TABLE_ENTRIES

#define LEVEL_1_PAGE_TABLE_ENTRIES   (1 << LEVEL_1_PAGE_TABLE_BITS)

Definition at line 39 of file footprint_client2.cpp.

◆ LEVEL_1_PAGE_TABLE_SIZE

#define LEVEL_1_PAGE_TABLE_SIZE   (LEVEL_1_PAGE_TABLE_ENTRIES * PTR_SIZE)

Definition at line 40 of file footprint_client2.cpp.

◆ LEVEL_1_PAGE_TABLE_SLOT

#define LEVEL_1_PAGE_TABLE_SLOT (   addr)    (((addr) >> (LEVEL_2_PAGE_TABLE_BITS + PAGE_OFFSET_BITS)) & 0xfffff)

Definition at line 46 of file footprint_client2.cpp.

◆ LEVEL_2_PAGE_TABLE_BITS

#define LEVEL_2_PAGE_TABLE_BITS   (12)

Definition at line 42 of file footprint_client2.cpp.

◆ LEVEL_2_PAGE_TABLE_ENTRIES

#define LEVEL_2_PAGE_TABLE_ENTRIES   (1 << LEVEL_2_PAGE_TABLE_BITS)

Definition at line 43 of file footprint_client2.cpp.

◆ LEVEL_2_PAGE_TABLE_SIZE

#define LEVEL_2_PAGE_TABLE_SIZE   (LEVEL_2_PAGE_TABLE_ENTRIES * PTR_SIZE)

Definition at line 44 of file footprint_client2.cpp.

◆ LEVEL_2_PAGE_TABLE_SLOT

#define LEVEL_2_PAGE_TABLE_SLOT (   addr)    (((addr) >> (PAGE_OFFSET_BITS)) & 0xFFF)

Definition at line 47 of file footprint_client2.cpp.

◆ MAX_FOOTPRINT_CONTEXTS_TO_LOG

#define MAX_FOOTPRINT_CONTEXTS_TO_LOG   (1000)

Definition at line 52 of file footprint_client2.cpp.

◆ PAGE_OFFSET

#define PAGE_OFFSET (   addr)    (addr & 0xFFFF)

Definition at line 30 of file footprint_client2.cpp.

◆ PAGE_OFFSET_BITS

#define PAGE_OFFSET_BITS   (16LL)

Definition at line 29 of file footprint_client2.cpp.

◆ PAGE_OFFSET_MASK

#define PAGE_OFFSET_MASK   (0xFFFF)

Definition at line 31 of file footprint_client2.cpp.

◆ PAGE_SIZE

#define PAGE_SIZE   (1 << PAGE_OFFSET_BITS)

Definition at line 34 of file footprint_client2.cpp.

◆ PTR_SIZE

#define PTR_SIZE   (sizeof(void*))

Definition at line 37 of file footprint_client2.cpp.

◆ THREAD_MAX

#define THREAD_MAX   (1024)

Definition at line 69 of file footprint_client2.cpp.

Function Documentation

◆ CheckDependence()

bool CheckDependence ( uint64_t  curAddr,
uint64_t  prevAddr 
)
inline

Definition at line 124 of file footprint_client2.cpp.

◆ ClientInit()

void ClientInit ( int  argc,
char *  argv[] 
)

Definition at line 85 of file footprint_client2.cpp.

References gTraceFile, and MAX_FILE_PATH.

Referenced by main().

◆ DecodingFootPrint()

void DecodingFootPrint ( const THREADID  threadid,
ContextHandle_t  myHandle,
ContextHandle_t  parentHandle,
void **  myMetric,
void **  parentMetric 
)

Definition at line 185 of file footprint_client2.cpp.

References node_metric_t::addressSet, and node_metric_t::addressSetDecoded.

Referenced by ThreadFiniFunc().

◆ FiniFunc()

VOID FiniFunc ( INT32  code,
VOID *  v 
)

Definition at line 270 of file footprint_client2.cpp.

Referenced by main().

◆ FootPrintCompare()

bool FootPrintCompare ( const struct sort_format_t first,
const struct sort_format_t second 
)
inline

Definition at line 221 of file footprint_client2.cpp.

References sort_format_t::footprint.

Referenced by PrintTopFootPrintPath().

◆ GetOrCreateShadowBaseAddress()

uint8_t* GetOrCreateShadowBaseAddress ( uint64_t  address)

◆ InstrumentInsCallback()

VOID InstrumentInsCallback ( INS  ins,
VOID *  v,
const uint32_t  slot 
)

Definition at line 168 of file footprint_client2.cpp.

References MemFunc().

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ MemFunc()

VOID MemFunc ( THREADID  id,
void *  addr,
bool  rwFlag,
UINT32  refSize 
)

◆ MergeFootPrint()

void MergeFootPrint ( const THREADID  threadid,
ContextHandle_t  myHandle,
ContextHandle_t  parentHandle,
void **  myMetric,
void **  parentMetric 
)

◆ PrintTopFootPrintPath()

◆ ThreadFiniFunc()

VOID ThreadFiniFunc ( THREADID  threadid,
const CONTEXT *  ctxt,
INT32  code,
VOID *  v 
)

Definition at line 255 of file footprint_client2.cpp.

References DecodingFootPrint(), gTraceFile, MergeFootPrint(), PrintTopFootPrintPath(), tv1, tv2, and tv3.

Referenced by main().

◆ Usage()

static INT32 Usage ( )
static

Definition at line 72 of file footprint_client2.cpp.

Referenced by main().

Variable Documentation

◆ gL1PageTable

uint8_t** gL1PageTable[LEVEL_1_PAGE_TABLE_SIZE]

Definition at line 49 of file footprint_client2.cpp.

Referenced by GetOrCreateShadowBaseAddress().

◆ gTraceFile

FILE* gTraceFile

Definition at line 78 of file footprint_client2.cpp.

Referenced by ClientInit(), main(), PrintTopFootPrintPath(), and ThreadFiniFunc().

◆ hmap_vector

unordered_map<uint32_t, struct node_metric_t> hmap_vector[THREAD_MAX]

Definition at line 70 of file footprint_client2.cpp.

Referenced by MemFunc(), MergeFootPrint(), and PrintTopFootPrintPath().

◆ tv1

struct timeval tv1

Definition at line 78 of file footprint_client2.cpp.

Referenced by main(), and ThreadFiniFunc().

◆ tv2

__thread struct timeval tv2

Definition at line 81 of file footprint_client2.cpp.

Referenced by ThreadFiniFunc().

◆ tv3

__thread struct timeval tv3

Definition at line 82 of file footprint_client2.cpp.

Referenced by ThreadFiniFunc().