[Lldb-commits] [lldb] r166368 - /lldb/trunk/source/Core/DataExtractor.cpp
Sean Callanan
scallanan at apple.com
Fri Oct 19 23:08:09 PDT 2012
Author: spyffe
Date: Sat Oct 20 01:08:09 2012
New Revision: 166368
URL: http://llvm.org/viewvc/llvm-project?rev=166368&view=rev
Log:
Fixed a bug that caused floating-point values
to be printed truncated.
<rdar://problem/12389615>
Modified:
lldb/trunk/source/Core/DataExtractor.cpp
Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=166368&r1=166367&r2=166368&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Sat Oct 20 01:08:09 2012
@@ -11,6 +11,8 @@
#include <stddef.h>
#include <bitset>
+#include <limits>
+#include <sstream>
#include <string>
#include "llvm/ADT/APFloat.h"
@@ -1706,22 +1708,28 @@
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;
More information about the lldb-commits
mailing list