xref: /freebsd-src/contrib/llvm-project/lldb/source/Target/MemoryRegionInfo.cpp (revision 480093f4440d54b30b3025afeac24b48f2ba7a2e)
1*480093f4SDimitry Andric //===-- MemoryRegionInfo.cpp ------------------------------------*- C++ -*-===//
2*480093f4SDimitry Andric //
3*480093f4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*480093f4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*480093f4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*480093f4SDimitry Andric //
7*480093f4SDimitry Andric //===----------------------------------------------------------------------===//
8*480093f4SDimitry Andric 
9*480093f4SDimitry Andric #include "lldb/Target/MemoryRegionInfo.h"
10*480093f4SDimitry Andric 
11*480093f4SDimitry Andric using namespace lldb_private;
12*480093f4SDimitry Andric 
13*480093f4SDimitry Andric llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &OS,
14*480093f4SDimitry Andric                                             const MemoryRegionInfo &Info) {
15*480093f4SDimitry Andric   return OS << llvm::formatv("MemoryRegionInfo([{0}, {1}), {2:r}{3:w}{4:x}, "
16*480093f4SDimitry Andric                              "{5}, `{6}`, {7}, {8})",
17*480093f4SDimitry Andric                              Info.GetRange().GetRangeBase(),
18*480093f4SDimitry Andric                              Info.GetRange().GetRangeEnd(), Info.GetReadable(),
19*480093f4SDimitry Andric                              Info.GetWritable(), Info.GetExecutable(),
20*480093f4SDimitry Andric                              Info.GetMapped(), Info.GetName(), Info.GetFlash(),
21*480093f4SDimitry Andric                              Info.GetBlocksize());
22*480093f4SDimitry Andric }
23*480093f4SDimitry Andric 
24*480093f4SDimitry Andric void llvm::format_provider<MemoryRegionInfo::OptionalBool>::format(
25*480093f4SDimitry Andric     const MemoryRegionInfo::OptionalBool &B, raw_ostream &OS,
26*480093f4SDimitry Andric     StringRef Options) {
27*480093f4SDimitry Andric   assert(Options.size() <= 1);
28*480093f4SDimitry Andric   bool Empty = Options.empty();
29*480093f4SDimitry Andric   switch (B) {
30*480093f4SDimitry Andric   case lldb_private::MemoryRegionInfo::eNo:
31*480093f4SDimitry Andric     OS << (Empty ? "no" : "-");
32*480093f4SDimitry Andric     return;
33*480093f4SDimitry Andric   case lldb_private::MemoryRegionInfo::eYes:
34*480093f4SDimitry Andric     OS << (Empty ? "yes" : Options);
35*480093f4SDimitry Andric     return;
36*480093f4SDimitry Andric   case lldb_private::MemoryRegionInfo::eDontKnow:
37*480093f4SDimitry Andric     OS << (Empty ? "don't know" : "?");
38*480093f4SDimitry Andric     return;
39*480093f4SDimitry Andric   }
40*480093f4SDimitry Andric }
41