diff options
Diffstat (limited to 'source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp')
| -rw-r--r-- | source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp | 61 | 
1 files changed, 44 insertions, 17 deletions
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index dc0917255d9b..da29c16ac3ab 100644 --- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -10,10 +10,13 @@  #include "lldb/lldb-python.h"  #include "PlatformFreeBSD.h" +#include "lldb/Host/Config.h"  // C Includes  #include <stdio.h> +#ifndef LLDB_DISABLE_POSIX  #include <sys/utsname.h> +#endif  // C++ Includes  // Other libraries and framework includes @@ -153,6 +156,26 @@ PlatformFreeBSD::~PlatformFreeBSD()  {  } +//TODO:VK: inherit PlatformPOSIX +lldb_private::Error +PlatformFreeBSD::RunShellCommand (const char *command, +                                  const char *working_dir, +                                  int *status_ptr, +                                  int *signo_ptr, +                                  std::string *command_output, +                                  uint32_t timeout_sec) +{ +    if (IsHost()) +        return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec); +    else +    { +        if (m_remote_platform_sp) +            return m_remote_platform_sp->RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec); +        else +            return Error("unable to run a remote command without a platform"); +    } +} +  Error  PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file, @@ -162,10 +185,10 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file,  {      Error error;      // Nothing special to do here, just use the actual file and architecture - +          char exe_path[PATH_MAX];      FileSpec resolved_exe_file (exe_file); - +          if (IsHost())      {          // If we have "ls" as the exe_file, resolve the executable location based on @@ -175,10 +198,10 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file,              exe_file.GetPath(exe_path, sizeof(exe_path));              resolved_exe_file.SetFile(exe_path, true);          } - +                  if (!resolved_exe_file.Exists())              resolved_exe_file.ResolveExecutableLocation (); - +                  if (resolved_exe_file.Exists())              error.Clear();          else @@ -214,7 +237,6 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file,          }      } -      if (error.Success())      {          ModuleSpec module_spec (resolved_exe_file, exe_arch); @@ -225,7 +247,7 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file,                                                   module_search_paths_ptr,                                                   NULL,                                                   NULL); - +                          if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL)              {                  exe_module_sp.reset(); @@ -256,12 +278,12 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file,                      else                          error.SetErrorToGenericError();                  } - +                                  if (idx > 0)                      arch_names.PutCString (", ");                  arch_names.PutCString (platform_arch.GetArchitectureName());              } - +                          if (error.Fail() || !exe_module_sp)              {                  error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s", @@ -271,11 +293,6 @@ PlatformFreeBSD::ResolveExecutable (const FileSpec &exe_file,              }          }      } -    else -    { -        error.SetErrorStringWithFormat ("'%s' does not exist", -                                        exe_file.GetPath().c_str()); -    }      return error;  } @@ -636,13 +653,23 @@ PlatformFreeBSD::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)  void  PlatformFreeBSD::GetStatus (Stream &strm)  { +#ifndef LLDB_DISABLE_POSIX      struct utsname un; -    if (uname(&un)) { -        strm << "FreeBSD"; -        return; -    } +    strm << "      Host: "; + +    ::memset(&un, 0, sizeof(utsname)); +    if (uname(&un) == -1) +        strm << "FreeBSD" << '\n'; +    strm << un.sysname << ' ' << un.release; +    if (un.nodename[0] != '\0') +        strm << " (" << un.nodename << ')'; +    strm << '\n'; + +    // Dump a common information about the platform status.      strm << "Host: " << un.sysname << ' ' << un.release << ' ' << un.version << '\n'; +#endif +      Platform::GetStatus(strm);  }  | 
