2010-07-24 10:19:04 +08:00
|
|
|
//===-- ProcessLinux.h ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef liblldb_ProcessLinux_H_
|
|
|
|
#define liblldb_ProcessLinux_H_
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
|
|
|
|
// C++ Includes
|
|
|
|
#include <queue>
|
|
|
|
|
|
|
|
// Other libraries and framework includes
|
|
|
|
#include "lldb/Target/Process.h"
|
2011-03-30 23:55:52 +08:00
|
|
|
#include "LinuxSignals.h"
|
2010-07-24 10:19:04 +08:00
|
|
|
#include "ProcessMessage.h"
|
|
|
|
|
|
|
|
class ProcessMonitor;
|
|
|
|
|
|
|
|
class ProcessLinux :
|
|
|
|
public lldb_private::Process
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Static functions.
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
static Process*
|
|
|
|
CreateInstance(lldb_private::Target& target,
|
|
|
|
lldb_private::Listener &listener);
|
|
|
|
|
|
|
|
static void
|
|
|
|
Initialize();
|
|
|
|
|
|
|
|
static void
|
|
|
|
Terminate();
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
GetPluginNameStatic();
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
GetPluginDescriptionStatic();
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Constructors and destructors
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
ProcessLinux(lldb_private::Target& target,
|
|
|
|
lldb_private::Listener &listener);
|
|
|
|
|
|
|
|
virtual
|
|
|
|
~ProcessLinux();
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Process protocol.
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
virtual bool
|
|
|
|
CanDebug(lldb_private::Target &target);
|
|
|
|
|
2011-01-17 03:45:39 +08:00
|
|
|
virtual lldb_private::Error
|
|
|
|
WillLaunch(lldb_private::Module *module);
|
|
|
|
|
2010-07-24 10:19:04 +08:00
|
|
|
virtual lldb_private::Error
|
|
|
|
DoAttachToProcessWithID(lldb::pid_t pid);
|
|
|
|
|
|
|
|
virtual lldb_private::Error
|
|
|
|
DoLaunch(lldb_private::Module *module,
|
|
|
|
char const *argv[],
|
|
|
|
char const *envp[],
|
2011-01-05 05:41:31 +08:00
|
|
|
uint32_t launch_flags,
|
2010-07-24 10:19:04 +08:00
|
|
|
const char *stdin_path,
|
|
|
|
const char *stdout_path,
|
Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.
Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.
Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.
After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.
Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.
llvm-svn: 124060
2011-01-23 13:56:20 +08:00
|
|
|
const char *stderr_path,
|
|
|
|
const char *working_directory);
|
2010-07-24 10:19:04 +08:00
|
|
|
|
2011-01-17 03:45:39 +08:00
|
|
|
virtual void
|
|
|
|
DidLaunch();
|
|
|
|
|
2010-07-24 10:19:04 +08:00
|
|
|
virtual lldb_private::Error
|
|
|
|
DoResume();
|
|
|
|
|
|
|
|
virtual lldb_private::Error
|
2011-01-05 05:41:31 +08:00
|
|
|
DoHalt(bool &caused_stop);
|
2010-07-24 10:19:04 +08:00
|
|
|
|
|
|
|
virtual lldb_private::Error
|
|
|
|
DoDetach();
|
|
|
|
|
|
|
|
virtual lldb_private::Error
|
|
|
|
DoSignal(int signal);
|
|
|
|
|
|
|
|
virtual lldb_private::Error
|
|
|
|
DoDestroy();
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
RefreshStateAfterStop();
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
IsAlive();
|
|
|
|
|
|
|
|
virtual size_t
|
|
|
|
DoReadMemory(lldb::addr_t vm_addr,
|
|
|
|
void *buf,
|
|
|
|
size_t size,
|
|
|
|
lldb_private::Error &error);
|
|
|
|
|
|
|
|
virtual size_t
|
|
|
|
DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
|
|
|
|
lldb_private::Error &error);
|
|
|
|
|
|
|
|
virtual lldb::addr_t
|
|
|
|
DoAllocateMemory(size_t size, uint32_t permissions,
|
|
|
|
lldb_private::Error &error);
|
|
|
|
|
|
|
|
lldb::addr_t
|
|
|
|
AllocateMemory(size_t size, uint32_t permissions,
|
|
|
|
lldb_private::Error &error);
|
|
|
|
|
|
|
|
virtual lldb_private::Error
|
|
|
|
DoDeallocateMemory(lldb::addr_t ptr);
|
|
|
|
|
|
|
|
virtual size_t
|
|
|
|
GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site);
|
|
|
|
|
|
|
|
virtual lldb_private::Error
|
|
|
|
EnableBreakpoint(lldb_private::BreakpointSite *bp_site);
|
|
|
|
|
|
|
|
virtual lldb_private::Error
|
|
|
|
DisableBreakpoint(lldb_private::BreakpointSite *bp_site);
|
|
|
|
|
|
|
|
virtual uint32_t
|
|
|
|
UpdateThreadListIfNeeded();
|
|
|
|
|
|
|
|
virtual lldb::ByteOrder
|
|
|
|
GetByteOrder() const;
|
|
|
|
|
2011-01-15 08:10:37 +08:00
|
|
|
virtual lldb::addr_t
|
|
|
|
GetImageInfoAddress();
|
|
|
|
|
2011-03-23 10:14:42 +08:00
|
|
|
virtual size_t
|
|
|
|
PutSTDIN(const char *buf, size_t len, lldb_private::Error &error);
|
|
|
|
|
|
|
|
virtual size_t
|
|
|
|
GetSTDOUT(char *buf, size_t len, lldb_private::Error &error);
|
|
|
|
|
|
|
|
virtual size_t
|
|
|
|
GetSTDERR(char *buf, size_t len, lldb_private::Error &error);
|
|
|
|
|
2010-07-24 10:19:04 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
// PluginInterface protocol
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
virtual const char *
|
|
|
|
GetPluginName();
|
|
|
|
|
|
|
|
virtual const char *
|
|
|
|
GetShortPluginName();
|
|
|
|
|
|
|
|
virtual uint32_t
|
|
|
|
GetPluginVersion();
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
GetPluginCommandHelp(const char *command, lldb_private::Stream *strm);
|
|
|
|
|
|
|
|
virtual lldb_private::Error
|
|
|
|
ExecutePluginCommand(lldb_private::Args &command,
|
|
|
|
lldb_private::Stream *strm);
|
|
|
|
|
|
|
|
virtual lldb_private::Log *
|
|
|
|
EnablePluginLogging(lldb_private::Stream *strm,
|
|
|
|
lldb_private::Args &command);
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
// ProcessLinux internal API.
|
|
|
|
|
|
|
|
/// Registers the given message with this process.
|
|
|
|
void SendMessage(const ProcessMessage &message);
|
|
|
|
|
|
|
|
ProcessMonitor &GetMonitor() { return *m_monitor; }
|
|
|
|
|
2011-03-30 23:55:52 +08:00
|
|
|
lldb_private::UnixSignals &
|
|
|
|
GetUnixSignals();
|
|
|
|
|
2010-07-24 10:19:04 +08:00
|
|
|
private:
|
|
|
|
/// Target byte order.
|
|
|
|
lldb::ByteOrder m_byte_order;
|
|
|
|
|
|
|
|
/// Process monitor;
|
|
|
|
ProcessMonitor *m_monitor;
|
|
|
|
|
|
|
|
/// The module we are executing.
|
|
|
|
lldb_private::Module *m_module;
|
|
|
|
|
|
|
|
/// Message queue notifying this instance of inferior process state changes.
|
|
|
|
lldb_private::Mutex m_message_mutex;
|
|
|
|
std::queue<ProcessMessage> m_message_queue;
|
|
|
|
|
2011-03-30 23:55:52 +08:00
|
|
|
/// True when the process has entered a state of "limbo".
|
|
|
|
///
|
|
|
|
/// This flag qualifies eStateStopped. It lets us know that when we
|
|
|
|
/// continue from this state the process will exit. Also, when true,
|
|
|
|
/// Process::m_exit_status is set.
|
|
|
|
bool m_in_limbo;
|
|
|
|
|
|
|
|
/// Drive any exit events to completion.
|
|
|
|
bool m_exit_now;
|
|
|
|
|
|
|
|
/// Linux-specific signal set.
|
|
|
|
LinuxSignals m_linux_signals;
|
|
|
|
|
2010-07-24 10:19:04 +08:00
|
|
|
/// Updates the loaded sections provided by the executable.
|
|
|
|
///
|
|
|
|
/// FIXME: It would probably be better to delegate this task to the
|
|
|
|
/// DynamicLoader plugin, when we have one.
|
|
|
|
void UpdateLoadedSections();
|
|
|
|
|
|
|
|
/// Returns true if the process has exited.
|
|
|
|
bool HasExited();
|
2011-03-30 23:55:52 +08:00
|
|
|
|
|
|
|
/// Returns true if the process is stopped.
|
|
|
|
bool IsStopped();
|
2010-07-24 10:19:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // liblldb_MacOSXProcess_H_
|