xref: /src/contrib/llvm-project/lldb/source/Target/MemoryRegionInfo.cpp (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
1cfca06d7SDimitry Andric //===-- MemoryRegionInfo.cpp ----------------------------------------------===//
2706b4fc4SDimitry Andric //
3706b4fc4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4706b4fc4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5706b4fc4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6706b4fc4SDimitry Andric //
7706b4fc4SDimitry Andric //===----------------------------------------------------------------------===//
8706b4fc4SDimitry Andric 
9706b4fc4SDimitry Andric #include "lldb/Target/MemoryRegionInfo.h"
10706b4fc4SDimitry Andric 
11706b4fc4SDimitry Andric using namespace lldb_private;
12706b4fc4SDimitry Andric 
operator <<(llvm::raw_ostream & OS,const MemoryRegionInfo & Info)13706b4fc4SDimitry Andric llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &OS,
14706b4fc4SDimitry Andric                                             const MemoryRegionInfo &Info) {
15706b4fc4SDimitry Andric   return OS << llvm::formatv("MemoryRegionInfo([{0}, {1}), {2:r}{3:w}{4:x}, "
16b60736ecSDimitry Andric                              "{5}, `{6}`, {7}, {8}, {9})",
17706b4fc4SDimitry Andric                              Info.GetRange().GetRangeBase(),
18706b4fc4SDimitry Andric                              Info.GetRange().GetRangeEnd(), Info.GetReadable(),
19706b4fc4SDimitry Andric                              Info.GetWritable(), Info.GetExecutable(),
20706b4fc4SDimitry Andric                              Info.GetMapped(), Info.GetName(), Info.GetFlash(),
21b60736ecSDimitry Andric                              Info.GetBlocksize(), Info.GetMemoryTagged());
22706b4fc4SDimitry Andric }
23706b4fc4SDimitry Andric 
format(const MemoryRegionInfo::OptionalBool & B,raw_ostream & OS,StringRef Options)24706b4fc4SDimitry Andric void llvm::format_provider<MemoryRegionInfo::OptionalBool>::format(
25706b4fc4SDimitry Andric     const MemoryRegionInfo::OptionalBool &B, raw_ostream &OS,
26706b4fc4SDimitry Andric     StringRef Options) {
27706b4fc4SDimitry Andric   assert(Options.size() <= 1);
28706b4fc4SDimitry Andric   bool Empty = Options.empty();
29706b4fc4SDimitry Andric   switch (B) {
30706b4fc4SDimitry Andric   case lldb_private::MemoryRegionInfo::eNo:
31706b4fc4SDimitry Andric     OS << (Empty ? "no" : "-");
32706b4fc4SDimitry Andric     return;
33706b4fc4SDimitry Andric   case lldb_private::MemoryRegionInfo::eYes:
34706b4fc4SDimitry Andric     OS << (Empty ? "yes" : Options);
35706b4fc4SDimitry Andric     return;
36706b4fc4SDimitry Andric   case lldb_private::MemoryRegionInfo::eDontKnow:
37706b4fc4SDimitry Andric     OS << (Empty ? "don't know" : "?");
38706b4fc4SDimitry Andric     return;
39706b4fc4SDimitry Andric   }
40706b4fc4SDimitry Andric }
41