Author: jmolenda Date: Thu Jun 14 17:55:53 2018 New Revision: 334783 URL: http://llvm.org/viewvc/llvm-project?rev=334783&view=rev Log: Change TestExec.py from creating an i386+x86_64 fat binary on darwin systems and re-execing itself, to creating two separate test programs; lldb runs the first program and it exec's the second.
Support for compiling for i386 is going away. Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/main.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile?rev=334783&r1=334782&r2=334783&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/Makefile Thu Jun 14 17:55:53 2018 @@ -2,4 +2,12 @@ LEVEL = ../../make CXX_SOURCES := main.cpp +all: a.out secondprog + include $(LEVEL)/Makefile.rules + +secondprog: + $(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/secondprog.mk + +clean:: + $(MAKE) -f $(SRCDIR)/secondprog.mk clean Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py?rev=334783&r1=334782&r2=334783&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py Thu Jun 14 17:55:53 2018 @@ -41,29 +41,20 @@ class ExecTestCase(TestBase): self.do_test(True) def do_test(self, skip_exec): + self.build() exe = self.getBuildArtifact("a.out") - if self.getArchitecture() == 'x86_64': - source = self.getSourcePath("main.cpp") - o_file = self.getBuildArtifact("main.o") - execute_command( - "'%s' -g -O0 -arch i386 -arch x86_64 '%s' -c -o '%s'" % - (os.environ["CC"], source, o_file)) - execute_command( - "'%s' -g -O0 -arch i386 -arch x86_64 '%s' -o '%s'" % - (os.environ["CC"], o_file, exe)) - if self.getDebugInfo() != "dsym": - dsym_path = self.getBuildArtifact("a.out.dSYM") - execute_command("rm -rf '%s'" % (dsym_path)) - else: - self.build() + secondprog = self.getBuildArtifact("secondprog") # Create the target target = self.dbg.CreateTarget(exe) # Create any breakpoints we need - breakpoint = target.BreakpointCreateBySourceRegex( + breakpoint1 = target.BreakpointCreateBySourceRegex( 'Set breakpoint 1 here', lldb.SBFileSpec("main.cpp", False)) - self.assertTrue(breakpoint, VALID_BREAKPOINT) + self.assertTrue(breakpoint1, VALID_BREAKPOINT) + breakpoint2 = target.BreakpointCreateBySourceRegex( + 'Set breakpoint 2 here', lldb.SBFileSpec("secondprog.cpp", False)) + self.assertTrue(breakpoint2, VALID_BREAKPOINT) # Launch the process process = target.LaunchSimple( @@ -79,50 +70,48 @@ class ExecTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - - for i in range(6): - # The stop reason of the thread should be breakpoint. - self.assertTrue(process.GetState() == lldb.eStateStopped, - STOPPED_DUE_TO_BREAKPOINT) + # The stop reason of the thread should be breakpoint. + self.assertTrue(process.GetState() == lldb.eStateStopped, + STOPPED_DUE_TO_BREAKPOINT) + + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint1) + self.assertTrue(len(threads) == 1) + + # We had a deadlock tearing down the TypeSystemMap on exec, but only if some + # expression had been evaluated. So make sure we do that here so the teardown + # is not trivial. + + thread = threads[0] + value = thread.frames[0].EvaluateExpression("1 + 2") + self.assertTrue( + value.IsValid(), + "Expression evaluated successfully") + int_value = value.GetValueAsSigned() + self.assertTrue(int_value == 3, "Expression got the right result.") - threads = lldbutil.get_threads_stopped_at_breakpoint( - process, breakpoint) - self.assertTrue(len(threads) == 1) - - # We had a deadlock tearing down the TypeSystemMap on exec, but only if some - # expression had been evaluated. So make sure we do that here so the teardown - # is not trivial. + # Run and we should stop due to exec + process.Continue() - thread = threads[0] - value = thread.frames[0].EvaluateExpression("1 + 2") + if not skip_exec: + self.assertTrue(process.GetState() == lldb.eStateStopped, + "Process should be stopped at __dyld_start") + + threads = lldbutil.get_stopped_threads( + process, lldb.eStopReasonExec) self.assertTrue( - value.IsValid(), - "Expression evaluated successfully") - int_value = value.GetValueAsSigned() - self.assertTrue(int_value == 3, "Expression got the right result.") + len(threads) == 1, + "We got a thread stopped for exec.") - # Run and we should stop due to exec + # Run and we should stop at breakpoint in main after exec process.Continue() - if not skip_exec: - self.assertTrue(process.GetState() == lldb.eStateStopped, - "Process should be stopped at __dyld_start") - - threads = lldbutil.get_stopped_threads( - process, lldb.eStopReasonExec) - self.assertTrue( - len(threads) == 1, - "We got a thread stopped for exec.") - - # Run and we should stop at breakpoint in main after exec - process.Continue() - - threads = lldbutil.get_threads_stopped_at_breakpoint( - process, breakpoint) - if self.TraceOn(): - for t in process.threads: - print(t) - if t.GetStopReason() != lldb.eStopReasonBreakpoint: - self.runCmd("bt") - self.assertTrue(len(threads) == 1, - "Stopped at breakpoint in exec'ed process.") + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint2) + if self.TraceOn(): + for t in process.threads: + print(t) + if t.GetStopReason() != lldb.eStopReasonBreakpoint: + self.runCmd("bt") + self.assertTrue(len(threads) == 1, + "Stopped at breakpoint in exec'ed process.") Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/main.cpp?rev=334783&r1=334782&r2=334783&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/main.cpp Thu Jun 14 17:55:53 2018 @@ -6,6 +6,8 @@ #include <stdlib.h> #include <spawn.h> #include <unistd.h> +#include <libgen.h> +#include <string> static void exit_with_errno (int err, const char *prefix) @@ -21,9 +23,9 @@ exit_with_errno (int err, const char *pr } static pid_t -spawn_process (const char **argv, +spawn_process (const char *progname, + const char **argv, const char **envp, - cpu_type_t cpu_type, int &err) { pid_t pid = 0; @@ -46,21 +48,12 @@ spawn_process (const char **argv, posix_spawnattr_setsigmask(&attr, &no_signals); posix_spawnattr_setsigdefault(&attr, &all_signals); - if (cpu_type != 0) - { - size_t ocount = 0; - err = posix_spawnattr_setbinpref_np (&attr, 1, &cpu_type, &ocount); - } - - if (err == 0) - { - err = posix_spawn (&pid, - argv[0], - file_actions, - &attr, - (char * const *)argv, - (char * const *)envp); - } + err = posix_spawn (&pid, + progname, + file_actions, + &attr, + (char * const *)argv, + (char * const *)envp); posix_spawnattr_destroy(&attr); } @@ -70,25 +63,14 @@ spawn_process (const char **argv, int main (int argc, char const **argv) { - printf ("pid %i: Pointer size is %zu.\n", getpid(), sizeof(void *)); + char *buf = (char*) malloc (strlen (argv[0]) + 12); + strlcpy (buf, argv[0], strlen (argv[0]) + 1); + std::string directory_name (::dirname (buf)); + + std::string other_program = directory_name + "/secondprog"; int err = 0; // Set breakpoint 1 here -#if defined (__x86_64__) - if (sizeof(void *) == 8) - { - spawn_process (argv, NULL, CPU_TYPE_I386, err); - if (err) - exit_with_errno (err, "posix_spawn i386 error"); - } - else - { - spawn_process (argv, NULL, CPU_TYPE_X86_64, err); - if (err) - exit_with_errno (err, "posix_spawn x86_64 error"); - } -#else - spawn_process (argv, NULL, 0, err); + spawn_process (other_program.c_str(), argv, NULL, err); if (err) exit_with_errno (err, "posix_spawn x86_64 error"); -#endif return 0; } Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp?rev=334783&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp Thu Jun 14 17:55:53 2018 @@ -0,0 +1,5 @@ +#include <stdio.h> +int main () +{ + puts ("I am the second program."); // Set breakpoint 2 here +} Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk?rev=334783&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk Thu Jun 14 17:55:53 2018 @@ -0,0 +1,13 @@ +LEVEL = ../../make + +CXX_SOURCES := secondprog.cpp + +all: secondprog + +secondprog: + $(CXX) $(CXXFLAGS) -o secondprog $(SRCDIR)/secondprog.cpp + +clean:: + rm -rf secondprog secondprog.dSYM + +include $(LEVEL)/Makefile.rules _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits