76 #include <sys/types.h> 78 #include <sys/resource.h> 97 #define ADDR_SIZE (256 * 1024) 98 #define INIT_INBUF_SIZE 2000 102 #define END_OF_FILE -2 137 while (len < count) {
138 ret =
read(fd, ((
char *) buf) + len, count - len);
139 if (ret < 0 && errno != EINTR) {
164 while (len < count) {
165 ret =
write(fd, ((
const char *) buf) + len, count - len);
166 if (ret < 0 && errno != EINTR) {
186 memset(mesg, 0,
sizeof(*mesg));
227 errx(1,
"write to fdout failed");
236 errx(1,
"write to fdout failed");
264 if (sig == SIGPIPE) {
265 errx(0,
"hpcrun has prematurely exited");
272 errx(1,
"got signal outside sigsetjmp: %d", sig);
280 struct sigaction act;
284 sigemptyset(&act.sa_mask);
286 if (sigaction(SIGSEGV, &act,
NULL) != 0) {
287 err(1,
"sigaction failed on SIGSEGV");
289 if (sigaction(SIGBUS, &act,
NULL) != 0) {
290 err(1,
"sigaction failed on SIGBUS");
292 if (sigaction(SIGABRT, &act,
NULL) != 0) {
293 err(1,
"sigaction failed on SIGABRT");
295 if (sigaction(SIGPIPE, &act,
NULL) != 0) {
296 err(1,
"sigaction failed on SIGPIPE");
315 err(1,
"realloc for inbuf failed");
321 err(1,
"read from fdin failed");
329 if (sigsetjmp(
jmpbuf, 1) == 0) {
348 errx(1,
"write to fdout failed");
356 if (getrusage(RUSAGE_SELF, &usage) == 0) {
366 err(1,
"write to fdout failed");
372 errx(1,
"caught signal after telling client ok");
379 errx(1,
"write to fdout failed");
399 err(1,
"realloc for inbuf failed");
405 err(1,
"read from fdin failed");
413 if (sigsetjmp(
jmpbuf, 1) == 0) {
432 errx(1,
"write to fdout failed");
440 if (getrusage(RUSAGE_SELF, &usage) == 0) {
450 err(1,
"write to fdout failed");
456 errx(1,
"caught signal after telling client ok");
463 errx(1,
"write to fdout failed");
480 err(1,
"malloc for inbuf failed");
489 err(1,
"read from fdin failed");
514 err(1,
"unknown mesg type from client: %d", mesg.
type);
static void signal_handler(int sig)
ssize_t MONITOR_EXT_WRAP_NAME() write(int fd, const void *buf, size_t count)
void system_server(DiscoverFnTy fn_discovery, int fd1, int fd2)
static void * addr_buf[ADDR_SIZE]
static int read_mesg(struct syserv_mesg *mesg)
void code_ranges_reinit(void)
static void signal_handler_init(void)
static long max_num_addrs
static long total_num_addrs
static int read_all(int fd, void *buf, size_t count)
static void do_query(DiscoverFnTy fn_discovery, struct syserv_mesg *mesg)
static void do_query_var(DiscoverFnTy fn_discovery, struct syserv_mesg *mesg)
static struct syserv_fnbounds_info fnb_info
static int write_all(int fd, const void *buf, size_t count)
void syserv_add_addr(void *addr, long func_entry_map_size)
void *MONITOR_EXT_WRAP_NAME() realloc(void *ptr, size_t bytes)
void dump_file_info(const char *filename, DiscoverFnTy fn_discovery, int query)
void variable_entries_reinit(void)
ssize_t MONITOR_EXT_WRAP_NAME() read(int fd, void *buf, size_t count)
void *MONITOR_EXT_WRAP_NAME() malloc(size_t bytes)
void function_entries_reinit(void)
void syserv_add_header(int is_relocatable, uintptr_t ref_offset)
uint64_t reference_offset
static int write_mesg(int32_t type, int64_t len)