lin
2025-08-01 633231e833e21d5b8b1c00cb15aedb62b3b78e8f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2016 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
#ifndef CHROMIUMOS_WIDE_PROFILING_DSO_H_
#define CHROMIUMOS_WIDE_PROFILING_DSO_H_
 
#include <sys/stat.h>
 
#include <unordered_set>
#include <utility>
 
#include "compat/string.h"
#include "data_reader.h"
 
namespace quipper {
 
// Defines a type for a pid:tid pair.
using PidTid = std::pair<u32, u32>;
 
// A struct containing all relevant info for a mapped DSO, independent of any
// samples.
struct DSOInfo {
  string name;
  string build_id;
  u32 maj = 0;
  u32 min = 0;
  u64 ino = 0;
  bool hit = false;  // Have we seen any samples in this DSO?
  // unordered_set of pids this DSO had samples in.
  std::unordered_set<uint64_t> threads;
};
 
// Do the |DSOInfo| and |struct stat| refer to the same inode?
bool SameInode(const DSOInfo& dso, const struct stat* s);
 
// Must be called at least once before using libelf.
void InitializeLibelf();
// Read buildid from an ELF file using libelf.
bool ReadElfBuildId(const string& filename, string* buildid);
bool ReadElfBuildId(int fd, string* buildid);
 
// Read buildid from /sys/module/<module_name>/notes/.note.gnu.build-id
// (Does not use libelf.)
bool ReadModuleBuildId(const string& module_name, string* buildid);
// Read builid from Elf note data section.
bool ReadBuildIdNote(DataReader* data, string* buildid);
 
// Is |name| match one of the things reported by the kernel that is known
// not to be a kernel module?
bool IsKernelNonModuleName(string name);
 
}  // namespace quipper
 
#endif  // CHROMIUMOS_WIDE_PROFILING_DSO_H_