From ctice at apple.com Mon Jun 13 15:20:29 2011 From: ctice at apple.com (Caroline Tice) Date: Mon, 13 Jun 2011 20:20:29 -0000 Subject: [Lldb-commits] [lldb] r132930 - in /lldb/trunk/source/Commands: CommandObjectExpression.cpp CommandObjectExpression.h Message-ID: <20110613202029.EA2952A6C12C@llvm.org> Author: ctice Date: Mon Jun 13 15:20:29 2011 New Revision: 132930 URL: http://llvm.org/viewvc/llvm-project?rev=132930&view=rev Log: More prompt-timing cleanups: Make multi-line expressions use the asynchronous stream mechanism rather than writing directly to the Debugger's output & error streams. Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=132930&r1=132929&r2=132930&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Jun 13 15:20:29 2011 @@ -234,9 +234,13 @@ case eInputReaderDone: if (cmd_object_expr->m_expr_lines.size() > 0) { + StreamSP output_stream = reader.GetDebugger().GetAsyncOutputStream(); + StreamSP error_stream = reader.GetDebugger().GetAsyncErrorStream(); cmd_object_expr->EvaluateExpression (cmd_object_expr->m_expr_lines.c_str(), - reader.GetDebugger().GetOutputStream(), - reader.GetDebugger().GetErrorStream()); + output_stream.get(), + error_stream.get()); + output_stream->Flush(); + error_stream->Flush(); } break; } @@ -248,8 +252,8 @@ CommandObjectExpression::EvaluateExpression ( const char *expr, - Stream &output_stream, - Stream &error_stream, + Stream *output_stream, + Stream *error_stream, CommandReturnObject *result ) { @@ -307,7 +311,7 @@ if (m_options.format != eFormatDefault) result_valobj_sp->SetFormat (m_options.format); - ValueObject::DumpValueObject (output_stream, + ValueObject::DumpValueObject (*(output_stream), result_valobj_sp.get(), // Variable object to dump result_valobj_sp->GetName().GetCString(),// Root object name 0, // Pointer depth to traverse (zero means stop at pointers) @@ -324,7 +328,7 @@ } else { - error_stream.PutCString(result_valobj_sp->GetError().AsCString()); + error_stream->PutCString(result_valobj_sp->GetError().AsCString()); if (result) result->SetStatus (eReturnStatusFailed); } @@ -332,7 +336,7 @@ } else { - error_stream.Printf ("error: invalid execution context for expression\n"); + error_stream->Printf ("error: invalid execution context for expression\n"); return false; } @@ -426,7 +430,7 @@ if (expr == NULL) expr = command; - if (EvaluateExpression (expr, result.GetOutputStream(), result.GetErrorStream(), &result)) + if (EvaluateExpression (expr, &(result.GetOutputStream()), &(result.GetErrorStream()), &result)) return true; result.SetStatus (eReturnStatusFailed); Modified: lldb/trunk/source/Commands/CommandObjectExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=132930&r1=132929&r2=132930&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.h (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.h Mon Jun 13 15:20:29 2011 @@ -89,8 +89,8 @@ bool EvaluateExpression (const char *expr, - Stream &output_stream, - Stream &error_stream, + Stream *output_stream, + Stream *error_stream, CommandReturnObject *result = NULL); CommandOptions m_options; From ctice at apple.com Mon Jun 13 16:33:00 2011 From: ctice at apple.com (Caroline Tice) Date: Mon, 13 Jun 2011 21:33:00 -0000 Subject: [Lldb-commits] [lldb] r132935 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110613213300.483C42A6C12C@llvm.org> Author: ctice Date: Mon Jun 13 16:33:00 2011 New Revision: 132935 URL: http://llvm.org/viewvc/llvm-project?rev=132935&view=rev Log: Cleaning up the Python script interpreter: Use the embedded_interpreter.py file rather than keeping it all in a string and compiling the string (easier to maintain, easier to read, remove redundancy). 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=132935&r1=132934&r2=132935&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Jun 13 16:33:00 2011 @@ -35,109 +35,6 @@ static ScriptInterpreter::SWIGInitCallback g_swig_init_callback = NULL; static ScriptInterpreter::SWIGBreakpointCallbackFunction g_swig_breakpoint_callback = NULL; -const char embedded_interpreter_string[] = -"import readline\n\ -import code\n\ -import sys\n\ -import traceback\n\ -\n\ -class SimpleREPL(code.InteractiveConsole):\n\ - def __init__(self, prompt, dict):\n\ - code.InteractiveConsole.__init__(self,dict)\n\ - self.prompt = prompt\n\ - self.loop_exit = False\n\ - self.dict = dict\n\ -\n\ - def interact(self):\n\ - try:\n\ - sys.ps1\n\ - except AttributeError:\n\ - sys.ps1 = \">>> \"\n\ - try:\n\ - sys.ps2\n\ - except AttributeError:\n\ - sys.ps2 = \"... \"\n\ -\n\ - while not self.loop_exit:\n\ - try:\n\ - self.read_py_command()\n\ - except (SystemExit, EOFError):\n\ - # EOF while in Python just breaks out to top level.\n\ - self.write('\\n')\n\ - self.loop_exit = True\n\ - break\n\ - except KeyboardInterrupt:\n\ - self.write(\"\\nKeyboardInterrupt\\n\")\n\ - self.resetbuffer()\n\ - more = 0\n\ - except:\n\ - traceback.print_exc()\n\ -\n\ - def process_input (self, in_str):\n\ - # Canonicalize the format of the input string\n\ - temp_str = in_str\n\ - temp_str.strip(' \t')\n\ - words = temp_str.split()\n\ - temp_str = ('').join(words)\n\ -\n\ - # Check the input string to see if it was the quit\n\ - # command. If so, intercept it, so that it doesn't\n\ - # close stdin on us!\n\ - if (temp_str.lower() == \"quit()\" or temp_str.lower() == \"exit()\"):\n\ - self.loop_exit = True\n\ - in_str = \"raise SystemExit \"\n\ - return in_str\n\ -\n\ - def my_raw_input (self, prompt):\n\ - stream = sys.stdout\n\ - stream.write (prompt)\n\ - stream.flush ()\n\ - try:\n\ - line = sys.stdin.readline()\n\ - except KeyboardInterrupt:\n\ - line = \" \\n\"\n\ - except (SystemExit, EOFError):\n\ - line = \"quit()\\n\"\n\ - if not line:\n\ - raise EOFError\n\ - if line[-1] == '\\n':\n\ - line = line[:-1]\n\ - return line\n\ -\n\ - def read_py_command(self):\n\ - # Read off a complete Python command.\n\ - more = 0\n\ - while 1:\n\ - if more:\n\ - prompt = sys.ps2\n\ - else:\n\ - prompt = sys.ps1\n\ - line = self.my_raw_input(prompt)\n\ - # Can be None if sys.stdin was redefined\n\ - encoding = getattr(sys.stdin, \"encoding\", None)\n\ - if encoding and not isinstance(line, unicode):\n\ - line = line.decode(encoding)\n\ - line = self.process_input (line)\n\ - more = self.push(line)\n\ - if not more:\n\ - break\n\ -\n\ - def one_line (self, input):\n\ - line = self.process_input (input)\n\ - more = self.push(line)\n\ - if more:\n\ - self.write (\"Input not a complete line.\")\n\ - self.resetbuffer()\n\ - more = 0\n\ -\n\ -def run_python_interpreter (dict):\n\ - # Pass in the dictionary, for continuity from one session to the next.\n\ - repl = SimpleREPL('>>> ', dict)\n\ - repl.interact()\n\ -\n\ -def run_one_line (dict, input_string):\n\ - repl = SimpleREPL ('', dict)\n\ - repl.one_line (input_string)\n"; static int _check_and_flush (FILE *stream) @@ -1542,44 +1439,21 @@ PyEval_InitThreads (); Py_InitializeEx (0); - PyObject *compiled_module = Py_CompileString (embedded_interpreter_string, - "embedded_interpreter.py", - Py_file_input); - - PyObject *py_error = PyErr_Occurred (); - if (py_error != NULL) - { - PyErr_Print(); - PyErr_Clear(); - } - - // Initialize SWIG after setting up python assert (g_swig_init_callback != NULL); g_swig_init_callback (); // Update the path python uses to search for modules to include the current directory. - int success = PyRun_SimpleString ("import sys"); - success = PyRun_SimpleString ("sys.path.append ('.')"); + PyRun_SimpleString ("import sys"); + PyRun_SimpleString ("sys.path.append ('.')"); - PyObject *pmod = NULL; + PyRun_SimpleString ("import embedded_interpreter"); - if (compiled_module) - { - pmod = PyImport_ExecCodeModule (const_cast ("embedded_interpreter"), - compiled_module); - Py_DECREF (compiled_module); - } - - if (pmod != NULL) - { - PyRun_SimpleString ("from embedded_interpreter import run_python_interpreter"); - PyRun_SimpleString ("from embedded_interpreter import run_one_line"); - PyRun_SimpleString ("import sys"); - PyRun_SimpleString ("from termios import *"); - Py_DECREF (pmod); - } + PyRun_SimpleString ("from embedded_interpreter import run_python_interpreter"); + PyRun_SimpleString ("from embedded_interpreter import run_one_line"); + PyRun_SimpleString ("import sys"); + PyRun_SimpleString ("from termios import *"); stdin_tty_state.Restore(); } From johnny.chen at apple.com Mon Jun 13 18:19:35 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 13 Jun 2011 23:19:35 -0000 Subject: [Lldb-commits] [lldb] r132951 - in /lldb/trunk/test: class_types/TestClassTypes.py hello_world/TestHelloWorld.py lldbtest.py Message-ID: <20110613231935.C8E6D2A6C132@llvm.org> Author: johnny Date: Mon Jun 13 18:19:35 2011 New Revision: 132951 URL: http://llvm.org/viewvc/llvm-project?rev=132951&view=rev Log: Removed unneeded method breakAfterLaunch() from the TestBase class to simplify our base class. It was introduced to work around some debugger infrastructure bug which has long since been fixed. Modified: lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/hello_world/TestHelloWorld.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=132951&r1=132950&r2=132951&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Mon Jun 13 18:19:35 2011 @@ -121,7 +121,6 @@ # Now launch the process, and do not stop at entry point. error = lldb.SBError() self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - #self.breakAfterLaunch(self.process, "C::C(int, int, int)") if not error.Success() or not self.process: self.fail("SBTarget.Launch() failed") Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=132951&r1=132950&r2=132951&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Mon Jun 13 18:19:35 2011 @@ -62,10 +62,6 @@ # On the other hand, the following line of code are more reliable. self.runCmd("run", setCookie=False) - #self.runCmd("thread backtrace") - #self.runCmd("breakpoint list") - #self.runCmd("thread list") - self.process = target.GetProcess() self.assertTrue(self.process, PROCESS_IS_VALID) Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=132951&r1=132950&r2=132951&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Mon Jun 13 18:19:35 2011 @@ -879,46 +879,6 @@ print >> sbuf, str(method) + ":", result return result - def breakAfterLaunch(self, process, func, trace=False): - """ - Perform some dances after Launch() to break at func name. - - Return True if we can successfully break at the func name in due time. - """ - trace = (True if traceAlways else trace) - - count = 0 - while True: - # The stop reason of the thread should be breakpoint. - thread = process.GetThreadAtIndex(0) - SR = thread.GetStopReason() - with recording(self, trace) as sbuf: - print >> sbuf, "StopReason =", stop_reason_to_str(SR) - - if SR == lldb.eStopReasonBreakpoint: - frame = thread.GetFrameAtIndex(0) - name = frame.GetFunction().GetName() - with recording(self, trace) as sbuf: - print >> sbuf, "function =", name - if (name == func): - # We got what we want; now break out of the loop. - return True - - # The inferior is in a transient state; continue the process. - time.sleep(1.0) - with recording(self, trace) as sbuf: - print >> sbuf, "Continuing the process:", process - process.Continue() - - count = count + 1 - if count == 15: - with recording(self, trace) as sbuf: - print >> sbuf, "Reached 15 iterations, giving up..." - # Enough iterations already, break out of the loop. - return False - - # End of while loop. - # ==================================================== # Config. methods supported through a plugin interface # (enables reading of the current test configuration) From gclayton at apple.com Mon Jun 13 20:53:36 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Jun 2011 01:53:36 -0000 Subject: [Lldb-commits] [lldb] r132960 - /lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Message-ID: <20110614015336.AA8AA2A6C12C@llvm.org> Author: gclayton Date: Mon Jun 13 20:53:36 2011 New Revision: 132960 URL: http://llvm.org/viewvc/llvm-project?rev=132960&view=rev Log: Remove assert() calls that were firing off and crashing the LLDB framework. Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp 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=132960&r1=132959&r2=132960&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Mon Jun 13 20:53:36 2011 @@ -366,14 +366,25 @@ for (uint32_t i=0; iFindSectionByName(info.segments[i].name)); - assert (section_sp.get() != NULL); const addr_t new_section_load_addr = info.segments[i].vmaddr + info.slide; - const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section_sp.get()); - if (old_section_load_addr == LLDB_INVALID_ADDRESS || - old_section_load_addr != new_section_load_addr) + if (section_sp) { - if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), new_section_load_addr)) - changed = true; + const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section_sp.get()); + if (old_section_load_addr == LLDB_INVALID_ADDRESS || + old_section_load_addr != new_section_load_addr) + { + if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), new_section_load_addr)) + changed = true; + } + } + else + { + fprintf (stderr, + "warning: unable to find and load segment named '%s' at 0x%llx in '%s/%s' in macosx dynamic loader plug-in.\n", + info.segments[i].name.AsCString(""), + (uint64_t)new_section_load_addr, + image_object_file->GetFileSpec().GetDirectory().AsCString(), + image_object_file->GetFileSpec().GetFilename().AsCString()); } } } @@ -402,10 +413,20 @@ for (uint32_t i=0; iFindSectionByName(info.segments[i].name)); - assert (section_sp.get() != NULL); - const addr_t old_section_load_addr = info.segments[i].vmaddr + info.slide; - if (m_process->GetTarget().GetSectionLoadList().SetSectionUnloaded (section_sp.get(), old_section_load_addr)) - changed = true; + if (section_sp) + { + const addr_t old_section_load_addr = info.segments[i].vmaddr + info.slide; + if (m_process->GetTarget().GetSectionLoadList().SetSectionUnloaded (section_sp.get(), old_section_load_addr)) + changed = true; + } + else + { + fprintf (stderr, + "warning: unable to find and unload segment named '%s' in '%s/%s' in macosx dynamic loader plug-in.\n", + info.segments[i].name.AsCString(""), + image_object_file->GetFileSpec().GetDirectory().AsCString(), + image_object_file->GetFileSpec().GetFilename().AsCString()); + } } } } @@ -472,7 +493,7 @@ addr_size + // errorClientOfDylibPath addr_size + // errorTargetDylibPath addr_size; // errorSymbol - assert (sizeof (buf) > count_v11); + assert (sizeof (buf) >= count_v11); int count; Error error; @@ -598,9 +619,8 @@ { uint32_t info_data_offset = 0; DataExtractor info_data_ref(info_data.GetBytes(), info_data.GetByteSize(), endian, addr_size); - for (i = 0; info_data_ref.ValidOffset(info_data_offset); i++) + for (i = 0; i < m_dyld_image_infos.size() && info_data_ref.ValidOffset(info_data_offset); i++) { - assert (i < m_dyld_image_infos.size()); m_dyld_image_infos[i].address = info_data_ref.GetPointer(&info_data_offset); lldb::addr_t path_addr = info_data_ref.GetPointer(&info_data_offset); m_dyld_image_infos[i].mod_date = info_data_ref.GetPointer(&info_data_offset); @@ -611,7 +631,6 @@ const bool resolve_path = false; m_dyld_image_infos[i].file_spec.SetFile(raw_path, resolve_path); } - assert(i == m_dyld_all_image_infos.dylib_info_count); UpdateAllImageInfosHeaderAndLoadCommands(); } From peter at pcc.me.uk Mon Jun 13 22:55:29 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 14 Jun 2011 03:55:29 -0000 Subject: [Lldb-commits] [lldb] r132965 - /lldb/trunk/source/Commands/CommandObjectThread.cpp Message-ID: <20110614035530.0B1002A6C12C@llvm.org> Author: pcc Date: Mon Jun 13 22:55:29 2011 New Revision: 132965 URL: http://llvm.org/viewvc/llvm-project?rev=132965&view=rev Log: Fix typo: fucntion -> function Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=132965&r1=132964&r2=132965&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Mon Jun 13 22:55:29 2011 @@ -1244,7 +1244,7 @@ LoadSubCommand ("step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( interpreter, "thread step-out", - "Finish executing the current fucntion and return to its call site in specified thread (current thread, if none specified).", + "Finish executing the current function and return to its call site in specified thread (current thread, if none specified).", NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOut, From peter at pcc.me.uk Mon Jun 13 22:55:34 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 14 Jun 2011 03:55:34 -0000 Subject: [Lldb-commits] [lldb] r132966 - /lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Message-ID: <20110614035534.73C692A6C12D@llvm.org> Author: pcc Date: Mon Jun 13 22:55:34 2011 New Revision: 132966 URL: http://llvm.org/viewvc/llvm-project?rev=132966&view=rev Log: Add license header to InferiorCallPOSIX.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp?rev=132966&r1=132965&r2=132966&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Mon Jun 13 22:55:34 2011 @@ -1,3 +1,12 @@ +//===-- InferiorCallPOSIX.cpp -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + #include "InferiorCallPOSIX.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" From peter at pcc.me.uk Mon Jun 13 22:55:38 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 14 Jun 2011 03:55:38 -0000 Subject: [Lldb-commits] [lldb] r132967 - /lldb/trunk/include/lldb/Core/History.h Message-ID: <20110614035538.6859A2A6C12C@llvm.org> Author: pcc Date: Mon Jun 13 22:55:38 2011 New Revision: 132967 URL: http://llvm.org/viewvc/llvm-project?rev=132967&view=rev Log: Declare CompareHistoryEvents and IsCurrentHistoryEvent as pure virtual functions Fixes the Linux build. Modified: lldb/trunk/include/lldb/Core/History.h Modified: lldb/trunk/include/lldb/Core/History.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/History.h?rev=132967&r1=132966&r2=132967&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/History.h (original) +++ lldb/trunk/include/lldb/Core/History.h Mon Jun 13 22:55:38 2011 @@ -70,10 +70,10 @@ // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs. virtual int CompareHistoryEvents (const HistoryEvent lhs, - const HistoryEvent rhs); + const HistoryEvent rhs) = 0; virtual bool - IsCurrentHistoryEvent (const HistoryEvent event); + IsCurrentHistoryEvent (const HistoryEvent event) = 0; private: typedef std::stack collection; From peter at pcc.me.uk Mon Jun 13 22:55:41 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 14 Jun 2011 03:55:41 -0000 Subject: [Lldb-commits] [lldb] r132968 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110614035541.E81732A6C12D@llvm.org> Author: pcc Date: Mon Jun 13 22:55:41 2011 New Revision: 132968 URL: http://llvm.org/viewvc/llvm-project?rev=132968&view=rev Log: Generalise pattern for matching IsValid signature Previously the IsValid pattern matched only function signatures of the form: def IsValid(*args): ... However under SWIG 1.3.40 on Linux the signature reads: def IsValid(self): ... The new pattern matches both signature types by matching only up to the left paren. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=132968&r1=132967&r2=132968&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Mon Jun 13 22:55:41 2011 @@ -123,7 +123,7 @@ init_pattern = re.compile("^ def __init__\(self, \*args\):") # The pattern for recognizing the beginning of the IsValid method definition. -isvalid_pattern = re.compile("^ def IsValid\(\*args\):") +isvalid_pattern = re.compile("^ def IsValid\(") # These define the states of our finite state machine. NORMAL = 0 From peter at pcc.me.uk Mon Jun 13 22:55:49 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 14 Jun 2011 03:55:49 -0000 Subject: [Lldb-commits] [lldb] r132970 - /lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Message-ID: <20110614035549.CCFC32A6C12D@llvm.org> Author: pcc Date: Mon Jun 13 22:55:49 2011 New Revision: 132970 URL: http://llvm.org/viewvc/llvm-project?rev=132970&view=rev Log: If ProcessMonitor::Launch fails, post semaphore to notify caller Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=132970&r1=132969&r2=132970&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Mon Jun 13 22:55:49 2011 @@ -659,8 +659,10 @@ { LaunchArgs *args = static_cast(arg); - if (!Launch(args)) + if (!Launch(args)) { + sem_post(&args->m_semaphore); return NULL; + } ServeOperation(args); return NULL; From peter at pcc.me.uk Mon Jun 13 22:55:45 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 14 Jun 2011 03:55:45 -0000 Subject: [Lldb-commits] [lldb] r132969 - /lldb/trunk/test/dotest.py Message-ID: <20110614035545.6EC562A6C12C@llvm.org> Author: pcc Date: Mon Jun 13 22:55:45 2011 New Revision: 132969 URL: http://llvm.org/viewvc/llvm-project?rev=132969&view=rev Log: Fix typo: curret -> current 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=132969&r1=132968&r2=132969&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Jun 13 22:55:45 2011 @@ -193,7 +193,7 @@ and: 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 + if empty, search from the current working directory, instead """ if verbose > 0: From peter at pcc.me.uk Mon Jun 13 22:55:54 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 14 Jun 2011 03:55:54 -0000 Subject: [Lldb-commits] [lldb] r132971 - /lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Message-ID: <20110614035554.2CAB02A6C12C@llvm.org> Author: pcc Date: Mon Jun 13 22:55:54 2011 New Revision: 132971 URL: http://llvm.org/viewvc/llvm-project?rev=132971&view=rev Log: Fix mistakes relating to ProcessMonitor::DupDescriptor Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=132971&r1=132970&r2=132971&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Mon Jun 13 22:55:54 2011 @@ -722,7 +722,7 @@ // FIXME: If two or more of the paths are the same we needlessly open // the same file multiple times. if (stdin_path != NULL && stdin_path[0]) - if (!DupDescriptor(stdin_path, STDIN_FILENO, O_RDONLY | O_CREAT)) + if (!DupDescriptor(stdin_path, STDIN_FILENO, O_RDONLY)) exit(1); if (stdout_path != NULL && stdout_path[0]) @@ -730,7 +730,7 @@ exit(1); if (stderr_path != NULL && stderr_path[0]) - if (!DupDescriptor(stderr_path, STDOUT_FILENO, O_WRONLY | O_CREAT)) + if (!DupDescriptor(stderr_path, STDERR_FILENO, O_WRONLY | O_CREAT)) exit(1); // Execute. We should never return. @@ -1263,12 +1263,12 @@ bool ProcessMonitor::DupDescriptor(const char *path, int fd, int flags) { - int target_fd = open(path, flags); + int target_fd = open(path, flags, 0666); if (target_fd == -1) return false; - return (dup2(fd, target_fd) == -1) ? false : true; + return (dup2(target_fd, fd) == -1) ? false : true; } void From peter at pcc.me.uk Mon Jun 13 22:55:58 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 14 Jun 2011 03:55:58 -0000 Subject: [Lldb-commits] [lldb] r132972 - /lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Message-ID: <20110614035558.E64592A6C12D@llvm.org> Author: pcc Date: Mon Jun 13 22:55:58 2011 New Revision: 132972 URL: http://llvm.org/viewvc/llvm-project?rev=132972&view=rev Log: Improve error reporting in ProcessMonitor::Launch Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=132972&r1=132971&r2=132972&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Mon Jun 13 22:55:58 2011 @@ -705,11 +705,21 @@ goto FINISH; } + // Recognized child exit status codes. + enum { + ePtraceFailed = 1, + eDupStdinFailed, + eDupStdoutFailed, + eDupStderrFailed, + eExecFailed + }; + // Child process. if (pid == 0) { // Trace this process. - ptrace(PTRACE_TRACEME, 0, NULL, NULL); + if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) < 0) + exit(ePtraceFailed); // Do not inherit setgid powers. setgid(getgid()); @@ -723,32 +733,60 @@ // the same file multiple times. if (stdin_path != NULL && stdin_path[0]) if (!DupDescriptor(stdin_path, STDIN_FILENO, O_RDONLY)) - exit(1); + exit(eDupStdinFailed); if (stdout_path != NULL && stdout_path[0]) if (!DupDescriptor(stdout_path, STDOUT_FILENO, O_WRONLY | O_CREAT)) - exit(1); + exit(eDupStdoutFailed); if (stderr_path != NULL && stderr_path[0]) if (!DupDescriptor(stderr_path, STDERR_FILENO, O_WRONLY | O_CREAT)) - exit(1); + exit(eDupStderrFailed); // Execute. We should never return. execve(argv[0], const_cast(argv), const_cast(envp)); - exit(-1); + exit(eExecFailed); } // Wait for the child process to to trap on its call to execve. + pid_t wpid; int status; - if ((status = waitpid(pid, NULL, 0)) < 0) + if ((wpid = waitpid(pid, &status, 0)) < 0) { - // execve likely failed for some reason. args->m_error.SetErrorToErrno(); goto FINISH; } - assert(status == pid && "Could not sync with inferior process."); + else if (WIFEXITED(status)) + { + // open, dup or execve likely failed for some reason. + args->m_error.SetErrorToGenericError(); + switch (WEXITSTATUS(status)) + { + case ePtraceFailed: + args->m_error.SetErrorString("Child ptrace failed."); + break; + case eDupStdinFailed: + args->m_error.SetErrorString("Child open stdin failed."); + break; + case eDupStdoutFailed: + args->m_error.SetErrorString("Child open stdout failed."); + break; + case eDupStderrFailed: + args->m_error.SetErrorString("Child open stderr failed."); + break; + case eExecFailed: + args->m_error.SetErrorString("Child exec failed."); + break; + default: + args->m_error.SetErrorString("Child returned unknown exit status."); + break; + } + goto FINISH; + } + assert(WIFSTOPPED(status) && wpid == pid && + "Could not sync with inferior process."); // Have the child raise an event on exit. This is used to keep the child in // limbo until it is destroyed. From mminutoli at gmail.com Tue Jun 14 07:48:53 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Tue, 14 Jun 2011 14:48:53 +0200 Subject: [Lldb-commits] [PATCH] Primitive attach support for linux Message-ID: <1308055733-5102-1-git-send-email-mminutoli@gmail.com> This patch is a starting point for the attach functionality. --- source/Plugins/Process/Linux/ProcessLinux.cpp | 11 ++- source/Plugins/Process/Linux/ProcessMonitor.cpp | 178 +++++++++++++++++++++-- source/Plugins/Process/Linux/ProcessMonitor.h | 49 ++++++- 3 files changed, 214 insertions(+), 24 deletions(-) diff --git a/source/Plugins/Process/Linux/ProcessLinux.cpp b/source/Plugins/Process/Linux/ProcessLinux.cpp index c4ce8ee..e6940fe 100644 --- a/source/Plugins/Process/Linux/ProcessLinux.cpp +++ b/source/Plugins/Process/Linux/ProcessLinux.cpp @@ -105,7 +105,16 @@ ProcessLinux::CanDebug(Target &target) Error ProcessLinux::DoAttachToProcessWithID(lldb::pid_t pid) { - return Error(1, eErrorTypeGeneric); + Error error; + assert(m_monitor == NULL); + + m_monitor = new ProcessMonitor(this, pid, error); + + if (!error.Success()) + return error; + + SetID(pid); + return error; } Error diff --git a/source/Plugins/Process/Linux/ProcessMonitor.cpp b/source/Plugins/Process/Linux/ProcessMonitor.cpp index ce16159..ebe5959 100644 --- a/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -524,6 +524,17 @@ KillOperation::Execute(ProcessMonitor *monitor) m_result = true; } +ProcessMonitor::OperationArgs::OperationArgs(ProcessMonitor *monitor) + : m_monitor(monitor) +{ + sem_init(&m_semaphore, 0, 0); +} + +ProcessMonitor::OperationArgs::~OperationArgs() +{ + sem_destroy(&m_semaphore); +} + ProcessMonitor::LaunchArgs::LaunchArgs(ProcessMonitor *monitor, lldb_private::Module *module, char const **argv, @@ -531,21 +542,23 @@ ProcessMonitor::LaunchArgs::LaunchArgs(ProcessMonitor *monitor, const char *stdin_path, const char *stdout_path, const char *stderr_path) - : m_monitor(monitor), + : OperationArgs(monitor), m_module(module), m_argv(argv), m_envp(envp), m_stdin_path(stdin_path), m_stdout_path(stdout_path), - m_stderr_path(stderr_path) -{ - sem_init(&m_semaphore, 0, 0); -} + m_stderr_path(stderr_path) { } ProcessMonitor::LaunchArgs::~LaunchArgs() -{ - sem_destroy(&m_semaphore); -} +{ } + +ProcessMonitor::AttachArgs::AttachArgs(ProcessMonitor *monitor, + lldb::pid_t pid) + : OperationArgs(monitor), m_pid(pid) { } + +ProcessMonitor::AttachArgs::~AttachArgs() +{ } //------------------------------------------------------------------------------ /// The basic design of the ProcessMonitor is built around two threads. @@ -587,7 +600,7 @@ ProcessMonitor::ProcessMonitor(ProcessLinux *process, error.SetErrorString("Monitor failed to initialize."); } - StartOperationThread(args.get(), error); + StartLaunchOpThread(args.get(), error); if (!error.Success()) return; @@ -607,7 +620,7 @@ WAIT_AGAIN: // Check that the launch was a success. if (!args->m_error.Success()) { - StopOperationThread(); + StopLaunchOpThread(); error = args->m_error; return; } @@ -623,6 +636,64 @@ WAIT_AGAIN: } } +ProcessMonitor::ProcessMonitor(ProcessLinux *process, + lldb::pid_t pid, + lldb_private::Error &error) + : m_process(process), + m_operation_thread(LLDB_INVALID_HOST_THREAD), + m_pid(LLDB_INVALID_PROCESS_ID), + m_terminal_fd(-1), + m_monitor_thread(LLDB_INVALID_HOST_THREAD), + m_client_fd(-1), + m_server_fd(-1) +{ + std::auto_ptr args; + + args.reset(new AttachArgs(this, pid)); + + // Server/client descriptors. + if (!EnableIPC()) + { + error.SetErrorToGenericError(); + error.SetErrorString("Monitor failed to initialize."); + } + + StartAttachOpThread(args.get(), error); + if (!error.Success()) + return; + +WAIT_AGAIN: + // Wait for the operation thread to initialize. + if (sem_wait(&args->m_semaphore)) + { + if (errno == EINTR) + goto WAIT_AGAIN; + else + { + error.SetErrorToErrno(); + return; + } + } + + // Check that the launch was a success. + if (!args->m_error.Success()) + { + StopAttachOpThread(); + error = args->m_error; + return; + } + + // Finally, start monitoring the child process for change in state. + m_monitor_thread = Host::StartMonitoringChildProcess( + ProcessMonitor::MonitorCallback, this, GetPID(), true); + if (!IS_VALID_LLDB_HOST_THREAD(m_monitor_thread)) + { + error.SetErrorToGenericError(); + error.SetErrorString("Process attach failed."); + return; + } +} + ProcessMonitor::~ProcessMonitor() { StopMonitor(); @@ -631,7 +702,7 @@ ProcessMonitor::~ProcessMonitor() //------------------------------------------------------------------------------ // Thread setup and tear down. void -ProcessMonitor::StartOperationThread(LaunchArgs *args, Error &error) +ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Error &error) { static const char *g_thread_name = "lldb.process.linux.operation"; @@ -639,11 +710,11 @@ ProcessMonitor::StartOperationThread(LaunchArgs *args, Error &error) return; m_operation_thread = - Host::ThreadCreate(g_thread_name, OperationThread, args, &error); + Host::ThreadCreate(g_thread_name, LaunchOpThread, args, &error); } void -ProcessMonitor::StopOperationThread() +ProcessMonitor::StopLaunchOpThread() { lldb::thread_result_t result; @@ -655,7 +726,7 @@ ProcessMonitor::StopOperationThread() } void * -ProcessMonitor::OperationThread(void *arg) +ProcessMonitor::LaunchOpThread(void *arg) { LaunchArgs *args = static_cast(arg); @@ -833,6 +904,80 @@ ProcessMonitor::EnableIPC() return true; } +void +ProcessMonitor::StartAttachOpThread(AttachArgs *args, lldb_private::Error &error) +{ + static const char *g_thread_name = "lldb.process.linux.operation"; + + if (IS_VALID_LLDB_HOST_THREAD(m_operation_thread)) + return; + + m_operation_thread = + Host::ThreadCreate(g_thread_name, AttachOpThread, args, &error); +} + +void +ProcessMonitor::StopAttachOpThread() +{ + assert(!"Not implemented yet!!!"); +} + +void * +ProcessMonitor::AttachOpThread(void *arg) +{ + AttachArgs *args = static_cast(arg); + + if (!Attach(args)) + return NULL; + + ServeOperation(args); + return NULL; +} + +bool +ProcessMonitor::Attach(AttachArgs *args) +{ + lldb::pid_t pid = args->m_pid; + + ProcessMonitor *monitor = args->m_monitor; + ProcessLinux &process = monitor->GetProcess(); + + lldb::ThreadSP inferior; + + if (pid <= 1) + { + args->m_error.SetErrorToGenericError(); + args->m_error.SetErrorString("Attaching to process 1 is not allowed."); + goto FINISH; + } + + // Attach to the requested process. + if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) + { + args->m_error.SetErrorToErrno(); + goto FINISH; + } + + int status; + if ((status = waitpid(pid, NULL, 0)) < 0) + { + args->m_error.SetErrorToErrno(); + goto FINISH; + } + + // Update the process thread list with the attached thread and + // mark it as current. + inferior.reset(new LinuxThread(process, pid)); + process.GetThreadList().AddThread(inferior); + process.GetThreadList().SetSelectedThreadByID(pid); + + // Let our process instance know the thread has stopped. + process.SendMessage(ProcessMessage::Trace(pid)); + + FINISH: + return args->m_error.Success(); +} + bool ProcessMonitor::MonitorCallback(void *callback_baton, lldb::pid_t pid, @@ -1094,10 +1239,11 @@ ProcessMonitor::GetCrashReasonForSIGBUS(const struct siginfo *info) } void -ProcessMonitor::ServeOperation(LaunchArgs *args) +ProcessMonitor::ServeOperation(OperationArgs *args) { int status; pollfd fdset; + ProcessMonitor *monitor = args->m_monitor; fdset.fd = monitor->m_server_fd; @@ -1326,7 +1472,7 @@ void ProcessMonitor::StopMonitor() { StopMonitoringChildProcess(); - StopOperationThread(); + StopLaunchOpThread(); CloseFD(m_terminal_fd); CloseFD(m_client_fd); CloseFD(m_server_fd); diff --git a/source/Plugins/Process/Linux/ProcessMonitor.h b/source/Plugins/Process/Linux/ProcessMonitor.h index 9b8051b..ef9a179 100644 --- a/source/Plugins/Process/Linux/ProcessMonitor.h +++ b/source/Plugins/Process/Linux/ProcessMonitor.h @@ -56,6 +56,10 @@ public: const char *stderr_path, lldb_private::Error &error); + ProcessMonitor(ProcessLinux *process, + lldb::pid_t pid, + lldb_private::Error &error); + ~ProcessMonitor(); /// Provides the process number of debugee. @@ -169,11 +173,22 @@ private: int m_client_fd; int m_server_fd; + struct OperationArgs + { + OperationArgs(ProcessMonitor *monitor); + + ~OperationArgs(); + + ProcessMonitor *m_monitor; // The monitor performing the attach. + sem_t m_semaphore; // Posted to once operation complete. + lldb_private::Error m_error; // Set if process operation failed. + }; + /// @class LauchArgs /// /// @brief Simple structure to pass data to the thread responsible for /// launching a child process. - struct LaunchArgs + struct LaunchArgs : OperationArgs { LaunchArgs(ProcessMonitor *monitor, lldb_private::Module *module, @@ -192,18 +207,16 @@ private: const char *m_stdin_path; // Redirect stdin or NULL. const char *m_stdout_path; // Redirect stdout or NULL. const char *m_stderr_path; // Redirect stderr or NULL. - sem_t m_semaphore; // Posted to once launch complete. - lldb_private::Error m_error; // Set if process launch failed. }; void - StartOperationThread(LaunchArgs *args, lldb_private::Error &error); + StartLaunchOpThread(LaunchArgs *args, lldb_private::Error &error); void - StopOperationThread(); + StopLaunchOpThread(); static void * - OperationThread(void *arg); + LaunchOpThread(void *arg); static bool Launch(LaunchArgs *args); @@ -211,8 +224,30 @@ private: bool EnableIPC(); + struct AttachArgs : OperationArgs + { + AttachArgs(ProcessMonitor *monitor, + lldb::pid_t pid); + + ~AttachArgs(); + + lldb::pid_t m_pid; // pid of the process to be attached. + }; + + void + StartAttachOpThread(AttachArgs *args, lldb_private::Error &error); + + void + StopAttachOpThread(); + + static void * + AttachOpThread(void *args); + + static bool + Attach(AttachArgs *args); + static void - ServeOperation(LaunchArgs *args); + ServeOperation(OperationArgs *args); static bool DupDescriptor(const char *path, int fd, int flags); -- 1.7.3.4 From gclayton at apple.com Tue Jun 14 10:38:33 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Jun 2011 08:38:33 -0700 Subject: [Lldb-commits] [PATCH] Primitive attach support for linux In-Reply-To: <1308055733-5102-1-git-send-email-mminutoli@gmail.com> References: <1308055733-5102-1-git-send-email-mminutoli@gmail.com> Message-ID: <182D6365-C98A-45EC-8A84-0C856466F168@apple.com> This patch is in linux files only, so feel free to commit as long as no one else has any objections! Greg Clayton On Jun 14, 2011, at 5:48 AM, Marco Minutoli wrote: > This patch is a starting point for the attach functionality. > --- > source/Plugins/Process/Linux/ProcessLinux.cpp | 11 ++- > source/Plugins/Process/Linux/ProcessMonitor.cpp | 178 +++++++++++++++++++++-- > source/Plugins/Process/Linux/ProcessMonitor.h | 49 ++++++- > 3 files changed, 214 insertions(+), 24 deletions(-) > > diff --git a/source/Plugins/Process/Linux/ProcessLinux.cpp b/source/Plugins/Process/Linux/ProcessLinux.cpp > index c4ce8ee..e6940fe 100644 > --- a/source/Plugins/Process/Linux/ProcessLinux.cpp > +++ b/source/Plugins/Process/Linux/ProcessLinux.cpp > @@ -105,7 +105,16 @@ ProcessLinux::CanDebug(Target &target) > Error > ProcessLinux::DoAttachToProcessWithID(lldb::pid_t pid) > { > - return Error(1, eErrorTypeGeneric); > + Error error; > + assert(m_monitor == NULL); > + > + m_monitor = new ProcessMonitor(this, pid, error); > + > + if (!error.Success()) > + return error; > + > + SetID(pid); > + return error; > } > > Error > diff --git a/source/Plugins/Process/Linux/ProcessMonitor.cpp b/source/Plugins/Process/Linux/ProcessMonitor.cpp > index ce16159..ebe5959 100644 > --- a/source/Plugins/Process/Linux/ProcessMonitor.cpp > +++ b/source/Plugins/Process/Linux/ProcessMonitor.cpp > @@ -524,6 +524,17 @@ KillOperation::Execute(ProcessMonitor *monitor) > m_result = true; > } > > +ProcessMonitor::OperationArgs::OperationArgs(ProcessMonitor *monitor) > + : m_monitor(monitor) > +{ > + sem_init(&m_semaphore, 0, 0); > +} > + > +ProcessMonitor::OperationArgs::~OperationArgs() > +{ > + sem_destroy(&m_semaphore); > +} > + > ProcessMonitor::LaunchArgs::LaunchArgs(ProcessMonitor *monitor, > lldb_private::Module *module, > char const **argv, > @@ -531,21 +542,23 @@ ProcessMonitor::LaunchArgs::LaunchArgs(ProcessMonitor *monitor, > const char *stdin_path, > const char *stdout_path, > const char *stderr_path) > - : m_monitor(monitor), > + : OperationArgs(monitor), > m_module(module), > m_argv(argv), > m_envp(envp), > m_stdin_path(stdin_path), > m_stdout_path(stdout_path), > - m_stderr_path(stderr_path) > -{ > - sem_init(&m_semaphore, 0, 0); > -} > + m_stderr_path(stderr_path) { } > > ProcessMonitor::LaunchArgs::~LaunchArgs() > -{ > - sem_destroy(&m_semaphore); > -} > +{ } > + > +ProcessMonitor::AttachArgs::AttachArgs(ProcessMonitor *monitor, > + lldb::pid_t pid) > + : OperationArgs(monitor), m_pid(pid) { } > + > +ProcessMonitor::AttachArgs::~AttachArgs() > +{ } > > //------------------------------------------------------------------------------ > /// The basic design of the ProcessMonitor is built around two threads. > @@ -587,7 +600,7 @@ ProcessMonitor::ProcessMonitor(ProcessLinux *process, > error.SetErrorString("Monitor failed to initialize."); > } > > - StartOperationThread(args.get(), error); > + StartLaunchOpThread(args.get(), error); > if (!error.Success()) > return; > > @@ -607,7 +620,7 @@ WAIT_AGAIN: > // Check that the launch was a success. > if (!args->m_error.Success()) > { > - StopOperationThread(); > + StopLaunchOpThread(); > error = args->m_error; > return; > } > @@ -623,6 +636,64 @@ WAIT_AGAIN: > } > } > > +ProcessMonitor::ProcessMonitor(ProcessLinux *process, > + lldb::pid_t pid, > + lldb_private::Error &error) > + : m_process(process), > + m_operation_thread(LLDB_INVALID_HOST_THREAD), > + m_pid(LLDB_INVALID_PROCESS_ID), > + m_terminal_fd(-1), > + m_monitor_thread(LLDB_INVALID_HOST_THREAD), > + m_client_fd(-1), > + m_server_fd(-1) > +{ > + std::auto_ptr args; > + > + args.reset(new AttachArgs(this, pid)); > + > + // Server/client descriptors. > + if (!EnableIPC()) > + { > + error.SetErrorToGenericError(); > + error.SetErrorString("Monitor failed to initialize."); > + } > + > + StartAttachOpThread(args.get(), error); > + if (!error.Success()) > + return; > + > +WAIT_AGAIN: > + // Wait for the operation thread to initialize. > + if (sem_wait(&args->m_semaphore)) > + { > + if (errno == EINTR) > + goto WAIT_AGAIN; > + else > + { > + error.SetErrorToErrno(); > + return; > + } > + } > + > + // Check that the launch was a success. > + if (!args->m_error.Success()) > + { > + StopAttachOpThread(); > + error = args->m_error; > + return; > + } > + > + // Finally, start monitoring the child process for change in state. > + m_monitor_thread = Host::StartMonitoringChildProcess( > + ProcessMonitor::MonitorCallback, this, GetPID(), true); > + if (!IS_VALID_LLDB_HOST_THREAD(m_monitor_thread)) > + { > + error.SetErrorToGenericError(); > + error.SetErrorString("Process attach failed."); > + return; > + } > +} > + > ProcessMonitor::~ProcessMonitor() > { > StopMonitor(); > @@ -631,7 +702,7 @@ ProcessMonitor::~ProcessMonitor() > //------------------------------------------------------------------------------ > // Thread setup and tear down. > void > -ProcessMonitor::StartOperationThread(LaunchArgs *args, Error &error) > +ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Error &error) > { > static const char *g_thread_name = "lldb.process.linux.operation"; > > @@ -639,11 +710,11 @@ ProcessMonitor::StartOperationThread(LaunchArgs *args, Error &error) > return; > > m_operation_thread = > - Host::ThreadCreate(g_thread_name, OperationThread, args, &error); > + Host::ThreadCreate(g_thread_name, LaunchOpThread, args, &error); > } > > void > -ProcessMonitor::StopOperationThread() > +ProcessMonitor::StopLaunchOpThread() > { > lldb::thread_result_t result; > > @@ -655,7 +726,7 @@ ProcessMonitor::StopOperationThread() > } > > void * > -ProcessMonitor::OperationThread(void *arg) > +ProcessMonitor::LaunchOpThread(void *arg) > { > LaunchArgs *args = static_cast(arg); > > @@ -833,6 +904,80 @@ ProcessMonitor::EnableIPC() > return true; > } > > +void > +ProcessMonitor::StartAttachOpThread(AttachArgs *args, lldb_private::Error &error) > +{ > + static const char *g_thread_name = "lldb.process.linux.operation"; > + > + if (IS_VALID_LLDB_HOST_THREAD(m_operation_thread)) > + return; > + > + m_operation_thread = > + Host::ThreadCreate(g_thread_name, AttachOpThread, args, &error); > +} > + > +void > +ProcessMonitor::StopAttachOpThread() > +{ > + assert(!"Not implemented yet!!!"); > +} > + > +void * > +ProcessMonitor::AttachOpThread(void *arg) > +{ > + AttachArgs *args = static_cast(arg); > + > + if (!Attach(args)) > + return NULL; > + > + ServeOperation(args); > + return NULL; > +} > + > +bool > +ProcessMonitor::Attach(AttachArgs *args) > +{ > + lldb::pid_t pid = args->m_pid; > + > + ProcessMonitor *monitor = args->m_monitor; > + ProcessLinux &process = monitor->GetProcess(); > + > + lldb::ThreadSP inferior; > + > + if (pid <= 1) > + { > + args->m_error.SetErrorToGenericError(); > + args->m_error.SetErrorString("Attaching to process 1 is not allowed."); > + goto FINISH; > + } > + > + // Attach to the requested process. > + if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) > + { > + args->m_error.SetErrorToErrno(); > + goto FINISH; > + } > + > + int status; > + if ((status = waitpid(pid, NULL, 0)) < 0) > + { > + args->m_error.SetErrorToErrno(); > + goto FINISH; > + } > + > + // Update the process thread list with the attached thread and > + // mark it as current. > + inferior.reset(new LinuxThread(process, pid)); > + process.GetThreadList().AddThread(inferior); > + process.GetThreadList().SetSelectedThreadByID(pid); > + > + // Let our process instance know the thread has stopped. > + process.SendMessage(ProcessMessage::Trace(pid)); > + > + FINISH: > + return args->m_error.Success(); > +} > + > bool > ProcessMonitor::MonitorCallback(void *callback_baton, > lldb::pid_t pid, > @@ -1094,10 +1239,11 @@ ProcessMonitor::GetCrashReasonForSIGBUS(const struct siginfo *info) > } > > void > -ProcessMonitor::ServeOperation(LaunchArgs *args) > +ProcessMonitor::ServeOperation(OperationArgs *args) > { > int status; > pollfd fdset; > + > ProcessMonitor *monitor = args->m_monitor; > > fdset.fd = monitor->m_server_fd; > @@ -1326,7 +1472,7 @@ void > ProcessMonitor::StopMonitor() > { > StopMonitoringChildProcess(); > - StopOperationThread(); > + StopLaunchOpThread(); > CloseFD(m_terminal_fd); > CloseFD(m_client_fd); > CloseFD(m_server_fd); > diff --git a/source/Plugins/Process/Linux/ProcessMonitor.h b/source/Plugins/Process/Linux/ProcessMonitor.h > index 9b8051b..ef9a179 100644 > --- a/source/Plugins/Process/Linux/ProcessMonitor.h > +++ b/source/Plugins/Process/Linux/ProcessMonitor.h > @@ -56,6 +56,10 @@ public: > const char *stderr_path, > lldb_private::Error &error); > > + ProcessMonitor(ProcessLinux *process, > + lldb::pid_t pid, > + lldb_private::Error &error); > + > ~ProcessMonitor(); > > /// Provides the process number of debugee. > @@ -169,11 +173,22 @@ private: > int m_client_fd; > int m_server_fd; > > + struct OperationArgs > + { > + OperationArgs(ProcessMonitor *monitor); > + > + ~OperationArgs(); > + > + ProcessMonitor *m_monitor; // The monitor performing the attach. > + sem_t m_semaphore; // Posted to once operation complete. > + lldb_private::Error m_error; // Set if process operation failed. > + }; > + > /// @class LauchArgs > /// > /// @brief Simple structure to pass data to the thread responsible for > /// launching a child process. > - struct LaunchArgs > + struct LaunchArgs : OperationArgs > { > LaunchArgs(ProcessMonitor *monitor, > lldb_private::Module *module, > @@ -192,18 +207,16 @@ private: > const char *m_stdin_path; // Redirect stdin or NULL. > const char *m_stdout_path; // Redirect stdout or NULL. > const char *m_stderr_path; // Redirect stderr or NULL. > - sem_t m_semaphore; // Posted to once launch complete. > - lldb_private::Error m_error; // Set if process launch failed. > }; > > void > - StartOperationThread(LaunchArgs *args, lldb_private::Error &error); > + StartLaunchOpThread(LaunchArgs *args, lldb_private::Error &error); > > void > - StopOperationThread(); > + StopLaunchOpThread(); > > static void * > - OperationThread(void *arg); > + LaunchOpThread(void *arg); > > static bool > Launch(LaunchArgs *args); > @@ -211,8 +224,30 @@ private: > bool > EnableIPC(); > > + struct AttachArgs : OperationArgs > + { > + AttachArgs(ProcessMonitor *monitor, > + lldb::pid_t pid); > + > + ~AttachArgs(); > + > + lldb::pid_t m_pid; // pid of the process to be attached. > + }; > + > + void > + StartAttachOpThread(AttachArgs *args, lldb_private::Error &error); > + > + void > + StopAttachOpThread(); > + > + static void * > + AttachOpThread(void *args); > + > + static bool > + Attach(AttachArgs *args); > + > static void > - ServeOperation(LaunchArgs *args); > + ServeOperation(OperationArgs *args); > > static bool > DupDescriptor(const char *path, int fd, int flags); > -- > 1.7.3.4 > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From ctice at apple.com Tue Jun 14 11:36:12 2011 From: ctice at apple.com (Caroline Tice) Date: Tue, 14 Jun 2011 16:36:12 -0000 Subject: [Lldb-commits] [lldb] r132997 - in /lldb/trunk/source: API/SBHostOS.cpp Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110614163612.D05B42A6C12C@llvm.org> Author: ctice Date: Tue Jun 14 11:36:12 2011 New Revision: 132997 URL: http://llvm.org/viewvc/llvm-project?rev=132997&view=rev Log: Add error message; clean up comment. Modified: lldb/trunk/source/API/SBHostOS.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/API/SBHostOS.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBHostOS.cpp?rev=132997&r1=132996&r2=132997&view=diff ============================================================================== --- lldb/trunk/source/API/SBHostOS.cpp (original) +++ lldb/trunk/source/API/SBHostOS.cpp Tue Jun 14 11:36:12 2011 @@ -41,7 +41,7 @@ log->Printf ("SBHostOS::ThreadCreate (name=\"%s\", thread_function=%p, thread_arg=%p, error_ptr=%p)", name, thread_function, thread_arg, error_ptr); - // CAROLINE: FIXME: You need to log a return value? + // FIXME: You should log the return value? return Host::ThreadCreate (name, thread_function, thread_arg, error_ptr ? error_ptr->get() : NULL); } Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=132997&r1=132996&r2=132997&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Jun 14 11:36:12 2011 @@ -1038,7 +1038,7 @@ } else { - // FIXME: Error processing. + out_file.Printf ("Warning: Unable to find script intepreter; no command attached to breakpoint.\n"); } } } From johnny.chen at apple.com Tue Jun 14 14:09:15 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Jun 2011 12:09:15 -0700 Subject: [Lldb-commits] [PATCH] Primitive attach support for linux In-Reply-To: <182D6365-C98A-45EC-8A84-0C856466F168@apple.com> References: <1308055733-5102-1-git-send-email-mminutoli@gmail.com> <182D6365-C98A-45EC-8A84-0C856466F168@apple.com> Message-ID: Hi Marco, I'll get to your patch shortly. Thanks. Johnny On Jun 14, 2011, at 8:38 AM, Greg Clayton wrote: > This patch is in linux files only, so feel free to commit as long as no one else has any objections! > > Greg Clayton > > On Jun 14, 2011, at 5:48 AM, Marco Minutoli wrote: > >> This patch is a starting point for the attach functionality. >> --- >> source/Plugins/Process/Linux/ProcessLinux.cpp | 11 ++- >> source/Plugins/Process/Linux/ProcessMonitor.cpp | 178 +++++++++++++++++++++-- >> source/Plugins/Process/Linux/ProcessMonitor.h | 49 ++++++- >> 3 files changed, 214 insertions(+), 24 deletions(-) >> >> diff --git a/source/Plugins/Process/Linux/ProcessLinux.cpp b/source/Plugins/Process/Linux/ProcessLinux.cpp >> index c4ce8ee..e6940fe 100644 >> --- a/source/Plugins/Process/Linux/ProcessLinux.cpp >> +++ b/source/Plugins/Process/Linux/ProcessLinux.cpp >> @@ -105,7 +105,16 @@ ProcessLinux::CanDebug(Target &target) >> Error >> ProcessLinux::DoAttachToProcessWithID(lldb::pid_t pid) >> { >> - return Error(1, eErrorTypeGeneric); >> + Error error; >> + assert(m_monitor == NULL); >> + >> + m_monitor = new ProcessMonitor(this, pid, error); >> + >> + if (!error.Success()) >> + return error; >> + >> + SetID(pid); >> + return error; >> } >> >> Error >> diff --git a/source/Plugins/Process/Linux/ProcessMonitor.cpp b/source/Plugins/Process/Linux/ProcessMonitor.cpp >> index ce16159..ebe5959 100644 >> --- a/source/Plugins/Process/Linux/ProcessMonitor.cpp >> +++ b/source/Plugins/Process/Linux/ProcessMonitor.cpp >> @@ -524,6 +524,17 @@ KillOperation::Execute(ProcessMonitor *monitor) >> m_result = true; >> } >> >> +ProcessMonitor::OperationArgs::OperationArgs(ProcessMonitor *monitor) >> + : m_monitor(monitor) >> +{ >> + sem_init(&m_semaphore, 0, 0); >> +} >> + >> +ProcessMonitor::OperationArgs::~OperationArgs() >> +{ >> + sem_destroy(&m_semaphore); >> +} >> + >> ProcessMonitor::LaunchArgs::LaunchArgs(ProcessMonitor *monitor, >> lldb_private::Module *module, >> char const **argv, >> @@ -531,21 +542,23 @@ ProcessMonitor::LaunchArgs::LaunchArgs(ProcessMonitor *monitor, >> const char *stdin_path, >> const char *stdout_path, >> const char *stderr_path) >> - : m_monitor(monitor), >> + : OperationArgs(monitor), >> m_module(module), >> m_argv(argv), >> m_envp(envp), >> m_stdin_path(stdin_path), >> m_stdout_path(stdout_path), >> - m_stderr_path(stderr_path) >> -{ >> - sem_init(&m_semaphore, 0, 0); >> -} >> + m_stderr_path(stderr_path) { } >> >> ProcessMonitor::LaunchArgs::~LaunchArgs() >> -{ >> - sem_destroy(&m_semaphore); >> -} >> +{ } >> + >> +ProcessMonitor::AttachArgs::AttachArgs(ProcessMonitor *monitor, >> + lldb::pid_t pid) >> + : OperationArgs(monitor), m_pid(pid) { } >> + >> +ProcessMonitor::AttachArgs::~AttachArgs() >> +{ } >> >> //------------------------------------------------------------------------------ >> /// The basic design of the ProcessMonitor is built around two threads. >> @@ -587,7 +600,7 @@ ProcessMonitor::ProcessMonitor(ProcessLinux *process, >> error.SetErrorString("Monitor failed to initialize."); >> } >> >> - StartOperationThread(args.get(), error); >> + StartLaunchOpThread(args.get(), error); >> if (!error.Success()) >> return; >> >> @@ -607,7 +620,7 @@ WAIT_AGAIN: >> // Check that the launch was a success. >> if (!args->m_error.Success()) >> { >> - StopOperationThread(); >> + StopLaunchOpThread(); >> error = args->m_error; >> return; >> } >> @@ -623,6 +636,64 @@ WAIT_AGAIN: >> } >> } >> >> +ProcessMonitor::ProcessMonitor(ProcessLinux *process, >> + lldb::pid_t pid, >> + lldb_private::Error &error) >> + : m_process(process), >> + m_operation_thread(LLDB_INVALID_HOST_THREAD), >> + m_pid(LLDB_INVALID_PROCESS_ID), >> + m_terminal_fd(-1), >> + m_monitor_thread(LLDB_INVALID_HOST_THREAD), >> + m_client_fd(-1), >> + m_server_fd(-1) >> +{ >> + std::auto_ptr args; >> + >> + args.reset(new AttachArgs(this, pid)); >> + >> + // Server/client descriptors. >> + if (!EnableIPC()) >> + { >> + error.SetErrorToGenericError(); >> + error.SetErrorString("Monitor failed to initialize."); >> + } >> + >> + StartAttachOpThread(args.get(), error); >> + if (!error.Success()) >> + return; >> + >> +WAIT_AGAIN: >> + // Wait for the operation thread to initialize. >> + if (sem_wait(&args->m_semaphore)) >> + { >> + if (errno == EINTR) >> + goto WAIT_AGAIN; >> + else >> + { >> + error.SetErrorToErrno(); >> + return; >> + } >> + } >> + >> + // Check that the launch was a success. >> + if (!args->m_error.Success()) >> + { >> + StopAttachOpThread(); >> + error = args->m_error; >> + return; >> + } >> + >> + // Finally, start monitoring the child process for change in state. >> + m_monitor_thread = Host::StartMonitoringChildProcess( >> + ProcessMonitor::MonitorCallback, this, GetPID(), true); >> + if (!IS_VALID_LLDB_HOST_THREAD(m_monitor_thread)) >> + { >> + error.SetErrorToGenericError(); >> + error.SetErrorString("Process attach failed."); >> + return; >> + } >> +} >> + >> ProcessMonitor::~ProcessMonitor() >> { >> StopMonitor(); >> @@ -631,7 +702,7 @@ ProcessMonitor::~ProcessMonitor() >> //------------------------------------------------------------------------------ >> // Thread setup and tear down. >> void >> -ProcessMonitor::StartOperationThread(LaunchArgs *args, Error &error) >> +ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Error &error) >> { >> static const char *g_thread_name = "lldb.process.linux.operation"; >> >> @@ -639,11 +710,11 @@ ProcessMonitor::StartOperationThread(LaunchArgs *args, Error &error) >> return; >> >> m_operation_thread = >> - Host::ThreadCreate(g_thread_name, OperationThread, args, &error); >> + Host::ThreadCreate(g_thread_name, LaunchOpThread, args, &error); >> } >> >> void >> -ProcessMonitor::StopOperationThread() >> +ProcessMonitor::StopLaunchOpThread() >> { >> lldb::thread_result_t result; >> >> @@ -655,7 +726,7 @@ ProcessMonitor::StopOperationThread() >> } >> >> void * >> -ProcessMonitor::OperationThread(void *arg) >> +ProcessMonitor::LaunchOpThread(void *arg) >> { >> LaunchArgs *args = static_cast(arg); >> >> @@ -833,6 +904,80 @@ ProcessMonitor::EnableIPC() >> return true; >> } >> >> +void >> +ProcessMonitor::StartAttachOpThread(AttachArgs *args, lldb_private::Error &error) >> +{ >> + static const char *g_thread_name = "lldb.process.linux.operation"; >> + >> + if (IS_VALID_LLDB_HOST_THREAD(m_operation_thread)) >> + return; >> + >> + m_operation_thread = >> + Host::ThreadCreate(g_thread_name, AttachOpThread, args, &error); >> +} >> + >> +void >> +ProcessMonitor::StopAttachOpThread() >> +{ >> + assert(!"Not implemented yet!!!"); >> +} >> + >> +void * >> +ProcessMonitor::AttachOpThread(void *arg) >> +{ >> + AttachArgs *args = static_cast(arg); >> + >> + if (!Attach(args)) >> + return NULL; >> + >> + ServeOperation(args); >> + return NULL; >> +} >> + >> +bool >> +ProcessMonitor::Attach(AttachArgs *args) >> +{ >> + lldb::pid_t pid = args->m_pid; >> + >> + ProcessMonitor *monitor = args->m_monitor; >> + ProcessLinux &process = monitor->GetProcess(); >> + >> + lldb::ThreadSP inferior; >> + >> + if (pid <= 1) >> + { >> + args->m_error.SetErrorToGenericError(); >> + args->m_error.SetErrorString("Attaching to process 1 is not allowed."); >> + goto FINISH; >> + } >> + >> + // Attach to the requested process. >> + if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) >> + { >> + args->m_error.SetErrorToErrno(); >> + goto FINISH; >> + } >> + >> + int status; >> + if ((status = waitpid(pid, NULL, 0)) < 0) >> + { >> + args->m_error.SetErrorToErrno(); >> + goto FINISH; >> + } >> + >> + // Update the process thread list with the attached thread and >> + // mark it as current. >> + inferior.reset(new LinuxThread(process, pid)); >> + process.GetThreadList().AddThread(inferior); >> + process.GetThreadList().SetSelectedThreadByID(pid); >> + >> + // Let our process instance know the thread has stopped. >> + process.SendMessage(ProcessMessage::Trace(pid)); >> + >> + FINISH: >> + return args->m_error.Success(); >> +} >> + >> bool >> ProcessMonitor::MonitorCallback(void *callback_baton, >> lldb::pid_t pid, >> @@ -1094,10 +1239,11 @@ ProcessMonitor::GetCrashReasonForSIGBUS(const struct siginfo *info) >> } >> >> void >> -ProcessMonitor::ServeOperation(LaunchArgs *args) >> +ProcessMonitor::ServeOperation(OperationArgs *args) >> { >> int status; >> pollfd fdset; >> + >> ProcessMonitor *monitor = args->m_monitor; >> >> fdset.fd = monitor->m_server_fd; >> @@ -1326,7 +1472,7 @@ void >> ProcessMonitor::StopMonitor() >> { >> StopMonitoringChildProcess(); >> - StopOperationThread(); >> + StopLaunchOpThread(); >> CloseFD(m_terminal_fd); >> CloseFD(m_client_fd); >> CloseFD(m_server_fd); >> diff --git a/source/Plugins/Process/Linux/ProcessMonitor.h b/source/Plugins/Process/Linux/ProcessMonitor.h >> index 9b8051b..ef9a179 100644 >> --- a/source/Plugins/Process/Linux/ProcessMonitor.h >> +++ b/source/Plugins/Process/Linux/ProcessMonitor.h >> @@ -56,6 +56,10 @@ public: >> const char *stderr_path, >> lldb_private::Error &error); >> >> + ProcessMonitor(ProcessLinux *process, >> + lldb::pid_t pid, >> + lldb_private::Error &error); >> + >> ~ProcessMonitor(); >> >> /// Provides the process number of debugee. >> @@ -169,11 +173,22 @@ private: >> int m_client_fd; >> int m_server_fd; >> >> + struct OperationArgs >> + { >> + OperationArgs(ProcessMonitor *monitor); >> + >> + ~OperationArgs(); >> + >> + ProcessMonitor *m_monitor; // The monitor performing the attach. >> + sem_t m_semaphore; // Posted to once operation complete. >> + lldb_private::Error m_error; // Set if process operation failed. >> + }; >> + >> /// @class LauchArgs >> /// >> /// @brief Simple structure to pass data to the thread responsible for >> /// launching a child process. >> - struct LaunchArgs >> + struct LaunchArgs : OperationArgs >> { >> LaunchArgs(ProcessMonitor *monitor, >> lldb_private::Module *module, >> @@ -192,18 +207,16 @@ private: >> const char *m_stdin_path; // Redirect stdin or NULL. >> const char *m_stdout_path; // Redirect stdout or NULL. >> const char *m_stderr_path; // Redirect stderr or NULL. >> - sem_t m_semaphore; // Posted to once launch complete. >> - lldb_private::Error m_error; // Set if process launch failed. >> }; >> >> void >> - StartOperationThread(LaunchArgs *args, lldb_private::Error &error); >> + StartLaunchOpThread(LaunchArgs *args, lldb_private::Error &error); >> >> void >> - StopOperationThread(); >> + StopLaunchOpThread(); >> >> static void * >> - OperationThread(void *arg); >> + LaunchOpThread(void *arg); >> >> static bool >> Launch(LaunchArgs *args); >> @@ -211,8 +224,30 @@ private: >> bool >> EnableIPC(); >> >> + struct AttachArgs : OperationArgs >> + { >> + AttachArgs(ProcessMonitor *monitor, >> + lldb::pid_t pid); >> + >> + ~AttachArgs(); >> + >> + lldb::pid_t m_pid; // pid of the process to be attached. >> + }; >> + >> + void >> + StartAttachOpThread(AttachArgs *args, lldb_private::Error &error); >> + >> + void >> + StopAttachOpThread(); >> + >> + static void * >> + AttachOpThread(void *args); >> + >> + static bool >> + Attach(AttachArgs *args); >> + >> static void >> - ServeOperation(LaunchArgs *args); >> + ServeOperation(OperationArgs *args); >> >> static bool >> DupDescriptor(const char *path, int fd, int flags); >> -- >> 1.7.3.4 >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Tue Jun 14 14:19:50 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Jun 2011 19:19:50 -0000 Subject: [Lldb-commits] [lldb] r133006 - in /lldb/trunk/source/Plugins/Process/Linux: ProcessLinux.cpp ProcessMonitor.cpp ProcessMonitor.h Message-ID: <20110614191951.089152A6C12C@llvm.org> Author: johnny Date: Tue Jun 14 14:19:50 2011 New Revision: 133006 URL: http://llvm.org/viewvc/llvm-project?rev=133006&view=rev Log: Primitive attach support for linux This patch is a starting point for the attach functionality. Signed-off-by: Johnny Chen Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp?rev=133006&r1=133005&r2=133006&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp Tue Jun 14 14:19:50 2011 @@ -105,7 +105,16 @@ Error ProcessLinux::DoAttachToProcessWithID(lldb::pid_t pid) { - return Error(1, eErrorTypeGeneric); + Error error; + assert(m_monitor == NULL); + + m_monitor = new ProcessMonitor(this, pid, error); + + if (!error.Success()) + return error; + + SetID(pid); + return error; } Error Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=133006&r1=133005&r2=133006&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Tue Jun 14 14:19:50 2011 @@ -524,6 +524,17 @@ m_result = true; } +ProcessMonitor::OperationArgs::OperationArgs(ProcessMonitor *monitor) + : m_monitor(monitor) +{ + sem_init(&m_semaphore, 0, 0); +} + +ProcessMonitor::OperationArgs::~OperationArgs() +{ + sem_destroy(&m_semaphore); +} + ProcessMonitor::LaunchArgs::LaunchArgs(ProcessMonitor *monitor, lldb_private::Module *module, char const **argv, @@ -531,21 +542,23 @@ const char *stdin_path, const char *stdout_path, const char *stderr_path) - : m_monitor(monitor), + : OperationArgs(monitor), m_module(module), m_argv(argv), m_envp(envp), m_stdin_path(stdin_path), m_stdout_path(stdout_path), - m_stderr_path(stderr_path) -{ - sem_init(&m_semaphore, 0, 0); -} + m_stderr_path(stderr_path) { } ProcessMonitor::LaunchArgs::~LaunchArgs() -{ - sem_destroy(&m_semaphore); -} +{ } + +ProcessMonitor::AttachArgs::AttachArgs(ProcessMonitor *monitor, + lldb::pid_t pid) + : OperationArgs(monitor), m_pid(pid) { } + +ProcessMonitor::AttachArgs::~AttachArgs() +{ } //------------------------------------------------------------------------------ /// The basic design of the ProcessMonitor is built around two threads. @@ -587,7 +600,7 @@ error.SetErrorString("Monitor failed to initialize."); } - StartOperationThread(args.get(), error); + StartLaunchOpThread(args.get(), error); if (!error.Success()) return; @@ -607,7 +620,7 @@ // Check that the launch was a success. if (!args->m_error.Success()) { - StopOperationThread(); + StopLaunchOpThread(); error = args->m_error; return; } @@ -623,6 +636,64 @@ } } +ProcessMonitor::ProcessMonitor(ProcessLinux *process, + lldb::pid_t pid, + lldb_private::Error &error) + : m_process(process), + m_operation_thread(LLDB_INVALID_HOST_THREAD), + m_pid(LLDB_INVALID_PROCESS_ID), + m_terminal_fd(-1), + m_monitor_thread(LLDB_INVALID_HOST_THREAD), + m_client_fd(-1), + m_server_fd(-1) +{ + std::auto_ptr args; + + args.reset(new AttachArgs(this, pid)); + + // Server/client descriptors. + if (!EnableIPC()) + { + error.SetErrorToGenericError(); + error.SetErrorString("Monitor failed to initialize."); + } + + StartAttachOpThread(args.get(), error); + if (!error.Success()) + return; + +WAIT_AGAIN: + // Wait for the operation thread to initialize. + if (sem_wait(&args->m_semaphore)) + { + if (errno == EINTR) + goto WAIT_AGAIN; + else + { + error.SetErrorToErrno(); + return; + } + } + + // Check that the launch was a success. + if (!args->m_error.Success()) + { + StopAttachOpThread(); + error = args->m_error; + return; + } + + // Finally, start monitoring the child process for change in state. + m_monitor_thread = Host::StartMonitoringChildProcess( + ProcessMonitor::MonitorCallback, this, GetPID(), true); + if (!IS_VALID_LLDB_HOST_THREAD(m_monitor_thread)) + { + error.SetErrorToGenericError(); + error.SetErrorString("Process attach failed."); + return; + } +} + ProcessMonitor::~ProcessMonitor() { StopMonitor(); @@ -631,7 +702,7 @@ //------------------------------------------------------------------------------ // Thread setup and tear down. void -ProcessMonitor::StartOperationThread(LaunchArgs *args, Error &error) +ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Error &error) { static const char *g_thread_name = "lldb.process.linux.operation"; @@ -639,11 +710,11 @@ return; m_operation_thread = - Host::ThreadCreate(g_thread_name, OperationThread, args, &error); + Host::ThreadCreate(g_thread_name, LaunchOpThread, args, &error); } void -ProcessMonitor::StopOperationThread() +ProcessMonitor::StopLaunchOpThread() { lldb::thread_result_t result; @@ -655,7 +726,7 @@ } void * -ProcessMonitor::OperationThread(void *arg) +ProcessMonitor::LaunchOpThread(void *arg) { LaunchArgs *args = static_cast(arg); @@ -833,6 +904,80 @@ return true; } +void +ProcessMonitor::StartAttachOpThread(AttachArgs *args, lldb_private::Error &error) +{ + static const char *g_thread_name = "lldb.process.linux.operation"; + + if (IS_VALID_LLDB_HOST_THREAD(m_operation_thread)) + return; + + m_operation_thread = + Host::ThreadCreate(g_thread_name, AttachOpThread, args, &error); +} + +void +ProcessMonitor::StopAttachOpThread() +{ + assert(!"Not implemented yet!!!"); +} + +void * +ProcessMonitor::AttachOpThread(void *arg) +{ + AttachArgs *args = static_cast(arg); + + if (!Attach(args)) + return NULL; + + ServeOperation(args); + return NULL; +} + +bool +ProcessMonitor::Attach(AttachArgs *args) +{ + lldb::pid_t pid = args->m_pid; + + ProcessMonitor *monitor = args->m_monitor; + ProcessLinux &process = monitor->GetProcess(); + + lldb::ThreadSP inferior; + + if (pid <= 1) + { + args->m_error.SetErrorToGenericError(); + args->m_error.SetErrorString("Attaching to process 1 is not allowed."); + goto FINISH; + } + + // Attach to the requested process. + if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) + { + args->m_error.SetErrorToErrno(); + goto FINISH; + } + + int status; + if ((status = waitpid(pid, NULL, 0)) < 0) + { + args->m_error.SetErrorToErrno(); + goto FINISH; + } + + // Update the process thread list with the attached thread and + // mark it as current. + inferior.reset(new LinuxThread(process, pid)); + process.GetThreadList().AddThread(inferior); + process.GetThreadList().SetSelectedThreadByID(pid); + + // Let our process instance know the thread has stopped. + process.SendMessage(ProcessMessage::Trace(pid)); + + FINISH: + return args->m_error.Success(); +} + bool ProcessMonitor::MonitorCallback(void *callback_baton, lldb::pid_t pid, @@ -1094,10 +1239,11 @@ } void -ProcessMonitor::ServeOperation(LaunchArgs *args) +ProcessMonitor::ServeOperation(OperationArgs *args) { int status; pollfd fdset; + ProcessMonitor *monitor = args->m_monitor; fdset.fd = monitor->m_server_fd; @@ -1326,7 +1472,7 @@ ProcessMonitor::StopMonitor() { StopMonitoringChildProcess(); - StopOperationThread(); + StopLaunchOpThread(); CloseFD(m_terminal_fd); CloseFD(m_client_fd); CloseFD(m_server_fd); Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h?rev=133006&r1=133005&r2=133006&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Tue Jun 14 14:19:50 2011 @@ -56,6 +56,10 @@ const char *stderr_path, lldb_private::Error &error); + ProcessMonitor(ProcessLinux *process, + lldb::pid_t pid, + lldb_private::Error &error); + ~ProcessMonitor(); /// Provides the process number of debugee. @@ -169,11 +173,22 @@ int m_client_fd; int m_server_fd; + struct OperationArgs + { + OperationArgs(ProcessMonitor *monitor); + + ~OperationArgs(); + + ProcessMonitor *m_monitor; // The monitor performing the attach. + sem_t m_semaphore; // Posted to once operation complete. + lldb_private::Error m_error; // Set if process operation failed. + }; + /// @class LauchArgs /// /// @brief Simple structure to pass data to the thread responsible for /// launching a child process. - struct LaunchArgs + struct LaunchArgs : OperationArgs { LaunchArgs(ProcessMonitor *monitor, lldb_private::Module *module, @@ -192,18 +207,16 @@ const char *m_stdin_path; // Redirect stdin or NULL. const char *m_stdout_path; // Redirect stdout or NULL. const char *m_stderr_path; // Redirect stderr or NULL. - sem_t m_semaphore; // Posted to once launch complete. - lldb_private::Error m_error; // Set if process launch failed. }; void - StartOperationThread(LaunchArgs *args, lldb_private::Error &error); + StartLaunchOpThread(LaunchArgs *args, lldb_private::Error &error); void - StopOperationThread(); + StopLaunchOpThread(); static void * - OperationThread(void *arg); + LaunchOpThread(void *arg); static bool Launch(LaunchArgs *args); @@ -211,8 +224,30 @@ bool EnableIPC(); + struct AttachArgs : OperationArgs + { + AttachArgs(ProcessMonitor *monitor, + lldb::pid_t pid); + + ~AttachArgs(); + + lldb::pid_t m_pid; // pid of the process to be attached. + }; + + void + StartAttachOpThread(AttachArgs *args, lldb_private::Error &error); + + void + StopAttachOpThread(); + + static void * + AttachOpThread(void *args); + + static bool + Attach(AttachArgs *args); + static void - ServeOperation(LaunchArgs *args); + ServeOperation(OperationArgs *args); static bool DupDescriptor(const char *path, int fd, int flags); From johnny.chen at apple.com Tue Jun 14 17:23:54 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Jun 2011 22:23:54 -0000 Subject: [Lldb-commits] [lldb] r133020 - /lldb/trunk/utils/git-svn/convert.py Message-ID: <20110614222354.CFFD42A6C12C@llvm.org> Author: johnny Date: Tue Jun 14 17:23:54 2011 New Revision: 133020 URL: http://llvm.org/viewvc/llvm-project?rev=133020&view=rev Log: Update usage comment. Modified: lldb/trunk/utils/git-svn/convert.py Modified: lldb/trunk/utils/git-svn/convert.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/git-svn/convert.py?rev=133020&r1=133019&r2=133020&view=diff ============================================================================== --- lldb/trunk/utils/git-svn/convert.py (original) +++ lldb/trunk/utils/git-svn/convert.py Tue Jun 14 17:23:54 2011 @@ -7,8 +7,8 @@ 1. Mail.app -> Save As -> api.eml (Raw Message Source) 2. .../convert.py api.eml -3. git am --signoff < api.eml -4. git svn dcommit +3. git am [--signoff] < api.eml +4. git svn dcommit [--commit-url https://id at llvm.org/svn/llvm-project/lldb/trunk] """ import os, re, sys From ctice at apple.com Wed Jun 15 11:37:40 2011 From: ctice at apple.com (Caroline Tice) Date: Wed, 15 Jun 2011 16:37:40 -0000 Subject: [Lldb-commits] [lldb] r133061 - /lldb/trunk/www/scripting.html Message-ID: <20110615163740.83FCC2A6C12C@llvm.org> Author: ctice Date: Wed Jun 15 11:37:40 2011 New Revision: 133061 URL: http://llvm.org/viewvc/llvm-project?rev=133061&view=rev Log: Add an introduction to the scripting example web page. Modified: lldb/trunk/www/scripting.html Modified: lldb/trunk/www/scripting.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/scripting.html?rev=133061&r1=133060&r2=133061&view=diff ============================================================================== --- lldb/trunk/www/scripting.html (original) +++ lldb/trunk/www/scripting.html Wed Jun 15 11:37:40 2011 @@ -16,6 +16,22 @@
+

Introduction

+
+ +

LLDB has been structured from the beginning to be scriptable in two ways + -- a Unix Python session can initiate/run a debug session non-interactively + using LLDB; and within the LLDB debugger tool, Python scripts can be used to + help with many tasks, including inspecting program data, iterating over + containers and determining if a breakpoint should stop execution or continue. + This document will show how to do some of these things by going through an + example, explaining how to use Python scripting to find a bug in a program + that searches for text in a large binary tree.

+ +
+ + +

The Test Program and Input

From ctice at apple.com Wed Jun 15 14:35:17 2011 From: ctice at apple.com (Caroline Tice) Date: Wed, 15 Jun 2011 19:35:17 -0000 Subject: [Lldb-commits] [lldb] r133076 - in /lldb/trunk/source: Commands/CommandObjectCommands.cpp Commands/CommandObjectExpression.cpp Target/ThreadPlanTracer.cpp Message-ID: <20110615193517.67D022A6C12C@llvm.org> Author: ctice Date: Wed Jun 15 14:35:17 2011 New Revision: 133076 URL: http://llvm.org/viewvc/llvm-project?rev=133076&view=rev Log: Replace direct uses of the Debugger's output stream with uses of the asynchronous stream. Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Target/ThreadPlanTracer.cpp Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=133076&r1=133075&r2=133076&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Jun 15 14:35:17 2011 @@ -929,7 +929,11 @@ switch (notification) { case eInputReaderActivate: - reader.GetDebugger().GetOutputStream().Printf("%s\n", "Enter regular expressions in the form 's///' and terminate with an empty line:"); + { + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream (); + out_stream->Printf("%s\n", "Enter regular expressions in the form 's///' and terminate with an empty line:"); + out_stream->Flush(); + } break; case eInputReaderReactivate: break; @@ -951,7 +955,9 @@ Error error (add_regex_cmd->AppendRegexSubstitution (bytes_strref)); if (error.Fail()) { - reader.GetDebugger().GetOutputStream().Printf("error: %s\n", error.AsCString()); + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); + out_stream->Printf("error: %s\n", error.AsCString()); + out_stream->Flush(); add_regex_cmd->InputReaderDidCancel (); reader.SetIsDone (true); } @@ -959,9 +965,13 @@ break; case eInputReaderInterrupt: - reader.SetIsDone (true); - reader.GetDebugger().GetOutputStream().PutCString("Regular expression command creations was cancelled.\n"); - add_regex_cmd->InputReaderDidCancel (); + { + reader.SetIsDone (true); + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); + out_stream->PutCString("Regular expression command creations was cancelled.\n"); + out_stream->Flush(); + add_regex_cmd->InputReaderDidCancel (); + } break; case eInputReaderEndOfFile: Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=133076&r1=133075&r2=133076&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Wed Jun 15 14:35:17 2011 @@ -195,11 +195,13 @@ switch (notification) { case eInputReaderActivate: - reader.GetDebugger().GetOutputStream().Printf("%s\n", "Enter expressions, then terminate with an empty line to evaluate:"); + { + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); + out_stream->Printf("%s\n", "Enter expressions, then terminate with an empty line to evaluate:"); + out_stream->Flush(); + } // Fall through case eInputReaderReactivate: - //if (out_fh) - // reader.GetDebugger().GetOutputStream().Printf ("%3u: ", cmd_object_expr->m_expr_line_count); break; case eInputReaderDeactivate: @@ -217,14 +219,16 @@ if (bytes_len == 0) reader.SetIsDone(true); - //else if (out_fh && !reader->IsDone()) - // ::fprintf (out_fh, "%3u: ", cmd_object_expr->m_expr_line_count); break; case eInputReaderInterrupt: cmd_object_expr->m_expr_lines.clear(); reader.SetIsDone (true); - reader.GetDebugger().GetOutputStream().Printf("%s\n", "Expression evaluation cancelled."); + { + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); + out_stream->Printf("%s\n", "Expression evaluation cancelled."); + out_stream->Flush(); + } break; case eInputReaderEndOfFile: Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=133076&r1=133075&r2=133076&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Wed Jun 15 14:35:17 2011 @@ -55,7 +55,7 @@ if (m_stream_sp.get()) return m_stream_sp.get(); else - return &(m_thread.GetProcess().GetTarget().GetDebugger().GetOutputStream()); + return m_thread.GetProcess().GetTarget().GetDebugger().GetAsyncOutputStream().get(); } void @@ -65,8 +65,11 @@ bool show_frame_index = false; bool show_fullpaths = false; - m_thread.GetStackFrameAtIndex(0)->Dump (GetLogStream(), show_frame_index, show_fullpaths); - GetLogStream()->Printf("\n"); + Stream *stream = GetLogStream(); + m_thread.GetStackFrameAtIndex(0)->Dump (stream, show_frame_index, show_fullpaths); + stream->Printf("\n"); + stream->Flush(); + } bool @@ -259,4 +262,5 @@ } } stream->EOL(); + stream->Flush(); } From jingham at apple.com Wed Jun 15 16:01:30 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 15 Jun 2011 21:01:30 -0000 Subject: [Lldb-commits] [lldb] r133084 - /lldb/trunk/www/lldb-gdb.html Message-ID: <20110615210130.6FA942A6C12C@llvm.org> Author: jingham Date: Wed Jun 15 16:01:30 2011 New Revision: 133084 URL: http://llvm.org/viewvc/llvm-project?rev=133084&view=rev Log: Added a few trivial mods. Modified: lldb/trunk/www/lldb-gdb.html Modified: lldb/trunk/www/lldb-gdb.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/lldb-gdb.html?rev=133084&r1=133083&r2=133084&view=diff ============================================================================== --- lldb/trunk/www/lldb-gdb.html (original) +++ lldb/trunk/www/lldb-gdb.html Wed Jun 15 16:01:30 2011 @@ -337,10 +337,16 @@ Read 512 bytes of memory from address 0xbffff3c0 and save results to a local file as text. - + (lldb) memory read --outfile /tmp/mem.txt --count 512 0xbffff3c0
(lldb) memory read -o/tmp/mem.txt -c512 0xbffff3c0
+ + (gdb) set logging on
+ (gdb) set logging file /tmp/mem.txt
+ (gdb) x/512bx 0xbffff3c0
+ (gdb) set logging off
+ Save binary memory data starting at 0x1000 and ending at 0x2000 to a file. @@ -384,6 +390,17 @@ + Disassemble 20 instructions from a given address. + + + (lldb) disassemble --start-address 0x1eb8 --count 20
+ (lldb) disassemble -s 0x1eb8 -c 20
+ + + (gdb) x/20i 0x1eb8 + + + Show mixed source and disassembly for the current function for the current frame. From jingham at apple.com Wed Jun 15 16:16:00 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 15 Jun 2011 21:16:00 -0000 Subject: [Lldb-commits] [lldb] r133088 - in /lldb/trunk: include/lldb/Breakpoint/Breakpoint.h include/lldb/Breakpoint/BreakpointLocation.h include/lldb/Breakpoint/BreakpointOptions.h source/Breakpoint/Breakpoint.cpp source/Breakpoint/BreakpointLocation.cpp source/Breakpoint/BreakpointOptions.cpp Message-ID: <20110615211600.5900E2A6C12C@llvm.org> Author: jingham Date: Wed Jun 15 16:16:00 2011 New Revision: 133088 URL: http://llvm.org/viewvc/llvm-project?rev=133088&view=rev Log: Made GetConditionText const everywhere. Made it return NULL when there's no condition like the doc's say it should. Make sure we have a condition before we set up a test whether we have one, so we only present a "could not parse condition" error if we actually have a condition. Modified: lldb/trunk/include/lldb/Breakpoint/Breakpoint.h lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h lldb/trunk/source/Breakpoint/Breakpoint.cpp lldb/trunk/source/Breakpoint/BreakpointLocation.cpp lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Modified: lldb/trunk/include/lldb/Breakpoint/Breakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Breakpoint.h?rev=133088&r1=133087&r2=133088&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/Breakpoint.h (original) +++ lldb/trunk/include/lldb/Breakpoint/Breakpoint.h Wed Jun 15 16:16:00 2011 @@ -404,7 +404,7 @@ /// A pointer to the condition expression text, or NULL if no // condition has been set. //------------------------------------------------------------------ - const char *GetConditionText (); + const char *GetConditionText () const; //------------------------------------------------------------------ // The next section are various utility functions. Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h?rev=133088&r1=133087&r2=133088&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h Wed Jun 15 16:16:00 2011 @@ -190,7 +190,7 @@ // condition has been set. //------------------------------------------------------------------ const char * - GetConditionText (); + GetConditionText () const; //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h?rev=133088&r1=133087&r2=133088&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h Wed Jun 15 16:16:00 2011 @@ -126,7 +126,7 @@ /// A pointer to the condition expression text, or NULL if no // condition has been set. //------------------------------------------------------------------ - const char *GetConditionText (); + const char *GetConditionText () const; //------------------------------------------------------------------ // Enabled/Ignore Count Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=133088&r1=133087&r2=133088&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original) +++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Wed Jun 15 16:16:00 2011 @@ -201,7 +201,7 @@ } const char * -Breakpoint::GetConditionText () +Breakpoint::GetConditionText () const { return m_options.GetConditionText(); } Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=133088&r1=133087&r2=133088&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Wed Jun 15 16:16:00 2011 @@ -157,9 +157,9 @@ } const char * -BreakpointLocation::GetConditionText () +BreakpointLocation::GetConditionText () const { - return GetLocationOptions()->GetConditionText(); + return GetOptionsNoCreate()->GetConditionText(); } uint32_t @@ -226,7 +226,7 @@ // The SYNCHRONOUS callback says we should stop, next try the condition. - if (should_stop) + if (should_stop && GetConditionText() != NULL) { // We need to make sure the user sees any parse errors in their condition, so we'll hook the // constructor errors up to the debugger's Async I/O. Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointOptions.cpp?rev=133088&r1=133087&r2=133088&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointOptions.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Wed Jun 15 16:16:00 2011 @@ -217,12 +217,12 @@ } const char * -BreakpointOptions::GetConditionText () +BreakpointOptions::GetConditionText () const { if (m_condition_ap.get()) return m_condition_ap->GetUserText(); else - return ""; + return NULL; } //------------------------------------------------------------------ From johnny.chen at apple.com Wed Jun 15 16:24:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Jun 2011 21:24:24 -0000 Subject: [Lldb-commits] [lldb] r133091 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/API/SBTarget.h source/API/SBDebugger.cpp source/API/SBTarget.cpp test/lldbtest.py Message-ID: <20110615212424.700E12A6C12C@llvm.org> Author: johnny Date: Wed Jun 15 16:24:24 2011 New Revision: 133091 URL: http://llvm.org/viewvc/llvm-project?rev=133091&view=rev Log: Add an API to SBDebugger class: bool SBDebugger::DeleteTarget(lldb::SBTarget &target); which is used in the test tearDown() phase to cleanup the debugger's target list so that it won't grow larger and larger as test cases are executed. This is also a good opportunity to get rid of the arcane requirement that test cases exercising the Python API must assign the process object to self.process so that it gets shutdown gracefully. Instead, the shutdown of the process associated with each target is now being now automatically. Also get rid of an API from SBTarget class: SBTarget::DeleteTargetFromList(lldb_private::TargetList *list); Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/test/lldbtest.py Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=133091&r1=133090&r2=133091&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Wed Jun 15 16:24:24 2011 @@ -98,6 +98,10 @@ lldb::SBTarget CreateTarget (const char *filename); + // Return true if target is deleted from the target list of the debugger. + bool + DeleteTarget (lldb::SBTarget &target); + lldb::SBTarget GetTargetAtIndex (uint32_t idx); Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=133091&r1=133090&r2=133091&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Wed Jun 15 16:24:24 2011 @@ -187,9 +187,6 @@ Clear (); bool - DeleteTargetFromList (lldb_private::TargetList *list); - - bool ResolveLoadAddress (lldb::addr_t vm_addr, lldb::SBAddress& addr); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=133091&r1=133090&r2=133091&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Wed Jun 15 16:24:24 2011 @@ -508,6 +508,24 @@ return target; } +bool +SBDebugger::DeleteTarget (lldb::SBTarget &target) +{ + bool result = false; + if (m_opaque_sp) + { + // No need to lock, the target list is thread safe + result = m_opaque_sp->GetTargetList().DeleteTarget (target.m_opaque_sp); + } + + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + log->Printf ("SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i", m_opaque_sp.get(), target.m_opaque_sp.get(), result); + } + + return result; +} SBTarget SBDebugger::GetTargetAtIndex (uint32_t idx) { Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=133091&r1=133090&r2=133091&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Wed Jun 15 16:24:24 2011 @@ -397,16 +397,6 @@ return exe_file_spec; } - -bool -SBTarget::DeleteTargetFromList (TargetList *list) -{ - if (m_opaque_sp) - return list->DeleteTarget (m_opaque_sp); - else - return false; -} - bool SBTarget::operator == (const SBTarget &rhs) const { Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=133091&r1=133090&r2=133091&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Jun 15 16:24:24 2011 @@ -365,12 +365,8 @@ - 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 + - kill the inferior process associated with each target, if any, + and, then delete the target from the debugger's target list - 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: @@ -537,11 +533,6 @@ # interpreter. self.child_in_script_interpreter = False - # There is no process associated with the debugger as yet. - # See also self.tearDown() where it checks whether self.process has a - # valid reference and calls self.process.Kill() to kill the process. - self.process = None - # Retrieve the associated command interpreter instance. self.ci = self.dbg.GetCommandInterpreter() if not self.ci: @@ -712,13 +703,20 @@ except: pass - # Terminate the current process being debugged, if any. - if self.runStarted: - self.runCmd("process kill", PROCESS_KILLED, check=False) - elif self.process: - rc = self.invoke(self.process, "Kill") - self.assertTrue(rc.Success(), PROCESS_KILLED) - del self.process + # Delete the target(s) from the debugger as a general cleanup step. + # This includes terminating the process for each target, if any. + # We'd like to reuse the debugger for our next test without incurring + # the initialization overhead. + targets = [] + for target in self.dbg: + if target: + targets.append(target) + process = target.GetProcess() + if process: + rc = self.invoke(process, "Kill") + self.assertTrue(rc.Success(), PROCESS_KILLED) + for target in targets: + self.dbg.DeleteTarget(target) del self.dbg del self.hooks From johnny.chen at apple.com Wed Jun 15 16:38:40 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Jun 2011 21:38:40 -0000 Subject: [Lldb-commits] [lldb] r133092 - in /lldb/trunk/test: hello_world/TestHelloWorld.py lldbtest.py Message-ID: <20110615213840.1ACD02A6C12C@llvm.org> Author: johnny Date: Wed Jun 15 16:38:39 2011 New Revision: 133092 URL: http://llvm.org/viewvc/llvm-project?rev=133092&view=rev Log: Simplify the base test class. Remove keyword argument setCookie from TestBase.runCmd() and remove the self.runStarted attribute since the automatic shutdown of processes associated with the targets are now performed automatically. Modified: lldb/trunk/test/hello_world/TestHelloWorld.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=133092&r1=133091&r2=133092&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Wed Jun 15 16:38:39 2011 @@ -60,7 +60,7 @@ #self.breakAfterLaunch(process, "main") else: # On the other hand, the following line of code are more reliable. - self.runCmd("run", setCookie=False) + self.runCmd("run") self.process = target.GetProcess() self.assertTrue(self.process, PROCESS_IS_VALID) Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=133092&r1=133091&r2=133092&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Jun 15 16:38:39 2011 @@ -403,12 +403,6 @@ # The concrete subclass should override this attribute. mydir = None - # State pertaining to the inferior process, if any. - # This reflects inferior process started through the command interface with - # either the lldb "run" or "process launch" command. - # See also self.runCmd(). - runStarted = False - # Maximum allowed attempts when launching the inferior process. # Can be overridden by the LLDB_MAX_LAUNCH_COUNT environment variable. maxLaunchCount = 3; @@ -738,7 +732,7 @@ # Decide whether to dump the session info. self.dumpSessionInfo() - def runCmd(self, cmd, msg=None, check=True, trace=False, setCookie=True): + def runCmd(self, cmd, msg=None, check=True, trace=False): """ Ask the command interpreter to handle the command and then check its return status. @@ -772,10 +766,6 @@ with recording(self, True) as sbuf: print >> sbuf, "Command '" + cmd + "' failed!" - # Modify runStarted only if "run" or "process launch" was encountered. - if running: - self.runStarted = running and setCookie - if check: self.assertTrue(self.res.Succeeded(), msg if msg else CMD_MSG(cmd)) From johnny.chen at apple.com Wed Jun 15 17:14:12 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Jun 2011 22:14:12 -0000 Subject: [Lldb-commits] [lldb] r133097 - in /lldb/trunk/test: ./ array_types/ bitfields/ breakpoint_conditions/ breakpoint_ignore_count/ class_static/ class_types/ conditional_break/ cpp/dynamic-value/ expression_command/test/ foundation/ hello_world/ inferior-crashing/ objc-dynamic-value/ objc-stepping/ python_api/event/ python_api/frame/ python_api/function_symbol/ python_api/interpreter/ python_api/lldbutil/frame/ python_api/lldbutil/iter/ python_api/lldbutil/process/ python_api/process/ python_api/symbol-context/ python_api... Message-ID: <20110615221412.A7EED2A6C12C@llvm.org> Author: johnny Date: Wed Jun 15 17:14:12 2011 New Revision: 133097 URL: http://llvm.org/viewvc/llvm-project?rev=133097&view=rev Log: The extra burden for the Python API test case to assign its process object to self.process in order to have its process cleaned up (terminated) upon tearDown is gone for good. Let's simplify a bunch of Python API test cases. Modified: lldb/trunk/test/array_types/TestArrayTypes.py lldb/trunk/test/bitfields/TestBitfields.py lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py lldb/trunk/test/class_static/TestStaticVariables.py lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/conditional_break/TestConditionalBreak.py lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py lldb/trunk/test/expression_command/test/TestExprs.py lldb/trunk/test/foundation/TestObjCMethods.py lldb/trunk/test/hello_world/TestHelloWorld.py lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py lldb/trunk/test/lldbutil.py lldb/trunk/test/objc-dynamic-value/TestObjCDynamicValue.py lldb/trunk/test/objc-stepping/TestObjCStepping.py lldb/trunk/test/python_api/event/TestEvents.py lldb/trunk/test/python_api/frame/TestFrames.py lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py lldb/trunk/test/python_api/process/TestProcessAPI.py lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py lldb/trunk/test/python_api/target/TestTargetAPI.py lldb/trunk/test/python_api/thread/TestThreadAPI.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Wed Jun 15 17:14:12 2011 @@ -110,19 +110,17 @@ substrs = ["resolved = 1"]) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) - - self.process = target.GetProcess() - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) # Sanity check the print representation of process. - proc = repr(self.process) + proc = repr(process) self.expect(proc, msg="Process looks good", exe=False, substrs = ["state = stopped", "executable = a.out"]) # The stop reason of the thread should be breakpoint. - thread = self.process.GetThreadAtIndex(0) + thread = process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Wed Jun 15 17:14:12 2011 @@ -94,8 +94,8 @@ breakpoint = target.BreakpointCreateByLocation("main.c", self.line) self.assertTrue(breakpoint, VALID_BREAKPOINT) - self.process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. thread = target.GetProcess().GetThreadAtIndex(0) Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Wed Jun 15 17:14:12 2011 @@ -139,14 +139,12 @@ startstr = 'val == 3') # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) - - self.process = target.GetProcess() - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1 and the break condition should hold. from lldbutil import get_stopped_thread - thread = get_stopped_thread(self.process, lldb.eStopReasonPlanComplete) + thread = get_stopped_thread(process, lldb.eStopReasonPlanComplete) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) var = frame0.FindValue('val', lldb.eValueTypeVariableArgument) @@ -156,7 +154,7 @@ # The hit count for the breakpoint should be 3. self.assertTrue(breakpoint.GetHitCount() == 3) - self.process.Continue() + process.Continue() if __name__ == '__main__': Modified: lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py (original) +++ lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py Wed Jun 15 17:14:12 2011 @@ -101,16 +101,14 @@ "SetIgnoreCount() works correctly") # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) - - self.process = target.GetProcess() - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and # frame#2 should be on main.c:48. - #lldbutil.print_stacktraces(self.process) + #lldbutil.print_stacktraces(process) from lldbutil import get_stopped_thread - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") frame0 = thread.GetFrameAtIndex(0) frame1 = thread.GetFrameAtIndex(1) @@ -123,7 +121,7 @@ # The hit count for the breakpoint should be 3. self.assertTrue(breakpoint.GetHitCount() == 3) - self.process.Continue() + process.Continue() if __name__ == '__main__': Modified: lldb/trunk/test/class_static/TestStaticVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_static/TestStaticVariables.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/class_static/TestStaticVariables.py (original) +++ lldb/trunk/test/class_static/TestStaticVariables.py Wed Jun 15 17:14:12 2011 @@ -80,13 +80,11 @@ self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) - - self.process = target.GetProcess() - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread = self.process.GetThreadAtIndex(0) + thread = process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Wed Jun 15 17:14:12 2011 @@ -120,18 +120,18 @@ # Now launch the process, and do not stop at entry point. error = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) + process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - if not error.Success() or not self.process: + if not error.Success() or not process: self.fail("SBTarget.Launch() failed") - if self.process.GetState() != lldb.eStateStopped: + if process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % - lldbutil.state_type_to_str(self.process.GetState())) + lldbutil.state_type_to_str(process.GetState())) # The stop reason of the thread should be breakpoint. - thread = self.process.GetThreadAtIndex(0) + thread = process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % @@ -149,7 +149,7 @@ # We should be stopped on the breakpoint with a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) - self.process.Continue() + process.Continue() def class_types_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Wed Jun 15 17:14:12 2011 @@ -53,12 +53,12 @@ # Now launch the process, and do not stop at entry point. error = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) + process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - self.assertTrue(error.Success() and self.process, PROCESS_IS_VALID) + self.assertTrue(error.Success() and process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - self.assertTrue(self.process.GetState() == lldb.eStateStopped, + self.assertTrue(process.GetState() == lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT) # Find the line number where a's parent frame function is c. @@ -72,7 +72,7 @@ # The 10 in range(10) is just an arbitrary number, which means we would # like to try for at most 10 times. for j in range(10): - thread = self.process.GetThreadAtIndex(0) + thread = process.GetThreadAtIndex(0) if thread.GetNumFrames() >= 2: frame0 = thread.GetFrameAtIndex(0) @@ -94,7 +94,7 @@ self.assertTrue(val.GetValue(frame1) == "3", "'val' has a value of 3") break - self.process.Continue() + process.Continue() def simulate_conditional_break_by_user(self): """Simulate a user using lldb commands to break on c() if called from a().""" Modified: lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py (original) +++ lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py Wed Jun 15 17:14:12 2011 @@ -114,12 +114,12 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at the entry point. - self.process = target.LaunchSimple (None, None, os.getcwd()) + process = target.LaunchSimple (None, None, os.getcwd()) - self.assertTrue(self.process.GetState() == lldb.eStateStopped, + self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, first_call_bpt) + threads = lldbutil.get_threads_stopped_at_breakpoint (process, first_call_bpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -141,7 +141,7 @@ # Okay now run to doSomething: - threads = lldbutil.continue_to_breakpoint (self.process, do_something_bpt) + threads = lldbutil.continue_to_breakpoint (process, do_something_bpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -194,7 +194,7 @@ # Okay, now continue again, and when we hit the second breakpoint in main - threads = lldbutil.continue_to_breakpoint (self.process, second_call_bpt) + threads = lldbutil.continue_to_breakpoint (process, second_call_bpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -206,7 +206,7 @@ # Finally continue to doSomething again, and make sure we get the right value for anotherA, # which this time around is just an "A". - threads = lldbutil.continue_to_breakpoint (self.process, do_something_bpt) + threads = lldbutil.continue_to_breakpoint (process, do_something_bpt) self.assertTrue(len(threads) == 1) thread = threads[0] Modified: lldb/trunk/test/expression_command/test/TestExprs.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/TestExprs.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/expression_command/test/TestExprs.py (original) +++ lldb/trunk/test/expression_command/test/TestExprs.py Wed Jun 15 17:14:12 2011 @@ -101,18 +101,18 @@ # Launch the process, and do not stop at the entry point. # Pass 'X Y Z' as the args, which makes argc == 4. error = lldb.SBError() - self.process = target.Launch(self.dbg.GetListener(), ['X', 'Y', 'Z'], None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) + process = target.Launch(self.dbg.GetListener(), ['X', 'Y', 'Z'], None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - if not error.Success() or not self.process: + if not error.Success() or not process: self.fail("SBTarget.LaunchProcess() failed") - if self.process.GetState() != lldb.eStateStopped: + if process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % - lldbutil.state_type_to_str(self.process.GetState())) + lldbutil.state_type_to_str(process.GetState())) # The stop reason of the thread should be breakpoint. - thread = self.process.GetThreadAtIndex(0) + thread = process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Wed Jun 15 17:14:12 2011 @@ -213,12 +213,12 @@ # Now launch the process, and do not stop at entry point. error = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) + process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - self.assertTrue(self.process, PROCESS_IS_VALID) + self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread = self.process.GetThreadAtIndex(0) + thread = process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Wed Jun 15 17:14:12 2011 @@ -62,10 +62,10 @@ # On the other hand, the following line of code are more reliable. self.runCmd("run") - self.process = target.GetProcess() - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.GetProcess() + self.assertTrue(process, PROCESS_IS_VALID) - thread = self.process.GetThreadAtIndex(0) + thread = process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % Modified: lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py (original) +++ lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Wed Jun 15 17:14:12 2011 @@ -58,15 +58,15 @@ # Now launch the process, and do not stop at entry point. # Both argv and envp are null. - self.process = target.LaunchSimple(None, None, os.getcwd()) + process = target.LaunchSimple(None, None, os.getcwd()) import lldbutil - if self.process.GetState() != lldb.eStateStopped: + if process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % - lldbutil.state_type_to_str(self.process.GetState())) + lldbutil.state_type_to_str(process.GetState())) - thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonException) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonException) if not thread: self.fail("Fail to stop the thread upon bad access exception") Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Wed Jun 15 17:14:12 2011 @@ -230,7 +230,7 @@ ... from lldbutil import get_stopped_thread - thread = get_stopped_thread(self.process, lldb.eStopReasonPlanComplete) + thread = get_stopped_thread(process, lldb.eStopReasonPlanComplete) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") ... @@ -238,7 +238,7 @@ ... from lldbutil import get_stopped_thread - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") ... Modified: lldb/trunk/test/objc-dynamic-value/TestObjCDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/objc-dynamic-value/TestObjCDynamicValue.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/objc-dynamic-value/TestObjCDynamicValue.py (original) +++ lldb/trunk/test/objc-dynamic-value/TestObjCDynamicValue.py Wed Jun 15 17:14:12 2011 @@ -67,12 +67,12 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at the entry point. - self.process = target.LaunchSimple (None, None, os.getcwd()) + process = target.LaunchSimple (None, None, os.getcwd()) - self.assertTrue(self.process.GetState() == lldb.eStateStopped, + self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, main_before_setProperty_bkpt) + threads = lldbutil.get_threads_stopped_at_breakpoint (process, main_before_setProperty_bkpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -99,7 +99,7 @@ thread.StepInto() - threads = lldbutil.get_stopped_threads (self.process, lldb.eStopReasonPlanComplete) + threads = lldbutil.get_stopped_threads (process, lldb.eStopReasonPlanComplete) self.assertTrue (len(threads) == 1) line_entry = threads[0].GetFrameAtIndex(0).GetLineEntry() self.assertTrue (line_entry.GetLine() == self.set_property_line) @@ -107,7 +107,7 @@ # Okay, back to the main business. Continue to the handle_SourceBase and make sure we get the correct dynamic value. - threads = lldbutil.continue_to_breakpoint (self.process, handle_SourceBase_bkpt) + threads = lldbutil.continue_to_breakpoint (process, handle_SourceBase_bkpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -142,7 +142,7 @@ # This one looks exactly the same, but in fact this is an "un-KVO'ed" version of SourceBase, so # its isa pointer points to SourceBase not NSKVOSourceBase or whatever... - threads = lldbutil.continue_to_breakpoint (self.process, handle_SourceBase_bkpt) + threads = lldbutil.continue_to_breakpoint (process, handle_SourceBase_bkpt) self.assertTrue (len(threads) == 1) thread = threads[0] Modified: lldb/trunk/test/objc-stepping/TestObjCStepping.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/objc-stepping/TestObjCStepping.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/objc-stepping/TestObjCStepping.py (original) +++ lldb/trunk/test/objc-stepping/TestObjCStepping.py Wed Jun 15 17:14:12 2011 @@ -64,12 +64,12 @@ self.assertTrue(break_returnStruct_call_super, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple (None, None, os.getcwd()) + process = target.LaunchSimple (None, None, os.getcwd()) - self.assertTrue(self.process, PROCESS_IS_VALID) + self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread = self.process.GetThreadAtIndex(0) + thread = process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: from lldbutil import stop_reason_to_str self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % @@ -100,7 +100,7 @@ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod.") - self.process.Continue() + process.Continue() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.line2, "Continued to second breakpoint in main.") @@ -109,7 +109,7 @@ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct.") - self.process.Continue() + process.Continue() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.source_returnsStruct_call_line, "Stepped to the call super line in Source returnsStruct.") @@ -120,7 +120,7 @@ # Cool now continue to get past the call that intializes the Observer, and then do our steps in again to see that # we can find our way when we're stepping through a KVO swizzled object. - self.process.Continue() + process.Continue() frame = thread.GetFrameAtIndex(0) line_number = frame.GetLineEntry().GetLine() self.assertTrue (line_number == self.line3, "Continued to third breakpoint in main, our object should now be swizzled.") @@ -140,7 +140,7 @@ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod in swizzled object.") - self.process.Continue() + process.Continue() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.line4, "Continued to fourth breakpoint in main.") @@ -149,7 +149,7 @@ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct in swizzled object.") - self.process.Continue() + process.Continue() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.source_returnsStruct_call_line, "Stepped to the call super line in Source returnsStruct - second time.") Modified: lldb/trunk/test/python_api/event/TestEvents.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/event/TestEvents.py (original) +++ lldb/trunk/test/python_api/event/TestEvents.py Wed Jun 15 17:14:12 2011 @@ -64,13 +64,11 @@ # Now launch the process, and do not stop at entry point. error = lldb.SBError() - self.process = target.Launch (listener, None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - - self.process = target.GetProcess() - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.Launch (listener, None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) + self.assertTrue(process, PROCESS_IS_VALID) # Get a handle on the process's broadcaster. - broadcaster = self.process.GetBroadcaster() + broadcaster = process.GetBroadcaster() self.assertTrue(broadcaster, "Process with valid broadcaster") # Create an empty event object. @@ -94,7 +92,7 @@ # Use Python API to kill the process. The listening thread should be # able to receive a state changed event. - self.process.Kill() + process.Kill() # Let's start the listening thread to retrieve the event. my_thread = MyListeningThread() @@ -122,14 +120,12 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at the entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) - - self.process = target.GetProcess() - self.assertTrue(self.process.GetState() == lldb.eStateStopped, + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) # Get a handle on the process's broadcaster. - broadcaster = self.process.GetBroadcaster() + broadcaster = process.GetBroadcaster() self.assertTrue(broadcaster, "Process with valid broadcaster") # Create an empty event object. @@ -188,7 +184,7 @@ # Use Python API to continue the process. The listening thread should be # able to receive the state changed events. - self.process.Continue() + process.Continue() # Start the listening thread to receive the "running" followed by the # "stopped" events. Modified: lldb/trunk/test/python_api/frame/TestFrames.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/TestFrames.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/frame/TestFrames.py (original) +++ lldb/trunk/test/python_api/frame/TestFrames.py Wed Jun 15 17:14:12 2011 @@ -41,9 +41,6 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at the entry point. - # Note that we don't assign the process to self.process as in other test - # cases. We want the inferior to run till it exits and there's no need - # for the testing framework to kill the inferior upon tearDown(). process = target.LaunchSimple(None, None, os.getcwd()) process = target.GetProcess() Modified: lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py (original) +++ lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py Wed Jun 15 17:14:12 2011 @@ -53,14 +53,12 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) - - self.process = target.GetProcess() - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1. - self.assertTrue(self.process.GetState() == lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() @@ -77,9 +75,9 @@ print "context1:", context1 # Continue the inferior, the breakpoint 2 should be hit. - self.process.Continue() - self.assertTrue(self.process.GetState() == lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + process.Continue() + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() Modified: lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py (original) +++ lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py Wed Jun 15 17:14:12 2011 @@ -53,14 +53,12 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) - - self.process = target.GetProcess() - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1. - self.assertTrue(self.process.GetState() == lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) symbol_line1 = frame0.GetSymbol() @@ -71,9 +69,9 @@ self.assertTrue(addr_line1.GetSectionType() == lldb.eSectionTypeCode) # Continue the inferior, the breakpoint 2 should be hit. - self.process.Continue() - self.assertTrue(self.process.GetState() == lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + process.Continue() + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) symbol_line2 = frame0.GetSymbol() Modified: lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py (original) +++ lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py Wed Jun 15 17:14:12 2011 @@ -59,18 +59,17 @@ ci.HandleCommand("process launch", res) self.assertTrue(res.Succeeded()) - # Assigning to self.process so it gets cleaned up during test tear down. - self.process = ci.GetProcess() - self.assertTrue(self.process) + process = ci.GetProcess() + self.assertTrue(process) import lldbutil - if self.process.GetState() != lldb.eStateStopped: + if process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % - lldbutil.state_type_to_str(self.process.GetState())) + lldbutil.state_type_to_str(process.GetState())) if self.TraceOn(): - lldbutil.print_stacktraces(self.process) + lldbutil.print_stacktraces(process) if __name__ == '__main__': Modified: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py (original) +++ lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Wed Jun 15 17:14:12 2011 @@ -33,15 +33,15 @@ self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) + process = target.LaunchSimple(None, None, os.getcwd()) - if not self.process: + if not process: self.fail("SBTarget.LaunchProcess() failed") - self.assertTrue(self.process.GetState() == lldb.eStateStopped, + self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) import lldbutil - thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) frame0 = thread.GetFrameAtIndex(0) frame1 = thread.GetFrameAtIndex(1) parent = lldbutil.get_parent_frame(frame0) Modified: lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py Wed Jun 15 17:14:12 2011 @@ -45,9 +45,9 @@ # Now launch the process, and do not stop at entry point. rc = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) + process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - if not rc.Success() or not self.process: + if not rc.Success() or not process: self.fail("SBTarget.LaunchProcess() failed") from lldbutil import get_description @@ -106,14 +106,14 @@ # Now launch the process, and do not stop at entry point. rc = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) + process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - if not rc.Success() or not self.process: + if not rc.Success() or not process: self.fail("SBTarget.LaunchProcess() failed") from lldbutil import print_stacktrace stopped_due_to_breakpoint = False - for thread in self.process: + for thread in process: if self.TraceOn(): print_stacktrace(thread) ID = thread.GetThreadID() Modified: lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py Wed Jun 15 17:14:12 2011 @@ -34,13 +34,13 @@ # Now launch the process, and do not stop at entry point. rc = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) + process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - if not rc.Success() or not self.process: + if not rc.Success() or not process: self.fail("SBTarget.LaunchProcess() failed") import lldbutil - for thread in self.process: + for thread in process: if thread.GetStopReason() == lldb.eStopReasonBreakpoint: for frame in thread: # Dump the registers of this frame using lldbutil.get_GPRs() and friends. Modified: lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py (original) +++ lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py Wed Jun 15 17:14:12 2011 @@ -35,19 +35,19 @@ # Now launch the process, and do not stop at entry point. rc = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) + process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - if not rc.Success() or not self.process: + if not rc.Success() or not process: self.fail("SBTarget.LaunchProcess() failed") import lldbutil - if self.process.GetState() != lldb.eStateStopped: + if process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'stopped' state, " "instead the actual state is: '%s'" % - lldbutil.state_type_to_str(self.process.GetState())) + lldbutil.state_type_to_str(process.GetState())) if self.TraceOn(): - lldbutil.print_stacktraces(self.process) + lldbutil.print_stacktraces(process) if __name__ == '__main__': Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/TestProcessAPI.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/TestProcessAPI.py (original) +++ lldb/trunk/test/python_api/process/TestProcessAPI.py Wed Jun 15 17:14:12 2011 @@ -76,9 +76,9 @@ # Launch the process, and do not stop at the entry point. error = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) + process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") frame = thread.GetFrameAtIndex(0) @@ -95,7 +95,7 @@ # Due to the typemap magic (see lldb.swig), we pass in 1 to ReadMemory and # expect to get a Python string as the result object! - content = self.process.ReadMemory(location, 1, error) + content = process.ReadMemory(location, 1, error) if not error.Success(): self.fail("SBProcess.ReadMemory() failed") if self.TraceOn(): @@ -118,9 +118,9 @@ # Launch the process, and do not stop at the entry point. error = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) + process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") frame = thread.GetFrameAtIndex(0) @@ -139,14 +139,14 @@ # But we want to use the WriteMemory() API to assign 'a' to the variable. # Now use WriteMemory() API to write 'a' into the global variable. - result = self.process.WriteMemory(location, 'a', error) + result = process.WriteMemory(location, 'a', error) if not error.Success() or result != 1: self.fail("SBProcess.WriteMemory() failed") # Read from the memory location. This time it should be 'a'. # Due to the typemap magic (see lldb.swig), we pass in 1 to ReadMemory and # expect to get a Python string as the result object! - content = self.process.ReadMemory(location, 1, error) + content = process.ReadMemory(location, 1, error) if not error.Success(): self.fail("SBProcess.ReadMemory() failed") if self.TraceOn(): @@ -169,9 +169,9 @@ # Launch the process, and do not stop at the entry point. error = lldb.SBError() - self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) + process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") frame = thread.GetFrameAtIndex(0) @@ -192,7 +192,7 @@ byteSize = val.GetByteSize() bytes = int_to_bytearray(256, byteSize) - byteOrder = self.process.GetByteOrder() + byteOrder = process.GetByteOrder() if byteOrder == lldb.eByteOrderBig: bytes.reverse() elif byteOrder == lldb.eByteOrderLittle: @@ -207,7 +207,7 @@ # Now use WriteMemory() API to write 256 into the global variable. new_value = str(bytes) - result = self.process.WriteMemory(location, new_value, error) + result = process.WriteMemory(location, new_value, error) if not error.Success() or result != byteSize: self.fail("SBProcess.WriteMemory() failed") @@ -225,7 +225,7 @@ startstr = '256') # Now read the memory content. The bytearray should have (byte)1 as the second element. - content = self.process.ReadMemory(location, byteSize, error) + content = process.ReadMemory(location, byteSize, error) if not error.Success(): self.fail("SBProcess.ReadMemory() failed") Modified: lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py (original) +++ lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py Wed Jun 15 17:14:12 2011 @@ -47,14 +47,12 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) - - self.process = target.GetProcess() - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line. from lldbutil import get_stopped_thread - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") frame0 = thread.GetFrameAtIndex(0) self.assertTrue(frame0.GetLineEntry().GetLine() == self.line) Modified: lldb/trunk/test/python_api/target/TestTargetAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/TestTargetAPI.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/target/TestTargetAPI.py (original) +++ lldb/trunk/test/python_api/target/TestTargetAPI.py Wed Jun 15 17:14:12 2011 @@ -99,8 +99,7 @@ breakpoint = target.BreakpointCreateByLocation('main.c', line) # Now launch the process, do not stop at entry point, and redirect stdout to "stdout.txt" file. - # The inferior should run to completion after "process.Continue()" call, so there's no need - # to assign to self.process to have the inferior kiiled during test teardown. + # The inferior should run to completion after "process.Continue()" call. error = lldb.SBError() process = target.Launch (self.dbg.GetListener(), None, None, None, "stdout.txt", None, None, 0, False, error) process.Continue() @@ -146,14 +145,12 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) - - self.process = target.GetProcess() - self.assertTrue(self.process, PROCESS_IS_VALID) + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line1. - self.assertTrue(self.process.GetState() == lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") #self.runCmd("process status") frame0 = thread.GetFrameAtIndex(0) @@ -163,9 +160,9 @@ address1 = lineEntry.GetStartAddress() # Continue the inferior, the breakpoint 2 should be hit. - self.process.Continue() - self.assertTrue(self.process.GetState() == lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + process.Continue() + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") #self.runCmd("process status") frame0 = thread.GetFrameAtIndex(0) Modified: lldb/trunk/test/python_api/thread/TestThreadAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/thread/TestThreadAPI.py?rev=133097&r1=133096&r2=133097&view=diff ============================================================================== --- lldb/trunk/test/python_api/thread/TestThreadAPI.py (original) +++ lldb/trunk/test/python_api/thread/TestThreadAPI.py Wed Jun 15 17:14:12 2011 @@ -116,15 +116,15 @@ self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) + process = target.LaunchSimple(None, None, os.getcwd()) - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") self.runCmd("process status") proc_of_thread = thread.GetProcess() #print "proc_of_thread:", proc_of_thread - self.assertTrue(proc_of_thread.GetProcessID() == self.process.GetProcessID()) + self.assertTrue(proc_of_thread.GetProcessID() == process.GetProcessID()) def get_stop_description(self): """Test Python SBThread.GetStopDescription() API.""" @@ -138,9 +138,9 @@ #self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) + process = target.LaunchSimple(None, None, os.getcwd()) - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") #self.runCmd("process status") @@ -163,10 +163,10 @@ self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) + process = target.LaunchSimple(None, None, os.getcwd()) while True: - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") caller_symbol = get_caller_symbol(thread) #print "caller symbol of malloc:", caller_symbol @@ -176,7 +176,7 @@ break #self.runCmd("thread backtrace") #self.runCmd("process status") - self.process.Continue() + process.Continue() thread.StepOut() self.runCmd("thread backtrace") @@ -196,13 +196,13 @@ self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) + process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(self.process, PROCESS_IS_VALID) + self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line2. - self.assertTrue(self.process.GetState() == lldb.eStateStopped) - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.runCmd("thread backtrace") frame0 = thread.GetFrameAtIndex(0) @@ -237,13 +237,13 @@ self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. - self.process = target.LaunchSimple(None, None, os.getcwd()) + process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(self.process, PROCESS_IS_VALID) + self.assertTrue(process, PROCESS_IS_VALID) # Frame #0 should be on self.line2. - self.assertTrue(self.process.GetState() == lldb.eStateStopped) - thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") self.runCmd("thread backtrace") frame0 = thread.GetFrameAtIndex(0) From ctice at apple.com Thu Jun 16 11:27:20 2011 From: ctice at apple.com (Caroline Tice) Date: Thu, 16 Jun 2011 16:27:20 -0000 Subject: [Lldb-commits] [lldb] r133162 - in /lldb/trunk: include/lldb/Interpreter/CommandInterpreter.h source/Commands/CommandObjectBreakpointCommand.cpp source/Commands/CommandObjectCommands.cpp source/Commands/CommandObjectExpression.cpp source/Commands/CommandObjectTarget.cpp source/Core/Debugger.cpp source/Core/InputReader.cpp source/Interpreter/CommandInterpreter.cpp source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110616162720.2D3452A6C12C@llvm.org> Author: ctice Date: Thu Jun 16 11:27:19 2011 New Revision: 133162 URL: http://llvm.org/viewvc/llvm-project?rev=133162&view=rev Log: Add 'batch_mode' to CommandInterpreter. Modify InputReaders to not write output (prompts, instructions,etc.) if the CommandInterpreter is in batch_mode. Also, finish updating InputReaders to write to the asynchronous stream, rather than using the Debugger's output file directly. Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/InputReader.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=133162&r1=133161&r2=133162&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Thu Jun 16 11:27:19 2011 @@ -354,6 +354,12 @@ const char *search_word, StringList &commands_found, StringList &commands_help); + + bool + GetBatchCommandMode () { return m_batch_command_mode; } + + void + SetBatchCommandMode (bool value) { m_batch_command_mode = value; } protected: friend class Debugger; @@ -378,6 +384,7 @@ std::string m_repeat_command; // Stores the command that will be executed for an empty command string. std::auto_ptr m_script_interpreter_ap; char m_comment_char; + bool m_batch_command_mode; }; Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=133162&r1=133161&r2=133162&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Thu Jun 16 11:27:19 2011 @@ -445,25 +445,29 @@ size_t bytes_len ) { - File &out_file = reader.GetDebugger().GetOutputFile(); - + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); + bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode(); + switch (notification) { case eInputReaderActivate: - out_file.Printf ("%s\n", g_reader_instructions); - if (reader.GetPrompt()) - out_file.Printf ("%s", reader.GetPrompt()); - out_file.Flush(); + if (!batch_mode) + { + out_stream->Printf ("%s\n", g_reader_instructions); + if (reader.GetPrompt()) + out_stream->Printf ("%s", reader.GetPrompt()); + out_stream->Flush(); + } break; case eInputReaderDeactivate: break; case eInputReaderReactivate: - if (reader.GetPrompt()) + if (reader.GetPrompt() && !batch_mode) { - out_file.Printf ("%s", reader.GetPrompt()); - out_file.Flush(); + out_stream->Printf ("%s", reader.GetPrompt()); + out_stream->Flush(); } break; @@ -481,10 +485,10 @@ ((BreakpointOptions::CommandData *)bp_options_baton->m_data)->user_source.AppendString (bytes, bytes_len); } } - if (!reader.IsDone() && reader.GetPrompt()) + if (!reader.IsDone() && reader.GetPrompt() && !batch_mode) { - out_file.Printf ("%s", reader.GetPrompt()); - out_file.Flush(); + out_stream->Printf ("%s", reader.GetPrompt()); + out_stream->Flush(); } break; @@ -502,8 +506,11 @@ ((BreakpointOptions::CommandData *) bp_options_baton->m_data)->script_source.Clear(); } } - out_file.Printf ("Warning: No command attached to breakpoint.\n"); - out_file.Flush(); + if (!batch_mode) + { + out_stream->Printf ("Warning: No command attached to breakpoint.\n"); + out_stream->Flush(); + } } break; Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=133162&r1=133161&r2=133162&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Thu Jun 16 11:27:19 2011 @@ -925,10 +925,12 @@ size_t bytes_len) { CommandObjectCommandsAddRegex *add_regex_cmd = (CommandObjectCommandsAddRegex *) baton; + bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode(); switch (notification) { case eInputReaderActivate: + if (!batch_mode) { StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream (); out_stream->Printf("%s\n", "Enter regular expressions in the form 's///' and terminate with an empty line:"); @@ -955,9 +957,12 @@ Error error (add_regex_cmd->AppendRegexSubstitution (bytes_strref)); if (error.Fail()) { - StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); - out_stream->Printf("error: %s\n", error.AsCString()); - out_stream->Flush(); + if (!batch_mode) + { + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); + out_stream->Printf("error: %s\n", error.AsCString()); + out_stream->Flush(); + } add_regex_cmd->InputReaderDidCancel (); reader.SetIsDone (true); } @@ -967,9 +972,12 @@ case eInputReaderInterrupt: { reader.SetIsDone (true); - StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); - out_stream->PutCString("Regular expression command creations was cancelled.\n"); - out_stream->Flush(); + if (!batch_mode) + { + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); + out_stream->PutCString("Regular expression command creations was cancelled.\n"); + out_stream->Flush(); + } add_regex_cmd->InputReaderDidCancel (); } break; Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=133162&r1=133161&r2=133162&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Jun 16 11:27:19 2011 @@ -191,10 +191,12 @@ ) { CommandObjectExpression *cmd_object_expr = (CommandObjectExpression *) baton; - + bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode(); + switch (notification) { case eInputReaderActivate: + if (!batch_mode) { StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); out_stream->Printf("%s\n", "Enter expressions, then terminate with an empty line to evaluate:"); @@ -224,6 +226,7 @@ case eInputReaderInterrupt: cmd_object_expr->m_expr_lines.clear(); reader.SetIsDone (true); + if (!batch_mode) { StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); out_stream->Printf("%s\n", "Expression evaluation cancelled."); Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=133162&r1=133161&r2=133162&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Thu Jun 16 11:27:19 2011 @@ -3075,17 +3075,21 @@ const char *bytes, size_t bytes_len) { - File &out_file = reader.GetDebugger().GetOutputFile(); + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); Target::StopHook *new_stop_hook = ((Target::StopHook *) baton); static bool got_interrupted; + bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode(); switch (notification) { case eInputReaderActivate: - out_file.Printf ("%s\n", "Enter your stop hook command(s). Type 'DONE' to end."); - if (reader.GetPrompt()) - out_file.Printf ("%s", reader.GetPrompt()); - out_file.Flush(); + if (!batch_mode) + { + out_stream->Printf ("%s\n", "Enter your stop hook command(s). Type 'DONE' to end."); + if (reader.GetPrompt()) + out_stream->Printf ("%s", reader.GetPrompt()); + out_stream->Flush(); + } got_interrupted = false; break; @@ -3093,10 +3097,10 @@ break; case eInputReaderReactivate: - if (reader.GetPrompt()) + if (reader.GetPrompt() && !batch_mode) { - out_file.Printf ("%s", reader.GetPrompt()); - out_file.Flush(); + out_stream->Printf ("%s", reader.GetPrompt()); + out_stream->Flush(); } got_interrupted = false; break; @@ -3113,10 +3117,10 @@ commands->AppendString (bytes, bytes_len); } } - if (!reader.IsDone() && reader.GetPrompt()) + if (!reader.IsDone() && reader.GetPrompt() && !batch_mode) { - out_file.Printf ("%s", reader.GetPrompt()); - out_file.Flush(); + out_stream->Printf ("%s", reader.GetPrompt()); + out_stream->Flush(); } break; @@ -3124,8 +3128,12 @@ { // Finish, and cancel the stop hook. new_stop_hook->GetTarget()->RemoveStopHookByID(new_stop_hook->GetID()); - out_file.Printf ("Stop hook cancelled.\n"); - + if (!batch_mode) + { + out_stream->Printf ("Stop hook cancelled.\n"); + out_stream->Flush(); + } + reader.SetIsDone (true); } got_interrupted = true; @@ -3136,8 +3144,11 @@ break; case eInputReaderDone: - if (!got_interrupted) - out_file.Printf ("Stop hook #%d added.\n", new_stop_hook->GetID()); + if (!got_interrupted && !batch_mode) + { + out_stream->Printf ("Stop hook #%d added.\n", new_stop_hook->GetID()); + out_stream->Flush(); + } break; } Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=133162&r1=133161&r2=133162&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Jun 16 11:27:19 2011 @@ -452,19 +452,9 @@ bool Debugger::InputReaderIsTopReader (const lldb::InputReaderSP& reader_sp) { - if (reader_sp) - { - InputReaderSP top_reader_sp (GetCurrentInputReader()); - if (top_reader_sp) - { - return (reader_sp.get() == top_reader_sp.get()); - } - else - return false; - } - else - return false; + InputReaderSP top_reader_sp (GetCurrentInputReader()); + return (reader_sp.get() == top_reader_sp.get()); } Modified: lldb/trunk/source/Core/InputReader.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/InputReader.cpp?rev=133162&r1=133161&r2=133162&view=diff ============================================================================== --- lldb/trunk/source/Core/InputReader.cpp (original) +++ lldb/trunk/source/Core/InputReader.cpp Thu Jun 16 11:27:19 2011 @@ -11,6 +11,7 @@ #include "lldb/Core/InputReader.h" #include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/CommandInterpreter.h" using namespace lldb; using namespace lldb_private; @@ -300,6 +301,9 @@ void InputReader::RefreshPrompt () { + if (m_debugger.GetCommandInterpreter().GetBatchCommandMode()) + return; + if (!m_prompt.empty()) { File &out_file = m_debugger.GetOutputFile(); Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=133162&r1=133161&r2=133162&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Jun 16 11:27:19 2011 @@ -69,7 +69,8 @@ m_synchronous_execution (synchronous_execution), m_skip_lldbinit_files (false), m_script_interpreter_ap (), - m_comment_char ('#') + m_comment_char ('#'), + m_batch_command_mode (false) { const char *dbg_name = debugger.GetInstanceName().AsCString(); std::string lang_name = ScriptInterpreter::LanguageToString (script_language); Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=133162&r1=133161&r2=133162&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Thu Jun 16 11:27:19 2011 @@ -499,13 +499,18 @@ if (script_interpreter->m_script_lang != eScriptLanguagePython) return 0; - File &out_file = reader.GetDebugger().GetOutputFile(); - + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); + bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode(); + switch (notification) { case eInputReaderActivate: { - out_file.Printf ("Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.\n"); + if (!batch_mode) + { + out_stream->Printf ("Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.\n"); + out_stream->Flush(); + } // Save terminal settings if we can int input_fd = reader.GetDebugger().GetInputFile().GetDescriptor(); @@ -518,7 +523,8 @@ { while (!GetPythonLock(1)) { - out_file.Printf ("Python interpreter locked on another thread; waiting to acquire lock...\n"); + out_stream->Printf ("Python interpreter locked on another thread; waiting to acquire lock...\n"); + out_stream->Flush(); } script_interpreter->EnterSession (); ReleasePythonLock(); @@ -958,21 +964,22 @@ size_t bytes_len ) { - static StringList commands_in_progress; - - File &out_file = reader.GetDebugger().GetOutputFile(); - + static StringList commands_in_progress; + + StreamSP out_stream = reader.GetDebugger().GetAsyncOutputStream(); + bool batch_mode = reader.GetDebugger().GetCommandInterpreter().GetBatchCommandMode(); + switch (notification) { case eInputReaderActivate: { commands_in_progress.Clear(); - if (out_file.IsValid()) + if (!batch_mode) { - out_file.Printf ("%s\n", g_reader_instructions); + out_stream->Printf ("%s\n", g_reader_instructions); if (reader.GetPrompt()) - out_file.Printf ("%s", reader.GetPrompt()); - out_file.Flush (); + out_stream->Printf ("%s", reader.GetPrompt()); + out_stream->Flush (); } } break; @@ -981,10 +988,10 @@ break; case eInputReaderReactivate: - if (reader.GetPrompt() && out_file.IsValid()) + if (reader.GetPrompt() && !batch_mode) { - out_file.Printf ("%s", reader.GetPrompt()); - out_file.Flush (); + out_stream->Printf ("%s", reader.GetPrompt()); + out_stream->Flush (); } break; @@ -995,10 +1002,10 @@ { std::string temp_string (bytes, bytes_len); commands_in_progress.AppendString (temp_string.c_str()); - if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt()) + if (!reader.IsDone() && reader.GetPrompt() && !batch_mode) { - out_file.Printf ("%s", reader.GetPrompt()); - out_file.Flush (); + out_stream->Printf ("%s", reader.GetPrompt()); + out_stream->Flush (); } } break; @@ -1033,12 +1040,19 @@ bp_options->SetCallback (ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp); } } - else - out_file.Printf ("Warning: No command attached to breakpoint.\n"); + else if (!batch_mode) + { + out_stream->Printf ("Warning: No command attached to breakpoint.\n"); + out_stream->Flush(); + } } else { - out_file.Printf ("Warning: Unable to find script intepreter; no command attached to breakpoint.\n"); + if (!batch_mode) + { + out_stream->Printf ("Warning: Unable to find script intepreter; no command attached to breakpoint.\n"); + out_stream->Flush(); + } } } } From gclayton at apple.com Thu Jun 16 16:22:36 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 16 Jun 2011 21:22:36 -0000 Subject: [Lldb-commits] [lldb] r133193 - /lldb/trunk/lldb.xcodeproj/project.pbxproj Message-ID: <20110616212236.A48D52A6C12C@llvm.org> Author: gclayton Date: Thu Jun 16 16:22:36 2011 New Revision: 133193 URL: http://llvm.org/viewvc/llvm-project?rev=133193&view=rev Log: Add some extra linker flags to LLDB.framework so we can track down why we aren't getting debug info from the liblldb-core.a file in our build server builds. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=133193&r1=133192&r2=133193&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jun 16 16:22:36 2011 @@ -3431,6 +3431,9 @@ Foundation, "-framework", AppKit, + "-v", + "-t", + "-Wl,-v", ); PRODUCT_NAME = LLDB; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include"; @@ -3480,6 +3483,9 @@ Foundation, "-framework", AppKit, + "-v", + "-t", + "-Wl,-v", ); PRODUCT_NAME = LLDB; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include"; @@ -3708,6 +3714,9 @@ Foundation, "-framework", AppKit, + "-v", + "-t", + "-Wl,-v", ); PRODUCT_NAME = LLDB; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include"; From ctice at apple.com Thu Jun 16 17:07:38 2011 From: ctice at apple.com (Caroline Tice) Date: Thu, 16 Jun 2011 22:07:38 -0000 Subject: [Lldb-commits] [lldb] r133203 - /lldb/branches/commands-from-file/ Message-ID: <20110616220738.37AC62A6C12C@llvm.org> Author: ctice Date: Thu Jun 16 17:07:38 2011 New Revision: 133203 URL: http://llvm.org/viewvc/llvm-project?rev=133203&view=rev Log: Create a branch to hold current work on reading lines from a file and directing them to the approprate InputReader (or HandleCommand). Added: lldb/branches/commands-from-file/ - copied from r133202, lldb/trunk/ From johnny.chen at apple.com Thu Jun 16 17:07:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Jun 2011 22:07:48 -0000 Subject: [Lldb-commits] [lldb] r133204 - in /lldb/trunk/test: lldbutil.py python_api/lldbutil/frame/TestFrameUtils.py python_api/lldbutil/process/TestPrintStackTraces.py Message-ID: <20110616220748.C35FE2A6C12C@llvm.org> Author: johnny Date: Thu Jun 16 17:07:48 2011 New Revision: 133204 URL: http://llvm.org/viewvc/llvm-project?rev=133204&view=rev Log: o lldbutil.py: For the print_stacktrace(thread, string_buffer = False) function, if we have debug info for a frame function, let's also emit the args for the current function. o TestFrameUtils.py: Add stronger assertTrue for frame0's args. o TestPrintStackTraces.py: Launch the inferior with ["abc", "xyz"] and expect '(int)argc=3' in the stack traces, since by design the inferior is built with debug info. Modified: lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=133204&r1=133203&r2=133204&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Thu Jun 16 17:07:48 2011 @@ -387,11 +387,14 @@ load_addr = addrs[i].GetLoadAddress(target) if not function: file_addr = addrs[i].GetFileAddress() - print >> output, " frame #{num}: {addr:#016x} {mod}`{symbol} + ????".format( - num=i, addr=load_addr, mod=mods[i], symbol=symbols[i]) + start_addr = frame.GetSymbol().GetStartAddress().GetFileAddress() + symbol_offset = file_addr - start_addr + print >> output, " frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}".format( + num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset) else: - print >> output, " frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line}".format( - num=i, addr=load_addr, mod=mods[i], func=funcs[i], file=files[i], line=lines[i]) + print >> output, " frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}".format( + num=i, addr=load_addr, mod=mods[i], func=funcs[i], file=files[i], line=lines[i], + args=get_args_as_string(frame, showFuncName=False)) if string_buffer: return output.getvalue() @@ -429,7 +432,7 @@ # If we reach here, no parent has been found, return None. return None -def get_args_as_string(frame): +def get_args_as_string(frame, showFuncName=True): """ Returns the args of the input frame object as a string. """ @@ -449,8 +452,11 @@ name = frame.GetSymbol().GetName() else: name = "" - return "%s(%s)" % (name, ", ".join(args)) - + if showFuncName: + return "%s(%s)" % (name, ", ".join(args)) + else: + return "(%s)" % (", ".join(args)) + def print_registers(frame, string_buffer = False): """Prints all the register sets of the frame.""" Modified: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py?rev=133204&r1=133203&r2=133204&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py (original) +++ lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Thu Jun 16 17:07:48 2011 @@ -48,7 +48,7 @@ self.assertTrue(parent and parent.GetFrameID() == frame1.GetFrameID()) frame0_args = lldbutil.get_args_as_string(frame0) parent_args = lldbutil.get_args_as_string(parent) - self.assertTrue(frame0_args and parent_args) + self.assertTrue(frame0_args and parent_args and "(int)val=1" in frame0_args) if self.TraceOn(): lldbutil.print_stacktrace(thread) print "Current frame: %s" % frame0_args Modified: lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py?rev=133204&r1=133203&r2=133204&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py (original) +++ lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py Thu Jun 16 17:07:48 2011 @@ -35,7 +35,7 @@ # Now launch the process, and do not stop at entry point. rc = lldb.SBError() - process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) + process = target.Launch (self.dbg.GetListener(), ["abc", "xyz"], None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) if not rc.Success() or not process: self.fail("SBTarget.LaunchProcess() failed") @@ -46,8 +46,9 @@ "instead the actual state is: '%s'" % lldbutil.state_type_to_str(process.GetState())) - if self.TraceOn(): - lldbutil.print_stacktraces(process) + stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) + self.expect(stacktraces, exe=False, + substrs = ['(int)argc=3']) if __name__ == '__main__': From ctice at apple.com Thu Jun 16 17:40:38 2011 From: ctice at apple.com (Caroline Tice) Date: Thu, 16 Jun 2011 22:40:38 -0000 Subject: [Lldb-commits] [lldb] r133209 - in /lldb/branches/commands-from-file: include/lldb/API/SBCommandInterpreter.h include/lldb/API/SBInputReader.h include/lldb/Core/Debugger.h include/lldb/Interpreter/CommandInterpreter.h source/API/SBCommandInterpreter.cpp source/Interpreter/CommandInterpreter.cpp tools/driver/Driver.cpp Message-ID: <20110616224038.3EB392A6C12C@llvm.org> Author: ctice Date: Thu Jun 16 17:40:38 2011 New Revision: 133209 URL: http://llvm.org/viewvc/llvm-project?rev=133209&view=rev Log: Commit current work on reading commands from files and directing it to appropriate InputReaders. Hopefully this commit will go to my newly created branch. Modified: lldb/branches/commands-from-file/include/lldb/API/SBCommandInterpreter.h lldb/branches/commands-from-file/include/lldb/API/SBInputReader.h lldb/branches/commands-from-file/include/lldb/Core/Debugger.h lldb/branches/commands-from-file/include/lldb/Interpreter/CommandInterpreter.h lldb/branches/commands-from-file/source/API/SBCommandInterpreter.cpp lldb/branches/commands-from-file/source/Interpreter/CommandInterpreter.cpp lldb/branches/commands-from-file/tools/driver/Driver.cpp Modified: lldb/branches/commands-from-file/include/lldb/API/SBCommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/commands-from-file/include/lldb/API/SBCommandInterpreter.h?rev=133209&r1=133208&r2=133209&view=diff ============================================================================== --- lldb/branches/commands-from-file/include/lldb/API/SBCommandInterpreter.h (original) +++ lldb/branches/commands-from-file/include/lldb/API/SBCommandInterpreter.h Thu Jun 16 17:40:38 2011 @@ -87,6 +87,9 @@ int match_start_point, int max_return_elements, lldb::SBStringList &matches); + + void + SetInputReader (lldb::SBInputReader &reader); protected: Modified: lldb/branches/commands-from-file/include/lldb/API/SBInputReader.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/commands-from-file/include/lldb/API/SBInputReader.h?rev=133209&r1=133208&r2=133209&view=diff ============================================================================== --- lldb/branches/commands-from-file/include/lldb/API/SBInputReader.h (original) +++ lldb/branches/commands-from-file/include/lldb/API/SBInputReader.h Thu Jun 16 17:40:38 2011 @@ -64,6 +64,7 @@ protected: friend class SBDebugger; + friend class SBCommandInterpreter; #ifndef SWIG Modified: lldb/branches/commands-from-file/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/commands-from-file/include/lldb/Core/Debugger.h?rev=133209&r1=133208&r2=133209&view=diff ============================================================================== --- lldb/branches/commands-from-file/include/lldb/Core/Debugger.h (original) +++ lldb/branches/commands-from-file/include/lldb/Core/Debugger.h Thu Jun 16 17:40:38 2011 @@ -429,6 +429,7 @@ SetCloseInputOnEOF (bool b); protected: + friend class CommandInterpreter; static void DispatchInputCallback (void *baton, const void *bytes, size_t bytes_len); Modified: lldb/branches/commands-from-file/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/commands-from-file/include/lldb/Interpreter/CommandInterpreter.h?rev=133209&r1=133208&r2=133209&view=diff ============================================================================== --- lldb/branches/commands-from-file/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/branches/commands-from-file/include/lldb/Interpreter/CommandInterpreter.h Thu Jun 16 17:40:38 2011 @@ -360,6 +360,12 @@ void SetBatchCommandMode (bool value) { m_batch_command_mode = value; } + + lldb::InputReaderSP & + GetInputReader () { return m_default_input_reader; } + + void + SetInputReader (lldb::InputReaderSP &reader_sp) { m_default_input_reader = reader_sp; } protected: friend class Debugger; @@ -385,6 +391,7 @@ std::auto_ptr m_script_interpreter_ap; char m_comment_char; bool m_batch_command_mode; + lldb::InputReaderSP m_default_input_reader; }; Modified: lldb/branches/commands-from-file/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/commands-from-file/source/API/SBCommandInterpreter.cpp?rev=133209&r1=133208&r2=133209&view=diff ============================================================================== --- lldb/branches/commands-from-file/source/API/SBCommandInterpreter.cpp (original) +++ lldb/branches/commands-from-file/source/API/SBCommandInterpreter.cpp Thu Jun 16 17:40:38 2011 @@ -18,6 +18,7 @@ #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBInputReader.h" #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBProcess.h" @@ -304,6 +305,13 @@ return CommandObject::GetArgumentDescriptionAsCString (arg_type); } +void +SBCommandInterpreter::SetInputReader (lldb::SBInputReader &reader) +{ + InputReaderSP reader_sp (reader.get()); + if (m_opaque_ptr) + m_opaque_ptr->SetInputReader (reader_sp); +} extern "C" bool LLDBSwigPythonBreakpointCallbackFunction Modified: lldb/branches/commands-from-file/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/commands-from-file/source/Interpreter/CommandInterpreter.cpp?rev=133209&r1=133208&r2=133209&view=diff ============================================================================== --- lldb/branches/commands-from-file/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/branches/commands-from-file/source/Interpreter/CommandInterpreter.cpp Thu Jun 16 17:40:38 2011 @@ -70,7 +70,8 @@ m_skip_lldbinit_files (false), m_script_interpreter_ap (), m_comment_char ('#'), - m_batch_command_mode (false) + m_batch_command_mode (false), + m_default_input_reader () { const char *dbg_name = debugger.GetInstanceName().AsCString(); std::string lang_name = ScriptInterpreter::LanguageToString (script_language); @@ -1874,16 +1875,71 @@ { if (cmd_file.Exists()) { - bool success; StringList commands; - success = commands.ReadFileLines(cmd_file); + InputReaderSP cmd_input_reader = GetInputReader(); + + bool success = commands.ReadFileLines(cmd_file); if (!success) { result.AppendErrorWithFormat ("Error reading commands from file: %s.\n", cmd_file.GetFilename().AsCString()); result.SetStatus (eReturnStatusFailed); return; } - HandleCommands (commands, context, stop_on_continue, stop_on_error, echo_command, print_result, result); + + bool old_async_execution = m_debugger.GetAsyncExecution(); + if (!stop_on_continue) + m_debugger.SetAsyncExecution (false); + + bool save_auto_confirm = m_debugger.GetAutoConfirm(); + m_debugger.SetAutoConfirm (true); + + bool save_batch_command_mode = GetBatchCommandMode(); + SetBatchCommandMode (true); + + size_t num_lines = commands.GetSize(); + StreamString input_stream; + for (size_t i = 0; i < num_lines;++i) + { + const char *cmd = commands.GetStringAtIndex (i); + if (m_debugger.InputReaderIsTopReader (cmd_input_reader)) + { + CommandReturnObject tmp_result; + + if (!cmd || (strlen(cmd) == 0)) // Do NOT interpreter blank lines as 'repeat' + continue; + + if (echo_command) + result.AppendMessageWithFormat ("%s\n", cmd); + success = HandleCommand(cmd, false, tmp_result, NULL); + if (!success || !tmp_result.Succeeded()) + { + if (stop_on_error) + { + result.AppendErrorWithFormat ("Aborting reading of commands after command #%d: '%s' failed.\n", + i, cmd); + result.SetStatus (eReturnStatusFailed); + m_debugger.SetAsyncExecution (old_async_execution); + SetBatchCommandMode (save_batch_command_mode); + return; + } else if (print_result) + { + result.AppendMessageWithFormat ("Command #%d '%s' failed with error: %s.\n", + i + 1, + cmd, + tmp_result.GetErrorData()); + } + } + } + else + { + if (echo_command) + result.AppendMessageWithFormat ("%s\n", cmd); + m_debugger.DispatchInput (cmd, strlen(cmd)); + m_debugger.DispatchInput ("\n", 1); + } + } + SetBatchCommandMode (save_batch_command_mode); + m_debugger.SetAutoConfirm (save_auto_confirm); } else { Modified: lldb/branches/commands-from-file/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/commands-from-file/tools/driver/Driver.cpp?rev=133209&r1=133208&r2=133209&view=diff ============================================================================== --- lldb/branches/commands-from-file/tools/driver/Driver.cpp (original) +++ lldb/branches/commands-from-file/tools/driver/Driver.cpp Thu Jun 16 17:40:38 2011 @@ -1115,6 +1115,7 @@ } m_debugger.PushInputReader (m_editline_reader); + m_debugger.GetCommandInterpreter().SetInputReader (m_editline_reader); SBListener listener(m_debugger.GetListener()); if (listener.IsValid()) From johnny.chen at apple.com Thu Jun 16 19:51:15 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Jun 2011 00:51:15 -0000 Subject: [Lldb-commits] [lldb] r133223 - in /lldb/trunk: source/API/SBTarget.cpp test/hello_world/TestHelloWorld.py test/hello_world/main.c Message-ID: <20110617005115.98C3C2A6C12C@llvm.org> Author: johnny Date: Thu Jun 16 19:51:15 2011 New Revision: 133223 URL: http://llvm.org/viewvc/llvm-project?rev=133223&view=rev Log: o TestHelloWorld.py: Add a test case for the SBTarget::AttachToProcessWithID() API call. o main.c: The change goes with the added test case test_with_dwarf_and_attach_to_process_with_id_api() above. o SBTarget.cpp: Checks whether we're in synchronous mode. If yes, let's wait for the process to stop right after attaching. Modified: lldb/trunk/source/API/SBTarget.cpp lldb/trunk/test/hello_world/TestHelloWorld.py lldb/trunk/test/hello_world/main.c Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=133223&r1=133222&r2=133223&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Thu Jun 16 19:51:15 2011 @@ -290,6 +290,10 @@ if (sb_process.IsValid()) { error.SetError (sb_process->Attach (pid)); + // If we are doing synchronous mode, then wait for the + // process to stop! + if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false) + sb_process->WaitForProcessToStop (NULL); } else { Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=133223&r1=133222&r2=133223&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Thu Jun 16 19:51:15 2011 @@ -27,6 +27,22 @@ self.buildDwarf() self.hello_world_python(useLaunchAPI = True) + @python_api_test + def test_with_dwarf_and_attach_to_process_with_id_api(self): + """Create target, breakpoint, start a process, and attach to it. + + Use dwarf map (no dsym) and attach to process with id API. + """ + self.buildDwarf() + self.hello_world_attach_api() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find a couple of the line numbers within main.c. + self.line1 = line_number('main.c', '// Set break point at this line.') + self.line2 = line_number('main.c', '// Waiting to be attached...') + def hello_world_python(self, useLaunchAPI): """Create target, breakpoint, launch a process, and then kill it.""" @@ -34,7 +50,7 @@ target = self.dbg.CreateTarget(exe) - breakpoint = target.BreakpointCreateByLocation("main.c", 4) + breakpoint = target.BreakpointCreateByLocation("main.c", self.line1) # The default state after breakpoint creation should be enabled. self.assertTrue(breakpoint.IsEnabled(), @@ -74,6 +90,31 @@ # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) + def hello_world_attach_api(self): + """Create target, breakpoint, start a process, and attach to it.""" + + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + + # Spawn a new process. + import subprocess + popen = subprocess.Popen([exe, "abc", "xyz"]) + #print "pid of spawned process: %d" % popen.pid + + listener = lldb.SBListener("my.attach.listener") + error = lldb.SBError() + process = target.AttachToProcessWithID(listener, popen.pid, error) + + self.assertTrue(process, PROCESS_IS_VALID) + + # Let's check the stack traces of the attached process. + import lldbutil + stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) + self.expect(stacktraces, exe=False, + substrs = ['main.c:%d' % self.line2, + '(int)argc=3']) + if __name__ == '__main__': import atexit Modified: lldb/trunk/test/hello_world/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/main.c?rev=133223&r1=133222&r2=133223&view=diff ============================================================================== --- lldb/trunk/test/hello_world/main.c (original) +++ lldb/trunk/test/hello_world/main.c Thu Jun 16 19:51:15 2011 @@ -1,6 +1,15 @@ #include int main(int argc, char const *argv[]) { - printf("Hello world.\n"); - return 0; + printf("Hello world.\n"); // Set break point at this line. + if (argc == 1) + return 0; + + // Waiting to be attached by the debugger, otherwise. + char line[100]; + while (fgets(line, sizeof(line), stdin)) { // Waiting to be attached... + printf("input line=>%s\n", line); + } + + printf("Exiting now\n"); } From gclayton at apple.com Thu Jun 16 20:22:15 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Jun 2011 01:22:15 -0000 Subject: [Lldb-commits] [lldb] r133224 - in /lldb/trunk: include/lldb/API/ include/lldb/Core/ source/API/ source/Core/ source/Host/macosx/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ tools/lldb-platform/ Message-ID: <20110617012216.2BD3F2A6C12C@llvm.org> Author: gclayton Date: Thu Jun 16 20:22:15 2011 New Revision: 133224 URL: http://llvm.org/viewvc/llvm-project?rev=133224&view=rev Log: Improved the packet throughput when debugging with GDB remote by over 3x on darwin (not sure about other platforms). Modified the communication and connection classes to not require the BytesAvailable function. Now the "Read(...)" function has a timeout in microseconds. Fixed a lot of assertions that were firing off in certain cases and replaced them with error output and code that can deal with the assertion case. Modified: lldb/trunk/include/lldb/API/SBCommunication.h lldb/trunk/include/lldb/Core/Communication.h lldb/trunk/include/lldb/Core/Connection.h lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h lldb/trunk/include/lldb/Core/ConnectionMachPort.h lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h lldb/trunk/source/API/SBCommunication.cpp lldb/trunk/source/Core/Communication.cpp lldb/trunk/source/Core/ConnectionFileDescriptor.cpp lldb/trunk/source/Core/ConnectionMachPort.cpp lldb/trunk/source/Core/ConnectionSharedMemory.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp lldb/trunk/tools/lldb-platform/lldb-platform.cpp Modified: lldb/trunk/include/lldb/API/SBCommunication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommunication.h?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommunication.h (original) +++ lldb/trunk/include/lldb/API/SBCommunication.h Thu Jun 16 20:22:15 2011 @@ -41,15 +41,6 @@ AdoptFileDesriptor (int fd, bool owns_fd); lldb::ConnectionStatus - CheckIfBytesAvailable (); - - lldb::ConnectionStatus - WaitForBytesAvailableInfinite (); - - lldb::ConnectionStatus - WaitForBytesAvailableWithTimeout (uint32_t timeout_usec); - - lldb::ConnectionStatus Connect (const char *url); lldb::ConnectionStatus Modified: lldb/trunk/include/lldb/Core/Communication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Communication.h?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Communication.h (original) +++ lldb/trunk/include/lldb/Core/Communication.h Thu Jun 16 20:22:15 2011 @@ -121,20 +121,6 @@ Clear (); //------------------------------------------------------------------ - /// Poll for bytes available if the communications supports it. - /// - /// @param[in] timeout_usec - /// A timeout value in micro-seconds, UINT32_MAX for infinite - /// wait. - /// - /// @return - /// \b True if the bytes are, or became available within the - /// timeout period, \b false otherwise. - //------------------------------------------------------------------ - virtual lldb::ConnectionStatus - BytesAvailable (uint32_t timeout_usec, Error *error_ptr); - - //------------------------------------------------------------------ /// Connect using the current connection by passing \a url to its /// connect function. /// string. @@ -185,10 +171,7 @@ /// Read bytes from the current connection. /// /// If no read thread is running, this function call the - /// connection's Connection::BytesAvailable(uint32_t) method to - /// wait for available data, and then call the - /// Connection::Read(void *, size_t) function to get any available - /// bytes if Connection::BytesAvailable(uint32_t) returned true. + /// connection's Connection::Read(...) function to get any available. /// /// If a read thread has been started, this function will check for /// any cached bytes that have already been read and return any @@ -212,7 +195,6 @@ /// @return /// The number of bytes actually read. /// - /// @see bool Connection::BytesAvailable (uint32_t); /// @see size_t Connection::Read (void *, size_t); //------------------------------------------------------------------ size_t @@ -365,6 +347,7 @@ size_t ReadFromConnection (void *dst, size_t dst_len, + uint32_t timeout_usec, lldb::ConnectionStatus &status, Error *error_ptr); //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Core/Connection.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Connection.h?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Connection.h (original) +++ lldb/trunk/include/lldb/Core/Connection.h Thu Jun 16 20:22:15 2011 @@ -47,24 +47,6 @@ ~Connection (); //------------------------------------------------------------------ - /// Poll for bytes available if the communications supports it. - /// - /// @param[in] timeout_usec - /// A timeout value in micro-seconds. - /// - /// @param[out] error - /// A reference to an error object that should be given an - /// approriate error value if this method returns false. This - /// value can be NULL if the error value should be ignored. - /// - /// @return - /// \b True if the bytes are, or became available within the - /// timeout period, \b false otherwise. - //------------------------------------------------------------------ - virtual lldb::ConnectionStatus - BytesAvailable (uint32_t timeout_usec, Error *error_ptr) = 0; - - //------------------------------------------------------------------ /// Connect using the connect string \a url. /// /// @param[in] url @@ -137,7 +119,11 @@ /// @see size_t Communication::Read (void *, size_t, uint32_t); //------------------------------------------------------------------ virtual size_t - Read (void *dst, size_t dst_len, lldb::ConnectionStatus &status, Error *error_ptr) = 0; + Read (void *dst, + size_t dst_len, + uint32_t timeout_usec, + lldb::ConnectionStatus &status, + Error *error_ptr) = 0; //------------------------------------------------------------------ /// The actual write function that attempts to write to the Modified: lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h (original) +++ lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h Thu Jun 16 20:22:15 2011 @@ -34,21 +34,29 @@ IsConnected () const; virtual lldb::ConnectionStatus - BytesAvailable (uint32_t timeout_usec, Error *error_ptr); - - virtual lldb::ConnectionStatus Connect (const char *s, Error *error_ptr); virtual lldb::ConnectionStatus Disconnect (Error *error_ptr); virtual size_t - Read (void *dst, size_t dst_len, lldb::ConnectionStatus &status, Error *error_ptr); + Read (void *dst, + size_t dst_len, + uint32_t timeout_usec, + lldb::ConnectionStatus &status, + Error *error_ptr); virtual size_t - Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr); + Write (const void *src, + size_t src_len, + lldb::ConnectionStatus &status, + Error *error_ptr); protected: + + lldb::ConnectionStatus + BytesAvailable (uint32_t timeout_usec, Error *error_ptr); + lldb::ConnectionStatus SocketListen (uint16_t listen_port_num, Error *error_ptr); @@ -67,10 +75,14 @@ int m_fd; // Socket we use to communicate once conn established bool m_is_socket; bool m_should_close_fd; // True if this class should close the file descriptor when it goes away. - + uint32_t m_socket_timeout_usec; + static int SetSocketOption(int fd, int level, int option_name, int option_value); + bool + SetSocketRecieveTimeout (uint32_t timeout_usec); + private: DISALLOW_COPY_AND_ASSIGN (ConnectionFileDescriptor); }; Modified: lldb/trunk/include/lldb/Core/ConnectionMachPort.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionMachPort.h?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ConnectionMachPort.h (original) +++ lldb/trunk/include/lldb/Core/ConnectionMachPort.h Thu Jun 16 20:22:15 2011 @@ -45,6 +45,7 @@ virtual size_t Read (void *dst, size_t dst_len, + uint32_t timeout_usec, lldb::ConnectionStatus &status, lldb_private::Error *error_ptr); Modified: lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h (original) +++ lldb/trunk/include/lldb/Core/ConnectionSharedMemory.h Thu Jun 16 20:22:15 2011 @@ -44,7 +44,11 @@ Disconnect (Error *error_ptr); virtual size_t - Read (void *dst, size_t dst_len, lldb::ConnectionStatus &status, Error *error_ptr); + Read (void *dst, + size_t dst_len, + uint32_t timeout_usec, + lldb::ConnectionStatus &status, + Error *error_ptr); virtual size_t Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr); Modified: lldb/trunk/source/API/SBCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommunication.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommunication.cpp (original) +++ lldb/trunk/source/API/SBCommunication.cpp Thu Jun 16 20:22:15 2011 @@ -59,30 +59,6 @@ } ConnectionStatus -SBCommunication::CheckIfBytesAvailable () -{ - if (m_opaque) - return m_opaque->BytesAvailable (0, NULL); - return eConnectionStatusNoConnection; -} - -ConnectionStatus -SBCommunication::WaitForBytesAvailableInfinite () -{ - if (m_opaque) - return m_opaque->BytesAvailable (UINT32_MAX, NULL); - return eConnectionStatusNoConnection; -} - -ConnectionStatus -SBCommunication::WaitForBytesAvailableWithTimeout (uint32_t timeout_usec) -{ - if (m_opaque) - return m_opaque->BytesAvailable (timeout_usec, NULL); - return eConnectionStatusNoConnection; -} - -ConnectionStatus SBCommunication::Connect (const char *url) { if (m_opaque) Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Thu Jun 16 20:22:15 2011 @@ -69,19 +69,6 @@ } ConnectionStatus -Communication::BytesAvailable (uint32_t timeout_usec, Error *error_ptr) -{ - lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::BytesAvailable (timeout_usec = %u)", this, timeout_usec); - - lldb::ConnectionSP connection_sp (m_connection_sp); - if (connection_sp.get()) - return connection_sp->BytesAvailable (timeout_usec, error_ptr); - if (error_ptr) - error_ptr->SetErrorString("Invalid connection."); - return eConnectionStatusNoConnection; -} - -ConnectionStatus Communication::Connect (const char *url, Error *error_ptr) { Clear(); @@ -139,7 +126,7 @@ Communication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, ConnectionStatus &status, Error *error_ptr) { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, - "%p Communication::Read (dst = %p, dst_len = %zu, timeout_usec = %u) connection = %p", + "%p Communication::Read (dst = %p, dst_len = %zu, timeout = %u usec) connection = %p", this, dst, dst_len, @@ -196,9 +183,7 @@ lldb::ConnectionSP connection_sp (m_connection_sp); if (connection_sp.get()) { - status = connection_sp->BytesAvailable (timeout_usec, error_ptr); - if (status == eConnectionStatusSuccess) - return connection_sp->Read (dst, dst_len, status, error_ptr); + return connection_sp->Read (dst, dst_len, timeout_usec, status, error_ptr); } if (error_ptr) @@ -320,11 +305,15 @@ } size_t -Communication::ReadFromConnection (void *dst, size_t dst_len, ConnectionStatus &status, Error *error_ptr) +Communication::ReadFromConnection (void *dst, + size_t dst_len, + uint32_t timeout_usec, + ConnectionStatus &status, + Error *error_ptr) { lldb::ConnectionSP connection_sp (m_connection_sp); if (connection_sp.get()) - return connection_sp->Read (dst, dst_len, status, error_ptr); + return connection_sp->Read (dst, dst_len, timeout_usec, status, error_ptr); return 0; } @@ -351,20 +340,15 @@ bool done = false; while (!done && comm->m_read_thread_enabled) { - status = comm->BytesAvailable (UINT32_MAX, &error); - - if (status == eConnectionStatusSuccess) + size_t bytes_read = comm->ReadFromConnection (buf, sizeof(buf), 5 * USEC_PER_SEC, status, &error); + if (bytes_read > 0) + comm->AppendBytesToCache (buf, bytes_read, true, status); + else if ((bytes_read == 0) + && status == eConnectionStatusEndOfFile) { - size_t bytes_read = comm->ReadFromConnection (buf, sizeof(buf), status, &error); - if (bytes_read > 0) - comm->AppendBytesToCache (buf, bytes_read, true, status); - else if ((bytes_read == 0) - && status == eConnectionStatusEndOfFile) - { - if (comm->GetCloseOnEOF ()) - comm->Disconnect (); - comm->AppendBytesToCache (buf, bytes_read, true, status); - } + if (comm->GetCloseOnEOF ()) + comm->Disconnect (); + comm->AppendBytesToCache (buf, bytes_read, true, status); } switch (status) @@ -384,7 +368,7 @@ case eConnectionStatusError: // Check GetError() for details case eConnectionStatusTimedOut: // Request timed out if (log) - error.LogIfError(log.get(), "%p Communication::BytesAvailable () => status = %i", p, status); + error.LogIfError(log.get(), "%p Communication::ReadFromConnection () => status = %i", p, status); break; } } Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Thu Jun 16 20:22:15 2011 @@ -39,7 +39,8 @@ Connection(), m_fd (-1), m_is_socket (false), - m_should_close_fd (false) + m_should_close_fd (false), + m_socket_timeout_usec(0) { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT, "%p ConnectionFileDescriptor::ConnectionFileDescriptor ()", @@ -50,7 +51,8 @@ Connection(), m_fd (fd), m_is_socket (false), - m_should_close_fd (owns_fd) + m_should_close_fd (owns_fd), + m_socket_timeout_usec(0) { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT, "%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)", @@ -185,13 +187,33 @@ } size_t -ConnectionFileDescriptor::Read (void *dst, size_t dst_len, ConnectionStatus &status, Error *error_ptr) +ConnectionFileDescriptor::Read (void *dst, + size_t dst_len, + uint32_t timeout_usec, + ConnectionStatus &status, + Error *error_ptr) { LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION)); if (log) log->Printf ("%p ConnectionFileDescriptor::Read () ::read (fd = %i, dst = %p, dst_len = %zu)...", this, m_fd, dst, dst_len); + if (timeout_usec == UINT32_MAX) + { + if (m_is_socket) + SetSocketRecieveTimeout (0); + status = eConnectionStatusSuccess; + } + else + { + if (m_is_socket && SetSocketRecieveTimeout (timeout_usec)) + status = eConnectionStatusSuccess; + else + status = BytesAvailable (timeout_usec, error_ptr); + } + if (status != eConnectionStatusSuccess) + return 0; + Error error; ssize_t bytes_read = ::read (m_fd, dst, dst_len); if (bytes_read == 0) @@ -370,7 +392,7 @@ log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION); if (log) - log->Printf("%p ConnectionFileDescriptor::Write() ::select (nfds = %i, fd = %i, NULL, NULL, timeout = %p)...", + log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds = %i, fd = %i, NULL, NULL, timeout = %p)...", this, nfds, m_fd, tv_ptr); const int num_set_fds = ::select (nfds, &read_fds, NULL, NULL, tv_ptr); @@ -381,7 +403,7 @@ log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION); if (log) - log->Printf("%p ConnectionFileDescriptor::Write() ::select (nfds = %i, fd = %i, NULL, NULL, timeout = %p) => %d, error = %s", + log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds = %i, fd = %i, NULL, NULL, timeout = %p) => %d, error = %s", this, nfds, m_fd, tv_ptr, num_set_fds, error.AsCString()); if (error_ptr) @@ -703,4 +725,25 @@ return ::setsockopt(fd, level, option_name, option_value_p, sizeof(option_value)); } +bool +ConnectionFileDescriptor::SetSocketRecieveTimeout (uint32_t timeout_usec) +{ + if (m_is_socket) + { + // Check in case timeout for m_fd has already been set to this value + if (timeout_usec == m_socket_timeout_usec) + return true; + + struct timeval timeout; + timeout.tv_sec = timeout_usec / USEC_PER_SEC; + timeout.tv_usec = timeout_usec % USEC_PER_SEC; + if (::setsockopt (m_fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) == 0) + { + m_socket_timeout_usec = timeout_usec; + return true; + } + } + return false; +} + Modified: lldb/trunk/source/Core/ConnectionMachPort.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionMachPort.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionMachPort.cpp (original) +++ lldb/trunk/source/Core/ConnectionMachPort.cpp Thu Jun 16 20:22:15 2011 @@ -213,7 +213,11 @@ } size_t -ConnectionMachPort::Read (void *dst, size_t dst_len, ConnectionStatus &status, Error *error_ptr) +ConnectionMachPort::Read (void *dst, + size_t dst_len, + uint32_t timeout_usec, + ConnectionStatus &status, + Error *error_ptr) { PayloadType payload; Modified: lldb/trunk/source/Core/ConnectionSharedMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionSharedMemory.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionSharedMemory.cpp (original) +++ lldb/trunk/source/Core/ConnectionSharedMemory.cpp Thu Jun 16 20:22:15 2011 @@ -80,7 +80,11 @@ } size_t -ConnectionSharedMemory::Read (void *dst, size_t dst_len, ConnectionStatus &status, Error *error_ptr) +ConnectionSharedMemory::Read (void *dst, + size_t dst_len, + uint32_t timeout_usec, + ConnectionStatus &status, + Error *error_ptr) { status = eConnectionStatusSuccess; return 0; Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Thu Jun 16 20:22:15 2011 @@ -195,7 +195,7 @@ char pid_str[256]; ::memset (pid_str, 0, sizeof(pid_str)); ConnectionStatus status; - const size_t pid_str_len = file_conn.Read (pid_str, sizeof(pid_str), status, NULL); + const size_t pid_str_len = file_conn.Read (pid_str, sizeof(pid_str), NULL, status, NULL); if (pid_str_len > 0) { int pid = atoi (pid_str); Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Thu Jun 16 20:22:15 2011 @@ -258,26 +258,40 @@ m_current_offset_backed_up_one = -1; addr_t cfa_regval; int row_register_kind = m_full_unwind_plan_sp->GetRegisterKind (); - uint32_t cfa_regnum = m_full_unwind_plan_sp->GetRowForFunctionOffset(0)->GetCFARegister(); - int cfa_offset = m_full_unwind_plan_sp->GetRowForFunctionOffset(0)->GetCFAOffset(); - if (!ReadGPRValue (row_register_kind, cfa_regnum, cfa_regval)) + const UnwindPlan::Row *row = m_full_unwind_plan_sp->GetRowForFunctionOffset(0); + if (row) { - if (log) + uint32_t cfa_regnum = row->GetCFARegister(); + int cfa_offset = row->GetCFAOffset(); + if (!ReadGPRValue (row_register_kind, cfa_regnum, cfa_regval)) { - log->Printf("%*sFrame %u failed to get cfa value", - m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); + if (log) + { + log->Printf("%*sFrame %u failed to get cfa value", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); + } + m_frame_type = eNormalFrame; + return; } - m_frame_type = eNormalFrame; - return; - } - m_cfa = cfa_regval + cfa_offset; + m_cfa = cfa_regval + cfa_offset; - // A couple of sanity checks.. - if (cfa_regval == LLDB_INVALID_ADDRESS || cfa_regval == 0 || cfa_regval == 1) + // A couple of sanity checks.. + if (cfa_regval == LLDB_INVALID_ADDRESS || cfa_regval == 0 || cfa_regval == 1) + { + if (log) + { + log->Printf("%*sFrame %u could not find a valid cfa address", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); + } + m_frame_type = eNotAValidFrame; + return; + } + } + else { if (log) { - log->Printf("%*sFrame %u could not find a valid cfa address", + log->Printf("%*sFrame %u could not find a row for function offset zero", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); } m_frame_type = eNotAValidFrame; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Thu Jun 16 20:22:15 2011 @@ -39,16 +39,12 @@ bool is_platform) : Communication(comm_name), m_packet_timeout (60), - m_rx_packet_listener (listener_name), m_sequence_mutex (Mutex::eMutexTypeRecursive), m_public_is_running (false), m_private_is_running (false), m_send_acks (true), m_is_platform (is_platform) { - m_rx_packet_listener.StartListeningForEvents(this, - Communication::eBroadcastBitPacketAvailable | - Communication::eBroadcastBitReadThreadDidExit); } //---------------------------------------------------------------------- @@ -56,12 +52,8 @@ //---------------------------------------------------------------------- GDBRemoteCommunication::~GDBRemoteCommunication() { - m_rx_packet_listener.StopListeningForEvents(this, - Communication::eBroadcastBitPacketAvailable | - Communication::eBroadcastBitReadThreadDidExit); if (IsConnected()) { - StopReadThread(); Disconnect(); } } @@ -167,7 +159,7 @@ GDBRemoteCommunication::GetAck () { StringExtractorGDBRemote packet; - if (WaitForPacket (packet, m_packet_timeout) == 1) + if (WaitForPacketWithTimeoutMicroSeconds (packet, GetPacketTimeoutInMicroSeconds ()) == 1) return packet.GetChar(); return 0; } @@ -186,99 +178,63 @@ } size_t -GDBRemoteCommunication::WaitForPacket (StringExtractorGDBRemote &packet, uint32_t timeout_seconds) +GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSeconds (StringExtractorGDBRemote &packet, uint32_t timeout_usec) { Mutex::Locker locker(m_sequence_mutex); - TimeValue timeout_time; - timeout_time = TimeValue::Now(); - timeout_time.OffsetWithSeconds (timeout_seconds); - return WaitForPacketNoLock (packet, &timeout_time); + return WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec); } size_t -GDBRemoteCommunication::WaitForPacket (StringExtractorGDBRemote &packet, const TimeValue* timeout_time_ptr) +GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtractorGDBRemote &packet, uint32_t timeout_usec) { - Mutex::Locker locker(m_sequence_mutex); - return WaitForPacketNoLock (packet, timeout_time_ptr); -} - -size_t -GDBRemoteCommunication::WaitForPacketNoLock (StringExtractorGDBRemote &packet, const TimeValue* timeout_time_ptr) -{ - bool checksum_error = false; - packet.Clear (); + uint8_t buffer[8192]; + Error error; - EventSP event_sp; + // Check for a packet from our cache first without trying any reading... + if (CheckForPacket (NULL, 0, packet)) + return packet.GetStringRef().size(); - if (m_rx_packet_listener.WaitForEvent (timeout_time_ptr, event_sp)) + bool timed_out = false; + while (IsConnected() && !timed_out) { - const uint32_t event_type = event_sp->GetType(); - if (event_type | Communication::eBroadcastBitPacketAvailable) + lldb::ConnectionStatus status; + size_t bytes_read = Read (buffer, sizeof(buffer), timeout_usec, status, &error); + if (bytes_read > 0) { - const EventDataBytes *event_bytes = EventDataBytes::GetEventDataFromEvent(event_sp.get()); - if (event_bytes) - { - const char *packet_data = (const char *)event_bytes->GetBytes(); - const uint32_t packet_size = event_bytes->GetByteSize(); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); - if (log) - log->Printf ("read packet: %.*s", packet_size, packet_data); - if (packet_data && packet_size > 0) - { - std::string &packet_str = packet.GetStringRef(); - if (packet_data[0] == '$') - { - bool success = false; - if (packet_size < 4) - ::fprintf (stderr, "Packet that starts with $ is too short: '%s'\n", packet_data); - else if (packet_data[packet_size-3] != '#' || - !::isxdigit (packet_data[packet_size-2]) || - !::isxdigit (packet_data[packet_size-1])) - ::fprintf (stderr, "Invalid checksum footer for packet: '%s'\n", packet_data); - else - success = true; - - if (success) - packet_str.assign (packet_data + 1, packet_size - 4); - if (GetSendAcks ()) - { - if (success) - { - char packet_checksum = strtol (&packet_data[packet_size-2], NULL, 16); - char actual_checksum = CalculcateChecksum (&packet_str[0], packet_str.size()); - checksum_error = packet_checksum != actual_checksum; - } - // Send the ack or nack if needed - if (checksum_error || !success) - SendNack(); - else - SendAck(); - } - } - else - { - packet_str.assign (packet_data, packet_size); - } - return packet_str.size(); - } - } + if (CheckForPacket (buffer, bytes_read, packet)) + return packet.GetStringRef().size(); } - else if (event_type | Communication::eBroadcastBitReadThreadDidExit) + else { - // Our read thread exited on us so just fall through and return zero... - Disconnect(); + switch (status) + { + case eConnectionStatusSuccess: + break; + + case eConnectionStatusEndOfFile: + case eConnectionStatusNoConnection: + case eConnectionStatusLostConnection: + case eConnectionStatusError: + Disconnect(); + break; + + case eConnectionStatusTimedOut: + timed_out = true; + break; + } } } + packet.Clear (); return 0; } -void -GDBRemoteCommunication::AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast, - ConnectionStatus status) +bool +GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, StringExtractorGDBRemote &packet) { // Put the packet data into the buffer in a thread safe fashion Mutex::Locker locker(m_bytes_mutex); - m_bytes.append ((const char *)src, src_len); + if (src && src_len > 0) + m_bytes.append ((const char *)src, src_len); // Parse up the packets into gdb remote packets while (!m_bytes.empty()) @@ -286,29 +242,40 @@ // end_idx must be one past the last valid packet byte. Start // it off with an invalid value that is the same as the current // index. - size_t end_idx = 0; + size_t content_start = 0; + size_t content_length = 0; + size_t total_length = 0; + size_t checksum_idx = std::string::npos; switch (m_bytes[0]) { case '+': // Look for ack case '-': // Look for cancel case '\x03': // ^C to halt target - end_idx = 1; // The command is one byte long... + content_length = total_length = 1; // The command is one byte long... break; case '$': // Look for a standard gdb packet? - end_idx = m_bytes.find('#'); - if (end_idx != std::string::npos) { - if (end_idx + 2 < m_bytes.size()) + size_t hash_pos = m_bytes.find('#'); + if (hash_pos != std::string::npos) { - end_idx += 3; - } - else - { - // Checksum bytes aren't all here yet - end_idx = std::string::npos; + if (hash_pos + 2 < m_bytes.size()) + { + checksum_idx = hash_pos + 1; + // Skip the dollar sign + content_start = 1; + // Don't include the # in the content or the $ in the content length + content_length = hash_pos - 1; + + total_length = hash_pos + 3; // Skip the # and the two hex checksum bytes + } + else + { + // Checksum bytes aren't all here yet + content_length = std::string::npos; + } } } break; @@ -317,27 +284,76 @@ break; } - if (end_idx == std::string::npos) + LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); + if (content_length == std::string::npos) { - //ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS | GDBR_LOG_VERBOSE, "GDBRemoteCommunication::%s packet not yet complete: '%s'",__FUNCTION__, m_bytes.c_str()); - return; + packet.Clear(); + return false; } - else if (end_idx > 0) + else if (content_length > 0) { + // We have a valid packet... - assert (end_idx <= m_bytes.size()); - std::auto_ptr event_bytes_ap (new EventDataBytes (&m_bytes[0], end_idx)); - ProcessGDBRemoteLog::LogIf (GDBR_LOG_COMM, "got full packet: %s", event_bytes_ap->GetBytes()); - BroadcastEvent (eBroadcastBitPacketAvailable, event_bytes_ap.release()); - m_bytes.erase(0, end_idx); + assert (content_length <= m_bytes.size()); + assert (total_length <= m_bytes.size()); + assert (content_length <= total_length); + + bool success = true; + std::string &packet_str = packet.GetStringRef(); + packet_str.assign (m_bytes, content_start, content_length); + if (m_bytes[0] == '$') + { + assert (checksum_idx < m_bytes.size()); + if (::isxdigit (m_bytes[checksum_idx+0]) || + ::isxdigit (m_bytes[checksum_idx+1])) + { + if (GetSendAcks ()) + { + const char *packet_checksum_cstr = &m_bytes[checksum_idx]; + char packet_checksum = strtol (packet_checksum_cstr, NULL, 16); + char actual_checksum = CalculcateChecksum (packet_str.c_str(), packet_str.size()); + success = packet_checksum == actual_checksum; + if (!success) + { + if (log) + log->Printf ("error: checksum mismatch: %.*s expected 0x%2.2x, got 0x%2.2x", + (int)(total_length), + m_bytes.c_str(), + (uint8_t)packet_checksum, + (uint8_t)actual_checksum); + } + // Send the ack or nack if needed + if (!success) + SendNack(); + else + SendAck(); + } + if (success) + { + if (log) + log->Printf ("read packet: %.*s", (int)(total_length), m_bytes.c_str()); + } + } + else + { + success = false; + if (log) + log->Printf ("error: invalid checksum in packet: '%s'\n", (int)(total_length), m_bytes.c_str()); + } + } + m_bytes.erase(0, total_length); + packet.SetFilePos(0); + return success; } else { - assert (1 <= m_bytes.size()); - ProcessGDBRemoteLog::LogIf (GDBR_LOG_COMM, "GDBRemoteCommunication::%s tossing junk byte at %c",__FUNCTION__, m_bytes[0]); + if (log) + log->Printf ("GDBRemoteCommunication::%s tossing junk byte at %c",__FUNCTION__, m_bytes[0]); m_bytes.erase(0, 1); } } + packet.Clear(); + return false; } Error Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Thu Jun 16 20:22:15 2011 @@ -56,14 +56,8 @@ // Wait for a packet within 'nsec' seconds size_t - WaitForPacket (StringExtractorGDBRemote &response, - uint32_t sec); - - // Wait for a packet with an absolute timeout time. If 'timeout' is NULL - // wait indefinitely. - size_t - WaitForPacket (StringExtractorGDBRemote &response, - const lldb_private::TimeValue* timeout); + WaitForPacketWithTimeoutMicroSeconds (StringExtractorGDBRemote &response, + uint32_t usec); char GetAck (); @@ -81,12 +75,10 @@ bool GetSequenceMutex(lldb_private::Mutex::Locker& locker); - //------------------------------------------------------------------ - // Communication overrides - //------------------------------------------------------------------ - virtual void - AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast, lldb::ConnectionStatus status); - + bool + CheckForPacket (const uint8_t *src, + size_t src_len, + StringExtractorGDBRemote &packet); bool IsRunning() const { @@ -121,6 +113,11 @@ return old_packet_timeout; } + uint32_t + GetPacketTimeoutInMicroSeconds () const + { + return m_packet_timeout * USEC_PER_SEC; + } //------------------------------------------------------------------ // Start a debugserver instance on the current host using the // supplied connection URL. @@ -130,6 +127,7 @@ const char *unix_socket_name, lldb_private::ProcessLaunchInfo &launch_info); + protected: typedef std::list packet_collection; @@ -138,8 +136,8 @@ size_t payload_length); size_t - WaitForPacketNoLock (StringExtractorGDBRemote &response, - const lldb_private::TimeValue* timeout_ptr); + WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtractorGDBRemote &response, + uint32_t timeout_usec); bool WaitForNotRunningPrivate (const lldb_private::TimeValue *timeout_ptr); @@ -148,7 +146,6 @@ // Classes that inherit from GDBRemoteCommunication can see and modify these //------------------------------------------------------------------ uint32_t m_packet_timeout; - lldb_private::Listener m_rx_packet_listener; lldb_private::Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time lldb_private::Predicate m_public_is_running; lldb_private::Predicate m_private_is_running; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Thu Jun 16 20:22:15 2011 @@ -68,9 +68,6 @@ m_os_version_minor (UINT32_MAX), m_os_version_update (UINT32_MAX) { - m_rx_packet_listener.StartListeningForEvents(this, - Communication::eBroadcastBitPacketAvailable | - Communication::eBroadcastBitReadThreadDidExit); } //---------------------------------------------------------------------- @@ -78,14 +75,8 @@ //---------------------------------------------------------------------- GDBRemoteCommunicationClient::~GDBRemoteCommunicationClient() { - m_rx_packet_listener.StopListeningForEvents(this, - Communication::eBroadcastBitPacketAvailable | - Communication::eBroadcastBitReadThreadDidExit); if (IsConnected()) - { - StopReadThread(); Disconnect(); - } } bool @@ -94,7 +85,7 @@ // Start the read thread after we send the handshake ack since if we // fail to send the handshake ack, there is no reason to continue... if (SendAck()) - return StartReadThread (error_ptr); + return true; if (error_ptr) error_ptr->SetErrorString("failed to send the handshake ack"); @@ -245,15 +236,12 @@ ) { Mutex::Locker locker; - TimeValue timeout_time; - timeout_time = TimeValue::Now(); - timeout_time.OffsetWithSeconds (m_packet_timeout); LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); if (GetSequenceMutex (locker)) { if (SendPacketNoLock (payload, payload_length)) - return WaitForPacketNoLock (response, &timeout_time); + return WaitForPacketWithTimeoutMicroSecondsNoLock (response, GetPacketTimeoutInMicroSeconds ()); } else { @@ -272,6 +260,10 @@ { if (sent_interrupt) { + TimeValue timeout_time; + timeout_time = TimeValue::Now(); + timeout_time.OffsetWithSeconds (m_packet_timeout); + if (log) log->Printf ("async: sent interrupt"); if (m_async_packet_predicate.WaitForValueEqualTo (false, &timeout_time, &timed_out)) @@ -380,7 +372,7 @@ if (log) log->Printf ("GDBRemoteCommunicationClient::%s () WaitForPacket(%.*s)", __FUNCTION__); - if (WaitForPacket (response, (TimeValue*)NULL)) + if (WaitForPacketWithTimeoutMicroSeconds (response, UINT32_MAX)) { if (response.Empty()) state = eStateInvalid; @@ -1662,13 +1654,9 @@ sequence_mutex_unavailable = false; StringExtractorGDBRemote response; - TimeValue timeout_time; - timeout_time = TimeValue::Now(); - timeout_time.OffsetWithSeconds (m_packet_timeout*2); // We will always send at least two packets here... - - for (SendPacketNoLock ("qfThreadInfo", strlen("qfThreadInfo")) && WaitForPacketNoLock (response, &timeout_time); + for (SendPacketNoLock ("qfThreadInfo", strlen("qfThreadInfo")) && WaitForPacketWithTimeoutMicroSecondsNoLock (response, GetPacketTimeoutInMicroSeconds ()); response.IsNormalResponse(); - SendPacketNoLock ("qsThreadInfo", strlen("qsThreadInfo")) && WaitForPacketNoLock (response, &timeout_time)) + SendPacketNoLock ("qsThreadInfo", strlen("qsThreadInfo")) && WaitForPacketWithTimeoutMicroSecondsNoLock (response, GetPacketTimeoutInMicroSeconds ())) { char ch = response.GetChar(); if (ch == 'l') Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Thu Jun 16 20:22:15 2011 @@ -78,13 +78,13 @@ //} // bool -GDBRemoteCommunicationServer::GetPacketAndSendResponse (const TimeValue* timeout_ptr, +GDBRemoteCommunicationServer::GetPacketAndSendResponse (uint32_t timeout_usec, Error &error, bool &interrupt, bool &quit) { StringExtractorGDBRemote packet; - if (WaitForPacketNoLock (packet, timeout_ptr)) + if (WaitForPacketWithTimeoutMicroSeconds(packet, timeout_usec)) { const StringExtractorGDBRemote::ServerPacketType packet_type = packet.GetServerPacketType (); switch (packet_type) @@ -199,9 +199,7 @@ bool GDBRemoteCommunicationServer::HandshakeWithClient(Error *error_ptr) { - if (StartReadThread(error_ptr)) - return GetAck(); - return false; + return GetAck(); } bool @@ -517,7 +515,7 @@ char pid_str[256]; ::memset (pid_str, 0, sizeof(pid_str)); ConnectionStatus status; - const size_t pid_str_len = file_conn.Read (pid_str, sizeof(pid_str), status, NULL); + const size_t pid_str_len = file_conn.Read (pid_str, sizeof(pid_str), NULL, status, NULL); if (pid_str_len > 0) { int pid = atoi (pid_str); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h Thu Jun 16 20:22:15 2011 @@ -37,7 +37,7 @@ ~GDBRemoteCommunicationServer(); bool - GetPacketAndSendResponse (const lldb_private::TimeValue* timeout_ptr, + GetPacketAndSendResponse (uint32_t timeout_usec, lldb_private::Error &error, bool &interrupt, bool &quit); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Jun 16 20:22:15 2011 @@ -2273,10 +2273,16 @@ { // We found a type pointer, now find the shared pointer form our type list TypeSP type_sp (GetTypeList()->FindType(matching_type->GetID())); - assert (type_sp.get() != NULL); - types.InsertUnique (type_sp); - if (types.GetSize() >= max_matches) - break; + if (type_sp) + { + types.InsertUnique (type_sp); + if (types.GetSize() >= max_matches) + break; + } + else + { + fprintf (stderr, "error: can't find shared pointer for type 0x%8.8x.\n", matching_type->GetID()); + } } } return types.GetSize() - initial_types_size; @@ -4170,7 +4176,6 @@ if (orig_die == NULL) return 0; - size_t vars_added = 0; const DWARFDebugInfoEntry *die = orig_die; const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(orig_die); dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; @@ -4189,8 +4194,12 @@ } else { - assert(!"Parent DIE was a compile unit, yet we don't have a valid compile unit in the symbol context..."); - vars_added = 0; + fprintf (stderr, + "error: parent 0x%8.8x %s with no valid compile unit in symbol context for 0x%8.8x %s.\n", + sc_parent_die->GetOffset(), + DW_TAG_value_to_name (parent_tag), + orig_die->GetOffset(), + DW_TAG_value_to_name (orig_die->Tag())); } break; @@ -4202,71 +4211,91 @@ // Check to see if we already have parsed the variables for the given scope Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); - assert (block != NULL); - variables = block->GetVariableList(false, false); - if (variables.get() == NULL) + if (block != NULL) { - variables.reset(new VariableList()); - block->SetVariableList(variables); + variables = block->GetVariableList(false, false); + if (variables.get() == NULL) + { + variables.reset(new VariableList()); + block->SetVariableList(variables); + } + } + else + { + fprintf (stderr, + "error: NULL block for 0x%8.8x %s for variable at 0x%8.8x %s\n", + sc_parent_die->GetOffset(), + DW_TAG_value_to_name (parent_tag), + orig_die->GetOffset(), + DW_TAG_value_to_name (orig_die->Tag())); } } else { - assert(!"Parent DIE was a function or block, yet we don't have a function in the symbol context..."); - vars_added = 0; + fprintf (stderr, + "error: parent 0x%8.8x %s with no valid function in symbol context for 0x%8.8x %s.\n", + sc_parent_die->GetOffset(), + DW_TAG_value_to_name (parent_tag), + orig_die->GetOffset(), + DW_TAG_value_to_name (orig_die->Tag())); } break; default: - assert(!"Didn't find appropriate parent DIE for variable list..."); + fprintf (stderr, + "error: didn't find appropriate parent DIE for variable list for 0x%8.8x %s.\n", + orig_die->GetOffset(), + DW_TAG_value_to_name (orig_die->Tag())); break; } // We need to have a variable list at this point that we can add variables to - assert(variables.get()); - - while (die != NULL) + if (variables.get()) { - dw_tag_t tag = die->Tag(); - - // Check to see if we have already parsed this variable or constant? - if (m_die_to_variable_sp[die]) - { - if (cc_variable_list) - cc_variable_list->AddVariableIfUnique (m_die_to_variable_sp[die]); - } - else + size_t vars_added = 0; + while (die != NULL) { - // We haven't already parsed it, lets do that now. - if ((tag == DW_TAG_variable) || - (tag == DW_TAG_constant) || - (tag == DW_TAG_formal_parameter && sc.function)) + dw_tag_t tag = die->Tag(); + + // Check to see if we have already parsed this variable or constant? + if (m_die_to_variable_sp[die]) + { + if (cc_variable_list) + cc_variable_list->AddVariableIfUnique (m_die_to_variable_sp[die]); + } + else { - VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, func_low_pc)); - if (var_sp) + // We haven't already parsed it, lets do that now. + if ((tag == DW_TAG_variable) || + (tag == DW_TAG_constant) || + (tag == DW_TAG_formal_parameter && sc.function)) { - variables->AddVariableIfUnique (var_sp); - if (cc_variable_list) - cc_variable_list->AddVariableIfUnique (var_sp); - ++vars_added; + VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, func_low_pc)); + if (var_sp) + { + variables->AddVariableIfUnique (var_sp); + if (cc_variable_list) + cc_variable_list->AddVariableIfUnique (var_sp); + ++vars_added; + } } } - } - bool skip_children = (sc.function == NULL && tag == DW_TAG_subprogram); + bool skip_children = (sc.function == NULL && tag == DW_TAG_subprogram); - if (!skip_children && parse_children && die->HasChildren()) - { - vars_added += ParseVariables(sc, dwarf_cu, func_low_pc, die->GetFirstChild(), true, true, cc_variable_list); - } + if (!skip_children && parse_children && die->HasChildren()) + { + vars_added += ParseVariables(sc, dwarf_cu, func_low_pc, die->GetFirstChild(), true, true, cc_variable_list); + } - if (parse_siblings) - die = die->GetSibling(); - else - die = NULL; + if (parse_siblings) + die = die->GetSibling(); + else + die = NULL; + } + return vars_added; } - - return vars_added; + return 0; } //------------------------------------------------------------------ Modified: lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp (original) +++ lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp Thu Jun 16 20:22:15 2011 @@ -300,7 +300,7 @@ } while (m_cfi_data.ValidOffsetForDataOfSize (offset, 8)) { - dw_offset_t current_entry = offset; + const dw_offset_t current_entry = offset; uint32_t len = m_cfi_data.GetU32 (&offset); dw_offset_t next_entry = current_entry + len + 4; dw_offset_t cie_id = m_cfi_data.GetU32 (&offset); @@ -312,20 +312,29 @@ continue; } - const CIE *cie = GetCIE (current_entry + 4 - cie_id); - assert (cie != NULL); - - const lldb::addr_t pc_rel_addr = m_section->GetFileAddress(); - const lldb::addr_t text_addr = LLDB_INVALID_ADDRESS; - const lldb::addr_t data_addr = LLDB_INVALID_ADDRESS; - - lldb::addr_t addr = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding, pc_rel_addr, text_addr, data_addr); - lldb::addr_t length = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding & DW_EH_PE_MASK_ENCODING, pc_rel_addr, text_addr, data_addr); - FDEEntry fde; - fde.bounds = AddressRange (addr, length, m_objfile.GetSectionList()); - fde.offset = current_entry; - m_fde_index.push_back(fde); - + const dw_offset_t cie_offset = current_entry + 4 - cie_id; + const CIE *cie = GetCIE (cie_offset); + if (cie) + { + const lldb::addr_t pc_rel_addr = m_section->GetFileAddress(); + const lldb::addr_t text_addr = LLDB_INVALID_ADDRESS; + const lldb::addr_t data_addr = LLDB_INVALID_ADDRESS; + + lldb::addr_t addr = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding, pc_rel_addr, text_addr, data_addr); + lldb::addr_t length = m_cfi_data.GetGNUEHPointer(&offset, cie->ptr_encoding & DW_EH_PE_MASK_ENCODING, pc_rel_addr, text_addr, data_addr); + FDEEntry fde; + fde.bounds = AddressRange (addr, length, m_objfile.GetSectionList()); + fde.offset = current_entry; + m_fde_index.push_back(fde); + } + else + { + fprintf (stderr, + "error: unable to find CIE at 0x%8.8x for cie_id = 0x%8.8x for entry at 0x%8.8x.\n", + cie_offset, + cie_id, + current_entry); + } offset = next_entry; } std::sort (m_fde_index.begin(), m_fde_index.end()); Modified: lldb/trunk/tools/lldb-platform/lldb-platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-platform/lldb-platform.cpp?rev=133224&r1=133223&r2=133224&view=diff ============================================================================== --- lldb/trunk/tools/lldb-platform/lldb-platform.cpp (original) +++ lldb/trunk/tools/lldb-platform/lldb-platform.cpp Thu Jun 16 20:22:15 2011 @@ -72,7 +72,7 @@ StreamSP log_stream_sp; Args log_args; Error error; - std::string listen_host_post; + std::string listen_host_port; char ch; Debugger::Initialize(); @@ -163,7 +163,7 @@ break; case 'L': - listen_host_post.append (optarg); + listen_host_port.append (optarg); break; } } @@ -181,15 +181,15 @@ GDBRemoteCommunicationServer gdb_server (true); - if (!listen_host_post.empty()) + if (!listen_host_port.empty()) { std::auto_ptr conn_ap(new ConnectionFileDescriptor()); if (conn_ap.get()) { std::string connect_url ("listen://"); - connect_url.append(listen_host_post.c_str()); + connect_url.append(listen_host_port.c_str()); - printf ("Listening for a connection on %s...\n", listen_host_post.c_str()); + printf ("Listening for a connection on %s...\n", listen_host_port.c_str()); if (conn_ap->Connect(connect_url.c_str(), &error) == eConnectionStatusSuccess) { printf ("Connection established.\n"); @@ -208,7 +208,7 @@ bool done = false; while (!interrupt && !done) { - if (!gdb_server.GetPacketAndSendResponse(NULL, error, interrupt, done)) + if (!gdb_server.GetPacketAndSendResponse (UINT32_MAX, error, interrupt, done)) break; } } From johnny.chen at apple.com Thu Jun 16 22:22:59 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Jun 2011 03:22:59 -0000 Subject: [Lldb-commits] [lldb] r133230 - /lldb/trunk/test/hello_world/TestHelloWorld.py Message-ID: <20110617032259.212832A6C12C@llvm.org> Author: johnny Date: Thu Jun 16 22:22:58 2011 New Revision: 133230 URL: http://llvm.org/viewvc/llvm-project?rev=133230&view=rev Log: Modify docstring. Modified: lldb/trunk/test/hello_world/TestHelloWorld.py Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=133230&r1=133229&r2=133230&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Thu Jun 16 22:22:58 2011 @@ -29,7 +29,7 @@ @python_api_test def test_with_dwarf_and_attach_to_process_with_id_api(self): - """Create target, breakpoint, start a process, and attach to it. + """Create target, breakpoint, spawn a process, and attach to it. Use dwarf map (no dsym) and attach to process with id API. """ @@ -91,7 +91,7 @@ self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) def hello_world_attach_api(self): - """Create target, breakpoint, start a process, and attach to it.""" + """Create target, breakpoint, spawn a process, and attach to it.""" exe = os.path.join(os.getcwd(), "a.out") From gclayton at apple.com Thu Jun 16 22:31:01 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Jun 2011 03:31:01 -0000 Subject: [Lldb-commits] [lldb] r133231 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/Interpreter/OptionGroupPlatform.h include/lldb/Target/Platform.h lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist source/API/SBDebugger.cpp source/Interpreter/OptionGroupPlatform.cpp source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp source/Target/Platform.cpp Message-ID: <20110617033102.0E5272A6C12C@llvm.org> Author: gclayton Date: Thu Jun 16 22:31:01 2011 New Revision: 133231 URL: http://llvm.org/viewvc/llvm-project?rev=133231&view=rev Log: Added the notion of an system root for SDKs. This is a directory where all libraries and headers exist. This can be specified using the platform select function: platform select --sysroot /Volumes/remote-root remote-macosx Each platform subclass is free to interpret the sysroot as needed. Expose the new SDK root directory through the SBDebugger class. Fixed an issue with the GDB remote protocol where unimplemented packets were not being handled correctly. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/Interpreter/OptionGroupPlatform.h lldb/trunk/include/lldb/Target/Platform.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Target/Platform.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=133231&r1=133230&r2=133231&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Thu Jun 16 22:31:01 2011 @@ -126,6 +126,9 @@ lldb::SBError SetCurrentPlatform (const char *platform_name); + bool + SetCurrentPlatformSDKRoot (const char *sysroot); + // FIXME: Once we get the set show stuff in place, the driver won't need // an interface to the Set/Get UseExternalEditor. bool Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupPlatform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupPlatform.h?rev=133231&r1=133230&r2=133231&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionGroupPlatform.h (original) +++ lldb/trunk/include/lldb/Interpreter/OptionGroupPlatform.h Thu Jun 16 22:31:01 2011 @@ -14,6 +14,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/ConstString.h" #include "lldb/Interpreter/Options.h" namespace lldb_private { @@ -30,6 +31,7 @@ OptionGroupPlatform (bool include_platform_option) : OptionGroup(), m_platform_name (), + m_sdk_sysroot (), m_os_version_major (UINT32_MAX), m_os_version_minor (UINT32_MAX), m_os_version_update (UINT32_MAX), @@ -75,9 +77,36 @@ else m_platform_name.clear(); } + + const ConstString & + GetSDKRootDirectory () const + { + return m_sdk_sysroot; + } + + void + SetSDKRootDirectory (const ConstString &sdk_root_directory) + { + m_sdk_sysroot = sdk_root_directory; + } + + const ConstString & + GetSDKBuild () const + { + return m_sdk_build; + } + + void + SetSDKBuild (const ConstString &sdk_build) + { + m_sdk_build = sdk_build; + } + protected: std::string m_platform_name; + ConstString m_sdk_sysroot; + ConstString m_sdk_build; uint32_t m_os_version_major; uint32_t m_os_version_minor; uint32_t m_os_version_update; Modified: lldb/trunk/include/lldb/Target/Platform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=133231&r1=133230&r2=133231&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Platform.h (original) +++ lldb/trunk/include/lldb/Target/Platform.h Thu Jun 16 22:31:01 2011 @@ -383,6 +383,32 @@ { return m_max_gid_name_len; } + + const ConstString & + GetSDKRootDirectory () const + { + return m_sdk_sysroot; + } + + void + SetSDKRootDirectory (const ConstString &dir) + { + m_sdk_sysroot = dir; + } + + const ConstString & + GetSDKBuild () const + { + return m_sdk_build; + } + + void + SetSDKBuild (const ConstString &sdk_build) + { + m_sdk_build = sdk_build; + } + + protected: bool m_is_host; // Set to true when we are able to actually set the OS version while @@ -392,6 +418,8 @@ // will be set to the once we call Host::GetOSVersion(). bool m_os_version_set_while_connected; bool m_system_arch_set_while_connected; + ConstString m_sdk_sysroot; // the root location of where the SDK files are all located + ConstString m_sdk_build; std::string m_remote_url; std::string m_name; uint32_t m_major_os_version; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=133231&r1=133230&r2=133231&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jun 16 22:31:01 2011 @@ -3394,10 +3394,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 62; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 60; + DYLIB_CURRENT_VERSION = 62; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3446,11 +3446,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 62; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 60; + DYLIB_CURRENT_VERSION = 62; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3497,8 +3497,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 60; - DYLIB_CURRENT_VERSION = 60; + CURRENT_PROJECT_VERSION = 62; + DYLIB_CURRENT_VERSION = 62; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3536,9 +3536,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 62; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 60; + DYLIB_CURRENT_VERSION = 62; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3576,9 +3576,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 62; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 60; + DYLIB_CURRENT_VERSION = 62; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3646,7 +3646,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 62; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3677,11 +3677,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 62; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 60; + DYLIB_CURRENT_VERSION = 62; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3806,7 +3806,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 62; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3838,7 +3838,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 62; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=133231&r1=133230&r2=133231&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Thu Jun 16 22:31:01 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 60 + 62 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=133231&r1=133230&r2=133231&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Thu Jun 16 22:31:01 2011 @@ -880,6 +880,22 @@ } bool +SBDebugger::SetCurrentPlatformSDKRoot (const char *sysroot) +{ + if (m_opaque_sp) + { + PlatformSP platform_sp (m_opaque_sp->GetPlatformList().GetSelectedPlatform()); + + if (platform_sp) + { + platform_sp->SetSDKRootDirectory (ConstString (sysroot)); + return true; + } + } + return false; +} + +bool SBDebugger::GetCloseInputOnEOF () const { if (m_opaque_sp) Modified: lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp?rev=133231&r1=133230&r2=133231&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp Thu Jun 16 22:31:01 2011 @@ -36,6 +36,12 @@ m_os_version_minor, m_os_version_update); } + + if (m_sdk_sysroot) + platform_sp->SetSDKRootDirectory (m_sdk_sysroot); + + if (m_sdk_build) + platform_sp->SetSDKBuild (m_sdk_build); } } return platform_sp; @@ -45,6 +51,8 @@ OptionGroupPlatform::OptionParsingStarting (CommandInterpreter &interpreter) { m_platform_name.clear(); + m_sdk_sysroot.Clear(); + m_sdk_build.Clear(); m_os_version_major = UINT32_MAX; m_os_version_minor = UINT32_MAX; m_os_version_update = UINT32_MAX; @@ -53,8 +61,10 @@ static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "platform" , 'p', required_argument, NULL, 0, eArgTypePlatform, "Specify name of the platform to use for this target, creating the platform if necessary."}, - { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." } + { LLDB_OPT_SET_ALL, false, "platform", 'p', required_argument, NULL, 0, eArgTypePlatform, "Specify name of the platform to use for this target, creating the platform if necessary."}, + { LLDB_OPT_SET_ALL, false, "version" , 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." }, + { LLDB_OPT_SET_ALL, false, "build" , 'b', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK build number." }, + { LLDB_OPT_SET_ALL, false, "sysroot" , 's', required_argument, NULL, 0, eArgTypeFilename, "Specify the SDK root directory that contains a root of all remote system files." } }; static const uint32_t k_option_table_size = sizeof(g_option_table)/sizeof (OptionDefinition); @@ -101,6 +111,14 @@ error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg); break; + case 'b': + m_sdk_build.SetCString (option_arg); + break; + + case 's': + m_sdk_sysroot.SetCString (option_arg); + break; + default: error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); break; Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp?rev=133231&r1=133230&r2=133231&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp Thu Jun 16 22:31:01 2011 @@ -270,6 +270,9 @@ const char * PlatformRemoteiOS::GetDeviceSupportDirectoryForOSVersion() { + if (m_sdk_sysroot) + return m_sdk_sysroot.GetCString(); + if (m_device_support_directory_for_os_version.empty()) { const char *device_support_dir = GetDeviceSupportDirectory(); @@ -376,6 +379,16 @@ { ::snprintf (resolved_path, sizeof(resolved_path), + "%s/%s", + os_version_dir, + platform_file_path); + + local_file.SetFile(resolved_path, true); + if (local_file.Exists()) + return error; + + ::snprintf (resolved_path, + sizeof(resolved_path), "%s/Symbols.Internal/%s", os_version_dir, platform_file_path); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=133231&r1=133230&r2=133231&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Thu Jun 16 22:31:01 2011 @@ -38,7 +38,7 @@ const char *listener_name, bool is_platform) : Communication(comm_name), - m_packet_timeout (60), + m_packet_timeout (1), m_sequence_mutex (Mutex::eMutexTypeRecursive), m_public_is_running (false), m_private_is_running (false), @@ -246,6 +246,7 @@ size_t content_length = 0; size_t total_length = 0; size_t checksum_idx = std::string::npos; + LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); switch (m_bytes[0]) { @@ -281,16 +282,20 @@ break; default: + { + if (log) + log->Printf ("GDBRemoteCommunication::%s tossing junk byte at %c",__FUNCTION__, m_bytes[0]); + m_bytes.erase(0, 1); + } break; } - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); if (content_length == std::string::npos) { packet.Clear(); return false; } - else if (content_length > 0) + else if (total_length > 0) { // We have a valid packet... @@ -345,12 +350,6 @@ packet.SetFilePos(0); return success; } - else - { - if (log) - log->Printf ("GDBRemoteCommunication::%s tossing junk byte at %c",__FUNCTION__, m_bytes[0]); - m_bytes.erase(0, 1); - } } packet.Clear(); return false; Modified: lldb/trunk/source/Target/Platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=133231&r1=133230&r2=133231&view=diff ============================================================================== --- lldb/trunk/source/Target/Platform.cpp (original) +++ lldb/trunk/source/Target/Platform.cpp Thu Jun 16 22:31:01 2011 @@ -161,6 +161,8 @@ m_is_host (is_host), m_os_version_set_while_connected (false), m_system_arch_set_while_connected (false), + m_sdk_sysroot (), + m_sdk_build (), m_remote_url (), m_name (), m_major_os_version (UINT32_MAX), From johnny.chen at apple.com Fri Jun 17 13:47:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Jun 2011 18:47:58 -0000 Subject: [Lldb-commits] [lldb] r133277 - in /lldb/trunk/test/hello_world: Makefile TestHelloWorld.py Message-ID: <20110617184758.C1DA62A6C12C@llvm.org> Author: johnny Date: Fri Jun 17 13:47:58 2011 New Revision: 133277 URL: http://llvm.org/viewvc/llvm-project?rev=133277&view=rev Log: Localize the finding of our to-be-debugged executable in one spot during the setUp() phase. Change the executable name to be "hello_world". Modified: lldb/trunk/test/hello_world/Makefile lldb/trunk/test/hello_world/TestHelloWorld.py Modified: lldb/trunk/test/hello_world/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/Makefile?rev=133277&r1=133276&r2=133277&view=diff ============================================================================== --- lldb/trunk/test/hello_world/Makefile (original) +++ lldb/trunk/test/hello_world/Makefile Fri Jun 17 13:47:58 2011 @@ -1,5 +1,6 @@ LEVEL = ../make C_SOURCES := main.c +EXE := hello_world include $(LEVEL)/Makefile.rules Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=133277&r1=133276&r2=133277&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Fri Jun 17 13:47:58 2011 @@ -39,6 +39,8 @@ def setUp(self): # Call super's setUp(). TestBase.setUp(self) + # Get the full path to our executable to be debugged. + self.exe = os.path.join(os.getcwd(), "hello_world") # Find a couple of the line numbers within main.c. self.line1 = line_number('main.c', '// Set break point at this line.') self.line2 = line_number('main.c', '// Waiting to be attached...') @@ -46,9 +48,7 @@ def hello_world_python(self, useLaunchAPI): """Create target, breakpoint, launch a process, and then kill it.""" - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) + target = self.dbg.CreateTarget(self.exe) breakpoint = target.BreakpointCreateByLocation("main.c", self.line1) @@ -93,13 +93,11 @@ def hello_world_attach_api(self): """Create target, breakpoint, spawn a process, and attach to it.""" - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) + target = self.dbg.CreateTarget(self.exe) # Spawn a new process. import subprocess - popen = subprocess.Popen([exe, "abc", "xyz"]) + popen = subprocess.Popen([self.exe, "abc", "xyz"]) #print "pid of spawned process: %d" % popen.pid listener = lldb.SBListener("my.attach.listener") From johnny.chen at apple.com Fri Jun 17 14:21:30 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Jun 2011 19:21:30 -0000 Subject: [Lldb-commits] [lldb] r133279 - in /lldb/trunk: source/API/SBTarget.cpp test/hello_world/TestHelloWorld.py Message-ID: <20110617192130.431302A6C12C@llvm.org> Author: johnny Date: Fri Jun 17 14:21:30 2011 New Revision: 133279 URL: http://llvm.org/viewvc/llvm-project?rev=133279&view=rev Log: Add a bunch of test cases to TestHelloWorld.py to exercise combinations of dwarf/dsym debug setup. Among them are test cases to exercise SBTarget.AttachToProcessWithName(); we attach to "hello_world", and verify that, after attachment, the currently selected target indeed matches "hello_world". Modified: lldb/trunk/source/API/SBTarget.cpp lldb/trunk/test/hello_world/TestHelloWorld.py Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=133279&r1=133278&r2=133279&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Fri Jun 17 14:21:30 2011 @@ -330,6 +330,10 @@ if (sb_process.IsValid()) { error.SetError (sb_process->Attach (name, wait_for)); + // If we are doing synchronous mode, then wait for the + // process to stop! + if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false) + sb_process->WaitForProcessToStop (NULL); } else { Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=133279&r1=133278&r2=133279&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Fri Jun 17 14:21:30 2011 @@ -1,4 +1,4 @@ -"""Test Python APIs for target, breakpoint, and process.""" +"""Test Python APIs for target (launch and attach), breakpoint, and process.""" import os, sys, time import unittest2 @@ -18,23 +18,70 @@ self.buildDsym() self.hello_world_python(useLaunchAPI = False) + def test_with_dwarf_and_run_command(self): + """Create target, breakpoint, launch a process, and then kill it. + + Use dwarf debug map and lldb "run" command. + """ + self.buildDwarf() + self.hello_world_python(useLaunchAPI = False) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_with_dsym_and_process_launch_api(self): + """Create target, breakpoint, launch a process, and then kill it. + + Use dsym info and process launch API. + """ + self.buildDsym() + self.hello_world_python(useLaunchAPI = True) + @python_api_test def test_with_dwarf_and_process_launch_api(self): """Create target, breakpoint, launch a process, and then kill it. - Use dwarf map (no dsym) and process launch API. + Use dwarf debug map and process launch API. """ self.buildDwarf() self.hello_world_python(useLaunchAPI = True) + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_with_dsym_and_attach_to_process_with_id_api(self): + """Create target, breakpoint, spawn a process, and attach to it with process id. + + Use dsym info and attach to process with id API. + """ + self.buildDsym() + self.hello_world_attach_with_id_api() + @python_api_test def test_with_dwarf_and_attach_to_process_with_id_api(self): - """Create target, breakpoint, spawn a process, and attach to it. + """Create target, breakpoint, spawn a process, and attach to it with process id. Use dwarf map (no dsym) and attach to process with id API. """ self.buildDwarf() - self.hello_world_attach_api() + self.hello_world_attach_with_id_api() + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_with_dsym_and_attach_to_process_with_name_api(self): + """Create target, breakpoint, spawn a process, and attach to it with process name. + + Use dsym info and attach to process with name API. + """ + self.buildDsym() + self.hello_world_attach_with_name_api() + + @python_api_test + def test_with_dwarf_and_attach_to_process_with_name_api(self): + """Create target, breakpoint, spawn a process, and attach to it with process name. + + Use dwarf map (no dsym) and attach to process with name API. + """ + self.buildDwarf() + self.hello_world_attach_with_name_api() def setUp(self): # Call super's setUp(). @@ -90,8 +137,8 @@ # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) - def hello_world_attach_api(self): - """Create target, breakpoint, spawn a process, and attach to it.""" + def hello_world_attach_with_id_api(self): + """Create target, breakpoint, spawn a process, and attach to it by id.""" target = self.dbg.CreateTarget(self.exe) @@ -113,6 +160,35 @@ substrs = ['main.c:%d' % self.line2, '(int)argc=3']) + def hello_world_attach_with_name_api(self): + """Create target, breakpoint, spawn a process, and attach to it by name.""" + + target = self.dbg.CreateTarget(self.exe) + + # Spawn a new process. + import subprocess + popen = subprocess.Popen([self.exe, "abc", "xyz"]) + #print "pid of spawned process: %d" % popen.pid + + listener = lldb.SBListener("my.attach.listener") + error = lldb.SBError() + # Pass 'False' since we don't want to wait for new instance of "hello_world" to be launched. + name = os.path.basename(self.exe) + process = target.AttachToProcessWithName(listener, name, False, error) + + self.assertTrue(process, PROCESS_IS_VALID) + + # Verify that after attach, our selected target indeed matches name. + self.expect(self.dbg.GetSelectedTarget().GetExecutable().GetFilename(), exe=False, + startstr = name) + + # Let's check the stack traces of the attached process. + import lldbutil + stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) + self.expect(stacktraces, exe=False, + substrs = ['main.c:%d' % self.line2, + '(int)argc=3']) + if __name__ == '__main__': import atexit From johnny.chen at apple.com Fri Jun 17 14:38:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Jun 2011 19:38:48 -0000 Subject: [Lldb-commits] [lldb] r133280 - /lldb/trunk/test/hello_world/TestHelloWorld.py Message-ID: <20110617193848.B1E8F2A6C12C@llvm.org> Author: johnny Date: Fri Jun 17 14:38:48 2011 New Revision: 133280 URL: http://llvm.org/viewvc/llvm-project?rev=133280&view=rev Log: Modify a bunch of docstrings to be more correct. Check the SBError.Success() after attaching. Also eat the stdout of the spawned "hello_world" process if not in TraceOn() mode. Modified: lldb/trunk/test/hello_world/TestHelloWorld.py Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=133280&r1=133279&r2=133280&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Fri Jun 17 14:38:48 2011 @@ -48,7 +48,7 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @python_api_test def test_with_dsym_and_attach_to_process_with_id_api(self): - """Create target, breakpoint, spawn a process, and attach to it with process id. + """Create target, spawn a process, and attach to it with process id. Use dsym info and attach to process with id API. """ @@ -57,7 +57,7 @@ @python_api_test def test_with_dwarf_and_attach_to_process_with_id_api(self): - """Create target, breakpoint, spawn a process, and attach to it with process id. + """Create target, spawn a process, and attach to it with process id. Use dwarf map (no dsym) and attach to process with id API. """ @@ -67,7 +67,7 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @python_api_test def test_with_dsym_and_attach_to_process_with_name_api(self): - """Create target, breakpoint, spawn a process, and attach to it with process name. + """Create target, spawn a process, and attach to it with process name. Use dsym info and attach to process with name API. """ @@ -76,7 +76,7 @@ @python_api_test def test_with_dwarf_and_attach_to_process_with_name_api(self): - """Create target, breakpoint, spawn a process, and attach to it with process name. + """Create target, spawn a process, and attach to it with process name. Use dwarf map (no dsym) and attach to process with name API. """ @@ -138,20 +138,21 @@ self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) def hello_world_attach_with_id_api(self): - """Create target, breakpoint, spawn a process, and attach to it by id.""" + """Create target, spawn a process, and attach to it by id.""" target = self.dbg.CreateTarget(self.exe) - # Spawn a new process. + # Spawn a new process and don't display the stdout if not in TraceOn() mode. import subprocess - popen = subprocess.Popen([self.exe, "abc", "xyz"]) + popen = subprocess.Popen([self.exe, "abc", "xyz"], + stdout = open(os.devnull, 'w') if not self.TraceOn() else None) #print "pid of spawned process: %d" % popen.pid listener = lldb.SBListener("my.attach.listener") error = lldb.SBError() process = target.AttachToProcessWithID(listener, popen.pid, error) - self.assertTrue(process, PROCESS_IS_VALID) + self.assertTrue(error.Success() and process, PROCESS_IS_VALID) # Let's check the stack traces of the attached process. import lldbutil @@ -161,13 +162,14 @@ '(int)argc=3']) def hello_world_attach_with_name_api(self): - """Create target, breakpoint, spawn a process, and attach to it by name.""" + """Create target, spawn a process, and attach to it by name.""" target = self.dbg.CreateTarget(self.exe) - # Spawn a new process. + # Spawn a new process and don't display the stdout if not in TraceOn() mode. import subprocess - popen = subprocess.Popen([self.exe, "abc", "xyz"]) + popen = subprocess.Popen([self.exe, "abc", "xyz"], + stdout = open(os.devnull, 'w') if not self.TraceOn() else None) #print "pid of spawned process: %d" % popen.pid listener = lldb.SBListener("my.attach.listener") @@ -176,7 +178,7 @@ name = os.path.basename(self.exe) process = target.AttachToProcessWithName(listener, name, False, error) - self.assertTrue(process, PROCESS_IS_VALID) + self.assertTrue(error.Success() and process, PROCESS_IS_VALID) # Verify that after attach, our selected target indeed matches name. self.expect(self.dbg.GetSelectedTarget().GetExecutable().GetFilename(), exe=False, From johnny.chen at apple.com Fri Jun 17 16:17:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Jun 2011 21:17:56 -0000 Subject: [Lldb-commits] [lldb] r133294 - /lldb/trunk/test/connect_remote/TestConnectRemote.py Message-ID: <20110617211756.91B1E2A6C12C@llvm.org> Author: johnny Date: Fri Jun 17 16:17:56 2011 New Revision: 133294 URL: http://llvm.org/viewvc/llvm-project?rev=133294&view=rev Log: Test case test_connect_remote() has been passing consistently for some times. Let's remove the @expectedFailure marker from it. Modified: lldb/trunk/test/connect_remote/TestConnectRemote.py Modified: lldb/trunk/test/connect_remote/TestConnectRemote.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/connect_remote/TestConnectRemote.py?rev=133294&r1=133293&r2=133294&view=diff ============================================================================== --- lldb/trunk/test/connect_remote/TestConnectRemote.py (original) +++ lldb/trunk/test/connect_remote/TestConnectRemote.py Fri Jun 17 16:17:56 2011 @@ -12,7 +12,6 @@ mydir = "connect_remote" - @unittest2.expectedFailure def test_connect_remote(self): """Test "process connect connect:://localhost:12345".""" From gclayton at apple.com Fri Jun 17 17:10:16 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Jun 2011 22:10:16 -0000 Subject: [Lldb-commits] [lldb] r133302 - in /lldb/trunk: include/lldb/Symbol/Block.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/Block.cpp source/Target/StackFrame.cpp Message-ID: <20110617221017.1600D2A6C12C@llvm.org> Author: gclayton Date: Fri Jun 17 17:10:16 2011 New Revision: 133302 URL: http://llvm.org/viewvc/llvm-project?rev=133302&view=rev Log: Fixed variable parsing to not parse block variables over and over due to an issue in the way block variables are marked as parsed. In the DWARF parser we always parse all blocks for a function at once, so we can mark all blocks as having all variables parsed and avoid recursive function calls to try and reparse things that have already been handled. Fixed an issue with how variables get scoped into blocks. The DWARF parser can now handle abtract class definitions that contain concrete static variables. When the concrete instance of the class functions get instantiated, they will track down the concrete block for the abtract block and add the variable to each block. Modified: lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Target/StackFrame.cpp Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=133302&r1=133301&r2=133302&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Fri Jun 17 17:10:16 2011 @@ -281,10 +281,15 @@ /// for this block. //------------------------------------------------------------------ lldb::VariableListSP - GetVariableList (bool get_child_variables, - bool can_create); + GetBlockVariableList (bool can_create); + uint32_t + AppendBlockVariables (bool can_create, + bool get_child_block_variables, + bool stop_if_child_block_is_inlined_function, + VariableList *variable_list); + //------------------------------------------------------------------ /// Appends the variables from this block, and optionally from all /// parent blocks, to \a variable_list. @@ -431,6 +436,9 @@ bool GetStartAddress (Address &addr); + void + SetDidParseVariables (bool b, bool set_children); + protected: typedef std::vector collection; //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=133302&r1=133301&r2=133302&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Fri Jun 17 17:10:16 2011 @@ -263,6 +263,29 @@ return NULL; // Not found in any compile units } +DWARFDebugInfoEntry* +DWARFDebugInfo::GetDIEPtrWithCompileUnitHint (dw_offset_t die_offset, DWARFCompileUnit**cu_handle) +{ + assert (cu_handle); + DWARFDebugInfoEntry* die = NULL; + if (*cu_handle) + die = (*cu_handle)->GetDIEPtr(die_offset); + + if (die == NULL) + { + DWARFCompileUnitSP cu_sp (GetCompileUnitContainingDIE(die_offset)); + if (cu_sp.get()) + { + *cu_handle = cu_sp.get(); + die = cu_sp->GetDIEPtr(die_offset); + } + } + if (die == NULL) + *cu_handle = NULL; + return die; +} + + const DWARFDebugInfoEntry* DWARFDebugInfo::GetDIEPtrContainingOffset(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h?rev=133302&r1=133301&r2=133302&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h Fri Jun 17 17:10:16 2011 @@ -52,6 +52,8 @@ DWARFCompileUnitSP GetCompileUnitContainingDIE(dw_offset_t die_offset); DWARFDebugInfoEntry* GetDIEPtr(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr); + DWARFDebugInfoEntry* GetDIEPtrWithCompileUnitHint (dw_offset_t die_offset, DWARFCompileUnit**cu_handle); + const DWARFDebugInfoEntry* GetDIEPtrContainingOffset(dw_offset_t die_offset, DWARFCompileUnitSP* cu_sp_ptr); void Dump(lldb_private::Stream *s, const uint32_t die_offset, const uint32_t recurse_depth); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=133302&r1=133301&r2=133302&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Jun 17 17:10:16 2011 @@ -3983,7 +3983,12 @@ dw_addr_t func_lo_pc = function_die->GetAttributeValueAsUnsigned (this, dwarf_cu, DW_AT_low_pc, DW_INVALID_ADDRESS); assert (func_lo_pc != DW_INVALID_ADDRESS); - return ParseVariables(sc, dwarf_cu, func_lo_pc, function_die->GetFirstChild(), true, true); + const size_t num_variables = ParseVariables(sc, dwarf_cu, func_lo_pc, function_die->GetFirstChild(), true, true); + + // Let all blocks know they have parse all their variables + sc.function->GetBlock (false).SetDidParseVariables (true, true); + + return num_variables; } else if (sc.comp_unit) { @@ -4161,6 +4166,74 @@ return var_sp; } + +const DWARFDebugInfoEntry * +SymbolFileDWARF::FindBlockContainingSpecification (dw_offset_t func_die_offset, + dw_offset_t spec_block_die_offset, + DWARFCompileUnit **result_die_cu_handle) +{ + // Give the concrete function die specified by "func_die_offset", find the + // concrete block whose DW_AT_specification or DW_AT_abstract_origin points + // to "spec_block_die_offset" + DWARFDebugInfo* info = DebugInfo(); + + const DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint(func_die_offset, result_die_cu_handle); + if (die) + { + assert (*result_die_cu_handle); + return FindBlockContainingSpecification (*result_die_cu_handle, die, spec_block_die_offset, result_die_cu_handle); + } + return NULL; +} + + +const DWARFDebugInfoEntry * +SymbolFileDWARF::FindBlockContainingSpecification(DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die, + dw_offset_t spec_block_die_offset, + DWARFCompileUnit **result_die_cu_handle) +{ + if (die) + { + switch (die->Tag()) + { + case DW_TAG_subprogram: + case DW_TAG_inlined_subroutine: + case DW_TAG_lexical_block: + { + if (die->GetAttributeValueAsReference (this, dwarf_cu, DW_AT_specification, DW_INVALID_OFFSET) == spec_block_die_offset) + { + *result_die_cu_handle = dwarf_cu; + return die; + } + + if (die->GetAttributeValueAsReference (this, dwarf_cu, DW_AT_abstract_origin, DW_INVALID_OFFSET) == spec_block_die_offset) + { + *result_die_cu_handle = dwarf_cu; + return die; + } + } + break; + } + + // Give the concrete function die specified by "func_die_offset", find the + // concrete block whose DW_AT_specification or DW_AT_abstract_origin points + // to "spec_block_die_offset" + for (const DWARFDebugInfoEntry *child_die = die->GetFirstChild(); child_die != NULL; child_die = child_die->GetSibling()) + { + const DWARFDebugInfoEntry *result_die = FindBlockContainingSpecification (dwarf_cu, + child_die, + spec_block_die_offset, + result_die_cu_handle); + if (result_die) + return result_die; + } + } + + *result_die_cu_handle = NULL; + return NULL; +} + size_t SymbolFileDWARF::ParseVariables ( @@ -4176,126 +4249,125 @@ if (orig_die == NULL) return 0; + VariableListSP variable_list_sp; + + size_t vars_added = 0; const DWARFDebugInfoEntry *die = orig_die; - const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(orig_die); - dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; - VariableListSP variables; - switch (parent_tag) + while (die != NULL) { - case DW_TAG_compile_unit: - if (sc.comp_unit != NULL) + dw_tag_t tag = die->Tag(); + + // Check to see if we have already parsed this variable or constant? + if (m_die_to_variable_sp[die]) { - variables = sc.comp_unit->GetVariableList(false); - if (variables.get() == NULL) - { - variables.reset(new VariableList()); - sc.comp_unit->SetVariableList(variables); - } + if (cc_variable_list) + cc_variable_list->AddVariableIfUnique (m_die_to_variable_sp[die]); } else { - fprintf (stderr, - "error: parent 0x%8.8x %s with no valid compile unit in symbol context for 0x%8.8x %s.\n", - sc_parent_die->GetOffset(), - DW_TAG_value_to_name (parent_tag), - orig_die->GetOffset(), - DW_TAG_value_to_name (orig_die->Tag())); - } - break; - - case DW_TAG_subprogram: - case DW_TAG_inlined_subroutine: - case DW_TAG_lexical_block: - if (sc.function != NULL) - { - // Check to see if we already have parsed the variables for the given scope - - Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); - if (block != NULL) + // We haven't already parsed it, lets do that now. + if ((tag == DW_TAG_variable) || + (tag == DW_TAG_constant) || + (tag == DW_TAG_formal_parameter && sc.function)) { - variables = block->GetVariableList(false, false); - if (variables.get() == NULL) + if (variable_list_sp.get() == NULL) { - variables.reset(new VariableList()); - block->SetVariableList(variables); + const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(orig_die); + dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; + switch (parent_tag) + { + case DW_TAG_compile_unit: + if (sc.comp_unit != NULL) + { + variable_list_sp = sc.comp_unit->GetVariableList(false); + if (variable_list_sp.get() == NULL) + { + variable_list_sp.reset(new VariableList()); + sc.comp_unit->SetVariableList(variable_list_sp); + } + } + else + { + fprintf (stderr, + "error: parent 0x%8.8x %s with no valid compile unit in symbol context for 0x%8.8x %s.\n", + sc_parent_die->GetOffset(), + DW_TAG_value_to_name (parent_tag), + orig_die->GetOffset(), + DW_TAG_value_to_name (orig_die->Tag())); + } + break; + + case DW_TAG_subprogram: + case DW_TAG_inlined_subroutine: + case DW_TAG_lexical_block: + if (sc.function != NULL) + { + // Check to see if we already have parsed the variables for the given scope + + Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); + if (block == NULL) + { + // This must be a specification or abstract origin with + // a concrete block couterpart in the current function. We need + // to find the concrete block so we can correctly add the + // variable to it + DWARFCompileUnit *concrete_block_die_cu = dwarf_cu; + const DWARFDebugInfoEntry *concrete_block_die = FindBlockContainingSpecification (sc.function->GetID(), + sc_parent_die->GetOffset(), + &concrete_block_die_cu); + if (concrete_block_die) + block = sc.function->GetBlock(true).FindBlockByID(concrete_block_die->GetOffset()); + } + + if (block != NULL) + { + const bool can_create = false; + variable_list_sp = block->GetBlockVariableList (can_create); + if (variable_list_sp.get() == NULL) + { + variable_list_sp.reset(new VariableList()); + block->SetVariableList(variable_list_sp); + } + } + } + break; + + default: + fprintf (stderr, + "error: didn't find appropriate parent DIE for variable list for 0x%8.8x %s.\n", + orig_die->GetOffset(), + DW_TAG_value_to_name (orig_die->Tag())); + break; + } } - } - else - { - fprintf (stderr, - "error: NULL block for 0x%8.8x %s for variable at 0x%8.8x %s\n", - sc_parent_die->GetOffset(), - DW_TAG_value_to_name (parent_tag), - orig_die->GetOffset(), - DW_TAG_value_to_name (orig_die->Tag())); - } - } - else - { - fprintf (stderr, - "error: parent 0x%8.8x %s with no valid function in symbol context for 0x%8.8x %s.\n", - sc_parent_die->GetOffset(), - DW_TAG_value_to_name (parent_tag), - orig_die->GetOffset(), - DW_TAG_value_to_name (orig_die->Tag())); - } - break; - - default: - fprintf (stderr, - "error: didn't find appropriate parent DIE for variable list for 0x%8.8x %s.\n", - orig_die->GetOffset(), - DW_TAG_value_to_name (orig_die->Tag())); - break; - } - - // We need to have a variable list at this point that we can add variables to - if (variables.get()) - { - size_t vars_added = 0; - while (die != NULL) - { - dw_tag_t tag = die->Tag(); - - // Check to see if we have already parsed this variable or constant? - if (m_die_to_variable_sp[die]) - { - if (cc_variable_list) - cc_variable_list->AddVariableIfUnique (m_die_to_variable_sp[die]); - } - else - { - // We haven't already parsed it, lets do that now. - if ((tag == DW_TAG_variable) || - (tag == DW_TAG_constant) || - (tag == DW_TAG_formal_parameter && sc.function)) + + if (variable_list_sp) { VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, func_low_pc)); if (var_sp) { - variables->AddVariableIfUnique (var_sp); + variable_list_sp->AddVariableIfUnique (var_sp); if (cc_variable_list) cc_variable_list->AddVariableIfUnique (var_sp); ++vars_added; } } } + } - bool skip_children = (sc.function == NULL && tag == DW_TAG_subprogram); + bool skip_children = (sc.function == NULL && tag == DW_TAG_subprogram); - if (!skip_children && parse_children && die->HasChildren()) - { - vars_added += ParseVariables(sc, dwarf_cu, func_low_pc, die->GetFirstChild(), true, true, cc_variable_list); - } - - if (parse_siblings) - die = die->GetSibling(); - else - die = NULL; + if (!skip_children && parse_children && die->HasChildren()) + { + vars_added += ParseVariables(sc, dwarf_cu, func_low_pc, die->GetFirstChild(), true, true, cc_variable_list); } - return vars_added; + + if (parse_siblings) + die = die->GetSibling(); + else + die = NULL; } - return 0; + return vars_added; } //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=133302&r1=133301&r2=133302&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Jun 17 17:10:16 2011 @@ -311,6 +311,17 @@ m_debug_map_symfile = debug_map_symfile; } + const DWARFDebugInfoEntry * + FindBlockContainingSpecification (dw_offset_t func_die_offset, + dw_offset_t spec_block_die_offset, + DWARFCompileUnit **dwarf_cu_handle); + + const DWARFDebugInfoEntry * + FindBlockContainingSpecification (DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die, + dw_offset_t spec_block_die_offset, + DWARFCompileUnit **dwarf_cu_handle); + clang::NamespaceDecl * ResolveNamespaceDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die); Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=133302&r1=133301&r2=133302&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Fri Jun 17 17:10:16 2011 @@ -455,9 +455,8 @@ VariableListSP -Block::GetVariableList (bool get_child_variables, bool can_create) +Block::GetBlockVariableList (bool can_create) { - VariableListSP variable_list_sp; if (m_parsed_block_variables == false) { if (m_variable_list_sp.get() == NULL && can_create) @@ -469,31 +468,40 @@ sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc); } } + return m_variable_list_sp; +} - if (m_variable_list_sp.get()) +uint32_t +Block::AppendBlockVariables (bool can_create, + bool get_child_block_variables, + bool stop_if_child_block_is_inlined_function, + VariableList *variable_list) +{ + uint32_t num_variables_added = 0; + VariableList *block_var_list = GetBlockVariableList (can_create).get(); + if (block_var_list) { - variable_list_sp.reset(new VariableList()); - if (variable_list_sp.get()) - variable_list_sp->AddVariables(m_variable_list_sp.get()); - - if (get_child_variables) - { - for (Block *child_block = GetFirstChild(); - child_block != NULL; - child_block = child_block->GetSibling()) - { - if (child_block->GetInlinedFunctionInfo() == NULL) - { - VariableListSP child_block_variable_list(child_block->GetVariableList(get_child_variables, can_create)); - if (child_block_variable_list.get()) - variable_list_sp->AddVariables(child_block_variable_list.get()); - } - + num_variables_added += block_var_list->GetSize(); + variable_list->AddVariables (block_var_list); + } + + if (get_child_block_variables) + { + for (Block *child_block = GetFirstChild(); + child_block != NULL; + child_block = child_block->GetSibling()) + { + if (stop_if_child_block_is_inlined_function == false || + child_block->GetInlinedFunctionInfo() == NULL) + { + num_variables_added += child_block->AppendBlockVariables (can_create, + get_child_block_variables, + stop_if_child_block_is_inlined_function, + variable_list); } } } - - return variable_list_sp; + return num_variables_added; } uint32_t @@ -506,7 +514,7 @@ ) { uint32_t num_variables_added = 0; - VariableListSP variable_list_sp(GetVariableList(false, can_create)); + VariableListSP variable_list_sp(GetBlockVariableList(can_create)); bool is_inlined_function = GetInlinedFunctionInfo() != NULL; if (variable_list_sp.get()) @@ -538,3 +546,15 @@ child_block->SetBlockInfoHasBeenParsed (b, true); } } + +void +Block::SetDidParseVariables (bool b, bool set_children) +{ + m_parsed_block_variables = b; + if (set_children) + { + for (Block *child_block = GetFirstChild(); child_block != NULL; child_block = child_block->GetSibling()) + child_block->SetDidParseVariables (b, true); + } +} + Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=133302&r1=133301&r2=133302&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Fri Jun 17 17:10:16 2011 @@ -460,7 +460,9 @@ { const bool get_child_variables = true; const bool can_create = true; - m_variable_list_sp = frame_block->GetVariableList (get_child_variables, can_create); + const bool stop_if_child_block_is_inlined_function = true; + m_variable_list_sp.reset(new VariableList()); + frame_block->AppendBlockVariables(can_create, get_child_variables, stop_if_child_block_is_inlined_function, m_variable_list_sp.get()); } } From gclayton at apple.com Fri Jun 17 18:50:44 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Jun 2011 23:50:44 -0000 Subject: [Lldb-commits] [lldb] r133316 - in /lldb/trunk: include/lldb/lldb-enumerations.h source/Commands/CommandObjectMemory.cpp source/Core/DataExtractor.cpp source/Core/State.cpp source/Core/ValueObject.cpp source/Interpreter/Args.cpp source/Symbol/ClangASTType.cpp Message-ID: <20110617235044.C62492A6C12C@llvm.org> Author: gclayton Date: Fri Jun 17 18:50:44 2011 New Revision: 133316 URL: http://llvm.org/viewvc/llvm-project?rev=133316&view=rev Log: Added a new format for displaying an array of characters: eFormatCharArray This us useful because sometomes you have to show a single character as: 'a' (using eFormatChar) and other times you might have an array of single charcters for display as: 'a' 'b' 'c', and other times you might want to show the contents of buffer of characters that can contain non printable chars: "\0\x22\n123". This also fixes an issue that currently happens when you have a single character C string (const char *a = "a"; or char b[1] = { 'b' };) that was being output as "'a'" incorrectly due to the way the eFormatChar format output worked. Modified: lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Core/DataExtractor.cpp lldb/trunk/source/Core/State.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Interpreter/Args.cpp lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=133316&r1=133315&r2=133316&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Jun 17 18:50:44 2011 @@ -92,6 +92,7 @@ eFormatBytesWithASCII, eFormatChar, eFormatCharPrintable, // Only printable characters, space if not printable + eFormatCharArray, // Print characters with no single quotes, used for character arrays that can contain non printable characters eFormatComplex, // Floating point complex type eFormatComplexFloat = eFormatComplex, eFormatCString, // NULL terminated C strings Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=133316&r1=133315&r2=133316&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Fri Jun 17 18:50:44 2011 @@ -210,6 +210,7 @@ if (!count_option_set) m_count = 32; break; + case eFormatCharArray: case eFormatChar: case eFormatCharPrintable: if (!byte_size_option_set) @@ -1062,6 +1063,7 @@ buffer.PutMaxHex64 (uval64, item_byte_size); break; + case eFormatCharArray: case eFormatChar: case eFormatCString: if (value_str[0]) Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=133316&r1=133315&r2=133316&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Fri Jun 17 18:50:44 2011 @@ -1354,6 +1354,7 @@ else if (item_format != eFormatChar && item_format != eFormatCharPrintable && + item_format != eFormatCharArray && count > 0) { s->PutChar(' '); @@ -1397,6 +1398,7 @@ case eFormatChar: case eFormatCharPrintable: + case eFormatCharArray: { // If we are only printing one character surround it with single // quotes @@ -1406,7 +1408,7 @@ uint32_t ch = GetMaxU64(&offset, item_byte_size); if (isprint(ch)) s->Printf ("%c", ch); - else if (item_format == eFormatChar) + else if (item_format != eFormatCharPrintable) { switch (ch) { @@ -1608,7 +1610,7 @@ case eFormatVectorOfChar: s->PutChar('{'); - offset = Dump (s, start_offset, eFormatChar, 1, item_byte_size, item_byte_size, LLDB_INVALID_ADDRESS, 0, 0); + offset = Dump (s, start_offset, eFormatCharArray, 1, item_byte_size, item_byte_size, LLDB_INVALID_ADDRESS, 0, 0); s->PutChar('}'); break; Modified: lldb/trunk/source/Core/State.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/State.cpp?rev=133316&r1=133315&r2=133316&view=diff ============================================================================== --- lldb/trunk/source/Core/State.cpp (original) +++ lldb/trunk/source/Core/State.cpp Fri Jun 17 18:50:44 2011 @@ -51,6 +51,7 @@ case eFormatBytes: return "bytes"; case eFormatBytesWithASCII: return "bytes with ASCII"; case eFormatChar: return "character"; + case eFormatCharArray: return "character array"; case eFormatCharPrintable: return "printable character"; case eFormatComplexFloat: return "complet float"; case eFormatCString: return "c-string"; Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=133316&r1=133315&r2=133316&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Jun 17 18:50:44 2011 @@ -505,7 +505,7 @@ sstr << '"'; data.Dump (&sstr, 0, // Start offset in "data" - eFormatChar, // Print as characters + eFormatCharArray, // Print as characters 1, // Size of item (1 byte for a char!) bytes_read, // How many bytes to print? UINT32_MAX, // num per line @@ -535,7 +535,7 @@ data.Dump (&sstr, 0, // Start offset in "data" - eFormatChar, // Print as characters + eFormatCharArray, // Print as characters 1, // Size of item (1 byte for a char!) len, // How many bytes to print? UINT32_MAX, // num per line Modified: lldb/trunk/source/Interpreter/Args.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=133316&r1=133315&r2=133316&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Args.cpp (original) +++ lldb/trunk/source/Interpreter/Args.cpp Fri Jun 17 18:50:44 2011 @@ -908,6 +908,7 @@ case 'Y': format = eFormatBytesWithASCII; break; case 'b': format = eFormatBinary; break; case 'B': format = eFormatBoolean; break; + case 'a': format = eFormatCharArray; break; case 'c': format = eFormatChar; break; case 'C': format = eFormatCharPrintable; break; case 'o': format = eFormatOctal; break; @@ -930,6 +931,7 @@ } if (!success) error.SetErrorStringWithFormat ("Invalid format specification '%s'. Valid values are:\n" + " a - char buffer\n" " b - binary\n" " B - boolean\n" " c - char\n" Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=133316&r1=133315&r2=133316&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Jun 17 18:50:44 2011 @@ -788,6 +788,7 @@ case eFormatChar: case eFormatCharPrintable: + case eFormatCharArray: case eFormatBytes: case eFormatBytesWithASCII: item_count = (byte_size * item_count); From gclayton at apple.com Fri Jun 17 18:55:27 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Jun 2011 23:55:27 -0000 Subject: [Lldb-commits] [lldb] r133317 - /lldb/tags/lldb-62/ Message-ID: <20110617235527.20DBE2A6C12C@llvm.org> Author: gclayton Date: Fri Jun 17 18:55:26 2011 New Revision: 133317 URL: http://llvm.org/viewvc/llvm-project?rev=133317&view=rev Log: lldb-62 tag. Added: lldb/tags/lldb-62/ - copied from r133316, lldb/trunk/ From gclayton at apple.com Sat Jun 18 15:06:08 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Jun 2011 20:06:08 -0000 Subject: [Lldb-commits] [lldb] r133357 - in /lldb/trunk: include/lldb/API/SBFrame.h source/API/SBFrame.cpp Message-ID: <20110618200608.69F532A6C12C@llvm.org> Author: gclayton Date: Sat Jun 18 15:06:08 2011 New Revision: 133357 URL: http://llvm.org/viewvc/llvm-project?rev=133357&view=rev Log: Added two new API functions to SBFrame: const char * SBFrame::GetFunctionName(); bool SBFrame::IsInlined(); The first one will return the correct name for a frame. The name of a frame is: - the name of the inlined function (if there is one) - the name of the concrete function (if there is one) - the name of the symbol (if there is one) - NULL We also can now easily check if a frame is an inline function or not. Modified: lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/source/API/SBFrame.cpp Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=133357&r1=133356&r2=133357&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Sat Jun 18 15:06:08 2011 @@ -71,6 +71,18 @@ lldb::SBBlock GetBlock () const; + // Get the appropriate function name for this frame. Inlined functions in + // LLDB are represented by Blocks that have inlined function information, so + // just looking at the SBFunction or SBSymbol for a frame isn't enough. + // This function will return the appriopriate function, symbol or inlined + // function name for the frame. + const char * + GetFunctionName(); + + // Return true if this frame represents and an inlined function. + bool + IsInlined(); + // The version that doesn't supply a "use_dynamic" value will use the target's default. lldb::SBValue EvaluateExpression (const char *expr); Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=133357&r1=133356&r2=133357&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Sat Jun 18 15:06:08 2011 @@ -343,8 +343,13 @@ SBValue SBFrame::FindVariable (const char *name) { - lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); - return FindVariable (name, use_dynamic); + SBValue value; + if (m_opaque_sp) + { + lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + value = FindVariable (name, use_dynamic); + } + return value; } SBValue @@ -373,11 +378,12 @@ var_sp = variable_list.FindVariable (ConstString(name)); } } + + if (var_sp) + *sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic)); + } - if (var_sp) - *sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic)); - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)", @@ -389,8 +395,13 @@ SBValue SBFrame::FindValue (const char *name, ValueType value_type) { - lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); - return FindValue (name, value_type, use_dynamic); + SBValue value; + if (m_opaque_sp) + { + lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + value = FindValue (name, value_type, use_dynamic); + } + return value; } SBValue @@ -579,8 +590,13 @@ bool statics, bool in_scope_only) { - lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); - return GetVariables (arguments, locals, statics, in_scope_only, use_dynamic); + SBValueList value_list; + if (m_opaque_sp) + { + lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + value_list = GetVariables (arguments, locals, statics, in_scope_only, use_dynamic); + } + return value_list; } SBValueList @@ -706,15 +722,18 @@ SBValue SBFrame::EvaluateExpression (const char *expr) { - lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); - return EvaluateExpression (expr, use_dynamic); + SBValue result; + if (m_opaque_sp) + { + lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + result = EvaluateExpression (expr, use_dynamic); + } + return result; } SBValue SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value) { - Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -725,6 +744,8 @@ if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); + ExecutionResults exe_results; const bool unwind_on_error = true; const bool keep_in_memory = false; @@ -749,3 +770,48 @@ return expr_result; } + +bool +SBFrame::IsInlined() +{ + if (m_opaque_sp) + { + Block *block = m_opaque_sp->GetSymbolContext(eSymbolContextBlock).block; + if (block) + return block->GetContainingInlinedBlock () != NULL; + } + return false; +} + +const char * +SBFrame::GetFunctionName() +{ + const char *name = NULL; + if (m_opaque_sp) + { + SymbolContext sc (m_opaque_sp->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol)); + if (sc.block) + { + Block *inlined_block = sc.block->GetContainingInlinedBlock (); + if (inlined_block) + { + const InlineFunctionInfo* inlined_info = inlined_block->GetInlinedFunctionInfo(); + name = inlined_info->GetName().AsCString(); + } + } + + if (name == NULL) + { + if (sc.function) + name = sc.function->GetName().GetCString(); + } + + if (name == NULL) + { + if (sc.symbol) + name = sc.symbol->GetName().GetCString(); + } + } + return name; +} + From gclayton at apple.com Sat Jun 18 15:12:02 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Jun 2011 20:12:02 -0000 Subject: [Lldb-commits] [lldb] r133358 - /lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Message-ID: <20110618201203.0D4C92A6C12C@llvm.org> Author: gclayton Date: Sat Jun 18 15:12:02 2011 New Revision: 133358 URL: http://llvm.org/viewvc/llvm-project?rev=133358&view=rev Log: Don't print the baton when a breakpoint has a callback since it is pretty useless to show. Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointOptions.cpp?rev=133358&r1=133357&r2=133358&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointOptions.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Sat Jun 18 15:12:02 2011 @@ -309,14 +309,6 @@ } } - if (m_callback_baton_sp.get()) - { - if (level != eDescriptionLevelBrief) - { - s->EOL(); - m_callback_baton_sp->GetDescription (s, level); - } - } if (m_condition_ap.get()) { if (level != eDescriptionLevelBrief) From peter at pcc.me.uk Sat Jun 18 18:52:14 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Sat, 18 Jun 2011 23:52:14 -0000 Subject: [Lldb-commits] [lldb] r133370 - in /lldb/trunk: include/lldb/Host/TimeValue.h source/Core/Communication.cpp source/Core/ConnectionFileDescriptor.cpp source/Host/common/TimeValue.cpp source/Plugins/Process/Utility/UnwindLLDB.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Message-ID: <20110618235214.8BBCA2A6C12C@llvm.org> Author: pcc Date: Sat Jun 18 18:52:14 2011 New Revision: 133370 URL: http://llvm.org/viewvc/llvm-project?rev=133370&view=rev Log: Switch from USEC_PER_SEC/NSEC_PER_SEC/NSEC_PER_USEC to TimeValue constants Fixes the Linux build. Modified: lldb/trunk/include/lldb/Host/TimeValue.h lldb/trunk/source/Core/Communication.cpp lldb/trunk/source/Core/ConnectionFileDescriptor.cpp lldb/trunk/source/Host/common/TimeValue.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Modified: lldb/trunk/include/lldb/Host/TimeValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/TimeValue.h?rev=133370&r1=133369&r2=133370&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/TimeValue.h (original) +++ lldb/trunk/include/lldb/Host/TimeValue.h Sat Jun 18 18:52:14 2011 @@ -29,7 +29,9 @@ class TimeValue { public: - static const uint32_t NanoSecondPerSecond = 1000000000U; + static const uint32_t MicroSecPerSec = 1000000UL; + static const uint32_t NanoSecPerSec = 1000000000UL; + static const uint32_t NanoSecPerMicroSec = 1000U; //------------------------------------------------------------------ // Constructors and Destructors Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=133370&r1=133369&r2=133370&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Sat Jun 18 18:52:14 2011 @@ -340,7 +340,7 @@ bool done = false; while (!done && comm->m_read_thread_enabled) { - size_t bytes_read = comm->ReadFromConnection (buf, sizeof(buf), 5 * USEC_PER_SEC, status, &error); + size_t bytes_read = comm->ReadFromConnection (buf, sizeof(buf), 5 * TimeValue::MicroSecPerSec, status, &error); if (bytes_read > 0) comm->AppendBytesToCache (buf, bytes_read, true, status); else if ((bytes_read == 0) Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=133370&r1=133369&r2=133370&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Sat Jun 18 18:52:14 2011 @@ -735,8 +735,8 @@ return true; struct timeval timeout; - timeout.tv_sec = timeout_usec / USEC_PER_SEC; - timeout.tv_usec = timeout_usec % USEC_PER_SEC; + timeout.tv_sec = timeout_usec / TimeValue::MicroSecPerSec; + timeout.tv_usec = timeout_usec % TimeValue::MicroSecPerSec; if (::setsockopt (m_fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) == 0) { m_socket_timeout_usec = timeout_usec; Modified: lldb/trunk/source/Host/common/TimeValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=133370&r1=133369&r2=133370&view=diff ============================================================================== --- lldb/trunk/source/Host/common/TimeValue.cpp (original) +++ lldb/trunk/source/Host/common/TimeValue.cpp Sat Jun 18 18:52:14 2011 @@ -15,10 +15,6 @@ // Other libraries and framework includes // Project includes -#define NSEC_PER_USEC 1000ull -#define USEC_PER_SEC 1000000ull -#define NSEC_PER_SEC 1000000000ull - using namespace lldb_private; //---------------------------------------------------------------------- @@ -38,12 +34,12 @@ } TimeValue::TimeValue(const struct timespec& ts) : - m_nano_seconds (ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec) + m_nano_seconds (ts.tv_sec * NanoSecPerSec + ts.tv_nsec) { } TimeValue::TimeValue(const struct timeval& tv) : - m_nano_seconds (tv.tv_sec * NSEC_PER_SEC + tv.tv_usec * NSEC_PER_USEC) + m_nano_seconds (tv.tv_sec * NanoSecPerSec + tv.tv_usec * NanoSecPerMicroSec) { } @@ -64,15 +60,15 @@ uint64_t TimeValue::GetAsMicroSecondsSinceJan1_1970() const { - return m_nano_seconds / NSEC_PER_USEC; + return m_nano_seconds / NanoSecPerMicroSec; } struct timespec TimeValue::GetAsTimeSpec () const { struct timespec ts; - ts.tv_sec = m_nano_seconds / NSEC_PER_SEC; - ts.tv_nsec = m_nano_seconds % NSEC_PER_SEC; + ts.tv_sec = m_nano_seconds / NanoSecPerSec; + ts.tv_nsec = m_nano_seconds % NanoSecPerSec; return ts; } @@ -80,8 +76,8 @@ TimeValue::GetAsTimeVal () const { struct timeval tv; - tv.tv_sec = m_nano_seconds / NSEC_PER_SEC; - tv.tv_usec = (m_nano_seconds % NSEC_PER_SEC) / NSEC_PER_USEC; + tv.tv_sec = m_nano_seconds / NanoSecPerSec; + tv.tv_usec = (m_nano_seconds % NanoSecPerSec) / NanoSecPerMicroSec; return tv; } @@ -100,13 +96,13 @@ void TimeValue::OffsetWithSeconds (uint64_t sec) { - m_nano_seconds += sec * NSEC_PER_SEC; + m_nano_seconds += sec * NanoSecPerSec; } void TimeValue::OffsetWithMicroSeconds (uint64_t usec) { - m_nano_seconds += usec * NSEC_PER_USEC; + m_nano_seconds += usec * NanoSecPerMicroSec; } void Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=133370&r1=133369&r2=133370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Sat Jun 18 18:52:14 2011 @@ -53,9 +53,9 @@ uint64_t delta_t = now - time_value; printf ("%u frames in %llu.%09llu ms (%g frames/sec)\n", FRAME_COUNT, - delta_t / NSEC_PER_SEC, - delta_t % NSEC_PER_SEC, - (float)FRAME_COUNT / ((float)delta_t / (float)NSEC_PER_SEC)); + delta_t / TimeValue::NanoSecPerSec, + delta_t % TimeValue::NanoSecPerSec, + (float)FRAME_COUNT / ((float)delta_t / (float)TimeValue::NanoSecPerSec)); time_value = now; } #endif Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=133370&r1=133369&r2=133370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Sat Jun 18 18:52:14 2011 @@ -22,6 +22,7 @@ #include "lldb/Core/Listener.h" #include "lldb/Host/Mutex.h" #include "lldb/Host/Predicate.h" +#include "lldb/Host/TimeValue.h" #include "Utility/StringExtractorGDBRemote.h" @@ -116,7 +117,7 @@ uint32_t GetPacketTimeoutInMicroSeconds () const { - return m_packet_timeout * USEC_PER_SEC; + return m_packet_timeout * lldb_private::TimeValue::MicroSecPerSec; } //------------------------------------------------------------------ // Start a debugserver instance on the current host using the Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=133370&r1=133369&r2=133370&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Sat Jun 18 18:52:14 2011 @@ -1430,13 +1430,13 @@ } end_time = TimeValue::Now(); total_time_nsec = end_time.GetAsNanoSecondsSinceJan1_1970() - start_time.GetAsNanoSecondsSinceJan1_1970(); - packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecondPerSecond; + packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecPerSec; printf ("%u qSpeedTest(send=%-5u, recv=%-5u) in %llu.%09.9llu sec for %f packets/sec.\n", num_packets, send_size, recv_size, - total_time_nsec / TimeValue::NanoSecondPerSecond, - total_time_nsec % TimeValue::NanoSecondPerSecond, + total_time_nsec / TimeValue::NanoSecPerSec, + total_time_nsec % TimeValue::NanoSecPerSec, packets_per_second); if (recv_size == 0) recv_size = 32; @@ -1454,11 +1454,11 @@ } end_time = TimeValue::Now(); total_time_nsec = end_time.GetAsNanoSecondsSinceJan1_1970() - start_time.GetAsNanoSecondsSinceJan1_1970(); - packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecondPerSecond; + packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecPerSec; printf ("%u 'qC' packets packets in 0x%llu%09.9llu sec for %f packets/sec.\n", num_packets, - total_time_nsec / TimeValue::NanoSecondPerSecond, - total_time_nsec % TimeValue::NanoSecondPerSecond, + total_time_nsec / TimeValue::NanoSecPerSec, + total_time_nsec % TimeValue::NanoSecPerSec, packets_per_second); } } From peter at pcc.me.uk Sat Jun 18 19:32:02 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Sun, 19 Jun 2011 01:32:02 +0100 Subject: [Lldb-commits] [PATCH] Support for running test suite using makefiles on Linux Message-ID: <20110619003200.GA6464@pcc.me.uk> Hi, These patches allow for running the test suite using the makefiles on Linux (and presumably on Darwin, but I haven't tested that) either using "make test" in the lldb directory or "make" in the lldb/test directory. I'm seeking review because they touch some platform-independent components of the test suite. OK to commit? Thanks, -- Peter -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Add-Linux-rules-to-test-makefile.patch Type: text/x-diff Size: 4258 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110619/0590497b/attachment-0008.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-Add-a-builder-module-for-Linux-plus-some-refactoring.patch Type: text/x-diff Size: 6471 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110619/0590497b/attachment-0009.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0003-Have-dotest.py-search-for-test-cases-in-its-own-dire.patch Type: text/x-diff Size: 846 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110619/0590497b/attachment-0010.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0004-Create-a-_lldb.so-symlink-in-the-bin-directory.patch Type: text/x-diff Size: 3202 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110619/0590497b/attachment-0011.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0005-Modify-TestHelp-to-search-for-LLDB-Info.plist-in-the.patch Type: text/x-diff Size: 1631 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110619/0590497b/attachment-0012.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0006-Add-a-default-rule-to-test-Makefile-which-runs-the-t.patch Type: text/x-diff Size: 1669 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110619/0590497b/attachment-0013.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0007-Enable-the-make-test-rule-in-the-root-Makefile.patch Type: text/x-diff Size: 560 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110619/0590497b/attachment-0014.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0008-Add-dependency-tracking-clean-rule-to-interpreter-ma.patch Type: text/x-diff Size: 2787 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110619/0590497b/attachment-0015.bin From johnny.chen at apple.com Sat Jun 18 21:25:08 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 18 Jun 2011 19:25:08 -0700 Subject: [Lldb-commits] [PATCH] Support for running test suite using makefiles on Linux In-Reply-To: <20110619003200.GA6464@pcc.me.uk> References: <20110619003200.GA6464@pcc.me.uk> Message-ID: <02B91F13-5C11-4AA3-B0D1-5DF0D2D08DA2@apple.com> Hi Peter, These look good. Feel free to commit. Thanks. Johnny Chen On Jun 18, 2011, at 5:32 PM, Peter Collingbourne wrote: > Hi, > > These patches allow for running the test suite using the makefiles > on Linux (and presumably on Darwin, but I haven't tested that) > either using "make test" in the lldb directory or "make" in the > lldb/test directory. I'm seeking review because they touch some > platform-independent components of the test suite. > > OK to commit? > > Thanks, > -- > Peter > <0001-Add-Linux-rules-to-test-makefile.patch><0002-Add-a-builder-module-for-Linux-plus-some-refactoring.patch><0003-Have-dotest.py-search-for-test-cases-in-its-own-dire.patch><0004-Create-a-_lldb.so-symlink-in-the-bin-directory.patch><0005-Modify-TestHelp-to-search-for-LLDB-Info.plist-in-the.patch><0006-Add-a-default-rule-to-test-Makefile-which-runs-the-t.patch><0007-Enable-the-make-test-rule-in-the-root-Makefile.patch><0008-Add-dependency-tracking-clean-rule-to-interpreter-ma.patch>_______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Sat Jun 18 22:43:27 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 19 Jun 2011 03:43:27 -0000 Subject: [Lldb-commits] [lldb] r133375 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Symbol/ClangASTContext.cpp Message-ID: <20110619034327.AE2C92A6C12C@llvm.org> Author: gclayton Date: Sat Jun 18 22:43:27 2011 New Revision: 133375 URL: http://llvm.org/viewvc/llvm-project?rev=133375&view=rev Log: Fixed a case where LLDB would crash if we get C++ operators with invalid operator counts due to bad debug DWARF debug info. We now verify the operator has a valid number of params using the clang operator tables. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=133375&r1=133374&r2=133375&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Sat Jun 18 22:43:27 2011 @@ -289,6 +289,10 @@ is_explicit); } + static bool + CheckOverloadedOperatorKindParameterCount (uint32_t op_kind, + uint32_t num_params); + bool FieldIsBitfield (clang::FieldDecl* field, uint32_t& bitfield_bit_size); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=133375&r1=133374&r2=133375&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sat Jun 18 22:43:27 2011 @@ -1358,6 +1358,29 @@ return true; } +static inline bool +check_op_param (bool unary, bool binary, uint32_t num_params) +{ + // The parameter count doens't include "this" + if (num_params == 0) + return unary; + if (num_params == 1) + return binary; + return false; +} + +bool +ClangASTContext::CheckOverloadedOperatorKindParameterCount (uint32_t op_kind, uint32_t num_params) +{ +#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) case OO_##Name: return check_op_param (Unary, Binary, num_params); + switch (op_kind) + { +#include "clang/Basic/OperatorKinds.def" + default: break; + } + return false; +} + CXXMethodDecl * ClangASTContext::AddMethodToCXXRecordType ( @@ -1439,6 +1462,13 @@ { if (op_kind != NUM_OVERLOADED_OPERATORS) { + // Check the number of operator parameters. Sometimes we have + // seen bad DWARF that doesn't correctly describe operators and + // if we try to create a methed and add it to the class, clang + // will assert and crash, so we need to make sure things are + // acceptable. + if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount (op_kind, num_params)) + return NULL; cxx_method_decl = CXXMethodDecl::Create (*ast, cxx_record_decl, SourceLocation(), From gclayton at apple.com Sat Jun 18 23:02:02 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 19 Jun 2011 04:02:02 -0000 Subject: [Lldb-commits] [lldb] r133376 - /lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Message-ID: <20110619040202.CD69D2A6C12C@llvm.org> Author: gclayton Date: Sat Jun 18 23:02:02 2011 New Revision: 133376 URL: http://llvm.org/viewvc/llvm-project?rev=133376&view=rev Log: Make sure we have a valid object file before we try getting the symbol table so we avoid crashing. Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=133376&r1=133375&r2=133376&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Sat Jun 18 23:02:02 2011 @@ -76,43 +76,45 @@ SymbolFileSymtab::GetAbilities () { uint32_t abilities = 0; - const Symtab *symtab = m_obj_file->GetSymtab(); - if (symtab) + if (m_obj_file) { - - //---------------------------------------------------------------------- - // The snippet of code below will get the indexes the module symbol - // table entries that are code, data, or function related (debug info), - // sort them by value (address) and dump the sorted symbols. - //---------------------------------------------------------------------- - symtab->AppendSymbolIndexesWithType(eSymbolTypeSourceFile, m_source_indexes); - if (!m_source_indexes.empty()) - { - abilities |= CompileUnits; - } - symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugYes, Symtab::eVisibilityAny, m_func_indexes); - if (!m_func_indexes.empty()) + const Symtab *symtab = m_obj_file->GetSymtab(); + if (symtab) { - symtab->SortSymbolIndexesByValue(m_func_indexes, true); - abilities |= Functions; - } - symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes); - if (!m_code_indexes.empty()) - { - symtab->SortSymbolIndexesByValue(m_code_indexes, true); - abilities |= Labels; - } + //---------------------------------------------------------------------- + // The snippet of code below will get the indexes the module symbol + // table entries that are code, data, or function related (debug info), + // sort them by value (address) and dump the sorted symbols. + //---------------------------------------------------------------------- + symtab->AppendSymbolIndexesWithType(eSymbolTypeSourceFile, m_source_indexes); + if (!m_source_indexes.empty()) + { + abilities |= CompileUnits; + } + symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugYes, Symtab::eVisibilityAny, m_func_indexes); + if (!m_func_indexes.empty()) + { + symtab->SortSymbolIndexesByValue(m_func_indexes, true); + abilities |= Functions; + } + + symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes); + if (!m_code_indexes.empty()) + { + symtab->SortSymbolIndexesByValue(m_code_indexes, true); + abilities |= Labels; + } - symtab->AppendSymbolIndexesWithType(eSymbolTypeData, m_data_indexes); + symtab->AppendSymbolIndexesWithType(eSymbolTypeData, m_data_indexes); - if (!m_data_indexes.empty()) - { - symtab->SortSymbolIndexesByValue(m_data_indexes, true); - abilities |= GlobalVariables; + if (!m_data_indexes.empty()) + { + symtab->SortSymbolIndexesByValue(m_data_indexes, true); + abilities |= GlobalVariables; + } } } - return abilities; } From gclayton at apple.com Sat Jun 18 23:26:01 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 19 Jun 2011 04:26:01 -0000 Subject: [Lldb-commits] [lldb] r133377 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20110619042601.B5AF02A6C12C@llvm.org> Author: gclayton Date: Sat Jun 18 23:26:01 2011 New Revision: 133377 URL: http://llvm.org/viewvc/llvm-project?rev=133377&view=rev Log: Fixed a crasher where we were accessing a symbol with a bad index. Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 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=133377&r1=133376&r2=133377&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Sat Jun 18 23:26:01 2011 @@ -968,7 +968,7 @@ // using nlist_idx in case we ever start trimming entries out if (symbol_name[0] == '/') N_SO_index = sym_idx; - else if (minimize && (N_SO_index == sym_idx - 1)) + else if (minimize && (N_SO_index == sym_idx - 1) && ((sym_idx - 1) < num_syms)) { const char *so_path = sym[sym_idx - 1].GetMangled().GetDemangledName().AsCString(); if (so_path && so_path[0]) From gclayton at apple.com Sat Jun 18 23:35:24 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 19 Jun 2011 04:35:24 -0000 Subject: [Lldb-commits] [lldb] r133378 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20110619043524.E65F02A6C12C@llvm.org> Author: gclayton Date: Sat Jun 18 23:35:24 2011 New Revision: 133378 URL: http://llvm.org/viewvc/llvm-project?rev=133378&view=rev Log: Bumping Xcode project version for lldb-63. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=133378&r1=133377&r2=133378&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat Jun 18 23:35:24 2011 @@ -3394,10 +3394,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3446,11 +3446,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3497,8 +3497,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 62; - DYLIB_CURRENT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; + DYLIB_CURRENT_VERSION = 63; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3536,9 +3536,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3576,9 +3576,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3646,7 +3646,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3677,11 +3677,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 62; + DYLIB_CURRENT_VERSION = 63; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3806,7 +3806,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3838,7 +3838,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 63; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=133378&r1=133377&r2=133378&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Sat Jun 18 23:35:24 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 62 + 63 CFBundleName ${EXECUTABLE_NAME} From gclayton at apple.com Sat Jun 18 23:35:52 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 19 Jun 2011 04:35:52 -0000 Subject: [Lldb-commits] [lldb] r133379 - /lldb/tags/lldb-63/ Message-ID: <20110619043552.16E362A6C12C@llvm.org> Author: gclayton Date: Sat Jun 18 23:35:51 2011 New Revision: 133379 URL: http://llvm.org/viewvc/llvm-project?rev=133379&view=rev Log: lldb-63. Added: lldb/tags/lldb-63/ - copied from r133378, lldb/trunk/ From cdavis at mymail.mines.edu Sat Jun 18 23:58:38 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Sat, 18 Jun 2011 22:58:38 -0600 Subject: [Lldb-commits] [PATCH] Support for running test suite using makefiles on Linux In-Reply-To: <20110619003200.GA6464@pcc.me.uk> References: <20110619003200.GA6464@pcc.me.uk> Message-ID: <4DFD81FE.4000407@mymail.mines.edu> On 6/18/11 6:32 PM, Peter Collingbourne wrote: [From patch 1] > @@ -31,15 +36,27 @@ endif [...] > +ifeq "$(DYLIB_NAME)" "" You do mean "ifneq" here, right? Otherwise, you'll get back lib.so (or lib.dylib) as the shared library's filename. :) [From patch 4] > @@ -35,21 +35,23 @@ LLDB_SWIG_INCLUDE_DIRS += -I"/usr/include" > LLDBWrapPython.cpp: [...] > + $(Verb) $(RM) -f $(PYTHON_DIR)/_lldb.so > + $(Verb) $(AliasTool) $(LIBLLDB) $(PYTHON_DIR)/_lldb.so This can't work. At least, it can't if the $(AliasTool) expects the source file to exist. At first, I thought you'd need to depend on liblldb.so; but that won't work either, because liblldb.so depends on LLDBWrapPython.cpp! You'll have to make the _lldb.so symlink elsewhere. Otherwise, looks fine. I would test on my Mac, but I already know it won't work because of patch 4. Chip From bugzilla-daemon at llvm.org Sun Jun 19 13:43:10 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Sun, 19 Jun 2011 13:43:10 -0500 (CDT) Subject: [Lldb-commits] [Bug 10157] New: source/Interpreter/Makefile: broken install-local Message-ID: http://llvm.org/bugs/show_bug.cgi?id=10157 Summary: source/Interpreter/Makefile: broken install-local Product: lldb Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: pipping at exherbo.org Created an attachment (id=6749) --> (http://llvm.org/bugs/attachment.cgi?id=6749) don't depend on an installed lib; proper symlink I think the attached patch is in order. -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From cdavis at mymail.mines.edu Sun Jun 19 14:56:06 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Sun, 19 Jun 2011 13:56:06 -0600 Subject: [Lldb-commits] [PATCH] Support for running test suite using makefiles on Linux In-Reply-To: <4DFD81FE.4000407@mymail.mines.edu> References: <20110619003200.GA6464@pcc.me.uk> <4DFD81FE.4000407@mymail.mines.edu> Message-ID: <4DFE5456.7060301@mymail.mines.edu> On 6/18/11 10:58 PM, Charles Davis wrote: > On 6/18/11 6:32 PM, Peter Collingbourne wrote: > [From patch 4] >> @@ -35,21 +35,23 @@ LLDB_SWIG_INCLUDE_DIRS += -I"/usr/include" >> LLDBWrapPython.cpp: > [...] >> + $(Verb) $(RM) -f $(PYTHON_DIR)/_lldb.so >> + $(Verb) $(AliasTool) $(LIBLLDB) $(PYTHON_DIR)/_lldb.so > This can't work. At least, it can't if the $(AliasTool) expects the > source file to exist. At first, I thought you'd need to depend on > liblldb.so; but that won't work either, because liblldb.so depends on > LLDBWrapPython.cpp! You'll have to make the _lldb.so symlink elsewhere. Never mind. ln -s works even if the source file doesn't exist, even on Darwin. But it wouldn't work on Windows, where the $(AliasTool) is not 'ln -s' but 'cp'/'copy'. But that's OK for now, because LLDB doesn't even work on Windows :). Chip From johnny.chen at apple.com Sun Jun 19 19:26:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Jun 2011 00:26:39 -0000 Subject: [Lldb-commits] [lldb] r133404 - in /lldb/trunk/test: lldbutil.py python_api/frame/inlines/ python_api/frame/inlines/Makefile python_api/frame/inlines/TestInlinedFrame.py Message-ID: <20110620002639.4F0DA2A6C12C@llvm.org> Author: johnny Date: Sun Jun 19 19:26:39 2011 New Revision: 133404 URL: http://llvm.org/viewvc/llvm-project?rev=133404&view=rev Log: Add TestInlinedFrame.py to exercise the newly added SBFrame APIs: IsInlined() and GetFunctionName(). Added: lldb/trunk/test/python_api/frame/inlines/ - copied from r133401, lldb/trunk/test/inlines/ lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py Modified: lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/frame/inlines/Makefile Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=133404&r1=133403&r2=133404&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Sun Jun 19 19:26:39 2011 @@ -293,7 +293,7 @@ Returns a sequence of function names from the stack frames of this thread. """ def GetFuncName(i): - return thread.GetFrameAtIndex(i).GetFunction().GetName() + return thread.GetFrameAtIndex(i).GetFunctionName() return map(GetFuncName, range(thread.GetNumFrames())) @@ -393,8 +393,9 @@ num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset) else: print >> output, " frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}".format( - num=i, addr=load_addr, mod=mods[i], func=funcs[i], file=files[i], line=lines[i], - args=get_args_as_string(frame, showFuncName=False)) + num=i, addr=load_addr, mod=mods[i], + func='%s [inlined]' % funcs[i] if frame.IsInlined() else funcs[i], + file=files[i], line=lines[i], args=get_args_as_string(frame, showFuncName=False)) if string_buffer: return output.getvalue() Modified: lldb/trunk/test/python_api/frame/inlines/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/inlines/Makefile?rev=133404&r1=133401&r2=133404&view=diff ============================================================================== --- lldb/trunk/test/python_api/frame/inlines/Makefile (original) +++ lldb/trunk/test/python_api/frame/inlines/Makefile Sun Jun 19 19:26:39 2011 @@ -1,4 +1,4 @@ -LEVEL = ../make +LEVEL = ../../../make C_SOURCES := inlines.c Added: lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py?rev=133404&view=auto ============================================================================== --- lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py (added) +++ lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py Sun Jun 19 19:26:39 2011 @@ -0,0 +1,66 @@ +""" +Testlldb Python SBFrame APIs IsInlined() and GetFunctionName(). +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class InlinedFrameAPITestCase(TestBase): + + mydir = os.path.join("python_api", "frame", "inlines") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_stop_at_outer_inline_dsym(self): + """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName().""" + self.buildDsym() + self.do_stop_at_outer_inline() + + @python_api_test + def test_stop_at_outer_inline_with_dwarf(self): + """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName().""" + self.buildDwarf() + self.do_stop_at_outer_inline() + + def do_stop_at_outer_inline(self): + """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName().""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('outer_inline', 'a.out') + #print "breakpoint:", breakpoint + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() > 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at the entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + + process = target.GetProcess() + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + + # The first breakpoint should correspond to an inlined call frame. + frame0 = process.GetThreadAtIndex(0).GetFrameAtIndex(0) + self.assertTrue(frame0.IsInlined() and + frame0.GetFunctionName() == 'outer_inline') + + self.runCmd("bt") + if self.TraceOn(): + print "Full stack traces when first stopped on the breakpoint 'outer_inline':" + import lldbutil + print lldbutil.print_stacktraces(process) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From bugzilla-daemon at llvm.org Sun Jun 19 23:40:35 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Sun, 19 Jun 2011 23:40:35 -0500 (CDT) Subject: [Lldb-commits] [Bug 10157] source/Interpreter/Makefile: broken install-local In-Reply-To: References: Message-ID: <20110620044035.A13302A6C124@llvm.org> http://llvm.org/bugs/show_bug.cgi?id=10157 Charles Davis changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |cdavis at mymail.mines.edu AssignedTo|lldb-commits at cs.uiuc.edu |cdavis at mymail.mines.edu OS/Version|Linux |All --- Comment #2 from Charles Davis 2011-06-19 23:40:35 CDT --- One comment on your patch. Why does the path to the LLDB library not respect the DESTDIR variable? liblldb will be installed to $(DESTDIR)$(PROJ_libdir), but the symlink is to $(PROJ_libdir)/liblldb.so. Is this on purpose? I could see how, if e.g. the DESTDIR were the root of a chroot(8) environment. But, are you sure you want to do it this way? -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.