This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix that LLDB doesn't print NaN's sign on Darwin
ClosedPublic

Authored by teemperor on May 20 2021, 7:50 AM.

Details

Summary

It seems std::ostringstream ignores NaN signs on Darwin while it prints them on Linux. This causes
that LLDB behaves differently on those platforms which is both confusing for users and it also
means we have to deal with that in our tests.

This patch manually implements the NaN/Inf printing (which are apparently implementation defined)
to make LLDB print the same thing on all platforms. The only output difference in practice seems to
be that we now print negative NaNs as -nan, but this potentially also changes the output on other
systems I haven't tested this on.

Diff Detail

Event Timeline

teemperor requested review of this revision.May 20 2021, 7:50 AM
teemperor planned changes to this revision.
teemperor created this revision.

That's the wrong set of tests...

teemperor updated this revision to Diff 346744.May 20 2021, 8:08 AM
  • Now uploaded the right tests.
JDevlieghere accepted this revision.May 20 2021, 8:16 PM

LGTM

lldb/source/Core/DumpDataExtractor.cpp
238–240

Seems like this could be part of the doxygen comment above?

This revision is now accepted and ready to land.May 20 2021, 8:16 PM

LGTM besides my minor comment on headers. Thanks for fixing this!

lldb/source/Core/DumpDataExtractor.cpp
241

We are not explicitly including <cmath> for std::isnan we should replace math.h include. We should replace all the C header includes for C++ ones but that feels out of scope for this change.

LGTM besides my minor comment on headers. Thanks for fixing this!

lldb/unittests/Core/DumpDataExtractorTest.cpp
212

We should explicitly include <limits>

This revision was landed with ongoing or failed builds.May 25 2021, 4:33 AM
This revision was automatically updated to reflect the committed changes.