| 1 | //===-- MemoryRegionInfo.cpp ----------------------------------------------===// |
| 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-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "lldb/Target/MemoryRegionInfo.h" |
| 10 | |
| 11 | using namespace lldb_private; |
| 12 | |
| 13 | llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &OS, |
| 14 | const MemoryRegionInfo &Info) { |
| 15 | return OS << llvm::formatv(Fmt: "MemoryRegionInfo([{0}, {1}), {2:r}{3:w}{4:x}, " |
| 16 | "{5}, `{6}`, {7}, {8}, {9}, {10}, {11})" , |
| 17 | Vals: Info.GetRange().GetRangeBase(), |
| 18 | Vals: Info.GetRange().GetRangeEnd(), Vals: Info.GetReadable(), |
| 19 | Vals: Info.GetWritable(), Vals: Info.GetExecutable(), |
| 20 | Vals: Info.GetMapped(), Vals: Info.GetName(), Vals: Info.GetFlash(), |
| 21 | Vals: Info.GetBlocksize(), Vals: Info.GetMemoryTagged(), |
| 22 | Vals: Info.IsStackMemory(), Vals: Info.IsShadowStack()); |
| 23 | } |
| 24 | |
| 25 | void llvm::format_provider<MemoryRegionInfo::OptionalBool>::format( |
| 26 | const MemoryRegionInfo::OptionalBool &B, raw_ostream &OS, |
| 27 | StringRef Options) { |
| 28 | assert(Options.size() <= 1); |
| 29 | bool Empty = Options.empty(); |
| 30 | switch (B) { |
| 31 | case lldb_private::MemoryRegionInfo::eNo: |
| 32 | OS << (Empty ? "no" : "-" ); |
| 33 | return; |
| 34 | case lldb_private::MemoryRegionInfo::eYes: |
| 35 | OS << (Empty ? "yes" : Options); |
| 36 | return; |
| 37 | case lldb_private::MemoryRegionInfo::eDontKnow: |
| 38 | OS << (Empty ? "don't know" : "?" ); |
| 39 | return; |
| 40 | } |
| 41 | } |
| 42 | |