From ba38ef02cca96861d1a6d5f7244904c9b0dc0f3f Mon Sep 17 00:00:00 2001 From: Lyupa Anastasia Date: Wed, 26 Oct 2022 16:44:33 +0300 Subject: [PATCH] Fix Create host sysroot link if uuid is invalid Check if module exists before getting its UUID Signed-off-by: Lyupa Anastasia --- lldb/source/Target/ModuleCache.cpp | 32 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lldb/source/Target/ModuleCache.cpp b/lldb/source/Target/ModuleCache.cpp index 08fb43bf7a57..18fefacad588 100644 --- a/lldb/source/Target/ModuleCache.cpp +++ b/lldb/source/Target/ModuleCache.cpp @@ -132,21 +132,6 @@ Status CreateHostSysRootModuleLink(const FileSpec &root_dir_spec, const auto sysroot_module_path_spec = JoinPath(JoinPath(root_dir_spec, hostname), platform_module_spec.GetPath().c_str()); - UUID module_uuid; - { - auto module_sp = - std::make_shared(ModuleSpec(sysroot_module_path_spec)); - module_uuid = module_sp->GetUUID(); - } - - if (!module_uuid.IsValid()) { - LLDB_LOGF(log, "Try CreateHostSysRootModuleLink but uuid is invalid %s", - module_uuid.GetAsString().c_str()); - return Status(); - } - - LLDB_LOGF(log, "CreateHostSysRootModuleLink with uuid %s", - module_uuid.GetAsString().c_str()); if (FileSystem::Instance().Exists(sysroot_module_path_spec)) { if (!delete_existing) @@ -155,6 +140,23 @@ Status CreateHostSysRootModuleLink(const FileSpec &root_dir_spec, DecrementRefExistingModule(root_dir_spec, sysroot_module_path_spec); } + // sysroot_module_path_spec might still exist. + // It means that module UUID is not valid. + if (FileSystem::Instance().Exists(sysroot_module_path_spec)) { + auto module_sp = + std::make_shared(ModuleSpec(sysroot_module_path_spec)); + UUID module_uuid = module_sp->GetUUID(); + + if (!module_uuid.IsValid()) { + LLDB_LOGF(log, "Try CreateHostSysRootModuleLink but uuid is invalid %s", + module_uuid.GetAsString().c_str()); + return Status(); + } + + LLDB_LOGF(log, "CreateHostSysRootModuleLink with uuid %s", + module_uuid.GetAsString().c_str()); + } + const auto error = MakeDirectory( FileSpec(sysroot_module_path_spec.GetDirectory().AsCString())); if (error.Fail()) -- Gitee