180814287SRaphael Isemann //===-- MemoryRegionInfo.cpp ----------------------------------------------===//
27c603a41SPavel Labath //
37c603a41SPavel Labath // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
47c603a41SPavel Labath // See https://llvm.org/LICENSE.txt for license information.
57c603a41SPavel Labath // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67c603a41SPavel Labath //
77c603a41SPavel Labath //===----------------------------------------------------------------------===//
87c603a41SPavel Labath 
97c603a41SPavel Labath #include "lldb/Target/MemoryRegionInfo.h"
107c603a41SPavel Labath 
1128cf9698SPavel Labath using namespace lldb_private;
1228cf9698SPavel Labath 
operator <<(llvm::raw_ostream & OS,const MemoryRegionInfo & Info)137c603a41SPavel Labath llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &OS,
147c603a41SPavel Labath                                             const MemoryRegionInfo &Info) {
1528cf9698SPavel Labath   return OS << llvm::formatv("MemoryRegionInfo([{0}, {1}), {2:r}{3:w}{4:x}, "
16*32541685SDavid Spickett                              "{5}, `{6}`, {7}, {8}, {9})",
177c603a41SPavel Labath                              Info.GetRange().GetRangeBase(),
187c603a41SPavel Labath                              Info.GetRange().GetRangeEnd(), Info.GetReadable(),
197c603a41SPavel Labath                              Info.GetWritable(), Info.GetExecutable(),
207c603a41SPavel Labath                              Info.GetMapped(), Info.GetName(), Info.GetFlash(),
21*32541685SDavid Spickett                              Info.GetBlocksize(), Info.GetMemoryTagged());
227c603a41SPavel Labath }
2328cf9698SPavel Labath 
format(const MemoryRegionInfo::OptionalBool & B,raw_ostream & OS,StringRef Options)2428cf9698SPavel Labath void llvm::format_provider<MemoryRegionInfo::OptionalBool>::format(
2528cf9698SPavel Labath     const MemoryRegionInfo::OptionalBool &B, raw_ostream &OS,
2628cf9698SPavel Labath     StringRef Options) {
2728cf9698SPavel Labath   assert(Options.size() <= 1);
2828cf9698SPavel Labath   bool Empty = Options.empty();
2928cf9698SPavel Labath   switch (B) {
3028cf9698SPavel Labath   case lldb_private::MemoryRegionInfo::eNo:
3128cf9698SPavel Labath     OS << (Empty ? "no" : "-");
3228cf9698SPavel Labath     return;
3328cf9698SPavel Labath   case lldb_private::MemoryRegionInfo::eYes:
3428cf9698SPavel Labath     OS << (Empty ? "yes" : Options);
3528cf9698SPavel Labath     return;
3628cf9698SPavel Labath   case lldb_private::MemoryRegionInfo::eDontKnow:
3728cf9698SPavel Labath     OS << (Empty ? "don't know" : "?");
3828cf9698SPavel Labath     return;
3928cf9698SPavel Labath   }
4028cf9698SPavel Labath }
41