https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/92701
>From 7d455ee2dabe3adc851b0c7989e9cef53eb24e6e Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev <dvassil...@accesssoftek.com> Date: Sun, 19 May 2024 21:50:21 +0400 Subject: [PATCH] [lldb][Windows] Fixed LibcxxChronoTimePointSecondsSummaryProvider() This patch fixes #92574. It is a replacement for #92575. --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 11 ++++ .../chrono/TestDataFormatterLibcxxChrono.py | 57 ++++++++++++++++--- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index e160fd0763939..b0e6fb7d6f5af 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -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 @@ -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) @@ -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) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py index fb35481d55514..0737a5bc7e6eb 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py @@ -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) @@ -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( @@ -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( @@ -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", @@ -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", @@ -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( @@ -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( @@ -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", @@ -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", _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits