
This PR adds formatters for `std::shared_ptr` and `std::weak_ptr`. They
are similar to the ones from libc++ and libstdc++.
[Section from MSVC STL
NatVis](313964b78a/stl/debugger/STL.natvis (L512-L578)
).
To support debugging with PDB debug info, I had to add an early exit in
`GetDesugaredSmartPointerValue`, because with PDB, LLDB doesn't know
about template types. This isn't an issue here, since the typedef type
is already resolved there, so no casting is needed.
The tests don't check for PDB - maybe this should be changed? I don't
know a good way to do this. PDB has the downside that it resolves
typedefs. Here in particular, the test for `element_type` would need to
be replaced with `User` and `std::string` with
`std::basic_string<char,std::char_traits<char>,std::allocator<char> >`.
Towards #24834.
26 lines
882 B
C++
26 lines
882 B
C++
//===-- Generic.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 "Generic.h"
|
|
#include "LibStdcpp.h"
|
|
#include "MsvcStl.h"
|
|
|
|
lldb::ValueObjectSP lldb_private::formatters::GetDesugaredSmartPointerValue(
|
|
ValueObject &ptr, ValueObject &container) {
|
|
auto container_type = container.GetCompilerType().GetNonReferenceType();
|
|
if (!container_type)
|
|
return nullptr;
|
|
|
|
auto arg = container_type.GetTypeTemplateArgument(0);
|
|
if (!arg)
|
|
// If there isn't enough debug info, use the pointer type as is
|
|
return ptr.GetSP();
|
|
|
|
return ptr.Cast(arg.GetPointerType());
|
|
}
|