81 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// CoreSpec holds the internal representation of the data that will be11/// written into the corefile. Theads, register sets within threads, registers12/// within register sets. Block of memory. Metadata about the CPU or binaries13/// that were present.14//===----------------------------------------------------------------------===//15 16#ifndef YAML2MACHOCOREFILE_CORESPEC_H17#define YAML2MACHOCOREFILE_CORESPEC_H18 19#include <cstdint>20#include <optional>21#include <string>22#include <vector>23 24struct RegisterNameAndValue {25 std::string name;26 uint64_t value;27};28 29enum RegisterFlavor { GPR = 0, FPR, EXC };30 31struct RegisterSet {32 RegisterFlavor flavor;33 std::vector<RegisterNameAndValue> registers;34};35 36struct Thread {37 std::vector<RegisterSet> regsets;38};39 40enum MemoryType { UInt8 = 0, UInt32, UInt64 };41 42struct MemoryRegion {43 uint64_t addr;44 MemoryType type;45 uint32_t size;46 // One of the following formats.47 std::vector<uint8_t> bytes;48 std::vector<uint32_t> words;49 std::vector<uint64_t> doublewords;50};51 52struct AddressableBits {53 std::optional<int> lowmem_bits;54 std::optional<int> highmem_bits;55};56 57struct Binary {58 std::string name;59 std::string uuid;60 bool value_is_slide;61 uint64_t value;62};63 64struct CoreSpec {65 uint32_t cputype;66 uint32_t cpusubtype;67 int wordsize;68 69 std::vector<Thread> threads;70 std::vector<MemoryRegion> memory_regions;71 72 std::optional<AddressableBits> addressable_bits;73 std::vector<Binary> binaries;74 75 CoreSpec() : cputype(0), cpusubtype(0), wordsize(0) {}76};77 78CoreSpec from_yaml(char *buf, size_t len);79 80#endif81