From mminutoli at gmail.com Mon Apr 11 03:38:20 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Mon, 11 Apr 2011 10:38:20 +0200 Subject: [Lldb-commits] [PATCH 1/3] struct ParserVars warning fix. Message-ID: <1302511102-13460-1-git-send-email-mminutoli@gmail.com> ParserVars is declared using the class keyword. This solve the warning. --- include/lldb/Expression/ClangExpressionDeclMap.h | 2 +- include/lldb/Expression/ClangExpressionVariable.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/lldb/Expression/ClangExpressionDeclMap.h b/include/lldb/Expression/ClangExpressionDeclMap.h index b0a08f7..ebae71d 100644 --- a/include/lldb/Expression/ClangExpressionDeclMap.h +++ b/include/lldb/Expression/ClangExpressionDeclMap.h @@ -509,7 +509,7 @@ private: EnableParserVars() { if (!m_parser_vars.get()) - m_parser_vars.reset(new struct ParserVars); + m_parser_vars.reset(new ParserVars); } //---------------------------------------------------------------------- diff --git a/include/lldb/Expression/ClangExpressionVariable.h b/include/lldb/Expression/ClangExpressionVariable.h index dc6b7f8..a1a9deb 100644 --- a/include/lldb/Expression/ClangExpressionVariable.h +++ b/include/lldb/Expression/ClangExpressionVariable.h @@ -117,7 +117,7 @@ public: EnableParserVars() { if (!m_parser_vars.get()) - m_parser_vars.reset(new struct ParserVars); + m_parser_vars.reset(new ParserVars); } //---------------------------------------------------------------------- -- 1.7.1 From mminutoli at gmail.com Mon Apr 11 03:38:21 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Mon, 11 Apr 2011 10:38:21 +0200 Subject: [Lldb-commits] [PATCH 2/3] Order of initialization lists. In-Reply-To: <1302511102-13460-1-git-send-email-mminutoli@gmail.com> References: <1302511102-13460-1-git-send-email-mminutoli@gmail.com> Message-ID: <1302511102-13460-2-git-send-email-mminutoli@gmail.com> This patch fix all the warning due to unordered initialization lists. --- include/lldb/Utility/CleanUp.h | 2 +- source/Core/EmulateInstruction.cpp | 2 +- source/Core/ValueObject.cpp | 23 ++++++++++--------- source/Expression/ASTStructExtractor.cpp | 4 +- source/Expression/ClangExpressionDeclMap.cpp | 4 +- source/Expression/ClangExpressionVariable.cpp | 8 +++--- source/Expression/ClangUserExpression.cpp | 4 +- source/Expression/IRDynamicChecks.cpp | 4 +- source/Expression/IRForTarget.cpp | 8 +++--- source/Expression/IRToDWARF.cpp | 4 +- .../Process/Utility/RegisterContextLLDB.cpp | 22 +++++++++--------- .../Process/Utility/UnwindAssemblyProfiler-x86.cpp | 4 +- source/Symbol/DWARFCallFrameInfo.cpp | 4 +- source/Symbol/Symbol.cpp | 8 +++--- source/Symbol/Type.cpp | 4 +- source/Symbol/UnwindTable.cpp | 4 +- source/Target/StackFrameList.cpp | 4 +- source/Target/Target.cpp | 8 +++--- source/Target/ThreadPlanTestCondition.cpp | 2 +- source/Target/ThreadPlanTracer.cpp | 4 +- tools/driver/Driver.cpp | 4 +- 21 files changed, 66 insertions(+), 65 deletions(-) diff --git a/include/lldb/Utility/CleanUp.h b/include/lldb/Utility/CleanUp.h index 35eda02..9f7b169 100644 --- a/include/lldb/Utility/CleanUp.h +++ b/include/lldb/Utility/CleanUp.h @@ -80,8 +80,8 @@ public: //---------------------------------------------------------------------- CleanUp (value_type value, value_type invalid, CallbackType callback) : m_current_value (value), - m_callback (callback), m_invalid_value (invalid), + m_callback (callback), m_callback_called (false), m_invalid_value_is_valid (true) { diff --git a/source/Core/EmulateInstruction.cpp b/source/Core/EmulateInstruction.cpp index e828dbc..5a7006b 100644 --- a/source/Core/EmulateInstruction.cpp +++ b/source/Core/EmulateInstruction.cpp @@ -69,8 +69,8 @@ EmulateInstruction::EmulateInstruction m_write_mem_callback (write_mem_callback), m_read_reg_callback (read_reg_callback), m_write_reg_callback (write_reg_callback), - m_opcode (), m_opcode_pc (LLDB_INVALID_ADDRESS), + m_opcode (), m_advance_pc (false) { } diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp index 78e0cfc..eeb3ac0 100644 --- a/source/Core/ValueObject.cpp +++ b/source/Core/ValueObject.cpp @@ -48,6 +48,7 @@ static lldb::user_id_t g_value_obj_uid = 0; ValueObject::ValueObject (ValueObject &parent) : UserID (++g_value_obj_uid), // Unique identifier for every value object m_parent (&parent), + m_update_point (parent.GetUpdatePoint ()), m_name (), m_data (), m_value (), @@ -66,8 +67,7 @@ ValueObject::ValueObject (ValueObject &parent) : m_children_count_valid (false), m_old_value_valid (false), m_pointers_point_to_load_addrs (false), - m_is_deref_of_parent (false), - m_update_point (parent.GetUpdatePoint ()) + m_is_deref_of_parent (false) { } @@ -77,6 +77,7 @@ ValueObject::ValueObject (ValueObject &parent) : ValueObject::ValueObject (ExecutionContextScope *exe_scope) : UserID (++g_value_obj_uid), // Unique identifier for every value object m_parent (NULL), + m_update_point (exe_scope), m_name (), m_data (), m_value (), @@ -95,8 +96,7 @@ ValueObject::ValueObject (ExecutionContextScope *exe_scope) : m_children_count_valid (false), m_old_value_valid (false), m_pointers_point_to_load_addrs (false), - m_is_deref_of_parent (false), - m_update_point (exe_scope) + m_is_deref_of_parent (false) { } @@ -1410,16 +1410,17 @@ ValueObject::AddressOf (Error &error) } ValueObject::EvaluationPoint::EvaluationPoint () : - m_stop_id (0), - m_thread_id (LLDB_INVALID_UID) + m_thread_id (LLDB_INVALID_UID), + m_stop_id (0) { } ValueObject::EvaluationPoint::EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected): - m_stop_id (0), - m_thread_id (LLDB_INVALID_UID), m_needs_update (true), - m_first_update (true) + m_first_update (true), + m_thread_id (LLDB_INVALID_UID), + m_stop_id (0) + { ExecutionContext exe_ctx; ExecutionContextScope *computed_exe_scope = exe_scope; // If use_selected is true, we may find a better scope, @@ -1477,12 +1478,12 @@ ValueObject::EvaluationPoint::EvaluationPoint (ExecutionContextScope *exe_scope, ValueObject::EvaluationPoint::EvaluationPoint (const ValueObject::EvaluationPoint &rhs) : m_exe_scope (rhs.m_exe_scope), + m_needs_update(true), + m_first_update(true), m_target_sp (rhs.m_target_sp), m_process_sp (rhs.m_process_sp), m_thread_id (rhs.m_thread_id), m_stack_id (rhs.m_stack_id), - m_needs_update(true), - m_first_update(true), m_stop_id (0) { } diff --git a/source/Expression/ASTStructExtractor.cpp b/source/Expression/ASTStructExtractor.cpp index 0375a97..efad383 100644 --- a/source/Expression/ASTStructExtractor.cpp +++ b/source/Expression/ASTStructExtractor.cpp @@ -34,8 +34,8 @@ ASTStructExtractor::ASTStructExtractor(ASTConsumer *passthrough, m_passthrough_sema (NULL), m_sema (NULL), m_action (NULL), - m_struct_name (struct_name), - m_function (function) + m_function (function), + m_struct_name (struct_name) { if (!m_passthrough) return; diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp index 411651f..99f0e60 100644 --- a/source/Expression/ClangExpressionDeclMap.cpp +++ b/source/Expression/ClangExpressionDeclMap.cpp @@ -50,9 +50,9 @@ using namespace clang; ClangExpressionDeclMap::ClangExpressionDeclMap (bool keep_result_in_memory) : m_found_entities (), m_struct_members (), + m_keep_result_in_memory (keep_result_in_memory), m_parser_vars (), - m_struct_vars (), - m_keep_result_in_memory (keep_result_in_memory) + m_struct_vars () { EnableStructVars(); } diff --git a/source/Expression/ClangExpressionVariable.cpp b/source/Expression/ClangExpressionVariable.cpp index 7cb25e3..2725e6c 100644 --- a/source/Expression/ClangExpressionVariable.cpp +++ b/source/Expression/ClangExpressionVariable.cpp @@ -28,16 +28,16 @@ using namespace clang; ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) : m_parser_vars(), m_jit_vars (), - m_frozen_sp (new ValueObjectConstResult(exe_scope, byte_order, addr_byte_size)), - m_flags (EVNone) + m_flags (EVNone), + m_frozen_sp (new ValueObjectConstResult(exe_scope, byte_order, addr_byte_size)) { } ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) : m_parser_vars(), m_jit_vars (), - m_frozen_sp (valobj_sp), - m_flags (EVNone) + m_flags (EVNone), + m_frozen_sp (valobj_sp) { } diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp index d560e0f..c86a771 100644 --- a/source/Expression/ClangUserExpression.cpp +++ b/source/Expression/ClangUserExpression.cpp @@ -45,11 +45,11 @@ ClangUserExpression::ClangUserExpression (const char *expr, m_expr_text (expr), m_expr_prefix (expr_prefix ? expr_prefix : ""), m_transformed_text (), + m_desired_type (NULL, NULL), m_cplusplus (false), m_objectivec (false), m_needs_object_ptr (false), - m_const_object (false), - m_desired_type (NULL, NULL) + m_const_object (false) { } diff --git a/source/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp index e0284c7..a84fe8e 100644 --- a/source/Expression/IRDynamicChecks.cpp +++ b/source/Expression/IRDynamicChecks.cpp @@ -462,8 +462,8 @@ private: IRDynamicChecks::IRDynamicChecks(DynamicCheckerFunctions &checker_functions, const char *func_name) : ModulePass(ID), - m_checker_functions(checker_functions), - m_func_name(func_name) + m_func_name(func_name), + m_checker_functions(checker_functions) { } diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp index f9ea7e1..a6d1651 100644 --- a/source/Expression/IRForTarget.cpp +++ b/source/Expression/IRForTarget.cpp @@ -38,15 +38,15 @@ IRForTarget::IRForTarget (lldb_private::ClangExpressionDeclMap *decl_map, lldb_private::Stream *error_stream, const char *func_name) : ModulePass(ID), + m_resolve_vars(resolve_vars), + m_func_name(func_name), m_decl_map(decl_map), m_CFStringCreateWithBytes(NULL), m_sel_registerName(NULL), - m_func_name(func_name), - m_resolve_vars(resolve_vars), m_const_result(const_result), + m_error_stream(error_stream), m_has_side_effects(false), - m_result_is_pointer(false), - m_error_stream(error_stream) + m_result_is_pointer(false) { } diff --git a/source/Expression/IRToDWARF.cpp b/source/Expression/IRToDWARF.cpp index 88d880b..289d617 100644 --- a/source/Expression/IRToDWARF.cpp +++ b/source/Expression/IRToDWARF.cpp @@ -31,10 +31,10 @@ IRToDWARF::IRToDWARF(lldb_private::ClangExpressionVariableList &local_vars, lldb_private::StreamString &strm, const char *func_name) : ModulePass(ID), + m_func_name(func_name), m_local_vars(local_vars), m_decl_map(decl_map), - m_strm(strm), - m_func_name(func_name) + m_strm(strm) { } diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index 0f3207b..077aa4d 100644 --- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -40,20 +40,20 @@ RegisterContextLLDB::RegisterContextLLDB ) : RegisterContext (thread, frame_number), m_thread(thread), - m_next_frame(next_frame), - m_sym_ctx(sym_ctx), - m_all_registers_available(false), - m_registers(), - m_cfa (LLDB_INVALID_ADDRESS), + m_next_frame(next_frame), + m_fast_unwind_plan_sp (), + m_full_unwind_plan_sp (), + m_all_registers_available(false), + m_frame_type (-1), + m_cfa (LLDB_INVALID_ADDRESS), m_start_pc (), m_current_pc (), - m_frame_number (frame_number), - m_full_unwind_plan_sp (), - m_fast_unwind_plan_sp (), - m_frame_type (-1), m_current_offset (0), - m_current_offset_backed_up_one (0), - m_sym_ctx_valid (false) + m_current_offset_backed_up_one (0), + m_sym_ctx(sym_ctx), + m_sym_ctx_valid (false), + m_frame_number (frame_number), + m_registers() { m_sym_ctx.Clear(); m_sym_ctx_valid = false; diff --git a/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp b/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp index 83255e2..855aa69 100644 --- a/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp +++ b/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp @@ -167,10 +167,10 @@ private: }; AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, AddressRange func) : - m_target (target), m_thread (thread), m_cpu(cpu), m_func_bounds(func), + m_target (target), m_thread (thread), m_func_bounds(func), m_cur_insn (), m_machine_ip_regnum (-1), m_machine_sp_regnum (-1), m_machine_fp_regnum (-1), m_lldb_ip_regnum (-1), m_lldb_sp_regnum (-1), m_lldb_fp_regnum (-1), - m_wordsize (-1), m_cur_insn () + m_wordsize (-1), m_cpu(cpu) { int *initialized_flag = NULL; m_lldb_ip_regnum = m_lldb_sp_regnum = m_lldb_fp_regnum = -1; diff --git a/source/Symbol/DWARFCallFrameInfo.cpp b/source/Symbol/DWARFCallFrameInfo.cpp index 3fb84f4..7513d23 100644 --- a/source/Symbol/DWARFCallFrameInfo.cpp +++ b/source/Symbol/DWARFCallFrameInfo.cpp @@ -30,13 +30,13 @@ DWARFCallFrameInfo::DWARFCallFrameInfo(ObjectFile& objfile, SectionSP& section, m_objfile (objfile), m_section (section), m_reg_kind (reg_kind), // The flavor of registers that the CFI data uses (enum RegisterKind) + m_flags (), m_cie_map (), m_cfi_data (), m_cfi_data_initialized (false), m_fde_index (), m_fde_index_initialized (false), - m_is_eh_frame (is_eh_frame), - m_flags () + m_is_eh_frame (is_eh_frame) { } diff --git a/source/Symbol/Symbol.cpp b/source/Symbol/Symbol.cpp index bd8246b..480405e 100644 --- a/source/Symbol/Symbol.cpp +++ b/source/Symbol/Symbol.cpp @@ -20,8 +20,8 @@ using namespace lldb_private; Symbol::Symbol() : - SymbolContextScope (), UserID (), + SymbolContextScope (), m_mangled (), m_type (eSymbolTypeInvalid), m_type_data (0), @@ -53,8 +53,8 @@ Symbol::Symbol uint32_t size, uint32_t flags ) : - SymbolContextScope (), UserID (symID), + SymbolContextScope (), m_mangled (name, name_is_mangled), m_type (type), m_type_data (0), @@ -84,8 +84,8 @@ Symbol::Symbol const AddressRange &range, uint32_t flags ) : - SymbolContextScope (), UserID (symID), + SymbolContextScope (), m_mangled (name, name_is_mangled), m_type (type), m_type_data (0), @@ -103,8 +103,8 @@ Symbol::Symbol } Symbol::Symbol(const Symbol& rhs): - SymbolContextScope (rhs), UserID (rhs), + SymbolContextScope (rhs), m_mangled (rhs.m_mangled), m_type (rhs.m_type), m_type_data (rhs.m_type_data), diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp index 379fa20..31fad29 100644 --- a/source/Symbol/Type.cpp +++ b/source/Symbol/Type.cpp @@ -63,8 +63,8 @@ Type::Type () : m_symbol_file (NULL), m_context (NULL), m_encoding_type (NULL), - m_encoding_uid_type (eEncodingInvalid), m_encoding_uid (0), + m_encoding_uid_type (eEncodingInvalid), m_byte_size (0), m_decl (), m_clang_type (NULL), @@ -79,8 +79,8 @@ Type::Type (const Type &rhs) : m_symbol_file (rhs.m_symbol_file), m_context (rhs.m_context), m_encoding_type (rhs.m_encoding_type), - m_encoding_uid_type (rhs.m_encoding_uid_type), m_encoding_uid (rhs.m_encoding_uid), + m_encoding_uid_type (rhs.m_encoding_uid_type), m_byte_size (rhs.m_byte_size), m_decl (rhs.m_decl), m_clang_type (rhs.m_clang_type), diff --git a/source/Symbol/UnwindTable.cpp b/source/Symbol/UnwindTable.cpp index 4b30980..d185655 100644 --- a/source/Symbol/UnwindTable.cpp +++ b/source/Symbol/UnwindTable.cpp @@ -33,8 +33,8 @@ UnwindTable::UnwindTable (ObjectFile& objfile) : m_object_file (objfile), m_unwinds (), m_initialized (false), - m_eh_frame (NULL), - m_assembly_profiler (NULL) + m_assembly_profiler (NULL), + m_eh_frame (NULL) { } diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp index 6ad1799..aef35a8 100644 --- a/source/Target/StackFrameList.cpp +++ b/source/Target/StackFrameList.cpp @@ -38,10 +38,10 @@ StackFrameList::StackFrameList ) : m_thread (thread), m_prev_frames_sp (prev_frames_sp), - m_show_inlined_frames (show_inline_frames), m_mutex (Mutex::eMutexTypeRecursive), m_frames (), - m_selected_frame_idx (0) + m_selected_frame_idx (0), + m_show_inlined_frames (show_inline_frames) { } diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp index 05403f8..2ade9e6 100644 --- a/source/Target/Target.cpp +++ b/source/Target/Target.cpp @@ -1174,10 +1174,10 @@ Target::RunStopHooks () Target::StopHook::StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid) : UserID (uid), m_target_sp (target_sp), - m_active (true), m_commands (), m_specifier_sp (), - m_thread_spec_ap(NULL) + m_thread_spec_ap(NULL), + m_active (true) { } @@ -1186,8 +1186,8 @@ Target::StopHook::StopHook (const StopHook &rhs) : m_target_sp (rhs.m_target_sp), m_commands (rhs.m_commands), m_specifier_sp (rhs.m_specifier_sp), - m_active (rhs.m_active), - m_thread_spec_ap (NULL) + m_thread_spec_ap (NULL), + m_active (rhs.m_active) { if (rhs.m_thread_spec_ap.get() != NULL) m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get())); diff --git a/source/Target/ThreadPlanTestCondition.cpp b/source/Target/ThreadPlanTestCondition.cpp index b2c90db..9facfdc 100644 --- a/source/Target/ThreadPlanTestCondition.cpp +++ b/source/Target/ThreadPlanTestCondition.cpp @@ -43,8 +43,8 @@ ThreadPlanTestCondition::ThreadPlanTestCondition ( lldb::BreakpointLocationSP break_loc_sp, bool stop_others) : ThreadPlan (ThreadPlan::eKindTestCondition, "test condition", thread, eVoteNoOpinion, eVoteNoOpinion), - m_exe_ctx (exe_ctx), m_expression (expression), + m_exe_ctx (exe_ctx), m_break_loc_sp (break_loc_sp), m_did_stop (false), m_stop_others (stop_others) diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp index fe95b9a..961c9cd 100644 --- a/source/Target/ThreadPlanTracer.cpp +++ b/source/Target/ThreadPlanTracer.cpp @@ -33,17 +33,17 @@ using namespace lldb_private; #pragma mark ThreadPlanTracer ThreadPlanTracer::ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp) : + m_thread (thread), m_single_step(true), m_enabled (false), - m_thread (thread), m_stream_sp (stream_sp) { } ThreadPlanTracer::ThreadPlanTracer (Thread &thread) : + m_thread (thread), m_single_step(true), m_enabled (false), - m_thread (thread), m_stream_sp () { } diff --git a/tools/driver/Driver.cpp b/tools/driver/Driver.cpp index 77c6fc2..e29db66 100644 --- a/tools/driver/Driver.cpp +++ b/tools/driver/Driver.cpp @@ -342,8 +342,8 @@ Driver::OptionData::OptionData () : m_debug_mode (false), m_print_version (false), m_print_help (false), - m_seen_options(), - m_use_external_editor(false) + m_use_external_editor(false), + m_seen_options() { } -- 1.7.1 From mminutoli at gmail.com Mon Apr 11 03:38:22 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Mon, 11 Apr 2011 10:38:22 +0200 Subject: [Lldb-commits] [PATCH 3/3] Order of initialization lists. In-Reply-To: <1302511102-13460-1-git-send-email-mminutoli@gmail.com> References: <1302511102-13460-1-git-send-email-mminutoli@gmail.com> Message-ID: <1302511102-13460-3-git-send-email-mminutoli@gmail.com> This patch fix all the warning due to unordered initialization lists. PS: Sorry I forgot this file in my previous commit. --- include/lldb/Symbol/DWARFCallFrameInfo.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/lldb/Symbol/DWARFCallFrameInfo.h b/include/lldb/Symbol/DWARFCallFrameInfo.h index c9f6083..35cbf76 100644 --- a/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -70,9 +70,9 @@ private: uint8_t ptr_encoding; lldb_private::UnwindPlan::Row initial_row; - CIE(dw_offset_t offset) : cie_offset(offset), initial_row(), version (-1), - code_align (0), data_align (0), return_addr_reg_num (-1), - inst_offset (0), inst_length (0), ptr_encoding (0) {} + CIE(dw_offset_t offset) : cie_offset(offset), version (-1), code_align (0), + data_align (0), return_addr_reg_num (-1), inst_offset (0), + inst_length (0), ptr_encoding (0), initial_row() {} }; typedef lldb::SharedPtr::Type CIESP; @@ -82,7 +82,7 @@ private: AddressRange bounds; // function bounds dw_offset_t offset; // offset to this FDE within the Section - FDEEntry () : offset (0), bounds () { } + FDEEntry () : bounds (), offset (0) { } inline bool operator<(const DWARFCallFrameInfo::FDEEntry& b) const -- 1.7.1 From wilsons at start.ca Mon Apr 11 06:52:28 2011 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 11 Apr 2011 07:52:28 -0400 Subject: [Lldb-commits] [PATCH 1/3] struct ParserVars warning fix. In-Reply-To: <1302511102-13460-1-git-send-email-mminutoli@gmail.com> References: <1302511102-13460-1-git-send-email-mminutoli@gmail.com> Message-ID: <20110411115228.GA3835@fibrous.localdomain> All of these look good to me. Built and tested. On Mon, Apr 11, 2011 at 10:38:20AM +0200, Marco Minutoli wrote: > ParserVars is declared using the class keyword. This solve the > warning. > --- > include/lldb/Expression/ClangExpressionDeclMap.h | 2 +- > include/lldb/Expression/ClangExpressionVariable.h | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/lldb/Expression/ClangExpressionDeclMap.h b/include/lldb/Expression/ClangExpressionDeclMap.h > index b0a08f7..ebae71d 100644 > --- a/include/lldb/Expression/ClangExpressionDeclMap.h > +++ b/include/lldb/Expression/ClangExpressionDeclMap.h > @@ -509,7 +509,7 @@ private: > EnableParserVars() > { > if (!m_parser_vars.get()) > - m_parser_vars.reset(new struct ParserVars); > + m_parser_vars.reset(new ParserVars); > } > > //---------------------------------------------------------------------- > diff --git a/include/lldb/Expression/ClangExpressionVariable.h b/include/lldb/Expression/ClangExpressionVariable.h > index dc6b7f8..a1a9deb 100644 > --- a/include/lldb/Expression/ClangExpressionVariable.h > +++ b/include/lldb/Expression/ClangExpressionVariable.h > @@ -117,7 +117,7 @@ public: > EnableParserVars() > { > if (!m_parser_vars.get()) > - m_parser_vars.reset(new struct ParserVars); > + m_parser_vars.reset(new ParserVars); > } > > //---------------------------------------------------------------------- > -- > 1.7.1 > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits -- steve From gclayton at apple.com Mon Apr 11 09:53:24 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 11 Apr 2011 07:53:24 -0700 Subject: [Lldb-commits] [PATCH 1/3] struct ParserVars warning fix. In-Reply-To: <20110411115228.GA3835@fibrous.localdomain> References: <1302511102-13460-1-git-send-email-mminutoli@gmail.com> <20110411115228.GA3835@fibrous.localdomain> Message-ID: <46C8199D-80F0-4A7A-83D0-84D653228B3C@apple.com> Me too, whomever can commit these first can feel free to do so! On Apr 11, 2011, at 4:52 AM, Stephen Wilson wrote: > > All of these look good to me. Built and tested. > > > On Mon, Apr 11, 2011 at 10:38:20AM +0200, Marco Minutoli wrote: >> ParserVars is declared using the class keyword. This solve the >> warning. >> --- >> include/lldb/Expression/ClangExpressionDeclMap.h | 2 +- >> include/lldb/Expression/ClangExpressionVariable.h | 2 +- >> 2 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/include/lldb/Expression/ClangExpressionDeclMap.h b/include/lldb/Expression/ClangExpressionDeclMap.h >> index b0a08f7..ebae71d 100644 >> --- a/include/lldb/Expression/ClangExpressionDeclMap.h >> +++ b/include/lldb/Expression/ClangExpressionDeclMap.h >> @@ -509,7 +509,7 @@ private: >> EnableParserVars() >> { >> if (!m_parser_vars.get()) >> - m_parser_vars.reset(new struct ParserVars); >> + m_parser_vars.reset(new ParserVars); >> } >> >> //---------------------------------------------------------------------- >> diff --git a/include/lldb/Expression/ClangExpressionVariable.h b/include/lldb/Expression/ClangExpressionVariable.h >> index dc6b7f8..a1a9deb 100644 >> --- a/include/lldb/Expression/ClangExpressionVariable.h >> +++ b/include/lldb/Expression/ClangExpressionVariable.h >> @@ -117,7 +117,7 @@ public: >> EnableParserVars() >> { >> if (!m_parser_vars.get()) >> - m_parser_vars.reset(new struct ParserVars); >> + m_parser_vars.reset(new ParserVars); >> } >> >> //---------------------------------------------------------------------- >> -- >> 1.7.1 >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > > -- > steve > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From ctice at apple.com Mon Apr 11 10:51:10 2011 From: ctice at apple.com (Caroline Tice) Date: Mon, 11 Apr 2011 15:51:10 -0000 Subject: [Lldb-commits] [lldb] r129279 - in /lldb/trunk: include/lldb/Core/EmulateInstruction.h source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110411155110.7696F2A6C12D@llvm.org> Author: ctice Date: Mon Apr 11 10:51:10 2011 New Revision: 129279 URL: http://llvm.org/viewvc/llvm-project?rev=129279&view=rev Log: Implement ARM emulation function to handle "SUBS PC, LR and related instructions". Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=129279&r1=129278&r2=129279&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Mon Apr 11 10:51:10 2011 @@ -111,6 +111,7 @@ // Add or subtract a value from a base address register (other than SP) eContextAdjustBaseRegister, + eContextAdjustPC, // Used in WriteRegister callbacks to indicate where the eContextRegisterPlusOffset, Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=129279&r1=129278&r2=129279&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Apr 11 10:51:10 2011 @@ -686,10 +686,10 @@ Rd = Bits32(opcode, 15, 12); Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -777,11 +777,14 @@ break; case eEncodingA1: - // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; // d = UInt(Rd); setflags = (S == ???1???); (imm32, carry) = ARMExpandImm_C(imm12, APSR.C); Rd = Bits32 (opcode, 15, 12); setflags = BitIsSet (opcode, 20); imm32 = ARMExpandImm_C (opcode, APSR_C, carry); + + // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + if ((Rd == 15) && setflags) + return EmulateSUBSPcLrEtc (opcode, encoding); break; @@ -986,10 +989,10 @@ Rd = Bits32(opcode, 15, 12); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm_C(opcode, APSR_C, carry); + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -1749,10 +1752,10 @@ Rd = Bits32(opcode, 15, 12); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm(opcode); // imm32 = ARMExpandImm(imm12) + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -5130,9 +5133,9 @@ Rn = Bits32(opcode, 19, 16); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm(opcode); // imm32 = ARMExpandImm(imm12) - // TODO: Emulate SUBS PC, LR and related instructions. + if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -5210,9 +5213,9 @@ Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); shift_n = DecodeImmShiftARM(opcode, shift_t); - // TODO: Emulate SUBS PC, LR and related instructions. + if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -5352,9 +5355,9 @@ Rn = Bits32(opcode, 19, 16); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm_C(opcode, APSR_C, carry); // (imm32, carry) = ARMExpandImm(imm12, APSR.C) - // TODO: Emulate SUBS PC, LR and related instructions. + if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -5436,9 +5439,9 @@ Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); shift_n = DecodeImmShiftARM(opcode, shift_t); - // TODO: Emulate SUBS PC, LR and related instructions. + if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -5512,10 +5515,10 @@ Rn = Bits32(opcode, 19, 16); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm_C(opcode, APSR_C, carry); // (imm32, carry) = ARMExpandImm(imm12, APSR.C) + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -5594,10 +5597,10 @@ Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); shift_n = DecodeImmShiftARM(opcode, shift_t); + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8125,10 +8128,10 @@ Rn = Bits32(opcode, 19, 16); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm_C(opcode, APSR_C, carry); // (imm32, carry) = ARMExpandImm(imm12, APSR.C) + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8210,10 +8213,10 @@ Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); shift_n = DecodeImmShiftARM(opcode, shift_t); + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8290,9 +8293,9 @@ Rn = Bits32(opcode, 19, 16); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm_C(opcode, APSR_C, carry); // (imm32, carry) = ARMExpandImm(imm12, APSR.C) - // TODO: Emulate SUBS PC, LR and related instructions. + if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8374,9 +8377,9 @@ Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); shift_n = DecodeImmShiftARM(opcode, shift_t); - // TODO: Emulate SUBS PC, LR and related instructions. + if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8452,10 +8455,10 @@ Rn = Bits32(opcode, 19, 16); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm(opcode); // imm32 = ARMExpandImm(imm12) + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8524,10 +8527,10 @@ Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); shift_n = DecodeImmShiftARM(opcode, shift_t); + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8588,10 +8591,10 @@ Rn = Bits32(opcode, 19, 16); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm(opcode); // imm32 = ARMExpandImm(imm12) + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8651,10 +8654,10 @@ Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); shift_n = DecodeImmShiftARM(opcode, shift_t); + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8723,10 +8726,10 @@ Rn = Bits32(opcode, 19, 16); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm(opcode); // imm32 = ARMExpandImm(imm12) + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8802,10 +8805,10 @@ Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); shift_n = DecodeImmShiftARM(opcode, shift_t); + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -8966,9 +8969,8 @@ return EmulateSUBSPImm (opcode, eEncodingA1); // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; - // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) - return false; + return EmulateSUBSPcLrEtc (opcode, encoding); break; default: return false; @@ -9292,11 +9294,14 @@ break; case eEncodingA1: - // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; // d = UInt(Rd); m = UInt(Rm); setflags = (S == ???1???); d = Bits32 (opcode, 15, 12); m = Bits32 (opcode, 3, 0); setflags = BitIsSet (opcode, 20); + + // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + if (d == 15 && setflags) + EmulateSUBSPcLrEtc (opcode, encoding); // (shift_t, shift_n) = DecodeImmShift(type, imm5); shift_n = DecodeImmShiftARM (opcode, shift_t); @@ -9496,13 +9501,16 @@ break; case eEncodingA1: - // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; // if Rn == ???1101??? then SEE SUB (SP minus register); // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ???1???); d = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); m = Bits32 (opcode, 3, 0); setflags = BitIsSet (opcode, 20); + + // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + if ((d == 15) && setflags) + EmulateSUBSPcLrEtc (opcode, encoding); // (shift_t, shift_n) = DecodeImmShift(type, imm5); shift_n = DecodeImmShiftARM (opcode, shift_t); @@ -11864,6 +11872,195 @@ return true; } +// B6.2.13 SUBS PC, LR and related instructions +//The SUBS PC, LR, # , , "}, // mul { 0x0fe000f0, 0x00000090, ARMvAll, eEncodingA1, No_VFP, eSize32, &EmulateInstructionARM::EmulateMUL, "mul{s} ,," }, + { 0x0e10f000, 0x0210f000, ARMvAll, eEncodingA1, No_VFP, eSize32, &EmulateInstructionARM::EmulateSUBSPcLrEtc, "S PC,# | ,#" }, + { 0x0e10f010, 0x0010f000, ARMvAll, eEncodingA2, No_VFP, eSize32, &EmulateInstructionARM::EmulateSUBSPcLrEtc, "S PC,,}" }, //---------------------------------------------------------------------- // Load instructions @@ -12305,6 +12504,7 @@ { 0xffffffc0, 0x00004340, ARMV4T_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateMUL, "muls ,," }, // mul { 0xfff0f0f0, 0xfb00f000, ARMV6T2_ABOVE, eEncodingT2, No_VFP, eSize32, &EmulateInstructionARM::EmulateMUL, "mul ,," }, + { 0xffffff00, 0xf3de8f00, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize32, &EmulateInstructionARM::EmulateSUBSPcLrEtc, "SUBS PC, LR, #" }, //---------------------------------------------------------------------- Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=129279&r1=129278&r2=129279&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Mon Apr 11 10:51:10 2011 @@ -935,6 +935,9 @@ bool EmulateVSTR (const uint32_t opcode, const ARMEncoding encoding); + // B6.2.13 SUBS PC, LR and related instructions + bool + EmulateSUBSPcLrEtc (const uint32_t opcode, const ARMEncoding encoding); uint32_t m_arm_isa; Mode m_opcode_mode; From wilsons at start.ca Mon Apr 11 14:38:03 2011 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 11 Apr 2011 19:38:03 -0000 Subject: [Lldb-commits] [lldb] r129289 - in /lldb/trunk/include/lldb/Expression: ClangExpressionDeclMap.h ClangExpressionVariable.h Message-ID: <20110411193803.5E8822A6C12D@llvm.org> Author: wilsons Date: Mon Apr 11 14:38:03 2011 New Revision: 129289 URL: http://llvm.org/viewvc/llvm-project?rev=129289&view=rev Log: Fix struct vs. class warning. ParserVars is declared using the class keyword. This solves the warning. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=129289&r1=129288&r2=129289&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon Apr 11 14:38:03 2011 @@ -509,7 +509,7 @@ EnableParserVars() { if (!m_parser_vars.get()) - m_parser_vars.reset(new struct ParserVars); + m_parser_vars.reset(new ParserVars); } //---------------------------------------------------------------------- Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=129289&r1=129288&r2=129289&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Mon Apr 11 14:38:03 2011 @@ -117,7 +117,7 @@ EnableParserVars() { if (!m_parser_vars.get()) - m_parser_vars.reset(new struct ParserVars); + m_parser_vars.reset(new ParserVars); } //---------------------------------------------------------------------- From wilsons at start.ca Mon Apr 11 14:41:40 2011 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 11 Apr 2011 19:41:40 -0000 Subject: [Lldb-commits] [lldb] r129290 - in /lldb/trunk: include/lldb/Symbol/ include/lldb/Utility/ source/Core/ source/Expression/ source/Plugins/Process/Utility/ source/Symbol/ source/Target/ tools/driver/ Message-ID: <20110411194140.C00422A6C12D@llvm.org> Author: wilsons Date: Mon Apr 11 14:41:40 2011 New Revision: 129290 URL: http://llvm.org/viewvc/llvm-project?rev=129290&view=rev Log: Order of initialization lists. This patch fixes all of the warnings due to unordered initialization lists. Patch by Marco Minutoli. Modified: lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h lldb/trunk/include/lldb/Utility/CleanUp.h lldb/trunk/source/Core/EmulateInstruction.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Expression/ASTStructExtractor.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionVariable.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/IRDynamicChecks.cpp lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Expression/IRToDWARF.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp lldb/trunk/source/Symbol/Symbol.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Symbol/UnwindTable.cpp lldb/trunk/source/Target/StackFrameList.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/ThreadPlanTestCondition.cpp lldb/trunk/source/Target/ThreadPlanTracer.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h (original) +++ lldb/trunk/include/lldb/Symbol/DWARFCallFrameInfo.h Mon Apr 11 14:41:40 2011 @@ -70,9 +70,9 @@ uint8_t ptr_encoding; lldb_private::UnwindPlan::Row initial_row; - CIE(dw_offset_t offset) : cie_offset(offset), initial_row(), version (-1), - code_align (0), data_align (0), return_addr_reg_num (-1), - inst_offset (0), inst_length (0), ptr_encoding (0) {} + CIE(dw_offset_t offset) : cie_offset(offset), version (-1), code_align (0), + data_align (0), return_addr_reg_num (-1), inst_offset (0), + inst_length (0), ptr_encoding (0), initial_row() {} }; typedef lldb::SharedPtr::Type CIESP; @@ -82,7 +82,7 @@ AddressRange bounds; // function bounds dw_offset_t offset; // offset to this FDE within the Section - FDEEntry () : offset (0), bounds () { } + FDEEntry () : bounds (), offset (0) { } inline bool operator<(const DWARFCallFrameInfo::FDEEntry& b) const Modified: lldb/trunk/include/lldb/Utility/CleanUp.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/CleanUp.h?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/CleanUp.h (original) +++ lldb/trunk/include/lldb/Utility/CleanUp.h Mon Apr 11 14:41:40 2011 @@ -80,8 +80,8 @@ //---------------------------------------------------------------------- CleanUp (value_type value, value_type invalid, CallbackType callback) : m_current_value (value), - m_callback (callback), m_invalid_value (invalid), + m_callback (callback), m_callback_called (false), m_invalid_value_is_valid (true) { Modified: lldb/trunk/source/Core/EmulateInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp (original) +++ lldb/trunk/source/Core/EmulateInstruction.cpp Mon Apr 11 14:41:40 2011 @@ -69,8 +69,8 @@ m_write_mem_callback (write_mem_callback), m_read_reg_callback (read_reg_callback), m_write_reg_callback (write_reg_callback), - m_opcode (), m_opcode_pc (LLDB_INVALID_ADDRESS), + m_opcode (), m_advance_pc (false) { } Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Mon Apr 11 14:41:40 2011 @@ -48,6 +48,7 @@ ValueObject::ValueObject (ValueObject &parent) : UserID (++g_value_obj_uid), // Unique identifier for every value object m_parent (&parent), + m_update_point (parent.GetUpdatePoint ()), m_name (), m_data (), m_value (), @@ -66,8 +67,7 @@ m_children_count_valid (false), m_old_value_valid (false), m_pointers_point_to_load_addrs (false), - m_is_deref_of_parent (false), - m_update_point (parent.GetUpdatePoint ()) + m_is_deref_of_parent (false) { } @@ -77,6 +77,7 @@ ValueObject::ValueObject (ExecutionContextScope *exe_scope) : UserID (++g_value_obj_uid), // Unique identifier for every value object m_parent (NULL), + m_update_point (exe_scope), m_name (), m_data (), m_value (), @@ -95,8 +96,7 @@ m_children_count_valid (false), m_old_value_valid (false), m_pointers_point_to_load_addrs (false), - m_is_deref_of_parent (false), - m_update_point (exe_scope) + m_is_deref_of_parent (false) { } @@ -1410,16 +1410,17 @@ } ValueObject::EvaluationPoint::EvaluationPoint () : - m_stop_id (0), - m_thread_id (LLDB_INVALID_UID) + m_thread_id (LLDB_INVALID_UID), + m_stop_id (0) { } ValueObject::EvaluationPoint::EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected): - m_stop_id (0), - m_thread_id (LLDB_INVALID_UID), m_needs_update (true), - m_first_update (true) + m_first_update (true), + m_thread_id (LLDB_INVALID_UID), + m_stop_id (0) + { ExecutionContext exe_ctx; ExecutionContextScope *computed_exe_scope = exe_scope; // If use_selected is true, we may find a better scope, @@ -1477,12 +1478,12 @@ ValueObject::EvaluationPoint::EvaluationPoint (const ValueObject::EvaluationPoint &rhs) : m_exe_scope (rhs.m_exe_scope), + m_needs_update(true), + m_first_update(true), m_target_sp (rhs.m_target_sp), m_process_sp (rhs.m_process_sp), m_thread_id (rhs.m_thread_id), m_stack_id (rhs.m_stack_id), - m_needs_update(true), - m_first_update(true), m_stop_id (0) { } Modified: lldb/trunk/source/Expression/ASTStructExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTStructExtractor.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTStructExtractor.cpp (original) +++ lldb/trunk/source/Expression/ASTStructExtractor.cpp Mon Apr 11 14:41:40 2011 @@ -34,8 +34,8 @@ m_passthrough_sema (NULL), m_sema (NULL), m_action (NULL), - m_struct_name (struct_name), - m_function (function) + m_function (function), + m_struct_name (struct_name) { if (!m_passthrough) return; Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Apr 11 14:41:40 2011 @@ -50,9 +50,9 @@ ClangExpressionDeclMap::ClangExpressionDeclMap (bool keep_result_in_memory) : m_found_entities (), m_struct_members (), + m_keep_result_in_memory (keep_result_in_memory), m_parser_vars (), - m_struct_vars (), - m_keep_result_in_memory (keep_result_in_memory) + m_struct_vars () { EnableStructVars(); } Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Mon Apr 11 14:41:40 2011 @@ -28,16 +28,16 @@ ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) : m_parser_vars(), m_jit_vars (), - m_frozen_sp (new ValueObjectConstResult(exe_scope, byte_order, addr_byte_size)), - m_flags (EVNone) + m_flags (EVNone), + m_frozen_sp (new ValueObjectConstResult(exe_scope, byte_order, addr_byte_size)) { } ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) : m_parser_vars(), m_jit_vars (), - m_frozen_sp (valobj_sp), - m_flags (EVNone) + m_flags (EVNone), + m_frozen_sp (valobj_sp) { } Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Apr 11 14:41:40 2011 @@ -45,11 +45,11 @@ m_expr_text (expr), m_expr_prefix (expr_prefix ? expr_prefix : ""), m_transformed_text (), + m_desired_type (NULL, NULL), m_cplusplus (false), m_objectivec (false), m_needs_object_ptr (false), - m_const_object (false), - m_desired_type (NULL, NULL) + m_const_object (false) { } Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original) +++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Mon Apr 11 14:41:40 2011 @@ -462,8 +462,8 @@ IRDynamicChecks::IRDynamicChecks(DynamicCheckerFunctions &checker_functions, const char *func_name) : ModulePass(ID), - m_checker_functions(checker_functions), - m_func_name(func_name) + m_func_name(func_name), + m_checker_functions(checker_functions) { } Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Mon Apr 11 14:41:40 2011 @@ -38,15 +38,15 @@ lldb_private::Stream *error_stream, const char *func_name) : ModulePass(ID), + m_resolve_vars(resolve_vars), + m_func_name(func_name), m_decl_map(decl_map), m_CFStringCreateWithBytes(NULL), m_sel_registerName(NULL), - m_func_name(func_name), - m_resolve_vars(resolve_vars), m_const_result(const_result), + m_error_stream(error_stream), m_has_side_effects(false), - m_result_is_pointer(false), - m_error_stream(error_stream) + m_result_is_pointer(false) { } Modified: lldb/trunk/source/Expression/IRToDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRToDWARF.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRToDWARF.cpp (original) +++ lldb/trunk/source/Expression/IRToDWARF.cpp Mon Apr 11 14:41:40 2011 @@ -31,10 +31,10 @@ lldb_private::StreamString &strm, const char *func_name) : ModulePass(ID), + m_func_name(func_name), m_local_vars(local_vars), m_decl_map(decl_map), - m_strm(strm), - m_func_name(func_name) + m_strm(strm) { } Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Apr 11 14:41:40 2011 @@ -40,20 +40,20 @@ ) : RegisterContext (thread, frame_number), m_thread(thread), - m_next_frame(next_frame), - m_sym_ctx(sym_ctx), - m_all_registers_available(false), - m_registers(), - m_cfa (LLDB_INVALID_ADDRESS), + m_next_frame(next_frame), + m_fast_unwind_plan_sp (), + m_full_unwind_plan_sp (), + m_all_registers_available(false), + m_frame_type (-1), + m_cfa (LLDB_INVALID_ADDRESS), m_start_pc (), m_current_pc (), - m_frame_number (frame_number), - m_full_unwind_plan_sp (), - m_fast_unwind_plan_sp (), - m_frame_type (-1), m_current_offset (0), - m_current_offset_backed_up_one (0), - m_sym_ctx_valid (false) + m_current_offset_backed_up_one (0), + m_sym_ctx(sym_ctx), + m_sym_ctx_valid (false), + m_frame_number (frame_number), + m_registers() { m_sym_ctx.Clear(); m_sym_ctx_valid = false; Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp Mon Apr 11 14:41:40 2011 @@ -167,10 +167,10 @@ }; AssemblyParse_x86::AssemblyParse_x86 (Target& target, Thread* thread, int cpu, AddressRange func) : - m_target (target), m_thread (thread), m_cpu(cpu), m_func_bounds(func), + m_target (target), m_thread (thread), m_func_bounds(func), m_cur_insn (), m_machine_ip_regnum (-1), m_machine_sp_regnum (-1), m_machine_fp_regnum (-1), m_lldb_ip_regnum (-1), m_lldb_sp_regnum (-1), m_lldb_fp_regnum (-1), - m_wordsize (-1), m_cur_insn () + m_wordsize (-1), m_cpu(cpu) { int *initialized_flag = NULL; m_lldb_ip_regnum = m_lldb_sp_regnum = m_lldb_fp_regnum = -1; Modified: lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp (original) +++ lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp Mon Apr 11 14:41:40 2011 @@ -30,13 +30,13 @@ m_objfile (objfile), m_section (section), m_reg_kind (reg_kind), // The flavor of registers that the CFI data uses (enum RegisterKind) + m_flags (), m_cie_map (), m_cfi_data (), m_cfi_data_initialized (false), m_fde_index (), m_fde_index_initialized (false), - m_is_eh_frame (is_eh_frame), - m_flags () + m_is_eh_frame (is_eh_frame) { } Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Mon Apr 11 14:41:40 2011 @@ -20,8 +20,8 @@ Symbol::Symbol() : - SymbolContextScope (), UserID (), + SymbolContextScope (), m_mangled (), m_type (eSymbolTypeInvalid), m_type_data (0), @@ -53,8 +53,8 @@ uint32_t size, uint32_t flags ) : - SymbolContextScope (), UserID (symID), + SymbolContextScope (), m_mangled (name, name_is_mangled), m_type (type), m_type_data (0), @@ -84,8 +84,8 @@ const AddressRange &range, uint32_t flags ) : - SymbolContextScope (), UserID (symID), + SymbolContextScope (), m_mangled (name, name_is_mangled), m_type (type), m_type_data (0), @@ -103,8 +103,8 @@ } Symbol::Symbol(const Symbol& rhs): - SymbolContextScope (rhs), UserID (rhs), + SymbolContextScope (rhs), m_mangled (rhs.m_mangled), m_type (rhs.m_type), m_type_data (rhs.m_type_data), Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Mon Apr 11 14:41:40 2011 @@ -63,8 +63,8 @@ m_symbol_file (NULL), m_context (NULL), m_encoding_type (NULL), - m_encoding_uid_type (eEncodingInvalid), m_encoding_uid (0), + m_encoding_uid_type (eEncodingInvalid), m_byte_size (0), m_decl (), m_clang_type (NULL), @@ -79,8 +79,8 @@ m_symbol_file (rhs.m_symbol_file), m_context (rhs.m_context), m_encoding_type (rhs.m_encoding_type), - m_encoding_uid_type (rhs.m_encoding_uid_type), m_encoding_uid (rhs.m_encoding_uid), + m_encoding_uid_type (rhs.m_encoding_uid_type), m_byte_size (rhs.m_byte_size), m_decl (rhs.m_decl), m_clang_type (rhs.m_clang_type), Modified: lldb/trunk/source/Symbol/UnwindTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindTable.cpp (original) +++ lldb/trunk/source/Symbol/UnwindTable.cpp Mon Apr 11 14:41:40 2011 @@ -33,8 +33,8 @@ m_object_file (objfile), m_unwinds (), m_initialized (false), - m_eh_frame (NULL), - m_assembly_profiler (NULL) + m_assembly_profiler (NULL), + m_eh_frame (NULL) { } Modified: lldb/trunk/source/Target/StackFrameList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrameList.cpp (original) +++ lldb/trunk/source/Target/StackFrameList.cpp Mon Apr 11 14:41:40 2011 @@ -38,10 +38,10 @@ ) : m_thread (thread), m_prev_frames_sp (prev_frames_sp), - m_show_inlined_frames (show_inline_frames), m_mutex (Mutex::eMutexTypeRecursive), m_frames (), - m_selected_frame_idx (0) + m_selected_frame_idx (0), + m_show_inlined_frames (show_inline_frames) { } Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Mon Apr 11 14:41:40 2011 @@ -1174,10 +1174,10 @@ Target::StopHook::StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid) : UserID (uid), m_target_sp (target_sp), - m_active (true), m_commands (), m_specifier_sp (), - m_thread_spec_ap(NULL) + m_thread_spec_ap(NULL), + m_active (true) { } @@ -1186,8 +1186,8 @@ m_target_sp (rhs.m_target_sp), m_commands (rhs.m_commands), m_specifier_sp (rhs.m_specifier_sp), - m_active (rhs.m_active), - m_thread_spec_ap (NULL) + m_thread_spec_ap (NULL), + m_active (rhs.m_active) { if (rhs.m_thread_spec_ap.get() != NULL) m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get())); Modified: lldb/trunk/source/Target/ThreadPlanTestCondition.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTestCondition.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTestCondition.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Mon Apr 11 14:41:40 2011 @@ -43,8 +43,8 @@ lldb::BreakpointLocationSP break_loc_sp, bool stop_others) : ThreadPlan (ThreadPlan::eKindTestCondition, "test condition", thread, eVoteNoOpinion, eVoteNoOpinion), - m_exe_ctx (exe_ctx), m_expression (expression), + m_exe_ctx (exe_ctx), m_break_loc_sp (break_loc_sp), m_did_stop (false), m_stop_others (stop_others) Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Mon Apr 11 14:41:40 2011 @@ -33,17 +33,17 @@ #pragma mark ThreadPlanTracer ThreadPlanTracer::ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp) : + m_thread (thread), m_single_step(true), m_enabled (false), - m_thread (thread), m_stream_sp (stream_sp) { } ThreadPlanTracer::ThreadPlanTracer (Thread &thread) : + m_thread (thread), m_single_step(true), m_enabled (false), - m_thread (thread), m_stream_sp () { } Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=129290&r1=129289&r2=129290&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Mon Apr 11 14:41:40 2011 @@ -342,8 +342,8 @@ m_debug_mode (false), m_print_version (false), m_print_help (false), - m_seen_options(), - m_use_external_editor(false) + m_use_external_editor(false), + m_seen_options() { } From wilsons at start.ca Mon Apr 11 14:50:16 2011 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 11 Apr 2011 15:50:16 -0400 Subject: [Lldb-commits] [PATCH 1/3] struct ParserVars warning fix. In-Reply-To: <46C8199D-80F0-4A7A-83D0-84D653228B3C@apple.com> References: <1302511102-13460-1-git-send-email-mminutoli@gmail.com> <20110411115228.GA3835@fibrous.localdomain> <46C8199D-80F0-4A7A-83D0-84D653228B3C@apple.com> Message-ID: <20110411195016.GA6642@fibrous.localdomain> Committed in r129290 and r129289 (I folded patch 3/3 into 2/3). Marco, I forgot to credit you in the changelog in one of the patches. My apologies, it completely slipped my mind. On Mon, Apr 11, 2011 at 07:53:24AM -0700, Greg Clayton wrote: > Me too, whomever can commit these first can feel free to do so! > > On Apr 11, 2011, at 4:52 AM, Stephen Wilson wrote: > > > > > All of these look good to me. Built and tested. > > > > > > On Mon, Apr 11, 2011 at 10:38:20AM +0200, Marco Minutoli wrote: > >> ParserVars is declared using the class keyword. This solve the > >> warning. > >> --- > >> include/lldb/Expression/ClangExpressionDeclMap.h | 2 +- > >> include/lldb/Expression/ClangExpressionVariable.h | 2 +- > >> 2 files changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/include/lldb/Expression/ClangExpressionDeclMap.h b/include/lldb/Expression/ClangExpressionDeclMap.h > >> index b0a08f7..ebae71d 100644 > >> --- a/include/lldb/Expression/ClangExpressionDeclMap.h > >> +++ b/include/lldb/Expression/ClangExpressionDeclMap.h > >> @@ -509,7 +509,7 @@ private: > >> EnableParserVars() > >> { > >> if (!m_parser_vars.get()) > >> - m_parser_vars.reset(new struct ParserVars); > >> + m_parser_vars.reset(new ParserVars); > >> } > >> > >> //---------------------------------------------------------------------- > >> diff --git a/include/lldb/Expression/ClangExpressionVariable.h b/include/lldb/Expression/ClangExpressionVariable.h > >> index dc6b7f8..a1a9deb 100644 > >> --- a/include/lldb/Expression/ClangExpressionVariable.h > >> +++ b/include/lldb/Expression/ClangExpressionVariable.h > >> @@ -117,7 +117,7 @@ public: > >> EnableParserVars() > >> { > >> if (!m_parser_vars.get()) > >> - m_parser_vars.reset(new struct ParserVars); > >> + m_parser_vars.reset(new ParserVars); > >> } > >> > >> //---------------------------------------------------------------------- > >> -- > >> 1.7.1 > >> > >> _______________________________________________ > >> lldb-commits mailing list > >> lldb-commits at cs.uiuc.edu > >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > > > > -- > > steve > > > > _______________________________________________ > > lldb-commits mailing list > > lldb-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits -- steve From gclayton at apple.com Mon Apr 11 19:43:35 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 12 Apr 2011 00:43:35 -0000 Subject: [Lldb-commits] [lldb] r129332 - /lldb/trunk/www/lldb-gdb.html Message-ID: <20110412004335.9DD9A2A6C12D@llvm.org> Author: gclayton Date: Mon Apr 11 19:43:35 2011 New Revision: 129332 URL: http://llvm.org/viewvc/llvm-project?rev=129332&view=rev Log: Added a few more commands, but I mainly wanted to include how to run lldb with the same program arguments for a process over and over without having to specify them (like you can with gdb with the "--args" option). Modified: lldb/trunk/www/lldb-gdb.html Modified: lldb/trunk/www/lldb-gdb.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/lldb-gdb.html?rev=129332&r1=129331&r2=129332&view=diff ============================================================================== --- lldb/trunk/www/lldb-gdb.html (original) +++ lldb/trunk/www/lldb-gdb.html Mon Apr 11 19:43:35 2011 @@ -61,6 +61,23 @@ + Launch a process for with arguments a.out 1 2 3 without having to supply the args every time. + + % lldb a.out 1 2 3
+ (lldb) run
+ ...
+ (lldb) run
+ ...
+ + + % gdb --args a.out 1 2 3
+ (gdb) run
+ ...
+ (gdb) run
+ ...
+ + + Launch a process with arguments in new terminal window (Mac OS X only). (lldb) process launch --tty -- <args>
@@ -310,13 +327,30 @@ (lldb) memory read --size 4 --format x --count 4 0xbffff3c0
- (lldb) x --size 4 --format x --count 4 0xbffff3c0 + (lldb) memory read -s4 -fx -c4 0xbffff3c0
+ (lldb) x -s4 -fx -c4 0xbffff3c0 (gdb) x/4xw 0xbffff3c0 + Read 512 bytes of memory from address 0xbffff3c0 and save results to a local file as text. + + + (lldb) memory read --outfile /tmp/mem.txt --count 512 0xbffff3c0
+ (lldb) memory read -o/tmp/mem.txt -c512 0xbffff3c0
+ + + + Save binary memory data starting at 0x1000 and ending at 0x2000 to a file. + + + (lldb) memory read --outfile /tmp/mem.bin --binary 0x1000 0x1200
+ (lldb) memory read -o /tmp/mem.bin -b 0x1000 0x1200
+ + + Disassemble the current function for the current frame. @@ -342,10 +376,11 @@ Disassemble an address range. - (lldb) disassemble --start-address 0x00001eb8 --end-address 0x00001ec3
+ (lldb) disassemble --start-address 0x1eb8 --end-address 0x1ec3
+ (lldb) disassemble -s 0x1eb8 -e 0x1ec3
- (gdb) disassemble 0x00001eb8 0x00001ec3 + (gdb) disassemble 0x1eb8 0x1ec3 @@ -420,6 +455,27 @@ + Lookup information for an address in a.out only. + + + (lldb) image lookup --address 0x1ec4 a.out
+ (lldb) image lookup -a 0x1ec4 a.out
+ + + + + + Lookup information for for a type Point by name. + + + (lldb) image lookup --type Point
+ (lldb) image lookup -t Point
+ + + (lldb) ptype Point
+ + + Dump all sections from the main executable and any shared libraries. @@ -430,6 +486,33 @@ + Dump all sections in the a.out module. + + + (lldb) image dump sections a.out
+ + + + + + Dump all symbols from the main executable and any shared libraries. + + + (lldb) image dump symtab
+ + + + + + Dump all symbols in a.out and liba.so. + + + (lldb) image dump symtab a.out liba.so
+ + + + +

From gclayton at apple.com Tue Apr 12 00:54:46 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 12 Apr 2011 05:54:46 -0000 Subject: [Lldb-commits] [lldb] r129351 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Host/ include/lldb/Interpreter/ include/lldb/Target/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Host/common/ source/Host/macosx/ source/Host/macosx/cfcpp/ source/Interpreter/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/Platform/MacOSX/ source/Plugins/Platform/gdb-server/ source/Plugins/Process/gdb-remote/ source/Symbol/ source/Target/ source/Utility/ test/ test/abbreviation_tests/ test/founda... Message-ID: <20110412055447.62EE22A6C12D@llvm.org> Author: gclayton Date: Tue Apr 12 00:54:46 2011 New Revision: 129351 URL: http://llvm.org/viewvc/llvm-project?rev=129351&view=rev Log: Moved the execution context that was in the Debugger into the CommandInterpreter where it was always being used. Make sure that Modules can track their object file offsets correctly to allow opening of sub object files (like the "__commpage" on darwin). Modified the Platforms to be able to launch processes. The first part of this move is the platform soon will become the entity that launches your program and when it does, it uses a new ProcessLaunchInfo class which encapsulates all process launching settings. This simplifies the internal APIs needed for launching. I want to slowly phase out process launching from the process classes, so for now we can still launch just as we used to, but eventually the platform is the object that should do the launching. Modified the Host::LaunchProcess in the MacOSX Host.mm to correctly be able to launch processes with all of the new eLaunchFlag settings. Modified any code that was manually launching processes to use the Host::LaunchProcess functions. Fixed an issue where lldb_private::Args had implicitly defined copy constructors that could do the wrong thing. This has now been fixed by adding an appropriate copy constructor and assignment operator. Make sure we don't add empty ModuleSP entries to a module list. Fixed the commpage module creation on MacOSX, but we still need to train the MacOSX dynamic loader to not get rid of it when it doesn't have an entry in the all image infos. Abstracted many more calls from in ProcessGDBRemote down into the GDBRemoteCommunicationClient subclass to make the classes cleaner and more efficient. Fixed the default iOS ARM register context to be correct and also added support for targets that don't support the qThreadStopInfo packet by selecting the current thread (only if needed) and then sending a stop reply packet. Debugserver can now start up with a --unix-socket (-u for short) and can then bind to port zero and send the port it bound to to a listening process on the other end. This allows the GDB remote platform to spawn new GDB server instances (debugserver) to allow platform debugging. Modified: lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h lldb/trunk/include/lldb/Core/ConnectionMachPort.h lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Core/Module.h lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Interpreter/Args.h lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/include/lldb/Target/Platform.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Commands/CommandObjectArgs.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/ConnectionFileDescriptor.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Host/macosx/Symbols.cpp lldb/trunk/source/Host/macosx/cfcpp/CFCString.h lldb/trunk/source/Interpreter/Args.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Symbol/ObjectFile.cpp lldb/trunk/source/Target/Platform.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp lldb/trunk/source/Utility/StringExtractorGDBRemote.h lldb/trunk/test/abbreviation_tests/TestAbbreviations.py lldb/trunk/test/dotest.py lldb/trunk/test/foundation/TestFoundationDisassembly.py lldb/trunk/test/foundation/TestObjCMethods.py lldb/trunk/tools/darwin-debug/darwin-debug.cpp lldb/trunk/tools/debugserver/source/MacOSX/CFString.h lldb/trunk/tools/debugserver/source/RNBSocket.cpp lldb/trunk/tools/debugserver/source/RNBSocket.h lldb/trunk/tools/debugserver/source/debugserver.cpp lldb/trunk/tools/lldb-platform/lldb-platform.cpp Modified: lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h (original) +++ lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h Tue Apr 12 00:54:46 2011 @@ -59,6 +59,9 @@ NamedSocketAccept (const char *socket_name, Error *error_ptr); lldb::ConnectionStatus + NamedSocketConnect (const char *socket_name, Error *error_ptr); + + lldb::ConnectionStatus Close (int& fd, Error *error); int m_fd; // Socket we use to communicate once conn established Modified: lldb/trunk/include/lldb/Core/ConnectionMachPort.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionMachPort.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ConnectionMachPort.h (original) +++ lldb/trunk/include/lldb/Core/ConnectionMachPort.h Tue Apr 12 00:54:46 2011 @@ -88,4 +88,4 @@ #endif // liblldb_ConnectionMachPort_h_ -#endif // #if defined(__APPLE__) \ No newline at end of file +#endif // #if defined(__APPLE__) Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Tue Apr 12 00:54:46 2011 @@ -388,15 +388,6 @@ bool PopInputReader (const lldb::InputReaderSP& reader_sp); - ExecutionContext & - GetExecutionContext() - { - return m_exe_ctx; - } - - void - UpdateExecutionContext (ExecutionContext *override_context); - static lldb::DebuggerSP FindDebuggerWithID (lldb::user_id_t id); @@ -447,7 +438,6 @@ Listener m_listener; SourceManager m_source_manager; std::auto_ptr m_command_interpreter_ap; - ExecutionContext m_exe_ctx; std::stack m_input_readers; std::string m_input_reader_data; Modified: lldb/trunk/include/lldb/Core/Module.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Module.h (original) +++ lldb/trunk/include/lldb/Core/Module.h Tue Apr 12 00:54:46 2011 @@ -391,8 +391,11 @@ const ConstString & GetObjectName() const; - off_t - GetObjectOffset() const; + uint64_t + GetObjectOffset() const + { + return m_object_offset; + } //------------------------------------------------------------------ /// Get the object file representation for the current architecture. @@ -598,6 +601,7 @@ FileSpec m_file; ///< The file representation on disk for this module (if there is one). FileSpec m_platform_file;///< The path to the module on the platform on which it is being debugged ConstString m_object_name; ///< The name an object within this module that is selected, or empty of the module is represented by \a m_file. + uint64_t m_object_offset; std::auto_ptr m_objfile_ap; ///< A pointer to the object file parser for this module. std::auto_ptr m_symfile_ap; ///< A pointer to the symbol vendor for this module. ClangASTContext m_ast; ///< The AST context for this module. Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Tue Apr 12 00:54:46 2011 @@ -343,23 +343,17 @@ SetCrashDescription (const char *description); static uint32_t - FindProcesses (const ProcessInfoMatch &match_info, - ProcessInfoList &proc_infos); + FindProcesses (const ProcessInstanceInfoMatch &match_info, + ProcessInstanceInfoList &proc_infos); static bool - GetProcessInfo (lldb::pid_t pid, ProcessInfo &proc_info); + GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info); static lldb::pid_t LaunchApplication (const FileSpec &app_file_spec); - static lldb::pid_t - LaunchInNewTerminal (const char *tty_name, // Optional partial or full tty name ("/dev/ttys000" or "ttys000") - const char **argv, // argv[0] is executable, argv[1] and on are the arguments - const char **envp, - const char *working_dir, - const ArchSpec *arch_spec, - bool stop_at_entry, - bool disable_aslr); + static Error + LaunchProcess (ProcessLaunchInfo &launch_info); static bool OpenFileInExternalEditor (const FileSpec &file_spec, Modified: lldb/trunk/include/lldb/Interpreter/Args.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Args.h (original) +++ lldb/trunk/include/lldb/Interpreter/Args.h Tue Apr 12 00:54:46 2011 @@ -82,6 +82,11 @@ Args (const char *command, size_t len); + Args (const Args &rhs); + + const Args & + operator= (const Args &rhs); + //------------------------------------------------------------------ /// Destructor. //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Tue Apr 12 00:54:46 2011 @@ -39,7 +39,8 @@ }; void - SourceInitFile (bool in_cwd, CommandReturnObject &result); + SourceInitFile (bool in_cwd, + CommandReturnObject &result); CommandInterpreter (Debugger &debugger, lldb::ScriptLanguage script_language, @@ -49,13 +50,16 @@ ~CommandInterpreter (); lldb::CommandObjectSP - GetCommandSPExact (const char *cmd, bool include_aliases); + GetCommandSPExact (const char *cmd, + bool include_aliases); CommandObject * - GetCommandObjectExact (const char *cmd_cstr, bool include_aliases); + GetCommandObjectExact (const char *cmd_cstr, + bool include_aliases); CommandObject * - GetCommandObject (const char *cmd, StringList *matches = NULL); + GetCommandObject (const char *cmd, + StringList *matches = NULL); bool CommandExists (const char *cmd); @@ -67,7 +71,8 @@ UserCommandExists (const char *cmd); void - AddAlias (const char *alias_name, lldb::CommandObjectSP& command_obj_sp); + AddAlias (const char *alias_name, + lldb::CommandObjectSP& command_obj_sp); bool RemoveAlias (const char *alias_name); @@ -82,14 +87,19 @@ RemoveAliasOptions (const char *alias_name); void - AddOrReplaceAliasOptions (const char *alias_name, OptionArgVectorSP &option_arg_vector_sp); + AddOrReplaceAliasOptions (const char *alias_name, + OptionArgVectorSP &option_arg_vector_sp); bool - StripFirstWord (std::string &command_string, std::string &next_word); + StripFirstWord (std::string &command_string, + std::string &next_word); void - BuildAliasResult (const char *alias_name, std::string &raw_input_string, std::string &alias_result, - CommandObject *&alias_cmd_obj, CommandReturnObject &result); + BuildAliasResult (const char *alias_name, + std::string &raw_input_string, + std::string &alias_result, + CommandObject *&alias_cmd_obj, + CommandReturnObject &result); bool HandleCommand (const char *command_line, @@ -151,12 +161,12 @@ //------------------------------------------------------------------ void HandleCommandsFromFile (FileSpec &file, - ExecutionContext *context, - bool stop_on_continue, - bool stop_on_error, - bool echo_commands, - bool print_results, - CommandReturnObject &result); + ExecutionContext *context, + bool stop_on_continue, + bool stop_on_error, + bool echo_commands, + bool print_results, + CommandReturnObject &result); CommandObject * GetCommandObjectForCommand (std::string &command_line); @@ -177,11 +187,11 @@ int HandleCompletion (const char *current_line, - const char *cursor, - const char *last_char, - int match_start_point, - int max_return_elements, - StringList &matches); + const char *cursor, + const char *last_char, + int match_start_point, + int max_return_elements, + StringList &matches); // This version just returns matches, and doesn't compute the substring. It is here so the // Help command can call it for the first argument. @@ -190,22 +200,26 @@ int HandleCompletionMatches (Args &input, - int &cursor_index, - int &cursor_char_position, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches); + int &cursor_index, + int &cursor_char_position, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches); int - GetCommandNamesMatchingPartialString (const char *cmd_cstr, bool include_aliases, StringList &matches); + GetCommandNamesMatchingPartialString (const char *cmd_cstr, + bool include_aliases, + StringList &matches); void GetHelp (CommandReturnObject &result); void - GetAliasHelp (const char *alias_name, const char *command_name, StreamString &help_string); + GetAliasHelp (const char *alias_name, + const char *command_name, + StreamString &help_string); void OutputFormattedHelpText (Stream &stream, @@ -219,6 +233,18 @@ { return m_debugger; } + + ExecutionContext & + GetExecutionContext() + { + return m_exe_ctx; + } + + void + UpdateExecutionContext (ExecutionContext *override_context); + + lldb::PlatformSP + GetPlatform (bool prefer_target_platform); const char * ProcessEmbeddedScriptCommands (const char *arg); @@ -245,7 +271,8 @@ Initialize (); void - CrossRegisterCommand (const char * dest_cmd, const char * object_type); + CrossRegisterCommand (const char *dest_cmd, + const char *object_type); void SetScriptLanguage (lldb::ScriptLanguage lang); @@ -264,8 +291,11 @@ HasAliasOptions (); void - BuildAliasCommandArgs (CommandObject *alias_cmd_obj, const char *alias_name, Args &cmd_args, - std::string &raw_input_string, CommandReturnObject &result); + BuildAliasCommandArgs (CommandObject *alias_cmd_obj, + const char *alias_name, + Args &cmd_args, + std::string &raw_input_string, + CommandReturnObject &result); int GetOptionArgumentPosition (const char *in_string); @@ -284,10 +314,12 @@ #ifndef SWIG void - AddLogChannel (const char *name, const Log::Callbacks &log_callbacks); + AddLogChannel (const char *name, + const Log::Callbacks &log_callbacks); bool - GetLogChannelCallbacks (const char *channel, Log::Callbacks &log_callbacks); + GetLogChannelCallbacks (const char *channel, + Log::Callbacks &log_callbacks); bool RemoveLogChannel (const char *name); @@ -297,11 +329,16 @@ FindLongestCommandWord (CommandObject::CommandMap &dict); void - FindCommandsForApropos (const char *word, StringList &commands_found, StringList &commands_help); + FindCommandsForApropos (const char *word, + StringList &commands_found, + StringList &commands_help); void - AproposAllSubCommands (CommandObject *cmd_obj, const char *prefix, const char *search_word, - StringList &commands_found, StringList &commands_help); + AproposAllSubCommands (CommandObject *cmd_obj, + const char *prefix, + const char *search_word, + StringList &commands_found, + StringList &commands_help); protected: friend class Debugger; @@ -314,15 +351,16 @@ private: - Debugger &m_debugger; // The debugger session that this interpreter is associated with + Debugger &m_debugger; // The debugger session that this interpreter is associated with + ExecutionContext m_exe_ctx; // The current execution context to use when handling commands bool m_synchronous_execution; bool m_skip_lldbinit_files; - CommandObject::CommandMap m_command_dict; // Stores basic built-in commands (they cannot be deleted, removed or overwritten). - CommandObject::CommandMap m_alias_dict; // Stores user aliases/abbreviations for commands - CommandObject::CommandMap m_user_dict; // Stores user-defined commands - OptionArgMap m_alias_options; // Stores any options (with or without arguments) that go with any alias. + CommandObject::CommandMap m_command_dict; // Stores basic built-in commands (they cannot be deleted, removed or overwritten). + CommandObject::CommandMap m_alias_dict; // Stores user aliases/abbreviations for commands + CommandObject::CommandMap m_user_dict; // Stores user-defined commands + OptionArgMap m_alias_options; // Stores any options (with or without arguments) that go with any alias. std::vector m_command_history; - std::string m_repeat_command; // Stores the command that will be executed for an empty command string. + std::string m_repeat_command; // Stores the command that will be executed for an empty command string. std::auto_ptr m_script_interpreter_ap; char m_comment_char; }; Modified: lldb/trunk/include/lldb/Target/Platform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Platform.h (original) +++ lldb/trunk/include/lldb/Target/Platform.h Tue Apr 12 00:54:46 2011 @@ -123,6 +123,11 @@ bool GetOSKernelDescription (std::string &s); + // Returns the the hostname if we are connected, else the short plugin + // name. + const char * + GetName (); + virtual const char * GetHostname (); @@ -252,83 +257,47 @@ BreakpointSite *bp_site) = 0; //------------------------------------------------------------------ - /// Launch a new process. - /// - /// Launch a new process by spawning a new process using the - /// target object's executable module's file as the file to launch. - /// Arguments are given in \a argv, and the environment variables - /// are in \a envp. Standard input and output files can be - /// optionally re-directed to \a stdin_path, \a stdout_path, and - /// \a stderr_path. - /// - /// This function is not meant to be overridden by Process - /// subclasses. It will first call Process::WillLaunch (Module *) - /// and if that returns \b true, Process::DoLaunch (Module*, - /// char const *[],char const *[],const char *,const char *, - /// const char *) will be called to actually do the launching. If - /// DoLaunch returns \b true, then Process::DidLaunch() will be - /// called. - /// - /// @param[in] argv - /// The argument array. - /// - /// @param[in] envp - /// The environment array. - /// - /// @param[in] launch_flags - /// Flags to modify the launch (@see lldb::LaunchFlags) - /// - /// @param[in] stdin_path - /// The path to use when re-directing the STDIN of the new - /// process. If all stdXX_path arguments are NULL, a pseudo - /// terminal will be used. - /// - /// @param[in] stdout_path - /// The path to use when re-directing the STDOUT of the new - /// process. If all stdXX_path arguments are NULL, a pseudo - /// terminal will be used. - /// - /// @param[in] stderr_path - /// The path to use when re-directing the STDERR of the new - /// process. If all stdXX_path arguments are NULL, a pseudo - /// terminal will be used. - /// - /// @param[in] working_directory - /// The working directory to have the child process run in - /// - /// @return - /// An error object. Call GetID() to get the process ID if - /// the error object is success. + /// Launch a new process on a platform, not necessarily for + /// debugging, it could be just for running the process. //------------------------------------------------------------------ -// virtual lldb::ProcessSP -// Launch (char const *argv[], -// char const *envp[], -// uint32_t launch_flags, -// const char *stdin_path, -// const char *stdout_path, -// const char *stderr_path, -// const char *working_directory, -// Error &error) = 0; + virtual Error + LaunchProcess (ProcessLaunchInfo &launch_info); + + //------------------------------------------------------------------ + /// Subclasses should NOT need to implement this function as it uses + /// the Platform::LaunchProcess() followed by Platform::Attach () + //------------------------------------------------------------------ + lldb::ProcessSP + DebugProcess (ProcessLaunchInfo &launch_info, + Debugger &debugger, + Target *target, // Can be NULL, if NULL create a new target, else use existing one + Listener &listener, + Error &error); //------------------------------------------------------------------ /// Attach to an existing process using a process ID. /// - /// This function is not meant to be overridden by Process - /// subclasses. It will first call Process::WillAttach (lldb::pid_t) - /// and if that returns \b true, Process::DoAttach (lldb::pid_t) will - /// be called to actually do the attach. If DoAttach returns \b - /// true, then Process::DidAttach() will be called. + /// Each platform subclass needs to implement this function and + /// attempt to attach to the process with the process ID of \a pid. + /// The platform subclass should return an appropriate ProcessSP + /// subclass that is attached to the process, or an empty shared + /// pointer with an appriopriate error. /// /// @param[in] pid /// The process ID that we should attempt to attach to. /// /// @return - /// Returns \a pid if attaching was successful, or - /// LLDB_INVALID_PROCESS_ID if attaching fails. - //------------------------------------------------------------------ -// virtual lldb::ProcessSP -// Attach (lldb::pid_t pid, -// Error &error) = 0; + /// An appropriate ProcessSP containing a valid shared pointer + /// to the default Process subclass for the platform that is + /// attached to the process, or an empty shared pointer with an + /// appriopriate error fill into the \a error object. + //------------------------------------------------------------------ + virtual lldb::ProcessSP + Attach (lldb::pid_t pid, + Debugger &debugger, + Target *target, // Can be NULL, if NULL create a new target, else use existing one + Listener &listener, + Error &error) = 0; //------------------------------------------------------------------ /// Attach to an existing process by process name. @@ -357,11 +326,11 @@ // Subclasses will need to fill in the remote case. //------------------------------------------------------------------ virtual uint32_t - FindProcesses (const ProcessInfoMatch &match_info, - ProcessInfoList &proc_infos); + FindProcesses (const ProcessInstanceInfoMatch &match_info, + ProcessInstanceInfoList &proc_infos); virtual bool - GetProcessInfo (lldb::pid_t pid, ProcessInfo &proc_info); + GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info); const std::string & GetRemoteURL () const @@ -529,7 +498,8 @@ public: PlatformList() : m_mutex (Mutex::eMutexTypeRecursive), - m_platforms () + m_platforms (), + m_selected_platform_sp() { } Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Tue Apr 12 00:54:46 2011 @@ -11,8 +11,11 @@ #define liblldb_Process_h_ // C Includes +#include + // C++ Includes #include +#include #include // Other libraries and framework includes @@ -39,7 +42,9 @@ namespace lldb_private { - +//---------------------------------------------------------------------- +// ProcessInstanceSettings +//---------------------------------------------------------------------- class ProcessInstanceSettings : public InstanceSettings { public: @@ -224,35 +229,38 @@ bool m_got_host_env; }; - +//---------------------------------------------------------------------- +// ProcessInfo +// +// A base class for information for a process. This can be used to fill +// out information for a process prior to launching it, or it can be +// used for an instance of a process and can be filled in with the +// existing values for that process. +//---------------------------------------------------------------------- class ProcessInfo { public: ProcessInfo () : m_executable (), - m_args (), - m_real_uid (UINT32_MAX), - m_real_gid (UINT32_MAX), - m_effective_uid (UINT32_MAX), - m_effective_gid (UINT32_MAX), + m_arguments (), + m_environment (), + m_uid (LLDB_INVALID_UID), + m_gid (LLDB_INVALID_UID), m_arch(), - m_pid (LLDB_INVALID_PROCESS_ID), - m_parent_pid (LLDB_INVALID_PROCESS_ID) + m_pid (LLDB_INVALID_PROCESS_ID) { } - + ProcessInfo (const char *name, const ArchSpec &arch, lldb::pid_t pid) : - m_executable (), - m_args (), - m_real_uid (UINT32_MAX), - m_real_gid (UINT32_MAX), - m_effective_uid (UINT32_MAX), - m_effective_gid (UINT32_MAX), + m_executable (name, false), + m_arguments (), + m_environment(), + m_uid (LLDB_INVALID_UID), + m_gid (LLDB_INVALID_UID), m_arch (arch), - m_pid (pid), - m_parent_pid (LLDB_INVALID_PROCESS_ID) + m_pid (pid) { } @@ -260,14 +268,12 @@ Clear () { m_executable.Clear(); - m_args.Clear(); - m_real_uid = UINT32_MAX; - m_real_gid = UINT32_MAX; - m_effective_uid = UINT32_MAX; - m_effective_gid = UINT32_MAX; + m_arguments.Clear(); + m_environment.Clear(); + m_uid = LLDB_INVALID_UID; + m_gid = LLDB_INVALID_UID; m_arch.Clear(); m_pid = LLDB_INVALID_PROCESS_ID; - m_parent_pid = LLDB_INVALID_PROCESS_ID; } const char * @@ -275,7 +281,7 @@ { return m_executable.GetFilename().GetCString(); } - + size_t GetNameLength() const { @@ -293,97 +299,61 @@ { return m_executable; } - + const FileSpec & GetExecutableFile () const { return m_executable; } - - uint32_t - GetRealUserID() const - { - return m_real_uid; - } uint32_t - GetRealGroupID() const - { - return m_real_gid; - } - - uint32_t - GetEffectiveUserID() const + GetUserID() const { - return m_effective_uid; + return m_uid; } - + uint32_t - GetEffectiveGroupID() const + GetGroupID() const { - return m_effective_gid; + return m_gid; } bool - RealUserIDIsValid () const + UserIDIsValid () const { - return m_real_uid != UINT32_MAX; + return m_uid != UINT32_MAX; } bool - RealGroupIDIsValid () const + GroupIDIsValid () const { - return m_real_gid != UINT32_MAX; + return m_gid != UINT32_MAX; } - bool - EffectiveUserIDIsValid () const - { - return m_effective_uid != UINT32_MAX; - } - - bool - EffectiveGroupIDIsValid () const - { - return m_effective_gid != UINT32_MAX; - } - - void - SetRealUserID (uint32_t uid) - { - m_real_uid = uid; - } - - void - SetRealGroupID (uint32_t gid) - { - m_real_gid = gid; - } - void - SetEffectiveUserID (uint32_t uid) + SetUserID (uint32_t uid) { - m_effective_uid = uid; + m_uid = uid; } void - SetEffectiveGroupID (uint32_t gid) + SetGroupID (uint32_t gid) { - m_effective_gid = gid; + m_gid = gid; } - + ArchSpec & GetArchitecture () { return m_arch; } - + const ArchSpec & GetArchitecture () const { return m_arch; } - + lldb::pid_t GetProcessID () const { @@ -401,6 +371,120 @@ { return m_pid != LLDB_INVALID_PROCESS_ID; } + + void + Dump (Stream &s, Platform *platform) const; + + Args & + GetArguments () + { + return m_arguments; + } + + const Args & + GetArguments () const + { + return m_arguments; + } + + void + SetArgumentsFromArgs (const Args& args, + bool first_arg_is_executable, + bool first_arg_is_executable_and_argument); + + Args & + GetEnvironmentEntries () + { + return m_environment; + } + + const Args & + GetEnvironmentEntries () const + { + return m_environment; + } + +protected: + FileSpec m_executable; + Args m_arguments; + Args m_environment; + uint32_t m_uid; + uint32_t m_gid; + ArchSpec m_arch; + lldb::pid_t m_pid; +}; + +//---------------------------------------------------------------------- +// ProcessInstanceInfo +// +// Describes an existing process and any discoverable information that +// pertains to that process. +//---------------------------------------------------------------------- +class ProcessInstanceInfo : public ProcessInfo +{ +public: + ProcessInstanceInfo () : + ProcessInfo (), + m_euid (UINT32_MAX), + m_egid (UINT32_MAX), + m_parent_pid (LLDB_INVALID_PROCESS_ID) + { + } + + ProcessInstanceInfo (const char *name, + const ArchSpec &arch, + lldb::pid_t pid) : + ProcessInfo (name, arch, pid), + m_euid (UINT32_MAX), + m_egid (UINT32_MAX), + m_parent_pid (LLDB_INVALID_PROCESS_ID) + { + } + + void + Clear () + { + ProcessInfo::Clear(); + m_euid = UINT32_MAX; + m_egid = UINT32_MAX; + m_parent_pid = LLDB_INVALID_PROCESS_ID; + } + + uint32_t + GetEffectiveUserID() const + { + return m_euid; + } + + uint32_t + GetEffectiveGroupID() const + { + return m_egid; + } + + bool + EffectiveUserIDIsValid () const + { + return m_euid != UINT32_MAX; + } + + bool + EffectiveGroupIDIsValid () const + { + return m_egid != UINT32_MAX; + } + + void + SetEffectiveUserID (uint32_t uid) + { + m_euid = uid; + } + + void + SetEffectiveGroupID (uint32_t gid) + { + m_egid = gid; + } lldb::pid_t GetParentProcessID () const @@ -424,46 +508,272 @@ Dump (Stream &s, Platform *platform) const; static void - DumpTableHeader (Stream &s, Platform *platform, bool verbose = false); + DumpTableHeader (Stream &s, Platform *platform, bool show_args, bool verbose); + + void + DumpAsTableRow (Stream &s, Platform *platform, bool show_args, bool verbose) const; + +protected: + uint32_t m_euid; + uint32_t m_egid; + lldb::pid_t m_parent_pid; +}; + + +//---------------------------------------------------------------------- +// ProcessLaunchInfo +// +// Describes any information that is required to launch a process. +//---------------------------------------------------------------------- + +class ProcessLaunchInfo : public ProcessInfo +{ +public: + + class FileAction + { + public: + + FileAction () : + m_action (eFileActionNone), + m_fd (-1), + m_arg (-1), + m_path () + { + } + + void + Clear() + { + m_action = eFileActionNone; + m_fd = -1; + m_arg = -1; + m_path.clear(); + } + + bool + Close (int fd); + + bool + Duplicate (int fd, int dup_fd); + + bool + Open (int fd, const char *path, bool read, bool write); + + static bool + AddPosixSpawnFileAction (posix_spawn_file_actions_t *file_actions, + const FileAction *info, + Log *log, + Error& error); + + protected: + enum Action + { + eFileActionNone, + eFileActionClose, + eFileActionDuplicate, + eFileActionOpen + }; + + Action m_action; // The action for this file + int m_fd; // An existing file descriptor + int m_arg; // oflag for eFileActionOpen*, dup_fd for eFileActionDuplicate + std::string m_path; // A file path to use for opening after fork or posix_spawn + }; + + ProcessLaunchInfo () : + ProcessInfo(), + m_flags (), + m_stdin_info (), + m_stdout_info (), + m_stderr_info () + { + } + + void + AppendFileAction (const FileAction &info) + { + m_file_actions.push_back(info); + } + + void + AppendCloseFileAction (int fd) + { + FileAction file_action; + file_action.Close (fd); + AppendFileAction (file_action); + } + + void + AppendDuplciateFileAction (int fd, int dup_fd) + { + FileAction file_action; + file_action.Duplicate (fd, dup_fd); + AppendFileAction (file_action); + } + + void + AppendOpenFileAction (int fd, const char *path, bool read, bool write) + { + FileAction file_action; + file_action.Open (fd, path, read, write); + AppendFileAction (file_action); + } + + void + AppendSuppressFileAction (int fd, bool read, bool write) + { + FileAction file_action; + file_action.Open (fd, "/dev/null", read, write); + AppendFileAction (file_action); + } + + size_t + GetNumFileActions () const + { + return m_file_actions.size(); + } + + const FileAction * + GetFileActionAtIndex (size_t idx) const + { + if (idx < m_file_actions.size()) + return &m_file_actions[idx]; + return NULL; + } + + Flags & + GetFlags () + { + return m_flags; + } + + const Flags & + GetFlags () const + { + return m_flags; + } + + const char * + GetWorkingDirectory () const + { + if (m_working_dir.empty()) + return NULL; + return m_working_dir.c_str(); + } + + void + SetWorkingDirectory (const char *working_dir) + { + if (working_dir && working_dir[0]) + m_working_dir.assign (working_dir); + else + m_working_dir.clear(); + } void - DumpAsTableRow (Stream &s, Platform *platform, bool verbose = false) const; + SwapWorkingDirectory (std::string &working_dir) + { + m_working_dir.swap (working_dir); + } + + + const char * + GetProcessPluginName () const + { + if (m_plugin_name.empty()) + return NULL; + return m_plugin_name.c_str(); + } - StringList & - GetArguments() + void + SetProcessPluginName (const char *plugin) { - return m_args; + if (plugin && plugin[0]) + m_plugin_name.assign (plugin); + else + m_plugin_name.clear(); } - const StringList & - GetArguments() const + void + Clear () { - return m_args; + ProcessInfo::Clear(); + m_working_dir.clear(); + m_plugin_name.clear(); + m_flags.Clear(); + m_stdin_info.Clear(); + m_stdout_info.Clear(); + m_stderr_info.Clear(); + m_file_actions.clear(); } protected: - FileSpec m_executable; - StringList m_args; - uint32_t m_real_uid; - uint32_t m_real_gid; - uint32_t m_effective_uid; - uint32_t m_effective_gid; - ArchSpec m_arch; - lldb::pid_t m_pid; - lldb::pid_t m_parent_pid; + std::string m_working_dir; + std::string m_plugin_name; + Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags + FileAction m_stdin_info; // File action for stdin + FileAction m_stdout_info; // File action for stdout + FileAction m_stderr_info; // File action for stderr + std::vector m_file_actions; // File actions for any other files +}; + +class ProcessLaunchCommandOptions : public Options +{ +public: + + ProcessLaunchCommandOptions (CommandInterpreter &interpreter) : + Options(interpreter) + { + // Keep default values of all options in one place: ResetOptionValues () + ResetOptionValues (); + } + + ~ProcessLaunchCommandOptions () + { + } + + Error + SetOptionValue (int option_idx, const char *option_arg); + + void + ResetOptionValues () + { + launch_info.Clear(); + } + + const OptionDefinition* + GetDefinitions () + { + return g_option_table; + } + + // Options table: Required for subclasses of Options. + + static OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + ProcessLaunchInfo launch_info; }; -class ProcessInfoMatch +//---------------------------------------------------------------------- +// ProcessInstanceInfoMatch +// +// A class to help matching one ProcessInstanceInfo to another. +//---------------------------------------------------------------------- + +class ProcessInstanceInfoMatch { public: - ProcessInfoMatch () : + ProcessInstanceInfoMatch () : m_match_info (), m_name_match_type (lldb_private::eNameMatchIgnore), m_match_all_users (false) { } - ProcessInfoMatch (const char *process_name, + ProcessInstanceInfoMatch (const char *process_name, lldb_private::NameMatchType process_name_match_type) : m_match_info (), m_name_match_type (process_name_match_type), @@ -472,13 +782,13 @@ m_match_info.SetName (process_name); } - ProcessInfo & + ProcessInstanceInfo & GetProcessInfo () { return m_match_info; } - const ProcessInfo & + const ProcessInstanceInfo & GetProcessInfo () const { return m_match_info; @@ -512,7 +822,7 @@ NameMatches (const char *process_name) const; bool - Matches (const ProcessInfo &proc_info) const; + Matches (const ProcessInstanceInfo &proc_info) const; bool MatchAllProcesses () const; @@ -520,15 +830,15 @@ Clear (); protected: - ProcessInfo m_match_info; + ProcessInstanceInfo m_match_info; lldb_private::NameMatchType m_name_match_type; bool m_match_all_users; }; -class ProcessInfoList +class ProcessInstanceInfoList { public: - ProcessInfoList () : + ProcessInstanceInfoList () : m_infos() { } @@ -546,7 +856,7 @@ } void - Append (const ProcessInfo &info) + Append (const ProcessInstanceInfo &info) { m_infos.push_back (info); } @@ -576,7 +886,7 @@ } bool - GetInfoAtIndex (uint32_t idx, ProcessInfo &info) + GetInfoAtIndex (uint32_t idx, ProcessInstanceInfo &info) { if (idx < m_infos.size()) { @@ -587,7 +897,7 @@ } // You must ensure "idx" is valid before calling this function - const ProcessInfo & + const ProcessInstanceInfo & GetProcessInfoAtIndex (uint32_t idx) const { assert (idx < m_infos.size()); @@ -595,7 +905,7 @@ } protected: - typedef std::vector collection; + typedef std::vector collection; collection m_infos; }; @@ -1732,6 +2042,20 @@ size_t size, Error &error); + //------------------------------------------------------------------ + /// Read a NULL terminated C string from memory + /// + /// This function will read a cache page at a time until the NULL + /// C stirng terminator is found. It will stop reading if the NULL + /// termination byte isn't found before reading \a cstr_max_len + /// bytes, and the results are always guaranteed to be NULL + /// terminated (at most cstr_max_len - 1 bytes will be read). + //------------------------------------------------------------------ + size_t + ReadCStringFromMemory (lldb::addr_t vm_addr, + char *cstr, + size_t cstr_max_len); + size_t ReadMemoryFromInferior (lldb::addr_t vm_addr, void *buf, @@ -2292,6 +2616,11 @@ size_t dst_len, Error &error); + uint32_t + GetMemoryCacheLineSize() const + { + return m_cache_line_byte_size ; + } protected: typedef std::map collection; //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Tue Apr 12 00:54:46 2011 @@ -39,9 +39,12 @@ typedef enum LaunchFlags { eLaunchFlagNone = 0u, - eLaunchFlagDisableASLR = (1u << 0), ///< Disable Address Space Layout Randomization - eLaunchFlagDisableSTDIO = (1u << 1), ///< Disable stdio for inferior process (e.g. for a GUI app) - eLaunchFlagLaunchInTTY = (1u << 2) ///< Launch the process in a new TTY if supported by the host + eLaunchFlagExec = (1u << 0), ///< Exec when launching and turn the calling process into a new process + eLaunchFlagDebug = (1u << 1), ///< Stop as soon as the process launches to allow the process to be debugged + eLaunchFlagStopAtEntry = (1u << 2), ///< Stop at the program entry point instead of auto-continuing when launching or attaching at entry point + eLaunchFlagDisableASLR = (1u << 3), ///< Disable Address Space Layout Randomization + eLaunchFlagDisableSTDIO = (1u << 4), ///< Disable stdio for inferior process (e.g. for a GUI app) + eLaunchFlagLaunchInTTY = (1u << 5) ///< Launch the process in a new TTY if supported by the host } LaunchFlags; //---------------------------------------------------------------------- Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Tue Apr 12 00:54:46 2011 @@ -103,8 +103,10 @@ class Platform; class Process; class ProcessInfo; -class ProcessInfoList; -class ProcessInfoMatch; +class ProcessInstanceInfo; +class ProcessInstanceInfoList; +class ProcessInstanceInfoMatch; +class ProcessLaunchInfo; class RegisterContext; class RegisterLocation; class RegisterLocationList; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Apr 12 00:54:46 2011 @@ -62,6 +62,7 @@ 26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */; }; 26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */; }; 2668035C11601108008E1FE4 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; + 266E8C6A13528ABC000C2042 /* lldb-platform in Resources */ = {isa = PBXBuildFile; fileRef = 26DC6A101337FE6900FF7998 /* lldb-platform */; }; 2671A0CE134825F6003A87BB /* ConnectionMachPort.h in Headers */ = {isa = PBXBuildFile; fileRef = 2671A0CD134825F6003A87BB /* ConnectionMachPort.h */; }; 2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2671A0CF13482601003A87BB /* ConnectionMachPort.cpp */; }; 26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */; }; @@ -446,6 +447,13 @@ remoteGlobalIDString = 26680206115FD0ED008E1FE4; remoteInfo = LLDB; }; + 266E8C6C13528AD2000C2042 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 26DC6A0F1337FE6900FF7998; + remoteInfo = "lldb-platform"; + }; 2689011413353E9B00698AC0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; @@ -2579,6 +2587,7 @@ buildRules = ( ); dependencies = ( + 266E8C6D13528AD2000C2042 /* PBXTargetDependency */, 2689011513353E9B00698AC0 /* PBXTargetDependency */, 262CFC7211A450CB00946C6C /* PBXTargetDependency */, 26368AF6126B95FA00E8659F /* PBXTargetDependency */, @@ -2688,6 +2697,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 266E8C6A13528ABC000C2042 /* lldb-platform in Resources */, 262CFC7711A4510000946C6C /* debugserver in Resources */, 26368AF7126B960500E8659F /* darwin-debug in Resources */, ); @@ -3143,6 +3153,11 @@ target = 26680206115FD0ED008E1FE4 /* LLDB */; targetProxy = 266803611160110D008E1FE4 /* PBXContainerItemProxy */; }; + 266E8C6D13528AD2000C2042 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 26DC6A0F1337FE6900FF7998 /* lldb-platform */; + targetProxy = 266E8C6C13528AD2000C2042 /* PBXContainerItemProxy */; + }; 2689011513353E9B00698AC0 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 2689FFC913353D7A00698AC0 /* lldb-core */; Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Tue Apr 12 00:54:46 2011 @@ -204,65 +204,65 @@ } } - if ((launch_flags & eLaunchFlagLaunchInTTY) || g_launch_tty) - { - ArchSpec arch (m_opaque_sp->GetArchitecture ()); - - Module *exe_module = m_opaque_sp->GetExecutableModule().get(); - if (exe_module) - { - char exec_file_path[PATH_MAX]; - exe_module->GetFileSpec().GetPath(exec_file_path, sizeof(exec_file_path)); - if (exe_module->GetFileSpec().Exists()) - { - // Make a new argument vector - std::vector exec_path_plus_argv; - // Append the resolved executable path - exec_path_plus_argv.push_back (exec_file_path); - - // Push all args if there are any - if (argv) - { - for (int i = 0; argv[i]; ++i) - exec_path_plus_argv.push_back(argv[i]); - } - - // Push a NULL to terminate the args. - exec_path_plus_argv.push_back(NULL); - - - const char *tty_name = NULL; - if (g_launch_tty && g_launch_tty[0] == '/') - tty_name = g_launch_tty; - - lldb::pid_t pid = Host::LaunchInNewTerminal (tty_name, - &exec_path_plus_argv[0], - envp, - working_directory, - &arch, - true, - launch_flags & eLaunchFlagDisableASLR); - - if (pid != LLDB_INVALID_PROCESS_ID) - { - sb_process = AttachToProcessWithID(listener, pid, error); - } - else - { - error.SetErrorStringWithFormat("failed to launch process in terminal"); - } - } - else - { - error.SetErrorStringWithFormat("executable doesn't exist: \"%s\"", exec_file_path); - } - } - else - { - error.SetErrorStringWithFormat("invalid executable"); - } - } - else +// if ((launch_flags & eLaunchFlagLaunchInTTY) || g_launch_tty) +// { +// ArchSpec arch (m_opaque_sp->GetArchitecture ()); +// +// Module *exe_module = m_opaque_sp->GetExecutableModule().get(); +// if (exe_module) +// { +// char exec_file_path[PATH_MAX]; +// exe_module->GetFileSpec().GetPath(exec_file_path, sizeof(exec_file_path)); +// if (exe_module->GetFileSpec().Exists()) +// { +// // Make a new argument vector +// std::vector exec_path_plus_argv; +// // Append the resolved executable path +// exec_path_plus_argv.push_back (exec_file_path); +// +// // Push all args if there are any +// if (argv) +// { +// for (int i = 0; argv[i]; ++i) +// exec_path_plus_argv.push_back(argv[i]); +// } +// +// // Push a NULL to terminate the args. +// exec_path_plus_argv.push_back(NULL); +// +// +// const char *tty_name = NULL; +// if (g_launch_tty && g_launch_tty[0] == '/') +// tty_name = g_launch_tty; +// +// lldb::pid_t pid = Host::LaunchInNewTerminal (tty_name, +// &exec_path_plus_argv[0], +// envp, +// working_directory, +// &arch, +// true, +// launch_flags & eLaunchFlagDisableASLR); +// +// if (pid != LLDB_INVALID_PROCESS_ID) +// { +// sb_process = AttachToProcessWithID(listener, pid, error); +// } +// else +// { +// error.SetErrorStringWithFormat("failed to launch process in terminal"); +// } +// } +// else +// { +// error.SetErrorStringWithFormat("executable doesn't exist: \"%s\"", exec_file_path); +// } +// } +// else +// { +// error.SetErrorStringWithFormat("invalid executable"); +// } +// } +// else { if (listener.IsValid()) sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref())); Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Tue Apr 12 00:54:46 2011 @@ -105,7 +105,7 @@ ConstString target_triple; - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (!process) { result.AppendError ("Args found no process."); @@ -131,7 +131,7 @@ return false; } - Thread *thread = m_interpreter.GetDebugger().GetExecutionContext ().thread; + Thread *thread = m_interpreter.GetExecutionContext ().thread; if (!thread) { Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Tue Apr 12 00:54:46 2011 @@ -322,7 +322,7 @@ FileSpec file; if (m_options.m_filename.empty()) { - StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame; + StackFrame *cur_frame = m_interpreter.GetExecutionContext().frame; if (cur_frame == NULL) { result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Tue Apr 12 00:54:46 2011 @@ -128,7 +128,7 @@ break; case 'a': - arch.SetTriple (option_arg, m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform().get()); + arch.SetTriple (option_arg, m_interpreter.GetPlatform (true).get()); break; default: @@ -257,7 +257,7 @@ if (m_options.show_mixed && m_options.num_lines_context == 0) m_options.num_lines_context = 1; - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (!m_options.func_name.empty()) { Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Apr 12 00:54:46 2011 @@ -295,7 +295,7 @@ CommandReturnObject &result ) { - m_exe_ctx = m_interpreter.GetDebugger().GetExecutionContext(); + m_exe_ctx = m_interpreter.GetExecutionContext(); m_options.Reset(); Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Tue Apr 12 00:54:46 2011 @@ -58,7 +58,7 @@ { case 'a': { - PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + PlatformSP platform_sp (m_interpreter.GetPlatform (false)); ArchSpec option_arch (option_arg, platform_sp.get()); if (option_arch.IsValid()) m_arch = option_arch; Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Apr 12 00:54:46 2011 @@ -69,7 +69,7 @@ Execute (Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.frame) { exe_ctx.frame->DumpUsingSettingsFormat (&result.GetOutputStream()); @@ -188,7 +188,7 @@ Execute (Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx (m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); if (exe_ctx.thread) { const uint32_t num_frames = exe_ctx.thread->GetStackFrameCount(); @@ -445,7 +445,7 @@ CommandReturnObject &result ) { - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.frame == NULL) { result.AppendError ("you must be stopped in a valid stack frame to view frame variables."); Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Tue Apr 12 00:54:46 2011 @@ -87,7 +87,7 @@ LineTable *line_table = sc.comp_unit->GetLineTable(); if (line_table) line_table->GetDescription (&strm, - interpreter.GetDebugger().GetExecutionContext().target, + interpreter.GetExecutionContext().target, lldb::eDescriptionLevelBrief); else strm << "No line table"; @@ -165,7 +165,7 @@ { Symtab *symtab = objfile->GetSymtab(); if (symtab) - symtab->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, sort_order); + symtab->Dump(&strm, interpreter.GetExecutionContext().target, sort_order); } } } @@ -183,9 +183,11 @@ { strm.PutCString ("Sections for '"); strm << module->GetFileSpec(); + if (module->GetObjectName()) + strm << '(' << module->GetObjectName() << ')'; strm.Printf ("' (%s):\n", module->GetArchitecture().GetArchitectureName()); strm.IndentMore(); - section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, true, UINT32_MAX); + section_list->Dump(&strm, interpreter.GetExecutionContext().target, true, UINT32_MAX); strm.IndentLess(); } } @@ -224,7 +226,7 @@ lldb::addr_t addr = raw_addr - offset; Address so_addr; SymbolContext sc; - Target *target = interpreter.GetDebugger().GetExecutionContext().target; + Target *target = interpreter.GetExecutionContext().target; if (target && !target->GetSectionLoadList().IsEmpty()) { if (!target->GetSectionLoadList().ResolveLoadAddress (addr, so_addr)) @@ -242,7 +244,7 @@ if (offset) strm.Printf("File Address: 0x%llx\n", addr); - ExecutionContextScope *exe_scope = interpreter.GetDebugger().GetExecutionContext().GetBestExecutionContextScope(); + ExecutionContextScope *exe_scope = interpreter.GetExecutionContext().GetBestExecutionContextScope(); strm.IndentMore(); strm.Indent (" Address: "); so_addr.Dump (&strm, exe_scope, Address::DumpStyleSectionNameOffset); @@ -309,7 +311,7 @@ { Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); strm.Indent (); - symbol->Dump (&strm, interpreter.GetDebugger().GetExecutionContext().target, i); + symbol->Dump (&strm, interpreter.GetExecutionContext().target, i); } strm.IndentLess (); return num_matches; @@ -338,9 +340,9 @@ { if (sc.line_entry.range.GetBaseAddress().IsValid()) { - lldb::addr_t vm_addr = sc.line_entry.range.GetBaseAddress().GetLoadAddress(interpreter.GetDebugger().GetExecutionContext().target); + lldb::addr_t vm_addr = sc.line_entry.range.GetBaseAddress().GetLoadAddress(interpreter.GetExecutionContext().target); int addr_size = sizeof (addr_t); - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = interpreter.GetExecutionContext().process; if (process) addr_size = process->GetTarget().GetArchitecture().GetAddressByteSize(); if (vm_addr != LLDB_INVALID_ADDRESS) @@ -351,7 +353,7 @@ strm.PutCString(" in "); } } - sc.DumpStopContext(&strm, interpreter.GetDebugger().GetExecutionContext().process, sc.line_entry.range.GetBaseAddress(), true, true, false); + sc.DumpStopContext(&strm, interpreter.GetExecutionContext().process, sc.line_entry.range.GetBaseAddress(), true, true, false); } } strm.IndentLess (); @@ -1050,7 +1052,7 @@ } else { - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); uint32_t total_num_dumped = 0; uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); @@ -1233,9 +1235,11 @@ Module *module = target->GetImages().GetModulePointerAtIndex(image_idx); strm.Printf("[%3u] ", image_idx); + bool dump_object_name = false; if (m_options.m_format_array.empty()) { DumpFullpath(strm, &module->GetFileSpec(), 0); + dump_object_name = true; } else { @@ -1254,6 +1258,7 @@ case 'f': DumpFullpath (strm, &module->GetFileSpec(), width); + dump_object_name = true; break; case 'd': @@ -1262,6 +1267,7 @@ case 'b': DumpBasename (strm, &module->GetFileSpec(), width); + dump_object_name = true; break; case 's': @@ -1277,6 +1283,7 @@ DumpBasename(strm, &symbol_file->GetObjectFile()->GetFileSpec(), width); else DumpFullpath (strm, &symbol_file->GetObjectFile()->GetFileSpec(), width); + dump_object_name = true; break; } } @@ -1291,8 +1298,15 @@ default: break; } + } } + if (dump_object_name) + { + const char *object_name = module->GetObjectName().GetCString(); + if (object_name) + strm.Printf ("(%s)", object_name); + } strm.EOL(); } result.SetStatus (eReturnStatusSuccessFinishResult); @@ -1682,16 +1696,16 @@ OptionDefinition CommandObjectImageLookup::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress, "Lookup an address in one or more executable images."}, -{ LLDB_OPT_SET_1, false, "offset", 'o', required_argument, NULL, 0, eArgTypeOffset, "When looking up an address subtract from any addresses before doing the lookup."}, -{ LLDB_OPT_SET_2, true, "symbol", 's', required_argument, NULL, 0, eArgTypeSymbol, "Lookup a symbol by name in the symbol tables in one or more executable images."}, -{ LLDB_OPT_SET_2, false, "regex", 'r', no_argument, NULL, 0, eArgTypeNone, "The argument for name lookups are regular expressions."}, -{ LLDB_OPT_SET_3, true, "file", 'f', required_argument, NULL, 0, eArgTypeFilename, "Lookup a file by fullpath or basename in one or more executable images."}, -{ LLDB_OPT_SET_3, false, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, "Lookup a line number in a file (must be used in conjunction with --file)."}, -{ LLDB_OPT_SET_3, false, "no-inlines", 'i', no_argument, NULL, 0, eArgTypeNone, "Check inline line entries (must be used in conjunction with --file)."}, -{ LLDB_OPT_SET_4, true, "function", 'n', required_argument, NULL, 0, eArgTypeFunctionName, "Lookup a function by name in the debug symbols in one or more executable images."}, -{ LLDB_OPT_SET_5, true, "type", 't', required_argument, NULL, 0, eArgTypeName, "Lookup a type by name in the debug symbols in one or more executable images."}, -{ LLDB_OPT_SET_ALL, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, "Enable verbose lookup information."}, +{ LLDB_OPT_SET_1, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress, "Lookup an address in one or more executable images."}, +{ LLDB_OPT_SET_1, false, "offset", 'o', required_argument, NULL, 0, eArgTypeOffset, "When looking up an address subtract from any addresses before doing the lookup."}, +{ LLDB_OPT_SET_2, true, "symbol", 's', required_argument, NULL, 0, eArgTypeSymbol, "Lookup a symbol by name in the symbol tables in one or more executable images."}, +{ LLDB_OPT_SET_2, false, "regex", 'r', no_argument, NULL, 0, eArgTypeNone, "The argument for name lookups are regular expressions."}, +{ LLDB_OPT_SET_3, true, "file", 'f', required_argument, NULL, 0, eArgTypeFilename, "Lookup a file by fullpath or basename in one or more executable images."}, +{ LLDB_OPT_SET_3, false, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, "Lookup a line number in a file (must be used in conjunction with --file)."}, +{ LLDB_OPT_SET_3, false, "no-inlines", 'i', no_argument, NULL, 0, eArgTypeNone, "Check inline line entries (must be used in conjunction with --file)."}, +{ LLDB_OPT_SET_4, true, "function", 'n', required_argument, NULL, 0, eArgTypeFunctionName, "Lookup a function by name in the debug symbols in one or more executable images."}, +{ LLDB_OPT_SET_5, true, "type", 't', required_argument, NULL, 0, eArgTypeName, "Lookup a type by name in the debug symbols in one or more executable images."}, +{ LLDB_OPT_SET_ALL, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, "Enable verbose lookup information."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Apr 12 00:54:46 2011 @@ -240,7 +240,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); @@ -415,7 +415,7 @@ { SET1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat, "The format that will be used to display the memory. Defaults to bytes with ASCII (--format=Y)."}, { SET1 , false, "size", 's', required_argument, NULL, 0, eArgTypeByteSize, "The size in bytes to use when displaying with the selected format."}, { SET1 , false, "num-per-line", 'l', required_argument, NULL, 0, eArgTypeNumberPerLine,"The number of items per line to display."}, -{ SET1 , false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "The number of total items to display."}, +{ SET1 | SET2, false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "The number of total items to display."}, { SET1 | SET2, false, "outfile", 'o', required_argument, NULL, 0, eArgTypeFilename, "Dump memory read results into a file."}, { SET1 | SET2, false, "append", 'a', no_argument, NULL, 0, eArgTypeNone, "Append memory read results to 'outfile'."}, { SET2, false, "binary", 'b', no_argument, NULL, 0, eArgTypeNone, "If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, @@ -591,7 +591,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Tue Apr 12 00:54:46 2011 @@ -413,6 +413,134 @@ return result.Succeeded(); } }; +//---------------------------------------------------------------------- +// "platform process launch" +//---------------------------------------------------------------------- +class CommandObjectPlatformProcessLaunch : public CommandObject +{ +public: + CommandObjectPlatformProcessLaunch (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "platform process launch", + "Launch a new process on a remote platform.", + "platform process launch program", + 0), + m_options (interpreter) + { + } + + virtual + ~CommandObjectPlatformProcessLaunch () + { + } + + virtual bool + Execute (Args& args, CommandReturnObject &result) + { + PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + + if (platform_sp) + { + Error error; + const uint32_t argc = args.GetArgumentCount(); + Target *target = m_interpreter.GetExecutionContext().target; + ModuleSP exe_module_sp; + if (target) + { + exe_module_sp = target->GetExecutableModule(); + if (exe_module_sp) + { + m_options.launch_info.GetExecutableFile () = exe_module_sp->GetFileSpec(); + char exe_path[PATH_MAX]; + if (m_options.launch_info.GetExecutableFile ().GetPath (exe_path, sizeof(exe_path))) + m_options.launch_info.GetArguments().AppendArgument (exe_path); + m_options.launch_info.GetArchitecture() = exe_module_sp->GetArchitecture(); + } + } + + if (argc > 0) + { + if (m_options.launch_info.GetExecutableFile ()) + { + // We already have an executable file, so we will use this + // and all arguments to this function are extra arguments + m_options.launch_info.GetArguments().AppendArguments (args); + } + else + { + // We don't have any file yet, so the first argument is our + // executable, and the rest are program arguments + const bool first_arg_is_executable = true; + m_options.launch_info.SetArgumentsFromArgs (args, + first_arg_is_executable, + first_arg_is_executable); + } + } + + if (m_options.launch_info.GetExecutableFile ()) + { + Debugger &debugger = m_interpreter.GetDebugger(); + + if (argc == 0) + { + lldb::UserSettingsControllerSP process_usc_sp (Process::GetSettingsController ()); + if (process_usc_sp) + { + SettableVariableType type; + StringList settings_args (process_usc_sp->GetVariable ("process.run-args", + type, + m_interpreter.GetDebugger().GetInstanceName().GetCString(), + error)); + if (error.Success()) + { + const size_t num_settings_args = settings_args.GetSize(); + for (size_t i=0; iDebugProcess (m_options.launch_info, + debugger, + target, + debugger.GetListener(), + error)); + if (process_sp && process_sp->IsAlive()) + { + result.SetStatus (eReturnStatusSuccessFinishNoResult); + return true; + } + + if (error.Success()) + result.AppendError ("process launch failed"); + else + result.AppendError (error.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + else + { + result.AppendError ("'platform process launch' uses the current target file and arguments, or the executable and its arguments can be specified in this command"); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + else + { + result.AppendError ("no platform is selected\n"); + } + return result.Succeeded(); + } + + virtual Options * + GetOptions () + { + return &m_options; + } + +protected: + ProcessLaunchCommandOptions m_options; +}; + //---------------------------------------------------------------------- @@ -454,11 +582,11 @@ lldb::pid_t pid = m_options.match_info.GetProcessInfo().GetProcessID(); if (pid != LLDB_INVALID_PROCESS_ID) { - ProcessInfo proc_info; + ProcessInstanceInfo proc_info; if (platform_sp->GetProcessInfo (pid, proc_info)) { - ProcessInfo::DumpTableHeader (ostrm, platform_sp.get()); - proc_info.DumpAsTableRow(ostrm, platform_sp.get()); + ProcessInstanceInfo::DumpTableHeader (ostrm, platform_sp.get(), m_options.show_args, m_options.verbose); + proc_info.DumpAsTableRow(ostrm, platform_sp.get(), m_options.show_args, m_options.verbose); result.SetStatus (eReturnStatusSuccessFinishResult); } else @@ -469,24 +597,25 @@ } else { - ProcessInfoList proc_infos; + ProcessInstanceInfoList proc_infos; const uint32_t matches = platform_sp->FindProcesses (m_options.match_info, proc_infos); - if (matches == 0) + const char *match_desc = NULL; + const char *match_name = m_options.match_info.GetProcessInfo().GetName(); + if (match_name && match_name[0]) { - const char *match_desc = NULL; - const char *match_name = m_options.match_info.GetProcessInfo().GetName(); - if (match_name && match_name[0]) + switch (m_options.match_info.GetNameMatchType()) { - switch (m_options.match_info.GetNameMatchType()) - { - case eNameMatchIgnore: break; - case eNameMatchEquals: match_desc = "match"; break; - case eNameMatchContains: match_desc = "contains"; break; - case eNameMatchStartsWith: match_desc = "starts with"; break; - case eNameMatchEndsWith: match_desc = "end with"; break; - case eNameMatchRegularExpression: match_desc = "match the regular expression"; break; - } + case eNameMatchIgnore: break; + case eNameMatchEquals: match_desc = "matched"; break; + case eNameMatchContains: match_desc = "contained"; break; + case eNameMatchStartsWith: match_desc = "started with"; break; + case eNameMatchEndsWith: match_desc = "ended with"; break; + case eNameMatchRegularExpression: match_desc = "matched the regular expression"; break; } + } + + if (matches == 0) + { if (match_desc) result.AppendErrorWithFormat ("no processes were found that %s \"%s\" on the \"%s\" platform\n", match_desc, @@ -498,11 +627,19 @@ } else { - - ProcessInfo::DumpTableHeader (ostrm, platform_sp.get()); + result.AppendMessageWithFormat ("%u matching process%s found on \"%s\"", + matches, + matches > 1 ? "es were" : " was", + platform_sp->GetName()); + if (match_desc) + result.AppendMessageWithFormat (" whose name %s \"%s\"", + match_desc, + match_name); + result.AppendMessageWithFormat ("\n"); + ProcessInstanceInfo::DumpTableHeader (ostrm, platform_sp.get(), m_options.show_args, m_options.verbose); for (uint32_t i=0; iGetProcessInfo (pid, proc_info)) { ostrm.Printf ("Process information for process %i:\n", pid); @@ -805,7 +931,7 @@ "platform process [attach|launch|list] ...") { // LoadSubCommand ("attach", CommandObjectSP (new CommandObjectPlatformProcessAttach (interpreter))); -// LoadSubCommand ("launch", CommandObjectSP (new CommandObjectPlatformProcessLaunch (interpreter))); + LoadSubCommand ("launch", CommandObjectSP (new CommandObjectPlatformProcessLaunch (interpreter))); LoadSubCommand ("info" , CommandObjectSP (new CommandObjectPlatformProcessInfo (interpreter))); LoadSubCommand ("list" , CommandObjectSP (new CommandObjectPlatformProcessList (interpreter))); Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Apr 12 00:54:46 2011 @@ -175,7 +175,7 @@ exe_module->GetFileSpec().GetPath(filename, sizeof(filename)); StateType state = eStateInvalid; - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process) { state = process->GetState(); @@ -266,7 +266,10 @@ if (process->GetDisableASLR()) launch_flags |= eLaunchFlagDisableASLR; - + + if (m_options.in_new_tty) + launch_flags |= eLaunchFlagLaunchInTTY; + if (m_options.no_stdio) launch_flags |= eLaunchFlagDisableSTDIO; else if (!m_options.in_new_tty @@ -287,52 +290,35 @@ if (!m_options.working_dir.empty()) working_dir = m_options.working_dir.c_str(); - if (m_options.in_new_tty) - { - - lldb::pid_t pid = Host::LaunchInNewTerminal (m_options.tty_name.c_str(), - inferior_argv, - inferior_envp, - working_dir, - &exe_module->GetArchitecture(), - true, - process->GetDisableASLR()); - - if (pid != LLDB_INVALID_PROCESS_ID) - error = process->Attach (pid); + const char * stdin_path = NULL; + const char * stdout_path = NULL; + const char * stderr_path = NULL; + + // Were any standard input/output/error paths given on the command line? + if (m_options.stdin_path.empty() && + m_options.stdout_path.empty() && + m_options.stderr_path.empty()) + { + // No standard file handles were given on the command line, check + // with the process object in case they were give using "set settings" + stdin_path = process->GetStandardInputPath(); + stdout_path = process->GetStandardOutputPath(); + stderr_path = process->GetStandardErrorPath(); } else { - const char * stdin_path = NULL; - const char * stdout_path = NULL; - const char * stderr_path = NULL; - - // Were any standard input/output/error paths given on the command line? - if (m_options.stdin_path.empty() && - m_options.stdout_path.empty() && - m_options.stderr_path.empty()) - { - // No standard file handles were given on the command line, check - // with the process object in case they were give using "set settings" - stdin_path = process->GetStandardInputPath(); - stdout_path = process->GetStandardOutputPath(); - stderr_path = process->GetStandardErrorPath(); - } - else - { - stdin_path = m_options.stdin_path.empty() ? NULL : m_options.stdin_path.c_str(); - stdout_path = m_options.stdout_path.empty() ? NULL : m_options.stdout_path.c_str(); - stderr_path = m_options.stderr_path.empty() ? NULL : m_options.stderr_path.c_str(); - } - - error = process->Launch (inferior_argv, - inferior_envp, - launch_flags, - stdin_path, - stdout_path, - stderr_path, - working_dir); + stdin_path = m_options.stdin_path.empty() ? NULL : m_options.stdin_path.c_str(); + stdout_path = m_options.stdout_path.empty() ? NULL : m_options.stdout_path.c_str(); + stderr_path = m_options.stderr_path.empty() ? NULL : m_options.stderr_path.c_str(); } + + error = process->Launch (inferior_argv, + inferior_envp, + launch_flags, + stdin_path, + stdout_path, + stderr_path, + working_dir); if (error.Success()) { @@ -521,11 +507,11 @@ const char *partial_name = NULL; partial_name = input.GetArgumentAtIndex(opt_arg_pos); - PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform ()); + PlatformSP platform_sp (m_interpreter.GetPlatform (true)); if (platform_sp) { - ProcessInfoList process_infos; - ProcessInfoMatch match_info; + ProcessInstanceInfoList process_infos; + ProcessInstanceInfoMatch match_info; if (partial_name) { match_info.GetProcessInfo().SetName(partial_name); @@ -579,7 +565,7 @@ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); bool synchronous_execution = m_interpreter.GetSynchronous (); - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; StateType state = eStateInvalid; if (process) { @@ -707,11 +693,11 @@ if (attach_pid == LLDB_INVALID_PROCESS_ID && wait_name != NULL) { - ProcessInfoList process_infos; - PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform ()); + ProcessInstanceInfoList process_infos; + PlatformSP platform_sp (m_interpreter.GetPlatform (true)); if (platform_sp) { - ProcessInfoMatch match_info (wait_name, eNameMatchEquals); + ProcessInstanceInfoMatch match_info (wait_name, eNameMatchEquals); platform_sp->FindProcesses (match_info, process_infos); } if (process_infos.GetSize() > 1) @@ -860,7 +846,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; bool synchronous_execution = m_interpreter.GetSynchronous (); if (process == NULL) @@ -947,7 +933,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("must have a valid process in order to detach"); @@ -1057,7 +1043,7 @@ TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget()); Error error; - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process) { if (process->IsAlive()) @@ -1172,7 +1158,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("must have a valid process in order to load a shared library"); @@ -1230,7 +1216,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("must have a valid process in order to load a shared library"); @@ -1307,7 +1293,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to signal"); @@ -1382,7 +1368,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to halt"); @@ -1444,7 +1430,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to kill"); @@ -1507,7 +1493,7 @@ { Stream &output_stream = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.process) { const StateType state = exe_ctx.process->GetState(); Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Tue Apr 12 00:54:46 2011 @@ -75,7 +75,7 @@ { Stream &output_stream = result.GetOutputStream(); DataExtractor reg_data; - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -274,7 +274,7 @@ ) { DataExtractor reg_data; - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Tue Apr 12 00:54:46 2011 @@ -272,7 +272,7 @@ result.SetStatus (eReturnStatusFailed); } - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (!m_options.symbol_name.empty()) { Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Tue Apr 12 00:54:46 2011 @@ -362,7 +362,7 @@ if (command.GetArgumentCount() == 0) { - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.thread) { if (DisplayFramesForExecutionContext (exe_ctx.thread, @@ -386,7 +386,7 @@ } else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; uint32_t num_threads = process->GetThreadList().GetSize(); for (uint32_t i = 0; i < num_threads; i++) { @@ -412,7 +412,7 @@ else { uint32_t num_args = command.GetArgumentCount(); - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; std::vector thread_sps; for (uint32_t i = 0; i < num_args; i++) @@ -610,7 +610,7 @@ CommandReturnObject &result ) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; bool synchronous_execution = m_interpreter.GetSynchronous(); if (process == NULL) @@ -851,7 +851,7 @@ return false; } - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process exists. Cannot continue"); @@ -1115,7 +1115,7 @@ return false; } - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("need a valid process to step"); @@ -1308,7 +1308,7 @@ CommandReturnObject &result ) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process"); @@ -1378,7 +1378,7 @@ { Stream &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.process) { const StateType state = exe_ctx.process->GetState(); Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Tue Apr 12 00:54:46 2011 @@ -459,6 +459,41 @@ } ConnectionStatus +ConnectionFileDescriptor::NamedSocketConnect (const char *socket_name, Error *error_ptr) +{ + Close (m_fd, NULL); + m_is_socket = true; + + // Open the socket that was passed in as an option + struct sockaddr_un saddr_un; + m_fd = ::socket (AF_UNIX, SOCK_STREAM, 0); + if (m_fd == -1) + { + if (error_ptr) + error_ptr->SetErrorToErrno(); + return eConnectionStatusError; + } + + saddr_un.sun_family = AF_UNIX; + ::strncpy(saddr_un.sun_path, socket_name, sizeof(saddr_un.sun_path) - 1); + saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0'; +#if defined(__APPLE__) || defined(__FreeBSD__) + saddr_un.sun_len = SUN_LEN (&saddr_un); +#endif + + if (::connect (m_fd, (struct sockaddr *)&saddr_un, SUN_LEN (&saddr_un)) < 0) + { + if (error_ptr) + error_ptr->SetErrorToErrno(); + Close (m_fd, NULL); + return eConnectionStatusError; + } + if (error_ptr) + error_ptr->Clear(); + return eConnectionStatusSuccess; +} + +ConnectionStatus ConnectionFileDescriptor::SocketListen (uint16_t listen_port_num, Error *error_ptr) { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION, Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Tue Apr 12 00:54:46 2011 @@ -229,7 +229,6 @@ m_listener ("lldb.Debugger"), m_source_manager (), m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)), - m_exe_ctx (), m_input_readers (), m_input_reader_data () { @@ -556,51 +555,6 @@ } } -void -Debugger::UpdateExecutionContext (ExecutionContext *override_context) -{ - m_exe_ctx.Clear(); - - if (override_context != NULL) - { - m_exe_ctx.target = override_context->target; - m_exe_ctx.process = override_context->process; - m_exe_ctx.thread = override_context->thread; - m_exe_ctx.frame = override_context->frame; - } - else - { - TargetSP target_sp (GetSelectedTarget()); - if (target_sp) - { - m_exe_ctx.target = target_sp.get(); - m_exe_ctx.process = target_sp->GetProcessSP().get(); - if (m_exe_ctx.process && m_exe_ctx.process->IsAlive() && !m_exe_ctx.process->IsRunning()) - { - m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetSelectedThread().get(); - if (m_exe_ctx.thread == NULL) - { - m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); - // If we didn't have a selected thread, select one here. - if (m_exe_ctx.thread != NULL) - m_exe_ctx.process->GetThreadList().SetSelectedThreadByID(m_exe_ctx.thread->GetID()); - } - if (m_exe_ctx.thread) - { - m_exe_ctx.frame = m_exe_ctx.thread->GetSelectedFrame().get(); - if (m_exe_ctx.frame == NULL) - { - m_exe_ctx.frame = m_exe_ctx.thread->GetStackFrameAtIndex (0).get(); - // If we didn't have a selected frame select one here. - if (m_exe_ctx.frame != NULL) - m_exe_ctx.thread->SetSelectedFrame(m_exe_ctx.frame); - } - } - } - } - } -} - DebuggerSP Debugger::FindDebuggerWithID (lldb::user_id_t id) { Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Tue Apr 12 00:54:46 2011 @@ -28,6 +28,7 @@ m_file (file_spec), m_platform_file(), m_object_name (), + m_object_offset (object_offset), m_objfile_ap (), m_symfile_ap (), m_ast (), @@ -534,7 +535,7 @@ m_did_load_objfile = true; Timer scoped_timer(__PRETTY_FUNCTION__, "Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString("")); - m_objfile_ap.reset(ObjectFile::FindPlugin(this, &m_file, 0, m_file.GetByteSize())); + m_objfile_ap.reset(ObjectFile::FindPlugin(this, &m_file, m_object_offset, m_file.GetByteSize())); } return m_objfile_ap.get(); } Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Tue Apr 12 00:54:46 2011 @@ -63,36 +63,46 @@ void ModuleList::Append (ModuleSP &module_sp) { - Mutex::Locker locker(m_modules_mutex); - m_modules.push_back(module_sp); + if (module_sp) + { + Mutex::Locker locker(m_modules_mutex); + m_modules.push_back(module_sp); + } } bool ModuleList::AppendIfNeeded (ModuleSP &module_sp) { - Mutex::Locker locker(m_modules_mutex); - collection::iterator pos, end = m_modules.end(); - for (pos = m_modules.begin(); pos != end; ++pos) + if (module_sp) { - if (pos->get() == module_sp.get()) - return false; // Already in the list + Mutex::Locker locker(m_modules_mutex); + collection::iterator pos, end = m_modules.end(); + for (pos = m_modules.begin(); pos != end; ++pos) + { + if (pos->get() == module_sp.get()) + return false; // Already in the list + } + // Only push module_sp on the list if it wasn't already in there. + m_modules.push_back(module_sp); + return true; } - // Only push module_sp on the list if it wasn't already in there. - m_modules.push_back(module_sp); - return true; + return false; } bool ModuleList::Remove (ModuleSP &module_sp) { - Mutex::Locker locker(m_modules_mutex); - collection::iterator pos, end = m_modules.end(); - for (pos = m_modules.begin(); pos != end; ++pos) + if (module_sp) { - if (pos->get() == module_sp.get()) + Mutex::Locker locker(m_modules_mutex); + collection::iterator pos, end = m_modules.end(); + for (pos = m_modules.begin(); pos != end; ++pos) { - m_modules.erase (pos); - return true; + if (pos->get() == module_sp.get()) + { + m_modules.erase (pos); + return true; + } } } return false; Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Tue Apr 12 00:54:46 2011 @@ -1138,14 +1138,14 @@ } uint32_t -Host::FindProcesses (const ProcessInfoMatch &match_info, ProcessInfoList &process_infos) +Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos) { process_infos.Clear(); return process_infos.GetSize(); } bool -Host::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { process_info.Clear(); return false; Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Tue Apr 12 00:54:46 2011 @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -25,12 +26,15 @@ #include "lldb/Core/Communication.h" #include "lldb/Core/ConnectionFileDescriptor.h" #include "lldb/Core/DataExtractor.h" -#include "lldb/Host/Endian.h" -#include "lldb/Host/FileSpec.h" #include "lldb/Core/Log.h" +#include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StreamString.h" +#include "lldb/Host/Endian.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/CleanUp.h" #include "cfcpp/CFCBundle.h" #include "cfcpp/CFCMutableArray.h" @@ -47,6 +51,10 @@ #include #include +#ifndef _POSIX_SPAWN_DISABLE_ASLR +#define _POSIX_SPAWN_DISABLE_ASLR 0x0100 +#endif + using namespace lldb; using namespace lldb_private; @@ -414,57 +422,64 @@ do script the_shell_script\n\ end tell\n"; -lldb::pid_t -LaunchInNewTerminalWithAppleScript -( - const char *tty_name, - const char **argv, - const char **envp, - const char *working_dir, - const ArchSpec *arch_spec, - bool stop_at_entry, - bool disable_aslr -) +static Error +LaunchInNewTerminalWithAppleScript (const char *exe_path, + ProcessLaunchInfo &launch_info) { - if (!argv || !argv[0]) - return LLDB_INVALID_PROCESS_ID; + Error error; + if (exe_path == NULL || exe_path[0] == '\0') + { + error.SetErrorString ("invalid executable path"); + return error; + } - std::string unix_socket_name; - - char temp_file_path[PATH_MAX] = "/tmp/XXXXXX"; - if (::mktemp (temp_file_path) == NULL) - return LLDB_INVALID_PROCESS_ID; - - unix_socket_name.assign (temp_file_path); + char unix_socket_name[PATH_MAX] = "/tmp/XXXXXX"; + if (::mktemp (unix_socket_name) == NULL) + { + error.SetErrorString ("failed to make temporary path for a unix socket"); + return error; + } StreamString command; FileSpec darwin_debug_file_spec; if (!Host::GetLLDBPath (ePathTypeSupportExecutableDir, darwin_debug_file_spec)) - return LLDB_INVALID_PROCESS_ID; + { + error.SetErrorString ("can't locate the 'darwin-debug' executable"); + return error; + } + darwin_debug_file_spec.GetFilename().SetCString("darwin-debug"); if (!darwin_debug_file_spec.Exists()) - return LLDB_INVALID_PROCESS_ID; + { + error.SetErrorStringWithFormat ("the 'darwin-debug' executable doesn't exists at %s/%s", + darwin_debug_file_spec.GetDirectory().GetCString(), + darwin_debug_file_spec.GetFilename().GetCString()); + return error; + } char launcher_path[PATH_MAX]; darwin_debug_file_spec.GetPath(launcher_path, sizeof(launcher_path)); - if (arch_spec) - command.Printf("arch -arch %s ", arch_spec->GetArchitectureName()); + const ArchSpec &arch_spec = launch_info.GetArchitecture(); + if (arch_spec.IsValid()) + command.Printf("arch -arch %s ", arch_spec.GetArchitectureName()); - command.Printf("'%s' --unix-socket=%s", launcher_path, unix_socket_name.c_str()); + command.Printf("'%s' --unix-socket=%s", launcher_path, unix_socket_name); - if (arch_spec && arch_spec->IsValid()) - command.Printf(" --arch=%s", arch_spec->GetArchitectureName()); + if (arch_spec.IsValid()) + command.Printf(" --arch=%s", arch_spec.GetArchitectureName()); + const char *working_dir = launch_info.GetWorkingDirectory(); if (working_dir) command.Printf(" --working-dir '%s'", working_dir); - if (disable_aslr) + if (launch_info.GetFlags().Test (eLaunchFlagDisableASLR)) command.PutCString(" --disable-aslr"); - command.PutCString(" --"); + command.Printf(" -- '%s'", exe_path); + const char **argv = launch_info.GetArguments().GetConstArgumentVector (); if (argv) { for (size_t i=0; argv[i] != NULL; ++i) @@ -477,17 +492,17 @@ StreamString applescript_source; const char *tty_command = command.GetString().c_str(); - if (tty_name && tty_name[0]) - { - applescript_source.Printf (applscript_in_existing_tty, - tty_command, - tty_name); - } - else - { +// if (tty_name && tty_name[0]) +// { +// applescript_source.Printf (applscript_in_existing_tty, +// tty_command, +// tty_name); +// } +// else +// { applescript_source.Printf (applscript_in_new_tty, tty_command); - } +// } @@ -501,11 +516,15 @@ // Sleep and wait a bit for debugserver to start to listen... ConnectionFileDescriptor file_conn; char connect_url[128]; - ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name.c_str()); + ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name); // Spawn a new thread to accept incoming connection on the connect_url - // so we can grab the pid from the inferior - lldb::thread_t accept_thread = Host::ThreadCreate (unix_socket_name.c_str(), + // so we can grab the pid from the inferior. We have to do this because we + // are sending an AppleScript that will launch a process in Terminal.app, + // in a shell and the shell will fork/exec a couple of times before we get + // to the process that we wanted to launch. So when our process actually + // gets launched, we will handshake with it and get the process ID for it. + lldb::thread_t accept_thread = Host::ThreadCreate (unix_socket_name, AcceptPIDFromInferior, connect_url, &lldb_error); @@ -526,33 +545,14 @@ WaitForProcessToSIGSTOP (pid, 5); } } - ::unlink (unix_socket_name.c_str()); + ::unlink (unix_socket_name); [applescript release]; - return pid; + if (pid != LLDB_INVALID_PROCESS_ID) + launch_info.SetProcessID (pid); + return error; } -#define LLDB_HOST_USE_APPLESCRIPT - -lldb::pid_t -Host::LaunchInNewTerminal -( - const char *tty_name, - const char **argv, - const char **envp, - const char *working_dir, - const ArchSpec *arch_spec, - bool stop_at_entry, - bool disable_aslr -) -{ -#if defined (LLDB_HOST_USE_APPLESCRIPT) - return LaunchInNewTerminalWithAppleScript (tty_name, argv, envp, working_dir, arch_spec, stop_at_entry, disable_aslr); -#else - return LaunchInNewTerminalWithCommandFile (argv, envp, working_dir, arch_spec, stop_at_entry, disable_aslr); -#endif -} - // On MacOSX CrashReporter will display a string for each shared library if // the shared library has an exported symbol named "__crashreporter_info__". @@ -914,8 +914,8 @@ } static bool -GetMacOSXProcessName (const ProcessInfoMatch *match_info_ptr, - ProcessInfo &process_info) +GetMacOSXProcessName (const ProcessInstanceInfoMatch *match_info_ptr, + ProcessInstanceInfo &process_info) { if (process_info.ProcessIDIsValid()) { @@ -938,7 +938,7 @@ static bool -GetMacOSXProcessCPUType (ProcessInfo &process_info) +GetMacOSXProcessCPUType (ProcessInstanceInfo &process_info) { if (process_info.ProcessIDIsValid()) { @@ -970,8 +970,8 @@ } static bool -GetMacOSXProcessArgs (const ProcessInfoMatch *match_info_ptr, - ProcessInfo &process_info) +GetMacOSXProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr, + ProcessInstanceInfo &process_info) { if (process_info.ProcessIDIsValid()) { @@ -1006,13 +1006,13 @@ ++offset; } // Now extract all arguments - StringList &proc_args = process_info.GetArguments(); + Args &proc_args = process_info.GetArguments(); for (int i=0; i 0) { process_info.SetParentProcessID (proc_kinfo.kp_eproc.e_ppid); - process_info.SetRealUserID (proc_kinfo.kp_eproc.e_pcred.p_ruid); - process_info.SetRealGroupID (proc_kinfo.kp_eproc.e_pcred.p_rgid); + process_info.SetUserID (proc_kinfo.kp_eproc.e_pcred.p_ruid); + process_info.SetGroupID (proc_kinfo.kp_eproc.e_pcred.p_rgid); process_info.SetEffectiveUserID (proc_kinfo.kp_eproc.e_ucred.cr_uid); if (proc_kinfo.kp_eproc.e_ucred.cr_ngroups > 0) process_info.SetEffectiveGroupID (proc_kinfo.kp_eproc.e_ucred.cr_groups[0]); @@ -1052,8 +1052,8 @@ } } process_info.SetParentProcessID (LLDB_INVALID_PROCESS_ID); - process_info.SetRealUserID (UINT32_MAX); - process_info.SetRealGroupID (UINT32_MAX); + process_info.SetUserID (UINT32_MAX); + process_info.SetGroupID (UINT32_MAX); process_info.SetEffectiveUserID (UINT32_MAX); process_info.SetEffectiveGroupID (UINT32_MAX); return false; @@ -1061,7 +1061,7 @@ uint32_t -Host::FindProcesses (const ProcessInfoMatch &match_info, ProcessInfoList &process_infos) +Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos) { std::vector kinfos; @@ -1104,11 +1104,11 @@ kinfo.kp_proc.p_flag & P_TRANSLATED) // Skip translated ppc (Rosetta) continue; - ProcessInfo process_info; + ProcessInstanceInfo process_info; process_info.SetProcessID (kinfo.kp_proc.p_pid); process_info.SetParentProcessID (kinfo.kp_eproc.e_ppid); - process_info.SetRealUserID (kinfo.kp_eproc.e_pcred.p_ruid); - process_info.SetRealGroupID (kinfo.kp_eproc.e_pcred.p_rgid); + process_info.SetUserID (kinfo.kp_eproc.e_pcred.p_ruid); + process_info.SetGroupID (kinfo.kp_eproc.e_pcred.p_rgid); process_info.SetEffectiveUserID (kinfo.kp_eproc.e_ucred.cr_uid); if (kinfo.kp_eproc.e_ucred.cr_ngroups > 0) process_info.SetEffectiveGroupID (kinfo.kp_eproc.e_ucred.cr_groups[0]); @@ -1130,7 +1130,7 @@ } bool -Host::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { process_info.SetProcessID(pid); if (GetMacOSXProcessArgs (NULL, process_info)) @@ -1144,3 +1144,194 @@ } +Error +Host::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS)); + char exe_path[PATH_MAX]; + PlatformSP host_platform_sp (Platform::GetDefaultPlatform ()); + + const ArchSpec &arch_spec = launch_info.GetArchitecture(); + + FileSpec exe_spec(launch_info.GetExecutableFile()); + + FileSpec::FileType file_type = exe_spec.GetFileType(); + if (file_type != FileSpec::eFileTypeRegular) + { + lldb::ModuleSP exe_module_sp; + error = host_platform_sp->ResolveExecutable (exe_spec, + arch_spec, + exe_module_sp); + + if (error.Fail()) + return error; + + if (exe_module_sp) + exe_spec = exe_module_sp->GetFileSpec(); + } + + if (exe_spec.Exists()) + { + exe_spec.GetPath (exe_path, sizeof(exe_path)); + } + else + { + launch_info.GetExecutableFile().GetPath (exe_path, sizeof(exe_path)); + error.SetErrorStringWithFormat ("executable doesn't exist: '%s'", exe_path); + return error; + } + + + if (launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY)) + { +#if !defined(__arm__) + return LaunchInNewTerminalWithAppleScript (exe_path, launch_info); +#else + error.SetErrorString ("launching a processs in a new terminal is not supported on iOS devices"); + return error; +#endif + } + + Error local_err; // Errors that don't affect the spawning. + posix_spawnattr_t attr; + error.SetError( ::posix_spawnattr_init (&attr), eErrorTypePOSIX); + + if (error.Fail() || log) + error.PutToLog(log.get(), "::posix_spawnattr_init ( &attr )"); + if (error.Fail()) + return error; + + // Make a quick class that will cleanup the posix spawn attributes in case + // we return in the middle of this function. + lldb_utility::CleanUp posix_spawnattr_cleanup(&attr, posix_spawnattr_destroy); + + short flags = 0; + if (launch_info.GetFlags().Test (eLaunchFlagExec)) + flags |= POSIX_SPAWN_SETEXEC; // Darwin specific posix_spawn flag + + if (launch_info.GetFlags().Test (eLaunchFlagDebug)) + flags |= POSIX_SPAWN_START_SUSPENDED; // Darwin specific posix_spawn flag + + if (launch_info.GetFlags().Test (eLaunchFlagDisableASLR)) + flags |= _POSIX_SPAWN_DISABLE_ASLR; // Darwin specific posix_spawn flag + + error.SetError( ::posix_spawnattr_setflags (&attr, flags), eErrorTypePOSIX); + if (error.Fail() || log) + error.PutToLog(log.get(), "::posix_spawnattr_setflags ( &attr, flags=0x%8.8x )", flags); + if (error.Fail()) + return error; + +#if !defined(__arm__) + + // We don't need to do this for ARM, and we really shouldn't now that we + // have multiple CPU subtypes and no posix_spawnattr call that allows us + // to set which CPU subtype to launch... + cpu_type_t cpu = arch_spec.GetMachOCPUType(); + if (cpu != 0 && + cpu != UINT32_MAX && + cpu != LLDB_INVALID_CPUTYPE) + { + size_t ocount = 0; + error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX); + if (error.Fail() || log) + error.PutToLog(log.get(), "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %zu )", cpu, ocount); + + if (error.Fail() || ocount != 1) + return error; + } + +#endif + lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; + const char *tmp_argv[2]; + char * const *argv = (char * const*)launch_info.GetArguments().GetConstArgumentVector(); + char * const *envp = (char * const*)launch_info.GetEnvironmentEntries().GetConstArgumentVector(); + if (argv == NULL) + { + // posix_spawn gets very unhappy if it doesn't have at least the program + // name in argv[0]. One of the side affects I have noticed is the environment + // variables don't make it into the child process if "argv == NULL"!!! + tmp_argv[0] = exe_path; + tmp_argv[1] = NULL; + argv = (char * const*)tmp_argv; + } + + + const size_t num_file_actions = launch_info.GetNumFileActions (); + if (num_file_actions > 0) + { + posix_spawn_file_actions_t file_actions; + error.SetError( ::posix_spawn_file_actions_init (&file_actions), eErrorTypePOSIX); + if (error.Fail() || log) + error.PutToLog(log.get(), "::posix_spawn_file_actions_init ( &file_actions )"); + if (error.Fail()) + return error; + + // Make a quick class that will cleanup the posix spawn attributes in case + // we return in the middle of this function. + lldb_utility::CleanUp posix_spawn_file_actions_cleanup (&file_actions, posix_spawn_file_actions_destroy); + + for (size_t i=0; i %i, path = '%s', file_actions = %p, attr = %p, argv = %p, envp = %p )", + pid, + exe_path, + &file_actions, + &attr, + argv, + envp); + } + else + { + error.SetError (::posix_spawnp (&pid, + exe_path, + NULL, + &attr, + argv, + envp), + eErrorTypePOSIX); + + if (error.Fail() || log) + error.PutToLog(log.get(), "::posix_spawnp ( pid => %i, path = '%s', file_actions = NULL, attr = %p, argv = %p, envp = %p )", + pid, + exe_path, + &attr, + argv, + envp); + } + + if (pid != LLDB_INVALID_PROCESS_ID) + { + // If all went well, then set the process ID into the launch info + launch_info.SetProcessID(pid); + } + else + { + // Invalid process ID, something didn't go well + if (error.Success()) + error.SetErrorString ("process launch failed for unknown reasons"); + } + return error; +} + + Modified: lldb/trunk/source/Host/macosx/Symbols.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Symbols.cpp (original) +++ lldb/trunk/source/Host/macosx/Symbols.cpp Tue Apr 12 00:54:46 2011 @@ -25,8 +25,8 @@ #include "lldb/Core/UUID.h" #include "lldb/Host/Endian.h" #include "lldb/Utility/CleanUp.h" - #include "Host/macosx/cfcpp/CFCReleaser.h" +#include "Host/macosx/cfcpp/CFCString.h" #include "mach/machine.h" using namespace lldb; @@ -352,11 +352,18 @@ CFCReleaser dict(::DBGCopyDSYMPropertyLists (dsym_url.get()));; if (dict.get()) { - CFStringRef exec_cf_path = static_cast(::CFDictionaryGetValue (dict.get(), CFSTR("DBGSymbolRichExecutable"))); - if (exec_cf_path && ::CFStringGetFileSystemRepresentation (exec_cf_path, path, sizeof(path))) + char uuid_cstr_buf[64]; + const char *uuid_cstr = uuid->GetAsCString (uuid_cstr_buf, sizeof(uuid_cstr_buf)); + CFCString uuid_cfstr (uuid_cstr); + CFDictionaryRef uuid_dict = static_cast(::CFDictionaryGetValue (dict.get(), uuid_cfstr.get())); + if (uuid_dict) { - ++items_found; - out_dsym_fspec->SetFile(path, false); + CFStringRef exec_cf_path = static_cast(::CFDictionaryGetValue (uuid_dict, CFSTR("DBGSymbolRichExecutable"))); + if (exec_cf_path && ::CFStringGetFileSystemRepresentation (exec_cf_path, path, sizeof(path))) + { + ++items_found; + out_exec_fspec->SetFile(path, path[0] == '~'); + } } } } Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCString.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCString.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/cfcpp/CFCString.h (original) +++ lldb/trunk/source/Host/macosx/cfcpp/CFCString.h Tue Apr 12 00:54:46 2011 @@ -21,7 +21,7 @@ // Constructors and Destructors //------------------------------------------------------------------ CFCString (CFStringRef cf_str = NULL); - CFCString (const char *s, CFStringEncoding encoding); + CFCString (const char *s, CFStringEncoding encoding = kCFStringEncodingUTF8); CFCString (const CFCString& rhs); CFCString& operator= (const CFCString& rhs); virtual ~CFCString (); Modified: lldb/trunk/source/Interpreter/Args.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Args.cpp (original) +++ lldb/trunk/source/Interpreter/Args.cpp Tue Apr 12 00:54:46 2011 @@ -28,7 +28,8 @@ //---------------------------------------------------------------------- Args::Args (const char *command) : m_args(), - m_argv() + m_argv(), + m_args_quote_char() { if (command) SetCommandString (command); @@ -37,13 +38,49 @@ Args::Args (const char *command, size_t len) : m_args(), - m_argv() + m_argv(), + m_args_quote_char() { if (command && len) SetCommandString (command, len); } //---------------------------------------------------------------------- +// We have to be very careful on the copy constructor of this class +// to make sure we copy all of the string values, but we can't copy the +// rhs.m_argv into m_argv since it will point to the "const char *" c +// strings in rhs.m_args. We need to copy the string list and update our +// own m_argv appropriately. +//---------------------------------------------------------------------- +Args::Args (const Args &rhs) : + m_args (rhs.m_args), + m_argv (), + m_args_quote_char(rhs.m_args_quote_char) +{ + UpdateArgvFromArgs(); +} + +//---------------------------------------------------------------------- +// We have to be very careful on the copy constructor of this class +// to make sure we copy all of the string values, but we can't copy the +// rhs.m_argv into m_argv since it will point to the "const char *" c +// strings in rhs.m_args. We need to copy the string list and update our +// own m_argv appropriately. +//---------------------------------------------------------------------- +const Args & +Args::operator= (const Args &rhs) +{ + // Make sure we aren't assigning to self + if (this != &rhs) + { + m_args = rhs.m_args; + m_args_quote_char = rhs.m_args_quote_char; + UpdateArgvFromArgs(); + } + return *this; +} + +//---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- Args::~Args () Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Apr 12 00:54:46 2011 @@ -100,22 +100,23 @@ HandleCommand ("command alias continue process continue", false, result); HandleCommand ("command alias expr expression", false, result); HandleCommand ("command alias exit quit", false, result); - HandleCommand ("command alias b regexp-break", false, result); + HandleCommand ("command alias b _regexp-break", false, result); HandleCommand ("command alias bt thread backtrace", false, result); HandleCommand ("command alias si thread step-inst", false, result); HandleCommand ("command alias step thread step-in", false, result); HandleCommand ("command alias s thread step-in", false, result); HandleCommand ("command alias next thread step-over", false, result); HandleCommand ("command alias n thread step-over", false, result); + HandleCommand ("command alias f thread step-out", false, result); HandleCommand ("command alias finish thread step-out", false, result); HandleCommand ("command alias x memory read", false, result); HandleCommand ("command alias l source list", false, result); HandleCommand ("command alias list source list", false, result); - HandleCommand ("command alias p frame variable", false, result); + HandleCommand ("command alias p expression --", false, result); HandleCommand ("command alias print expression --", false, result); HandleCommand ("command alias po expression -o --", false, result); - HandleCommand ("command alias up regexp-up", false, result); - HandleCommand ("command alias down regexp-down", false, result); + HandleCommand ("command alias up _regexp-up", false, result); + HandleCommand ("command alias down _regexp-down", false, result); } @@ -183,15 +184,15 @@ std::auto_ptr break_regex_cmd_ap(new CommandObjectRegexCommand (*this, - "regexp-break", + "_regexp-break", "Set a breakpoint using a regular expression to specify the location.", - "regexp-break [:]\nregexp-break [

]\nregexp-break <...>", 2)); + "_regexp-break [:]\n_regexp-break [
]\n_regexp-break <...>", 2)); if (break_regex_cmd_ap.get()) { if (break_regex_cmd_ap->AddRegexCommand("^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*$", "breakpoint set --file '%1' --line %2") && break_regex_cmd_ap->AddRegexCommand("^(0x[[:xdigit:]]+)[[:space:]]*$", "breakpoint set --address %1") && break_regex_cmd_ap->AddRegexCommand("^[\"']?([-+]\\[.*\\])[\"']?[[:space:]]*$", "breakpoint set --name '%1'") && - break_regex_cmd_ap->AddRegexCommand("^$", "breakpoint list") && + break_regex_cmd_ap->AddRegexCommand("^$", "breakpoint list --full") && break_regex_cmd_ap->AddRegexCommand("^(-.*)$", "breakpoint set %1") && break_regex_cmd_ap->AddRegexCommand("^(.*[^[:space:]])`(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%2' --shlib '%1'") && break_regex_cmd_ap->AddRegexCommand("^(.*[^[:space:]])[[:space:]]*$", "breakpoint set --name '%1'")) @@ -203,9 +204,9 @@ std::auto_ptr down_regex_cmd_ap(new CommandObjectRegexCommand (*this, - "regexp-down", - "Go down \"n\" frames in the stack (1 frame by default).", - "down [n]", 2)); + "_regexp-down", + "Go down \"n\" frames in the stack (1 frame by default).", + "_regexp-down [n]", 2)); if (down_regex_cmd_ap.get()) { if (down_regex_cmd_ap->AddRegexCommand("^$", "frame select -r -1") && @@ -218,9 +219,9 @@ std::auto_ptr up_regex_cmd_ap(new CommandObjectRegexCommand (*this, - "regexp-up", - "Go up \"n\" frames in the stack (1 frame by default).", - "up [n]", 2)); + "_regexp-up", + "Go up \"n\" frames in the stack (1 frame by default).", + "_regexp-up [n]", 2)); if (up_regex_cmd_ap.get()) { if (up_regex_cmd_ap->AddRegexCommand("^$", "frame select -r 1") && @@ -759,7 +760,7 @@ Timer scoped_timer (__PRETTY_FUNCTION__, "Handling command: %s.", command_line); - m_debugger.UpdateExecutionContext (override_context); + UpdateExecutionContext (override_context); bool empty_command = false; bool comment_command = false; @@ -1542,6 +1543,18 @@ } } +PlatformSP +CommandInterpreter::GetPlatform (bool prefer_target_platform) +{ + PlatformSP platform_sp; + if (prefer_target_platform && m_exe_ctx.target) + platform_sp = m_exe_ctx.target->GetPlatform(); + + if (!platform_sp) + platform_sp = m_debugger.GetPlatformList().GetSelectedPlatform(); + return platform_sp; +} + void CommandInterpreter::HandleCommands (const StringList &commands, ExecutionContext *override_context, @@ -1562,7 +1575,7 @@ // cause series of commands that change the context, then do an operation that relies on that context to fail. if (override_context != NULL) - m_debugger.UpdateExecutionContext (override_context); + UpdateExecutionContext (override_context); if (!stop_on_continue) { @@ -1842,3 +1855,50 @@ } } + + +void +CommandInterpreter::UpdateExecutionContext (ExecutionContext *override_context) +{ + m_exe_ctx.Clear(); + + if (override_context != NULL) + { + m_exe_ctx.target = override_context->target; + m_exe_ctx.process = override_context->process; + m_exe_ctx.thread = override_context->thread; + m_exe_ctx.frame = override_context->frame; + } + else + { + TargetSP target_sp (m_debugger.GetSelectedTarget()); + if (target_sp) + { + m_exe_ctx.target = target_sp.get(); + m_exe_ctx.process = target_sp->GetProcessSP().get(); + if (m_exe_ctx.process && m_exe_ctx.process->IsAlive() && !m_exe_ctx.process->IsRunning()) + { + m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetSelectedThread().get(); + if (m_exe_ctx.thread == NULL) + { + m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); + // If we didn't have a selected thread, select one here. + if (m_exe_ctx.thread != NULL) + m_exe_ctx.process->GetThreadList().SetSelectedThreadByID(m_exe_ctx.thread->GetID()); + } + if (m_exe_ctx.thread) + { + m_exe_ctx.frame = m_exe_ctx.thread->GetSelectedFrame().get(); + if (m_exe_ctx.frame == NULL) + { + m_exe_ctx.frame = m_exe_ctx.thread->GetStackFrameAtIndex (0).get(); + // If we didn't have a selected frame select one here. + if (m_exe_ctx.frame != NULL) + m_exe_ctx.thread->SetSelectedFrame(m_exe_ctx.frame); + } + } + } + } + } +} + Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Apr 12 00:54:46 2011 @@ -219,7 +219,7 @@ if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused)) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("Process must exist."); Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Apr 12 00:54:46 2011 @@ -295,7 +295,7 @@ // it again (since Target::SetExecutableModule() will clear the // images). So append the dyld module back to the list if it is /// unique! - if (m_process->GetTarget().GetImages().AppendIfNeeded (dyld_module_sp)) + if (dyld_module_sp && m_process->GetTarget().GetImages().AppendIfNeeded (dyld_module_sp)) UpdateImageLoadAddress(dyld_module_sp.get(), m_dyld); return true; @@ -603,6 +603,7 @@ uint32_t idx; uint32_t i = 0; + // Since we can't downsize a vector, we must do this using the swap method DYLDImageInfo::collection old_dyld_all_image_infos; old_dyld_all_image_infos.swap(m_dyld_image_infos); @@ -639,7 +640,10 @@ m_dyld_image_infos[i].mod_date = info_data_ref.GetPointer(&info_data_offset); char raw_path[PATH_MAX]; - m_process->ReadMemory (path_addr, raw_path, sizeof(raw_path), error); + m_process->ReadCStringFromMemory (path_addr, raw_path, sizeof(raw_path)); + char raw_path2[PATH_MAX];// TODO: remove after assertion doesn't assert + m_process->ReadMemory (path_addr, raw_path2, sizeof(raw_path2), error);// TODO: remove after assertion doesn't assert + assert (strcmp (raw_path, raw_path2) == 0);// TODO: remove after assertion doesn't assert m_dyld_image_infos[i].file_spec.SetFile(raw_path, true); } assert(i == m_dyld_all_image_infos.dylib_info_count); @@ -653,10 +657,6 @@ } } } - else - { - m_dyld_image_infos.clear(); - } // If our new list is smaller than our old list, we have unloaded // some shared libraries @@ -763,9 +763,9 @@ { commpage_image_module_sp = m_process->GetTarget().GetSharedModule (m_dyld_image_infos[idx].file_spec, arch, - &m_dyld_image_infos[idx].uuid, + NULL, &commpage_dbstr, - objfile->GetOffset() + commpage_section->GetOffset()); + objfile->GetOffset() + commpage_section->GetFileOffset()); } if (commpage_image_module_sp) UpdateCommPageLoadAddress (commpage_image_module_sp.get()); Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Tue Apr 12 00:54:46 2011 @@ -14,6 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Error.h" #include "lldb/Host/Host.h" #include "lldb/Target/Target.h" @@ -50,17 +51,47 @@ Error error; // Nothing special to do here, just use the actual file and architecture + char exe_path[PATH_MAX]; FileSpec resolved_exe_file (exe_file); - // If we have "ls" as the exe_file, resolve the executable loation based on - // the current path variables - if (!resolved_exe_file.Exists()) - resolved_exe_file.ResolveExecutableLocation (); + if (IsHost()) + { + // If we have "ls" as the exe_file, resolve the executable loation based on + // the current path variables + if (!resolved_exe_file.Exists()) + { + exe_file.GetPath (exe_path, sizeof(exe_path)); + resolved_exe_file.SetFile(exe_path, true); + } - // Resolve any executable within a bundle on MacOSX - Host::ResolveExecutableInBundle (resolved_exe_file); + if (!resolved_exe_file.Exists()) + resolved_exe_file.ResolveExecutableLocation (); - if (resolved_exe_file.Exists()) + // Resolve any executable within a bundle on MacOSX + Host::ResolveExecutableInBundle (resolved_exe_file); + + if (resolved_exe_file.Exists()) + error.Clear(); + else + { + exe_file.GetPath (exe_path, sizeof(exe_path)); + error.SetErrorStringWithFormat ("enable to find executable for '%s'", exe_path); + } + } + else + { + if (m_remote_platform_sp) + { + error = m_remote_platform_sp->ResolveExecutable (exe_file, + exe_arch, + exe_module_sp); + } + else + error.SetErrorString ("the platform is not currently connected"); + } + + + if (error.Success()) { if (exe_arch.IsValid()) { @@ -321,7 +352,7 @@ bool -PlatformDarwin::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +PlatformDarwin::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { bool sucess = false; if (IsHost()) @@ -339,8 +370,8 @@ uint32_t -PlatformDarwin::FindProcesses (const ProcessInfoMatch &match_info, - ProcessInfoList &process_infos) +PlatformDarwin::FindProcesses (const ProcessInstanceInfoMatch &match_info, + ProcessInstanceInfoList &process_infos) { uint32_t match_count = 0; if (IsHost()) @@ -357,6 +388,71 @@ return match_count; } +Error +PlatformDarwin::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + if (IsHost()) + { + error = Platform::LaunchProcess (launch_info); + } + else + { + if (m_remote_platform_sp) + error = m_remote_platform_sp->LaunchProcess (launch_info); + else + error.SetErrorString ("the platform is not currently connected"); + } + return error; +} + +lldb::ProcessSP +PlatformDarwin::Attach (lldb::pid_t pid, + Debugger &debugger, + Target *target, + Listener &listener, + Error &error) +{ + lldb::ProcessSP process_sp; + if (IsHost()) + { + if (target == NULL) + { + TargetSP new_target_sp; + FileSpec emptyFileSpec; + ArchSpec emptyArchSpec; + + error = debugger.GetTargetList().CreateTarget (debugger, + emptyFileSpec, + emptyArchSpec, + false, + new_target_sp); + target = new_target_sp.get(); + } + else + error.Clear(); + + if (target && error.Success()) + { + debugger.GetTargetList().SetSelectedTarget(target); + // The darwin always currently uses the GDB remote debugger plug-in + // so even when debugging locally we are debugging remotely! + process_sp = target->CreateProcess (listener, "gdb-remote"); + + if (process_sp) + error = process_sp->Attach (pid); + } + } + else + { + if (m_remote_platform_sp) + process_sp = m_remote_platform_sp->Attach (pid, debugger, target, listener, error); + else + error.SetErrorString ("the platform is not currently connected"); + } + return process_sp; +} + const char * PlatformDarwin::GetUserName (uint32_t uid) { Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Tue Apr 12 00:54:46 2011 @@ -69,12 +69,22 @@ virtual bool GetProcessInfo (lldb::pid_t pid, - lldb_private::ProcessInfo &proc_info); + lldb_private::ProcessInstanceInfo &proc_info); virtual uint32_t - FindProcesses (const lldb_private::ProcessInfoMatch &match_info, - lldb_private::ProcessInfoList &process_infos); + FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info, + lldb_private::ProcessInstanceInfoList &process_infos); + virtual lldb_private::Error + LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info); + + virtual lldb::ProcessSP + Attach (lldb::pid_t pid, + lldb_private::Debugger &debugger, + lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one + lldb_private::Listener &listener, + lldb_private::Error &error); + protected: lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote darwin OS Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp Tue Apr 12 00:54:46 2011 @@ -447,8 +447,8 @@ uint32_t -PlatformRemoteiOS::FindProcesses (const ProcessInfoMatch &match_info, - ProcessInfoList &process_infos) +PlatformRemoteiOS::FindProcesses (const ProcessInstanceInfoMatch &match_info, + ProcessInstanceInfoList &process_infos) { // TODO: if connected, send a packet to get the remote process infos by name process_infos.Clear(); @@ -456,7 +456,7 @@ } bool -PlatformRemoteiOS::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +PlatformRemoteiOS::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { // TODO: if connected, send a packet to get the remote process info process_info.Clear(); Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h Tue Apr 12 00:54:46 2011 @@ -103,12 +103,12 @@ bool *did_create_ptr); virtual uint32_t - FindProcesses (const lldb_private::ProcessInfoMatch &match_info, - lldb_private::ProcessInfoList &process_infos); + FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info, + lldb_private::ProcessInstanceInfoList &process_infos); virtual bool GetProcessInfo (lldb::pid_t pid, - lldb_private::ProcessInfo &proc_info); + lldb_private::ProcessInstanceInfo &proc_info); virtual bool GetSupportedArchitectureAtIndex (uint32_t idx, Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original) +++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Tue Apr 12 00:54:46 2011 @@ -17,6 +17,7 @@ // Project includes #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/ConnectionFileDescriptor.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Error.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" @@ -112,7 +113,8 @@ /// Default Constructor //------------------------------------------------------------------ PlatformRemoteGDBServer::PlatformRemoteGDBServer () : - Platform(false) // This is a remote platform + Platform(false), // This is a remote platform + m_gdb_client(true) { } @@ -267,17 +269,139 @@ } uint32_t -PlatformRemoteGDBServer::FindProcesses (const ProcessInfoMatch &match_info, - ProcessInfoList &process_infos) +PlatformRemoteGDBServer::FindProcesses (const ProcessInstanceInfoMatch &match_info, + ProcessInstanceInfoList &process_infos) { return m_gdb_client.FindProcesses (match_info, process_infos); } bool -PlatformRemoteGDBServer::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +PlatformRemoteGDBServer::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { return m_gdb_client.GetProcessInfo (pid, process_info); } +Error +PlatformRemoteGDBServer::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; + + m_gdb_client.SetSTDIN ("/dev/null"); + m_gdb_client.SetSTDOUT ("/dev/null"); + m_gdb_client.SetSTDERR ("/dev/null"); + m_gdb_client.SetDisableASLR (launch_info.GetFlags().Test (eLaunchFlagDisableASLR)); + + const char *working_dir = launch_info.GetWorkingDirectory(); + if (working_dir && working_dir[0]) + { + m_gdb_client.SetWorkingDir (working_dir); + } + + // Send the environment and the program + arguments after we connect + const char **argv = launch_info.GetArguments().GetConstArgumentVector(); + const char **envp = launch_info.GetEnvironmentEntries().GetConstArgumentVector(); + + if (envp) + { + const char *env_entry; + for (int i=0; (env_entry = envp[i]); ++i) + { + if (m_gdb_client.SendEnvironmentPacket(env_entry) != 0) + break; + } + } + const uint32_t old_packet_timeout = m_gdb_client.SetPacketTimeout (3000); // TODO: lower this to 5 seconds prior to checkin!!! + int arg_packet_err = m_gdb_client.SendArgumentsPacket (argv); + m_gdb_client.SetPacketTimeout (old_packet_timeout); + if (arg_packet_err == 0) + { + std::string error_str; + if (m_gdb_client.GetLaunchSuccess (error_str)) + { + pid = m_gdb_client.GetCurrentProcessID (); + if (pid != LLDB_INVALID_PROCESS_ID) + launch_info.SetProcessID (pid); + } + else + { + error.SetErrorString (error_str.c_str()); + } + } + else + { + error.SetErrorStringWithFormat("'A' packet returned an error: %i.\n", arg_packet_err); + } + return error; +} + +lldb::ProcessSP +PlatformRemoteGDBServer::Attach (lldb::pid_t pid, + Debugger &debugger, + Target *target, // Can be NULL, if NULL create a new target, else use existing one + Listener &listener, + Error &error) +{ + lldb::ProcessSP process_sp; + if (IsRemote()) + { + if (IsConnected()) + { + uint16_t port = m_gdb_client.LaunchGDBserverAndGetPort(); + + if (port == 0) + { + error.SetErrorStringWithFormat ("unable to launch a GDB server on '%s'", GetHostname ()); + } + else + { + if (target == NULL) + { + TargetSP new_target_sp; + FileSpec emptyFileSpec; + ArchSpec emptyArchSpec; + + error = debugger.GetTargetList().CreateTarget (debugger, + emptyFileSpec, + emptyArchSpec, + false, + new_target_sp); + target = new_target_sp.get(); + } + else + error.Clear(); + + if (target && error.Success()) + { + debugger.GetTargetList().SetSelectedTarget(target); + + // The darwin always currently uses the GDB remote debugger plug-in + // so even when debugging locally we are debugging remotely! + process_sp = target->CreateProcess (listener, "gdb-remote"); + + if (process_sp) + { + char connect_url[256]; + const int connect_url_len = ::snprintf (connect_url, + sizeof(connect_url), + "connect://%s:%u", + GetHostname (), + port); + assert (connect_url_len < sizeof(connect_url)); + error = process_sp->ConnectRemote (connect_url); + if (error.Success()) + error = process_sp->Attach(pid); + } + } + } + } + else + { + error.SetErrorString("not connected to remote gdb server"); + } + } + return process_sp; +} + Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h (original) +++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h Tue Apr 12 00:54:46 2011 @@ -83,11 +83,22 @@ lldb_private::FileSpec &local_file); virtual bool - GetProcessInfo (lldb::pid_t pid, lldb_private::ProcessInfo &proc_info); + GetProcessInfo (lldb::pid_t pid, + lldb_private::ProcessInstanceInfo &proc_info); virtual uint32_t - FindProcesses (const lldb_private::ProcessInfoMatch &match_info, - lldb_private::ProcessInfoList &process_infos); + FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info, + lldb_private::ProcessInstanceInfoList &process_infos); + + virtual lldb_private::Error + LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info); + + virtual lldb::ProcessSP + Attach (lldb::pid_t pid, + lldb_private::Debugger &debugger, + lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one + lldb_private::Listener &listener, + lldb_private::Error &error); virtual bool GetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch); 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=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Tue Apr 12 00:54:46 2011 @@ -17,25 +17,33 @@ // Other libraries and framework includes #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Host/Host.h" #include "lldb/Host/TimeValue.h" +#include "lldb/Target/Process.h" // Project includes #include "ProcessGDBRemoteLog.h" +#define DEBUGSERVER_BASENAME "debugserver" + using namespace lldb; using namespace lldb_private; //---------------------------------------------------------------------- // GDBRemoteCommunication constructor //---------------------------------------------------------------------- -GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name, const char *listener_name) : +GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name, + const char *listener_name, + bool is_platform) : Communication(comm_name), m_packet_timeout (60), m_rx_packet_listener (listener_name), m_sequence_mutex (Mutex::eMutexTypeRecursive), m_public_is_running (false), m_private_is_running (false), - m_send_acks (true) + m_send_acks (true), + m_is_platform (is_platform) { m_rx_packet_listener.StartListeningForEvents(this, Communication::eBroadcastBitPacketAvailable | @@ -328,3 +336,131 @@ } } +Error +GDBRemoteCommunication::StartDebugserverProcess (const char *debugserver_url, + const char *unix_socket_name, // For handshaking + lldb_private::ProcessLaunchInfo &launch_info) +{ + Error error; + // If we locate debugserver, keep that located version around + static FileSpec g_debugserver_file_spec; + + // This function will fill in the launch information for the debugserver + // instance that gets launched. + launch_info.Clear(); + + char debugserver_path[PATH_MAX]; + FileSpec &debugserver_file_spec = launch_info.GetExecutableFile(); + + // Always check to see if we have an environment override for the path + // to the debugserver to use and use it if we do. + const char *env_debugserver_path = getenv("LLDB_DEBUGSERVER_PATH"); + if (env_debugserver_path) + debugserver_file_spec.SetFile (env_debugserver_path, false); + else + debugserver_file_spec = g_debugserver_file_spec; + bool debugserver_exists = debugserver_file_spec.Exists(); + if (!debugserver_exists) + { + // The debugserver binary is in the LLDB.framework/Resources + // directory. + if (Host::GetLLDBPath (ePathTypeSupportExecutableDir, debugserver_file_spec)) + { + debugserver_file_spec.GetFilename().SetCString(DEBUGSERVER_BASENAME); + debugserver_exists = debugserver_file_spec.Exists(); + if (debugserver_exists) + { + g_debugserver_file_spec = debugserver_file_spec; + } + else + { + g_debugserver_file_spec.Clear(); + debugserver_file_spec.Clear(); + } + } + } + + if (debugserver_exists) + { + debugserver_file_spec.GetPath (debugserver_path, sizeof(debugserver_path)); + + Args &debugserver_args = launch_info.GetArguments(); + debugserver_args.Clear(); + char arg_cstr[PATH_MAX]; + + // Start args with "debugserver /file/path -r --" + debugserver_args.AppendArgument(debugserver_path); + debugserver_args.AppendArgument(debugserver_url); + // use native registers, not the GDB registers + debugserver_args.AppendArgument("--native-regs"); + // make debugserver run in its own session so signals generated by + // special terminal key sequences (^C) don't affect debugserver + debugserver_args.AppendArgument("--setsid"); + + if (unix_socket_name && unix_socket_name[0]) + { + debugserver_args.AppendArgument("--unix-socket"); + debugserver_args.AppendArgument(unix_socket_name); + } + + const char *env_debugserver_log_file = getenv("LLDB_DEBUGSERVER_LOG_FILE"); + if (env_debugserver_log_file) + { + ::snprintf (arg_cstr, sizeof(arg_cstr), "--log-file=%s", env_debugserver_log_file); + debugserver_args.AppendArgument(arg_cstr); + } + + const char *env_debugserver_log_flags = getenv("LLDB_DEBUGSERVER_LOG_FLAGS"); + if (env_debugserver_log_flags) + { + ::snprintf (arg_cstr, sizeof(arg_cstr), "--log-flags=%s", env_debugserver_log_flags); + debugserver_args.AppendArgument(arg_cstr); + } + // debugserver_args.AppendArgument("--log-file=/tmp/debugserver.txt"); + // debugserver_args.AppendArgument("--log-flags=0x802e0e"); + + // We currently send down all arguments, attach pids, or attach + // process names in dedicated GDB server packets, so we don't need + // to pass them as arguments. This is currently because of all the + // things we need to setup prior to launching: the environment, + // current working dir, file actions, etc. +#if 0 + // Now append the program arguments + if (inferior_argv) + { + // Terminate the debugserver args so we can now append the inferior args + debugserver_args.AppendArgument("--"); + + for (int i = 0; inferior_argv[i] != NULL; ++i) + debugserver_args.AppendArgument (inferior_argv[i]); + } + else if (attach_pid != LLDB_INVALID_PROCESS_ID) + { + ::snprintf (arg_cstr, sizeof(arg_cstr), "--attach=%u", attach_pid); + debugserver_args.AppendArgument (arg_cstr); + } + else if (attach_name && attach_name[0]) + { + if (wait_for_launch) + debugserver_args.AppendArgument ("--waitfor"); + else + debugserver_args.AppendArgument ("--attach"); + debugserver_args.AppendArgument (attach_name); + } +#endif + + // Close STDIN, STDOUT and STDERR. We might need to redirect them + // to "/dev/null" if we run into any problems. +// launch_info.AppendCloseFileAction (STDIN_FILENO); +// launch_info.AppendCloseFileAction (STDOUT_FILENO); +// launch_info.AppendCloseFileAction (STDERR_FILENO); + + error = Host::LaunchProcess(launch_info); + } + else + { + error.SetErrorStringWithFormat ("Unable to locate " DEBUGSERVER_BASENAME ".\n"); + } + return error; +} + Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Tue Apr 12 00:54:46 2011 @@ -37,7 +37,9 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - GDBRemoteCommunication(const char *comm_name, const char *listener_name); + GDBRemoteCommunication(const char *comm_name, + const char *listener_name, + bool is_platform); virtual ~GDBRemoteCommunication(); @@ -119,6 +121,15 @@ return old_packet_timeout; } + //------------------------------------------------------------------ + // Start a debugserver instance on the current host using the + // supplied connection URL. + //------------------------------------------------------------------ + lldb_private::Error + StartDebugserverProcess (const char *connect_url, + const char *unix_socket_name, + lldb_private::ProcessLaunchInfo &launch_info); + protected: typedef std::list packet_collection; @@ -142,10 +153,13 @@ lldb_private::Predicate m_public_is_running; lldb_private::Predicate m_private_is_running; bool m_send_acks; - + bool m_is_platform; // Set to true if this class represents a platform, + // false if this class represents a debug session for + // a single process + private: //------------------------------------------------------------------ // For GDBRemoteCommunication only Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Tue Apr 12 00:54:46 2011 @@ -34,8 +34,8 @@ //---------------------------------------------------------------------- // GDBRemoteCommunicationClient constructor //---------------------------------------------------------------------- -GDBRemoteCommunicationClient::GDBRemoteCommunicationClient() : - GDBRemoteCommunication("gdb-remote.client", "gdb-remote.client.rx_packet"), +GDBRemoteCommunicationClient::GDBRemoteCommunicationClient(bool is_platform) : + GDBRemoteCommunication("gdb-remote.client", "gdb-remote.client.rx_packet", is_platform), m_supports_not_sending_acks (eLazyBoolCalculate), m_supports_thread_suffix (eLazyBoolCalculate), m_supports_vCont_all (eLazyBoolCalculate), @@ -49,6 +49,14 @@ m_supports_qfProcessInfo (true), m_supports_qUserName (true), m_supports_qGroupName (true), + m_supports_qThreadStopInfo (true), + m_supports_z0 (true), + m_supports_z1 (true), + m_supports_z2 (true), + m_supports_z3 (true), + m_supports_z4 (true), + m_curr_tid (LLDB_INVALID_THREAD_ID), + m_curr_tid_run (LLDB_INVALID_THREAD_ID), m_async_mutex (Mutex::eMutexTypeRecursive), m_async_packet_predicate (false), m_async_packet (), @@ -126,6 +134,12 @@ m_supports_qfProcessInfo = true; m_supports_qUserName = true; m_supports_qGroupName = true; + m_supports_qThreadStopInfo = true; + m_supports_z0 = true; + m_supports_z1 = true; + m_supports_z2 = true; + m_supports_z3 = true; + m_supports_z4 = true; m_host_arch.Clear(); } @@ -1119,7 +1133,7 @@ } bool -GDBRemoteCommunicationClient::DecodeProcessInfoResponse (StringExtractorGDBRemote &response, ProcessInfo &process_info) +GDBRemoteCommunicationClient::DecodeProcessInfoResponse (StringExtractorGDBRemote &response, ProcessInstanceInfo &process_info) { if (response.IsNormalResponse()) { @@ -1139,7 +1153,7 @@ } else if (name.compare("uid") == 0) { - process_info.SetRealUserID (Args::StringToUInt32 (value.c_str(), UINT32_MAX, 0)); + process_info.SetUserID (Args::StringToUInt32 (value.c_str(), UINT32_MAX, 0)); } else if (name.compare("euid") == 0) { @@ -1147,7 +1161,7 @@ } else if (name.compare("gid") == 0) { - process_info.SetRealGroupID (Args::StringToUInt32 (value.c_str(), UINT32_MAX, 0)); + process_info.SetGroupID (Args::StringToUInt32 (value.c_str(), UINT32_MAX, 0)); } else if (name.compare("egid") == 0) { @@ -1180,7 +1194,7 @@ } bool -GDBRemoteCommunicationClient::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +GDBRemoteCommunicationClient::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { process_info.Clear(); @@ -1205,8 +1219,8 @@ } uint32_t -GDBRemoteCommunicationClient::FindProcesses (const ProcessInfoMatch &match_info, - ProcessInfoList &process_infos) +GDBRemoteCommunicationClient::FindProcesses (const ProcessInstanceInfoMatch &match_info, + ProcessInstanceInfoList &process_infos) { process_infos.Clear(); @@ -1261,10 +1275,10 @@ packet.Printf("pid:%u;",match_info.GetProcessInfo().GetProcessID()); if (match_info.GetProcessInfo().ParentProcessIDIsValid()) packet.Printf("parent_pid:%u;",match_info.GetProcessInfo().GetParentProcessID()); - if (match_info.GetProcessInfo().RealUserIDIsValid()) - packet.Printf("uid:%u;",match_info.GetProcessInfo().GetRealUserID()); - if (match_info.GetProcessInfo().RealGroupIDIsValid()) - packet.Printf("gid:%u;",match_info.GetProcessInfo().GetRealGroupID()); + if (match_info.GetProcessInfo().UserIDIsValid()) + packet.Printf("uid:%u;",match_info.GetProcessInfo().GetUserID()); + if (match_info.GetProcessInfo().GroupIDIsValid()) + packet.Printf("gid:%u;",match_info.GetProcessInfo().GetGroupID()); if (match_info.GetProcessInfo().EffectiveUserIDIsValid()) packet.Printf("euid:%u;",match_info.GetProcessInfo().GetEffectiveUserID()); if (match_info.GetProcessInfo().EffectiveGroupIDIsValid()) @@ -1291,7 +1305,7 @@ do { - ProcessInfo process_info; + ProcessInstanceInfo process_info; if (!DecodeProcessInfoResponse (response, process_info)) break; process_infos.Append(process_info); @@ -1447,3 +1461,154 @@ } return false; } + +uint16_t +GDBRemoteCommunicationClient::LaunchGDBserverAndGetPort () +{ + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse("qLaunchGDBServer", strlen("qLaunchGDBServer"), response, false)) + { + std::string name; + std::string value; + uint16_t port = 0; + lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; + while (response.GetNameColonValue(name, value)) + { + if (name.size() == 4 && name.compare("port") == 0) + port = Args::StringToUInt32(value.c_str(), 0, 0); + if (name.size() == 3 && name.compare("pid") == 0) + pid = Args::StringToUInt32(value.c_str(), LLDB_INVALID_PROCESS_ID, 0); + } + return port; + } + return 0; +} + +bool +GDBRemoteCommunicationClient::SetCurrentThread (int tid) +{ + if (m_curr_tid == tid) + return true; + + char packet[32]; + int packet_len; + if (tid <= 0) + packet_len = ::snprintf (packet, sizeof(packet), "Hg%i", tid); + else + packet_len = ::snprintf (packet, sizeof(packet), "Hg%x", tid); + assert (packet_len + 1 < sizeof(packet)); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse(packet, packet_len, response, false)) + { + if (response.IsOKResponse()) + { + m_curr_tid = tid; + return true; + } + } + return false; +} + +bool +GDBRemoteCommunicationClient::SetCurrentThreadForRun (int tid) +{ + if (m_curr_tid_run == tid) + return true; + + char packet[32]; + int packet_len; + if (tid <= 0) + packet_len = ::snprintf (packet, sizeof(packet), "Hc%i", tid); + else + packet_len = ::snprintf (packet, sizeof(packet), "Hc%x", tid); + + assert (packet_len + 1 < sizeof(packet)); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse(packet, packet_len, response, false)) + { + if (response.IsOKResponse()) + { + m_curr_tid_run = tid; + return true; + } + } + return false; +} + +bool +GDBRemoteCommunicationClient::GetStopReply (StringExtractorGDBRemote &response) +{ + if (SendPacketAndWaitForResponse("?", 1, response, false)) + return response.IsNormalResponse(); + return false; +} + +bool +GDBRemoteCommunicationClient::GetThreadStopInfo (uint32_t tid, StringExtractorGDBRemote &response) +{ + if (m_supports_qThreadStopInfo) + { + char packet[256]; + int packet_len = ::snprintf(packet, sizeof(packet), "qThreadStopInfo%x", tid); + assert (packet_len < sizeof(packet)); + if (SendPacketAndWaitForResponse(packet, packet_len, response, false)) + { + if (response.IsUnsupportedResponse()) + m_supports_qThreadStopInfo = false; + else if (response.IsNormalResponse()) + return true; + else + return false; + } + } + if (SetCurrentThread (tid)) + return GetStopReply (response); + return false; +} + + +uint8_t +GDBRemoteCommunicationClient::SendGDBStoppointTypePacket (GDBStoppointType type, bool insert, addr_t addr, uint32_t length) +{ + switch (type) + { + case eBreakpointSoftware: if (!m_supports_z0) return UINT8_MAX; break; + case eBreakpointHardware: if (!m_supports_z1) return UINT8_MAX; break; + case eWatchpointWrite: if (!m_supports_z2) return UINT8_MAX; break; + case eWatchpointRead: if (!m_supports_z3) return UINT8_MAX; break; + case eWatchpointReadWrite: if (!m_supports_z4) return UINT8_MAX; break; + default: return UINT8_MAX; + } + + char packet[64]; + const int packet_len = ::snprintf (packet, + sizeof(packet), + "%c%i,%llx,%x", + insert ? 'Z' : 'z', + type, + addr, + length); + + assert (packet_len + 1 < sizeof(packet)); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse(packet, packet_len, response, true)) + { + if (response.IsOKResponse()) + return 0; + if (response.IsUnsupportedResponse()) + { + switch (type) + { + case eBreakpointSoftware: m_supports_z0 = false; break; + case eBreakpointHardware: m_supports_z1 = false; break; + case eWatchpointWrite: m_supports_z2 = false; break; + case eWatchpointRead: m_supports_z3 = false; break; + case eWatchpointReadWrite: m_supports_z4 = false; break; + default: break; + } + } + else if (response.IsErrorResponse()) + return response.GetError(); + } + return UINT8_MAX; +} Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Tue Apr 12 00:54:46 2011 @@ -18,13 +18,22 @@ #include "GDBRemoteCommunication.h" +typedef enum +{ + eBreakpointSoftware = 0, + eBreakpointHardware, + eWatchpointWrite, + eWatchpointRead, + eWatchpointReadWrite +} GDBStoppointType; + class GDBRemoteCommunicationClient : public GDBRemoteCommunication { public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - GDBRemoteCommunicationClient(); + GDBRemoteCommunicationClient(bool is_platform); virtual ~GDBRemoteCommunicationClient(); @@ -74,6 +83,9 @@ bool GetLaunchSuccess (std::string &error_str); + uint16_t + LaunchGDBserverAndGetPort (); + //------------------------------------------------------------------ /// Sends a GDB remote protocol 'A' packet that delivers program /// arguments to the remote server. @@ -214,11 +226,11 @@ bool GetProcessInfo (lldb::pid_t pid, - lldb_private::ProcessInfo &process_info); + lldb_private::ProcessInstanceInfo &process_info); uint32_t - FindProcesses (const lldb_private::ProcessInfoMatch &process_match_info, - lldb_private::ProcessInfoList &process_infos); + FindProcesses (const lldb_private::ProcessInstanceInfoMatch &process_match_info, + lldb_private::ProcessInstanceInfoList &process_infos); bool GetUserName (uint32_t uid, std::string &name); @@ -246,6 +258,33 @@ return old_packet_timeout; } + bool + GetStopReply (StringExtractorGDBRemote &response); + + bool + GetThreadStopInfo (uint32_t tid, + StringExtractorGDBRemote &response); + + bool + SupportsGDBStoppointPacket (GDBStoppointType type) + { + switch (type) + { + case eBreakpointSoftware: return m_supports_z0; + case eBreakpointHardware: return m_supports_z1; + case eWatchpointWrite: return m_supports_z2; + case eWatchpointRead: return m_supports_z3; + case eWatchpointReadWrite: return m_supports_z4; + default: break; + } + return false; + } + uint8_t + SendGDBStoppointTypePacket (GDBStoppointType type, // Type of breakpoint or watchpoint + bool insert, // Insert or remove? + lldb::addr_t addr, // Address of breakpoint or watchpoint + uint32_t length); // Byte Size of breakpoint or watchpoint + void TestPacketSpeed (const uint32_t num_packets); @@ -257,6 +296,13 @@ bool SendSpeedTestPacket (uint32_t send_size, uint32_t recv_size); + + bool + SetCurrentThread (int tid); + + bool + SetCurrentThreadForRun (int tid); + protected: //------------------------------------------------------------------ @@ -271,10 +317,21 @@ lldb_private::LazyBool m_supports_vCont_s; lldb_private::LazyBool m_supports_vCont_S; lldb_private::LazyBool m_qHostInfo_is_valid; - bool m_supports_qProcessInfoPID; - bool m_supports_qfProcessInfo; - bool m_supports_qUserName; - bool m_supports_qGroupName; + bool + m_supports_qProcessInfoPID:1, + m_supports_qfProcessInfo:1, + m_supports_qUserName:1, + m_supports_qGroupName:1, + m_supports_qThreadStopInfo:1, + m_supports_z0:1, + m_supports_z1:1, + m_supports_z2:1, + m_supports_z3:1, + m_supports_z4:1; + + lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations + lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc + // If we need to send a packet while the target is running, the m_async_XXX // member variables take care of making this happen. @@ -294,7 +351,7 @@ bool DecodeProcessInfoResponse (StringExtractorGDBRemote &response, - lldb_private::ProcessInfo &process_info); + lldb_private::ProcessInstanceInfo &process_info); private: //------------------------------------------------------------------ // For GDBRemoteCommunicationClient only Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Tue Apr 12 00:54:46 2011 @@ -21,6 +21,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Host/Host.h" #include "lldb/Host/TimeValue.h" +#include "lldb/Target/Process.h" // Project includes #include "Utility/StringExtractorGDBRemote.h" @@ -33,9 +34,15 @@ //---------------------------------------------------------------------- // GDBRemoteCommunicationServer constructor //---------------------------------------------------------------------- -GDBRemoteCommunicationServer::GDBRemoteCommunicationServer() : - GDBRemoteCommunication ("gdb-remote.server", "gdb-remote.server.rx_packet"), - m_async_thread (LLDB_INVALID_HOST_THREAD) +GDBRemoteCommunicationServer::GDBRemoteCommunicationServer(bool is_platform) : + GDBRemoteCommunication ("gdb-remote.server", "gdb-remote.server.rx_packet", is_platform), + m_async_thread (LLDB_INVALID_HOST_THREAD), + m_process_launch_info (), + m_process_launch_error (), + m_proc_infos (), + m_proc_infos_index (0), + m_lo_port_num (0), + m_hi_port_num (0) { } @@ -82,45 +89,76 @@ const StringExtractorGDBRemote::ServerPacketType packet_type = packet.GetServerPacketType (); switch (packet_type) { - case StringExtractorGDBRemote::eServerPacketType_nack: - case StringExtractorGDBRemote::eServerPacketType_ack: - break; - - case StringExtractorGDBRemote::eServerPacketType_invalid: - error.SetErrorString("invalid packet"); - quit = true; - break; - - case StringExtractorGDBRemote::eServerPacketType_interrupt: - error.SetErrorString("interrupt received"); - interrupt = true; - break; - - case StringExtractorGDBRemote::eServerPacketType_unimplemented: - return SendUnimplementedResponse (packet.GetStringRef().c_str()) > 0; - - case StringExtractorGDBRemote::eServerPacketType_qHostInfo: - return Handle_qHostInfo (packet); - - case StringExtractorGDBRemote::eServerPacketType_qProcessInfoPID: - return Handle_qProcessInfoPID (packet); - - case StringExtractorGDBRemote::eServerPacketType_qfProcessInfo: - return Handle_qfProcessInfo (packet); - - case StringExtractorGDBRemote::eServerPacketType_qsProcessInfo: - return Handle_qsProcessInfo (packet); - - case StringExtractorGDBRemote::eServerPacketType_qUserName: - return Handle_qUserName (packet); - - case StringExtractorGDBRemote::eServerPacketType_qGroupName: - return Handle_qGroupName (packet); - - case StringExtractorGDBRemote::eServerPacketType_qSpeedTest: - return Handle_qSpeedTest (packet); - case StringExtractorGDBRemote::eServerPacketType_QStartNoAckMode: - return Handle_QStartNoAckMode (packet); + case StringExtractorGDBRemote::eServerPacketType_nack: + case StringExtractorGDBRemote::eServerPacketType_ack: + break; + + case StringExtractorGDBRemote::eServerPacketType_invalid: + error.SetErrorString("invalid packet"); + quit = true; + break; + + case StringExtractorGDBRemote::eServerPacketType_interrupt: + error.SetErrorString("interrupt received"); + interrupt = true; + break; + + case StringExtractorGDBRemote::eServerPacketType_unimplemented: + return SendUnimplementedResponse (packet.GetStringRef().c_str()) > 0; + + case StringExtractorGDBRemote::eServerPacketType_A: + return Handle_A (packet); + + case StringExtractorGDBRemote::eServerPacketType_qfProcessInfo: + return Handle_qfProcessInfo (packet); + + case StringExtractorGDBRemote::eServerPacketType_qsProcessInfo: + return Handle_qsProcessInfo (packet); + + case StringExtractorGDBRemote::eServerPacketType_qC: + return Handle_qC (packet); + + case StringExtractorGDBRemote::eServerPacketType_qHostInfo: + return Handle_qHostInfo (packet); + + case StringExtractorGDBRemote::eServerPacketType_qLaunchGDBServer: + return Handle_qLaunchGDBServer (packet); + + case StringExtractorGDBRemote::eServerPacketType_qLaunchSuccess: + return Handle_qLaunchSuccess (packet); + + case StringExtractorGDBRemote::eServerPacketType_qGroupName: + return Handle_qGroupName (packet); + + case StringExtractorGDBRemote::eServerPacketType_qProcessInfoPID: + return Handle_qProcessInfoPID (packet); + + case StringExtractorGDBRemote::eServerPacketType_qSpeedTest: + return Handle_qSpeedTest (packet); + + case StringExtractorGDBRemote::eServerPacketType_qUserName: + return Handle_qUserName (packet); + + case StringExtractorGDBRemote::eServerPacketType_QEnvironment: + return Handle_QEnvironment (packet); + + case StringExtractorGDBRemote::eServerPacketType_QSetDisableASLR: + return Handle_QSetDisableASLR (packet); + + case StringExtractorGDBRemote::eServerPacketType_QSetSTDIN: + return Handle_QSetSTDIN (packet); + + case StringExtractorGDBRemote::eServerPacketType_QSetSTDOUT: + return Handle_QSetSTDOUT (packet); + + case StringExtractorGDBRemote::eServerPacketType_QSetSTDERR: + return Handle_QSetSTDERR (packet); + + case StringExtractorGDBRemote::eServerPacketType_QSetWorkingDir: + return Handle_QSetWorkingDir (packet); + + case StringExtractorGDBRemote::eServerPacketType_QStartNoAckMode: + return Handle_QStartNoAckMode (packet); } return true; } @@ -236,13 +274,13 @@ } static void -CreateProcessInfoResponse (const ProcessInfo &proc_info, StreamString &response) +CreateProcessInfoResponse (const ProcessInstanceInfo &proc_info, StreamString &response) { response.Printf ("pid:%i;ppid:%i;uid:%i;gid:%i;euid:%i;egid:%i;", proc_info.GetProcessID(), proc_info.GetParentProcessID(), - proc_info.GetRealUserID(), - proc_info.GetRealGroupID(), + proc_info.GetUserID(), + proc_info.GetGroupID(), proc_info.GetEffectiveUserID(), proc_info.GetEffectiveGroupID()); response.PutCString ("name:"); @@ -262,11 +300,11 @@ GDBRemoteCommunicationServer::Handle_qProcessInfoPID (StringExtractorGDBRemote &packet) { // Packet format: "qProcessInfoPID:%i" where %i is the pid - packet.SetFilePos(strlen ("qProcessInfoPID:")); + packet.SetFilePos(::strlen ("qProcessInfoPID:")); lldb::pid_t pid = packet.GetU32 (LLDB_INVALID_PROCESS_ID); if (pid != LLDB_INVALID_PROCESS_ID) { - ProcessInfo proc_info; + ProcessInstanceInfo proc_info; if (Host::GetProcessInfo(pid, proc_info)) { StreamString response; @@ -283,8 +321,8 @@ m_proc_infos_index = 0; m_proc_infos.Clear(); - ProcessInfoMatch match_info; - packet.SetFilePos(strlen ("qfProcessInfo")); + ProcessInstanceInfoMatch match_info; + packet.SetFilePos(::strlen ("qfProcessInfo")); if (packet.GetChar() == ':') { @@ -337,11 +375,11 @@ } else if (key.compare("uid") == 0) { - match_info.GetProcessInfo().SetRealUserID (Args::StringToUInt32(value.c_str(), UINT32_MAX, 0, &success)); + match_info.GetProcessInfo().SetUserID (Args::StringToUInt32(value.c_str(), UINT32_MAX, 0, &success)); } else if (key.compare("gid") == 0) { - match_info.GetProcessInfo().SetRealGroupID (Args::StringToUInt32(value.c_str(), UINT32_MAX, 0, &success)); + match_info.GetProcessInfo().SetGroupID (Args::StringToUInt32(value.c_str(), UINT32_MAX, 0, &success)); } else if (key.compare("euid") == 0) { @@ -395,7 +433,7 @@ GDBRemoteCommunicationServer::Handle_qUserName (StringExtractorGDBRemote &packet) { // Packet format: "qUserName:%i" where %i is the uid - packet.SetFilePos(strlen ("qUserName:")); + packet.SetFilePos(::strlen ("qUserName:")); uint32_t uid = packet.GetU32 (UINT32_MAX); if (uid != UINT32_MAX) { @@ -415,7 +453,7 @@ GDBRemoteCommunicationServer::Handle_qGroupName (StringExtractorGDBRemote &packet) { // Packet format: "qGroupName:%i" where %i is the gid - packet.SetFilePos(strlen ("qGroupName:")); + packet.SetFilePos(::strlen ("qGroupName:")); uint32_t gid = packet.GetU32 (UINT32_MAX); if (gid != UINT32_MAX) { @@ -433,7 +471,7 @@ bool GDBRemoteCommunicationServer::Handle_qSpeedTest (StringExtractorGDBRemote &packet) { - packet.SetFilePos(strlen ("qSpeedTest:")); + packet.SetFilePos(::strlen ("qSpeedTest:")); std::string key; std::string value; @@ -466,6 +504,327 @@ } return SendErrorResponse (7); } + + +static void * +AcceptPortFromInferior (void *arg) +{ + const char *connect_url = (const char *)arg; + ConnectionFileDescriptor file_conn; + Error error; + if (file_conn.Connect (connect_url, &error) == eConnectionStatusSuccess) + { + char pid_str[256]; + ::memset (pid_str, 0, sizeof(pid_str)); + ConnectionStatus status; + const size_t pid_str_len = file_conn.Read (pid_str, sizeof(pid_str), status, NULL); + if (pid_str_len > 0) + { + int pid = atoi (pid_str); + return (void *)(intptr_t)pid; + } + } + return NULL; +} +// +//static bool +//WaitForProcessToSIGSTOP (const lldb::pid_t pid, const int timeout_in_seconds) +//{ +// const int time_delta_usecs = 100000; +// const int num_retries = timeout_in_seconds/time_delta_usecs; +// for (int i=0; i 0) + { + // Decode the decimal argument string length. This length is the + // number of hex nibbles in the argument string value. + const uint32_t arg_len = packet.GetU32(UINT32_MAX); + if (arg_len == UINT32_MAX) + success = false; + else + { + // Make sure the argument hex string length is followed by a comma + if (packet.GetChar() != ',') + success = false; + else + { + // Decode the argument index. We ignore this really becuase + // who would really send down the arguments in a random order??? + const uint32_t arg_idx = packet.GetU32(UINT32_MAX); + if (arg_idx == UINT32_MAX) + success = false; + else + { + // Make sure the argument index is followed by a comma + if (packet.GetChar() != ',') + success = false; + else + { + // Decode the argument string value from hex bytes + // back into a UTF8 string and make sure the length + // matches the one supplied in the packet + std::string arg; + if (packet.GetHexByteString(arg) != (arg_len / 2)) + success = false; + else + { + // If there are any bytes lft + if (packet.GetBytesLeft()) + { + if (packet.GetChar() != ',') + success = false; + } + + if (success) + { + if (arg_idx == 0) + m_process_launch_info.GetExecutableFile().SetFile(arg.c_str(), false); + m_process_launch_info.GetArguments().AppendArgument(arg.c_str()); + } + } + } + } + } + } + } + + if (success) + { + m_process_launch_info.GetFlags().Set (eLaunchFlagDebug); + m_process_launch_error = Host::LaunchProcess (m_process_launch_info); + if (m_process_launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) + { + return SendOKResponse (); + } + } + return SendErrorResponse (8); +} + +bool +GDBRemoteCommunicationServer::Handle_qC (StringExtractorGDBRemote &packet) +{ + lldb::pid_t pid = m_process_launch_info.GetProcessID(); + StreamString response; + response.Printf("QC%x", pid); + if (m_is_platform) + { + // If we launch a process and this GDB server is acting as a platform, + // then we need to clear the process launch state so we can start + // launching another process. In order to launch a process a bunch or + // packets need to be sent: environment packets, working directory, + // disable ASLR, and many more settings. When we launch a process we + // then need to know when to clear this information. Currently we are + // selecting the 'qC' packet as that packet which seems to make the most + // sense. + if (pid != LLDB_INVALID_PROCESS_ID) + { + m_process_launch_info.Clear(); + } + } + return SendPacket (response); +} + +bool +GDBRemoteCommunicationServer::Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet) +{ + // Spawn a local debugserver as a platform so we can then attach or launch + // a process... + + if (m_is_platform) + { + // Sleep and wait a bit for debugserver to start to listen... + ConnectionFileDescriptor file_conn; + char connect_url[PATH_MAX]; + Error error; + char unix_socket_name[PATH_MAX] = "/tmp/XXXXXX"; + if (::mktemp (unix_socket_name) == NULL) + { + error.SetErrorString ("failed to make temporary path for a unix socket"); + } + else + { + ::snprintf (connect_url, sizeof(connect_url), "unix-accept://%s", unix_socket_name); + // Spawn a new thread to accept the port that gets bound after + // binding to port 0 (zero). + lldb::thread_t accept_thread = Host::ThreadCreate (unix_socket_name, + AcceptPortFromInferior, + connect_url, + &error); + + if (IS_VALID_LLDB_HOST_THREAD(accept_thread)) + { + // Spawn a debugserver and try to get + ProcessLaunchInfo debugserver_launch_info; + error = StartDebugserverProcess ("localhost:0", + unix_socket_name, + debugserver_launch_info); + + lldb::pid_t debugserver_pid = debugserver_launch_info.GetProcessID(); + if (error.Success()) + { + bool success = false; + + thread_result_t accept_thread_result = NULL; + if (Host::ThreadJoin (accept_thread, &accept_thread_result, &error)) + { + if (accept_thread_result) + { + uint16_t port = (intptr_t)accept_thread_result; + char response[256]; + const int response_len = ::snprintf (response, sizeof(response), "pid:%u;port:%u;", debugserver_pid, port); + assert (response_len < sizeof(response)); + //m_port_to_pid_map[port] = debugserver_launch_info.GetProcessID(); + success = SendPacket (response, response_len) > 0; + } + } + ::unlink (unix_socket_name); + + if (!success) + { + if (debugserver_pid != LLDB_INVALID_PROCESS_ID) + ::kill (debugserver_pid, SIGINT); + } + return success; + } + } + } + } + return SendErrorResponse (13); +} + +bool +GDBRemoteCommunicationServer::Handle_qLaunchSuccess (StringExtractorGDBRemote &packet) +{ + if (m_process_launch_error.Success()) + return SendOKResponse(); + StreamString response; + response.PutChar('E'); + response.PutCString(m_process_launch_error.AsCString("")); + return SendPacket (response); +} + +bool +GDBRemoteCommunicationServer::Handle_QEnvironment (StringExtractorGDBRemote &packet) +{ + packet.SetFilePos(::strlen ("QEnvironment:")); + const uint32_t bytes_left = packet.GetBytesLeft(); + if (bytes_left > 0) + { + m_process_launch_info.GetEnvironmentEntries ().AppendArgument (packet.Peek()); + return SendOKResponse (); + } + return SendErrorResponse (9); +} + +bool +GDBRemoteCommunicationServer::Handle_QSetDisableASLR (StringExtractorGDBRemote &packet) +{ + packet.SetFilePos(::strlen ("QSetDisableASLR:")); + if (packet.GetU32(0)) + m_process_launch_info.GetFlags().Set (eLaunchFlagDisableASLR); + else + m_process_launch_info.GetFlags().Clear (eLaunchFlagDisableASLR); + return SendOKResponse (); +} + +bool +GDBRemoteCommunicationServer::Handle_QSetWorkingDir (StringExtractorGDBRemote &packet) +{ + packet.SetFilePos(::strlen ("QSetWorkingDir:")); + std::string path; + packet.GetHexByteString(path); + m_process_launch_info.SwapWorkingDirectory (path); + return SendOKResponse (); +} + +bool +GDBRemoteCommunicationServer::Handle_QSetSTDIN (StringExtractorGDBRemote &packet) +{ + packet.SetFilePos(::strlen ("QSetSTDIN:")); + ProcessLaunchInfo::FileAction file_action; + std::string path; + packet.GetHexByteString(path); + const bool read = false; + const bool write = true; + if (file_action.Open(STDIN_FILENO, path.c_str(), read, write)) + { + m_process_launch_info.AppendFileAction(file_action); + return SendOKResponse (); + } + return SendErrorResponse (10); +} + +bool +GDBRemoteCommunicationServer::Handle_QSetSTDOUT (StringExtractorGDBRemote &packet) +{ + packet.SetFilePos(::strlen ("QSetSTDOUT:")); + ProcessLaunchInfo::FileAction file_action; + std::string path; + packet.GetHexByteString(path); + const bool read = true; + const bool write = false; + if (file_action.Open(STDOUT_FILENO, path.c_str(), read, write)) + { + m_process_launch_info.AppendFileAction(file_action); + return SendOKResponse (); + } + return SendErrorResponse (11); +} + +bool +GDBRemoteCommunicationServer::Handle_QSetSTDERR (StringExtractorGDBRemote &packet) +{ + packet.SetFilePos(::strlen ("QSetSTDERR:")); + ProcessLaunchInfo::FileAction file_action; + std::string path; + packet.GetHexByteString(path); + const bool read = true; + const bool write = true; + if (file_action.Open(STDERR_FILENO, path.c_str(), read, write)) + { + m_process_launch_info.AppendFileAction(file_action); + return SendOKResponse (); + } + return SendErrorResponse (12); +} + bool GDBRemoteCommunicationServer::Handle_QStartNoAckMode (StringExtractorGDBRemote &packet) { Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h Tue Apr 12 00:54:46 2011 @@ -31,7 +31,7 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - GDBRemoteCommunicationServer(); + GDBRemoteCommunicationServer(bool is_platform); virtual ~GDBRemoteCommunicationServer(); @@ -53,10 +53,26 @@ bool HandshakeWithClient (lldb_private::Error *error_ptr); + // Set both ports to zero to let the platform automatically bind to + // a port chosen by the OS. + void + SetPortRange (uint16_t lo_port_num, uint16_t hi_port_num) + { + m_lo_port_num = lo_port_num; + m_hi_port_num = hi_port_num; + } + protected: + //typedef std::map PortToPIDMap; + lldb::thread_t m_async_thread; - lldb_private::ProcessInfoList m_proc_infos; + lldb_private::ProcessLaunchInfo m_process_launch_info; + lldb_private::Error m_process_launch_error; + lldb_private::ProcessInstanceInfoList m_proc_infos; uint32_t m_proc_infos_index; + uint16_t m_lo_port_num; + uint16_t m_hi_port_num; + //PortToPIDMap m_port_to_pid_map; size_t SendUnimplementedResponse (const char *packet); @@ -68,9 +84,18 @@ SendOKResponse (); bool + Handle_A (StringExtractorGDBRemote &packet); + + bool + Handle_qLaunchSuccess (StringExtractorGDBRemote &packet); + + bool Handle_qHostInfo (StringExtractorGDBRemote &packet); bool + Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet); + + bool Handle_qProcessInfoPID (StringExtractorGDBRemote &packet); bool @@ -79,6 +104,9 @@ bool Handle_qsProcessInfo (StringExtractorGDBRemote &packet); + bool + Handle_qC (StringExtractorGDBRemote &packet); + bool Handle_qUserName (StringExtractorGDBRemote &packet); @@ -89,8 +117,26 @@ Handle_qSpeedTest (StringExtractorGDBRemote &packet); bool + Handle_QEnvironment (StringExtractorGDBRemote &packet); + + bool + Handle_QSetDisableASLR (StringExtractorGDBRemote &packet); + + bool + Handle_QSetWorkingDir (StringExtractorGDBRemote &packet); + + bool Handle_QStartNoAckMode (StringExtractorGDBRemote &packet); + bool + Handle_QSetSTDIN (StringExtractorGDBRemote &packet); + + bool + Handle_QSetSTDOUT (StringExtractorGDBRemote &packet); + + bool + Handle_QSetSTDERR (StringExtractorGDBRemote &packet); + private: //------------------------------------------------------------------ // For GDBRemoteCommunicationServer only Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Tue Apr 12 00:54:46 2011 @@ -220,7 +220,7 @@ if (gdb_comm.GetSequenceMutex (locker)) { const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported(); - if (thread_suffix_supported || GetGDBProcess().SetCurrentGDBRemoteThread(m_thread.GetID())) + if (thread_suffix_supported || GetGDBProcess().GetGDBRemote().SetCurrentThread(m_thread.GetID())) { char packet[64]; StringExtractorGDBRemote response; @@ -329,7 +329,7 @@ if (gdb_comm.GetSequenceMutex (locker)) { const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported(); - if (thread_suffix_supported || GetGDBProcess().SetCurrentGDBRemoteThread(m_thread.GetID())) + if (thread_suffix_supported || GetGDBProcess().GetGDBRemote().SetCurrentThread(m_thread.GetID())) { uint32_t offset, end_offset; StreamString packet; @@ -407,7 +407,7 @@ { char packet[32]; const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported(); - if (thread_suffix_supported || GetGDBProcess().SetCurrentGDBRemoteThread(m_thread.GetID())) + if (thread_suffix_supported || GetGDBProcess().GetGDBRemote().SetCurrentThread(m_thread.GetID())) { int packet_len = 0; if (thread_suffix_supported) @@ -449,7 +449,7 @@ if (gdb_comm.GetSequenceMutex (locker)) { const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported(); - if (thread_suffix_supported || GetGDBProcess().SetCurrentGDBRemoteThread(m_thread.GetID())) + if (thread_suffix_supported || GetGDBProcess().GetGDBRemote().SetCurrentThread(m_thread.GetID())) { if (gdb_comm.SendPacketAndWaitForResponse((const char *)data_sp->GetBytes(), data_sp->GetByteSize(), @@ -474,91 +474,102 @@ void GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters() { - static RegisterInfo - g_register_infos[] = - { - // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE - // ====== ======= == ==== ============= ============ =============== =============== ========= ===== =========== - { "r0", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 0 }}, - { "r1", NULL, 4, 4, eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 1 }}, - { "r2", NULL, 4, 8, eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 2 }}, - { "r3", NULL, 4, 12, eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 3 }}, - { "r4", NULL, 4, 16, eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 4 }}, - { "r5", NULL, 4, 20, eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 5 }}, - { "r6", NULL, 4, 24, eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 6 }}, - { "r7", NULL, 4, 28, eEncodingUint, eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, 7 }}, - { "r8", NULL, 4, 32, eEncodingUint, eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 8 }}, - { "r9", NULL, 4, 36, eEncodingUint, eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 9 }}, - { "r10", NULL, 4, 40, eEncodingUint, eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 10 }}, - { "r11", NULL, 4, 44, eEncodingUint, eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 11 }}, - { "r12", NULL, 4, 48, eEncodingUint, eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 12 }}, - { "sp", "r13", 4, 52, eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, 13 }}, - { "lr", "r14", 4, 56, eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, 14 }}, - { "pc", "r15", 4, 60, eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, 15 }}, -// { NULL, NULL, 12, 64, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 16 }}, -// { NULL, NULL, 12, 76, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 17 }}, -// { NULL, NULL, 12, 88, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 18 }}, -// { NULL, NULL, 12, 100, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 19 }}, -// { NULL, NULL, 12, 112, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 20 }}, -// { NULL, NULL, 12, 124, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 21 }}, -// { NULL, NULL, 12, 136, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 22 }}, -// { NULL, NULL, 12, 148, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 23 }}, -// { NULL, NULL, 12, 160, eEncodingIEEE754, eFormatFloat, { LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 24 }}, - { "cpsr", "psr", 4, 172, eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, 25 }}, - { "s0", NULL, 4, 176, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 26 }}, - { "s1", NULL, 4, 180, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 27 }}, - { "s2", NULL, 4, 184, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 28 }}, - { "s3", NULL, 4, 188, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 29 }}, - { "s4", NULL, 4, 192, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 30 }}, - { "s5", NULL, 4, 196, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 31 }}, - { "s6", NULL, 4, 200, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 32 }}, - { "s7", NULL, 4, 204, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 33 }}, - { "s8", NULL, 4, 208, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 34 }}, - { "s9", NULL, 4, 212, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 35 }}, - { "s10", NULL, 4, 216, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 36 }}, - { "s11", NULL, 4, 220, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 37 }}, - { "s12", NULL, 4, 224, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 38 }}, - { "s13", NULL, 4, 228, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 39 }}, - { "s14", NULL, 4, 232, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 40 }}, - { "s15", NULL, 4, 236, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 41 }}, - { "s16", NULL, 4, 240, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 42 }}, - { "s17", NULL, 4, 244, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 43 }}, - { "s18", NULL, 4, 248, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 44 }}, - { "s19", NULL, 4, 252, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 45 }}, - { "s20", NULL, 4, 256, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 46 }}, - { "s21", NULL, 4, 260, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 47 }}, - { "s22", NULL, 4, 264, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 48 }}, - { "s23", NULL, 4, 268, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 49 }}, - { "s24", NULL, 4, 272, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 50 }}, - { "s25", NULL, 4, 276, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 51 }}, - { "s26", NULL, 4, 280, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 52 }}, - { "s27", NULL, 4, 284, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 53 }}, - { "s28", NULL, 4, 288, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 54 }}, - { "s29", NULL, 4, 292, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 55 }}, - { "s30", NULL, 4, 296, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 56 }}, - { "s31", NULL, 4, 300, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 57 }}, - { "fpscr", NULL, 4, 304, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 58 }}, - { "d16", NULL, 8, 308, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 59 }}, - { "d17", NULL, 8, 316, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 60 }}, - { "d18", NULL, 8, 324, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 61 }}, - { "d19", NULL, 8, 332, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 62 }}, - { "d20", NULL, 8, 340, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 63 }}, - { "d21", NULL, 8, 348, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 64 }}, - { "d22", NULL, 8, 356, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 65 }}, - { "d23", NULL, 8, 364, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 66 }}, - { "d24", NULL, 8, 372, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 67 }}, - { "d25", NULL, 8, 380, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 68 }}, - { "d26", NULL, 8, 388, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 69 }}, - { "d27", NULL, 8, 396, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 70 }}, - { "d28", NULL, 8, 404, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 71 }}, - { "d29", NULL, 8, 412, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 72 }}, - { "d30", NULL, 8, 420, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 73 }}, - { "d31", NULL, 8, 428, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 74 }}, + static RegisterInfo g_register_infos[] = { +// NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB +// ====== ====== === === ============= ============ =================== =================== ====================== === ==== + { "r0", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_INVALID_REGNUM, 0, 0 }}, + { "r1", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_INVALID_REGNUM, 1, 1 }}, + { "r2", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_INVALID_REGNUM, 2, 2 }}, + { "r3", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_INVALID_REGNUM, 3, 3 }}, + { "r4", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, 4, 4 }}, + { "r5", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, 5, 5 }}, + { "r6", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, 6, 6 }}, + { "r7", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, 7, 7 }}, + { "r8", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, 8, 8 }}, + { "r9", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, 9, 9 }}, + { "r10", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, 10, 10 }}, + { "r11", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, 11, 11 }}, + { "r12", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, 12, 12 }}, + { "sp", "r13", 4, 0, eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, 13, 13 }}, + { "lr", "r14", 4, 0, eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, 14, 14 }}, + { "pc", "r15", 4, 0, eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, 15, 15 }}, + { "f0", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 16, 16 }}, + { "f1", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 17, 17 }}, + { "f2", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 18, 18 }}, + { "f3", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 19, 19 }}, + { "f4", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 20, 20 }}, + { "f5", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 21, 21 }}, + { "f6", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 22, 22 }}, + { "f7", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 23, 23 }}, + { "fps", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 24, 24 }}, + { "cpsr", "psr", 4, 0, eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_INVALID_REGNUM, 25, 25 }}, + { "s0", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, 26, 26 }}, + { "s1", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, 27, 27 }}, + { "s2", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, 28, 28 }}, + { "s3", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, 29, 29 }}, + { "s4", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, 30, 30 }}, + { "s5", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, 31, 31 }}, + { "s6", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, 32, 32 }}, + { "s7", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, 33, 33 }}, + { "s8", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, 34, 34 }}, + { "s9", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, 35, 35 }}, + { "s10", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, 36, 36 }}, + { "s11", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, 37, 37 }}, + { "s12", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, 38, 38 }}, + { "s13", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, 39, 39 }}, + { "s14", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, 40, 40 }}, + { "s15", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, 41, 41 }}, + { "s16", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, 42, 42 }}, + { "s17", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, 43, 43 }}, + { "s18", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, 44, 44 }}, + { "s19", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, 45, 45 }}, + { "s20", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, 46, 46 }}, + { "s21", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, 47, 47 }}, + { "s22", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, 48, 48 }}, + { "s23", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, 49, 49 }}, + { "s24", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, 50, 50 }}, + { "s25", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, 51, 51 }}, + { "s26", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, 52, 52 }}, + { "s27", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, 53, 53 }}, + { "s28", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, 54, 54 }}, + { "s29", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, 55, 55 }}, + { "s30", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, 56, 56 }}, + { "s31", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, 57, 57 }}, + { "fpscr",NULL, 4, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 58, 58 }}, + { "d16", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, 59, 59 }}, + { "d17", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, 60, 60 }}, + { "d18", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, 61, 61 }}, + { "d19", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, 62, 62 }}, + { "d20", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, 63, 63 }}, + { "d21", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, 64, 64 }}, + { "d22", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, 65, 65 }}, + { "d23", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, 66, 66 }}, + { "d24", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, 67, 67 }}, + { "d25", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, 68, 68 }}, + { "d26", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, 69, 69 }}, + { "d27", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, 70, 70 }}, + { "d28", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, 71, 71 }}, + { "d29", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, 72, 72 }}, + { "d30", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, 73, 73 }}, + { "d31", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, 74, 74 }}, }; + static const uint32_t num_registers = sizeof (g_register_infos)/sizeof (RegisterInfo); static ConstString gpr_reg_set ("General Purpose Registers"); + static ConstString sfp_reg_set ("Software Floating Point Registers"); static ConstString vfp_reg_set ("Floating Point Registers"); - for (uint32_t i=0; iGetObjectFile(); if (object_file) { - ArchSpec inferior_arch(module->GetArchitecture()); char host_port[128]; snprintf (host_port, sizeof(host_port), "localhost:%u", get_random_port ()); char connect_url[128]; @@ -439,13 +435,7 @@ // Make sure we aren't already connected? if (!m_gdb_comm.IsConnected()) { - error = StartDebugserverProcess (host_port, - NULL, - NULL, - LLDB_INVALID_PROCESS_ID, - NULL, - false, - inferior_arch); + error = StartDebugserverProcess (host_port); if (error.Fail()) return error; @@ -700,8 +690,6 @@ Error error; // Clear out and clean up from any current state Clear(); - const ArchSpec &arch_spec = GetTarget().GetArchitecture(); - if (attach_pid != LLDB_INVALID_PROCESS_ID) { // Make sure we aren't already connected? @@ -712,13 +700,7 @@ char connect_url[128]; snprintf (connect_url, sizeof(connect_url), "connect://%s", host_port); - error = StartDebugserverProcess (host_port, // debugserver_url - NULL, // inferior_argv - NULL, // inferior_envp - 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 - arch_spec); + error = StartDebugserverProcess (host_port); if (error.Fail()) { @@ -778,21 +760,12 @@ // Make sure we aren't already connected? if (!m_gdb_comm.IsConnected()) { - - const ArchSpec &arch_spec = GetTarget().GetArchitecture(); - char host_port[128]; snprintf (host_port, sizeof(host_port), "localhost:%u", get_random_port ()); char connect_url[128]; snprintf (connect_url, sizeof(connect_url), "connect://%s", host_port); - error = StartDebugserverProcess (host_port, // debugserver_url - NULL, // inferior_argv - NULL, // inferior_envp - 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 - arch_spec); + error = StartDebugserverProcess (host_port); if (error.Fail()) { const char *error_string = error.AsCString(); @@ -925,7 +898,7 @@ if (num_continue_c_tids == num_threads) { // All threads are resuming... - SetCurrentGDBRemoteThreadForRun (-1); + m_gdb_comm.SetCurrentThreadForRun (-1); continue_packet.PutChar ('c'); } else if (num_continue_c_tids == 1 && @@ -934,7 +907,7 @@ num_continue_S_tids == 0 ) { // Only one thread is continuing - SetCurrentGDBRemoteThreadForRun (m_continue_c_tids.front()); + m_gdb_comm.SetCurrentThreadForRun (m_continue_c_tids.front()); continue_packet.PutChar ('c'); } else @@ -960,7 +933,7 @@ if (!continue_packet_error) { // Add threads continuing with the same signo... - SetCurrentGDBRemoteThreadForRun (-1); + m_gdb_comm.SetCurrentThreadForRun (-1); continue_packet.Printf("C%2.2x", continue_signo); } } @@ -970,7 +943,7 @@ num_continue_S_tids == 0 ) { // Only one thread is continuing with signal - SetCurrentGDBRemoteThreadForRun (m_continue_C_tids.front().first); + m_gdb_comm.SetCurrentThreadForRun (m_continue_C_tids.front().first); continue_packet.Printf("C%2.2x", m_continue_C_tids.front().second); } else @@ -985,7 +958,7 @@ if (num_continue_s_tids == num_threads) { // All threads are resuming... - SetCurrentGDBRemoteThreadForRun (-1); + m_gdb_comm.SetCurrentThreadForRun (-1); continue_packet.PutChar ('s'); } else if (num_continue_c_tids == 0 && @@ -994,7 +967,7 @@ num_continue_S_tids == 0 ) { // Only one thread is stepping - SetCurrentGDBRemoteThreadForRun (m_continue_s_tids.front()); + m_gdb_comm.SetCurrentThreadForRun (m_continue_s_tids.front()); continue_packet.PutChar ('s'); } else @@ -1021,7 +994,7 @@ if (!continue_packet_error) { // Add threads stepping with the same signo... - SetCurrentGDBRemoteThreadForRun (-1); + m_gdb_comm.SetCurrentThreadForRun (-1); continue_packet.Printf("S%2.2x", step_signo); } } @@ -1031,7 +1004,7 @@ num_continue_S_tids == 1 ) { // Only one thread is stepping with signal - SetCurrentGDBRemoteThreadForRun (m_continue_S_tids.front().first); + m_gdb_comm.SetCurrentThreadForRun (m_continue_S_tids.front().first); continue_packet.Printf("S%2.2x", m_continue_S_tids.front().second); } else @@ -1667,40 +1640,28 @@ { // Try and set hardware breakpoint, and if that fails, fall through // and set a software breakpoint? - } - - if (m_z0_supported) - { - char packet[64]; - const int packet_len = ::snprintf (packet, sizeof(packet), "Z0,%llx,%zx", addr, bp_op_size); - assert (packet_len + 1 < sizeof(packet)); - StringExtractorGDBRemote response; - if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, true)) + if (m_gdb_comm.SupportsGDBStoppointPacket (eBreakpointHardware)) { - if (response.IsUnsupportedResponse()) - { - // Disable z packet support and try again - m_z0_supported = 0; - return EnableBreakpoint (bp_site); - } - else if (response.IsOKResponse()) + if (m_gdb_comm.SendGDBStoppointTypePacket(eBreakpointHardware, true, addr, bp_op_size) == 0) { bp_site->SetEnabled(true); - bp_site->SetType (BreakpointSite::eExternal); + bp_site->SetType (BreakpointSite::eHardware); return error; } - else - { - uint8_t error_byte = response.GetError(); - if (error_byte) - error.SetErrorStringWithFormat("%x packet failed with error: %i (0x%2.2x).\n", packet, error_byte, error_byte); - } } } - else + + if (m_gdb_comm.SupportsGDBStoppointPacket (eBreakpointSoftware)) { - return EnableSoftwareBreakpoint (bp_site); + if (m_gdb_comm.SendGDBStoppointTypePacket(eBreakpointSoftware, true, addr, bp_op_size) == 0) + { + bp_site->SetEnabled(true); + bp_site->SetType (BreakpointSite::eExternal); + return error; + } } + + return EnableSoftwareBreakpoint (bp_site); } if (log) @@ -1731,44 +1692,25 @@ { const size_t bp_op_size = GetSoftwareBreakpointTrapOpcode (bp_site); - if (bp_site->IsHardware()) - { - // TODO: disable hardware breakpoint... - } - else + BreakpointSite::Type bp_type = bp_site->GetType(); + switch (bp_type) { - if (m_z0_supported) - { - char packet[64]; - const int packet_len = ::snprintf (packet, sizeof(packet), "z0,%llx,%zx", addr, bp_op_size); - assert (packet_len + 1 < sizeof(packet)); - StringExtractorGDBRemote response; - if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, true)) - { - if (response.IsUnsupportedResponse()) - { - error.SetErrorString("Breakpoint site was set with Z packet, yet remote debugserver states z packets are not supported."); - } - else if (response.IsOKResponse()) - { - if (log) - log->Printf ("ProcessGDBRemote::DisableBreakpoint (site_id = %d) addr = 0x%8.8llx -- SUCCESS", site_id, (uint64_t)addr); - bp_site->SetEnabled(false); - return error; - } - else - { - uint8_t error_byte = response.GetError(); - if (error_byte) - error.SetErrorStringWithFormat("%x packet failed with error: %i (0x%2.2x).\n", packet, error_byte, error_byte); - } - } - } - else - { - return DisableSoftwareBreakpoint (bp_site); - } + case BreakpointSite::eSoftware: + error = DisableSoftwareBreakpoint (bp_site); + break; + + case BreakpointSite::eHardware: + if (m_gdb_comm.SendGDBStoppointTypePacket(eBreakpointSoftware, false, addr, bp_op_size)) + error.SetErrorToGenericError(); + break; + + case BreakpointSite::eExternal: + if (m_gdb_comm.SendGDBStoppointTypePacket(eBreakpointSoftware, false, addr, bp_op_size)) + error.SetErrorToGenericError(); + break; } + if (error.Success()) + bp_site->SetEnabled(false); } else { @@ -1869,16 +1811,7 @@ } Error -ProcessGDBRemote::StartDebugserverProcess -( - const char *debugserver_url, // The connection string to use in the spawned debugserver ("localhost:1234" or "/dev/tty...") - char const *inferior_argv[], // Arguments for the inferior program including the path to the inferior itself as the first argument - char const *inferior_envp[], // Environment to pass along to the inferior program - 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 - const ArchSpec& inferior_arch // The arch of the inferior that we will launch -) +ProcessGDBRemote::StartDebugserverProcess (const char *debugserver_url) // The connection string to use in the spawned debugserver ("localhost:1234" or "/dev/tty...") { Error error; if (m_debugserver_pid == LLDB_INVALID_PROCESS_ID) @@ -1886,8 +1819,9 @@ // If we locate debugserver, keep that located version around static FileSpec g_debugserver_file_spec; - FileSpec debugserver_file_spec; + ProcessLaunchInfo launch_info; char debugserver_path[PATH_MAX]; + FileSpec &debugserver_file_spec = launch_info.GetExecutableFile(); // Always check to see if we have an environment override for the path // to the debugserver to use and use it if we do. @@ -1922,25 +1856,10 @@ debugserver_file_spec.GetPath (debugserver_path, sizeof(debugserver_path)); m_stdio_communication.Clear(); - posix_spawnattr_t attr; LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); - Error local_err; // Errors that don't affect the spawning. - if (log) - log->Printf ("%s ( path='%s', argv=%p, envp=%p, arch=%s )", - __FUNCTION__, - debugserver_path, - inferior_argv, - inferior_envp, - inferior_arch.GetArchitectureName()); - error.SetError( ::posix_spawnattr_init (&attr), eErrorTypePOSIX); - if (error.Fail() || log) - error.PutToLog(log.get(), "::posix_spawnattr_init ( &attr )"); - if (error.Fail()) - return error; - - Args debugserver_args; + Args &debugserver_args = launch_info.GetArguments(); char arg_cstr[PATH_MAX]; // Start args with "debugserver /file/path -r --" @@ -1968,6 +1887,12 @@ // debugserver_args.AppendArgument("--log-file=/tmp/debugserver.txt"); // debugserver_args.AppendArgument("--log-flags=0x802e0e"); + // We currently send down all arguments, attach pids, or attach + // process names in dedicated GDB server packets, so we don't need + // to pass them as arguments. This is currently because of all the + // things we need to setup prior to launching: the environment, + // current working dir, file actions, etc. +#if 0 // Now append the program arguments if (inferior_argv) { @@ -1990,20 +1915,18 @@ debugserver_args.AppendArgument ("--attach"); debugserver_args.AppendArgument (attach_name); } - - Error file_actions_err; - posix_spawn_file_actions_t file_actions; -#if DONT_CLOSE_DEBUGSERVER_STDIO - file_actions_err.SetErrorString ("Remove this after uncommenting the code block below."); -#else - file_actions_err.SetError( ::posix_spawn_file_actions_init (&file_actions), eErrorTypePOSIX); - if (file_actions_err.Success()) - { - ::posix_spawn_file_actions_addclose (&file_actions, STDIN_FILENO); - ::posix_spawn_file_actions_addclose (&file_actions, STDOUT_FILENO); - ::posix_spawn_file_actions_addclose (&file_actions, STDERR_FILENO); - } #endif + + ProcessLaunchInfo::FileAction file_action; + + // Close STDIN, STDOUT and STDERR. We might need to redirect them + // to "/dev/null" if we run into any problems. + file_action.Close (STDIN_FILENO); + launch_info.AppendFileAction (file_action); + file_action.Close (STDOUT_FILENO); + launch_info.AppendFileAction (file_action); + file_action.Close (STDERR_FILENO); + launch_info.AppendFileAction (file_action); if (log) { @@ -2012,28 +1935,15 @@ log->Printf("%s arguments:\n%s", debugserver_args.GetArgumentAtIndex(0), strm.GetData()); } - error.SetError (::posix_spawnp (&m_debugserver_pid, - debugserver_path, - file_actions_err.Success() ? &file_actions : NULL, - &attr, - debugserver_args.GetArgumentVector(), - (char * const*)inferior_envp), - eErrorTypePOSIX); - - - ::posix_spawnattr_destroy (&attr); - - if (file_actions_err.Success()) - ::posix_spawn_file_actions_destroy (&file_actions); + error = Host::LaunchProcess(launch_info); - // We have seen some cases where posix_spawnp was returning a valid - // looking pid even when an error was returned, so clear it out - if (error.Fail()) + if (error.Success ()) + m_debugserver_pid = launch_info.GetProcessID(); + else m_debugserver_pid = LLDB_INVALID_PROCESS_ID; 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); - + error.PutToLog(log.get(), "Host::LaunchProcess (launch_info) => pid=%i, path='%s'", m_debugserver_pid, debugserver_path); } else { @@ -2143,71 +2053,8 @@ } bool -ProcessGDBRemote::SetCurrentGDBRemoteThread (int tid) -{ - if (m_curr_tid == tid) - return true; - - char packet[32]; - int packet_len; - if (tid <= 0) - packet_len = ::snprintf (packet, sizeof(packet), "Hg%i", tid); - else - packet_len = ::snprintf (packet, sizeof(packet), "Hg%x", tid); - assert (packet_len + 1 < sizeof(packet)); - StringExtractorGDBRemote response; - if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, false)) - { - if (response.IsOKResponse()) - { - m_curr_tid = tid; - return true; - } - } - return false; -} - -bool -ProcessGDBRemote::SetCurrentGDBRemoteThreadForRun (int tid) -{ - if (m_curr_tid_run == tid) - return true; - - char packet[32]; - int packet_len; - if (tid <= 0) - packet_len = ::snprintf (packet, sizeof(packet), "Hc%i", tid); - else - packet_len = ::snprintf (packet, sizeof(packet), "Hc%x", tid); - - assert (packet_len + 1 < sizeof(packet)); - StringExtractorGDBRemote response; - if (m_gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, false)) - { - if (response.IsOKResponse()) - { - m_curr_tid_run = tid; - return true; - } - } - return false; -} - -void -ProcessGDBRemote::ResetGDBRemoteState () -{ - // Reset and GDB remote state - m_curr_tid = LLDB_INVALID_THREAD_ID; - m_curr_tid_run = LLDB_INVALID_THREAD_ID; - m_z0_supported = 1; -} - - -bool ProcessGDBRemote::StartAsyncThread () { - ResetGDBRemoteState (); - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); if (log) 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=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Tue Apr 12 00:54:46 2011 @@ -215,12 +215,6 @@ friend class GDBRemoteCommunicationClient; friend class GDBRemoteRegisterContext; - bool - SetCurrentGDBRemoteThread (int tid); - - bool - SetCurrentGDBRemoteThreadForRun (int tid); - //---------------------------------------------------------------------- // Accessors //---------------------------------------------------------------------- @@ -275,13 +269,7 @@ UpdateThreadListIfNeeded (); lldb_private::Error - StartDebugserverProcess (const char *debugserver_url, // The connection string to use in the spawned debugserver ("localhost:1234" or "/dev/tty...") - char const *inferior_argv[], - char const *inferior_envp[], - 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 - const lldb_private::ArchSpec& arch_spec); + StartDebugserverProcess (const char *debugserver_url); void KillDebugserverProcess (); @@ -313,11 +301,6 @@ GDBRemoteDynamicRegisterInfo m_register_info; lldb_private::Broadcaster m_async_broadcaster; lldb::thread_t m_async_thread; - // Current GDB remote state. Any members added here need to be reset to - // proper default values in ResetGDBRemoteState (). - lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations - lldb::tid_t m_curr_tid_run; // Current gdb remote protocol thread index for continue, step, etc - uint32_t m_z0_supported:1; // Set to non-zero if Z0 and z0 packets are supported typedef std::vector tid_collection; typedef std::vector< std::pair > tid_sig_collection; tid_collection m_continue_c_tids; // 'c' for continue @@ -330,9 +313,6 @@ bool m_local_debugserver; // Is the debugserver process we are talking to local or on another machine. std::vector m_thread_observation_bps; - void - ResetGDBRemoteState (); - bool StartAsyncThread (); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Tue Apr 12 00:54:46 2011 @@ -261,13 +261,10 @@ m_thread_stop_reason_stop_id = process_stop_id; m_actual_stop_info_sp.reset(); - char packet[256]; - ::snprintf(packet, sizeof(packet), "qThreadStopInfo%x", GetID()); StringExtractorGDBRemote stop_packet; - if (GetGDBProcess().GetGDBRemote().SendPacketAndWaitForResponse(packet, stop_packet, false)) - { - GetGDBProcess().SetThreadStopInfo (stop_packet); - } + ProcessGDBRemote &gdb_process = GetGDBProcess(); + if (gdb_process.GetGDBRemote().GetThreadStopInfo(GetID(), stop_packet)) + gdb_process.SetThreadStopInfo (stop_packet); } return m_actual_stop_info_sp; } Modified: lldb/trunk/source/Symbol/ObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ObjectFile.cpp (original) +++ lldb/trunk/source/Symbol/ObjectFile.cpp Tue Apr 12 00:54:46 2011 @@ -61,8 +61,8 @@ // No need to delegate further if (file_offset, file_size) exceeds the total file size. // This is the base case. - if (file_offset + file_size > file->GetByteSize()) - return NULL; +// if (file_offset + file_size > file->GetByteSize()) +// return NULL; DataBufferSP file_header_data_sp(file->ReadFileContents(file_offset, 512)); uint32_t idx; Modified: lldb/trunk/source/Target/Platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Target/Platform.cpp (original) +++ lldb/trunk/source/Target/Platform.cpp Tue Apr 12 00:54:46 2011 @@ -14,9 +14,11 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Error.h" +#include "lldb/Core/Log.h" #include "lldb/Core/PluginManager.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" +#include "lldb/Target/Process.h" #include "lldb/Target/Target.h" using namespace lldb; @@ -165,6 +167,9 @@ m_max_uid_name_len (0), m_max_gid_name_len (0) { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); + if (log) + log->Printf ("%p Platform::Platform()", this); } //------------------------------------------------------------------ @@ -175,6 +180,9 @@ //------------------------------------------------------------------ Platform::~Platform() { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); + if (log) + log->Printf ("%p Platform::~Platform()", this); } void @@ -300,6 +308,15 @@ } const char * +Platform::GetName () +{ + const char *name = GetHostname(); + if (name == NULL || name[0] == '\0') + name = GetShortPluginName(); + return name; +} + +const char * Platform::GetHostname () { if (IsHost() && m_name.empty()) @@ -498,21 +515,66 @@ } bool -Platform::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info) +Platform::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { // Take care of the host case so that each subclass can just - // call Platform::GetProcessInfo (pid, process_info) + // call this function to get the host functionality. if (IsHost()) return Host::GetProcessInfo (pid, process_info); return false; } uint32_t -Platform::FindProcesses (const ProcessInfoMatch &match_info, - ProcessInfoList &process_infos) +Platform::FindProcesses (const ProcessInstanceInfoMatch &match_info, + ProcessInstanceInfoList &process_infos) { + // Take care of the host case so that each subclass can just + // call this function to get the host functionality. uint32_t match_count = 0; if (IsHost()) match_count = Host::FindProcesses (match_info, process_infos); return match_count; } + + +Error +Platform::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + // Take care of the host case so that each subclass can just + // call this function to get the host functionality. + if (IsHost()) + error = Host::LaunchProcess (launch_info); + else + error.SetErrorString ("base lldb_private::Platform class can't launch remote processes"); + return error; +} + +lldb::ProcessSP +Platform::DebugProcess (ProcessLaunchInfo &launch_info, + Debugger &debugger, + Target *target, // Can be NULL, if NULL create a new target, else use existing one + Listener &listener, + Error &error) +{ + ProcessSP process_sp; + // Make sure we stop at the entry point + launch_info.GetFlags ().Set (eLaunchFlagDebug); + error = LaunchProcess (launch_info); + if (error.Success()) + { + lldb::pid_t pid = launch_info.GetProcessID(); + if (pid != LLDB_INVALID_PROCESS_ID) + { + process_sp = Attach (pid, debugger, target, listener, error); + +// if (process_sp) +// { +// if (launch_info.GetFlags().IsClear (eLaunchFlagStopAtEntry)) +// process_sp->Resume(); +// } + } + } + return process_sp; +} + Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Apr 12 00:54:46 2011 @@ -40,7 +40,7 @@ using namespace lldb_private; void -ProcessInfo::Dump (Stream &s, Platform *platform) const +ProcessInstanceInfo::Dump (Stream &s, Platform *platform) const { const char *cstr; if (m_pid != LLDB_INVALID_PROCESS_ID) @@ -56,59 +56,80 @@ m_executable.Dump(&s); s.EOL(); } - const uint32_t argc = m_args.GetSize(); + const uint32_t argc = m_arguments.GetArgumentCount(); if (argc > 0) { for (uint32_t i=0; i 0) + { + for (uint32_t i=0; iGetUserName (m_real_uid); - s.Printf (" uid = %-5u (%s)\n", m_real_uid, cstr ? cstr : ""); + cstr = platform->GetUserName (m_uid); + s.Printf (" uid = %-5u (%s)\n", m_uid, cstr ? cstr : ""); } - if (m_real_gid != UINT32_MAX) + if (m_gid != UINT32_MAX) { - cstr = platform->GetGroupName (m_real_gid); - s.Printf (" gid = %-5u (%s)\n", m_real_gid, cstr ? cstr : ""); + cstr = platform->GetGroupName (m_gid); + s.Printf (" gid = %-5u (%s)\n", m_gid, cstr ? cstr : ""); } - if (m_effective_uid != UINT32_MAX) + if (m_euid != UINT32_MAX) { - cstr = platform->GetUserName (m_effective_uid); - s.Printf (" euid = %-5u (%s)\n", m_effective_uid, cstr ? cstr : ""); + cstr = platform->GetUserName (m_euid); + s.Printf (" euid = %-5u (%s)\n", m_euid, cstr ? cstr : ""); } - if (m_effective_gid != UINT32_MAX) + if (m_egid != UINT32_MAX) { - cstr = platform->GetGroupName (m_effective_gid); - s.Printf (" egid = %-5u (%s)\n", m_effective_gid, cstr ? cstr : ""); + cstr = platform->GetGroupName (m_egid); + s.Printf (" egid = %-5u (%s)\n", m_egid, cstr ? cstr : ""); } } void -ProcessInfo::DumpTableHeader (Stream &s, Platform *platform, bool verbose) +ProcessInstanceInfo::DumpTableHeader (Stream &s, Platform *platform, bool show_args, bool verbose) { + const char *label; + if (show_args || verbose) + label = "ARGUMENTS"; + else + label = "NAME"; + if (verbose) { - s.PutCString ("PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME\n"); + s.Printf ("PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE %s\n", label); s.PutCString ("====== ====== ========== ========== ========== ========== ======================== ============================\n"); } else { - s.PutCString ("PID PARENT USER ARCH NAME\n"); + s.Printf ("PID PARENT USER ARCH %s\n", label); s.PutCString ("====== ====== ========== ======= ============================\n"); } } void -ProcessInfo::DumpAsTableRow (Stream &s, Platform *platform, bool verbose) const +ProcessInstanceInfo::DumpAsTableRow (Stream &s, Platform *platform, bool show_args, bool verbose) const { if (m_pid != LLDB_INVALID_PROCESS_ID) { @@ -118,49 +139,49 @@ if (verbose) { - cstr = platform->GetUserName (m_real_uid); + cstr = platform->GetUserName (m_uid); if (cstr && cstr[0]) // Watch for empty string that indicates lookup failed s.Printf ("%-10s ", cstr); else - s.Printf ("%-10u ", m_real_uid); + s.Printf ("%-10u ", m_uid); - cstr = platform->GetGroupName (m_real_gid); + cstr = platform->GetGroupName (m_gid); if (cstr && cstr[0]) // Watch for empty string that indicates lookup failed s.Printf ("%-10s ", cstr); else - s.Printf ("%-10u ", m_real_gid); + s.Printf ("%-10u ", m_gid); - cstr = platform->GetUserName (m_effective_uid); + cstr = platform->GetUserName (m_euid); if (cstr && cstr[0]) // Watch for empty string that indicates lookup failed s.Printf ("%-10s ", cstr); else - s.Printf ("%-10u ", m_effective_uid); + s.Printf ("%-10u ", m_euid); - cstr = platform->GetGroupName (m_effective_gid); + cstr = platform->GetGroupName (m_egid); if (cstr && cstr[0]) // Watch for empty string that indicates lookup failed s.Printf ("%-10s ", cstr); else - s.Printf ("%-10u ", m_effective_gid); + s.Printf ("%-10u ", m_egid); s.Printf ("%-24s ", m_arch.IsValid() ? m_arch.GetTriple().str().c_str() : ""); } else { s.Printf ("%-10s %.*-7s ", - platform->GetUserName (m_effective_uid), + platform->GetUserName (m_euid), (int)m_arch.GetTriple().getArchName().size(), m_arch.GetTriple().getArchName().data()); } - if (verbose) + if (verbose || show_args) { - const uint32_t argc = m_args.GetSize(); + const uint32_t argc = m_arguments.GetArgumentCount(); if (argc > 0) { for (uint32_t i=0; i 0) s.PutChar (' '); - s.PutCString (m_args.GetStringAtIndex(i)); + s.PutCString (m_arguments.GetArgumentAtIndex(i)); } } } @@ -173,8 +194,263 @@ } } + +void +ProcessInfo::SetArgumentsFromArgs (const Args& args, + bool first_arg_is_executable, + bool first_arg_is_executable_and_argument) +{ + // Copy all arguments + m_arguments = args; + + // Is the first argument the executable? + if (first_arg_is_executable) + { + const char *first_arg = args.GetArgumentAtIndex (0); + if (first_arg) + { + // Yes the first argument is an executable, set it as the executable + // in the launch options. Don't resolve the file path as the path + // could be a remote platform path + const bool resolve = false; + m_executable.SetFile(first_arg, resolve); + + // If argument zero is an executable and shouldn't be included + // in the arguments, remove it from the front of the arguments + if (first_arg_is_executable_and_argument == false) + m_arguments.DeleteArgumentAtIndex (0); + } + } +} + +bool +ProcessLaunchInfo::FileAction::Open (int fd, const char *path, bool read, bool write) +{ + if ((read || write) && fd >= 0 && path && path[0]) + { + m_action = eFileActionOpen; + m_fd = fd; + if (read && write) + m_arg = O_RDWR; + else if (read) + m_arg = O_RDONLY; + else + m_arg = O_WRONLY; + m_path.assign (path); + return true; + } + else + { + Clear(); + } + return false; +} + +bool +ProcessLaunchInfo::FileAction::Close (int fd) +{ + Clear(); + if (fd >= 0) + { + m_action = eFileActionClose; + m_fd = fd; + } + return m_fd >= 0; +} + + bool -ProcessInfoMatch::NameMatches (const char *process_name) const +ProcessLaunchInfo::FileAction::Duplicate (int fd, int dup_fd) +{ + Clear(); + if (fd >= 0 && dup_fd >= 0) + { + m_action = eFileActionDuplicate; + m_fd = fd; + m_arg = dup_fd; + } + return m_fd >= 0; +} + + + +bool +ProcessLaunchInfo::FileAction::AddPosixSpawnFileAction (posix_spawn_file_actions_t *file_actions, + const FileAction *info, + Log *log, + Error& error) +{ + if (info == NULL) + return false; + + switch (info->m_action) + { + case eFileActionNone: + error.Clear(); + break; + + case eFileActionClose: + if (info->m_fd == -1) + error.SetErrorString ("invalid fd for posix_spawn_file_actions_addclose(...)"); + else + { + error.SetError (::posix_spawn_file_actions_addclose (file_actions, info->m_fd), + eErrorTypePOSIX); + if (log && (error.Fail() || log)) + error.PutToLog(log, "posix_spawn_file_actions_addclose (action=%p, fd=%i)", + file_actions, info->m_fd); + } + break; + + case eFileActionDuplicate: + if (info->m_fd == -1) + error.SetErrorString ("invalid fd for posix_spawn_file_actions_adddup2(...)"); + else if (info->m_arg == -1) + error.SetErrorString ("invalid duplicate fd for posix_spawn_file_actions_adddup2(...)"); + else + { + error.SetError (::posix_spawn_file_actions_adddup2 (file_actions, info->m_fd, info->m_arg), + eErrorTypePOSIX); + if (log && (error.Fail() || log)) + error.PutToLog(log, "posix_spawn_file_actions_adddup2 (action=%p, fd=%i, dup_fd=%i)", + file_actions, info->m_fd, info->m_arg); + } + break; + + case eFileActionOpen: + if (info->m_fd == -1) + error.SetErrorString ("invalid fd in posix_spawn_file_actions_addopen(...)"); + else + { + int oflag = info->m_arg; + mode_t mode = 0; + + error.SetError (::posix_spawn_file_actions_addopen (file_actions, + info->m_fd, + info->m_path.c_str(), + oflag, + mode), + eErrorTypePOSIX); + if (error.Fail() || log) + error.PutToLog(log, + "posix_spawn_file_actions_addopen (action=%p, fd=%i, path='%s', oflag=%i, mode=%i)", + file_actions, info->m_fd, info->m_path.c_str(), oflag, mode); + } + break; + + default: + error.SetErrorStringWithFormat ("invalid file action: %i", info->m_action); + break; + } + return error.Success(); +} + +Error +ProcessLaunchCommandOptions::SetOptionValue (int option_idx, const char *option_arg) +{ + Error error; + char short_option = (char) m_getopt_table[option_idx].val; + + switch (short_option) + { + case 's': // Stop at program entry point + launch_info.GetFlags().Set (eLaunchFlagStopAtEntry); + break; + + case 'e': // STDERR for read + write + { + ProcessLaunchInfo::FileAction action; + if (action.Open(STDERR_FILENO, option_arg, true, true)) + launch_info.AppendFileAction (action); + } + break; + + case 'i': // STDIN for read only + { + ProcessLaunchInfo::FileAction action; + if (action.Open(STDIN_FILENO, option_arg, true, false)) + launch_info.AppendFileAction (action); + } + break; + + case 'o': // Open STDOUT for write only + { + ProcessLaunchInfo::FileAction action; + if (action.Open(STDOUT_FILENO, option_arg, false, true)) + launch_info.AppendFileAction (action); + } + break; + + case 'p': // Process plug-in name + launch_info.SetProcessPluginName (option_arg); + break; + + case 'n': // Disable STDIO + { + ProcessLaunchInfo::FileAction action; + if (action.Open(STDERR_FILENO, "/dev/null", true, true)) + launch_info.AppendFileAction (action); + if (action.Open(STDOUT_FILENO, "/dev/null", false, true)) + launch_info.AppendFileAction (action); + if (action.Open(STDIN_FILENO, "/dev/null", true, false)) + launch_info.AppendFileAction (action); + } + break; + + case 'w': + launch_info.SetWorkingDirectory (option_arg); + break; + + case 't': // Open process in new terminal window + launch_info.GetFlags().Set (eLaunchFlagLaunchInTTY); + break; + + case 'a': + launch_info.GetArchitecture().SetTriple (option_arg, + m_interpreter.GetPlatform(true).get()); + break; + + case 'A': + launch_info.GetFlags().Set (eLaunchFlagDisableASLR); + break; + + case 'v': + launch_info.GetEnvironmentEntries().AppendArgument(option_arg); + break; + + default: + error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); + break; + + } + return error; +} + +OptionDefinition +ProcessLaunchCommandOptions::g_option_table[] = +{ +{ LLDB_OPT_SET_ALL, false, "stop-at-entry", 's', no_argument, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."}, +{ LLDB_OPT_SET_ALL, false, "disable-aslr", 'A', no_argument, NULL, 0, eArgTypeNone, "Disable address space layout randomization when launching a process."}, +{ LLDB_OPT_SET_ALL, false, "plugin", 'p', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, +{ LLDB_OPT_SET_ALL, false, "working-dir", 'w', required_argument, NULL, 0, eArgTypePath, "Set the current working directory to when running the inferior."}, +{ LLDB_OPT_SET_ALL, false, "arch", 'a', required_argument, NULL, 0, eArgTypeArchitecture, "Set the architecture for the process to launch when ambiguous."}, +{ LLDB_OPT_SET_ALL, false, "environment", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify an environment variable name/value stirng (--environement NAME=VALUE). Can be specified multiple times for subsequent environment entries."}, + +{ LLDB_OPT_SET_1 , false, "stdin", 'i', required_argument, NULL, 0, eArgTypePath, "Redirect stdin for the process to ."}, +{ LLDB_OPT_SET_1 , false, "stdout", 'o', required_argument, NULL, 0, eArgTypePath, "Redirect stdout for the process to ."}, +{ LLDB_OPT_SET_1 , false, "stderr", 'e', required_argument, NULL, 0, eArgTypePath, "Redirect stderr for the process to ."}, + +{ LLDB_OPT_SET_2 , false, "tty", 't', no_argument, NULL, 0, eArgTypeNone, "Start the process in a terminal (not supported on all platforms)."}, + +{ LLDB_OPT_SET_3 , 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 } +}; + + + +bool +ProcessInstanceInfoMatch::NameMatches (const char *process_name) const { if (m_name_match_type == eNameMatchIgnore || process_name == NULL) return true; @@ -186,7 +462,7 @@ } bool -ProcessInfoMatch::Matches (const ProcessInfo &proc_info) const +ProcessInstanceInfoMatch::Matches (const ProcessInstanceInfo &proc_info) const { if (!NameMatches (proc_info.GetName())) return false; @@ -199,12 +475,12 @@ m_match_info.GetParentProcessID() != proc_info.GetParentProcessID()) return false; - if (m_match_info.RealUserIDIsValid () && - m_match_info.GetRealUserID() != proc_info.GetRealUserID()) + if (m_match_info.UserIDIsValid () && + m_match_info.GetUserID() != proc_info.GetUserID()) return false; - if (m_match_info.RealGroupIDIsValid () && - m_match_info.GetRealGroupID() != proc_info.GetRealGroupID()) + if (m_match_info.GroupIDIsValid () && + m_match_info.GetGroupID() != proc_info.GetGroupID()) return false; if (m_match_info.EffectiveUserIDIsValid () && @@ -222,7 +498,7 @@ } bool -ProcessInfoMatch::MatchAllProcesses () const +ProcessInstanceInfoMatch::MatchAllProcesses () const { if (m_name_match_type != eNameMatchIgnore) return false; @@ -233,10 +509,10 @@ if (m_match_info.ParentProcessIDIsValid()) return false; - if (m_match_info.RealUserIDIsValid ()) + if (m_match_info.UserIDIsValid ()) return false; - if (m_match_info.RealGroupIDIsValid ()) + if (m_match_info.GroupIDIsValid ()) return false; if (m_match_info.EffectiveUserIDIsValid ()) @@ -256,7 +532,7 @@ } void -ProcessInfoMatch::Clear() +ProcessInstanceInfoMatch::Clear() { m_match_info.Clear(); m_name_match_type = eNameMatchIgnore; @@ -1504,6 +1780,46 @@ size_t +Process::ReadCStringFromMemory (addr_t addr, char *dst, size_t dst_max_len) +{ + size_t total_cstr_len = 0; + if (dst && dst_max_len) + { + // NULL out everything just to be safe + memset (dst, 0, dst_max_len); + Error error; + addr_t curr_addr = addr; + const size_t cache_line_size = m_memory_cache.GetMemoryCacheLineSize(); + size_t bytes_left = dst_max_len - 1; + char *curr_dst = dst; + + while (bytes_left > 0) + { + addr_t cache_line_bytes_left = cache_line_size - (curr_addr % cache_line_size); + addr_t bytes_to_read = std::min(bytes_left, cache_line_bytes_left); + size_t bytes_read = ReadMemory (curr_addr, curr_dst, bytes_to_read, error); + + if (bytes_read == 0) + { + dst[total_cstr_len] = '\0'; + break; + } + const size_t len = strlen(curr_dst); + + total_cstr_len += len; + + if (len < bytes_to_read) + break; + + curr_dst += bytes_read; + curr_addr += bytes_read; + bytes_left -= bytes_read; + } + } + return total_cstr_len; +} + +size_t Process::ReadMemoryFromInferior (addr_t addr, void *buf, size_t size, Error &error) { if (buf == NULL || size == 0) @@ -1894,7 +2210,7 @@ // Find the process and its architecture. Make sure it matches the architecture // of the current Target, and if not adjust it. - ProcessInfo process_info; + ProcessInstanceInfo process_info; PlatformSP platform_sp (m_target.GetDebugger().GetPlatformList().GetSelectedPlatform ()); if (platform_sp) { @@ -1947,11 +2263,11 @@ if (!wait_for_launch) { - ProcessInfoList process_infos; + ProcessInstanceInfoList process_infos; PlatformSP platform_sp (m_target.GetDebugger().GetPlatformList().GetSelectedPlatform ()); if (platform_sp) { - ProcessInfoMatch match_info; + ProcessInstanceInfoMatch match_info; match_info.GetProcessInfo().SetName(process_name); match_info.SetNameMatchType (eNameMatchEquals); platform_sp->FindProcesses (match_info, process_infos); @@ -1965,7 +2281,7 @@ } else { - ProcessInfo process_info; + ProcessInstanceInfo process_info; if (process_infos.GetInfoAtIndex (0, process_info)) { const ArchSpec &process_arch = process_info.GetArchitecture(); @@ -2034,7 +2350,7 @@ for (int i = 0; i < num_modules; i++) { ModuleSP module_sp (modules.GetModuleAtIndex(i)); - if (module_sp->IsExecutable()) + if (module_sp && module_sp->IsExecutable()) { ModuleSP target_exe_module_sp (m_target.GetExecutableModule()); if (target_exe_module_sp != module_sp) @@ -2391,8 +2707,12 @@ { LogSP log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS)); + bool already_running = PrivateStateThreadIsValid (); if (log) - log->Printf ("Process::%s ( )", __FUNCTION__); + log->Printf ("Process::%s()%s ", __FUNCTION__, already_running ? " already running" : " starting private state thread"); + + if (already_running) + return true; // Create a thread that watches our internal state and controls which // events make it to clients (into the DCProcess event queue). @@ -2417,7 +2737,8 @@ void Process::StopPrivateStateThread () { - ControlPrivateStateThread (eBroadcastInternalStateControlStop); + if (PrivateStateThreadIsValid ()) + ControlPrivateStateThread (eBroadcastInternalStateControlStop); } void @@ -2702,7 +3023,7 @@ if (m_process_sp) s->Printf(" process = %p (pid = %u), ", m_process_sp.get(), m_process_sp->GetID()); - s->Printf("state = %s", StateAsCString(GetState()));; + s->Printf("state = %s", StateAsCString(GetState())); } const Process::ProcessEventData * @@ -3005,7 +3326,7 @@ sstr.Printf ("%s", module_sp->GetFileSpec().GetFilename().AsCString()); GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), - sstr.GetData()); + sstr.GetData()); } } @@ -3661,7 +3982,11 @@ UserSettingsController::UpdateStringArrayVariable (op, index_value, m_run_args, value, err); else if (var_name == EnvVarsVarName()) { - GetHostEnvironmentIfNeeded (); + // This is nice for local debugging, but it is isn't correct for + // remote debugging. We need to stop process.env-vars from being + // populated with the host environment and add this as a launch option + // and get the correct environment from the Target's platform. + // GetHostEnvironmentIfNeeded (); UserSettingsController::UpdateDictionaryVariable (op, index_value, m_env_vars, value, err); } else if (var_name == InputPathVarName()) Modified: lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp (original) +++ lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp Tue Apr 12 00:54:46 2011 @@ -53,48 +53,90 @@ StringExtractorGDBRemote::ServerPacketType StringExtractorGDBRemote::GetServerPacketType () const { +#define PACKET_MATCHES(s) ((packet_size == (sizeof(s)-1)) && (strcmp((packet_cstr),(s)) == 0)) +#define PACKET_STARTS_WITH(s) ((packet_size >= (sizeof(s)-1)) && ::strncmp(packet_cstr, s, (sizeof(s)-1))==0) + // Empty is not a supported packet... if (m_packet.empty()) return eServerPacketType_invalid; + const size_t packet_size = m_packet.size(); const char *packet_cstr = m_packet.c_str(); switch (m_packet[0]) { case '\x03': - if (m_packet.size() == 1) - return eServerPacketType_interrupt; + if (packet_size == 1) return eServerPacketType_interrupt; break; case '-': - if (m_packet.size() == 1) - return eServerPacketType_nack; + if (packet_size == 1) return eServerPacketType_nack; break; case '+': - if (m_packet.size() == 1) - return eServerPacketType_ack; + if (packet_size == 1) return eServerPacketType_ack; break; + case 'A': + return eServerPacketType_A; + case 'Q': - if (strcmp (packet_cstr, "QStartNoAckMode") == 0) - return eServerPacketType_QStartNoAckMode; + switch (packet_cstr[1]) + { + case 'E': + if (PACKET_STARTS_WITH ("QEnvironment:")) return eServerPacketType_QEnvironment; + break; + + case 'S': + if (PACKET_MATCHES ("QStartNoAckMode")) return eServerPacketType_QStartNoAckMode; + else if (PACKET_STARTS_WITH ("QSetDisableASLR:")) return eServerPacketType_QSetDisableASLR; + else if (PACKET_STARTS_WITH ("QSetSTDIN:")) return eServerPacketType_QSetSTDIN; + else if (PACKET_STARTS_WITH ("QSetSTDOUT:")) return eServerPacketType_QSetSTDOUT; + else if (PACKET_STARTS_WITH ("QSetSTDERR:")) return eServerPacketType_QSetSTDERR; + else if (PACKET_STARTS_WITH ("QSetWorkingDir:")) return eServerPacketType_QSetWorkingDir; + break; + } break; case 'q': - if (packet_cstr[1] == 'S' && 0 == ::strncmp(packet_cstr, "qSpeedTest:", strlen("qSpeedTest:"))) - return eServerPacketType_qSpeedTest; - else if (packet_cstr[1] == 'H' && 0 == ::strcmp (packet_cstr, "qHostInfo")) - return eServerPacketType_qHostInfo; - else if (packet_cstr[1] == 'P' && 0 == ::strncmp(packet_cstr, "qProcessInfoPID:", strlen("qProcessInfoPID:"))) - return eServerPacketType_qProcessInfoPID; - else if (packet_cstr[1] == 'f' && 0 == ::strncmp(packet_cstr, "qfProcessInfo", strlen("qfProcessInfo"))) - return eServerPacketType_qfProcessInfo; - else if (packet_cstr[1] == 'U' && 0 == ::strncmp(packet_cstr, "qUserName:", strlen("qUserName:"))) - return eServerPacketType_qUserName; - else if (packet_cstr[1] == 'G' && 0 == ::strncmp(packet_cstr, "qGroupName:", strlen("qGroupName:"))) - return eServerPacketType_qGroupName; - else if (packet_cstr[1] == 's' && 0 == ::strcmp (packet_cstr, "qsProcessInfo")) - return eServerPacketType_qsProcessInfo; + switch (packet_cstr[1]) + { + case 's': + if (PACKET_MATCHES ("qsProcessInfo")) return eServerPacketType_qsProcessInfo; + break; + + case 'f': + if (PACKET_STARTS_WITH ("qfProcessInfo")) return eServerPacketType_qfProcessInfo; + break; + + case 'C': + if (packet_size == 2) return eServerPacketType_qC; + break; + + case 'G': + if (PACKET_STARTS_WITH ("qGroupName:")) return eServerPacketType_qGroupName; + break; + + case 'H': + if (PACKET_MATCHES ("qHostInfo")) return eServerPacketType_qHostInfo; + break; + + case 'L': + if (PACKET_MATCHES ("qLaunchGDBServer")) return eServerPacketType_qLaunchGDBServer; + if (PACKET_MATCHES ("qLaunchSuccess")) return eServerPacketType_qLaunchSuccess; + break; + + case 'P': + if (PACKET_STARTS_WITH ("qProcessInfoPID:")) return eServerPacketType_qProcessInfoPID; + break; + + case 'S': + if (PACKET_STARTS_WITH ("qSpeedTest:")) return eServerPacketType_qSpeedTest; + break; + + case 'U': + if (PACKET_STARTS_WITH ("qUserName:")) return eServerPacketType_qUserName; + break; + } break; } return eServerPacketType_unimplemented; Modified: lldb/trunk/source/Utility/StringExtractorGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringExtractorGDBRemote.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/source/Utility/StringExtractorGDBRemote.h (original) +++ lldb/trunk/source/Utility/StringExtractorGDBRemote.h Tue Apr 12 00:54:46 2011 @@ -46,13 +46,23 @@ eServerPacketType_invalid, eServerPacketType_unimplemented, eServerPacketType_interrupt, // CTRL+c packet or "\x03" - eServerPacketType_qHostInfo, - eServerPacketType_qProcessInfoPID, + eServerPacketType_A, // Program arguments packet eServerPacketType_qfProcessInfo, eServerPacketType_qsProcessInfo, - eServerPacketType_qUserName, + eServerPacketType_qC, eServerPacketType_qGroupName, + eServerPacketType_qHostInfo, + eServerPacketType_qLaunchGDBServer, + eServerPacketType_qLaunchSuccess, + eServerPacketType_qProcessInfoPID, eServerPacketType_qSpeedTest, + eServerPacketType_qUserName, + eServerPacketType_QEnvironment, + eServerPacketType_QSetDisableASLR, + eServerPacketType_QSetSTDIN, + eServerPacketType_QSetSTDOUT, + eServerPacketType_QSetSTDERR, + eServerPacketType_QSetWorkingDir, eServerPacketType_QStartNoAckMode }; Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/TestAbbreviations.py?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/test/abbreviation_tests/TestAbbreviations.py (original) +++ lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Tue Apr 12 00:54:46 2011 @@ -74,7 +74,7 @@ self.expect("fil " + exe, patterns = [ "Current executable set to .*a.out.*" ]) - self.expect("regexp-b product", + self.expect("_regexp-b product", substrs = [ "breakpoint set --name 'product'", "Breakpoint created: 1: name = 'product', locations = 1" ]) Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Tue Apr 12 00:54:46 2011 @@ -216,9 +216,9 @@ Collected 4 tests test_break_with_dsym (TestObjCMethods.FoundationTestCase) -Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'. ... ok +Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'. ... ok test_break_with_dwarf (TestObjCMethods.FoundationTestCase) -Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'. ... ok +Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'. ... ok test_data_type_and_expr_with_dsym (TestObjCMethods.FoundationTestCase) Lookup objective-c data types and evaluate expressions. ... ok test_data_type_and_expr_with_dwarf (TestObjCMethods.FoundationTestCase) Modified: lldb/trunk/test/foundation/TestFoundationDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestFoundationDisassembly.py?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestFoundationDisassembly.py (original) +++ lldb/trunk/test/foundation/TestFoundationDisassembly.py Tue Apr 12 00:54:46 2011 @@ -70,7 +70,7 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at +[NSString stringWithFormat:]. - self.expect("regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, + self.expect("_regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, substrs = ["Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1"]) # Stop at -[MyString initWithNSString:]. @@ -82,7 +82,7 @@ startstr = "Breakpoint created: 3: name = 'description', locations = 1") # Stop at -[NSAutoreleasePool release]. - self.expect("regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, + self.expect("_regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, substrs = ["Breakpoint created: 4: name = '-[NSAutoreleasePool release]', locations = 1"]) self.runCmd("run", RUN_SUCCEEDED) Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Tue Apr 12 00:54:46 2011 @@ -14,12 +14,12 @@ mydir = "foundation" def test_break_with_dsym(self): - """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" + """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" self.buildDsym() self.break_on_objc_methods() def test_break_with_dwarf(self): - """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" + """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" self.buildDwarf() self.break_on_objc_methods() @@ -50,12 +50,12 @@ self.print_ivars_correctly() def break_on_objc_methods(self): - """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" + """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at +[NSString stringWithFormat:]. - self.expect("regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, + self.expect("_regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, substrs = ["Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1"]) # Stop at -[MyString initWithNSString:]. @@ -67,7 +67,7 @@ startstr = "Breakpoint created: 3: name = 'description', locations = 1") # Stop at -[NSAutoreleasePool release]. - self.expect("regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, + self.expect("_regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, substrs = ["Breakpoint created: 4: name = '-[NSAutoreleasePool release]', locations = 1"]) self.runCmd("run", RUN_SUCCEEDED) Modified: lldb/trunk/tools/darwin-debug/darwin-debug.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/darwin-debug/darwin-debug.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/tools/darwin-debug/darwin-debug.cpp (original) +++ lldb/trunk/tools/darwin-debug/darwin-debug.cpp Tue Apr 12 00:54:46 2011 @@ -246,7 +246,7 @@ printf ("argv[%u] = '%s'\n", i, argv[i]); #endif - // Open the socket that was passed in as an argument + // Open the socket that was passed in as an option struct sockaddr_un saddr_un; int s = ::socket (AF_UNIX, SOCK_STREAM, 0); if (s < 0) Modified: lldb/trunk/tools/debugserver/source/MacOSX/CFString.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/CFString.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/CFString.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/CFString.h Tue Apr 12 00:54:46 2011 @@ -24,7 +24,7 @@ // Constructors and Destructors //------------------------------------------------------------------ CFString (CFStringRef cf_str = NULL); - CFString (const char *s, CFStringEncoding encoding); + CFString (const char *s, CFStringEncoding encoding = kCFStringEncodingUTF8); CFString (const CFString& rhs); CFString& operator= (const CFString& rhs); virtual ~CFString (); Modified: lldb/trunk/tools/debugserver/source/RNBSocket.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBSocket.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBSocket.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBSocket.cpp Tue Apr 12 00:54:46 2011 @@ -31,78 +31,90 @@ This function blocks while waiting for that connection. */ rnb_err_t -RNBSocket::Listen (in_port_t listen_port_num) +RNBSocket::Listen (in_port_t port, PortBoundCallback callback, const void *callback_baton) { //DNBLogThreadedIf(LOG_RNB_COMM, "%8u RNBSocket::%s called", (uint32_t)m_timer.ElapsedMicroSeconds(true), __FUNCTION__); // Disconnect without saving errno Disconnect (false); DNBError err; - int listen_port = ::socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (listen_port == -1) + int listen_fd = ::socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (listen_fd == -1) err.SetError(errno, DNBError::POSIX); if (err.Fail() || DNBLogCheckLogBit(LOG_RNB_COMM)) - err.LogThreaded("::socket ( domain = AF_INET, type = SOCK_STREAM, protocol = IPPROTO_TCP ) => socket = %i", listen_port); + err.LogThreaded("::socket ( domain = AF_INET, type = SOCK_STREAM, protocol = IPPROTO_TCP ) => socket = %i", listen_fd); if (err.Fail()) return rnb_err; // enable local address reuse - SetSocketOption (listen_port, SOL_SOCKET, SO_REUSEADDR, 1); + SetSocketOption (listen_fd, SOL_SOCKET, SO_REUSEADDR, 1); struct sockaddr_in sa; ::memset (&sa, 0, sizeof sa); sa.sin_len = sizeof sa; sa.sin_family = AF_INET; - sa.sin_port = htons (listen_port_num); + sa.sin_port = htons (port); sa.sin_addr.s_addr = htonl (INADDR_ANY); - int error = ::bind (listen_port, (struct sockaddr *) &sa, sizeof(sa)); + int error = ::bind (listen_fd, (struct sockaddr *) &sa, sizeof(sa)); if (error == -1) err.SetError(errno, DNBError::POSIX); if (err.Fail() || DNBLogCheckLogBit(LOG_RNB_COMM)) - err.LogThreaded("::bind ( socket = %i, (struct sockaddr *) &sa, sizeof(sa)) )", listen_port); + err.LogThreaded("::bind ( socket = %i, (struct sockaddr *) &sa, sizeof(sa)) )", listen_fd); if (err.Fail()) { - ClosePort (listen_port, false); + ClosePort (listen_fd, false); return rnb_err; } - error = ::listen (listen_port, 1); + if (callback && port == 0) + { + // We were asked to listen on port zero which means we + // must now read the actual port that was given to us + // as port zero is a special code for "find an open port + // for me". + socklen_t sa_len = sizeof (sa); + if (getsockname(listen_fd, (struct sockaddr *)&sa, &sa_len) == 0) + { + port = ntohs (sa.sin_port); + callback (callback_baton, port); + } + } + + error = ::listen (listen_fd, 1); if (error == -1) err.SetError(errno, DNBError::POSIX); if (err.Fail() || DNBLogCheckLogBit(LOG_RNB_COMM)) - err.LogThreaded("::listen ( socket = %i, backlog = 1 )", listen_port); + err.LogThreaded("::listen ( socket = %i, backlog = 1 )", listen_fd); if (err.Fail()) { - ClosePort (listen_port, false); + ClosePort (listen_fd, false); return rnb_err; } - m_conn_port = ::accept (listen_port, NULL, 0); - if (m_conn_port == -1) + m_fd = ::accept (listen_fd, NULL, 0); + if (m_fd == -1) err.SetError(errno, DNBError::POSIX); if (err.Fail() || DNBLogCheckLogBit(LOG_RNB_COMM)) - err.LogThreaded("::accept ( socket = %i, address = NULL, address_len = 0 )", listen_port); + err.LogThreaded("::accept ( socket = %i, address = NULL, address_len = 0 )", listen_fd); + + ClosePort (listen_fd, false); if (err.Fail()) { - ClosePort (listen_port, false); return rnb_err; } else { - // We are done with the listen port - ClosePort (listen_port, false); - // Keep our TCP packets coming without any delays. - SetSocketOption (m_conn_port, IPPROTO_TCP, TCP_NODELAY, 1); + SetSocketOption (m_fd, IPPROTO_TCP, TCP_NODELAY, 1); } return rnb_success; @@ -114,12 +126,12 @@ Disconnect (false); // Create the socket - m_conn_port = ::socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (m_conn_port == -1) + m_fd = ::socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (m_fd == -1) return rnb_err; // Enable local address reuse - SetSocketOption (m_conn_port, SOL_SOCKET, SO_REUSEADDR, 1); + SetSocketOption (m_fd, SOL_SOCKET, SO_REUSEADDR, 1); struct sockaddr_in sa; ::memset (&sa, 0, sizeof (sa)); @@ -146,14 +158,14 @@ } } - if (-1 == ::connect (m_conn_port, (const struct sockaddr *)&sa, sizeof(sa))) + if (-1 == ::connect (m_fd, (const struct sockaddr *)&sa, sizeof(sa))) { Disconnect (false); return rnb_err; } // Keep our TCP packets coming without any delays. - SetSocketOption (m_conn_port, IPPROTO_TCP, TCP_NODELAY, 1); + SetSocketOption (m_fd, IPPROTO_TCP, TCP_NODELAY, 1); return rnb_success; } @@ -165,13 +177,13 @@ // Disconnect from any previous connections Disconnect(false); - m_conn_port = ::lockdown_checkin (NULL, NULL); - if (m_conn_port == -1) + m_fd = ::lockdown_checkin (NULL, NULL); + if (m_fd == -1) { DNBLogThreadedIf(LOG_RNB_COMM, "::lockdown_checkin(NULL, NULL) failed"); return rnb_not_connected; } - m_conn_port_from_lockdown = true; + m_fd_from_lockdown = true; return rnb_success; } #endif @@ -180,8 +192,8 @@ RNBSocket::OpenFile (const char *path) { DNBError err; - m_conn_port = open (path, O_RDWR); - if (m_conn_port == -1) + m_fd = open (path, O_RDWR); + if (m_fd == -1) { err.SetError(errno, DNBError::POSIX); err.LogThreaded ("can't open file '%s'", path); @@ -191,11 +203,11 @@ { struct termios stdin_termios; - if (::tcgetattr (m_conn_port, &stdin_termios) == 0) + if (::tcgetattr (m_fd, &stdin_termios) == 0) { stdin_termios.c_lflag &= ~ECHO; // Turn off echoing stdin_termios.c_lflag &= ~ICANON; // Get one char at a time - ::tcsetattr (m_conn_port, TCSANOW, &stdin_termios); + ::tcsetattr (m_fd, TCSANOW, &stdin_termios); } } return rnb_success; @@ -210,9 +222,9 @@ rnb_err_t RNBSocket::Disconnect (bool save_errno) { - if (m_conn_port_from_lockdown) - m_conn_port_from_lockdown = false; - return ClosePort (m_conn_port, save_errno); + if (m_fd_from_lockdown) + m_fd_from_lockdown = false; + return ClosePort (m_fd, save_errno); } @@ -225,29 +237,29 @@ // Note that BUF is on the stack so we must be careful to keep any // writes to BUF from overflowing or we'll have security issues. - if (m_conn_port == -1) + if (m_fd == -1) return rnb_err; //DNBLogThreadedIf(LOG_RNB_COMM, "%8u RNBSocket::%s calling read()", (uint32_t)m_timer.ElapsedMicroSeconds(true), __FUNCTION__); DNBError err; - int bytesread = read (m_conn_port, buf, sizeof (buf)); + int bytesread = read (m_fd, buf, sizeof (buf)); if (bytesread <= 0) err.SetError(errno, DNBError::POSIX); else p.append(buf, bytesread); if (err.Fail() || DNBLogCheckLogBit(LOG_RNB_COMM)) - err.LogThreaded("::read ( %i, %p, %zu ) => %i", m_conn_port, buf, sizeof (buf), bytesread); + err.LogThreaded("::read ( %i, %p, %zu ) => %i", m_fd, buf, sizeof (buf), bytesread); // Our port went away - we have to mark this so IsConnected will return the truth. if (bytesread == 0) { - m_conn_port = -1; + m_fd = -1; return rnb_not_connected; } else if (bytesread == -1) { - m_conn_port = -1; + m_fd = -1; return rnb_err; } // Strip spaces from the end of the buffer @@ -262,16 +274,16 @@ rnb_err_t RNBSocket::Write (const void *buffer, size_t length) { - if (m_conn_port == -1) + if (m_fd == -1) return rnb_err; DNBError err; - int bytessent = send (m_conn_port, buffer, length, 0); + int bytessent = send (m_fd, buffer, length, 0); if (bytessent < 0) err.SetError(errno, DNBError::POSIX); if (err.Fail() || DNBLogCheckLogBit(LOG_RNB_COMM)) - err.LogThreaded("::send ( socket = %i, buffer = %p, length = %zu, flags = 0 ) => %i", m_conn_port, buffer, length, bytessent); + err.LogThreaded("::send ( socket = %i, buffer = %p, length = %zu, flags = 0 ) => %i", m_fd, buffer, length, bytessent); if (bytessent < 0) return rnb_err; Modified: lldb/trunk/tools/debugserver/source/RNBSocket.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBSocket.h?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBSocket.h (original) +++ lldb/trunk/tools/debugserver/source/RNBSocket.h Tue Apr 12 00:54:46 2011 @@ -23,10 +23,11 @@ class RNBSocket { public: + typedef void (*PortBoundCallback) (const void *baton, in_port_t port); RNBSocket () : - m_conn_port (-1), - m_conn_port_from_lockdown (false), + m_fd (-1), + m_fd_from_lockdown (false), m_timer (true) // Make a thread safe timer { } @@ -35,7 +36,7 @@ Disconnect (false); } - rnb_err_t Listen (in_port_t listen_port_num); + rnb_err_t Listen (in_port_t port, PortBoundCallback callback, const void *callback_baton); rnb_err_t Connect (const char *host, uint16_t port); #if defined (__arm__) @@ -46,7 +47,7 @@ rnb_err_t Read (std::string &p); rnb_err_t Write (const void *buffer, size_t length); - bool IsConnected () const { return m_conn_port != -1; } + bool IsConnected () const { return m_fd != -1; } void SaveErrno (int curr_errno); DNBTimer& Timer() { return m_timer; } @@ -58,8 +59,8 @@ protected: rnb_err_t ClosePort (int& fd, bool save_errno); - int m_conn_port; // Socket we use to communicate once conn established - bool m_conn_port_from_lockdown; + int m_fd; // Socket we use to communicate once conn established + bool m_fd_from_lockdown; DNBTimer m_timer; }; Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/debugserver.cpp (original) +++ lldb/trunk/tools/debugserver/source/debugserver.cpp Tue Apr 12 00:54:46 2011 @@ -17,6 +17,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include "CFString.h" #include "DNB.h" @@ -608,13 +614,68 @@ // Returns 1 for success 0 for failure. //---------------------------------------------------------------------- +static void +PortWasBoundCallback (const void *baton, in_port_t port) +{ + //::printf ("PortWasBoundCallback (baton = %p, port = %u)\n", baton, port); + + const char *unix_socket_name = (const char *)baton; + + if (unix_socket_name && unix_socket_name[0]) + { + // We were given a unix socket name to use to communicate the port + // that we ended up binding to back to our parent process + struct sockaddr_un saddr_un; + int s = ::socket (AF_UNIX, SOCK_STREAM, 0); + if (s < 0) + { + perror("error: socket (AF_UNIX, SOCK_STREAM, 0)"); + exit(1); + } + + saddr_un.sun_family = AF_UNIX; + ::strncpy(saddr_un.sun_path, unix_socket_name, sizeof(saddr_un.sun_path) - 1); + saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0'; + saddr_un.sun_len = SUN_LEN (&saddr_un); + + if (::connect (s, (struct sockaddr *)&saddr_un, SUN_LEN (&saddr_un)) < 0) + { + perror("error: connect (socket, &saddr_un, saddr_un_len)"); + exit(1); + } + + //::printf ("connect () sucess!!\n"); + + + // We were able to connect to the socket, now write our PID so whomever + // launched us will know this process's ID + RNBLogSTDOUT ("Listening to port %i...\n", port); + + char pid_str[64]; + const int pid_str_len = ::snprintf (pid_str, sizeof(pid_str), "%u", port); + const int bytes_sent = ::send (s, pid_str, pid_str_len, 0); + + if (pid_str_len != bytes_sent) + { + perror("error: send (s, pid_str, pid_str_len, 0)"); + exit (1); + } + + //::printf ("send () sucess!!\n"); + + // We are done with the socket + close (s); + } +} + static int -StartListening (RNBRemote *remote, int listen_port) +StartListening (RNBRemote *remote, int listen_port, const char *unix_socket_name) { if (!remote->Comm().IsConnected()) { - RNBLogSTDOUT ("Listening to port %i...\n", listen_port); - if (remote->Comm().Listen(listen_port) != rnb_success) + if (listen_port != 0) + RNBLogSTDOUT ("Listening to port %i...\n", listen_port); + if (remote->Comm().Listen(listen_port, PortWasBoundCallback, unix_socket_name) != rnb_success) { RNBLogSTDERR ("Failed to get connection from a remote gdb process.\n"); return 0; @@ -709,6 +770,7 @@ { "disable-aslr", no_argument, NULL, 'D' }, // Use _POSIX_SPAWN_DISABLE_ASLR to avoid shared library randomization { "working-dir", required_argument, NULL, 'W' }, // The working directory that the inferior process should have (only if debugserver launches the process) { "platform", required_argument, NULL, 'p' }, // Put this executable into a remote platform mode + { "unix-socket", required_argument, NULL, 'u' }, // If we need to handshake with our parent process, an option will be passed down that specifies a unix socket name to use { NULL, 0, NULL, 0 } }; @@ -757,7 +819,8 @@ std::string waitfor_pid_name; // Wait for a process that starts with this name std::string attach_pid_name; std::string arch_name; - std::string working_dir; // The new working directory to use for the inferior + std::string working_dir; // The new working directory to use for the inferior + std::string unix_socket_name; // If we need to handshake with our parent process, an option will be passed down that specifies a unix socket name to use 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; @@ -768,7 +831,7 @@ RNBRunLoopMode start_mode = eRNBRunLoopModeExit; - while ((ch = getopt_long(argc, argv, "a:A:d:gi:vktl:f:w:x:rs:n", g_long_options, &long_option_index)) != -1) + while ((ch = getopt_long(argc, argv, "a:A:d:gi:vktl:f:w:x:rs:nu:", g_long_options, &long_option_index)) != -1) { DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n", ch, (uint8_t)ch, @@ -967,6 +1030,11 @@ case 'p': start_mode = eRNBRunLoopModePlatformMode; break; + + case 'u': + unix_socket_name.assign (optarg); + break; + } } @@ -1171,7 +1239,7 @@ #endif if (listen_port != INT32_MAX) { - if (!StartListening (remote, listen_port)) + if (!StartListening (remote, listen_port, unix_socket_name.c_str())) mode = eRNBRunLoopModeExit; } else if (str[0] == '/') @@ -1282,7 +1350,7 @@ { if (listen_port != INT32_MAX) { - if (!StartListening (remote, listen_port)) + if (!StartListening (remote, listen_port, unix_socket_name.c_str())) mode = eRNBRunLoopModeExit; } else if (str[0] == '/') @@ -1307,7 +1375,7 @@ { if (listen_port != INT32_MAX) { - if (!StartListening (remote, listen_port)) + if (!StartListening (remote, listen_port, unix_socket_name.c_str())) mode = eRNBRunLoopModeExit; } else if (str[0] == '/') @@ -1334,7 +1402,7 @@ case eRNBRunLoopModePlatformMode: if (listen_port != INT32_MAX) { - if (!StartListening (remote, listen_port)) + if (!StartListening (remote, listen_port, unix_socket_name.c_str())) mode = eRNBRunLoopModeExit; } else if (str[0] == '/') Modified: lldb/trunk/tools/lldb-platform/lldb-platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-platform/lldb-platform.cpp?rev=129351&r1=129350&r2=129351&view=diff ============================================================================== --- lldb/trunk/tools/lldb-platform/lldb-platform.cpp (original) +++ lldb/trunk/tools/lldb-platform/lldb-platform.cpp Tue Apr 12 00:54:46 2011 @@ -180,7 +180,7 @@ argv += optind; - GDBRemoteCommunicationServer gdb_server; + GDBRemoteCommunicationServer gdb_server (true); if (!listen_host_post.empty()) { std::auto_ptr conn_ap(new ConnectionFileDescriptor()); From gclayton at apple.com Tue Apr 12 19:18:08 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 13 Apr 2011 00:18:08 -0000 Subject: [Lldb-commits] [lldb] r129415 - in /lldb/trunk: include/lldb/Interpreter/ include/lldb/Target/ lldb.xcodeproj/xcshareddata/xcschemes/ source/Commands/ source/Interpreter/ source/Target/ Message-ID: <20110413001808.E0DE92A6C12D@llvm.org> Author: gclayton Date: Tue Apr 12 19:18:08 2011 New Revision: 129415 URL: http://llvm.org/viewvc/llvm-project?rev=129415&view=rev Log: Added two new classes for command options: lldb_private::OptionGroup lldb_private::OptionGroupOptions OptionGroup lets you define a class that encapsulates settings that you want to reuse in multiple commands. It contains only the option definitions and the ability to set the option values, but it doesn't directly interface with the lldb_private::Options class that is the front end to all of the CommandObject option parsing. For that the OptionGroupOptions class can be used. It aggregates one or more OptionGroup objects and directs the option setting to the appropriate OptionGroup class. For an example of this, take a look at the CommandObjectFile and how it uses its "m_option_group" object shown below to be able to set values in both the FileOptionGroup and PlatformOptionGroup classes. The members used in CommandObjectFile are: OptionGroupOptions m_option_group; FileOptionGroup m_file_options; PlatformOptionGroup m_platform_options; Then in the constructor for CommandObjectFile you can combine the option settings. The code below shows a simplified version of the constructor: CommandObjectFile::CommandObjectFile(CommandInterpreter &interpreter) : CommandObject (...), m_option_group (interpreter), m_file_options (), m_platform_options(true) { m_option_group.Append (&m_file_options); m_option_group.Append (&m_platform_options); m_option_group.Finalize(); } We append the m_file_options and then the m_platform_options and then tell the option group the finalize the results. This allows the m_option_group to become the organizer of our prefs and after option parsing we end up with valid preference settings in both the m_file_options and m_platform_options objects. This also allows any other commands to use the FileOptionGroup and PlatformOptionGroup classes to implement options for their commands. Renamed: virtual void Options::ResetOptionValues(); to: virtual void Options::OptionParsingStarting(); And implemented a new callback named: virtual Error Options::OptionParsingFinished(); This allows Options subclasses to verify that the options all go together after all of the options have been specified and gives the chance for the command object to return an error. It also gives a chance to take all of the option values and produce or initialize objects after all options have completed parsing. Modfied: virtual Error SetOptionValue (int option_idx, const char *option_arg) = 0; to be: virtual Error SetOptionValue (uint32_t option_idx, const char *option_arg) = 0; (option_idx is now unsigned). Modified: lldb/trunk/include/lldb/Interpreter/Options.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme lldb/trunk/source/Commands/CommandObjectArgs.cpp lldb/trunk/source/Commands/CommandObjectArgs.h lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.h lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectFile.h lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectLog.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectPlatform.h lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectSettings.h lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Interpreter/Options.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Options.h (original) +++ lldb/trunk/include/lldb/Interpreter/Options.h Tue Apr 12 19:18:08 2011 @@ -56,7 +56,7 @@ /// } /// /// virtual Error -/// SetOptionValue (int option_idx, int option_val, const char *option_arg) +/// SetOptionValue (uint32_t option_idx, int option_val, const char *option_arg) /// { /// Error error; /// switch (option_val) @@ -142,15 +142,13 @@ bool VerifyOptions (CommandReturnObject &result); - // Verify that the options given are in the options table and can be used together, but there may be - // some required options that are missing (used to verify options that get folded into command aliases). + // Verify that the options given are in the options table and can + // be used together, but there may be some required options that are + // missing (used to verify options that get folded into command aliases). bool VerifyPartialOptions (CommandReturnObject &result); -// void -// BuildAliasOptions (OptionArgVector *option_arg_vector, Args args); - void OutputFormattedUsageText (Stream &strm, const char *text, @@ -160,19 +158,22 @@ GenerateOptionUsage (Stream &strm, CommandObject *cmd); - // The following two pure virtual functions must be defined by every class that inherits from - // this class. + // The following two pure virtual functions must be defined by every + // class that inherits from this class. virtual const OptionDefinition* GetDefinitions () { return NULL; } // Call this prior to parsing any options. This call will call the - // subclass ResetOptionValues() and will avoid the need for all - // ResetOptionValues() function instances from having to call the - // Option::ResetOptionValues() like they did before. This was error + // subclass OptionParsingStarting() and will avoid the need for all + // OptionParsingStarting() function instances from having to call the + // Option::OptionParsingStarting() like they did before. This was error // prone and subclasses shouldn't have to do it. void - Reset (); + NotifyOptionParsingStarting (); + + Error + NotifyOptionParsingFinished (); //------------------------------------------------------------------ /// Set the value of an option. @@ -190,11 +191,11 @@ /// @see man getopt_long //------------------------------------------------------------------ virtual Error - SetOptionValue (int option_idx, const char *option_arg) = 0; + SetOptionValue (uint32_t option_idx, const char *option_arg) = 0; //------------------------------------------------------------------ - /// Handles the generic bits of figuring out whether we are in an option, and if so completing - /// it. + /// Handles the generic bits of figuring out whether we are in an + /// option, and if so completing it. /// /// @param[in] input /// The command line parsed into words @@ -207,20 +208,22 @@ /// /// @param[in] match_start_point /// @param[in] match_return_elements - /// See CommandObject::HandleCompletions for a description of how these work. + /// See CommandObject::HandleCompletions for a description of + /// how these work. /// /// @param[in] interpreter /// The interpreter that's doing the completing. /// /// @param[out] word_complete - /// \btrue if this is a complete option value (a space will be inserted after the - /// completion.) \bfalse otherwise. + /// \btrue if this is a complete option value (a space will be + /// inserted after the completion.) \b false otherwise. /// /// @param[out] matches /// The array of matches returned. /// - /// FIXME: This is the wrong return value, since we also need to make a distinction between - /// total number of matches, and the window the user wants returned. + /// FIXME: This is the wrong return value, since we also need to + /// make a distinction between total number of matches, and the + /// window the user wants returned. /// /// @return /// \btrue if we were in an option, \bfalse otherwise. @@ -236,8 +239,8 @@ lldb_private::StringList &matches); //------------------------------------------------------------------ - /// Handles the generic bits of figuring out whether we are in an option, and if so completing - /// it. + /// Handles the generic bits of figuring out whether we are in an + /// option, and if so completing it. /// /// @param[in] interpreter /// The command interpreter doing the completion. @@ -255,21 +258,24 @@ /// The results of the options parse of \a input. /// /// @param[in] opt_element_index - /// The position in \a opt_element_vector of the word in \a input containing the cursor. + /// The position in \a opt_element_vector of the word in \a + /// input containing the cursor. /// /// @param[in] match_start_point /// @param[in] match_return_elements - /// See CommandObject::HandleCompletions for a description of how these work. + /// See CommandObject::HandleCompletions for a description of + /// how these work. /// /// @param[out] word_complete - /// \btrue if this is a complete option value (a space will be inserted after the - /// completion.) \bfalse otherwise. + /// \btrue if this is a complete option value (a space will + /// be inserted after the completion.) \bfalse otherwise. /// /// @param[out] matches /// The array of matches returned. /// - /// FIXME: This is the wrong return value, since we also need to make a distinction between - /// total number of matches, and the window the user wants returned. + /// FIXME: This is the wrong return value, since we also need to + /// make a distinction between total number of matches, and the + /// window the user wants returned. /// /// @return /// \btrue if we were in an option, \bfalse otherwise. @@ -321,9 +327,104 @@ // option parse. Each subclass must override this function and revert // all option settings to default values. virtual void - ResetOptionValues () = 0; + OptionParsingStarting () = 0; + + virtual Error + OptionParsingFinished () + { + // If subclasses need to know when the options are done being parsed + // they can implement this function to do extra checking + Error error; + return error; + } }; + class OptionGroup + { + public: + OptionGroup () + { + } + + virtual + ~OptionGroup () + { + } + + virtual uint32_t + GetNumDefinitions () = 0; + + virtual const OptionDefinition* + GetDefinitions () = 0; + + virtual Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value) = 0; + + virtual void + OptionParsingStarting (CommandInterpreter &interpreter) = 0; + + virtual Error + OptionParsingFinished (CommandInterpreter &interpreter) + { + // If subclasses need to know when the options are done being parsed + // they can implement this function to do extra checking + Error error; + return error; + } + }; + + class OptionGroupOptions : public Options + { + public: + + OptionGroupOptions (CommandInterpreter &interpreter) : + Options (interpreter), + m_option_defs (), + m_option_groups (), + m_did_finalize (false) + { + } + + virtual + ~OptionGroupOptions () + { + } + + void + Append (OptionGroup* group); + + void + Append (OptionGroup* group, uint32_t usage_mask); + + void + Finalize (); + + virtual Error + SetOptionValue (uint32_t option_idx, + const char *option_arg); + + virtual void + OptionParsingStarting (); + + virtual Error + OptionParsingFinished (); + + const OptionDefinition* + GetDefinitions () + { + assert (m_did_finalize); + return &m_option_defs[0]; + } + typedef std::vector OptionGroupsType; + + std::vector m_option_defs; + OptionGroupsType m_option_groups; + bool m_did_finalize; + }; + + } // namespace lldb_private #endif // liblldb_Options_h_ Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Tue Apr 12 19:18:08 2011 @@ -725,8 +725,8 @@ ProcessLaunchCommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - // Keep default values of all options in one place: ResetOptionValues () - ResetOptionValues (); + // Keep default values of all options in one place: OptionParsingStarting () + OptionParsingStarting (); } ~ProcessLaunchCommandOptions () @@ -734,10 +734,10 @@ } Error - SetOptionValue (int option_idx, const char *option_arg); + SetOptionValue (uint32_t option_idx, const char *option_arg); void - ResetOptionValues () + OptionParsingStarting () { launch_info.Clear(); } Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Tue Apr 12 19:18:08 2011 @@ -1,6 +1,6 @@ + version = "1.5"> @@ -196,4 +196,7 @@ buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> + + Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Tue Apr 12 19:18:08 2011 @@ -40,7 +40,7 @@ Options(interpreter) { // Keep only one place to reset the values to their defaults - ResetOptionValues(); + OptionParsingStarting(); } @@ -49,7 +49,7 @@ } Error -CommandObjectArgs::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) +CommandObjectArgs::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; @@ -66,7 +66,7 @@ } void -CommandObjectArgs::CommandOptions::ResetOptionValues () +CommandObjectArgs::CommandOptions::OptionParsingStarting () { } Modified: lldb/trunk/source/Commands/CommandObjectArgs.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.h?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.h (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.h Tue Apr 12 19:18:08 2011 @@ -34,10 +34,10 @@ ~CommandOptions (); virtual Error - SetOptionValue (int option_idx, const char *option_arg); + SetOptionValue (uint32_t option_idx, const char *option_arg); void - ResetOptionValues (); + OptionParsingStarting (); const OptionDefinition* GetDefinitions (); Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Tue Apr 12 19:18:08 2011 @@ -134,7 +134,7 @@ } Error -CommandObjectBreakpointSet::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) +CommandObjectBreakpointSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -233,7 +233,7 @@ } void -CommandObjectBreakpointSet::CommandOptions::ResetOptionValues () +CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting () { m_filename.clear(); m_line_num = 0; @@ -675,7 +675,7 @@ } Error -CommandObjectBreakpointList::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) +CommandObjectBreakpointList::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -703,7 +703,7 @@ } void -CommandObjectBreakpointList::CommandOptions::ResetOptionValues () +CommandObjectBreakpointList::CommandOptions::OptionParsingStarting () { m_level = lldb::eDescriptionLevelBrief; m_internal = false; @@ -1077,7 +1077,7 @@ } Error -CommandObjectBreakpointClear::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) +CommandObjectBreakpointClear::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -1101,7 +1101,7 @@ } void -CommandObjectBreakpointClear::CommandOptions::ResetOptionValues () +CommandObjectBreakpointClear::CommandOptions::OptionParsingStarting () { m_filename.clear(); m_line_num = 0; @@ -1394,7 +1394,7 @@ } Error -CommandObjectBreakpointModify::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) +CommandObjectBreakpointModify::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -1480,7 +1480,7 @@ } void -CommandObjectBreakpointModify::CommandOptions::ResetOptionValues () +CommandObjectBreakpointModify::CommandOptions::OptionParsingStarting () { m_ignore_count = 0; m_thread_id = LLDB_INVALID_THREAD_ID; Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.h?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.h Tue Apr 12 19:18:08 2011 @@ -82,10 +82,10 @@ ~CommandOptions (); virtual Error - SetOptionValue (int option_idx, const char *option_arg); + SetOptionValue (uint32_t option_idx, const char *option_arg); void - ResetOptionValues (); + OptionParsingStarting (); const OptionDefinition* GetDefinitions (); @@ -148,10 +148,10 @@ ~CommandOptions (); virtual Error - SetOptionValue (int option_idx, const char *option_arg); + SetOptionValue (uint32_t option_idx, const char *option_arg); void - ResetOptionValues (); + OptionParsingStarting (); const OptionDefinition* GetDefinitions (); @@ -249,10 +249,10 @@ ~CommandOptions (); virtual Error - SetOptionValue (int option_idx, const char *option_arg); + SetOptionValue (uint32_t option_idx, const char *option_arg); void - ResetOptionValues (); + OptionParsingStarting (); const OptionDefinition * GetDefinitions (); @@ -309,10 +309,10 @@ ~CommandOptions (); virtual Error - SetOptionValue (int option_idx, const char *option_arg); + SetOptionValue (uint32_t option_idx, const char *option_arg); void - ResetOptionValues (); + OptionParsingStarting (); const OptionDefinition* GetDefinitions (); Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Tue Apr 12 19:18:08 2011 @@ -82,7 +82,7 @@ Error CommandObjectBreakpointCommandAdd::CommandOptions::SetOptionValue ( - int option_idx, + uint32_t option_idx, const char *option_arg ) { @@ -133,7 +133,7 @@ } void -CommandObjectBreakpointCommandAdd::CommandOptions::ResetOptionValues () +CommandObjectBreakpointCommandAdd::CommandOptions::OptionParsingStarting () { m_use_commands = true; m_use_script_language = false; Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h Tue Apr 12 19:18:08 2011 @@ -101,10 +101,10 @@ ~CommandOptions (); virtual Error - SetOptionValue (int option_idx, const char *option_arg); + SetOptionValue (uint32_t option_idx, const char *option_arg); void - ResetOptionValues (); + OptionParsingStarting (); const OptionDefinition* GetDefinitions (); Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Apr 12 19:18:08 2011 @@ -43,7 +43,7 @@ ~CommandOptions (){} virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -70,7 +70,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_stop_on_error = true; m_stop_on_continue = true; @@ -360,7 +360,7 @@ if (options) { // See if any options were specified as part of the alias; if so, handle them appropriately - options->Reset (); + options->NotifyOptionParsingStarting (); Args tmp_args (raw_command_string.c_str()); args.Unshift ("dummy_arg"); args.ParseAliasOptions (*options, result, option_arg_vector, raw_command_string); @@ -491,7 +491,7 @@ options = sub_cmd_obj->GetOptions(); else options = cmd_obj->GetOptions(); - options->Reset (); + options->NotifyOptionParsingStarting (); std::string empty_string; args.Unshift ("dummy_arg"); args.ParseAliasOptions (*options, result, option_arg_vector, empty_string); Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Tue Apr 12 19:18:08 2011 @@ -44,7 +44,7 @@ plugin_name (), arch() { - ResetOptionValues(); + OptionParsingStarting(); } CommandObjectDisassemble::CommandOptions::~CommandOptions () @@ -52,7 +52,7 @@ } Error -CommandObjectDisassemble::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) +CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; @@ -140,7 +140,7 @@ } void -CommandObjectDisassemble::CommandOptions::ResetOptionValues () +CommandObjectDisassemble::CommandOptions::OptionParsingStarting () { show_mixed = false; show_bytes = false; Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.h?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.h (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.h Tue Apr 12 19:18:08 2011 @@ -36,10 +36,10 @@ ~CommandOptions (); virtual Error - SetOptionValue (int option_idx, const char *option_arg); + SetOptionValue (uint32_t option_idx, const char *option_arg); void - ResetOptionValues (); + OptionParsingStarting (); const OptionDefinition* GetDefinitions (); Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Apr 12 19:18:08 2011 @@ -41,7 +41,7 @@ Options(interpreter) { // Keep only one place to reset the values to their defaults - ResetOptionValues(); + OptionParsingStarting(); } @@ -50,7 +50,7 @@ } Error -CommandObjectExpression::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) +CommandObjectExpression::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; @@ -93,7 +93,7 @@ } void -CommandObjectExpression::CommandOptions::ResetOptionValues () +CommandObjectExpression::CommandOptions::OptionParsingStarting () { //language.Clear(); debug = false; @@ -297,7 +297,7 @@ { m_exe_ctx = m_interpreter.GetExecutionContext(); - m_options.Reset(); + m_options.NotifyOptionParsingStarting(); const char * expr = NULL; @@ -361,6 +361,14 @@ Args args (command, end_options - command); if (!ParseOptions (args, result)) return false; + + Error error (m_options.NotifyOptionParsingFinished()); + if (error.Fail()) + { + result.AppendError (error.AsCString()); + result.SetStatus (eReturnStatusFailed); + return false; + } } } Modified: lldb/trunk/source/Commands/CommandObjectExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.h (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.h Tue Apr 12 19:18:08 2011 @@ -35,10 +35,10 @@ ~CommandOptions (); virtual Error - SetOptionValue (int option_idx, const char *option_arg); + SetOptionValue (uint32_t option_idx, const char *option_arg); void - ResetOptionValues (); + OptionParsingStarting (); const OptionDefinition* GetDefinitions (); Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Tue Apr 12 19:18:08 2011 @@ -25,41 +25,51 @@ using namespace lldb; using namespace lldb_private; -CommandObjectFile::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : - Options (interpreter), - m_arch () // Breakpoint info defaults to brief descriptions +FileOptionGroup::FileOptionGroup() : + m_arch (), + m_arch_str () { } -CommandObjectFile::CommandOptions::~CommandOptions () +FileOptionGroup::~FileOptionGroup () { } -OptionDefinition -CommandObjectFile::CommandOptions::g_option_table[] = +OptionDefinition g_file_option_table[] = { - { LLDB_OPT_SET_1, false, "arch", 'a', required_argument, NULL, 0, eArgTypeArchitecture, "Specify the architecture to be used when the process is launched."}, - { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } + { LLDB_OPT_SET_1 , false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."}, }; +const uint32_t k_num_file_options = sizeof(g_file_option_table)/sizeof(OptionDefinition); + +uint32_t +FileOptionGroup::GetNumDefinitions () +{ + return k_num_file_options; +} const OptionDefinition * -CommandObjectFile::CommandOptions::GetDefinitions () +FileOptionGroup::GetDefinitions () { - return g_option_table; + return g_file_option_table; } Error -CommandObjectFile::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) +FileOptionGroup::SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) { Error error; - char short_option = (char) m_getopt_table[option_idx].val; + char short_option = (char) g_file_option_table[option_idx].short_option; switch (short_option) { case 'a': { - PlatformSP platform_sp (m_interpreter.GetPlatform (false)); - ArchSpec option_arch (option_arg, platform_sp.get()); + // Save the arch value in case we specify a platform after specifying the arch + m_arch_str.assign (option_arg); + // Check to see if we already have a platform? + m_arch_platform_sp = interpreter.GetPlatform (false); + ArchSpec option_arch (option_arg, m_arch_platform_sp.get()); if (option_arch.IsValid()) m_arch = option_arch; else @@ -76,11 +86,30 @@ } void -CommandObjectFile::CommandOptions::ResetOptionValues () +FileOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter) { m_arch.Clear(); } +Error +FileOptionGroup::OptionParsingFinished (CommandInterpreter &interpreter) +{ + Error error; + if (m_arch.IsValid()) + { + PlatformSP curr_platform_sp (interpreter.GetPlatform (false)); + if (curr_platform_sp.get() != m_arch_platform_sp.get()) + { + ArchSpec option_arch (m_arch_str.c_str(), curr_platform_sp.get()); + if (option_arch.IsValid()) + m_arch = option_arch; + else + error.SetErrorStringWithFormat ("invalid arch '%s' for platform '%s'", m_arch_str.c_str(), curr_platform_sp->GetName()); + } + } + return error; +} + //------------------------------------------------------------------------- // CommandObjectFile //------------------------------------------------------------------------- @@ -90,7 +119,9 @@ "file", "Set the file to be used as the main executable by the debugger.", NULL), - m_options (interpreter) + m_option_group (interpreter), + m_file_options (), + m_platform_options(true) // Do include the "--platform" option in the platform settings by passing true { CommandArgumentEntry arg; CommandArgumentData file_arg; @@ -104,6 +135,10 @@ // Push the data for the first argument into the m_arguments vector. m_arguments.push_back (arg); + + m_option_group.Append (&m_file_options); + m_option_group.Append (&m_platform_options); + m_option_group.Finalize(); } CommandObjectFile::~CommandObjectFile () @@ -113,7 +148,7 @@ Options * CommandObjectFile::GetOptions () { - return &m_options; + return &m_option_group; } bool @@ -140,7 +175,7 @@ TargetSP target_sp; Debugger &debugger = m_interpreter.GetDebugger(); - Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, m_options.m_arch, true, target_sp); + Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, m_file_options.m_arch, true, target_sp); if (target_sp) { Modified: lldb/trunk/source/Commands/CommandObjectFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.h?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.h (original) +++ lldb/trunk/source/Commands/CommandObjectFile.h Tue Apr 12 19:18:08 2011 @@ -12,11 +12,13 @@ // C Includes // C++ Includes +#include // Other libraries and framework includes // Project includes #include "lldb/Interpreter/Options.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Interpreter/CommandObject.h" +#include "CommandObjectPlatform.h" namespace lldb_private { @@ -24,6 +26,38 @@ // CommandObjectFile //------------------------------------------------------------------------- + class FileOptionGroup : public OptionGroup + { + public: + + FileOptionGroup (); + + virtual + ~FileOptionGroup (); + + + virtual uint32_t + GetNumDefinitions (); + + virtual const OptionDefinition* + GetDefinitions (); + + virtual Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + virtual void + OptionParsingStarting (CommandInterpreter &interpreter); + + virtual Error + OptionParsingFinished (CommandInterpreter &interpreter); + + ArchSpec m_arch; + lldb::PlatformSP m_arch_platform_sp; // The platform that was used to resolve m_arch + std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture + }; + class CommandObjectFile : public CommandObject { public: @@ -40,32 +74,6 @@ virtual Options * GetOptions (); - class CommandOptions : public Options - { - public: - - CommandOptions (CommandInterpreter &interpreter); - - virtual - ~CommandOptions (); - - virtual Error - SetOptionValue (int option_idx, const char *option_arg); - - void - ResetOptionValues (); - - const OptionDefinition* - GetDefinitions (); - - // Options table: Required for subclasses of Options. - - static OptionDefinition g_option_table[]; - - // Instance variables to hold the values for command options. - - ArchSpec m_arch; - }; virtual int HandleArgumentCompletion (Args &input, @@ -79,8 +87,9 @@ private: - CommandOptions m_options; - + OptionGroupOptions m_option_group; + FileOptionGroup m_file_options; + PlatformOptionGroup m_platform_options; }; } // namespace lldb_private Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Apr 12 19:18:08 2011 @@ -102,7 +102,7 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - ResetOptionValues (); + OptionParsingStarting (); } virtual @@ -111,7 +111,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; bool success = false; @@ -133,7 +133,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { relative_frame_offset = INT32_MIN; } @@ -293,7 +293,7 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - ResetOptionValues (); + OptionParsingStarting (); } virtual @@ -302,7 +302,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; bool success; @@ -350,7 +350,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { use_objc = false; use_regex = false; Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Tue Apr 12 19:18:08 2011 @@ -734,7 +734,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -764,7 +764,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_sort_order = eSortOrderNone; } @@ -1155,7 +1155,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { char short_option = (char) m_getopt_table[option_idx].val; uint32_t width = 0; @@ -1167,7 +1167,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_format_array.clear(); } @@ -1365,7 +1365,7 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - ResetOptionValues(); + OptionParsingStarting(); } virtual @@ -1374,7 +1374,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; @@ -1441,7 +1441,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_type = eLookupTypeInvalid; m_str.clear(); Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectLog.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectLog.cpp Tue Apr 12 19:18:08 2011 @@ -183,7 +183,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -207,7 +207,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { log_file.clear(); log_options = 0; Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Apr 12 19:18:08 2011 @@ -39,7 +39,7 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - ResetOptionValues(); + OptionParsingStarting(); } virtual @@ -48,7 +48,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -162,7 +162,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_format = eFormatBytesWithASCII; m_byte_size = 0; @@ -438,7 +438,7 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - ResetOptionValues(); + OptionParsingStarting(); } virtual @@ -447,7 +447,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -491,7 +491,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_format = eFormatBytes; m_byte_size = 1; Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Tue Apr 12 19:18:08 2011 @@ -27,24 +27,134 @@ using namespace lldb; using namespace lldb_private; + +PlatformSP +PlatformOptionGroup::CreatePlatformWithOptions (CommandInterpreter &interpreter, + const char *platform_name, + bool select, + Error& error) +{ + if (platform_name && platform_name[0]) + { + if (platform_sp) + { + error.SetErrorString ("platform can't be set more than once in a command"); + return PlatformSP(); + } + + platform_sp = Platform::Create (platform_name, error); + + if (platform_sp) + { + interpreter.GetDebugger().GetPlatformList().Append (platform_sp, select); + if (os_version_major != UINT32_MAX) + { + platform_sp->SetOSVersion (os_version_major, + os_version_minor, + os_version_update); + } + } + } + else + { + error.SetErrorString ("invalid platform name"); + platform_sp.reset(); + } + return platform_sp; +} + +void +PlatformOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter) +{ + platform_sp.reset(); + os_version_major = UINT32_MAX; + os_version_minor = UINT32_MAX; + os_version_update = UINT32_MAX; +} + +static OptionDefinition +g_option_table[] = +{ + { LLDB_OPT_SET_ALL, false, "platform" , 'p', required_argument, NULL, 0, eArgTypeNone, "Specify name of the platform to use for this target, creating the platform if necessary."}, + { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." } +}; + +static const uint32_t k_option_table_size = sizeof(g_option_table)/sizeof (OptionDefinition); + +const OptionDefinition* +PlatformOptionGroup::GetDefinitions () +{ + if (m_include_platform_option) + return g_option_table; + return g_option_table + 1; +} + +uint32_t +PlatformOptionGroup::GetNumDefinitions () +{ + if (m_include_platform_option) + return k_option_table_size; + return k_option_table_size - 1; +} + + +Error +PlatformOptionGroup::SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_arg) +{ + Error error; + if (!m_include_platform_option) + --option_idx; + + char short_option = (char) g_option_table[option_idx].short_option; + + switch (short_option) + { + case 'p': + CreatePlatformWithOptions (interpreter, option_arg, true, error); + break; + + case 'v': + if (Args::StringToVersion (option_arg, os_version_major, os_version_minor, os_version_update) == option_arg) + { + error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg); + } + else + { + if (platform_sp) + platform_sp->SetOSVersion (os_version_major, os_version_minor, os_version_update); + } + break; + + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + return error; +} + //---------------------------------------------------------------------- // "platform create " //---------------------------------------------------------------------- -class CommandObjectPlatformCreate : public CommandObject +class CommandObjectPlatformSelect : public CommandObject { public: - CommandObjectPlatformCreate (CommandInterpreter &interpreter) : + CommandObjectPlatformSelect (CommandInterpreter &interpreter) : CommandObject (interpreter, - "platform create", - "Create a platform instance by name and select it as the current platform.", - "platform create ", + "platform select", + "Create a platform if needed and select it as the current platform.", + "platform select ", 0), - m_options (interpreter) + m_option_group (interpreter), + m_platform_options (false) // Don't include the "--platform" option by passing false { + m_option_group.Append (&m_platform_options); + m_option_group.Finalize(); } virtual - ~CommandObjectPlatformCreate () + ~CommandObjectPlatformSelect () { } @@ -54,20 +164,13 @@ Error error; if (args.GetArgumentCount() == 1) { - PlatformSP platform_sp (Platform::Create (args.GetArgumentAtIndex (0), error)); - + const bool select = true; + PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, + args.GetArgumentAtIndex (0), + select, + error)); if (platform_sp) - { - m_interpreter.GetDebugger().GetPlatformList().Append (platform_sp, true); - if (m_options.os_version_major != UINT32_MAX) - { - platform_sp->SetOSVersion (m_options.os_version_major, - m_options.os_version_minor, - m_options.os_version_update); - } - platform_sp->GetStatus (result.GetOutputStream()); - } } else { @@ -80,86 +183,12 @@ virtual Options * GetOptions () { - return &m_options; + return &m_option_group; } protected: - - class CommandOptions : public Options - { - public: - - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), - os_version_major (UINT32_MAX), - os_version_minor (UINT32_MAX), - os_version_update (UINT32_MAX) - { - } - - virtual - ~CommandOptions () - { - } - - virtual Error - SetOptionValue (int option_idx, const char *option_arg) - { - Error error; - char short_option = (char) m_getopt_table[option_idx].val; - - switch (short_option) - { - case 'v': - if (Args::StringToVersion (option_arg, - os_version_major, - os_version_minor, - os_version_update) == option_arg) - { - error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg); - } - break; - - default: - error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); - break; - } - - return error; - } - - void - ResetOptionValues () - { - os_version_major = UINT32_MAX; - os_version_minor = UINT32_MAX; - os_version_update = UINT32_MAX; - } - - const OptionDefinition* - GetDefinitions () - { - return g_option_table; - } - - // Options table: Required for subclasses of Options. - - static OptionDefinition g_option_table[]; - - // Instance variables to hold the values for command options. - - uint32_t os_version_major; - uint32_t os_version_minor; - uint32_t os_version_update; - }; - CommandOptions m_options; -}; - -OptionDefinition -CommandObjectPlatformCreate::CommandOptions::g_option_table[] = -{ - { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." }, - { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } + OptionGroupOptions m_option_group; + PlatformOptionGroup m_platform_options; }; //---------------------------------------------------------------------- @@ -256,37 +285,6 @@ } }; - -//---------------------------------------------------------------------- -// "platform select " -//---------------------------------------------------------------------- -class CommandObjectPlatformSelect : public CommandObject -{ -public: - CommandObjectPlatformSelect (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "platform select", - "Select a platform by name to be the currently selected platform.", - "platform select ", - 0) - { - } - - virtual - ~CommandObjectPlatformSelect () - { - } - - virtual bool - Execute (Args& args, CommandReturnObject &result) - { - result.AppendError ("command not implemented\n"); - result.SetStatus (eReturnStatusFailed); - return result.Succeeded(); - } -}; - - //---------------------------------------------------------------------- // "platform connect " //---------------------------------------------------------------------- @@ -683,7 +681,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -773,7 +771,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { match_info.Clear(); show_args = false; @@ -956,11 +954,10 @@ CommandObjectMultiword (interpreter, "platform", "A set of commands to manage and create platforms.", - "platform [connect|create|disconnect|info|list|status|select] ...") + "platform [connect|disconnect|info|list|status|select] ...") { - LoadSubCommand ("create", CommandObjectSP (new CommandObjectPlatformCreate (interpreter))); - LoadSubCommand ("list" , CommandObjectSP (new CommandObjectPlatformList (interpreter))); LoadSubCommand ("select", CommandObjectSP (new CommandObjectPlatformSelect (interpreter))); + LoadSubCommand ("list" , CommandObjectSP (new CommandObjectPlatformList (interpreter))); LoadSubCommand ("status", CommandObjectSP (new CommandObjectPlatformStatus (interpreter))); LoadSubCommand ("connect", CommandObjectSP (new CommandObjectPlatformConnect (interpreter))); LoadSubCommand ("disconnect", CommandObjectSP (new CommandObjectPlatformDisconnect (interpreter))); Modified: lldb/trunk/source/Commands/CommandObjectPlatform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.h?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPlatform.h (original) +++ lldb/trunk/source/Commands/CommandObjectPlatform.h Tue Apr 12 19:18:08 2011 @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/CommandObjectMultiword.h" +#include "lldb/Interpreter/Options.h" namespace lldb_private { @@ -25,21 +26,74 @@ class CommandObjectPlatform : public CommandObjectMultiword { public: - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ CommandObjectPlatform(CommandInterpreter &interpreter); virtual ~CommandObjectPlatform(); -private: - //------------------------------------------------------------------ - // For CommandObjectPlatform only - //------------------------------------------------------------------ + private: DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatform); }; + +//------------------------------------------------------------------------- +// PlatformOptionGroup +// +// Make platform options available to to any other command in case they +// need them. The "file" command needs them, and by exposing them we can +// reuse the platform command options for any command, we can keep things +// consistent. +//------------------------------------------------------------------------- +class PlatformOptionGroup : public OptionGroup +{ +public: + + PlatformOptionGroup (bool include_platform_option) : + m_include_platform_option (include_platform_option), + platform_sp (), + os_version_major (UINT32_MAX), + os_version_minor (UINT32_MAX), + os_version_update (UINT32_MAX) + { + } + + virtual + ~PlatformOptionGroup () + { + } + + virtual uint32_t + GetNumDefinitions (); + + virtual const OptionDefinition* + GetDefinitions (); + + virtual Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + lldb::PlatformSP + CreatePlatformWithOptions (CommandInterpreter &interpreter, + const char *platform_name, + bool select, + Error& error); + + virtual void + OptionParsingStarting (CommandInterpreter &interpreter); + + // Instance variables to hold the values for command options. + + lldb::PlatformSP platform_sp; + uint32_t os_version_major; + uint32_t os_version_minor; + uint32_t os_version_update; +protected: + bool m_include_platform_option; +}; + + + } // namespace lldb_private #endif // liblldb_CommandObjectPlatform_h_ Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Apr 12 19:18:08 2011 @@ -43,8 +43,8 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - // Keep default values of all options in one place: ResetOptionValues () - ResetOptionValues (); + // Keep default values of all options in one place: OptionParsingStarting () + OptionParsingStarting (); } ~CommandOptions () @@ -52,7 +52,7 @@ } Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -80,7 +80,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { stop_at_entry = false; in_new_tty = false; @@ -423,8 +423,8 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - // Keep default values of all options in one place: ResetOptionValues () - ResetOptionValues (); + // Keep default values of all options in one place: OptionParsingStarting () + OptionParsingStarting (); } ~CommandOptions () @@ -432,7 +432,7 @@ } Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -467,7 +467,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { pid = LLDB_INVALID_PROCESS_ID; name.clear(); @@ -973,8 +973,8 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - // Keep default values of all options in one place: ResetOptionValues () - ResetOptionValues (); + // Keep default values of all options in one place: OptionParsingStarting () + OptionParsingStarting (); } ~CommandOptions () @@ -982,7 +982,7 @@ } Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -1001,7 +1001,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { plugin_name.clear(); } @@ -1559,7 +1559,7 @@ CommandOptions (CommandInterpreter &interpreter) : Options (interpreter) { - ResetOptionValues (); + OptionParsingStarting (); } ~CommandOptions () @@ -1567,7 +1567,7 @@ } Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -1591,7 +1591,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { stop.clear(); notify.clear(); Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Tue Apr 12 19:18:08 2011 @@ -159,7 +159,7 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - ResetOptionValues(); + OptionParsingStarting(); } virtual @@ -168,7 +168,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -186,7 +186,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_format = eFormatBytes; } Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Tue Apr 12 19:18:08 2011 @@ -263,7 +263,7 @@ } Error -CommandObjectSettingsSet::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) +CommandObjectSettingsSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -285,7 +285,7 @@ } void -CommandObjectSettingsSet::CommandOptions::ResetOptionValues () +CommandObjectSettingsSet::CommandOptions::OptionParsingStarting () { m_override = true; m_reset = false; Modified: lldb/trunk/source/Commands/CommandObjectSettings.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.h?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.h (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.h Tue Apr 12 19:18:08 2011 @@ -65,10 +65,10 @@ ~CommandOptions (); virtual Error - SetOptionValue (int option_idx, const char *option_arg); + SetOptionValue (uint32_t option_idx, const char *option_arg); void - ResetOptionValues (); + OptionParsingStarting (); const OptionDefinition* GetDefinitions (); Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Tue Apr 12 19:18:08 2011 @@ -47,7 +47,7 @@ } Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; const char short_option = g_option_table[option_idx].short_option; @@ -72,7 +72,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { file_spec.Clear(); file_name.clear(); @@ -159,7 +159,7 @@ } Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; const char short_option = g_option_table[option_idx].short_option; @@ -197,7 +197,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { file_spec.Clear(); file_name.clear(); Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Apr 12 19:18:08 2011 @@ -508,7 +508,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -587,7 +587,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_class_name.clear(); m_function_name.clear(); Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Tue Apr 12 19:18:08 2011 @@ -252,8 +252,8 @@ CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { - // Keep default values of all options in one place: ResetOptionValues () - ResetOptionValues (); + // Keep default values of all options in one place: OptionParsingStarting () + OptionParsingStarting (); } virtual @@ -262,7 +262,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -298,7 +298,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_count = -1; m_start = 0; @@ -490,8 +490,8 @@ CommandOptions (CommandInterpreter &interpreter) : Options (interpreter) { - // Keep default values of all options in one place: ResetOptionValues () - ResetOptionValues (); + // Keep default values of all options in one place: OptionParsingStarting () + OptionParsingStarting (); } virtual @@ -500,7 +500,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -542,7 +542,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_avoid_no_debug = true; m_run_mode = eOnlyDuringStepping; @@ -981,8 +981,8 @@ m_thread_idx(LLDB_INVALID_THREAD_ID), m_frame_idx(LLDB_INVALID_FRAME_ID) { - // Keep default values of all options in one place: ResetOptionValues () - ResetOptionValues (); + // Keep default values of all options in one place: OptionParsingStarting () + OptionParsingStarting (); } virtual @@ -991,7 +991,7 @@ } virtual Error - SetOptionValue (int option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -1040,7 +1040,7 @@ } void - ResetOptionValues () + OptionParsingStarting () { m_thread_idx = LLDB_INVALID_THREAD_ID; m_frame_idx = 0; Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Apr 12 19:18:08 2011 @@ -177,7 +177,7 @@ if (options != NULL) { Error error; - options->Reset(); + options->NotifyOptionParsingStarting(); // ParseOptions calls getopt_long, which always skips the zero'th item in the array and starts at position 1, // so we need to push a dummy value into position zero. @@ -187,7 +187,15 @@ // The "dummy_string" will have already been removed by ParseOptions, // so no need to remove it. - if (error.Fail() || !options->VerifyOptions (result)) + if (error.Success()) + error = options->NotifyOptionParsingFinished(); + + if (error.Success()) + { + if (options->VerifyOptions (result)) + return true; + } + else { const char *error_cstr = error.AsCString(); if (error_cstr) @@ -200,10 +208,9 @@ // No error string, output the usage information into result options->GenerateOptionUsage (result.GetErrorStream(), this); } - // Set the return status to failed (this was an error). - result.SetStatus (eReturnStatusFailed); - return false; } + result.SetStatus (eReturnStatusFailed); + return false; } return true; } Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Tue Apr 12 19:18:08 2011 @@ -41,11 +41,17 @@ } void -Options::Reset () +Options::NotifyOptionParsingStarting () { m_seen_options.clear(); // Let the subclass reset its option values - ResetOptionValues (); + OptionParsingStarting (); +} + +Error +Options::NotifyOptionParsingFinished () +{ + return OptionParsingFinished (); } void @@ -885,3 +891,80 @@ matches); } + + + + +void +OptionGroupOptions::Append (OptionGroup* group) +{ + m_option_groups.push_back (group); + const OptionDefinition* group_option_defs = group->GetDefinitions (); + const uint32_t group_option_count = group->GetNumDefinitions(); + for (uint32_t i=0; iGetDefinitions (); + const uint32_t group_option_count = group->GetNumDefinitions(); + for (uint32_t i=0; iGetNumDefinitions(); + if (option_idx < curr_idx + num_group_definitions) + return (*pos)->SetOptionValue (m_interpreter, option_idx - curr_idx, option_value); + curr_idx += num_group_definitions; + } + Error error; + error.SetErrorString ("invalid option index"); // Shouldn't happen... + return error; +} + +void +OptionGroupOptions::OptionParsingStarting () +{ + OptionGroupsType::iterator pos, end = m_option_groups.end(); + for (pos = m_option_groups.begin(); pos != end; ++pos) + (*pos)->OptionParsingStarting (m_interpreter); +} +Error +OptionGroupOptions::OptionParsingFinished () +{ + Error error; + OptionGroupsType::iterator pos, end = m_option_groups.end(); + for (pos = m_option_groups.begin(); pos != end; ++pos) + { + error = (*pos)->OptionParsingFinished (m_interpreter); + if (error.Fail()) + return error; + } + return error; +} Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=129415&r1=129414&r2=129415&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Apr 12 19:18:08 2011 @@ -346,7 +346,7 @@ } Error -ProcessLaunchCommandOptions::SetOptionValue (int option_idx, const char *option_arg) +ProcessLaunchCommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) { Error error; char short_option = (char) m_getopt_table[option_idx].val; From gclayton at apple.com Tue Apr 12 19:20:53 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 13 Apr 2011 00:20:53 -0000 Subject: [Lldb-commits] [lldb] r129416 - /lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Message-ID: <20110413002053.21DD72A6C12D@llvm.org> Author: gclayton Date: Tue Apr 12 19:20:52 2011 New Revision: 129416 URL: http://llvm.org/viewvc/llvm-project?rev=129416&view=rev Log: Revert newer xcscheme project file to avoid conflict with older Xcode versions. Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=129416&r1=129415&r2=129416&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Tue Apr 12 19:20:52 2011 @@ -1,6 +1,6 @@ + version = "1.3"> @@ -196,7 +196,4 @@ buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> - - From ctice at apple.com Tue Apr 12 19:42:12 2011 From: ctice at apple.com (Caroline Tice) Date: Wed, 13 Apr 2011 00:42:12 -0000 Subject: [Lldb-commits] [lldb] r129422 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110413004212.A9B2D2A6C12D@llvm.org> Author: ctice Date: Tue Apr 12 19:42:12 2011 New Revision: 129422 URL: http://llvm.org/viewvc/llvm-project?rev=129422&view=rev Log: Fix various minor bugs in the ARM instruction emulation code. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=129422&r1=129421&r2=129422&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Apr 12 19:42:12 2011 @@ -9757,7 +9757,7 @@ // if wback then R[n] = offset_addr; if (wback) { - if (WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, offset_addr)) + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, offset_addr)) return false; } } @@ -13036,7 +13036,7 @@ overflow = ((int32_t)result == signed_sum ? 0 : 1); if (carry_in) - carry_out = ((int32_t) x >= (int32_t) y) ? 1 : 0; + carry_out = ((int32_t) x >= (int32_t) (~y)) ? 1 : 0; else carry_out = ((int32_t) x > (int32_t) y) ? 1 : 0; @@ -13193,7 +13193,16 @@ ARMOpcode *opcode_data; if (m_opcode_mode == eModeThumb) + { + if (m_opcode.GetType() == Opcode::eType32) + { + uint16_t upper_bits = Bits32 (m_opcode.GetOpcode32(), 31, 16); + uint16_t lower_bits = Bits32 (m_opcode.GetOpcode32(), 15, 0); + uint32_t swapped = (lower_bits << 16) | upper_bits; + m_opcode.SetOpcode32 (swapped); + } opcode_data = GetThumbOpcodeForInstruction (m_opcode.GetOpcode32()); + } else if (m_opcode_mode == eModeARM) opcode_data = GetARMOpcodeForInstruction (m_opcode.GetOpcode32()); else From jingham at apple.com Wed Apr 13 16:11:41 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 13 Apr 2011 21:11:41 -0000 Subject: [Lldb-commits] [lldb] r129470 - /lldb/trunk/test/dotest.py Message-ID: <20110413211141.76A4A2A6C12C@llvm.org> Author: jingham Date: Wed Apr 13 16:11:41 2011 New Revision: 129470 URL: http://llvm.org/viewvc/llvm-project?rev=129470&view=rev Log: Have "-h" print just the command arguments, and "-h -v" print the examples as well. 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=129470&r1=129469&r2=129470&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Wed Apr 13 16:11:41 2011 @@ -146,7 +146,7 @@ print """ Usage: dotest.py [option] [args] where options: --h : print this help message and exit (also --help) +-h : print this help message and exit. Add '-v' for more detailed help. -A : specify the architecture(s) to launch for the inferior process -A i386 => launch inferior with i386 architecture -A x86_64^i386 => launch inferior with x86_64 and i386 architectures @@ -190,7 +190,10 @@ args : specify a list of directory names to search for test modules named after Test*.py (test discovery) if empty, search from the curret working directory, instead +""" + if verbose > 0: + print """ Examples: This is an example of using the -f option to pinpoint to a specfic test class @@ -299,6 +302,8 @@ global verbose global testdirs + do_help = False + if len(sys.argv) == 1: return @@ -313,7 +318,8 @@ break if sys.argv[index].find('-h') != -1: - usage() + index += 1 + do_help = True elif sys.argv[index].startswith('-A'): # Increment by 1 to fetch the ARCH spec. index += 1 @@ -434,6 +440,9 @@ print "Unknown option: ", sys.argv[index] usage() + if do_help == True: + usage() + # Do not specify both '-a' and '+a' at the same time. if dont_do_python_api_test and just_do_python_api_test: usage() From ctice at apple.com Wed Apr 13 16:49:04 2011 From: ctice at apple.com (Caroline Tice) Date: Wed, 13 Apr 2011 21:49:04 -0000 Subject: [Lldb-commits] [lldb] r129474 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110413214904.4E32C2A6C12C@llvm.org> Author: ctice Date: Wed Apr 13 16:49:04 2011 New Revision: 129474 URL: http://llvm.org/viewvc/llvm-project?rev=129474&view=rev Log: Fix bug where source & target registers were swapped in an emulation function. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=129474&r1=129473&r2=129474&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Wed Apr 13 16:49:04 2011 @@ -3750,8 +3750,8 @@ bool add, index, wback; switch (encoding) { case eEncodingT1: - Rt = Bits32(opcode, 5, 3); - Rn = Bits32(opcode, 2, 0); + Rt = Bits32(opcode, 2, 0); + Rn = Bits32(opcode, 5, 3); imm32 = Bits32(opcode, 10, 6) << 2; // imm32 = ZeroExtend(imm5:'00', 32); // index = TRUE; add = TRUE; wback = FALSE add = true; From gclayton at apple.com Wed Apr 13 17:47:15 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 13 Apr 2011 22:47:15 -0000 Subject: [Lldb-commits] [lldb] r129483 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Target/ source/Commands/ source/Core/ source/Interpreter/ source/Plugins/Platform/MacOSX/ source/Plugins/Platform/gdb-server/ source/Plugins/SymbolFile/DWARF/ source/Target/ tools/driver/ Message-ID: <20110413224715.E24FF2A6C12C@llvm.org> Author: gclayton Date: Wed Apr 13 17:47:15 2011 New Revision: 129483 URL: http://llvm.org/viewvc/llvm-project?rev=129483&view=rev Log: Added auto completion for architecture names and for platforms. Modified the OptionGroupOptions to be able to specify only some of the options that should be appended by using the usage_mask in the group defintions and also provided a way to remap them to a new usage mask after the copy. This allows options to be re-used and also targetted for specific option groups. Modfied the CommandArgumentType to have a new eArgTypePlatform enumeration. Taught the option parser to be able to automatically use the appropriate auto completion for a given options if nothing is explicitly specified in the option definition. So you don't have to specify it in the option definition tables. Renamed the default host platform name to "host", and the default platform hostname to be "localhost". Modified the "file" and "platform select" commands to make sure all options and args are good prior to creating a new platform. Also defer the computation of the architecture in the file command until all options are parsed and the platform has either not been specified or reset to a new value to avoid computing the arch more than once. Switch the PluginManager code over to using llvm::StringRef for string comparisons and got rid of all the AccessorXXX functions in lieu of the newer mutex + collection singleton accessors. Modified: lldb/trunk/include/lldb/Core/ArchSpec.h lldb/trunk/include/lldb/Core/Log.h lldb/trunk/include/lldb/Core/PluginManager.h lldb/trunk/include/lldb/Interpreter/CommandCompletions.h lldb/trunk/include/lldb/Interpreter/Options.h lldb/trunk/include/lldb/Target/Platform.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/include/lldb/lldb-private-types.h lldb/trunk/source/Commands/CommandCompletions.cpp lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectFile.h lldb/trunk/source/Commands/CommandObjectLog.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectPlatform.h lldb/trunk/source/Core/ArchSpec.cpp lldb/trunk/source/Core/Log.cpp lldb/trunk/source/Core/PluginManager.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp lldb/trunk/source/Target/Platform.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/Core/ArchSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ArchSpec.h (original) +++ lldb/trunk/include/lldb/Core/ArchSpec.h Wed Apr 13 17:47:15 2011 @@ -142,6 +142,10 @@ const ArchSpec& operator= (const ArchSpec& rhs); + static uint32_t + AutoComplete (const char *name, + StringList &matches); + //------------------------------------------------------------------ /// Returns a static string representing the current architecture. /// Modified: lldb/trunk/include/lldb/Core/Log.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Log.h (original) +++ lldb/trunk/include/lldb/Core/Log.h Wed Apr 13 17:47:15 2011 @@ -105,6 +105,13 @@ static void Terminate (); + + //------------------------------------------------------------------ + // Auto completion + //------------------------------------------------------------------ + static void + AutoCompleteChannelName (const char *channel_name, + StringList &matches); //------------------------------------------------------------------ // Member functions @@ -193,9 +200,6 @@ virtual ~LogChannel (); - static const char * - GetPluginSuffix (); - static lldb::LogChannelSP FindPlugin (const char *plugin_name); Modified: lldb/trunk/include/lldb/Core/PluginManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/PluginManager.h (original) +++ lldb/trunk/include/lldb/Core/PluginManager.h Wed Apr 13 17:47:15 2011 @@ -192,6 +192,9 @@ static const char * GetPlatformPluginDescriptionAtIndex (uint32_t idx); + static uint32_t + AutoCompletePlatformName (const char *partial_name, + StringList &matches); //------------------------------------------------------------------ // Process //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Interpreter/CommandCompletions.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandCompletions.h?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandCompletions.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandCompletions.h Wed Apr 13 17:47:15 2011 @@ -38,16 +38,19 @@ lldb_private::StringList &matches); // The array of matches we return. typedef enum { - eNoCompletion = 0, - eSourceFileCompletion = (1 << 0), - eDiskFileCompletion = (1 << 1), - eDiskDirectoryCompletion = (1 << 2), - eSymbolCompletion = (1 << 3), - eModuleCompletion = (1 << 4), - eSettingsNameCompletion = (1 << 5), - eCustomCompletion = (1 << 6) // This item serves two purposes. It is the last element in the enum, - // so you can add custom enums starting from here in your Option class. - // Also if you & in this bit the base code will not process the option. + eNoCompletion = 0u, + eSourceFileCompletion = (1u << 0), + eDiskFileCompletion = (1u << 1), + eDiskDirectoryCompletion = (1u << 2), + eSymbolCompletion = (1u << 3), + eModuleCompletion = (1u << 4), + eSettingsNameCompletion = (1u << 5), + ePlatformPluginCompletion = (1u << 6), + eArchitectureCompletion = (1u << 7), + // This item serves two purposes. It is the last element in the enum, + // so you can add custom enums starting from here in your Option class. + // Also if you & in this bit the base code will not process the option. + eCustomCompletion = (1u << 8) } CommonCompletionTypes; @@ -121,6 +124,25 @@ SearchFilter *searcher, bool &word_complete, lldb_private::StringList &matches); + + static int + PlatformPluginNames (CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + bool &word_complete, + lldb_private::StringList &matches); + + + static int + ArchitectureNames (CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + bool &word_complete, + lldb_private::StringList &matches); //---------------------------------------------------------------------- // The Completer class is a convenient base class for building searchers Modified: lldb/trunk/include/lldb/Interpreter/Options.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Options.h (original) +++ lldb/trunk/include/lldb/Interpreter/Options.h Wed Apr 13 17:47:15 2011 @@ -382,7 +382,7 @@ OptionGroupOptions (CommandInterpreter &interpreter) : Options (interpreter), m_option_defs (), - m_option_groups (), + m_option_infos (), m_did_finalize (false) { } @@ -392,11 +392,32 @@ { } + //---------------------------------------------------------------------- + /// Append options from a OptionGroup class. + /// + /// Append options from \a group that have a usage mask that has any bits + /// in "src_mask" set. After the option definition is copied into the + /// options definitions in this class, set the usage_mask to "dst_mask". + /// + /// @param[in] group + /// A group of options to take option values from and copy their + /// definitions into this class. + /// + /// @param[in] src_mask + /// When copying options from \a group, you might only want some of + /// the options to be appended to this group. This mask allows you + /// to control which options from \a group get added. It also allows + /// you to specify the same options from \a group multiple times + /// for different option sets. + /// + /// @param[in] dst_mask + /// Set the usage mask for any copied options to \a dst_mask after + /// copying the option definition. + //---------------------------------------------------------------------- void - Append (OptionGroup* group); - - void - Append (OptionGroup* group, uint32_t usage_mask); + Append (OptionGroup* group, + uint32_t src_mask, + uint32_t dst_mask); void Finalize (); @@ -417,10 +438,20 @@ assert (m_did_finalize); return &m_option_defs[0]; } - typedef std::vector OptionGroupsType; + struct OptionInfo + { + OptionInfo (OptionGroup* g, uint32_t i) : + option_group (g), + option_index (i) + { + } + OptionGroup* option_group; // The group that this option came from + uint32_t option_index; // The original option index from the OptionGroup + }; + typedef std::vector OptionInfos; std::vector m_option_defs; - OptionGroupsType m_option_groups; + OptionInfos m_option_infos; bool m_did_finalize; }; Modified: lldb/trunk/include/lldb/Target/Platform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Platform.h (original) +++ lldb/trunk/include/lldb/Target/Platform.h Wed Apr 13 17:47:15 2011 @@ -57,6 +57,9 @@ static lldb::PlatformSP GetDefaultPlatform (); + static const char * + GetHostPlatformName (); + static void SetDefaultPlatform (const lldb::PlatformSP &platform_sp); Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Apr 13 17:47:15 2011 @@ -387,6 +387,7 @@ eArgTypeValue, eArgTypeWidth, eArgTypeNone, + eArgTypePlatform, eArgTypeLastArg // Always keep this entry as the last entry in this enumeration!! } CommandArgumentType; Modified: lldb/trunk/include/lldb/lldb-private-types.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-types.h?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-types.h (original) +++ lldb/trunk/include/lldb/lldb-private-types.h Wed Apr 13 17:47:15 2011 @@ -59,7 +59,7 @@ char short_option; // Single character for this option. int option_has_arg; // no_argument, required_argument or optional_argument OptionEnumValueElement *enum_values; // If non-NULL an array of enum values. - uint32_t completionType; // Cookie the option class can use to do define the argument completion. + uint32_t completion_type; // Cookie the option class can use to do define the argument completion. lldb::CommandArgumentType argument_type; // Type of argument this option takes const char * usage_text; // Full text explaining what this options does and what (if any) argument to // pass it. Modified: lldb/trunk/source/Commands/CommandCompletions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) +++ lldb/trunk/source/Commands/CommandCompletions.cpp Wed Apr 13 17:47:15 2011 @@ -20,6 +20,7 @@ // Project includes #include "lldb/Host/FileSpec.h" #include "lldb/Core/FileSpecList.h" +#include "lldb/Core/PluginManager.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -38,6 +39,8 @@ {eSymbolCompletion, CommandCompletions::Symbols}, {eModuleCompletion, CommandCompletions::Modules}, {eSettingsNameCompletion, CommandCompletions::SettingsNames}, + {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames}, + {eArchitectureCompletion, CommandCompletions::ArchitectureNames}, {eNoCompletion, NULL} // This one has to be last in the list. }; @@ -413,6 +416,36 @@ //return matches.GetSize(); } + +int +CommandCompletions::PlatformPluginNames (CommandInterpreter &interpreter, + const char *partial_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + bool &word_complete, + lldb_private::StringList &matches) +{ + const uint32_t num_matches = PluginManager::AutoCompletePlatformName(partial_name, matches); + word_complete = num_matches == 1; + return num_matches; +} + +int +CommandCompletions::ArchitectureNames (CommandInterpreter &interpreter, + const char *partial_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + bool &word_complete, + lldb_private::StringList &matches) +{ + const uint32_t num_matches = ArchSpec::AutoComplete (partial_name, matches); + word_complete = num_matches == 1; + return num_matches; +} + + CommandCompletions::Completer::Completer ( CommandInterpreter &interpreter, Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Wed Apr 13 17:47:15 2011 @@ -26,7 +26,6 @@ using namespace lldb_private; FileOptionGroup::FileOptionGroup() : - m_arch (), m_arch_str () { } @@ -53,6 +52,17 @@ return g_file_option_table; } +bool +FileOptionGroup::GetArchitecture (Platform *platform, ArchSpec &arch) +{ + if (m_arch_str.empty()) + arch.Clear(); + else + arch.SetTriple(m_arch_str.c_str(), platform); + return arch.IsValid(); +} + + Error FileOptionGroup::SetOptionValue (CommandInterpreter &interpreter, uint32_t option_idx, @@ -64,17 +74,7 @@ switch (short_option) { case 'a': - { - // Save the arch value in case we specify a platform after specifying the arch - m_arch_str.assign (option_arg); - // Check to see if we already have a platform? - m_arch_platform_sp = interpreter.GetPlatform (false); - ArchSpec option_arch (option_arg, m_arch_platform_sp.get()); - if (option_arch.IsValid()) - m_arch = option_arch; - else - error.SetErrorStringWithFormat ("Invalid arch string '%s'.\n", option_arg); - } + m_arch_str.assign (option_arg); break; default: @@ -88,26 +88,7 @@ void FileOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter) { - m_arch.Clear(); -} - -Error -FileOptionGroup::OptionParsingFinished (CommandInterpreter &interpreter) -{ - Error error; - if (m_arch.IsValid()) - { - PlatformSP curr_platform_sp (interpreter.GetPlatform (false)); - if (curr_platform_sp.get() != m_arch_platform_sp.get()) - { - ArchSpec option_arch (m_arch_str.c_str(), curr_platform_sp.get()); - if (option_arch.IsValid()) - m_arch = option_arch; - else - error.SetErrorStringWithFormat ("invalid arch '%s' for platform '%s'", m_arch_str.c_str(), curr_platform_sp->GetName()); - } - } - return error; + m_arch_str.clear(); } //------------------------------------------------------------------------- @@ -136,8 +117,8 @@ // Push the data for the first argument into the m_arguments vector. m_arguments.push_back (arg); - m_option_group.Append (&m_file_options); - m_option_group.Append (&m_platform_options); + m_option_group.Append (&m_file_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); + m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Finalize(); } @@ -164,18 +145,46 @@ if (argc == 1) { FileSpec file_spec (file_path, true); + + bool select = true; + PlatformSP platform_sp; + + Error error; + + if (!m_platform_options.platform_name.empty()) + { + platform_sp = m_platform_options.CreatePlatformWithOptions(m_interpreter, select, error); + if (!platform_sp) + { + result.AppendError(error.AsCString()); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + ArchSpec file_arch; + + if (!m_file_options.m_arch_str.empty()) + { + if (!platform_sp) + platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform(); + if (!m_file_options.GetArchitecture(platform_sp.get(), file_arch)) + { + result.AppendErrorWithFormat("invalid architecture '%s'", m_file_options.m_arch_str.c_str()); + result.SetStatus (eReturnStatusFailed); + return false; + } + } if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation()) { result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path); result.SetStatus (eReturnStatusFailed); - return result.Succeeded(); + return false; } TargetSP target_sp; - Debugger &debugger = m_interpreter.GetDebugger(); - Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, m_file_options.m_arch, true, target_sp); + error = debugger.GetTargetList().CreateTarget (debugger, file_spec, file_arch, true, target_sp); if (target_sp) { Modified: lldb/trunk/source/Commands/CommandObjectFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.h?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.h (original) +++ lldb/trunk/source/Commands/CommandObjectFile.h Wed Apr 13 17:47:15 2011 @@ -26,37 +26,35 @@ // CommandObjectFile //------------------------------------------------------------------------- - class FileOptionGroup : public OptionGroup - { - public: - - FileOptionGroup (); - - virtual - ~FileOptionGroup (); - - - virtual uint32_t - GetNumDefinitions (); - - virtual const OptionDefinition* - GetDefinitions (); - - virtual Error - SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_value); - - virtual void - OptionParsingStarting (CommandInterpreter &interpreter); - - virtual Error - OptionParsingFinished (CommandInterpreter &interpreter); - - ArchSpec m_arch; - lldb::PlatformSP m_arch_platform_sp; // The platform that was used to resolve m_arch - std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture - }; +class FileOptionGroup : public OptionGroup +{ +public: + + FileOptionGroup (); + + virtual + ~FileOptionGroup (); + + + virtual uint32_t + GetNumDefinitions (); + + virtual const OptionDefinition* + GetDefinitions (); + + virtual Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + virtual void + OptionParsingStarting (CommandInterpreter &interpreter); + + bool + GetArchitecture (Platform *platform, ArchSpec &arch); + + std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture +}; class CommandObjectFile : public CommandObject { Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectLog.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectLog.cpp Wed Apr 13 17:47:15 2011 @@ -42,16 +42,6 @@ using namespace lldb_private; -static LogChannelSP -GetLogChannelPluginForChannel (const char *channel) -{ - std::string log_channel_plugin_name(channel); - log_channel_plugin_name += LogChannel::GetPluginSuffix(); - LogChannelSP log_channel_sp (LogChannel::FindPlugin (log_channel_plugin_name.c_str())); - return log_channel_sp; -} - - class CommandObjectLogEnable : public CommandObject { public: @@ -99,6 +89,27 @@ return &m_options; } +// int +// HandleArgumentCompletion (Args &input, +// int &cursor_index, +// int &cursor_char_position, +// OptionElementVector &opt_element_vector, +// int match_start_point, +// int max_return_elements, +// bool &word_complete, +// StringList &matches) +// { +// std::string completion_str (input.GetArgumentAtIndex(cursor_index)); +// completion_str.erase (cursor_char_position); +// +// if (cursor_index == 1) +// { +// // +// Log::AutoCompleteChannelName (completion_str.c_str(), matches); +// } +// return matches.GetSize(); +// } +// virtual bool Execute (Args& args, CommandReturnObject &result) @@ -141,7 +152,7 @@ } else { - LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str())); + LogChannelSP log_channel_sp (LogChannel::FindPlugin (channel.c_str())); if (log_channel_sp) { if (log_channel_sp->Enable (log_stream_sp, log_options, &result.GetErrorStream(), args)) @@ -314,7 +325,7 @@ } else { - LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str())); + LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str())); if (log_channel_sp) { log_channel_sp->Disable(args, &result.GetErrorStream()); @@ -388,7 +399,7 @@ } else { - LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str())); + LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str())); if (log_channel_sp) { log_channel_sp->ListCategories(&result.GetOutputStream()); Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Wed Apr 13 17:47:15 2011 @@ -29,44 +29,31 @@ PlatformSP -PlatformOptionGroup::CreatePlatformWithOptions (CommandInterpreter &interpreter, - const char *platform_name, - bool select, - Error& error) +PlatformOptionGroup::CreatePlatformWithOptions (CommandInterpreter &interpreter, bool select, Error& error) { - if (platform_name && platform_name[0]) + PlatformSP platform_sp; + if (!platform_name.empty()) { - if (platform_sp) - { - error.SetErrorString ("platform can't be set more than once in a command"); - return PlatformSP(); - } - - platform_sp = Platform::Create (platform_name, error); + platform_sp = Platform::Create (platform_name.c_str(), error); if (platform_sp) { - interpreter.GetDebugger().GetPlatformList().Append (platform_sp, select); - if (os_version_major != UINT32_MAX) - { - platform_sp->SetOSVersion (os_version_major, - os_version_minor, - os_version_update); - } + interpreter.GetDebugger().GetPlatformList().Append (platform_sp, select); + if (os_version_major != UINT32_MAX) + { + platform_sp->SetOSVersion (os_version_major, + os_version_minor, + os_version_update); + } } } - else - { - error.SetErrorString ("invalid platform name"); - platform_sp.reset(); - } return platform_sp; } void PlatformOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter) { - platform_sp.reset(); + platform_name.clear(); os_version_major = UINT32_MAX; os_version_minor = UINT32_MAX; os_version_update = UINT32_MAX; @@ -75,7 +62,7 @@ static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "platform" , 'p', required_argument, NULL, 0, eArgTypeNone, "Specify name of the platform to use for this target, creating the platform if necessary."}, + { LLDB_OPT_SET_ALL, false, "platform" , 'p', required_argument, NULL, 0, eArgTypePlatform, "Specify name of the platform to use for this target, creating the platform if necessary."}, { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." } }; @@ -112,19 +99,12 @@ switch (short_option) { case 'p': - CreatePlatformWithOptions (interpreter, option_arg, true, error); + platform_name.assign (option_arg); break; case 'v': if (Args::StringToVersion (option_arg, os_version_major, os_version_minor, os_version_update) == option_arg) - { error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg); - } - else - { - if (platform_sp) - platform_sp->SetOSVersion (os_version_major, os_version_minor, os_version_update); - } break; default: @@ -149,7 +129,7 @@ m_option_group (interpreter), m_platform_options (false) // Don't include the "--platform" option by passing false { - m_option_group.Append (&m_platform_options); + m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, 1); m_option_group.Finalize(); } @@ -161,16 +141,31 @@ virtual bool Execute (Args& args, CommandReturnObject &result) { - Error error; if (args.GetArgumentCount() == 1) { - const bool select = true; - PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, - args.GetArgumentAtIndex (0), - select, - error)); - if (platform_sp) - platform_sp->GetStatus (result.GetOutputStream()); + const char *platform_name = args.GetArgumentAtIndex (0); + if (platform_name && platform_name[0]) + { + const bool select = true; + m_platform_options.platform_name.assign (platform_name); + Error error; + PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, select, error)); + if (platform_sp) + { + platform_sp->GetStatus (result.GetOutputStream()); + result.SetStatus (eReturnStatusSuccessFinishResult); + } + else + { + result.AppendError(error.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + result.AppendError ("invalid platform name"); + result.SetStatus (eReturnStatusFailed); + } } else { Modified: lldb/trunk/source/Commands/CommandObjectPlatform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.h?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPlatform.h (original) +++ lldb/trunk/source/Commands/CommandObjectPlatform.h Wed Apr 13 17:47:15 2011 @@ -49,11 +49,11 @@ public: PlatformOptionGroup (bool include_platform_option) : - m_include_platform_option (include_platform_option), - platform_sp (), + platform_name (), os_version_major (UINT32_MAX), os_version_minor (UINT32_MAX), - os_version_update (UINT32_MAX) + os_version_update (UINT32_MAX), + m_include_platform_option (include_platform_option) { } @@ -74,17 +74,16 @@ const char *option_value); lldb::PlatformSP - CreatePlatformWithOptions (CommandInterpreter &interpreter, - const char *platform_name, - bool select, - Error& error); + CreatePlatformWithOptions (CommandInterpreter &interpreter, + bool select, + Error &error); virtual void OptionParsingStarting (CommandInterpreter &interpreter); // Instance variables to hold the values for command options. - lldb::PlatformSP platform_sp; + std::string platform_name; uint32_t os_version_major; uint32_t os_version_minor; uint32_t os_version_update; Modified: lldb/trunk/source/Core/ArchSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Core/ArchSpec.cpp (original) +++ lldb/trunk/source/Core/ArchSpec.cpp Wed Apr 13 17:47:15 2011 @@ -79,11 +79,11 @@ { eByteOrderLittle, 4, 4, 4, llvm::Triple::sparc , ArchSpec::eCore_sparc_generic , "sparc" }, { eByteOrderLittle, 8, 4, 4, llvm::Triple::sparcv9, ArchSpec::eCore_sparc9_generic , "sparcv9" }, - { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i386 , "i386" }, - { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486 , "i486" }, - { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486sx , "i486sx" }, + { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i386 , "i386" }, + { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486 , "i486" }, + { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86 , ArchSpec::eCore_x86_32_i486sx , "i486sx" }, - { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64 , "x86_64" } + { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64 , "x86_64" } }; struct ArchDefinitionEntry @@ -104,6 +104,28 @@ }; +uint32_t +ArchSpec::AutoComplete (const char *name, StringList &matches) +{ + uint32_t i; + if (name && name[0]) + { + for (i = 0; i < ArchSpec::kNumCores; ++i) + { + if (NameMatches(g_core_definitions[i].name, eNameMatchStartsWith, name)) + matches.AppendString (g_core_definitions[i].name); + } + } + else + { + for (i = 0; i < ArchSpec::kNumCores; ++i) + matches.AppendString (g_core_definitions[i].name); + } + return matches.GetSize(); +} + + + #define CPU_ANY (UINT32_MAX) //===----------------------------------------------------------------------===// Modified: lldb/trunk/source/Core/Log.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Core/Log.cpp (original) +++ lldb/trunk/source/Core/Log.cpp Wed Apr 13 17:47:15 2011 @@ -382,6 +382,27 @@ } void +Log::AutoCompleteChannelName (const char *channel_name, StringList &matches) +{ + LogChannelMap &map = GetChannelMap (); + LogChannelMapIter pos, end = map.end(); + for (pos = map.begin(); pos != end; ++pos) + { + const char *pos_channel_name = pos->first.GetCString(); + if (channel_name && channel_name[0]) + { + if (NameMatches (channel_name, eNameMatchStartsWith, pos_channel_name)) + { + matches.AppendString(pos_channel_name); + } + } + else + matches.AppendString(pos_channel_name); + + } +} + +void Log::DisableAllLogChannels (Stream *feedback_strm) { CallbackMap &callback_map = GetCallbackMap (); @@ -499,10 +520,4 @@ { } -const char * -LogChannel::GetPluginSuffix () -{ - return ".log-channel"; -} - Modified: lldb/trunk/source/Core/PluginManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Core/PluginManager.cpp (original) +++ lldb/trunk/source/Core/PluginManager.cpp Wed Apr 13 17:47:15 2011 @@ -19,6 +19,8 @@ #include "lldb/Host/Host.h" #include "lldb/Host/Mutex.h" +#include "llvm/ADT/StringRef.h" + using namespace lldb; using namespace lldb_private; @@ -256,7 +258,7 @@ { ABIInstance instance; assert (name && name[0]); - instance.name = name; + instance.name.assign (name); if (description && description[0]) instance.description = description; instance.create_callback = create_callback; @@ -293,7 +295,6 @@ { Mutex::Locker locker (GetABIInstancesMutex ()); ABIInstances &instances = GetABIInstances (); - if (idx < instances.size()) return instances[idx].create_callback; return NULL; @@ -305,13 +306,13 @@ if (name && name[0]) { Mutex::Locker locker (GetABIInstancesMutex ()); - std::string ss_name(name); + llvm::StringRef name_sref(name); ABIInstances &instances = GetABIInstances (); ABIInstances::iterator pos, end = instances.end(); for (pos = instances.begin(); pos != end; ++ pos) { - if (pos->name == ss_name) + if (name_sref.equals (pos->name)) return pos->create_callback; } } @@ -338,50 +339,19 @@ typedef std::vector DisassemblerInstances; -static bool -AccessDisassemblerInstances (PluginAction action, DisassemblerInstance &instance, uint32_t index) +static Mutex & +GetDisassemblerMutex () { - static DisassemblerInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - DisassemblerInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; - - default: - break; - } - return false; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; } +static DisassemblerInstances & +GetDisassemblerInstances () +{ + static DisassemblerInstances g_instances; + return g_instances; +} bool PluginManager::RegisterPlugin @@ -399,7 +369,9 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessDisassemblerInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetDisassemblerMutex ()); + GetDisassemblerInstances ().push_back (instance); + return true; } return false; } @@ -409,9 +381,18 @@ { if (create_callback) { - DisassemblerInstance instance; - instance.create_callback = create_callback; - return AccessDisassemblerInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetDisassemblerMutex ()); + DisassemblerInstances &instances = GetDisassemblerInstances (); + + DisassemblerInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -419,9 +400,10 @@ DisassemblerCreateInstance PluginManager::GetDisassemblerCreateCallbackAtIndex (uint32_t idx) { - DisassemblerInstance instance; - if (AccessDisassemblerInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetDisassemblerMutex ()); + DisassemblerInstances &instances = GetDisassemblerInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } @@ -430,12 +412,15 @@ { if (name && name[0]) { - DisassemblerInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessDisassemblerInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetDisassemblerMutex ()); + DisassemblerInstances &instances = GetDisassemblerInstances (); + + DisassemblerInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -462,48 +447,19 @@ typedef std::vector DynamicLoaderInstances; -static bool -AccessDynamicLoaderInstances (PluginAction action, DynamicLoaderInstance &instance, uint32_t index) -{ - static DynamicLoaderInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - DynamicLoaderInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; +static Mutex & +GetDynamicLoaderMutex () +{ + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} - default: - break; - } - return false; +static DynamicLoaderInstances & +GetDynamicLoaderInstances () +{ + static DynamicLoaderInstances g_instances; + return g_instances; } @@ -523,7 +479,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessDynamicLoaderInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetDynamicLoaderMutex ()); + GetDynamicLoaderInstances ().push_back (instance); } return false; } @@ -533,9 +490,18 @@ { if (create_callback) { - DynamicLoaderInstance instance; - instance.create_callback = create_callback; - return AccessDynamicLoaderInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetDynamicLoaderMutex ()); + DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); + + DynamicLoaderInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -543,9 +509,10 @@ DynamicLoaderCreateInstance PluginManager::GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx) { - DynamicLoaderInstance instance; - if (AccessDynamicLoaderInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetDynamicLoaderMutex ()); + DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } @@ -554,12 +521,15 @@ { if (name && name[0]) { - DynamicLoaderInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessDynamicLoaderInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetDynamicLoaderMutex ()); + DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); + + DynamicLoaderInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -584,48 +554,18 @@ typedef std::vector EmulateInstructionInstances; -static bool -AccessEmulateInstructionInstances (PluginAction action, EmulateInstructionInstance &instance, uint32_t index) +static Mutex & +GetEmulateInstructionMutex () { - static EmulateInstructionInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - EmulateInstructionInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; - - default: - break; - } - return false; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} + +static EmulateInstructionInstances & +GetEmulateInstructionInstances () +{ + static EmulateInstructionInstances g_instances; + return g_instances; } @@ -645,7 +585,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessEmulateInstructionInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetEmulateInstructionMutex ()); + GetEmulateInstructionInstances ().push_back (instance); } return false; } @@ -655,9 +596,18 @@ { if (create_callback) { - EmulateInstructionInstance instance; - instance.create_callback = create_callback; - return AccessEmulateInstructionInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetEmulateInstructionMutex ()); + EmulateInstructionInstances &instances = GetEmulateInstructionInstances (); + + EmulateInstructionInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -665,9 +615,10 @@ EmulateInstructionCreateInstance PluginManager::GetEmulateInstructionCreateCallbackAtIndex (uint32_t idx) { - EmulateInstructionInstance instance; - if (AccessEmulateInstructionInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetEmulateInstructionMutex ()); + EmulateInstructionInstances &instances = GetEmulateInstructionInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } @@ -676,12 +627,15 @@ { if (name && name[0]) { - EmulateInstructionInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessEmulateInstructionInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetEmulateInstructionMutex ()); + EmulateInstructionInstances &instances = GetEmulateInstructionInstances (); + + EmulateInstructionInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -707,50 +661,19 @@ typedef std::vector LanguageRuntimeInstances; -static bool -AccessLanguageRuntimeInstances (PluginAction action, LanguageRuntimeInstance &instance, uint32_t index) +static Mutex & +GetLanguageRuntimeMutex () { - static LanguageRuntimeInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - LanguageRuntimeInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; - - default: - break; - } - return false; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; } +static LanguageRuntimeInstances & +GetLanguageRuntimeInstances () +{ + static LanguageRuntimeInstances g_instances; + return g_instances; +} bool PluginManager::RegisterPlugin @@ -768,7 +691,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessLanguageRuntimeInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetLanguageRuntimeMutex ()); + GetLanguageRuntimeInstances ().push_back (instance); } return false; } @@ -778,9 +702,18 @@ { if (create_callback) { - LanguageRuntimeInstance instance; - instance.create_callback = create_callback; - return AccessLanguageRuntimeInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetLanguageRuntimeMutex ()); + LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); + + LanguageRuntimeInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -788,9 +721,10 @@ LanguageRuntimeCreateInstance PluginManager::GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx) { - LanguageRuntimeInstance instance; - if (AccessLanguageRuntimeInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetLanguageRuntimeMutex ()); + LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } @@ -799,12 +733,15 @@ { if (name && name[0]) { - LanguageRuntimeInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessLanguageRuntimeInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetLanguageRuntimeMutex ()); + LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); + + LanguageRuntimeInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -828,48 +765,18 @@ typedef std::vector ObjectFileInstances; -static bool -AccessObjectFileInstances (PluginAction action, ObjectFileInstance &instance, uint32_t index) +static Mutex & +GetObjectFileMutex () { - static ObjectFileInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - ObjectFileInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} - default: - break; - } - return false; +static ObjectFileInstances & +GetObjectFileInstances () +{ + static ObjectFileInstances g_instances; + return g_instances; } @@ -889,7 +796,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessObjectFileInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetObjectFileMutex ()); + GetObjectFileInstances ().push_back (instance); } return false; } @@ -899,9 +807,18 @@ { if (create_callback) { - ObjectFileInstance instance; - instance.create_callback = create_callback; - return AccessObjectFileInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetObjectFileMutex ()); + ObjectFileInstances &instances = GetObjectFileInstances (); + + ObjectFileInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -909,22 +826,27 @@ ObjectFileCreateInstance PluginManager::GetObjectFileCreateCallbackAtIndex (uint32_t idx) { - ObjectFileInstance instance; - if (AccessObjectFileInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetObjectFileMutex ()); + ObjectFileInstances &instances = GetObjectFileInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } + ObjectFileCreateInstance PluginManager::GetObjectFileCreateCallbackForPluginName (const char *name) { if (name && name[0]) { - ObjectFileInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessObjectFileInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetObjectFileMutex ()); + ObjectFileInstances &instances = GetObjectFileInstances (); + + ObjectFileInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -950,50 +872,19 @@ typedef std::vector ObjectContainerInstances; -static bool -AccessObjectContainerInstances (PluginAction action, ObjectContainerInstance &instance, uint32_t index) +static Mutex & +GetObjectContainerMutex () { - static ObjectContainerInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - ObjectContainerInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; - - default: - break; - } - return false; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; } +static ObjectContainerInstances & +GetObjectContainerInstances () +{ + static ObjectContainerInstances g_instances; + return g_instances; +} bool PluginManager::RegisterPlugin @@ -1011,7 +902,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessObjectContainerInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetObjectContainerMutex ()); + GetObjectContainerInstances ().push_back (instance); } return false; } @@ -1021,9 +913,18 @@ { if (create_callback) { - ObjectContainerInstance instance; - instance.create_callback = create_callback; - return AccessObjectContainerInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetObjectContainerMutex ()); + ObjectContainerInstances &instances = GetObjectContainerInstances (); + + ObjectContainerInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -1031,22 +932,27 @@ ObjectContainerCreateInstance PluginManager::GetObjectContainerCreateCallbackAtIndex (uint32_t idx) { - ObjectContainerInstance instance; - if (AccessObjectContainerInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetObjectContainerMutex ()); + ObjectContainerInstances &instances = GetObjectContainerInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } + ObjectContainerCreateInstance PluginManager::GetObjectContainerCreateCallbackForPluginName (const char *name) { if (name && name[0]) { - ObjectContainerInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessObjectContainerInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetObjectContainerMutex ()); + ObjectContainerInstances &instances = GetObjectContainerInstances (); + + ObjectContainerInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -1054,9 +960,9 @@ #pragma mark LogChannel -struct LogChannelInstance +struct LogInstance { - LogChannelInstance() : + LogInstance() : name(), description(), create_callback(NULL) @@ -1068,53 +974,24 @@ LogChannelCreateInstance create_callback; }; -typedef std::vector LogChannelInstances; +typedef std::vector LogInstances; -static bool -AccessLogChannelInstances (PluginAction action, LogChannelInstance &instance, uint32_t index) +static Mutex & +GetLogMutex () { - static LogChannelInstances g_plugin_instances; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - LogChannelInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; - - default: - break; - } - return false; +static LogInstances & +GetLogInstances () +{ + static LogInstances g_instances; + return g_instances; } + bool PluginManager::RegisterPlugin ( @@ -1125,13 +1002,14 @@ { if (create_callback) { - LogChannelInstance instance; + LogInstance instance; assert (name && name[0]); instance.name = name; if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessLogChannelInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetLogMutex ()); + GetLogInstances ().push_back (instance); } return false; } @@ -1141,9 +1019,18 @@ { if (create_callback) { - LogChannelInstance instance; - instance.create_callback = create_callback; - return AccessLogChannelInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetLogMutex ()); + LogInstances &instances = GetLogInstances (); + + LogInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -1151,9 +1038,10 @@ const char * PluginManager::GetLogChannelCreateNameAtIndex (uint32_t idx) { - LogChannelInstance instance; - if (AccessLogChannelInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.name.c_str(); + Mutex::Locker locker (GetLogMutex ()); + LogInstances &instances = GetLogInstances (); + if (idx < instances.size()) + return instances[idx].name.c_str(); return NULL; } @@ -1161,9 +1049,10 @@ LogChannelCreateInstance PluginManager::GetLogChannelCreateCallbackAtIndex (uint32_t idx) { - LogChannelInstance instance; - if (AccessLogChannelInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetLogMutex ()); + LogInstances &instances = GetLogInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } @@ -1172,12 +1061,15 @@ { if (name && name[0]) { - LogChannelInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessLogChannelInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetLogMutex ()); + LogInstances &instances = GetLogInstances (); + + LogInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -1215,6 +1107,7 @@ return g_platform_instances; } + bool PluginManager::RegisterPlugin (const char *name, const char *description, @@ -1240,9 +1133,9 @@ PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx) { Mutex::Locker locker (GetPlatformInstancesMutex ()); - PlatformInstances &platform_instances = GetPlatformInstances (); - if (idx < platform_instances.size()) - return platform_instances[idx].name.c_str(); + PlatformInstances &instances = GetPlatformInstances (); + if (idx < instances.size()) + return instances[idx].name.c_str(); return NULL; } @@ -1250,9 +1143,9 @@ PluginManager::GetPlatformPluginDescriptionAtIndex (uint32_t idx) { Mutex::Locker locker (GetPlatformInstancesMutex ()); - PlatformInstances &platform_instances = GetPlatformInstances (); - if (idx < platform_instances.size()) - return platform_instances[idx].description.c_str(); + PlatformInstances &instances = GetPlatformInstances (); + if (idx < instances.size()) + return instances[idx].description.c_str(); return NULL; } @@ -1262,14 +1155,14 @@ if (create_callback) { Mutex::Locker locker (GetPlatformInstancesMutex ()); - PlatformInstances &platform_instances = GetPlatformInstances (); + PlatformInstances &instances = GetPlatformInstances (); - PlatformInstances::iterator pos, end = platform_instances.end(); - for (pos = platform_instances.begin(); pos != end; ++ pos) + PlatformInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { if (pos->create_callback == create_callback) { - platform_instances.erase(pos); + instances.erase(pos); return true; } } @@ -1281,9 +1174,9 @@ PluginManager::GetPlatformCreateCallbackAtIndex (uint32_t idx) { Mutex::Locker locker (GetPlatformInstancesMutex ()); - PlatformInstances &platform_instances = GetPlatformInstances (); - if (idx < platform_instances.size()) - return platform_instances[idx].create_callback; + PlatformInstances &instances = GetPlatformInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } @@ -1293,19 +1186,39 @@ if (name && name[0]) { Mutex::Locker locker (GetPlatformInstancesMutex ()); - std::string ss_name(name); - PlatformInstances &platform_instances = GetPlatformInstances (); + PlatformInstances &instances = GetPlatformInstances (); + llvm::StringRef name_sref(name); - PlatformInstances::iterator pos, end = platform_instances.end(); - for (pos = platform_instances.begin(); pos != end; ++ pos) + PlatformInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (pos->name == ss_name) + if (name_sref.equals (name)) return pos->create_callback; } } return NULL; } +uint32_t +PluginManager::AutoCompletePlatformName (const char *name, StringList &matches) +{ + if (name && name[0]) + { + Mutex::Locker locker (GetPlatformInstancesMutex ()); + PlatformInstances &instances = GetPlatformInstances (); + llvm::StringRef name_sref(name); + + PlatformInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + const char *plugin_name = pos->name.c_str(); + if (name_sref.startswith(plugin_name)) + matches.AppendString (plugin_name); + } + } + return matches.GetSize(); +} + #pragma mark Process struct ProcessInstance @@ -1324,48 +1237,18 @@ typedef std::vector ProcessInstances; -static bool -AccessProcessInstances (PluginAction action, ProcessInstance &instance, uint32_t index) +static Mutex & +GetProcessMutex () { - static ProcessInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - ProcessInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; - - default: - break; - } - return false; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} + +static ProcessInstances & +GetProcessInstances () +{ + static ProcessInstances g_instances; + return g_instances; } @@ -1385,7 +1268,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessProcessInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetProcessMutex ()); + GetProcessInstances ().push_back (instance); } return false; } @@ -1393,18 +1277,20 @@ const char * PluginManager::GetProcessPluginNameAtIndex (uint32_t idx) { - ProcessInstance instance; - if (AccessProcessInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.name.c_str(); + Mutex::Locker locker (GetProcessMutex ()); + ProcessInstances &instances = GetProcessInstances (); + if (idx < instances.size()) + return instances[idx].name.c_str(); return NULL; } const char * PluginManager::GetProcessPluginDescriptionAtIndex (uint32_t idx) { - ProcessInstance instance; - if (AccessProcessInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.description.c_str(); + Mutex::Locker locker (GetProcessMutex ()); + ProcessInstances &instances = GetProcessInstances (); + if (idx < instances.size()) + return instances[idx].description.c_str(); return NULL; } @@ -1413,9 +1299,18 @@ { if (create_callback) { - ProcessInstance instance; - instance.create_callback = create_callback; - return AccessProcessInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetProcessMutex ()); + ProcessInstances &instances = GetProcessInstances (); + + ProcessInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -1423,23 +1318,28 @@ ProcessCreateInstance PluginManager::GetProcessCreateCallbackAtIndex (uint32_t idx) { - ProcessInstance instance; - if (AccessProcessInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetProcessMutex ()); + ProcessInstances &instances = GetProcessInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } + ProcessCreateInstance PluginManager::GetProcessCreateCallbackForPluginName (const char *name) { if (name && name[0]) { - ProcessInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessProcessInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetProcessMutex ()); + ProcessInstances &instances = GetProcessInstances (); + + ProcessInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -1463,48 +1363,18 @@ typedef std::vector SymbolFileInstances; -static bool -AccessSymbolFileInstances (PluginAction action, SymbolFileInstance &instance, uint32_t index) +static Mutex & +GetSymbolFileMutex () { - static SymbolFileInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - SymbolFileInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} - default: - break; - } - return false; +static SymbolFileInstances & +GetSymbolFileInstances () +{ + static SymbolFileInstances g_instances; + return g_instances; } @@ -1524,7 +1394,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessSymbolFileInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetSymbolFileMutex ()); + GetSymbolFileInstances ().push_back (instance); } return false; } @@ -1534,9 +1405,18 @@ { if (create_callback) { - SymbolFileInstance instance; - instance.create_callback = create_callback; - return AccessSymbolFileInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetSymbolFileMutex ()); + SymbolFileInstances &instances = GetSymbolFileInstances (); + + SymbolFileInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -1544,22 +1424,27 @@ SymbolFileCreateInstance PluginManager::GetSymbolFileCreateCallbackAtIndex (uint32_t idx) { - SymbolFileInstance instance; - if (AccessSymbolFileInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetSymbolFileMutex ()); + SymbolFileInstances &instances = GetSymbolFileInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } + SymbolFileCreateInstance PluginManager::GetSymbolFileCreateCallbackForPluginName (const char *name) { if (name && name[0]) { - SymbolFileInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessSymbolFileInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetSymbolFileMutex ()); + SymbolFileInstances &instances = GetSymbolFileInstances (); + + SymbolFileInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -1585,48 +1470,18 @@ typedef std::vector SymbolVendorInstances; -static bool -AccessSymbolVendorInstances (PluginAction action, SymbolVendorInstance &instance, uint32_t index) +static Mutex & +GetSymbolVendorMutex () { - static SymbolVendorInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - SymbolVendorInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} - default: - break; - } - return false; +static SymbolVendorInstances & +GetSymbolVendorInstances () +{ + static SymbolVendorInstances g_instances; + return g_instances; } bool @@ -1645,7 +1500,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessSymbolVendorInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetSymbolVendorMutex ()); + GetSymbolVendorInstances ().push_back (instance); } return false; } @@ -1655,9 +1511,18 @@ { if (create_callback) { - SymbolVendorInstance instance; - instance.create_callback = create_callback; - return AccessSymbolVendorInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetSymbolVendorMutex ()); + SymbolVendorInstances &instances = GetSymbolVendorInstances (); + + SymbolVendorInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -1665,23 +1530,28 @@ SymbolVendorCreateInstance PluginManager::GetSymbolVendorCreateCallbackAtIndex (uint32_t idx) { - SymbolVendorInstance instance; - if (AccessSymbolVendorInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetSymbolVendorMutex ()); + SymbolVendorInstances &instances = GetSymbolVendorInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } + SymbolVendorCreateInstance PluginManager::GetSymbolVendorCreateCallbackForPluginName (const char *name) { if (name && name[0]) { - SymbolVendorInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessSymbolVendorInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetSymbolVendorMutex ()); + SymbolVendorInstances &instances = GetSymbolVendorInstances (); + + SymbolVendorInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -1706,48 +1576,18 @@ typedef std::vector UnwindAssemblyProfilerInstances; -static bool -AccessUnwindAssemblyProfilerInstances (PluginAction action, UnwindAssemblyProfilerInstance &instance, uint32_t index) +static Mutex & +GetUnwindAssemblyProfilerMutex () { - static UnwindAssemblyProfilerInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - UnwindAssemblyProfilerInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} - default: - break; - } - return false; +static UnwindAssemblyProfilerInstances & +GetUnwindAssemblyProfilerInstances () +{ + static UnwindAssemblyProfilerInstances g_instances; + return g_instances; } bool @@ -1766,7 +1606,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessUnwindAssemblyProfilerInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ()); + GetUnwindAssemblyProfilerInstances ().push_back (instance); } return false; } @@ -1776,9 +1617,18 @@ { if (create_callback) { - UnwindAssemblyProfilerInstance instance; - instance.create_callback = create_callback; - return AccessUnwindAssemblyProfilerInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ()); + UnwindAssemblyProfilerInstances &instances = GetUnwindAssemblyProfilerInstances (); + + UnwindAssemblyProfilerInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -1786,23 +1636,28 @@ UnwindAssemblyProfilerCreateInstance PluginManager::GetUnwindAssemblyProfilerCreateCallbackAtIndex (uint32_t idx) { - UnwindAssemblyProfilerInstance instance; - if (AccessUnwindAssemblyProfilerInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ()); + UnwindAssemblyProfilerInstances &instances = GetUnwindAssemblyProfilerInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } + UnwindAssemblyProfilerCreateInstance PluginManager::GetUnwindAssemblyProfilerCreateCallbackForPluginName (const char *name) { if (name && name[0]) { - UnwindAssemblyProfilerInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessUnwindAssemblyProfilerInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ()); + UnwindAssemblyProfilerInstances &instances = GetUnwindAssemblyProfilerInstances (); + + UnwindAssemblyProfilerInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -1826,50 +1681,21 @@ typedef std::vector ArchDefaultUnwindPlanInstances; -static bool -AccessArchDefaultUnwindPlanInstances (PluginAction action, ArchDefaultUnwindPlanInstance &instance, uint32_t index) +static Mutex & +GetArchDefaultUnwindPlanMutex () { - static ArchDefaultUnwindPlanInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - ArchDefaultUnwindPlanInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} - default: - break; - } - return false; +static ArchDefaultUnwindPlanInstances & +GetArchDefaultUnwindPlanInstances () +{ + static ArchDefaultUnwindPlanInstances g_instances; + return g_instances; } + bool PluginManager::RegisterPlugin ( @@ -1886,7 +1712,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessArchDefaultUnwindPlanInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ()); + GetArchDefaultUnwindPlanInstances ().push_back (instance); } return false; } @@ -1896,9 +1723,18 @@ { if (create_callback) { - ArchDefaultUnwindPlanInstance instance; - instance.create_callback = create_callback; - return AccessArchDefaultUnwindPlanInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ()); + ArchDefaultUnwindPlanInstances &instances = GetArchDefaultUnwindPlanInstances (); + + ArchDefaultUnwindPlanInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -1906,23 +1742,28 @@ ArchDefaultUnwindPlanCreateInstance PluginManager::GetArchDefaultUnwindPlanCreateCallbackAtIndex (uint32_t idx) { - ArchDefaultUnwindPlanInstance instance; - if (AccessArchDefaultUnwindPlanInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ()); + ArchDefaultUnwindPlanInstances &instances = GetArchDefaultUnwindPlanInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } + ArchDefaultUnwindPlanCreateInstance PluginManager::GetArchDefaultUnwindPlanCreateCallbackForPluginName (const char *name) { if (name && name[0]) { - ArchDefaultUnwindPlanInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessArchDefaultUnwindPlanInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ()); + ArchDefaultUnwindPlanInstances &instances = GetArchDefaultUnwindPlanInstances (); + + ArchDefaultUnwindPlanInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; @@ -1946,48 +1787,18 @@ typedef std::vector ArchVolatileRegsInstances; -static bool -AccessArchVolatileRegsInstances (PluginAction action, ArchVolatileRegsInstance &instance, uint32_t index) +static Mutex & +GetArchVolatileRegsMutex () { - static ArchVolatileRegsInstances g_plugin_instances; - - switch (action) - { - case ePluginRegisterInstance: - if (instance.create_callback) - { - g_plugin_instances.push_back (instance); - return true; - } - break; - - case ePluginUnregisterInstance: - if (instance.create_callback) - { - ArchVolatileRegsInstances::iterator pos, end = g_plugin_instances.end(); - for (pos = g_plugin_instances.begin(); pos != end; ++ pos) - { - if (pos->create_callback == instance.create_callback) - { - g_plugin_instances.erase(pos); - return true; - } - } - } - break; - - case ePluginGetInstanceAtIndex: - if (index < g_plugin_instances.size()) - { - instance = g_plugin_instances[index]; - return true; - } - break; + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} - default: - break; - } - return false; +static ArchVolatileRegsInstances & +GetArchVolatileRegsInstances () +{ + static ArchVolatileRegsInstances g_instances; + return g_instances; } bool @@ -2006,7 +1817,8 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - return AccessArchVolatileRegsInstances (ePluginRegisterInstance, instance, 0); + Mutex::Locker locker (GetArchVolatileRegsMutex ()); + GetArchVolatileRegsInstances ().push_back (instance); } return false; } @@ -2016,9 +1828,18 @@ { if (create_callback) { - ArchVolatileRegsInstance instance; - instance.create_callback = create_callback; - return AccessArchVolatileRegsInstances (ePluginUnregisterInstance, instance, 0); + Mutex::Locker locker (GetArchVolatileRegsMutex ()); + ArchVolatileRegsInstances &instances = GetArchVolatileRegsInstances (); + + ArchVolatileRegsInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (pos->create_callback == create_callback) + { + instances.erase(pos); + return true; + } + } } return false; } @@ -2026,9 +1847,10 @@ ArchVolatileRegsCreateInstance PluginManager::GetArchVolatileRegsCreateCallbackAtIndex (uint32_t idx) { - ArchVolatileRegsInstance instance; - if (AccessArchVolatileRegsInstances (ePluginGetInstanceAtIndex, instance, idx)) - return instance.create_callback; + Mutex::Locker locker (GetArchVolatileRegsMutex ()); + ArchVolatileRegsInstances &instances = GetArchVolatileRegsInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; return NULL; } @@ -2037,12 +1859,15 @@ { if (name && name[0]) { - ArchVolatileRegsInstance instance; - std::string ss_name(name); - for (uint32_t idx = 0; AccessArchVolatileRegsInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx) + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetArchVolatileRegsMutex ()); + ArchVolatileRegsInstances &instances = GetArchVolatileRegsInstances (); + + ArchVolatileRegsInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) { - if (instance.name == ss_name) - return instance.create_callback; + if (name_sref.equals (pos->name)) + return pos->create_callback; } } return NULL; Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Wed Apr 13 17:47:15 2011 @@ -650,7 +650,7 @@ { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, NULL, "A valid address in the target program's execution space." }, { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, NULL, "The name of an abbreviation (alias) for a debugger command." }, { eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, NULL, "Command options to be used as part of an alias (abbreviation) definition. (See 'help commands alias' for more information.)" }, - { eArgTypeArchitecture, "arch", CommandCompletions::eNoCompletion, NULL, "The architecture name, e.g. i386 or x86_64." }, + { eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, NULL, "The architecture name, e.g. i386 or x86_64." }, { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, NULL, "A Boolean value: 'true' or 'false'" }, { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, BreakpointIDHelpTextCallback, NULL }, { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, BreakpointIDRangeHelpTextCallback, NULL }, @@ -707,6 +707,7 @@ { eArgTypeValue, "value", CommandCompletions::eNoCompletion, NULL, "A value could be anything, depending on where and how it is used." }, { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeNone, "none", CommandCompletions::eNoCompletion, NULL, "No help available for this." }, + { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, NULL, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." } }; const CommandObject::ArgumentTableEntry* Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Wed Apr 13 17:47:15 2011 @@ -11,8 +11,9 @@ // C Includes // C++ Includes -#include #include +#include +#include // Other libraries and framework includes // Project includes @@ -853,7 +854,19 @@ // for that shared library. // FIXME: Do we want to also have an "OptionType" so we don't have to match string names? - uint32_t completion_mask = opt_defs[opt_defs_index].completionType; + uint32_t completion_mask = opt_defs[opt_defs_index].completion_type; + + if (completion_mask == 0) + { + lldb::CommandArgumentType option_arg_type = opt_defs[opt_defs_index].argument_type; + if (option_arg_type != eArgTypeNone) + { + CommandObject::ArgumentTableEntry *arg_entry = CommandObject::FindArgumentDataByType (opt_defs[opt_defs_index].argument_type); + if (arg_entry) + completion_mask = arg_entry->completion_type; + } + } + if (completion_mask & CommandCompletions::eSourceFileCompletion || completion_mask & CommandCompletions::eSymbolCompletion) { @@ -893,28 +906,21 @@ } - - -void -OptionGroupOptions::Append (OptionGroup* group) -{ - m_option_groups.push_back (group); - const OptionDefinition* group_option_defs = group->GetDefinitions (); - const uint32_t group_option_count = group->GetNumDefinitions(); - for (uint32_t i=0; iGetDefinitions (); const uint32_t group_option_count = group->GetNumDefinitions(); for (uint32_t i=0; iGetNumDefinitions(); - if (option_idx < curr_idx + num_group_definitions) - return (*pos)->SetOptionValue (m_interpreter, option_idx - curr_idx, option_value); - curr_idx += num_group_definitions; - } + assert (m_option_infos.size() + 1 == m_option_defs.size()); Error error; - error.SetErrorString ("invalid option index"); // Shouldn't happen... + if (option_idx < m_option_infos.size()) + { + error = m_option_infos[option_idx].option_group->SetOptionValue (m_interpreter, + m_option_infos[option_idx].option_index, + option_value); + + } + else + { + error.SetErrorString ("invalid option index"); // Shouldn't happen... + } return error; } void OptionGroupOptions::OptionParsingStarting () { - OptionGroupsType::iterator pos, end = m_option_groups.end(); - for (pos = m_option_groups.begin(); pos != end; ++pos) - (*pos)->OptionParsingStarting (m_interpreter); + std::set group_set; + OptionInfos::iterator pos, end = m_option_infos.end(); + for (pos = m_option_infos.begin(); pos != end; ++pos) + { + OptionGroup* group = pos->option_group; + if (group_set.find(group) == group_set.end()) + { + group->OptionParsingStarting (m_interpreter); + group_set.insert(group); + } + } } Error OptionGroupOptions::OptionParsingFinished () { + std::set group_set; Error error; - OptionGroupsType::iterator pos, end = m_option_groups.end(); - for (pos = m_option_groups.begin(); pos != end; ++pos) + OptionInfos::iterator pos, end = m_option_infos.end(); + for (pos = m_option_infos.begin(); pos != end; ++pos) { - error = (*pos)->OptionParsingFinished (m_interpreter); - if (error.Fail()) - return error; + OptionGroup* group = pos->option_group; + if (group_set.find(group) == group_set.end()) + { + error = group->OptionParsingFinished (m_interpreter); + group_set.insert(group); + if (error.Fail()) + return error; + } } return error; } Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Wed Apr 13 17:47:15 2011 @@ -80,7 +80,7 @@ PlatformMacOSX::GetShortPluginNameStatic (bool is_host) { if (is_host) - return "local-macosx"; + return Platform::GetHostPlatformName (); else return "remote-macosx"; } Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original) +++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Wed Apr 13 17:47:15 2011 @@ -312,7 +312,7 @@ break; } } - const uint32_t old_packet_timeout = m_gdb_client.SetPacketTimeout (3000); // TODO: lower this to 5 seconds prior to checkin!!! + const uint32_t old_packet_timeout = m_gdb_client.SetPacketTimeout (5); int arg_packet_err = m_gdb_client.SendArgumentsPacket (argv); m_gdb_client.SetPacketTimeout (old_packet_timeout); if (arg_packet_err == 0) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp Wed Apr 13 17:47:15 2011 @@ -54,16 +54,9 @@ const char * LogChannelDWARF::GetPluginNameStatic() { - static std::string g_plugin_name; - if (g_plugin_name.empty()) - { - g_plugin_name = SymbolFileDWARF::GetPluginNameStatic(); - g_plugin_name += LogChannel::GetPluginSuffix (); - } - return g_plugin_name.c_str(); + return SymbolFileDWARF::GetPluginNameStatic(); } - const char * LogChannelDWARF::GetPluginDescriptionStatic() { Modified: lldb/trunk/source/Target/Platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/source/Target/Platform.cpp (original) +++ lldb/trunk/source/Target/Platform.cpp Wed Apr 13 17:47:15 2011 @@ -46,6 +46,13 @@ return g_remote_connected_platforms; } + +const char * +Platform::GetHostPlatformName () +{ + return "host"; +} + //------------------------------------------------------------------ /// Get the native host platform plug-in. /// @@ -319,11 +326,8 @@ const char * Platform::GetHostname () { - if (IsHost() && m_name.empty()) - { - if (!Host::GetHostname(m_name)) - return "localhost"; - } + if (IsHost()) + return "localhost"; if (m_name.empty()) return NULL; Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=129483&r1=129482&r2=129483&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Wed Apr 13 17:47:15 2011 @@ -59,7 +59,7 @@ const char * long_option; // Full name for this option. char short_option; // Single character for this option. int option_has_arg; // no_argument, required_argument or optional_argument - uint32_t completionType; // Cookie the option class can use to do define the argument completion. + uint32_t completion_type; // Cookie the option class can use to do define the argument completion. lldb::CommandArgumentType argument_type; // Type of argument this option takes const char * usage_text; // Full text explaining what this options does and what (if any) argument to // pass it. From scallanan at apple.com Wed Apr 13 21:01:31 2011 From: scallanan at apple.com (Sean Callanan) Date: Thu, 14 Apr 2011 02:01:31 -0000 Subject: [Lldb-commits] [lldb] r129500 - in /lldb/trunk: llvm.zip scripts/build-llvm.pl source/Expression/ClangExpressionParser.cpp source/Expression/IRDynamicChecks.cpp source/Expression/IRForTarget.cpp Message-ID: <20110414020131.8A1622A6C12C@llvm.org> Author: spyffe Date: Wed Apr 13 21:01:31 2011 New Revision: 129500 URL: http://llvm.org/viewvc/llvm-project?rev=129500&view=rev Log: Updated LLVM to pick up fixes to the ARM instruction tables. Modified: lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/IRDynamicChecks.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=129500&r1=129499&r2=129500&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=129500&r1=129499&r2=129500&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Wed Apr 13 21:01:31 2011 @@ -26,7 +26,7 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "128303"; +our $llvm_revision = "129495"; our $llvm_source_dir = "$ENV{SRCROOT}"; our @archs = split (/\s+/, $ENV{ARCHS}); Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=129500&r1=129499&r2=129500&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Wed Apr 13 21:01:31 2011 @@ -244,10 +244,28 @@ // and other things that _are_ target specific really shouldn't just be // using the host triple. This needs to be fixed in a better way. if (target && target->GetArchitecture().IsValid()) - m_compiler->getTargetOpts().Triple = target->GetArchitecture().GetTriple().str(); + { + std::string triple = target->GetArchitecture().GetTriple().str(); + + int dash_count = 0; + for (int i = 0; i < triple.size(); ++i) + { + if (triple[i] == '-') + dash_count++; + if (dash_count == 3) + { + triple.resize(i); + break; + } + } + + m_compiler->getTargetOpts().Triple = triple; + } else + { m_compiler->getTargetOpts().Triple = llvm::sys::getHostTriple(); - + } + // 3. Set up various important bits of infrastructure. m_compiler->createDiagnostics(0, 0); Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=129500&r1=129499&r2=129500&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original) +++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Wed Apr 13 21:01:31 2011 @@ -18,6 +18,7 @@ #include "lldb/Target/StackFrame.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Module.h" Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=129500&r1=129499&r2=129500&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Wed Apr 13 21:01:31 2011 @@ -10,6 +10,7 @@ #include "lldb/Expression/IRForTarget.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Constants.h" #include "llvm/InstrTypes.h" #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" From johnny.chen at apple.com Thu Apr 14 17:20:37 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 14 Apr 2011 22:20:37 -0000 Subject: [Lldb-commits] [lldb] r129542 - in /lldb/trunk/test/inferior-crashing: ./ Makefile TestInferiorCrashing.py main.c Message-ID: <20110414222037.13BC72A6C12C@llvm.org> Author: johnny Date: Thu Apr 14 17:20:36 2011 New Revision: 129542 URL: http://llvm.org/viewvc/llvm-project?rev=129542&view=rev Log: Add a test to check that lldb reliably catches a crashing inferior (both command and Python API). Added: lldb/trunk/test/inferior-crashing/ lldb/trunk/test/inferior-crashing/Makefile lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py lldb/trunk/test/inferior-crashing/main.c Added: lldb/trunk/test/inferior-crashing/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/inferior-crashing/Makefile?rev=129542&view=auto ============================================================================== --- lldb/trunk/test/inferior-crashing/Makefile (added) +++ lldb/trunk/test/inferior-crashing/Makefile Thu Apr 14 17:20:36 2011 @@ -0,0 +1,5 @@ +LEVEL = ../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py?rev=129542&view=auto ============================================================================== --- lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py (added) +++ lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Thu Apr 14 17:20:36 2011 @@ -0,0 +1,79 @@ +"""Test that lldb reliably catches the inferior crashing.""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class CrashingInferiorTestCase(TestBase): + + mydir = "inferior-crashing" + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_inferior_crashing_dsym(self): + """Test that lldb reliably catches the inferior crashing (command).""" + self.buildDsym() + self.inferior_crashing() + + def test_inferior_crashing_dwarf(self): + """Test that lldb reliably catches the inferior crashing (command).""" + self.buildDwarf() + self.inferior_crashing() + + @python_api_test + def test_inferior_crashing_python(self): + """Test that lldb reliably catches the inferior crashing (Python API).""" + self.buildDefault() + self.inferior_crashing_python() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number of the crash. + self.line = line_number('main.c', '// Crash here.') + + def inferior_crashing(self): + """Inferior crashes upon launching; lldb should catch the event and stop.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be a bad access exception. + self.expect("thread list", STOPPED_DUE_TO_EXC_BAD_ACCESS, + substrs = ['state is stopped', + 'stop reason = EXC_BAD_ACCESS']) + + # And it should report the correct line number. + self.expect("thread backtrace", + substrs = ['stop reason = EXC_BAD_ACCESS', + 'main.c:%d' % self.line]) + + def inferior_crashing_python(self): + """Inferior crashes upon launching; lldb should catch the event and stop.""" + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Now launch the process, and do not stop at entry point. + # Both argv and envp are null. + self.process = target.LaunchSimple(None, None, os.getcwd()) + + import lldbutil + if self.process.GetState() != lldb.eStateStopped: + self.fail("Process should be in the 'stopped' state, " + "instead the actual state is: '%s'" % + lldbutil.StateTypeString(self.process.GetState())) + + thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonException) + if not thread: + self.fail("Fail to stop the thread due to exception") + + lldbutil.PrintStackTrace(thread) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/inferior-crashing/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/inferior-crashing/main.c?rev=129542&view=auto ============================================================================== --- lldb/trunk/test/inferior-crashing/main.c (added) +++ lldb/trunk/test/inferior-crashing/main.c Thu Apr 14 17:20:36 2011 @@ -0,0 +1,8 @@ +#include + +int main(int argc, const char* argv[]) +{ + int *null_ptr = 0; + printf("Hello, segfault!\n"); + printf("Now crash %d\n", *null_ptr); // Crash here. +} From johnny.chen at apple.com Thu Apr 14 17:24:12 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 14 Apr 2011 22:24:12 -0000 Subject: [Lldb-commits] [lldb] r129543 - /lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Message-ID: <20110414222412.2F6DA2A6C12C@llvm.org> Author: johnny Date: Thu Apr 14 17:24:12 2011 New Revision: 129543 URL: http://llvm.org/viewvc/llvm-project?rev=129543&view=rev Log: Rewording of assert message. Modified: lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Modified: lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py?rev=129543&r1=129542&r2=129543&view=diff ============================================================================== --- lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py (original) +++ lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Thu Apr 14 17:24:12 2011 @@ -68,7 +68,7 @@ thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonException) if not thread: - self.fail("Fail to stop the thread due to exception") + self.fail("Fail to stop the thread upon bad access exception") lldbutil.PrintStackTrace(thread) From wilsons at start.ca Fri Apr 15 08:40:54 2011 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 15 Apr 2011 09:40:54 -0400 Subject: [Lldb-commits] [PATCH] optimize address range coalescing Message-ID: <20110415134054.GA4932@fibrous.localdomain> DWARFDebugAranges::Sort() calls std::stable_sort() over a set of address ranges and then proceeds to collapse neighboring ranges together. One problem with the current implementation is that it does an incomplete job. When a pair of ranges are merged the next pair considered does not include the just-merged range. IOW, three consecutive ranges are never collapsed into one. Another problem is that for each range merged we are calling std::vector::erase() which "shifts" all remaining elements of the vector by one position on every merge. The end result (in the worst case) is a quadratic algorithm -- not good when the input vector is large. The following patch merges all consecutive ranges and removes the quadratic behavior. The implementation uses an auxiliary vector of indices in order to remember all ranges that can be dropped, then performs the coalescing of ranges in a single pass. Instrumenting DWARFDebugAranges::Sort() with a timer and loading LLDB in LLDB prior to this patch gives (on my prone-to-overheat 2GHz laptop): Current executable set to './lldb' (x86_64). (lldb) break set -n main Breakpoint created: 1: name = 'main', locations = 1 (lldb) log timers enable (lldb) r Process 12840 launched: '/home/steve/development/build/llvm-git/Debug+Asserts/bin/lldb' (x86_64) (lldb) Process 12840 stopped * thread #1: tid = 0x3228, 0x0000000000411fed lldb`main + 32 at Driver.cpp:1275, stop reason = breakpoint 1.1 1272 int 1273 main (int argc, char const *argv[], const char *envp[]) 1274 { -> 1275 SBDebugger::Initialize(); 1276 1277 SBHostOS::ThreadCreated (""); 1278 (lldb) log timers dump 17.027432000 sec for void DWARFDebugAranges::Sort() ... and after this patch: ... (lldb) log timers dump ... 0.154519000 sec for void DWARFDebugAranges::Sort() ... diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp index 8e3461d..2d69926 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp @@ -15,6 +15,7 @@ #include #include "lldb/Core/Stream.h" +#include "lldb/Core/Timer.h" #include "SymbolFileDWARF.h" #include "DWARFDebugInfo.h" @@ -290,36 +291,46 @@ DWARFDebugAranges::AppendRange (dw_offset_t offset, dw_addr_t low_pc, dw_addr_t void DWARFDebugAranges::Sort() -{ - // Sort our address range entries +{ + std::vector indices; + size_t end; + Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", + __PRETTY_FUNCTION__, this); + + // Sort our address range entries. std::stable_sort (m_aranges.begin(), m_aranges.end(), RangeLessThan); - // Merge any entries that have the same offset and same start/end address - RangeColl::iterator pos = m_aranges.begin(); - RangeColl::iterator end = m_aranges.end(); - while (pos != end) + // Merge all neighbouring ranges into a single range and remember the + // indices of all ranges merged. + end = m_aranges.size(); + for (size_t merge = 0, cursor = 1; cursor < end; ++cursor) { - RangeColl::iterator next_pos = pos + 1; - if (next_pos != end && - pos->offset == next_pos->offset && - pos->hi_pc == next_pos->lo_pc) + Range &r1 = m_aranges[merge]; + Range &r2 = m_aranges[cursor]; + + if (r1.hi_pc == r2.lo_pc && r1.offset == r2.offset) { - // We have found an entry whose end address it he same as the - // next entry's start address and the offsets are the same so - // we can merge these two entries. - pos->hi_pc = next_pos->hi_pc; - // Erase the next entry that wasn't needed - pos = m_aranges.erase (next_pos); - // Now recompute the end of the collection - end = m_aranges.end(); + r1.hi_pc = r2.hi_pc; + indices.push_back(cursor); } else - { - // Two entries have either different offsets or there are gaps - // in the address range, move along, nothing to see here. - pos = next_pos; - } + merge = cursor; } + + if (indices.empty()) + return; + + // Remove the merged ranges by shifting down all the keepers... + indices.push_back(m_aranges.size()); + end = indices.size(); + for (size_t target = indices[0], cursor = 1; cursor < end; ++cursor) + { + for (size_t i = indices[cursor - 1] + 1; i < indices[cursor]; ++i) + m_aranges[target++] = m_aranges[i]; + } + + // ...and drop the extra elements. + m_aranges.resize(m_aranges.size() - end + 1); } //---------------------------------------------------------------------- From johnny.chen at apple.com Fri Apr 15 11:44:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 15 Apr 2011 16:44:48 -0000 Subject: [Lldb-commits] [lldb] r129574 - /lldb/trunk/test/lldbtest.py Message-ID: <20110415164448.3CBE82A6C12C@llvm.org> Author: johnny Date: Fri Apr 15 11:44:48 2011 New Revision: 129574 URL: http://llvm.org/viewvc/llvm-project?rev=129574&view=rev Log: Forgot to check in this change with http://llvm.org/viewvc/llvm-project?view=rev&revision=129542. 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=129574&r1=129573&r2=129574&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Apr 15 11:44:48 2011 @@ -159,6 +159,8 @@ STEP_OUT_SUCCEEDED = "Thread step-out succeeded" +STOPPED_DUE_TO_EXC_BAD_ACCESS = "Process should be stopped due to bad access exception" + STOPPED_DUE_TO_BREAKPOINT = "Process should be stopped due to breakpoint" STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS = "%s, %s" % ( @@ -223,7 +225,7 @@ if line.find(string_to_match) != -1: # Found our match. return i+1 - raise Exception("Unable to find %s within file %s" % (string_to_match, filename)) + raise Exception("Unable to find '%s' within file %s" % (string_to_match, filename)) def pointer_size(): """Return the pointer size of the host system.""" From johnny.chen at apple.com Fri Apr 15 14:57:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 15 Apr 2011 12:57:24 -0700 Subject: [Lldb-commits] [PATCH] optimize address range coalescing In-Reply-To: <20110415134054.GA4932@fibrous.localdomain> References: <20110415134054.GA4932@fibrous.localdomain> Message-ID: <51F35474-7BB3-4B3A-8FDB-58B915E38C1F@apple.com> Hi Stephen, Greg is skiing somewhere right now... I modified your patch a tiny bit and will be committing it soon (it just passes the test suite). Thanks for the patch! Johnny On Apr 15, 2011, at 6:40 AM, Stephen Wilson wrote: > > DWARFDebugAranges::Sort() calls std::stable_sort() over a set of address ranges > and then proceeds to collapse neighboring ranges together. > > One problem with the current implementation is that it does an incomplete job. > When a pair of ranges are merged the next pair considered does not include the > just-merged range. IOW, three consecutive ranges are never collapsed into one. > > Another problem is that for each range merged we are calling > std::vector::erase() which "shifts" all remaining elements of the vector by one > position on every merge. The end result (in the worst case) is a quadratic > algorithm -- not good when the input vector is large. > > The following patch merges all consecutive ranges and removes the quadratic > behavior. The implementation uses an auxiliary vector of indices in order to > remember all ranges that can be dropped, then performs the coalescing of ranges > in a single pass. > > Instrumenting DWARFDebugAranges::Sort() with a timer and loading LLDB in LLDB > prior to this patch gives (on my prone-to-overheat 2GHz laptop): > > Current executable set to './lldb' (x86_64). > (lldb) break set -n main > Breakpoint created: 1: name = 'main', locations = 1 > (lldb) log timers enable > (lldb) r > Process 12840 launched: '/home/steve/development/build/llvm-git/Debug+Asserts/bin/lldb' (x86_64) > (lldb) Process 12840 stopped > * thread #1: tid = 0x3228, 0x0000000000411fed lldb`main + 32 at Driver.cpp:1275, stop reason = breakpoint 1.1 > 1272 int > 1273 main (int argc, char const *argv[], const char *envp[]) > 1274 { > -> 1275 SBDebugger::Initialize(); > 1276 > 1277 SBHostOS::ThreadCreated (""); > 1278 > > (lldb) log timers dump > 17.027432000 sec for void DWARFDebugAranges::Sort() > ... > > and after this patch: > > ... > (lldb) log timers dump > ... > 0.154519000 sec for void DWARFDebugAranges::Sort() > ... > > > > diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp > index 8e3461d..2d69926 100644 > --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp > +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp > @@ -15,6 +15,7 @@ > #include > > #include "lldb/Core/Stream.h" > +#include "lldb/Core/Timer.h" > > #include "SymbolFileDWARF.h" > #include "DWARFDebugInfo.h" > @@ -290,36 +291,46 @@ DWARFDebugAranges::AppendRange (dw_offset_t offset, dw_addr_t low_pc, dw_addr_t > > void > DWARFDebugAranges::Sort() > -{ > - // Sort our address range entries > +{ > + std::vector indices; > + size_t end; > + Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", > + __PRETTY_FUNCTION__, this); > + > + // Sort our address range entries. > std::stable_sort (m_aranges.begin(), m_aranges.end(), RangeLessThan); > > - // Merge any entries that have the same offset and same start/end address > - RangeColl::iterator pos = m_aranges.begin(); > - RangeColl::iterator end = m_aranges.end(); > - while (pos != end) > + // Merge all neighbouring ranges into a single range and remember the > + // indices of all ranges merged. > + end = m_aranges.size(); > + for (size_t merge = 0, cursor = 1; cursor < end; ++cursor) > { > - RangeColl::iterator next_pos = pos + 1; > - if (next_pos != end && > - pos->offset == next_pos->offset && > - pos->hi_pc == next_pos->lo_pc) > + Range &r1 = m_aranges[merge]; > + Range &r2 = m_aranges[cursor]; > + > + if (r1.hi_pc == r2.lo_pc && r1.offset == r2.offset) > { > - // We have found an entry whose end address it he same as the > - // next entry's start address and the offsets are the same so > - // we can merge these two entries. > - pos->hi_pc = next_pos->hi_pc; > - // Erase the next entry that wasn't needed > - pos = m_aranges.erase (next_pos); > - // Now recompute the end of the collection > - end = m_aranges.end(); > + r1.hi_pc = r2.hi_pc; > + indices.push_back(cursor); > } > else > - { > - // Two entries have either different offsets or there are gaps > - // in the address range, move along, nothing to see here. > - pos = next_pos; > - } > + merge = cursor; > } > + > + if (indices.empty()) > + return; > + > + // Remove the merged ranges by shifting down all the keepers... > + indices.push_back(m_aranges.size()); > + end = indices.size(); > + for (size_t target = indices[0], cursor = 1; cursor < end; ++cursor) > + { > + for (size_t i = indices[cursor - 1] + 1; i < indices[cursor]; ++i) > + m_aranges[target++] = m_aranges[i]; > + } > + > + // ...and drop the extra elements. > + m_aranges.resize(m_aranges.size() - end + 1); > } > > //---------------------------------------------------------------------- > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Fri Apr 15 14:56:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 15 Apr 2011 19:56:24 -0000 Subject: [Lldb-commits] [lldb] r129595 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Message-ID: <20110415195624.B84D52A6C12C@llvm.org> Author: johnny Date: Fri Apr 15 14:56:24 2011 New Revision: 129595 URL: http://llvm.org/viewvc/llvm-project?rev=129595&view=rev Log: Optimize address range coalescing. DWARFDebugAranges::Sort() calls std::stable_sort() over a set of address ranges and then proceeds to collapse neighboring ranges together. One problem with the current implementation is that it does an incomplete job. When a pair of ranges are merged the next pair considered does not include the just-merged range. IOW, three consecutive ranges are never collapsed into one. Another problem is that for each range merged we are calling std::vector::erase() which "shifts" all remaining elements of the vector by one position on every merge. The end result (in the worst case) is a quadratic algorithm -- not good when the input vector is large. The following patch merges all consecutive ranges and removes the quadratic behavior. The implementation uses an auxiliary vector of indices in order to remember all ranges that can be dropped, then performs the coalescing of ranges in a single pass. Patch from Stephen Wilson with some minor modification by me. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=129595&r1=129594&r2=129595&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Fri Apr 15 14:56:24 2011 @@ -15,6 +15,7 @@ #include #include "lldb/Core/Stream.h" +#include "lldb/Core/Timer.h" #include "SymbolFileDWARF.h" #include "DWARFDebugInfo.h" @@ -291,35 +292,47 @@ void DWARFDebugAranges::Sort() { + std::vector indices; + size_t end; + Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", + __PRETTY_FUNCTION__, this); + // Sort our address range entries std::stable_sort (m_aranges.begin(), m_aranges.end(), RangeLessThan); - // Merge any entries that have the same offset and same start/end address - RangeColl::iterator pos = m_aranges.begin(); - RangeColl::iterator end = m_aranges.end(); - while (pos != end) - { - RangeColl::iterator next_pos = pos + 1; - if (next_pos != end && - pos->offset == next_pos->offset && - pos->hi_pc == next_pos->lo_pc) - { - // We have found an entry whose end address it he same as the - // next entry's start address and the offsets are the same so - // we can merge these two entries. - pos->hi_pc = next_pos->hi_pc; - // Erase the next entry that wasn't needed - pos = m_aranges.erase (next_pos); - // Now recompute the end of the collection - end = m_aranges.end(); - } - else + // Merge all neighbouring ranges into a single range and remember the + // indices of all ranges merged. + end = m_aranges.size(); + for (size_t merge, cursor = 1; cursor < end; ++cursor) + { + merge = cursor - 1; + Range &r1 = m_aranges[merge]; + Range &r2 = m_aranges[cursor]; + + if (r1.hi_pc == r2.lo_pc && r1.offset == r2.offset) { - // Two entries have either different offsets or there are gaps - // in the address range, move along, nothing to see here. - pos = next_pos; + r2.lo_pc = r1.lo_pc; + indices.push_back(merge); } } + + if (indices.empty()) + return; + + // Remove the merged ranges by shifting down all the keepers... + std::set purged(indices.begin(), indices.end()); + size_t new_size = m_aranges.size() - indices.size(); + for (size_t src = 0, dst = 0; dst < new_size; ++dst) + { + while (purged.count(src) > 0) + ++src; + if (src == dst) + continue; + m_aranges[dst] = m_aranges[src]; + } + + // ...and drop the extra elements. + m_aranges.resize(new_size); } //---------------------------------------------------------------------- From wilsons at start.ca Fri Apr 15 15:51:40 2011 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 15 Apr 2011 16:51:40 -0400 Subject: [Lldb-commits] [lldb] r129595 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp In-Reply-To: <20110415195624.B84D52A6C12C@llvm.org> References: <20110415195624.B84D52A6C12C@llvm.org> Message-ID: <20110415205140.GA8368@fibrous.localdomain> Hi Johnny, On Fri, Apr 15, 2011 at 07:56:24PM -0000, Johnny Chen wrote: > + // Remove the merged ranges by shifting down all the keepers... > + std::set purged(indices.begin(), indices.end()); > + size_t new_size = m_aranges.size() - indices.size(); > + for (size_t src = 0, dst = 0; dst < new_size; ++dst) > + { > + while (purged.count(src) > 0) > + ++src; > + if (src == dst) > + continue; > + m_aranges[dst] = m_aranges[src]; > + } That looks broken to me. Index zero is never in the purged set since we merge ranges into their predecessors. Therefore purged.count(0) == 0 and on the first iteration we have src == dst, so we increment dst. What ends up happening is that src remains zero and we just do: for (i = 0; i < size; ++i) { m_arages[i] = m_aranges[0]; } Now, I *think* I know what you were trying to do here, and I think the main motivation on your side was to "clean up the code" -- but since the name of the game of the patch was optimization replacing the original O(n) approach with a "clean" O(n log(n)) implementation is not the way to go IMHO. Is there something I can do to clean up the original patch without reducing it's performance? Cheers, -- steve From johnny.chen at apple.com Fri Apr 15 15:59:22 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 15 Apr 2011 13:59:22 -0700 Subject: [Lldb-commits] [lldb] r129595 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp In-Reply-To: <20110415205140.GA8368@fibrous.localdomain> References: <20110415195624.B84D52A6C12C@llvm.org> <20110415205140.GA8368@fibrous.localdomain> Message-ID: Hi Stephen, You're more than welcome to commit your patch after some testing. Yes, my motivation was to clean up the code to make it more understandable. But since it broke the logic, it's no good. Thanks. On Apr 15, 2011, at 1:51 PM, Stephen Wilson wrote: > > Hi Johnny, > > On Fri, Apr 15, 2011 at 07:56:24PM -0000, Johnny Chen wrote: >> + // Remove the merged ranges by shifting down all the keepers... >> + std::set purged(indices.begin(), indices.end()); >> + size_t new_size = m_aranges.size() - indices.size(); >> + for (size_t src = 0, dst = 0; dst < new_size; ++dst) >> + { >> + while (purged.count(src) > 0) >> + ++src; >> + if (src == dst) >> + continue; >> + m_aranges[dst] = m_aranges[src]; >> + } > > That looks broken to me. Index zero is never in the purged set since we > merge ranges into their predecessors. Therefore purged.count(0) == 0 > and on the first iteration we have src == dst, so we increment dst. > What ends up happening is that src remains zero and we just do: > > for (i = 0; i < size; ++i) { m_arages[i] = m_aranges[0]; } > > > Now, I *think* I know what you were trying to do here, and I think the > main motivation on your side was to "clean up the code" -- but since the > name of the game of the patch was optimization replacing the original > O(n) approach with a "clean" O(n log(n)) implementation is not the way > to go IMHO. > > Is there something I can do to clean up the original patch without > reducing it's performance? > > > Cheers, > > -- > steve > From johnny.chen at apple.com Fri Apr 15 15:59:47 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 15 Apr 2011 20:59:47 -0000 Subject: [Lldb-commits] [lldb] r129605 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Message-ID: <20110415205947.2F0BB2A6C12C@llvm.org> Author: johnny Date: Fri Apr 15 15:59:46 2011 New Revision: 129605 URL: http://llvm.org/viewvc/llvm-project?rev=129605&view=rev Log: Update both the src and dst pointers at the end of the loop. Stephen Wilson is working on a better performing patch in the meantime. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=129605&r1=129604&r2=129605&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Fri Apr 15 15:59:46 2011 @@ -322,7 +322,7 @@ // Remove the merged ranges by shifting down all the keepers... std::set purged(indices.begin(), indices.end()); size_t new_size = m_aranges.size() - indices.size(); - for (size_t src = 0, dst = 0; dst < new_size; ++dst) + for (size_t src = 0, dst = 0; dst < new_size; ++src, ++dst) { while (purged.count(src) > 0) ++src; From johnny.chen at apple.com Fri Apr 15 16:45:12 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 15 Apr 2011 21:45:12 -0000 Subject: [Lldb-commits] [lldb] r129611 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Message-ID: <20110415214512.37AEE2A6C12C@llvm.org> Author: johnny Date: Fri Apr 15 16:45:12 2011 New Revision: 129611 URL: http://llvm.org/viewvc/llvm-project?rev=129611&view=rev Log: Get rid the of set membership test (log(m)) and, instead, use an index variable 'i' which advances when src collides with a purged slot. Hi Stephen, you're welcome to overwrite/or improve upon this version. Thanks. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=129611&r1=129610&r2=129611&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Fri Apr 15 16:45:12 2011 @@ -320,12 +320,13 @@ return; // Remove the merged ranges by shifting down all the keepers... - std::set purged(indices.begin(), indices.end()); size_t new_size = m_aranges.size() - indices.size(); - for (size_t src = 0, dst = 0; dst < new_size; ++src, ++dst) + for (size_t i = 0, src = 0, dst = 0; dst < new_size; ++src, ++dst) { - while (purged.count(src) > 0) + while (src == indices[i]) { ++src; + ++i; + } if (src == dst) continue; m_aranges[dst] = m_aranges[src]; From johnny.chen at apple.com Fri Apr 15 18:17:51 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 15 Apr 2011 16:17:51 -0700 Subject: [Lldb-commits] [lldb] r129595 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp In-Reply-To: <20110415205140.GA8368@fibrous.localdomain> References: <20110415195624.B84D52A6C12C@llvm.org> <20110415205140.GA8368@fibrous.localdomain> Message-ID: <6FE4D6CE-D64D-467C-8FFF-764F04BFAF2C@apple.com> Hi Stephen, I forgot to mention that ToT changed the 'merge' logic a little bit. Instead of (r1, r2) merged into r1 (and drop r2), it was changed to (r1, r2) merged into r2 (and drop r1). The reason is that for r1, r2, r3 ... which might get merged into rn, dropping r1 and updating r2 to the larger range works out better. Thanks. On Apr 15, 2011, at 1:51 PM, Stephen Wilson wrote: > > Hi Johnny, > > On Fri, Apr 15, 2011 at 07:56:24PM -0000, Johnny Chen wrote: >> + // Remove the merged ranges by shifting down all the keepers... >> + std::set purged(indices.begin(), indices.end()); >> + size_t new_size = m_aranges.size() - indices.size(); >> + for (size_t src = 0, dst = 0; dst < new_size; ++dst) >> + { >> + while (purged.count(src) > 0) >> + ++src; >> + if (src == dst) >> + continue; >> + m_aranges[dst] = m_aranges[src]; >> + } > > That looks broken to me. Index zero is never in the purged set since we > merge ranges into their predecessors. Therefore purged.count(0) == 0 > and on the first iteration we have src == dst, so we increment dst. > What ends up happening is that src remains zero and we just do: > > for (i = 0; i < size; ++i) { m_arages[i] = m_aranges[0]; } > > > Now, I *think* I know what you were trying to do here, and I think the > main motivation on your side was to "clean up the code" -- but since the > name of the game of the patch was optimization replacing the original > O(n) approach with a "clean" O(n log(n)) implementation is not the way > to go IMHO. > > Is there something I can do to clean up the original patch without > reducing it's performance? > > > Cheers, > > -- > steve > From jingham at apple.com Fri Apr 15 18:41:23 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 15 Apr 2011 23:41:23 -0000 Subject: [Lldb-commits] [lldb] r129620 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20110415234123.5B9982A6C12C@llvm.org> Author: jingham Date: Fri Apr 15 18:41:23 2011 New Revision: 129620 URL: http://llvm.org/viewvc/llvm-project?rev=129620&view=rev Log: Work around a llvm gcc bug where the name of a reference doesn't include the "&". 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=129620&r1=129619&r2=129620&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Apr 15 18:41:23 2011 @@ -3026,8 +3026,17 @@ case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: + type_name_cstr = form_value.AsCString(&get_debug_str_data()); - type_name_const_str.SetCString(type_name_cstr); + // Work around a bug in llvm-gcc where they give a name to a reference type which doesn't + // include the "&"... + if (tag == DW_TAG_reference_type) + { + if (strchr (type_name_cstr, '&') == NULL) + type_name_cstr = NULL; + } + if (type_name_cstr) + type_name_const_str.SetCString(type_name_cstr); break; case DW_AT_byte_size: byte_size = form_value.Unsigned(); byte_size_valid = true; break; case DW_AT_encoding: encoding = form_value.Unsigned(); break; From jingham at apple.com Fri Apr 15 18:42:06 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 15 Apr 2011 23:42:06 -0000 Subject: [Lldb-commits] [lldb] r129621 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20110415234208.37D202A6C12C@llvm.org> Author: jingham Date: Fri Apr 15 18:42:06 2011 New Revision: 129621 URL: http://llvm.org/viewvc/llvm-project?rev=129621&view=rev Log: Fix comment typo. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=129621&r1=129620&r2=129621&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Apr 15 18:42:06 2011 @@ -2519,7 +2519,7 @@ uint64_t clang_type_info_bit_size = ast->getTypeSize(base_class->getType()); - // Base classes biut sizes should be a multiple of 8 bits in size + // Base classes bit sizes should be a multiple of 8 bits in size assert (clang_type_info_bit_size % 8 == 0); child_byte_size = clang_type_info_bit_size / 8; child_is_base_class = true; From jingham at apple.com Fri Apr 15 19:01:13 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 16 Apr 2011 00:01:13 -0000 Subject: [Lldb-commits] [lldb] r129623 - in /lldb/trunk: include/lldb/API/ include/lldb/Core/ include/lldb/Target/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Target/ test/ test/cpp/dynamic-value/ test/python_api/process/ tools/debugserver/debugserver.xcodeproj/ Message-ID: <20110416000114.5F71E2A6C12C@llvm.org> Author: jingham Date: Fri Apr 15 19:01:13 2011 New Revision: 129623 URL: http://llvm.org/viewvc/llvm-project?rev=129623&view=rev Log: Add support for "dynamic values" for C++ classes. This currently only works for "frame var" and for the expressions that are simple enough to get passed to the "frame var" underpinnings. The parser code will have to be changed to also query for the dynamic types & offsets as it is looking up variables. The behavior of "frame var" is controlled in two ways. You can pass "-d {true/false} to the frame var command to get the dynamic or static value of the variables you are printing. There's also a general setting: target.prefer-dynamic-value (boolean) = 'true' which is consulted if you call "frame var" without supplying a value for the -d option. Added: lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h lldb/trunk/include/lldb/Core/ValueObjectMemory.h lldb/trunk/source/Core/ValueObjectDynamicValue.cpp lldb/trunk/source/Core/ValueObjectMemory.cpp lldb/trunk/test/cpp/dynamic-value/ lldb/trunk/test/cpp/dynamic-value/Makefile lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp Modified: lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/include/lldb/API/SBValue.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectConstResult.h lldb/trunk/include/lldb/Target/LanguageRuntime.h lldb/trunk/include/lldb/Target/StackFrame.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectChild.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/ThreadPlanTestCondition.cpp lldb/trunk/test/lldbutil.py lldb/trunk/test/python_api/process/TestProcessAPI.py lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Fri Apr 15 19:01:13 2011 @@ -71,8 +71,12 @@ lldb::SBBlock GetBlock () const; + // The version that doesn't supply a "use_dynamic" value will use the target's default. lldb::SBValue - EvaluateExpression (const char *expr); + EvaluateExpression (const char *expr); + + lldb::SBValue + EvaluateExpression (const char *expr, bool fetch_dynamic_value); // Gets the lexical block that defines the stack frame. Another way to think // of this is it will return the block that contains all of the variables @@ -116,17 +120,32 @@ bool statics, bool in_scope_only); + // The version that doesn't supply a "use_dynamic" value will use the target's default. + lldb::SBValueList + GetVariables (bool arguments, + bool locals, + bool statics, + bool in_scope_only, + bool use_dynamic); + lldb::SBValueList GetRegisters (); + // The version that doesn't supply a "use_dynamic" value will use the target's default. lldb::SBValue FindVariable (const char *var_name); + lldb::SBValue + FindVariable (const char *var_name, bool use_dynamic); + // Find variables, register sets, registers, or persistent variables using // the frame as the scope lldb::SBValue FindValue (const char *name, ValueType value_type); + lldb::SBValue + FindValue (const char *name, ValueType value_type, bool use_dynamic); + bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/include/lldb/API/SBValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBValue.h (original) +++ lldb/trunk/include/lldb/API/SBValue.h Fri Apr 15 19:01:13 2011 @@ -99,6 +99,9 @@ lldb::SBValue GetChildAtIndex (uint32_t idx); + lldb::SBValue + GetChildAtIndex (uint32_t idx, bool use_dynamic); + // Matches children of this object only and will match base classes and // member names if this is a clang typed object. uint32_t @@ -109,6 +112,11 @@ lldb::SBValue GetChildMemberWithName (const char *name); + // Matches child members of this object and child members of any base + // classes. + lldb::SBValue + GetChildMemberWithName (const char *name, bool use_dynamic); + uint32_t GetNumChildren (); Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Apr 15 19:01:13 2011 @@ -306,7 +306,7 @@ bool ResolveValue (Scalar &scalar); - + const char * GetLocationAsCString (); @@ -325,9 +325,6 @@ bool UpdateValueIfNeeded (); - const DataExtractor & - GetDataExtractor () const; - DataExtractor & GetDataExtractor (); @@ -345,10 +342,10 @@ GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create); lldb::ValueObjectSP - GetDynamicValue () - { - return m_dynamic_value_sp; - } + GetDynamicValue (bool can_create); + + lldb::ValueObjectSP + GetDynamicValue (bool can_create, lldb::ValueObjectSP &owning_valobj_sp); virtual lldb::ValueObjectSP CreateConstantValue (const ConstString &name); @@ -369,8 +366,11 @@ m_object_desc_str.clear(); } - bool - SetDynamicValue (); + virtual bool + IsDynamic () + { + return false; + } static void DumpValueObject (Stream &s, @@ -382,6 +382,7 @@ bool show_types, bool show_location, bool use_objc, + bool use_dynamic, bool scope_already_checked, bool flat_output); @@ -411,13 +412,16 @@ m_format = format; } - ValueObject * + // Use GetParent for display purposes, but if you want to tell the parent to update itself + // then use m_parent. The ValueObjectDynamicValue's parent is not the correct parent for + // displaying, they are really siblings, so for display it needs to route through to its grandparent. + virtual ValueObject * GetParent() { return m_parent; } - const ValueObject * + virtual const ValueObject * GetParent() const { return m_parent; @@ -436,8 +440,8 @@ //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these //------------------------------------------------------------------ - ValueObject* m_parent; // The parent value object, or NULL if this has no parent - EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last + ValueObject *m_parent; // The parent value object, or NULL if this has no parent + EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last // updated. When we are asked to update the value object, we check whether // the context & stop id are the same before updating. ConstString m_name; // The name of this object @@ -453,6 +457,10 @@ std::vector m_children; std::map m_synthetic_children; lldb::ValueObjectSP m_dynamic_value_sp; + lldb::ValueObjectSP m_addr_of_valobj_sp; // These two shared pointers help root the ValueObject shared pointers that + lldb::ValueObjectSP m_deref_valobj_sp; // we hand out, so that we can use them in their dynamic types and ensure + // they will last as long as this ValueObject... + lldb::Format m_format; bool m_value_is_valid:1, m_value_did_change:1, @@ -463,6 +471,7 @@ friend class CommandObjectExpression; friend class ClangExpressionVariable; + friend class ClangExpressionDeclMap; // For GetValue... friend class Target; friend class ValueObjectChild; //------------------------------------------------------------------ @@ -486,6 +495,9 @@ virtual bool UpdateValue () = 0; + virtual void + CalculateDynamicValue (); + // Should only be called by ValueObject::GetChildAtIndex() virtual lldb::ValueObjectSP CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index); @@ -509,7 +521,7 @@ void SetValueIsValid (bool valid); - +public: lldb::addr_t GetPointerValue (AddressType &address_type, bool scalar_is_load_address); Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Fri Apr 15 19:01:13 2011 @@ -91,6 +91,12 @@ virtual bool UpdateValue (); + virtual void + CalculateDynamicValue () {} // CalculateDynamicValue doesn't change the dynamic value, since this can get + // called at any time and you can't reliably fetch the dynamic value at any time. + // If we want to have dynamic values for ConstResults, then we'll need to make them + // up when we make the const result & stuff them in by hand. + clang::ASTContext *m_clang_ast; // The clang AST that the clang type comes from ConstString m_type_name; uint32_t m_byte_size; Added: lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h?rev=129623&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h (added) +++ lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h Fri Apr 15 19:01:13 2011 @@ -0,0 +1,105 @@ +//===-- ValueObjectDynamicValue.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_ValueObjectDynamicValue_h_ +#define liblldb_ValueObjectDynamicValue_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/ValueObject.h" + +namespace lldb_private { + +//---------------------------------------------------------------------- +// A ValueObject that represents memory at a given address, viewed as some +// set lldb type. +//---------------------------------------------------------------------- +class ValueObjectDynamicValue : public ValueObject +{ +public: + ValueObjectDynamicValue (ValueObject &parent); + + virtual + ~ValueObjectDynamicValue(); + + virtual size_t + GetByteSize(); + + virtual clang::ASTContext * + GetClangAST (); + + virtual lldb::clang_type_t + GetClangType (); + + virtual ConstString + GetTypeName(); + + virtual uint32_t + CalculateNumChildren(); + + virtual lldb::ValueType + GetValueType() const; + + virtual bool + IsInScope (); + + virtual bool + IsDynamic () + { + return true; + } + + virtual ValueObject * + GetParent() + { + if (m_parent) + return m_parent->GetParent(); + else + return NULL; + } + + virtual const ValueObject * + GetParent() const + { + if (m_parent) + return m_parent->GetParent(); + else + return NULL; + } + + void + SetOwningSP (lldb::ValueObjectSP &owning_sp) + { + if (m_owning_valobj_sp == owning_sp) + return; + + assert (m_owning_valobj_sp.get() == NULL); + m_owning_valobj_sp = owning_sp; + } + +protected: + virtual bool + UpdateValue (); + + Address m_address; ///< The variable that this value object is based upon + lldb::TypeSP m_type_sp; + lldb::ValueObjectSP m_owning_valobj_sp; + +private: + //------------------------------------------------------------------ + // For ValueObject only + //------------------------------------------------------------------ + DISALLOW_COPY_AND_ASSIGN (ValueObjectDynamicValue); +}; + +} // namespace lldb_private + +#endif // liblldb_ValueObjectDynamicValue_h_ Added: lldb/trunk/include/lldb/Core/ValueObjectMemory.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectMemory.h?rev=129623&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectMemory.h (added) +++ lldb/trunk/include/lldb/Core/ValueObjectMemory.h Fri Apr 15 19:01:13 2011 @@ -0,0 +1,73 @@ +//===-- ValueObjectMemory.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_ValueObjectMemory_h_ +#define liblldb_ValueObjectMemory_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/ValueObject.h" + +namespace lldb_private { + +//---------------------------------------------------------------------- +// A ValueObject that represents memory at a given address, viewed as some +// set lldb type. +//---------------------------------------------------------------------- +class ValueObjectMemory : public ValueObject +{ +public: + ValueObjectMemory (ExecutionContextScope *exe_scope, + const char *name, + const Address &address, + lldb::TypeSP &type_sp); + + virtual + ~ValueObjectMemory(); + + virtual size_t + GetByteSize(); + + virtual clang::ASTContext * + GetClangAST (); + + virtual lldb::clang_type_t + GetClangType (); + + virtual ConstString + GetTypeName(); + + virtual uint32_t + CalculateNumChildren(); + + virtual lldb::ValueType + GetValueType() const; + + virtual bool + IsInScope (); + +protected: + virtual bool + UpdateValue (); + + Address m_address; ///< The variable that this value object is based upon + lldb::TypeSP m_type_sp; + +private: + //------------------------------------------------------------------ + // For ValueObject only + //------------------------------------------------------------------ + DISALLOW_COPY_AND_ASSIGN (ValueObjectMemory); +}; + +} // namespace lldb_private + +#endif // liblldb_ValueObjectMemory_h_ Modified: lldb/trunk/include/lldb/Target/LanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/LanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Fri Apr 15 19:01:13 2011 @@ -42,9 +42,14 @@ virtual bool GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) = 0; - virtual lldb::ValueObjectSP - GetDynamicValue (lldb::ValueObjectSP in_value) = 0; + virtual bool + GetDynamicValue (ValueObject &in_value, lldb::TypeSP &type_sp, Address &address) = 0; + // This should be a fast test to determine whether it is likely that this value would + // have a dynamic type. + virtual bool + CouldHaveDynamicValue (ValueObject &in_value) = 0; + virtual void SetExceptionBreakpoints () { Modified: lldb/trunk/include/lldb/Target/StackFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StackFrame.h (original) +++ lldb/trunk/include/lldb/Target/StackFrame.h Fri Apr 15 19:01:13 2011 @@ -33,7 +33,8 @@ enum ExpressionPathOption { eExpressionPathOptionCheckPtrVsMember = (1u << 0), - eExpressionPathOptionsNoFragileObjcIvar = (1u << 1) + eExpressionPathOptionsNoFragileObjcIvar = (1u << 1), + eExpressionPathOptionsDynamicValue = (1u << 2) }; //------------------------------------------------------------------ // Constructors and Destructors @@ -133,10 +134,10 @@ } lldb::ValueObjectSP - GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp); + GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp, bool use_dynamic); lldb::ValueObjectSP - TrackGlobalVariable (const lldb::VariableSP &variable_sp); + TrackGlobalVariable (const lldb::VariableSP &variable_sp, bool use_dynamic); //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Fri Apr 15 19:01:13 2011 @@ -66,6 +66,12 @@ StringList &value, Error *err); + bool + GetPreferDynamicValue() + { + return m_prefer_dynamic_value; + } + protected: void @@ -77,6 +83,7 @@ std::string m_expr_prefix_path; std::string m_expr_prefix_contents; + bool m_prefer_dynamic_value; }; @@ -461,6 +468,7 @@ StackFrame *frame, bool unwind_on_error, bool keep_in_memory, + bool fetch_dynamic_value, lldb::ValueObjectSP &result_valobj_sp); ClangPersistentVariables & Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Apr 15 19:01:13 2011 @@ -408,6 +408,10 @@ 26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; }; 26F5C39110F3FA26009D5894 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; + 4CABA9DD134A8BA800539BDD /* ValueObjectMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CABA9DC134A8BA700539BDD /* ValueObjectMemory.h */; }; + 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */; }; + 4CD0BD0D134BFAB600CB44D4 /* ValueObjectDynamicValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CD0BD0C134BFAB600CB44D4 /* ValueObjectDynamicValue.h */; }; + 4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */; }; 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; }; 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1103,6 +1107,8 @@ 4C98D3E1118FB98F00E575D0 /* RecordingMemoryManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecordingMemoryManager.h; path = include/lldb/Expression/RecordingMemoryManager.h; sourceTree = ""; }; 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectApropos.cpp; path = source/Commands/CommandObjectApropos.cpp; sourceTree = ""; }; 4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectApropos.h; path = source/Commands/CommandObjectApropos.h; sourceTree = ""; }; + 4CABA9DC134A8BA700539BDD /* ValueObjectMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectMemory.h; path = include/lldb/Core/ValueObjectMemory.h; sourceTree = ""; }; + 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectMemory.cpp; path = source/Core/ValueObjectMemory.cpp; sourceTree = ""; }; 4CAFCE001101216B00CA63DB /* ThreadPlanRunToAddress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanRunToAddress.h; path = include/lldb/Target/ThreadPlanRunToAddress.h; sourceTree = ""; }; 4CAFCE031101218900CA63DB /* ThreadPlanRunToAddress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanRunToAddress.cpp; path = source/Target/ThreadPlanRunToAddress.cpp; sourceTree = ""; }; 4CB4430912491DDA00C13DC2 /* LanguageRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LanguageRuntime.h; path = include/lldb/Target/LanguageRuntime.h; sourceTree = ""; }; @@ -1115,6 +1121,8 @@ 4CB443F612499B6E00C13DC2 /* ObjCLanguageRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjCLanguageRuntime.h; path = include/lldb/Target/ObjCLanguageRuntime.h; sourceTree = ""; }; 4CC2A148128C73ED001531C4 /* ThreadPlanTracer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanTracer.cpp; path = source/Target/ThreadPlanTracer.cpp; sourceTree = ""; }; 4CC2A14C128C7409001531C4 /* ThreadPlanTracer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanTracer.h; path = include/lldb/Target/ThreadPlanTracer.h; sourceTree = ""; }; + 4CD0BD0C134BFAB600CB44D4 /* ValueObjectDynamicValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectDynamicValue.h; path = include/lldb/Core/ValueObjectDynamicValue.h; sourceTree = ""; }; + 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectDynamicValue.cpp; path = source/Core/ValueObjectDynamicValue.cpp; sourceTree = ""; }; 4CEDAED311754F5E00E875A6 /* ThreadPlanStepUntil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepUntil.h; path = include/lldb/Target/ThreadPlanStepUntil.h; sourceTree = ""; }; 69A01E1B1236C5D400C660B5 /* Condition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Condition.cpp; sourceTree = ""; }; 69A01E1C1236C5D400C660B5 /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = ""; }; @@ -1902,8 +1910,12 @@ 26BC7E9B10F1B85900F91463 /* ValueObjectChild.cpp */, 26424E3E125986D30016D82C /* ValueObjectConstResult.h */, 26424E3C125986CB0016D82C /* ValueObjectConstResult.cpp */, + 4CD0BD0C134BFAB600CB44D4 /* ValueObjectDynamicValue.h */, + 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */, 26BC7D8410F1B77400F91463 /* ValueObjectList.h */, 26BC7E9C10F1B85900F91463 /* ValueObjectList.cpp */, + 4CABA9DC134A8BA700539BDD /* ValueObjectMemory.h */, + 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */, 2643343A1110F63C00CDB6C6 /* ValueObjectRegister.h */, 264334381110F63100CDB6C6 /* ValueObjectRegister.cpp */, 26BC7D8510F1B77400F91463 /* ValueObjectVariable.h */, @@ -2550,6 +2562,8 @@ 26651A16133BF9CD005B64B7 /* Opcode.h in Headers */, 266603CD1345B5C0004DA8B6 /* ConnectionSharedMemory.h in Headers */, 2671A0CE134825F6003A87BB /* ConnectionMachPort.h in Headers */, + 4CABA9DD134A8BA800539BDD /* ValueObjectMemory.h in Headers */, + 4CD0BD0D134BFAB600CB44D4 /* ValueObjectDynamicValue.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3114,6 +3128,8 @@ 26651A18133BF9E0005B64B7 /* Opcode.cpp in Sources */, 266603CA1345B5A8004DA8B6 /* ConnectionSharedMemory.cpp in Sources */, 2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */, + 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */, + 4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3209,7 +3225,6 @@ LLVM_CONFIGURATION = Release; LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; ONLY_ACTIVE_ARCH = YES; - PREBINDING = NO; VALID_ARCHS = "x86_64 i386"; }; name = Debug; @@ -3251,7 +3266,6 @@ COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_OPTIMIZATION_LEVEL = 0; INSTALL_PATH = /Developer/usr/bin; ONLY_ACTIVE_ARCH = NO; @@ -3265,7 +3279,6 @@ ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; INSTALL_PATH = /Developer/usr/bin; ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = "darwin-debug"; @@ -3277,7 +3290,6 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = YES; INSTALL_PATH = /Developer/usr/bin; ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = "darwin-debug"; @@ -3542,7 +3554,6 @@ "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", ); - GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; @@ -3730,7 +3741,6 @@ "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", ); - GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ""; Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Fri Apr 15 19:01:13 2011 @@ -343,6 +343,13 @@ SBValue SBFrame::FindVariable (const char *name) { + bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + return FindVariable (name, use_dynamic); +} + +SBValue +SBFrame::FindVariable (const char *name, bool use_dynamic) +{ VariableSP var_sp; if (m_opaque_sp && name && name[0]) { @@ -369,7 +376,7 @@ SBValue sb_value; if (var_sp) - *sb_value = ValueObjectSP (new ValueObjectVariable (m_opaque_sp.get(), var_sp)); + *sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic)); LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -382,6 +389,13 @@ SBValue SBFrame::FindValue (const char *name, ValueType value_type) { + bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + return FindValue (name, value_type, use_dynamic); +} + +SBValue +SBFrame::FindValue (const char *name, ValueType value_type, bool use_dynamic) +{ SBValue sb_value; if (m_opaque_sp && name && name[0]) { @@ -416,7 +430,8 @@ variable_sp->GetScope() == value_type && variable_sp->GetName() == const_name) { - *sb_value = ValueObjectSP (new ValueObjectVariable (m_opaque_sp.get(), variable_sp)); + *sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(variable_sp, + use_dynamic)); break; } } @@ -564,6 +579,17 @@ bool statics, bool in_scope_only) { + bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + return GetVariables (arguments, locals, statics, in_scope_only, use_dynamic); +} + +SBValueList +SBFrame::GetVariables (bool arguments, + bool locals, + bool statics, + bool in_scope_only, + bool use_dynamic) +{ LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -619,7 +645,7 @@ if (in_scope_only && !variable_sp->IsInScope(m_opaque_sp.get())) continue; - value_list.Append(m_opaque_sp->GetValueObjectForFrameVariable (variable_sp)); + value_list.Append(m_opaque_sp->GetValueObjectForFrameVariable (variable_sp, use_dynamic)); } } } @@ -680,6 +706,13 @@ SBValue SBFrame::EvaluateExpression (const char *expr) { + bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); + return EvaluateExpression (expr, use_dynamic); +} + +SBValue +SBFrame::EvaluateExpression (const char *expr, bool fetch_dynamic_value) +{ Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -696,14 +729,23 @@ const bool unwind_on_error = true; const bool keep_in_memory = false; - exe_results = m_opaque_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr, m_opaque_sp.get(), unwind_on_error, keep_in_memory, *expr_result); + exe_results = m_opaque_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr, + m_opaque_sp.get(), + unwind_on_error, + fetch_dynamic_value, + keep_in_memory, + *expr_result); } if (expr_log) - expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **", expr_result.GetValue(*this), expr_result.GetSummary(*this)); + expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **", + expr_result.GetValue(*this), + expr_result.GetSummary(*this)); if (log) - log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p)", m_opaque_sp.get(), expr, expr_result.get()); + log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p)", m_opaque_sp.get(), + expr, + expr_result.get()); return expr_result; } Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Fri Apr 15 19:01:13 2011 @@ -339,6 +339,13 @@ SBValue SBValue::GetChildAtIndex (uint32_t idx) { + bool use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue(); + return GetChildAtIndex (idx, use_dynamic_value); +} + +SBValue +SBValue::GetChildAtIndex (uint32_t idx, bool use_dynamic_value) +{ lldb::ValueObjectSP child_sp; if (m_opaque_sp) @@ -346,6 +353,16 @@ child_sp = m_opaque_sp->GetChildAtIndex (idx, true); } + if (use_dynamic_value) + { + if (child_sp) + { + lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue(true, child_sp); + if (dynamic_sp) + child_sp = dynamic_sp; + } + } + SBValue sb_value (child_sp); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -374,6 +391,13 @@ SBValue SBValue::GetChildMemberWithName (const char *name) { + bool use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue(); + return GetChildMemberWithName (name, use_dynamic_value); +} + +SBValue +SBValue::GetChildMemberWithName (const char *name, bool use_dynamic_value) +{ lldb::ValueObjectSP child_sp; const ConstString str_name (name); @@ -382,6 +406,16 @@ child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true); } + if (use_dynamic_value) + { + if (child_sp) + { + lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue(true, child_sp); + if (dynamic_sp) + child_sp = dynamic_sp; + } + } + SBValue sb_value (child_sp); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Fri Apr 15 19:01:13 2011 @@ -77,6 +77,23 @@ print_object = true; break; + case 'd': + { + bool success; + bool result; + result = Args::StringToBoolean(option_arg, true, &success); + if (!success) + error.SetErrorStringWithFormat("Invalid dynamic value setting: \"%s\".\n", option_arg); + else + { + if (result) + use_dynamic = eLazyBoolYes; + else + use_dynamic = eLazyBoolNo; + } + } + break; + case 'u': bool success; unwind_on_error = Args::StringToBoolean(option_arg, true, &success); @@ -99,6 +116,7 @@ debug = false; format = eFormatDefault; print_object = false; + use_dynamic = eLazyBoolCalculate; unwind_on_error = true; show_types = true; show_summary = true; @@ -239,8 +257,27 @@ ExecutionResults exe_results; bool keep_in_memory = true; + bool use_dynamic; + // If use dynamic is not set, get it from the target: + switch (m_options.use_dynamic) + { + case eLazyBoolCalculate: + { + if (m_exe_ctx.target->GetPreferDynamicValue()) + use_dynamic = true; + else + use_dynamic = false; + } + break; + case eLazyBoolYes: + use_dynamic = true; + break; + case eLazyBoolNo: + use_dynamic = false; + break; + } - exe_results = m_exe_ctx.target->EvaluateExpression(expr, m_exe_ctx.frame, m_options.unwind_on_error, keep_in_memory, result_valobj_sp); + exe_results = m_exe_ctx.target->EvaluateExpression(expr, m_exe_ctx.frame, m_options.unwind_on_error, use_dynamic, keep_in_memory, result_valobj_sp); if (exe_results == eExecutionInterrupted && !m_options.unwind_on_error) { @@ -266,6 +303,7 @@ m_options.show_types, // Show types when dumping? false, // Show locations of variables, no since this is a host address which we don't care to see m_options.print_object, // Print the objective C object? + use_dynamic, true, // Scope is already checked. Const results are always in scope. false); // Don't flatten output if (result) @@ -389,6 +427,7 @@ //{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."}, { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the expression output should use."}, { LLDB_OPT_SET_2, false, "object-description", 'o', no_argument, NULL, 0, eArgTypeNone, "Print the object description of the value resulting from the expression."}, +{ LLDB_OPT_SET_2, false, "dynamic-value", 'd', required_argument, NULL, 0, eArgTypeBoolean, "Upcast the value resulting from the expression to its dynamic type if available."}, { LLDB_OPT_SET_ALL, false, "unwind-on-error", 'u', required_argument, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, breakpoint hit or signal."}, { LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation."}, { LLDB_OPT_SET_ALL, false, "use-ir", 'i', no_argument, NULL, 0, eArgTypeNone, "[Temporary] Instructs the expression evaluator to use IR instead of ASTs."}, Modified: lldb/trunk/source/Commands/CommandObjectExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.h (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.h Fri Apr 15 19:01:13 2011 @@ -51,6 +51,7 @@ lldb::Format format; bool debug; bool print_object; + LazyBool use_dynamic; bool unwind_on_error; bool show_types; bool show_summary; Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Apr 15 19:01:13 2011 @@ -310,6 +310,22 @@ switch (short_option) { case 'o': use_objc = true; break; + case 'd': + { + bool success; + bool result; + result = Args::StringToBoolean(option_arg, true, &success); + if (!success) + error.SetErrorStringWithFormat("Invalid dynamic value setting: \"%s\".\n", option_arg); + else + { + if (result) + use_dynamic = eLazyBoolYes; + else + use_dynamic = eLazyBoolNo; + } + } + break; case 'r': use_regex = true; break; case 'a': show_args = false; break; case 'l': show_locals = false; break; @@ -321,7 +337,7 @@ case 'D': debug = true; break; case 'f': error = Args::StringToFormat(option_arg, format); break; case 'F': flat_output = true; break; - case 'd': + case 'A': max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); if (!success) error.SetErrorStringWithFormat("Invalid max depth '%s'.\n", option_arg); @@ -364,6 +380,7 @@ show_decl = false; debug = false; flat_output = false; + use_dynamic = eLazyBoolCalculate; max_depth = UINT32_MAX; ptr_depth = 0; format = eFormatDefault; @@ -391,6 +408,7 @@ show_decl:1, debug:1, flat_output:1; + LazyBool use_dynamic; uint32_t max_depth; // The depth to print when dumping concrete (not pointers) aggreate values uint32_t ptr_depth; // The default depth that is dumped when we find pointers lldb::Format format; // The format to use when dumping variables or children of variables @@ -461,7 +479,28 @@ VariableSP var_sp; ValueObjectSP valobj_sp; - //ValueObjectList &valobj_list = exe_ctx.frame->GetValueObjectList(); + + bool use_dynamic; + + // If use dynamic is not set, get it from the target: + switch (m_options.use_dynamic) + { + case eLazyBoolCalculate: + { + if (exe_ctx.target->GetPreferDynamicValue()) + use_dynamic = true; + else + use_dynamic = false; + } + break; + case eLazyBoolYes: + use_dynamic = true; + break; + case eLazyBoolNo: + use_dynamic = false; + break; + } + const char *name_cstr = NULL; size_t idx; if (!m_options.globals.empty()) @@ -473,12 +512,17 @@ for (idx = 0; idx < num_globals; ++idx) { VariableList global_var_list; - const uint32_t num_matching_globals = exe_ctx.target->GetImages().FindGlobalVariables (m_options.globals[idx], true, UINT32_MAX, global_var_list); + const uint32_t num_matching_globals + = exe_ctx.target->GetImages().FindGlobalVariables (m_options.globals[idx], + true, + UINT32_MAX, + global_var_list); if (num_matching_globals == 0) { ++fail_count; - result.GetErrorStream().Printf ("error: can't find global variable '%s'\n", m_options.globals[idx].AsCString()); + result.GetErrorStream().Printf ("error: can't find global variable '%s'\n", + m_options.globals[idx].AsCString()); } else { @@ -487,9 +531,9 @@ var_sp = global_var_list.GetVariableAtIndex(global_idx); if (var_sp) { - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, use_dynamic); if (!valobj_sp) - valobj_sp = exe_ctx.frame->TrackGlobalVariable (var_sp); + valobj_sp = exe_ctx.frame->TrackGlobalVariable (var_sp, use_dynamic); if (valobj_sp) { @@ -501,7 +545,7 @@ var_sp->GetDeclaration ().DumpStopContext (&s, false); s.PutCString (": "); } - + ValueObject::DumpValueObject (result.GetOutputStream(), valobj_sp.get(), name_cstr, @@ -510,7 +554,8 @@ m_options.max_depth, m_options.show_types, m_options.show_location, - m_options.use_objc, + m_options.use_objc, + use_dynamic, false, m_options.flat_output); } @@ -541,7 +586,9 @@ if (regex.Compile(name_cstr)) { size_t num_matches = 0; - const size_t num_new_regex_vars = variable_list->AppendVariablesIfUnique(regex, regex_var_list, num_matches); + const size_t num_new_regex_vars = variable_list->AppendVariablesIfUnique(regex, + regex_var_list, + num_matches); if (num_new_regex_vars > 0) { for (uint32_t regex_idx = regex_start_index, end_index = regex_var_list.GetSize(); @@ -551,9 +598,9 @@ var_sp = regex_var_list.GetVariableAtIndex (regex_idx); if (var_sp) { - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, use_dynamic); if (valobj_sp) - { + { if (m_options.format != eFormatDefault) valobj_sp->SetFormat (m_options.format); @@ -571,7 +618,8 @@ m_options.max_depth, m_options.show_types, m_options.show_location, - m_options.use_objc, + m_options.use_objc, + use_dynamic, false, m_options.flat_output); } @@ -595,10 +643,20 @@ else { Error error; - const uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember; + uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember; + if (use_dynamic) + expr_path_options |= StackFrame::eExpressionPathOptionsDynamicValue; + valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, expr_path_options, error); if (valobj_sp) { +// if (use_dynamic) +// { +// lldb::ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue(true, valobj_sp); +// if (dynamic_sp != NULL) +// valobj_sp = dynamic_sp; +// } +// if (m_options.format != eFormatDefault) valobj_sp->SetFormat (m_options.format); @@ -615,7 +673,8 @@ m_options.max_depth, m_options.show_types, m_options.show_location, - m_options.use_objc, + m_options.use_objc, + use_dynamic, false, m_options.flat_output); } @@ -639,6 +698,7 @@ for (uint32_t i=0; iGetVariableAtIndex(i); + bool dump_variable = true; switch (var_sp->GetScope()) @@ -677,7 +737,7 @@ // Use the variable object code to make sure we are // using the same APIs as the the public API will be // using... - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, use_dynamic); if (valobj_sp) { if (m_options.format != eFormatDefault) @@ -700,7 +760,8 @@ m_options.max_depth, m_options.show_types, m_options.show_location, - m_options.use_objc, + m_options.use_objc, + use_dynamic, false, m_options.flat_output); } @@ -722,22 +783,23 @@ OptionDefinition CommandObjectFrameVariable::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "debug", 'D', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug information."}, -{ LLDB_OPT_SET_1, false, "depth", 'd', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, -{ LLDB_OPT_SET_1, false, "show-globals",'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."}, -{ LLDB_OPT_SET_1, false, "find-global",'G', required_argument, NULL, 0, eArgTypeVarName, "Find a global variable by name (which might not be in the current stack frame source file)."}, -{ LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, -{ LLDB_OPT_SET_1, false, "show-declaration", 'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."}, -{ LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."}, -{ LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."}, -{ LLDB_OPT_SET_1, false, "show-types", 't', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, -{ LLDB_OPT_SET_1, false, "no-summary", 'y', no_argument, NULL, 0, eArgTypeNone, "Omit summary information."}, -{ LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."}, -{ LLDB_OPT_SET_1, false, "objc", 'o', no_argument, NULL, 0, eArgTypeNone, "When looking up a variable by name, print as an Objective-C object."}, -{ LLDB_OPT_SET_1, false, "ptr-depth", 'p', required_argument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."}, -{ LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The argument for name lookups are regular expressions."}, -{ LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."}, -{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the variable output should use."}, +{ LLDB_OPT_SET_1, false, "aggregate-depth", 'A', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, +{ LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."}, +{ LLDB_OPT_SET_1, false, "show-declaration",'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."}, +{ LLDB_OPT_SET_1, false, "debug", 'D', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug information."}, +{ LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, NULL, 0, eArgTypeBoolean, "Show the object as its full dynamic type, not its static type, if available."}, +{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the variable output should use."}, +{ LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."}, +{ LLDB_OPT_SET_1, false, "show-globals", 'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."}, +{ LLDB_OPT_SET_1, false, "find-global", 'G', required_argument, NULL, 0, eArgTypeVarName, "Find a global variable by name (which might not be in the current stack frame source file)."}, +{ LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, +{ LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."}, +{ LLDB_OPT_SET_1, false, "objc", 'o', no_argument, NULL, 0, eArgTypeNone, "When looking up a variable by name, print as an Objective-C object."}, +{ LLDB_OPT_SET_1, false, "ptr-depth", 'p', required_argument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."}, +{ LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The argument for name lookups are regular expressions."}, +{ LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."}, +{ LLDB_OPT_SET_1, false, "show-types", 't', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, +{ LLDB_OPT_SET_1, false, "no-summary", 'y', no_argument, NULL, 0, eArgTypeNone, "Omit summary information."}, { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; #pragma mark CommandObjectMultiwordFrame Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Apr 15 19:01:13 2011 @@ -22,6 +22,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectChild.h" #include "lldb/Core/ValueObjectConstResult.h" +#include "lldb/Core/ValueObjectDynamicValue.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Host/Endian.h" @@ -159,15 +160,10 @@ return m_error.Success(); } -const DataExtractor & -ValueObject::GetDataExtractor () const -{ - return m_data; -} - DataExtractor & ValueObject::GetDataExtractor () { + UpdateValueIfNeeded(); return m_data; } @@ -281,17 +277,20 @@ ValueObject::GetChildAtIndex (uint32_t idx, bool can_create) { ValueObjectSP child_sp; - if (idx < GetNumChildren()) + if (UpdateValueIfNeeded()) { - // Check if we have already made the child value object? - if (can_create && m_children[idx].get() == NULL) + if (idx < GetNumChildren()) { - // No we haven't created the child at this index, so lets have our - // subclass do it and cache the result for quick future access. - m_children[idx] = CreateChildAtIndex (idx, false, 0); - } + // Check if we have already made the child value object? + if (can_create && m_children[idx].get() == NULL) + { + // No we haven't created the child at this index, so lets have our + // subclass do it and cache the result for quick future access. + m_children[idx] = CreateChildAtIndex (idx, false, 0); + } - child_sp = m_children[idx]; + child_sp = m_children[idx]; + } } return child_sp; } @@ -312,34 +311,38 @@ // when getting a child by name, it could be buried inside some base // classes (which really aren't part of the expression path), so we // need a vector of indexes that can get us down to the correct child - std::vector child_indexes; - clang::ASTContext *clang_ast = GetClangAST(); - void *clang_type = GetClangType(); - bool omit_empty_base_classes = true; - const size_t num_child_indexes = ClangASTContext::GetIndexOfChildMemberWithName (clang_ast, - clang_type, - name.GetCString(), - omit_empty_base_classes, - child_indexes); ValueObjectSP child_sp; - if (num_child_indexes > 0) - { - std::vector::const_iterator pos = child_indexes.begin (); - std::vector::const_iterator end = child_indexes.end (); - child_sp = GetChildAtIndex(*pos, can_create); - for (++pos; pos != end; ++pos) + if (UpdateValueIfNeeded()) + { + std::vector child_indexes; + clang::ASTContext *clang_ast = GetClangAST(); + void *clang_type = GetClangType(); + bool omit_empty_base_classes = true; + const size_t num_child_indexes = ClangASTContext::GetIndexOfChildMemberWithName (clang_ast, + clang_type, + name.GetCString(), + omit_empty_base_classes, + child_indexes); + if (num_child_indexes > 0) { - if (child_sp) - { - ValueObjectSP new_child_sp(child_sp->GetChildAtIndex (*pos, can_create)); - child_sp = new_child_sp; - } - else + std::vector::const_iterator pos = child_indexes.begin (); + std::vector::const_iterator end = child_indexes.end (); + + child_sp = GetChildAtIndex(*pos, can_create); + for (++pos; pos != end; ++pos) { - child_sp.reset(); - } + if (child_sp) + { + ValueObjectSP new_child_sp(child_sp->GetChildAtIndex (*pos, can_create)); + child_sp = new_child_sp; + } + else + { + child_sp.reset(); + } + } } } return child_sp; @@ -378,55 +381,60 @@ ValueObject::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index) { ValueObjectSP valobj_sp; - bool omit_empty_base_classes = true; + + if (UpdateValueIfNeeded()) + { + bool omit_empty_base_classes = true; + + std::string child_name_str; + uint32_t child_byte_size = 0; + int32_t child_byte_offset = 0; + uint32_t child_bitfield_bit_size = 0; + uint32_t child_bitfield_bit_offset = 0; + bool child_is_base_class = false; + bool child_is_deref_of_parent = false; + + const bool transparent_pointers = synthetic_array_member == false; + clang::ASTContext *clang_ast = GetClangAST(); + clang_type_t clang_type = GetClangType(); + clang_type_t child_clang_type; + child_clang_type = ClangASTContext::GetChildClangTypeAtIndex (clang_ast, + GetName().GetCString(), + clang_type, + idx, + transparent_pointers, + omit_empty_base_classes, + child_name_str, + child_byte_size, + child_byte_offset, + child_bitfield_bit_size, + child_bitfield_bit_offset, + child_is_base_class, + child_is_deref_of_parent); + if (child_clang_type && child_byte_size) + { + if (synthetic_index) + child_byte_offset += child_byte_size * synthetic_index; + + ConstString child_name; + if (!child_name_str.empty()) + child_name.SetCString (child_name_str.c_str()); - std::string child_name_str; - uint32_t child_byte_size = 0; - int32_t child_byte_offset = 0; - uint32_t child_bitfield_bit_size = 0; - uint32_t child_bitfield_bit_offset = 0; - bool child_is_base_class = false; - bool child_is_deref_of_parent = false; - - const bool transparent_pointers = synthetic_array_member == false; - clang::ASTContext *clang_ast = GetClangAST(); - clang_type_t clang_type = GetClangType(); - clang_type_t child_clang_type; - child_clang_type = ClangASTContext::GetChildClangTypeAtIndex (clang_ast, - GetName().GetCString(), - clang_type, - idx, - transparent_pointers, - omit_empty_base_classes, - child_name_str, - child_byte_size, - child_byte_offset, - child_bitfield_bit_size, - child_bitfield_bit_offset, - child_is_base_class, - child_is_deref_of_parent); - if (child_clang_type && child_byte_size) - { - if (synthetic_index) - child_byte_offset += child_byte_size * synthetic_index; - - ConstString child_name; - if (!child_name_str.empty()) - child_name.SetCString (child_name_str.c_str()); - - valobj_sp.reset (new ValueObjectChild (*this, - clang_ast, - child_clang_type, - child_name, - child_byte_size, - child_byte_offset, - child_bitfield_bit_size, - child_bitfield_bit_offset, - child_is_base_class, - child_is_deref_of_parent)); - if (m_pointers_point_to_load_addrs) - valobj_sp->SetPointersPointToLoadAddrs (m_pointers_point_to_load_addrs); + valobj_sp.reset (new ValueObjectChild (*this, + clang_ast, + child_clang_type, + child_name, + child_byte_size, + child_byte_offset, + child_bitfield_bit_size, + child_bitfield_bit_offset, + child_is_base_class, + child_is_deref_of_parent)); + if (m_pointers_point_to_load_addrs) + valobj_sp->SetPointersPointToLoadAddrs (m_pointers_point_to_load_addrs); + } } + return valobj_sp; } @@ -710,6 +718,9 @@ addr_t ValueObject::GetAddressOf (AddressType &address_type, bool scalar_is_load_address) { + if (!UpdateValueIfNeeded()) + return LLDB_INVALID_ADDRESS; + switch (m_value.GetValueType()) { case Value::eValueTypeScalar: @@ -738,6 +749,10 @@ { lldb::addr_t address = LLDB_INVALID_ADDRESS; address_type = eAddressTypeInvalid; + + if (!UpdateValueIfNeeded()) + return address; + switch (m_value.GetValueType()) { case Value::eValueTypeScalar: @@ -957,16 +972,66 @@ return synthetic_child_sp; } -bool -ValueObject::SetDynamicValue () +void +ValueObject::CalculateDynamicValue () { - if (!IsPointerOrReferenceType()) - return false; + if (!m_dynamic_value_sp && !IsDynamic()) + { + Process *process = m_update_point.GetProcess(); + bool worth_having_dynamic_value = false; - // Check that the runtime class is correct for determining the most specific class. - // If it is a C++ class, see if it is dynamic: - - return true; + + // FIXME: Process should have some kind of "map over Runtimes" so we don't have to + // hard code this everywhere. + lldb::LanguageType known_type = GetObjectRuntimeLanguage(); + if (known_type != lldb::eLanguageTypeUnknown && known_type != lldb::eLanguageTypeC) + { + LanguageRuntime *runtime = process->GetLanguageRuntime (known_type); + if (runtime) + worth_having_dynamic_value = runtime->CouldHaveDynamicValue(*this); + } + else + { + LanguageRuntime *cpp_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeC_plus_plus); + if (cpp_runtime) + worth_having_dynamic_value = cpp_runtime->CouldHaveDynamicValue(*this); + + if (!worth_having_dynamic_value) + { + LanguageRuntime *objc_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeObjC); + if (objc_runtime) + worth_having_dynamic_value = cpp_runtime->CouldHaveDynamicValue(*this); + } + } + + if (worth_having_dynamic_value) + m_dynamic_value_sp.reset (new ValueObjectDynamicValue (*this)); + } +} + +lldb::ValueObjectSP +ValueObject::GetDynamicValue (bool can_create) +{ + if (!IsDynamic() && m_dynamic_value_sp == NULL && can_create) + { + CalculateDynamicValue(); + } + return m_dynamic_value_sp; +} + +lldb::ValueObjectSP +ValueObject::GetDynamicValue (bool can_create, lldb::ValueObjectSP &owning_valobj_sp) +{ + if (!IsDynamic() && m_dynamic_value_sp == NULL && can_create) + { + CalculateDynamicValue(); + if (m_dynamic_value_sp) + { + ValueObjectDynamicValue *as_dynamic_value = static_cast(m_dynamic_value_sp.get()); + as_dynamic_value->SetOwningSP (owning_valobj_sp); + } + } + return m_dynamic_value_sp; } bool @@ -974,7 +1039,7 @@ { if (IsBaseClass()) { - bool parent_had_base_class = m_parent && m_parent->GetBaseClassPath (s); + bool parent_had_base_class = GetParent() && GetParent()->GetBaseClassPath (s); clang_type_t clang_type = GetClangType(); std::string cxx_class_name; bool this_had_base_class = ClangASTContext::GetCXXClassName (clang_type, cxx_class_name); @@ -993,12 +1058,12 @@ ValueObject * ValueObject::GetNonBaseClassParent() { - if (m_parent) + if (GetParent()) { - if (m_parent->IsBaseClass()) - return m_parent->GetNonBaseClassParent(); + if (GetParent()->IsBaseClass()) + return GetParent()->GetNonBaseClassParent(); else - return m_parent; + return GetParent(); } return NULL; } @@ -1011,8 +1076,8 @@ if (is_deref_of_parent) s.PutCString("*("); - if (m_parent) - m_parent->GetExpressionPath (s, qualify_cxx_base_classes); + if (GetParent()) + GetParent()->GetExpressionPath (s, qualify_cxx_base_classes); if (!IsBaseClass()) { @@ -1067,12 +1132,20 @@ bool show_types, bool show_location, bool use_objc, + bool use_dynamic, bool scope_already_checked, bool flat_output ) { if (valobj && valobj->UpdateValueIfNeeded ()) { + if (use_dynamic) + { + ValueObject *dynamic_value = valobj->GetDynamicValue(true).get(); + if (dynamic_value) + valobj = dynamic_value; + } + clang_type_t clang_type = valobj->GetClangType(); const Flags type_flags (ClangASTContext::GetTypeInfo (clang_type, NULL, NULL)); @@ -1216,6 +1289,7 @@ show_types, show_location, false, + use_dynamic, true, flat_output); } @@ -1296,7 +1370,9 @@ lldb::ValueObjectSP ValueObject::Dereference (Error &error) { - lldb::ValueObjectSP valobj_sp; + if (m_deref_valobj_sp) + return m_deref_valobj_sp; + const bool is_pointer_type = IsPointerType(); if (is_pointer_type) { @@ -1332,20 +1408,20 @@ if (!child_name_str.empty()) child_name.SetCString (child_name_str.c_str()); - valobj_sp.reset (new ValueObjectChild (*this, - clang_ast, - child_clang_type, - child_name, - child_byte_size, - child_byte_offset, - child_bitfield_bit_size, - child_bitfield_bit_offset, - child_is_base_class, - child_is_deref_of_parent)); + m_deref_valobj_sp.reset (new ValueObjectChild (*this, + clang_ast, + child_clang_type, + child_name, + child_byte_size, + child_byte_offset, + child_bitfield_bit_size, + child_bitfield_bit_offset, + child_is_base_class, + child_is_deref_of_parent)); } } - if (valobj_sp) + if (m_deref_valobj_sp) { error.Clear(); } @@ -1360,13 +1436,15 @@ error.SetErrorStringWithFormat("not a pointer type: (%s) %s", GetTypeName().AsCString(""), strm.GetString().c_str()); } - return valobj_sp; + return m_deref_valobj_sp; } - lldb::ValueObjectSP +lldb::ValueObjectSP ValueObject::AddressOf (Error &error) { - lldb::ValueObjectSP valobj_sp; + if (m_addr_of_valobj_sp) + return m_addr_of_valobj_sp; + AddressType address_type = eAddressTypeInvalid; const bool scalar_is_load_address = false; lldb::addr_t addr = GetAddressOf (address_type, scalar_is_load_address); @@ -1394,19 +1472,19 @@ { std::string name (1, '&'); name.append (m_name.AsCString("")); - valobj_sp.reset (new ValueObjectConstResult (GetExecutionContextScope(), - ast, - ClangASTContext::CreatePointerType (ast, clang_type), - ConstString (name.c_str()), - addr, - eAddressTypeInvalid, - m_data.GetAddressByteSize())); + m_addr_of_valobj_sp.reset (new ValueObjectConstResult (GetExecutionContextScope(), + ast, + ClangASTContext::CreatePointerType (ast, clang_type), + ConstString (name.c_str()), + addr, + eAddressTypeInvalid, + m_data.GetAddressByteSize())); } } break; } } - return valobj_sp; + return m_addr_of_valobj_sp; } ValueObject::EvaluationPoint::EvaluationPoint () : @@ -1523,10 +1601,16 @@ return false; // If our stop id is the current stop ID, nothing has changed: - if (m_stop_id == m_process_sp->GetStopID()) + uint32_t cur_stop_id = m_process_sp->GetStopID(); + if (m_stop_id == cur_stop_id) return false; - m_stop_id = m_process_sp->GetStopID(); + // If the current stop id is 0, either we haven't run yet, or the process state has been cleared. + // In either case, we aren't going to be able to sync with the process state. + if (cur_stop_id == 0) + return false; + + m_stop_id = cur_stop_id; m_needs_update = true; m_exe_scope = m_process_sp.get(); Modified: lldb/trunk/source/Core/ValueObjectChild.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp (original) +++ lldb/trunk/source/Core/ValueObjectChild.cpp Fri Apr 15 19:01:13 2011 @@ -97,7 +97,7 @@ ValueObject* parent = m_parent; if (parent) { - if (parent->UpdateValue()) + if (parent->UpdateValueIfNeeded()) { m_value.SetContext(Value::eContextTypeClangType, m_clang_type); Added: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=129623&view=auto ============================================================================== --- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (added) +++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Fri Apr 15 19:01:13 2011 @@ -0,0 +1,254 @@ +//===-- ValueObjectDynamicValue.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/Core/ValueObjectDynamicValue.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/Module.h" +#include "lldb/Core/ValueObjectList.h" +#include "lldb/Core/Value.h" +#include "lldb/Core/ValueObject.h" + +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Symbol/Type.h" +#include "lldb/Symbol/Variable.h" + +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" + + +using namespace lldb_private; + +ValueObjectDynamicValue::ValueObjectDynamicValue (ValueObject &parent) : + ValueObject(parent), + m_address (), + m_type_sp() +{ + // THINK ABOUT: It looks ugly to doctor up the name like this. But if + // people find it confusing to tell the difference, we may want to do something... + +// std::string dynamic_name (""); +// +// SetName (dynamic_name.c_str()); + SetName (parent.GetName().AsCString()); +} + +ValueObjectDynamicValue::~ValueObjectDynamicValue() +{ + m_owning_valobj_sp.reset(); +} + +lldb::clang_type_t +ValueObjectDynamicValue::GetClangType () +{ + if (m_type_sp) + return m_value.GetClangType(); + else + return m_parent->GetClangType(); +} + +ConstString +ValueObjectDynamicValue::GetTypeName() +{ + // FIXME: Maybe cache the name, but have to clear it out if the type changes... + if (!UpdateValueIfNeeded()) + return ConstString(""); + + if (m_type_sp) + return ClangASTType::GetClangTypeName (GetClangType()); + else + return m_parent->GetTypeName(); +} + +uint32_t +ValueObjectDynamicValue::CalculateNumChildren() +{ + if (!UpdateValueIfNeeded()) + return 0; + + if (m_type_sp) + return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true); + else + return m_parent->GetNumChildren(); +} + +clang::ASTContext * +ValueObjectDynamicValue::GetClangAST () +{ + if (!UpdateValueIfNeeded()) + return NULL; + + if (m_type_sp) + return m_type_sp->GetClangAST(); + else + return m_parent->GetClangAST (); +} + +size_t +ValueObjectDynamicValue::GetByteSize() +{ + if (!UpdateValueIfNeeded()) + return 0; + + if (m_type_sp) + return m_value.GetValueByteSize(GetClangAST(), NULL); + else + return m_parent->GetByteSize(); +} + +lldb::ValueType +ValueObjectDynamicValue::GetValueType() const +{ + return m_parent->GetValueType(); +} + +bool +ValueObjectDynamicValue::UpdateValue () +{ + SetValueIsValid (false); + m_error.Clear(); + + if (!m_parent->UpdateValueIfNeeded()) + { + return false; + } + + ExecutionContext exe_ctx (GetExecutionContextScope()); + + if (exe_ctx.target) + { + m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder()); + m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize()); + } + + // First make sure our Type and/or Address haven't changed: + Process *process = m_update_point.GetProcess(); + if (!process) + return false; + + lldb::TypeSP dynamic_type_sp; + Address dynamic_address; + bool found_dynamic_type = false; + + lldb::LanguageType known_type = m_parent->GetObjectRuntimeLanguage(); + if (known_type != lldb::eLanguageTypeUnknown && known_type != lldb::eLanguageTypeC) + { + LanguageRuntime *runtime = process->GetLanguageRuntime (known_type); + if (runtime) + found_dynamic_type = runtime->GetDynamicValue(*m_parent, dynamic_type_sp, dynamic_address); + } + else + { + LanguageRuntime *cpp_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeC_plus_plus); + if (cpp_runtime) + found_dynamic_type = cpp_runtime->GetDynamicValue(*m_parent, dynamic_type_sp, dynamic_address); + + if (!found_dynamic_type) + { + LanguageRuntime *objc_runtime = process->GetLanguageRuntime (lldb::eLanguageTypeObjC); + if (objc_runtime) + found_dynamic_type = cpp_runtime->GetDynamicValue(*m_parent, dynamic_type_sp, dynamic_address); + } + } + + // If we don't have a dynamic type, then make ourselves just a echo of our parent. + // Or we could return false, and make ourselves an echo of our parent? + if (!found_dynamic_type) + { + if (m_type_sp) + SetValueDidChange(true); + m_value = m_parent->GetValue(); + m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0); + return m_error.Success(); + } + + Value old_value(m_value); + + if (!m_type_sp) + { + m_type_sp = dynamic_type_sp; + } + else if (dynamic_type_sp != m_type_sp) + { + // We are another type, we need to tear down our children... + m_type_sp = dynamic_type_sp; + SetValueDidChange (true); + } + + if (!m_address.IsValid() || m_address != dynamic_address) + { + if (m_address.IsValid()) + SetValueDidChange (true); + + // We've moved, so we should be fine... + m_address = dynamic_address; + lldb::addr_t load_address = m_address.GetLoadAddress(m_update_point.GetTarget()); + m_value.GetScalar() = load_address; + } + + // The type will always be the type of the dynamic object. If our parent's type was a pointer, + // then our type should be a pointer to the type of the dynamic object. If a reference, then the original type + // should be okay... + lldb::clang_type_t orig_type = m_type_sp->GetClangForwardType(); + lldb::clang_type_t corrected_type = orig_type; + if (m_parent->IsPointerType()) + corrected_type = ClangASTContext::CreatePointerType (m_type_sp->GetClangAST(), orig_type); + else if (m_parent->IsPointerOrReferenceType()) + corrected_type = ClangASTContext::CreateLValueReferenceType (m_type_sp->GetClangAST(), orig_type); + + m_value.SetContext (Value::eContextTypeClangType, corrected_type); + + // Our address is the location of the dynamic type stored in memory. It isn't a load address, + // because we aren't pointing to the LOCATION that stores the pointer to us, we're pointing to us... + m_value.SetValueType(Value::eValueTypeScalar); + + if (m_address.IsValid() && m_type_sp) + { + // The variable value is in the Scalar value inside the m_value. + // We can point our m_data right to it. + m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0); + if (m_error.Success()) + { + if (ClangASTContext::IsAggregateType (GetClangType())) + { + // this value object represents an aggregate type whose + // children have values, but this object does not. So we + // say we are changed if our location has changed. + SetValueDidChange (m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); + } + + SetValueIsValid (true); + return true; + } + } + + // We get here if we've failed above... + SetValueIsValid (false); + return false; +} + + + +bool +ValueObjectDynamicValue::IsInScope () +{ + return m_parent->IsInScope(); +} + Added: lldb/trunk/source/Core/ValueObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectMemory.cpp?rev=129623&view=auto ============================================================================== --- lldb/trunk/source/Core/ValueObjectMemory.cpp (added) +++ lldb/trunk/source/Core/ValueObjectMemory.cpp Fri Apr 15 19:01:13 2011 @@ -0,0 +1,196 @@ +//===-- ValueObjectMemory.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/Core/ValueObjectMemory.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/Module.h" +#include "lldb/Core/ValueObjectList.h" +#include "lldb/Core/Value.h" +#include "lldb/Core/ValueObject.h" + +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Symbol/Type.h" +#include "lldb/Symbol/Variable.h" + +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" + + +using namespace lldb_private; + +ValueObjectMemory::ValueObjectMemory (ExecutionContextScope *exe_scope, + const char *name, + const Address &address, + lldb::TypeSP &type_sp) : + ValueObject(exe_scope), + m_address (address), + m_type_sp(type_sp) +{ + // Do not attempt to construct one of these objects with no variable! + assert (m_type_sp.get() != NULL); + SetName (name); + m_value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get()); + lldb::addr_t load_address = m_address.GetLoadAddress(m_update_point.GetTarget()); + if (load_address != LLDB_INVALID_ADDRESS) + { + m_value.SetValueType(Value::eValueTypeLoadAddress); + m_value.GetScalar() = load_address; + } + else + { + lldb::addr_t file_address = m_address.GetFileAddress(); + if (file_address != LLDB_INVALID_ADDRESS) + { + m_value.SetValueType(Value::eValueTypeFileAddress); + m_value.GetScalar() = file_address; + } + else + { + m_value.GetScalar() = m_address.GetOffset(); + m_value.SetValueType (Value::eValueTypeScalar); + } + } +} + +ValueObjectMemory::~ValueObjectMemory() +{ +} + +lldb::clang_type_t +ValueObjectMemory::GetClangType () +{ + return m_type_sp->GetClangForwardType(); +} + +ConstString +ValueObjectMemory::GetTypeName() +{ + return m_type_sp->GetName(); +} + +uint32_t +ValueObjectMemory::CalculateNumChildren() +{ + return m_type_sp->GetNumChildren(true); +} + +clang::ASTContext * +ValueObjectMemory::GetClangAST () +{ + return m_type_sp->GetClangAST(); +} + +size_t +ValueObjectMemory::GetByteSize() +{ + return m_type_sp->GetByteSize(); +} + +lldb::ValueType +ValueObjectMemory::GetValueType() const +{ + // RETHINK: Should this be inherited from somewhere? + return lldb::eValueTypeVariableGlobal; +} + +bool +ValueObjectMemory::UpdateValue () +{ + SetValueIsValid (false); + m_error.Clear(); + + ExecutionContext exe_ctx (GetExecutionContextScope()); + + if (exe_ctx.target) + { + m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder()); + m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize()); + } + + Value old_value(m_value); + if (m_address.IsValid()) + { + Value::ValueType value_type = m_value.GetValueType(); + + switch (value_type) + { + default: + assert(!"Unhandled expression result value kind..."); + break; + + case Value::eValueTypeScalar: + // The variable value is in the Scalar value inside the m_value. + // We can point our m_data right to it. + m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0); + break; + + case Value::eValueTypeFileAddress: + case Value::eValueTypeLoadAddress: + case Value::eValueTypeHostAddress: + // The DWARF expression result was an address in the inferior + // process. If this variable is an aggregate type, we just need + // the address as the main value as all child variable objects + // will rely upon this location and add an offset and then read + // their own values as needed. If this variable is a simple + // type, we read all data for it into m_data. + // Make sure this type has a value before we try and read it + + // If we have a file address, convert it to a load address if we can. + if (value_type == Value::eValueTypeFileAddress && exe_ctx.process) + { + lldb::addr_t load_addr = m_address.GetLoadAddress(exe_ctx.target); + if (load_addr != LLDB_INVALID_ADDRESS) + { + m_value.SetValueType(Value::eValueTypeLoadAddress); + m_value.GetScalar() = load_addr; + } + } + + if (ClangASTContext::IsAggregateType (GetClangType())) + { + // this value object represents an aggregate type whose + // children have values, but this object does not. So we + // say we are changed if our location has changed. + SetValueDidChange (value_type != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); + } + else + { + // Copy the Value and set the context to use our Variable + // so it can extract read its value into m_data appropriately + Value value(m_value); + value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get()); + m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0); + } + break; + } + + SetValueIsValid (m_error.Success()); + } + return m_error.Success(); +} + + + +bool +ValueObjectMemory::IsInScope () +{ + // FIXME: Maybe try to read the memory address, and if that works, then + // we are in scope? + return true; +} + Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Apr 15 19:01:13 2011 @@ -848,7 +848,6 @@ // with with a '$' character... if (member_sp->GetName().AsCString ("!")[0] == '$' && persistent_vars.ContainsVariable(member_sp)) { - bool keep_this_in_memory = false; if (member_sp->GetName() == m_struct_vars->m_result_name) { @@ -858,7 +857,6 @@ if (result_sp_ptr) *result_sp_ptr = member_sp; - keep_this_in_memory = m_keep_result_in_memory; } if (!DoMaterializeOnePersistentVariable (dematerialize, Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Fri Apr 15 19:01:13 2011 @@ -15,6 +15,8 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Scalar.h" +#include "lldb/Core/ValueObject.h" +#include "lldb/Core/ValueObjectMemory.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -30,12 +32,134 @@ static const char *pluginName = "ItaniumABILanguageRuntime"; static const char *pluginDesc = "Itanium ABI for the C++ language"; static const char *pluginShort = "language.itanium"; +static const char *vtable_demangled_prefix = "vtable for "; -lldb::ValueObjectSP -ItaniumABILanguageRuntime::GetDynamicValue (ValueObjectSP in_value) +bool +ItaniumABILanguageRuntime::CouldHaveDynamicValue (ValueObject &in_value) +{ + return in_value.IsPointerOrReferenceType(); +} + +bool +ItaniumABILanguageRuntime::GetDynamicValue (ValueObject &in_value, lldb::TypeSP &dynamic_type_sp, Address &dynamic_address) { - ValueObjectSP ret_sp; - return ret_sp; + // For Itanium, if the type has a vtable pointer in the object, it will be at offset 0 + // in the object. That will point to the "address point" within the vtable (not the beginning of the + // vtable.) We can then look up the symbol containing this "address point" and that symbol's name + // demangled will contain the full class name. + // The second pointer above the "address point" is the "offset_to_top". We'll use that to get the + // start of the value object which holds the dynamic type. + // + + // Only a pointer or reference type can have a different dynamic and static type: + if (CouldHaveDynamicValue (in_value)) + { + // FIXME: Can we get the Clang Type and ask it if the thing is really virtual? That would avoid false positives, + // at the cost of not looking for the dynamic type of objects if DWARF->Clang gets it wrong. + + // First job, pull out the address at 0 offset from the object. + AddressType address_type; + lldb::addr_t original_ptr = in_value.GetPointerValue(address_type, true); + if (original_ptr == LLDB_INVALID_ADDRESS) + return false; + + Target *target = in_value.GetUpdatePoint().GetTarget(); + Process *process = in_value.GetUpdatePoint().GetProcess(); + + char memory_buffer[16]; + DataExtractor data(memory_buffer, sizeof(memory_buffer), + process->GetByteOrder(), + process->GetAddressByteSize()); + size_t address_byte_size = process->GetAddressByteSize(); + Error error; + size_t bytes_read = process->ReadMemory (original_ptr, + memory_buffer, + address_byte_size, + error); + if (!error.Success() || (bytes_read != address_byte_size)) + { + return false; + } + + uint32_t offset_ptr = 0; + lldb::addr_t vtable_address_point = data.GetAddress (&offset_ptr); + + if (offset_ptr == 0) + return false; + + // Now find the symbol that contains this address: + + SymbolContext sc; + Address address_point_address; + if (target && !target->GetSectionLoadList().IsEmpty()) + { + if (target->GetSectionLoadList().ResolveLoadAddress (vtable_address_point, address_point_address)) + { + target->GetImages().ResolveSymbolContextForAddress (address_point_address, eSymbolContextSymbol, sc); + Symbol *symbol = sc.symbol; + if (symbol != NULL) + { + const char *name = symbol->GetMangled().GetDemangledName().AsCString(); + if (strstr(name, vtable_demangled_prefix) == name) + { + // We are a C++ class, that's good. Get the class name and look it up: + const char *class_name = name + strlen(vtable_demangled_prefix); + TypeList class_types; + uint32_t num_matches = target->GetImages().FindTypes (sc, + ConstString(class_name), + true, + UINT32_MAX, + class_types); + if (num_matches == 1) + { + dynamic_type_sp = class_types.GetTypeAtIndex(0); + } + else if (num_matches > 1) + { + // How to sort out which of the type matches to pick? + } + + if (!dynamic_type_sp) + return false; + + // The offset_to_top is two pointers above the address. + Address offset_to_top_address = address_point_address; + int64_t slide = -2 * ((int64_t) target->GetArchitecture().GetAddressByteSize()); + offset_to_top_address.Slide (slide); + + Error error; + lldb::addr_t offset_to_top_location = offset_to_top_address.GetLoadAddress(target); + + size_t bytes_read = process->ReadMemory (offset_to_top_location, + memory_buffer, + address_byte_size, + error); + + if (!error.Success() || (bytes_read != address_byte_size)) + { + return false; + } + + offset_ptr = 0; + int64_t offset_to_top = data.GetMaxS64(&offset_ptr, process->GetAddressByteSize()); + + // So the dynamic type is a value that starts at offset_to_top + // above the original address. + lldb::addr_t dynamic_addr = original_ptr + offset_to_top; + if (!target->GetSectionLoadList().ResolveLoadAddress (dynamic_addr, dynamic_address)) + { + dynamic_address.SetOffset(dynamic_addr); + dynamic_address.SetSection(NULL); + } + return true; + } + } + } + } + + } + + return false; } bool Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h Fri Apr 15 19:01:13 2011 @@ -30,9 +30,12 @@ virtual bool IsVTableName (const char *name); - virtual lldb::ValueObjectSP - GetDynamicValue (lldb::ValueObjectSP in_value); - + virtual bool + GetDynamicValue (ValueObject &in_value, lldb::TypeSP &type_sp, Address &address); + + virtual bool + CouldHaveDynamicValue (ValueObject &in_value); + //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ 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=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Fri Apr 15 19:01:13 2011 @@ -191,11 +191,16 @@ return m_PrintForDebugger_addr.get(); } -lldb::ValueObjectSP -AppleObjCRuntime::GetDynamicValue (lldb::ValueObjectSP in_value) +bool +AppleObjCRuntime::CouldHaveDynamicValue (ValueObject &in_value) +{ + return in_value.IsPointerType(); +} + +bool +AppleObjCRuntime::GetDynamicValue (ValueObject &in_value, lldb::TypeSP &type_sp, Address &address) { - lldb::ValueObjectSP ret_sp; - return ret_sp; + return false; } bool Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h Fri Apr 15 19:01:13 2011 @@ -37,8 +37,11 @@ virtual bool GetObjectDescription (Stream &str, ValueObject &object); - virtual lldb::ValueObjectSP - GetDynamicValue (lldb::ValueObjectSP in_value); + virtual bool + CouldHaveDynamicValue (ValueObject &in_value); + + virtual bool + GetDynamicValue (ValueObject &in_value, lldb::TypeSP &type_sp, Address &address); // These are the ObjC specific functions. Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Fri Apr 15 19:01:13 2011 @@ -40,11 +40,10 @@ static const char *pluginDesc = "Apple Objective C Language Runtime - Version 1"; static const char *pluginShort = "language.apple.objc.v1"; -lldb::ValueObjectSP -AppleObjCRuntimeV1::GetDynamicValue (lldb::ValueObjectSP in_value) +bool +AppleObjCRuntimeV1::GetDynamicValue (ValueObject &in_value, lldb::TypeSP &type_sp, Address &address) { - lldb::ValueObjectSP ret_sp; - return ret_sp; + return false; } //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h Fri Apr 15 19:01:13 2011 @@ -31,8 +31,8 @@ ~AppleObjCRuntimeV1() { } // These are generic runtime functions: - virtual lldb::ValueObjectSP - GetDynamicValue (lldb::ValueObjectSP in_value); + virtual bool + GetDynamicValue (ValueObject &in_value, lldb::TypeSP &type_sp, Address &address); virtual ClangUtilityFunction * CreateObjectChecker (const char *); Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Fri Apr 15 19:01:13 2011 @@ -46,11 +46,10 @@ m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(ConstString("gdb_object_getClass")) != NULL); } -lldb::ValueObjectSP -AppleObjCRuntimeV2::GetDynamicValue (lldb::ValueObjectSP in_value) +bool +AppleObjCRuntimeV2::GetDynamicValue (ValueObject &in_value, lldb::TypeSP &type_sp, Address &address) { - lldb::ValueObjectSP ret_sp; - return ret_sp; + return false; } //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Fri Apr 15 19:01:13 2011 @@ -31,8 +31,8 @@ ~AppleObjCRuntimeV2() { } // These are generic runtime functions: - virtual lldb::ValueObjectSP - GetDynamicValue (lldb::ValueObjectSP in_value); + virtual bool + GetDynamicValue (ValueObject &in_value, lldb::TypeSP &type_sp, Address &address); virtual ClangUtilityFunction * CreateObjectChecker (const char *); Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Fri Apr 15 19:01:13 2011 @@ -1902,6 +1902,12 @@ if (buf == NULL || size == 0) return 0; + + // Need to bump the stop ID after writing so that ValueObjects will know to re-read themselves. + // FUTURE: Doing this should be okay, but if anybody else gets upset about the stop_id changing when + // the target hasn't run, then we will need to add a "memory generation" as well as a stop_id... + m_stop_id++; + // We need to write any data that would go where any current software traps // (enabled software breakpoints) any software traps (breakpoints) that we // may have placed in our tasks memory. @@ -1962,7 +1968,7 @@ ubuf + bytes_written, size - bytes_written, error); - + return bytes_written; } Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Fri Apr 15 19:01:13 2011 @@ -493,6 +493,7 @@ { const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0; const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0; + const bool dynamic_value = (options & eExpressionPathOptionsDynamicValue) != 0; error.Clear(); bool deref = false; bool address_of = false; @@ -528,8 +529,10 @@ VariableSP var_sp (variable_list->FindVariable(name_const_string)); if (var_sp) { - valobj_sp = GetValueObjectForFrameVariable (var_sp); - + valobj_sp = GetValueObjectForFrameVariable (var_sp, dynamic_value); + if (!valobj_sp) + return valobj_sp; + var_path.erase (0, name_const_string.GetLength ()); // We are dumping at least one child while (separator_idx != std::string::npos) @@ -600,7 +603,6 @@ return ValueObjectSP(); } } - child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); if (!child_valobj_sp) { @@ -624,6 +626,12 @@ } // Remove the child name from the path var_path.erase(0, child_name.GetLength()); + if (dynamic_value) + { + ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(true, child_valobj_sp)); + if (dynamic_value_sp) + child_valobj_sp = dynamic_value_sp; + } } break; @@ -650,6 +658,8 @@ } else if (ClangASTContext::IsArrayType (valobj_sp->GetClangType(), NULL, NULL)) { + // Pass false to dynamic_value here so we can tell the difference between + // no dynamic value and no member of this type... child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); if (!child_valobj_sp) { @@ -678,7 +688,12 @@ // %i is the array index var_path.erase(0, (end - var_path.c_str()) + 1); separator_idx = var_path.find_first_of(".-["); - + if (dynamic_value) + { + ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(true, child_valobj_sp)); + if (dynamic_value_sp) + child_valobj_sp = dynamic_value_sp; + } // Break out early from the switch since we were // able to find the child member break; @@ -794,7 +809,7 @@ ValueObjectSP -StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp) +StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, bool use_dynamic) { ValueObjectSP valobj_sp; VariableList *var_list = GetVariableList (true); @@ -815,14 +830,20 @@ } } } + if (use_dynamic && valobj_sp) + { + ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (true, valobj_sp); + if (dynamic_sp) + return dynamic_sp; + } return valobj_sp; } ValueObjectSP -StackFrame::TrackGlobalVariable (const VariableSP &variable_sp) +StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, bool use_dynamic) { // Check to make sure we aren't already tracking this variable? - ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp)); + ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp, use_dynamic)); if (!valobj_sp) { // We aren't already tracking this global @@ -835,7 +856,7 @@ m_variable_list_sp->AddVariable (variable_sp); // Now make a value object for it so we can track its changes - valobj_sp = GetValueObjectForFrameVariable (variable_sp); + valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic); } return valobj_sp; } Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Fri Apr 15 19:01:13 2011 @@ -887,6 +887,7 @@ StackFrame *frame, bool unwind_on_error, bool keep_in_memory, + bool fetch_dynamic_value, lldb::ValueObjectSP &result_valobj_sp ) { @@ -927,7 +928,16 @@ const_valobj_sp->SetName (persistent_variable_name); } else + { + if (fetch_dynamic_value) + { + ValueObjectSP dynamic_sp = result_valobj_sp->GetDynamicValue(true, result_valobj_sp); + if (dynamic_sp) + result_valobj_sp = dynamic_sp; + } + const_valobj_sp = result_valobj_sp->CreateConstantValue (persistent_variable_name); + } lldb::ValueObjectSP live_valobj_sp = result_valobj_sp; @@ -1277,11 +1287,12 @@ } -#define TSC_DEFAULT_ARCH "default-arch" -#define TSC_EXPR_PREFIX "expr-prefix" -#define TSC_EXEC_LEVEL "execution-level" -#define TSC_EXEC_MODE "execution-mode" -#define TSC_EXEC_OS_TYPE "execution-os-type" +#define TSC_DEFAULT_ARCH "default-arch" +#define TSC_EXPR_PREFIX "expr-prefix" +#define TSC_EXEC_LEVEL "execution-level" +#define TSC_EXEC_MODE "execution-mode" +#define TSC_EXEC_OS_TYPE "execution-os-type" +#define TSC_PREFER_DYNAMIC "prefer-dynamic-value" static const ConstString & @@ -1320,6 +1331,13 @@ return g_const_string; } +static const ConstString & +GetSettingNameForPreferDynamicValue () +{ + static ConstString g_const_string (TSC_PREFER_DYNAMIC); + return g_const_string; +} + bool Target::SettingsController::SetGlobalVariable (const ConstString &var_name, @@ -1369,7 +1387,8 @@ ) : InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance), m_expr_prefix_path (), - m_expr_prefix_contents () + m_expr_prefix_contents (), + m_prefer_dynamic_value (true) { // 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. @@ -1467,6 +1486,39 @@ return; } } + else if (var_name == GetSettingNameForPreferDynamicValue()) + { + switch (op) + { + default: + err.SetErrorToGenericError (); + err.SetErrorString ("Unrecognized operation. Cannot update value.\n"); + return; + case eVarSetOperationAssign: + { + bool success; + bool result = Args::StringToBoolean(value, false, &success); + + if (success) + { + m_prefer_dynamic_value = result; + } + else + { + err.SetErrorStringWithFormat ("Bad value \"%s\" for %s, should be Boolean.", + value, + GetSettingNameForPreferDynamicValue().AsCString()); + } + return; + } + case eVarSetOperationClear: + m_prefer_dynamic_value = true; + case eVarSetOperationAppend: + err.SetErrorToGenericError (); + err.SetErrorString ("Cannot append to a bool.\n"); + return; + } + } } void @@ -1479,6 +1531,7 @@ m_expr_prefix_path = new_settings_ptr->m_expr_prefix_path; m_expr_prefix_contents = new_settings_ptr->m_expr_prefix_contents; + m_prefer_dynamic_value = new_settings_ptr->m_prefer_dynamic_value; } bool @@ -1491,6 +1544,13 @@ { value.AppendString (m_expr_prefix_path.c_str(), m_expr_prefix_path.size()); } + else if (var_name == GetSettingNameForPreferDynamicValue()) + { + if (m_prefer_dynamic_value) + value.AppendString ("true"); + else + value.AppendString ("false"); + } else { if (err) @@ -1533,5 +1593,6 @@ // var-name var-type default enum init'd hidden help-text // ================= ================== =========== ==== ====== ====== ========================================================================= { TSC_EXPR_PREFIX , eSetVarTypeString , NULL , NULL, false, false, "Path to a file containing expressions to be prepended to all expressions." }, + { TSC_PREFER_DYNAMIC, eSetVarTypeBoolean ,"true" , NULL, false, false, "Should printed values be shown as their dynamic value." }, { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL } }; Modified: lldb/trunk/source/Target/ThreadPlanTestCondition.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTestCondition.cpp?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTestCondition.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Fri Apr 15 19:01:13 2011 @@ -84,8 +84,8 @@ if (result_sp) { // FIXME: This is not the right answer, we should have a "GetValueAsBoolean..." - Scalar scalar_value = result_sp->GetValue().ResolveValue (&m_exe_ctx, result_sp->GetClangAST()); - if (scalar_value.IsValid()) + Scalar scalar_value; + if (result_sp->ResolveValue (scalar_value)) { if (scalar_value.ULongLong(1) == 0) m_did_stop = false; Added: lldb/trunk/test/cpp/dynamic-value/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/Makefile?rev=129623&view=auto ============================================================================== --- lldb/trunk/test/cpp/dynamic-value/Makefile (added) +++ lldb/trunk/test/cpp/dynamic-value/Makefile Fri Apr 15 19:01:13 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := pass-to-base.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py?rev=129623&view=auto ============================================================================== --- lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py (added) +++ lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py Fri Apr 15 19:01:13 2011 @@ -0,0 +1,226 @@ +""" +Use lldb Python API to test dynamic values in C++ +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class DynamicValueTestCase(TestBase): + + mydir = os.path.join("cpp", "dynamic-value") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_get_dynamic_vals_with_dsym(self): + """Test fetching C++ dynamic values from pointers & references.""" + self.buildDsym() + self.do_get_dynamic_vals() + + @python_api_test + def test_get_dynamic_vals_with_dwarf(self): + """Test fetching C++ dynamic values from pointers & references.""" + self.buildDwarf() + self.do_get_dynamic_vals() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + # Find the line number to break for main.c. + + self.do_something_line = line_number('pass-to-base.cpp', '// Break here in doSomething.') + self.main_first_call_line = line_number('pass-to-base.cpp', + '// Break here and get real addresses of myB and otherB.') + self.main_second_call_line = line_number('pass-to-base.cpp', + '// Break here and get real address of reallyA.') + + def examine_value_object_of_this_ptr (self, this_static, this_dynamic, dynamic_location): + + # Get "this" as its static value + + self.assertTrue (this_static.IsValid()) + this_static_loc = int (this_static.GetValue(), 16) + + # Get "this" as its dynamic value + + self.assertTrue (this_dynamic.IsValid()) + this_dynamic_typename = this_dynamic.GetTypeName() + self.assertTrue (this_dynamic_typename.find('B') != -1) + this_dynamic_loc = int (this_dynamic.GetValue(), 16) + + # Make sure we got the right address for "this" + + self.assertTrue (this_dynamic_loc == dynamic_location) + + # And that the static address is greater than the dynamic one + + self.assertTrue (this_static_loc > this_dynamic_loc) + + # Now read m_b_value which is only in the dynamic value: + + this_dynamic_m_b_value = this_dynamic.GetChildMemberWithName('m_b_value', True) + self.assertTrue (this_dynamic_m_b_value.IsValid()) + + m_b_value = int (this_dynamic_m_b_value.GetValue(), 0) + self.assertTrue (m_b_value == 10) + + # Make sure it is not in the static version + + this_static_m_b_value = this_static.GetChildMemberWithName('m_b_value', False) + self.assertTrue (this_static_m_b_value.IsValid() == False) + + # Okay, now let's make sure that we can get the dynamic type of a child element: + + contained_auto_ptr = this_dynamic.GetChildMemberWithName ('m_client_A', True) + self.assertTrue (contained_auto_ptr.IsValid()) + contained_b = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', True) + self.assertTrue (contained_b.IsValid()) + + contained_b_static = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', False) + self.assertTrue (contained_b_static.IsValid()) + + contained_b_addr = int (contained_b.GetValue(), 16) + contained_b_static_addr = int (contained_b_static.GetValue(), 16) + + self.assertTrue (contained_b_addr < contained_b_static_addr) + + def do_get_dynamic_vals(self): + """Get argument vals for the call stack when stopped on a breakpoint.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target from the debugger. + + target = self.dbg.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Set up our breakpoints: + + do_something_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.do_something_line) + self.assertTrue(do_something_bpt.IsValid() and + do_something_bpt.GetNumLocations() == 1, + VALID_BREAKPOINT) + + first_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_first_call_line) + self.assertTrue(first_call_bpt.IsValid() and + first_call_bpt.GetNumLocations() == 1, + VALID_BREAKPOINT) + + second_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_second_call_line) + self.assertTrue(second_call_bpt.IsValid() and + second_call_bpt.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at the entry point. + + error = lldb.SBError() + self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) + + self.assertTrue(self.process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + + threads = lldbutil.GetThreadsStoppedAtBreakpoint (self.process, first_call_bpt) + self.assertTrue (len(threads) == 1) + thread = threads[0] + + frame = thread.GetFrameAtIndex(0) + + # Now find the dynamic addresses of myB and otherB so we can compare them + # with the dynamic values we get in doSomething: + + noDynamic = False + useDynamic = True + + myB = frame.FindVariable ('myB', noDynamic); + self.assertTrue (myB.IsValid()) + myB_loc = int (myB.GetLocation(), 16) + + otherB = frame.FindVariable('otherB', noDynamic) + self.assertTrue (otherB.IsValid()) + otherB_loc = int (otherB.GetLocation(), 16) + + # Okay now run to doSomething: + + threads = lldbutil.ContinueToBreakpoint (self.process, do_something_bpt) + self.assertTrue (len(threads) == 1) + thread = threads[0] + + frame = thread.GetFrameAtIndex(0) + + # Get "this" using FindVariable: + + this_static = frame.FindVariable ('this', noDynamic) + this_dynamic = frame.FindVariable ('this', useDynamic) + self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) + + # Get "this" using FindValue, make sure that works too: + this_static = frame.FindValue ('this', lldb.eValueTypeVariableArgument, noDynamic) + this_dynamic = frame.FindValue ('this', lldb.eValueTypeVariableArgument, useDynamic) + self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) + + # Get "this" using the EvaluateExpression: + # These tests fail for now because EvaluateExpression doesn't currently support dynamic typing... + #this_static = frame.EvaluateExpression ('this', False) + #this_dynamic = frame.EvaluateExpression ('this', True) + #self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) + + # The "frame var" code uses another path to get into children, so let's + # make sure that works as well: + + self.expect('frame var -d 1 anotherA.m_client_A._M_ptr', 'frame var finds its way into a child member', + patterns = ['\(.* B \*\)']) + + # Now make sure we also get it right for a reference as well: + + anotherA_static = frame.FindVariable ('anotherA', False) + self.assertTrue (anotherA_static.IsValid()) + anotherA_static_addr = int (anotherA_static.GetValue(), 16) + + anotherA_dynamic = frame.FindVariable ('anotherA', True) + self.assertTrue (anotherA_dynamic.IsValid()) + anotherA_dynamic_addr = int (anotherA_dynamic.GetValue(), 16) + anotherA_dynamic_typename = anotherA_dynamic.GetTypeName() + self.assertTrue (anotherA_dynamic_typename.find('B') != -1) + + self.assertTrue(anotherA_dynamic_addr < anotherA_static_addr) + + anotherA_m_b_value_dynamic = anotherA_dynamic.GetChildMemberWithName('m_b_value', True) + self.assertTrue (anotherA_m_b_value_dynamic.IsValid()) + anotherA_m_b_val = int (anotherA_m_b_value_dynamic.GetValue(), 10) + self.assertTrue (anotherA_m_b_val == 300) + + anotherA_m_b_value_static = anotherA_static.GetChildMemberWithName('m_b_value', True) + self.assertTrue (anotherA_m_b_value_static.IsValid() == False) + + # Okay, now continue again, and when we hit the second breakpoint in main + + threads = lldbutil.ContinueToBreakpoint (self.process, second_call_bpt) + self.assertTrue (len(threads) == 1) + thread = threads[0] + + frame = thread.GetFrameAtIndex(0) + reallyA_value = frame.FindVariable ('reallyA', False) + self.assertTrue(reallyA_value.IsValid()) + reallyA_loc = int (reallyA_value.GetLocation(), 16) + + # Finally continue to doSomething again, and make sure we get the right value for anotherA, + # which this time around is just an "A". + + threads = lldbutil.ContinueToBreakpoint (self.process, do_something_bpt) + self.assertTrue(len(threads) == 1) + thread = threads[0] + + frame = thread.GetFrameAtIndex(0) + anotherA_value = frame.FindVariable ('anotherA', True) + self.assertTrue(anotherA_value.IsValid()) + anotherA_loc = int (anotherA_value.GetValue(), 16) + self.assertTrue (anotherA_loc == reallyA_loc) + self.assertTrue (anotherA_value.GetTypeName().find ('B') == -1) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp?rev=129623&view=auto ============================================================================== --- lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp (added) +++ lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp Fri Apr 15 19:01:13 2011 @@ -0,0 +1,62 @@ +#include +#include + +class Extra +{ +public: + Extra (int in_one, int in_two) : m_extra_one(in_one), m_extra_two(in_two) {} + +private: + int m_extra_one; + int m_extra_two; +}; + +class A +{ +public: + A(int value) : m_a_value (value) {} + A(int value, A* client_A) : m_a_value (value), m_client_A (client_A) {} + + virtual void + doSomething (A &anotherA) + { + printf ("In A %p doing something with %d.\n", this, m_a_value); + printf ("Also have another A at %p: %d.\n", &anotherA, anotherA.Value()); // Break here in doSomething. + } + + int + Value() + { + return m_a_value; + } + +private: + int m_a_value; + std::auto_ptr m_client_A; +}; + +class B : public Extra, public virtual A +{ +public: + B (int b_value, int a_value) : Extra(b_value, a_value), A(a_value), m_b_value(b_value) {} + B (int b_value, int a_value, A *client_A) : Extra(b_value, a_value), A(a_value, client_A), m_b_value(b_value) {} +private: + int m_b_value; +}; + +static A* my_global_A_ptr; + +int +main (int argc, char **argv) +{ + my_global_A_ptr = new B (100, 200); + B myB (10, 20, my_global_A_ptr); + B otherB (300, 400, my_global_A_ptr); + + myB.doSomething(otherB); // Break here and get real addresses of myB and otherB. + + A reallyA (500); + myB.doSomething (reallyA); // Break here and get real address of reallyA. + + return 0; +} Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Fri Apr 15 19:01:13 2011 @@ -383,3 +383,30 @@ if string_buffer: return output.getvalue() + +def GetThreadsStoppedAtBreakpoint (process, bkpt): + """ For a stopped process returns the thread stopped at the breakpoint passed in in bkpt""" + stopped_threads = [] + threads = [] + + stopped_threads = get_stopped_threads (process, lldb.eStopReasonBreakpoint) + + if len(stopped_threads) == 0: + return threads + + for thread in stopped_threads: + # Make sure we've hit our breakpoint... + break_id = thread.GetStopReasonDataAtIndex (0) + if break_id == bkpt.GetID(): + threads.append(thread) + + return threads + +def ContinueToBreakpoint (process, bkpt): + """ Continues the process, when it stops, if there is a thread stopped at bkpt, returns that thread""" + process.Continue() + if process.GetState() != lldb.eStateStopped: + return None + else: + return GetThreadsStoppedAtBreakpoint (process, bkpt) + Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/TestProcessAPI.py?rev=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/TestProcessAPI.py (original) +++ lldb/trunk/test/python_api/process/TestProcessAPI.py Fri Apr 15 19:01:13 2011 @@ -209,7 +209,13 @@ if not error.Success() or result != byteSize: self.fail("SBProcess.WriteMemory() failed") - # Get the SBValue for the global variable 'my_int' again, with its updated value. + # Make sure that the val we got originally updates itself to notice the change: + self.expect(val.GetValue(frame), + "SBProcess.ReadMemory() successfully writes (int)256 to the memory location for 'my_int'", + exe=False, + startstr = '256') + + # And for grins, get the SBValue for the global variable 'my_int' again, to make sure that also tracks the new value: val = frame.FindValue("my_int", lldb.eValueTypeVariableGlobal) self.expect(val.GetValue(frame), "SBProcess.ReadMemory() successfully writes (int)256 to the memory location for 'my_int'", 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=129623&r1=129622&r2=129623&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Apr 15 19:01:13 2011 @@ -551,7 +551,6 @@ "-llockdown", ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; - PREBINDING = NO; PRODUCT_NAME = debugserver; STRIP_INSTALLED_PRODUCT = YES; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; @@ -592,7 +591,6 @@ "-llockdown", ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; - PREBINDING = NO; PRODUCT_NAME = debugserver; "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; @@ -633,7 +631,6 @@ "-llockdown", ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; - PREBINDING = NO; PRODUCT_NAME = debugserver; "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; From mminutoli at gmail.com Sat Apr 16 18:09:47 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Sun, 17 Apr 2011 01:09:47 +0200 Subject: [Lldb-commits] [PATCH 1/2] NameSearchContext warning. Message-ID: <1302995388-16520-1-git-send-email-mminutoli@gmail.com> NameSearchContext is declared as a struct this solve the warning. --- include/lldb/lldb-forward.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h index ed6e8b3..8e861f6 100644 --- a/include/lldb/lldb-forward.h +++ b/include/lldb/lldb-forward.h @@ -94,7 +94,7 @@ class Mangled; class Module; class ModuleList; class Mutex; -class NameSearchContext; +struct NameSearchContext; class ObjCLanguageRuntime; class ObjectContainer; class ObjectFile; -- 1.7.1 From mminutoli at gmail.com Sat Apr 16 18:09:48 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Sun, 17 Apr 2011 01:09:48 +0200 Subject: [Lldb-commits] [PATCH 2/2] Some fixes for different sign in comparison. In-Reply-To: <1302995388-16520-1-git-send-email-mminutoli@gmail.com> References: <1302995388-16520-1-git-send-email-mminutoli@gmail.com> Message-ID: <1302995388-16520-2-git-send-email-mminutoli@gmail.com> This patch solves some of the warning due to comparison of integers of different signs. \e isn't portable so I replaced it with its octal value. --- source/Core/DataExtractor.cpp | 10 ++-- source/Core/Opcode.cpp | 2 +- source/Core/UserSettingsController.cpp | 52 +++++++++++++------------- source/Expression/ClangExpressionDeclMap.cpp | 2 +- source/Expression/ClangExpressionParser.cpp | 2 +- source/Expression/IRForTarget.cpp | 2 +- source/Host/common/FileSpec.cpp | 2 +- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/source/Core/DataExtractor.cpp b/source/Core/DataExtractor.cpp index 4119828..882cbf7 100644 --- a/source/Core/DataExtractor.cpp +++ b/source/Core/DataExtractor.cpp @@ -780,7 +780,7 @@ DataExtractor::GetFloat (uint32_t *offset_ptr) const if (m_byte_order != lldb::endian::InlHostByteOrder()) { uint8_t *dst_data = (uint8_t *)&val; - for (int i=0; iPrintf ("\\e", (uint8_t)ch); break; + case '\033': s->Printf ("\\e", (uint8_t)ch); break; case '\a': s->Printf ("\\a", ch); break; case '\b': s->Printf ("\\b", ch); break; case '\f': s->Printf ("\\f", ch); break; @@ -1351,7 +1351,7 @@ DataExtractor::Dump { switch (ch) { - case '\e': s->Printf ("\\e", (uint8_t)ch); break; + case '\033': s->Printf ("\\e", (uint8_t)ch); break; case '\a': s->Printf ("\\a", ch); break; case '\b': s->Printf ("\\b", ch); break; case '\f': s->Printf ("\\f", ch); break; diff --git a/source/Core/Opcode.cpp b/source/Core/Opcode.cpp index b765bf7..e24647a 100644 --- a/source/Core/Opcode.cpp +++ b/source/Core/Opcode.cpp @@ -22,7 +22,7 @@ using namespace lldb_private; int Opcode::Dump (Stream *s, uint32_t min_byte_width) { - int bytes_written = 0; + size_t bytes_written = 0; switch (m_type) { case Opcode::eTypeInvalid: diff --git a/source/Core/UserSettingsController.cpp b/source/Core/UserSettingsController.cpp index 60c2aa3..6fa7676 100644 --- a/source/Core/UserSettingsController.cpp +++ b/source/Core/UserSettingsController.cpp @@ -211,7 +211,7 @@ const SettingEntry * UserSettingsController::GetGlobalEntry (const ConstString &var_name) { - for (int i = 0; i < m_settings.global_settings.size(); ++i) + for (size_t i = 0; i < m_settings.global_settings.size(); ++i) { const SettingEntry &entry = m_settings.global_settings[i]; ConstString entry_name (entry.var_name); @@ -226,7 +226,7 @@ const SettingEntry * UserSettingsController::GetInstanceEntry (const ConstString &const_var_name) { - for (int i = 0; i < m_settings.instance_settings.size(); ++i) + for (size_t i = 0; i < m_settings.instance_settings.size(); ++i) { SettingEntry &entry = m_settings.instance_settings[i]; ConstString entry_name (entry.var_name); @@ -500,7 +500,7 @@ UserSettingsController::SetVariable (const char *full_dot_name, { found = true; std::string new_name; - for (int j = 0; j < names.GetArgumentCount(); ++j) + for (size_t j = 0; j < names.GetArgumentCount(); ++j) { if (j > 0) new_name += '.'; @@ -568,14 +568,14 @@ UserSettingsController::GetVariable { ConstString child_prefix (names.GetArgumentAtIndex (0)); bool found = false; - for (int i = 0; i < m_children.size() && !found; ++i) + for (size_t i = 0; i < m_children.size() && !found; ++i) { if (child_prefix == m_children[i]->GetLevelName()) { found = true; child = m_children[i]; std::string new_name; - for (int j = 0; j < names.GetArgumentCount(); ++j) + for (size_t j = 0; j < names.GetArgumentCount(); ++j) { if (j > 0) new_name += '.'; @@ -727,7 +727,7 @@ UserSettingsController::CreateDefaultInstanceSettings () { Error err; const ConstString &default_name = InstanceSettings::GetDefaultName(); - for (int i = 0; i < m_settings.instance_settings.size(); ++i) + for (size_t i = 0; i < m_settings.instance_settings.size(); ++i) { SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); @@ -747,7 +747,7 @@ UserSettingsController::CopyDefaultSettings (const InstanceSettingsSP &actual_se bool pending) { Error err; - for (int i = 0; i < m_settings.instance_settings.size(); ++i) + for (size_t i = 0; i < m_settings.instance_settings.size(); ++i) { SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); @@ -759,7 +759,7 @@ UserSettingsController::CopyDefaultSettings (const InstanceSettingsSP &actual_se value_str.append (value.GetStringAtIndex (0)); else if (value.GetSize() > 1) { - for (int j = 0; j < value.GetSize(); ++j) + for (size_t j = 0; j < value.GetSize(); ++j) { if (j > 0) value_str.append (" "); @@ -808,7 +808,7 @@ UserSettingsController::GetAllDefaultSettingValues (Stream &result_stream) BuildParentPrefix (parent_prefix); const char *prefix = parent_prefix.c_str(); - for (int i = 0; i < m_settings.instance_settings.size(); ++i) + for (size_t i = 0; i < m_settings.instance_settings.size(); ++i) { SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); @@ -822,7 +822,7 @@ UserSettingsController::GetAllDefaultSettingValues (Stream &result_stream) value_string.Printf ("%s", tmp_value.GetStringAtIndex (0)); else { - for (int j = 0; j < tmp_value.GetSize(); ++j) + for (size_t j = 0; j < tmp_value.GetSize(); ++j) { if (entry.var_type == eSetVarTypeArray) value_string.Printf ("\n [%d]: '%s'", j, tmp_value.GetStringAtIndex (j)); @@ -860,7 +860,7 @@ UserSettingsController::GetAllPendingSettingValues (Stream &result_stream) const ConstString instance_name (tmp_name.c_str()); - for (int i = 0; i < m_settings.instance_settings.size(); ++i) + for (size_t i = 0; i < m_settings.instance_settings.size(); ++i) { SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); @@ -875,7 +875,7 @@ UserSettingsController::GetAllPendingSettingValues (Stream &result_stream) value_str.Printf ("%s", tmp_value.GetStringAtIndex (0)); else { - for (int j = 0; j < tmp_value.GetSize(); ++j) + for (size_t j = 0; j < tmp_value.GetSize(); ++j) value_str.Printf ("%s ", tmp_value.GetStringAtIndex (j)); } @@ -926,7 +926,7 @@ UserSettingsController::GetAllInstanceVariableValues (CommandInterpreter &interp std::string instance_name = pos->first; InstanceSettings *settings = pos->second; - for (int i = 0; i < m_settings.instance_settings.size(); ++i) + for (size_t i = 0; i < m_settings.instance_settings.size(); ++i) { SettingEntry &entry = m_settings.instance_settings[i]; const ConstString var_name (entry.var_name); @@ -940,7 +940,7 @@ UserSettingsController::GetAllInstanceVariableValues (CommandInterpreter &interp tmp_value_str.Printf ("%s", tmp_value.GetStringAtIndex (0)); else { - for (int j = 0; j < tmp_value.GetSize(); ++j) + for (size_t j = 0; j < tmp_value.GetSize(); ++j) tmp_value_str.Printf ("%s ",tmp_value.GetStringAtIndex (j)); } @@ -1042,7 +1042,7 @@ FindMaxNameLength (std::vector table) { int max_length = 1; - for (int i = 0; i < table.size(); ++i) + for (size_t i = 0; i < table.size(); ++i) { int len = strlen (table[i].var_name); if (len > max_length) @@ -1382,11 +1382,11 @@ UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter, Error &err) { StreamString description; - int num_entries = root->m_settings.global_settings.size(); + size_t num_entries = root->m_settings.global_settings.size(); SettableVariableType var_type; - for (int i = 0; i < num_entries; ++i) + for (size_t i = 0; i < num_entries; ++i) { StreamString full_var_name; const SettingEntry &entry = root->m_settings.global_settings[i]; @@ -1403,7 +1403,7 @@ UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter, else { description.Printf ("%s (%s):\n", full_var_name.GetData(), GetTypeString (entry.var_type)); - for (int j = 0; j < value.GetSize(); ++j) + for (size_t j = 0; j < value.GetSize(); ++j) if (entry.var_type == eSetVarTypeArray) description.Printf (" [%d]: '%s'\n", j, value.GetStringAtIndex (j)); else if (entry.var_type == eSetVarTypeDictionary) @@ -1581,7 +1581,7 @@ UserSettingsController::BooleanMatches (const char *partial_value, } else { - int partial_len = strlen (partial_value); + size_t partial_len = strlen (partial_value); if ((partial_len <= true_string.length()) && (true_string.find (partial_value) == 0)) @@ -1604,7 +1604,7 @@ UserSettingsController::EnumMatches (const char *partial_value, bool &word_complete, StringList &matches) { - int len = (partial_value != NULL) ? strlen (partial_value) : 0; + size_t len = (partial_value != NULL) ? strlen (partial_value) : 0; int i = 0; while (enum_values[i].string_value != NULL) @@ -1783,7 +1783,7 @@ UserSettingsController::GlobalVariableMatches (const char *partial_name, const std::string &complete_prefix, StringList &matches) { - int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0; + size_t partial_len = (partial_name != NULL) ? strlen (partial_name) : 0; int num_matches = 0; for (size_t i = 0; i < m_settings.global_settings.size(); ++i) @@ -1814,7 +1814,7 @@ UserSettingsController::InstanceVariableMatches (const char *partial_name, const char *instance_name, StringList &matches) { - int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0; + size_t partial_len = (partial_name != NULL) ? strlen (partial_name) : 0; int num_matches = 0; for (size_t i = 0; i < m_settings.instance_settings.size(); ++i) @@ -1857,7 +1857,7 @@ UserSettingsController::LiveInstanceMatches (const char *partial_name, bool &word_complete, StringList &matches) { - int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0; + size_t partial_len = (partial_name != NULL) ? strlen (partial_name) : 0; int num_matches = 0; std::map::iterator pos; @@ -1890,7 +1890,7 @@ UserSettingsController::ChildMatches (const char *partial_name, bool &word_complete, StringList &matches) { - int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0; + size_t partial_len = (partial_name != NULL) ? strlen (partial_name) : 0; int num_children = GetNumChildren(); int num_matches = 0; for (int i = 0; i < num_children; ++i) @@ -2027,7 +2027,7 @@ UserSettingsController::UpdateStringArrayVariable (VarSetOperationType op, if (index_value != NULL) { - for (int i = 0; i < strlen(index_value); ++i) + for (size_t i = 0; i < strlen(index_value); ++i) if (!isdigit (index_value[i])) { valid_index = false; @@ -2066,7 +2066,7 @@ UserSettingsController::UpdateStringArrayVariable (VarSetOperationType op, Args new_array (new_value); if (op == eVarSetOperationInsertAfter) ++index; - for (int i = 0; i < new_array.GetArgumentCount(); ++i) + for (size_t i = 0; i < new_array.GetArgumentCount(); ++i) array_var.InsertArgumentAtIndex (index, new_array.GetArgumentAtIndex (i)); } break; diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp index 0054a03..6fb0bdb 100644 --- a/source/Expression/ClangExpressionDeclMap.cpp +++ b/source/Expression/ClangExpressionDeclMap.cpp @@ -166,7 +166,7 @@ ClangExpressionDeclMap::BuildIntegerVariable (const ConstString &name, if (num_bytes > num_data_bytes) num_bytes = num_data_bytes; - for (off_t byte_idx = 0; + for (size_t byte_idx = 0; byte_idx < num_bytes; ++byte_idx) { diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp index 0d693ce..1509e43 100644 --- a/source/Expression/ClangExpressionParser.cpp +++ b/source/Expression/ClangExpressionParser.cpp @@ -248,7 +248,7 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope, std::string triple = target->GetArchitecture().GetTriple().str(); int dash_count = 0; - for (int i = 0; i < triple.size(); ++i) + for (size_t i = 0; i < triple.size(); ++i) { if (triple[i] == '-') dash_count++; diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp index 4581712..a2a69bb 100644 --- a/source/Expression/IRForTarget.cpp +++ b/source/Expression/IRForTarget.cpp @@ -1587,7 +1587,7 @@ IRForTarget::UnfoldConstant(Constant *old_constant, Value *new_constant, Instruc ++ui) users.push_back(*ui); - for (int i = 0; + for (size_t i = 0; i < users.size(); ++i) { diff --git a/source/Host/common/FileSpec.cpp b/source/Host/common/FileSpec.cpp index d83b182..fc4f6ba 100644 --- a/source/Host/common/FileSpec.cpp +++ b/source/Host/common/FileSpec.cpp @@ -912,7 +912,7 @@ FileSpec::EnumerateDirectory if (call_callback) { char child_path[PATH_MAX]; - const int child_path_len = ::snprintf (child_path, sizeof(child_path), "%s/%s", dir_path, dp->d_name); + const size_t child_path_len = ::snprintf (child_path, sizeof(child_path), "%s/%s", dir_path, dp->d_name); if (child_path_len < sizeof(child_path) - 1) { // Don't resolve the file type or path -- 1.7.1