diff options
| author | Sean Callanan <scallanan@apple.com> | 2012-10-20 06:08:09 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2012-10-20 06:08:09 +0000 |
| commit | a2cd62a1e73c38477df852c86ffd59d4e0a2c848 (patch) | |
| tree | 6ed3720981023da9fcbe2bc6f8d6f04db572d49b | |
| parent | 3940bafb5449186c2364d263da7f1d4f7e224661 (diff) | |
| download | bcm5719-llvm-a2cd62a1e73c38477df852c86ffd59d4e0a2c848.tar.gz bcm5719-llvm-a2cd62a1e73c38477df852c86ffd59d4e0a2c848.zip | |
Fixed a bug that caused floating-point values
to be printed truncated.
<rdar://problem/12389615>
llvm-svn: 166368
| -rw-r--r-- | lldb/source/Core/DataExtractor.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/lldb/source/Core/DataExtractor.cpp b/lldb/source/Core/DataExtractor.cpp index 7cfe16991df..353fd26f042 100644 --- a/lldb/source/Core/DataExtractor.cpp +++ b/lldb/source/Core/DataExtractor.cpp @@ -11,6 +11,8 @@ #include <stddef.h> #include <bitset> +#include <limits> +#include <sstream> #include <string> #include "llvm/ADT/APFloat.h" @@ -1706,22 +1708,28 @@ DataExtractor::Dump (Stream *s, break; case eFormatFloat: - if (sizeof(float) == item_byte_size) - { - s->Printf ("%g", GetFloat (&offset)); - } - else if (sizeof(double) == item_byte_size) - { - s->Printf ("%lg", GetDouble(&offset)); - } - else if (sizeof(long double) == item_byte_size) - { - s->Printf ("%Lg", GetLongDouble(&offset)); - } - else { - s->Printf("error: unsupported byte size (%u) for float format", item_byte_size); - return offset; + std::ostringstream ss; + switch (item_byte_size) + { + default: + s->Printf("error: unsupported byte size (%u) for float format", item_byte_size); + return offset; + case sizeof(float): + ss.precision(std::numeric_limits<float>::digits10); + ss << GetFloat(&offset); + break; + case sizeof(double): + ss.precision(std::numeric_limits<double>::digits10); + ss << GetDouble(&offset); + break; + case sizeof(long double): + ss.precision(std::numeric_limits<long double>::digits10); + ss << GetLongDouble(&offset); + break; + } + ss.flush(); + s->Printf("%s", ss.str().c_str()); } break; |

