Author: Jonas Devlieghere Date: 2021-11-03T15:04:36-07:00 New Revision: f9e6be5cc1a2cfe5294d4d55336b23266fcfc26f
URL: https://github.com/llvm/llvm-project/commit/f9e6be5cc1a2cfe5294d4d55336b23266fcfc26f DIFF: https://github.com/llvm/llvm-project/commit/f9e6be5cc1a2cfe5294d4d55336b23266fcfc26f.diff LOG: [lldb] Update tagged pointer command output and test. - Use formatv to print the addresses. - Add check for 0x0 which is treated as an invalid address. - Use a an address that's less likely to be interpreted as a real tagged pointer. Added: Modified: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py Removed: ################################################################################ diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index b4c517e76c49a..2cc05f4234fa7 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -976,17 +976,16 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info lldb::addr_t arg_addr = OptionArgParser::ToAddress( &exe_ctx, arg_str, LLDB_INVALID_ADDRESS, &error); if (arg_addr == 0 || arg_addr == LLDB_INVALID_ADDRESS || error.Fail()) { - result.AppendErrorWithFormat( - "could not convert '%s' to a valid address\n", arg_str); + result.AppendErrorWithFormatv( + "could not convert '{0}' to a valid address\n", arg_str); result.SetStatus(lldb::eReturnStatusFailed); return false; } auto descriptor_sp = tagged_ptr_vendor->GetClassDescriptor(arg_addr); if (!descriptor_sp) { - result.AppendErrorWithFormat( - "could not get class descriptor for 0x%" PRIx64 "\n", - (uint64_t)arg_addr); + result.AppendErrorWithFormatv( + "could not get class descriptor for {0:x}\n", arg_addr); result.SetStatus(lldb::eReturnStatusFailed); return false; } @@ -996,14 +995,16 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info uint64_t payload = 0; if (descriptor_sp->GetTaggedPointerInfo(&info_bits, &value_bits, &payload)) { - result.GetOutputStream().Printf( - "0x%" PRIx64 " is tagged.\n\tpayload = 0x%" PRIx64 - "\n\tvalue = 0x%" PRIx64 "\n\tinfo bits = 0x%" PRIx64 - "\n\tclass = %s\n", - (uint64_t)arg_addr, payload, value_bits, info_bits, + result.GetOutputStream().Format( + "{0:x} is tagged\n" + "\tpayload = {1:x}\n" + "\tvalue = {2:x}\n" + "\tinfo bits = {3:x}\n" + "\tclass = {4}\n", + arg_addr, payload, value_bits, info_bits, descriptor_sp->GetClassName().AsCString("<unknown>")); } else { - result.GetOutputStream().Printf("0x%" PRIx64 " is not tagged.\n", + result.GetOutputStream().Format("{0:x16} is not tagged\n", (uint64_t)arg_addr); } } diff --git a/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py b/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py index 0b9ebd86a914b..fbe9de7ecf80e 100644 --- a/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py +++ b/lldb/test/API/lang/objc/tagged-pointer/TestTaggedPointerCmd.py @@ -15,6 +15,8 @@ def test(self): self.expect("lang objc tagged-pointer info bogus", error=True, patterns=["could not convert 'bogus' to a valid address"]) - self.expect("lang objc tagged-pointer info 0x1", error=True, - patterns=["could not get class descriptor for 0x1"]) + self.expect("lang objc tagged-pointer info 0x0", error=True, + patterns=["could not convert '0x0' to a valid address"]) + self.expect("lang objc tagged-pointer info 0xffffffff", error=True, + patterns=["could not get class descriptor for 0xffffffff"]) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits