@@ -958,50 +958,70 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
958
958
959
959
Process *process = m_exe_ctx.GetProcessPtr ();
960
960
ExecutionContext exe_ctx (process);
961
+
961
962
ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get (*process);
962
- if (objc_runtime) {
963
- ObjCLanguageRuntime::TaggedPointerVendor *tagged_ptr_vendor =
964
- objc_runtime->GetTaggedPointerVendor ();
965
- if (tagged_ptr_vendor) {
966
- for (size_t i = 0 ; i < command.GetArgumentCount (); i++) {
967
- const char *arg_str = command.GetArgumentAtIndex (i);
968
- if (!arg_str)
969
- continue ;
970
- Status error;
971
- lldb::addr_t arg_addr = OptionArgParser::ToAddress (
972
- &exe_ctx, arg_str, LLDB_INVALID_ADDRESS, &error);
973
- if (arg_addr == 0 || arg_addr == LLDB_INVALID_ADDRESS || error.Fail ())
974
- continue ;
975
- auto descriptor_sp = tagged_ptr_vendor->GetClassDescriptor (arg_addr);
976
- if (!descriptor_sp)
977
- continue ;
978
- uint64_t info_bits = 0 ;
979
- uint64_t value_bits = 0 ;
980
- uint64_t payload = 0 ;
981
- if (descriptor_sp->GetTaggedPointerInfo (&info_bits, &value_bits,
982
- &payload)) {
983
- result.GetOutputStream ().Printf (
984
- " 0x%" PRIx64 " is tagged.\n\t payload = 0x%" PRIx64
985
- " \n\t value = 0x%" PRIx64 " \n\t info bits = 0x%" PRIx64
986
- " \n\t class = %s\n " ,
987
- (uint64_t )arg_addr, payload, value_bits, info_bits,
988
- descriptor_sp->GetClassName ().AsCString (" <unknown>" ));
989
- } else {
990
- result.GetOutputStream ().Printf (" 0x%" PRIx64 " is not tagged.\n " ,
991
- (uint64_t )arg_addr);
992
- }
993
- }
994
- } else {
995
- result.AppendError (" current process has no tagged pointer support" );
963
+ if (!objc_runtime) {
964
+ result.AppendError (" current process has no Objective-C runtime loaded" );
965
+ result.SetStatus (lldb::eReturnStatusFailed);
966
+ return false ;
967
+ }
968
+
969
+ ObjCLanguageRuntime::TaggedPointerVendor *tagged_ptr_vendor =
970
+ objc_runtime->GetTaggedPointerVendor ();
971
+ if (!tagged_ptr_vendor) {
972
+ result.AppendError (" current process has no tagged pointer support" );
973
+ result.SetStatus (lldb::eReturnStatusFailed);
974
+ return false ;
975
+ }
976
+
977
+ for (size_t i = 0 ; i < command.GetArgumentCount (); i++) {
978
+ const char *arg_str = command.GetArgumentAtIndex (i);
979
+ if (!arg_str)
980
+ continue ;
981
+
982
+ Status error;
983
+ lldb::addr_t arg_addr = OptionArgParser::ToAddress (
984
+ &exe_ctx, arg_str, LLDB_INVALID_ADDRESS, &error);
985
+ if (arg_addr == 0 || arg_addr == LLDB_INVALID_ADDRESS || error.Fail ()) {
986
+ result.AppendErrorWithFormatv (
987
+ " could not convert '{0}' to a valid address\n " , arg_str);
996
988
result.SetStatus (lldb::eReturnStatusFailed);
997
989
return false ;
998
990
}
999
- result.SetStatus (lldb::eReturnStatusSuccessFinishResult);
1000
- return true ;
991
+
992
+ if (!tagged_ptr_vendor->IsPossibleTaggedPointer (arg_addr)) {
993
+ result.GetOutputStream ().Format (" {0:x16} is not tagged\n " , arg_addr);
994
+ continue ;
995
+ }
996
+
997
+ auto descriptor_sp = tagged_ptr_vendor->GetClassDescriptor (arg_addr);
998
+ if (!descriptor_sp) {
999
+ result.AppendErrorWithFormatv (
1000
+ " could not get class descriptor for {0:x16}\n " , arg_addr);
1001
+ result.SetStatus (lldb::eReturnStatusFailed);
1002
+ return false ;
1003
+ }
1004
+
1005
+ uint64_t info_bits = 0 ;
1006
+ uint64_t value_bits = 0 ;
1007
+ uint64_t payload = 0 ;
1008
+ if (descriptor_sp->GetTaggedPointerInfo (&info_bits, &value_bits,
1009
+ &payload)) {
1010
+ result.GetOutputStream ().Format (
1011
+ " {0:x} is tagged\n "
1012
+ " \t payload = {1:x16}\n "
1013
+ " \t value = {2:x16}\n "
1014
+ " \t info bits = {3:x16}\n "
1015
+ " \t class = {4}\n " ,
1016
+ arg_addr, payload, value_bits, info_bits,
1017
+ descriptor_sp->GetClassName ().AsCString (" <unknown>" ));
1018
+ } else {
1019
+ result.GetOutputStream ().Format (" {0:x16} is not tagged\n " , arg_addr);
1020
+ }
1001
1021
}
1002
- result. AppendError ( " current process has no Objective-C runtime loaded " );
1003
- result.SetStatus (lldb::eReturnStatusFailed );
1004
- return false ;
1022
+
1023
+ result.SetStatus (lldb::eReturnStatusSuccessFinishResult );
1024
+ return true ;
1005
1025
}
1006
1026
};
1007
1027
0 commit comments