From 400235a6ae7e4b1b275ebaa1c77c7801b018351b Mon Sep 17 00:00:00 2001 From: hunt Date: Thu, 9 Nov 2006 17:53:41 +0000 Subject: [PATCH] 2006-11-09 Martin Hunt * librelay.c: Change all references to transport messages to use the new names with "_stp" prefix. (stp_main_loop): For STP_SYMBOLS, check pointer size and endianess to confirm staprun is compatible with the kernel. * librelay.h: Move a bunch of common includes here. * stpd.c: Cleanup includes. * symbols.c: Ditto. --- runtime/stpd/ChangeLog | 11 ++++++++++ runtime/stpd/librelay.c | 48 ++++++++++++++++++++--------------------- runtime/stpd/librelay.h | 11 ++++++++++ runtime/stpd/stpd.c | 6 +----- runtime/stpd/symbols.c | 10 --------- 5 files changed, 47 insertions(+), 39 deletions(-) diff --git a/runtime/stpd/ChangeLog b/runtime/stpd/ChangeLog index 82f3c59c3..15f151ba1 100644 --- a/runtime/stpd/ChangeLog +++ b/runtime/stpd/ChangeLog @@ -1,3 +1,14 @@ +2006-11-09 Martin Hunt + + * librelay.c: Change all references to transport messages + to use the new names with "_stp" prefix. + (stp_main_loop): For STP_SYMBOLS, check pointer size and + endianess to confirm staprun is compatible with the kernel. + + * librelay.h: Move a bunch of common includes here. + * stpd.c: Cleanup includes. + * symbols.c: Ditto. + 2006-11-02 Martin Hunt * symbols.c: New file. Sends symbol and module information to diff --git a/runtime/stpd/librelay.c b/runtime/stpd/librelay.c index 259c2cc73..04ea7285e 100644 --- a/runtime/stpd/librelay.c +++ b/runtime/stpd/librelay.c @@ -19,16 +19,9 @@ * Copyright (C) Red Hat Inc, 2005, 2006 * */ -#include -#include -#include -#include -#include +#include "librelay.h" #include -#include -#include #include -#include #include #include #include @@ -39,8 +32,6 @@ #include #include #include -#include -#include "librelay.h" /* stp_check script */ @@ -106,7 +97,7 @@ extern gid_t cmd_gid; /* per-cpu buffer info */ static struct buf_status { - struct buf_info info; + struct _stp_buf_info info; unsigned max_backlog; /* max # sub-buffers ready at one time */ } status[NR_CPUS]; @@ -295,7 +286,7 @@ static void wait_for_percpu_threads(int n) /** * process_subbufs - write ready subbufs to disk */ -static int process_subbufs(struct buf_info *info) +static int process_subbufs(struct _stp_buf_info *info) { unsigned subbufs_ready, start_subbuf, end_subbuf, subbuf_idx, i; int len, cpu = info->cpu; @@ -333,7 +324,7 @@ static void *reader_thread(void *data) int rc; int cpu = (long)data; struct pollfd pollfd; - struct consumed_info consumed_info; + struct _stp_consumed_info consumed_info; unsigned subbufs_consumed; pollfd.fd = relay_file[cpu]; @@ -353,7 +344,7 @@ static void *reader_thread(void *data) } rc = read(proc_file[cpu], &status[cpu].info, - sizeof(struct buf_info)); + sizeof(struct _stp_buf_info)); subbufs_consumed = process_subbufs(&status[cpu].info); if (subbufs_consumed) { if (subbufs_consumed > status[cpu].max_backlog) @@ -361,7 +352,7 @@ static void *reader_thread(void *data) status[cpu].info.consumed += subbufs_consumed; consumed_info.cpu = cpu; consumed_info.consumed = subbufs_consumed; - if (write (proc_file[cpu], &consumed_info, sizeof(struct consumed_info)) < 0) + if (write (proc_file[cpu], &consumed_info, sizeof(struct _stp_consumed_info)) < 0) fprintf(stderr,"WARNING: writing consumed info failed.\n"); } if (status[cpu].info.flushing) @@ -496,7 +487,7 @@ void system_cmd(char *cmd) int init_stp(int print_summary) { char buf[1024]; - struct transport_info ti; + struct _stp_transport_info ti; pid_t pid; int rstatus; @@ -779,7 +770,7 @@ int stp_main_loop(void) } case STP_START: { - struct transport_start *t = (struct transport_start *)data; + struct _stp_transport_start *t = (struct _stp_transport_start *)data; dbug("probe_start() returned %d\n", t->pid); if (t->pid < 0) { if (target_cmd) @@ -791,14 +782,14 @@ int stp_main_loop(void) } case STP_SYSTEM: { - struct cmd_info *c = (struct cmd_info *)data; + struct _stp_cmd_info *c = (struct _stp_cmd_info *)data; system_cmd(c->cmd); break; } case STP_TRANSPORT_INFO: { - struct transport_info *info = (struct transport_info *)data; - struct transport_start ts; + struct _stp_transport_info *info = (struct _stp_transport_info *)data; + struct _stp_transport_start ts; transport_mode = info->transport_mode; params.subbuf_size = info->subbuf_size; params.n_subbufs = info->n_subbufs; @@ -825,8 +816,7 @@ int stp_main_loop(void) if (!ofp) { fprintf (stderr, "ERROR: couldn't open output file %s: errcode = %s\n", outfile_name, strerror(errno)); - /* FIXME. Need to cleanup properly */ - exit(1); + cleanup_and_exit(0); } } ts.pid = getpid(); @@ -835,7 +825,7 @@ int stp_main_loop(void) } case STP_MODULE: { - struct transport_start ts; + struct _stp_transport_start ts; if (do_module(data)) { ts.pid = getpid(); send_request(STP_START, &ts, sizeof(ts)); @@ -844,8 +834,18 @@ int stp_main_loop(void) } case STP_SYMBOLS: { - struct transport_start ts; + struct _stp_symbol_req *req = (struct _stp_symbol_req *)data; + struct _stp_transport_start ts; dbug("STP_SYMBOLS request received\n"); + if (req->endian != 0x1234) { + fprintf(stderr,"ERROR: staprun is compiled with different endianess than the kernel!\n"); + cleanup_and_exit(0); + } + if (req->ptr_size != sizeof(char *)) { + fprintf(stderr,"ERROR: staprun is compiled with %d-bit pointers and the kernel uses %d-bit.\n", + 8*sizeof(char *), 8*req->ptr_size); + cleanup_and_exit(0); + } do_kernel_symbols(); ts.pid = getpid(); send_request(STP_START, &ts, sizeof(ts)); diff --git a/runtime/stpd/librelay.h b/runtime/stpd/librelay.h index 38d623698..15ef6c407 100644 --- a/runtime/stpd/librelay.h +++ b/runtime/stpd/librelay.h @@ -1,3 +1,14 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "../transport/transport_msgs.h" #ifdef DEBUG diff --git a/runtime/stpd/stpd.c b/runtime/stpd/stpd.c index 5420cf80e..f5c2ea134 100644 --- a/runtime/stpd/stpd.c +++ b/runtime/stpd/stpd.c @@ -20,12 +20,8 @@ * */ -#include -#include -#include -#include -#include #include "librelay.h" +#include extern char *optarg; extern int optopt; diff --git a/runtime/stpd/symbols.c b/runtime/stpd/symbols.c index 09724ea2c..7138e17c6 100644 --- a/runtime/stpd/symbols.c +++ b/runtime/stpd/symbols.c @@ -9,16 +9,6 @@ * later version. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "librelay.h" #include "../sym.h" -- 2.43.5