2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBProcess.cpp -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBProcess.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#include "lldb/lldb-defines.h"
|
|
|
|
#include "lldb/lldb-types.h"
|
|
|
|
|
2010-06-16 03:49:27 +08:00
|
|
|
#include "lldb/Interpreter/Args.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/DataBufferHeap.h"
|
|
|
|
#include "lldb/Core/DataExtractor.h"
|
2010-10-06 11:53:16 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/State.h"
|
|
|
|
#include "lldb/Core/Stream.h"
|
|
|
|
#include "lldb/Core/StreamFile.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2010-06-23 09:19:29 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Target/Thread.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Project includes
|
|
|
|
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBBroadcaster.h"
|
|
|
|
#include "lldb/API/SBDebugger.h"
|
|
|
|
#include "lldb/API/SBCommandReturnObject.h"
|
|
|
|
#include "lldb/API/SBEvent.h"
|
|
|
|
#include "lldb/API/SBThread.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBStringList.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SBProcess::SBProcess () :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// SBProcess constructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
SBProcess::SBProcess (const SBProcess& rhs) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (rhs.m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBProcess::SBProcess (const lldb::ProcessSP &process_sp) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (process_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
SBProcess::~SBProcess()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBProcess::SetProcess (const ProcessSP &process_sp)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp = process_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBProcess::Clear ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp.reset();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBProcess::IsValid() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get() != NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBProcess::GetNumThreads ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
const bool can_update = true;
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->GetThreadList().GetSize(can_update);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBThread
|
2010-08-27 05:32:51 +08:00
|
|
|
SBProcess::GetSelectedThread () const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SBThread sb_thread;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-08-27 05:32:51 +08:00
|
|
|
sb_thread.SetThread (m_opaque_sp->GetThreadList().GetSelectedThread());
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_thread;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTarget
|
|
|
|
SBProcess::GetTarget() const
|
|
|
|
{
|
|
|
|
SBTarget sb_target;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
sb_target = m_opaque_sp->GetTarget().GetSP();
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_target;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBProcess::PutSTDIN (const char *src, size_t src_len)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp != NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
Error error;
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->PutSTDIN (src, src_len, error);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBProcess::GetSTDOUT (char *dst, size_t dst_len) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp != NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
Error error;
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->GetSTDOUT (dst, dst_len, error);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBProcess::GetSTDERR (char *dst, size_t dst_len) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp != NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
Error error;
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->GetSTDERR (dst, dst_len, error);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-08-27 05:32:51 +08:00
|
|
|
SBProcess::ReportEventState (const SBEvent &event, FILE *out) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (out == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp != NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
const StateType event_state = SBProcess::GetStateFromEvent (event);
|
|
|
|
char message[1024];
|
|
|
|
int message_len = ::snprintf (message,
|
|
|
|
sizeof (message),
|
|
|
|
"Process %d %s\n",
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->GetID(),
|
2010-06-09 00:52:24 +08:00
|
|
|
SBDebugger::StateAsCString (event_state));
|
|
|
|
|
|
|
|
if (message_len > 0)
|
|
|
|
::fwrite (message, 1, message_len, out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-08-27 05:32:51 +08:00
|
|
|
SBProcess::AppendEventStateReport (const SBEvent &event, SBCommandReturnObject &result)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp != NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
const StateType event_state = SBProcess::GetStateFromEvent (event);
|
|
|
|
char message[1024];
|
|
|
|
::snprintf (message,
|
|
|
|
sizeof (message),
|
|
|
|
"Process %d %s\n",
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->GetID(),
|
2010-06-09 00:52:24 +08:00
|
|
|
SBDebugger::StateAsCString (event_state));
|
|
|
|
|
|
|
|
result.AppendMessage (message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-08-27 05:32:51 +08:00
|
|
|
SBProcess::SetSelectedThread (const SBThread &thread)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp != NULL)
|
2010-08-27 05:32:51 +08:00
|
|
|
return m_opaque_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID());
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-08-27 05:32:51 +08:00
|
|
|
SBProcess::SetSelectedThreadByID (uint32_t tid)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp != NULL)
|
2010-08-27 05:32:51 +08:00
|
|
|
return m_opaque_sp->GetThreadList().SetSelectedThreadByID (tid);
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBThread
|
|
|
|
SBProcess::GetThreadAtIndex (size_t index)
|
|
|
|
{
|
|
|
|
SBThread thread;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
thread.SetThread (m_opaque_sp->GetThreadList().GetThreadAtIndex(index));
|
2010-06-09 00:52:24 +08:00
|
|
|
return thread;
|
|
|
|
}
|
|
|
|
|
|
|
|
StateType
|
|
|
|
SBProcess::GetState ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp != NULL)
|
|
|
|
return m_opaque_sp->GetState();
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return eStateInvalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
SBProcess::GetExitStatus ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp != NULL)
|
|
|
|
return m_opaque_sp->GetExitStatus ();
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBProcess::GetExitDescription ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp != NULL)
|
|
|
|
return m_opaque_sp->GetExitDescription ();
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::pid_t
|
|
|
|
SBProcess::GetProcessID ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetID();
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return LLDB_INVALID_PROCESS_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBProcess::GetAddressByteSize () const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetAddressByteSize();
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBProcess::WaitUntilProcessHasStopped (SBCommandReturnObject &result)
|
|
|
|
{
|
|
|
|
bool state_changed = false;
|
|
|
|
|
|
|
|
if (IsValid())
|
|
|
|
{
|
|
|
|
EventSP event_sp;
|
2010-06-23 09:19:29 +08:00
|
|
|
StateType state = m_opaque_sp->WaitForStateChangedEvents (NULL, event_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
while (StateIsStoppedState (state))
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
state = m_opaque_sp->WaitForStateChangedEvents (NULL, event_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
SBEvent event (event_sp);
|
2010-08-27 05:32:51 +08:00
|
|
|
AppendEventStateReport (event, result);
|
2010-06-09 00:52:24 +08:00
|
|
|
state_changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return state_changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBProcess::Continue ()
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
if (IsValid())
|
2010-10-06 11:53:16 +08:00
|
|
|
{
|
|
|
|
Error error (m_opaque_sp->Resume());
|
|
|
|
if (error.Success())
|
|
|
|
{
|
|
|
|
if (m_opaque_sp->GetTarget().GetDebugger().GetAsyncExecution () == false)
|
|
|
|
m_opaque_sp->WaitForProcessToStop (NULL);
|
|
|
|
}
|
|
|
|
sb_error.SetError(error);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
sb_error.SetErrorString ("SBProcess is invalid");
|
|
|
|
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBProcess::Destroy ()
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
sb_error.SetError(m_opaque_sp->Destroy());
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
sb_error.SetErrorString ("SBProcess is invalid");
|
|
|
|
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBProcess::Stop ()
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
if (IsValid())
|
2010-06-23 09:19:29 +08:00
|
|
|
sb_error.SetError (m_opaque_sp->Halt());
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
sb_error.SetErrorString ("SBProcess is invalid");
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBProcess::Kill ()
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
sb_error.SetError (m_opaque_sp->Destroy());
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
sb_error.SetErrorString ("SBProcess is invalid");
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBProcess::AttachByName (const char *name, bool wait_for_launch)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
sb_error.SetError (m_opaque_sp->Attach (name, wait_for_launch));
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
sb_error.SetErrorString ("SBProcess is invalid");
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::pid_t
|
2010-09-16 02:29:06 +08:00
|
|
|
SBProcess::AttachByPID (lldb::pid_t attach_pid) // DEPRECATED: will be removed in a few builds in favor of SBError AttachByPID(pid_t)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
Attach (attach_pid);
|
|
|
|
return GetProcessID();
|
|
|
|
}
|
|
|
|
|
2010-09-16 02:29:06 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBError
|
|
|
|
SBProcess::Attach (lldb::pid_t attach_pid)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
sb_error.SetError (m_opaque_sp->Attach (attach_pid));
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
sb_error.SetErrorString ("SBProcess is invalid");
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBProcess::Detach ()
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
sb_error.SetError (m_opaque_sp->Detach());
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
sb_error.SetErrorString ("SBProcess is invalid");
|
|
|
|
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBProcess::Signal (int signal)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
sb_error.SetError (m_opaque_sp->Signal (signal));
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
sb_error.SetErrorString ("SBProcess is invalid");
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBThread
|
|
|
|
SBProcess::GetThreadByID (tid_t sb_thread_id)
|
|
|
|
{
|
|
|
|
SBThread thread;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
thread.SetThread (m_opaque_sp->GetThreadList().FindThreadByID ((tid_t) sb_thread_id));
|
2010-06-09 00:52:24 +08:00
|
|
|
return thread;
|
|
|
|
}
|
|
|
|
|
|
|
|
StateType
|
|
|
|
SBProcess::GetStateFromEvent (const SBEvent &event)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return Process::ProcessEventData::GetStateFromEvent (event.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBProcess::GetRestartedFromEvent (const SBEvent &event)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return Process::ProcessEventData::GetRestartedFromEvent (event.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBProcess
|
|
|
|
SBProcess::GetProcessFromEvent (const SBEvent &event)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
SBProcess process(Process::ProcessEventData::GetProcessFromEvent (event.get()));
|
2010-06-09 00:52:24 +08:00
|
|
|
return process;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBBroadcaster
|
|
|
|
SBProcess::GetBroadcaster () const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
SBBroadcaster broadcaster(m_opaque_sp.get(), false);
|
2010-06-09 00:52:24 +08:00
|
|
|
return broadcaster;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::Process *
|
|
|
|
SBProcess::operator->() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error)
|
|
|
|
{
|
|
|
|
size_t bytes_read = 0;
|
|
|
|
|
|
|
|
if (IsValid())
|
|
|
|
{
|
|
|
|
Error error;
|
2010-06-23 09:19:29 +08:00
|
|
|
bytes_read = m_opaque_sp->ReadMemory (addr, dst, dst_len, error);
|
2010-06-09 00:52:24 +08:00
|
|
|
sb_error.SetError (error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorString ("SBProcess is invalid");
|
|
|
|
}
|
|
|
|
|
|
|
|
return bytes_read;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &sb_error)
|
|
|
|
{
|
|
|
|
size_t bytes_written = 0;
|
|
|
|
|
|
|
|
if (IsValid())
|
|
|
|
{
|
|
|
|
Error error;
|
2010-06-23 09:19:29 +08:00
|
|
|
bytes_written = m_opaque_sp->WriteMemory (addr, src, src_len, error);
|
2010-06-09 00:52:24 +08:00
|
|
|
sb_error.SetError (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bytes_written;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mimic shared pointer...
|
|
|
|
lldb_private::Process *
|
|
|
|
SBProcess::get() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool
|
|
|
|
SBProcess::GetDescription (SBStream &description)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
char path[PATH_MAX];
|
|
|
|
GetTarget().GetExecutable().GetPath (path, sizeof(path));
|
2010-10-06 11:09:58 +08:00
|
|
|
Module *exe_module = m_opaque_sp->GetTarget().GetExecutableModule ().get();
|
|
|
|
const char *exe_name = NULL;
|
|
|
|
if (exe_module)
|
|
|
|
exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
|
|
|
|
|
2010-10-07 12:19:01 +08:00
|
|
|
description.Printf ("SBProcess: pid = %d, state = %s, threads = %d%s%s",
|
2010-10-06 11:09:58 +08:00
|
|
|
m_opaque_sp->GetID(),
|
2010-09-20 13:20:02 +08:00
|
|
|
SBDebugger::StateAsCString (GetState()),
|
2010-10-06 11:09:58 +08:00
|
|
|
GetNumThreads(),
|
2010-10-07 12:19:01 +08:00
|
|
|
exe_name ? ", executable = " : "",
|
2010-10-06 11:09:58 +08:00
|
|
|
exe_name ? exe_name : "");
|
2010-09-20 13:20:02 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
description.Printf ("No value");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|