blob: 0d5ebbdbe23800413819e4ed144678927bfe893f [file] [log] [blame]
Raphael Isemann80814282020-01-24 08:23:27 +01001//===-- MemoryRegionInfo.cpp ----------------------------------------------===//
Pavel Labath7c603a42019-10-25 22:18:51 +00002//
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-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/Target/MemoryRegionInfo.h"
10
Pavel Labath28cf9692019-10-16 15:29:20 +020011using namespace lldb_private;
12
Pavel Labath7c603a42019-10-25 22:18:51 +000013llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &OS,
14 const MemoryRegionInfo &Info) {
Pavel Labath28cf9692019-10-16 15:29:20 +020015 return OS << llvm::formatv("MemoryRegionInfo([{0}, {1}), {2:r}{3:w}{4:x}, "
David Spickett32541682020-08-17 15:02:04 +010016 "{5}, `{6}`, {7}, {8}, {9})",
Pavel Labath7c603a42019-10-25 22:18:51 +000017 Info.GetRange().GetRangeBase(),
18 Info.GetRange().GetRangeEnd(), Info.GetReadable(),
19 Info.GetWritable(), Info.GetExecutable(),
20 Info.GetMapped(), Info.GetName(), Info.GetFlash(),
David Spickett32541682020-08-17 15:02:04 +010021 Info.GetBlocksize(), Info.GetMemoryTagged());
Pavel Labath7c603a42019-10-25 22:18:51 +000022}
Pavel Labath28cf9692019-10-16 15:29:20 +020023
24void llvm::format_provider<MemoryRegionInfo::OptionalBool>::format(
25 const MemoryRegionInfo::OptionalBool &B, raw_ostream &OS,
26 StringRef Options) {
27 assert(Options.size() <= 1);
28 bool Empty = Options.empty();
29 switch (B) {
30 case lldb_private::MemoryRegionInfo::eNo:
31 OS << (Empty ? "no" : "-");
32 return;
33 case lldb_private::MemoryRegionInfo::eYes:
34 OS << (Empty ? "yes" : Options);
35 return;
36 case lldb_private::MemoryRegionInfo::eDontKnow:
37 OS << (Empty ? "don't know" : "?");
38 return;
39 }
40}