Yeah I need to see if I can write a unit test instantiating the platform and changing the values that HostInfo::GetLLDBPath returns to synthetic values, but I haven’t had time to look at that yet.
> On Dec 21, 2017, at 7:01 AM, Davide Italiano via lldb-commits > <lldb-commits@lists.llvm.org> wrote: > > Jason, any chance we can write a test case for this? > > -- > Davide > >> On Mon, Dec 11, 2017 at 12:52 AM, Davide Italiano <dccitali...@gmail.com> >> wrote: >> Testcase? >> >> On Fri, Dec 8, 2017 at 7:06 PM, Jason Molenda via lldb-commits >> <lldb-commits@lists.llvm.org> wrote: >>> Author: jmolenda >>> Date: Fri Dec 8 19:06:19 2017 >>> New Revision: 320240 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=320240&view=rev >>> Log: >>> Update PlatformDarwin::GetDeveloperDir to handle the two >>> most common cases where the Xcode.app bundle puts lldb - >>> either as a default part of the bundle, or in a toolchain >>> subdirectory, so the platform subclasses can find files >>> relative to this directory. >>> >>> Dropped support for handling the case where the lldb >>> framework was in /Library/PrivateFrameworks. I think >>> this was intended to handle the case where lldb is installed >>> in / (outside the Xcode.app bundle) - but in that case, we >>> can look in the raw directory file paths to find anything. >>> >>> <rdar://problem/35285622> >>> >>> Modified: >>> lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp >>> >>> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=320240&r1=320239&r2=320240&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original) >>> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Fri Dec 8 >>> 19:06:19 2017 >>> @@ -1132,28 +1132,33 @@ bool PlatformDarwin::ARMGetSupportedArch >>> return false; >>> } >>> >>> +// Return a directory path like /Applications/Xcode.app/Contents/Developer >>> const char *PlatformDarwin::GetDeveloperDirectory() { >>> std::lock_guard<std::mutex> guard(m_mutex); >>> if (m_developer_directory.empty()) { >>> bool developer_dir_path_valid = false; >>> char developer_dir_path[PATH_MAX]; >>> FileSpec temp_file_spec; >>> + >>> + // Get the lldb framework's file path, and if it exists, truncate some >>> + // components to only the developer directory path. >>> if (HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, temp_file_spec)) { >>> if (temp_file_spec.GetPath(developer_dir_path, >>> sizeof(developer_dir_path))) { >>> + // e.g. >>> /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework >>> char *shared_frameworks = >>> strstr(developer_dir_path, "/SharedFrameworks/LLDB.framework"); >>> if (shared_frameworks) { >>> - ::snprintf(shared_frameworks, >>> - sizeof(developer_dir_path) - >>> - (shared_frameworks - developer_dir_path), >>> - "/Developer"); >>> + shared_frameworks[0] = '\0'; // truncate developer_dir_path at >>> this point >>> + strncat (developer_dir_path, "/Developer", sizeof >>> (developer_dir_path) - 1); // add /Developer on >>> developer_dir_path_valid = true; >>> } else { >>> - char *lib_priv_frameworks = strstr( >>> - developer_dir_path, >>> "/Library/PrivateFrameworks/LLDB.framework"); >>> - if (lib_priv_frameworks) { >>> - *lib_priv_frameworks = '\0'; >>> + // e.g. >>> /Applications/Xcode.app/Contents/Developer/Toolchains/iOS11.2.xctoolchain/System/Library/PrivateFrameworks/LLDB.framework >>> + char *developer_toolchains = >>> + strstr(developer_dir_path, "/Contents/Developer/Toolchains/"); >>> + if (developer_toolchains) { >>> + developer_toolchains += sizeof ("/Contents/Developer") - 1; >>> + developer_toolchains[0] = '\0'; // truncate developer_dir_path >>> at this point >>> developer_dir_path_valid = true; >>> } >>> } >>> >>> >>> _______________________________________________ >>> lldb-commits mailing list >>> lldb-commits@lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits > _______________________________________________ > lldb-commits mailing list > lldb-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits