Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 263057
b: refs/heads/master
c: f57b05e
h: refs/heads/master
i:
  263055: 1814bc3
v: v3
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Aug 11, 2011
1 parent a736daf commit b76d3bf
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 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: fc8ed7be738ffb1b3b0140ed2de6def38b9a7101
refs/heads/master: f57b05ed532ccf3b3e22878a5678ca10de50ad29
11 changes: 10 additions & 1 deletion trunk/tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,16 @@ static int perf_header__read_build_ids_abi_quirk(struct perf_header *header,
return -1;

bev.header = old_bev.header;
bev.pid = 0;

/*
* As the pid is the missing value, we need to fill
* it properly. The header.misc value give us nice hint.
*/
bev.pid = HOST_KERNEL_ID;
if (bev.header.misc == PERF_RECORD_MISC_GUEST_USER ||
bev.header.misc == PERF_RECORD_MISC_GUEST_KERNEL)
bev.pid = DEFAULT_GUEST_KERNEL_ID;

memcpy(bev.build_id, old_bev.build_id, sizeof(bev.build_id));
__event_process_build_id(&bev, filename, session);

Expand Down
57 changes: 32 additions & 25 deletions trunk/tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2181,27 +2181,22 @@ size_t machines__fprintf_dsos_buildid(struct rb_root *machines,
return ret;
}

struct dso *dso__new_kernel(const char *name)
static struct dso*
dso__kernel_findnew(struct machine *machine, const char *name,
const char *short_name, int dso_type)
{
struct dso *dso = dso__new(name ?: "[kernel.kallsyms]");

if (dso != NULL) {
dso__set_short_name(dso, "[kernel]");
dso->kernel = DSO_TYPE_KERNEL;
}

return dso;
}
/*
* The kernel dso could be created by build_id processing.
*/
struct dso *dso = __dsos__findnew(&machine->kernel_dsos, name);

static struct dso *dso__new_guest_kernel(struct machine *machine,
const char *name)
{
char bf[PATH_MAX];
struct dso *dso = dso__new(name ?: machine__mmap_name(machine, bf,
sizeof(bf)));
/*
* We need to run this in all cases, since during the build_id
* processing we had no idea this was the kernel dso.
*/
if (dso != NULL) {
dso__set_short_name(dso, "[guest.kernel]");
dso->kernel = DSO_TYPE_GUEST_KERNEL;
dso__set_short_name(dso, short_name);
dso->kernel = dso_type;
}

return dso;
Expand All @@ -2219,24 +2214,36 @@ void dso__read_running_kernel_build_id(struct dso *dso, struct machine *machine)
dso->has_build_id = true;
}

static struct dso *machine__create_kernel(struct machine *machine)
static struct dso *machine__get_kernel(struct machine *machine)
{
const char *vmlinux_name = NULL;
struct dso *kernel;

if (machine__is_host(machine)) {
vmlinux_name = symbol_conf.vmlinux_name;
kernel = dso__new_kernel(vmlinux_name);
if (!vmlinux_name)
vmlinux_name = "[kernel.kallsyms]";

kernel = dso__kernel_findnew(machine, vmlinux_name,
"[kernel]",
DSO_TYPE_KERNEL);
} else {
char bf[PATH_MAX];

if (machine__is_default_guest(machine))
vmlinux_name = symbol_conf.default_guest_vmlinux_name;
kernel = dso__new_guest_kernel(machine, vmlinux_name);
if (!vmlinux_name)
vmlinux_name = machine__mmap_name(machine, bf,
sizeof(bf));

kernel = dso__kernel_findnew(machine, vmlinux_name,
"[guest.kernel]",
DSO_TYPE_GUEST_KERNEL);
}

if (kernel != NULL) {
if (kernel != NULL && (!kernel->has_build_id))
dso__read_running_kernel_build_id(kernel, machine);
dsos__add(&machine->kernel_dsos, kernel);
}

return kernel;
}

Expand Down Expand Up @@ -2340,7 +2347,7 @@ void machine__destroy_kernel_maps(struct machine *machine)

int machine__create_kernel_maps(struct machine *machine)
{
struct dso *kernel = machine__create_kernel(machine);
struct dso *kernel = machine__get_kernel(machine);

if (kernel == NULL ||
__machine__create_kernel_maps(machine, kernel) < 0)
Expand Down
1 change: 0 additions & 1 deletion trunk/tools/perf/util/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ struct dso {
};

struct dso *dso__new(const char *name);
struct dso *dso__new_kernel(const char *name);
void dso__delete(struct dso *dso);

int dso__name_len(const struct dso *dso);
Expand Down

0 comments on commit b76d3bf

Please sign in to comment.