[Lldb-commits] [PATCH] D85235: [lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 4 11:54:18 PDT 2020
JDevlieghere updated this revision to Diff 282990.
JDevlieghere added a comment.
Add test
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85235/new/
https://reviews.llvm.org/D85235
Files:
lldb/source/API/SBTarget.cpp
lldb/test/API/python_api/target/TestTargetAPI.py
Index: lldb/test/API/python_api/target/TestTargetAPI.py
===================================================================
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -150,6 +150,20 @@
self.assertTrue(error.Success(), "Make sure memory read succeeded")
self.assertEqual(len(content), 1)
+
+ @add_test_categories(['pyapi'])
+ def test_launch_simple(self):
+ d = {'EXE': 'b.out'}
+ self.build(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+ target = self.create_simple_target('b.out')
+ self.runCmd("settings set target.disable-stdio true")
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.runCmd("run")
+ output = process.GetSTDOUT(1000)
+ self.assertEqual(output, "")
+
def create_simple_target(self, fn):
exe = self.getBuildArtifact(fn)
target = self.dbg.CreateTarget(exe)
Index: lldb/source/API/SBTarget.cpp
===================================================================
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -287,16 +287,24 @@
(const char **, const char **, const char *), argv, envp,
working_directory);
- char *stdin_path = nullptr;
- char *stdout_path = nullptr;
- char *stderr_path = nullptr;
- uint32_t launch_flags = 0;
- bool stop_at_entry = false;
+ TargetSP target_sp = GetSP();
+ if (!target_sp)
+ return LLDB_RECORD_RESULT(SBProcess());
+
+ SBLaunchInfo launch_info = GetLaunchInfo();
+
+ if (Module *exe_module = target_sp->GetExecutableModulePointer())
+ launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(),
+ /*add_as_first_arg*/ true);
+ if (argv)
+ launch_info.SetArguments(argv, /*append*/ true);
+ if (envp)
+ launch_info.SetEnvironmentEntries(envp, /*append*/ false);
+ if (working_directory)
+ launch_info.SetWorkingDirectory(working_directory);
+
SBError error;
- SBListener listener = GetDebugger().GetListener();
- return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
- stdout_path, stderr_path, working_directory,
- launch_flags, stop_at_entry, error));
+ return LLDB_RECORD_RESULT(Launch(launch_info, error));
}
SBError SBTarget::Install() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85235.282990.patch
Type: text/x-patch
Size: 2456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200804/406321e6/attachment.bin>
More information about the lldb-commits
mailing list