From johnny.chen at apple.com Mon Nov 29 11:50:10 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 29 Nov 2010 17:50:10 -0000 Subject: [Lldb-commits] [lldb] r120294 - /lldb/trunk/test/dotest.py Message-ID: <20101129175010.50BE32A6C12D@llvm.org> Author: johnny Date: Mon Nov 29 11:50:10 2010 New Revision: 120294 URL: http://llvm.org/viewvc/llvm-project?rev=120294&view=rev Log: When looping through the test suite more than once (repeat count > 1), we should ignore and not enforce the signleton pattern for the LLDBTestResult class. 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=120294&r1=120293&r2=120294&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Nov 29 11:50:10 2010 @@ -718,9 +718,10 @@ to a log file for easier human inspection of test failres/errors. """ __singleton__ = None + __ignore_singleton__ = False def __init__(self, *args): - if LLDBTestResult.__singleton__: + if not LLDBTestResult.__ignore_singleton__ and LLDBTestResult.__singleton__: raise Exception("LLDBTestResult instantiated more than once") super(LLDBTestResult, self).__init__(*args) LLDBTestResult.__singleton__ = self @@ -756,8 +757,10 @@ result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose, resultclass=LLDBTestResult).run(suite) else: + LLDBTestResult.__ignore_singleton__ = True for i in range(count): - result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose).run(suite) + result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose, + resultclass=LLDBTestResult).run(suite) if sdir_has_content: From johnny.chen at apple.com Mon Nov 29 11:52:43 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 29 Nov 2010 17:52:43 -0000 Subject: [Lldb-commits] [lldb] r120295 - /lldb/trunk/test/dotest.py Message-ID: <20101129175243.CC33D2A6C12D@llvm.org> Author: johnny Date: Mon Nov 29 11:52:43 2010 New Revision: 120295 URL: http://llvm.org/viewvc/llvm-project?rev=120295&view=rev Log: Add comment. 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=120295&r1=120294&r2=120295&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Nov 29 11:52:43 2010 @@ -757,6 +757,9 @@ result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose, resultclass=LLDBTestResult).run(suite) else: + # We are invoking the same test suite more than once. In this case, + # mark __ignore_singleton__ flag as True so the signleton pattern is + # not enforced. LLDBTestResult.__ignore_singleton__ = True for i in range(count): result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose, From johnny.chen at apple.com Mon Nov 29 14:20:34 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 29 Nov 2010 20:20:34 -0000 Subject: [Lldb-commits] [lldb] r120315 - /lldb/trunk/test/lldbtest.py Message-ID: <20101129202034.DD71C2A6C12D@llvm.org> Author: johnny Date: Mon Nov 29 14:20:34 2010 New Revision: 120315 URL: http://llvm.org/viewvc/llvm-project?rev=120315&view=rev Log: Change the variable TestBase.timeWait to the more descriptive timeWaitNextLaunch. Increase the delta between successive test cases, enabled with the '-w' option to the test driver, from 0.5 to 1.0 second, to arrive at a cleaner state before the next test case. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=120315&r1=120314&r2=120315&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Mon Nov 29 14:20:34 2010 @@ -392,7 +392,7 @@ # Time to wait before the next launching attempt in second(s). # Can be overridden by the LLDB_TIME_WAIT_NEXT_LAUNCH environment variable. - timeWait = 1.0; + timeWaitNextLaunch = 1.0; # Keep track of the old current working directory. oldcwd = None @@ -451,13 +451,13 @@ if ("LLDB_WAIT_BETWEEN_TEST_CASES" in os.environ and os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] == 'YES'): - time.sleep(0.5) + time.sleep(1.0) if "LLDB_MAX_LAUNCH_COUNT" in os.environ: self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"]) if "LLDB_TIME_WAIT_NEXT_LAUNCH" in os.environ: - self.timeWait = float(os.environ["LLDB_TIME_WAIT_NEXT_LAUNCH"]) + self.timeWaitNextLaunch = float(os.environ["LLDB_TIME_WAIT_NEXT_LAUNCH"]) # Create the debugger instance if necessary. try: @@ -654,7 +654,7 @@ if running: # For process launch, wait some time before possible next try. - time.sleep(self.timeWait) + time.sleep(self.timeWaitNextLaunch) if self.res.Succeeded(): break From johnny.chen at apple.com Mon Nov 29 14:49:09 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 29 Nov 2010 20:49:09 -0000 Subject: [Lldb-commits] [lldb] r120318 - in /lldb/trunk/test: breakpoint_conditions/TestBreakpointConditions.py lldbtest.py Message-ID: <20101129204909.98E412A6C12F@llvm.org> Author: johnny Date: Mon Nov 29 14:49:09 2010 New Revision: 120318 URL: http://llvm.org/viewvc/llvm-project?rev=120318&view=rev Log: Add an expect() statement within breakpoint_conditions() method which tests that the process status is indeed 'stopped' before invoking 'frame variable -t val' command to inspect the frame variable. When I run the test suite, it sometimes emits an output like: runCmd: frame variable -t val runCmd failed! error: you must be stopped in a valid stack frame to view frame variables. The expect() statement inserted is to make sure that the process is stopped and we have a valid frame. Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=120318&r1=120317&r2=120318&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Mon Nov 29 14:49:09 2010 @@ -56,6 +56,10 @@ # Now run the program. self.runCmd("run", RUN_SUCCEEDED) + # The process should be stopped. + self.expect("process status", PROCESS_STOPPED, + patterns = ['Process .* stopped']) + # 'frame variable -t val' should return 3 due to breakpoint condition. self.expect("frame variable -t val", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int) val = 3') Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=120318&r1=120317&r2=120318&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Mon Nov 29 14:49:09 2010 @@ -151,6 +151,8 @@ STEP_OUT_SUCCEEDED = "Thread step-out succeeded" +PROCESS_STOPPED = "Process status should be stopped" + STOPPED_DUE_TO_BREAKPOINT = "Process should be stopped due to breakpoint" STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS = "%s, %s" % ( From jmolenda at apple.com Mon Nov 29 15:38:59 2010 From: jmolenda at apple.com (Jason Molenda) Date: Mon, 29 Nov 2010 21:38:59 -0000 Subject: [Lldb-commits] [lldb] r120322 - /lldb/trunk/source/Expression/DWARFExpression.cpp Message-ID: <20101129213859.239182A6C12D@llvm.org> Author: jmolenda Date: Mon Nov 29 15:38:58 2010 New Revision: 120322 URL: http://llvm.org/viewvc/llvm-project?rev=120322&view=rev Log: Fix build error when lldb is being built i386. Modified: lldb/trunk/source/Expression/DWARFExpression.cpp Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=120322&r1=120321&r2=120322&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Mon Nov 29 15:38:58 2010 @@ -1033,9 +1033,11 @@ case 2: ptr = ptr & 0xffff; break; case 3: ptr = ptr & 0xffffff; break; case 4: ptr = ptr & 0xffffffff; break; - case 5: ptr = ptr & 0xffffffffff; break; - case 6: ptr = ptr & 0xffffffffffff; break; - case 7: ptr = ptr & 0xffffffffffffff; break; + // the casts are added to work around the case where intptr_t is a 32 bit quantity; + // presumably we won't hit the 5..7 cases if (void*) is 32-bits in this program. + case 5: ptr = (intptr_t) ptr & 0xffffffffffULL; break; + case 6: ptr = (intptr_t) ptr & 0xffffffffffffULL; break; + case 7: ptr = (intptr_t) ptr & 0xffffffffffffffULL; break; default: break; } stack.back().GetScalar() = ptr; From johnny.chen at apple.com Mon Nov 29 17:47:40 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 29 Nov 2010 23:47:40 -0000 Subject: [Lldb-commits] [lldb] r120352 - /lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Message-ID: <20101129234740.3DB492A6C12D@llvm.org> Author: johnny Date: Mon Nov 29 17:47:40 2010 New Revision: 120352 URL: http://llvm.org/viewvc/llvm-project?rev=120352&view=rev Log: Minor comment fix. Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=120352&r1=120351&r2=120352&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Mon Nov 29 17:47:40 2010 @@ -56,7 +56,7 @@ # Now run the program. self.runCmd("run", RUN_SUCCEEDED) - # The process should be stopped. + # The process should be stopped at this point. self.expect("process status", PROCESS_STOPPED, patterns = ['Process .* stopped']) From johnny.chen at apple.com Mon Nov 29 17:58:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 29 Nov 2010 23:58:04 -0000 Subject: [Lldb-commits] [lldb] r120355 - /lldb/trunk/test/class_static/TestStaticVariables.py Message-ID: <20101129235804.8989D2A6C12D@llvm.org> Author: johnny Date: Mon Nov 29 17:58:04 2010 New Revision: 120355 URL: http://llvm.org/viewvc/llvm-project?rev=120355&view=rev Log: Add comment for a branch of test logic which applies to ['clang', 'llvm-gcc'] only. Modified: lldb/trunk/test/class_static/TestStaticVariables.py Modified: lldb/trunk/test/class_static/TestStaticVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_static/TestStaticVariables.py?rev=120355&r1=120354&r2=120355&view=diff ============================================================================== --- lldb/trunk/test/class_static/TestStaticVariables.py (original) +++ lldb/trunk/test/class_static/TestStaticVariables.py Mon Nov 29 17:58:04 2010 @@ -108,6 +108,7 @@ if name == 'g_points': self.assertTrue(val.GetNumChildren() == 2) elif name == 'A::g_points' and self.getCompiler() in ['clang', 'llvm-gcc']: + # On Mac OS X, gcc 4.2 emits the wrong debug info for A::g_points. self.assertTrue(val.GetNumChildren() == 2) child1 = val.GetChildAtIndex(1) self.DebugSBValue(frame, child1) From scallanan at apple.com Mon Nov 29 18:27:43 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 30 Nov 2010 00:27:43 -0000 Subject: [Lldb-commits] [lldb] r120367 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Expression/ClangExpressionVariable.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangExpressionVariable.cpp Message-ID: <20101130002743.B4F342A6C12D@llvm.org> Author: spyffe Date: Mon Nov 29 18:27:43 2010 New Revision: 120367 URL: http://llvm.org/viewvc/llvm-project?rev=120367&view=rev Log: Added a feature where registers can be referred to using special $-variables from expressions. (lldb) expr $rip These variables are available for reading and writing. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionVariable.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=120367&r1=120366&r2=120367&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon Nov 29 18:27:43 2010 @@ -491,6 +491,18 @@ //------------------------------------------------------------------ /// Use the NameSearchContext to generate a Decl for the given + /// register. + /// + /// @param[in] context + /// The NameSearchContext to use when constructing the Decl. + /// + /// @param[in] reg_info + /// The information corresponding to that register. + //------------------------------------------------------------------ + void AddOneRegister(NameSearchContext &context, const lldb::RegisterInfo *reg_info); + + //------------------------------------------------------------------ + /// Use the NameSearchContext to generate a Decl for the given /// type. (Types are not placed in the Tuple list.) /// /// @param[in] context @@ -605,6 +617,40 @@ Error &err); //------------------------------------------------------------------ + /// Actually do the task of materializing or dematerializing a + /// register variable. + /// + /// @param[in] dematerialize + /// True if the variable is to be dematerialized; false if it is to + /// be materialized. + /// + /// @param[in] exe_ctx + /// The execution context to use. + /// + /// @param[in] reg_ctx + /// The register context to use. + /// + /// @param[in] reg_info + /// The information for the register to read/write. + /// + /// @param[in] addr + /// The address at which to materialize the variable. + /// + /// @param[in] err + /// An Error to populate with any messages related to + /// (de)materializing the persistent variable. + /// + /// @return + /// True on success; false otherwise. + //------------------------------------------------------------------ + bool DoMaterializeOneRegister(bool dematerialize, + ExecutionContext &exe_ctx, + RegisterContext ®_ctx, + const lldb::RegisterInfo ®_info, + lldb::addr_t addr, + Error &err); + + //------------------------------------------------------------------ /// A wrapper for ClangASTContext::CopyType that sets a flag that /// indicates that we should not respond to queries during import. /// Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=120367&r1=120366&r2=120367&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Mon Nov 29 18:27:43 2010 @@ -20,6 +20,7 @@ // Other libraries and framework includes // Project includes +#include "lldb/lldb-types.h" #include "lldb/Core/ClangForward.h" #include "lldb/Core/ConstString.h" #include "lldb/Symbol/TaggedASTType.h" @@ -89,9 +90,11 @@ //---------------------------------------------------------------------- /// The following values should stay valid for the life of the variable //---------------------------------------------------------------------- - ConstString m_name; ///< The name of the variable - TypeFromUser m_user_type; ///< The type of the variable according to some LLDB context; - ///< NULL if the type hasn't yet been migrated to one + ConstString m_name; ///< The name of the variable + TypeFromUser m_user_type; ///< The type of the variable according to some LLDB context; + ///< NULL if the type hasn't yet been migrated to one + + const lldb::RegisterInfo *m_register_info; ///< if non-NULL, LLDB's information for the register this value is stored in. Only used for register values //---------------------------------------------------------------------- /// The following values indicate where the variable originally came from Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=120367&r1=120366&r2=120367&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Mon Nov 29 18:27:43 2010 @@ -132,6 +132,8 @@ clang::NamedDecl *NameSearchContext::AddVarDecl(void *type) { IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo(); + + assert (type && "Type for variable must be non-NULL!"); clang::NamedDecl *Decl = VarDecl::Create(m_ast_source.m_ast_context, const_cast(m_decl_context), Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=120367&r1=120366&r2=120367&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Nov 29 18:27:43 2010 @@ -584,11 +584,26 @@ if (entity) { - if (!member.m_jit_vars.get()) - return false; - - if (!DoMaterializeOneVariable(dematerialize, *exe_ctx, sym_ctx, member.m_name, member.m_user_type, m_materialized_location + member.m_jit_vars->m_offset, err)) - return false; + if (entity->m_register_info) + { + // This is a register variable + + RegisterContext *reg_ctx = exe_ctx->GetRegisterContext(); + + if (!reg_ctx) + return false; + + if (!DoMaterializeOneRegister(dematerialize, *exe_ctx, *reg_ctx, *entity->m_register_info, m_materialized_location + member.m_jit_vars->m_offset, err)) + return false; + } + else + { + if (!member.m_jit_vars.get()) + return false; + + if (!DoMaterializeOneVariable(dematerialize, *exe_ctx, sym_ctx, member.m_name, member.m_user_type, m_materialized_location + member.m_jit_vars->m_offset, err)) + return false; + } } else if (persistent_variable) { @@ -917,6 +932,72 @@ return true; } +bool +ClangExpressionDeclMap::DoMaterializeOneRegister +( + bool dematerialize, + ExecutionContext &exe_ctx, + RegisterContext ®_ctx, + const lldb::RegisterInfo ®_info, + lldb::addr_t addr, + Error &err +) +{ + uint32_t register_number = reg_info.kinds[lldb::eRegisterKindLLDB]; + uint32_t register_byte_size = reg_info.byte_size; + + Error error; + + if (dematerialize) + { + DataBufferHeap register_data (register_byte_size, 0); + + Error error; + if (exe_ctx.process->ReadMemory (addr, register_data.GetBytes(), register_byte_size, error) != register_byte_size) + { + err.SetErrorStringWithFormat ("Couldn't read %s from the target: %s", reg_info.name, error.AsCString()); + return false; + } + + DataExtractor register_extractor (register_data.GetBytes(), register_byte_size, exe_ctx.process->GetByteOrder(), exe_ctx.process->GetAddressByteSize()); + + if (!reg_ctx.WriteRegisterBytes(register_number, register_extractor, 0)) + { + err.SetErrorStringWithFormat("Couldn't read %s", reg_info.name); + return false; + } + } + else + { + DataExtractor register_extractor; + + if (!reg_ctx.ReadRegisterBytes(register_number, register_extractor)) + { + err.SetErrorStringWithFormat("Couldn't read %s", reg_info.name); + return false; + } + + uint32_t register_offset = 0; + + const void *register_data = register_extractor.GetData(®ister_offset, register_byte_size); + + if (!register_data) + { + err.SetErrorStringWithFormat("Read but couldn't extract data for %s", reg_info.name); + return false; + } + + Error error; + if (exe_ctx.process->WriteMemory (addr, register_data, register_byte_size, error) != register_byte_size) + { + err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", error.AsCString()); + return false; + } + } + + return true; +} + Variable * ClangExpressionDeclMap::FindVariableInScope ( @@ -1121,7 +1202,20 @@ ClangExpressionVariable *pvar(m_persistent_vars->GetVariable(name)); if (pvar) + { AddOneVariable(context, pvar); + return; + } + + const char *reg_name(&name.GetCString()[1]); + + if (m_exe_ctx.GetRegisterContext()) + { + const lldb::RegisterInfo *reg_info(m_exe_ctx.GetRegisterContext()->GetRegisterInfoByName(reg_name)); + + if (reg_info) + AddOneRegister(context, reg_info); + } } lldb::TypeSP type_sp (m_sym_ctx.FindTypeByName (name)); @@ -1338,6 +1432,49 @@ } } +void +ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context, + const RegisterInfo *reg_info) +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + void *ast_type = ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(context.GetASTContext(), + reg_info->encoding, + reg_info->byte_size * 8); + + if (!ast_type) + { + log->Printf("Tried to add a type for %s, but couldn't get one", context.m_decl_name.getAsString().c_str()); + return; + } + + TypeFromParser parser_type(ast_type, + context.GetASTContext()); + + NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType()); + + ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(m_found_entities.CreateVariable())); + std::string decl_name(context.m_decl_name.getAsString()); + entity.m_name.SetCString (decl_name.c_str()); + entity.m_register_info = reg_info; + + entity.EnableParserVars(); + entity.m_parser_vars->m_parser_type = parser_type; + entity.m_parser_vars->m_named_decl = var_decl; + entity.m_parser_vars->m_llvm_value = NULL; + entity.m_parser_vars->m_lldb_value = NULL; + + if (log) + { + std::string var_decl_print_string; + llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string); + var_decl->print(var_decl_print_stream); + var_decl_print_stream.flush(); + + log->Printf("Added register %s, returned %s", context.m_decl_name.getAsString().c_str(), var_decl_print_string.c_str()); + } +} + clang::NamespaceDecl * ClangExpressionDeclMap::AddNamespace (NameSearchContext &context, const ClangNamespaceDecl &namespace_decl) { Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=120367&r1=120366&r2=120367&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Mon Nov 29 18:27:43 2010 @@ -29,6 +29,7 @@ m_name(), m_user_type (TypeFromUser(NULL, NULL)), m_store (NULL), + m_register_info (NULL), m_index (0), m_parser_vars(), m_jit_vars (), From jingham at apple.com Mon Nov 29 20:22:11 2010 From: jingham at apple.com (Jim Ingham) Date: Tue, 30 Nov 2010 02:22:11 -0000 Subject: [Lldb-commits] [lldb] r120386 - in /lldb/trunk: include/lldb/Expression/ include/lldb/Target/ lldb.xcodeproj/ source/API/ source/Commands/ source/Expression/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Target/ Message-ID: <20101130022211.C7C3F2A6C12D@llvm.org> Author: jingham Date: Mon Nov 29 20:22:11 2010 New Revision: 120386 URL: http://llvm.org/viewvc/llvm-project?rev=120386&view=rev Log: Moved the code in ClangUserExpression that set up & ran the thread plan with timeouts, and restarting with all threads into a utility function in Process. This required a bunch of renaming. Added a ThreadPlanCallUserExpression that differs from ThreadPlanCallFunction in that it holds onto a shared pointer to its ClangUserExpression so that can't go away before the thread plan is done using it. Fixed the stop message when you hit a breakpoint while running a user expression so it is more obvious what has happened. Added: lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/ThreadPlan.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/Commands/CommandObjectCall.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/ThreadPlan.cpp lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangFunction.h Mon Nov 29 20:22:11 2010 @@ -21,9 +21,7 @@ #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Expression/ClangExpression.h" - -// Right now, this is just a toy. It calls a set function, with fixed -// values. +#include "lldb/Target/Process.h" namespace lldb_private { @@ -68,15 +66,6 @@ { friend class ASTStructExtractor; public: - enum ExecutionResults - { - eExecutionSetupError, - eExecutionCompleted, - eExecutionDiscarded, - eExecutionInterrupted, - eExecutionTimedOut - }; - //------------------------------------------------------------------ /// Constructor /// @@ -275,15 +264,16 @@ /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ - static ExecutionResults ExecuteFunction (ExecutionContext &exe_ctx, - lldb::addr_t function_address, - lldb::addr_t &void_arg, - bool stop_others, - bool try_all_threads, - bool discard_on_error, - uint32_t single_thread_timeout_usec, - Stream &errors, - lldb::addr_t* this_arg = 0); + static Process::ExecutionResults + ExecuteFunction (ExecutionContext &exe_ctx, + lldb::addr_t function_address, + lldb::addr_t &void_arg, + bool stop_others, + bool try_all_threads, + bool discard_on_error, + uint32_t single_thread_timeout_usec, + Stream &errors, + lldb::addr_t* this_arg = 0); //------------------------------------------------------------------ /// Run the function this ClangFunction was created with. @@ -304,9 +294,10 @@ /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ - ExecutionResults ExecuteFunction(ExecutionContext &exe_ctx, - Stream &errors, - Value &results); + Process::ExecutionResults + ExecuteFunction(ExecutionContext &exe_ctx, + Stream &errors, + Value &results); //------------------------------------------------------------------ /// Run the function this ClangFunction was created with. @@ -329,9 +320,10 @@ /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ - ExecutionResults ExecuteFunction(ExecutionContext &exe_ctx, - Stream &errors, bool stop_others, - Value &results); + Process::ExecutionResults + ExecuteFunction(ExecutionContext &exe_ctx, + Stream &errors, bool stop_others, + Value &results); //------------------------------------------------------------------ /// Run the function this ClangFunction was created with. @@ -358,11 +350,12 @@ /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ - ExecutionResults ExecuteFunction(ExecutionContext &exe_ctx, - Stream &errors, - uint32_t single_thread_timeout_usec, - bool try_all_threads, - Value &results); + Process::ExecutionResults + ExecuteFunction(ExecutionContext &exe_ctx, + Stream &errors, + uint32_t single_thread_timeout_usec, + bool try_all_threads, + Value &results); //------------------------------------------------------------------ /// Run the function this ClangFunction was created with. @@ -397,14 +390,15 @@ /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ - ExecutionResults ExecuteFunction(ExecutionContext &exe_ctx, - lldb::addr_t *args_addr_ptr, - Stream &errors, - bool stop_others, - uint32_t single_thread_timeout_usec, - bool try_all_threads, - bool discard_on_error, - Value &results); + Process::ExecutionResults + ExecuteFunction(ExecutionContext &exe_ctx, + lldb::addr_t *args_addr_ptr, + Stream &errors, + bool stop_others, + uint32_t single_thread_timeout_usec, + bool try_all_threads, + bool discard_on_error, + Value &results); //------------------------------------------------------------------ /// [static] Get a thread plan to run a function. Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon Nov 29 20:22:11 2010 @@ -26,6 +26,7 @@ #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangExpressionVariable.h" #include "lldb/Symbol/TaggedASTType.h" +#include "lldb/Target/Process.h" #include "llvm/ExecutionEngine/JITMemoryManager.h" @@ -44,6 +45,8 @@ class ClangUserExpression : public ClangExpression { public: + typedef lldb::SharedPtr::Type ClangUserExpressionSP; + //------------------------------------------------------------------ /// Constructor /// @@ -100,18 +103,25 @@ /// If true, and the execution stops before completion, we unwind the /// function call, and return the program state to what it was before the /// execution. If false, we leave the program in the stopped state. + /// @param[in] shared_ptr_to_me + /// This is a shared pointer to this ClangUserExpression. This is + /// needed because Execute can push a thread plan that will hold onto + /// the ClangUserExpression for an unbounded period of time. So you + /// need to give the thread plan a reference to this object that can + /// keep it alive. /// /// @param[in] result /// A pointer to direct at the persistent variable in which the /// expression's result is stored. /// /// @return - /// True on success; false otherwise. + /// A Process::Execution results value. //------------------------------------------------------------------ - bool + Process::ExecutionResults Execute (Stream &error_stream, ExecutionContext &exe_ctx, bool discard_on_error, + ClangUserExpressionSP &shared_ptr_to_me, ClangExpressionVariable *&result); ThreadPlan * @@ -222,12 +232,19 @@ /// @param[in] expr_prefix /// If non-NULL, a C string containing translation-unit level /// definitions to be included when the expression is parsed. + /// + /// @param[in/out] result_valobj_sp + /// If execution is successful, the result valobj is placed here. + /// + /// @result + /// A Process::ExecutionResults value. eExecutionCompleted for success. //------------------------------------------------------------------ - static lldb::ValueObjectSP + static Process::ExecutionResults Evaluate (ExecutionContext &exe_ctx, bool discard_on_error, const char *expr_cstr, - const char *expr_prefix); + const char *expr_prefix, + lldb::ValueObjectSP &result_valobj_sp); private: //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon Nov 29 20:22:11 2010 @@ -255,6 +255,17 @@ eBroadcastInternalStateControlResume = (1<<2) }; + // We can execute Thread Plans on one thread with various fall-back modes (try other threads after timeout, etc.) + // This enum gives the result of thread plan executions. + typedef enum ExecutionResults + { + eExecutionSetupError, + eExecutionCompleted, + eExecutionDiscarded, + eExecutionInterrupted, + eExecutionTimedOut + } ExecutionResults; + //------------------------------------------------------------------ /// A notification structure that can be used by clients to listen /// for changes in a process's lifetime. @@ -1019,8 +1030,12 @@ //------------------------------------------------------------------ /// Halts a running process. /// - /// DoHalt should consume any process events that were delivered in - /// the process of implementing the halt. + /// DoHalt must produce one and only one stop StateChanged event if it actually + /// stops the process. If the stop happens through some natural event (for + /// instance a SIGSTOP), then forwarding that event will do. Otherwise, you must + /// generate the event manually. Note also, the private event thread is stopped when + /// DoHalt is run to prevent the events generated while halting to trigger + /// other state changes before the halt is complete. /// /// @param[out] caused_stop /// If true, then this Halt caused the stop, otherwise, the @@ -1167,6 +1182,18 @@ //------------------------------------------------------------------ lldb::StateType GetState (); + + ExecutionResults + RunThreadPlan (ExecutionContext &exe_ctx, + lldb::ThreadPlanSP &thread_plan_sp, + bool stop_others, + bool try_all_threads, + bool discard_on_error, + uint32_t single_thread_timeout_usec, + Stream &errors); + + static const char * + ExecutionResultAsCString (ExecutionResults result); protected: friend class CommandObjectProcessLaunch; Modified: lldb/trunk/include/lldb/Target/ThreadPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlan.h?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlan.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlan.h Mon Nov 29 20:22:11 2010 @@ -82,6 +82,11 @@ // Next the "StopOthers" method of all the threads are polled, and if one thread's Current plan // returns "true" then only that thread gets to run. If more than one returns "true" the threads that want to run solo // get run one by one round robin fashion. Otherwise all are let to run. +// +// Note, the way StopOthers is implemented, the base class implementation just asks the previous plan. So if your plan +// has no opinion about whether it should run stopping others or not, just don't implement StopOthers, and the parent +// will be asked. +// // Finally, for each thread that is running, it run state is set to the return of RunState from the // thread's Current plan. // @@ -240,6 +245,7 @@ /// /// @param[in] error /// A stream to which to print some reason why the plan could not be created. + /// Can be NULL. /// /// @return /// \b true if the plan should be queued, \b false otherwise. @@ -281,6 +287,9 @@ virtual lldb::Vote ShouldReportRun (Event *event_ptr); + virtual void + SetStopOthers (bool new_value); + virtual bool StopOthers (); Added: lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h?rev=120386&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h (added) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h Mon Nov 29 20:22:11 2010 @@ -0,0 +1,59 @@ +//===-- ThreadPlanCallUserExpression.h --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_ThreadPlanCallUserExpression_h_ +#define liblldb_ThreadPlanCallUserExpression_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/Expression/ClangUserExpression.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlan.h" +#include "lldb/Target/ThreadPlanCallFunction.h" + +namespace lldb_private { + +class ThreadPlanCallUserExpression : public ThreadPlanCallFunction +{ +public: + ThreadPlanCallUserExpression (Thread &thread, + Address &function, + lldb::addr_t arg, + bool stop_other_threads, + bool discard_on_error, + lldb::addr_t *this_arg, + ClangUserExpression::ClangUserExpressionSP &user_expression_sp); + + virtual + ~ThreadPlanCallUserExpression (); + + virtual void + GetDescription (Stream *s, lldb::DescriptionLevel level); + + virtual void + WillPop () + { + if (m_user_expression_sp) + m_user_expression_sp.reset(); + } + +protected: +private: + ClangUserExpression::ClangUserExpressionSP m_user_expression_sp; // This is currently just used to ensure the + // User expression the initiated this ThreadPlan + // lives as long as the thread plan does. + DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallUserExpression); +}; + +} // namespace lldb_private + +#endif // liblldb_ThreadPlanCallUserExpression_h_ Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Nov 29 20:22:11 2010 @@ -341,6 +341,8 @@ 4C61978E12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C61978A12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp */; }; 4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C61978B12823D4300FAFFCC /* AppleObjCRuntimeV1.h */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; + 4C7CF7E41295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C7CF7E31295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h */; }; + 4C7CF7E61295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7CF7E51295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp */; }; 4CA9637B11B6E99A00780E28 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; }; 4CB4430C12491DDA00C13DC2 /* LanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CB4430A12491DDA00C13DC2 /* LanguageRuntime.cpp */; }; 4CB4436C124944B000C13DC2 /* ItaniumABILanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CB4436A124944B000C13DC2 /* ItaniumABILanguageRuntime.cpp */; }; @@ -981,6 +983,8 @@ 4C61978A12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCRuntimeV1.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp; sourceTree = ""; }; 4C61978B12823D4300FAFFCC /* AppleObjCRuntimeV1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCRuntimeV1.h; path = LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h; sourceTree = ""; }; 4C74CB6212288704006A8171 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = ""; }; + 4C7CF7E31295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanCallUserExpression.h; path = include/lldb/Target/ThreadPlanCallUserExpression.h; sourceTree = ""; }; + 4C7CF7E51295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanCallUserExpression.cpp; path = source/Target/ThreadPlanCallUserExpression.cpp; sourceTree = ""; }; 4C98D3DA118FB96F00E575D0 /* ClangFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangFunction.cpp; path = source/Expression/ClangFunction.cpp; sourceTree = ""; }; 4C98D3DB118FB96F00E575D0 /* RecordingMemoryManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecordingMemoryManager.cpp; path = source/Expression/RecordingMemoryManager.cpp; sourceTree = ""; }; 4C98D3E0118FB98F00E575D0 /* ClangFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangFunction.h; path = include/lldb/Expression/ClangFunction.h; sourceTree = ""; }; @@ -2061,6 +2065,8 @@ 260C847110F50EFC00BB2B04 /* ThreadPlanBase.cpp */, 49EC3E9C118F90D400B1265E /* ThreadPlanCallFunction.h */, 49EC3E98118F90AC00B1265E /* ThreadPlanCallFunction.cpp */, + 4C7CF7E31295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h */, + 4C7CF7E51295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp */, 4C43DEF9110641F300E55CBF /* ThreadPlanShouldStopHere.h */, 4C43DEFA110641F300E55CBF /* ThreadPlanShouldStopHere.cpp */, 260C848010F50F0A00BB2B04 /* ThreadPlanStepInstruction.h */, @@ -2381,6 +2387,7 @@ 4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */, 4CC2A14D128C7409001531C4 /* ThreadPlanTracer.h in Headers */, 266A42D8128E40040090CF7C /* ClangNamespaceDecl.h in Headers */, + 4C7CF7E41295E10E00B4FBB5 /* ThreadPlanCallUserExpression.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2452,7 +2459,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, @@ -2885,6 +2891,7 @@ 4C61978E12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp in Sources */, 4CC2A149128C73ED001531C4 /* ThreadPlanTracer.cpp in Sources */, 266A42D6128E3FFB0090CF7C /* ClangNamespaceDecl.cpp in Sources */, + 4C7CF7E61295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Mon Nov 29 20:22:11 2010 @@ -577,7 +577,7 @@ if (exe_ctx.target) prefix = exe_ctx.target->GetExpressionPrefixContentsAsCString(); - *expr_result = ClangUserExpression::Evaluate (exe_ctx, discard_on_error, expr, prefix); + ClangUserExpression::Evaluate (exe_ctx, discard_on_error, expr, prefix, *expr_result); } if (log) Modified: lldb/trunk/source/Commands/CommandObjectCall.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCall.cpp?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCall.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCall.cpp Mon Nov 29 20:22:11 2010 @@ -292,20 +292,20 @@ } } - ClangFunction::ExecutionResults return_status; + Process::ExecutionResults return_status; Value return_value; bool stop_others = true; return_status = clang_fun.ExecuteFunction(exe_ctx, errors, stop_others, NULL, return_value); // Now figure out what to do with the return value. - if (return_status == ClangFunction::eExecutionSetupError) + if (return_status == Process::eExecutionSetupError) { result.AppendErrorWithFormat("Error setting up function execution: '%s'.\n", errors.GetData()); result.SetStatus (eReturnStatusFailed); return false; } - else if (return_status != ClangFunction::eExecutionCompleted) + else if (return_status != Process::eExecutionCompleted) { result.AppendWarningWithFormat("Interrupted while calling function: '%s'.\n", errors.GetData()); result.SetStatus(eReturnStatusSuccessFinishNoResult); Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Nov 29 20:22:11 2010 @@ -13,6 +13,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "CommandObjectThread.h" // For DisplayThreadInfo. #include "lldb/Interpreter/Args.h" #include "lldb/Core/Value.h" #include "lldb/Core/InputReader.h" @@ -242,7 +243,8 @@ if (m_exe_ctx.target) prefix = m_exe_ctx.target->GetExpressionPrefixContentsAsCString(); - lldb::ValueObjectSP result_valobj_sp (ClangUserExpression::Evaluate (m_exe_ctx, m_options.unwind_on_error, expr, prefix)); + lldb::ValueObjectSP result_valobj_sp; + Process::ExecutionResults execution_results = ClangUserExpression::Evaluate (m_exe_ctx, m_options.unwind_on_error, expr, prefix, result_valobj_sp); assert (result_valobj_sp.get()); if (result_valobj_sp->GetError().Success()) { @@ -267,6 +269,16 @@ else { error_stream.PutCString(result_valobj_sp->GetError().AsCString()); + // If we've been interrupted, display state information. + if (execution_results == Process::eExecutionInterrupted && !m_options.unwind_on_error) + { + if (m_exe_ctx.thread) + lldb_private::DisplayThreadInfo (m_interpreter, result->GetOutputStream(), m_exe_ctx.thread, false, true); + else + { + lldb_private::DisplayThreadsInfo (m_interpreter, &m_exe_ctx, *result, true, true); + } + } if (result) result->SetStatus (eReturnStatusFailed); } Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Mon Nov 29 20:22:11 2010 @@ -275,7 +275,7 @@ Error error; using namespace clang; - ExecutionResults return_value = eExecutionSetupError; + Process::ExecutionResults return_value = Process::eExecutionSetupError; Process *process = exe_ctx.process; @@ -439,13 +439,13 @@ exe_ctx.process->DeallocateMemory(args_addr); } -ClangFunction::ExecutionResults +Process::ExecutionResults ClangFunction::ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, Value &results) { return ExecuteFunction (exe_ctx, errors, 1000, true, results); } -ClangFunction::ExecutionResults +Process::ExecutionResults ClangFunction::ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, bool stop_others, Value &results) { const bool try_all_threads = false; @@ -453,7 +453,7 @@ return ExecuteFunction (exe_ctx, NULL, errors, stop_others, NULL, try_all_threads, discard_on_error, results); } -ClangFunction::ExecutionResults +Process::ExecutionResults ClangFunction::ExecuteFunction( ExecutionContext &exe_ctx, Stream &errors, @@ -468,7 +468,7 @@ } // This is the static function -ClangFunction::ExecutionResults +Process::ExecutionResults ClangFunction::ExecuteFunction ( ExecutionContext &exe_ctx, lldb::addr_t function_address, @@ -480,259 +480,19 @@ Stream &errors, lldb::addr_t *this_arg) { - // Save this value for restoration of the execution context after we run - uint32_t tid = exe_ctx.thread->GetIndexID(); - - // N.B. Running the target may unset the currently selected thread and frame. We don't want to do that either, - // so we should arrange to reset them as well. - - lldb::ThreadSP selected_thread_sp = exe_ctx.process->GetThreadList().GetSelectedThread(); - lldb::StackFrameSP selected_frame_sp; - - uint32_t selected_tid; - if (selected_thread_sp != NULL) - { - selected_tid = selected_thread_sp->GetIndexID(); - selected_frame_sp = selected_thread_sp->GetSelectedFrame(); - } - else - { - selected_tid = LLDB_INVALID_THREAD_ID; - } - - ClangFunction::ExecutionResults return_value = eExecutionSetupError; lldb::ThreadPlanSP call_plan_sp(ClangFunction::GetThreadPlanToCallFunction(exe_ctx, function_address, void_arg, errors, stop_others, discard_on_error, this_arg)); - - ThreadPlanCallFunction *call_plan_ptr = static_cast (call_plan_sp.get()); - if (call_plan_sp == NULL) - return eExecutionSetupError; + return Process::eExecutionSetupError; call_plan_sp->SetPrivate(true); - exe_ctx.thread->QueueThreadPlan(call_plan_sp, true); - - Listener listener("ClangFunction temporary listener"); - exe_ctx.process->HijackProcessEvents(&listener); - - Error resume_error = exe_ctx.process->Resume (); - if (!resume_error.Success()) - { - errors.Printf("Error resuming inferior: \"%s\".\n", resume_error.AsCString()); - exe_ctx.process->RestoreProcessEvents(); - return eExecutionSetupError; - } - - // We need to call the function synchronously, so spin waiting for it to return. - // If we get interrupted while executing, we're going to lose our context, and - // won't be able to gather the result at this point. - // We set the timeout AFTER the resume, since the resume takes some time and we - // don't want to charge that to the timeout. - - TimeValue* timeout_ptr = NULL; - TimeValue real_timeout; - - if (single_thread_timeout_usec != 0) - { - real_timeout = TimeValue::Now(); - real_timeout.OffsetWithMicroSeconds(single_thread_timeout_usec); - timeout_ptr = &real_timeout; - } - - lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); - while (1) - { - lldb::EventSP event_sp; - lldb::StateType stop_state = lldb::eStateInvalid; - // Now wait for the process to stop again: - bool got_event = listener.WaitForEvent (timeout_ptr, event_sp); - - if (!got_event) - { - // Right now this is the only way to tell we've timed out... - // We should interrupt the process here... - // Not really sure what to do if Halt fails here... - if (log) - if (try_all_threads) - log->Printf ("Running function with timeout: %d timed out, trying with all threads enabled.", - single_thread_timeout_usec); - else - log->Printf ("Running function with timeout: %d timed out, abandoning execution.", - single_thread_timeout_usec); - - if (exe_ctx.process->Halt().Success()) - { - timeout_ptr = NULL; - if (log) - log->Printf ("Halt succeeded."); - - // Between the time that we got the timeout and the time we halted, but target - // might have actually completed the plan. If so, we're done. Note, I call WFE here with a short - // timeout to - got_event = listener.WaitForEvent(NULL, event_sp); - - if (got_event) - { - stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); - if (log) - { - log->Printf ("Stopped with event: %s", StateAsCString(stop_state)); - if (stop_state == lldb::eStateStopped && Process::ProcessEventData::GetInterruptedFromEvent(event_sp.get())) - log->Printf (" Event was the Halt interruption event."); - } - - if (exe_ctx.thread->IsThreadPlanDone (call_plan_sp.get())) - { - if (log) - log->Printf ("Even though we timed out, the call plan was done. Exiting wait loop."); - return_value = eExecutionCompleted; - break; - } - - if (try_all_threads - && (stop_state == lldb::eStateStopped && Process::ProcessEventData::GetInterruptedFromEvent (event_sp.get()))) - { - - call_plan_ptr->SetStopOthers (false); - if (log) - log->Printf ("About to resume."); - - exe_ctx.process->Resume(); - continue; - } - else - { - exe_ctx.process->RestoreProcessEvents (); - return eExecutionInterrupted; - } - } - } - } - - stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); - if (log) - log->Printf("Got event: %s.", StateAsCString(stop_state)); - - if (stop_state == lldb::eStateRunning || stop_state == lldb::eStateStepping) - continue; - - if (exe_ctx.thread->IsThreadPlanDone (call_plan_sp.get())) - { - return_value = eExecutionCompleted; - break; - } - else if (exe_ctx.thread->WasThreadPlanDiscarded (call_plan_sp.get())) - { - return_value = eExecutionDiscarded; - break; - } - else - { - if (log) - { - StreamString s; - event_sp->Dump (&s); - StreamString ts; - - const char *event_explanation; - - do - { - const Process::ProcessEventData *event_data = Process::ProcessEventData::GetEventDataFromEvent (event_sp.get()); - - if (!event_data) - { - event_explanation = ""; - break; - } - - Process *process = event_data->GetProcessSP().get(); - - if (!process) - { - event_explanation = ""; - break; - } - - ThreadList &thread_list = process->GetThreadList(); - - uint32_t num_threads = thread_list.GetSize(); - uint32_t thread_index; - - ts.Printf("<%u threads> ", num_threads); - - for (thread_index = 0; - thread_index < num_threads; - ++thread_index) - { - Thread *thread = thread_list.GetThreadAtIndex(thread_index).get(); - - if (!thread) - { - ts.Printf(" "); - continue; - } - - ts.Printf("<"); - RegisterContext *register_context = thread->GetRegisterContext(); - - if (register_context) - ts.Printf("[ip 0x%llx] ", register_context->GetPC()); - else - ts.Printf("[ip unknown] "); - - lldb::StopInfoSP stop_info_sp = thread->GetStopInfo(); - if (stop_info_sp) - { - const char *stop_desc = stop_info_sp->GetDescription(); - if (stop_desc) - ts.PutCString (stop_desc); - } - ts.Printf(">"); - } - - event_explanation = ts.GetData(); - } while (0); - - if (log) - log->Printf("Execution interrupted: %s %s", s.GetData(), event_explanation); - } - - if (discard_on_error && call_plan_sp) - { - exe_ctx.thread->DiscardThreadPlansUpToPlan (call_plan_sp); - } - return_value = eExecutionInterrupted; - break; - } - } - - if (exe_ctx.process) - exe_ctx.process->RestoreProcessEvents (); - - // Thread we ran the function in may have gone away because we ran the target - // Check that it's still there. - exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(tid, true).get(); - if (exe_ctx.thread) - exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex(0).get(); - - // Also restore the current process'es selected frame & thread, since this function calling may - // be done behind the user's back. - - if (selected_tid != LLDB_INVALID_THREAD_ID) - { - if (exe_ctx.process->GetThreadList().SetSelectedThreadByIndexID (selected_tid)) - { - // We were able to restore the selected thread, now restore the frame: - exe_ctx.process->GetThreadList().GetSelectedThread()->SetSelectedFrame(selected_frame_sp.get()); - } - } - return return_value; + return exe_ctx.process->RunThreadPlan (exe_ctx, call_plan_sp, stop_others, try_all_threads, discard_on_error, + single_thread_timeout_usec, errors); } -ClangFunction::ExecutionResults +Process::ExecutionResults ClangFunction::ExecuteFunction( ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr, @@ -744,7 +504,7 @@ Value &results) { using namespace clang; - ExecutionResults return_value = eExecutionSetupError; + Process::ExecutionResults return_value = Process::eExecutionSetupError; lldb::addr_t args_addr; @@ -754,12 +514,12 @@ args_addr = LLDB_INVALID_ADDRESS; if (CompileFunction(errors) != 0) - return eExecutionSetupError; + return Process::eExecutionSetupError; if (args_addr == LLDB_INVALID_ADDRESS) { if (!InsertFunction(exe_ctx, args_addr, errors)) - return eExecutionSetupError; + return Process::eExecutionSetupError; } return_value = ClangFunction::ExecuteFunction(exe_ctx, m_wrapper_function_addr, args_addr, stop_others, @@ -768,7 +528,7 @@ if (args_addr_ptr != NULL) *args_addr_ptr = args_addr; - if (return_value != eExecutionCompleted) + if (return_value != Process::eExecutionCompleted) return return_value; FetchFunctionResults(exe_ctx, args_addr, results); @@ -776,7 +536,7 @@ if (args_addr_ptr == NULL) DeallocateFunctionResults(exe_ctx, args_addr); - return eExecutionCompleted; + return Process::eExecutionCompleted; } clang::ASTConsumer * Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Nov 29 20:22:11 2010 @@ -33,6 +33,8 @@ #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "lldb/Target/ThreadPlan.h" +#include "lldb/Target/ThreadPlanCallUserExpression.h" using namespace lldb_private; @@ -318,6 +320,9 @@ PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr); + // FIXME: This should really return a ThreadPlanCallUserExpression, in order to make sure that we don't release the + // ClangUserExpression resources before the thread plan finishes execution in the target. But because we are + // forcing unwind_on_error to be true here, in practical terms that can't happen. return ClangFunction::GetThreadPlanToCallFunction (exe_ctx, m_jit_addr, struct_address, @@ -342,10 +347,11 @@ return true; } -bool +Process::ExecutionResults ClangUserExpression::Execute (Stream &error_stream, ExecutionContext &exe_ctx, bool discard_on_error, + ClangUserExpression::ClangUserExpressionSP &shared_ptr_to_me, ClangExpressionVariable *&result) { if (m_dwarf_opcodes.get()) @@ -354,7 +360,7 @@ error_stream.Printf("We don't currently support executing DWARF expressions"); - return false; + return Process::eExecutionSetupError; } else if (m_jit_addr != LLDB_INVALID_ADDRESS) { @@ -366,50 +372,46 @@ const bool stop_others = true; const bool try_all_threads = true; - ClangFunction::ExecutionResults execution_result = - ClangFunction::ExecuteFunction (exe_ctx, - m_jit_addr, - struct_address, - stop_others, - try_all_threads, - discard_on_error, - 10000000, - error_stream, - (m_needs_object_ptr ? &object_ptr : NULL)); - if (execution_result != ClangFunction::eExecutionCompleted) + Address wrapper_address (NULL, m_jit_addr); + lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (*(exe_ctx.thread), wrapper_address, struct_address, + stop_others, discard_on_error, + (m_needs_object_ptr ? &object_ptr : NULL), + shared_ptr_to_me)); + if (call_plan_sp == NULL || !call_plan_sp->ValidatePlan (NULL)) + return Process::eExecutionSetupError; + + call_plan_sp->SetPrivate(true); + + uint32_t single_thread_timeout_usec = 10000000; + Process::ExecutionResults execution_result = + exe_ctx.process->RunThreadPlan (exe_ctx, call_plan_sp, stop_others, try_all_threads, discard_on_error, + single_thread_timeout_usec, error_stream); + + if (execution_result == Process::eExecutionInterrupted) { - const char *result_name; - - switch (execution_result) - { - case ClangFunction::eExecutionCompleted: - result_name = "eExecutionCompleted"; - break; - case ClangFunction::eExecutionDiscarded: - result_name = "eExecutionDiscarded"; - break; - case ClangFunction::eExecutionInterrupted: - result_name = "eExecutionInterrupted"; - break; - case ClangFunction::eExecutionSetupError: - result_name = "eExecutionSetupError"; - break; - case ClangFunction::eExecutionTimedOut: - result_name = "eExecutionTimedOut"; - break; - } - - error_stream.Printf ("Couldn't execute function; result was %s\n", result_name); - return false; + if (discard_on_error) + error_stream.Printf ("Expression execution was interrupted. The process has been returned to the state before execution."); + else + error_stream.Printf ("Expression execution was interrupted. The process has been left at the point where it was interrupted."); + + return execution_result; + } + else if (execution_result != Process::eExecutionCompleted) + { + error_stream.Printf ("Couldn't execute function; result was %s\n", Process::ExecutionResultAsCString (execution_result)); + return execution_result; } - return FinalizeJITExecution (error_stream, exe_ctx, result); + if (FinalizeJITExecution (error_stream, exe_ctx, result)) + return Process::eExecutionCompleted; + else + return Process::eExecutionSetupError; } else { error_stream.Printf("Expression can't be run; neither DWARF nor a JIT compiled function is present"); - return false; + return Process::eExecutionSetupError; } } @@ -422,18 +424,24 @@ return *m_dwarf_opcodes.get(); } -lldb::ValueObjectSP +Process::ExecutionResults ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, bool discard_on_error, const char *expr_cstr, - const char *expr_prefix) + const char *expr_prefix, + lldb::ValueObjectSP &result_valobj_sp) { Error error; - lldb::ValueObjectSP result_valobj_sp; + Process::ExecutionResults execution_results = Process::eExecutionSetupError; if (exe_ctx.process == NULL) - return result_valobj_sp; - + { + error.SetErrorString ("Must have a process to evaluate expressions."); + + result_valobj_sp.reset (new ValueObjectConstResult (error)); + return Process::eExecutionSetupError; + } + if (!exe_ctx.process->GetDynamicCheckers()) { DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions(); @@ -448,17 +456,17 @@ error.SetErrorString (install_errors.GetString().c_str()); result_valobj_sp.reset (new ValueObjectConstResult (error)); - return result_valobj_sp; + return Process::eExecutionSetupError; } exe_ctx.process->SetDynamicCheckers(dynamic_checkers); } - ClangUserExpression user_expression (expr_cstr, expr_prefix); - + ClangUserExpressionSP user_expression_sp (new ClangUserExpression (expr_cstr, expr_prefix)); + StreamString error_stream; - if (!user_expression.Parse (error_stream, exe_ctx, TypeFromUser(NULL, NULL))) + if (!user_expression_sp->Parse (error_stream, exe_ctx, TypeFromUser(NULL, NULL))) { if (error_stream.GetString().empty()) error.SetErrorString ("expression failed to parse, unknown error"); @@ -471,7 +479,12 @@ error_stream.GetString().clear(); - if (!user_expression.Execute (error_stream, exe_ctx, discard_on_error, expr_result)) + execution_results = user_expression_sp->Execute (error_stream, + exe_ctx, + discard_on_error, + user_expression_sp, + expr_result); + if (execution_results != Process::eExecutionCompleted) { if (error_stream.GetString().empty()) error.SetErrorString ("expression failed to execute, unknown error"); @@ -499,5 +512,5 @@ if (result_valobj_sp.get() == NULL) result_valobj_sp.reset (new ValueObjectConstResult (error)); - return result_valobj_sp; + return execution_results; } Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Mon Nov 29 20:22:11 2010 @@ -122,9 +122,9 @@ bool try_all_threads = true; bool stop_others = true; - ClangFunction::ExecutionResults results + Process::ExecutionResults results = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, stop_others, 1000000, try_all_threads, unwind_on_error, ret); - if (results != ClangFunction::eExecutionCompleted) + if (results != Process::eExecutionCompleted) { str.Printf("Error evaluating Print Object function: %d.\n", results); return false; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Nov 29 20:22:11 2010 @@ -524,7 +524,8 @@ image_spec.GetPath(path, sizeof(path)); expr.Printf("dlopen (\"%s\", 2)", path); const char *prefix = "extern \"C\" void* dlopen (const char *path, int mode);\n"; - lldb::ValueObjectSP result_valobj_sp (ClangUserExpression::Evaluate (exe_ctx, unwind_on_error, expr.GetData(), prefix)); + lldb::ValueObjectSP result_valobj_sp; + ClangUserExpression::Evaluate (exe_ctx, unwind_on_error, expr.GetData(), prefix, result_valobj_sp); if (result_valobj_sp->GetError().Success()) { Scalar scalar; @@ -588,7 +589,8 @@ StreamString expr; expr.Printf("dlclose ((void *)0x%llx)", image_addr); const char *prefix = "extern \"C\" int dlclose(void* handle);\n"; - lldb::ValueObjectSP result_valobj_sp (ClangUserExpression::Evaluate (exe_ctx, unwind_on_error, expr.GetData(), prefix)); + lldb::ValueObjectSP result_valobj_sp; + ClangUserExpression::Evaluate (exe_ctx, unwind_on_error, expr.GetData(), prefix, result_valobj_sp); if (result_valobj_sp->GetError().Success()) { Scalar scalar; @@ -1502,7 +1504,8 @@ // Post any event we might have consumed. If all goes well, we will have // stopped the process, intercepted the event and set the interrupted - // bool in the event. + // bool in the event. Post it to the private event queue and that will end up + // correctly setting the state. if (event_sp) m_private_state_broadcaster.BroadcastEvent(event_sp); @@ -2281,6 +2284,284 @@ } } +Process::ExecutionResults +Process::RunThreadPlan (ExecutionContext &exe_ctx, + lldb::ThreadPlanSP &thread_plan_sp, + bool stop_others, + bool try_all_threads, + bool discard_on_error, + uint32_t single_thread_timeout_usec, + Stream &errors) +{ + ExecutionResults return_value = eExecutionSetupError; + + // Save this value for restoration of the execution context after we run + uint32_t tid = exe_ctx.thread->GetIndexID(); + + // N.B. Running the target may unset the currently selected thread and frame. We don't want to do that either, + // so we should arrange to reset them as well. + + lldb::ThreadSP selected_thread_sp = exe_ctx.process->GetThreadList().GetSelectedThread(); + lldb::StackFrameSP selected_frame_sp; + + uint32_t selected_tid; + if (selected_thread_sp != NULL) + { + selected_tid = selected_thread_sp->GetIndexID(); + selected_frame_sp = selected_thread_sp->GetSelectedFrame(); + } + else + { + selected_tid = LLDB_INVALID_THREAD_ID; + } + + exe_ctx.thread->QueueThreadPlan(thread_plan_sp, true); + + Listener listener("ClangFunction temporary listener"); + exe_ctx.process->HijackProcessEvents(&listener); + + Error resume_error = exe_ctx.process->Resume (); + if (!resume_error.Success()) + { + errors.Printf("Error resuming inferior: \"%s\".\n", resume_error.AsCString()); + exe_ctx.process->RestoreProcessEvents(); + return Process::eExecutionSetupError; + } + + // We need to call the function synchronously, so spin waiting for it to return. + // If we get interrupted while executing, we're going to lose our context, and + // won't be able to gather the result at this point. + // We set the timeout AFTER the resume, since the resume takes some time and we + // don't want to charge that to the timeout. + + TimeValue* timeout_ptr = NULL; + TimeValue real_timeout; + + if (single_thread_timeout_usec != 0) + { + real_timeout = TimeValue::Now(); + real_timeout.OffsetWithMicroSeconds(single_thread_timeout_usec); + timeout_ptr = &real_timeout; + } + + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + while (1) + { + lldb::EventSP event_sp; + lldb::StateType stop_state = lldb::eStateInvalid; + // Now wait for the process to stop again: + bool got_event = listener.WaitForEvent (timeout_ptr, event_sp); + + if (!got_event) + { + // Right now this is the only way to tell we've timed out... + // We should interrupt the process here... + // Not really sure what to do if Halt fails here... + if (log) + if (try_all_threads) + log->Printf ("Running function with timeout: %d timed out, trying with all threads enabled.", + single_thread_timeout_usec); + else + log->Printf ("Running function with timeout: %d timed out, abandoning execution.", + single_thread_timeout_usec); + + if (exe_ctx.process->Halt().Success()) + { + timeout_ptr = NULL; + if (log) + log->Printf ("Halt succeeded."); + + // Between the time that we got the timeout and the time we halted, but target + // might have actually completed the plan. If so, we're done. Note, I call WFE here with a short + // timeout to + got_event = listener.WaitForEvent(NULL, event_sp); + + if (got_event) + { + stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); + if (log) + { + log->Printf ("Stopped with event: %s", StateAsCString(stop_state)); + if (stop_state == lldb::eStateStopped && Process::ProcessEventData::GetInterruptedFromEvent(event_sp.get())) + log->Printf (" Event was the Halt interruption event."); + } + + if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) + { + if (log) + log->Printf ("Even though we timed out, the call plan was done. Exiting wait loop."); + return_value = Process::eExecutionCompleted; + break; + } + + if (try_all_threads + && (stop_state == lldb::eStateStopped && Process::ProcessEventData::GetInterruptedFromEvent (event_sp.get()))) + { + + thread_plan_sp->SetStopOthers (false); + if (log) + log->Printf ("About to resume."); + + exe_ctx.process->Resume(); + continue; + } + else + { + exe_ctx.process->RestoreProcessEvents (); + return Process::eExecutionInterrupted; + } + } + } + } + + stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); + if (log) + log->Printf("Got event: %s.", StateAsCString(stop_state)); + + if (stop_state == lldb::eStateRunning || stop_state == lldb::eStateStepping) + continue; + + if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) + { + return_value = Process::eExecutionCompleted; + break; + } + else if (exe_ctx.thread->WasThreadPlanDiscarded (thread_plan_sp.get())) + { + return_value = Process::eExecutionDiscarded; + break; + } + else + { + if (log) + { + StreamString s; + event_sp->Dump (&s); + StreamString ts; + + const char *event_explanation; + + do + { + const Process::ProcessEventData *event_data = Process::ProcessEventData::GetEventDataFromEvent (event_sp.get()); + + if (!event_data) + { + event_explanation = ""; + break; + } + + Process *process = event_data->GetProcessSP().get(); + + if (!process) + { + event_explanation = ""; + break; + } + + ThreadList &thread_list = process->GetThreadList(); + + uint32_t num_threads = thread_list.GetSize(); + uint32_t thread_index; + + ts.Printf("<%u threads> ", num_threads); + + for (thread_index = 0; + thread_index < num_threads; + ++thread_index) + { + Thread *thread = thread_list.GetThreadAtIndex(thread_index).get(); + + if (!thread) + { + ts.Printf(" "); + continue; + } + + ts.Printf("<"); + RegisterContext *register_context = thread->GetRegisterContext(); + + if (register_context) + ts.Printf("[ip 0x%llx] ", register_context->GetPC()); + else + ts.Printf("[ip unknown] "); + + lldb::StopInfoSP stop_info_sp = thread->GetStopInfo(); + if (stop_info_sp) + { + const char *stop_desc = stop_info_sp->GetDescription(); + if (stop_desc) + ts.PutCString (stop_desc); + } + ts.Printf(">"); + } + + event_explanation = ts.GetData(); + } while (0); + + if (log) + log->Printf("Execution interrupted: %s %s", s.GetData(), event_explanation); + } + + if (discard_on_error && thread_plan_sp) + { + exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); + } + return_value = Process::eExecutionInterrupted; + break; + } + } + + if (exe_ctx.process) + exe_ctx.process->RestoreProcessEvents (); + + // Thread we ran the function in may have gone away because we ran the target + // Check that it's still there. + exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(tid, true).get(); + if (exe_ctx.thread) + exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex(0).get(); + + // Also restore the current process'es selected frame & thread, since this function calling may + // be done behind the user's back. + + if (selected_tid != LLDB_INVALID_THREAD_ID) + { + if (exe_ctx.process->GetThreadList().SetSelectedThreadByIndexID (selected_tid)) + { + // We were able to restore the selected thread, now restore the frame: + exe_ctx.process->GetThreadList().GetSelectedThread()->SetSelectedFrame(selected_frame_sp.get()); + } + } + + return return_value; +} + +const char * +Process::ExecutionResultAsCString (ExecutionResults result) +{ + const char *result_name; + + switch (result) + { + case Process::eExecutionCompleted: + result_name = "eExecutionCompleted"; + break; + case Process::eExecutionDiscarded: + result_name = "eExecutionDiscarded"; + break; + case Process::eExecutionInterrupted: + result_name = "eExecutionInterrupted"; + break; + case Process::eExecutionSetupError: + result_name = "eExecutionSetupError"; + break; + case Process::eExecutionTimedOut: + result_name = "eExecutionTimedOut"; + break; + } + return result_name; +} + //-------------------------------------------------------------- // class Process::SettingsController //-------------------------------------------------------------- Modified: lldb/trunk/source/Target/ThreadPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlan.cpp?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlan.cpp (original) +++ lldb/trunk/source/Target/ThreadPlan.cpp Mon Nov 29 20:22:11 2010 @@ -133,6 +133,13 @@ return prev_plan->StopOthers(); } +void +ThreadPlan::SetStopOthers (bool new_value) +{ + // SetStopOthers doesn't work up the hierarchy. You have to set the + // explicit ThreadPlan you want to affect. +} + bool ThreadPlan::WillResume (StateType resume_state, bool current_plan) { Added: lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp?rev=120386&view=auto ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp (added) +++ lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp Mon Nov 29 20:22:11 2010 @@ -0,0 +1,59 @@ +//===-- ThreadPlanCallUserExpression.cpp ------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Target/ThreadPlanCallUserExpression.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +#include "llvm/Support/MachO.h" +// Project includes +#include "lldb/lldb-private-log.h" +#include "lldb/Breakpoint/Breakpoint.h" +#include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Core/Address.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/Stream.h" +#include "lldb/Expression/ClangUserExpression.h" +#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/StopInfo.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanRunToAddress.h" + +using namespace lldb; +using namespace lldb_private; + +//---------------------------------------------------------------------- +// ThreadPlanCallUserExpression: Plan to call a single function +//---------------------------------------------------------------------- + +ThreadPlanCallUserExpression::ThreadPlanCallUserExpression (Thread &thread, + Address &function, + lldb::addr_t arg, + bool stop_other_threads, + bool discard_on_error, + lldb::addr_t *this_arg, + ClangUserExpression::ClangUserExpressionSP &user_expression_sp) : + ThreadPlanCallFunction (thread, function, arg, stop_other_threads, discard_on_error, this_arg), + m_user_expression_sp (user_expression_sp) +{ +} + +ThreadPlanCallUserExpression::~ThreadPlanCallUserExpression () +{ +} + +void +ThreadPlanCallUserExpression::GetDescription (Stream *s, lldb::DescriptionLevel level) +{ + ThreadPlanCallFunction::GetDescription (s, level); +} Modified: lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp Mon Nov 29 20:22:11 2010 @@ -168,9 +168,12 @@ if (m_break_ids[i] == LLDB_INVALID_BREAK_ID) { all_bps_good = false; - error->Printf ("Could not set breakpoint for address: "); - error->Address (m_addresses[i], sizeof (addr_t)); - error->Printf ("\n"); + if (error) + { + error->Printf ("Could not set breakpoint for address: "); + error->Address (m_addresses[i], sizeof (addr_t)); + error->Printf ("\n"); + } } } return all_bps_good; Modified: lldb/trunk/source/Target/ThreadPlanTestCondition.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTestCondition.cpp?rev=120386&r1=120385&r2=120386&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTestCondition.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Mon Nov 29 20:22:11 2010 @@ -64,7 +64,10 @@ void ThreadPlanTestCondition::GetDescription (Stream *s, lldb::DescriptionLevel level) { - + if (m_expression) + s->Printf("Thread plan to test condition: \"%s\".", m_expression->GetUserText()); + else + s->Printf("Thread plan to test unspecified condition."); } bool From johnny.chen at apple.com Tue Nov 30 11:35:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 30 Nov 2010 17:35:58 -0000 Subject: [Lldb-commits] [lldb] r120430 - /lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Message-ID: <20101130173558.3A0122A6C12D@llvm.org> Author: johnny Date: Tue Nov 30 11:35:58 2010 New Revision: 120430 URL: http://llvm.org/viewvc/llvm-project?rev=120430&view=rev Log: Entire test class skipped due to: rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199 Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=120430&r1=120429&r2=120430&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Tue Nov 30 11:35:58 2010 @@ -8,6 +8,7 @@ import lldb, lldbutil from lldbtest import * + at unittest2.skip("rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199") class BreakpointConditionsTestCase(TestBase): mydir = "breakpoint_conditions" From johnny.chen at apple.com Tue Nov 30 11:46:46 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 30 Nov 2010 17:46:46 -0000 Subject: [Lldb-commits] [lldb] r120431 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20101130174646.D538E2A6C12D@llvm.org> Author: johnny Date: Tue Nov 30 11:46:46 2010 New Revision: 120431 URL: http://llvm.org/viewvc/llvm-project?rev=120431&view=rev Log: Skipped two test cases due to seg fault while hadnling command: Application Specific Information: HandleCommand(command = "expression self->str") radar:8711052 Modified: lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=120431&r1=120430&r2=120431&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Tue Nov 30 11:46:46 2010 @@ -23,6 +23,7 @@ self.buildDwarf() self.break_on_objc_methods() + @unittest2.skip("rdar://problem/8711052") #@unittest2.expectedFailure # rdar://problem/8542091 # rdar://problem/8492646 @@ -31,6 +32,7 @@ self.buildDsym() self.data_type_and_expr_objc() + @unittest2.skip("rdar://problem/8711052") #@unittest2.expectedFailure # rdar://problem/8542091 # rdar://problem/8492646 From johnny.chen at apple.com Tue Nov 30 11:53:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 30 Nov 2010 17:53:12 -0000 Subject: [Lldb-commits] [lldb] r120432 - /lldb/trunk/test/expression_command/radar_8638051/Test8638051.py Message-ID: <20101130175312.4E1572A6C12D@llvm.org> Author: johnny Date: Tue Nov 30 11:53:12 2010 New Revision: 120432 URL: http://llvm.org/viewvc/llvm-project?rev=120432&view=rev Log: Entire test class skipped due to: rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199 Modified: lldb/trunk/test/expression_command/radar_8638051/Test8638051.py Modified: lldb/trunk/test/expression_command/radar_8638051/Test8638051.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_8638051/Test8638051.py?rev=120432&r1=120431&r2=120432&view=diff ============================================================================== --- lldb/trunk/test/expression_command/radar_8638051/Test8638051.py (original) +++ lldb/trunk/test/expression_command/radar_8638051/Test8638051.py Tue Nov 30 11:53:12 2010 @@ -7,6 +7,7 @@ import lldb from lldbtest import * + at unittest2.skip("rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199") class Radar8638051TestCase(TestBase): mydir = os.path.join("expression_command", "radar_8638051") From johnny.chen at apple.com Tue Nov 30 11:59:40 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 30 Nov 2010 17:59:40 -0000 Subject: [Lldb-commits] [lldb] r120434 - /lldb/trunk/test/namespace/TestNamespace.py Message-ID: <20101130175940.518362A6C12D@llvm.org> Author: johnny Date: Tue Nov 30 11:59:40 2010 New Revision: 120434 URL: http://llvm.org/viewvc/llvm-project?rev=120434&view=rev Log: Entire test class skipped due to: rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199 Modified: lldb/trunk/test/namespace/TestNamespace.py Modified: lldb/trunk/test/namespace/TestNamespace.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/namespace/TestNamespace.py?rev=120434&r1=120433&r2=120434&view=diff ============================================================================== --- lldb/trunk/test/namespace/TestNamespace.py (original) +++ lldb/trunk/test/namespace/TestNamespace.py Tue Nov 30 11:59:40 2010 @@ -7,6 +7,7 @@ import lldb from lldbtest import * + at unittest2.skip("rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199") class NamespaceTestCase(TestBase): mydir = "namespace" From johnny.chen at apple.com Tue Nov 30 15:09:06 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 30 Nov 2010 21:09:06 -0000 Subject: [Lldb-commits] [lldb] r120462 - in /lldb/trunk/test/types: TestFloatTypesExpr.py TestIntegerTypesExpr.py Message-ID: <20101130210906.A59B12A6C12D@llvm.org> Author: johnny Date: Tue Nov 30 15:09:06 2010 New Revision: 120462 URL: http://llvm.org/viewvc/llvm-project?rev=120462&view=rev Log: Skip two test classes due to: rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199 Modified: lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=120462&r1=120461&r2=120462&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Tue Nov 30 15:09:06 2010 @@ -7,6 +7,7 @@ import lldb import sys + at unittest2.skip("rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199") class FloatTypesExprTestCase(AbstractBase.GenericTester): mydir = "types" Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=120462&r1=120461&r2=120462&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Tue Nov 30 15:09:06 2010 @@ -7,6 +7,7 @@ import lldb import sys + at unittest2.skip("rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199") class IntegerTypesExprTestCase(AbstractBase.GenericTester): mydir = "types" From scallanan at apple.com Tue Nov 30 16:01:58 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 30 Nov 2010 22:01:58 -0000 Subject: [Lldb-commits] [lldb] r120472 - /lldb/trunk/source/Expression/ClangExpressionVariable.cpp Message-ID: <20101130220158.CEF5D2A6C12D@llvm.org> Author: spyffe Date: Tue Nov 30 16:01:58 2010 New Revision: 120472 URL: http://llvm.org/viewvc/llvm-project?rev=120472&view=rev Log: Fixed a problem where m_register_info was not being copied by the copy constructor for ClangExpressionVariable. This meant that a NULL m_register_info wouldn't be copied, and instead the field was uninitialized, potentially confusing the materializer. Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=120472&r1=120471&r2=120472&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Tue Nov 30 16:01:58 2010 @@ -47,7 +47,8 @@ ClangExpressionVariable::ClangExpressionVariable(const ClangExpressionVariable &rhs) : m_name(rhs.m_name), m_user_type(rhs.m_user_type), - m_store(rhs.m_store), + m_store(rhs.m_store), + m_register_info(rhs.m_register_info), m_index(rhs.m_index) { if (rhs.m_parser_vars.get()) From johnny.chen at apple.com Tue Nov 30 16:34:19 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 30 Nov 2010 22:34:19 -0000 Subject: [Lldb-commits] [lldb] r120479 - in /lldb/trunk/test: breakpoint_conditions/TestBreakpointConditions.py expression_command/radar_8638051/Test8638051.py foundation/TestObjCMethods.py namespace/TestNamespace.py types/TestFloatTypesExpr.py types/TestIntegerTypesExpr.py Message-ID: <20101130223419.88BFE2A6C12D@llvm.org> Author: johnny Date: Tue Nov 30 16:34:19 2010 New Revision: 120479 URL: http://llvm.org/viewvc/llvm-project?rev=120479&view=rev Log: Remove @skip decorators for fixed crashes. Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py lldb/trunk/test/expression_command/radar_8638051/Test8638051.py lldb/trunk/test/foundation/TestObjCMethods.py lldb/trunk/test/namespace/TestNamespace.py lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=120479&r1=120478&r2=120479&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Tue Nov 30 16:34:19 2010 @@ -8,7 +8,6 @@ import lldb, lldbutil from lldbtest import * - at unittest2.skip("rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199") class BreakpointConditionsTestCase(TestBase): mydir = "breakpoint_conditions" Modified: lldb/trunk/test/expression_command/radar_8638051/Test8638051.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_8638051/Test8638051.py?rev=120479&r1=120478&r2=120479&view=diff ============================================================================== --- lldb/trunk/test/expression_command/radar_8638051/Test8638051.py (original) +++ lldb/trunk/test/expression_command/radar_8638051/Test8638051.py Tue Nov 30 16:34:19 2010 @@ -7,7 +7,6 @@ import lldb from lldbtest import * - at unittest2.skip("rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199") class Radar8638051TestCase(TestBase): mydir = os.path.join("expression_command", "radar_8638051") Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=120479&r1=120478&r2=120479&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Tue Nov 30 16:34:19 2010 @@ -23,7 +23,6 @@ self.buildDwarf() self.break_on_objc_methods() - @unittest2.skip("rdar://problem/8711052") #@unittest2.expectedFailure # rdar://problem/8542091 # rdar://problem/8492646 @@ -32,7 +31,6 @@ self.buildDsym() self.data_type_and_expr_objc() - @unittest2.skip("rdar://problem/8711052") #@unittest2.expectedFailure # rdar://problem/8542091 # rdar://problem/8492646 Modified: lldb/trunk/test/namespace/TestNamespace.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/namespace/TestNamespace.py?rev=120479&r1=120478&r2=120479&view=diff ============================================================================== --- lldb/trunk/test/namespace/TestNamespace.py (original) +++ lldb/trunk/test/namespace/TestNamespace.py Tue Nov 30 16:34:19 2010 @@ -7,7 +7,6 @@ import lldb from lldbtest import * - at unittest2.skip("rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199") class NamespaceTestCase(TestBase): mydir = "namespace" Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=120479&r1=120478&r2=120479&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Tue Nov 30 16:34:19 2010 @@ -7,7 +7,6 @@ import lldb import sys - at unittest2.skip("rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199") class FloatTypesExprTestCase(AbstractBase.GenericTester): mydir = "types" Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=120479&r1=120478&r2=120479&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Tue Nov 30 16:34:19 2010 @@ -7,7 +7,6 @@ import lldb import sys - at unittest2.skip("rdar://problem/8710994 Assertion failed: (reg_info) GDBRemoteRegisterContext.cpp, line 199") class IntegerTypesExprTestCase(AbstractBase.GenericTester): mydir = "types" From jingham at apple.com Tue Nov 30 16:59:38 2010 From: jingham at apple.com (Jim Ingham) Date: Tue, 30 Nov 2010 22:59:38 -0000 Subject: [Lldb-commits] [lldb] r120484 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectHelp.cpp Message-ID: <20101130225938.2AAC12A6C12D@llvm.org> Author: jingham Date: Tue Nov 30 16:59:37 2010 New Revision: 120484 URL: http://llvm.org/viewvc/llvm-project?rev=120484&view=rev Log: Fix completion for multi-word commands in the "help" command. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectHelp.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=120484&r1=120483&r2=120484&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Nov 30 16:59:37 2010 @@ -2459,6 +2459,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=120484&r1=120483&r2=120484&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Tue Nov 30 16:59:37 2010 @@ -74,6 +74,7 @@ if (cmd_obj != NULL) { + StringList matches; bool all_okay = true; CommandObject *sub_cmd_obj = cmd_obj; // Loop down through sub_command dictionaries until we find the command object that corresponds @@ -81,17 +82,22 @@ for (int i = 1; i < argc && all_okay; ++i) { std::string sub_command = command.GetArgumentAtIndex(i); + matches.Clear(); if (! sub_cmd_obj->IsMultiwordObject ()) { all_okay = false; } else { - pos = ((CommandObjectMultiword *) sub_cmd_obj)->m_subcommand_dict.find (sub_command); - if (pos != ((CommandObjectMultiword *) sub_cmd_obj)->m_subcommand_dict.end()) - sub_cmd_obj = pos->second.get(); - else + CommandObject *found_cmd; + found_cmd = ((CommandObjectMultiword *) sub_cmd_obj)->GetSubcommandObject(sub_command.c_str(), + &matches); + if (found_cmd == NULL) + all_okay = false; + else if (matches.GetSize() != 1) all_okay = false; + else + sub_cmd_obj = found_cmd; } } @@ -99,9 +105,25 @@ { std::string cmd_string; command.GetCommandString (cmd_string); - result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - cmd_string.c_str()); + if (matches.GetSize() < 2) + { + result.AppendErrorWithFormat("'%s' is not a known command.\n" + "Try 'help' to see a current list of commands.\n", + cmd_string.c_str()); + } + else + { + StreamString s; + s.Printf ("ambiguous command %s", cmd_string.c_str()); + size_t num_matches = matches.GetSize(); + for (size_t match_idx = 0; match_idx < num_matches; match_idx++) + { + s.Printf ("\n\t%s", matches.GetStringAtIndex(match_idx)); + } + s.Printf ("\n"); + result.AppendError(s.GetData()); + } + result.SetStatus (eReturnStatusFailed); } else From johnny.chen at apple.com Tue Nov 30 17:57:59 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 30 Nov 2010 23:57:59 -0000 Subject: [Lldb-commits] [lldb] r120503 - /lldb/trunk/test/help/TestHelp.py Message-ID: <20101130235759.2378E2A6C12D@llvm.org> Author: johnny Date: Tue Nov 30 17:57:58 2010 New Revision: 120503 URL: http://llvm.org/viewvc/llvm-project?rev=120503&view=rev Log: Add expectedFailure decorator for test_help_image_dump_symtab_should_not_crash(). Possibly due to http://llvm.org/viewvc/llvm-project?rev=120484&view=rev. Modified: lldb/trunk/test/help/TestHelp.py Modified: lldb/trunk/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=120503&r1=120502&r2=120503&view=diff ============================================================================== --- lldb/trunk/test/help/TestHelp.py (original) +++ lldb/trunk/test/help/TestHelp.py Tue Nov 30 17:57:58 2010 @@ -24,6 +24,8 @@ self.expect("help", startstr = 'The following is a list of built-in, permanent debugger commands') + @unittest2.expectedFailure + # rdar://problem/8713425 def test_help_image_dump_symtab_should_not_crash(self): """Command 'help image dump symtab' should not crash lldb.""" self.expect("help image dump symtab", From johnny.chen at apple.com Tue Nov 30 18:03:17 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Dec 2010 00:03:17 -0000 Subject: [Lldb-commits] [lldb] r120505 - /lldb/trunk/test/macosx/universal/TestUniversal.py Message-ID: <20101201000317.B84882A6C12D@llvm.org> Author: johnny Date: Tue Nov 30 18:03:17 2010 New Revision: 120505 URL: http://llvm.org/viewvc/llvm-project?rev=120505&view=rev Log: Add @expectedFailure decorator for a known bug: rdar://problem/8689814 test failure: test/macosx/universal (the i386 slice does not break?) Modified: lldb/trunk/test/macosx/universal/TestUniversal.py Modified: lldb/trunk/test/macosx/universal/TestUniversal.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/macosx/universal/TestUniversal.py?rev=120505&r1=120504&r2=120505&view=diff ============================================================================== --- lldb/trunk/test/macosx/universal/TestUniversal.py (original) +++ lldb/trunk/test/macosx/universal/TestUniversal.py Tue Nov 30 18:03:17 2010 @@ -15,6 +15,8 @@ # Find the line number to break inside main(). self.line = line_number('main.c', '// Set break point at this line.') + @unittest2.expectedFailure + # rdar://problem/8689814 test failure: test/macosx/universal (the i386 slice does not break?) @unittest2.skipUnless(sys.platform.startswith("darwin") and os.uname()[4]=='i386', "requires Darwin & i386") def test_process_launch_for_universal(self): From jingham at apple.com Tue Nov 30 18:42:17 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 01 Dec 2010 00:42:17 -0000 Subject: [Lldb-commits] [lldb] r120511 - /lldb/trunk/source/Commands/CommandObjectHelp.cpp Message-ID: <20101201004217.7276D2A6C12D@llvm.org> Author: jingham Date: Tue Nov 30 18:42:17 2010 New Revision: 120511 URL: http://llvm.org/viewvc/llvm-project?rev=120511&view=rev Log: GetCommandObject returns no matches in the match array when there is only one match. That's odd, but I don't want to change that right now, just cope with it where I'm doing the command matching. Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=120511&r1=120510&r2=120511&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Tue Nov 30 18:42:17 2010 @@ -94,7 +94,7 @@ &matches); if (found_cmd == NULL) all_okay = false; - else if (matches.GetSize() != 1) + else if (matches.GetSize() > 1) all_okay = false; else sub_cmd_obj = found_cmd; From johnny.chen at apple.com Tue Nov 30 19:01:23 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Dec 2010 01:01:23 -0000 Subject: [Lldb-commits] [lldb] r120515 - /lldb/trunk/test/help/TestHelp.py Message-ID: <20101201010124.0B69A2A6C12D@llvm.org> Author: johnny Date: Tue Nov 30 19:01:23 2010 New Revision: 120515 URL: http://llvm.org/viewvc/llvm-project?rev=120515&view=rev Log: Remove the @expectedFailure decorator as the bug has been fixed. Modified: lldb/trunk/test/help/TestHelp.py Modified: lldb/trunk/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=120515&r1=120514&r2=120515&view=diff ============================================================================== --- lldb/trunk/test/help/TestHelp.py (original) +++ lldb/trunk/test/help/TestHelp.py Tue Nov 30 19:01:23 2010 @@ -24,8 +24,6 @@ self.expect("help", startstr = 'The following is a list of built-in, permanent debugger commands') - @unittest2.expectedFailure - # rdar://problem/8713425 def test_help_image_dump_symtab_should_not_crash(self): """Command 'help image dump symtab' should not crash lldb.""" self.expect("help image dump symtab", From johnny.chen at apple.com Tue Nov 30 19:04:22 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Dec 2010 01:04:22 -0000 Subject: [Lldb-commits] [lldb] r120516 - /lldb/trunk/source/Commands/CommandObjectMultiword.cpp Message-ID: <20101201010422.4D3082A6C12D@llvm.org> Author: johnny Date: Tue Nov 30 19:04:22 2010 New Revision: 120516 URL: http://llvm.org/viewvc/llvm-project?rev=120516&view=rev Log: Make CommandObjectMultiword::GetSubcommandSP() more robust by appending the exactly-matched sub_cmd to the passed in 'matches' string list. Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=120516&r1=120515&r2=120516&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Tue Nov 30 19:04:22 2010 @@ -49,8 +49,12 @@ if (!m_subcommand_dict.empty()) { pos = m_subcommand_dict.find (sub_cmd); - if (pos != m_subcommand_dict.end()) + if (pos != m_subcommand_dict.end()) { + // An exact match; append the sub_cmd to the 'matches' string list. + if (matches) + matches->AppendString(sub_cmd); return_cmd_sp = pos->second; + } else { From scallanan at apple.com Tue Nov 30 19:28:24 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 01 Dec 2010 01:28:24 -0000 Subject: [Lldb-commits] [lldb] r120520 - /lldb/trunk/source/Expression/ClangUserExpression.cpp Message-ID: <20101201012824.1B3D12A6C12D@llvm.org> Author: spyffe Date: Tue Nov 30 19:28:23 2010 New Revision: 120520 URL: http://llvm.org/viewvc/llvm-project?rev=120520&view=rev Log: Whitespace fix. Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=120520&r1=120519&r2=120520&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Nov 30 19:28:23 2010 @@ -324,12 +324,12 @@ // ClangUserExpression resources before the thread plan finishes execution in the target. But because we are // forcing unwind_on_error to be true here, in practical terms that can't happen. return ClangFunction::GetThreadPlanToCallFunction (exe_ctx, - m_jit_addr, - struct_address, - error_stream, - true, - true, - (m_needs_object_ptr ? &object_ptr : NULL)); + m_jit_addr, + struct_address, + error_stream, + true, + true, + (m_needs_object_ptr ? &object_ptr : NULL)); } bool From scallanan at apple.com Tue Nov 30 19:29:06 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 01 Dec 2010 01:29:06 -0000 Subject: [Lldb-commits] [lldb] r120521 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20101201012906.3D3D12A6C12D@llvm.org> Author: spyffe Date: Tue Nov 30 19:29:06 2010 New Revision: 120521 URL: http://llvm.org/viewvc/llvm-project?rev=120521&view=rev Log: Allowed ClangExpressionDeclMap to dematerialize persistent variables even after the parser has finished running. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=120521&r1=120520&r2=120521&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Nov 30 19:29:06 2010 @@ -576,10 +576,11 @@ { ClangExpressionVariable &member (m_struct_members.VariableAtIndex(member_index)); - if (!member.m_parser_vars.get()) - return false; + ClangExpressionVariable *entity = NULL; + + if (member.m_parser_vars.get()) + entity = m_found_entities.GetVariable(member.m_parser_vars->m_named_decl); - ClangExpressionVariable *entity = m_found_entities.GetVariable(member.m_parser_vars->m_named_decl); ClangExpressionVariable *persistent_variable = m_persistent_vars->GetVariable(member.m_name); if (entity) From johnny.chen at apple.com Wed Dec 1 13:10:59 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Dec 2010 19:10:59 -0000 Subject: [Lldb-commits] [lldb] r120587 - /lldb/trunk/test/help/TestHelp.py Message-ID: <20101201191059.728CE2A6C12D@llvm.org> Author: johnny Date: Wed Dec 1 13:10:59 2010 New Revision: 120587 URL: http://llvm.org/viewvc/llvm-project?rev=120587&view=rev Log: Add test cases to test that: 1. 'help image du sym' is ambiguous. 2. 'help image du line' is not ambiguous. Modified: lldb/trunk/test/help/TestHelp.py Modified: lldb/trunk/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=120587&r1=120586&r2=120587&view=diff ============================================================================== --- lldb/trunk/test/help/TestHelp.py (original) +++ lldb/trunk/test/help/TestHelp.py Wed Dec 1 13:10:59 2010 @@ -30,6 +30,19 @@ substrs = ['image dump symtab', 'sort-order']) + def test_help_image_du_sym_is_ambiguous(self): + """Command 'help image du sym' is ambiguous and spits out the list of candidates.""" + self.expect("help image du sym", + COMMAND_FAILED_AS_EXPECTED, error=True, + substrs = ['error: ambiguous command image du sym', + 'symfile', + 'symtab']) + + def test_help_image_du_line_should_work(self): + """Command 'help image du line' is not ambiguous and should work.""" + self.expect("help image du line", + substrs = ['Dump the debug symbol file for one or more executable images']) + if __name__ == '__main__': import atexit From scallanan at apple.com Wed Dec 1 15:35:54 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 01 Dec 2010 21:35:54 -0000 Subject: [Lldb-commits] [lldb] r120606 - in /lldb/trunk: include/lldb/Expression/ClangUserExpression.h include/lldb/Symbol/ClangASTType.h source/Expression/ClangUserExpression.cpp source/Symbol/ClangASTType.cpp Message-ID: <20101201213554.EE4DE2A6C12D@llvm.org> Author: spyffe Date: Wed Dec 1 15:35:54 2010 New Revision: 120606 URL: http://llvm.org/viewvc/llvm-project?rev=120606&view=rev Log: Fixed ClangUserExpression's wrapping of expressions in C++ methods. There were two fixes involved: - For an object whose contents are not known, the expression should be treated as a non-member, and "this" should have no meaning. - For a const object, the method should be declared const as well. Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/Symbol/ClangASTType.h lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=120606&r1=120605&r2=120606&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Wed Dec 1 15:35:54 2010 @@ -272,6 +272,7 @@ bool m_cplusplus; ///< True if the expression is compiled as a C++ member function (true if it was parsed when exe_ctx was in a C++ method). bool m_objectivec; ///< True if the expression is compiled as an Objective-C method (true if it was parsed when exe_ctx was in an Objective-C method). bool m_needs_object_ptr; ///< True if "this" or "self" must be looked up and passed in. False if the expression doesn't really use them and they can be NULL. + bool m_const_object; ///< True if "this" is const. }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=120606&r1=120605&r2=120606&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Wed Dec 1 15:35:54 2010 @@ -197,6 +197,12 @@ IsDefined (lldb::clang_type_t opaque_clang_qual_type); bool + IsConst(); + + static bool + IsConst (lldb::clang_type_t opaque_clang_qual_type); + + bool SetValueFromScalar (const Scalar &value, Stream &strm); Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=120606&r1=120605&r2=120606&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Wed Dec 1 15:35:54 2010 @@ -47,6 +47,7 @@ m_cplusplus(false), m_objectivec(false), m_needs_object_ptr(false), + m_const_object(false), m_desired_type(NULL, NULL) { } @@ -73,10 +74,31 @@ if (!vars) return; - if (vars->FindVariable(ConstString("this")).get()) - m_cplusplus = true; - else if (vars->FindVariable(ConstString("self")).get()) + lldb::VariableSP this_var(vars->FindVariable(ConstString("this"))); + lldb::VariableSP self_var(vars->FindVariable(ConstString("self"))); + + if (this_var.get()) + { + Type *this_type = this_var->GetType(); + + lldb::clang_type_t pointer_target_type; + + if (ClangASTContext::IsPointerType(this_type->GetClangType(), + &pointer_target_type)) + { + TypeFromUser target_ast_type(pointer_target_type, this_type->GetClangAST()); + + if (target_ast_type.IsDefined()) + m_cplusplus = true; + + if (target_ast_type.IsConst()) + m_const_object = true; + } + } + else if (self_var.get()) + { m_objectivec = true; + } } // This is a really nasty hack, meant to fix Objective-C expressions of the form @@ -141,12 +163,13 @@ m_transformed_stream.Printf("%s \n" "typedef unsigned short unichar; \n" "void \n" - "$__lldb_class::%s(void *$__lldb_arg) \n" + "$__lldb_class::%s(void *$__lldb_arg) %s\n" "{ \n" " %s; \n" "} \n", m_expr_prefix.c_str(), FunctionName(), + (m_const_object ? "const" : ""), m_expr_text.c_str()); m_needs_object_ptr = true; Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=120606&r1=120605&r2=120606&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Wed Dec 1 15:35:54 2010 @@ -812,7 +812,6 @@ return ClangASTType::IsDefined (m_type); } - bool ClangASTType::IsDefined (clang_type_t clang_type) { @@ -838,6 +837,20 @@ return true; } +bool +ClangASTType::IsConst() +{ + return ClangASTType::IsConst (m_type); +} + +bool +ClangASTType::IsConst (lldb::clang_type_t clang_type) +{ + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); + + return qual_type.isConstQualified(); +} + void ClangASTType::DumpTypeDescription (Stream *s) { From gclayton at apple.com Wed Dec 1 16:45:40 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 01 Dec 2010 22:45:40 -0000 Subject: [Lldb-commits] [lldb] r120618 - in /lldb/trunk/tools/debugserver/source: DNB.cpp DNB.h DNBArch.cpp DNBArch.h MacOSX/MachProcess.cpp MacOSX/MachProcess.h MacOSX/MachThreadList.cpp debugserver.cpp Message-ID: <20101201224540.51A552A6C12D@llvm.org> Author: gclayton Date: Wed Dec 1 16:45:40 2010 New Revision: 120618 URL: http://llvm.org/viewvc/llvm-project?rev=120618&view=rev Log: Fixed 32 bit debugging after recent architecture changes to debugserver. Modified: lldb/trunk/tools/debugserver/source/DNB.cpp lldb/trunk/tools/debugserver/source/DNB.h lldb/trunk/tools/debugserver/source/DNBArch.cpp lldb/trunk/tools/debugserver/source/DNBArch.h lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp lldb/trunk/tools/debugserver/source/debugserver.cpp Modified: lldb/trunk/tools/debugserver/source/DNB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=120618&r1=120617&r2=120618&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.cpp (original) +++ lldb/trunk/tools/debugserver/source/DNB.cpp Wed Dec 1 16:45:40 2010 @@ -2019,3 +2019,18 @@ DNBTerminate() { } + +nub_bool_t +DNBSetArchitecture (const char *arch) +{ + if (arch && arch[0]) + { + if (strcasecmp (arch, "i386") == 0) + return DNBArchProtocol::SetArchitecture (CPU_TYPE_I386); + else if (strcasecmp (arch, "x86_64") == 0) + return DNBArchProtocol::SetArchitecture (CPU_TYPE_X86_64); + else if (strstr (arch, "arm") == arch) + return DNBArchProtocol::SetArchitecture (CPU_TYPE_ARM); + } + return false; +} Modified: lldb/trunk/tools/debugserver/source/DNB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.h?rev=120618&r1=120617&r2=120618&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.h (original) +++ lldb/trunk/tools/debugserver/source/DNB.h Wed Dec 1 16:45:40 2010 @@ -28,6 +28,8 @@ void DNBInitialize (); void DNBTerminate (); +nub_bool_t DNBSetArchitecture (const char *arch); + //---------------------------------------------------------------------- // Process control //---------------------------------------------------------------------- Modified: lldb/trunk/tools/debugserver/source/DNBArch.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBArch.cpp?rev=120618&r1=120617&r2=120618&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNBArch.cpp (original) +++ lldb/trunk/tools/debugserver/source/DNBArch.cpp Wed Dec 1 16:45:40 2010 @@ -22,13 +22,13 @@ typedef std::map CPUPluginInfoMap; #if defined (__i386__) -uint32_t g_current_cpu_type = CPU_TYPE_I386; +static uint32_t g_current_cpu_type = CPU_TYPE_I386; #elif defined (__x86_64__) -uint32_t g_current_cpu_type = CPU_TYPE_X86_64; +static uint32_t g_current_cpu_type = CPU_TYPE_X86_64; #elif defined (__arm__) -uint32_t g_current_cpu_type = CPU_TYPE_ARM; +static uint32_t g_current_cpu_type = CPU_TYPE_ARM; #else -uint32_t g_current_cpu_type = 0; +static uint32_t g_current_cpu_type = 0; #endif CPUPluginInfoMap g_arch_plugins; @@ -43,12 +43,20 @@ return NULL; } -void -DNBArchProtocol::SetDefaultArchitecture (uint32_t cpu_type) + +uint32_t +DNBArchProtocol::GetArchitecture () +{ + return g_current_cpu_type; +} + +bool +DNBArchProtocol::SetArchitecture (uint32_t cpu_type) { - DNBLogThreadedIf (LOG_PROCESS, "DNBArchProtocol::SetDefaultArchitecture (cpu_type=0x%8.8x)", cpu_type); g_current_cpu_type = cpu_type; - assert (g_arch_plugins.find(g_current_cpu_type) != g_arch_plugins.end()); + bool result = g_arch_plugins.find(g_current_cpu_type) != g_arch_plugins.end(); + DNBLogThreadedIf (LOG_PROCESS, "DNBArchProtocol::SetDefaultArchitecture (cpu_type=0x%8.8x) => %i", cpu_type, result); + return result; } void Modified: lldb/trunk/tools/debugserver/source/DNBArch.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBArch.h?rev=120618&r1=120617&r2=120618&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNBArch.h (original) +++ lldb/trunk/tools/debugserver/source/DNBArch.h Wed Dec 1 16:45:40 2010 @@ -52,9 +52,12 @@ static void RegisterArchPlugin (const DNBArchPluginInfo &arch_info); - static void - SetDefaultArchitecture (uint32_t cpu_type); + static uint32_t + GetArchitecture (); + static bool + SetArchitecture (uint32_t cpu_type); + virtual bool GetRegisterValue (int set, int reg, DNBRegisterValue *value) = 0; virtual bool SetRegisterValue (int set, int reg, const DNBRegisterValue *value) = 0; virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len) = 0; Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=120618&r1=120617&r2=120618&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Wed Dec 1 16:45:40 2010 @@ -115,7 +115,6 @@ m_image_infos_baton(NULL) { DNBLogThreadedIf(LOG_PROCESS | LOG_VERBOSE, "%s", __PRETTY_FUNCTION__); - bzero(&m_arch_plugin_info, sizeof(m_arch_plugin_info)); } MachProcess::~MachProcess() @@ -1517,7 +1516,7 @@ case eLaunchFlavorPosixSpawn: m_pid = MachProcess::PosixSpawnChildForPTraceDebugging (path, - m_arch_plugin_info.cpu_type, + DNBArchProtocol::GetArchitecture (), argv, envp, stdio_path, Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h?rev=120618&r1=120617&r2=120618&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h Wed Dec 1 16:45:40 2010 @@ -254,7 +254,6 @@ DNBCallbackCopyExecutableImageInfos m_image_infos_callback; void * m_image_infos_baton; - DNBArchPluginInfo m_arch_plugin_info; }; Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=120618&r1=120617&r2=120618&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Wed Dec 1 16:45:40 2010 @@ -230,9 +230,9 @@ is_64_bit = true; } if (is_64_bit) - DNBArchProtocol::SetDefaultArchitecture(CPU_TYPE_X86_64); + DNBArchProtocol::SetArchitecture(CPU_TYPE_X86_64); else - DNBArchProtocol::SetDefaultArchitecture(CPU_TYPE_I386); + DNBArchProtocol::SetArchitecture(CPU_TYPE_I386); } #endif Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=120618&r1=120617&r2=120618&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/debugserver.cpp (original) +++ lldb/trunk/tools/debugserver/source/debugserver.cpp Wed Dec 1 16:45:40 2010 @@ -886,6 +886,10 @@ arch_name.assign ("arm"); #endif } + else + { + DNBSetArchitecture (arch_name.c_str()); + } if (arch_name.empty()) { @@ -897,6 +901,8 @@ argv += optind; g_remoteSP.reset (new RNBRemote (use_native_registers, arch_name.c_str())); + + RNBRemote *remote = g_remoteSP.get(); if (remote == NULL) From johnny.chen at apple.com Wed Dec 1 16:47:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Dec 2010 22:47:54 -0000 Subject: [Lldb-commits] [lldb] r120620 - in /lldb/trunk/test: blacklist.py dotest.py lldbtest.py Message-ID: <20101201224754.CA3052A6C12D@llvm.org> Author: johnny Date: Wed Dec 1 16:47:54 2010 New Revision: 120620 URL: http://llvm.org/viewvc/llvm-project?rev=120620&view=rev Log: Add a '-b blacklistFile' option to the test driver to take a file specifying the test classes or test cases to be excludued from the test suite. Check in an example blacklist file: blacklist.py: """ 'blacklist' is a Python dictionary, it stores the mapping of a string describing either a testclass or a testcase, i.e, testclass.testmethod, to the reason (a string) it is blacklisted. Following is an example which states that test class IntegerTypesExprTestCase should be skipped because 'This test class crashed' and the test case FoundationTestCase.test_data_type_and_expr_with_dsym should be skipped because it is 'Temporarily disabled'. blacklist = {'IntegerTypesExprTestCase': 'This test class crashed', 'FoundationTestCase.test_data_type_and_expr_with_dsym': 'Temporarily disabled' } """ blacklist = {} An example of invoking the test driver and specifying a blacklist file: ./dotest.py -b blacklist.py -v types This runs the tests under 'types' directory but excludes the tests specified in balcklist.py. Added: lldb/trunk/test/blacklist.py Modified: lldb/trunk/test/dotest.py lldb/trunk/test/lldbtest.py Added: lldb/trunk/test/blacklist.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/blacklist.py?rev=120620&view=auto ============================================================================== --- lldb/trunk/test/blacklist.py (added) +++ lldb/trunk/test/blacklist.py Wed Dec 1 16:47:54 2010 @@ -0,0 +1,16 @@ +""" +'blacklist' is a Python dictionary, it stores the mapping of a string describing +either a testclass or a testcase, i.e, testclass.testmethod, to the reason (a +string) it is blacklisted. + +Following is an example which states that test class IntegerTypesExprTestCase +should be skipped because 'This test class crashed' and the test case +FoundationTestCase.test_data_type_and_expr_with_dsym should be skipped because +it is 'Temporarily disabled'. + +blacklist = {'IntegerTypesExprTestCase': 'This test class crashed', + 'FoundationTestCase.test_data_type_and_expr_with_dsym': 'Temporarily disabled' + } +""" + +blacklist = {} Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=120620&r1=120619&r2=120620&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Wed Dec 1 16:47:54 2010 @@ -45,6 +45,13 @@ # The test suite. suite = unittest2.TestSuite() +# The blacklist is optional (-b blacklistFile) and allows a central place to skip +# testclass's and/or testclass.testmethod's. +blacklist = None + +# The dictionary as a result of sourcing blacklistFile. +blacklistConfig = {} + # The config file is optional. configFile = None @@ -103,6 +110,7 @@ Usage: dotest.py [option] [args] where options: -h : print this help message and exit (also --help) +-b : read a blacklist file specified after this option -c : read a config file specified after this option (see also lldb-trunk/example/test/usage-config) -d : delay startup for 10 seconds (in order for the debugger to attach) @@ -219,6 +227,8 @@ '-h/--help as the first option prints out usage info and exit the program. """ + global blacklist + global blacklistConfig global configFile global count global delay @@ -244,6 +254,19 @@ if sys.argv[index].find('-h') != -1: usage() + elif sys.argv[index].startswith('-b'): + # Increment by 1 to fetch the blacklist file name option argument. + index += 1 + if index >= len(sys.argv) or sys.argv[index].startswith('-'): + usage() + blacklistFile = sys.argv[index] + if not os.path.isfile(blacklistFile): + print "Blacklist file:", blacklistFile, "does not exist!" + usage() + index += 1 + # Now read the blacklist contents and assign it to blacklist. + execfile(blacklistFile, globals(), blacklistConfig) + blacklist = blacklistConfig.get('blacklist') elif sys.argv[index].startswith('-c'): # Increment by 1 to fetch the config file name option argument. index += 1 @@ -593,6 +616,9 @@ # Create a singleton SBDebugger in the lldb namespace. lldb.DBG = lldb.SBDebugger.Create() +# And put the blacklist in the lldb namespace, to be used by lldb.TestBase. +lldb.blacklist = blacklist + # Turn on lldb loggings if necessary. lldbLoggings() Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=120620&r1=120619&r2=120620&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Dec 1 16:47:54 2010 @@ -451,6 +451,13 @@ #import traceback #traceback.print_stack() + className = self.__class__.__name__ + classAndMethodName = "%s.%s" % (className, self._testMethodName) + if className in lldb.blacklist: + self.skipTest(lldb.blacklist.get(className)) + elif classAndMethodName in lldb.blacklist: + self.skipTest(lldb.blacklist.get(classAndMethodName)) + if ("LLDB_WAIT_BETWEEN_TEST_CASES" in os.environ and os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] == 'YES'): time.sleep(1.0) From johnny.chen at apple.com Wed Dec 1 17:07:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Dec 2010 23:07:37 -0000 Subject: [Lldb-commits] [lldb] r120623 - /lldb/trunk/test/lldbtest.py Message-ID: <20101201230737.228DF2A6C12D@llvm.org> Author: johnny Date: Wed Dec 1 17:07:36 2010 New Revision: 120623 URL: http://llvm.org/viewvc/llvm-project?rev=120623&view=rev Log: TestBase.setUp() needs to make sure lldb.blacklist is not None before iterating on it. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=120623&r1=120622&r2=120623&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Dec 1 17:07:36 2010 @@ -451,12 +451,13 @@ #import traceback #traceback.print_stack() - className = self.__class__.__name__ - classAndMethodName = "%s.%s" % (className, self._testMethodName) - if className in lldb.blacklist: - self.skipTest(lldb.blacklist.get(className)) - elif classAndMethodName in lldb.blacklist: - self.skipTest(lldb.blacklist.get(classAndMethodName)) + if lldb.blacklist: + className = self.__class__.__name__ + classAndMethodName = "%s.%s" % (className, self._testMethodName) + if className in lldb.blacklist: + self.skipTest(lldb.blacklist.get(className)) + elif classAndMethodName in lldb.blacklist: + self.skipTest(lldb.blacklist.get(classAndMethodName)) if ("LLDB_WAIT_BETWEEN_TEST_CASES" in os.environ and os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] == 'YES'): From johnny.chen at apple.com Wed Dec 1 17:15:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Dec 2010 23:15:58 -0000 Subject: [Lldb-commits] [lldb] r120624 - /lldb/trunk/test/macosx/universal/TestUniversal.py Message-ID: <20101201231558.466252A6C12D@llvm.org> Author: johnny Date: Wed Dec 1 17:15:58 2010 New Revision: 120624 URL: http://llvm.org/viewvc/llvm-project?rev=120624&view=rev Log: Remove @expectedFailure decorator as the bug has been fixed. Modified: lldb/trunk/test/macosx/universal/TestUniversal.py Modified: lldb/trunk/test/macosx/universal/TestUniversal.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/macosx/universal/TestUniversal.py?rev=120624&r1=120623&r2=120624&view=diff ============================================================================== --- lldb/trunk/test/macosx/universal/TestUniversal.py (original) +++ lldb/trunk/test/macosx/universal/TestUniversal.py Wed Dec 1 17:15:58 2010 @@ -15,7 +15,6 @@ # Find the line number to break inside main(). self.line = line_number('main.c', '// Set break point at this line.') - @unittest2.expectedFailure # rdar://problem/8689814 test failure: test/macosx/universal (the i386 slice does not break?) @unittest2.skipUnless(sys.platform.startswith("darwin") and os.uname()[4]=='i386', "requires Darwin & i386") From johnny.chen at apple.com Wed Dec 1 17:35:13 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Dec 2010 23:35:13 -0000 Subject: [Lldb-commits] [lldb] r120625 - /lldb/trunk/test/lldbtest.py Message-ID: <20101201233513.AFC082A6C12D@llvm.org> Author: johnny Date: Wed Dec 1 17:35:13 2010 New Revision: 120625 URL: http://llvm.org/viewvc/llvm-project?rev=120625&view=rev Log: Add a mechanism of overwriting the default 1.0 second wait time between test cases when specifying '-w' to the test driver, by using an environment variable LLDB_TIME_WAIT_BETWEEN_TEST_CASES. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=120625&r1=120624&r2=120625&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Dec 1 17:35:13 2010 @@ -461,7 +461,10 @@ if ("LLDB_WAIT_BETWEEN_TEST_CASES" in os.environ and os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] == 'YES'): - time.sleep(1.0) + waitTime = 1.0 + if "LLDB_TIME_WAIT_BETWEEN_TEST_CASES" in os.environ: + waitTime = float(os.environ["LLDB_TIME_WAIT_BETWEEN_TEST_CASES"]) + time.sleep(waitTime) if "LLDB_MAX_LAUNCH_COUNT" in os.environ: self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"]) From johnny.chen at apple.com Wed Dec 1 17:46:33 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Dec 2010 23:46:33 -0000 Subject: [Lldb-commits] [lldb] r120626 - /lldb/trunk/test/types/AbstractBase.py Message-ID: <20101201234633.6BD8D2A6C12D@llvm.org> Author: johnny Date: Wed Dec 1 17:46:33 2010 New Revision: 120626 URL: http://llvm.org/viewvc/llvm-project?rev=120626&view=rev Log: GenericTester.generic_type_expr_tester(): Don't overwhelm the expression mechanism. Previously, there was no delay between successive invocations of 'expression' command. The test suite run has experienced 'Resume timed out' or similar error messages. Now we currently add a sleep of 1.0 second before issuing the next 'expression' command. Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=120626&r1=120625&r2=120626&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Wed Dec 1 17:46:33 2010 @@ -113,6 +113,8 @@ # Now iterate through the golden list, comparing against the output from # 'expr var'. for var, val in gl: + # Don't overwhelm the expression mechanism. + time.sleep(1.0) self.runCmd("expression %s" % var) output = self.res.GetOutput() From johnny.chen at apple.com Thu Dec 2 12:03:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 02 Dec 2010 18:03:37 -0000 Subject: [Lldb-commits] [lldb] r120719 - /lldb/trunk/test/types/AbstractBase.py Message-ID: <20101202180337.746F32A6C12D@llvm.org> Author: johnny Date: Thu Dec 2 12:03:37 2010 New Revision: 120719 URL: http://llvm.org/viewvc/llvm-project?rev=120719&view=rev Log: On second thought, inserting a delay of 1.0 second slows down the test suite for the types directory quite a bit and masking out potential problems. Enable the delay via an environment variable, instead. Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=120719&r1=120718&r2=120719&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Thu Dec 2 12:03:37 2010 @@ -114,7 +114,15 @@ # 'expr var'. for var, val in gl: # Don't overwhelm the expression mechanism. - time.sleep(1.0) + # This slows down the test suite quite a bit, to enable it, define + # the environment variable LLDB_TYPES_EXPR_TIME_WAIT. For example: + # + # export LLDB_TYPES_EXPR_TIME_WAIT=0.5 + # + # causes a 0.5 second delay between 'expression' commands. + if "LLDB_TYPES_EXPR_TIME_WAIT" in os.environ: + time.sleep(float(os.environ["LLDB_TYPES_EXPR_TIME_WAIT"])) + self.runCmd("expression %s" % var) output = self.res.GetOutput() From ctice at apple.com Thu Dec 2 12:31:56 2010 From: ctice at apple.com (Caroline Tice) Date: Thu, 02 Dec 2010 18:31:56 -0000 Subject: [Lldb-commits] [lldb] r120723 - in /lldb/trunk: include/lldb/API/SBCommunication.h include/lldb/Core/Communication.h source/API/SBCommunication.cpp source/Core/Communication.cpp source/Core/ConnectionFileDescriptor.cpp source/Core/Debugger.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp source/Target/Process.cpp tools/driver/Driver.cpp Message-ID: <20101202183156.A29A52A6C12D@llvm.org> Author: ctice Date: Thu Dec 2 12:31:56 2010 New Revision: 120723 URL: http://llvm.org/viewvc/llvm-project?rev=120723&view=rev Log: Add proper EOF handling to Communication & Connection classes: Add bool member to Communication class indicating whether the Connection should be closed on receiving an EOF or not. Update the Connection read to return an EOF status when appropriate. Modify the Communication class to pass the EOF along or not, and to close the Connection or not, as appropriate. Modified: lldb/trunk/include/lldb/API/SBCommunication.h lldb/trunk/include/lldb/Core/Communication.h lldb/trunk/source/API/SBCommunication.cpp lldb/trunk/source/Core/Communication.cpp lldb/trunk/source/Core/ConnectionFileDescriptor.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/API/SBCommunication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommunication.h?rev=120723&r1=120722&r2=120723&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommunication.h (original) +++ lldb/trunk/include/lldb/API/SBCommunication.h Thu Dec 2 12:31:56 2010 @@ -30,7 +30,7 @@ typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len); SBCommunication (); - SBCommunication (const char * broadcaster_name); + SBCommunication (const char * broadcaster_name, bool close_on_eof); ~SBCommunication (); Modified: lldb/trunk/include/lldb/Core/Communication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Communication.h?rev=120723&r1=120722&r2=120723&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Communication.h (original) +++ lldb/trunk/include/lldb/Core/Communication.h Thu Dec 2 12:31:56 2010 @@ -109,7 +109,7 @@ /// broadcaster name can be updated after the connect function /// is called. //------------------------------------------------------------------ - Communication(const char * broadcaster_name); + Communication(const char * broadcaster_name, bool close_on_eof); //------------------------------------------------------------------ /// Destructor. @@ -340,6 +340,9 @@ //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (Communication); + bool + CloseOnEOF (); + protected: std::auto_ptr m_connection_ap; ///< The connection that is current in use by this communications class. lldb::thread_t m_read_thread; ///< The read thread handle in case we need to cancel the thread. @@ -348,6 +351,7 @@ Mutex m_bytes_mutex; ///< A mutex to protect multi-threaded access to the cached bytes. ReadThreadBytesReceived m_callback; void *m_callback_baton; + bool m_close_on_eof; size_t ReadFromConnection (void *dst, Modified: lldb/trunk/source/API/SBCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommunication.cpp?rev=120723&r1=120722&r2=120723&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommunication.cpp (original) +++ lldb/trunk/source/API/SBCommunication.cpp Thu Dec 2 12:31:56 2010 @@ -24,8 +24,8 @@ { } -SBCommunication::SBCommunication(const char * broadcaster_name) : - m_opaque (new Communication (broadcaster_name)), +SBCommunication::SBCommunication(const char * broadcaster_name, bool close_on_eof) : + m_opaque (new Communication (broadcaster_name, close_on_eof)), m_opaque_owned (true) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=120723&r1=120722&r2=120723&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Thu Dec 2 12:31:56 2010 @@ -25,7 +25,7 @@ //---------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------- -Communication::Communication(const char *name) : +Communication::Communication(const char *name, bool close_on_eof) : Broadcaster (name), m_connection_ap (), m_read_thread (LLDB_INVALID_HOST_THREAD), @@ -33,7 +33,8 @@ m_bytes(), m_bytes_mutex (Mutex::eMutexTypeRecursive), m_callback (NULL), - m_callback_baton (NULL) + m_callback_baton (NULL), + m_close_on_eof (close_on_eof) { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION, @@ -265,7 +266,8 @@ lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::AppendBytesToCache (src = %p, src_len = %zu, broadcast = %i)", this, bytes, len, broadcast); - if (bytes == NULL || len == 0) + if ((bytes == NULL || len == 0) + && (status != eConnectionStatusEndOfFile)) return; if (m_callback) { @@ -289,6 +291,11 @@ return 0; } +bool +Communication::CloseOnEOF () +{ + return m_close_on_eof; +} bool Communication::ReadThreadIsRunning () @@ -320,14 +327,21 @@ 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->CloseOnEOF ()) + comm->Disconnect (); + comm->AppendBytesToCache (buf, bytes_read, true, status); + } } switch (status) { case eConnectionStatusSuccess: + case eConnectionStatusEndOfFile: break; - case eConnectionStatusEndOfFile: case eConnectionStatusNoConnection: // No connection case eConnectionStatusLostConnection: // Lost connection while connected to a valid connection done = true; Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=120723&r1=120722&r2=120723&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Thu Dec 2 12:31:56 2010 @@ -156,8 +156,8 @@ ssize_t bytes_read = ::read (m_fd, dst, dst_len); if (bytes_read == 0) { - error.SetErrorStringWithFormat("End-of-file.\n"); - status = eConnectionStatusLostConnection; + error.Clear(); // End-of-file. Do not automatically close; pass along for the end-of-file handlers. + status = eConnectionStatusEndOfFile; } else if (bytes_read < 0) { Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=120723&r1=120722&r2=120723&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Dec 2 12:31:56 2010 @@ -166,7 +166,7 @@ Debugger::Debugger () : UserID (g_unique_id++), DebuggerInstanceSettings (*GetSettingsController()), - m_input_comm("debugger.input"), + m_input_comm("debugger.input", false), m_input_file (), m_output_file (), m_error_file (), 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=120723&r1=120722&r2=120723&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Thu Dec 2 12:31:56 2010 @@ -32,7 +32,7 @@ // GDBRemoteCommunication constructor //---------------------------------------------------------------------- GDBRemoteCommunication::GDBRemoteCommunication() : - Communication("gdb-remote.packets"), + Communication("gdb-remote.packets", true), m_send_acks (true), m_rx_packet_listener ("gdbremote.rx_packet"), m_sequence_mutex (Mutex::eMutexTypeRecursive), Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=120723&r1=120722&r2=120723&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Dec 2 12:31:56 2010 @@ -96,7 +96,7 @@ m_addr_byte_size (0), m_abi_sp (), m_process_input_reader (), - m_stdio_communication ("lldb.process.stdio"), + m_stdio_communication ("lldb.process.stdio", true), m_stdio_communication_mutex (Mutex::eMutexTypeRecursive), m_stdout_data () { Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=120723&r1=120722&r2=120723&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Thu Dec 2 12:31:56 2010 @@ -1178,7 +1178,7 @@ // However, you don't need to do anything with the characters, since editline will dump these // unconsumed characters after printing the prompt again in el_gets. - SBCommunication master_out_comm("driver.editline"); + SBCommunication master_out_comm("driver.editline", false); master_out_comm.AdoptFileDesriptor(m_editline_pty.GetMasterFileDescriptor(), false); master_out_comm.SetReadThreadBytesReceivedCallback(Driver::MasterThreadBytesReceived, this); From johnny.chen at apple.com Thu Dec 2 12:35:14 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 02 Dec 2010 18:35:14 -0000 Subject: [Lldb-commits] [lldb] r120725 - /lldb/trunk/test/dotest.py Message-ID: <20101202183514.0EBD52A6C12D@llvm.org> Author: johnny Date: Thu Dec 2 12:35:13 2010 New Revision: 120725 URL: http://llvm.org/viewvc/llvm-project?rev=120725&view=rev Log: For lldb loggings, prepend log lines with a timestamp. And change the default log options: o lldb => event process expr o gdb-remote => packets process 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=120725&r1=120724&r2=120725&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Dec 2 12:35:13 2010 @@ -549,9 +549,9 @@ if ("LLDB_LOG_OPTION" in os.environ): lldb_log_option = os.environ["LLDB_LOG_OPTION"] else: - lldb_log_option = "event process" + lldb_log_option = "event process expr" ci.HandleCommand( - "log enable -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option, + "log enable -T -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option, res) if not res.Succeeded(): raise Exception('log enable failed (check LLDB_LOG env variable.') @@ -561,9 +561,9 @@ if ("GDB_REMOTE_LOG_OPTION" in os.environ): gdb_remote_log_option = os.environ["GDB_REMOTE_LOG_OPTION"] else: - gdb_remote_log_option = "packets" + gdb_remote_log_option = "packets process" ci.HandleCommand( - "log enable -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote " + "log enable -T -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote " + gdb_remote_log_option, res) if not res.Succeeded(): From scallanan at apple.com Thu Dec 2 13:47:57 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 02 Dec 2010 19:47:57 -0000 Subject: [Lldb-commits] [lldb] r120728 - /lldb/trunk/source/Expression/IRForTarget.cpp Message-ID: <20101202194757.46A8D2A6C12D@llvm.org> Author: spyffe Date: Thu Dec 2 13:47:57 2010 New Revision: 120728 URL: http://llvm.org/viewvc/llvm-project?rev=120728&view=rev Log: Fixed IRForTarget so that it errors out when function pointers are used. Previously, they caused a crash in the JIT because we didn't resolve them correctly. Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=120728&r1=120727&r2=120728&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Thu Dec 2 13:47:57 2010 @@ -844,6 +844,9 @@ IRForTarget::MaybeHandleVariable (Module &llvm_module, Value *llvm_value_ptr) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (log) + log->Printf("MaybeHandleVariable (%s)\n", PrintValue(llvm_value_ptr).c_str()); if (ConstantExpr *constant_expr = dyn_cast(llvm_value_ptr)) { @@ -854,7 +857,8 @@ case Instruction::GetElementPtr: case Instruction::BitCast: Value *s = constant_expr->getOperand(0); - MaybeHandleVariable(llvm_module, s); + if (!MaybeHandleVariable(llvm_module, s)) + return false; } } if (GlobalVariable *global_variable = dyn_cast(llvm_value_ptr)) @@ -909,6 +913,13 @@ value_alignment)) return false; } + else if (llvm::Function *function = dyn_cast(llvm_value_ptr)) + { + if (log) + log->Printf("Function pointers aren't handled right now"); + + return false; + } return true; } @@ -916,7 +927,10 @@ bool IRForTarget::MaybeHandleCallArguments (Module &llvm_module, CallInst *Old) { - // lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (log) + log->Printf("MaybeHandleCallArguments(%s)", PrintValue(Old).c_str()); for (unsigned op_index = 0, num_ops = Old->getNumArgOperands(); op_index < num_ops; @@ -945,11 +959,11 @@ fun = dyn_cast(const_expr->getOperand(0)); if (!fun) - return true; + return false; } else { - return true; + return false; } } @@ -1065,6 +1079,9 @@ if (call && !MaybeHandleCall(llvm_module, call)) return false; + + if (call && !MaybeHandleCallArguments(llvm_module, call)) + return false; } return true; From johnny.chen at apple.com Thu Dec 2 14:53:05 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 02 Dec 2010 20:53:05 -0000 Subject: [Lldb-commits] [lldb] r120733 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20101202205305.C1FC82A6C12D@llvm.org> Author: johnny Date: Thu Dec 2 14:53:05 2010 New Revision: 120733 URL: http://llvm.org/viewvc/llvm-project?rev=120733&view=rev Log: Fixed a typo in comment. Modified: lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=120733&r1=120732&r2=120733&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Dec 2 14:53:05 2010 @@ -1415,7 +1415,7 @@ // Tell the process it is about to resume before the thread list if (error.Success()) { - // Now let the thread list know we are about to resume to it + // Now let the thread list know we are about to resume so it // can let all of our threads know that they are about to be // resumed. Threads will each be called with // Thread::WillResume(StateType) where StateType contains the state From johnny.chen at apple.com Thu Dec 2 16:47:53 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 02 Dec 2010 22:47:53 -0000 Subject: [Lldb-commits] [lldb] r120745 - /lldb/trunk/test/dotest.py Message-ID: <20101202224753.12AF82A6C12D@llvm.org> Author: johnny Date: Thu Dec 2 16:47:52 2010 New Revision: 120745 URL: http://llvm.org/viewvc/llvm-project?rev=120745&view=rev Log: When logging, enable process and thread ID recordings. Also add 'state' to the lldb log-categories, so it now becomes "event process expr state". 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=120745&r1=120744&r2=120745&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Dec 2 16:47:52 2010 @@ -549,9 +549,9 @@ if ("LLDB_LOG_OPTION" in os.environ): lldb_log_option = os.environ["LLDB_LOG_OPTION"] else: - lldb_log_option = "event process expr" + lldb_log_option = "event process expr state" ci.HandleCommand( - "log enable -T -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option, + "log enable -T -p -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option, res) if not res.Succeeded(): raise Exception('log enable failed (check LLDB_LOG env variable.') @@ -563,7 +563,7 @@ else: gdb_remote_log_option = "packets process" ci.HandleCommand( - "log enable -T -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote " + "log enable -T -p -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote " + gdb_remote_log_option, res) if not res.Succeeded(): From gclayton at apple.com Thu Dec 2 17:20:03 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 02 Dec 2010 23:20:03 -0000 Subject: [Lldb-commits] [lldb] r120749 - in /lldb/trunk: include/lldb/Expression/ClangExpressionParser.h include/lldb/Symbol/ClangASTContext.h llvm.zip scripts/build-llvm.pl source/Core/FileSpec.cpp source/Expression/ClangExpressionParser.cpp source/Symbol/ClangASTContext.cpp Message-ID: <20101202232003.58D912A6C12D@llvm.org> Author: gclayton Date: Thu Dec 2 17:20:03 2010 New Revision: 120749 URL: http://llvm.org/viewvc/llvm-project?rev=120749&view=rev Log: Updated to latest LLVM/Clang for external AST source changes that allow TagDecl subclasses and Objective C interfaces to complete themselves through the ExternalASTSource class. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionParser.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/source/Core/FileSpec.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionParser.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionParser.h?rev=120749&r1=120748&r2=120749&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionParser.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionParser.h Thu Dec 2 17:20:03 2010 @@ -174,7 +174,6 @@ std::string m_target_triple; ///< The target triple used to initialize LLVM std::auto_ptr m_file_manager; ///< The Clang file manager object used by the compiler - std::auto_ptr m_file_system_options; ///< The Clang file system options object used by the compiler std::auto_ptr m_compiler; ///< The Clang compiler used to parse expressions into IR std::auto_ptr m_builtin_context; ///< Context for Clang built-ins std::auto_ptr m_selector_table; ///< Selector table for Objective-C methods Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=120749&r1=120748&r2=120749&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Dec 2 17:20:03 2010 @@ -75,9 +75,6 @@ clang::FileManager * getFileManager(); - clang::FileSystemOptions * - getFileSystemOptions(); - clang::SourceManager * getSourceManager(); Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=120749&r1=120748&r2=120749&view=diff ============================================================================== Binary files - no diff available. Modified: lldb/trunk/scripts/build-llvm.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/build-llvm.pl?rev=120749&r1=120748&r2=120749&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Thu Dec 2 17:20:03 2010 @@ -25,7 +25,7 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "'{2010-11-19T13:00}'"; +our $llvm_revision = "120727"; our $llvm_source_dir = "$ENV{SRCROOT}"; our $cc = "$ENV{DEVELOPER_BIN_DIR}/gcc-4.2"; our $cxx = "$ENV{DEVELOPER_BIN_DIR}/g++-4.2"; Modified: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=120749&r1=120748&r2=120749&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp Thu Dec 2 17:20:03 2010 @@ -19,8 +19,8 @@ #include #include "llvm/ADT/StringRef.h" -#include "llvm/System/Path.h" -#include "llvm/System/Program.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" #include "lldb/Core/FileSpec.h" #include "lldb/Core/DataBufferHeap.h" Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=120749&r1=120748&r2=120749&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Thu Dec 2 17:20:03 2010 @@ -54,9 +54,9 @@ #include "llvm/LLVMContext.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" -#include "llvm/System/DynamicLibrary.h" -#include "llvm/System/Host.h" -#include "llvm/System/Signals.h" +#include "llvm/Support/DynamicLibrary.h" +#include "llvm/Support/Host.h" +#include "llvm/Support/Signals.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetSelect.h" @@ -243,11 +243,11 @@ // 5. Set up the source management objects inside the compiler - m_file_manager.reset(new clang::FileManager()); - m_file_system_options.reset(new clang::FileSystemOptions()); + clang::FileSystemOptions file_system_options; + m_file_manager.reset(new clang::FileManager(file_system_options)); if (!m_compiler->hasSourceManager()) - m_compiler->createSourceManager(*m_file_manager.get(), *m_file_system_options.get()); + m_compiler->createSourceManager(*m_file_manager.get()); m_compiler->createFileManager(); m_compiler->createPreprocessor(); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=120749&r1=120748&r2=120749&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Dec 2 17:20:03 2010 @@ -356,23 +356,18 @@ ClangASTContext::getFileManager() { if (m_file_manager_ap.get() == NULL) - m_file_manager_ap.reset(new clang::FileManager()); + { + clang::FileSystemOptions file_system_options; + m_file_manager_ap.reset(new clang::FileManager(file_system_options)); + } return m_file_manager_ap.get(); } -clang::FileSystemOptions * -ClangASTContext::getFileSystemOptions() -{ - if (m_file_system_options_ap.get() == NULL) - m_file_system_options_ap.reset(new clang::FileSystemOptions()); - return m_file_system_options_ap.get(); -} - clang::SourceManager * ClangASTContext::getSourceManager() { if (m_source_manager_ap.get() == NULL) - m_source_manager_ap.reset(new clang::SourceManager(*getDiagnostic(), *getFileManager(), *getFileSystemOptions())); + m_source_manager_ap.reset(new clang::SourceManager(*getDiagnostic(), *getFileManager())); return m_source_manager_ap.get(); } @@ -748,33 +743,33 @@ }; clang_type_t -ClangASTContext::CopyType (ASTContext *dest_context, - ASTContext *source_context, +ClangASTContext::CopyType (ASTContext *dst_ast, + ASTContext *src_ast, clang_type_t clang_type) { // null_client's ownership is transferred to diagnostics - FileManager file_manager; FileSystemOptions file_system_options; - ASTImporter importer(*dest_context, file_manager, file_system_options, - *source_context, file_manager, file_system_options); + FileManager file_manager (file_system_options); + ASTImporter importer(*dst_ast, file_manager, + *src_ast, file_manager); - QualType src = QualType::getFromOpaquePtr(clang_type); - QualType dst = importer.Import(src); + QualType src (QualType::getFromOpaquePtr(clang_type)); + QualType dst (importer.Import(src)); return dst.getAsOpaquePtr(); } clang::Decl * -ClangASTContext::CopyDecl (ASTContext *dest_context, - ASTContext *source_context, +ClangASTContext::CopyDecl (ASTContext *dst_ast, + ASTContext *src_ast, clang::Decl *source_decl) { // null_client's ownership is transferred to diagnostics - FileManager file_manager; FileSystemOptions file_system_options; - ASTImporter importer(*dest_context, file_manager, file_system_options, - *source_context, file_manager, file_system_options); + FileManager file_manager (file_system_options); + ASTImporter importer(*dst_ast, file_manager, + *src_ast, file_manager); return importer.Import(source_decl); } From johnny.chen at apple.com Thu Dec 2 17:31:02 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 02 Dec 2010 23:31:02 -0000 Subject: [Lldb-commits] [lldb] r120751 - /lldb/trunk/test/dotest.py Message-ID: <20101202233102.ABCE02A6C12D@llvm.org> Author: johnny Date: Thu Dec 2 17:31:02 2010 New Revision: 120751 URL: http://llvm.org/viewvc/llvm-project?rev=120751&view=rev Log: Log just the thread name, not process/thread id for easier human reading. 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=120751&r1=120750&r2=120751&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Dec 2 17:31:02 2010 @@ -551,7 +551,7 @@ else: lldb_log_option = "event process expr state" ci.HandleCommand( - "log enable -T -p -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option, + "log enable -T -n -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option, res) if not res.Succeeded(): raise Exception('log enable failed (check LLDB_LOG env variable.') @@ -563,7 +563,7 @@ else: gdb_remote_log_option = "packets process" ci.HandleCommand( - "log enable -T -p -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote " + "log enable -T -n -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote " + gdb_remote_log_option, res) if not res.Succeeded(): From gclayton at apple.com Thu Dec 2 18:19:59 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Dec 2010 00:19:59 -0000 Subject: [Lldb-commits] [lldb] r120761 - /lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Message-ID: <20101203001959.222AA2A6C12D@llvm.org> Author: gclayton Date: Thu Dec 2 18:19:58 2010 New Revision: 120761 URL: http://llvm.org/viewvc/llvm-project?rev=120761&view=rev Log: Fixed bad logic that was trying to determine if the gdb remote resumed a process or not. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 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=120761&r1=120760&r2=120761&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Thu Dec 2 18:19:58 2010 @@ -867,9 +867,7 @@ timeout = TimeValue::Now(); timeout.OffsetWithSeconds (timeout_sec); } - bool timed_out = false; - m_is_running.WaitForValueEqualTo (true, &timeout, &timed_out); - return timed_out; + return m_is_running.WaitForValueEqualTo (true, &timeout, NULL); } From gclayton at apple.com Thu Dec 2 18:27:48 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Dec 2010 00:27:48 -0000 Subject: [Lldb-commits] [lldb] r120762 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20101203002748.988C32A6C12D@llvm.org> Author: gclayton Date: Thu Dec 2 18:27:48 2010 New Revision: 120762 URL: http://llvm.org/viewvc/llvm-project?rev=120762&view=rev Log: Fixed DoResume to watch for the correct return value from WaitForIsRunning to avoid spurious errors due to previous fix. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=120762&r1=120761&r2=120762&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Dec 2 18:27:48 2010 @@ -880,10 +880,8 @@ ProcessGDBRemoteLog::LogIf (GDBR_LOG_PROCESS, "ProcessGDBRemote::Resume()"); m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncContinue, new EventDataBytes (m_continue_packet.GetData(), m_continue_packet.GetSize())); const uint32_t timedout_sec = 1; - if (m_gdb_comm.WaitForIsRunning (timedout_sec)) - { + if (m_gdb_comm.WaitForIsRunning (timedout_sec) == false) error.SetErrorString("Resume timed out."); - } return error; } From scallanan at apple.com Thu Dec 2 19:38:59 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 03 Dec 2010 01:38:59 -0000 Subject: [Lldb-commits] [lldb] r120778 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangUserExpression.cpp source/Expression/ClangUtilityFunction.cpp Message-ID: <20101203013859.8F57A2A6C12D@llvm.org> Author: spyffe Date: Thu Dec 2 19:38:59 2010 New Revision: 120778 URL: http://llvm.org/viewvc/llvm-project?rev=120778&view=rev Log: Fixed object lifetimes in ClangExpressionDeclMap so that it is not referring to potentially stale state during IR execution. This was done by introducing modular state (like ClangExpressionVariable) where groups of state variables have well-defined lifetimes: - m_parser_vars are specific to parsing, and only exist between calls to WillParse() and DidParse(). - m_struct_vars survive for the entire execution of the ClangExpressionDeclMap because they provide the template for a materialized set of expression variables. - m_material_vars are specific to a single instance of materialization, and only exist between calls to Materialize() and Dematerialize(). I also removed unnecessary references to long- lived state that really didn't need to be referred to at all, and also introduced several assert()s that helped me diagnose a few bugs (fixed too). Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/ClangUtilityFunction.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=120778&r1=120777&r2=120778&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Thu Dec 2 19:38:59 2010 @@ -71,17 +71,27 @@ /// Constructor /// /// Initializes class variabes. + //------------------------------------------------------------------ + ClangExpressionDeclMap(); + + //------------------------------------------------------------------ + /// Destructor + //------------------------------------------------------------------ + ~ClangExpressionDeclMap(); + + //------------------------------------------------------------------ + /// Enable the state needed for parsing and IR transformation. /// /// @param[in] exe_ctx /// The execution context to use when finding types for variables. /// Also used to find a "scratch" AST context to store result types. //------------------------------------------------------------------ - ClangExpressionDeclMap(ExecutionContext *exe_ctx); + void WillParse(ExecutionContext &exe_ctx); //------------------------------------------------------------------ - /// Destructor + /// Disable the state needed for parsing and IR transformation. //------------------------------------------------------------------ - ~ClangExpressionDeclMap(); + void DidParse(); //------------------------------------------------------------------ /// [Used by IRForTarget] Get a new result variable name of the form @@ -270,7 +280,7 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool Materialize(ExecutionContext *exe_ctx, + bool Materialize(ExecutionContext &exe_ctx, lldb::addr_t &struct_address, Error &error); @@ -292,7 +302,7 @@ /// True on success; false otherwise. //------------------------------------------------------------------ bool GetObjectPointer(lldb::addr_t &object_ptr, - ExecutionContext *exe_ctx, + ExecutionContext &exe_ctx, Error &error); //------------------------------------------------------------------ @@ -313,7 +323,7 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool DumpMaterializedStruct(ExecutionContext *exe_ctx, + bool DumpMaterializedStruct(ExecutionContext &exe_ctx, Stream &s, Error &error); @@ -334,7 +344,7 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool Dematerialize(ExecutionContext *exe_ctx, + bool Dematerialize(ExecutionContext &exe_ctx, ClangExpressionVariable *&result, Error &error); @@ -356,37 +366,153 @@ //------------------------------------------------------------------ void GetDecls (NameSearchContext &context, const ConstString &name); - + + //------------------------------------------------------------------ + /// [Used by ClangASTSource] Report whether a $__lldb variable has + /// been searched for yet. This is the trigger for beginning to + /// actually look for externally-defined names. (Names that come + /// before this are typically the names of built-ins that don't need + /// to be looked up.) + /// + /// @return + /// True if a $__lldb variable has been found. + //------------------------------------------------------------------ bool GetLookupsEnabled () { - return m_enable_lookups; + assert(m_parser_vars.get()); + return m_parser_vars->m_enable_lookups; } + //------------------------------------------------------------------ + /// [Used by ClangASTSource] Indicate that a $__lldb variable has + /// been found. + //------------------------------------------------------------------ void - SetLookupsEnabled (bool b) + SetLookupsEnabled () { - m_enable_lookups = b; + assert(m_parser_vars.get()); + m_parser_vars->m_enable_lookups = true; } private: - ClangExpressionVariableStore m_found_entities; ///< All entities that were looked up for the parser. - ClangExpressionVariableList m_struct_members; ///< All entities that need to be placed in the struct. + ClangExpressionVariableStore m_found_entities; ///< All entities that were looked up for the parser. + ClangExpressionVariableList m_struct_members; ///< All entities that need to be placed in the struct. - ExecutionContext m_exe_ctx; ///< The execution context where this expression was first defined. It determines types for all the external variables, even if the expression is re-used. - SymbolContext m_sym_ctx; ///< [owned by ClangExpressionDeclMap] The symbol context where this expression was first defined. - ClangPersistentVariables *m_persistent_vars; ///< The list of persistent variables to use when resolving symbols in the expression and when creating new ones (like the result). - off_t m_struct_alignment; ///< The alignment of the struct in bytes. - size_t m_struct_size; ///< The size of the struct in bytes. - bool m_struct_laid_out; ///< True if the struct has been laid out and the layout is valid (that is, no new fields have been added since). - bool m_enable_lookups; ///< Set to true during expression evaluation if we have found the first "$__lldb" name. - lldb::addr_t m_allocated_area; ///< The base of the memory allocated for the struct. Starts on a potentially unaligned address and may therefore be larger than the struct. - lldb::addr_t m_materialized_location; ///< The address at which the struct is placed. Falls inside the allocated area. - ConstString m_result_name; ///< The name of the result variable ($1, for example) - TypeFromUser m_object_pointer_type; ///< The type of the "this" variable, if one exists. + //---------------------------------------------------------------------- + /// The following values should not live beyond parsing + //---------------------------------------------------------------------- + struct ParserVars { + ParserVars() : + m_exe_ctx(NULL), + m_sym_ctx(), + m_persistent_vars(NULL), + m_enable_lookups(false), + m_ignore_lookups(false) + { + } + + ExecutionContext *m_exe_ctx; ///< The execution context to use when parsing. + SymbolContext m_sym_ctx; ///< The symbol context to use in finding variables and types. + ClangPersistentVariables *m_persistent_vars; ///< The persistent variables for the process. + bool m_enable_lookups; ///< Set to true during parsing if we have found the first "$__lldb" name. + bool m_ignore_lookups; ///< True during an import when we should be ignoring type lookups. + }; + + std::auto_ptr m_parser_vars; + + //---------------------------------------------------------------------- + /// Activate parser-specific variables + //---------------------------------------------------------------------- + void EnableParserVars() + { + if (!m_parser_vars.get()) + m_parser_vars.reset(new struct ParserVars); + } + + //---------------------------------------------------------------------- + /// Deallocate parser-specific variables + //---------------------------------------------------------------------- + void DisableParserVars() + { + m_parser_vars.reset(); + } + + //---------------------------------------------------------------------- + /// The following values contain layout information for the materialized + /// struct, but are not specific to a single materialization + //---------------------------------------------------------------------- + struct StructVars { + StructVars() : + m_struct_alignment(0), + m_struct_size(0), + m_struct_laid_out(false), + m_result_name(), + m_object_pointer_type(NULL, NULL) + { + } + + off_t m_struct_alignment; ///< The alignment of the struct in bytes. + size_t m_struct_size; ///< The size of the struct in bytes. + bool m_struct_laid_out; ///< True if the struct has been laid out and the layout is valid (that is, no new fields have been added since). + ConstString m_result_name; ///< The name of the result variable ($1, for example) + TypeFromUser m_object_pointer_type; ///< The type of the "this" variable, if one exists + }; + + std::auto_ptr m_struct_vars; + + //---------------------------------------------------------------------- + /// Activate struct variables + //---------------------------------------------------------------------- + void EnableStructVars() + { + if (!m_struct_vars.get()) + m_struct_vars.reset(new struct StructVars); + } + + //---------------------------------------------------------------------- + /// Deallocate struct variables + //---------------------------------------------------------------------- + void DisableStructVars() + { + m_struct_vars.reset(); + } + + //---------------------------------------------------------------------- + /// The following values refer to a specific materialization of the + /// structure in a process + //---------------------------------------------------------------------- + struct MaterialVars { + MaterialVars() : + m_allocated_area(NULL), + m_materialized_location(NULL) + { + } + + Process *m_process; ///< The process that the struct is materialized into. + lldb::addr_t m_allocated_area; ///< The base of the memory allocated for the struct. Starts on a potentially unaligned address and may therefore be larger than the struct. + lldb::addr_t m_materialized_location; ///< The address at which the struct is placed. Falls inside the allocated area. + }; + + std::auto_ptr m_material_vars; + + //---------------------------------------------------------------------- + /// Activate materialization-specific variables + //---------------------------------------------------------------------- + void EnableMaterialVars() + { + if (!m_material_vars.get()) + m_material_vars.reset(new struct MaterialVars); + } + + //---------------------------------------------------------------------- + /// Deallocate materialization-specific variables + //---------------------------------------------------------------------- + void DisableMaterialVars() + { + m_material_vars.reset(); + } - bool m_ignore_lookups; ///< True during an import when we should be ignoring type lookups. - //------------------------------------------------------------------ /// Given a stack frame, find a variable that matches the given name and /// type. We need this for expression re-use; we may not always get the @@ -544,9 +670,14 @@ /// True on success; false otherwise. //------------------------------------------------------------------ bool DoMaterialize (bool dematerialize, - ExecutionContext *exe_ctx, + ExecutionContext &exe_ctx, ClangExpressionVariable **result, Error &err); + + //------------------------------------------------------------------ + /// Clean up the state required to dematerialize the variable. + //------------------------------------------------------------------ + void DidDematerialize (); //------------------------------------------------------------------ /// Actually do the task of materializing or dematerializing a persistent Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=120778&r1=120777&r2=120778&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Thu Dec 2 19:38:59 2010 @@ -83,7 +83,7 @@ // any lookups so we can avoid lookup up all of the builtin types. if (!decl_name.empty() && decl_name[0] == '$') { - m_decl_map.SetLookupsEnabled (true); + m_decl_map.SetLookupsEnabled (); } else { Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=120778&r1=120777&r2=120778&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Dec 2 19:38:59 2010 @@ -43,62 +43,58 @@ using namespace lldb_private; using namespace clang; -ClangExpressionDeclMap::ClangExpressionDeclMap (ExecutionContext *exe_ctx) : +ClangExpressionDeclMap::ClangExpressionDeclMap () : m_found_entities (), m_struct_members (), - m_exe_ctx (), - m_sym_ctx (), - m_persistent_vars (NULL), - m_struct_alignment (0), - m_struct_size (0), - m_struct_laid_out (false), - m_enable_lookups (false), - m_allocated_area (0), - m_materialized_location (0), - m_result_name (), - m_object_pointer_type (), - m_ignore_lookups (false) -{ - if (exe_ctx) - { - m_exe_ctx = *exe_ctx; - if (exe_ctx->frame) - m_sym_ctx = exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything); - if (exe_ctx->process) - m_persistent_vars = &exe_ctx->process->GetPersistentVariables(); - } + m_parser_vars (), + m_struct_vars () +{ + EnableStructVars(); } ClangExpressionDeclMap::~ClangExpressionDeclMap() +{ + DidDematerialize(); + DisableStructVars(); +} + +void ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx) { - for (uint64_t entity_index = 0, num_entities = m_found_entities.Size(); - entity_index < num_entities; - ++entity_index) - { - ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(entity_index)); - if (entity.m_parser_vars.get() && - entity.m_parser_vars->m_lldb_value) - delete entity.m_parser_vars->m_lldb_value; - - entity.DisableParserVars(); - } + EnableParserVars(); + m_parser_vars->m_exe_ctx = &exe_ctx; - for (uint64_t pvar_index = 0, num_pvars = m_persistent_vars->Size(); - pvar_index < num_pvars; - ++pvar_index) - { - ClangExpressionVariable &pvar(m_persistent_vars->VariableAtIndex(pvar_index)); - pvar.DisableParserVars(); - } + if (exe_ctx.frame) + m_parser_vars->m_sym_ctx = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything); - if (m_materialized_location) - { -//#define SINGLE_STEP_EXPRESSIONS + if (exe_ctx.process) + m_parser_vars->m_persistent_vars = &exe_ctx.process->GetPersistentVariables(); +} -#ifndef SINGLE_STEP_EXPRESSIONS - m_exe_ctx.process->DeallocateMemory(m_materialized_location); -#endif - m_materialized_location = 0; +void ClangExpressionDeclMap::DidParse() +{ + if (m_parser_vars.get()) + { + for (uint64_t entity_index = 0, num_entities = m_found_entities.Size(); + entity_index < num_entities; + ++entity_index) + { + ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(entity_index)); + if (entity.m_parser_vars.get() && + entity.m_parser_vars->m_lldb_value) + delete entity.m_parser_vars->m_lldb_value; + + entity.DisableParserVars(); + } + + for (uint64_t pvar_index = 0, num_pvars = m_parser_vars->m_persistent_vars->Size(); + pvar_index < num_pvars; + ++pvar_index) + { + ClangExpressionVariable &pvar(m_parser_vars->m_persistent_vars->VariableAtIndex(pvar_index)); + pvar.DisableParserVars(); + } + + DisableParserVars(); } } @@ -107,9 +103,13 @@ const ConstString & ClangExpressionDeclMap::GetPersistentResultName () { - if (!m_result_name) - m_persistent_vars->GetNextResultName(m_result_name); - return m_result_name; + assert (m_struct_vars.get()); + assert (m_parser_vars.get()); + + if (!m_struct_vars->m_result_name) + m_parser_vars->m_persistent_vars->GetNextResultName(m_struct_vars->m_result_name); + + return m_struct_vars->m_result_name; } bool @@ -120,17 +120,19 @@ TypeFromParser parser_type ) { - clang::ASTContext *context(m_exe_ctx.target->GetScratchClangASTContext()->getASTContext()); + assert (m_parser_vars.get()); + + clang::ASTContext *context(m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext()); TypeFromUser user_type(ClangASTContext::CopyType(context, parser_type.GetASTContext(), parser_type.GetOpaqueQualType()), context); - if (!m_persistent_vars->CreatePersistentVariable (name, user_type)) + if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (name, user_type)) return false; - ClangExpressionVariable *var = m_persistent_vars->GetVariable(name); + ClangExpressionVariable *var = m_parser_vars->m_persistent_vars->GetVariable(name); if (!var) return false; @@ -153,9 +155,12 @@ off_t alignment ) { + assert (m_struct_vars.get()); + assert (m_parser_vars.get()); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - m_struct_laid_out = false; + m_struct_vars->m_struct_laid_out = false; if (m_struct_members.GetVariable(decl)) return true; @@ -163,7 +168,7 @@ ClangExpressionVariable *var = m_found_entities.GetVariable(decl); if (!var) - var = m_persistent_vars->GetVariable(decl); + var = m_parser_vars->m_persistent_vars->GetVariable(decl); if (!var) return false; @@ -190,13 +195,15 @@ bool ClangExpressionDeclMap::DoStructLayout () { - if (m_struct_laid_out) + assert (m_struct_vars.get()); + + if (m_struct_vars->m_struct_laid_out) return true; off_t cursor = 0; - m_struct_alignment = 0; - m_struct_size = 0; + m_struct_vars->m_struct_alignment = 0; + m_struct_vars->m_struct_size = 0; for (uint64_t member_index = 0, num_members = m_struct_members.Size(); member_index < num_members; @@ -208,7 +215,7 @@ return false; if (member_index == 0) - m_struct_alignment = member.m_jit_vars->m_alignment; + m_struct_vars->m_struct_alignment = member.m_jit_vars->m_alignment; if (cursor % member.m_jit_vars->m_alignment) cursor += (member.m_jit_vars->m_alignment - (cursor % member.m_jit_vars->m_alignment)); @@ -217,9 +224,9 @@ cursor += member.m_jit_vars->m_size; } - m_struct_size = cursor; + m_struct_vars->m_struct_size = cursor; - m_struct_laid_out = true; + m_struct_vars->m_struct_laid_out = true; return true; } @@ -230,12 +237,14 @@ off_t &alignment ) { - if (!m_struct_laid_out) + assert (m_struct_vars.get()); + + if (!m_struct_vars->m_struct_laid_out) return false; num_elements = m_struct_members.Size(); - size = m_struct_size; - alignment = m_struct_alignment; + size = m_struct_vars->m_struct_size; + alignment = m_struct_vars->m_struct_alignment; return true; } @@ -250,7 +259,9 @@ uint32_t index ) { - if (!m_struct_laid_out) + assert (m_struct_vars.get()); + + if (!m_struct_vars->m_struct_laid_out) return false; if (index >= m_struct_members.Size()) @@ -299,13 +310,15 @@ uint64_t &ptr ) { + assert (m_parser_vars.get()); + // Back out in all cases where we're not fully initialized - if (m_exe_ctx.frame == NULL) + if (m_parser_vars->m_exe_ctx->frame == NULL) return false; SymbolContextList sc_list; - m_sym_ctx.FindFunctionsByName(name, false, sc_list); + m_parser_vars->m_sym_ctx.FindFunctionsByName(name, false, sc_list); if (!sc_list.GetSize()) return false; @@ -322,7 +335,7 @@ else return false; - ptr = fun_address->GetLoadAddress (m_exe_ctx.target); + ptr = fun_address->GetLoadAddress (m_parser_vars->m_exe_ctx->target); return true; } @@ -332,15 +345,19 @@ bool ClangExpressionDeclMap::Materialize ( - ExecutionContext *exe_ctx, + ExecutionContext &exe_ctx, lldb::addr_t &struct_address, Error &err ) { + EnableMaterialVars(); + + m_material_vars->m_process = exe_ctx.process; + bool result = DoMaterialize(false, exe_ctx, NULL, err); if (result) - struct_address = m_materialized_location; + struct_address = m_material_vars->m_materialized_location; return result; } @@ -349,24 +366,26 @@ ClangExpressionDeclMap::GetObjectPointer ( lldb::addr_t &object_ptr, - ExecutionContext *exe_ctx, + ExecutionContext &exe_ctx, Error &err ) { - if (!exe_ctx || !exe_ctx->frame || !exe_ctx->target || !exe_ctx->process) + assert (m_struct_vars.get()); + + if (!exe_ctx.frame || !exe_ctx.target || !exe_ctx.process) { err.SetErrorString("Couldn't load 'this' because the context is incomplete"); return false; } - if (!m_object_pointer_type.GetOpaqueQualType()) + if (!m_struct_vars->m_object_pointer_type.GetOpaqueQualType()) { err.SetErrorString("Couldn't load 'this' because its type is unknown"); return false; } static ConstString g_this_const_str ("this"); - Variable *object_ptr_var = FindVariableInScope (*exe_ctx->frame, g_this_const_str, &m_object_pointer_type); + Variable *object_ptr_var = FindVariableInScope (*exe_ctx.frame, g_this_const_str, &m_struct_vars->m_object_pointer_type); if (!object_ptr_var) { @@ -374,9 +393,9 @@ return false; } - std::auto_ptr location_value(GetVariableValue(*exe_ctx, + std::auto_ptr location_value(GetVariableValue(exe_ctx, object_ptr_var, - m_object_pointer_type.GetASTContext())); + NULL)); if (!location_value.get()) { @@ -387,10 +406,11 @@ if (location_value->GetValueType() == Value::eValueTypeLoadAddress) { lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); - uint32_t address_byte_size = exe_ctx->target->GetArchitecture().GetAddressByteSize(); - lldb::ByteOrder address_byte_order = exe_ctx->process->GetByteOrder(); + uint32_t address_byte_size = exe_ctx.target->GetArchitecture().GetAddressByteSize(); + lldb::ByteOrder address_byte_order = exe_ctx.process->GetByteOrder(); - if (ClangASTType::GetClangTypeBitWidth(m_object_pointer_type.GetASTContext(), m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8) + if (ClangASTType::GetClangTypeBitWidth(m_struct_vars->m_object_pointer_type.GetASTContext(), + m_struct_vars->m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8) { err.SetErrorStringWithFormat("'this' is not of an expected pointer size"); return false; @@ -400,7 +420,7 @@ data.SetByteSize(address_byte_size); Error read_error; - if (exe_ctx->process->ReadMemory (value_addr, data.GetBytes(), address_byte_size, read_error) != address_byte_size) + if (exe_ctx.process->ReadMemory (value_addr, data.GetBytes(), address_byte_size, read_error) != address_byte_size) { err.SetErrorStringWithFormat("Coldn't read 'this' from the target: %s", read_error.AsCString()); return false; @@ -424,57 +444,74 @@ bool ClangExpressionDeclMap::Dematerialize ( - ExecutionContext *exe_ctx, + ExecutionContext &exe_ctx, ClangExpressionVariable *&result, Error &err ) { return DoMaterialize(true, exe_ctx, &result, err); + + DidDematerialize(); +} + +void +ClangExpressionDeclMap::DidDematerialize() +{ + if (m_material_vars.get()) + { + if (m_material_vars->m_materialized_location) + { + //#define SINGLE_STEP_EXPRESSIONS + +#ifndef SINGLE_STEP_EXPRESSIONS + m_material_vars->m_process->DeallocateMemory(m_material_vars->m_materialized_location); +#endif + m_material_vars->m_materialized_location = 0; + } + + DisableMaterialVars(); + } } bool ClangExpressionDeclMap::DumpMaterializedStruct ( - ExecutionContext *exe_ctx, + ExecutionContext &exe_ctx, Stream &s, Error &err ) { - if (!m_struct_laid_out) + assert (m_struct_vars.get()); + assert (m_material_vars.get()); + + if (!m_struct_vars->m_struct_laid_out) { err.SetErrorString("Structure hasn't been laid out yet"); return false; } - if (!exe_ctx) - { - err.SetErrorString("Received null execution context"); - return false; - } - - - if (!exe_ctx->process) + if (!exe_ctx.process) { err.SetErrorString("Couldn't find the process"); return false; } - if (!exe_ctx->target) + if (!exe_ctx.target) { err.SetErrorString("Couldn't find the target"); return false; } - lldb::DataBufferSP data(new DataBufferHeap(m_struct_size, 0)); + lldb::DataBufferSP data(new DataBufferHeap(m_struct_vars->m_struct_size, 0)); Error error; - if (exe_ctx->process->ReadMemory (m_materialized_location, data->GetBytes(), data->GetByteSize(), error) != data->GetByteSize()) + if (exe_ctx.process->ReadMemory (m_material_vars->m_materialized_location, data->GetBytes(), data->GetByteSize(), error) != data->GetByteSize()) { err.SetErrorStringWithFormat ("Couldn't read struct from the target: %s", error.AsCString()); return false; } - DataExtractor extractor(data, exe_ctx->process->GetByteOrder(), exe_ctx->target->GetArchitecture().GetAddressByteSize()); + DataExtractor extractor(data, exe_ctx.process->GetByteOrder(), exe_ctx.target->GetArchitecture().GetAddressByteSize()); for (uint64_t member_index = 0, num_members = m_struct_members.Size(); member_index < num_members; @@ -487,15 +524,15 @@ if (!member.m_jit_vars.get()) return false; - extractor.Dump(&s, // stream - member.m_jit_vars->m_offset, // offset - lldb::eFormatBytesWithASCII, // format - 1, // byte size of individual entries - member.m_jit_vars->m_size, // number of entries - 16, // entries per line - m_materialized_location + member.m_jit_vars->m_offset, // address to print - 0, // bit size (bitfields only; 0 means ignore) - 0); // bit alignment (bitfields only; 0 means ignore) + extractor.Dump(&s, // stream + member.m_jit_vars->m_offset, // offset + lldb::eFormatBytesWithASCII, // format + 1, // byte size of individual entries + member.m_jit_vars->m_size, // number of entries + 16, // entries per line + m_material_vars->m_materialized_location + member.m_jit_vars->m_offset, // address to print + 0, // bit size (bitfields only; 0 means ignore) + 0); // bit alignment (bitfields only; 0 means ignore) s.PutChar('\n'); } @@ -507,68 +544,66 @@ ClangExpressionDeclMap::DoMaterialize ( bool dematerialize, - ExecutionContext *exe_ctx, + ExecutionContext &exe_ctx, ClangExpressionVariable **result, Error &err ) { + assert (m_struct_vars.get()); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - if (!m_struct_laid_out) + if (!m_struct_vars->m_struct_laid_out) { err.SetErrorString("Structure hasn't been laid out yet"); return LLDB_INVALID_ADDRESS; } - if (!exe_ctx) - { - err.SetErrorString("Received null execution context"); - return LLDB_INVALID_ADDRESS; - } - - if (!exe_ctx->frame) + if (!exe_ctx.frame) { err.SetErrorString("Received null execution frame"); return LLDB_INVALID_ADDRESS; } - if (!m_struct_size) + ClangPersistentVariables &persistent_vars = exe_ctx.process->GetPersistentVariables(); + + if (!m_struct_vars->m_struct_size) { if (log) log->PutCString("Not bothering to allocate a struct because no arguments are needed"); - m_allocated_area = NULL; + m_material_vars->m_allocated_area = NULL; return true; } - const SymbolContext &sym_ctx(exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything)); + const SymbolContext &sym_ctx(exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything)); if (!dematerialize) { - if (m_materialized_location) + if (m_material_vars->m_materialized_location) { - exe_ctx->process->DeallocateMemory(m_materialized_location); - m_materialized_location = 0; + exe_ctx.process->DeallocateMemory(m_material_vars->m_materialized_location); + m_material_vars->m_materialized_location = 0; } if (log) log->PutCString("Allocating memory for materialized argument struct"); - lldb::addr_t mem = exe_ctx->process->AllocateMemory(m_struct_alignment + m_struct_size, - lldb::ePermissionsReadable | lldb::ePermissionsWritable, - err); + lldb::addr_t mem = exe_ctx.process->AllocateMemory(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size, + lldb::ePermissionsReadable | lldb::ePermissionsWritable, + err); if (mem == LLDB_INVALID_ADDRESS) return false; - m_allocated_area = mem; + m_material_vars->m_allocated_area = mem; } - m_materialized_location = m_allocated_area; + m_material_vars->m_materialized_location = m_material_vars->m_allocated_area; - if (m_materialized_location % m_struct_alignment) - m_materialized_location += (m_struct_alignment - (m_materialized_location % m_struct_alignment)); + if (m_material_vars->m_materialized_location % m_struct_vars->m_struct_alignment) + m_material_vars->m_materialized_location += (m_struct_vars->m_struct_alignment - (m_material_vars->m_materialized_location % m_struct_vars->m_struct_alignment)); for (uint64_t member_index = 0, num_members = m_struct_members.Size(); member_index < num_members; @@ -578,10 +613,14 @@ ClangExpressionVariable *entity = NULL; + /* if (member.m_parser_vars.get()) entity = m_found_entities.GetVariable(member.m_parser_vars->m_named_decl); + */ - ClangExpressionVariable *persistent_variable = m_persistent_vars->GetVariable(member.m_name); + entity = m_found_entities.GetVariable(member.m_name); + + ClangExpressionVariable *persistent_variable = persistent_vars.GetVariable(member.m_name); if (entity) { @@ -589,12 +628,12 @@ { // This is a register variable - RegisterContext *reg_ctx = exe_ctx->GetRegisterContext(); + RegisterContext *reg_ctx = exe_ctx.GetRegisterContext(); if (!reg_ctx) return false; - if (!DoMaterializeOneRegister(dematerialize, *exe_ctx, *reg_ctx, *entity->m_register_info, m_materialized_location + member.m_jit_vars->m_offset, err)) + if (!DoMaterializeOneRegister(dematerialize, exe_ctx, *reg_ctx, *entity->m_register_info, m_material_vars->m_materialized_location + member.m_jit_vars->m_offset, err)) return false; } else @@ -602,13 +641,13 @@ if (!member.m_jit_vars.get()) return false; - if (!DoMaterializeOneVariable(dematerialize, *exe_ctx, sym_ctx, member.m_name, member.m_user_type, m_materialized_location + member.m_jit_vars->m_offset, err)) + if (!DoMaterializeOneVariable(dematerialize, exe_ctx, sym_ctx, member.m_name, member.m_user_type, m_material_vars->m_materialized_location + member.m_jit_vars->m_offset, err)) return false; } } else if (persistent_variable) { - if (member.m_name == m_result_name) + if (member.m_name == m_struct_vars->m_result_name) { if (!dematerialize) continue; @@ -622,7 +661,7 @@ if (log) log->Printf("Searched for persistent variable %s and found %s", member.m_name.GetCString(), persistent_variable->m_name.GetCString()); - if (!DoMaterializeOnePersistentVariable(dematerialize, *exe_ctx, persistent_variable->m_name, m_materialized_location + member.m_jit_vars->m_offset, err)) + if (!DoMaterializeOnePersistentVariable(dematerialize, exe_ctx, persistent_variable->m_name, m_material_vars->m_materialized_location + member.m_jit_vars->m_offset, err)) return false; } else @@ -644,8 +683,10 @@ lldb::addr_t addr, Error &err ) -{ - ClangExpressionVariable *pvar(m_persistent_vars->GetVariable(name)); +{ + ClangPersistentVariables &persistent_vars = exe_ctx.process->GetPersistentVariables(); + + ClangExpressionVariable *pvar(persistent_vars.GetVariable(name)); if (!pvar) { @@ -711,7 +752,7 @@ std::auto_ptr location_value(GetVariableValue(exe_ctx, var, - type.GetASTContext())); + NULL)); if (!location_value.get()) { @@ -1006,7 +1047,7 @@ const ConstString &name, TypeFromUser *type ) -{ +{ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); VariableList *var_list = frame.GetVariableList(true); @@ -1021,7 +1062,7 @@ if (!var_sp) { // Look for globals elsewhere in the module for the frame - ModuleSP module_sp (m_exe_ctx.frame->GetSymbolContext(eSymbolContextModule).module_sp); + ModuleSP module_sp (frame.GetSymbolContext(eSymbolContextModule).module_sp); if (module_sp) { VariableList module_globals; @@ -1033,7 +1074,7 @@ if (!var_sp) { // Look for globals elsewhere in the program (all images) - TargetSP target_sp (m_exe_ctx.frame->GetSymbolContext(eSymbolContextTarget).target_sp); + TargetSP target_sp (frame.GetSymbolContext(eSymbolContextTarget).target_sp); if (target_sp) { VariableList program_globals; @@ -1064,16 +1105,19 @@ void ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString &name) { + assert (m_struct_vars.get()); + assert (m_parser_vars.get()); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); if (log) log->Printf("Hunting for a definition for '%s'", name.GetCString()); // Back out in all cases where we're not fully initialized - if (m_exe_ctx.frame == NULL) + if (m_parser_vars->m_exe_ctx->frame == NULL) return; - if (m_ignore_lookups) + if (m_parser_vars->m_ignore_lookups) { if (log) log->Printf("Ignoring a query during an import"); @@ -1091,7 +1135,7 @@ // doesn't start with our phony prefix of '$' if (name_unique_cstr[0] != '$') { - Variable *var = FindVariableInScope(*m_exe_ctx.frame, name); + Variable *var = FindVariableInScope(*m_parser_vars->m_exe_ctx->frame, name); // If we found a variable in scope, no need to pull up function names if (var != NULL) @@ -1100,7 +1144,7 @@ } else { - m_sym_ctx.FindFunctionsByName (name, false, sc_list); + m_parser_vars->m_sym_ctx.FindFunctionsByName (name, false, sc_list); bool found_specific = false; Symbol *generic_symbol = NULL; @@ -1138,7 +1182,7 @@ AddOneFunction(context, NULL, non_extern_symbol); } - ClangNamespaceDecl namespace_decl (m_sym_ctx.FindNamespace(name)); + ClangNamespaceDecl namespace_decl (m_parser_vars->m_sym_ctx.FindNamespace(name)); if (namespace_decl) { clang::NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decl); @@ -1158,7 +1202,7 @@ { // Clang is looking for the type of "this" - VariableList *vars = m_exe_ctx.frame->GetVariableList(false); + VariableList *vars = m_parser_vars->m_exe_ctx->frame->GetVariableList(false); if (!vars) return; @@ -1184,7 +1228,7 @@ TypeFromUser this_user_type(this_type->GetClangType(), this_type->GetClangAST()); - m_object_pointer_type = this_user_type; + m_struct_vars->m_object_pointer_type = this_user_type; void *pointer_target_type; @@ -1200,7 +1244,7 @@ return; } - ClangExpressionVariable *pvar(m_persistent_vars->GetVariable(name)); + ClangExpressionVariable *pvar(m_parser_vars->m_persistent_vars->GetVariable(name)); if (pvar) { @@ -1210,16 +1254,16 @@ const char *reg_name(&name.GetCString()[1]); - if (m_exe_ctx.GetRegisterContext()) + if (m_parser_vars->m_exe_ctx->GetRegisterContext()) { - const lldb::RegisterInfo *reg_info(m_exe_ctx.GetRegisterContext()->GetRegisterInfoByName(reg_name)); + const lldb::RegisterInfo *reg_info(m_parser_vars->m_exe_ctx->GetRegisterContext()->GetRegisterInfoByName(reg_name)); if (reg_info) AddOneRegister(context, reg_info); } } - lldb::TypeSP type_sp (m_sym_ctx.FindTypeByName (name)); + lldb::TypeSP type_sp (m_parser_vars->m_sym_ctx.FindTypeByName (name)); if (type_sp) { @@ -1347,7 +1391,7 @@ Address so_addr(var_location->GetScalar().ULongLong(), object_file->GetSectionList()); - lldb::addr_t load_addr = so_addr.GetLoadAddress(m_exe_ctx.target); + lldb::addr_t load_addr = so_addr.GetLoadAddress(exe_ctx.target); var_location->GetScalar() = load_addr; var_location->SetValueType(Value::eValueTypeLoadAddress); @@ -1363,12 +1407,14 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, Variable* var) { + assert (m_parser_vars.get()); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); TypeFromUser ut; TypeFromParser pt; - Value *var_location = GetVariableValue (m_exe_ctx, + Value *var_location = GetVariableValue (*m_parser_vars->m_exe_ctx, var, context.GetASTContext(), &ut, @@ -1494,6 +1540,8 @@ Function* fun, Symbol* symbol) { + assert (m_parser_vars.get()); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); NamedDecl *fun_decl; @@ -1545,7 +1593,7 @@ return; } - lldb::addr_t load_addr = fun_address->GetLoadAddress(m_exe_ctx.target); + lldb::addr_t load_addr = fun_address->GetLoadAddress(m_parser_vars->m_exe_ctx->target); fun_location->SetValueType(Value::eValueTypeLoadAddress); fun_location->GetScalar() = load_addr; @@ -1619,13 +1667,15 @@ ASTContext *source_context, void *clang_type) { - m_ignore_lookups = true; + assert (m_parser_vars.get()); + + m_parser_vars->m_ignore_lookups = true; void *ret = ClangASTContext::CopyType (dest_context, source_context, clang_type); - m_ignore_lookups = false; + m_parser_vars->m_ignore_lookups = false; return ret; } Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=120778&r1=120777&r2=120778&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Thu Dec 2 19:38:59 2010 @@ -225,7 +225,9 @@ m_desired_type = desired_type; - m_expr_decl_map.reset(new ClangExpressionDeclMap(&exe_ctx)); + m_expr_decl_map.reset(new ClangExpressionDeclMap()); + + m_expr_decl_map->WillParse(exe_ctx); ClangExpressionParser parser(target_triple.GetCString(), *this); @@ -234,6 +236,9 @@ if (num_errors) { error_stream.Printf ("error: %d errors parsing expression\n", num_errors); + + m_expr_decl_map->DidParse(); + return false; } @@ -254,6 +259,8 @@ if (log) log->Printf("Code can be interpreted."); + m_expr_decl_map->DidParse(); + return true; } @@ -267,6 +274,8 @@ Error jit_error = parser.MakeJIT (m_jit_addr, jit_end, exe_ctx); + m_expr_decl_map->DidParse(); + if (jit_error.Success()) { return true; @@ -292,13 +301,13 @@ Error materialize_error; - if (m_needs_object_ptr && !(m_expr_decl_map->GetObjectPointer(object_ptr, &exe_ctx, materialize_error))) + if (m_needs_object_ptr && !(m_expr_decl_map->GetObjectPointer(object_ptr, exe_ctx, materialize_error))) { error_stream.Printf("Couldn't get required object pointer: %s\n", materialize_error.AsCString()); return false; } - if (!m_expr_decl_map->Materialize(&exe_ctx, struct_address, materialize_error)) + if (!m_expr_decl_map->Materialize(exe_ctx, struct_address, materialize_error)) { error_stream.Printf("Couldn't materialize struct: %s\n", materialize_error.AsCString()); return false; @@ -319,7 +328,7 @@ if (struct_address) { - if (!m_expr_decl_map->DumpMaterializedStruct(&exe_ctx, args, dump_error)) + if (!m_expr_decl_map->DumpMaterializedStruct(exe_ctx, args, dump_error)) { log->Printf("Couldn't extract variable values : %s", dump_error.AsCString("unknown error")); } @@ -362,7 +371,7 @@ { Error expr_error; - if (!m_expr_decl_map->Dematerialize(&exe_ctx, result, expr_error)) + if (!m_expr_decl_map->Dematerialize(exe_ctx, result, expr_error)) { error_stream.Printf ("Couldn't dematerialize struct : %s\n", expr_error.AsCString("unknown error")); return false; Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=120778&r1=120777&r2=120778&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Thu Dec 2 19:38:59 2010 @@ -99,7 +99,9 @@ // Parse the expression // - m_expr_decl_map.reset(new ClangExpressionDeclMap(&exe_ctx)); + m_expr_decl_map.reset(new ClangExpressionDeclMap()); + + m_expr_decl_map->WillParse(exe_ctx); ClangExpressionParser parser(target_triple.GetCString(), *this); @@ -120,6 +122,8 @@ Error jit_error = parser.MakeJIT (m_jit_begin, m_jit_end, exe_ctx); + m_expr_decl_map->DidParse(); + m_expr_decl_map.reset(); if (jit_error.Success()) From scallanan at apple.com Thu Dec 2 21:02:32 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 03 Dec 2010 03:02:32 -0000 Subject: [Lldb-commits] [lldb] r120788 - /lldb/trunk/source/Expression/IRForTarget.cpp Message-ID: <20101203030232.179872A6C12D@llvm.org> Author: spyffe Date: Thu Dec 2 21:02:31 2010 New Revision: 120788 URL: http://llvm.org/viewvc/llvm-project?rev=120788&view=rev Log: Removed a compiler warning. Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=120788&r1=120787&r2=120788&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Thu Dec 2 21:02:31 2010 @@ -913,7 +913,7 @@ value_alignment)) return false; } - else if (llvm::Function *function = dyn_cast(llvm_value_ptr)) + else if (dyn_cast(llvm_value_ptr)) { if (log) log->Printf("Function pointers aren't handled right now"); From gclayton at apple.com Fri Dec 3 00:02:24 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Dec 2010 06:02:24 -0000 Subject: [Lldb-commits] [lldb] r120793 - in /lldb/trunk: include/lldb/Host/Host.h lldb.xcodeproj/project.pbxproj source/Host/common/Host.cpp source/Host/macosx/Host.mm source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp tools/debugserver/debugserver.xcodeproj/project.pbxproj tools/debugserver/source/DNBLog.cpp Message-ID: <20101203060224.56D342A6C12D@llvm.org> Author: gclayton Date: Fri Dec 3 00:02:24 2010 New Revision: 120793 URL: http://llvm.org/viewvc/llvm-project?rev=120793&view=rev Log: Fixed a race condition that could cause ProcessGDBRemote::DoResume() to return an error saying the resume timed out. Previously the thread that was trying to resume the process would eventually call ProcessGDBRemote::DoResume() which would broadcast an event over to the async GDB remote thread which would sent the continue packet to the remote gdb server. Right after this was sent, it would set a predicate boolean value (protected by a mutex and condition) and then the thread that issued the ProcessGDBRemote::DoResume() would then wait for that condition variable to be set. If the async gdb thread was too quick though, the predicate boolean value could have been set to true and back to false by the time the thread that issued the ProcessGDBRemote::DoResume() checks the boolean value. So we can't use the predicate value as a handshake. I have changed the code over to using a Event by having the GDB remote communication object post an event: GDBRemoteCommunication::eBroadcastBitRunPacketSent This allows reliable handshaking between the two threads and avoids the erroneous ProcessGDBRemote::DoResume() errors. Added a host backtrace service to allow in process backtraces when trying to track down tricky issues. I need to see if LLVM has any backtracing abilities abstracted in it already, and if so, use that, but I needed something ASAP for the current issue I was working on. The static function is: void Host::Backtrace (Stream &strm, uint32_t max_frames); And it will backtrace at most "max_frames" frames for the current thread and can be used with any of the Stream subclasses for logging. Modified: lldb/trunk/include/lldb/Host/Host.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/macosx/Host.mm 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/ProcessGDBRemote.cpp lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj lldb/trunk/tools/debugserver/source/DNBLog.cpp Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=120793&r1=120792&r2=120793&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Fri Dec 3 00:02:24 2010 @@ -315,7 +315,6 @@ static void SetCrashDescription (const char *description); - static uint32_t ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids); @@ -339,6 +338,8 @@ static bool OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no); + static void + Backtrace (Stream &strm, uint32_t max_frames); }; } // namespace lldb_private Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=120793&r1=120792&r2=120793&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Dec 3 00:02:24 2010 @@ -2459,7 +2459,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=120793&r1=120792&r2=120793&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Fri Dec 3 00:02:24 2010 @@ -402,6 +402,13 @@ Host::ThreadCreated (const char *thread_name) { } + +void +Host::Backtrace (Stream &strm, uint32_t max_frames) +{ + // TODO: Is there a way to backtrace the current process on linux? +} + #endif struct HostThreadCreateInfo Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=120793&r1=120792&r2=120793&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Fri Dec 3 00:02:24 2010 @@ -9,10 +9,13 @@ #include "lldb/Host/Host.h" +#include #include +#include #include #include #include +#include #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Communication.h" @@ -772,3 +775,33 @@ return true; } + + +void +Host::Backtrace (Stream &strm, uint32_t max_frames) +{ + char backtrace_path[] = "/tmp/lldb-backtrace-tmp-XXXXXX"; + int backtrace_fd = ::mkstemp (backtrace_path); + if (backtrace_fd != -1) + { + std::vector frame_buffer (max_frames, NULL); + int count = ::backtrace (&frame_buffer[0], frame_buffer.size()); + ::backtrace_symbols_fd (&frame_buffer[0], count, backtrace_fd); + + const off_t buffer_size = ::lseek(backtrace_fd, 0, SEEK_CUR); + + if (::lseek(backtrace_fd, 0, SEEK_SET) == 0) + { + char *buffer = (char *)::malloc (buffer_size); + if (buffer) + { + ssize_t bytes_read = ::read (backtrace_fd, buffer, buffer_size); + if (bytes_read > 0) + strm.Write(buffer, bytes_read); + ::free (buffer); + } + } + ::close (backtrace_fd); + ::unlink (backtrace_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=120793&r1=120792&r2=120793&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Fri Dec 3 00:02:24 2010 @@ -199,13 +199,13 @@ log->Printf ("GDBRemoteCommunication::%s ()", __FUNCTION__); Mutex::Locker locker(m_sequence_mutex); -// ScopedValueChanger restore_running_to_false (m_is_running, false); StateType state = eStateRunning; if (SendPacket(payload, packet_length) == 0) state = eStateInvalid; - m_is_running.SetValue (true, eBroadcastAlways); + BroadcastEvent(eBroadcastBitRunPacketSent, NULL); + m_is_running.SetValue (true, eBroadcastNever); while (state == eStateRunning) { @@ -357,7 +357,7 @@ if (log) log->Printf ("GDBRemoteCommunication::%s () => %s", __FUNCTION__, StateAsCString(state)); response.SetFilePos(0); - m_is_running.SetValue (false, eBroadcastOnChange); + m_is_running.SetValue (false, eBroadcastAlways); return state; } @@ -858,16 +858,3 @@ return false; } -bool -GDBRemoteCommunication::WaitForIsRunning (uint32_t timeout_sec) -{ - TimeValue timeout; - if (timeout_sec) - { - timeout = TimeValue::Now(); - timeout.OffsetWithSeconds (timeout_sec); - } - return m_is_running.WaitForValueEqualTo (true, &timeout, NULL); -} - - 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=120793&r1=120792&r2=120793&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Fri Dec 3 00:02:24 2010 @@ -34,6 +34,10 @@ public lldb_private::Communication { public: + enum + { + eBroadcastBitRunPacketSent = kLoUserBroadcastBit + }; //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ @@ -203,9 +207,6 @@ } bool - WaitForIsRunning (uint32_t timeout_sec); - - bool GetHostInfo (uint32_t timeout_seconds); bool Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=120793&r1=120792&r2=120793&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Dec 3 00:02:24 2010 @@ -878,10 +878,20 @@ { Error error; ProcessGDBRemoteLog::LogIf (GDBR_LOG_PROCESS, "ProcessGDBRemote::Resume()"); - m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncContinue, new EventDataBytes (m_continue_packet.GetData(), m_continue_packet.GetSize())); - const uint32_t timedout_sec = 1; - if (m_gdb_comm.WaitForIsRunning (timedout_sec) == false) - error.SetErrorString("Resume timed out."); + + Listener listener ("gdb-remote.resume-packet-sent"); + if (listener.StartListeningForEvents (&m_gdb_comm, GDBRemoteCommunication::eBroadcastBitRunPacketSent)) + { + EventSP event_sp; + TimeValue timeout; + timeout = TimeValue::Now(); + timeout.OffsetWithSeconds (5); + m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncContinue, new EventDataBytes (m_continue_packet.GetData(), m_continue_packet.GetSize())); + + if (listener.WaitForEvent (&timeout, event_sp) == false) + error.SetErrorString("Resume timed out."); + } + return error; } @@ -1206,7 +1216,7 @@ SetExitStatus(-1, "process killed"); StringExtractorGDBRemote response; - if (m_gdb_comm.SendPacketAndWaitForResponse("k", response, 2, false)) + if (m_gdb_comm.SendPacketAndWaitForResponse("k", response, 1, false)) { log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS); if (log) Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=120793&r1=120792&r2=120793&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Dec 3 00:02:24 2010 @@ -372,7 +372,6 @@ isa = PBXProject; buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "debugserver" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, Modified: lldb/trunk/tools/debugserver/source/DNBLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBLog.cpp?rev=120793&r1=120792&r2=120793&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNBLog.cpp (original) +++ lldb/trunk/tools/debugserver/source/DNBLog.cpp Fri Dec 3 00:02:24 2010 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -166,7 +167,27 @@ if (arg_msg != NULL) { - _DNBLog (DNBLOG_FLAG_THREADED, "%u [%4.4x/%4.4x]: %s", ++g_message_id, getpid(), mach_thread_self(), arg_msg); + static struct timeval g_timeval = { 0 , 0 }; + static struct timeval tv; + static struct timeval delta; + gettimeofday(&tv, NULL); + if (g_timeval.tv_sec == 0) + { + delta.tv_sec = 0; + delta.tv_usec = 0; + } + else + { + timersub (&tv, &g_timeval, &delta); + } + g_timeval = tv; + _DNBLog (DNBLOG_FLAG_THREADED, "%u +%u.%06u sec [%4.4x/%4.4x]: %s", + ++g_message_id, + delta.tv_sec, + delta.tv_usec, + getpid(), + mach_thread_self(), + arg_msg); free (arg_msg); } } @@ -191,7 +212,27 @@ if (arg_msg != NULL) { - _DNBLog (DNBLOG_FLAG_THREADED, "%u [%4.4x/%4.4x]: %s", ++g_message_id, getpid(), mach_thread_self(), arg_msg); + static struct timeval g_timeval = { 0 , 0 }; + static struct timeval tv; + static struct timeval delta; + gettimeofday(&tv, NULL); + if (g_timeval.tv_sec == 0) + { + delta.tv_sec = 0; + delta.tv_usec = 0; + } + else + { + timersub (&tv, &g_timeval, &delta); + } + g_timeval = tv; + _DNBLog (DNBLOG_FLAG_THREADED, "%u +%u.%06u sec [%4.4x/%4.4x]: %s", + ++g_message_id, + delta.tv_sec, + delta.tv_usec, + getpid(), + mach_thread_self(), + arg_msg); free (arg_msg); } } From gclayton at apple.com Fri Dec 3 11:47:00 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Dec 2010 17:47:00 -0000 Subject: [Lldb-commits] [lldb] r120813 - /lldb/trunk/include/lldb/Host/Predicate.h Message-ID: <20101203174700.7E6022A6C12D@llvm.org> Author: gclayton Date: Fri Dec 3 11:47:00 2010 New Revision: 120813 URL: http://llvm.org/viewvc/llvm-project?rev=120813&view=rev Log: Make sure timed_out is initialized to false just to be on the safe side. Modified: lldb/trunk/include/lldb/Host/Predicate.h Modified: lldb/trunk/include/lldb/Host/Predicate.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Predicate.h?rev=120813&r1=120812&r2=120813&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Predicate.h (original) +++ lldb/trunk/include/lldb/Host/Predicate.h Fri Dec 3 11:47:00 2010 @@ -309,6 +309,9 @@ #ifdef DB_PTHREAD_LOG_EVENTS printf("%s (value = 0x%8.8x, abstime = %p), m_value = 0x%8.8x", __FUNCTION__, value, abstime, m_value); #endif + if (timed_out) + *timed_out = false; + while (err == 0 && m_value != value) { err = m_condition.Wait (m_mutex.GetMutex(), abstime, timed_out); From gclayton at apple.com Fri Dec 3 11:49:14 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Dec 2010 17:49:14 -0000 Subject: [Lldb-commits] [lldb] r120814 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20101203174914.E71212A6C12D@llvm.org> Author: gclayton Date: Fri Dec 3 11:49:14 2010 New Revision: 120814 URL: http://llvm.org/viewvc/llvm-project?rev=120814&view=rev Log: Fixed an issue that would cause an assertion to fire when an inlined function was found during a regex function find call. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 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=120814&r1=120813&r2=120814&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Dec 3 11:49:14 2010 @@ -2025,20 +2025,52 @@ curr_cu->ExtractDIEsIfNeeded (false); die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + + const DWARFDebugInfoEntry* inlined_die = NULL; + if (die->Tag() == DW_TAG_inlined_subroutine) + { + inlined_die = die; + + while ((die = die->GetParent()) != NULL) + { + if (die->Tag() == DW_TAG_subprogram) + break; + } + } + assert (die->Tag() == DW_TAG_subprogram); if (GetFunction (curr_cu, die, sc)) { - // We found the function, so we should find the line table - // and line table entry as well - LineTable *line_table = sc.comp_unit->GetLineTable(); - if (line_table == NULL) + Address addr; + // Parse all blocks if needed + if (inlined_die) { - if (ParseCompileUnitLineTable(sc)) - line_table = sc.comp_unit->GetLineTable(); + sc.block = sc.function->GetBlock (true).FindBlockByID (inlined_die->GetOffset()); + assert (sc.block != NULL); + if (sc.block->GetStartAddress (addr) == false) + addr.Clear(); + } + else + { + sc.block = NULL; + addr = sc.function->GetAddressRange().GetBaseAddress(); } - if (line_table != NULL) - line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry); - sc_list.Append(sc); + if (addr.IsValid()) + { + + // We found the function, so we should find the line table + // and line table entry as well + LineTable *line_table = sc.comp_unit->GetLineTable(); + if (line_table == NULL) + { + if (ParseCompileUnitLineTable(sc)) + line_table = sc.comp_unit->GetLineTable(); + } + if (line_table != NULL) + line_table->FindLineEntryByAddress (addr, sc.line_entry); + + sc_list.Append(sc); + } } } } From ctice at apple.com Fri Dec 3 12:46:09 2010 From: ctice at apple.com (Caroline Tice) Date: Fri, 03 Dec 2010 18:46:09 -0000 Subject: [Lldb-commits] [lldb] r120825 - in /lldb/trunk: include/lldb/Target/Process.h include/lldb/lldb-enumerations.h source/Commands/CommandObjectProcess.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.h source/Target/Process.cpp tools/debugserver/source/DNB.cpp tools/debugserver/source/DNB.h tools/debugserver/source/MacOSX/MachProcess.cpp tools/debugserver/source/MacOSX/MachProcess.h tools/debugserver/source/debugserver.cpp Message-ID: <20101203184609.D57CC2A6C12D@llvm.org> Author: ctice Date: Fri Dec 3 12:46:09 2010 New Revision: 120825 URL: http://llvm.org/viewvc/llvm-project?rev=120825&view=rev Log: Add '-no-stdio' option to 'process launch' command, which causes the inferior to be launched without setting up terminal stdin/stdout for it (leaving the lldb command line accessible while the program is executing). Also add a user settings variable, 'target.process.disable-stdio' to allow the user to set this globally rather than having to use the command option each time the process is launched. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/trunk/source/Target/Process.cpp lldb/trunk/tools/debugserver/source/DNB.cpp lldb/trunk/tools/debugserver/source/DNB.h lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h lldb/trunk/tools/debugserver/source/debugserver.cpp Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Fri Dec 3 12:46:09 2010 @@ -176,6 +176,18 @@ { m_disable_aslr = b; } + + bool + GetDisableSTDIO () const + { + return m_disable_stdio; + } + + void + SetDisableSTDIO (bool b) + { + m_disable_stdio = b; + } protected: @@ -207,7 +219,9 @@ static const ConstString & DisableASLRVarName(); - + static const ConstString & + DisableSTDIOVarName (); + private: typedef std::map dictionary; @@ -218,6 +232,7 @@ std::string m_error_path; ProcessPlugins m_plugin; bool m_disable_aslr; + bool m_disable_stdio; }; Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Dec 3 12:46:09 2010 @@ -55,7 +55,8 @@ typedef enum LaunchFlags { eLaunchFlagNone = 0u, - eLaunchFlagDisableASLR = (1u << 0) ///< Disable Address Space Layout Randomization + eLaunchFlagDisableASLR = (1u << 0), ///< Disable Address Space Layout Randomization + eLaunchFlagDisableSTDIO = (1u << 1) /// Disable stdio for inferior process (e.g. for a GUI app) } LaunchFlags; //---------------------------------------------------------------------- Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Dec 3 12:46:09 2010 @@ -62,6 +62,7 @@ case 'i': stdin_path = option_arg; break; case 'o': stdout_path = option_arg; break; case 'p': plugin_name = option_arg; break; + case 'n': no_stdio = true; break; case 't': if (option_arg && option_arg[0]) tty_name.assign (option_arg); @@ -86,6 +87,7 @@ stdout_path.clear(); stderr_path.clear(); plugin_name.clear(); + no_stdio = false; } const lldb::OptionDefinition* @@ -102,6 +104,7 @@ bool stop_at_entry; bool in_new_tty; + bool no_stdio; std::string tty_name; std::string stderr_path; std::string stdin_path; @@ -214,6 +217,18 @@ if (process->GetDisableASLR()) launch_flags |= eLaunchFlagDisableASLR; + if (m_options.no_stdio) + launch_flags |= eLaunchFlagDisableSTDIO; + else if (!m_options.in_new_tty + && m_options.stdin_path.empty() + && m_options.stdout_path.empty() + && m_options.stderr_path.empty()) + { + // Only use the settings value if the user hasn't specified any options that would override it. + if (process->GetDisableSTDIO()) + launch_flags |= eLaunchFlagDisableSTDIO; + } + const char **inferior_argv = launch_args.GetArgumentCount() ? launch_args.GetConstArgumentVector() : NULL; const char **inferior_envp = environment.GetArgumentCount() ? environment.GetConstArgumentVector() : NULL; @@ -320,21 +335,24 @@ #define SET1 LLDB_OPT_SET_1 #define SET2 LLDB_OPT_SET_2 +#define SET3 LLDB_OPT_SET_3 lldb::OptionDefinition CommandObjectProcessLaunch::CommandOptions::g_option_table[] = { -{ SET1 | SET2, false, "stop-at-entry", 's', no_argument, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."}, -{ SET1 , false, "stdin", 'i', required_argument, NULL, 0, eArgTypePath, "Redirect stdin for the process to ."}, -{ SET1 , false, "stdout", 'o', required_argument, NULL, 0, eArgTypePath, "Redirect stdout for the process to ."}, -{ SET1 , false, "stderr", 'e', required_argument, NULL, 0, eArgTypePath, "Redirect stderr for the process to ."}, -{ SET1 | SET2, false, "plugin", 'p', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, -{ SET2, false, "tty", 't', optional_argument, NULL, 0, eArgTypePath, "Start the process in a terminal. If is specified, look for a terminal whose name contains , else start the process in a new terminal."}, -{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', no_argument, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."}, +{ SET1 , false, "stdin", 'i', required_argument, NULL, 0, eArgTypePath, "Redirect stdin for the process to ."}, +{ SET1 , false, "stdout", 'o', required_argument, NULL, 0, eArgTypePath, "Redirect stdout for the process to ."}, +{ SET1 , false, "stderr", 'e', required_argument, NULL, 0, eArgTypePath, "Redirect stderr for the process to ."}, +{ SET1 | SET2 | SET3, false, "plugin", 'p', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, +{ SET2 , false, "tty", 't', optional_argument, NULL, 0, eArgTypePath, "Start the process in a terminal. If is specified, look for a terminal whose name contains , else start the process in a new terminal."}, +{ SET3, false, "no-stdio", 'n', no_argument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; #undef SET1 #undef SET2 +#undef SET3 //------------------------------------------------------------------------- // CommandObjectProcessAttach Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Dec 3 12:46:09 2010 @@ -404,7 +404,7 @@ launch_process, LLDB_INVALID_PROCESS_ID, NULL, false, - (launch_flags & eLaunchFlagDisableASLR) != 0, + launch_flags, inferior_arch); if (error.Fail()) return error; @@ -424,7 +424,7 @@ launch_process, LLDB_INVALID_PROCESS_ID, NULL, false, - (launch_flags & eLaunchFlagDisableASLR) != 0, + launch_flags, inferior_arch); if (error.Fail()) return error; @@ -647,7 +647,7 @@ LLDB_INVALID_PROCESS_ID, // Don't send any attach to pid options to debugserver NULL, // Don't send any attach by process name option to debugserver false, // Don't send any attach wait_for_launch flag as an option to debugserver - false, // disable_aslr + 0, // launch_flags arch_spec); if (error.Fail()) @@ -749,7 +749,7 @@ LLDB_INVALID_PROCESS_ID, // Don't send any attach to pid options to debugserver NULL, // Don't send any attach by process name option to debugserver false, // Don't send any attach wait_for_launch flag as an option to debugserver - false, // disable_aslr + 0, // launch_flags arch_spec); if (error.Fail()) { @@ -1659,11 +1659,13 @@ lldb::pid_t attach_pid, // If inferior inferior_argv == NULL, and attach_pid != LLDB_INVALID_PROCESS_ID send this pid as an argument to debugserver const char *attach_name, // Wait for the next process to launch whose basename matches "attach_name" bool wait_for_launch, // Wait for the process named "attach_name" to launch - bool disable_aslr, // Disable ASLR + uint32_t launch_flags, // Launch flags ArchSpec& inferior_arch // The arch of the inferior that we will launch ) { Error error; + bool disable_aslr = (launch_flags & eLaunchFlagDisableASLR) != 0; + bool no_stdio = (launch_flags & eLaunchFlagDisableSTDIO) != 0; if (m_debugserver_pid == LLDB_INVALID_PROCESS_ID) { // If we locate debugserver, keep that located version around @@ -1744,7 +1746,7 @@ char arg_cstr[PATH_MAX]; lldb_utility::PseudoTerminal pty; - if (launch_process && stdio_path == NULL && m_local_debugserver) + if (launch_process && stdio_path == NULL && m_local_debugserver && !no_stdio) { if (pty.OpenFirstAvailableMaster(O_RDWR|O_NOCTTY, NULL, 0)) stdio_path = pty.GetSlaveName (NULL, 0); @@ -1768,6 +1770,10 @@ debugserver_args.AppendArgument("--stdio-path"); debugserver_args.AppendArgument(stdio_path); } + else if (launch_process && no_stdio) + { + debugserver_args.AppendArgument("--no-stdio"); + } const char *env_debugserver_log_file = getenv("LLDB_DEBUGSERVER_LOG_FILE"); if (env_debugserver_log_file) @@ -1859,7 +1865,7 @@ if (error.Fail() || log) error.PutToLog(log.get(), "::posix_spawnp ( pid => %i, path = '%s', file_actions = %p, attr = %p, argv = %p, envp = %p )", m_debugserver_pid, debugserver_path, NULL, &attr, inferior_argv, inferior_envp); - if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID) + if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID && !no_stdio) { if (pty.GetMasterFileDescriptor() != lldb_utility::PseudoTerminal::invalid_fd) SetUpProcessInputReader (pty.ReleaseMasterFileDescriptor()); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Fri Dec 3 12:46:09 2010 @@ -291,7 +291,7 @@ lldb::pid_t attach_pid, // If inferior inferior_argv == NULL, then attach to this pid const char *attach_pid_name, // Wait for the next process to launch whose basename matches "attach_wait_name" bool wait_for_launch, // Wait for the process named "attach_wait_name" to launch - bool disable_aslr, // Disable ASLR + uint32_t launch_flags, lldb_private::ArchSpec& arch_spec); void Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Fri Dec 3 12:46:09 2010 @@ -2600,7 +2600,8 @@ m_output_path (), m_error_path (), m_plugin (), - m_disable_aslr (true) + m_disable_aslr (true), + m_disable_stdio (false) { // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called // until the vtables for ProcessInstanceSettings are properly set up, i.e. AFTER all the initializers. @@ -2629,7 +2630,8 @@ m_output_path (rhs.m_output_path), m_error_path (rhs.m_error_path), m_plugin (rhs.m_plugin), - m_disable_aslr (rhs.m_disable_aslr) + m_disable_aslr (rhs.m_disable_aslr), + m_disable_stdio (rhs.m_disable_stdio) { if (m_instance_name != InstanceSettings::GetDefaultName()) { @@ -2655,6 +2657,7 @@ m_error_path = rhs.m_error_path; m_plugin = rhs.m_plugin; m_disable_aslr = rhs.m_disable_aslr; + m_disable_stdio = rhs.m_disable_stdio; } return *this; @@ -2685,6 +2688,8 @@ UserSettingsController::UpdateEnumVariable (entry.enum_values, (int *) &m_plugin, value, err); else if (var_name == DisableASLRVarName()) UserSettingsController::UpdateBooleanVariable (op, m_disable_aslr, value, err); + else if (var_name == DisableSTDIOVarName ()) + UserSettingsController::UpdateBooleanVariable (op, m_disable_stdio, value, err); } void @@ -2703,6 +2708,7 @@ m_error_path = new_process_settings->m_error_path; m_plugin = new_process_settings->m_plugin; m_disable_aslr = new_process_settings->m_disable_aslr; + m_disable_stdio = new_process_settings->m_disable_stdio; } bool @@ -2755,6 +2761,13 @@ else value.AppendString ("false"); } + else if (var_name == DisableSTDIOVarName()) + { + if (m_disable_stdio) + value.AppendString ("true"); + else + value.AppendString ("false"); + } else { if (err) @@ -2834,6 +2847,13 @@ return disable_aslr_var_name; } +const ConstString & +ProcessInstanceSettings::DisableSTDIOVarName () +{ + static ConstString disable_stdio_var_name ("disable-stdio"); + + return disable_stdio_var_name; +} //-------------------------------------------------- // SettingsController Variable Tables @@ -2864,8 +2884,9 @@ { "input-path", eSetVarTypeString, "/dev/stdin", NULL, false, false, "The file/path to be used by the executable program for reading its input." }, { "output-path", eSetVarTypeString, "/dev/stdout", NULL, false, false, "The file/path to be used by the executable program for writing its output." }, { "error-path", eSetVarTypeString, "/dev/stderr", NULL, false, false, "The file/path to be used by the executable program for writings its error messages." }, - { "plugin", eSetVarTypeEnum, NULL , g_plugins, false, false, "The plugin to be used to run the process." }, - { "disable-aslr", eSetVarTypeBoolean, "true", NULL, false, false, "Disable Address Space Layout Randomization (ASLR)" }, + { "plugin", eSetVarTypeEnum, NULL , g_plugins, false, false, "The plugin to be used to run the process." }, + { "disable-aslr", eSetVarTypeBoolean, "true", NULL, false, false, "Disable Address Space Layout Randomization (ASLR)" }, + { "disable-stdio",eSetVarTypeBoolean, "false", NULL, false, false, "Disable stdin/stdout for process (e.g. for a GUI application)" }, { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } }; Modified: lldb/trunk/tools/debugserver/source/DNB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.cpp (original) +++ lldb/trunk/tools/debugserver/source/DNB.cpp Fri Dec 3 12:46:09 2010 @@ -176,6 +176,7 @@ char const *argv[], const char *envp[], const char *stdio_path, + bool no_stdio, nub_launch_flavor_t launch_flavor, int disable_aslr, char *err_str, @@ -198,7 +199,7 @@ if (processSP.get()) { DNBError launch_err; - pid_t pid = processSP->LaunchForDebug(path, argv, envp, stdio_path, launch_flavor, disable_aslr, launch_err); + pid_t pid = processSP->LaunchForDebug(path, argv, envp, stdio_path, no_stdio, launch_flavor, disable_aslr, launch_err); if (err_str) { *err_str = '\0'; Modified: lldb/trunk/tools/debugserver/source/DNB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.h?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.h (original) +++ lldb/trunk/tools/debugserver/source/DNB.h Fri Dec 3 12:46:09 2010 @@ -33,7 +33,7 @@ //---------------------------------------------------------------------- // Process control //---------------------------------------------------------------------- -nub_process_t DNBProcessLaunch (const char *path, char const *argv[], const char *envp[], const char *stdio_path, nub_launch_flavor_t launch_flavor, int disable_aslr, char *err_str, size_t err_len) DNB_EXPORT; +nub_process_t DNBProcessLaunch (const char *path, char const *argv[], const char *envp[], const char *stdio_path, bool no_stdio, nub_launch_flavor_t launch_flavor, int disable_aslr, char *err_str, size_t err_len) DNB_EXPORT; nub_process_t DNBProcessAttach (nub_process_t pid, struct timespec *timeout, char *err_str, size_t err_len) DNB_EXPORT; nub_process_t DNBProcessAttachByName (const char *name, struct timespec *timeout, char *err_str, size_t err_len) DNB_EXPORT; nub_process_t DNBProcessAttachWait (const char *wait_name, nub_launch_flavor_t launch_flavor, struct timespec *timeout, useconds_t interval, char *err_str, size_t err_len, DNBShouldCancelCallback should_cancel = NULL, void *callback_data = NULL) DNB_EXPORT; Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Fri Dec 3 12:46:09 2010 @@ -1495,6 +1495,7 @@ char const *argv[], char const *envp[], const char *stdio_path, + bool no_stdio, nub_launch_flavor_t launch_flavor, int disable_aslr, DNBError &launch_err @@ -1519,7 +1520,8 @@ DNBArchProtocol::GetArchitecture (), argv, envp, - stdio_path, + stdio_path, + no_stdio, this, disable_aslr, launch_err); @@ -1533,7 +1535,7 @@ if (app_ext != NULL) { std::string app_bundle_path(path, app_ext + strlen(".app")); - return SBLaunchForDebug (app_bundle_path.c_str(), argv, envp, launch_err); + return SBLaunchForDebug (app_bundle_path.c_str(), argv, envp, no_stdio, launch_err); } } break; @@ -1609,6 +1611,7 @@ char const *argv[], char const *envp[], const char *stdio_path, + bool no_stdio, MachProcess* process, int disable_aslr, DNBError& err @@ -1665,7 +1668,7 @@ pid_t pid = INVALID_NUB_PROCESS; if (file_actions_valid) { - if (stdio_path == NULL) + if (stdio_path == NULL && !no_stdio) { pty_error = pty.OpenFirstAvailableMaster(O_RDWR|O_NOCTTY); if (pty_error == PseudoTerminal::success) @@ -1675,7 +1678,25 @@ stdio_path = "/dev/null"; } - if (stdio_path != NULL) + // if no_stdio, then do open file actions, opening /dev/null. + if (no_stdio) + { + err.SetError( ::posix_spawn_file_actions_addopen (&file_actions, STDIN_FILENO, "/dev/null", + O_RDONLY | O_NOCTTY, 0), DNBError::POSIX); + if (err.Fail() || DNBLogCheckLogBit (LOG_PROCESS)) + err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDIN_FILENO, path=/dev/null)"); + + err.SetError( ::posix_spawn_file_actions_addopen (&file_actions, STDOUT_FILENO, "/dev/null", + O_WRONLY | O_NOCTTY, 0), DNBError::POSIX); + if (err.Fail() || DNBLogCheckLogBit (LOG_PROCESS)) + err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDOUT_FILENO, path=/dev/null)"); + + err.SetError( ::posix_spawn_file_actions_addopen (&file_actions, STDERR_FILENO, "/dev/null", + O_RDWR | O_NOCTTY, 0), DNBError::POSIX); + if (err.Fail() || DNBLogCheckLogBit (LOG_PROCESS)) + err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDERR_FILENO, path=/dev/null)"); + } + else if (stdio_path != NULL) { int slave_fd_err = open (stdio_path, O_RDWR, 0); int slave_fd_in = open (stdio_path, O_RDONLY, 0); @@ -1807,7 +1828,7 @@ #if defined (__arm__) pid_t -MachProcess::SBLaunchForDebug (const char *path, char const *argv[], char const *envp[], DNBError &launch_err) +MachProcess::SBLaunchForDebug (const char *path, char const *argv[], char const *envp[], bool no_stdio, DNBError &launch_err) { // Clear out and clean up from any current state Clear(); @@ -1816,7 +1837,7 @@ // Fork a child process for debugging SetState(eStateLaunching); - m_pid = MachProcess::SBForkChildForPTraceDebugging(path, argv, envp, this, launch_err); + m_pid = MachProcess::SBForkChildForPTraceDebugging(path, argv, envp, no_stdio, this, launch_err); if (m_pid != 0) { m_flags |= eMachProcessFlagsUsingSBS; @@ -1892,7 +1913,7 @@ } pid_t -MachProcess::SBForkChildForPTraceDebugging (const char *app_bundle_path, char const *argv[], char const *envp[], MachProcess* process, DNBError &launch_err) +MachProcess::SBForkChildForPTraceDebugging (const char *app_bundle_path, char const *argv[], char const *envp[], bool no_stdio, MachProcess* process, DNBError &launch_err) { DNBLogThreadedIf(LOG_PROCESS, "%s( '%s', argv, %p)", __FUNCTION__, app_bundle_path, process); CFAllocatorRef alloc = kCFAllocatorDefault; @@ -1961,18 +1982,21 @@ CFString stdio_path; PseudoTerminal pty; - PseudoTerminal::Error pty_err = pty.OpenFirstAvailableMaster(O_RDWR|O_NOCTTY); - if (pty_err == PseudoTerminal::success) + if (!no_stdio) { - const char* slave_name = pty.SlaveName(); - DNBLogThreadedIf(LOG_PROCESS, "%s() successfully opened master pty, slave is %s", __FUNCTION__, slave_name); - if (slave_name && slave_name[0]) + PseudoTerminal::Error pty_err = pty.OpenFirstAvailableMaster(O_RDWR|O_NOCTTY); + if (pty_err == PseudoTerminal::success) { - ::chmod (slave_name, S_IRWXU | S_IRWXG | S_IRWXO); - stdio_path.SetFileSystemRepresentation (slave_name); + const char* slave_name = pty.SlaveName(); + DNBLogThreadedIf(LOG_PROCESS, "%s() successfully opened master pty, slave is %s", __FUNCTION__, slave_name); + if (slave_name && slave_name[0]) + { + ::chmod (slave_name, S_IRWXU | S_IRWXG | S_IRWXO); + stdio_path.SetFileSystemRepresentation (slave_name); + } } } - + if (stdio_path.get() == NULL) { stdio_path.SetFileSystemRepresentation ("/dev/null"); Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h Fri Dec 3 12:46:09 2010 @@ -46,16 +46,16 @@ // Child process control //---------------------------------------------------------------------- pid_t AttachForDebug (pid_t pid, char *err_str, size_t err_len); - pid_t LaunchForDebug (const char *path, char const *argv[], char const *envp[], const char *stdio_path, nub_launch_flavor_t launch_flavor, int disable_aslr, DNBError &err); + pid_t LaunchForDebug (const char *path, char const *argv[], char const *envp[], const char *stdio_path, bool no_stdio, nub_launch_flavor_t launch_flavor, int disable_aslr, DNBError &err); static pid_t ForkChildForPTraceDebugging (const char *path, char const *argv[], char const *envp[], MachProcess* process, DNBError &err); - static pid_t PosixSpawnChildForPTraceDebugging (const char *path, cpu_type_t cpu_type, char const *argv[], char const *envp[], const char *stdio_path, MachProcess* process, int disable_aslr, DNBError& err); + static pid_t PosixSpawnChildForPTraceDebugging (const char *path, cpu_type_t cpu_type, char const *argv[], char const *envp[], const char *stdio_path, bool no_stdio, MachProcess* process, int disable_aslr, DNBError& err); nub_addr_t GetDYLDAllImageInfosAddress (); static const void * PrepareForAttach (const char *path, nub_launch_flavor_t launch_flavor, bool waitfor, DNBError &err_str); static void CleanupAfterAttach (const void *attach_token, bool success, DNBError &err_str); static nub_process_t CheckForProcess (const void *attach_token); #if defined (__arm__) - pid_t SBLaunchForDebug (const char *app_bundle_path, char const *argv[], char const *envp[], DNBError &launch_err); - static pid_t SBForkChildForPTraceDebugging (const char *path, char const *argv[], char const *envp[], MachProcess* process, DNBError &launch_err); + pid_t SBLaunchForDebug (const char *app_bundle_path, char const *argv[], char const *envp[], bool no_stdio, DNBError &launch_err); + static pid_t SBForkChildForPTraceDebugging (const char *path, char const *argv[], char const *envp[], bool no_stdio, MachProcess* process, DNBError &launch_err); #endif nub_addr_t LookupSymbol (const char *name, const char *shlib); void SetNameToAddressCallback (DNBCallbackNameToAddress callback, void *baton) Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=120825&r1=120824&r2=120825&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/debugserver.cpp (original) +++ lldb/trunk/tools/debugserver/source/debugserver.cpp Fri Dec 3 12:46:09 2010 @@ -151,7 +151,7 @@ // or crash process state. //---------------------------------------------------------------------- RNBRunLoopMode -RNBRunLoopLaunchInferior (RNBRemoteSP &remote, const char *stdio_path) +RNBRunLoopLaunchInferior (RNBRemoteSP &remote, const char *stdio_path, bool no_stdio) { RNBContext& ctx = remote->Context(); @@ -209,6 +209,7 @@ &inferior_argv[0], &inferior_envp[0], stdio_path, + no_stdio, launch_flavor, g_disable_aslr, launch_err_str, @@ -656,6 +657,7 @@ { "waitfor-duration", required_argument, NULL, 'd' }, // The time in seconds to wait for a process to show up by name { "native-regs", no_argument, NULL, 'r' }, // Specify to use the native registers instead of the gdb defaults for the architecture. { "stdio-path", required_argument, NULL, 's' }, // Set the STDIO path to be used when launching applications + { "no-stdio", no_argument, NULL, 'n' }, // Do not set up any stdio (perhaps the program is a GUI program) { "setsid", no_argument, NULL, 'S' }, // call setsid() to make debugserver run in its own sessions { "disable-aslr", no_argument, NULL, 'D' }, // Use _POSIX_SPAWN_DISABLE_ASLR to avoid shared library randomization { NULL, 0, NULL, 0 } @@ -698,6 +700,7 @@ std::string arch_name; useconds_t waitfor_interval = 1000; // Time in usecs between process lists polls when waiting for a process by name, default 1 msec. useconds_t waitfor_duration = 0; // Time in seconds to wait for a process by name, 0 means wait forever. + bool no_stdio = false; #if !defined (DNBLOG_ENABLED) compile_options += "(no-logging) "; @@ -705,7 +708,7 @@ RNBRunLoopMode start_mode = eRNBRunLoopModeExit; - while ((ch = getopt_long(argc, argv, "a:A:d:gi:vktl:f:w:x:rs:", g_long_options, &long_option_index)) != -1) + while ((ch = getopt_long(argc, argv, "a:A:d:gi:vktl:f:w:x:rs:n", g_long_options, &long_option_index)) != -1) { DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n", ch, (uint8_t)ch, @@ -856,6 +859,10 @@ stdio_path = optarg; break; + case 'n': + no_stdio = true; + break; + case 'S': // Put debugserver into a new session. Terminals group processes // into sessions and when a special terminal key sequences @@ -1208,7 +1215,7 @@ break; case eRNBRunLoopModeInferiorLaunching: - mode = RNBRunLoopLaunchInferior (g_remoteSP, stdio_path.empty() ? NULL : stdio_path.c_str()); + mode = RNBRunLoopLaunchInferior (g_remoteSP, stdio_path.empty() ? NULL : stdio_path.c_str(), no_stdio); if (mode == eRNBRunLoopModeInferiorExecuting) { From scallanan at apple.com Fri Dec 3 13:51:05 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 03 Dec 2010 19:51:05 -0000 Subject: [Lldb-commits] [lldb] r120834 - /lldb/trunk/source/Expression/IRForTarget.cpp Message-ID: <20101203195105.C158D2A6C12D@llvm.org> Author: spyffe Date: Fri Dec 3 13:51:05 2010 New Revision: 120834 URL: http://llvm.org/viewvc/llvm-project?rev=120834&view=rev Log: Eliminated a redundant code path. Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=120834&r1=120833&r2=120834&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Fri Dec 3 13:51:05 2010 @@ -861,7 +861,7 @@ return false; } } - if (GlobalVariable *global_variable = dyn_cast(llvm_value_ptr)) + else if (GlobalVariable *global_variable = dyn_cast(llvm_value_ptr)) { clang::NamedDecl *named_decl = DeclForGlobalValue(llvm_module, global_variable); From johnny.chen at apple.com Fri Dec 3 13:59:35 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 03 Dec 2010 19:59:35 -0000 Subject: [Lldb-commits] [lldb] r120837 - /lldb/trunk/test/dotest.py Message-ID: <20101203195936.067E12A6C12D@llvm.org> Author: johnny Date: Fri Dec 3 13:59:35 2010 New Revision: 120837 URL: http://llvm.org/viewvc/llvm-project?rev=120837&view=rev Log: Add the '-F' option to the test driver, which makes the running of test suite failfast. As soon as an error or a failure is encountered, it stops the test suite. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=120837&r1=120836&r2=120837&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Dec 3 13:59:35 2010 @@ -64,6 +64,9 @@ # Delay startup in order for the debugger to attach. delay = False +# By default, failfast is False. Use '-F' to overwrite it. +failfast = False + # The filter (testclass.testmethod) used to admit tests into our test suite. filterspec = None @@ -114,6 +117,7 @@ -c : read a config file specified after this option (see also lldb-trunk/example/test/usage-config) -d : delay startup for 10 seconds (in order for the debugger to attach) +-F : failfast, stop the test suite on the first error/failure -f : specify a filter, which consists of the test class name, a dot, followed by the test method, to only admit such test into the test suite e.g., -f 'ClassTypesTestCase.test_with_dwarf_and_python_api' @@ -232,6 +236,7 @@ global configFile global count global delay + global failfast global filterspec global fs4all global ignore @@ -280,6 +285,9 @@ elif sys.argv[index].startswith('-d'): delay = True index += 1 + elif sys.argv[index].startswith('-F'): + failfast = True + index += 1 elif sys.argv[index].startswith('-f'): # Increment by 1 to fetch the filter spec. index += 1 @@ -780,7 +788,9 @@ # Invoke the test runner. if count == 1: - result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose, + result = unittest2.TextTestRunner(stream=sys.stderr, + verbosity=verbose, + failfast=failfast, resultclass=LLDBTestResult).run(suite) else: # We are invoking the same test suite more than once. In this case, @@ -788,7 +798,9 @@ # not enforced. LLDBTestResult.__ignore_singleton__ = True for i in range(count): - result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose, + result = unittest2.TextTestRunner(stream=sys.stderr, + verbosity=verbose, + failfast=failfast, resultclass=LLDBTestResult).run(suite) From gclayton at apple.com Fri Dec 3 15:42:06 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Dec 2010 21:42:06 -0000 Subject: [Lldb-commits] [lldb] r120840 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20101203214206.804022A6C12D@llvm.org> Author: gclayton Date: Fri Dec 3 15:42:06 2010 New Revision: 120840 URL: http://llvm.org/viewvc/llvm-project?rev=120840&view=rev Log: Make sure to index the DWARF if we already haven't so we can resolve forward declarations when they haven't been found yet. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=120840&r1=120839&r2=120840&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Dec 3 15:42:06 2010 @@ -2459,6 +2459,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=120840&r1=120839&r2=120840&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Dec 3 15:42:06 2010 @@ -2754,6 +2754,9 @@ if (curr_cu == NULL || die == NULL || !type_name) return type_sp; + if (!m_indexed) + Index (); + const dw_tag_t type_tag = die->Tag(); std::vector die_info_array; const size_t num_matches = m_type_index.Find (type_name, die_info_array); From jingham at apple.com Fri Dec 3 16:37:19 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 03 Dec 2010 22:37:19 -0000 Subject: [Lldb-commits] [lldb] r120850 - /lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Message-ID: <20101203223719.3064F2A6C12C@llvm.org> Author: jingham Date: Fri Dec 3 16:37:19 2010 New Revision: 120850 URL: http://llvm.org/viewvc/llvm-project?rev=120850&view=rev Log: Document the fact that "breakpoint modify" with no breakpoint acts on the last created breakpoint. Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=120850&r1=120849&r2=120850&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Dec 3 16:37:19 2010 @@ -1486,7 +1486,8 @@ CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) : CommandObject (interpreter, "breakpoint modify", - "Modify the options on a breakpoint or set of breakpoints in the executable.", + "Modify the options on a breakpoint or set of breakpoints in the executable. " + "If no breakpoint is specified, acts on the last created breakpoint.", NULL) { CommandArgumentEntry arg; From jingham at apple.com Fri Dec 3 17:04:19 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 03 Dec 2010 23:04:19 -0000 Subject: [Lldb-commits] [lldb] r120851 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectBreakpoint.cpp source/Commands/CommandObjectBreakpoint.h Message-ID: <20101203230419.73F022A6C12C@llvm.org> Author: jingham Date: Fri Dec 3 17:04:19 2010 New Revision: 120851 URL: http://llvm.org/viewvc/llvm-project?rev=120851&view=rev Log: Documentation fix - explain how to unset conditions. Also fix unsetting -x and -t so they work. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=120851&r1=120850&r2=120851&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Dec 3 17:04:19 2010 @@ -2459,7 +2459,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=120851&r1=120850&r2=120851&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Dec 3 17:04:19 2010 @@ -1358,7 +1358,9 @@ Options (), m_ignore_count (0), m_thread_id(LLDB_INVALID_THREAD_ID), + m_thread_id_passed(false), m_thread_index (UINT32_MAX), + m_thread_index_passed(false), m_thread_name(), m_queue_name(), m_condition (), @@ -1426,9 +1428,19 @@ break; case 't' : { - m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0); - if (m_thread_id == LLDB_INVALID_THREAD_ID) - error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg); + if (optarg[0] == '\0') + { + m_thread_id = LLDB_INVALID_THREAD_ID; + m_thread_id_passed = true; + } + else + { + m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0); + if (m_thread_id == LLDB_INVALID_THREAD_ID) + error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg); + else + m_thread_id_passed = true; + } } break; case 'T': @@ -1447,10 +1459,19 @@ break; case 'x': { - m_thread_index = Args::StringToUInt32 (optarg, UINT32_MAX, 0); - if (m_thread_id == UINT32_MAX) - error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg); - + if (optarg[0] == '\n') + { + m_thread_index = UINT32_MAX; + m_thread_index_passed = true; + } + else + { + m_thread_index = Args::StringToUInt32 (optarg, UINT32_MAX, 0); + if (m_thread_id == UINT32_MAX) + error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg); + else + m_thread_index_passed = true; + } } break; default: @@ -1468,7 +1489,9 @@ m_ignore_count = 0; m_thread_id = LLDB_INVALID_THREAD_ID; + m_thread_id_passed = false; m_thread_index = UINT32_MAX; + m_thread_index_passed = false; m_thread_name.clear(); m_queue_name.clear(); m_condition.clear(); @@ -1487,7 +1510,8 @@ CommandObject (interpreter, "breakpoint modify", "Modify the options on a breakpoint or set of breakpoints in the executable. " - "If no breakpoint is specified, acts on the last created breakpoint.", + "If no breakpoint is specified, acts on the last created breakpoint. " + "With the exception of -e, -d and -i, passing an empty argument clears the modification.", NULL) { CommandArgumentEntry arg; @@ -1558,10 +1582,10 @@ BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get(); if (location) { - if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) + if (m_options.m_thread_id_passed) location->SetThreadID (m_options.m_thread_id); - if (m_options.m_thread_index != UINT32_MAX) + if (m_options.m_thread_index_passed) location->GetLocationOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); if (m_options.m_name_passed) @@ -1582,10 +1606,10 @@ } else { - if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) + if (m_options.m_thread_id_passed) bp->SetThreadID (m_options.m_thread_id); - if (m_options.m_thread_index != UINT32_MAX) + if (m_options.m_thread_index_passed) bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); if (m_options.m_name_passed) Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.h?rev=120851&r1=120850&r2=120851&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.h Fri Dec 3 17:04:19 2010 @@ -164,7 +164,9 @@ uint32_t m_ignore_count; lldb::tid_t m_thread_id; + bool m_thread_id_passed; uint32_t m_thread_index; + bool m_thread_index_passed; std::string m_thread_name; std::string m_queue_name; std::string m_condition; From johnny.chen at apple.com Fri Dec 3 17:57:17 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 03 Dec 2010 23:57:17 -0000 Subject: [Lldb-commits] [lldb] r120859 - /lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Message-ID: <20101203235717.43A8C2A6C12C@llvm.org> Author: johnny Date: Fri Dec 3 17:57:17 2010 New Revision: 120859 URL: http://llvm.org/viewvc/llvm-project?rev=120859&view=rev Log: Test that "breakpoint modify -c ''" clears the condition for the last created breakpoint, so that when the breakpoint hits, val = 1 instead of 3. Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=120859&r1=120858&r2=120859&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Fri Dec 3 17:57:17 2010 @@ -77,6 +77,25 @@ patterns = ["frame #0.*main.c:%d" % self.line1, "frame #1.*main.c:%d" % self.line2]) + # Test that "breakpoint modify -c ''" clears the condition for the last + # created breakpoint, so that when the breakpoint hits, val == 1. + self.runCmd("process kill") + self.runCmd("breakpoint modify -c ''") + self.expect("breakpoint list", BREAKPOINT_STATE_CORRECT, matching=False, + substrs = ["Condition:"]) + + # Now run the program again. + self.runCmd("run", RUN_SUCCEEDED) + + # The process should be stopped at this point. + self.expect("process status", PROCESS_STOPPED, + patterns = ['Process .* stopped']) + + # 'frame variable -t val' should return 1 since it is the first breakpoint hit. + self.expect("frame variable -t val", VARIABLES_DISPLAYED_CORRECTLY, + startstr = '(int) val = 1') + + def breakpoint_conditions_python(self): """Use Python APIs to set breakpoint conditions.""" exe = os.path.join(os.getcwd(), "a.out") From johnny.chen at apple.com Fri Dec 3 18:07:24 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 04 Dec 2010 00:07:24 -0000 Subject: [Lldb-commits] [lldb] r120861 - /lldb/trunk/test/lldbtest.py Message-ID: <20101204000724.D09992A6C12C@llvm.org> Author: johnny Date: Fri Dec 3 18:07:24 2010 New Revision: 120861 URL: http://llvm.org/viewvc/llvm-project?rev=120861&view=rev Log: Forgot to also check in this file along with the TestBreakpointConditions.py change. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=120861&r1=120860&r2=120861&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Dec 3 18:07:24 2010 @@ -141,6 +141,8 @@ BREAKPOINT_CREATED = "Breakpoint created successfully" +BREAKPOINT_STATE_CORRECT = "Breakpoint state is correct" + BREAKPOINT_PENDING_CREATED = "Pending breakpoint created successfully" BREAKPOINT_HIT_ONCE = "Breakpoint resolved with hit cout = 1" From gclayton at apple.com Fri Dec 3 18:10:17 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 04 Dec 2010 00:10:17 -0000 Subject: [Lldb-commits] [lldb] r120862 - in /lldb/trunk: include/lldb/Host/Host.h include/lldb/Target/Process.h source/Core/Debugger.cpp source/Host/common/Host.cpp source/Host/macosx/Host.mm source/Target/Process.cpp source/Target/Target.cpp source/Target/Thread.cpp tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20101204001017.4A7182A6C12C@llvm.org> Author: gclayton Date: Fri Dec 3 18:10:17 2010 New Revision: 120862 URL: http://llvm.org/viewvc/llvm-project?rev=120862&view=rev Log: Added the ability for a process to inherit the current host environment. This was done as an settings variable in the process for now. We will eventually move all environment stuff over to the target, but we will leave it with the process for now. The default setting is for a process to inherit the host environment. This can be disabled by setting the "inherit-env" setting to false in the process. Modified: lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=120862&r1=120861&r2=120862&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Fri Dec 3 18:10:17 2010 @@ -340,6 +340,9 @@ static void Backtrace (Stream &strm, uint32_t max_frames); + + static size_t + GetEnvironment (StringList &env); }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=120862&r1=120861&r2=120862&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Fri Dec 3 18:10:17 2010 @@ -88,19 +88,11 @@ m_run_args = args; } + void + GetHostEnvironmentIfNeeded (); + size_t - GetEnvironmentAsArgs (Args &env) const - { - dictionary::const_iterator pos, end = m_env_vars.end(); - for (pos = m_env_vars.begin(); pos != end; ++pos) - { - std::string env_var_equal_value (pos->first); - env_var_equal_value.append(1, '='); - env_var_equal_value.append (pos->second); - env.AppendArgument (env_var_equal_value.c_str()); - } - return env.GetArgumentCount(); - } + GetEnvironmentAsArgs (Args &env); const char * GetStandardInputPath () const @@ -205,6 +197,9 @@ EnvVarsVarName (); static const ConstString & + InheritHostEnvVarName (); + + static const ConstString & InputPathVarName (); static const ConstString & @@ -233,6 +228,8 @@ ProcessPlugins m_plugin; bool m_disable_aslr; bool m_disable_stdio; + bool m_inherit_host_env; + bool m_got_host_env; }; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=120862&r1=120861&r2=120862&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Dec 3 18:10:17 2010 @@ -1318,7 +1318,7 @@ bool live_instance, const char *name ) : - InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance), + InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance), m_term_width (80), m_prompt (), m_frame_format (), Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=120862&r1=120861&r2=120862&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Fri Dec 3 18:10:17 2010 @@ -409,6 +409,14 @@ // TODO: Is there a way to backtrace the current process on linux? } + +size_t +Host::GetEnvironment (StringList &env) +{ + // TODO: Is there a way to the host environment for this process on linux? + return 0; +} + #endif struct HostThreadCreateInfo Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=120862&r1=120861&r2=120862&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Fri Dec 3 18:10:17 2010 @@ -9,6 +9,7 @@ #include "lldb/Host/Host.h" +#include #include #include #include @@ -805,3 +806,15 @@ ::unlink (backtrace_path); } } + +size_t +Host::GetEnvironment (StringList &env) +{ + char **host_env = *_NSGetEnviron(); + char *env_entry; + size_t i; + for (i=0; (env_entry = host_env[i]) != NULL; ++i) + env.AppendString(env_entry); + return i; + +} Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=120862&r1=120861&r2=120862&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Fri Dec 3 18:10:17 2010 @@ -358,6 +358,51 @@ return -1; } + +void +Process::ProcessInstanceSettings::GetHostEnvironmentIfNeeded () +{ + if (m_inherit_host_env && !m_got_host_env) + { + m_got_host_env = true; + StringList host_env; + const size_t host_env_count = Host::GetEnvironment (host_env); + for (size_t idx=0; idxsecond); + env.AppendArgument (env_var_equal_value.c_str()); + } + return env.GetArgumentCount(); +} + + const char * Process::GetExitDescription () { @@ -2569,7 +2614,8 @@ Process::SettingsController::SettingsController () : UserSettingsController ("process", Target::GetSettingsController()) { - m_default_settings.reset (new ProcessInstanceSettings (*this, false, + m_default_settings.reset (new ProcessInstanceSettings (*this, + false, InstanceSettings::GetDefaultName().AsCString())); } @@ -2591,9 +2637,13 @@ // class ProcessInstanceSettings //-------------------------------------------------------------- -ProcessInstanceSettings::ProcessInstanceSettings (UserSettingsController &owner, bool live_instance, - const char *name) : - InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance), +ProcessInstanceSettings::ProcessInstanceSettings +( + UserSettingsController &owner, + bool live_instance, + const char *name +) : + InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance), m_run_args (), m_env_vars (), m_input_path (), @@ -2601,7 +2651,9 @@ m_error_path (), m_plugin (), m_disable_aslr (true), - m_disable_stdio (false) + m_disable_stdio (false), + m_inherit_host_env (true), + m_got_host_env (false) { // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called // until the vtables for ProcessInstanceSettings are properly set up, i.e. AFTER all the initializers. @@ -2658,6 +2710,7 @@ m_plugin = rhs.m_plugin; m_disable_aslr = rhs.m_disable_aslr; m_disable_stdio = rhs.m_disable_stdio; + m_inherit_host_env = rhs.m_inherit_host_env; } return *this; @@ -2677,7 +2730,10 @@ if (var_name == RunArgsVarName()) UserSettingsController::UpdateStringArrayVariable (op, index_value, m_run_args, value, err); else if (var_name == EnvVarsVarName()) + { + GetHostEnvironmentIfNeeded (); UserSettingsController::UpdateDictionaryVariable (op, index_value, m_env_vars, value, err); + } else if (var_name == InputPathVarName()) UserSettingsController::UpdateStringVariable (op, m_input_path, value, err); else if (var_name == OutputPathVarName()) @@ -2686,6 +2742,8 @@ UserSettingsController::UpdateStringVariable (op, m_error_path, value, err); else if (var_name == PluginVarName()) UserSettingsController::UpdateEnumVariable (entry.enum_values, (int *) &m_plugin, value, err); + else if (var_name == InheritHostEnvVarName()) + UserSettingsController::UpdateBooleanVariable (op, m_inherit_host_env, value, err); else if (var_name == DisableASLRVarName()) UserSettingsController::UpdateBooleanVariable (op, m_disable_aslr, value, err); else if (var_name == DisableSTDIOVarName ()) @@ -2727,6 +2785,8 @@ } else if (var_name == EnvVarsVarName()) { + GetHostEnvironmentIfNeeded (); + if (m_env_vars.size() > 0) { std::map::iterator pos; @@ -2807,6 +2867,14 @@ } const ConstString & +ProcessInstanceSettings::InheritHostEnvVarName () +{ + static ConstString g_name ("inherit-env"); + + return g_name; +} + +const ConstString & ProcessInstanceSettings::InputPathVarName () { static ConstString input_path_var_name ("input-path"); @@ -2878,16 +2946,17 @@ SettingEntry Process::SettingsController::instance_settings_table[] = { - //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"}, - { "run-args", eSetVarTypeArray, NULL, NULL, false, false, "A list containing all the arguments to be passed to the executable when it is run." }, - { "env-vars", eSetVarTypeDictionary, NULL, NULL, false, false, "A list of all the environment variables to be passed to the executable's environment, and their values." }, - { "input-path", eSetVarTypeString, "/dev/stdin", NULL, false, false, "The file/path to be used by the executable program for reading its input." }, - { "output-path", eSetVarTypeString, "/dev/stdout", NULL, false, false, "The file/path to be used by the executable program for writing its output." }, - { "error-path", eSetVarTypeString, "/dev/stderr", NULL, false, false, "The file/path to be used by the executable program for writings its error messages." }, - { "plugin", eSetVarTypeEnum, NULL , g_plugins, false, false, "The plugin to be used to run the process." }, - { "disable-aslr", eSetVarTypeBoolean, "true", NULL, false, false, "Disable Address Space Layout Randomization (ASLR)" }, - { "disable-stdio",eSetVarTypeBoolean, "false", NULL, false, false, "Disable stdin/stdout for process (e.g. for a GUI application)" }, - { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } + //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"}, + { "run-args", eSetVarTypeArray, NULL, NULL, false, false, "A list containing all the arguments to be passed to the executable when it is run." }, + { "env-vars", eSetVarTypeDictionary, NULL, NULL, false, false, "A list of all the environment variables to be passed to the executable's environment, and their values." }, + { "inherit-env", eSetVarTypeBoolean, "true", NULL, false, false, "Inherit the environment from the process that is running LLDB." }, + { "input-path", eSetVarTypeString, "/dev/stdin", NULL, false, false, "The file/path to be used by the executable program for reading its input." }, + { "output-path", eSetVarTypeString, "/dev/stdout", NULL, false, false, "The file/path to be used by the executable program for writing its output." }, + { "error-path", eSetVarTypeString, "/dev/stderr", NULL, false, false, "The file/path to be used by the executable program for writings its error messages." }, + { "plugin", eSetVarTypeEnum, NULL , g_plugins, false, false, "The plugin to be used to run the process." }, + { "disable-aslr", eSetVarTypeBoolean, "true", NULL, false, false, "Disable Address Space Layout Randomization (ASLR)" }, + { "disable-stdio", eSetVarTypeBoolean, "false", NULL, false, false, "Disable stdin/stdout for process (e.g. for a GUI application)" }, + { NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL } }; Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=120862&r1=120861&r2=120862&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Fri Dec 3 18:10:17 2010 @@ -938,9 +938,13 @@ // class TargetInstanceSettings //-------------------------------------------------------------- -TargetInstanceSettings::TargetInstanceSettings (UserSettingsController &owner, bool live_instance, - const char *name) : - InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance) +TargetInstanceSettings::TargetInstanceSettings +( + UserSettingsController &owner, + bool live_instance, + const char *name +) : + InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance) { // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called // until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers. Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=120862&r1=120861&r2=120862&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Fri Dec 3 18:10:17 2010 @@ -1045,7 +1045,7 @@ //-------------------------------------------------------------- ThreadInstanceSettings::ThreadInstanceSettings (UserSettingsController &owner, bool live_instance, const char *name) : - InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance), + InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance), m_avoid_regexp_ap (), m_trace_enabled (false) { Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=120862&r1=120861&r2=120862&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Dec 3 18:10:17 2010 @@ -372,6 +372,7 @@ isa = PBXProject; buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "debugserver" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, From gclayton at apple.com Fri Dec 3 18:12:24 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 04 Dec 2010 00:12:24 -0000 Subject: [Lldb-commits] [lldb] r120863 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20101204001224.9D7A12A6C12C@llvm.org> Author: gclayton Date: Fri Dec 3 18:12:24 2010 New Revision: 120863 URL: http://llvm.org/viewvc/llvm-project?rev=120863&view=rev Log: Added the ability to display the new "target.process.inherit-env" setting. Modified: lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=120863&r1=120862&r2=120863&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Fri Dec 3 18:12:24 2010 @@ -2814,6 +2814,13 @@ { value.AppendString (UserSettingsController::EnumToString (entry.enum_values, (int) m_plugin)); } + else if (var_name == InheritHostEnvVarName()) + { + if (m_inherit_host_env) + value.AppendString ("true"); + else + value.AppendString ("false"); + } else if (var_name == DisableASLRVarName()) { if (m_disable_aslr) From gclayton at apple.com Fri Dec 3 18:16:27 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 04 Dec 2010 00:16:27 -0000 Subject: [Lldb-commits] [lldb] r120864 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20101204001627.914DD2A6C12C@llvm.org> Author: gclayton Date: Fri Dec 3 18:16:27 2010 New Revision: 120864 URL: http://llvm.org/viewvc/llvm-project?rev=120864&view=rev Log: Bumped lldb version to lldb-33 and debugserver to debugserver-120. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=120864&r1=120863&r2=120864&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Dec 3 18:16:27 2010 @@ -2459,6 +2459,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, @@ -3026,9 +3027,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 32; + DYLIB_CURRENT_VERSION = 33; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3078,11 +3079,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 32; + DYLIB_CURRENT_VERSION = 33; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3152,7 +3153,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3187,11 +3188,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 32; + DYLIB_CURRENT_VERSION = 33; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3240,7 +3241,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3278,7 +3279,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 32; + CURRENT_PROJECT_VERSION = 33; 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=120864&r1=120863&r2=120864&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Fri Dec 3 18:16:27 2010 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 32 + 33 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=120864&r1=120863&r2=120864&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Dec 3 18:16:27 2010 @@ -460,7 +460,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 119; + CURRENT_PROJECT_VERSION = 120; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIP_INSTALLED_PRODUCT = NO; @@ -478,7 +478,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 119; + CURRENT_PROJECT_VERSION = 120; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -498,7 +498,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 119; + CURRENT_PROJECT_VERSION = 120; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 119; + CURRENT_PROJECT_VERSION = 120; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -556,7 +556,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 119; + CURRENT_PROJECT_VERSION = 120; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -597,7 +597,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 119; + CURRENT_PROJECT_VERSION = 120; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From johnny.chen at apple.com Fri Dec 3 18:44:56 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 04 Dec 2010 00:44:56 -0000 Subject: [Lldb-commits] [lldb] r120871 - in /lldb/trunk/test/settings: TestSettings.py main.cpp Message-ID: <20101204004456.69FD22A6C12C@llvm.org> Author: johnny Date: Fri Dec 3 18:44:56 2010 New Revision: 120871 URL: http://llvm.org/viewvc/llvm-project?rev=120871&view=rev Log: Add a test method test_pass_host_env_vars to 'class SettingsCommandTestCase(TestBase)' which tests the recently added lldb feature of automatically passing the host environment variables to the launched process. Modified: lldb/trunk/test/settings/TestSettings.py lldb/trunk/test/settings/main.cpp Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=120871&r1=120870&r2=120871&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Fri Dec 3 18:44:56 2010 @@ -108,6 +108,31 @@ "argv[3] matches", "Environment variable 'MY_ENV_VAR' successfully passed."]) + def test_pass_host_env_vars(self): + """Test that the host env vars are passed to the launched process.""" + self.buildDefault() + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # By default, inherit-env is 'true'. + self.expect('settings show target.process.inherit-env', "Default inherit-env is 'true'", + startstr = "target.process.inherit-env (boolean) = 'true'") + + # Set some host environment variables now. + os.environ["MY_HOST_ENV_VAR1"] = "VAR1" + os.environ["MY_HOST_ENV_VAR2"] = "VAR2" + + self.runCmd("run", RUN_SUCCEEDED) + + # Read the output file produced by running the program. + with open('output.txt', 'r') as f: + output = f.read() + + self.expect(output, exe=False, + substrs = ["The host environment variable 'MY_HOST_ENV_VAR1' successfully passed.", + "The host environment variable 'MY_HOST_ENV_VAR2' successfully passed."]) + @unittest2.expectedFailure # rdar://problem/8435794 # settings set target.process.output-path does not seem to work Modified: lldb/trunk/test/settings/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/main.cpp?rev=120871&r1=120870&r2=120871&view=diff ============================================================================== --- lldb/trunk/test/settings/main.cpp (original) +++ lldb/trunk/test/settings/main.cpp Fri Dec 3 18:44:56 2010 @@ -30,6 +30,7 @@ outfile << "argv[3] matches\n"; } + // For passing environment vars from the debugger to the launched process. if (::getenv("MY_ENV_VAR")) { std::string MY_ENV_VAR(getenv("MY_ENV_VAR")); if ("YES" == MY_ENV_VAR) { @@ -37,6 +38,22 @@ } } + + // For passing host environment vars to the launched process. + if (::getenv("MY_HOST_ENV_VAR1")) { + std::string MY_HOST_ENV_VAR1(getenv("MY_HOST_ENV_VAR1")); + if ("VAR1" == MY_HOST_ENV_VAR1) { + outfile << "The host environment variable 'MY_HOST_ENV_VAR1' successfully passed.\n"; + } + } + + if (::getenv("MY_HOST_ENV_VAR2")) { + std::string MY_HOST_ENV_VAR2(getenv("MY_HOST_ENV_VAR2")); + if ("VAR2" == MY_HOST_ENV_VAR2) { + outfile << "The host environment variable 'MY_HOST_ENV_VAR2' successfully passed.\n"; + } + } + std::cout << "This message should go to standard out.\n"; return 0; From gclayton at apple.com Fri Dec 3 20:22:36 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 04 Dec 2010 02:22:36 -0000 Subject: [Lldb-commits] [lldb] r120883 - /lldb/trunk/source/Core/Communication.cpp Message-ID: <20101204022236.D32DC2A6C12C@llvm.org> Author: gclayton Date: Fri Dec 3 20:22:36 2010 New Revision: 120883 URL: http://llvm.org/viewvc/llvm-project?rev=120883&view=rev Log: Reverted the close on EOF stuff again as it was crashing Xcode. Modified: lldb/trunk/source/Core/Communication.cpp Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=120883&r1=120882&r2=120883&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Fri Dec 3 20:22:36 2010 @@ -266,8 +266,7 @@ lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::AppendBytesToCache (src = %p, src_len = %zu, broadcast = %i)", this, bytes, len, broadcast); - if ((bytes == NULL || len == 0) - && (status != eConnectionStatusEndOfFile)) + if (bytes == NULL || len == 0) return; if (m_callback) { @@ -327,21 +326,14 @@ 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->CloseOnEOF ()) - comm->Disconnect (); - comm->AppendBytesToCache (buf, bytes_read, true, status); - } } switch (status) { case eConnectionStatusSuccess: - case eConnectionStatusEndOfFile: break; + case eConnectionStatusEndOfFile: case eConnectionStatusNoConnection: // No connection case eConnectionStatusLostConnection: // Lost connection while connected to a valid connection done = true; From gclayton at apple.com Fri Dec 3 20:39:47 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 04 Dec 2010 02:39:47 -0000 Subject: [Lldb-commits] [lldb] r120885 - in /lldb/trunk: include/lldb/API/SBCommunication.h include/lldb/Core/Communication.h source/API/SBCommunication.cpp source/Core/Communication.cpp source/Core/Debugger.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp source/Target/Process.cpp tools/driver/Driver.cpp Message-ID: <20101204023947.C69F82A6C12C@llvm.org> Author: gclayton Date: Fri Dec 3 20:39:47 2010 New Revision: 120885 URL: http://llvm.org/viewvc/llvm-project?rev=120885&view=rev Log: More reverting of the EOF stuff as the API was changed which we don't want to do. Closing on EOF is an option that can be set on the lldb_private::Communication or the lldb::SBCommunication objects after they are created. Of course the EOF support isn't hooked up, so they don't do anything at the moment, but they are left in so when the code is fixed, it will be easy to get working again. Modified: lldb/trunk/include/lldb/API/SBCommunication.h lldb/trunk/include/lldb/Core/Communication.h lldb/trunk/source/API/SBCommunication.cpp lldb/trunk/source/Core/Communication.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/API/SBCommunication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommunication.h?rev=120885&r1=120884&r2=120885&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommunication.h (original) +++ lldb/trunk/include/lldb/API/SBCommunication.h Fri Dec 3 20:39:47 2010 @@ -30,7 +30,7 @@ typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len); SBCommunication (); - SBCommunication (const char * broadcaster_name, bool close_on_eof); + SBCommunication (const char * broadcaster_name); ~SBCommunication (); @@ -58,6 +58,12 @@ bool IsConnected () const; + bool + GetCloseOnEOF (); + + void + SetCloseOnEOF (bool b); + size_t Read (void *dst, size_t dst_len, Modified: lldb/trunk/include/lldb/Core/Communication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Communication.h?rev=120885&r1=120884&r2=120885&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Communication.h (original) +++ lldb/trunk/include/lldb/Core/Communication.h Fri Dec 3 20:39:47 2010 @@ -109,7 +109,7 @@ /// broadcaster name can be updated after the connect function /// is called. //------------------------------------------------------------------ - Communication(const char * broadcaster_name, bool close_on_eof); + Communication(const char * broadcaster_name); //------------------------------------------------------------------ /// Destructor. @@ -334,14 +334,24 @@ static const char * ConnectionStatusAsCString (lldb::ConnectionStatus status); + bool + GetCloseOnEOF () const + { + return m_close_on_eof; + } + + void + SetCloseOnEOF (bool b) + { + m_close_on_eof = b; + } + private: //------------------------------------------------------------------ // For Communication only //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (Communication); - bool - CloseOnEOF (); protected: std::auto_ptr m_connection_ap; ///< The connection that is current in use by this communications class. Modified: lldb/trunk/source/API/SBCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommunication.cpp?rev=120885&r1=120884&r2=120885&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommunication.cpp (original) +++ lldb/trunk/source/API/SBCommunication.cpp Fri Dec 3 20:39:47 2010 @@ -24,8 +24,8 @@ { } -SBCommunication::SBCommunication(const char * broadcaster_name, bool close_on_eof) : - m_opaque (new Communication (broadcaster_name, close_on_eof)), +SBCommunication::SBCommunication(const char * broadcaster_name) : + m_opaque (new Communication (broadcaster_name)), m_opaque_owned (true) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -43,6 +43,21 @@ m_opaque_owned = false; } +bool +SBCommunication::GetCloseOnEOF () +{ + if (m_opaque) + return m_opaque->GetCloseOnEOF (); + return false; +} + +void +SBCommunication::SetCloseOnEOF (bool b) +{ + if (m_opaque) + m_opaque->SetCloseOnEOF (b); +} + ConnectionStatus SBCommunication::CheckIfBytesAvailable () { Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=120885&r1=120884&r2=120885&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Fri Dec 3 20:39:47 2010 @@ -25,7 +25,7 @@ //---------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------- -Communication::Communication(const char *name, bool close_on_eof) : +Communication::Communication(const char *name) : Broadcaster (name), m_connection_ap (), m_read_thread (LLDB_INVALID_HOST_THREAD), @@ -34,7 +34,7 @@ m_bytes_mutex (Mutex::eMutexTypeRecursive), m_callback (NULL), m_callback_baton (NULL), - m_close_on_eof (close_on_eof) + m_close_on_eof (true) { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION, @@ -291,12 +291,6 @@ } bool -Communication::CloseOnEOF () -{ - return m_close_on_eof; -} - -bool Communication::ReadThreadIsRunning () { return m_read_thread != LLDB_INVALID_HOST_THREAD; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=120885&r1=120884&r2=120885&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Dec 3 20:39:47 2010 @@ -166,7 +166,7 @@ Debugger::Debugger () : UserID (g_unique_id++), DebuggerInstanceSettings (*GetSettingsController()), - m_input_comm("debugger.input", false), + m_input_comm("debugger.input"), m_input_file (), m_output_file (), m_error_file (), @@ -178,6 +178,7 @@ m_input_readers (), m_input_reader_data () { + m_input_comm.SetCloseOnEOF(false); m_command_interpreter_ap->Initialize (); } 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=120885&r1=120884&r2=120885&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Fri Dec 3 20:39:47 2010 @@ -32,7 +32,7 @@ // GDBRemoteCommunication constructor //---------------------------------------------------------------------- GDBRemoteCommunication::GDBRemoteCommunication() : - Communication("gdb-remote.packets", true), + Communication("gdb-remote.packets"), m_send_acks (true), m_rx_packet_listener ("gdbremote.rx_packet"), m_sequence_mutex (Mutex::eMutexTypeRecursive), Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=120885&r1=120884&r2=120885&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Fri Dec 3 20:39:47 2010 @@ -96,7 +96,7 @@ m_addr_byte_size (0), m_abi_sp (), m_process_input_reader (), - m_stdio_communication ("lldb.process.stdio", true), + m_stdio_communication ("lldb.process.stdio"), m_stdio_communication_mutex (Mutex::eMutexTypeRecursive), m_stdout_data () { Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=120885&r1=120884&r2=120885&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Fri Dec 3 20:39:47 2010 @@ -1178,7 +1178,8 @@ // However, you don't need to do anything with the characters, since editline will dump these // unconsumed characters after printing the prompt again in el_gets. - SBCommunication master_out_comm("driver.editline", false); + SBCommunication master_out_comm("driver.editline"); + master_out_comm.SetCloseOnEOF (false); master_out_comm.AdoptFileDesriptor(m_editline_pty.GetMasterFileDescriptor(), false); master_out_comm.SetReadThreadBytesReceivedCallback(Driver::MasterThreadBytesReceived, this); From gclayton at apple.com Fri Dec 3 20:47:38 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 04 Dec 2010 02:47:38 -0000 Subject: [Lldb-commits] [lldb] r120886 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20101204024739.DB2352A6C12C@llvm.org> Author: gclayton Date: Fri Dec 3 20:47:38 2010 New Revision: 120886 URL: http://llvm.org/viewvc/llvm-project?rev=120886&view=rev Log: Bumped Xcode project build version to 34 for lldb-34. 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=120886&r1=120885&r2=120886&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Dec 3 20:47:38 2010 @@ -3027,9 +3027,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 33; + CURRENT_PROJECT_VERSION = 34; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 33; + DYLIB_CURRENT_VERSION = 34; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3079,11 +3079,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 33; + CURRENT_PROJECT_VERSION = 34; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 33; + DYLIB_CURRENT_VERSION = 34; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3153,7 +3153,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 33; + CURRENT_PROJECT_VERSION = 34; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3188,11 +3188,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 33; + CURRENT_PROJECT_VERSION = 34; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 33; + DYLIB_CURRENT_VERSION = 34; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3241,7 +3241,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 33; + CURRENT_PROJECT_VERSION = 34; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3279,7 +3279,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 33; + CURRENT_PROJECT_VERSION = 34; 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=120886&r1=120885&r2=120886&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Fri Dec 3 20:47:38 2010 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 33 + 34 CFBundleName ${EXECUTABLE_NAME} From gclayton at apple.com Sun Dec 5 13:16:56 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 05 Dec 2010 19:16:56 -0000 Subject: [Lldb-commits] [lldb] r120947 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20101205191656.C95552A6C12C@llvm.org> Author: gclayton Date: Sun Dec 5 13:16:56 2010 New Revision: 120947 URL: http://llvm.org/viewvc/llvm-project?rev=120947&view=rev Log: Make sure that STDOUT and STDERR events in lldb_private::Process carry along a ProcessEventData so clients can get the process from these events. Modified: lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=120947&r1=120946&r2=120947&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Sun Dec 5 13:16:56 2010 @@ -2182,7 +2182,7 @@ Mutex::Locker locker (m_stdio_communication_mutex); m_stdout_data.append (s, len); - BroadcastEventIfUnique (eBroadcastBitSTDOUT); + BroadcastEventIfUnique (eBroadcastBitSTDOUT, new ProcessEventData (GetTarget().GetProcessSP(), GetState())); } void From gclayton at apple.com Sun Dec 5 13:21:02 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 05 Dec 2010 19:21:02 -0000 Subject: [Lldb-commits] [lldb] r120948 - /lldb/trunk/source/API/SBEvent.cpp Message-ID: <20101205192102.8A5DB2A6C12C@llvm.org> Author: gclayton Date: Sun Dec 5 13:21:02 2010 New Revision: 120948 URL: http://llvm.org/viewvc/llvm-project?rev=120948&view=rev Log: Fixed a crasher when trying to get event data flavors on events that don't have event data. Modified: lldb/trunk/source/API/SBEvent.cpp Modified: lldb/trunk/source/API/SBEvent.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBEvent.cpp?rev=120948&r1=120947&r2=120948&view=diff ============================================================================== --- lldb/trunk/source/API/SBEvent.cpp (original) +++ lldb/trunk/source/API/SBEvent.cpp Sun Dec 5 13:21:02 2010 @@ -68,7 +68,11 @@ { Event *lldb_event = get(); if (lldb_event) - return lldb_event->GetData()->GetFlavor().AsCString(); + { + EventData *event_data = lldb_event->GetData(); + if (event_data) + return lldb_event->GetData()->GetFlavor().AsCString(); + } return NULL; } From gclayton at apple.com Sun Dec 5 13:36:39 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 05 Dec 2010 19:36:39 -0000 Subject: [Lldb-commits] [lldb] r120949 - in /lldb/trunk: include/lldb/API/SBBroadcaster.h source/API/SBBroadcaster.cpp Message-ID: <20101205193639.877C22A6C12C@llvm.org> Author: gclayton Date: Sun Dec 5 13:36:39 2010 New Revision: 120949 URL: http://llvm.org/viewvc/llvm-project?rev=120949&view=rev Log: Added "void SBBroadcaster::Clear ();" method to SBBroadcaster. Modified: lldb/trunk/include/lldb/API/SBBroadcaster.h lldb/trunk/source/API/SBBroadcaster.cpp Modified: lldb/trunk/include/lldb/API/SBBroadcaster.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBroadcaster.h?rev=120949&r1=120948&r2=120949&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBroadcaster.h (original) +++ lldb/trunk/include/lldb/API/SBBroadcaster.h Sun Dec 5 13:36:39 2010 @@ -34,6 +34,9 @@ IsValid () const; void + Clear (); + + void BroadcastEventByType (uint32_t event_type, bool unique = false); void Modified: lldb/trunk/source/API/SBBroadcaster.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBroadcaster.cpp?rev=120949&r1=120948&r2=120949&view=diff ============================================================================== --- lldb/trunk/source/API/SBBroadcaster.cpp (original) +++ lldb/trunk/source/API/SBBroadcaster.cpp Sun Dec 5 13:36:39 2010 @@ -170,6 +170,13 @@ return m_opaque_ptr != NULL; } +void +SBBroadcaster::Clear () +{ + m_opaque_sp.reset(); + m_opaque_ptr = NULL; +} + bool SBBroadcaster::operator == (const SBBroadcaster &rhs) const { From gclayton at apple.com Sun Dec 5 14:38:01 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 05 Dec 2010 20:38:01 -0000 Subject: [Lldb-commits] [lldb] r120954 - /lldb/trunk/source/API/SBProcess.cpp Message-ID: <20101205203801.71BEB2A6C12C@llvm.org> Author: gclayton Date: Sun Dec 5 14:38:01 2010 New Revision: 120954 URL: http://llvm.org/viewvc/llvm-project?rev=120954&view=rev Log: Fixed an issue where SBProcess::LoadImage(...) was not returning the image token. Modified: lldb/trunk/source/API/SBProcess.cpp Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=120954&r1=120953&r2=120954&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Sun Dec 5 14:38:01 2010 @@ -716,7 +716,7 @@ SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error) { if (m_opaque_sp) - m_opaque_sp->LoadImage (*sb_image_spec, sb_error.ref()); + return m_opaque_sp->LoadImage (*sb_image_spec, sb_error.ref()); return LLDB_INVALID_IMAGE_TOKEN; } From gclayton at apple.com Sun Dec 5 17:14:19 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 05 Dec 2010 23:14:19 -0000 Subject: [Lldb-commits] [lldb] r120967 - in /lldb/trunk: include/lldb/API/SBBroadcaster.h source/API/SBBroadcaster.cpp Message-ID: <20101205231419.F28F72A6C12C@llvm.org> Author: gclayton Date: Sun Dec 5 17:14:19 2010 New Revision: 120967 URL: http://llvm.org/viewvc/llvm-project?rev=120967&view=rev Log: Added a less than operator that will compare the internal opaque pointer values so SBBroadcaster objects can be contained in ordered containers or sorted. Modified: lldb/trunk/include/lldb/API/SBBroadcaster.h lldb/trunk/source/API/SBBroadcaster.cpp Modified: lldb/trunk/include/lldb/API/SBBroadcaster.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBroadcaster.h?rev=120967&r1=120966&r2=120967&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBroadcaster.h (original) +++ lldb/trunk/include/lldb/API/SBBroadcaster.h Sun Dec 5 17:14:19 2010 @@ -58,12 +58,22 @@ RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX); #ifndef SWIG + // This comparison is checking if the internal opaque pointer value + // is equal to that in "rhs". bool operator == (const lldb::SBBroadcaster &rhs) const; + // This comparison is checking if the internal opaque pointer value + // is not equal to that in "rhs". bool operator != (const lldb::SBBroadcaster &rhs) const; + // This comparison is checking if the internal opaque pointer value + // is less than that in "rhs" so SBBroadcaster objects can be contained + // in ordered containers. + bool + operator < (const lldb::SBBroadcaster &rhs) const; + #endif protected: Modified: lldb/trunk/source/API/SBBroadcaster.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBroadcaster.cpp?rev=120967&r1=120966&r2=120967&view=diff ============================================================================== --- lldb/trunk/source/API/SBBroadcaster.cpp (original) +++ lldb/trunk/source/API/SBBroadcaster.cpp Sun Dec 5 17:14:19 2010 @@ -189,3 +189,9 @@ { return m_opaque_ptr != rhs.m_opaque_ptr; } + +bool +SBBroadcaster::operator < (const SBBroadcaster &rhs) const +{ + return m_opaque_ptr < rhs.m_opaque_ptr; +} From scallanan at apple.com Sun Dec 5 18:56:39 2010 From: scallanan at apple.com (Sean Callanan) Date: Mon, 06 Dec 2010 00:56:39 -0000 Subject: [Lldb-commits] [lldb] r120972 - /lldb/trunk/source/Expression/IRForTarget.cpp Message-ID: <20101206005639.786992A6C12C@llvm.org> Author: spyffe Date: Sun Dec 5 18:56:39 2010 New Revision: 120972 URL: http://llvm.org/viewvc/llvm-project?rev=120972&view=rev Log: Fixed a problem in which non-external variables (for example, string literals) were being flagged erroneously as undefined external variables. Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=120972&r1=120971&r2=120972&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Sun Dec 5 18:56:39 2010 @@ -870,6 +870,9 @@ if (IsObjCSelectorRef(llvm_value_ptr)) return true; + if (!global_variable->hasExternalLinkage()) + return true; + if (log) log->Printf("Found global variable \"%s\" without metadata", global_variable->getName().str().c_str()); return false; From gclayton at apple.com Sun Dec 5 20:44:26 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 06 Dec 2010 02:44:26 -0000 Subject: [Lldb-commits] [lldb] r120975 - in /lldb/trunk/test/expression_command/test: ./ Makefile main.cpp Message-ID: <20101206024426.7721F2A6C12C@llvm.org> Author: gclayton Date: Sun Dec 5 20:44:26 2010 New Revision: 120975 URL: http://llvm.org/viewvc/llvm-project?rev=120975&view=rev Log: Added a simple test case that can be used to test out the expression parser more completely. Example expressions are in the comments. Added: lldb/trunk/test/expression_command/test/ lldb/trunk/test/expression_command/test/Makefile lldb/trunk/test/expression_command/test/main.cpp Added: lldb/trunk/test/expression_command/test/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/Makefile?rev=120975&view=auto ============================================================================== --- lldb/trunk/test/expression_command/test/Makefile (added) +++ lldb/trunk/test/expression_command/test/Makefile Sun Dec 5 20:44:26 2010 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/expression_command/test/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/main.cpp?rev=120975&view=auto ============================================================================== --- lldb/trunk/test/expression_command/test/main.cpp (added) +++ lldb/trunk/test/expression_command/test/main.cpp Sun Dec 5 20:44:26 2010 @@ -0,0 +1,33 @@ +#include + +int main (int argc, char const *argv[]) +{ + printf ("Hello world!\n"); + puts ("hello"); + // Please test many expressions while stopped at this line: +#if 0 + expr 'a' // make sure character constant makes it down (this is broken by the command line parser code right now) + expr 2 // Test int + expr 2ull // Test unsigned long long + expr 2.234f // Test float constants + expr 2.234 // Test double constants + expr 2+3 + expr argc + expr argc + 22 + expr argv + expr argv[0] + expr argv[1] + expr argv[-1] + expr puts("bonjour") // Test constant strings... + expr printf("\t\x68\n") // Test constant strings that contain the \xXX (TAB, 'h', '\n' should be printed) + expr printf("\"\n") // Test constant strings that contains an escaped double quote char + expr printf("\'\n") // Test constant strings that contains an escaped single quote char + expr printf ("one: %i\n", 1) + expr printf ("1.234 as float: %f\n", 1.234f) + expr printf ("1.234 as double: %g\n", 1.234) + expr printf ("one: %i, two: %llu\n", 1, 2ull) + expr printf ("two: %llu, one: %i\n", 2ull, 1) + expr random() % 255l +#endif + return 0; +} From gclayton at apple.com Sun Dec 5 20:47:48 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 06 Dec 2010 02:47:48 -0000 Subject: [Lldb-commits] [lldb] r120976 - /lldb/trunk/test/expression_command/test/main.cpp Message-ID: <20101206024748.98B482A6C12C@llvm.org> Author: gclayton Date: Sun Dec 5 20:47:48 2010 New Revision: 120976 URL: http://llvm.org/viewvc/llvm-project?rev=120976&view=rev Log: Use full command to avoid "expr" alias. Add bug number for current expected failures. Modified: lldb/trunk/test/expression_command/test/main.cpp Modified: lldb/trunk/test/expression_command/test/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/main.cpp?rev=120976&r1=120975&r2=120976&view=diff ============================================================================== --- lldb/trunk/test/expression_command/test/main.cpp (original) +++ lldb/trunk/test/expression_command/test/main.cpp Sun Dec 5 20:47:48 2010 @@ -6,28 +6,28 @@ puts ("hello"); // Please test many expressions while stopped at this line: #if 0 - expr 'a' // make sure character constant makes it down (this is broken by the command line parser code right now) - expr 2 // Test int - expr 2ull // Test unsigned long long - expr 2.234f // Test float constants - expr 2.234 // Test double constants - expr 2+3 - expr argc - expr argc + 22 - expr argv - expr argv[0] - expr argv[1] - expr argv[-1] - expr puts("bonjour") // Test constant strings... - expr printf("\t\x68\n") // Test constant strings that contain the \xXX (TAB, 'h', '\n' should be printed) - expr printf("\"\n") // Test constant strings that contains an escaped double quote char - expr printf("\'\n") // Test constant strings that contains an escaped single quote char - expr printf ("one: %i\n", 1) - expr printf ("1.234 as float: %f\n", 1.234f) - expr printf ("1.234 as double: %g\n", 1.234) - expr printf ("one: %i, two: %llu\n", 1, 2ull) - expr printf ("two: %llu, one: %i\n", 2ull, 1) - expr random() % 255l + expression 'a' // make sure character constant makes it down (this is broken: ) + expression 2 // Test int + expression 2ull // Test unsigned long long + expression 2.234f // Test float constants + expression 2.234 // Test double constants + expression 2+3 + expression argc + expression argc + 22 + expression argv + expression argv[0] + expression argv[1] + expression argv[-1] + expression puts("bonjour") // Test constant strings... + expression printf("\t\x68\n") // Test constant strings that contain the \xXX (TAB, 'h', '\n' should be printed) (this is broken: ) + expression printf("\"\n") // Test constant strings that contains an escaped double quote char (this is broken: ) + expression printf("\'\n") // Test constant strings that contains an escaped single quote char (this is broken: ) + expression printf ("one: %i\n", 1) + expression printf ("1.234 as float: %f\n", 1.234f) + expression printf ("1.234 as double: %g\n", 1.234) + expression printf ("one: %i, two: %llu\n", 1, 2ull) + expression printf ("two: %llu, one: %i\n", 2ull, 1) + expression random() % 255l #endif return 0; }