Author: Jason Molenda Date: 2024-02-08T09:16:12-08:00 New Revision: f219cda7bd43696792ca4668ca5a9fbf55a9f09f
URL: https://github.com/llvm/llvm-project/commit/f219cda7bd43696792ca4668ca5a9fbf55a9f09f DIFF: https://github.com/llvm/llvm-project/commit/f219cda7bd43696792ca4668ca5a9fbf55a9f09f.diff LOG: [lldb] Fix printf formatting of std::time_t seconds (#81078) This formatter https://github.com/llvm/llvm-project/pull/78609 was originally passing the signed seconds (which can refer to times in the past) with an unsigned printf formatter, and had tests that expected to see negative values from the printf which always failed on macOS. I'm not clear how they ever passed on any platform. Fix the printf to print seconds as a signed value, and re-enable the tests. Added: Modified: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py Removed: ################################################################################ diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index a7d7066bb2c11d..7893aa7cc1f9df 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -1108,7 +1108,7 @@ bool lldb_private::formatters::LibcxxChronoSysSecondsSummaryProvider( const std::time_t seconds = ptr_sp->GetValueAsSigned(0); if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max) - stream.Printf("timestamp=%" PRIu64 " s", static_cast<uint64_t>(seconds)); + stream.Printf("timestamp=%" PRId64 " s", static_cast<int64_t>(seconds)); else { std::array<char, 128> str; std::size_t size = @@ -1116,8 +1116,8 @@ bool lldb_private::formatters::LibcxxChronoSysSecondsSummaryProvider( if (size == 0) return false; - stream.Printf("date/time=%s timestamp=%" PRIu64 " s", str.data(), - static_cast<uint64_t>(seconds)); + stream.Printf("date/time=%s timestamp=%" PRId64 " s", str.data(), + static_cast<int64_t>(seconds)); } return true; 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 9706f9e94e922f..a90fb828d121a7 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 @@ -54,17 +54,16 @@ def test_with_run_command(self): substrs=["ss_0 = date/time=1970-01-01T00:00:00Z timestamp=0 s"], ) - # FIXME disabled temporarily, macOS is printing this as an unsigned? - #self.expect( - # "frame variable ss_neg_date_time", - # substrs=[ - # "ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" - # ], - #) - #self.expect( - # "frame variable ss_neg_seconds", - # substrs=["ss_neg_seconds = timestamp=-1096193779201 s"], - #) + self.expect( + "frame variable ss_neg_date_time", + substrs=[ + "ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" + ], + ) + self.expect( + "frame variable ss_neg_seconds", + substrs=["ss_neg_seconds = timestamp=-1096193779201 s"], + ) self.expect( "frame variable ss_pos_date_time", @@ -77,11 +76,10 @@ def test_with_run_command(self): substrs=["ss_pos_seconds = timestamp=971890963200 s"], ) - # FIXME disabled temporarily, macOS is printing this as an unsigned? - #self.expect( - # "frame variable ss_min", - # substrs=["ss_min = timestamp=-9223372036854775808 s"], - #) + self.expect( + "frame variable ss_min", + substrs=["ss_min = timestamp=-9223372036854775808 s"], + ) self.expect( "frame variable ss_max", substrs=["ss_max = timestamp=9223372036854775807 s"], _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits