[Lldb-commits] [lldb] r154871 - in /lldb/branches/lldb-platform-work: include/lldb/Host/Host.h source/Host/macosx/Host.mm source/Plugins/Platform/MacOSX/PlatformDarwin.cpp source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp source/Plugins/Platform/MacOSX/PlatformMacOSX.h source/Plugins/Platform/POSIX/PlatformPOSIX.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp

Enrico Granata egranata at apple.com
Mon Apr 16 15:26:43 PDT 2012


Author: enrico
Date: Mon Apr 16 17:26:43 2012
New Revision: 154871

URL: http://llvm.org/viewvc/llvm-project?rev=154871&view=rev
Log:
Several small fixes to remote debugging.

Modified:
    lldb/branches/lldb-platform-work/include/lldb/Host/Host.h
    lldb/branches/lldb-platform-work/source/Host/macosx/Host.mm
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
    lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp

Modified: lldb/branches/lldb-platform-work/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Host/Host.h?rev=154871&r1=154870&r2=154871&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Host/Host.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Host/Host.h Mon Apr 16 17:26:43 2012
@@ -461,7 +461,7 @@
                              Error &error);
     
     static uint32_t
-    RunProgramAndGetExitCode (const FileSpec& file_spec);
+    RunProgramAndGetExitCode (const char* cmd_line);
     
     static uint32_t
     MakeDirectory (const char* path, mode_t mode);

Modified: lldb/branches/lldb-platform-work/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Host/macosx/Host.mm?rev=154871&r1=154870&r2=154871&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Host/macosx/Host.mm (original)
+++ lldb/branches/lldb-platform-work/source/Host/macosx/Host.mm Mon Apr 16 17:26:43 2012
@@ -1845,12 +1845,9 @@
 }
 
 uint32_t
-Host::RunProgramAndGetExitCode (const FileSpec& file_spec)
+Host::RunProgramAndGetExitCode (const char *cmd_line)
 {
-    std::string path;
-    if (file_spec.GetPath(path) == 0)
-        return UINT32_MAX;
-    return ::system(path.c_str());
+    return ::system(cmd_line);
 }
 
 uint32_t

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=154871&r1=154870&r2=154871&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Apr 16 17:26:43 2012
@@ -132,11 +132,11 @@
             StreamString arch_names;
             for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
             {
-                error = ModuleList::GetSharedModule (module_spec, 
-                                                     exe_module_sp, 
-                                                     module_search_paths_ptr,
-                                                     NULL, 
-                                                     NULL);
+                error = GetSharedModule (module_spec, 
+                                         exe_module_sp, 
+                                         module_search_paths_ptr,
+                                         NULL, 
+                                         NULL);
                 // Did we find an executable using one of the 
                 if (error.Success())
                 {

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=154871&r1=154870&r2=154871&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Mon Apr 16 17:26:43 2012
@@ -115,7 +115,8 @@
 /// Default Constructor
 //------------------------------------------------------------------
 PlatformMacOSX::PlatformMacOSX (bool is_host) :
-    PlatformDarwin (is_host)
+    PlatformDarwin (is_host),
+    m_local_cache_directory()
 {
 }
 
@@ -155,3 +156,57 @@
 #endif
 }
 
+void
+PlatformMacOSX::SetLocalCacheDirectory (const char* local)
+{
+    m_local_cache_directory.assign(local);
+}
+
+const char*
+PlatformMacOSX::GetLocalCacheDirectory ()
+{
+    return m_local_cache_directory.c_str();
+}
+
+lldb_private::Error
+PlatformMacOSX::GetSharedModule (const lldb_private::ModuleSpec &module_spec,
+                                 lldb::ModuleSP &module_sp,
+                                 const lldb_private::FileSpecList *module_search_paths_ptr,
+                                 lldb::ModuleSP *old_module_sp_ptr,
+                                 bool *did_create_ptr)
+{
+    printf("Trying to find module %s/%s - platform path %s/%s symbol path %s/%s\n",
+           module_spec.GetFileSpec().GetDirectory().AsCString(),
+           module_spec.GetFileSpec().GetFilename().AsCString(),
+           module_spec.GetPlatformFileSpec().GetDirectory().AsCString(),
+           module_spec.GetPlatformFileSpec().GetFilename().AsCString(),
+           module_spec.GetSymbolFileSpec().GetDirectory().AsCString(),
+           module_spec.GetSymbolFileSpec().GetFilename().AsCString());
+    if (module_spec.GetFileSpec().Exists() && !module_sp)
+    {
+        module_sp.reset(new Module(module_spec));
+        return Error();
+    }
+    // try to find the module in the cache
+    std::string cache_path(GetLocalCacheDirectory());
+    if (cache_path[cache_path.size()-1] != '/')
+        cache_path.append(1,'/');
+    std::string module_path;
+    module_spec.GetFileSpec().GetPath(module_path);
+    cache_path.append(module_path);
+    FileSpec module_cache_spec(cache_path.c_str(),false);
+    if (module_cache_spec.Exists())
+    {
+        ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
+        module_sp.reset(new Module(local_spec));
+        return Error();
+    }
+    // bring in the remote module file
+    return Error("unimplemented");
+}
+
+lldb_private::Options *
+PlatformMacOSX::GetConnectionOptions (lldb_private::CommandInterpreter& interpreter)
+{
+    return PlatformDarwin::GetConnectionOptions(interpreter);
+}

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h?rev=154871&r1=154870&r2=154871&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h Mon Apr 16 17:26:43 2012
@@ -70,6 +70,13 @@
         return 1;
     }
     
+    virtual lldb_private::Error
+    GetSharedModule (const lldb_private::ModuleSpec &module_spec,
+                     lldb::ModuleSP &module_sp,
+                     const lldb_private::FileSpecList *module_search_paths_ptr,
+                     lldb::ModuleSP *old_module_sp_ptr,
+                     bool *did_create_ptr);
+    
     virtual const char *
     GetDescription ()
     {
@@ -84,6 +91,19 @@
     virtual bool
     GetSupportedArchitectureAtIndex (uint32_t idx, 
                                      lldb_private::ArchSpec &arch);
+    
+    virtual void
+    SetLocalCacheDirectory (const char* local);
+    
+    virtual const char*
+    GetLocalCacheDirectory ();
+    
+    // must add --local-cache to the parent options
+    virtual lldb_private::Options *
+    GetConnectionOptions (lldb_private::CommandInterpreter& interpreter);
+    
+protected:
+    std::string m_local_cache_directory;
 
 private:
     DISALLOW_COPY_AND_ASSIGN (PlatformMacOSX);

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=154871&r1=154870&r2=154871&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Mon Apr 16 17:26:43 2012
@@ -131,9 +131,7 @@
 PlatformPOSIX::RunShellCommand (const std::string &command_line)
 {
     if (IsHost())
-    {
-        return Host::RunProgramAndGetExitCode(FileSpec(command_line.c_str(),false));
-    }
+        return Host::RunProgramAndGetExitCode(command_line.c_str());
     if (IsRemote())
     {
         if (GetSupportsSSH())
@@ -293,7 +291,7 @@
                                src_path.c_str(),
                                GetHostname(),
                                dst_path.c_str());
-            if (RunShellCommand(command.GetData()) == 0)
+            if (Host::RunProgramAndGetExitCode(command.GetData()) == 0)
             {
                 if (chown_file(this,dst_path.c_str(),uid,gid) != 0)
                     return Error("unable to perform chown");

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=154871&r1=154870&r2=154871&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Mon Apr 16 17:26:43 2012
@@ -864,7 +864,7 @@
     packet.SetFilePos(::strlen("qPlatform_Syscall_System:"));
     std::string path;
     packet.GetHexByteString(path);
-    uint32_t retcode = Host::RunProgramAndGetExitCode(FileSpec(path.c_str(),false));
+    uint32_t retcode = Host::RunProgramAndGetExitCode(path.c_str());
     StreamString response;
     response.PutHex32(retcode);
     SendPacketNoLock(response.GetData(), response.GetSize());





More information about the lldb-commits mailing list