HPCToolkit
main.c File Reference
#include <sys/types.h>
#include <pthread.h>
#include <unistd.h>
#include <setjmp.h>
#include <stdbool.h>
#include <stdint.h>
#include <inttypes.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>
#include <monitor.h>
#include <include/uint.h>
#include <include/hpctoolkit-config.h>
#include "main.h"
#include "disabled.h"
#include "env.h"
#include "loadmap.h"
#include "files.h"
#include "fnbounds_interface.h"
#include "fnbounds_table_interface.h"
#include "hpcrun_dlfns.h"
#include "hpcrun_options.h"
#include "hpcrun_return_codes.h"
#include "hpcrun_stats.h"
#include "name.h"
#include "start-stop.h"
#include "custom-init.h"
#include "cct_insert_backtrace.h"
#include "safe-sampling.h"
#include "metrics.h"
#include "sample_event.h"
#include <sample-sources/none.h>
#include <sample-sources/itimer.h>
#include "sample_sources_registered.h"
#include "sample_sources_all.h"
#include "segv_handler.h"
#include "sample_prob.h"
#include "term_handler.h"
#include "epoch.h"
#include "thread_data.h"
#include "threadmgr.h"
#include "thread_use.h"
#include "trace.h"
#include "write_data.h"
#include <utilities/token-iter.h>
#include <memory/hpcrun-malloc.h>
#include <memory/mmap.h>
#include <monitor-exts/monitor_ext.h>
#include <cct/cct.h>
#include <unwind/common/backtrace.h>
#include <unwind/common/unwind.h>
#include <utilities/arch/context-pc.h>
#include <lush/lush-backtrace.h>
#include <lush/lush-pthread.h>
#include <lib/prof-lean/hpcrun-fmt.h>
#include <lib/prof-lean/hpcio.h>
#include <messages/messages.h>
#include <messages/debug-flag.h>

Go to the source code of this file.

Classes

struct  local_thread_data_t
 
struct  fork_data_t
 
struct  hpcrun_aux_cleanup_t
 

Macros

#define GET_NEW_AUX_CLEANUP_NODE(node_ptr)
 
#define ADD_TO_FREE_AUX_CLEANUP_LIST(node_ptr)
 

Typedefs

typedef struct local_thread_data_t local_thread_data_t
 
typedef struct fork_data_t fork_data_t
 

Enumerations

enum  _local_const { PROC_NAME_LEN = 2048, ITIMER_EVENT = 0, _TST_EVENT = 0 }
 

Functions

void hpcrun_set_retain_recursion_mode (bool mode)
 
void hpcrun_dump_intervals (void *addr)
 
static int dump_interval_handler (int sig, siginfo_t *info, void *ctxt) __attribute__((unused))
 
static void setup_main_bounds_check (void *main_addr)
 
static void copy_execname (char *process_name)
 
bool hpcrun_is_initialized ()
 
void * hpcrun_get_addr_main (void)
 
bool hpcrun_inbounds_main (void *addr)
 
char * hpcrun_get_execname (void)
 
bool hpcrun_is_safe_to_sync (const char *fn)
 
void hpcrun_set_safe_to_sync (void)
 
static int abort_timeout_handler (int sig, siginfo_t *siginfo, void *context)
 
static void hpcrun_set_abort_timeout ()
 
siglongjmp_fcnhpcrun_get_real_siglongjmp (void)
 
void hpcrun_init_internal (bool is_child)
 
hpcrun_aux_cleanup_thpcrun_process_aux_cleanup_add (void(*func)(void *), void *arg)
 
void hpcrun_process_aux_cleanup_remove (hpcrun_aux_cleanup_t *node)
 
static void hpcrun_process_aux_cleanup_action ()
 
void hpcrun_fini_internal ()
 
void hpcrun_init_thread_support ()
 
static void logit (cct_node_t *n, cct_op_arg_t arg, size_t l)
 
void * hpcrun_thread_init (int id, local_thread_data_t *local_thread_data)
 
void hpcrun_thread_fini (epoch_t *epoch)
 
void hpcrun_continue ()
 
void hpcrun_wait ()
 
void * monitor_init_process (int *argc, char **argv, void *data)
 
void monitor_fini_process (int how, void *data)
 
void * monitor_pre_fork (void)
 
void monitor_post_fork (pid_t child, void *data)
 
void monitor_mpi_pre_init (void)
 
void monitor_init_mpi (int *argc, char ***argv)
 
void monitor_init_thread_support (void)
 
void * monitor_thread_pre_create (void)
 
void monitor_thread_post_create (void *data)
 
void * monitor_init_thread (int tid, void *data)
 
void monitor_fini_thread (void *init_thread_data)
 
size_t monitor_reset_stacksize (size_t old_size)
 
void hpcrun_set_real_siglongjmp (void)
 
void monitor_pre_dlopen (const char *path, int flags)
 
void monitor_dlopen (const char *path, int flags, void *handle)
 
void monitor_dlclose (void *handle)
 
void monitor_post_dlclose (void *handle, int ret)
 

Variables

int lush_metrics = 0
 
__thread bool hpcrun_thread_suppress_sample = true
 
static hpcrun_options_t opts
 
static bool hpcrun_is_initialized_private = false
 
static bool safe_to_sync_sample = false
 
static void * main_addr = NULL
 
static void * main_lower = NULL
 
static void * main_upper = (void*) (intptr_t) -1
 
static void * main_addr_dl = NULL
 
static void * main_lower_dl = NULL
 
static void * main_upper_dl = (void*) (intptr_t) -1
 
static spinlock_t hpcrun_aux_cleanup_lock = SPINLOCK_UNLOCKED
 
static hpcrun_aux_cleanup_thpcrun_aux_cleanup_list_head = NULL
 
static hpcrun_aux_cleanup_thpcrun_aux_cleanup_free_list_head = NULL
 
static char execname [PATH_MAX] = {'\0'}
 
static sigjmp_buf ivd_jb
 
volatile int HPCRUN_DEBUGGER_WAIT = 1
 
static fork_data_t from_fork
 
static siglongjmp_fcnreal_siglongjmp = NULL
 

Macro Definition Documentation

◆ ADD_TO_FREE_AUX_CLEANUP_LIST

#define ADD_TO_FREE_AUX_CLEANUP_LIST (   node_ptr)
Value:
do { (node_ptr)->next = hpcrun_aux_cleanup_free_list_head; \
hpcrun_aux_cleanup_free_list_head = (node_ptr); }while(0)
static hpcrun_aux_cleanup_t * hpcrun_aux_cleanup_free_list_head
Definition: main.c:213

Definition at line 533 of file main.c.

◆ GET_NEW_AUX_CLEANUP_NODE

#define GET_NEW_AUX_CLEANUP_NODE (   node_ptr)
Value:
do { \
hpcrun_aux_cleanup_free_list_head = hpcrun_aux_cleanup_free_list_head->next; \
} else { \
} \
} while(0)
void * hpcrun_malloc(size_t size)
Definition: mem.c:275
struct hpcrun_aux_cleanup_t * next
Definition: main.c:172
static hpcrun_aux_cleanup_t * hpcrun_aux_cleanup_free_list_head
Definition: main.c:213

Definition at line 524 of file main.c.

Typedef Documentation

◆ fork_data_t

typedef struct fork_data_t fork_data_t

◆ local_thread_data_t

Enumeration Type Documentation

◆ _local_const

Enumerator
PROC_NAME_LEN 
ITIMER_EVENT 
_TST_EVENT 

Definition at line 164 of file main.c.

Function Documentation

◆ abort_timeout_handler()

static int abort_timeout_handler ( int  sig,
siginfo_t *  siginfo,
void *  context 
)
static

Definition at line 344 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_execname()

static void copy_execname ( char *  process_name)
static

Definition at line 258 of file main.c.

Here is the caller graph for this function:

◆ dump_interval_handler()

static int dump_interval_handler ( int  sig,
siginfo_t *  info,
void *  ctxt 
)
static

Definition at line 377 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_continue()

void hpcrun_continue ( )

Definition at line 758 of file main.c.

◆ hpcrun_dump_intervals()

void hpcrun_dump_intervals ( void *  addr)

Definition at line 734 of file ppc64-unwind-interval.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_fini_internal()

void hpcrun_fini_internal ( )

Definition at line 603 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_get_addr_main()

void* hpcrun_get_addr_main ( void  )

Definition at line 278 of file main.c.

◆ hpcrun_get_execname()

char* hpcrun_get_execname ( void  )

Definition at line 304 of file main.c.

◆ hpcrun_get_real_siglongjmp()

siglongjmp_fcn * hpcrun_get_real_siglongjmp ( void  )

Definition at line 1142 of file main.c.

Here is the caller graph for this function:

◆ hpcrun_inbounds_main()

bool hpcrun_inbounds_main ( void *  addr)

Definition at line 284 of file main.c.

Here is the caller graph for this function:

◆ hpcrun_init_internal()

void hpcrun_init_internal ( bool  is_child)

Definition at line 388 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_init_thread_support()

void hpcrun_init_thread_support ( )

Definition at line 654 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_is_initialized()

bool hpcrun_is_initialized ( )

Definition at line 272 of file main.c.

Here is the caller graph for this function:

◆ hpcrun_is_safe_to_sync()

bool hpcrun_is_safe_to_sync ( const char *  fn)

Definition at line 314 of file main.c.

◆ hpcrun_process_aux_cleanup_action()

static void hpcrun_process_aux_cleanup_action ( )
static

Definition at line 581 of file main.c.

Here is the caller graph for this function:

◆ hpcrun_process_aux_cleanup_add()

hpcrun_aux_cleanup_t* hpcrun_process_aux_cleanup_add ( void(*)(void *)  func,
void *  arg 
)

Definition at line 540 of file main.c.

Here is the call graph for this function:

◆ hpcrun_process_aux_cleanup_remove()

void hpcrun_process_aux_cleanup_remove ( hpcrun_aux_cleanup_t node)

Definition at line 560 of file main.c.

Here is the call graph for this function:

◆ hpcrun_set_abort_timeout()

static void hpcrun_set_abort_timeout ( )
static

Definition at line 355 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_set_real_siglongjmp()

void hpcrun_set_real_siglongjmp ( void  )

Definition at line 1148 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_set_retain_recursion_mode()

void hpcrun_set_retain_recursion_mode ( bool  mode)

Definition at line 138 of file cct_insert_backtrace.c.

Here is the caller graph for this function:

◆ hpcrun_set_safe_to_sync()

void hpcrun_set_safe_to_sync ( void  )

Definition at line 320 of file main.c.

Here is the caller graph for this function:

◆ hpcrun_thread_fini()

void hpcrun_thread_fini ( epoch_t epoch)

Routine to handle the end of the thread: call sample sources to stop and finish the thread action notify thread manager of the end of the thread (so that it can either clean-up the data, or reuse the data for another thread)

Definition at line 722 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_thread_init()

void* hpcrun_thread_init ( int  id,
local_thread_data_t local_thread_data 
)

Definition at line 675 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hpcrun_wait()

void hpcrun_wait ( )

Definition at line 765 of file main.c.

Here is the caller graph for this function:

◆ logit()

static void logit ( cct_node_t n,
cct_op_arg_t  arg,
size_t  l 
)
static

Definition at line 664 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monitor_dlclose()

void monitor_dlclose ( void *  handle)

Definition at line 1563 of file main.c.

Here is the call graph for this function:

◆ monitor_dlopen()

void monitor_dlopen ( const char *  path,
int  flags,
void *  handle 
)

Definition at line 1549 of file main.c.

Here is the call graph for this function:

◆ monitor_fini_process()

void monitor_fini_process ( int  how,
void *  data 
)

Definition at line 875 of file main.c.

Here is the call graph for this function:

◆ monitor_fini_thread()

void monitor_fini_thread ( void *  init_thread_data)

Definition at line 1092 of file main.c.

Here is the call graph for this function:

◆ monitor_init_mpi()

void monitor_init_mpi ( int *  argc,
char ***  argv 
)

Definition at line 964 of file main.c.

Here is the call graph for this function:

◆ monitor_init_process()

void* monitor_init_process ( int *  argc,
char **  argv,
void *  data 
)

Definition at line 785 of file main.c.

Here is the call graph for this function:

◆ monitor_init_thread()

void* monitor_init_thread ( int  tid,
void *  data 
)

Definition at line 1061 of file main.c.

Here is the call graph for this function:

◆ monitor_init_thread_support()

void monitor_init_thread_support ( void  )

Definition at line 983 of file main.c.

Here is the call graph for this function:

◆ monitor_mpi_pre_init()

void monitor_mpi_pre_init ( void  )

Definition at line 949 of file main.c.

Here is the call graph for this function:

◆ monitor_post_dlclose()

void monitor_post_dlclose ( void *  handle,
int  ret 
)

Definition at line 1575 of file main.c.

Here is the call graph for this function:

◆ monitor_post_fork()

void monitor_post_fork ( pid_t  child,
void *  data 
)

Definition at line 917 of file main.c.

Here is the call graph for this function:

◆ monitor_pre_dlopen()

void monitor_pre_dlopen ( const char *  path,
int  flags 
)

Definition at line 1535 of file main.c.

Here is the call graph for this function:

◆ monitor_pre_fork()

void* monitor_pre_fork ( void  )

Definition at line 892 of file main.c.

Here is the call graph for this function:

◆ monitor_reset_stacksize()

size_t monitor_reset_stacksize ( size_t  old_size)

Definition at line 1109 of file main.c.

◆ monitor_thread_post_create()

void monitor_thread_post_create ( void *  data)

Definition at line 1047 of file main.c.

Here is the call graph for this function:

◆ monitor_thread_pre_create()

void* monitor_thread_pre_create ( void  )

Definition at line 996 of file main.c.

Here is the call graph for this function:

◆ setup_main_bounds_check()

static void setup_main_bounds_check ( void *  main_addr)
static

Definition at line 220 of file main.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ execname

char execname[PATH_MAX] = {'\0'}
static

Definition at line 214 of file main.c.

◆ from_fork

fork_data_t from_fork
static

Definition at line 889 of file main.c.

◆ hpcrun_aux_cleanup_free_list_head

hpcrun_aux_cleanup_t* hpcrun_aux_cleanup_free_list_head = NULL
static

Definition at line 213 of file main.c.

◆ hpcrun_aux_cleanup_list_head

hpcrun_aux_cleanup_t* hpcrun_aux_cleanup_list_head = NULL
static

Definition at line 212 of file main.c.

◆ hpcrun_aux_cleanup_lock

spinlock_t hpcrun_aux_cleanup_lock = SPINLOCK_UNLOCKED
static

Definition at line 211 of file main.c.

◆ HPCRUN_DEBUGGER_WAIT

volatile int HPCRUN_DEBUGGER_WAIT = 1

Definition at line 755 of file main.c.

◆ hpcrun_is_initialized_private

bool hpcrun_is_initialized_private = false
static

Definition at line 201 of file main.c.

◆ hpcrun_thread_suppress_sample

__thread bool hpcrun_thread_suppress_sample = true

Definition at line 193 of file main.c.

◆ ivd_jb

sigjmp_buf ivd_jb
static

Definition at line 372 of file main.c.

◆ lush_metrics

int lush_metrics = 0

Definition at line 188 of file main.c.

◆ main_addr

void* main_addr = NULL
static

Definition at line 203 of file main.c.

◆ main_addr_dl

void* main_addr_dl = NULL
static

Definition at line 207 of file main.c.

◆ main_lower

void* main_lower = NULL
static

Definition at line 204 of file main.c.

◆ main_lower_dl

void* main_lower_dl = NULL
static

Definition at line 208 of file main.c.

◆ main_upper

void* main_upper = (void*) (intptr_t) -1
static

Definition at line 205 of file main.c.

◆ main_upper_dl

void* main_upper_dl = (void*) (intptr_t) -1
static

Definition at line 209 of file main.c.

◆ opts

hpcrun_options_t opts
static

Definition at line 200 of file main.c.

◆ real_siglongjmp

siglongjmp_fcn* real_siglongjmp = NULL
static

Definition at line 1139 of file main.c.

◆ safe_to_sync_sample

bool safe_to_sync_sample = false
static

Definition at line 202 of file main.c.