static lldb::addr_t GetObjectPointer (lldb::StackFrameSP frame_sp, ConstString &object_name, Error &err) { err.Clear(); if (!frame_sp) { err.SetErrorStringWithFormat("Couldn't load '%s' because the context is incomplete", object_name.AsCString()); return LLDB_INVALID_ADDRESS; } lldb::VariableSP var_sp; lldb::ValueObjectSP valobj_sp; valobj_sp = frame_sp->GetValueForVariableExpressionPath(object_name.AsCString(), lldb::eNoDynamicValues, StackFrame::eExpressionPathOptionCheckPtrVsMember | StackFrame::eExpressionPathOptionsNoFragileObjcIvar | StackFrame::eExpressionPathOptionsNoSyntheticChildren | StackFrame::eExpressionPathOptionsNoSyntheticArrayRange, var_sp, err); if (!err.Success() || !valobj_sp.get()) return LLDB_INVALID_ADDRESS; lldb::addr_t ret = valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); if (ret == LLDB_INVALID_ADDRESS) { err.SetErrorStringWithFormat("Couldn't load '%s' because its value couldn't be evaluated", object_name.AsCString()); return LLDB_INVALID_ADDRESS; } return ret; }
void Symbol::GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const { s->Printf("id = {0x%8.8x}", m_uid); if (m_addr_range.GetBaseAddress().GetSection()) { if (ValueIsAddress()) { const lldb::addr_t byte_size = GetByteSize(); if (byte_size > 0) { s->PutCString (", range = "); m_addr_range.Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); } else { s->PutCString (", address = "); m_addr_range.GetBaseAddress().Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); } } else s->Printf (", value = 0x%16.16" PRIx64, m_addr_range.GetBaseAddress().GetOffset()); } else { if (m_size_is_sibling) s->Printf (", sibling = %5" PRIu64, m_addr_range.GetBaseAddress().GetOffset()); else s->Printf (", value = 0x%16.16" PRIx64, m_addr_range.GetBaseAddress().GetOffset()); } ConstString demangled = m_mangled.GetDemangledName(GetLanguage()); if (demangled) s->Printf(", name=\"%s\"", demangled.AsCString()); if (m_mangled.GetMangledName()) s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString()); }
Error PlatformRemoteAppleWatch::GetSharedModule( const ModuleSpec &module_spec, lldb_private::Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, bool *did_create_ptr) { // For Apple Watch, the SDK files are all cached locally on the host // system. So first we ask for the file in the cached SDK, // then we attempt to get a shared module for the right architecture // with the right UUID. const FileSpec &platform_file = module_spec.GetFileSpec(); Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE); Error error; char platform_file_path[PATH_MAX]; if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) { ModuleSpec platform_module_spec(module_spec); UpdateSDKDirectoryInfosIfNeeded(); const uint32_t num_sdk_infos = m_sdk_directory_infos.size(); // If we are connected we migth be able to correctly deduce the SDK // directory // using the OS build. const uint32_t connected_sdk_idx = GetConnectedSDKIndex(); if (connected_sdk_idx < num_sdk_infos) { if (log) { log->Printf("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[connected_sdk_idx] .directory.GetPath() .c_str()); } if (GetFileInSDK(platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); error = ResolveExecutable(platform_module_spec, module_sp, nullptr); if (module_sp) { m_last_module_sdk_idx = connected_sdk_idx; error.Clear(); return error; } } } // Try the last SDK index if it is set as most files from an SDK // will tend to be valid in that same SDK. if (m_last_module_sdk_idx < num_sdk_infos) { if (log) { log->Printf("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[m_last_module_sdk_idx] .directory.GetPath() .c_str()); } if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec())) { module_sp.reset(); error = ResolveExecutable(platform_module_spec, module_sp, nullptr); if (module_sp) { error.Clear(); return error; } } } // First try for an exact match of major, minor and update for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) { if (m_last_module_sdk_idx == sdk_idx) { // Skip the last module SDK index if we already searched // it above continue; } if (log) { log->Printf("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str()); } if (GetFileInSDK(platform_file_path, sdk_idx, platform_module_spec.GetFileSpec())) { // printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str()); error = ResolveExecutable(platform_module_spec, module_sp, nullptr); if (module_sp) { // Remember the index of the last SDK that we found a file // in in case the wrong SDK was selected. m_last_module_sdk_idx = sdk_idx; error.Clear(); return error; } } } } // Not the module we are looking for... Nothing to see here... module_sp.reset(); // This may not be an SDK-related module. Try whether we can bring in the // thing to our local cache. error = GetSharedModuleWithLocalCache(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr); if (error.Success()) return error; // See if the file is present in any of the module_search_paths_ptr // directories. if (!module_sp && module_search_paths_ptr && platform_file) { // create a vector of all the file / directory names in platform_file // e.g. this might be // /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation // // We'll need to look in the module_search_paths_ptr directories for // both "UIFoundation" and "UIFoundation.framework" -- most likely the // latter will be the one we find there. FileSpec platform_pull_apart(platform_file); std::vector<std::string> path_parts; ConstString unix_root_dir("/"); while (true) { ConstString part = platform_pull_apart.GetLastPathComponent(); platform_pull_apart.RemoveLastPathComponent(); if (part.IsEmpty() || part == unix_root_dir) break; path_parts.push_back(part.AsCString()); } const size_t path_parts_size = path_parts.size(); size_t num_module_search_paths = module_search_paths_ptr->GetSize(); for (size_t i = 0; i < num_module_search_paths; ++i) { // Create a new FileSpec with this module_search_paths_ptr // plus just the filename ("UIFoundation"), then the parent // dir plus filename ("UIFoundation.framework/UIFoundation") // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo") for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j) { FileSpec path_to_try(module_search_paths_ptr->GetFileSpecAtIndex(i)); // Add the components backwards. For // .../PrivateFrameworks/UIFoundation.framework/UIFoundation // path_parts is // [0] UIFoundation // [1] UIFoundation.framework // [2] PrivateFrameworks // // and if 'j' is 2, we want to append path_parts[1] and then // path_parts[0], aka // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr // path. for (int k = j; k >= 0; --k) { path_to_try.AppendPathComponent(path_parts[k]); } if (path_to_try.Exists()) { ModuleSpec new_module_spec(module_spec); new_module_spec.GetFileSpec() = path_to_try; Error new_error(Platform::GetSharedModule( new_module_spec, process, module_sp, NULL, old_module_sp_ptr, did_create_ptr)); if (module_sp) { module_sp->SetPlatformFileSpec(path_to_try); return new_error; } } } } } const bool always_create = false; error = ModuleList::GetSharedModule( module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr, always_create); if (module_sp) module_sp->SetPlatformFileSpec(platform_file); return error; }
void Dematerialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, lldb::addr_t frame_top, lldb::addr_t frame_bottom, Status &err) override { err.Clear(); ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope(); if (!exe_scope) { err.SetErrorString("Couldn't dematerialize a result variable: invalid " "execution context scope"); return; } lldb::addr_t address; Status read_error; const lldb::addr_t load_addr = process_address + m_offset; map.ReadPointerFromMemory(&address, load_addr, read_error); if (!read_error.Success()) { err.SetErrorString("Couldn't dematerialize a result variable: couldn't " "read its address"); return; } lldb::TargetSP target_sp = exe_scope->CalculateTarget(); if (!target_sp) { err.SetErrorString("Couldn't dematerialize a result variable: no target"); return; } Status type_system_error; TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage( &type_system_error, m_type.GetMinimumLanguage()); if (!type_system) { err.SetErrorStringWithFormat("Couldn't dematerialize a result variable: " "couldn't get the corresponding type " "system: %s", type_system_error.AsCString()); return; } PersistentExpressionState *persistent_state = type_system->GetPersistentExpressionState(); if (!persistent_state) { err.SetErrorString("Couldn't dematerialize a result variable: " "corresponding type system doesn't handle persistent " "variables"); return; } ConstString name = m_delegate ? m_delegate->GetName() : persistent_state->GetNextPersistentVariableName(); lldb::ExpressionVariableSP ret = persistent_state->CreatePersistentVariable( exe_scope, name, m_type, map.GetByteOrder(), map.GetAddressByteSize()); if (!ret) { err.SetErrorStringWithFormat("couldn't dematerialize a result variable: " "failed to make persistent variable %s", name.AsCString()); return; } lldb::ProcessSP process_sp = map.GetBestExecutionContextScope()->CalculateProcess(); if (m_delegate) { m_delegate->DidDematerialize(ret); } bool can_persist = (m_is_program_reference && process_sp && process_sp->CanJIT() && !(address >= frame_bottom && address < frame_top)); if (can_persist && m_keep_in_memory) { ret->m_live_sp = ValueObjectConstResult::Create(exe_scope, m_type, name, address, eAddressTypeLoad, map.GetAddressByteSize()); } ret->ValueUpdated(); const size_t pvar_byte_size = ret->GetByteSize(); uint8_t *pvar_data = ret->GetValueBytes(); map.ReadMemory(pvar_data, address, pvar_byte_size, read_error); if (!read_error.Success()) { err.SetErrorString( "Couldn't dematerialize a result variable: couldn't read its memory"); return; } if (!can_persist || !m_keep_in_memory) { ret->m_flags |= ExpressionVariable::EVNeedsAllocation; if (m_temporary_allocation != LLDB_INVALID_ADDRESS) { Status free_error; map.Free(m_temporary_allocation, free_error); } } else { ret->m_flags |= ExpressionVariable::EVIsLLDBAllocated; } m_temporary_allocation = LLDB_INVALID_ADDRESS; m_temporary_allocation_size = 0; }
void Add (ConstString& type_name, ConstString& type_equivalent) { m_impl.Insert(type_name.AsCString(), type_equivalent); }
void lldb_private::formatters::AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp, CXXFunctionSummaryFormat::Callback funct, const char* description, ConstString type_name, TypeSummaryImpl::Flags flags, bool regex) { lldb::TypeSummaryImplSP summary_sp(new CXXFunctionSummaryFormat(flags,funct,description)); if (regex) category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp); else category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp); }
void lldb_private::formatters::AddOneLineSummary (TypeCategoryImpl::SharedPointer category_sp, ConstString type_name, TypeSummaryImpl::Flags flags, bool regex) { flags.SetShowMembersOneLiner(true); lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags, "")); if (regex) category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp); else category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp); }
void lldb_private::formatters::AddStringSummary(TypeCategoryImpl::SharedPointer category_sp, const char* string, ConstString type_name, TypeSummaryImpl::Flags flags, bool regex) { lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags, string)); if (regex) category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp); else category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp); }
void lldb_private::formatters::AddSummary(TypeCategoryImpl::SharedPointer category_sp, TypeSummaryImplSP summary_sp, ConstString type_name, bool regex) { if (regex) category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),summary_sp); else category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp); }
void lldb_private::formatters::AddFormat (TypeCategoryImpl::SharedPointer category_sp, lldb::Format format, ConstString type_name, TypeFormatImpl::Flags flags, bool regex) { lldb::TypeFormatImplSP format_sp(new TypeFormatImpl_Format(format, flags)); if (regex) category_sp->GetRegexTypeFormatsContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())),format_sp); else category_sp->GetTypeFormatsContainer()->Add(type_name, format_sp); }
void lldb_private::formatters::AddFilter (TypeCategoryImpl::SharedPointer category_sp, std::vector<std::string> children, const char* description, ConstString type_name, ScriptedSyntheticChildren::Flags flags, bool regex) { TypeFilterImplSP filter_sp(new TypeFilterImpl(flags)); for (auto child : children) filter_sp->AddExpressionPath(child); if (regex) category_sp->GetRegexTypeFiltersContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())), filter_sp); else category_sp->GetTypeFiltersContainer()->Add(type_name,filter_sp); }
void lldb_private::formatters::AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp, CXXSyntheticChildren::CreateFrontEndCallback generator, const char* description, ConstString type_name, ScriptedSyntheticChildren::Flags flags, bool regex) { lldb::SyntheticChildrenSP synth_sp(new CXXSyntheticChildren(flags,description,generator)); if (regex) category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression(type_name.AsCString())), synth_sp); else category_sp->GetTypeSyntheticsContainer()->Add(type_name,synth_sp); }
ValueObjectSP ValueObject::GetChildMemberWithName (const ConstString &name, bool can_create) { // when getting a child by name, it could be burried inside some base // classes (which really aren't part of the expression path), so we // need a vector of indexes that can get us down to the correct child std::vector<uint32_t> child_indexes; clang::ASTContext *clang_ast = GetClangAST(); void *clang_type = GetOpaqueClangQualType(); bool omit_empty_base_classes = true; const size_t num_child_indexes = ClangASTContext::GetIndexOfChildMemberWithName (clang_ast, clang_type, name.AsCString(), omit_empty_base_classes, child_indexes); ValueObjectSP child_sp; if (num_child_indexes > 0) { std::vector<uint32_t>::const_iterator pos = child_indexes.begin (); std::vector<uint32_t>::const_iterator end = child_indexes.end (); child_sp = GetChildAtIndex(*pos, can_create); for (++pos; pos != end; ++pos) { if (child_sp) { ValueObjectSP new_child_sp(child_sp->GetChildAtIndex (*pos, can_create)); child_sp = new_child_sp; } else { child_sp.reset(); } } } return child_sp; }