xentrace: cleanup
PATCH 1/1 xentrace: cleanup
Hi!
Attached patch makes xentrace functions statich which have no prototype. Disable free_symbol() instead of removing it as not using this function may indicate a memory leak bug. This needs to be revisited.
Signed-off-by Christoph Egger <[email protected]>
Signature · 12 lines
AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Geschäftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplementär: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Geschäftsführer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
tools/xentrace/xenctx.c +16 -14
@@ -71,7 +71,7 @@ struct symbol {size_t kernel_stext, kernel_etext, kernel_sinittext, kernel_einittext, kernel_hypercallpage; -int is_kernel_text (size_t addr) +static int is_kernel_text (size_t addr) {#if defined (__i386__)if (symbol_table ==NULL )
@@ -96,7 +96,8 @@ int is_kernel_text(size_t addr)return 0 ; } -void free_symbol (struct symbol *symbol) +#if 0 +static void free_symbol (struct symbol *symbol) {if (symbol ==NULL )return ;
@@ -104,8 +105,9 @@ void free_symbol(struct symbol *symbol)free (symbol->name); free(symbol); } +#endif -void insert_symbol (struct symbol *symbol) +static void insert_symbol (struct symbol *symbol) {static struct symbol *prev =NULL ;struct symbol *s = symbol_table;
@@ -132,7 +134,7 @@ void insert_symbol(struct symbol *symbol prev = symbol; } -struct symbol *lookup_symbol (size_t address) +static struct symbol *lookup_symbol (size_t address) {struct symbol *s = symbol_table;
@@ -145,7 +147,7 @@ struct symbol *lookup_symbol(size_t addrreturn NULL ; } -void print_symbol (size_t addr) +static void print_symbol (size_t addr) {struct symbol *s;
@@ -163,7 +165,7 @@ void print_symbol(size_t addr)printf ("%s+%#x " , s->name, (unsigned int )(addr - s->address)); } -void read_symbol_table (const char *symtab) +static void read_symbol_table (const char *symtab) {char line[256 ];char *p;
@@ -240,7 +242,7 @@ char *flag_values[22][2] = { NULL, "cid" } // 21 Cpuid Identification Flag }; -void print_flags (uint64_t flags) +static void print_flags (uint64_t flags) {int i;
@@ -253,7 +255,7 @@ void print_flags(uint64_t flags)printf ("\n" ); } -void print_special (unsigned long *regs,const char *name,unsigned int mask) +static void print_special (unsigned long *regs,const char *name,unsigned int mask) {unsigned int i;
@@ -265,7 +267,7 @@ void print_special(unsigned long *regs,#endif #ifdef __i386__ -void print_ctx (vcpu_guest_context_t *ctx1) +static void print_ctx (vcpu_guest_context_t *ctx1) {struct cpu_user_regs *regs = &ctx1->user_regs;
@@ -294,7 +296,7 @@ void print_ctx(vcpu_guest_context_t *ctx } }#elif defined(__x86_64__) -void print_ctx (vcpu_guest_context_t *ctx1) +static void print_ctx (vcpu_guest_context_t *ctx1) {struct cpu_user_regs *regs = &ctx1->user_regs;
@@ -582,7 +584,7 @@ void print_ctx(vcpu_guest_context_t *ctx#endif #ifndef NO_TRANSLATION -void *map_page (vcpu_guest_context_t *ctx,int vcpu,size_t virt) +static void *map_page (vcpu_guest_context_t *ctx,int vcpu,size_t virt) {static unsigned long previous_mfn =0 ;static void *mapped =NULL ;
@@ -609,7 +611,7 @@ void *map_page(vcpu_guest_context_t *ctxreturn (void *)(mapped + offset); } -void print_stack (vcpu_guest_context_t *ctx,int vcpu) +static void print_stack (vcpu_guest_context_t *ctx,int vcpu) {struct cpu_user_regs *regs = &ctx->user_regs;size_t stack =STACK_POINTER (regs);
@@ -699,7 +701,7 @@ void print_stack(vcpu_guest_context_t *c }#endif -void dump_ctx (int vcpu) +static void dump_ctx (int vcpu) {int ret;vcpu_guest_context_any_t ctx;
@@ -748,7 +750,7 @@ void dump_ctx(int vcpu) } } -void usage (void ) +static void usage (void ) {printf ("usage:\n\n" );
tools/xentrace/xentrace.c +14 -14
@@ -68,7 +68,7 @@ static int event_fd = -1;static int event_fd =-1 ;static int virq_port =-1 ; -void close_handler (int signal) +static void close_handler (int signal) { interrupted =1 ; }
@@ -84,7 +84,7 @@ void close_handler(int signal)* Outputs the trace buffer to a filestream, prepending the CPU and size * of the buffer write. */ -void write_buffer (unsigned int cpu,unsigned char *start,int size, +static void write_buffer (unsigned int cpu,unsigned char *start,int size,int total_size,int outfd) {struct statvfs stat;
@@ -206,7 +206,7 @@ static void get_tbufs(unsigned long *mfn* * Maps the Xen trace buffers them into process address space. */ -struct t_buf *map_tbufs (unsigned long tbufs_mfn,unsigned int num, +static struct t_buf *map_tbufs (unsigned long tbufs_mfn,unsigned int num,unsigned long size) {struct t_buf *tbufs_mapped;
@@ -230,7 +230,7 @@ struct t_buf *map_tbufs(unsigned long tb* @type: the new mask type,0-event mask, 1-cpu mask * */ -void set_mask (uint32_t mask,int type) +static void set_mask (uint32_t mask,int type) {int ret =0 ;
@@ -258,7 +258,7 @@ void set_mask(uint32_t mask, int type)* Initialises an array of pointers to individual trace buffers within the * mapped region containing all trace buffers. */ -struct t_buf **init_bufs_ptrs (void *bufs_mapped,unsigned int num, +static struct t_buf **init_bufs_ptrs (void *bufs_mapped,unsigned int num,unsigned long size) {int i;
@@ -291,7 +291,7 @@ struct t_buf **init_bufs_ptrs(void *bufs* mapped in user space. Note that the trace buffer metadata contains machine * pointers - the array returned allows more convenient access to them. */ -unsigned char **init_rec_ptrs (struct t_buf **meta,unsigned int num) +static unsigned char **init_rec_ptrs (struct t_buf **meta,unsigned int num) {int i;unsigned char **data;
@@ -312,7 +312,7 @@ unsigned char **init_rec_ptrs(struct t_b/** * get_num_cpus - get the number of logical CPUs */ -unsigned int get_num_cpus (void ) +static unsigned int get_num_cpus (void ) {xc_physinfo_t physinfo = {0 };int ret;
@@ -331,7 +331,7 @@ unsigned int get_num_cpus(void)/** * event_init - setup to receive the VIRQ_TBUF event */ -void event_init (void ) +static void event_init (void ) {int rc;
@@ -354,7 +354,7 @@ void event_init(void)* wait_for_event_or_timeout - sleep for the specified number of milliseconds, * or until an VIRQ_TBUF event occurs */ -void wait_for_event_or_timeout (unsigned long milliseconds) +static void wait_for_event_or_timeout (unsigned long milliseconds) {int rc;struct pollfd fd = { .fd = event_fd,
@@ -394,7 +394,7 @@ void wait_for_event_or_timeout(unsigned* monitor_tbufs - monitor the contents of tbufs and output to a file * @logfile: the FILE * representing the file to log to */ -int monitor_tbufs (int outfd) +static int monitor_tbufs (int outfd) {int i;
@@ -512,7 +512,7 @@ const char *program_version = "xentrconst char *program_version ="xentrace v1.2" ;const char *program_bug_address ="<[email protected]>" ; -void usage (void ) +static void usage (void ) {#define USAGE_STR \ "Usage: xentrace [OPTION...] [output file]\n" \
@@ -554,7 +554,7 @@ void usage(void) }/* convert the argument string pointed to by arg to a long int representation */ -long argtol (const char *restrict arg,int base) +static long argtol (const char *restrict arg,int base) {char *endp;long val;
@@ -574,7 +574,7 @@ long argtol(const char *restrict arg, inreturn val; } -int parse_evtmask (char *arg) +static int parse_evtmask (char *arg) {/* search filtering class */ if (strcmp (arg,"gen" ) ==0 ){
@@ -595,7 +595,7 @@ int parse_evtmask(char *arg) }/* parse command line arguments */ -void parse_args (int argc,char **argv) +static void parse_args (int argc,char **argv) {int option;static struct option long_options[] = {
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel