From johnny.chen at apple.com Mon Oct 18 10:44:42 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 18 Oct 2010 15:44:42 -0000 Subject: [Lldb-commits] [lldb] r116705 - in /lldb/trunk/test: array_types/ bitfields/ breakpoint_command/ class_types/ conditional_break/ dead-strip/ enum_types/ forward/ function_types/ global_variables/ load_unload/ set_values/ signal/ stl/ threads/ unsigned_types/ Message-ID: <20101018154442.AC7E82A6C12C@llvm.org> Author: johnny Date: Mon Oct 18 10:44:42 2010 New Revision: 116705 URL: http://llvm.org/viewvc/llvm-project?rev=116705&view=rev Log: The StateType representation has been changed. Modify the test cases to accommodate. Modified: lldb/trunk/test/array_types/TestArrayTypes.py lldb/trunk/test/bitfields/TestBitfields.py lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/class_types/TestClassTypesDisassembly.py lldb/trunk/test/conditional_break/TestConditionalBreak.py lldb/trunk/test/dead-strip/TestDeadStrip.py lldb/trunk/test/enum_types/TestEnumTypes.py lldb/trunk/test/forward/TestForwardDeclaration.py lldb/trunk/test/function_types/TestFunctionTypes.py lldb/trunk/test/global_variables/TestGlobalVariables.py lldb/trunk/test/load_unload/TestLoadUnload.py lldb/trunk/test/set_values/TestSetValues.py lldb/trunk/test/signal/TestSendSignal.py lldb/trunk/test/stl/TestStdCXXDisassembly.py lldb/trunk/test/threads/TestPrintStackTraces.py lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Mon Oct 18 10:44:42 2010 @@ -58,7 +58,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. @@ -116,7 +116,7 @@ # Sanity check the print representation of process. proc = repr(self.process) self.expect(proc, msg="Process looks good", exe=False, - substrs = ["state = Stopped", + substrs = ["state = stopped", "executable = a.out"]) # The stop reason of the thread should be breakpoint. Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Mon Oct 18 10:44:42 2010 @@ -52,7 +52,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Mon Oct 18 10:44:42 2010 @@ -113,7 +113,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 2. Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Mon Oct 18 10:44:42 2010 @@ -80,7 +80,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. @@ -127,7 +127,7 @@ self.fail("SBTarget.LaunchProcess() failed") if self.process.GetState() != lldb.eStateStopped: - self.fail("Process should be in the 'Stopped' state, " + self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % lldbutil.StateTypeString(self.process.GetState())) @@ -167,7 +167,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. Modified: lldb/trunk/test/class_types/TestClassTypesDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypesDisassembly.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypesDisassembly.py (original) +++ lldb/trunk/test/class_types/TestClassTypesDisassembly.py Mon Oct 18 10:44:42 2010 @@ -54,7 +54,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # We should be stopped on the ctor function of class C. Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Mon Oct 18 10:44:42 2010 @@ -102,7 +102,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', 'stop reason = breakpoint']) + substrs = ['state is stopped', 'stop reason = breakpoint']) # The frame info for frame #0 points to a.out`c and its immediate caller # (frame #1) points to a.out`a. Modified: lldb/trunk/test/dead-strip/TestDeadStrip.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dead-strip/TestDeadStrip.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/dead-strip/TestDeadStrip.py (original) +++ lldb/trunk/test/dead-strip/TestDeadStrip.py Mon Oct 18 10:44:42 2010 @@ -43,7 +43,7 @@ # The stop reason of the thread should be breakpoint (breakpoint #1). self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'a.out`f1', 'stop reason = breakpoint']) @@ -55,7 +55,7 @@ # The stop reason of the thread should be breakpoint (breakpoint #3). self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'a.out`f3', 'stop reason = breakpoint']) Modified: lldb/trunk/test/enum_types/TestEnumTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/enum_types/TestEnumTypes.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/enum_types/TestEnumTypes.py (original) +++ lldb/trunk/test/enum_types/TestEnumTypes.py Mon Oct 18 10:44:42 2010 @@ -43,7 +43,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. Modified: lldb/trunk/test/forward/TestForwardDeclaration.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/forward/TestForwardDeclaration.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/forward/TestForwardDeclaration.py (original) +++ lldb/trunk/test/forward/TestForwardDeclaration.py Mon Oct 18 10:44:42 2010 @@ -36,7 +36,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. Modified: lldb/trunk/test/function_types/TestFunctionTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/function_types/TestFunctionTypes.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/function_types/TestFunctionTypes.py (original) +++ lldb/trunk/test/function_types/TestFunctionTypes.py Mon Oct 18 10:44:42 2010 @@ -41,7 +41,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. Modified: lldb/trunk/test/global_variables/TestGlobalVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/global_variables/TestGlobalVariables.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/global_variables/TestGlobalVariables.py (original) +++ lldb/trunk/test/global_variables/TestGlobalVariables.py Mon Oct 18 10:44:42 2010 @@ -41,7 +41,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. Modified: lldb/trunk/test/load_unload/TestLoadUnload.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/TestLoadUnload.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/load_unload/TestLoadUnload.py (original) +++ lldb/trunk/test/load_unload/TestLoadUnload.py Mon Oct 18 10:44:42 2010 @@ -30,7 +30,7 @@ # The stop reason of the thread should be breakpoint and at a_function. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'a_function', 'stop reason = breakpoint']) @@ -42,7 +42,7 @@ # The stop reason of the thread should be breakpoint and at a_function. self.runCmd("continue") self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'a_function', 'stop reason = breakpoint']) Modified: lldb/trunk/test/set_values/TestSetValues.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/set_values/TestSetValues.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/set_values/TestSetValues.py (original) +++ lldb/trunk/test/set_values/TestSetValues.py Mon Oct 18 10:44:42 2010 @@ -65,7 +65,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. Modified: lldb/trunk/test/signal/TestSendSignal.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/signal/TestSendSignal.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/signal/TestSendSignal.py (original) +++ lldb/trunk/test/signal/TestSendSignal.py Mon Oct 18 10:44:42 2010 @@ -43,7 +43,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. @@ -52,7 +52,7 @@ self.runCmd("process status") output = self.res.GetOutput() - pid = re.match("Process (.*) Stopped", output).group(1) + pid = re.match("Process (.*) stopped", output).group(1) # After resuming the process, send it a SIGUSR1 signal. @@ -73,7 +73,7 @@ # Make the interaction mode be synchronous again. self.dbg.SetAsync(False) self.expect("process status", STOPPED_DUE_TO_SIGNAL, - startstr = "Process %s Stopped" % pid, + startstr = "Process %s stopped" % pid, substrs = ['stop reason = signal SIGUSR1']) self.expect("thread backtrace", STOPPED_DUE_TO_SIGNAL, substrs = ['stop reason = signal SIGUSR1']) Modified: lldb/trunk/test/stl/TestStdCXXDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestStdCXXDisassembly.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/stl/TestStdCXXDisassembly.py (original) +++ lldb/trunk/test/stl/TestStdCXXDisassembly.py Mon Oct 18 10:44:42 2010 @@ -42,10 +42,10 @@ target = self.dbg.GetSelectedTarget() process = target.GetProcess() - # The process should be in a 'Stopped' state. + # The process should be in a 'stopped' state. self.expect(repr(process), STOPPED_DUE_TO_BREAKPOINT, exe=False, substrs = ["a.out", - "Stopped"]) + "stopped"]) # Disassemble the functions on the call stack. self.runCmd("thread backtrace") Modified: lldb/trunk/test/threads/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/threads/TestPrintStackTraces.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/threads/TestPrintStackTraces.py (original) +++ lldb/trunk/test/threads/TestPrintStackTraces.py Mon Oct 18 10:44:42 2010 @@ -35,7 +35,7 @@ self.fail("SBTarget.LaunchProcess() failed") if self.process.GetState() != lldb.eStateStopped: - self.fail("Process should be in the 'Stopped' state, " + self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % lldbutil.StateTypeString(self.process.GetState())) Modified: lldb/trunk/test/unsigned_types/TestUnsignedTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unsigned_types/TestUnsignedTypes.py?rev=116705&r1=116704&r2=116705&view=diff ============================================================================== --- lldb/trunk/test/unsigned_types/TestUnsignedTypes.py (original) +++ lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Mon Oct 18 10:44:42 2010 @@ -44,7 +44,7 @@ # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', 'stop reason = breakpoint']) + substrs = ['state is stopped', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, From johnny.chen at apple.com Mon Oct 18 10:46:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 18 Oct 2010 15:46:54 -0000 Subject: [Lldb-commits] [lldb] r116706 - /lldb/trunk/test/lldbutil.py Message-ID: <20101018154654.BB81C2A6C12C@llvm.org> Author: johnny Date: Mon Oct 18 10:46:54 2010 New Revision: 116706 URL: http://llvm.org/viewvc/llvm-project?rev=116706&view=rev Log: Also change the utility functions in lldbutil.py, too, to correspond to the StateType representation change. Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=116706&r1=116705&r2=116706&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Mon Oct 18 10:46:54 2010 @@ -42,48 +42,48 @@ def StateTypeString(enum): """Returns the stateType string given an enum.""" if enum == lldb.eStateInvalid: - return "Invalid" + return "invalid" elif enum == lldb.eStateUnloaded: - return "Unloaded" + return "unloaded" elif enum == lldb.eStateAttaching: - return "Attaching" + return "attaching" elif enum == lldb.eStateLaunching: - return "Launching" + return "launching" elif enum == lldb.eStateStopped: - return "Stopped" + return "stopped" elif enum == lldb.eStateRunning: - return "Running" + return "running" elif enum == lldb.eStateStepping: - return "Stepping" + return "stepping" elif enum == lldb.eStateCrashed: - return "Crashed" + return "crashed" elif enum == lldb.eStateDetached: - return "Detached" + return "detached" elif enum == lldb.eStateExited: - return "Exited" + return "exited" elif enum == lldb.eStateSuspended: - return "Suspended" + return "suspended" else: raise Exception("Unknown stopReason enum") def StopReasonString(enum): """Returns the stopReason string given an enum.""" if enum == lldb.eStopReasonInvalid: - return "Invalid" + return "invalid" elif enum == lldb.eStopReasonNone: - return "None" + return "none" elif enum == lldb.eStopReasonTrace: - return "Trace" + return "trace" elif enum == lldb.eStopReasonBreakpoint: - return "Breakpoint" + return "breakpoint" elif enum == lldb.eStopReasonWatchpoint: - return "Watchpoint" + return "watchpoint" elif enum == lldb.eStopReasonSignal: - return "Signal" + return "signal" elif enum == lldb.eStopReasonException: - return "Exception" + return "exception" elif enum == lldb.eStopReasonPlanComplete: - return "PlanComplete" + return "plancomplete" else: raise Exception("Unknown stopReason enum") From johnny.chen at apple.com Mon Oct 18 12:51:45 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 18 Oct 2010 17:51:45 -0000 Subject: [Lldb-commits] [lldb] r116718 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20101018175145.D702E2A6C12C@llvm.org> Author: johnny Date: Mon Oct 18 12:51:45 2010 New Revision: 116718 URL: http://llvm.org/viewvc/llvm-project?rev=116718&view=rev Log: Add a case to test that after 'set auto-confirm true', manual confirmation should not kick in. Also add a more useful assert message for test_set_output_path(), which is currently decorated with @expectedFailure. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=116718&r1=116717&r2=116718&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Mon Oct 18 12:51:45 2010 @@ -47,6 +47,31 @@ self.expect("settings show", substrs = ["term-width (int) = '70'"]) + def test_set_auto_confirm(self): + """Test that after 'set auto-confirm true', manual confirmation should not kick in.""" + self.buildDefault() + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # No '-o' option is needed for static setting. + self.runCmd("settings set auto-confirm true") + + # Immediately test the setting. + self.expect("settings show auto-confirm", + startstr = "auto-confirm (boolean) = 'true'") + + # Now 'breakpoint delete' should just work fine without confirmation + # prompt from the command interpreter. + self.runCmd("breakpoint set -n main") + self.expect("breakpoint delete", + startstr = "All breakpoints removed") + + # Restore the original setting of auto-confirm. + self.runCmd("settings set -r auto-confirm") + self.expect("settings show auto-confirm", + startstr = "auto-confirm (boolean) = 'false'") + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym(self): """Test that run-args and env-vars are passed to the launched process.""" @@ -96,6 +121,10 @@ self.runCmd("run", RUN_SUCCEEDED) + # The 'stdout.txt' file should now exist. + self.assertTrue(os.path.isfile("stdout.txt"), + "'stdout.txt' exists due to target.process.output-path.") + # Read the output file produced by running the program. with open('stdout.txt', 'r') as f: output = f.read() From ctice at apple.com Mon Oct 18 13:24:17 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 18 Oct 2010 18:24:17 -0000 Subject: [Lldb-commits] [lldb] r116725 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20101018182417.DD5C92A6C12C@llvm.org> Author: ctice Date: Mon Oct 18 13:24:17 2010 New Revision: 116725 URL: http://llvm.org/viewvc/llvm-project?rev=116725&view=rev Log: Prevent Python script interpreter initialization from changing the termios settings on the debugger's input handle. Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=116725&r1=116724&r2=116725&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Oct 18 13:24:17 2010 @@ -161,6 +161,17 @@ { Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); + + // Save terminal settings if we can + int input_fd; + FILE *input_fh = m_interpreter.GetDebugger().GetInputFileHandle(); + if (input_fh != NULL) + input_fd = ::fileno (input_fh); + else + input_fd = STDIN_FILENO; + + m_termios_valid = ::tcgetattr (input_fd, &m_termios) == 0; + // Find the module that owns this code and use that path we get to // set the PYTHONPATH appropriately. @@ -221,9 +232,9 @@ const char *pty_slave_name = GetScriptInterpreterPtyName (); FILE *out_fh = interpreter.GetDebugger().GetOutputFileHandle(); - PyObject *pmod = PyImport_ExecCodeModule( - const_cast("embedded_interpreter"), - static_cast(m_compiled_module)); + PyObject *pmod = PyImport_ExecCodeModule (const_cast ("embedded_interpreter"), + static_cast(m_compiled_module)); + if (pmod != NULL) { PyRun_SimpleString ("ConsoleDict = locals()"); @@ -231,11 +242,6 @@ PyRun_SimpleString ("import sys"); PyRun_SimpleString ("from termios import *"); - StreamString run_string; - run_string.Printf ("new_stdin = open('%s', 'r')", pty_slave_name); - PyRun_SimpleString (run_string.GetData()); - PyRun_SimpleString ("sys.stdin = new_stdin"); - if (out_fh != NULL) { PyObject *new_sysout = PyFile_FromFile (out_fh, (char *) "", (char *) "w", @@ -254,6 +260,11 @@ PyErr_Clear(); } + StreamString run_string; + run_string.Printf ("new_stdin = open('%s', 'r')", pty_slave_name); + PyRun_SimpleString (run_string.GetData()); + PyRun_SimpleString ("sys.stdin = new_stdin"); + PyRun_SimpleString ("new_mode = tcgetattr(new_stdin)"); PyRun_SimpleString ("new_mode[3] = new_mode[3] | ECHO | ICANON"); PyRun_SimpleString ("new_mode[6][VEOF] = 255"); @@ -265,6 +276,11 @@ } + // Restore terminal settings if they were validly saved + if (m_termios_valid) + { + ::tcsetattr (input_fd, TCSANOW, &m_termios); + } } ScriptInterpreterPython::~ScriptInterpreterPython () @@ -279,10 +295,26 @@ { int success; + + // Save the current input file handle state before executing the command. + int input_fd; + struct termios tmp_termios; + bool valid_termios = false; + FILE *input_fh = m_interpreter.GetDebugger().GetInputFileHandle(); + if (input_fh != NULL) + { + input_fd = ::fileno (input_fh); + valid_termios = ::tcgetattr (input_fd, &tmp_termios) == 0; + } + success = PyRun_SimpleString (command); if (success == 0) return true; + // Restore the input file handle state after executing the command. + if (valid_termios) + ::tcsetattr (input_fd, TCSANOW, &tmp_termios); + // The one-liner failed. Append the error message. if (result) result->AppendErrorWithFormat ("python failed attempting to evaluate '%s'\n", command); From ctice at apple.com Mon Oct 18 14:18:32 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 18 Oct 2010 19:18:32 -0000 Subject: [Lldb-commits] [lldb] r116735 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20101018191832.2A99B2A6C12C@llvm.org> Author: ctice Date: Mon Oct 18 14:18:31 2010 New Revision: 116735 URL: http://llvm.org/viewvc/llvm-project?rev=116735&view=rev Log: Fix bug where aliases for commands that take raw input were not executing properly. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=116735&r1=116734&r2=116735&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Oct 18 14:18:31 2010 @@ -542,11 +542,22 @@ if (command_obj != NULL) { + std::string aliased_cmd_str; if (command_obj->IsAlias()) { BuildAliasCommandArgs (command_obj, command_cstr, command_args, result); if (!result.Succeeded()) return false; + else + { + // We need to transfer the newly constructed args back into the command_line, in case + // this happens to be an alias for a command that takes raw input. + if (command_args.GetCommandString (aliased_cmd_str)) + { + command_line = aliased_cmd_str.c_str(); + command_cstr = command_obj->GetCommandName(); + } + } } if (add_to_history) From johnny.chen at apple.com Mon Oct 18 16:05:09 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 18 Oct 2010 21:05:09 -0000 Subject: [Lldb-commits] [lldb] r116747 - /lldb/trunk/docs/testsuite/ Message-ID: <20101018210509.B0B262A6C12D@llvm.org> Author: johnny Date: Mon Oct 18 16:05:09 2010 New Revision: 116747 URL: http://llvm.org/viewvc/llvm-project?rev=116747&view=rev Log: Add a docs/testsuite directory for tips on writing lldb test cases. Added: lldb/trunk/docs/testsuite/ From johnny.chen at apple.com Mon Oct 18 16:14:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 18 Oct 2010 21:14:58 -0000 Subject: [Lldb-commits] [lldb] r116748 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20101018211458.E90A92A6C12C@llvm.org> Author: johnny Date: Mon Oct 18 16:14:58 2010 New Revision: 116748 URL: http://llvm.org/viewvc/llvm-project?rev=116748&view=rev Log: Remove out-dated comments. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=116748&r1=116747&r2=116748&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Mon Oct 18 16:14:58 2010 @@ -36,7 +36,6 @@ def test_set_term_width(self): """Test that 'set term-width' actually changes the term-width.""" - # No '-o' option is needed for static setting. self.runCmd("settings set term-width 70") # Immediately test the setting. @@ -54,7 +53,6 @@ exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # No '-o' option is needed for static setting. self.runCmd("settings set auto-confirm true") # Immediately test the setting. From ctice at apple.com Mon Oct 18 17:38:05 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 18 Oct 2010 22:38:05 -0000 Subject: [Lldb-commits] [lldb] r116760 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20101018223805.D0E582A6C12C@llvm.org> Author: ctice Date: Mon Oct 18 17:38:05 2010 New Revision: 116760 URL: http://llvm.org/viewvc/llvm-project?rev=116760&view=rev Log: Fix small mistake in previous commit (fixing aliases for commands that take raw input). Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=116760&r1=116759&r2=116760&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Oct 18 17:38:05 2010 @@ -555,7 +555,7 @@ if (command_args.GetCommandString (aliased_cmd_str)) { command_line = aliased_cmd_str.c_str(); - command_cstr = command_obj->GetCommandName(); + command_cstr = command_args.GetArgumentAtIndex (0); } } } From johnny.chen at apple.com Mon Oct 18 17:54:25 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 18 Oct 2010 22:54:25 -0000 Subject: [Lldb-commits] [lldb] r116763 - in /lldb/trunk/test/types: TestFloatTypesExpr.py TestIntegerTypesExpr.py Message-ID: <20101018225425.DB8052A6C12C@llvm.org> Author: johnny Date: Mon Oct 18 17:54:25 2010 New Revision: 116763 URL: http://llvm.org/viewvc/llvm-project?rev=116763&view=rev Log: Uncomment the @skip decorator to reproduce the hang while running the test suite. Modified: lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=116763&r1=116762&r2=116763&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Mon Oct 18 17:54:25 2010 @@ -6,6 +6,7 @@ import unittest2 import lldb +#@unittest2.skip("rdar://problem/8562563 ./dotest.py -v . 2> ~/Developer/Log/lldbtest.log now hangs (very consistently) when executing test/types") class FloatTypesTestCase(AbstractBase.GenericTester): mydir = "types" Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=116763&r1=116762&r2=116763&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Mon Oct 18 17:54:25 2010 @@ -6,6 +6,7 @@ import unittest2 import lldb +#@unittest2.skip("rdar://problem/8562563 ./dotest.py -v . 2> ~/Developer/Log/lldbtest.log now hangs (very consistently) when executing test/types") class IntegerTypesTestCase(AbstractBase.GenericTester): mydir = "types" From ctice at apple.com Mon Oct 18 17:56:57 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 18 Oct 2010 22:56:57 -0000 Subject: [Lldb-commits] [lldb] r116764 - in /lldb/trunk: include/lldb/lldb-enumerations.h source/Commands/CommandObjectProcess.cpp source/Interpreter/CommandObject.cpp Message-ID: <20101018225657.60E3E2A6C12C@llvm.org> Author: ctice Date: Mon Oct 18 17:56:57 2010 New Revision: 116764 URL: http://llvm.org/viewvc/llvm-project?rev=116764&view=rev Log: Combine eArgTypeSignalName and eArgTypeUnixSignalNumber into a single argument type, eArgTypeUnixSignal. Modified: lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Interpreter/CommandObject.cpp Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=116764&r1=116763&r2=116764&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Mon Oct 18 17:56:57 2010 @@ -558,7 +558,6 @@ eArgTypeSettingKey, eArgTypeSettingPrefix, eArgTypeSettingVariableName, - eArgTypeSignalName, eArgTypeShlibName, eArgTypeSourceFile, eArgTypeSortOrder, @@ -567,7 +566,7 @@ eArgTypeThreadID, eArgTypeThreadIndex, eArgTypeThreadName, - eArgTypeUnixSignalNumber, + eArgTypeUnixSignal, eArgTypeVarName, eArgTypeValue, eArgTypeWidth, Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=116764&r1=116763&r2=116764&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Mon Oct 18 17:56:57 2010 @@ -877,7 +877,7 @@ CommandArgumentData signal_arg; // Define the first (and only) variant of this arg. - signal_arg.arg_type = eArgTypeUnixSignalNumber; + signal_arg.arg_type = eArgTypeUnixSignal; signal_arg.arg_repetition = eArgRepeatPlain; // There is only one variant this argument could be; put it into the argument entry. @@ -1219,12 +1219,12 @@ { SetHelpLong ("If no signals are specified, update them all. If no update option is specified, list the current values.\n"); CommandArgumentEntry arg; - CommandArgumentData signal_name_arg; + CommandArgumentData signal_arg; - signal_name_arg.arg_type = eArgTypeSignalName; - signal_name_arg.arg_repetition = eArgRepeatStar; + signal_arg.arg_type = eArgTypeUnixSignal; + signal_arg.arg_repetition = eArgRepeatStar; - arg.push_back (signal_name_arg); + arg.push_back (signal_arg); m_arguments.push_back (arg); } Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=116764&r1=116763&r2=116764&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Mon Oct 18 17:56:57 2010 @@ -646,8 +646,7 @@ { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, NULL, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." }, { eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, NULL, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." }, { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, NULL, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" }, - { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, NULL, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." }, - { eArgTypeSignalName, "signal-name", CommandCompletions::eNoCompletion, NULL, "The name of a UNIX signal (e.g. SIGINT or SIGKILL) ." }, + { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, NULL, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." }, { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, NULL, "The name of a shared library." }, { eArgTypeSourceFile, "source-file", CommandCompletions::eNoCompletion, NULL, "The name of a source file.." }, { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, NULL, "Specify a sort order when dumping lists." }, @@ -656,7 +655,7 @@ { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, NULL, "Thread ID number." }, { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, NULL, "Index into the process' list of threads." }, { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, NULL, "The thread's name." }, - { eArgTypeUnixSignalNumber, "unix-signal-number", CommandCompletions::eNoCompletion, NULL, "A valid Unix signal number." }, + { eArgTypeUnixSignal, "unix-signal", CommandCompletions::eNoCompletion, NULL, "A valid Unix signal name or number (e.g. SIGKILL, KILL or 9)." }, { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, NULL, "The name of a variable in your program." }, { eArgTypeValue, "value", CommandCompletions::eNoCompletion, NULL, "A value could be anything, depending on where and how it is used." }, { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, From ctice at apple.com Mon Oct 18 18:00:51 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 18 Oct 2010 23:00:51 -0000 Subject: [Lldb-commits] [lldb] r116765 - /lldb/trunk/scripts/Python/build-swig-Python.sh Message-ID: <20101018230051.AD6902A6C12C@llvm.org> Author: ctice Date: Mon Oct 18 18:00:51 2010 New Revision: 116765 URL: http://llvm.org/viewvc/llvm-project?rev=116765&view=rev Log: Add header files that were added to lldb.swig to the build script, so it can keep track of dependencies accurately (for knowing when to re-build LLDBWrapPython.cpp). Modified: lldb/trunk/scripts/Python/build-swig-Python.sh Modified: lldb/trunk/scripts/Python/build-swig-Python.sh URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=116765&r1=116764&r2=116765&view=diff ============================================================================== --- lldb/trunk/scripts/Python/build-swig-Python.sh (original) +++ lldb/trunk/scripts/Python/build-swig-Python.sh Mon Oct 18 18:00:51 2010 @@ -30,6 +30,11 @@ HEADER_FILES="${SRC_ROOT}/include/lldb/lldb-include.h"\ +" ${SRC_ROOT}/include/lldb/lldb-defines.h"\ +" ${SRC_ROOT}/include/lldb/lldb-enumerations.h"\ +" ${SRC_ROOT}/include/lldb/lldb-forward.h"\ +" ${SRC_ROOT}/include/lldb/lldb-forward-rtti.h"\ +" ${SRC_ROOT}/include/lldb/lldb-types.h"\ " ${SRC_ROOT}/include/lldb/API/SBAddress.h"\ " ${SRC_ROOT}/include/lldb/API/SBBlock.h"\ " ${SRC_ROOT}/include/lldb/API/SBBreakpoint.h"\ From johnny.chen at apple.com Mon Oct 18 19:16:14 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 00:16:14 -0000 Subject: [Lldb-commits] [lldb] r116775 - /lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Message-ID: <20101019001614.547B72A6C12C@llvm.org> Author: johnny Date: Mon Oct 18 19:16:14 2010 New Revision: 116775 URL: http://llvm.org/viewvc/llvm-project?rev=116775&view=rev Log: Add an assert that 'output.txt' exists before opening it. Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=116775&r1=116774&r2=116775&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Mon Oct 18 19:16:14 2010 @@ -74,6 +74,10 @@ # Check that the file 'output.txt' exists and contains the string "lldb". + # The 'output.txt' file should now exist. + self.assertTrue(os.path.isfile("output.txt"), + "'output.txt' exists due breakpoint command for breakpoint 2.") + # Read the output file produced by running the program. with open('output.txt', 'r') as f: output = f.read() From johnny.chen at apple.com Mon Oct 18 19:25:01 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 00:25:01 -0000 Subject: [Lldb-commits] [lldb] r116778 - in /lldb/trunk/test: dotest.py lldbtest.py Message-ID: <20101019002501.529012A6C12C@llvm.org> Author: johnny Date: Mon Oct 18 19:25:01 2010 New Revision: 116778 URL: http://llvm.org/viewvc/llvm-project?rev=116778&view=rev Log: Modify the test driver and lldbtest.TestBase so that the dumping of session info now goes into a timestamp-specific directory instead of the previous .session-* files. [17:24:34] johnny:/Volumes/data/lldb/svn/trunk $ ls -l test/2010-10-18-16:56:12.935342 total 48 -rw-r--r-- 1 johnny admin 1695 Oct 18 16:56 TestArrayTypes.ArrayTypesTestCase.test_with_dsym_and_run_command.log -rw-r--r-- 1 johnny admin 1652 Oct 18 16:56 TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log -rw-r--r-- 1 johnny admin 2967 Oct 18 16:56 TestBreakpointCommand.BreakpointCommandTestCase.test_with_dsym.log -rw-r--r-- 1 johnny admin 1648 Oct 18 16:56 TestClassTypes.ClassTypesTestCase.test_with_dwarf_and_run_command.log -rw-r--r-- 1 johnny admin 1665 Oct 18 16:56 TestClassTypesDisassembly.IterateFrameAndDisassembleTestCase.test_with_dsym_and_python_api.log -rw-r--r-- 1 johnny admin 3873 Oct 18 16:58 TestFloatTypesExpr.FloatTypesTestCase.test_float_types_with_dsym.log [17:24:37] johnny:/Volumes/data/lldb/svn/trunk $ Also, the dumping happens when a test errored in additioned to when it failed. Modified: lldb/trunk/test/dotest.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=116778&r1=116777&r2=116778&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Oct 18 19:25:01 2010 @@ -502,6 +502,15 @@ # Install the control-c handler. unittest2.signals.installHandler() +# Now get a timestamp string and export it as LLDB_TIMESTAMP environment var. +# This will be useful when/if we want to dump the session info of individual +# test cases later on. +# +# See also TestBase.dumpSessionInfo() in lldbtest.py. +import datetime +raw_timestamp = str(datetime.datetime.today()) +os.environ["LLDB_TIMESTAMP"] = raw_timestamp.replace(' ', '-') + # # Invoke the default TextTestRunner to run the test suite, possibly iterating # over different configurations. @@ -611,6 +620,12 @@ # Now put this singleton into the lldb module namespace. lldb.test_result = self + def addError(self, test, err): + super(LLDBTestResult, self).addError(test, err) + method = getattr(test, "markError", None) + if method: + method() + def addFailure(self, test, err): super(LLDBTestResult, self).addFailure(test, err) method = getattr(test, "markFailure", None) Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=116778&r1=116777&r2=116778&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Mon Oct 18 19:25:01 2010 @@ -411,15 +411,25 @@ # test case specific file if test failure is encountered. self.session = StringIO.StringIO() - # Optimistically set self.__failed__ to False initially. If the test - # failed, the session info (self.session) is then dumped into a session - # specific file for diagnosis. + # Optimistically set self.__errored__ and self.__failed__ to False + # initially. If the test errored/failed, the session info + # (self.session) is then dumped into a session specific file for + # diagnosis. + self.__errored__ = False self.__failed__ = False def setTearDownCleanup(self, dictionary=None): self.dict = dictionary self.doTearDownCleanup = True + def markError(self): + """Callback invoked when we (the test case instance) errored.""" + self.__errored__ = True + with recording(self, False) as sbuf: + # False because there's no need to write "ERROR" to the stderr twice. + # Once by the Python unittest framework, and a second time by us. + print >> sbuf, "ERROR" + def markFailure(self): """Callback invoked when we (the test case instance) failed.""" self.__failed__ = True @@ -430,14 +440,21 @@ def dumpSessionInfo(self): """ - Dump the debugger interactions leading to a test failure. This allows - for more convenient postmortem analysis. + Dump the debugger interactions leading to a test error/failure. This + allows for more convenient postmortem analysis. """ + for test, err in lldb.test_result.errors: + if test is self: + print >> self.session, err for test, err in lldb.test_result.failures: if test is self: print >> self.session, err - fname = os.path.join(os.environ["LLDB_TEST"], ".session-" + self.id()) + dname = os.path.join(os.environ["LLDB_TEST"], + os.environ["LLDB_TIMESTAMP"]) + if not os.path.isdir(dname): + os.mkdir(dname) + fname = os.path.join(dname, "%s.log" % self.id()) with open(fname, "w") as f: print >> f, self.session.getvalue() @@ -462,9 +479,9 @@ raise Exception("Don't know how to do cleanup") # See also LLDBTestResult (dotest.py) which is a singlton class derived - # from TextTestResult and overwrites addFailure() method to allow us to - # to check the failure status here. - if self.__failed__: + # from TextTestResult and overwrites addError()/addFailure() methods to + # allow us to to check the error/failure status here. + if self.__errored__ or self.__failed__: self.dumpSessionInfo() def runCmd(self, cmd, msg=None, check=True, trace=False, setCookie=True): From johnny.chen at apple.com Mon Oct 18 19:52:07 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 00:52:07 -0000 Subject: [Lldb-commits] [lldb] r116780 - in /lldb/trunk/test: class_types/TestClassTypes.py forward/TestForwardDeclaration.py foundation/TestObjCMethods.py persistent_variables/TestPersistentVariables.py Message-ID: <20101019005207.606852A6C12C@llvm.org> Author: johnny Date: Mon Oct 18 19:52:07 2010 New Revision: 116780 URL: http://llvm.org/viewvc/llvm-project?rev=116780&view=rev Log: Modify the command passed to command interpreter from 'expr' (which is an alias of 'expression') to 'expression' to avoid cases where 'expr' has been unaliased. Modified: lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/forward/TestForwardDeclaration.py lldb/trunk/test/foundation/TestObjCMethods.py lldb/trunk/test/persistent_variables/TestPersistentVariables.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=116780&r1=116779&r2=116780&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Mon Oct 18 19:52:07 2010 @@ -185,7 +185,7 @@ # expr this->m_c_int returns an incorrect value # # Verify that expr this->m_c_int behaves correctly. - self.expect("expr this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("expression this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, patterns = ['\(int\) \$[0-9]+ = 66']) Modified: lldb/trunk/test/forward/TestForwardDeclaration.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/forward/TestForwardDeclaration.py?rev=116780&r1=116779&r2=116780&view=diff ============================================================================== --- lldb/trunk/test/forward/TestForwardDeclaration.py (original) +++ lldb/trunk/test/forward/TestForwardDeclaration.py Mon Oct 18 19:52:07 2010 @@ -51,7 +51,7 @@ '(int) b = 2']) # And so should this. - self.expect("expr *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("expression *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['(struct bar)', '(int) a = 1', '(int) b = 2']) Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=116780&r1=116779&r2=116780&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Mon Oct 18 19:52:07 2010 @@ -140,21 +140,22 @@ "(NSDate *) date"]) # This should fail expectedly. - self.expect("expr self->non_existent_member", COMMAND_FAILED_AS_EXPECTED, error=True, + self.expect("expression self->non_existent_member", + COMMAND_FAILED_AS_EXPECTED, error=True, startstr = "error: 'MyString' does not have a member named 'non_existent_member'") # This currently fails. # rdar://problem/8492646 # # Use expression parser. - #self.runCmd("expr self->str") - #self.runCmd("expr self->date") + #self.runCmd("expression self->str") + #self.runCmd("expression self->date") - # (lldb) expr self->str + # (lldb) expression self->str # error: instance variable 'str' is protected # error: 1 errors parsing expression # - # (lldb) expr self->date + # (lldb) expression self->date # error: instance variable 'date' is protected # error: 1 errors parsing expression # @@ -172,7 +173,7 @@ # # Test new feature with r115115: # Add "-o" option to "expression" which prints the object description if available. - self.expect("expr -o -- my", "Object description displayed correctly", + self.expect("expression -o -- my", "Object description displayed correctly", patterns = ["Hello from.*a.out.*with timestamp: "]) Modified: lldb/trunk/test/persistent_variables/TestPersistentVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/persistent_variables/TestPersistentVariables.py?rev=116780&r1=116779&r2=116780&view=diff ============================================================================== --- lldb/trunk/test/persistent_variables/TestPersistentVariables.py (original) +++ lldb/trunk/test/persistent_variables/TestPersistentVariables.py Mon Oct 18 19:52:07 2010 @@ -21,19 +21,19 @@ self.runCmd("run", RUN_SUCCEEDED) - self.expect("expr int $i = 5; $i + 1", + self.expect("expression int $i = 5; $i + 1", startstr = "(int) $0 = 6") # (int) $0 = 6 - self.expect("expr $i + 3", + self.expect("expression $i + 3", startstr = "(int) $1 = 8") # (int) $1 = 8 - self.expect("expr $1 + $0", + self.expect("expression $1 + $0", startstr = "(int) $2 = 14") # (int) $2 = 14 - self.expect("expr $2", + self.expect("expression $2", startstr = "(int) $3 = 14") # (int) $3 = 14 From gclayton at apple.com Mon Oct 18 22:25:40 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 19 Oct 2010 03:25:40 -0000 Subject: [Lldb-commits] [lldb] r116792 - in /lldb/trunk: include/lldb/Core/ConnectionFileDescriptor.h source/Commands/CommandObjectProcess.cpp source/Core/ConnectionFileDescriptor.cpp source/Host/macosx/Host.mm source/Target/Process.cpp tools/darwin-debug/darwin-debug.cpp tools/driver/Driver.cpp Message-ID: <20101019032540.D98062A6C12C@llvm.org> Author: gclayton Date: Mon Oct 18 22:25:40 2010 New Revision: 116792 URL: http://llvm.org/viewvc/llvm-project?rev=116792&view=rev Log: Stop the driver from handling SIGPIPE in case we communicate with stale sockets so the driver doesn't just crash. Added support for connecting to named sockets (unix IPC sockets) in ConnectionFileDescriptor. Modified the Host::LaunchInNewTerminal() for MacOSX to return the process ID of the inferior process instead of the process ID of the Terminal.app. This was done by modifying the "darwin-debug" executable to connect to lldb through a named unix socket which is passed down as an argument. This allows a quick handshake between "lldb" and "darwin-debug" so we can get the process ID of the inferior and then attach by process ID and avoid attaching to the inferior by process name since there could be more than one process with that name. This still has possible race conditions, those will be fixed in the near future. This fixes the SIGPIPE issues that were sometimes being seen when task_for_pid was failing. Modified: lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Core/ConnectionFileDescriptor.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Target/Process.cpp lldb/trunk/tools/darwin-debug/darwin-debug.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h?rev=116792&r1=116791&r2=116792&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h (original) +++ lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h Mon Oct 18 22:25:40 2010 @@ -56,6 +56,9 @@ SocketConnect (const char *host_and_port, Error *error_ptr); lldb::ConnectionStatus + NamedSocketAccept (const char *socket_name, Error *error_ptr); + + lldb::ConnectionStatus Close (int& fd, Error *error); int m_fd; // Socket we use to communicate once conn established Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=116792&r1=116791&r2=116792&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Mon Oct 18 22:25:40 2010 @@ -216,29 +216,14 @@ if (m_options.in_new_tty) { - lldb::pid_t terminal_pid = Host::LaunchInNewTerminal (inferior_argv, - inferior_envp, - &exe_module->GetArchitecture(), - true, - process->GetDisableASLR()); + lldb::pid_t pid = Host::LaunchInNewTerminal (inferior_argv, + inferior_envp, + &exe_module->GetArchitecture(), + true, + process->GetDisableASLR()); - // Let the app get launched and stopped... - const char *process_name = exe_module->GetFileSpec().GetFilename().AsCString(""); - - if (terminal_pid == LLDB_INVALID_PROCESS_ID) - { - error.SetErrorStringWithFormat ("failed to launch '%s' in new terminal", process_name); - } - else - { - for (int i=0; i<20; i++) - { - usleep (250000); - error = process->Attach (process_name, false); - if (error.Success()) - break; - } - } + if (pid != LLDB_INVALID_PROCESS_ID) + error = process->Attach (pid); } else { Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=116792&r1=116791&r2=116792&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Mon Oct 18 22:25:40 2010 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -85,6 +86,11 @@ unsigned long listen_port = ::strtoul(s + strlen("listen://"), &end, 0); return SocketListen (listen_port, error_ptr); } + else if (strstr(s, "unix-accept://")) + { + // unix://SOCKNAME + return NamedSocketAccept (s + strlen("unix-accept://"), error_ptr); + } else if (strstr(s, "connect://")) { return SocketConnect (s + strlen("connect://"), error_ptr); @@ -400,6 +406,53 @@ } ConnectionStatus +ConnectionFileDescriptor::NamedSocketAccept (const char *socket_name, Error *error_ptr) +{ + ConnectionStatus result = eConnectionStatusError; + struct sockaddr_un saddr_un; + + m_is_socket = true; + + int listen_socket = ::socket (AF_UNIX, SOCK_STREAM, 0); + if (listen_socket == -1) + { + if (error_ptr) + error_ptr->SetErrorToErrno(); + return eConnectionStatusError; + } + + saddr_un.sun_family = AF_UNIX; + ::strncpy(saddr_un.sun_path, socket_name, sizeof(saddr_un.sun_path) - 1); + saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0'; + saddr_un.sun_len = SUN_LEN (&saddr_un); + + if (::bind (listen_socket, (struct sockaddr *)&saddr_un, SUN_LEN (&saddr_un)) == 0) + { + if (::listen (listen_socket, 5) == 0) + { + m_fd = ::accept (listen_socket, NULL, 0); + if (m_fd > 0) + { + m_should_close_fd = true; + + if (error_ptr) + error_ptr->Clear(); + result = eConnectionStatusSuccess; + } + } + } + + if (result != eConnectionStatusSuccess) + { + if (error_ptr) + error_ptr->SetErrorToErrno(); + } + // We are done with the listen port + Close (listen_socket, NULL); + return result; +} + +ConnectionStatus ConnectionFileDescriptor::SocketListen (uint16_t listen_port_num, Error *error_ptr) { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION, Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=116792&r1=116791&r2=116792&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Mon Oct 18 22:25:40 2010 @@ -13,6 +13,8 @@ #include #include "lldb/Core/ArchSpec.h" +#include "lldb/Core/Communication.h" +#include "lldb/Core/ConnectionFileDescriptor.h" #include "lldb/Core/FileSpec.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamFile.h" @@ -176,6 +178,8 @@ FileSpec program (argv[0]); + std::string unix_socket_name; + char temp_file_path[PATH_MAX]; const char *tmpdir = ::getenv ("TMPDIR"); if (tmpdir == NULL) @@ -185,6 +189,8 @@ if (::mktemp (temp_file_path) == NULL) return LLDB_INVALID_PROCESS_ID; + unix_socket_name.assign (temp_file_path); + ::strncat (temp_file_path, ".command", sizeof (temp_file_path)); StreamFile command_file (temp_file_path, "w"); @@ -201,6 +207,8 @@ darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path)); command_file.Printf("\"%s\" ", launcher_path); + command_file.Printf("--unix-socket=%s ", unix_socket_name.c_str()); + if (arch_spec && arch_spec->IsValid()) { command_file.Printf("--arch=%s ", arch_spec->AsCString()); @@ -253,7 +261,7 @@ CFCReleaser command_file_url (::CFURLCreateFromFileSystemRepresentation (NULL, (const UInt8 *)temp_file_path, - strlen (temp_file_path), + strlen(temp_file_path), false)); CFCMutableArray urls; @@ -263,14 +271,33 @@ // for us to attach. urls.AppendValue(command_file_url.get()); - ProcessSerialNumber psn; - error = LSOpenURLsWithRole(urls.get(), kLSRolesShell, NULL, &app_params, &psn, 1); - if (error != noErr) - return LLDB_INVALID_PROCESS_ID; + lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; - ::pid_t pid = LLDB_INVALID_PROCESS_ID; - error = ::GetProcessPID(&psn, &pid); + Error lldb_error; + // Sleep and wait a bit for debugserver to start to listen... + ConnectionFileDescriptor file_conn; + char connect_url[128]; + ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name.c_str()); + + ProcessSerialNumber psn; + error = LSOpenURLsWithRole(urls.get(), kLSRolesShell, NULL, &app_params, &psn, 1); + if (error == noErr) + { + if (file_conn.Connect(connect_url, &lldb_error) == eConnectionStatusSuccess) + { + char pid_str[256]; + ::bzero (pid_str, sizeof(pid_str)); + ConnectionStatus status; + const size_t pid_str_len = file_conn.Read (pid_str, sizeof(pid_str), status, NULL); + if (pid_str_len > 0) + { + pid = atoi (pid_str); + // Sleep for a bit to allow the process to exec and stop at the entry point... + sleep(1); + } + } + } return pid; } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=116792&r1=116791&r2=116792&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Oct 18 22:25:40 2010 @@ -243,10 +243,10 @@ log->Printf ("Process::%s (timeout = %p, event_sp)...", __FUNCTION__, timeout); StateType state = eStateInvalid; - if (m_listener.WaitForEventForBroadcasterWithType(timeout, - this, - eBroadcastBitStateChanged, - event_sp)) + if (m_listener.WaitForEventForBroadcasterWithType (timeout, + this, + eBroadcastBitStateChanged, + event_sp)) state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); if (log) @@ -266,8 +266,8 @@ log->Printf ("Process::%s...", __FUNCTION__); Event *event_ptr; - event_ptr = m_listener.PeekAtNextEventForBroadcasterWithType(this, - eBroadcastBitStateChanged); + event_ptr = m_listener.PeekAtNextEventForBroadcasterWithType (this, + eBroadcastBitStateChanged); if (log) { if (event_ptr) Modified: lldb/trunk/tools/darwin-debug/darwin-debug.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/darwin-debug/darwin-debug.cpp?rev=116792&r1=116791&r2=116792&view=diff ============================================================================== --- lldb/trunk/tools/darwin-debug/darwin-debug.cpp (original) +++ lldb/trunk/tools/darwin-debug/darwin-debug.cpp Mon Oct 18 22:25:40 2010 @@ -30,6 +30,11 @@ #include #include #include +#include +#include +#include + +#include #ifndef _POSIX_SPAWN_DISABLE_ASLR #define _POSIX_SPAWN_DISABLE_ASLR 0x0100 @@ -44,6 +49,7 @@ { "no-env", no_argument, NULL, 'e' }, { "help", no_argument, NULL, 'h' }, { "setsid", no_argument, NULL, 's' }, + { "unix-socket", required_argument, NULL, 'u' }, { NULL, 0, NULL, 0 } }; @@ -56,7 +62,7 @@ " for debugging.\n" "\n" "SYNOPSIS\n" -" darwin-debug [--arch=] [--disable-aslr] [--no-env] [--setsid] [--help] -- [ ....]\n" +" darwin-debug --unix-socket= [--arch=] [--disable-aslr] [--no-env] [--setsid] [--help] -- [ ....]\n" "\n" "DESCRIPTION\n" " darwin-debug will exec itself into a child process that is\n" @@ -65,7 +71,9 @@ " stop at the program entry point. Any program arguments are\n" " passed on to the exec as the arguments for the new process. The current\n" " environment will be passed to the new process unless the \"--no-env\"\n" -" option is used.\n" +" option is used. A unix socket must be supplied using the\n" +" --unix-socket= option so the calling program can handshake with\n" +" this process and get its process id.\n" "\n" "EXAMPLE\n" " darwin-debug --arch=i386 -- /bin/ls -al /tmp\n" @@ -148,7 +156,8 @@ char ch; int disable_aslr = 0; // By default we disable ASLR int pass_env = 1; - while ((ch = getopt_long(argc, argv, "a:dfh?", g_long_options, NULL)) != -1) + std::string unix_socket_name; + while ((ch = getopt_long(argc, argv, "a:dehsu:?", g_long_options, NULL)) != -1) { switch (ch) { @@ -186,6 +195,10 @@ ::setsid(); break; + case 'u': + unix_socket_name.assign (optarg); + break; + case 'h': case '?': default: @@ -196,7 +209,7 @@ argc -= optind; argv += optind; - if (show_usage || argc <= 0) + if (show_usage || argc <= 0 || unix_socket_name.empty()) usage(); #if defined (DEBUG_LLDB_LAUNCHER) @@ -205,6 +218,43 @@ printf ("argv[%u] = '%s'\n", i, argv[i]); #endif + // Open the socket that was passed in as an argument + struct sockaddr_un saddr_un; + int s = ::socket (AF_UNIX, SOCK_STREAM, 0); + if (s < 0) + { + perror("error: socket (AF_UNIX, SOCK_STREAM, 0)"); + exit(1); + } + + saddr_un.sun_family = AF_UNIX; + ::strncpy(saddr_un.sun_path, unix_socket_name.c_str(), sizeof(saddr_un.sun_path) - 1); + saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0'; + saddr_un.sun_len = SUN_LEN (&saddr_un); + + if (::connect (s, (struct sockaddr *)&saddr_un, SUN_LEN (&saddr_un)) < 0) + { + perror("error: connect (socket, &saddr_un, saddr_un_len)"); + exit(1); + } + + // We were able to connect to the socket, now write our PID so whomever + // launched us will know this process's ID + char pid_str[64]; + const int pid_str_len = ::snprintf (pid_str, sizeof(pid_str), "%i", ::getpid()); + const int bytes_sent = ::send (s, pid_str, pid_str_len, 0); + + if (pid_str_len != bytes_sent) + { + perror("error: send (s, pid_str, pid_str_len, 0)"); + exit (1); + } + + // We are done with the socket + close (s); + + // Now we posix spawn to exec this process into the inferior that we want + // to debug. posix_spawn_for_debug (argv, pass_env ? envp : NULL, cpu_type, Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=116792&r1=116791&r2=116792&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Mon Oct 18 22:25:40 2010 @@ -1377,6 +1377,7 @@ SBHostOS::ThreadCreated ("[main]"); + signal (SIGPIPE, SIG_IGN); signal (SIGWINCH, sigwinch_handler); // Create a scope for driver so that the driver object will destroy itself From johnny.chen at apple.com Tue Oct 19 11:00:42 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 16:00:42 -0000 Subject: [Lldb-commits] [lldb] r116809 - /lldb/trunk/test/lldbtest.py Message-ID: <20101019160042.B81212A6C12C@llvm.org> Author: johnny Date: Tue Oct 19 11:00:42 2010 New Revision: 116809 URL: http://llvm.org/viewvc/llvm-project?rev=116809&view=rev Log: Change the environment variable name to be more descriptive from LLDB_TIME_WAIT to LLDB_TIME_WAIT_NEXT_LAUNCH. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=116809&r1=116808&r2=116809&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Oct 19 11:00:42 2010 @@ -310,7 +310,7 @@ maxLaunchCount = 3; # Time to wait before the next launching attempt in second(s). - # Can be overridden by the LLDB_TIME_WAIT environment variable. + # Can be overridden by the LLDB_TIME_WAIT_NEXT_LAUNCH environment variable. timeWait = 1.0; # Keep track of the old current working directory. @@ -375,8 +375,8 @@ if "LLDB_MAX_LAUNCH_COUNT" in os.environ: self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"]) - if "LLDB_TIME_WAIT" in os.environ: - self.timeWait = float(os.environ["LLDB_TIME_WAIT"]) + if "LLDB_TIME_WAIT_NEXT_LAUNCH" in os.environ: + self.timeWait = float(os.environ["LLDB_TIME_WAIT_NEXT_LAUNCH"]) # Create the debugger instance if necessary. try: From gclayton at apple.com Tue Oct 19 12:03:58 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 19 Oct 2010 17:03:58 -0000 Subject: [Lldb-commits] [lldb] r116814 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Host/macosx/Host.mm tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20101019170358.656D42A6C12C@llvm.org> Author: gclayton Date: Tue Oct 19 12:03:58 2010 New Revision: 116814 URL: http://llvm.org/viewvc/llvm-project?rev=116814&view=rev Log: Use AppleScript when lauching inferior in terminal so the command that is being run is visible in the terminal as opposed to just seeing a path to a .command file. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=116814&r1=116813&r2=116814&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Oct 19 12:03:58 2010 @@ -2490,7 +2490,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=116814&r1=116813&r2=116814&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Tue Oct 19 12:03:58 2010 @@ -159,6 +159,8 @@ error = ::GetProcessPID(&psn, &pid); return pid; } +#define LLDB_HOST_USE_APPLESCRIPT +#if defined (LLDB_HOST_USE_APPLESCRIPT) lldb::pid_t Host::LaunchInNewTerminal @@ -172,6 +174,93 @@ { if (!argv || !argv[0]) return LLDB_INVALID_PROCESS_ID; + + std::string unix_socket_name; + + char temp_file_path[PATH_MAX] = "/tmp/XXXXXX"; + if (::mktemp (temp_file_path) == NULL) + return LLDB_INVALID_PROCESS_ID; + + unix_socket_name.assign (temp_file_path); + + StreamString command; + + FileSpec darwin_debug_file_spec; + if (!Host::GetLLDBPath (ePathTypeSupportExecutableDir, darwin_debug_file_spec)) + return LLDB_INVALID_PROCESS_ID; + darwin_debug_file_spec.GetFilename().SetCString("darwin-debug"); + + if (!darwin_debug_file_spec.Exists()) + return LLDB_INVALID_PROCESS_ID; + + char launcher_path[PATH_MAX]; + darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path)); + command.Printf ("tell application \"Terminal\"\n do script \"'%s'", launcher_path); + + command.Printf(" --unix-socket=%s", unix_socket_name.c_str()); + + if (arch_spec && arch_spec->IsValid()) + { + command.Printf(" --arch=%s", arch_spec->AsCString()); + } + + if (disable_aslr) + { + command.PutCString(" --disable-aslr"); + } + + command.PutCString(" --"); + + if (argv) + { + for (size_t i=0; argv[i] != NULL; ++i) + { + command.Printf(" '%s'", argv[i]); + } + } + command.PutCString (" ; exit\"\nend tell\n"); + const char *script_source = command.GetString().c_str(); + NSAppleScript* applescript = [[NSAppleScript alloc] initWithSource:[NSString stringWithCString:script_source encoding:NSUTF8StringEncoding]]; + + lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; + + Error lldb_error; + // Sleep and wait a bit for debugserver to start to listen... + ConnectionFileDescriptor file_conn; + char connect_url[128]; + ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name.c_str()); + + [applescript executeAndReturnError:nil]; + if (file_conn.Connect(connect_url, &lldb_error) == eConnectionStatusSuccess) + { + char pid_str[256]; + ::bzero (pid_str, sizeof(pid_str)); + ConnectionStatus status; + const size_t pid_str_len = file_conn.Read (pid_str, sizeof(pid_str), status, NULL); + if (pid_str_len > 0) + { + pid = atoi (pid_str); + // Sleep for a bit to allow the process to exec and stop at the entry point... + sleep(1); + } + } + [applescript release]; + return pid; +} + +#else +lldb::pid_t +Host::LaunchInNewTerminal +( + const char **argv, + const char **envp, + const ArchSpec *arch_spec, + bool stop_at_entry, + bool disable_aslr +) +{ + if (!argv || !argv[0]) + return LLDB_INVALID_PROCESS_ID; OSStatus error = 0; @@ -300,6 +389,7 @@ } return pid; } +#endif bool Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no) Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=116814&r1=116813&r2=116814&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Tue Oct 19 12:03:58 2010 @@ -369,7 +369,6 @@ isa = PBXProject; buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "debugserver" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, From johnny.chen at apple.com Tue Oct 19 12:37:52 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 17:37:52 -0000 Subject: [Lldb-commits] [lldb] r116822 - /lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt Message-ID: <20101019173752.73BB02A6C12C@llvm.org> Author: johnny Date: Tue Oct 19 12:37:52 2010 New Revision: 116822 URL: http://llvm.org/viewvc/llvm-project?rev=116822&view=rev Log: Initial version of a detailed walkthrough of a test case (test/settings/TestSettings.py). It's an in-progress snapshot, and not complete. Added: lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt Added: lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt?rev=116822&view=auto ============================================================================== --- lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt (added) +++ lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt Tue Oct 19 12:37:52 2010 @@ -0,0 +1,164 @@ +Let's pick test/settings/TestSettings.py as our example. First, notice the file +name "TestSettings.py", the Test*.py pattern is the default mechanism that the +test driver uses for discovery of tests. As to TestSettings.py, it defines a +class: + +class SettingsCommandTestCase(TestBase): + +derived from TestBase, which is defined in test/lldbtest.py and is itself +derived from Python's unittest framework's TestCase class. See also +http://docs.python.org/library/unittest.html for more details. + +To just run the TestSettings.py test, chdir to the lldb test directory, and then +type the following command: + +/Volumes/data/lldb/svn/trunk/test $ ./dotest.py settings +---------------------------------------------------------------------- +Collected 6 tests + +---------------------------------------------------------------------- +Ran 6 tests in 8.699s + +OK (expected failures=1) +/Volumes/data/lldb/svn/trunk/test $ + +Pass '-v' option to the test driver to also output verbose descriptions of the +individual test cases and their test status: + +/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v settings +---------------------------------------------------------------------- +Collected 6 tests + +test_set_auto_confirm (TestSettings.SettingsCommandTestCase) +Test that after 'set auto-confirm true', manual confirmation should not kick in. ... ok +test_set_output_path (TestSettings.SettingsCommandTestCase) +Test that setting target.process.output-path for the launched process works. ... expected failure +test_set_prompt (TestSettings.SettingsCommandTestCase) +Test that 'set prompt' actually changes the prompt. ... ok +test_set_term_width (TestSettings.SettingsCommandTestCase) +Test that 'set term-width' actually changes the term-width. ... ok +test_with_dsym (TestSettings.SettingsCommandTestCase) +Test that run-args and env-vars are passed to the launched process. ... ok +test_with_dwarf (TestSettings.SettingsCommandTestCase) +Test that run-args and env-vars are passed to the launched process. ... ok + +---------------------------------------------------------------------- +Ran 6 tests in 5.735s + +OK (expected failures=1) +/Volumes/data/lldb/svn/trunk/test $ + +Underneath, the '-v' option passes keyword argument verbosity=2 to the +Python's unittest.TextTestRunner (see also +http://docs.python.org/library/unittest.html#unittest.TextTestRunner). For very +detailed descriptions about what's going on during the test, pass '-t' to the +test driver, which asks the test driver to trace the commands executed and to +display their output. For brevity, the '-t' output is not included here. + +Notice the 'expected failures=1' message at the end of the run. This is because +of a bug currently in lldb such that setting target.process.output-path to +'stdout.txt' does not have any effect on the redirection of the standard output +of the subsequent launched process. We are using unittest2 (a backport of new +unittest features for Python 2.4-2.6) to decorate (mark) the particular test +method as such: + + @unittest2.expectedFailure + # rdar://problem/8435794 + # settings set target.process.output-path does not seem to work + def test_set_output_path(self): + +See http://pypi.python.org/pypi/unittest2 for more details. + +Now let's look inside the test method: + + def test_set_output_path(self): + """Test that setting target.process.output-path for the launched process works.""" + self.buildDefault() + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Set the output-path and verify it is set. + self.runCmd("settings set target.process.output-path 'stdout.txt'") + self.expect("settings show target.process.output-path", + startstr = "target.process.output-path (string) = 'stdout.txt'") + + self.runCmd("run", RUN_SUCCEEDED) + + # The 'stdout.txt' file should now exist. + self.assertTrue(os.path.isfile("stdout.txt"), + "'stdout.txt' exists due to target.process.output-path.") + + # Read the output file produced by running the program. + with open('stdout.txt', 'r') as f: + output = f.read() + + self.expect(output, exe=False, + startstr = "This message should go to standard out.") + +The self.buildDefault() statement is used to build a default binary for this +test instance. For this particular test case, since we don't really care what +debugging format is used, we instruct the build subsystem to build the default +binary for us. The base class TestBase has defined three instance methods: + + def buildDefault(self, architecture=None, compiler=None, dictionary=None): + """Platform specific way to build the default binaries.""" + module = __import__(sys.platform) + if not module.buildDefault(self, architecture, compiler, dictionary): + raise Exception("Don't know how to build default binary") + + def buildDsym(self, architecture=None, compiler=None, dictionary=None): + """Platform specific way to build binaries with dsym info.""" + module = __import__(sys.platform) + if not module.buildDsym(self, architecture, compiler, dictionary): + raise Exception("Don't know how to build binary with dsym") + + def buildDwarf(self, architecture=None, compiler=None, dictionary=None): + """Platform specific way to build binaries with dwarf maps.""" + module = __import__(sys.platform) + if not module.buildDwarf(self, architecture, compiler, dictionary): + raise Exception("Don't know how to build binary with dwarf") + +And the test/plugins/darwin.py provides the implmentation for all three build +methods using the makefile mechanism. We envision that linux plugin can use a +similar approach to accomplish the task of building the binaries. + +Mac OS X provides an additional way to manipulate archived DWARF debug symbol +files and produces dSYM files. The buildDsym() instance method is used by the +test method to build the binary with dsym info. For an example of this, +see test/array_types/TestArrayTypes.py: + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_run_command(self): + """Test 'frame variable var_name' on some variables with array types.""" + self.buildDsym() + self.array_types() + +This method is decorated with a skipUnless decorator so that it will only gets +included into the test suite if the platform it is running on is 'darwin', aka +Mac OS X. + +Type 'man dsymutil' for more details. + +After the binary is built, it is time to specify the file to be used as the main +executable by lldb: + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + +This is where the attribute assignment: + +class SettingsCommandTestCase(TestBase): + + mydir = "settings" + +which happens right after the SettingsCommandTestCase class declaration comes +into place. It specifies the relative directory to the top level 'test' so that +the test harness runtime can change its working directory in order to find the +executable as well as the source code files. The runCmd() method is defined +in the TestBase base class (within test/lldbtest.py) and its purpose is to pass +the specified command to the lldb command interpreter. It's like you're typing +the command within an interactive lldb session. + +The CURRENT_EXECUTABLE_SET is an assert message defined in the lldbtest module +so that it can reused from other test modules. From gclayton at apple.com Tue Oct 19 13:15:50 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 19 Oct 2010 18:15:50 -0000 Subject: [Lldb-commits] [lldb] r116841 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Host/macosx/Host.mm tools/darwin-debug/darwin-debug.cpp Message-ID: <20101019181550.824252A6C12C@llvm.org> Author: gclayton Date: Tue Oct 19 13:15:50 2010 New Revision: 116841 URL: http://llvm.org/viewvc/llvm-project?rev=116841&view=rev Log: Fixed all known race conditions with starting a process in a new terminal. We now spawn a thread to accept a unix socket connection from the inferior when it spawns in the terminal, then we launch the process, then we get the pid back through the unix socket, and then wait for it to SIGSTOP. darwin-debug now clears the terminal screen and prints out the program and arguments that are about to be launched. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/tools/darwin-debug/darwin-debug.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=116841&r1=116840&r2=116841&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Oct 19 13:15:50 2010 @@ -2490,6 +2490,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=116841&r1=116840&r2=116841&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Tue Oct 19 13:15:50 2010 @@ -9,8 +9,10 @@ #include "lldb/Host/Host.h" -#include +#include +#include #include +#include #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Communication.h" @@ -159,79 +161,15 @@ error = ::GetProcessPID(&psn, &pid); return pid; } -#define LLDB_HOST_USE_APPLESCRIPT -#if defined (LLDB_HOST_USE_APPLESCRIPT) - -lldb::pid_t -Host::LaunchInNewTerminal -( - const char **argv, - const char **envp, - const ArchSpec *arch_spec, - bool stop_at_entry, - bool disable_aslr -) -{ - if (!argv || !argv[0]) - return LLDB_INVALID_PROCESS_ID; - - std::string unix_socket_name; - - char temp_file_path[PATH_MAX] = "/tmp/XXXXXX"; - if (::mktemp (temp_file_path) == NULL) - return LLDB_INVALID_PROCESS_ID; - - unix_socket_name.assign (temp_file_path); - - StreamString command; - - FileSpec darwin_debug_file_spec; - if (!Host::GetLLDBPath (ePathTypeSupportExecutableDir, darwin_debug_file_spec)) - return LLDB_INVALID_PROCESS_ID; - darwin_debug_file_spec.GetFilename().SetCString("darwin-debug"); - - if (!darwin_debug_file_spec.Exists()) - return LLDB_INVALID_PROCESS_ID; - - char launcher_path[PATH_MAX]; - darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path)); - command.Printf ("tell application \"Terminal\"\n do script \"'%s'", launcher_path); - - command.Printf(" --unix-socket=%s", unix_socket_name.c_str()); - - if (arch_spec && arch_spec->IsValid()) - { - command.Printf(" --arch=%s", arch_spec->AsCString()); - } - - if (disable_aslr) - { - command.PutCString(" --disable-aslr"); - } - - command.PutCString(" --"); - - if (argv) - { - for (size_t i=0; argv[i] != NULL; ++i) - { - command.Printf(" '%s'", argv[i]); - } - } - command.PutCString (" ; exit\"\nend tell\n"); - const char *script_source = command.GetString().c_str(); - NSAppleScript* applescript = [[NSAppleScript alloc] initWithSource:[NSString stringWithCString:script_source encoding:NSUTF8StringEncoding]]; - lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; - Error lldb_error; - // Sleep and wait a bit for debugserver to start to listen... +static void * +AcceptPIDFromInferior (void *arg) +{ + const char *connect_url = (const char *)arg; ConnectionFileDescriptor file_conn; - char connect_url[128]; - ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name.c_str()); - - [applescript executeAndReturnError:nil]; - if (file_conn.Connect(connect_url, &lldb_error) == eConnectionStatusSuccess) + Error error; + if (file_conn.Connect (connect_url, &error) == eConnectionStatusSuccess) { char pid_str[256]; ::bzero (pid_str, sizeof(pid_str)); @@ -239,18 +177,48 @@ const size_t pid_str_len = file_conn.Read (pid_str, sizeof(pid_str), status, NULL); if (pid_str_len > 0) { - pid = atoi (pid_str); - // Sleep for a bit to allow the process to exec and stop at the entry point... - sleep(1); + int pid = atoi (pid_str); + return (void *)(intptr_t)pid; } } - [applescript release]; - return pid; + return NULL; } -#else -lldb::pid_t -Host::LaunchInNewTerminal +static bool +WaitForProcessToSIGSTOP (const lldb::pid_t pid, const int timeout_in_seconds) +{ + const int time_delta_usecs = 100000; + const int num_retries = timeout_in_seconds/time_delta_usecs; + for (int i=0; i 0) + if (accept_thread_result) { - pid = atoi (pid_str); - // Sleep for a bit to allow the process to exec and stop at the entry point... - sleep(1); + pid = (intptr_t)accept_thread_result; + + // Wait for process to be stopped the the entry point by watching + // for the process status to be set to SSTOP which indicates it it + // SIGSTOP'ed at the entry point + WaitForProcessToSIGSTOP (pid, 5); } } } + else + { + Host::ThreadCancel (accept_thread, &lldb_error); + } + return pid; } + + +lldb::pid_t +LaunchInNewTerminalWithAppleScript +( + const char **argv, + const char **envp, + const ArchSpec *arch_spec, + bool stop_at_entry, + bool disable_aslr +) +{ + if (!argv || !argv[0]) + return LLDB_INVALID_PROCESS_ID; + + std::string unix_socket_name; + + char temp_file_path[PATH_MAX] = "/tmp/XXXXXX"; + if (::mktemp (temp_file_path) == NULL) + return LLDB_INVALID_PROCESS_ID; + + unix_socket_name.assign (temp_file_path); + + StreamString command; + + FileSpec darwin_debug_file_spec; + if (!Host::GetLLDBPath (ePathTypeSupportExecutableDir, darwin_debug_file_spec)) + return LLDB_INVALID_PROCESS_ID; + darwin_debug_file_spec.GetFilename().SetCString("darwin-debug"); + + if (!darwin_debug_file_spec.Exists()) + return LLDB_INVALID_PROCESS_ID; + + char launcher_path[PATH_MAX]; + darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path)); + command.Printf ("tell application \"Terminal\"\n do script \"'%s'", launcher_path); + + command.Printf(" --unix-socket=%s", unix_socket_name.c_str()); + + if (arch_spec && arch_spec->IsValid()) + { + command.Printf(" --arch=%s", arch_spec->AsCString()); + } + + if (disable_aslr) + { + command.PutCString(" --disable-aslr"); + } + + command.PutCString(" --"); + + if (argv) + { + for (size_t i=0; argv[i] != NULL; ++i) + { + command.Printf(" '%s'", argv[i]); + } + } + command.PutCString (" ; echo Process exited with status $?\"\nend tell\n"); + const char *script_source = command.GetString().c_str(); + NSAppleScript* applescript = [[NSAppleScript alloc] initWithSource:[NSString stringWithCString:script_source encoding:NSUTF8StringEncoding]]; + + lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; + + Error lldb_error; + // Sleep and wait a bit for debugserver to start to listen... + ConnectionFileDescriptor file_conn; + char connect_url[128]; + ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name.c_str()); + + // Spawn a new thread to accept incoming connection on the connect_url + // so we can grab the pid from the inferior + lldb::thread_t accept_thread = Host::ThreadCreate (unix_socket_name.c_str(), + AcceptPIDFromInferior, + connect_url, + &lldb_error); + + + [applescript executeAndReturnError:nil]; + + thread_result_t accept_thread_result = NULL; + if (Host::ThreadJoin (accept_thread, &accept_thread_result, &lldb_error)) + { + if (accept_thread_result) + { + pid = (intptr_t)accept_thread_result; + + // Wait for process to be stopped the the entry point by watching + // for the process status to be set to SSTOP which indicates it it + // SIGSTOP'ed at the entry point + WaitForProcessToSIGSTOP (pid, 5); + } + } + [applescript release]; + return pid; +} + + +#define LLDB_HOST_USE_APPLESCRIPT + +lldb::pid_t +Host::LaunchInNewTerminal +( + const char **argv, + const char **envp, + const ArchSpec *arch_spec, + bool stop_at_entry, + bool disable_aslr +) +{ +#if defined (LLDB_HOST_USE_APPLESCRIPT) + return LaunchInNewTerminalWithAppleScript (argv, envp, arch_spec, stop_at_entry, disable_aslr); +#else + return LaunchInNewTerminalWithCommandFile (argv, envp, arch_spec, stop_at_entry, disable_aslr); #endif +} + bool Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no) Modified: lldb/trunk/tools/darwin-debug/darwin-debug.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/darwin-debug/darwin-debug.cpp?rev=116841&r1=116840&r2=116841&view=diff ============================================================================== --- lldb/trunk/tools/darwin-debug/darwin-debug.cpp (original) +++ lldb/trunk/tools/darwin-debug/darwin-debug.cpp Tue Oct 19 13:15:50 2010 @@ -253,6 +253,11 @@ // We are done with the socket close (s); + system("clear"); + printf ("Launching '%s' for debug with %u arguments:\n", argv[0], argc); + for (int i=0; i Author: johnny Date: Tue Oct 19 13:43:57 2010 New Revision: 116844 URL: http://llvm.org/viewvc/llvm-project?rev=116844&view=rev Log: Remove the two @skip decorators now that we are not seeing the hang while running the test suite. Modified: lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=116844&r1=116843&r2=116844&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Tue Oct 19 13:43:57 2010 @@ -6,7 +6,6 @@ import unittest2 import lldb -#@unittest2.skip("rdar://problem/8562563 ./dotest.py -v . 2> ~/Developer/Log/lldbtest.log now hangs (very consistently) when executing test/types") class FloatTypesTestCase(AbstractBase.GenericTester): mydir = "types" Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=116844&r1=116843&r2=116844&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Tue Oct 19 13:43:57 2010 @@ -6,7 +6,6 @@ import unittest2 import lldb -#@unittest2.skip("rdar://problem/8562563 ./dotest.py -v . 2> ~/Developer/Log/lldbtest.log now hangs (very consistently) when executing test/types") class IntegerTypesTestCase(AbstractBase.GenericTester): mydir = "types" From johnny.chen at apple.com Tue Oct 19 14:11:38 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 19:11:38 -0000 Subject: [Lldb-commits] [lldb] r116847 - in /lldb/trunk/test: lldbtest.py settings/TestSettings.py Message-ID: <20101019191138.E66E12A6C12C@llvm.org> Author: johnny Date: Tue Oct 19 14:11:38 2010 New Revision: 116847 URL: http://llvm.org/viewvc/llvm-project?rev=116847&view=rev Log: Add a little helper function SETTING_MSG(setting) to be used from TestSettings.test_set_output_path(). Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=116847&r1=116846&r2=116847&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Oct 19 14:11:38 2010 @@ -180,6 +180,12 @@ return "'%s' compares successfully" % str # +# And a generic "Value of setting '%s' is correct" message generator. +# +def SETTING_MSG(setting): + return "Value of setting '%s' is correct" % setting + +# # Returns an env variable array from the os.environ map object. # def EnvArray(): Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=116847&r1=116846&r2=116847&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Tue Oct 19 14:11:38 2010 @@ -115,6 +115,7 @@ # Set the output-path and verify it is set. self.runCmd("settings set target.process.output-path 'stdout.txt'") self.expect("settings show target.process.output-path", + SETTING_MSG("target.process.output-path"), startstr = "target.process.output-path (string) = 'stdout.txt'") self.runCmd("run", RUN_SUCCEEDED) From johnny.chen at apple.com Tue Oct 19 14:39:20 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 19:39:20 -0000 Subject: [Lldb-commits] [lldb] r116850 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20101019193920.9C2FC2A6C12C@llvm.org> Author: johnny Date: Tue Oct 19 14:39:20 2010 New Revision: 116850 URL: http://llvm.org/viewvc/llvm-project?rev=116850&view=rev Log: Add more descriptive messages to expect() instead of using the default assert messages. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=116850&r1=116849&r2=116850&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Tue Oct 19 14:39:20 2010 @@ -23,11 +23,11 @@ self.runCmd("settings set prompt 'lldb2'") # Immediately test the setting. - self.expect("settings show prompt", + self.expect("settings show prompt", SETTING_MSG("prompt"), startstr = "prompt (string) = 'lldb2'") # The overall display should also reflect the new setting. - self.expect("settings show", + self.expect("settings show", SETTING_MSG("prompt"), substrs = ["prompt (string) = 'lldb2'"]) # Use '-r' option to reset to the original default prompt. @@ -39,11 +39,11 @@ self.runCmd("settings set term-width 70") # Immediately test the setting. - self.expect("settings show term-width", + self.expect("settings show term-width", SETTING_MSG("term-width"), startstr = "term-width (int) = '70'") # The overall display should also reflect the new setting. - self.expect("settings show", + self.expect("settings show", SETTING_MSG("term-width"), substrs = ["term-width (int) = '70'"]) def test_set_auto_confirm(self): @@ -56,7 +56,7 @@ self.runCmd("settings set auto-confirm true") # Immediately test the setting. - self.expect("settings show auto-confirm", + self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"), startstr = "auto-confirm (boolean) = 'true'") # Now 'breakpoint delete' should just work fine without confirmation @@ -67,7 +67,7 @@ # Restore the original setting of auto-confirm. self.runCmd("settings set -r auto-confirm") - self.expect("settings show auto-confirm", + self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"), startstr = "auto-confirm (boolean) = 'false'") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") From scallanan at apple.com Tue Oct 19 15:15:00 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 19 Oct 2010 20:15:00 -0000 Subject: [Lldb-commits] [lldb] r116855 - /lldb/trunk/source/Expression/ClangUserExpression.cpp Message-ID: <20101019201500.6C2432A6C12C@llvm.org> Author: spyffe Date: Tue Oct 19 15:15:00 2010 New Revision: 116855 URL: http://llvm.org/viewvc/llvm-project?rev=116855&view=rev Log: Fixed the message that reports that an expression did not return a result. The result is nonexistent (or void), not NULL. Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=116855&r1=116854&r2=116855&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Oct 19 15:15:00 2010 @@ -422,13 +422,13 @@ } else { - error.SetErrorString ("NULL expression result"); + error.SetErrorString ("Expression did not return a result"); } } } + if (result_valobj_sp.get() == NULL) result_valobj_sp.reset (new ValueObjectConstResult (error)); return result_valobj_sp; - } \ No newline at end of file From johnny.chen at apple.com Tue Oct 19 16:46:48 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 21:46:48 -0000 Subject: [Lldb-commits] [lldb] r116865 - in /lldb/trunk/docs/testsuite: 2010-10-19-14:10:49.059609/ 2010-10-19-14:10:49.059609/TestSettings.SettingsCommandTestCase.test_set_output_path.log a-detailed-walkthrough.txt Message-ID: <20101019214648.8F5CE2A6C12C@llvm.org> Author: johnny Date: Tue Oct 19 16:46:48 2010 New Revision: 116865 URL: http://llvm.org/viewvc/llvm-project?rev=116865&view=rev Log: Finish the first draft of a detailed walkthrough of an lldb test method. Added: lldb/trunk/docs/testsuite/2010-10-19-14:10:49.059609/ lldb/trunk/docs/testsuite/2010-10-19-14:10:49.059609/TestSettings.SettingsCommandTestCase.test_set_output_path.log Modified: lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt Added: lldb/trunk/docs/testsuite/2010-10-19-14:10:49.059609/TestSettings.SettingsCommandTestCase.test_set_output_path.log URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/testsuite/2010-10-19-14%3A10%3A49.059609/TestSettings.SettingsCommandTestCase.test_set_output_path.log?rev=116865&view=auto ============================================================================== --- lldb/trunk/docs/testsuite/2010-10-19-14:10:49.059609/TestSettings.SettingsCommandTestCase.test_set_output_path.log (added) +++ lldb/trunk/docs/testsuite/2010-10-19-14:10:49.059609/TestSettings.SettingsCommandTestCase.test_set_output_path.log Tue Oct 19 16:46:48 2010 @@ -0,0 +1,43 @@ + +os command: [['/bin/sh', '-c', 'make clean; make']] +stdout: rm -rf "a.out" "a.out.dSYM" main.o main.d +g++ -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.cpp +g++ -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" +/usr/bin/dsymutil -o "a.out.dSYM" "a.out" + +stderr: None +retcode: 0 + + +runCmd: file /Volumes/data/lldb/svn/trunk/test/settings/a.out +output: Current executable set to '/Volumes/data/lldb/svn/trunk/test/settings/a.out' (x86_64). + + +runCmd: settings set target.process.output-path 'stdout.txt' +output: + +runCmd: settings show target.process.output-path +output: target.process.output-path (string) = 'stdout.txt' + + +Expecting start string: target.process.output-path (string) = 'stdout.txt' +Matched + +runCmd: run +output: Process 43533 launched: '/Volumes/data/lldb/svn/trunk/test/settings/a.out' (x86_64) + + +FAIL + +runCmd: process kill +check of return status not required +runCmd failed! +error: Process must be launched. + + +Traceback (most recent call last): + File "/Volumes/data/lldb/svn/trunk/test/settings/TestSettings.py", line 125, in test_set_output_path + "'stdout.txt' exists due to target.process.output-path.") +AssertionError: False is not True : 'stdout.txt' exists due to target.process.output-path. + + Modified: lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt?rev=116865&r1=116864&r2=116865&view=diff ============================================================================== --- lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt (original) +++ lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt Tue Oct 19 16:46:48 2010 @@ -161,4 +161,144 @@ the command within an interactive lldb session. The CURRENT_EXECUTABLE_SET is an assert message defined in the lldbtest module -so that it can reused from other test modules. +so that it can be reused from other test modules. + +By default, the runCmd() is going to check the return status of the command +execution and fails the test if it is not a success. The assert message, in our +case CURRENT_EXECUTABLE_SET, is used in the exception printout if this happens. + +There are cases when we don't care about the return status from the command +execution. This can be accomplished by passing the keyword argument pair +'check=False' to the method. + +After the current executable is set, we'll then execute two more commands: + + # Set the output-path and verify it is set. + self.runCmd("settings set target.process.output-path 'stdout.txt'") + self.expect("settings show target.process.output-path", + SETTING_MSG("target.process.output-path"), + startstr = "target.process.output-path (string) = 'stdout.txt'") + +The first uses the 'settings set' command to set the static setting +target.process.output-path to be 'stdout.txt', instead of the default +'/dev/stdout'. We then immediately issue a 'settings show' command to check +that, indeed, the setting did take place. Notice that we use a new method +expect() to accomplish the task, which in effect issues a runCmd() behind the +door and grabs the output from the command execution and expects to match the +start string of the output against what we pass in as the value of the keyword +argument pair: + + startstr = "target.process.output-path (string) = 'stdout.txt'" + +Take a look at TestBase.expect() within lldbtest.py for more details. Among +other things, it can also match against a list of regexp patterns as well as a +list of sub strings. And it can also perform negative matching, i.e., instead +of expecting something from the output of command execution, it can perform the +action of 'not expecting' something. + +This will launch/run the program: + + self.runCmd("run", RUN_SUCCEEDED) + +And this asserts that the file 'stdout.txt' should be present after running the +program. + + # The 'stdout.txt' file should now exist. + self.assertTrue(os.path.isfile("stdout.txt"), + "'stdout.txt' exists due to target.process.output-path.") + +Also take a look at main.cpp which emits some message to the stdout. Now, if we +pass this assertion, it's time to examine the contents of the file to make sure +it contains the same message as programmed in main.cpp: + + # Read the output file produced by running the program. + with open('stdout.txt', 'r') as f: + output = f.read() + + self.expect(output, exe=False, + startstr = "This message should go to standard out.") + +We open the file and read its contents into output, then issue an expect() +method. The 'exe=False' keyword argument pair tells expect() that don't try to +execute the first arg as a command at all. Instead, treat it as a string to +match against whatever is thrown in as keyword argument pairs! + +There are also other test methods present in the TestSettings.py mode: +test_set_prompt(), test_set_term_width(), test_set_auto_confirm(), +test_with_dsym(), and test_with_dwarf(). We are using the default test loader +from unittest framework, which uses the 'test' method name prefix to identify +test methods automatically. + +This finishes the walkthrough of the test method test_set_output_path(self). +Before we say goodbye, notice the little method definition at the top of the +file: + + @classmethod + def classCleanup(cls): + system(["/bin/sh", "-c", "rm -f output.txt"]) + system(["/bin/sh", "-c", "rm -f stdout.txt"]) + +This is a classmethod (as shown by the @classmethod decorator) which allows the +individual test class to perform cleanup actions after the test harness finishes +with the particular test class. This is part of the so-called test fixture in +the unittest framework. From http://docs.python.org/library/unittest.html: + +A test fixture represents the preparation needed to perform one or more tests, +and any associate cleanup actions. This may involve, for example, creating +temporary or proxy databases, directories, or starting a server process. + +The TestBase class uses such fixture with setUp(self), tearDown(self), +setUpClass(cls), and tearDownClass(cls). And within teraDownClass(cls), it +checks whether the current class has an attribute named 'classCleanup', and +executes as a method if present. In this particular case, the classCleanup() +calls a utility function system() defined in lldbtest.py in order to remove the +files created by running the program as the tests are executed. + +This system() function uses the Python subprocess module to spawn the process +and to retrieve its results. If the test instance passes the keyword argument +pair 'sender=self', the detailed command execution through the operating system +also gets recorded in a session object. If the test instance fails or errors, +the session info automatically gets dumped to a file grouped under a directory +named after the timestamp of the particular test suite run. + +For simple cases, look for the timestamp directory in the same directory of the +test driver program dotest.py. For example, if we comment out the + at expectedFailure decorator for TestSettings.py, and then run the test module: + +/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v settings +---------------------------------------------------------------------- +Collected 6 tests + +test_set_auto_confirm (TestSettings.SettingsCommandTestCase) +Test that after 'set auto-confirm true', manual confirmation should not kick in. ... ok +test_set_output_path (TestSettings.SettingsCommandTestCase) +Test that setting target.process.output-path for the launched process works. ... FAIL +test_set_prompt (TestSettings.SettingsCommandTestCase) +Test that 'set prompt' actually changes the prompt. ... ok +test_set_term_width (TestSettings.SettingsCommandTestCase) +Test that 'set term-width' actually changes the term-width. ... ok +test_with_dsym (TestSettings.SettingsCommandTestCase) +Test that run-args and env-vars are passed to the launched process. ... ok +test_with_dwarf (TestSettings.SettingsCommandTestCase) +Test that run-args and env-vars are passed to the launched process. ... ok + +====================================================================== +FAIL: test_set_output_path (TestSettings.SettingsCommandTestCase) +Test that setting target.process.output-path for the launched process works. +---------------------------------------------------------------------- +Traceback (most recent call last): + File "/Volumes/data/lldb/svn/trunk/test/settings/TestSettings.py", line 125, in test_set_output_path + "'stdout.txt' exists due to target.process.output-path.") +AssertionError: False is not True : 'stdout.txt' exists due to target.process.output-path. + +---------------------------------------------------------------------- +Ran 6 tests in 8.219s + +FAILED (failures=1) +/Volumes/data/lldb/svn/trunk/test $ ls 2010-10-19-14:10:49.059609 +TestSettings.SettingsCommandTestCase.test_set_output_path.log +/Volumes/data/lldb/svn/trunk/test $ + +We get one failure and a timestamp directory 2010-10-19-14:10:49.059609. +For education purposes, the directory and its contents are reproduced here in +the same directory as the current file. From scallanan at apple.com Tue Oct 19 17:24:06 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 19 Oct 2010 22:24:06 -0000 Subject: [Lldb-commits] [lldb] r116870 - /lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Message-ID: <20101019222406.2FC852A6C12C@llvm.org> Author: spyffe Date: Tue Oct 19 17:24:06 2010 New Revision: 116870 URL: http://llvm.org/viewvc/llvm-project?rev=116870&view=rev Log: Expressions now claim responsibility for all stops that occur while they run. This means that they clean up after themselves even when they crash. Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=116870&r1=116869&r2=116870&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Tue Oct 19 17:24:06 2010 @@ -171,6 +171,10 @@ bool ThreadPlanCallFunction::PlanExplainsStop () { + // If the subplan is running, any crashes are attributable to us. + + return (m_subplan_sp.get() != NULL); + if (!m_subplan_sp) return false; else From scallanan at apple.com Tue Oct 19 17:29:34 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 19 Oct 2010 22:29:34 -0000 Subject: [Lldb-commits] [lldb] r116871 - /lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Message-ID: <20101019222934.248CB2A6C12C@llvm.org> Author: spyffe Date: Tue Oct 19 17:29:33 2010 New Revision: 116871 URL: http://llvm.org/viewvc/llvm-project?rev=116871&view=rev Log: Removed a bit of dead code. Thanks to Eric Christopher for pointing it out. Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=116871&r1=116870&r2=116871&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Tue Oct 19 17:29:33 2010 @@ -174,11 +174,6 @@ // If the subplan is running, any crashes are attributable to us. return (m_subplan_sp.get() != NULL); - - if (!m_subplan_sp) - return false; - else - return m_subplan_sp->PlanExplainsStop(); } bool From johnny.chen at apple.com Tue Oct 19 17:31:50 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 22:31:50 -0000 Subject: [Lldb-commits] [lldb] r116873 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20101019223150.B03232A6C12C@llvm.org> Author: johnny Date: Tue Oct 19 17:31:50 2010 New Revision: 116873 URL: http://llvm.org/viewvc/llvm-project?rev=116873&view=rev Log: test_set_output_path() should restore the original setting of target.process.output-path after running the program. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=116873&r1=116872&r2=116873&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Tue Oct 19 17:31:50 2010 @@ -120,6 +120,9 @@ self.runCmd("run", RUN_SUCCEEDED) + # Restore the original setting now that the program has been run. + self.runCmd("settings set -r target.process.output-path") + # The 'stdout.txt' file should now exist. self.assertTrue(os.path.isfile("stdout.txt"), "'stdout.txt' exists due to target.process.output-path.") From johnny.chen at apple.com Tue Oct 19 17:45:25 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 22:45:25 -0000 Subject: [Lldb-commits] [lldb] r116874 - /lldb/trunk/test/lldbtest.py Message-ID: <20101019224525.C0B622A6C12C@llvm.org> Author: johnny Date: Tue Oct 19 17:45:25 2010 New Revision: 116874 URL: http://llvm.org/viewvc/llvm-project?rev=116874&view=rev Log: Add Python doc string for setTearDownCleanup() method. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=116874&r1=116873&r2=116874&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Oct 19 17:45:25 2010 @@ -424,10 +424,6 @@ self.__errored__ = False self.__failed__ = False - def setTearDownCleanup(self, dictionary=None): - self.dict = dictionary - self.doTearDownCleanup = True - def markError(self): """Callback invoked when we (the test case instance) errored.""" self.__errored__ = True @@ -464,6 +460,11 @@ with open(fname, "w") as f: print >> f, self.session.getvalue() + def setTearDownCleanup(self, dictionary=None): + """Register a cleanup action at tearDown() time with a dictinary""" + self.dict = dictionary + self.doTearDownCleanup = True + def tearDown(self): #import traceback #traceback.print_stack() From gclayton at apple.com Tue Oct 19 18:16:00 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 19 Oct 2010 23:16:00 -0000 Subject: [Lldb-commits] [lldb] r116878 - in /lldb/trunk: include/lldb/Host/Host.h source/Commands/CommandObjectProcess.cpp source/Host/macosx/Host.mm Message-ID: <20101019231600.6D5B72A6C12C@llvm.org> Author: gclayton Date: Tue Oct 19 18:16:00 2010 New Revision: 116878 URL: http://llvm.org/viewvc/llvm-project?rev=116878&view=rev Log: Ok, last commit for the running processes in a new window. Now you can optionally specify the tty you want to use if you want to use an existing terminal window by giving a partial or full path name: (lldb) process launch --tty=ttys002 This would find the terminal window (or tab on MacOSX) that has ttys002 in its tty path and use it. If it isn't found, it will use a new terminal window. Modified: lldb/trunk/include/lldb/Host/Host.h lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Host/macosx/Host.mm Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=116878&r1=116877&r2=116878&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Tue Oct 19 18:16:00 2010 @@ -310,7 +310,8 @@ LaunchApplication (const FileSpec &app_file_spec); static lldb::pid_t - LaunchInNewTerminal (const char **argv, // argv[0] is executable + LaunchInNewTerminal (const char *tty_name, // Optional partial or full tty name ("/dev/ttys000" or "ttys000") + const char **argv, // argv[0] is executable const char **envp, const ArchSpec *arch_spec, bool stop_at_entry, Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=116878&r1=116877&r2=116878&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Oct 19 18:16:00 2010 @@ -62,7 +62,11 @@ case 'i': stdin_path = option_arg; break; case 'o': stdout_path = option_arg; break; case 'p': plugin_name = option_arg; break; - case 't': in_new_tty = true; break; + case 't': + if (option_arg && option_arg[0]) + tty_name.assign (option_arg); + in_new_tty = true; + break; default: error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); break; @@ -77,6 +81,7 @@ Options::ResetOptionValues(); stop_at_entry = false; in_new_tty = false; + tty_name.clear(); stdin_path.clear(); stdout_path.clear(); stderr_path.clear(); @@ -97,6 +102,7 @@ bool stop_at_entry; bool in_new_tty; + std::string tty_name; std::string stderr_path; std::string stdin_path; std::string stdout_path; @@ -216,7 +222,8 @@ if (m_options.in_new_tty) { - lldb::pid_t pid = Host::LaunchInNewTerminal (inferior_argv, + lldb::pid_t pid = Host::LaunchInNewTerminal (m_options.tty_name.c_str(), + inferior_argv, inferior_envp, &exe_module->GetArchitecture(), true, @@ -322,7 +329,7 @@ { SET1 , false, "stdout", 'o', required_argument, NULL, 0, eArgTypePath, "Redirect stdout for the process to ."}, { SET1 , false, "stderr", 'e', required_argument, NULL, 0, eArgTypePath, "Redirect stderr for the process to ."}, { SET1 | SET2, false, "plugin", 'p', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, -{ SET2, false, "tty", 't', no_argument, NULL, 0, eArgTypeNone, "Start the process in a new terminal (tty)."}, +{ SET2, false, "tty", 't', optional_argument, NULL, 0, eArgTypePath, "Start the process in a terminal. If is specified, look for a terminal whose name contains , else start the process in a new terminal."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=116878&r1=116877&r2=116878&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Tue Oct 19 18:16:00 2010 @@ -369,10 +369,35 @@ return pid; } +const char *applscript_in_new_tty = +"tell application \"Terminal\"\n" +" do script \"%s\"\n" +"end tell\n"; + + +const char *applscript_in_existing_tty = "\ +set the_shell_script to \"%s\"\n\ +tell application \"Terminal\"\n\ + repeat with the_window in (get windows)\n\ + repeat with the_tab in tabs of the_window\n\ + set the_tty to tty in the_tab\n\ + if the_tty contains \"%s\" then\n\ + if the_tab is not busy then\n\ + set selected of the_tab to true\n\ + set frontmost of the_window to true\n\ + do script the_shell_script in the_tab\n\ + return\n\ + end if\n\ + end if\n\ + end repeat\n\ + end repeat\n\ + do script the_shell_script\n\ +end tell\n"; lldb::pid_t LaunchInNewTerminalWithAppleScript ( + const char *tty_name, const char **argv, const char **envp, const ArchSpec *arch_spec, @@ -392,7 +417,6 @@ unix_socket_name.assign (temp_file_path); StreamString command; - FileSpec darwin_debug_file_spec; if (!Host::GetLLDBPath (ePathTypeSupportExecutableDir, darwin_debug_file_spec)) return LLDB_INVALID_PROCESS_ID; @@ -403,19 +427,14 @@ char launcher_path[PATH_MAX]; darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path)); - command.Printf ("tell application \"Terminal\"\n do script \"'%s'", launcher_path); - - command.Printf(" --unix-socket=%s", unix_socket_name.c_str()); + + command.Printf("'%s' --unix-socket=%s", launcher_path, unix_socket_name.c_str()); if (arch_spec && arch_spec->IsValid()) - { command.Printf(" --arch=%s", arch_spec->AsCString()); - } if (disable_aslr) - { command.PutCString(" --disable-aslr"); - } command.PutCString(" --"); @@ -426,8 +445,26 @@ command.Printf(" '%s'", argv[i]); } } - command.PutCString (" ; echo Process exited with status $?\"\nend tell\n"); - const char *script_source = command.GetString().c_str(); + command.PutCString (" ; echo Process exited with status $?"); + + StreamString applescript_source; + + if (tty_name && tty_name[0]) + { + applescript_source.Printf (applscript_in_existing_tty, + command.GetString().c_str(), + tty_name); + } + else + { + applescript_source.Printf (applscript_in_new_tty, + command.GetString().c_str()); + } + + + + const char *script_source = applescript_source.GetString().c_str(); + //puts (script_source); NSAppleScript* applescript = [[NSAppleScript alloc] initWithSource:[NSString stringWithCString:script_source encoding:NSUTF8StringEncoding]]; lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; @@ -461,6 +498,7 @@ WaitForProcessToSIGSTOP (pid, 5); } } + ::unlink (unix_socket_name.c_str()); [applescript release]; return pid; } @@ -471,6 +509,7 @@ lldb::pid_t Host::LaunchInNewTerminal ( + const char *tty_name, const char **argv, const char **envp, const ArchSpec *arch_spec, @@ -479,7 +518,7 @@ ) { #if defined (LLDB_HOST_USE_APPLESCRIPT) - return LaunchInNewTerminalWithAppleScript (argv, envp, arch_spec, stop_at_entry, disable_aslr); + return LaunchInNewTerminalWithAppleScript (tty_name, argv, envp, arch_spec, stop_at_entry, disable_aslr); #else return LaunchInNewTerminalWithCommandFile (argv, envp, arch_spec, stop_at_entry, disable_aslr); #endif From johnny.chen at apple.com Tue Oct 19 18:40:14 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 19 Oct 2010 23:40:14 -0000 Subject: [Lldb-commits] [lldb] r116881 - in /lldb/trunk/test: lldbtest.py settings/TestSettings.py Message-ID: <20101019234014.1F02A2A6C12C@llvm.org> Author: johnny Date: Tue Oct 19 18:40:13 2010 New Revision: 116881 URL: http://llvm.org/viewvc/llvm-project?rev=116881&view=rev Log: Restoring the original setting should be done more robustly by adding a hook function to be run during tearDown() to effect the restore action instead of executing it inline during the test method, because the test may already fail and bailout before the inline restore action. Fix test_set_output_path() and pass_run_args_and_env_vars() to use this mechanism. Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=116881&r1=116880&r2=116881&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Oct 19 18:40:13 2010 @@ -424,6 +424,10 @@ self.__errored__ = False self.__failed__ = False + # See addTearDownHook(self, hook) which allows the client to add a hook + # function to be run during tearDown() time. + self.hooks = [] + def markError(self): """Callback invoked when we (the test case instance) errored.""" self.__errored__ = True @@ -465,10 +469,25 @@ self.dict = dictionary self.doTearDownCleanup = True + def addTearDownHook(self, hook): + """ + Add a function to be run during tearDown() time. + + Hooks are executed in a first come first serve manner. + """ + self.hooks.append(hook) + def tearDown(self): #import traceback #traceback.print_stack() + # Check and run any hook functions. + for hook in self.hooks: + #print "Executing hook:", hook + hook() + + self.runCmd("settings show") + # Terminate the current process being debugged, if any. if self.runStarted: self.runCmd("process kill", PROCESS_KILLED, check=False) @@ -478,6 +497,7 @@ del self.process del self.dbg + del self.hooks # Perform registered teardown cleanup. if doCleanup and self.doTearDownCleanup: Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=116881&r1=116880&r2=116881&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Tue Oct 19 18:40:13 2010 @@ -89,6 +89,11 @@ # Set the run-args and the env-vars. self.runCmd('settings set target.process.run-args A B C') self.runCmd('settings set target.process.env-vars ["MY_ENV_VAR"]=YES') + # And add hooks to restore the settings during tearDown(). + self.addTearDownHook( + lambda: self.runCmd("settings set -r target.process.run-args")) + self.addTearDownHook( + lambda: self.runCmd("settings set -r target.process.env-vars")) self.runCmd("run", RUN_SUCCEEDED) @@ -114,15 +119,17 @@ # Set the output-path and verify it is set. self.runCmd("settings set target.process.output-path 'stdout.txt'") + # And add a hook to restore original setting of target.process.output-path + # later on during tearDown(). + self.addTearDownHook( + lambda: self.runCmd("settings set -r target.process.output-path")) + self.expect("settings show target.process.output-path", SETTING_MSG("target.process.output-path"), startstr = "target.process.output-path (string) = 'stdout.txt'") self.runCmd("run", RUN_SUCCEEDED) - # Restore the original setting now that the program has been run. - self.runCmd("settings set -r target.process.output-path") - # The 'stdout.txt' file should now exist. self.assertTrue(os.path.isfile("stdout.txt"), "'stdout.txt' exists due to target.process.output-path.") From scallanan at apple.com Tue Oct 19 18:57:21 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 19 Oct 2010 23:57:21 -0000 Subject: [Lldb-commits] [lldb] r116884 - in /lldb/trunk: include/lldb/Expression/ClangUserExpression.h source/Expression/ClangUserExpression.cpp Message-ID: <20101019235721.A4DC22A6C12C@llvm.org> Author: spyffe Date: Tue Oct 19 18:57:21 2010 New Revision: 116884 URL: http://llvm.org/viewvc/llvm-project?rev=116884&view=rev Log: Fixed a silly bug that was causing the "this" pointer to be passed improperly to expressions in certain cases. Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=116884&r1=116883&r2=116884&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Tue Oct 19 18:57:21 2010 @@ -95,11 +95,11 @@ ThreadPlan * GetThreadPlanToExecuteJITExpression (Stream &error_stream, - ExecutionContext &exe_ctx); + ExecutionContext &exe_ctx); bool FinalizeJITExecution (Stream &error_stream, - ExecutionContext &exe_ctx, - ClangExpressionVariable *&result); + ExecutionContext &exe_ctx, + ClangExpressionVariable *&result); //------------------------------------------------------------------ /// Return the string that the parser should parse. Must be a full @@ -204,7 +204,7 @@ PrepareToExecuteJITExpression (Stream &error_stream, ExecutionContext &exe_ctx, lldb::addr_t &struct_address, - lldb::addr_t object_ptr); + lldb::addr_t &object_ptr); std::string m_expr_text; ///< The text of the expression, as typed by the user std::string m_transformed_text; ///< The text of the expression, as send to the parser Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=116884&r1=116883&r2=116884&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Oct 19 18:57:21 2010 @@ -216,9 +216,9 @@ bool ClangUserExpression::PrepareToExecuteJITExpression (Stream &error_stream, - ExecutionContext &exe_ctx, - lldb::addr_t &struct_address, - lldb::addr_t object_ptr) + ExecutionContext &exe_ctx, + lldb::addr_t &struct_address, + lldb::addr_t &object_ptr) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); From jingham at apple.com Tue Oct 19 19:39:53 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 20 Oct 2010 00:39:53 -0000 Subject: [Lldb-commits] [lldb] r116892 - in /lldb/trunk: include/lldb/Target/ source/API/ source/Core/ source/Expression/ source/Target/ Message-ID: <20101020003953.BEC312A6C12C@llvm.org> Author: jingham Date: Tue Oct 19 19:39:53 2010 New Revision: 116892 URL: http://llvm.org/viewvc/llvm-project?rev=116892&view=rev Log: Don't cache the public stop reason, since it can change as plan completion gets processed. That means GetStopReason needs to return a shared pointer, not a pointer to the thread's cached version. Also allow the thread plans to get and set the thread private stop reason - that is usually more appropriate for the logic the thread plans need to do. Modified: lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/include/lldb/Target/ThreadPlan.h lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadList.cpp lldb/trunk/source/Target/ThreadPlanBase.cpp lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp lldb/trunk/source/Target/ThreadPlanStepOut.cpp lldb/trunk/source/Target/ThreadPlanStepRange.cpp lldb/trunk/source/Target/ThreadPlanStepUntil.cpp lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Tue Oct 19 19:39:53 2010 @@ -235,15 +235,9 @@ virtual bool MatchesSpec (const ThreadSpec *spec); - StopInfo * + lldb::StopInfoSP GetStopInfo (); - void - SetStopInfo (lldb::StopInfoSP stop_info_sp) - { - m_public_stop_info_sp = stop_info_sp; - } - bool ThreadStoppedForAReason (); @@ -650,18 +644,22 @@ StackFrameList & GetStackFrameList (); + void + SetStopInfo (lldb::StopInfoSP stop_info_sp) + { + m_actual_stop_info_sp = stop_info_sp; + } + //------------------------------------------------------------------ // Classes that inherit from Process can see and modify these //------------------------------------------------------------------ Process & m_process; ///< The process that owns this thread. - lldb::StopInfoSP m_public_stop_info_sp; ///< The public stop reason for this thread lldb::StopInfoSP m_actual_stop_info_sp; ///< The private stop reason for this thread const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread for easy UI/command line access. lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this thread's current register state. lldb::StateType m_state; ///< The state of our process. mutable Mutex m_state_mutex; ///< Multithreaded protection for m_state. plan_stack m_plan_stack; ///< The stack of plans this thread is executing. - plan_stack m_immediate_plan_stack; ///< The plans that need to get executed before any other work gets done. plan_stack m_completed_plan_stack; ///< Plans that have been completed by this stop. They get deleted when the thread resumes. plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this stop. They get deleted when the thread resumes. std::auto_ptr m_curr_frames_ap; ///< The stack frames that get lazily populated after a thread stops. Modified: lldb/trunk/include/lldb/Target/ThreadPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlan.h?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlan.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlan.h Tue Oct 19 19:39:53 2010 @@ -18,6 +18,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/UserID.h" #include "lldb/Host/Mutex.h" +#include "lldb/Target/Thread.h" namespace lldb_private { @@ -40,20 +41,6 @@ // of the running process. // // -// DEPRECATED: This ended up causing a real hassle, too many cases where the immediate plan -// got stranded. So the better way to do this is to post any plans you need to do right before -// running in the PrepareToResume method. -//f -// Immediate Plans: -// -// One other complexity of the plan stack is that sometimes you need to do a piece of work immediately -// on resume, regardless of what other plans have been pushed on the stack while the process has -// been stopped. The classic example is stepping over a breakpoint. To that end the plan stack is -// actually two stacks, an "immediate" plan stack and the normal plan stack. A plan can indicate that it -// should go on the immediate plan stack by returning "true" from the IsImmediate method. -// -// END DEPRECATED... -// // Creating Plans: // // The thread plan is generally created and added to the plan stack through the QueueThreadPlanFor... API @@ -247,18 +234,6 @@ lldb::DescriptionLevel level) = 0; //------------------------------------------------------------------ - /// Returns whether this plan needs to be executed immediatly on resume. - /// - /// @return - /// \b true if the plan is immediate, \b false otherwise. - //------------------------------------------------------------------ - virtual bool - IsImmediate() const - { - return false; - } - - //------------------------------------------------------------------ /// Returns whether this plan could be successfully created. /// /// @param[in] error @@ -362,6 +337,21 @@ ThreadPlan * GetPreviousPlan (); + + // This forwards the private Thread::GetPrivateStopReason which is generally what + // ThreadPlan's need to know. + + lldb::StopInfoSP + GetPrivateStopReason() + { + return m_thread.GetPrivateStopReason(); + } + + void + SetStopInfo (lldb::StopInfoSP stop_reason_sp) + { + m_thread.SetStopInfo (stop_reason_sp); + } Thread &m_thread; lldb::Vote m_stop_vote; Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h Tue Oct 19 19:39:53 2010 @@ -31,10 +31,6 @@ virtual bool ShouldStop (Event *event_ptr); virtual bool StopOthers (); virtual lldb::StateType RunState (); - virtual bool IsImmediate () const - { - return false; - } virtual bool WillResume (lldb::StateType resume_state, bool current_plan); virtual bool WillStop (); virtual bool MischiefManaged (); Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Tue Oct 19 19:39:53 2010 @@ -81,9 +81,9 @@ { if (m_opaque_sp) { - lldb_private::StopInfo *stop_info = m_opaque_sp->GetStopInfo (); - if (stop_info) - return stop_info->GetStopReason(); + StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); + if (stop_info_sp) + return stop_info_sp->GetStopReason(); } return eStopReasonInvalid; } @@ -93,10 +93,10 @@ { if (m_opaque_sp) { - lldb_private::StopInfo *stop_info = m_opaque_sp->GetStopInfo (); - if (stop_info) + StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); + if (stop_info_sp) { - const char *stop_desc = stop_info->GetDescription(); + const char *stop_desc = stop_info_sp->GetDescription(); if (stop_desc) { if (dst) @@ -110,7 +110,7 @@ else { size_t stop_desc_len = 0; - switch (stop_info->GetStopReason()) + switch (stop_info_sp->GetStopReason()) { case eStopReasonTrace: case eStopReasonPlanComplete: @@ -139,7 +139,7 @@ case eStopReasonSignal: { - stop_desc = m_opaque_sp->GetProcess().GetUnixSignals ().GetSignalAsCString (stop_info->GetValue()); + stop_desc = m_opaque_sp->GetProcess().GetUnixSignals ().GetSignalAsCString (stop_info_sp->GetValue()); if (stop_desc == NULL || stop_desc[0] == '\0') { static char signal_desc[] = "signal"; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Tue Oct 19 19:39:53 2010 @@ -799,10 +799,10 @@ } else if (::strncmp (var_name_begin, "stop-reason}", strlen("stop-reason}")) == 0) { - lldb_private::StopInfo *stop_info = exe_ctx->thread->GetStopInfo (); - if (stop_info) + StopInfoSP stop_info_sp = exe_ctx->thread->GetStopInfo (); + if (stop_info_sp) { - cstr = stop_info->GetDescription(); + cstr = stop_info_sp->GetDescription(); if (cstr && cstr[0]) { s.PutCString(cstr); Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Tue Oct 19 19:39:53 2010 @@ -662,10 +662,10 @@ else ts.Printf("[ip unknown] "); - StopInfo *stop_info = thread->GetStopInfo(); - if (stop_info) + lldb::StopInfoSP stop_info_sp = thread->GetStopInfo(); + if (stop_info_sp) { - const char *stop_desc = stop_info->GetDescription(); + const char *stop_desc = stop_info_sp->GetDescription(); if (stop_desc) ts.PutCString (stop_desc); } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Oct 19 19:39:53 2010 @@ -1734,10 +1734,10 @@ { lldb::ThreadSP thread_sp = m_process_sp->GetThreadList().GetThreadAtIndex(idx); - StopInfo *stop_info = thread_sp->GetStopInfo (); - if (stop_info) + StopInfoSP stop_info_sp = thread_sp->GetStopInfo (); + if (stop_info_sp) { - stop_info->PerformAction(event_ptr); + stop_info_sp->PerformAction(event_ptr); } } Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Tue Oct 19 19:39:53 2010 @@ -44,14 +44,12 @@ UserID (tid), ThreadInstanceSettings (*(Thread::GetSettingsController().get())), m_process (process), - m_public_stop_info_sp (), m_actual_stop_info_sp (), m_index_id (process.GetNextThreadIndexID ()), m_reg_context_sp (), m_state (eStateUnloaded), m_state_mutex (Mutex::eMutexTypeRecursive), m_plan_stack (), - m_immediate_plan_stack(), m_completed_plan_stack(), m_curr_frames_ap (), m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER), @@ -99,18 +97,14 @@ m_resume_state = state; } -StopInfo * +lldb::StopInfoSP Thread::GetStopInfo () { - if (m_public_stop_info_sp.get() == NULL) - { - ThreadPlanSP plan_sp (GetCompletedPlan()); - if (plan_sp) - m_public_stop_info_sp = StopInfo::CreateStopReasonWithPlan (plan_sp); - else - m_public_stop_info_sp = GetPrivateStopReason (); - } - return m_public_stop_info_sp.get(); + ThreadPlanSP plan_sp (GetCompletedPlan()); + if (plan_sp) + return StopInfo::CreateStopReasonWithPlan (plan_sp); + else + return GetPrivateStopReason (); } bool @@ -210,7 +204,6 @@ plan_ptr->WillResume (resume_state, false); } - m_public_stop_info_sp.reset(); m_actual_stop_info_sp.reset(); return true; } @@ -353,10 +346,7 @@ { if (thread_plan_sp) { - if (thread_plan_sp->IsImmediate()) - m_immediate_plan_stack.push_back (thread_plan_sp); - else - m_plan_stack.push_back (thread_plan_sp); + m_plan_stack.push_back (thread_plan_sp); thread_plan_sp->DidPush(); @@ -365,10 +355,9 @@ { StreamString s; thread_plan_sp->GetDescription (&s, lldb::eDescriptionLevelFull); - log->Printf("Pushing plan: \"%s\", tid = 0x%4.4x, immediate = %s.", + log->Printf("Pushing plan: \"%s\", tid = 0x%4.4x.", s.GetData(), - thread_plan_sp->GetThread().GetID(), - thread_plan_sp->IsImmediate() ? "true" : "false"); + thread_plan_sp->GetThread().GetID()); } } } @@ -378,17 +367,7 @@ { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); - if (!m_immediate_plan_stack.empty()) - { - ThreadPlanSP &plan = m_immediate_plan_stack.back(); - if (log) - { - log->Printf("Popping plan: \"%s\", tid = 0x%4.4x, immediate = true.", plan->GetName(), plan->GetThread().GetID()); - } - plan->WillPop(); - m_immediate_plan_stack.pop_back(); - } - else if (m_plan_stack.empty()) + if (m_plan_stack.empty()) return; else { @@ -418,9 +397,7 @@ ThreadPlan * Thread::GetCurrentPlan () { - if (!m_immediate_plan_stack.empty()) - return m_immediate_plan_stack.back().get(); - else if (m_plan_stack.empty()) + if (m_plan_stack.empty()) return NULL; else return m_plan_stack.back().get(); @@ -488,22 +465,6 @@ if (stack_size > 0 && m_completed_plan_stack[0].get() == current_plan) { - if (m_immediate_plan_stack.size() > 0) - return m_immediate_plan_stack.back().get(); - else if (m_plan_stack.size() > 0) - return m_plan_stack.back().get(); - else - return NULL; - } - - stack_size = m_immediate_plan_stack.size(); - for (int i = stack_size - 1; i > 0; i--) - { - if (current_plan == m_immediate_plan_stack[i].get()) - return m_immediate_plan_stack[i-1].get(); - } - if (stack_size > 0 && m_immediate_plan_stack[0].get() == current_plan) - { if (m_plan_stack.size() > 0) return m_plan_stack.back().get(); else @@ -751,17 +712,6 @@ s->EOL(); } - stack_size = m_immediate_plan_stack.size(); - s->Printf ("Immediate Plan Stack: %d elements.\n", stack_size); - for (i = stack_size - 1; i >= 0; i--) - { - s->Printf ("Element %d: ", i); - s->IndentMore(); - m_immediate_plan_stack[i]->GetDescription (s, eDescriptionLevelFull); - s->IndentLess(); - s->EOL(); - } - stack_size = m_completed_plan_stack.size(); s->Printf ("Completed Plan Stack: %d elements.\n", stack_size); for (i = stack_size - 1; i >= 0; i--) Modified: lldb/trunk/source/Target/ThreadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadList.cpp (original) +++ lldb/trunk/source/Target/ThreadList.cpp Tue Oct 19 19:39:53 2010 @@ -430,15 +430,7 @@ for (pos = m_threads.begin(); pos != end; ++pos) { ThreadSP thread_sp(*pos); - if (thread_sp->GetCurrentPlan()->IsImmediate()) - { - // We first do all the immediate plans, so if we find one, set - // immediate_thread_sp and break out, and we'll pick it up first thing - // when we're negotiating which threads get to run. - immediate_thread_sp = thread_sp; - break; - } - else if (thread_sp->GetResumeState() != eStateSuspended && + if (thread_sp->GetResumeState() != eStateSuspended && thread_sp->GetCurrentPlan()->StopOthers()) { // You can't say "stop others" and also want yourself to be suspended. Modified: lldb/trunk/source/Target/ThreadPlanBase.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanBase.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanBase.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanBase.cpp Tue Oct 19 19:39:53 2010 @@ -67,10 +67,10 @@ m_stop_vote = eVoteYes; m_run_vote = eVoteYes; - StopInfo *stop_info = m_thread.GetStopInfo(); - if (stop_info) + StopInfoSP stop_info_sp = GetPrivateStopReason(); + if (stop_info_sp) { - StopReason reason = stop_info->GetStopReason(); + StopReason reason = stop_info_sp->GetStopReason(); switch (reason) { case eStopReasonInvalid: @@ -80,7 +80,7 @@ return false; case eStopReasonBreakpoint: - if (stop_info->ShouldStop(event_ptr)) + if (stop_info_sp->ShouldStop(event_ptr)) { // If we are going to stop for a breakpoint, then unship the other plans // at this point. Don't force the discard, however, so Master plans can stay @@ -92,7 +92,7 @@ // don't report this stop or the subsequent running event. // Otherwise we will post the stopped & running, but the stopped event will get marked // with "restarted" so the UI will know to wait and expect the consequent "running". - if (stop_info->ShouldNotify (event_ptr)) + if (stop_info_sp->ShouldNotify (event_ptr)) { m_stop_vote = eVoteYes; m_run_vote = eVoteYes; @@ -115,7 +115,7 @@ return true; case eStopReasonSignal: - if (stop_info->ShouldStop(event_ptr)) + if (stop_info_sp->ShouldStop(event_ptr)) { m_thread.DiscardThreadPlans(false); return true; @@ -124,7 +124,7 @@ { // We're not going to stop, but while we are here, let's figure out // whether to report this. - if (stop_info->ShouldNotify(event_ptr)) + if (stop_info_sp->ShouldNotify(event_ptr)) m_stop_vote = eVoteYes; else m_stop_vote = eVoteNo; Modified: lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp Tue Oct 19 19:39:53 2010 @@ -84,10 +84,10 @@ bool ThreadPlanStepInstruction::PlanExplainsStop () { - StopInfo *stop_info = m_thread.GetStopInfo(); - if (stop_info) + StopInfoSP stop_info_sp = GetPrivateStopReason(); + if (stop_info_sp) { - StopReason reason = stop_info->GetStopReason(); + StopReason reason = stop_info_sp->GetStopReason(); if (reason == eStopReasonTrace || reason == eStopReasonNone) return true; else Modified: lldb/trunk/source/Target/ThreadPlanStepOut.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOut.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOut.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOut.cpp Tue Oct 19 19:39:53 2010 @@ -104,16 +104,16 @@ { // We don't explain signals or breakpoints (breakpoints that handle stepping in or // out will be handled by a child plan. - StopInfo *stop_info = m_thread.GetStopInfo(); - if (stop_info) + StopInfoSP stop_info_sp = GetPrivateStopReason(); + if (stop_info_sp) { - StopReason reason = stop_info->GetStopReason(); + StopReason reason = stop_info_sp->GetStopReason(); switch (reason) { case eStopReasonBreakpoint: { // If this is OUR breakpoint, we're fine, otherwise we don't know why this happened... - BreakpointSiteSP site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (stop_info->GetValue())); + BreakpointSiteSP site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (stop_info_sp->GetValue())); if (site_sp && site_sp->IsBreakpointAtThisSite (m_return_bp_id)) { // If there was only one owner, then we're done. But if we also hit some Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Tue Oct 19 19:39:53 2010 @@ -62,10 +62,10 @@ { // We don't explain signals or breakpoints (breakpoints that handle stepping in or // out will be handled by a child plan. - StopInfo *stop_info = m_thread.GetStopInfo(); - if (stop_info) + StopInfoSP stop_info_sp = GetPrivateStopReason(); + if (stop_info_sp) { - StopReason reason = stop_info->GetStopReason(); + StopReason reason = stop_info_sp->GetStopReason(); switch (reason) { Modified: lldb/trunk/source/Target/ThreadPlanStepUntil.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepUntil.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepUntil.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepUntil.cpp Tue Oct 19 19:39:53 2010 @@ -170,20 +170,20 @@ if (m_ran_analyze) return; - StopInfo *stop_info = m_thread.GetStopInfo(); + StopInfoSP stop_info_sp = GetPrivateStopReason(); m_should_stop = true; m_explains_stop = false; - if (stop_info) + if (stop_info_sp) { - StopReason reason = stop_info->GetStopReason(); + StopReason reason = stop_info_sp->GetStopReason(); switch (reason) { case eStopReasonBreakpoint: { // If this is OUR breakpoint, we're fine, otherwise we don't know why this happened... - BreakpointSiteSP this_site = m_thread.GetProcess().GetBreakpointSiteList().FindByID (stop_info->GetValue()); + BreakpointSiteSP this_site = m_thread.GetProcess().GetBreakpointSiteList().FindByID (stop_info_sp->GetValue()); if (!this_site) { m_explains_stop = false; @@ -275,8 +275,8 @@ // do so here. Otherwise, as long as this thread has stopped for a reason, // we will stop. - StopInfo *stop_info = m_thread.GetStopInfo (); - if (stop_info == NULL || stop_info->GetStopReason() == eStopReasonNone) + StopInfoSP stop_info_sp = GetPrivateStopReason(); + if (stop_info_sp == NULL || stop_info_sp->GetStopReason() == eStopReasonNone) return false; AnalyzeStop(); Modified: lldb/trunk/source/Target/ThreadPlanTestCondition.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTestCondition.cpp?rev=116892&r1=116891&r2=116892&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTestCondition.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Tue Oct 19 19:39:53 2010 @@ -110,9 +110,9 @@ Process::ProcessEventData *new_data = new Process::ProcessEventData (m_thread.GetProcess().GetSP(), eStateStopped); event_ptr->SetData(new_data); event_ptr->SetType(Process::eBroadcastBitStateChanged); - m_thread.SetStopInfo(StopInfo::CreateStopReasonWithBreakpointSiteID (m_thread, - m_break_loc_sp->GetBreakpointSite()->GetID(), - m_did_stop)); + SetStopInfo(StopInfo::CreateStopReasonWithBreakpointSiteID (m_thread, + m_break_loc_sp->GetBreakpointSite()->GetID(), + m_did_stop)); if (m_did_stop) { Process::ProcessEventData::SetRestartedInEvent (event_ptr, false); From johnny.chen at apple.com Tue Oct 19 20:03:01 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 20 Oct 2010 01:03:01 -0000 Subject: [Lldb-commits] [lldb] r116895 - /lldb/trunk/source/Core/UserSettingsController.cpp Message-ID: <20101020010301.2B72F2A6C12C@llvm.org> Author: johnny Date: Tue Oct 19 20:03:00 2010 New Revision: 116895 URL: http://llvm.org/viewvc/llvm-project?rev=116895&view=rev Log: For UserSettingsController::UpdateDictionaryVariable(), clear the dictionary if passed in a NULL new_value and the operation intended is eVarSetOperationAssign. This fixed a bug where in TestSettings.py: # Set the run-args and the env-vars. self.runCmd('settings set target.process.run-args A B C') self.runCmd('settings set target.process.env-vars ["MY_ENV_VAR"]=YES') # And add hooks to restore the settings during tearDown(). self.addTearDownHook( lambda: self.runCmd("settings set -r target.process.run-args")) self.addTearDownHook( lambda: self.runCmd("settings set -r target.process.env-vars")) "settings set -r target.process.env-vars" was not restoring the original env-vars setting. Modified: lldb/trunk/source/Core/UserSettingsController.cpp Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=116895&r1=116894&r2=116895&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Tue Oct 19 20:03:00 2010 @@ -2079,6 +2079,12 @@ case lldb::eVarSetOperationAppend: case lldb::eVarSetOperationAssign: { + // Clear the dictionary if it's an assign with new_value as NULL. + if (new_value == NULL && op == lldb::eVarSetOperationAssign) + { + dictionary.clear (); + break; + } Args args (new_value); size_t num_args = args.GetArgumentCount(); for (size_t i = 0; i < num_args; ++i) From jingham at apple.com Tue Oct 19 22:36:33 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 20 Oct 2010 03:36:33 -0000 Subject: [Lldb-commits] [lldb] r116908 - in /lldb/trunk/source/Breakpoint: Breakpoint.cpp BreakpointLocationList.cpp Message-ID: <20101020033633.3F8BB2A6C12C@llvm.org> Author: jingham Date: Tue Oct 19 22:36:33 2010 New Revision: 116908 URL: http://llvm.org/viewvc/llvm-project?rev=116908&view=rev Log: Don't re-insert disabled breakpoint locations. Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=116908&r1=116907&r2=116908&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original) +++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Tue Oct 19 22:36:33 2010 @@ -290,6 +290,8 @@ for (size_t j = 0; j < m_locations.GetSize(); j++) { BreakpointLocationSP break_loc = m_locations.GetByIndex(j); + if (!break_loc->IsEnabled()) + continue; const Section *section = break_loc->GetAddress().GetSection(); if (section == NULL || section->GetModule() == module) { Modified: lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp?rev=116908&r1=116907&r2=116908&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Tue Oct 19 22:36:33 2010 @@ -260,7 +260,10 @@ collection::iterator pos, end = m_locations.end(); for (pos = m_locations.begin(); pos != end; ++pos) - (*pos)->ResolveBreakpointSite(); + { + if ((*pos)->IsEnabled()) + (*pos)->ResolveBreakpointSite(); + } } uint32_t From johnny.chen at apple.com Wed Oct 20 12:26:59 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 20 Oct 2010 17:26:59 -0000 Subject: [Lldb-commits] [lldb] r116936 - /lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py Message-ID: <20101020172659.C64082A6C12C@llvm.org> Author: johnny Date: Wed Oct 20 12:26:59 2010 New Revision: 116936 URL: http://llvm.org/viewvc/llvm-project?rev=116936&view=rev Log: Fix wrong test logic with regard to hit count and resolved status of disabled/enabled breakpoints. Modified: lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py Modified: lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py?rev=116936&r1=116935&r2=116936&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py (original) +++ lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py Wed Oct 20 12:26:59 2010 @@ -84,11 +84,11 @@ self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, substrs = ["stop reason = breakpoint 1."]) - # At this point, the 3 locations should all have "hit count = 2". - self.expect("breakpoint list", "Expect all 3 breakpoints with hit count of 2", - patterns = ["1\.1: .+ resolved, hit count = 2 +Options: disabled", - "1\.2: .+ resolved, hit count = 2", - "1\.3: .+ resolved, hit count = 2"]) + # At this point, 1.1 has a hit count of 0 and the other a hit count of 1". + self.expect("breakpoint list", "The breakpoints should report correct hit counts", + patterns = ["1\.1: .+ unresolved, hit count = 0 +Options: disabled", + "1\.2: .+ resolved, hit count = 1", + "1\.3: .+ resolved, hit count = 1"]) if __name__ == '__main__': From johnny.chen at apple.com Wed Oct 20 13:12:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 20 Oct 2010 18:12:58 -0000 Subject: [Lldb-commits] [lldb] r116938 - /lldb/trunk/test/lldbtest.py Message-ID: <20101020181258.8C8D62A6C12C@llvm.org> Author: johnny Date: Wed Oct 20 13:12:58 2010 New Revision: 116938 URL: http://llvm.org/viewvc/llvm-project?rev=116938&view=rev Log: Clean up the teardown logic to make it more robust and to record the additions and invocations of them into session object. Remove a debug statement. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=116938&r1=116937&r2=116938&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Oct 20 13:12:58 2010 @@ -475,7 +475,11 @@ Hooks are executed in a first come first serve manner. """ - self.hooks.append(hook) + if callable(hook): + with recording(self, traceAlways) as sbuf: + import inspect + print >> sbuf, "Adding tearDown hook:", inspect.getsource(hook) + self.hooks.append(hook) def tearDown(self): #import traceback @@ -483,11 +487,11 @@ # Check and run any hook functions. for hook in self.hooks: - #print "Executing hook:", hook + with recording(self, traceAlways) as sbuf: + import inspect + print >> sbuf, "Executing tearDown hook:", inspect.getsource(hook) hook() - self.runCmd("settings show") - # Terminate the current process being debugged, if any. if self.runStarted: self.runCmd("process kill", PROCESS_KILLED, check=False) From johnny.chen at apple.com Wed Oct 20 13:38:48 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 20 Oct 2010 18:38:48 -0000 Subject: [Lldb-commits] [lldb] r116939 - in /lldb/trunk/test: breakpoint_conditions/TestBreakpointConditions.py breakpoint_conditions/main.c lldbtest.py Message-ID: <20101020183848.E3C8C2A6C12C@llvm.org> Author: johnny Date: Wed Oct 20 13:38:48 2010 New Revision: 116939 URL: http://llvm.org/viewvc/llvm-project?rev=116939&view=rev Log: Make the breakpoint condition test more robust with regard to checking the correct parent call frame information. And comment out the check for stop reason for the time being. The stop reason disappeared from the "thread backtrace" output for breakpoint stop with condition. Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py lldb/trunk/test/breakpoint_conditions/main.c lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=116939&r1=116938&r2=116939&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Wed Oct 20 13:38:48 2010 @@ -27,7 +27,8 @@ # Call super's setUp(). TestBase.setUp(self) # Find the line number to of function 'c'. - self.line = line_number('main.c', '// Find the line number of function "c" here.') + self.line1 = line_number('main.c', '// Find the line number of function "c" here.') + self.line2 = line_number('main.c', "// Find the line number of c's parent call here.") def breakpoint_conditions(self): """Exercise breakpoint condition with 'breakpoint modify -c id'.""" @@ -55,10 +56,11 @@ "hit count = 3"]) # The frame #0 should correspond to main.c:36, the executable statement - # in function name 'c'. - self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, - substrs = ["stop reason = breakpoint"], - patterns = ["frame #0.*main.c:%d" % self.line]) + # in function name 'c'. And the parent frame should point to main.c:24. + self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT_CONDITION, + #substrs = ["stop reason = breakpoint"], + patterns = ["frame #0.*main.c:%d" % self.line1, + "frame #1.*main.c:%d" % self.line2]) if __name__ == '__main__': Modified: lldb/trunk/test/breakpoint_conditions/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/main.c?rev=116939&r1=116938&r2=116939&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/main.c (original) +++ lldb/trunk/test/breakpoint_conditions/main.c Wed Oct 20 13:38:48 2010 @@ -21,7 +21,7 @@ if (val <= 1) return b(val); else if (val >= 3) - return c(val); + return c(val); // Find the line number of c's parent call here. return val; } Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=116939&r1=116938&r2=116939&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Oct 20 13:38:48 2010 @@ -153,6 +153,8 @@ STOPPED_DUE_TO_BREAKPOINT = "Process state is stopped due to breakpoint" +STOPPED_DUE_TO_BREAKPOINT_CONDITION = "Stopped due to breakpoint condition" + STOPPED_DUE_TO_SIGNAL = "Process state is stopped due to signal" STOPPED_DUE_TO_STEP_IN = "Process state is stopped due to step in" From johnny.chen at apple.com Wed Oct 20 13:51:02 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 20 Oct 2010 18:51:02 -0000 Subject: [Lldb-commits] [lldb] r116941 - /lldb/trunk/test/class_types/TestClassTypes.py Message-ID: <20101020185102.0B3882A6C12C@llvm.org> Author: johnny Date: Wed Oct 20 13:51:01 2010 New Revision: 116941 URL: http://llvm.org/viewvc/llvm-project?rev=116941&view=rev Log: Remove the two @expectedFailure decorators as the bug has been fixed on tot. Modified: lldb/trunk/test/class_types/TestClassTypes.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=116941&r1=116940&r2=116941&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Wed Oct 20 13:51:01 2010 @@ -36,7 +36,6 @@ self.breakpoint_creation_by_filespec_python() @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @unittest2.expectedFailure # rdar://problem/8557478 # test/class_types test failures: runCmd: expr this->m_c_int def test_with_dsym_and_expr_parser(self): @@ -44,7 +43,6 @@ self.buildDsym() self.class_types_expr_parser() - @unittest2.expectedFailure # rdar://problem/8557478 # test/class_types test failures: runCmd: expr this->m_c_int def test_with_dwarf_and_expr_parser(self): From gclayton at apple.com Wed Oct 20 15:54:39 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 20 Oct 2010 20:54:39 -0000 Subject: [Lldb-commits] [lldb] r116944 - in /lldb/trunk: include/lldb/API/ include/lldb/Core/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Host/common/ source/Host/macosx/ source/Interpreter/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/ObjectFile/ELF/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ Message-ID: <20101020205439.EA7E02A6C12C@llvm.org> Author: gclayton Date: Wed Oct 20 15:54:39 2010 New Revision: 116944 URL: http://llvm.org/viewvc/llvm-project?rev=116944&view=rev Log: Fixed an issue where we were resolving paths when we should have been. So the issue here was that we have lldb_private::FileSpec that by default was always resolving a path when using the: FileSpec::FileSpec (const char *path); and in the: void FileSpec::SetFile(const char *pathname, bool resolve = true); This isn't what we want in many many cases. One example is you have "/tmp" on your file system which is really "/private/tmp". You compile code in that directory and end up with debug info that mentions "/tmp/file.c". Then you type: (lldb) breakpoint set --file file.c --line 5 If your current working directory is "/tmp", then "file.c" would be turned into "/private/tmp/file.c" which won't match anything in the debug info. Also, it should have been just a FileSpec with no directory and a filename of "file.c" which could (and should) potentially match any instances of "file.c" in the debug info. So I removed the constructor that just takes a path: FileSpec::FileSpec (const char *path); // REMOVED You must now use the other constructor that has a "bool resolve" parameter that you must always supply: FileSpec::FileSpec (const char *path, bool resolve); I also removed the default parameter to SetFile(): void FileSpec::SetFile(const char *pathname, bool resolve); And fixed all of the code to use the right settings. Modified: lldb/trunk/include/lldb/API/SBFileSpec.h lldb/trunk/include/lldb/Core/FileSpec.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBFileSpec.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Commands/CommandCompletions.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Core/FileSpec.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Host/macosx/Symbols.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Symbol/CompileUnit.cpp lldb/trunk/source/Symbol/ObjectFile.cpp Modified: lldb/trunk/include/lldb/API/SBFileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) +++ lldb/trunk/include/lldb/API/SBFileSpec.h Wed Oct 20 15:54:39 2010 @@ -21,7 +21,9 @@ SBFileSpec (const lldb::SBFileSpec &rhs); - SBFileSpec (const char *path); + SBFileSpec (const char *path);// Deprected, use SBFileSpec (const char *path, bool resolve) + + SBFileSpec (const char *path, bool resolve); ~SBFileSpec (); Modified: lldb/trunk/include/lldb/Core/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpec.h (original) +++ lldb/trunk/include/lldb/Core/FileSpec.h Wed Oct 20 15:54:39 2010 @@ -53,23 +53,11 @@ FileSpec(); //------------------------------------------------------------------ - /// Default constructor. + /// Constructor with path. /// - /// Takes an optional full path to a file. If \a path is valid, - /// this function will call FileSpec::SetFile (\a path). - /// - /// @param[in] path - /// The full or partial path to a file. - /// - /// @see FileSpec::SetFile () - //------------------------------------------------------------------ - explicit FileSpec (const char *path); - - //------------------------------------------------------------------ - /// Default constructor. - /// - /// Takes an optional full path to a file. If \a path is valid, - /// this function will call FileSpec::SetFile (\a path). + /// Takes an path to a file which can be just a filename, or a full + /// path. If \a path is not NULL or empty, this function will call + /// FileSpec::SetFile (const char *path, bool resolve). /// /// @param[in] path /// The full or partial path to a file. @@ -78,7 +66,7 @@ /// If \b true, then we resolve the path with realpath, /// if \b false we trust the path is in canonical form already. /// - /// @see FileSpec::SetFile () + /// @see FileSpec::SetFile (const char *path, bool resolve) //------------------------------------------------------------------ explicit FileSpec (const char *path, bool resolve_path); @@ -463,7 +451,7 @@ /// the static FileSpec::Resolve. //------------------------------------------------------------------ void - SetFile (const char *path, bool resolve = true); + SetFile (const char *path, bool resolve); //------------------------------------------------------------------ /// Read the file into an array of strings, one per line. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Oct 20 15:54:39 2010 @@ -2976,7 +2976,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_UNUSED_VARIABLE = YES; - ONLY_ACTIVE_ARCH = YES; + ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; VALID_ARCHS = "x86_64 i386"; }; Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Wed Oct 20 15:54:39 2010 @@ -381,7 +381,7 @@ if (m_opaque_sp) { ArchSpec arch; - FileSpec file_spec (filename); + FileSpec file_spec (filename, true); arch.SetArchFromTargetTriple(target_triple); TargetSP target_sp; Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file_spec, arch, NULL, true, target_sp)); @@ -396,7 +396,7 @@ SBTarget target; if (m_opaque_sp) { - FileSpec file (filename); + FileSpec file (filename, true); ArchSpec arch = lldb_private::Target::GetDefaultArchitecture (); TargetSP target_sp; Error error; @@ -439,7 +439,7 @@ SBTarget target; if (m_opaque_sp) { - FileSpec file (filename); + FileSpec file (filename, true); ArchSpec arch = lldb_private::Target::GetDefaultArchitecture (); TargetSP target_sp; Error error; @@ -495,7 +495,7 @@ ArchSpec arch; if (arch_name) arch.SetArch(arch_name); - TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename), arch_name ? &arch : NULL)); + TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename, false), arch_name ? &arch : NULL)); sb_target.reset(target_sp); } return sb_target; Modified: lldb/trunk/source/API/SBFileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/API/SBFileSpec.cpp (original) +++ lldb/trunk/source/API/SBFileSpec.cpp Wed Oct 20 15:54:39 2010 @@ -28,8 +28,14 @@ m_opaque_ap.reset (new FileSpec (rhs.get())); } +// Deprected!!! SBFileSpec::SBFileSpec (const char *path) : - m_opaque_ap(new FileSpec (path)) + m_opaque_ap(new FileSpec (path, true)) +{ +} + +SBFileSpec::SBFileSpec (const char *path, bool resolve) : + m_opaque_ap(new FileSpec (path, resolve)) { } Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Wed Oct 20 15:54:39 2010 @@ -355,7 +355,7 @@ { if (module_name && module_name[0]) { - FileSpec module_file_spec(module_name); + FileSpec module_file_spec(module_name, false); *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); } else @@ -376,7 +376,7 @@ if (module_name && module_name[0]) { - FileSpec module_file_spec(module_name); + FileSpec module_file_spec(module_name, false); *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, regexp, false); } @@ -523,7 +523,7 @@ ModuleSP module_sp; if (module_name != NULL) { - FileSpec module_file_spec (module_name); + FileSpec module_file_spec (module_name, false); module_sp = m_opaque_sp->GetImages().FindFirstModuleForFileSpec (module_file_spec, NULL); } @@ -602,7 +602,7 @@ ModuleSP module_sp; if (module_name != NULL) { - FileSpec module_file_spec (module_name); + FileSpec module_file_spec (module_name, false); module_sp = m_opaque_sp->GetImages().FindFirstModuleForFileSpec (module_file_spec, NULL); } Modified: lldb/trunk/source/Commands/CommandCompletions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) +++ lldb/trunk/source/Commands/CommandCompletions.cpp Wed Oct 20 15:54:39 2010 @@ -469,7 +469,7 @@ m_include_support_files (include_support_files), m_matching_files() { - FileSpec partial_spec (m_completion_str.c_str()); + FileSpec partial_spec (m_completion_str.c_str(), false); m_file_name = partial_spec.GetFilename().GetCString(); m_dir_name = partial_spec.GetDirectory().GetCString(); } @@ -661,7 +661,7 @@ ) : CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches) { - FileSpec partial_spec (m_completion_str.c_str()); + FileSpec partial_spec (m_completion_str.c_str(), false); m_file_name = partial_spec.GetFilename().GetCString(); m_dir_name = partial_spec.GetDirectory().GetCString(); } Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Wed Oct 20 15:54:39 2010 @@ -307,7 +307,7 @@ ModuleSP module_sp = target->GetExecutableModule(); Breakpoint *bp = NULL; - FileSpec module; + FileSpec module_spec; bool use_module = false; int num_modules = m_options.m_modules.size(); @@ -354,15 +354,15 @@ } else { - file.SetFile(m_options.m_filename.c_str()); + file.SetFile(m_options.m_filename.c_str(), false); } if (use_module) { for (int i = 0; i < num_modules; ++i) { - module.SetFile(m_options.m_modules[i].c_str()); - bp = target->CreateBreakpoint (&module, + module_spec.SetFile(m_options.m_modules[i].c_str(), false); + bp = target->CreateBreakpoint (&module_spec, file, m_options.m_line_num, m_options.m_ignore_inlines).get(); @@ -405,8 +405,11 @@ { for (int i = 0; i < num_modules; ++i) { - module.SetFile(m_options.m_modules[i].c_str()); - bp = target->CreateBreakpoint (&module, m_options.m_func_name.c_str(), name_type_mask, Breakpoint::Exact).get(); + module_spec.SetFile(m_options.m_modules[i].c_str(), false); + bp = target->CreateBreakpoint (&module_spec, + m_options.m_func_name.c_str(), + name_type_mask, + Breakpoint::Exact).get(); if (bp) { StreamString &output_stream = result.GetOutputStream(); @@ -435,8 +438,8 @@ { for (int i = 0; i < num_modules; ++i) { - module.SetFile(m_options.m_modules[i].c_str()); - bp = target->CreateBreakpoint (&module, regexp).get(); + module_spec.SetFile(m_options.m_modules[i].c_str(), false); + bp = target->CreateBreakpoint (&module_spec, regexp).get(); if (bp) { StreamString &output_stream = result.GetOutputStream(); Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Oct 20 15:54:39 2010 @@ -70,7 +70,7 @@ result.AppendMessageWithFormat ("Executing commands in '%s'.\n", filename); - FileSpec cmd_file (filename); + FileSpec cmd_file (filename, false); if (cmd_file.Exists()) { STLStringArray commands; Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Wed Oct 20 15:54:39 2010 @@ -127,7 +127,7 @@ const int argc = command.GetArgumentCount(); if (argc == 1) { - FileSpec file_spec (file_path); + FileSpec file_spec (file_path, true); if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation()) { Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Wed Oct 20 15:54:39 2010 @@ -656,7 +656,7 @@ const char *arg_cstr; for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx) { - FileSpec image_file(arg_cstr); + FileSpec image_file(arg_cstr, false); ModuleList matching_modules; size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules); @@ -861,7 +861,7 @@ const char *arg_cstr; for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx) { - FileSpec image_file(arg_cstr); + FileSpec image_file(arg_cstr, false); ModuleList matching_modules; size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules); @@ -969,7 +969,7 @@ const char *arg_cstr; for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx) { - FileSpec image_file(arg_cstr); + FileSpec image_file(arg_cstr, false); ModuleList matching_modules; size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules); @@ -1062,7 +1062,7 @@ const char *arg_cstr; for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx) { - FileSpec file_spec(arg_cstr); + FileSpec file_spec(arg_cstr, false); const uint32_t num_modules = target->GetImages().GetSize(); if (num_modules > 0) { @@ -1381,7 +1381,7 @@ break; case 'f': - m_file.SetFile (option_arg); + m_file.SetFile (option_arg, false); m_type = eLookupTypeFileLine; break; @@ -1627,7 +1627,7 @@ const char *arg_cstr; for (i = 0; (arg_cstr = command.GetArgumentAtIndex(i)) != NULL && syntax_error == false; ++i) { - FileSpec image_file(arg_cstr); + FileSpec image_file(arg_cstr, false); ModuleList matching_modules; size_t num_matching_modules = target->GetImages().FindModules(&image_file, NULL, NULL, NULL, matching_modules); Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Wed Oct 20 15:54:39 2010 @@ -143,7 +143,7 @@ break; case 'o': - m_outfile_filespec.SetFile (option_arg); + m_outfile_filespec.SetFile (option_arg, true); break; case 'b': @@ -462,7 +462,7 @@ break; case 'i': - m_infile.SetFile (option_arg); + m_infile.SetFile (option_arg, true); if (!m_infile.Exists()) { m_infile.Clear(); Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Wed Oct 20 15:54:39 2010 @@ -297,7 +297,7 @@ ModuleList matching_modules; for (unsigned i = 0, e = m_options.m_modules.size(); i != e; i++) { - FileSpec module_spec(m_options.m_modules[i].c_str()); + FileSpec module_spec(m_options.m_modules[i].c_str(), false); if (module_spec) { matching_modules.Clear(); @@ -471,7 +471,7 @@ ModuleList matching_modules; for (unsigned i = 0, e = m_options.m_modules.size(); i != e; i++) { - FileSpec module_spec(m_options.m_modules[i].c_str()); + FileSpec module_spec(m_options.m_modules[i].c_str(), false); if (module_spec) { matching_modules.Clear(); Modified: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp Wed Oct 20 15:54:39 2010 @@ -174,18 +174,6 @@ // Default constructor that can take an optional full path to a // file on disk. //------------------------------------------------------------------ -FileSpec::FileSpec(const char *pathname) : - m_directory(), - m_filename() -{ - if (pathname && pathname[0]) - SetFile(pathname); -} - -//------------------------------------------------------------------ -// Default constructor that can take an optional full path to a -// file on disk. -//------------------------------------------------------------------ FileSpec::FileSpec(const char *pathname, bool resolve_path) : m_directory(), m_filename() @@ -447,7 +435,7 @@ bool FileSpec::ResolveExecutableLocation () { - if (m_directory.GetLength() == 0) + if (!m_directory) { const std::string file_str (m_filename.AsCString()); llvm::sys::Path path = llvm::sys::Program::FindProgramByName (file_str); @@ -465,7 +453,7 @@ { // If FindProgramByName found the file, it returns the directory + filename in its return results. // We need to separate them. - FileSpec tmp_file (dir_ref.data()); + FileSpec tmp_file (dir_ref.data(), false); if (tmp_file.Exists()) { m_directory = tmp_file.m_directory; Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Wed Oct 20 15:54:39 2010 @@ -241,9 +241,16 @@ } uint32_t -Module::ResolveSymbolContextForFilePath (const char *file_path, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) +Module::ResolveSymbolContextForFilePath +( + const char *file_path, + uint32_t line, + bool check_inlines, + uint32_t resolve_scope, + SymbolContextList& sc_list +) { - FileSpec file_spec(file_path); + FileSpec file_spec(file_path, false); return ResolveSymbolContextsForFileSpec (file_spec, line, check_inlines, resolve_scope, sc_list); } Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Wed Oct 20 15:54:39 2010 @@ -405,9 +405,16 @@ } uint32_t -ModuleList::ResolveSymbolContextForFilePath (const char *file_path, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) +ModuleList::ResolveSymbolContextForFilePath +( + const char *file_path, + uint32_t line, + bool check_inlines, + uint32_t resolve_scope, + SymbolContextList& sc_list +) { - FileSpec file_spec(file_path); + FileSpec file_spec(file_path, false); return ResolveSymbolContextsForFileSpec (file_spec, line, check_inlines, resolve_scope, sc_list); } Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Wed Oct 20 15:54:39 2010 @@ -581,14 +581,14 @@ uint32_t len = sizeof(program_fullpath); int err = _NSGetExecutablePath (program_fullpath, &len); if (err == 0) - g_program_filespec.SetFile (program_fullpath); + g_program_filespec.SetFile (program_fullpath, true); else if (err == -1) { char *large_program_fullpath = (char *)::malloc (len + 1); err = _NSGetExecutablePath (large_program_fullpath, &len); if (err == 0) - g_program_filespec.SetFile (large_program_fullpath); + g_program_filespec.SetFile (large_program_fullpath, true); ::free (large_program_fullpath); } @@ -619,7 +619,7 @@ if (::dladdr (host_addr, &info)) { if (info.dli_fname) - module_filespec.SetFile(info.dli_fname); + module_filespec.SetFile(info.dli_fname, true); } return module_filespec; } Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Wed Oct 20 15:54:39 2010 @@ -116,7 +116,7 @@ { if (::CFURLGetFileSystemRepresentation (url.get(), YES, (UInt8*)path, sizeof(path))) { - file.SetFile(path); + file.SetFile(path, false); return true; } } @@ -232,7 +232,7 @@ OSStatus error = 0; - FileSpec program (argv[0]); + FileSpec program (argv[0], false); std::string unix_socket_name; Modified: lldb/trunk/source/Host/macosx/Symbols.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Symbols.cpp (original) +++ lldb/trunk/source/Host/macosx/Symbols.cpp Wed Oct 20 15:54:39 2010 @@ -239,8 +239,7 @@ DIR* dirp = ::opendir(path); if (dirp != NULL) { - const size_t path_len = strlen(path); - const int bytes_left = sizeof(path) - path_len - 1; + dsym_fspec.GetDirectory().SetCString(path); struct dirent* dp; while ((dp = readdir(dirp)) != NULL) { @@ -256,9 +255,7 @@ if (dp->d_type == DT_REG || dp->d_type == DT_UNKNOWN) { - ::strncpy (&path[path_len], dp->d_name, bytes_left); - - dsym_fspec.SetFile(path); + dsym_fspec.GetFilename().SetCString(dp->d_name); if (FileAtPathContainsArchAndUUID (dsym_fspec, arch, uuid)) return dsym_fspec; } @@ -334,7 +331,7 @@ { if (::CFURLGetFileSystemRepresentation (dsym_url.get(), true, (UInt8*)path, sizeof(path)-1)) { - out_dsym_fspec->SetFile(path); + out_dsym_fspec->SetFile(path, false); if (out_dsym_fspec->GetFileType () == FileSpec::eFileTypeDirectory) { @@ -358,7 +355,7 @@ if (exec_cf_path && ::CFStringGetFileSystemRepresentation (exec_cf_path, path, sizeof(path))) { ++items_found; - out_dsym_fspec->SetFile(path); + out_dsym_fspec->SetFile(path, false); } } } @@ -384,7 +381,7 @@ strncat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path)); strncat(path, exec_fspec->GetFilename().AsCString(), sizeof(path)); - dsym_fspec.SetFile(path); + dsym_fspec.SetFile(path, false); if (FileAtPathContainsArchAndUUID (dsym_fspec, arch, uuid)) { @@ -403,7 +400,7 @@ *next_slash = '\0'; strncat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path)); strncat(path, exec_fspec->GetFilename().AsCString(), sizeof(path)); - dsym_fspec.SetFile(path); + dsym_fspec.SetFile(path, false); if (dsym_fspec.Exists()) return true; else Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Wed Oct 20 15:54:39 2010 @@ -1074,7 +1074,7 @@ return; const char *init_file_path = in_cwd ? "./.lldbinit" : "~/.lldbinit"; - FileSpec init_file (init_file_path); + FileSpec init_file (init_file_path, true); // If the file exists, tell HandleCommand to 'source' it; this will do the actual broadcasting // of the commands back to any appropriate listener (see CommandObjectSource::Execute for more details). Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Wed Oct 20 15:54:39 2010 @@ -866,7 +866,7 @@ const char *module_name = input.GetArgumentAtIndex(cur_arg_pos); if (module_name) { - FileSpec module_spec(module_name); + FileSpec module_spec(module_name, false); lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget(); // Search filters require a target... if (target_sp != NULL) Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Wed Oct 20 15:54:39 2010 @@ -543,7 +543,7 @@ char raw_path[PATH_MAX]; m_process->ReadMemory (path_addr, raw_path, sizeof(raw_path), error); - m_dyld_image_infos[i].file_spec.SetFile(raw_path); + m_dyld_image_infos[i].file_spec.SetFile(raw_path, true); } assert(i == m_dyld_all_image_infos.dylib_info_count); @@ -787,7 +787,7 @@ { uint32_t name_offset = load_cmd_offset + data.GetU32 (&offset); const char *path = data.PeekCStr (name_offset); - lc_id_dylinker->SetFile (path); + lc_id_dylinker->SetFile (path, true); } break; Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Oct 20 15:54:39 2010 @@ -271,7 +271,7 @@ uint32_t str_index = static_cast(symbol.d_val); const char *lib_name = dynstr_data.PeekCStr(str_index); - m_filespec_ap->Append(FileSpec(lib_name)); + m_filespec_ap->Append(FileSpec(lib_name, true)); } } Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Oct 20 15:54:39 2010 @@ -1412,7 +1412,7 @@ // @rpath/.../file if (path && path[0] != '@') { - FileSpec file_spec(path); + FileSpec file_spec(path, true); if (files.AppendIfUnique(file_spec)) count++; } Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp Wed Oct 20 15:54:39 2010 @@ -111,13 +111,13 @@ DataExtractor data(memory_buffer, sizeof(memory_buffer), m_process.GetByteOrder(), m_process.GetAddressByteSize()); static ConstString g_dispatch_queue_offsets_symbol_name ("dispatch_queue_offsets"); const Symbol *dispatch_queue_offsets_symbol = NULL; - ModuleSP module_sp(m_process.GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libSystem.B.dylib"))); + ModuleSP module_sp(m_process.GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libSystem.B.dylib", false))); if (module_sp) dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (g_dispatch_queue_offsets_symbol_name, eSymbolTypeData); if (dispatch_queue_offsets_symbol == NULL) { - module_sp = m_process.GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libdispatch.dylib")); + module_sp = m_process.GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libdispatch.dylib", false)); if (module_sp) dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (g_dispatch_queue_offsets_symbol_name, eSymbolTypeData); } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Oct 20 15:54:39 2010 @@ -1674,7 +1674,7 @@ // to the debugserver to use and use it if we do. const char *env_debugserver_path = getenv("LLDB_DEBUGSERVER_PATH"); if (env_debugserver_path) - debugserver_file_spec.SetFile (env_debugserver_path); + debugserver_file_spec.SetFile (env_debugserver_path, false); else debugserver_file_spec = g_debugserver_file_spec; bool debugserver_exists = debugserver_file_spec.Exists(); @@ -2236,13 +2236,13 @@ { static ConstString g_dispatch_queue_offsets_symbol_name ("dispatch_queue_offsets"); const Symbol *dispatch_queue_offsets_symbol = NULL; - ModuleSP module_sp(GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libSystem.B.dylib"))); + ModuleSP module_sp(GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libSystem.B.dylib", false))); if (module_sp) dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (g_dispatch_queue_offsets_symbol_name, eSymbolTypeData); if (dispatch_queue_offsets_symbol == NULL) { - module_sp = GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libdispatch.dylib")); + module_sp = GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libdispatch.dylib", false)); if (module_sp) dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (g_dispatch_queue_offsets_symbol_name, eSymbolTypeData); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Wed Oct 20 15:54:39 2010 @@ -137,7 +137,7 @@ Symbol *oso_symbol = comp_unit_info->oso_symbol; if (oso_symbol) { - FileSpec oso_file_spec(oso_symbol->GetMangled().GetName().AsCString()); + FileSpec oso_file_spec(oso_symbol->GetMangled().GetName().AsCString(), true); ModuleList::GetSharedModule (oso_file_spec, m_obj_file->GetModule()->GetArchitecture(), @@ -168,7 +168,7 @@ std::string so_path (m_compile_unit_infos[oso_idx].so_symbol->GetMangled().GetName().AsCString()); if (m_compile_unit_infos[oso_idx].so_symbol[1].GetType() == eSymbolTypeSourceFile) so_path += m_compile_unit_infos[oso_idx].so_symbol[1].GetMangled().GetName().AsCString(); - m_compile_unit_infos[oso_idx].so_file.SetFile(so_path.c_str()); + m_compile_unit_infos[oso_idx].so_file.SetFile(so_path.c_str(), true); } file_spec = m_compile_unit_infos[oso_idx].so_file; return true; Modified: lldb/trunk/source/Symbol/CompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Symbol/CompileUnit.cpp (original) +++ lldb/trunk/source/Symbol/CompileUnit.cpp Wed Oct 20 15:54:39 2010 @@ -18,7 +18,7 @@ CompileUnit::CompileUnit (Module *module, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language) : ModuleChild(module), - FileSpec (pathname), + FileSpec (pathname, false), UserID(cu_sym_id), Language (language), m_user_data (user_data), Modified: lldb/trunk/source/Symbol/ObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=116944&r1=116943&r2=116944&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ObjectFile.cpp (original) +++ lldb/trunk/source/Symbol/ObjectFile.cpp Wed Oct 20 15:54:39 2010 @@ -51,7 +51,7 @@ if (g_object_regex.GetMatchAtIndex (path_with_object, 1, path) && g_object_regex.GetMatchAtIndex (path_with_object, 2, object)) { - archive_file.SetFile (path.c_str()); + archive_file.SetFile (path.c_str(), false); file_size = archive_file.GetByteSize(); if (file_size > 0) module->SetFileSpecAndObjectName (archive_file, ConstString(object.c_str())); From johnny.chen at apple.com Wed Oct 20 16:40:50 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 20 Oct 2010 21:40:50 -0000 Subject: [Lldb-commits] [lldb] r116948 - /lldb/trunk/source/Commands/CommandObjectCommands.cpp Message-ID: <20101020214050.EB8662A6C12C@llvm.org> Author: johnny Date: Wed Oct 20 16:40:50 2010 New Revision: 116948 URL: http://llvm.org/viewvc/llvm-project?rev=116948&view=rev Log: Fixed a crasher. The cmd_file needs to be resolved before reading lines from it. Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=116948&r1=116947&r2=116948&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Oct 20 16:40:50 2010 @@ -70,7 +70,7 @@ result.AppendMessageWithFormat ("Executing commands in '%s'.\n", filename); - FileSpec cmd_file (filename, false); + FileSpec cmd_file (filename, true); if (cmd_file.Exists()) { STLStringArray commands; From johnny.chen at apple.com Wed Oct 20 16:44:39 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 20 Oct 2010 21:44:39 -0000 Subject: [Lldb-commits] [lldb] r116949 - /lldb/trunk/include/lldb/Core/FileSpec.h Message-ID: <20101020214439.CABA32A6C12C@llvm.org> Author: johnny Date: Wed Oct 20 16:44:39 2010 New Revision: 116949 URL: http://llvm.org/viewvc/llvm-project?rev=116949&view=rev Log: Fixed a typo in the comment. Modified: lldb/trunk/include/lldb/Core/FileSpec.h Modified: lldb/trunk/include/lldb/Core/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=116949&r1=116948&r2=116949&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpec.h (original) +++ lldb/trunk/include/lldb/Core/FileSpec.h Wed Oct 20 16:44:39 2010 @@ -55,7 +55,7 @@ //------------------------------------------------------------------ /// Constructor with path. /// - /// Takes an path to a file which can be just a filename, or a full + /// Takes a path to a file which can be just a filename, or a full /// path. If \a path is not NULL or empty, this function will call /// FileSpec::SetFile (const char *path, bool resolve). /// From johnny.chen at apple.com Wed Oct 20 16:56:26 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 20 Oct 2010 21:56:26 -0000 Subject: [Lldb-commits] [lldb] r116950 - /lldb/trunk/test/load_unload/TestLoadUnload.py Message-ID: <20101020215626.3F7F32A6C12C@llvm.org> Author: johnny Date: Wed Oct 20 16:56:26 2010 New Revision: 116950 URL: http://llvm.org/viewvc/llvm-project?rev=116950&view=rev Log: Add more bug info. Modified: lldb/trunk/test/load_unload/TestLoadUnload.py Modified: lldb/trunk/test/load_unload/TestLoadUnload.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/TestLoadUnload.py?rev=116950&r1=116949&r2=116950&view=diff ============================================================================== --- lldb/trunk/test/load_unload/TestLoadUnload.py (original) +++ lldb/trunk/test/load_unload/TestLoadUnload.py Wed Oct 20 16:56:26 2010 @@ -41,6 +41,9 @@ # Issue the 'contnue' command. We should stop agaian at a_function. # The stop reason of the thread should be breakpoint and at a_function. self.runCmd("continue") + + # rdar://problem/8508987 + # The a_function breakpoint should be encountered twice. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs = ['state is stopped', 'a_function', From gclayton at apple.com Wed Oct 20 17:52:05 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 20 Oct 2010 22:52:05 -0000 Subject: [Lldb-commits] [lldb] r116963 - in /lldb/trunk: include/lldb/Core/FileSpec.h source/Core/FileSpec.cpp Message-ID: <20101020225205.760202A6C12C@llvm.org> Author: gclayton Date: Wed Oct 20 17:52:05 2010 New Revision: 116963 URL: http://llvm.org/viewvc/llvm-project?rev=116963&view=rev Log: Fixed a crasher that could happen if a FileSpec had a filename only, or vice versa. Modified: lldb/trunk/include/lldb/Core/FileSpec.h lldb/trunk/source/Core/FileSpec.cpp Modified: lldb/trunk/include/lldb/Core/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=116963&r1=116962&r2=116963&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpec.h (original) +++ lldb/trunk/include/lldb/Core/FileSpec.h Wed Oct 20 17:52:05 2010 @@ -462,8 +462,11 @@ /// /// @param[out] lines /// The string array into which to read the file. + /// + /// @result + /// Returns the number of lines that were read from the file. //------------------------------------------------------------------ - bool + size_t ReadFileLines (STLStringArray &lines); //------------------------------------------------------------------ Modified: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=116963&r1=116962&r2=116963&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp Wed Oct 20 17:52:05 2010 @@ -732,25 +732,21 @@ return data_sp; } -bool +size_t FileSpec::ReadFileLines (STLStringArray &lines) { - bool ret_val = false; lines.clear(); - - std::string dir_str (m_directory.AsCString()); - std::string file_str (m_filename.AsCString()); - std::string full_name = dir_str + "/" + file_str; - - ifstream file_stream (full_name.c_str()); - - if (file_stream) + char path[PATH_MAX]; + if (GetPath(path, sizeof(path))) { - std::string line; - while (getline (file_stream, line)) - lines.push_back (line); - ret_val = true; - } + ifstream file_stream (path); - return ret_val; + if (file_stream) + { + std::string line; + while (getline (file_stream, line)) + lines.push_back (line); + } + } + return lines.size(); } From johnny.chen at apple.com Wed Oct 20 17:56:32 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 20 Oct 2010 22:56:32 -0000 Subject: [Lldb-commits] [lldb] r116964 - /lldb/trunk/docs/testsuite/best-practices.txt Message-ID: <20101020225632.8B9122A6C12C@llvm.org> Author: johnny Date: Wed Oct 20 17:56:32 2010 New Revision: 116964 URL: http://llvm.org/viewvc/llvm-project?rev=116964&view=rev Log: Initial check in of best-practice documentation for building test cases. Added: lldb/trunk/docs/testsuite/best-practices.txt Added: lldb/trunk/docs/testsuite/best-practices.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/testsuite/best-practices.txt?rev=116964&view=auto ============================================================================== --- lldb/trunk/docs/testsuite/best-practices.txt (added) +++ lldb/trunk/docs/testsuite/best-practices.txt Wed Oct 20 17:56:32 2010 @@ -0,0 +1,39 @@ +This document attempts to point out some best practices that prove to be helpful +when building new test cases in the tot/test directory. Everyone is welcomed to +add/modify contents into this file. + +o Do not use hard-coded line numbers in your test case. Instead, try to tag the + line with some distinguishing pattern, and use the function line_number() + defined in lldbtest.py which takes filename and string_to_match as arguments + and returns the line number. + +As an example, take a look at test/breakpoint_conditions/main.c which has these +two lines: + + return c(val); // Find the line number of c's parent call here. + +and + + return val + 3; // Find the line number of function "c" here. + +The Python test case TestBreakpointConditions.py uses the comment strings to +find the line numbers during setUp(self) and use them later on to verify that +the correct breakpoint is being stopped on and that its parent frame also has +the correct line number as intended through the breakpoint condition. + +o Take advantage of the unittest framework's decorator features to properly + mark your test class or method for platform-specific tests. + +As an example, take a look at test/forward/TestForwardDeclaration.py which has +these lines: + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_run_command(self): + """Display *bar_ptr when stopped on a function with forward declaration of struct bar.""" + self.buildDsym() + self.forward_declaration() + +This tells the test harness that unless we are running "darwin", the test should +be skipped. This is because we are asking to build the binaries with dsym debug +info, which is only available on the darwin platforms. + From johnny.chen at apple.com Wed Oct 20 19:47:52 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 21 Oct 2010 00:47:52 -0000 Subject: [Lldb-commits] [lldb] r116980 - /lldb/trunk/test/dotest.py Message-ID: <20101021004752.F0FBC2A6C12C@llvm.org> Author: johnny Date: Wed Oct 20 19:47:52 2010 New Revision: 116980 URL: http://llvm.org/viewvc/llvm-project?rev=116980&view=rev Log: Add an example of option combination for running a single test method to the help text. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=116980&r1=116979&r2=116980&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Wed Oct 20 19:47:52 2010 @@ -115,6 +115,22 @@ args : specify a list of directory names to search for python Test*.py scripts if empty, search from the curret working directory, instead +This is an example of using the -f -g options to pinpoint to a specfic test +method to be run: + +$ ./dotest.py -f ClassTypesTestCase.test_with_dsym_and_run_command -g +---------------------------------------------------------------------- +Collected 1 test + +test_with_dsym_and_run_command (TestClassTypes.ClassTypesTestCase) +Test 'frame variable this' when stopped on a class constructor. ... ok + +---------------------------------------------------------------------- +Ran 1 test in 1.396s + +OK +$ + Running of this script also sets up the LLDB_TEST environment variable so that individual test cases can locate their supporting files correctly. The script tries to set up Python's search paths for modules by looking at the build tree From johnny.chen at apple.com Wed Oct 20 20:03:38 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 21 Oct 2010 01:03:38 -0000 Subject: [Lldb-commits] [lldb] r116982 - /lldb/trunk/test/dotest.py Message-ID: <20101021010338.7800C2A6C12C@llvm.org> Author: johnny Date: Wed Oct 20 20:03:38 2010 New Revision: 116982 URL: http://llvm.org/viewvc/llvm-project?rev=116982&view=rev Log: Get rid of the microsecond field in the timestamp directory name used to dump the session information files to. This makes the directory name less intimidating. Currently, the directory only gets created if there are failures/errors while running the test suite. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=116982&r1=116981&r2=116982&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Wed Oct 20 20:03:38 2010 @@ -525,6 +525,9 @@ # See also TestBase.dumpSessionInfo() in lldbtest.py. import datetime raw_timestamp = str(datetime.datetime.today()) +usec_position = raw_timestamp.rfind('.') +if usec_position != -1: + raw_timestamp = raw_timestamp[:usec_position] os.environ["LLDB_TIMESTAMP"] = raw_timestamp.replace(' ', '-') # From johnny.chen at apple.com Thu Oct 21 11:55:35 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 21 Oct 2010 16:55:35 -0000 Subject: [Lldb-commits] [lldb] r117028 - in /lldb/trunk/test: class_types/TestClassTypes.py dotest.py lldbtest.py Message-ID: <20101021165535.633C72A6C12C@llvm.org> Author: johnny Date: Thu Oct 21 11:55:35 2010 New Revision: 117028 URL: http://llvm.org/viewvc/llvm-project?rev=117028&view=rev Log: Add an option '-s session-dir-name' to overwrite the default timestamp-named directory used to dump the session info for test failures/errors. Example: /Volumes/data/lldb/svn/trunk/test $ ./dotest.py -s jason -v array_types Session info for test errors or failures will go into directory jason ---------------------------------------------------------------------- Collected 4 tests test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... ok test_with_dsym_and_run_command (TestArrayTypes.ArrayTypesTestCase) Test 'frame variable var_name' on some variables with array types. ... ok test_with_dwarf_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... ok test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase) Test 'frame variable var_name' on some variables with array types. ... FAIL ====================================================================== FAIL: test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase) Test 'frame variable var_name' on some variables with array types. ---------------------------------------------------------------------- Traceback (most recent call last): File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 27, in test_with_dwarf_and_run_command self.array_types() File "/Volumes/data/lldb/svn/trunk/test/array_types/TestArrayTypes.py", line 62, in array_types 'stop reason = breakpoint']) File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 594, in expect self.runCmd(str, trace = (True if trace else False), check = not error) File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 564, in runCmd msg if msg else CMD_MSG(cmd, True)) AssertionError: False is not True : Command 'thread list' returns successfully ---------------------------------------------------------------------- Ran 4 tests in 3.086s FAILED (failures=1) /Volumes/data/lldb/svn/trunk/test $ ls jason TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log /Volumes/data/lldb/svn/trunk/test $ head -10 jason/TestArrayTypes.ArrayTypesTestCase.test_with_dwarf_and_run_command.log Session info generated @ Thu Oct 21 09:54:15 2010 os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=NO']] stdout: rm -rf "a.out" "a.out.dSYM" main.o main.d cc -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c cc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" stderr: None retcode: 0 /Volumes/data/lldb/svn/trunk/test $ Modified: lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/dotest.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=117028&r1=117027&r2=117028&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Thu Oct 21 11:55:35 2010 @@ -106,7 +106,7 @@ self.assertTrue(fsDir == os.getcwd() and fsFile == "a.out", "FileSpec matches the executable") - bpfilespec = lldb.SBFileSpec("main.cpp") + bpfilespec = lldb.SBFileSpec("main.cpp", False) breakpoint = target.BreakpointCreateByLocation(bpfilespec, self.line) self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=117028&r1=117027&r2=117028&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Oct 21 11:55:35 2010 @@ -75,6 +75,11 @@ # not exist yet. rdir = None +# By default, recorded session info for errored/failed test are dumped into its +# own file under a session directory named after the timestamp of the test suite +# run. Use '-s session-dir-name' to specify a specific dir name. +sdir_name = None + # Default verbosity is 0. verbose = 0 @@ -107,6 +112,9 @@ -r : specify a dir to relocate the tests and their intermediate files to; the directory must not exist before running this test driver; no cleanup of intermediate test files is performed in this case +-s : specify the name of the dir created to store the session files of tests + with errored or failed status; if not specified, the test driver uses the + timestamp as the session dir name -t : trace lldb command execution and result -v : do verbose mode of unittest framework -w : insert some wait time (currently 0.5 sec) between consecutive test cases @@ -162,6 +170,7 @@ global skipLongRunningTest global regexp global rdir + global sdir_name global verbose global testdirs @@ -223,6 +232,13 @@ print "Relocated directory:", rdir, "must not exist!" usage() index += 1 + elif sys.argv[index].startswith('-s'): + # Increment by 1 to fetch the session dir name. + index += 1 + if index >= len(sys.argv) or sys.argv[index].startswith('-'): + usage() + sdir_name = sys.argv[index] + index += 1 elif sys.argv[index].startswith('-t'): os.environ["LLDB_COMMAND_TRACE"] = "YES" index += 1 @@ -518,17 +534,18 @@ # Install the control-c handler. unittest2.signals.installHandler() -# Now get a timestamp string and export it as LLDB_TIMESTAMP environment var. -# This will be useful when/if we want to dump the session info of individual -# test cases later on. +# If sdir_name is not specified through the '-s sdir_name' option, get a +# timestamp string and export it as LLDB_SESSION_DIR environment var. This will +# be used when/if we want to dump the session info of individual test cases +# later on. # # See also TestBase.dumpSessionInfo() in lldbtest.py. -import datetime -raw_timestamp = str(datetime.datetime.today()) -usec_position = raw_timestamp.rfind('.') -if usec_position != -1: - raw_timestamp = raw_timestamp[:usec_position] -os.environ["LLDB_TIMESTAMP"] = raw_timestamp.replace(' ', '-') +if not sdir_name: + import datetime + timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S") + sdir_name = timestamp +os.environ["LLDB_SESSION_DIRNAME"] = sdir_name +sys.stderr.write("\nSession info for test errors or failures will go into directory %s\n" % sdir_name) # # Invoke the default TextTestRunner to run the test suite, possibly iterating Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=117028&r1=117027&r2=117028&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Oct 21 11:55:35 2010 @@ -459,11 +459,13 @@ print >> self.session, err dname = os.path.join(os.environ["LLDB_TEST"], - os.environ["LLDB_TIMESTAMP"]) + os.environ["LLDB_SESSION_DIRNAME"]) if not os.path.isdir(dname): os.mkdir(dname) fname = os.path.join(dname, "%s.log" % self.id()) with open(fname, "w") as f: + import datetime + print >> f, "Session info generated @", datetime.datetime.now().ctime() print >> f, self.session.getvalue() def setTearDownCleanup(self, dictionary=None): From johnny.chen at apple.com Thu Oct 21 12:00:35 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 21 Oct 2010 17:00:35 -0000 Subject: [Lldb-commits] [lldb] r117030 - /lldb/trunk/test/dotest.py Message-ID: <20101021170035.E1B2F2A6C12C@llvm.org> Author: johnny Date: Thu Oct 21 12:00:35 2010 New Revision: 117030 URL: http://llvm.org/viewvc/llvm-project?rev=117030&view=rev Log: Rewording of output message. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=117030&r1=117029&r2=117030&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Oct 21 12:00:35 2010 @@ -545,7 +545,7 @@ timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S") sdir_name = timestamp os.environ["LLDB_SESSION_DIRNAME"] = sdir_name -sys.stderr.write("\nSession info for test errors or failures will go into directory %s\n" % sdir_name) +sys.stderr.write("\nSession info for test failures/errors will go into directory '%s'\n" % sdir_name) # # Invoke the default TextTestRunner to run the test suite, possibly iterating From johnny.chen at apple.com Thu Oct 21 16:39:02 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 21 Oct 2010 21:39:02 -0000 Subject: [Lldb-commits] [lldb] r117066 - /lldb/trunk/docs/testsuite/best-practices.txt Message-ID: <20101021213902.EE34A2A6C12C@llvm.org> Author: johnny Date: Thu Oct 21 16:39:02 2010 New Revision: 117066 URL: http://llvm.org/viewvc/llvm-project?rev=117066&view=rev Log: Add more information. Modified: lldb/trunk/docs/testsuite/best-practices.txt Modified: lldb/trunk/docs/testsuite/best-practices.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/testsuite/best-practices.txt?rev=117066&r1=117065&r2=117066&view=diff ============================================================================== --- lldb/trunk/docs/testsuite/best-practices.txt (original) +++ lldb/trunk/docs/testsuite/best-practices.txt Thu Oct 21 16:39:02 2010 @@ -37,3 +37,35 @@ be skipped. This is because we are asking to build the binaries with dsym debug info, which is only available on the darwin platforms. +o Cleanup after yourself. A classic example of this can be found in test/types/ + TestFloatTypes.py: + + def test_float_types_with_dsym(self): + """Test that float-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'float.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.float_type() + + ... + + def test_double_type_with_dsym(self): + """Test that double-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'double.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.double_type() + +This tests different data structures composed of float types to verify that what +the debugger prints out matches what the compiler does for different variables +of these types. We're using a dictionary to pass the build parameters to the +build system. After a particular test instance is done, it is a good idea to +clean up the files built. This eliminates the chance that some leftover files +can interfere with the build phase for the next test instance and render it +invalid. + +TestBase.setTearDownCleanup(self, dictionary) defined in lldbtest.py is created +to cope with this use case by taking the same build parameters in order to do +the cleanup when we are finished with a test instance, during +TestBase.tearDown(self). + From johnny.chen at apple.com Thu Oct 21 16:58:03 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 21 Oct 2010 21:58:03 -0000 Subject: [Lldb-commits] [lldb] r117071 - in /lldb/trunk/test/types: Makefile TestFloatTypes.py TestFloatTypesExpr.py TestIntegerTypes.py TestIntegerTypesExpr.py Message-ID: <20101021215803.2ABCC2A6C12C@llvm.org> Author: johnny Date: Thu Oct 21 16:58:02 2010 New Revision: 117071 URL: http://llvm.org/viewvc/llvm-project?rev=117071&view=rev Log: Mark these test methods to be eligible for running only under the 'darwin' platform. Modified: lldb/trunk/test/types/Makefile lldb/trunk/test/types/TestFloatTypes.py lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypes.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/types/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/Makefile?rev=117071&r1=117070&r2=117071&view=diff ============================================================================== --- lldb/trunk/test/types/Makefile (original) +++ lldb/trunk/test/types/Makefile Thu Oct 21 16:58:02 2010 @@ -1,5 +1,7 @@ LEVEL = ../make -#CXX_SOURCES := int.cpp +# Example: +# +# CXX_SOURCES := int.cpp include $(LEVEL)/Makefile.rules Modified: lldb/trunk/test/types/TestFloatTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypes.py?rev=117071&r1=117070&r2=117071&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypes.py (original) +++ lldb/trunk/test/types/TestFloatTypes.py Thu Oct 21 16:58:02 2010 @@ -5,11 +5,13 @@ import AbstractBase import unittest2 import lldb +import sys class FloatTypesTestCase(AbstractBase.GenericTester): mydir = "types" + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_float_types_with_dsym(self): """Test that float-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'float.cpp'} @@ -24,6 +26,7 @@ self.setTearDownCleanup(dictionary=d) self.float_type() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_double_type_with_dsym(self): """Test that double-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'double.cpp'} Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=117071&r1=117070&r2=117071&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Thu Oct 21 16:58:02 2010 @@ -5,6 +5,7 @@ import AbstractBase import unittest2 import lldb +import sys class FloatTypesTestCase(AbstractBase.GenericTester): @@ -13,6 +14,7 @@ # rdar://problem/8493023 # test/types failures for Test*TypesExpr.py: element offset computed wrong and sign error? + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_float_types_with_dsym(self): """Test that float-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'float.cpp'} @@ -27,6 +29,7 @@ self.setTearDownCleanup(dictionary=d) self.float_type_expr() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_double_type_with_dsym(self): """Test that double-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'double.cpp'} Modified: lldb/trunk/test/types/TestIntegerTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypes.py?rev=117071&r1=117070&r2=117071&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypes.py (original) +++ lldb/trunk/test/types/TestIntegerTypes.py Thu Oct 21 16:58:02 2010 @@ -5,11 +5,13 @@ import AbstractBase import unittest2 import lldb +import sys class IntegerTypesTestCase(AbstractBase.GenericTester): mydir = "types" + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_char_type_with_dsym(self): """Test that char-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'char.cpp'} @@ -24,6 +26,7 @@ self.setTearDownCleanup(dictionary=d) self.char_type() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_char_type_with_dsym(self): """Test that 'unsigned_char'-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'unsigned_char.cpp'} @@ -38,6 +41,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_char_type() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_short_type_with_dsym(self): """Test that short-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'short.cpp'} @@ -52,6 +56,7 @@ self.setTearDownCleanup(dictionary=d) self.short_type() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_short_type_with_dsym(self): """Test that 'unsigned_short'-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'unsigned_short.cpp'} @@ -66,6 +71,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_short_type() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_int_type_with_dsym(self): """Test that int-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'int.cpp'} @@ -80,6 +86,7 @@ self.setTearDownCleanup(dictionary=d) self.int_type() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_int_type_with_dsym(self): """Test that 'unsigned_int'-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'unsigned_int.cpp'} @@ -94,6 +101,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_int_type() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_type_with_dsym(self): """Test that long-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'long.cpp'} @@ -108,6 +116,7 @@ self.setTearDownCleanup(dictionary=d) self.long_type() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_long_type_with_dsym(self): """Test that 'unsigned long'-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'unsigned_long.cpp'} @@ -126,6 +135,7 @@ # test suite failure for types dir -- "long long" and "unsigned long long" @unittest2.expectedFailure + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_long_type_with_dsym(self): """Test that 'long long'-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'long_long.cpp'} @@ -142,6 +152,7 @@ self.long_long_type() @unittest2.expectedFailure + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_long_long_type_with_dsym(self): """Test that 'unsigned long long'-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=117071&r1=117070&r2=117071&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Thu Oct 21 16:58:02 2010 @@ -5,11 +5,13 @@ import AbstractBase import unittest2 import lldb +import sys class IntegerTypesTestCase(AbstractBase.GenericTester): mydir = "types" + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_char_type_with_dsym(self): """Test that char-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'char.cpp'} @@ -24,6 +26,7 @@ self.setTearDownCleanup(dictionary=d) self.char_type_expr() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_char_type_with_dsym(self): """Test that 'unsigned_char'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_char.cpp'} @@ -38,6 +41,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_char_type_expr() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_short_type_with_dsym(self): """Test that short-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'short.cpp'} @@ -52,6 +56,7 @@ self.setTearDownCleanup(dictionary=d) self.short_type_expr() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_short_type_with_dsym(self): """Test that 'unsigned_short'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_short.cpp'} @@ -66,6 +71,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_short_type_expr() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_int_type_with_dsym(self): """Test that int-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'int.cpp'} @@ -80,6 +86,7 @@ self.setTearDownCleanup(dictionary=d) self.int_type_expr() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_int_type_with_dsym(self): """Test that 'unsigned_int'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_int.cpp'} @@ -94,6 +101,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_int_type_expr() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_type_with_dsym(self): """Test that long-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'long.cpp'} @@ -108,6 +116,7 @@ self.setTearDownCleanup(dictionary=d) self.long_type_expr() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_long_type_with_dsym(self): """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_long.cpp'} @@ -126,6 +135,7 @@ # test suite failure for types dir -- "long long" and "unsigned long long" @unittest2.expectedFailure + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_long_type_with_dsym(self): """Test that 'long long'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'long_long.cpp'} @@ -142,6 +152,7 @@ self.long_long_type_expr() @unittest2.expectedFailure + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_long_long_type_with_dsym(self): """Test that 'unsigned long long'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} From scallanan at apple.com Thu Oct 21 17:41:33 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 21 Oct 2010 22:41:33 -0000 Subject: [Lldb-commits] [lldb] r117078 - /lldb/trunk/source/Expression/IRForTarget.cpp Message-ID: <20101021224133.171852A6C12C@llvm.org> Author: spyffe Date: Thu Oct 21 17:41:32 2010 New Revision: 117078 URL: http://llvm.org/viewvc/llvm-project?rev=117078&view=rev Log: Fixed IRForTarget to not recognize $__lldb variables as persistent variables. These are special markers used by LLDB. Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=117078&r1=117077&r2=117078&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Thu Oct 21 17:41:32 2010 @@ -494,7 +494,8 @@ Instruction &inst = *ii; if (AllocaInst *alloc = dyn_cast(&inst)) - if (alloc->getName().startswith("$")) + if (alloc->getName().startswith("$") && + !alloc->getName().startswith("$__lldb")) pvar_allocs.push_back(alloc); } From jingham at apple.com Thu Oct 21 20:15:49 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 22 Oct 2010 01:15:49 -0000 Subject: [Lldb-commits] [lldb] r117082 - in /lldb/trunk: include/lldb/API/SBBreakpoint.h include/lldb/API/SBBreakpointLocation.h source/API/SBBreakpoint.cpp source/API/SBBreakpointLocation.cpp Message-ID: <20101022011549.B1B2F2A6C12C@llvm.org> Author: jingham Date: Thu Oct 21 20:15:49 2010 New Revision: 117082 URL: http://llvm.org/viewvc/llvm-project?rev=117082&view=rev Log: Add and SB API to set breakpoint conditions. Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h lldb/trunk/include/lldb/API/SBBreakpointLocation.h lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBBreakpointLocation.cpp Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=117082&r1=117081&r2=117082&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpoint.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpoint.h Thu Oct 21 20:15:49 2010 @@ -70,6 +70,12 @@ uint32_t GetIgnoreCount () const; + + void + SetCondition (const char *condition); + + const char * + GetCondition (); void SetThreadID (lldb::tid_t sb_thread_id); Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=117082&r1=117081&r2=117082&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Thu Oct 21 20:15:49 2010 @@ -41,6 +41,12 @@ void SetIgnoreCount (uint32_t n); + void + SetCondition (const char *condition); + + const char * + GetCondition (); + void SetThreadID (lldb::tid_t sb_thread_id); Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=117082&r1=117081&r2=117082&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Thu Oct 21 20:15:49 2010 @@ -205,6 +205,18 @@ m_opaque_sp->SetIgnoreCount (count); } +void +SBBreakpoint::SetCondition (const char *condition) +{ + m_opaque_sp->SetCondition (condition); +} + +const char * +SBBreakpoint::GetCondition () +{ + return m_opaque_sp->GetConditionText (); +} + uint32_t SBBreakpoint::GetHitCount () const { Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=117082&r1=117081&r2=117082&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpointLocation.cpp (original) +++ lldb/trunk/source/API/SBBreakpointLocation.cpp Thu Oct 21 20:15:49 2010 @@ -99,6 +99,18 @@ } void +SBBreakpointLocation::SetCondition (const char *condition) +{ + m_opaque_sp->SetCondition (condition); +} + +const char * +SBBreakpointLocation::GetCondition () +{ + return m_opaque_sp->GetConditionText (); +} + +void SBBreakpointLocation::SetThreadID (tid_t thread_id) { if (m_opaque_sp) From gclayton at apple.com Thu Oct 21 21:39:02 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 22 Oct 2010 02:39:02 -0000 Subject: [Lldb-commits] [lldb] r117086 - /lldb/trunk/source/Core/ValueObject.cpp Message-ID: <20101022023902.874072A6C12C@llvm.org> Author: gclayton Date: Thu Oct 21 21:39:02 2010 New Revision: 117086 URL: http://llvm.org/viewvc/llvm-project?rev=117086&view=rev Log: Fixed a error formatting output issue when dumping variables where the error had no space before it and was missing a newline. Modified: lldb/trunk/source/Core/ValueObject.cpp Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=117086&r1=117085&r2=117086&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Thu Oct 21 21:39:02 2010 @@ -975,7 +975,7 @@ if (err_cstr) { - s.Printf ("error: %s", err_cstr); + s.Printf (" %s\n", err_cstr); } else { From johnny.chen at apple.com Fri Oct 22 11:17:39 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 22 Oct 2010 16:17:39 -0000 Subject: [Lldb-commits] [lldb] r117101 - /lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Message-ID: <20101022161739.4B6972A6C12C@llvm.org> Author: johnny Date: Fri Oct 22 11:17:39 2010 New Revision: 117101 URL: http://llvm.org/viewvc/llvm-project?rev=117101&view=rev Log: Fix misnamed test method names. Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=117101&r1=117100&r2=117101&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Fri Oct 22 11:17:39 2010 @@ -13,12 +13,12 @@ mydir = "breakpoint_conditions" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - def test_with_dsym_python(self): + def test_with_dsym_and_run_command(self): """Exercise breakpoint condition with 'breakpoint modify -c id'.""" self.buildDsym() self.breakpoint_conditions() - def test_with_dwarf_python(self): + def test_with_dwarf_and_run_command(self): """Exercise breakpoint condition with 'breakpoint modify -c id'.""" self.buildDwarf() self.breakpoint_conditions() From johnny.chen at apple.com Fri Oct 22 13:10:25 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 22 Oct 2010 18:10:25 -0000 Subject: [Lldb-commits] [lldb] r117116 - in /lldb/trunk/test: breakpoint_conditions/TestBreakpointConditions.py lldbtest.py Message-ID: <20101022181025.D34A52A6C12C@llvm.org> Author: johnny Date: Fri Oct 22 13:10:25 2010 New Revision: 117116 URL: http://llvm.org/viewvc/llvm-project?rev=117116&view=rev Log: Add test case for using SBBreakpointLocation to set break condition. Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=117116&r1=117115&r2=117116&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Fri Oct 22 13:10:25 2010 @@ -18,11 +18,22 @@ self.buildDsym() self.breakpoint_conditions() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_python_api(self): + """Use Python APIs to set breakpoint conditions.""" + self.buildDsym() + self.breakpoint_conditions_python() + def test_with_dwarf_and_run_command(self): """Exercise breakpoint condition with 'breakpoint modify -c id'.""" self.buildDwarf() self.breakpoint_conditions() + def test_with_dwarf_and_python_api(self): + """Use Python APIs to set breakpoint conditions.""" + self.buildDwarf() + self.breakpoint_conditions_python() + def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -62,7 +73,51 @@ patterns = ["frame #0.*main.c:%d" % self.line1, "frame #1.*main.c:%d" % self.line2]) + def breakpoint_conditions_python(self): + """Use Python APIs to set breakpoint conditions.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + print "breakpoint:", breakpoint + self.assertTrue(breakpoint.IsValid() and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Get the breakpoint location from breakpoint after we verified that, + # indeed, it has one location. + location = breakpoint.GetLocationAtIndex(0) + self.assertTrue(location.IsValid() and + location.IsEnabled(), + VALID_BREAKPOINT_LOCATION) + + # Set the condition on the breakpoint location. + location.SetCondition('val == 3') + self.expect(location.GetCondition(), exe=False, + startstr = 'val == 3') + + # Now launch the process, and do not stop at entry point. + self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + + self.process = target.GetProcess() + self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + + # Frame #0 should be on self.line1 and the break condition should hold. + frame0 = self.process.GetThreadAtIndex(0).GetFrameAtIndex(0) + var = frame0.LookupVarInScope('val', 'parameter') + self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and + var.GetValue(frame0) == '3') + + # The hit count for the breakpoint should be 3. + self.assertTrue(breakpoint.GetHitCount() == 3) + + self.process.Continue() + if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=117116&r1=117115&r2=117116&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Oct 22 13:10:25 2010 @@ -163,6 +163,8 @@ VALID_BREAKPOINT = "Got a valid breakpoint" +VALID_BREAKPOINT_LOCATION = "Got a valid breakpoint location" + VALID_FILESPEC = "Got a valid filespec" VALID_PROCESS = "Got a valid process" From jingham at apple.com Fri Oct 22 13:47:16 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 22 Oct 2010 18:47:16 -0000 Subject: [Lldb-commits] [lldb] r117125 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20101022184716.C537D2A6C12C@llvm.org> Author: jingham Date: Fri Oct 22 13:47:16 2010 New Revision: 117125 URL: http://llvm.org/viewvc/llvm-project?rev=117125&view=rev Log: Changed "run" to alias "process launch --". Added "po" alias for "expression -o --" Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=117125&r1=117124&r2=117125&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Oct 22 13:47:16 2010 @@ -83,8 +83,8 @@ // Set up some initial aliases. result.Clear(); HandleCommand ("command alias q quit", false, result); - result.Clear(); HandleCommand ("command alias run process launch", false, result); - result.Clear(); HandleCommand ("command alias r process launch", false, result); + result.Clear(); HandleCommand ("command alias run process launch --", false, result); + result.Clear(); HandleCommand ("command alias r process launch --", false, result); result.Clear(); HandleCommand ("command alias c process continue", false, result); result.Clear(); HandleCommand ("command alias continue process continue", false, result); result.Clear(); HandleCommand ("command alias expr expression", false, result); @@ -102,6 +102,7 @@ result.Clear(); HandleCommand ("command alias list source list", false, result); result.Clear(); HandleCommand ("command alias p frame variable", false, result); result.Clear(); HandleCommand ("command alias print frame variable", false, result); + result.Clear(); HandleCommand ("command alias po expression -o --", false, result); } const char * @@ -454,7 +455,8 @@ if (m_alias_dict.size() > 0) { - result.AppendMessage("The following is a list of your current command abbreviations (see 'help commands alias' for more info):"); + result.AppendMessage("The following is a list of your current command abbreviations " + "(see 'help commands alias' for more info):"); result.AppendMessage(""); max_len = FindLongestCommandWord (m_alias_dict); @@ -753,7 +755,8 @@ // put an empty string in element 0. std::string command_partial_str; if (cursor_index >= 0) - command_partial_str.assign(parsed_line.GetArgumentAtIndex(cursor_index), parsed_line.GetArgumentAtIndex(cursor_index) + cursor_char_position); + command_partial_str.assign(parsed_line.GetArgumentAtIndex(cursor_index), + parsed_line.GetArgumentAtIndex(cursor_index) + cursor_char_position); std::string common_prefix; matches.LongestCommonPrefix (common_prefix); From johnny.chen at apple.com Fri Oct 22 14:00:18 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 22 Oct 2010 19:00:18 -0000 Subject: [Lldb-commits] [lldb] r117129 - /lldb/trunk/test/dotest.py Message-ID: <20101022190018.827532A6C12C@llvm.org> Author: johnny Date: Fri Oct 22 14:00:18 2010 New Revision: 117129 URL: http://llvm.org/viewvc/llvm-project?rev=117129&view=rev Log: Add some more usage text. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=117129&r1=117128&r2=117129&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Oct 22 14:00:18 2010 @@ -120,9 +120,12 @@ -w : insert some wait time (currently 0.5 sec) between consecutive test cases and: -args : specify a list of directory names to search for python Test*.py scripts +args : specify a list of directory names to search for test modules named after + Test*.py (test discovery) if empty, search from the curret working directory, instead +Examples: + This is an example of using the -f -g options to pinpoint to a specfic test method to be run: @@ -137,7 +140,27 @@ Ran 1 test in 1.396s OK -$ + +And this is an example of using the -p option to run a single file (the filename +matches the pattern 'ObjC' and it happens to be 'TestObjCMethods.py'): + +$ ./dotest.py -v -p ObjC +---------------------------------------------------------------------- +Collected 4 tests + +test_break_with_dsym (TestObjCMethods.FoundationTestCase) +Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'. ... ok +test_break_with_dwarf (TestObjCMethods.FoundationTestCase) +Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'. ... ok +test_data_type_and_expr_with_dsym (TestObjCMethods.FoundationTestCase) +Lookup objective-c data types and evaluate expressions. ... ok +test_data_type_and_expr_with_dwarf (TestObjCMethods.FoundationTestCase) +Lookup objective-c data types and evaluate expressions. ... ok + +---------------------------------------------------------------------- +Ran 4 tests in 16.661s + +OK Running of this script also sets up the LLDB_TEST environment variable so that individual test cases can locate their supporting files correctly. The script From johnny.chen at apple.com Fri Oct 22 14:51:42 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 22 Oct 2010 19:51:42 -0000 Subject: [Lldb-commits] [lldb] r117136 - /lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Message-ID: <20101022195142.421A92A6C12D@llvm.org> Author: johnny Date: Fri Oct 22 14:51:42 2010 New Revision: 117136 URL: http://llvm.org/viewvc/llvm-project?rev=117136&view=rev Log: The test should remove 'output.txt' if it exists before launching the inferior process which is supposed to create the file. Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=117136&r1=117135&r2=117136&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Fri Oct 22 14:51:42 2010 @@ -69,7 +69,9 @@ "print >> here", "here.close()"]) - # Run the program. + # Run the program. Remove 'output.txt' if it exists. + if os.path.exists('output.txt'): + os.remove('output.txt') self.runCmd("run", RUN_SUCCEEDED) # Check that the file 'output.txt' exists and contains the string "lldb". From johnny.chen at apple.com Fri Oct 22 15:08:56 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 22 Oct 2010 20:08:56 -0000 Subject: [Lldb-commits] [lldb] r117140 - /lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Message-ID: <20101022200856.8D02A2A6C12C@llvm.org> Author: johnny Date: Fri Oct 22 15:08:56 2010 New Revision: 117140 URL: http://llvm.org/viewvc/llvm-project?rev=117140&view=rev Log: Comment out the debug statement for printing the SBBreakpoint object. Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=117140&r1=117139&r2=117140&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Fri Oct 22 15:08:56 2010 @@ -83,7 +83,7 @@ # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') - print "breakpoint:", breakpoint + #print "breakpoint:", breakpoint self.assertTrue(breakpoint.IsValid() and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) From johnny.chen at apple.com Fri Oct 22 16:06:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 22 Oct 2010 21:06:04 -0000 Subject: [Lldb-commits] [lldb] r117148 - in /lldb/trunk: docs/testsuite/best-practices.txt test/breakpoint_command/TestBreakpointCommand.py test/settings/TestSettings.py Message-ID: <20101022210604.A443A2A6C12C@llvm.org> Author: johnny Date: Fri Oct 22 16:06:04 2010 New Revision: 117148 URL: http://llvm.org/viewvc/llvm-project?rev=117148&view=rev Log: Add text about test class cleanup. Modified: lldb/trunk/docs/testsuite/best-practices.txt lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/docs/testsuite/best-practices.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/testsuite/best-practices.txt?rev=117148&r1=117147&r2=117148&view=diff ============================================================================== --- lldb/trunk/docs/testsuite/best-practices.txt (original) +++ lldb/trunk/docs/testsuite/best-practices.txt Fri Oct 22 16:06:04 2010 @@ -69,3 +69,25 @@ the cleanup when we are finished with a test instance, during TestBase.tearDown(self). +o Class-wise cleanup after yourself. + +TestBase.tearDownClass(cls) provides a mechanism to invoke the platform-specific +cleanup after finishing with a test class. A test class can have more than one +test methods, so the tearDownClass(cls) method gets run after all the test +methods have been executed by the test harness. + +The default cleanup action performed by the plugins/darwin.py module invokes the +"make clean" os command. + +If this default cleanup is not enough, individual class can provide an extra +cleanup hook with a class method named classCleanup , for example, +in test/breakpoint_command/TestBreakpointCommand.py: + + @classmethod + def classCleanup(cls): + system(["/bin/sh", "-c", "rm -f output.txt"]) + +The 'output.txt' file gets generated during the test run, so it makes sense to +explicitly spell out the action in the same TestBreakpointCommand.py file to do +the cleanup instead of artificially adding it as part of the default cleanup +action which serves to cleanup those intermediate and a.out files. Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=117148&r1=117147&r2=117148&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Fri Oct 22 16:06:04 2010 @@ -13,6 +13,7 @@ @classmethod def classCleanup(cls): + """Cleanup the test byproduct of breakpoint_command_sequence(self).""" system(["/bin/sh", "-c", "rm -f output.txt"]) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=117148&r1=117147&r2=117148&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Fri Oct 22 16:06:04 2010 @@ -13,6 +13,7 @@ @classmethod def classCleanup(cls): + """Cleanup the test byproducts.""" system(["/bin/sh", "-c", "rm -f output.txt"]) system(["/bin/sh", "-c", "rm -f stdout.txt"]) From gclayton at apple.com Fri Oct 22 16:15:00 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 22 Oct 2010 21:15:00 -0000 Subject: [Lldb-commits] [lldb] r117150 - /lldb/trunk/source/Core/Debugger.cpp Message-ID: <20101022211500.542932A6C12D@llvm.org> Author: gclayton Date: Fri Oct 22 16:15:00 2010 New Revision: 117150 URL: http://llvm.org/viewvc/llvm-project?rev=117150&view=rev Log: Fix the default prompt to have a space. Modified: lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=117150&r1=117149&r2=117150&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Oct 22 16:15:00 2010 @@ -1670,7 +1670,7 @@ // NAME Setting variable type Default Enum Init'd Hidden Help // ======================= ======================= ====================== ==== ====== ====== ====================== { "frame-format", eSetVarTypeString, DEFAULT_FRAME_FORMAT, NULL, false, false, "The default frame format string to use when displaying thread information." }, -{ "prompt", eSetVarTypeString, "(lldb)", NULL, false, false, "The debugger command line prompt displayed for the user." }, +{ "prompt", eSetVarTypeString, "(lldb) ", NULL, false, false, "The debugger command line prompt displayed for the user." }, { "script-lang", eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." }, { "term-width", eSetVarTypeInt, "80" , NULL, false, false, "The maximum number of columns to use for displaying text." }, { "thread-format", eSetVarTypeString, DEFAULT_THREAD_FORMAT, NULL, false, false, "The default thread format string to use when displaying thread information." }, From johnny.chen at apple.com Fri Oct 22 16:31:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 22 Oct 2010 21:31:04 -0000 Subject: [Lldb-commits] [lldb] r117152 - /lldb/trunk/test/lldbutil.py Message-ID: <20101022213104.1A1352A6C12D@llvm.org> Author: johnny Date: Fri Oct 22 16:31:03 2010 New Revision: 117152 URL: http://llvm.org/viewvc/llvm-project?rev=117152&view=rev Log: Comment heading changes. Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=117152&r1=117151&r2=117152&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Fri Oct 22 16:31:03 2010 @@ -6,11 +6,9 @@ import sys import StringIO -################################################ -# # -# Iterator for lldb aggregate data structures. # -# # -################################################ +# =========================================== +# Iterator for lldb aggregate data structures +# =========================================== def lldb_iter(obj, getsize, getelem): """ @@ -33,11 +31,9 @@ yield elem(i) -######################################################## -# # -# Convert some enum value to its string's counterpart. # -# # -######################################################## +# ================================================= +# Convert some enum value to its string counterpart +# ================================================= def StateTypeString(enum): """Returns the stateType string given an enum.""" @@ -88,11 +84,9 @@ raise Exception("Unknown stopReason enum") -####################################################### -# # -# Utility functions related to Threads and Processes. # -# # -####################################################### +# ================================================== +# Utility functions related to Threads and Processes +# ================================================== def GetFunctionNames(thread): """ From johnny.chen at apple.com Fri Oct 22 16:37:51 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 22 Oct 2010 21:37:51 -0000 Subject: [Lldb-commits] [lldb] r117153 - /lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt Message-ID: <20101022213751.BF7F52A6C12D@llvm.org> Author: johnny Date: Fri Oct 22 16:37:51 2010 New Revision: 117153 URL: http://llvm.org/viewvc/llvm-project?rev=117153&view=rev Log: Just use 'test harness', not 'test harness runtime'. Modified: lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt Modified: lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt?rev=117153&r1=117152&r2=117153&view=diff ============================================================================== --- lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt (original) +++ lldb/trunk/docs/testsuite/a-detailed-walkthrough.txt Fri Oct 22 16:37:51 2010 @@ -153,12 +153,12 @@ mydir = "settings" which happens right after the SettingsCommandTestCase class declaration comes -into place. It specifies the relative directory to the top level 'test' so that -the test harness runtime can change its working directory in order to find the -executable as well as the source code files. The runCmd() method is defined -in the TestBase base class (within test/lldbtest.py) and its purpose is to pass -the specified command to the lldb command interpreter. It's like you're typing -the command within an interactive lldb session. +into place. It specifies the relative directory to the top level 'test' so that +the test harness can change its working directory in order to find the +executable as well as the source code files. The runCmd() method is defined in +the TestBase base class (within test/lldbtest.py) and its purpose is to pass the +specified command to the lldb command interpreter. It's like you're typing the +command within an interactive lldb session. The CURRENT_EXECUTABLE_SET is an assert message defined in the lldbtest module so that it can be reused from other test modules. From johnny.chen at apple.com Fri Oct 22 18:15:46 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 22 Oct 2010 23:15:46 -0000 Subject: [Lldb-commits] [lldb] r117175 - /lldb/trunk/test/lldbtest.py Message-ID: <20101022231546.A9F652A6C12C@llvm.org> Author: johnny Date: Fri Oct 22 18:15:46 2010 New Revision: 117175 URL: http://llvm.org/viewvc/llvm-project?rev=117175&view=rev Log: Add more docstring for the lldbtest.TestBase class. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=117175&r1=117174&r2=117175&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Oct 22 18:15:46 2010 @@ -293,7 +293,60 @@ return output class TestBase(unittest2.TestCase): - """This LLDB abstract base class is meant to be subclassed.""" + """ + This abstract base class is meant to be subclassed. It provides default + implementations for setUpClass(), tearDownClass(), setUp(), and tearDown(), + among other things. + + Important things for test class writers: + + - Overwrite the mydir class attribute, otherwise your test class won't + run. It specifies the relative directory to the top level 'test' so + the test harness can change to the correct working directory before + running your test. + + - The setUp method sets up things to facilitate subsequent interactions + with the debugger as part of the test. These include: + - create/get a debugger set with synchronous mode (self.dbg) + - get the command interpreter from with the debugger (self.ci) + - create a result object for use with the command interpreter + (self.result) + - plus other stuffs + + - The tearDown method tries to perform some necessary cleanup on behalf + of the test to return the debugger to a good state for the next test. + These include: + - execute any tearDown hooks registered by the test method with + TestBase.addTearDownHook(); examples can be found in + settings/TestSettings.py + - kill the inferior process launched during the test method + - if by 'run' or 'process launch' command, 'process kill' + command is used + - if the test method uses LLDB Python API to launch process, + it should assign the process object to self.process; that + way, tearDown will use self.process.Kill() on the object + - perform build cleanup before running the next test method in the + same test class; examples of registering for this service can be + found in types/TestIntegerTypes.py with the call: + - self.setTearDownCleanup(dictionary=d) + + - Similarly setUpClass and tearDownClass perform classwise setup and + teardown fixtures. The tearDownClass method invokes a default build + cleanup for the entire test class; also, subclasses can implement the + classmethod classCleanup(cls) to perform special class cleanup action. + + - The instance methods runCmd and expect are used heavily by existing + test cases to send a command to the command interpreter and to perform + string/pattern matching on the output of such command execution. The + expect method also provides a mode to peform string/pattern matching + without running a command. + + - The build methods buildDefault, buildDsym, and buildDwarf are used to + build the binaries used during a particular test scenario. A plugin + should be provided for the sys.platform running the test suite. The + Mac OS X implementation is located in plugins/darwin.py. + + """ @classmethod def skipLongRunningTest(cls): From scallanan at apple.com Fri Oct 22 18:25:16 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 22 Oct 2010 23:25:16 -0000 Subject: [Lldb-commits] [lldb] r117178 - /lldb/trunk/source/Expression/ClangUserExpression.cpp Message-ID: <20101022232516.BD37A2A6C12C@llvm.org> Author: spyffe Date: Fri Oct 22 18:25:16 2010 New Revision: 117178 URL: http://llvm.org/viewvc/llvm-project?rev=117178&view=rev Log: Added a temporary hack to allow casting of Objective-C method results to int. This will only last until we get accurate type information for Objective-C methods or some way of making their types inferred by the parser. Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=117178&r1=117177&r2=117178&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Fri Oct 22 18:25:16 2010 @@ -72,7 +72,26 @@ m_objectivec = true; } -bool +// This is a really nasty hack, meant to fix Objective-C expressions of the form +// (int)[myArray count]. Right now, because the type information for count is +// not available, [myArray count] returns id, which can't be directly cast to +// int without causing a clang error. +static void +ApplyObjcCastHack(std::string &expr) +{ +#define OBJC_CAST_HACK_FROM "(int)[" +#define OBJC_CAST_HACK_TO "(int)(long long)[" + + size_t from_offset; + + while ((from_offset = expr.find(OBJC_CAST_HACK_FROM)) != expr.npos) + expr.replace(from_offset, sizeof(OBJC_CAST_HACK_FROM) - 1, OBJC_CAST_HACK_TO); + +#undef OBJC_CAST_HACK_TO +#undef OBJC_CAST_HACK_FROM +} + +bool ClangUserExpression::Parse (Stream &error_stream, ExecutionContext &exe_ctx) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); @@ -84,11 +103,13 @@ //////////////////////////////////// // Generate the expression // + + ApplyObjcCastHack(m_expr_text); if (m_cplusplus) { m_transformed_stream.Printf("void \n" - "$__lldb_class::%s(void *$__lldb_arg) \n" + "$__lldb_class::%s(void *$__lldb_arg) \n" "{ \n" " %s; \n" "} \n", @@ -100,7 +121,7 @@ else { m_transformed_stream.Printf("void \n" - "%s(void *$__lldb_arg) \n" + "%s(void *$__lldb_arg) \n" "{ \n" " %s; \n" "} \n", From jingham at apple.com Fri Oct 22 18:28:32 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 22 Oct 2010 23:28:32 -0000 Subject: [Lldb-commits] [lldb] r117179 - /lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp Message-ID: <20101022232832.8F3B12A6C12C@llvm.org> Author: jingham Date: Fri Oct 22 18:28:32 2010 New Revision: 117179 URL: http://llvm.org/viewvc/llvm-project?rev=117179&view=rev Log: If we hit a thread specific breakpoint for another thread, don't report the Exception as the stop reason, you have to report no stop reason. Modified: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp?rev=117179&r1=117178&r2=117179&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp Fri Oct 22 18:28:32 2010 @@ -324,9 +324,15 @@ lldb::BreakpointSiteSP bp_site_sp = thread.GetProcess().GetBreakpointSiteList().FindByAddress(pc); if (bp_site_sp) { + // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread, + // we can just report no reason. We don't need to worry about stepping over the breakpoint here, that + // will be taken care of when the thread resumes and notices that there's a breakpoint under the pc. if (bp_site_sp->ValidForThisThread (&thread)) return StopInfo::CreateStopReasonWithBreakpointSiteID (thread, bp_site_sp->GetID()); + else + return StopInfoSP(); } + } } break; From scallanan at apple.com Fri Oct 22 19:18:49 2010 From: scallanan at apple.com (Sean Callanan) Date: Sat, 23 Oct 2010 00:18:49 -0000 Subject: [Lldb-commits] [lldb] r117190 - /lldb/trunk/source/Core/ValueObject.cpp Message-ID: <20101023001849.741552A6C12C@llvm.org> Author: spyffe Date: Fri Oct 22 19:18:49 2010 New Revision: 117190 URL: http://llvm.org/viewvc/llvm-project?rev=117190&view=rev Log: Fixed value objects so that they return an informative message when they have no description. Modified: lldb/trunk/source/Core/ValueObject.cpp Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=117190&r1=117189&r2=117190&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Oct 22 19:18:49 2010 @@ -565,7 +565,11 @@ { m_object_desc_str.append (s.GetData()); } - return m_object_desc_str.c_str(); + + if (m_object_desc_str.empty()) + return NULL; + else + return m_object_desc_str.c_str(); } const char * @@ -995,7 +999,7 @@ if (object_desc) s.Printf(" %s\n", object_desc); else - s.Printf ("No description available.\n"); + s.Printf (" [no Objective-C description available]\n"); return; } } From scallanan at apple.com Sun Oct 24 15:45:49 2010 From: scallanan at apple.com (Sean Callanan) Date: Sun, 24 Oct 2010 20:45:49 -0000 Subject: [Lldb-commits] [lldb] r117247 - /lldb/trunk/source/Expression/ClangUserExpression.cpp Message-ID: <20101024204549.DFC972A6C12C@llvm.org> Author: spyffe Date: Sun Oct 24 15:45:49 2010 New Revision: 117247 URL: http://llvm.org/viewvc/llvm-project?rev=117247&view=rev Log: Added a hack so that "unichar" is resolved to "unsigned short." As discussed in the comments, this is pending a better solution to the problem of types not in the debug information but readily available through headers. Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=117247&r1=117246&r2=117247&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Sun Oct 24 15:45:49 2010 @@ -91,6 +91,26 @@ #undef OBJC_CAST_HACK_FROM } +// Another hack, meant to allow use of unichar despite it not being available in +// the type information. Although we could special-case it in type lookup, +// hopefully we'll figure out a way to #include the same environment as is +// present in the original source file rather than try to hack specific type +// definitions in as needed. +static void +ApplyUnicharHack(std::string &expr) +{ +#define UNICHAR_HACK_FROM "unichar" +#define UNICHAR_HACK_TO "unsigned short" + + size_t from_offset; + + while ((from_offset = expr.find(UNICHAR_HACK_FROM)) != expr.npos) + expr.replace(from_offset, sizeof(UNICHAR_HACK_FROM) - 1, UNICHAR_HACK_TO); + +#undef UNICHAR_HACK_TO +#undef UNICHAR_HACK_FROM +} + bool ClangUserExpression::Parse (Stream &error_stream, ExecutionContext &exe_ctx) { @@ -105,6 +125,7 @@ // ApplyObjcCastHack(m_expr_text); + ApplyUnicharHack(m_expr_text); if (m_cplusplus) { From scallanan at apple.com Sun Oct 24 19:29:48 2010 From: scallanan at apple.com (Sean Callanan) Date: Mon, 25 Oct 2010 00:29:48 -0000 Subject: [Lldb-commits] [lldb] r117249 - in /lldb/trunk/source: Core/ValueObjectChild.cpp Symbol/ClangASTContext.cpp Message-ID: <20101025002948.9ACF62A6C12C@llvm.org> Author: spyffe Date: Sun Oct 24 19:29:48 2010 New Revision: 117249 URL: http://llvm.org/viewvc/llvm-project?rev=117249&view=rev Log: Fixes to Objective-C built-in type handling. Specifically, we fixed handling of the objc_class built-in type, which allowed us to pass named Objective-C objects to functions, call variable list -t on objects safely, etc. Modified: lldb/trunk/source/Core/ValueObjectChild.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Core/ValueObjectChild.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=117249&r1=117248&r2=117249&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp (original) +++ lldb/trunk/source/Core/ValueObjectChild.cpp Sun Oct 24 19:29:48 2010 @@ -45,6 +45,8 @@ m_bitfield_bit_offset (bitfield_bit_offset), m_is_base_class (is_base_class) { + assert(byte_size != 0 && "TEMPORARY DEBUGGING ASSERT"); + m_name = name; } Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=117249&r1=117248&r2=117249&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sun Oct 24 19:29:48 2010 @@ -666,19 +666,19 @@ clang_type_t ClangASTContext::GetBuiltInType_objc_id() { - return getASTContext()->getObjCIdType().getAsOpaquePtr(); + return getASTContext()->ObjCBuiltinIdTy.getAsOpaquePtr(); } clang_type_t ClangASTContext::GetBuiltInType_objc_Class() { - return getASTContext()->getObjCClassType().getAsOpaquePtr(); + return getASTContext()->ObjCBuiltinClassTy.getAsOpaquePtr(); } clang_type_t ClangASTContext::GetBuiltInType_objc_selector() { - return getASTContext()->getObjCSelType().getAsOpaquePtr(); + return getASTContext()->ObjCBuiltinSelTy.getAsOpaquePtr(); } clang_type_t @@ -777,7 +777,7 @@ { ASTContext *ast_context = getASTContext(); assert (ast_context != NULL); - + if (decl_ctx == NULL) decl_ctx = ast_context->getTranslationUnitDecl(); @@ -1662,8 +1662,18 @@ const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { + case clang::Type::Builtin: + switch (cast(qual_type)->getKind()) + { + default: + break; + case clang::BuiltinType::ObjCId: + case clang::BuiltinType::ObjCClass: + case clang::BuiltinType::ObjCSel: + return eTypeIsBuiltIn | eTypeIsPointer | eTypeHasValue; + } + return eTypeIsBuiltIn | eTypeHasValue; case clang::Type::BlockPointer: return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock; - case clang::Type::Builtin: return eTypeIsBuiltIn | eTypeHasValue; case clang::Type::Complex: return eTypeHasChildren | eTypeIsBuiltIn | eTypeHasValue; case clang::Type::ConstantArray: return eTypeHasChildren | eTypeIsArray; case clang::Type::DependentName: return 0; @@ -1949,13 +1959,16 @@ { case clang::BuiltinType::ObjCId: case clang::BuiltinType::ObjCClass: + child_name = "isa"; + child_byte_size = ast_context->getTypeSize(ast_context->ObjCBuiltinClassTy) / CHAR_BIT; return ast_context->ObjCBuiltinClassTy.getAsOpaquePtr(); case clang::BuiltinType::ObjCSel: { QualType char_type(ast_context->CharTy); char_type.addConst(); - return ast_context->getPointerType(char_type).getAsOpaquePtr(); + child_byte_size = ast_context->getTypeSize(char_type); + return char_type.getAsOpaquePtr(); } break; @@ -3150,6 +3163,15 @@ return true; } + ObjCObjectType *objc_class_type = dyn_cast(qual_type); + + if (objc_class_type) + { + ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + + class_interface_decl->setForwardDecl(false); + } + const EnumType *enum_type = dyn_cast(qual_type.getTypePtr()); if (enum_type) @@ -3350,6 +3372,17 @@ const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { + case clang::Type::Builtin: + switch (cast(qual_type)->getKind()) + { + default: + break; + case clang::BuiltinType::ObjCId: + case clang::BuiltinType::ObjCClass: + case clang::BuiltinType::ObjCSel: + return true; + } + return false; case clang::Type::ObjCObjectPointer: if (target_type) *target_type = cast(qual_type)->getPointeeType().getAsOpaquePtr(); @@ -3411,6 +3444,17 @@ const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { + case clang::Type::Builtin: + switch (cast(qual_type)->getKind()) + { + default: + break; + case clang::BuiltinType::ObjCId: + case clang::BuiltinType::ObjCClass: + case clang::BuiltinType::ObjCSel: + return true; + } + return false; case clang::Type::ObjCObjectPointer: if (target_type) *target_type = cast(qual_type)->getPointeeType().getAsOpaquePtr();