1#ifndef MEMPROF_DATA_INC
2#define MEMPROF_DATA_INC
3/*===-- MemProfData.inc - MemProf profiling runtime structures -*- C++ -*-=== *\
4|*
5|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6|* See https://llvm.org/LICENSE.txt for license information.
7|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8|*
9\*===----------------------------------------------------------------------===*/
10/*
11 * This is the main file that defines all the data structure, signature,
12 * constant literals that are shared across profiling runtime library,
13 * and host tools (reader/writer).
14 *
15 * This file has two identical copies. The primary copy lives in LLVM and
16 * the other one sits in compiler-rt/include/profile directory. To make changes
17 * in this file, first modify the primary copy and copy it over to compiler-rt.
18 * Testing of any change in this file can start only after the two copies are
19 * synced up.
20 *
21\*===----------------------------------------------------------------------===*/
22
23
24#ifdef _MSC_VER
25#define PACKED(__decl__) __pragma(pack(push,1)) __decl__ __pragma(pack(pop))
26#else
27#define PACKED(__decl__) __decl__ __attribute__((__packed__))
28#endif
29
30// A 64-bit magic number to uniquely identify the raw binary memprof profile file.
31#define MEMPROF_RAW_MAGIC_64                                                                        \
32  ((uint64_t)255 << 56 | (uint64_t)'m' << 48 | (uint64_t)'p' << 40 | (uint64_t)'r' << 32 |          \
33   (uint64_t)'o' << 24 | (uint64_t)'f' << 16 | (uint64_t)'r' << 8 | (uint64_t)129)
34
35// The version number of the raw binary format.
36#define MEMPROF_RAW_VERSION 1ULL
37
38namespace llvm {
39namespace memprof {
40// A struct describing the header used for the raw binary memprof profile format.
41PACKED(struct Header {
42  uint64_t Magic;
43  uint64_t Version;
44  uint64_t TotalSize;
45  uint64_t SegmentOffset;
46  uint64_t MIBOffset;
47  uint64_t StackOffset;
48});
49
50// A struct describing the information necessary to describe a /proc/maps
51// segment entry for a particular binary/library identified by its build id.
52PACKED(struct SegmentEntry {
53  uint64_t Start;
54  uint64_t End;
55  uint64_t Offset;
56  uint8_t BuildId[32];
57});
58} // namespace memprof
59} // namespace llvm
60
61#endif
62