diff options
Diffstat (limited to 'source/Plugins/Process/POSIX/ProcessPOSIX.cpp')
| -rw-r--r-- | source/Plugins/Process/POSIX/ProcessPOSIX.cpp | 66 | 
1 files changed, 43 insertions, 23 deletions
diff --git a/source/Plugins/Process/POSIX/ProcessPOSIX.cpp b/source/Plugins/Process/POSIX/ProcessPOSIX.cpp index 62394623c59d..f340631c7d07 100644 --- a/source/Plugins/Process/POSIX/ProcessPOSIX.cpp +++ b/source/Plugins/Process/POSIX/ProcessPOSIX.cpp @@ -70,8 +70,8 @@ ProcessPOSIX::Initialize()  //------------------------------------------------------------------------------  // Constructors and destructors. -ProcessPOSIX::ProcessPOSIX(Target& target, Listener &listener) -    : Process(target, listener), +ProcessPOSIX::ProcessPOSIX(Target& target, Listener &listener, UnixSignalsSP &unix_signals_sp) +    : Process(target, listener, unix_signals_sp),        m_byte_order(lldb::endian::InlHostByteOrder()),        m_monitor(NULL),        m_module(NULL), @@ -176,23 +176,23 @@ ProcessPOSIX::WillLaunch(Module* module)  }  const char * -ProcessPOSIX::GetFilePath( -    const lldb_private::ProcessLaunchInfo::FileAction *file_action, -    const char *default_path) +ProcessPOSIX::GetFilePath(const lldb_private::FileAction *file_action, const char *default_path)  {      const char *pts_name = "/dev/pts/";      const char *path = NULL;      if (file_action)      { -        if (file_action->GetAction () == ProcessLaunchInfo::FileAction::eFileActionOpen) +        if (file_action->GetAction() == FileAction::eFileActionOpen) +        {              path = file_action->GetPath();              // By default the stdio paths passed in will be pseudo-terminal              // (/dev/pts). If so, convert to using a different default path              // instead to redirect I/O to the debugger console. This should              //  also handle user overrides to /dev/null or a different file. -            if (::strncmp(path, pts_name, ::strlen(pts_name)) == 0) +            if (!path || ::strncmp(path, pts_name, ::strlen(pts_name)) == 0)                  path = default_path; +        }      }      return path; @@ -217,7 +217,7 @@ ProcessPOSIX::DoLaunch (Module *module,      SetPrivateState(eStateLaunching); -    const lldb_private::ProcessLaunchInfo::FileAction *file_action; +    const lldb_private::FileAction *file_action;      // Default of NULL will mean to use existing open file descriptors      const char *stdin_path = NULL; @@ -241,6 +241,7 @@ ProcessPOSIX::DoLaunch (Module *module,                                      stdout_path,                                       stderr_path,                                      working_dir, +                                    launch_info,                                      error);      m_module = module; @@ -335,11 +336,9 @@ ProcessPOSIX::DoDestroy()      if (!HasExited())      { -        // Drive the exit event to completion (do not keep the inferior in -        // limbo). +        assert(m_monitor);          m_exit_now = true; - -        if ((m_monitor == NULL || kill(m_monitor->GetPID(), SIGKILL)) && error.Success()) +        if (!m_monitor->Kill())          {              error.SetErrorToErrno();              return error; @@ -379,6 +378,8 @@ ProcessPOSIX::DoDidExec()  void  ProcessPOSIX::SendMessage(const ProcessMessage &message)  { +    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS)); +      Mutex::Locker lock(m_message_mutex);      Mutex::Locker thread_lock(m_thread_list.GetMutex()); @@ -420,8 +421,14 @@ ProcessPOSIX::SendMessage(const ProcessMessage &message)          break;      case ProcessMessage::eExitMessage: -        assert(thread); -        thread->SetState(eStateExited); +        if (thread != nullptr) +            thread->SetState(eStateExited); +        else +        { +            if (log) +                log->Warning ("ProcessPOSIX::%s eExitMessage for TID %" PRIu64 " failed to find a thread to mark as eStateExited, ignoring", __FUNCTION__, message.GetTID ()); +        } +          // FIXME: I'm not sure we need to do this.          if (message.GetTID() == GetID())          { @@ -635,20 +642,26 @@ ProcessPOSIX::DoDeallocateMemory(lldb::addr_t addr)  size_t  ProcessPOSIX::GetSoftwareBreakpointTrapOpcode(BreakpointSite* bp_site)  { +    static const uint8_t g_aarch64_opcode[] = { 0x00, 0x00, 0x20, 0xD4 };      static const uint8_t g_i386_opcode[] = { 0xCC };      ArchSpec arch = GetTarget().GetArchitecture();      const uint8_t *opcode = NULL;      size_t opcode_size = 0; -    switch (arch.GetCore()) +    switch (arch.GetMachine())      {      default:          assert(false && "CPU type not supported!");          break; -    case ArchSpec::eCore_x86_32_i386: -    case ArchSpec::eCore_x86_64_x86_64: +    case llvm::Triple::aarch64: +        opcode = g_aarch64_opcode; +        opcode_size = sizeof(g_aarch64_opcode); +        break; + +    case llvm::Triple::x86: +    case llvm::Triple::x86_64:          opcode = g_i386_opcode;          opcode_size = sizeof(g_i386_opcode);          break; @@ -865,12 +878,6 @@ ProcessPOSIX::PutSTDIN(const char *buf, size_t len, Error &error)      return status;  } -UnixSignals & -ProcessPOSIX::GetUnixSignals() -{ -    return m_signals; -} -  //------------------------------------------------------------------------------  // Utility functions. @@ -926,3 +933,16 @@ ProcessPOSIX::IsAThreadRunning()      }      return is_running;  } + +const DataBufferSP +ProcessPOSIX::GetAuxvData () +{ +    // If we're the local platform, we can ask the host for auxv data. +    PlatformSP platform_sp = m_target.GetPlatform (); +    if (platform_sp && platform_sp->IsHost ()) +        return lldb_private::Host::GetAuxvData(this); + +    // Somewhat unexpected - the process is not running locally or we don't have a platform. +    assert (false && "no platform or not the host - how did we get here with ProcessPOSIX?"); +    return DataBufferSP (); +}  | 
