Skip to content

[lldb] Make variant formatter work with libstdc++-14 #97568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lldb/examples/synthetic/gnu_libstdcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,12 +914,15 @@ def get_variant_npos_value(index_byte_size):
if index == npos_value:
return " No Value"

# Strip references and typedefs.
variant_type = raw_obj.GetType().GetCanonicalType().GetDereferencedType()
template_arg_count = variant_type.GetNumberOfTemplateArguments()

# Invalid index can happen when the variant is not initialized yet.
template_arg_count = data_obj.GetType().GetNumberOfTemplateArguments()
if index >= template_arg_count:
return " <Invalid>"

active_type = data_obj.GetType().GetTemplateArgumentType(index)
active_type = variant_type.GetTemplateArgumentType(index)
return f" Active Type = {active_type.GetDisplayTypeName()} "


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ def test_with_run_command(self):

lldbutil.continue_to_breakpoint(self.process, bkpt)

self.expect(
"frame variable v1",
substrs=["v1 = Active Type = int {", "Value = 12", "}"],
)

self.expect(
"frame variable v1_ref",
substrs=["v1_ref = Active Type = int : {", "Value = 12", "}"],
)
for name in ["v1", "v1_typedef"]:
self.expect(
"frame variable " + name,
substrs=[name + " = Active Type = int {", "Value = 12", "}"],
)

for name in ["v1_ref", "v1_typedef_ref"]:
self.expect(
"frame variable " + name,
substrs=[name + " = Active Type = int : {", "Value = 12", "}"],
)

self.expect(
"frame variable v_v1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ int main() {

std::variant<int, double, char> v1;
std::variant<int, double, char> &v1_ref = v1;
using V1_typedef = std::variant<int, double, char>;
V1_typedef v1_typedef;
V1_typedef &v1_typedef_ref = v1_typedef;

std::variant<int, double, char> v2;
std::variant<int, double, char> v3;
std::variant<std::variant<int, double, char>> v_v1;
Expand Down Expand Up @@ -43,6 +47,7 @@ int main() {
v_many_types_no_value;

v1 = 12; // v contains int
v1_typedef = v1;
v_v1 = v1;
int i = std::get<int>(v1);
printf("%d\n", i); // break here
Expand Down
Loading