From: Greg Clayton Date: Wed, 31 Oct 2012 21:44:39 +0000 (+0000) Subject: Resolve any bundle paths we are given when the specified executable is a bundle. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48baf7a788272d088cb90d7b53e3415bd860bdf9;p=platform%2Fupstream%2Fllvm.git Resolve any bundle paths we are given when the specified executable is a bundle. llvm-svn: 167175 --- diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp index 4df1148..bb5e72c 100644 --- a/lldb/tools/debugserver/source/DNB.cpp +++ b/lldb/tools/debugserver/source/DNB.cpp @@ -31,6 +31,8 @@ #include "DNBDataRef.h" #include "DNBThreadResumeActions.h" #include "DNBTimer.h" +#include "CFBundle.h" + typedef STD_SHARED_PTR(MachProcess) MachProcessSP; typedef std::map ProcessMap; @@ -2097,6 +2099,21 @@ DNBResolveExecutablePath (const char *path, char *resolved_path, size_t resolved if (result.empty()) result = path; + + struct stat path_stat; + if (::stat(path, &path_stat) == 0) + { + if ((path_stat.st_mode & S_IFMT) == S_IFDIR) + { + CFBundle bundle (path); + CFReleaser url(bundle.CopyExecutableURL ()); + if (url.get()) + { + if (::CFURLGetFileSystemRepresentation (url.get(), true, (UInt8*)resolved_path, resolved_path_size)) + return true; + } + } + } if (realpath(path, max_path)) { diff --git a/lldb/tools/debugserver/source/MacOSX/CFBundle.cpp b/lldb/tools/debugserver/source/MacOSX/CFBundle.cpp index a157550..fdcb7cc 100644 --- a/lldb/tools/debugserver/source/MacOSX/CFBundle.cpp +++ b/lldb/tools/debugserver/source/MacOSX/CFBundle.cpp @@ -85,3 +85,13 @@ CFBundle::GetIdentifier () const return ::CFBundleGetIdentifier (bundle); return NULL; } + + +CFURLRef +CFBundle::CopyExecutableURL () const +{ + CFBundleRef bundle = get(); + if (bundle != NULL) + return CFBundleCopyExecutableURL(bundle); + return NULL; +} diff --git a/lldb/tools/debugserver/source/MacOSX/CFBundle.h b/lldb/tools/debugserver/source/MacOSX/CFBundle.h index d980c0b..e08290a 100644 --- a/lldb/tools/debugserver/source/MacOSX/CFBundle.h +++ b/lldb/tools/debugserver/source/MacOSX/CFBundle.h @@ -25,11 +25,17 @@ public: CFBundle(const char *path = NULL); CFBundle(const CFBundle& rhs); CFBundle& operator=(const CFBundle& rhs); - virtual ~CFBundle(); + virtual + ~CFBundle(); + bool + SetPath (const char *path); - bool SetPath (const char *path); - CFStringRef GetIdentifier () const; + CFStringRef + GetIdentifier () const; + CFURLRef + CopyExecutableURL () const; + protected: CFReleaser m_bundle_url; };