diff options
Diffstat (limited to 'lib/profile/InstrProfilingInternal.h')
-rw-r--r-- | lib/profile/InstrProfilingInternal.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/lib/profile/InstrProfilingInternal.h b/lib/profile/InstrProfilingInternal.h index ede39cd9d713..4aab78ea509c 100644 --- a/lib/profile/InstrProfilingInternal.h +++ b/lib/profile/InstrProfilingInternal.h @@ -11,6 +11,7 @@ #define PROFILE_INSTRPROFILING_INTERNALH_ #include "InstrProfiling.h" +#include "stddef.h" /*! * \brief Write instrumentation data to the given buffer, given explicit @@ -37,4 +38,81 @@ int __llvm_profile_write_buffer_internal( const __llvm_profile_data *DataEnd, const uint64_t *CountersBegin, const uint64_t *CountersEnd, const char *NamesBegin, const char *NamesEnd); +/*! + * The data structure describing the data to be written by the + * low level writer callback function. + */ +typedef struct ProfDataIOVec { + const void *Data; + size_t ElmSize; + size_t NumElm; +} ProfDataIOVec; + +typedef uint32_t (*WriterCallback)(ProfDataIOVec *, uint32_t NumIOVecs, + void **WriterCtx); + +/*! + * The data structure for buffered IO of profile data. + */ +typedef struct ProfBufferIO { + /* File handle. */ + void *File; + /* Low level IO callback. */ + WriterCallback FileWriter; + /* The start of the buffer. */ + uint8_t *BufferStart; + /* Total size of the buffer. */ + uint32_t BufferSz; + /* Current byte offset from the start of the buffer. */ + uint32_t CurOffset; +} ProfBufferIO; + +/* The creator interface used by testing. */ +ProfBufferIO *llvmCreateBufferIOInternal(void *File, uint32_t DefaultBufferSz); +/*! + * This is the interface to create a handle for buffered IO. + */ +ProfBufferIO *llvmCreateBufferIO(WriterCallback FileWriter, void *File, + uint32_t DefaultBufferSz); +/*! + * The interface to destroy the bufferIO handle and reclaim + * the memory. + */ +void llvmDeleteBufferIO(ProfBufferIO *BufferIO); + +/*! + * This is the interface to write \c Data of \c Size bytes through + * \c BufferIO. Returns 0 if successful, otherwise return -1. + */ +int llvmBufferIOWrite(ProfBufferIO *BufferIO, const uint8_t *Data, + uint32_t Size); +/*! + * The interface to flush the remaining data in the buffer. + * through the low level writer callback. + */ +int llvmBufferIOFlush(ProfBufferIO *BufferIO); + +/* The low level interface to write data into a buffer. It is used as the + * callback by other high level writer methods such as buffered IO writer + * and profile data writer. */ +uint32_t llvmBufferWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs, + void **WriterCtx); + +int llvmWriteProfData(WriterCallback Writer, void *WriterCtx, + struct ValueProfData **ValueDataArray, + const uint64_t ValueDataSize); +int llvmWriteProfDataImpl(WriterCallback Writer, void *WriterCtx, + const __llvm_profile_data *DataBegin, + const __llvm_profile_data *DataEnd, + const uint64_t *CountersBegin, + const uint64_t *CountersEnd, + struct ValueProfData **ValueDataBeginArray, + const uint64_t ValueDataSize, const char *NamesBegin, + const char *NamesEnd); + +extern char *(*GetEnvHook)(const char *); +extern void (*FreeHook)(void *); +extern void* (*CallocHook)(size_t, size_t); +extern uint32_t VPBufferSize; + #endif |