#ifndef UCS_PROFILE_DEFS_H_
#define UCS_PROFILE_DEFS_H_
#include <ucs/config/global_opts.h>
#include <ucs/sys/compiler_def.h>
#include <ucs/time/time_def.h>
#include <limits.h>
BEGIN_C_DECLS
#define UCS_PROFILE_STACK_MAX 64
#define UCS_PROFILE_FILE_VERSION 2u
enum {
UCS_PROFILE_MODE_ACCUM,
UCS_PROFILE_MODE_LOG,
UCS_PROFILE_MODE_LAST
};
typedef enum {
UCS_PROFILE_TYPE_SAMPLE,
UCS_PROFILE_TYPE_SCOPE_BEGIN,
UCS_PROFILE_TYPE_SCOPE_END,
UCS_PROFILE_TYPE_REQUEST_NEW,
UCS_PROFILE_TYPE_REQUEST_EVENT,
UCS_PROFILE_TYPE_REQUEST_FREE,
UCS_PROFILE_TYPE_LAST
} ucs_profile_type_t;
typedef struct ucs_profile_header {
uint32_t version;
char ucs_path[1024];
char cmdline[1024];
char hostname[64];
uint32_t pid;
uint32_t mode;
uint32_t num_locations;
uint32_t num_threads;
uint64_t one_second;
} UCS_S_PACKED ucs_profile_header_t;
typedef struct ucs_profile_location {
char file[64];
char function[64];
char name[32];
int line;
uint8_t type;
} UCS_S_PACKED ucs_profile_location_t;
typedef struct ucs_profile_thread_header {
uint32_t tid;
uint64_t start_time;
uint64_t end_time;
uint64_t num_records;
} UCS_S_PACKED ucs_profile_thread_header_t;
typedef struct ucs_profile_thread_location {
uint64_t total_time;
size_t count;
} UCS_S_PACKED ucs_profile_thread_location_t;
typedef struct ucs_profile_record {
uint64_t timestamp;
uint64_t param64;
uint32_t param32;
uint32_t location;
} UCS_S_PACKED ucs_profile_record_t;
typedef struct ucs_profile_context ucs_profile_context_t;
extern const char *ucs_profile_mode_names[];
extern ucs_profile_context_t *ucs_profile_default_ctx;
ucs_status_t ucs_profile_init(unsigned profile_mode, const char *file_name,
size_t max_file_size, ucs_profile_context_t **ctx_p);
void ucs_profile_cleanup(ucs_profile_context_t *ctx);
void ucs_profile_dump(ucs_profile_context_t *ctx);
END_C_DECLS
#endif