Skip to content

Commit 3a44d26

Browse files
[lldb][windows] add NSDate and FoundationEssentials.Date dataformatters
1 parent dbe29e4 commit 3a44d26

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

lldb/source/Plugins/Language/Swift/FoundationValueTypes.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ bool lldb_private::formatters::swift::Date_SummaryProvider(
3737

3838
ValueObjectSP time_sp(valobj.GetChildAtNamePath({g__time}));
3939

40+
#ifdef _WIN32
41+
static ConstString g__timeIntervalSinceReferenceDate(
42+
"_timeIntervalSinceReferenceDate");
43+
if (!time_sp)
44+
time_sp = valobj.GetChildAtNamePath({g__time});
45+
#endif
46+
4047
if (!time_sp)
4148
return false;
4249

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,16 @@ LoadFoundationValueTypesFormatters(lldb::TypeCategoryImplSP swift_category_sp) {
670670

671671
lldb_private::formatters::AddCXXSummary(
672672
swift_category_sp, lldb_private::formatters::swift::Date_SummaryProvider,
673-
"Foundation.Date summary provider", ConstString("Foundation.Date"),
673+
"Foundation.Date summary provider",
674+
ConstString("Foundation(Essentials)?\\.Date"),
675+
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true), true);
676+
677+
#ifdef _WIN32
678+
lldb_private::formatters::AddCXXSummary(
679+
swift_category_sp, lldb_private::formatters::swift::Date_SummaryProvider,
680+
"Foundation.NSDate summary provider", ConstString("Foundation.NSDate"),
674681
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));
682+
#endif
675683

676684
lldb_private::formatters::AddCXXSummary(
677685
swift_category_sp,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SWIFT_SOURCES := main.swift
2+
3+
include Makefile.rules
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Test Foundation.Date summary strings.
3+
"""
4+
5+
import lldb
6+
from lldbsuite.test.lldbtest import *
7+
from lldbsuite.test.decorators import *
8+
import lldbsuite.test.lldbutil as lldbutil
9+
10+
import sys
11+
12+
13+
class TestCase(TestBase):
14+
@swiftTest
15+
def test_swift_date_formatters(self):
16+
"""Test Date summary strings."""
17+
self.build()
18+
19+
_ = lldbutil.run_to_source_breakpoint(
20+
self, "break here", lldb.SBFileSpec("main.swift")
21+
)
22+
23+
self.expect(
24+
"v date",
25+
startstr="(Foundation.Date) date =",
26+
)
27+
28+
if sys.platform != "win32":
29+
return
30+
31+
self.expect(
32+
"v nsdate",
33+
startstr="(Foundation.NSDate) date =",
34+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Foundation
2+
3+
let date = Date.now
4+
let nsdate = NSDate()
5+
print("break here")

0 commit comments

Comments
 (0)