Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158253
b: refs/heads/master
c: cd84c2a
h: refs/heads/master
i:
  158251: 9ff53bb
v: v3
  • Loading branch information
Frederic Weisbecker committed Aug 12, 2009
1 parent 747abf6 commit e9e9e48
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 200 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9f8666971185b86615a074bcac67c90fdf8af8bc
refs/heads/master: cd84c2ac6d6425dd4d1b80a2231e534b9b03df18
1 change: 1 addition & 0 deletions trunk/tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ LIB_OBJS += util/pager.o
LIB_OBJS += util/header.o
LIB_OBJS += util/callchain.o
LIB_OBJS += util/values.o
LIB_OBJS += util/debug.o

BUILTIN_OBJS += builtin-annotate.o
BUILTIN_OBJS += builtin-help.o
Expand Down
96 changes: 0 additions & 96 deletions trunk/tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#define SHOW_HV 4

static char const *input_name = "perf.data";
static char *vmlinux = "vmlinux";

static char default_sort_order[] = "comm,symbol";
static char *sort_order = default_sort_order;
Expand All @@ -37,9 +36,6 @@ static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
static int dump_trace = 0;
#define dprintf(x...) do { if (dump_trace) printf(x); } while (0)

static int verbose;

static int modules;

static int full_paths;

Expand Down Expand Up @@ -89,98 +85,6 @@ struct sym_ext {
char *path;
};

static LIST_HEAD(dsos);
static struct dso *kernel_dso;
static struct dso *vdso;


static void dsos__add(struct dso *dso)
{
list_add_tail(&dso->node, &dsos);
}

static struct dso *dsos__find(const char *name)
{
struct dso *pos;

list_for_each_entry(pos, &dsos, node)
if (strcmp(pos->name, name) == 0)
return pos;
return NULL;
}

static struct dso *dsos__findnew(const char *name)
{
struct dso *dso = dsos__find(name);
int nr;

if (dso)
return dso;

dso = dso__new(name, 0);
if (!dso)
goto out_delete_dso;

nr = dso__load(dso, NULL, verbose);
if (nr < 0) {
if (verbose)
fprintf(stderr, "Failed to open: %s\n", name);
goto out_delete_dso;
}
if (!nr && verbose) {
fprintf(stderr,
"No symbols found in: %s, maybe install a debug package?\n",
name);
}

dsos__add(dso);

return dso;

out_delete_dso:
dso__delete(dso);
return NULL;
}

static void dsos__fprintf(FILE *fp)
{
struct dso *pos;

list_for_each_entry(pos, &dsos, node)
dso__fprintf(pos, fp);
}

static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
{
return dso__find_symbol(dso, ip);
}

static int load_kernel(void)
{
int err;

kernel_dso = dso__new("[kernel]", 0);
if (!kernel_dso)
return -1;

err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
if (err <= 0) {
dso__delete(kernel_dso);
kernel_dso = NULL;
} else
dsos__add(kernel_dso);

vdso = dso__new("[vdso]", 0);
if (!vdso)
return -1;

vdso->find_symbol = vdso__find_symbol;

dsos__add(vdso);

return err;
}

struct map {
struct list_head node;
u64 start;
Expand Down
1 change: 0 additions & 1 deletion trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ static int inherit = 1;
static int force = 0;
static int append_file = 0;
static int call_graph = 0;
static int verbose = 0;
static int inherit_stat = 0;
static int no_samples = 0;
static int sample_address = 0;
Expand Down
97 changes: 0 additions & 97 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#define SHOW_HV 4

static char const *input_name = "perf.data";
static char *vmlinux = NULL;

static char default_sort_order[] = "comm,dso,symbol";
static char *sort_order = default_sort_order;
Expand All @@ -46,11 +45,6 @@ static int dump_trace = 0;
#define dprintf(x...) do { if (dump_trace) printf(x); } while (0)
#define cdprintf(x...) do { if (dump_trace) color_fprintf(stdout, color, x); } while (0)

static int verbose;
#define eprintf(x...) do { if (verbose) fprintf(stderr, x); } while (0)

static int modules;

static int full_paths;
static int show_nr_samples;

Expand Down Expand Up @@ -161,98 +155,7 @@ static int repsep_fprintf(FILE *fp, const char *fmt, ...)
return n;
}

static LIST_HEAD(dsos);
static struct dso *kernel_dso;
static struct dso *vdso;
static struct dso *hypervisor_dso;

static void dsos__add(struct dso *dso)
{
list_add_tail(&dso->node, &dsos);
}

static struct dso *dsos__find(const char *name)
{
struct dso *pos;

list_for_each_entry(pos, &dsos, node)
if (strcmp(pos->name, name) == 0)
return pos;
return NULL;
}

static struct dso *dsos__findnew(const char *name)
{
struct dso *dso = dsos__find(name);
int nr;

if (dso)
return dso;

dso = dso__new(name, 0);
if (!dso)
goto out_delete_dso;

nr = dso__load(dso, NULL, verbose);
if (nr < 0) {
eprintf("Failed to open: %s\n", name);
goto out_delete_dso;
}
if (!nr)
eprintf("No symbols found in: %s, maybe install a debug package?\n", name);

dsos__add(dso);

return dso;

out_delete_dso:
dso__delete(dso);
return NULL;
}

static void dsos__fprintf(FILE *fp)
{
struct dso *pos;

list_for_each_entry(pos, &dsos, node)
dso__fprintf(pos, fp);
}

static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
{
return dso__find_symbol(dso, ip);
}

static int load_kernel(void)
{
int err;

kernel_dso = dso__new("[kernel]", 0);
if (!kernel_dso)
return -1;

err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
if (err <= 0) {
dso__delete(kernel_dso);
kernel_dso = NULL;
} else
dsos__add(kernel_dso);

vdso = dso__new("[vdso]", 0);
if (!vdso)
return -1;

vdso->find_symbol = vdso__find_symbol;

dsos__add(vdso);

hypervisor_dso = dso__new("[hypervisor]", 0);
if (!hypervisor_dso)
return -1;
dsos__add(hypervisor_dso);

return err;
}

static char __cwd[PATH_MAX];
static char *cwd = __cwd;
Expand Down
1 change: 0 additions & 1 deletion trunk/tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static struct perf_counter_attr default_attrs[] = {
#define MAX_RUN 100

static int system_wide = 0;
static int verbose = 0;
static unsigned int nr_cpus = 0;
static int run_idx = 0;

Expand Down
4 changes: 0 additions & 4 deletions trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ static int group = 0;
static unsigned int page_size;
static unsigned int mmap_pages = 16;
static int freq = 0;
static int verbose = 0;
static char *vmlinux = NULL;

static int delay_secs = 2;
static int zero;
Expand Down Expand Up @@ -338,8 +336,6 @@ static void show_details(struct sym_entry *syme)
printf("%d lines not displayed, maybe increase display entries [e]\n", more);
}

struct dso *kernel_dso;

/*
* Symbols will be added here in record_ip and will get out
* after decayed.
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ extern int cmd_stat(int argc, const char **argv, const char *prefix);
extern int cmd_top(int argc, const char **argv, const char *prefix);
extern int cmd_version(int argc, const char **argv, const char *prefix);
extern int cmd_list(int argc, const char **argv, const char *prefix);
extern int cmd_trace(int argc, const char **argv, const char *prefix);

#endif
1 change: 1 addition & 0 deletions trunk/tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

#include "../../include/linux/perf_counter.h"
#include "util/types.h"
#include "util/debug.h"

/*
* prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all
Expand Down
22 changes: 22 additions & 0 deletions trunk/tools/perf/util/debug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* For general debugging purposes */

#include "../perf.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>

int verbose = 0;

int eprintf(const char *fmt, ...)
{
va_list args;
int ret = 0;

if (verbose) {
va_start(args, fmt);
ret = vfprintf(stderr, fmt, args);
va_end(args);
}

return ret;
}
5 changes: 5 additions & 0 deletions trunk/tools/perf/util/debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* For debugging general purposes */

extern int verbose;

int eprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
Loading

0 comments on commit e9e9e48

Please sign in to comment.