summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/API/SBTarget.h21
-rw-r--r--lldb/scripts/Python/interface/SBTarget.i23
-rw-r--r--lldb/source/API/SBTarget.cpp95
3 files changed, 30 insertions, 109 deletions
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index dd1a6fdd13b..3f3efc23978 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -23,20 +23,7 @@ namespace lldb {
class SBLaunchInfo
{
public:
- SBLaunchInfo ();
-
- SBLaunchInfo (const char *executable_path,
- const char *triple,
- const char **argv);
-
- lldb::SBFileSpec
- GetExecutable ();
-
- void
- SetExecutable (const char *path);
-
- void
- SetExecutable (lldb::SBFileSpec executable);
+ SBLaunchInfo (const char **argv);
uint32_t
GetUserID();
@@ -56,12 +43,6 @@ public:
void
SetGroupID (uint32_t gid);
- const char *
- GetTriple ();
-
- void
- SetTriple (const char *triple);
-
uint32_t
GetNumArguments ();
diff --git a/lldb/scripts/Python/interface/SBTarget.i b/lldb/scripts/Python/interface/SBTarget.i
index c0243b8cb05..0990866fafe 100644
--- a/lldb/scripts/Python/interface/SBTarget.i
+++ b/lldb/scripts/Python/interface/SBTarget.i
@@ -11,21 +11,8 @@ namespace lldb {
class SBLaunchInfo
{
- public:
- SBLaunchInfo ();
-
- SBLaunchInfo (const char *executable_path,
- const char *triple,
- const char **argv);
-
- lldb::SBFileSpec
- GetExecutable ();
-
- void
- SetExecutable (const char *path);
-
- void
- SetExecutable (lldb::SBFileSpec executable);
+public:
+ SBLaunchInfo (const char **argv);
uint32_t
GetUserID();
@@ -45,12 +32,6 @@ class SBLaunchInfo
void
SetGroupID (uint32_t gid);
- const char *
- GetTriple ();
-
- void
- SetTriple (const char *triple);
-
uint32_t
GetNumArguments ();
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index f8c259add9a..fa9c43ef77f 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -54,47 +54,12 @@ using namespace lldb_private;
#define DEFAULT_DISASM_BYTE_SIZE 32
-
-
-SBLaunchInfo::SBLaunchInfo () :
-m_opaque_sp(new ProcessLaunchInfo())
-{
-}
-
-SBLaunchInfo::SBLaunchInfo (const char *path, const char *triple, const char **argv) :
-m_opaque_sp(new ProcessLaunchInfo())
-{
- SetExecutable(path);
- if (triple && triple[0])
- m_opaque_sp->GetArchitecture().SetTriple(triple, NULL);
- if (argv)
- SetArguments(argv, false);
-}
-
-SBFileSpec
-SBLaunchInfo::GetExecutable ()
-{
- SBFileSpec exe_file;
- exe_file.SetFileSpec (m_opaque_sp->GetExecutableFile());
- return exe_file;
-}
-
-void
-SBLaunchInfo::SetExecutable (const char *path)
-{
- if (path && path[0])
- m_opaque_sp->GetExecutableFile().SetFile(path, false);
- else
- m_opaque_sp->GetExecutableFile().Clear();
-}
-
-void
-SBLaunchInfo::SetExecutable (SBFileSpec exe_file)
+SBLaunchInfo::SBLaunchInfo (const char **argv) :
+ m_opaque_sp(new ProcessLaunchInfo())
{
- if (exe_file.IsValid())
- m_opaque_sp->GetExecutableFile() = exe_file.ref();
- else
- m_opaque_sp->GetExecutableFile().Clear();
+ m_opaque_sp->GetFlags().Reset (eLaunchFlagDebug | eLaunchFlagDisableASLR);
+ if (argv && argv[0])
+ m_opaque_sp->GetArguments().SetArguments(argv);
}
uint32_t
@@ -133,31 +98,6 @@ SBLaunchInfo::SetGroupID (uint32_t gid)
m_opaque_sp->SetGroupID (gid);
}
-const char *
-SBLaunchInfo::GetTriple ()
-{
- const ArchSpec &arch = m_opaque_sp->GetArchitecture();
- if (arch.IsValid())
- {
- std::string triple (arch.GetTriple().str());
- if (!triple.empty())
- {
- // Unique the string so we don't run into ownership issues since
- // the const strings put the string into the string pool once and
- // the strings never comes out
- ConstString const_triple (triple.c_str());
- return const_triple.GetCString();
- }
- }
- return NULL;
-}
-
-void
-SBLaunchInfo::SetTriple (const char *triple)
-{
- m_opaque_sp->GetArchitecture().SetTriple(triple, NULL);
-}
-
uint32_t
SBLaunchInfo::GetNumArguments ()
{
@@ -743,15 +683,34 @@ SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error)
{
sb_process.SetSP (process_sp);
lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref();
+
+ bool add_exe_as_first_argv = true; //launch_info.GetArguments().GetArgumentCount() == 0;
+ Module *exe_module = target_sp->GetExecutableModulePointer();
+ if (exe_module)
+ launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), add_exe_as_first_argv);
+
+ const ArchSpec &arch_spec = target_sp->GetArchitecture();
+ if (arch_spec.IsValid())
+ launch_info.GetArchitecture () = arch_spec;
+
error.SetError (process_sp->Launch (launch_info));
+ const bool synchronous_execution = target_sp->GetDebugger().GetAsyncExecution () == false;
if (error.Success())
{
- // We we are stopping at the entry point, we can return now!
+ StateType state = eStateInvalid;
if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
+ {
+ // If we are doing synchronous mode, then wait for the initial
+ // stop to happen, else, return and let the caller watch for
+ // the stop
+ if (synchronous_execution)
+ state = process_sp->WaitForProcessToStop (NULL);
+ // We we are stopping at the entry point, we can return now!
return sb_process;
+ }
// Make sure we are stopped at the entry
- StateType state = process_sp->WaitForProcessToStop (NULL);
+ state = process_sp->WaitForProcessToStop (NULL);
if (state == eStateStopped)
{
// resume the process to skip the entry point
@@ -760,7 +719,7 @@ SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error)
{
// If we are doing synchronous mode, then wait for the
// process to stop yet again!
- if (target_sp->GetDebugger().GetAsyncExecution () == false)
+ if (synchronous_execution)
process_sp->WaitForProcessToStop (NULL);
}
}
OpenPOWER on IntegriCloud