Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b96a6a1

Browse filesBrowse files
committed
[lldb] Add support for displaying __float128 variables
1 parent 0fb5720 commit b96a6a1
Copy full SHA for b96a6a1

File tree

Expand file treeCollapse file tree

13 files changed

+63
-10
lines changed
Filter options
Expand file treeCollapse file tree

13 files changed

+63
-10
lines changed

‎lldb/bindings/python/python-extensions.swig

Copy file name to clipboardExpand all lines: lldb/bindings/python/python-extensions.swig
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ def is_numeric_type(basic_type):
594594
if basic_type == eBasicTypeFloat: return (True,True)
595595
if basic_type == eBasicTypeDouble: return (True,True)
596596
if basic_type == eBasicTypeLongDouble: return (True,True)
597+
if basic_type == eBasicTypeFloat128: return (True,True)
597598
if basic_type == eBasicTypeFloatComplex: return (True,True)
598599
if basic_type == eBasicTypeDoubleComplex: return (True,True)
599600
if basic_type == eBasicTypeLongDoubleComplex: return (True,True)

‎lldb/docs/python_api_enums.rst

Copy file name to clipboardExpand all lines: lldb/docs/python_api_enums.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ Format
321321
.. py:data:: eFormatInstruction
322322
.. py:data:: eFormatVoid
323323
.. py:data:: eFormatUnicode8
324+
.. py:data:: eFormatFloat128
324325
325326
326327
.. _DescriptionLevel:
@@ -1045,6 +1046,7 @@ BasicType
10451046
.. py:data:: eBasicTypeObjCSel
10461047
.. py:data:: eBasicTypeNullPtr
10471048
.. py:data:: eBasicTypeOther
1049+
.. py:data:: eBasicTypeFloat128
10481050
10491051
10501052
.. _TraceType:

‎lldb/include/lldb/Symbol/TypeSystem.h

Copy file name to clipboardExpand all lines: lldb/include/lldb/Symbol/TypeSystem.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ class TypeSystem : public PluginInterface,
310310

311311
// Exploring the type
312312

313-
virtual const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) = 0;
313+
virtual const llvm::fltSemantics &
314+
GetFloatTypeSemantics(size_t byte_size, bool prefer_float128) = 0;
314315

315316
virtual llvm::Expected<uint64_t>
316317
GetBitSize(lldb::opaque_compiler_type_t type,

‎lldb/include/lldb/lldb-enumerations.h

Copy file name to clipboardExpand all lines: lldb/include/lldb/lldb-enumerations.h
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ enum Format {
203203
eFormatInstruction, ///< Disassemble an opcode
204204
eFormatVoid, ///< Do not print this
205205
eFormatUnicode8,
206+
eFormatFloat128, ///< Disambiguate between 128-bit `long double` (which uses
207+
///< `eFormatFloat`) and `__float128` (which uses
208+
///< `eFormatFloat128`). If the value being formatted is not
209+
///< 128 bits, then this is identical to `eFormatFloat`.
206210
kNumFormats
207211
};
208212

@@ -837,7 +841,8 @@ enum BasicType {
837841
eBasicTypeObjCClass,
838842
eBasicTypeObjCSel,
839843
eBasicTypeNullPtr,
840-
eBasicTypeOther
844+
eBasicTypeOther,
845+
eBasicTypeFloat128
841846
};
842847

843848
/// Deprecated

‎lldb/source/Commands/CommandObjectMemory.cpp

Copy file name to clipboardExpand all lines: lldb/source/Commands/CommandObjectMemory.cpp
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class OptionGroupReadMemory : public OptionGroup {
156156

157157
case eFormatBinary:
158158
case eFormatFloat:
159+
case eFormatFloat128:
159160
case eFormatOctal:
160161
case eFormatDecimal:
161162
case eFormatEnum:
@@ -1330,6 +1331,7 @@ class CommandObjectMemoryWrite : public CommandObjectParsed {
13301331
switch (m_format_options.GetFormat()) {
13311332
case kNumFormats:
13321333
case eFormatFloat: // TODO: add support for floats soon
1334+
case eFormatFloat128:
13331335
case eFormatCharPrintable:
13341336
case eFormatBytesWithASCII:
13351337
case eFormatComplex:

‎lldb/source/Core/DumpDataExtractor.cpp

Copy file name to clipboardExpand all lines: lldb/source/Core/DumpDataExtractor.cpp
+10-4Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,15 @@ static void printMemoryTags(const DataExtractor &DE, Stream *s,
318318
}
319319

320320
static const llvm::fltSemantics &GetFloatSemantics(const TargetSP &target_sp,
321-
size_t byte_size) {
321+
size_t byte_size,
322+
bool prefer_float128) {
322323
if (target_sp) {
323324
auto type_system_or_err =
324325
target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC);
325326
if (!type_system_or_err)
326327
llvm::consumeError(type_system_or_err.takeError());
327328
else if (auto ts = *type_system_or_err)
328-
return ts->GetFloatTypeSemantics(byte_size);
329+
return ts->GetFloatTypeSemantics(byte_size, prefer_float128);
329330
}
330331
// No target, just make a reasonable guess
331332
switch(byte_size) {
@@ -335,6 +336,10 @@ static const llvm::fltSemantics &GetFloatSemantics(const TargetSP &target_sp,
335336
return llvm::APFloat::IEEEsingle();
336337
case 8:
337338
return llvm::APFloat::IEEEdouble();
339+
case 16:
340+
if (prefer_float128) {
341+
return llvm::APFloat::IEEEquad();
342+
}
338343
}
339344
return llvm::APFloat::Bogus();
340345
}
@@ -653,6 +658,7 @@ lldb::offset_t lldb_private::DumpDataExtractor(
653658
}
654659
} break;
655660

661+
case eFormatFloat128:
656662
case eFormatFloat: {
657663
TargetSP target_sp;
658664
if (exe_scope)
@@ -665,8 +671,8 @@ lldb::offset_t lldb_private::DumpDataExtractor(
665671
// Show full precision when printing float values
666672
const unsigned format_precision = 0;
667673

668-
const llvm::fltSemantics &semantics =
669-
GetFloatSemantics(target_sp, item_byte_size);
674+
const llvm::fltSemantics &semantics = GetFloatSemantics(
675+
target_sp, item_byte_size, item_format == eFormatFloat128);
670676

671677
// Recalculate the byte size in case of a difference. This is possible
672678
// when item_byte_size is 16 (128-bit), because you could get back the

‎lldb/source/DataFormatters/FormatManager.cpp

Copy file name to clipboardExpand all lines: lldb/source/DataFormatters/FormatManager.cpp
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static constexpr FormatInfo g_format_infos[] = {
7272
{eFormatInstruction, 'i', "instruction"},
7373
{eFormatVoid, 'v', "void"},
7474
{eFormatUnicode8, 'u', "unicode8"},
75+
{eFormatFloat128, '\0', "float128"},
7576
};
7677

7778
static_assert((sizeof(g_format_infos) / sizeof(g_format_infos[0])) ==

‎lldb/source/DataFormatters/VectorType.cpp

Copy file name to clipboardExpand all lines: lldb/source/DataFormatters/VectorType.cpp
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ static CompilerType GetCompilerTypeForFormat(lldb::Format format,
5555

5656
case lldb::eFormatFloat:
5757
return type_system->GetBasicTypeFromAST(lldb::eBasicTypeFloat);
58+
case lldb::eFormatFloat128:
59+
return type_system->GetBasicTypeFromAST(lldb::eBasicTypeFloat128);
5860

5961
case lldb::eFormatHex:
6062
case lldb::eFormatHexUppercase:

‎lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Copy file name to clipboardExpand all lines: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+24-1Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,8 @@ TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
809809
return GetType(ast.LongDoubleTy);
810810
if (QualTypeMatchesBitSize(bit_size, ast, ast.HalfTy))
811811
return GetType(ast.HalfTy);
812+
if (QualTypeMatchesBitSize(bit_size, ast, ast.Float128Ty))
813+
return GetType(ast.Float128Ty);
812814
break;
813815

814816
case eEncodingVector:
@@ -970,6 +972,13 @@ CompilerType TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
970972
if (type_name == "long double" &&
971973
QualTypeMatchesBitSize(bit_size, ast, ast.LongDoubleTy))
972974
return GetType(ast.LongDoubleTy);
975+
// As Rust currently uses `TypeSystemClang`, match `f128` here as well so it
976+
// doesn't get misinterpreted as `long double` on targets where they are
977+
// the same size but different formats.
978+
if ((type_name == "__float128" || type_name == "_Float128" ||
979+
type_name == "f128") &&
980+
QualTypeMatchesBitSize(bit_size, ast, ast.Float128Ty))
981+
return GetType(ast.Float128Ty);
973982
// Fall back to not requiring a name match
974983
if (QualTypeMatchesBitSize(bit_size, ast, ast.FloatTy))
975984
return GetType(ast.FloatTy);
@@ -979,6 +988,8 @@ CompilerType TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
979988
return GetType(ast.LongDoubleTy);
980989
if (QualTypeMatchesBitSize(bit_size, ast, ast.HalfTy))
981990
return GetType(ast.HalfTy);
991+
if (QualTypeMatchesBitSize(bit_size, ast, ast.Float128Ty))
992+
return GetType(ast.Float128Ty);
982993
break;
983994

984995
case DW_ATE_signed:
@@ -2068,6 +2079,8 @@ TypeSystemClang::GetOpaqueCompilerType(clang::ASTContext *ast,
20682079
return ast->DoubleTy.getAsOpaquePtr();
20692080
case eBasicTypeLongDouble:
20702081
return ast->LongDoubleTy.getAsOpaquePtr();
2082+
case eBasicTypeFloat128:
2083+
return ast->Float128Ty.getAsOpaquePtr();
20712084
case eBasicTypeFloatComplex:
20722085
return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
20732086
case eBasicTypeDoubleComplex:
@@ -4737,19 +4750,23 @@ CompilerType TypeSystemClang::CreateGenericFunctionPrototype() {
47374750
// Exploring the type
47384751

47394752
const llvm::fltSemantics &
4740-
TypeSystemClang::GetFloatTypeSemantics(size_t byte_size) {
4753+
TypeSystemClang::GetFloatTypeSemantics(size_t byte_size, bool prefer_float128) {
47414754
clang::ASTContext &ast = getASTContext();
47424755
const size_t bit_size = byte_size * 8;
47434756
if (bit_size == ast.getTypeSize(ast.FloatTy))
47444757
return ast.getFloatTypeSemantics(ast.FloatTy);
47454758
else if (bit_size == ast.getTypeSize(ast.DoubleTy))
47464759
return ast.getFloatTypeSemantics(ast.DoubleTy);
4760+
else if (prefer_float128 && bit_size == ast.getTypeSize(ast.Float128Ty))
4761+
return ast.getFloatTypeSemantics(ast.Float128Ty);
47474762
else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
47484763
bit_size == llvm::APFloat::semanticsSizeInBits(
47494764
ast.getFloatTypeSemantics(ast.LongDoubleTy)))
47504765
return ast.getFloatTypeSemantics(ast.LongDoubleTy);
47514766
else if (bit_size == ast.getTypeSize(ast.HalfTy))
47524767
return ast.getFloatTypeSemantics(ast.HalfTy);
4768+
else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4769+
return ast.getFloatTypeSemantics(ast.Float128Ty);
47534770
return llvm::APFloatBase::Bogus();
47544771
}
47554772

@@ -5222,6 +5239,8 @@ lldb::Format TypeSystemClang::GetFormat(lldb::opaque_compiler_type_t type) {
52225239
case clang::BuiltinType::Double:
52235240
case clang::BuiltinType::LongDouble:
52245241
return lldb::eFormatFloat;
5242+
case clang::BuiltinType::Float128:
5243+
return lldb::eFormatFloat128;
52255244
default:
52265245
return lldb::eFormatHex;
52275246
}
@@ -5545,6 +5564,8 @@ TypeSystemClang::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) {
55455564
return eBasicTypeDouble;
55465565
case clang::BuiltinType::LongDouble:
55475566
return eBasicTypeLongDouble;
5567+
case clang::BuiltinType::Float128:
5568+
return eBasicTypeFloat128;
55485569

55495570
case clang::BuiltinType::NullPtr:
55505571
return eBasicTypeNullPtr;
@@ -6106,6 +6127,7 @@ uint32_t TypeSystemClang::GetNumPointeeChildren(clang::QualType type) {
61066127
case clang::BuiltinType::Float:
61076128
case clang::BuiltinType::Double:
61086129
case clang::BuiltinType::LongDouble:
6130+
case clang::BuiltinType::Float128:
61096131
case clang::BuiltinType::Dependent:
61106132
case clang::BuiltinType::Overload:
61116133
case clang::BuiltinType::ObjCId:
@@ -8837,6 +8859,7 @@ bool TypeSystemClang::DumpTypeValue(
88378859
case eFormatHex:
88388860
case eFormatHexUppercase:
88398861
case eFormatFloat:
8862+
case eFormatFloat128:
88408863
case eFormatOctal:
88418864
case eFormatOSType:
88428865
case eFormatUnsigned:

‎lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Copy file name to clipboardExpand all lines: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,8 @@ class TypeSystemClang : public TypeSystem {
826826

827827
// Exploring the type
828828

829-
const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) override;
829+
const llvm::fltSemantics &
830+
GetFloatTypeSemantics(size_t byte_size, bool prefer_float128) override;
830831

831832
llvm::Expected<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type,
832833
ExecutionContextScope *exe_scope) {

‎lldb/source/ValueObject/ValueObject.cpp

Copy file name to clipboardExpand all lines: lldb/source/ValueObject/ValueObject.cpp
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,8 +1468,9 @@ bool ValueObject::DumpPrintableRepresentation(
14681468
(custom_format == eFormatComplexFloat) ||
14691469
(custom_format == eFormatDecimal) || (custom_format == eFormatHex) ||
14701470
(custom_format == eFormatHexUppercase) ||
1471-
(custom_format == eFormatFloat) || (custom_format == eFormatOctal) ||
1472-
(custom_format == eFormatOSType) ||
1471+
(custom_format == eFormatFloat) ||
1472+
(custom_format == eFormatFloat128) ||
1473+
(custom_format == eFormatOctal) || (custom_format == eFormatOSType) ||
14731474
(custom_format == eFormatUnicode16) ||
14741475
(custom_format == eFormatUnicode32) ||
14751476
(custom_format == eFormatUnsigned) ||

‎lldb/unittests/Core/DumpDataExtractorTest.cpp

Copy file name to clipboardExpand all lines: lldb/unittests/Core/DumpDataExtractorTest.cpp
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ TEST_F(DumpDataExtractorTest, Formats) {
163163
TestDump(0xcafef00d, lldb::Format::eFormatHex, "0xcafef00d");
164164
TestDump(0xcafef00d, lldb::Format::eFormatHexUppercase, "0xCAFEF00D");
165165
TestDump(0.456, lldb::Format::eFormatFloat, "0.45600000000000002");
166+
TestDump(std::vector<uint64_t>{0x47ae147ae147ae14, 0x40011147ae147ae1},
167+
lldb::Format::eFormatFloat128,
168+
"4.26999999999999999999999999999999963");
166169
TestDump(9, lldb::Format::eFormatOctal, "011");
167170
// Chars packed into an integer.
168171
TestDump<uint32_t>(0x4C4C4442, lldb::Format::eFormatOSType, "'LLDB'");
@@ -388,6 +391,9 @@ TEST_F(DumpDataExtractorTest, ItemByteSizeErrors) {
388391
TestDumpWithItemByteSize(
389392
18, lldb::Format::eFormatFloat,
390393
"error: unsupported byte size (18) for float format");
394+
TestDumpWithItemByteSize(
395+
17, lldb::Format::eFormatFloat128,
396+
"error: unsupported byte size (17) for float format");
391397

392398
// We want sizes to exactly match one of float/double.
393399
TestDumpWithItemByteSize(

‎lldb/unittests/Symbol/TestTypeSystemClang.cpp

Copy file name to clipboardExpand all lines: lldb/unittests/Symbol/TestTypeSystemClang.cpp
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ TEST_F(TestTypeSystemClang, TestGetBasicTypeFromEnum) {
7676
context.getComplexType(context.FloatTy)));
7777
EXPECT_TRUE(
7878
context.hasSameType(GetBasicQualType(eBasicTypeHalf), context.HalfTy));
79+
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeFloat128),
80+
context.Float128Ty));
7981
EXPECT_TRUE(
8082
context.hasSameType(GetBasicQualType(eBasicTypeInt), context.IntTy));
8183
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeInt128),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.