[Lldb-commits] [lldb] r144443 - in /lldb/trunk: include/lldb/Target/Process.h source/API/SBProcess.cpp source/API/SBTarget.cpp source/Commands/CommandObjectProcess.cpp source/Host/macosx/Host.mm source/Plugins/Platform/MacOSX/PlatformDarwin.cpp source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp source/Target/Process.cpp
Greg Clayton
gclayton at apple.com
Fri Nov 11 18:10:57 PST 2011
Author: gclayton
Date: Fri Nov 11 20:10:56 2011
New Revision: 144443
URL: http://llvm.org/viewvc/llvm-project?rev=144443&view=rev
Log:
Added the ability to run a process in a shell on MacOSX currently when using
the --tty option. So you can now get shell expansion and file redirection:
(lldb) process launch --tty --shell -- *.jpg < in.txt > out.txt
Again, the "--tty" is mandatory for now until we hook this up to other
functions. The shell is also currently hard coded to "/bin/bash" and not the
"SHELL" variable. "/bin/tcsh" was causing problems which I need to dig into.
Modified:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/API/SBProcess.cpp
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/source/Host/macosx/Host.mm
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/trunk/source/Target/Process.cpp
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=144443&r1=144442&r2=144443&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Fri Nov 11 20:10:56 2011
@@ -1332,7 +1332,7 @@
/// LLDB_INVALID_PROCESS_ID if attaching fails.
//------------------------------------------------------------------
virtual Error
- Attach (lldb::pid_t pid);
+ Attach (lldb::pid_t pid, uint32_t exec_count);
//------------------------------------------------------------------
/// Attach to an existing process by process name.
@@ -2711,8 +2711,13 @@
NextEventAction (Process *process) :
m_process(process)
- {}
- virtual ~NextEventAction() {}
+ {
+ }
+
+ virtual
+ ~NextEventAction()
+ {
+ }
virtual EventActionResult PerformAction (lldb::EventSP &event_sp) = 0;
virtual void HandleBeingUnshipped () {};
@@ -2734,15 +2739,22 @@
class AttachCompletionHandler : public NextEventAction
{
public:
- AttachCompletionHandler (Process *process) :
- NextEventAction(process)
- {}
- virtual ~AttachCompletionHandler() {}
+ AttachCompletionHandler (Process *process, uint32_t exec_count) :
+ NextEventAction (process),
+ m_exec_count (exec_count)
+ {
+ }
+
+ virtual
+ ~AttachCompletionHandler()
+ {
+ }
virtual EventActionResult PerformAction (lldb::EventSP &event_sp);
virtual EventActionResult HandleBeingInterrupted ();
virtual const char *GetExitString();
private:
+ uint32_t m_exec_count;
std::string m_exit_string;
};
Modified: lldb/trunk/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=144443&r1=144442&r2=144443&view=diff
==============================================================================
--- lldb/trunk/source/API/SBProcess.cpp (original)
+++ lldb/trunk/source/API/SBProcess.cpp Fri Nov 11 20:10:56 2011
@@ -169,7 +169,7 @@
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
if (m_opaque_sp->GetState() == eStateConnected)
{
- error.SetError (m_opaque_sp->Attach (pid));
+ error.SetError (m_opaque_sp->Attach (pid, 0));
}
else
{
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=144443&r1=144442&r2=144443&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Fri Nov 11 20:10:56 2011
@@ -337,7 +337,7 @@
if (sb_process.IsValid())
{
- error.SetError (sb_process->Attach (pid));
+ error.SetError (sb_process->Attach (pid, 0));
// If we are doing synchronous mode, then wait for the
// process to stop!
if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false)
Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=144443&r1=144442&r2=144443&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Nov 11 20:10:56 2011
@@ -232,6 +232,8 @@
if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
{
+ m_options.launch_info.GetArchitecture() = target->GetArchitecture();
+
process = target->GetPlatform()->DebugProcess (m_options.launch_info,
debugger,
target,
@@ -695,7 +697,7 @@
if (attach_pid != LLDB_INVALID_PROCESS_ID)
{
- error = process->Attach (attach_pid);
+ error = process->Attach (attach_pid, 0);
if (error.Success())
{
result.SetStatus (eReturnStatusSuccessContinuingNoResult);
Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=144443&r1=144442&r2=144443&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Fri Nov 11 20:10:56 2011
@@ -501,10 +501,10 @@
if (launch_info.GetFlags().Test (eLaunchFlagLaunchInShell))
{
- const char *shell_executable = getenv("SHELL");
+ const char *shell_executable = "/bin/bash"; //getenv("SHELL");
std::string safe_arg;
if (launch_info.GetArchitecture().IsValid())
- command.Printf(" -- %s -c 'exec /usr/bin/arch -arch %s ", shell_executable, launch_info.GetArchitecture().GetArchitectureName());
+ command.Printf(" -- %s -c 'exec /usr/bin/arch -arch %s", shell_executable, launch_info.GetArchitecture().GetArchitectureName());
else
command.Printf(" -- %s -c 'exec ", shell_executable);
const char **argv = launch_info.GetArguments().GetConstArgumentVector ();
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=144443&r1=144442&r2=144443&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Fri Nov 11 20:10:56 2011
@@ -443,7 +443,7 @@
process_sp = target->CreateProcess (listener, "gdb-remote");
if (process_sp)
- error = process_sp->Attach (pid);
+ error = process_sp->Attach (pid, 2);
}
}
else
Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=144443&r1=144442&r2=144443&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Fri Nov 11 20:10:56 2011
@@ -391,7 +391,7 @@
assert (connect_url_len < sizeof(connect_url));
error = process_sp->ConnectRemote (connect_url);
if (error.Success())
- error = process_sp->Attach(pid);
+ error = process_sp->Attach(pid, 0);
}
}
}
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=144443&r1=144442&r2=144443&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Fri Nov 11 20:10:56 2011
@@ -2186,24 +2186,33 @@
case eStateStopped:
case eStateCrashed:
- {
- // During attach, prior to sending the eStateStopped event,
- // lldb_private::Process subclasses must set the process must set
- // the new process ID.
- assert (m_process->GetID() != LLDB_INVALID_PROCESS_ID);
- m_process->CompleteAttach ();
- return eEventActionSuccess;
- }
-
-
+ {
+ // During attach, prior to sending the eStateStopped event,
+ // lldb_private::Process subclasses must set the process must set
+ // the new process ID.
+ assert (m_process->GetID() != LLDB_INVALID_PROCESS_ID);
+ if (m_exec_count > 0)
+ {
+ --m_exec_count;
+ m_process->Resume();
+ return eEventActionRetry;
+ }
+ else
+ {
+ m_process->CompleteAttach ();
+ return eEventActionSuccess;
+ }
+ }
break;
+
default:
case eStateExited:
case eStateInvalid:
- m_exit_string.assign ("No valid Process");
- return eEventActionExit;
break;
}
+
+ m_exit_string.assign ("No valid Process");
+ return eEventActionExit;
}
Process::NextEventAction::EventActionResult
@@ -2219,7 +2228,7 @@
}
Error
-Process::Attach (lldb::pid_t attach_pid)
+Process::Attach (lldb::pid_t attach_pid, uint32_t exec_count)
{
m_abi_sp.reset();
@@ -2236,7 +2245,8 @@
error = DoAttachToProcessWithID (attach_pid);
if (error.Success())
{
- SetNextEventAction(new Process::AttachCompletionHandler(this));
+
+ SetNextEventAction(new Process::AttachCompletionHandler(this, exec_count));
StartPrivateStateThread();
}
else
@@ -2316,7 +2326,7 @@
}
else
{
- SetNextEventAction(new Process::AttachCompletionHandler(this));
+ SetNextEventAction(new Process::AttachCompletionHandler(this, 0));
StartPrivateStateThread();
}
}
@@ -2806,8 +2816,10 @@
case NextEventAction::eEventActionSuccess:
SetNextEventAction(NULL);
break;
+
case NextEventAction::eEventActionRetry:
break;
+
case NextEventAction::eEventActionExit:
// Handle Exiting Here. If we already got an exited event,
// we should just propagate it. Otherwise, swallow this event,
More information about the lldb-commits
mailing list