Skip to content

[lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() #92701

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
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
11 changes: 11 additions & 0 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ LibcxxChronoTimePointSecondsSummaryProvider(ValueObject &valobj, Stream &stream,
if (!ptr_sp)
return false;

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

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

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

const int days = ptr_sp->GetValueAsSigned(0);
if (days < chrono_timestamp_min || days > chrono_timestamp_max)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class LibcxxChronoDataFormatterTestCase(TestBase):
@skipIf(compiler="clang", compiler_version=["<", "17.0"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
isNotWindowsHost = lldbplatformutil.getHostPlatform() != "windows"
self.build()
(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
self, "break here", lldb.SBFileSpec("main.cpp", False)
Expand Down Expand Up @@ -57,7 +58,11 @@ def test_with_run_command(self):
self.expect(
"frame variable ss_neg_date_time",
substrs=[
"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s"
(
"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s"
if isNotWindowsHost
else "ss_neg_date_time = timestamp=-1096193779200 s"
)
],
)
self.expect(
Expand All @@ -68,7 +73,11 @@ def test_with_run_command(self):
self.expect(
"frame variable ss_pos_date_time",
substrs=[
"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s"
(
"ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s"
if isNotWindowsHost
else "ss_pos_date_time = timestamp=971890963199 s"
)
],
)
self.expect(
Expand Down Expand Up @@ -103,7 +112,13 @@ def test_with_run_command(self):
)
self.expect(
"frame variable sd_neg_date",
substrs=["sd_neg_date = date=-32767-01-01Z timestamp=-12687428 days"],
substrs=[
(
"sd_neg_date = date=-32767-01-01Z timestamp=-12687428 days"
if isNotWindowsHost
else "sd_neg_date = timestamp=-12687428 days"
)
],
)
self.expect(
"frame variable sd_neg_days",
Expand All @@ -112,7 +127,13 @@ def test_with_run_command(self):

self.expect(
"frame variable sd_pos_date",
substrs=["sd_pos_date = date=32767-12-31Z timestamp=11248737 days"],
substrs=[
(
"sd_pos_date = date=32767-12-31Z timestamp=11248737 days"
if isNotWindowsHost
else "sd_pos_date = timestamp=11248737 days"
)
],
)
self.expect(
"frame variable sd_pos_days",
Expand Down Expand Up @@ -157,7 +178,11 @@ def test_with_run_command(self):
self.expect(
"frame variable ls_neg_date_time",
substrs=[
"ls_neg_date_time = date/time=-32767-01-01T00:00:00 timestamp=-1096193779200 s"
(
"ls_neg_date_time = date/time=-32767-01-01T00:00:00 timestamp=-1096193779200 s"
if isNotWindowsHost
else "ls_neg_date_time = timestamp=-1096193779200 s"
)
],
)
self.expect(
Expand All @@ -168,7 +193,11 @@ def test_with_run_command(self):
self.expect(
"frame variable ls_pos_date_time",
substrs=[
"ls_pos_date_time = date/time=32767-12-31T23:59:59 timestamp=971890963199 s"
(
"ls_pos_date_time = date/time=32767-12-31T23:59:59 timestamp=971890963199 s"
if isNotWindowsHost
else "ls_pos_date_time = timestamp=971890963199 s"
)
],
)
self.expect(
Expand Down Expand Up @@ -207,7 +236,13 @@ def test_with_run_command(self):
)
self.expect(
"frame variable ld_neg_date",
substrs=["ld_neg_date = date=-32767-01-01 timestamp=-12687428 days"],
substrs=[
(
"ld_neg_date = date=-32767-01-01 timestamp=-12687428 days"
if isNotWindowsHost
else "ld_neg_date = timestamp=-12687428 days"
)
],
)
self.expect(
"frame variable ld_neg_days",
Expand All @@ -216,7 +251,13 @@ def test_with_run_command(self):

self.expect(
"frame variable ld_pos_date",
substrs=["ld_pos_date = date=32767-12-31 timestamp=11248737 days"],
substrs=[
(
"ld_pos_date = date=32767-12-31 timestamp=11248737 days"
if isNotWindowsHost
else "ld_pos_date = timestamp=11248737 days"
)
],
)
self.expect(
"frame variable ld_pos_days",
Expand Down
Loading