Skip to content

Commit 2217d17

Browse files
authored
[lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() (#92701)
This patch fixes #92574. It is a replacement for #92575.
1 parent 702a2b6 commit 2217d17

File tree

2 files changed

+60
-8
lines changed

2 files changed

+60
-8
lines changed

lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,7 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject &valobj, Stream &stream,
10981098
if (!ptr_sp)
10991099
return false;
11001100

1101+
#ifndef _WIN32
11011102
// The date time in the chrono library is valid in the range
11021103
// [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a
11031104
// larger range, the function strftime is not able to format the entire range
@@ -1107,6 +1108,11 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject &valobj, Stream &stream,
11071108
-1'096'193'779'200; // -32767-01-01T00:00:00Z
11081109
const std::time_t chrono_timestamp_max =
11091110
971'890'963'199; // 32767-12-31T23:59:59Z
1111+
#else
1112+
const std::time_t chrono_timestamp_min = -43'200; // 1969-12-31T12:00:00Z
1113+
const std::time_t chrono_timestamp_max =
1114+
32'536'850'399; // 3001-01-19T21:59:59
1115+
#endif
11101116

11111117
const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
11121118
if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
@@ -1148,12 +1154,17 @@ LibcxxChronoTimepointDaysSummaryProvider(ValueObject &valobj, Stream &stream,
11481154
if (!ptr_sp)
11491155
return false;
11501156

1157+
#ifndef _WIN32
11511158
// The date time in the chrono library is valid in the range
11521159
// [-32767-01-01Z, 32767-12-31Z]. A 32-bit time_t has a larger range, the
11531160
// function strftime is not able to format the entire range of time_t. The
11541161
// exact point has not been investigated; it's limited to chrono's range.
11551162
const int chrono_timestamp_min = -12'687'428; // -32767-01-01Z
11561163
const int chrono_timestamp_max = 11'248'737; // 32767-12-31Z
1164+
#else
1165+
const int chrono_timestamp_min = 0; // 1970-01-01Z
1166+
const int chrono_timestamp_max = 376'583; // 3001-01-19Z
1167+
#endif
11571168

11581169
const int days = ptr_sp->GetValueAsSigned(0);
11591170
if (days < chrono_timestamp_min || days > chrono_timestamp_max)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class LibcxxChronoDataFormatterTestCase(TestBase):
1414
@skipIf(compiler="clang", compiler_version=["<", "17.0"])
1515
def test_with_run_command(self):
1616
"""Test that that file and class static variables display correctly."""
17+
isNotWindowsHost = lldbplatformutil.getHostPlatform() != "windows"
1718
self.build()
1819
(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
1920
self, "break here", lldb.SBFileSpec("main.cpp", False)
@@ -57,7 +58,11 @@ def test_with_run_command(self):
5758
self.expect(
5859
"frame variable ss_neg_date_time",
5960
substrs=[
60-
"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s"
61+
(
62+
"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s"
63+
if isNotWindowsHost
64+
else "ss_neg_date_time = timestamp=-1096193779200 s"
65+
)
6166
],
6267
)
6368
self.expect(
@@ -68,7 +73,11 @@ def test_with_run_command(self):
6873
self.expect(
6974
"frame variable ss_pos_date_time",
7075
substrs=[
71-
"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s"
76+
(
77+
"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s"
78+
if isNotWindowsHost
79+
else "ss_pos_date_time = timestamp=971890963199 s"
80+
)
7281
],
7382
)
7483
self.expect(
@@ -103,7 +112,13 @@ def test_with_run_command(self):
103112
)
104113
self.expect(
105114
"frame variable sd_neg_date",
106-
substrs=["sd_neg_date = date=-32767-01-01Z timestamp=-12687428 days"],
115+
substrs=[
116+
(
117+
"sd_neg_date = date=-32767-01-01Z timestamp=-12687428 days"
118+
if isNotWindowsHost
119+
else "sd_neg_date = timestamp=-12687428 days"
120+
)
121+
],
107122
)
108123
self.expect(
109124
"frame variable sd_neg_days",
@@ -112,7 +127,13 @@ def test_with_run_command(self):
112127

113128
self.expect(
114129
"frame variable sd_pos_date",
115-
substrs=["sd_pos_date = date=32767-12-31Z timestamp=11248737 days"],
130+
substrs=[
131+
(
132+
"sd_pos_date = date=32767-12-31Z timestamp=11248737 days"
133+
if isNotWindowsHost
134+
else "sd_pos_date = timestamp=11248737 days"
135+
)
136+
],
116137
)
117138
self.expect(
118139
"frame variable sd_pos_days",
@@ -157,7 +178,11 @@ def test_with_run_command(self):
157178
self.expect(
158179
"frame variable ls_neg_date_time",
159180
substrs=[
160-
"ls_neg_date_time = date/time=-32767-01-01T00:00:00 timestamp=-1096193779200 s"
181+
(
182+
"ls_neg_date_time = date/time=-32767-01-01T00:00:00 timestamp=-1096193779200 s"
183+
if isNotWindowsHost
184+
else "ls_neg_date_time = timestamp=-1096193779200 s"
185+
)
161186
],
162187
)
163188
self.expect(
@@ -168,7 +193,11 @@ def test_with_run_command(self):
168193
self.expect(
169194
"frame variable ls_pos_date_time",
170195
substrs=[
171-
"ls_pos_date_time = date/time=32767-12-31T23:59:59 timestamp=971890963199 s"
196+
(
197+
"ls_pos_date_time = date/time=32767-12-31T23:59:59 timestamp=971890963199 s"
198+
if isNotWindowsHost
199+
else "ls_pos_date_time = timestamp=971890963199 s"
200+
)
172201
],
173202
)
174203
self.expect(
@@ -207,7 +236,13 @@ def test_with_run_command(self):
207236
)
208237
self.expect(
209238
"frame variable ld_neg_date",
210-
substrs=["ld_neg_date = date=-32767-01-01 timestamp=-12687428 days"],
239+
substrs=[
240+
(
241+
"ld_neg_date = date=-32767-01-01 timestamp=-12687428 days"
242+
if isNotWindowsHost
243+
else "ld_neg_date = timestamp=-12687428 days"
244+
)
245+
],
211246
)
212247
self.expect(
213248
"frame variable ld_neg_days",
@@ -216,7 +251,13 @@ def test_with_run_command(self):
216251

217252
self.expect(
218253
"frame variable ld_pos_date",
219-
substrs=["ld_pos_date = date=32767-12-31 timestamp=11248737 days"],
254+
substrs=[
255+
(
256+
"ld_pos_date = date=32767-12-31 timestamp=11248737 days"
257+
if isNotWindowsHost
258+
else "ld_pos_date = timestamp=11248737 days"
259+
)
260+
],
220261
)
221262
self.expect(
222263
"frame variable ld_pos_days",

0 commit comments

Comments
 (0)