Re: [PATCH 7/9] perf tools: add support for reading from /proc/kcore

From: Namhyung Kim
Date: Tue Jul 30 2013 - 00:37:32 EST


Hi,

On Thu, 25 Jul 2013 17:01:28 +0300, Adrian Hunter wrote:
> In the absence of vmlinux, perf tools uses kallsyms
> for symbols. If the user has access, now also map to
> /proc/kcore.
>
> The dso data_type is now set to either
> DSO_BINARY_TYPE__KCORE or DSO_BINARY_TYPE__GUEST_KCORE
> as approprite.

[SNIP]
> +
> +static bool is_host_buildid_str(const char *str)
> +{
> + u8 host_build_id[BUILD_ID_SIZE];
> + char host_build_id_str[BUILD_ID_SIZE * 2 + 1];
> +
> + if (sysfs__read_build_id("/sys/kernel/notes", host_build_id,
> + sizeof(host_build_id)))
> + return false;
> +
> + build_id__sprintf(host_build_id, sizeof(host_build_id),
> + host_build_id_str);
> +
> + return !strcmp(str, host_build_id_str);
> +}
> +
> +/*
> + * If kallsyms is referenced by name then we look for kcore in the same
> + * directory. Otherwise we use /proc/kcore but only if the buildid matches the
> + * host.
> + */
> +static bool kcore_filename_from_kallsyms_filename(char *kcore_filename,
> + const char *kallsyms_filename)
> +{
> + char *name;
> +
> + strcpy(kcore_filename, kallsyms_filename);
> + name = strrchr(kcore_filename, '/');
> + if (!name)
> + return false;
> +
> + if (!strcmp(name, "/kallsyms")) {
> + strcpy(name, "/kcore");
> + return true;
> + }
> +
> + if (is_host_buildid_str(name)) {

IIUC the name should start with '/' but build-id is not. So doesn't it
always fail?

Thanks,
Namhyung


> + strcpy(kcore_filename, "/proc/kcore");
> + return true;
> + }
> +
> + return false;
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/