[Lldb-commits] [lldb] [lldb][libc++] Adds slice_array data formatters. (PR #85544)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Sun Mar 17 03:29:47 PDT 2024
================
@@ -0,0 +1,166 @@
+//===-- LibCxxSliceArray.cpp-----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "LibCxx.h"
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+#include <optional>
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace lldb_private {
+namespace formatters {
+
+bool LibcxxStdSliceArraySummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options) {
+ ValueObjectSP obj = valobj.GetNonSyntheticValue();
+ if (!obj)
+ return false;
+
+ ValueObjectSP ptr_sp = obj->GetChildMemberWithName("__size_");
+ if (!ptr_sp)
+ return false;
+ const size_t size = ptr_sp->GetValueAsUnsigned(0);
+
+ ptr_sp = obj->GetChildMemberWithName("__stride_");
+ if (!ptr_sp)
+ return false;
+ const size_t stride = ptr_sp->GetValueAsUnsigned(0);
+
+ stream.Printf("stride=%" PRIu64 " size=%" PRIu64, stride, size);
+
+ return true;
+}
+
+/// Data formatter for libc++'s std::slice_array.
+///
+/// A slice_array is created by using:
+/// operator[](std::slice slicearr);
+/// and std::slice is created by:
+/// slice(std::size_t start, std::size_t size, std::size_t stride);
+/// The std::slice_array has the following members:
+/// - __vp_ pointes to std::valarray::__begin_ + @a start
----------------
Michael137 wrote:
```suggestion
/// - __vp_ points to std::valarray::__begin_ + @a start
```
https://github.com/llvm/llvm-project/pull/85544
More information about the lldb-commits
mailing list