diff options
Diffstat (limited to 'lldb')
8 files changed, 150 insertions, 4 deletions
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index e836009a6fb..dbec198c15e 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -139,6 +139,8 @@ public: bool GetEnableSyntheticValue() const; + uint32_t GetMaxZeroPaddingInFloatFormat() const; + uint32_t GetMaximumNumberOfChildrenToDisplay() const; uint32_t GetMaximumSizeOfStringSummary() const; diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/float-display/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/float-display/Makefile new file mode 100644 index 00000000000..f5a47fcc46c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/float-display/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../make +C_SOURCES := main.c +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/float-display/TestFloatDisplay.py b/lldb/packages/Python/lldbsuite/test/functionalities/float-display/TestFloatDisplay.py new file mode 100644 index 00000000000..48e49ed009b --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/float-display/TestFloatDisplay.py @@ -0,0 +1,5 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest( + __file__, globals(), []) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/float-display/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/float-display/main.c new file mode 100644 index 00000000000..7e89225a4cb --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/float-display/main.c @@ -0,0 +1,121 @@ +float f_neg3 = 1.234567 / 1e3; +float f_neg4 = 1.234567 / 1e4; +float f_neg5 = 1.234567 / 1e5; +float f_neg6 = 1.234567 / 1e6; +float f_neg7 = 1.234567 / 1e7; +float f_neg8 = 1.234567 / 1e8; +float f_neg20 = 1.234567 / 1e20; +float f_neg30 = 1.234567 / 1e30; + +float f_3 = 1.234567 * 1e3; +float f_4 = 1.234567 * 1e4; +float f_5 = 1.234567 * 1e5; +float f_6 = 1.234567 * 1e6; +float f_7 = 1.234567 * 1e7; +float f_8 = 1.234567 * 1e8; +float f_20 = 1.234567 * 1e20; +float f_30 = 1.234567 * 1e30; + +double d_neg3 = 1.234567 / 1e3; +double d_neg4 = 1.234567 / 1e4; +double d_neg5 = 1.234567 / 1e5; +double d_neg6 = 1.234567 / 1e6; +double d_neg7 = 1.234567 / 1e7; +double d_neg8 = 1.234567 / 1e8; +double d_neg20 = 1.234567 / 1e20; +double d_neg30 = 1.234567 / 1e30; +double d_neg50 = 1.234567 / 1e50; +double d_neg250 = 1.234567 / 1e250; + +double d_3 = 1.234567 * 1e3; +double d_4 = 1.234567 * 1e4; +double d_5 = 1.234567 * 1e5; +double d_6 = 1.234567 * 1e6; +double d_7 = 1.234567 * 1e7; +double d_8 = 1.234567 * 1e8; +double d_20 = 1.234567 * 1e20; +double d_30 = 1.234567 * 1e30; +double d_50 = 1.234567 * 1e50; +double d_250 = 1.234567 * 1e250; + +int main (int argc, char const *argv[]) { + //% # Default setting should be 6. + //% self.expect("frame variable f_neg3", substrs=["0.00123456"]) + //% self.expect("frame variable f_neg4", substrs=["0.000123456"]) + //% self.expect("frame variable f_neg5", substrs=["0.0000123456"]) + //% self.expect("frame variable f_neg6", substrs=["0.00000123456"]) + //% self.expect("frame variable f_neg7", substrs=["1.234567", "E-7"]) + //% self.expect("frame variable f_neg8", substrs=["1.23456", "E-8"]) + //% self.expect("frame variable f_neg20", substrs=["E-20"]) + //% self.expect("frame variable f_neg30", substrs=["E-30"]) + //% self.expect("frame variable f_3", substrs=["1234.56"]) + //% self.expect("frame variable f_4", substrs=["12345.6"]) + //% self.expect("frame variable f_5", substrs=["123456"]) + //% self.expect("frame variable f_6", substrs=["123456"]) + //% self.expect("frame variable f_7", substrs=["123456"]) + //% self.expect("frame variable f_8", substrs=["123456"]) + //% self.expect("frame variable f_20", substrs=["E+20"]) + //% self.expect("frame variable f_30", substrs=["E+30"]) + //% self.expect("frame variable d_neg3", substrs=["0.00123456"]) + //% self.expect("frame variable d_neg4", substrs=["0.000123456"]) + //% self.expect("frame variable d_neg5", substrs=["0.0000123456"]) + //% self.expect("frame variable d_neg6", substrs=["0.00000123456"]) + //% self.expect("frame variable d_neg7", substrs=["1.23456", "E-7"]) + //% self.expect("frame variable d_neg8", substrs=["1.23456", "E-8"]) + //% self.expect("frame variable d_neg20", substrs=["1.23456", "E-20"]) + //% self.expect("frame variable d_neg30", substrs=["1.23456", "E-30"]) + //% self.expect("frame variable d_neg50", substrs=["1.23456", "E-50"]) + //% self.expect("frame variable d_neg250", substrs=["E-250"]) + //% self.expect("frame variable d_3", substrs=["1234.56"]) + //% self.expect("frame variable d_4", substrs=["12345.6"]) + //% self.expect("frame variable d_5", substrs=["123456"]) + //% self.expect("frame variable d_6", substrs=["1234567"]) + //% self.expect("frame variable d_7", substrs=["1234567"]) + //% self.expect("frame variable d_8", substrs=["1234567"]) + //% self.expect("frame variable d_20", substrs=["1.23456", "E+20"]) + //% self.expect("frame variable d_30", substrs=["1.23456", "E+30"]) + //% self.expect("frame variable d_50", substrs=["1.23456", "E+50"]) + //% self.expect("frame variable d_250", substrs=["1.23456", "E+250"]) + //% # Now change the setting to print all the zeroes. + //% # Note that changing this setting should invalidate the data visualizer + //% # cache so that the new setting is used in the following calls. + //% self.runCmd("settings set target.max-zero-padding-in-float-format 9999") + //% self.expect("frame variable f_neg3", substrs=["0.00123456"]) + //% self.expect("frame variable f_neg4", substrs=["0.000123456"]) + //% self.expect("frame variable f_neg5", substrs=["0.0000123456"]) + //% self.expect("frame variable f_neg6", substrs=["0.00000123456"]) + //% self.expect("frame variable f_neg7", substrs=["0.000000123456"]) + //% self.expect("frame variable f_neg8", substrs=["0.0000000123456"]) + //% self.expect("frame variable f_neg20", substrs=["0.0000000000000000000123456"]) + //% self.expect("frame variable f_neg30", substrs=["0.00000000000000000000000000000123456"]) + //% self.expect("frame variable f_3", substrs=["1234.56"]) + //% self.expect("frame variable f_4", substrs=["12345.6"]) + //% self.expect("frame variable f_5", substrs=["123456"]) + //% self.expect("frame variable f_6", substrs=["1234567"]) + //% self.expect("frame variable f_7", substrs=["1234567"]) + //% self.expect("frame variable f_8", substrs=["1234567"]) + //% self.expect("frame variable f_20", substrs=["E+20"]) + //% self.expect("frame variable f_30", substrs=["E+30"]) + //% self.expect("frame variable d_neg3", substrs=["0.00123456"]) + //% self.expect("frame variable d_neg4", substrs=["0.000123456"]) + //% self.expect("frame variable d_neg5", substrs=["0.0000123456"]) + //% self.expect("frame variable d_neg6", substrs=["0.00000123456"]) + //% self.expect("frame variable d_neg7", substrs=["0.000000123456"]) + //% self.expect("frame variable d_neg8", substrs=["0.0000000123456"]) + //% self.expect("frame variable d_neg20", substrs=["0.0000000000000000000123456"]) + //% self.expect("frame variable d_neg30", substrs=["0.000000000000000000000000000001234567"]) + //% self.expect("frame variable d_neg50", substrs=["0.0000000000000000000000000000000000000000000000000123456"]) + //% self.expect("frame variable d_neg250", substrs=["0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456"]) + //% self.expect("frame variable d_3", substrs=["1234.56"]) + //% self.expect("frame variable d_4", substrs=["12345.6"]) + //% self.expect("frame variable d_5", substrs=["123456"]) + //% self.expect("frame variable d_6", substrs=["1234567"]) + //% self.expect("frame variable d_7", substrs=["1234567"]) + //% self.expect("frame variable d_8", substrs=["1234567"]) + //% # Positive numbers are not affected by this setting. + //% self.expect("frame variable d_20", substrs=["1.23456", "E+20"]) + //% self.expect("frame variable d_30", substrs=["1.23456", "E+30"]) + //% self.expect("frame variable d_50", substrs=["1.23456", "E+50"]) + //% self.expect("frame variable d_250", substrs=["1.23456", "E+250"]) + return 0; +} diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 683ecefe097..2e293f57c81 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -257,7 +257,14 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, llvm::StringRef value) { bool is_load_script = (property_path == "target.load-script-from-symbol-file"); - bool is_escape_non_printables = (property_path == "escape-non-printables"); + // These properties might change how we visualize data. + bool invalidate_data_vis = (property_path == "escape-non-printables"); + invalidate_data_vis |= + (property_path == "target.max-zero-padding-in-float-format"); + if (invalidate_data_vis) { + DataVisualization::ForceUpdate(); + } + TargetSP target_sp; LoadScriptFromSymFile load_script_old_value; if (is_load_script && exe_ctx->GetTargetSP()) { @@ -300,8 +307,6 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, } } } - } else if (is_escape_non_printables) { - DataVisualization::ForceUpdate(); } } return error; diff --git a/lldb/source/Core/DumpDataExtractor.cpp b/lldb/source/Core/DumpDataExtractor.cpp index 30c3a821c98..af8239332b1 100644 --- a/lldb/source/Core/DumpDataExtractor.cpp +++ b/lldb/source/Core/DumpDataExtractor.cpp @@ -563,7 +563,8 @@ lldb::offset_t lldb_private::DumpDataExtractor( llvm::SmallVector<char, 256> sv; // Show full precision when printing float values const unsigned format_precision = 0; - const unsigned format_max_padding = 100; + const unsigned format_max_padding = + target_sp->GetMaxZeroPaddingInFloatFormat(); size_t item_bit_size = item_byte_size * 8; if (item_bit_size == ast->getTypeSize(ast->FloatTy)) { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 5675e788a21..c92d63882c0 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3789,6 +3789,12 @@ bool TargetProperties::GetEnableSyntheticValue() const { nullptr, idx, g_target_properties[idx].default_uint_value != 0); } +uint32_t TargetProperties::GetMaxZeroPaddingInFloatFormat() const { + const uint32_t idx = ePropertyMaxZeroPaddingInFloatFormat; + return m_collection_sp->GetPropertyAtIndexAsUInt64( + nullptr, idx, g_target_properties[idx].default_uint_value); +} + uint32_t TargetProperties::GetMaximumNumberOfChildrenToDisplay() const { const uint32_t idx = ePropertyMaxChildrenCount; return m_collection_sp->GetPropertyAtIndexAsSInt64( diff --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td index 7fa8f1cdd8d..9079c3cf427 100644 --- a/lldb/source/Target/TargetProperties.td +++ b/lldb/source/Target/TargetProperties.td @@ -60,6 +60,9 @@ let Definition = "target" in { def SaveObjects: Property<"save-jit-objects", "Boolean">, DefaultFalse, Desc<"Save intermediate object files generated by the LLVM JIT">; + def MaxZeroPaddingInFloatFormat: Property<"max-zero-padding-in-float-format", "UInt64">, + DefaultUnsignedValue<6>, + Desc<"The maximum number of zeroes to insert when displaying a very small float before falling back to scientific notation.">; def MaxChildrenCount: Property<"max-children-count", "SInt64">, DefaultUnsignedValue<256>, Desc<"Maximum number of children to expand in any level of depth.">; |