header.c (00e4db51259a5f936fec1424b884f029479d3981) header.c (1c695c88a1092b4013e3fffbe0ca685149165403)
1// SPDX-License-Identifier: GPL-2.0
2#include <errno.h>
3#include <inttypes.h>
4#include "string2.h"
5#include <sys/param.h>
6#include <sys/types.h>
7#include <byteswap.h>
8#include <unistd.h>

--- 2042 unchanged lines hidden (view full) ---

2051static int __event_process_build_id(struct perf_record_header_build_id *bev,
2052 char *filename,
2053 struct perf_session *session)
2054{
2055 int err = -1;
2056 struct machine *machine;
2057 u16 cpumode;
2058 struct dso *dso;
1// SPDX-License-Identifier: GPL-2.0
2#include <errno.h>
3#include <inttypes.h>
4#include "string2.h"
5#include <sys/param.h>
6#include <sys/types.h>
7#include <byteswap.h>
8#include <unistd.h>

--- 2042 unchanged lines hidden (view full) ---

2051static int __event_process_build_id(struct perf_record_header_build_id *bev,
2052 char *filename,
2053 struct perf_session *session)
2054{
2055 int err = -1;
2056 struct machine *machine;
2057 u16 cpumode;
2058 struct dso *dso;
2059 enum dso_kernel_type dso_type;
2059 enum dso_space_type dso_space;
2060
2061 machine = perf_session__findnew_machine(session, bev->pid);
2062 if (!machine)
2063 goto out;
2064
2065 cpumode = bev->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
2066
2067 switch (cpumode) {
2068 case PERF_RECORD_MISC_KERNEL:
2060
2061 machine = perf_session__findnew_machine(session, bev->pid);
2062 if (!machine)
2063 goto out;
2064
2065 cpumode = bev->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
2066
2067 switch (cpumode) {
2068 case PERF_RECORD_MISC_KERNEL:
2069 dso_type = DSO_TYPE_KERNEL;
2069 dso_space = DSO_SPACE__KERNEL;
2070 break;
2071 case PERF_RECORD_MISC_GUEST_KERNEL:
2070 break;
2071 case PERF_RECORD_MISC_GUEST_KERNEL:
2072 dso_type = DSO_TYPE_GUEST_KERNEL;
2072 dso_space = DSO_SPACE__KERNEL_GUEST;
2073 break;
2074 case PERF_RECORD_MISC_USER:
2075 case PERF_RECORD_MISC_GUEST_USER:
2073 break;
2074 case PERF_RECORD_MISC_USER:
2075 case PERF_RECORD_MISC_GUEST_USER:
2076 dso_type = DSO_TYPE_USER;
2076 dso_space = DSO_SPACE__USER;
2077 break;
2078 default:
2079 goto out;
2080 }
2081
2082 dso = machine__findnew_dso(machine, filename);
2083 if (dso != NULL) {
2084 char sbuild_id[SBUILD_ID_SIZE];
2085
2086 dso__set_build_id(dso, &bev->build_id);
2087
2077 break;
2078 default:
2079 goto out;
2080 }
2081
2082 dso = machine__findnew_dso(machine, filename);
2083 if (dso != NULL) {
2084 char sbuild_id[SBUILD_ID_SIZE];
2085
2086 dso__set_build_id(dso, &bev->build_id);
2087
2088 if (dso_type != DSO_TYPE_USER) {
2088 if (dso_space != DSO_SPACE__USER) {
2089 struct kmod_path m = { .name = NULL, };
2090
2091 if (!kmod_path__parse_name(&m, filename) && m.kmod)
2092 dso__set_module_info(dso, &m, machine);
2093 else
2089 struct kmod_path m = { .name = NULL, };
2090
2091 if (!kmod_path__parse_name(&m, filename) && m.kmod)
2092 dso__set_module_info(dso, &m, machine);
2093 else
2094 dso->kernel = dso_type;
2094 dso->kernel = dso_space;
2095
2096 free(m.name);
2097 }
2098
2099 build_id__sprintf(dso->build_id, sizeof(dso->build_id),
2100 sbuild_id);
2101 pr_debug("build id event received for %s: %s\n",
2102 dso->long_name, sbuild_id);

--- 2020 unchanged lines hidden ---
2095
2096 free(m.name);
2097 }
2098
2099 build_id__sprintf(dso->build_id, sizeof(dso->build_id),
2100 sbuild_id);
2101 pr_debug("build id event received for %s: %s\n",
2102 dso->long_name, sbuild_id);

--- 2020 unchanged lines hidden ---