From gclayton at apple.com Mon Aug 15 02:23:47 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 15 Aug 2011 07:23:47 -0000 Subject: [Lldb-commits] [lldb] r137605 - /lldb/trunk/source/Core/DataExtractor.cpp Message-ID: <20110815072347.F39F62A6C12C@llvm.org> Author: gclayton Date: Mon Aug 15 02:23:47 2011 New Revision: 137605 URL: http://llvm.org/viewvc/llvm-project?rev=137605&view=rev Log: Patch from Matt Johnson that cleans up usage of APInt to keep GCC 4.5.2 happy and also to not use a deprecated llvm API. Modified: lldb/trunk/source/Core/DataExtractor.cpp Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=137605&r1=137604&r2=137605&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Mon Aug 15 02:23:47 2011 @@ -14,6 +14,7 @@ #include #include "llvm/ADT/APInt.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Support/MathExtras.h" #include "lldb/Core/DataExtractor.h" @@ -1357,9 +1358,7 @@ else return offset; - llvm::APInt apint (byte_size * 8, - uint64_array.size(), - uint64_array.data()); + llvm::APInt apint (byte_size * 8, llvm::ArrayRef(uint64_array)); std::string apint_str(apint.toString(radix, is_signed)); switch (radix) From gclayton at apple.com Mon Aug 15 02:25:21 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 15 Aug 2011 00:25:21 -0700 Subject: [Lldb-commits] [PATCH] Disambiguate APInt() call, fix build on GCC 4.5.2 In-Reply-To: <4E489E91.6050503@crhc.illinois.edu> References: <4E489E91.6050503@crhc.illinois.edu> Message-ID: <4A49C68C-0063-4FBD-AF01-269D494E23E6@apple.com> Patch looks good, thanks Matt. % svn commit Sending source/Core/DataExtractor.cpp Transmitting file data . Committed revision 137605. On Aug 14, 2011, at 9:20 PM, Matt Johnson wrote: > Hi All, > r137602 added a call to the (deprecated; see llvm/include/llvm/ADT/APInt.h) APInt constructor that takes a size and pointer for a word array. The reason this constructor is deprecated is that it is prone to ambiguity with another constructor that takes a single word and a bool that denotes the signedness of the value. The deprecated constructor has been supplanted by one that takes a single ArrayRef parameter that encapsulates the size and a pointer to the word array. The attached patch calls the other constructor instead, and avoids the following build-breaker on gcc 4.5.2: > > DataExtractor.cpp: In function ?uint32_t DumpAPInt(lldb_private::Stream*, const lldb_private::DataExtractor&, uint32_t, uint32_t, bool, unsigned int)?: > DataExtractor.cpp:1362:55: error: call of overloaded ?APInt(uint32_t, llvm::SmallVectorTemplateCommon::size_type, uint64_t*)? is ambiguous > /media/d2/llvm/include/llvm/ADT/APInt.h:250:3: note: candidates are: llvm::APInt::APInt(unsigned int, unsigned int, const uint64_t*) > /media/d2/llvm/include/llvm/ADT/APInt.h:227:3: note: llvm::APInt::APInt(unsigned int, uint64_t, bool) > > You can also get around this error by casting the second argument to (unsigned), but I think this solution is cleaner. > > Best, > Matt > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From granata.enrico at gmail.com Mon Aug 15 10:56:02 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 15 Aug 2011 15:56:02 -0000 Subject: [Lldb-commits] [lldb] r137612 - in /lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime: AppleObjCRuntimeV2.cpp AppleObjCRuntimeV2.h Message-ID: <20110815155602.ADA802A6C12C@llvm.org> Author: enrico Date: Mon Aug 15 10:56:02 2011 New Revision: 137612 URL: http://llvm.org/viewvc/llvm-project?rev=137612&view=rev Log: Objective-C runtime now caches resolved ISA information for increased efficiency Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h 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=137612&r1=137611&r2=137612&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Mon Aug 15 10:56:02 2011 @@ -94,7 +94,9 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2 (Process *process, ModuleSP &objc_module_sp) : lldb_private::AppleObjCRuntime (process), m_get_class_name_args(LLDB_INVALID_ADDRESS), - m_get_class_name_args_mutex(Mutex::eMutexTypeNormal) + m_get_class_name_args_mutex(Mutex::eMutexTypeNormal), + m_isa_to_name_cache(), + m_isa_to_parent_cache() { m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(ConstString("gdb_object_getClass")) != NULL); } @@ -637,6 +639,12 @@ if (isa == g_objc_Tagged_ISA) return ConstString("_lldb_Tagged_ObjC_ISA"); + ISAToNameIterator found = m_isa_to_name_cache.find(isa); + ISAToNameIterator end = m_isa_to_name_cache.end(); + + if (found != end) + return found->second; + uint8_t pointer_size = m_process->GetAddressByteSize(); Error error; lldb::addr_t rw_pointer = isa + (4 * pointer_size); @@ -682,10 +690,16 @@ // will return the swizzled class instead of the actual one // this swizzled class is a descendant of the real class, so just // return the parent type and all should be fine - return GetActualTypeName(GetParentClass(isa)); + ConstString class_name = GetActualTypeName(GetParentClass(isa)); + m_isa_to_name_cache[isa] = class_name; + return class_name; } else - return ConstString(cstr); + { + ConstString class_name = ConstString(cstr); + m_isa_to_name_cache[isa] = class_name; + return class_name; + } } else return ConstString("unknown"); @@ -700,6 +714,12 @@ if (isa == g_objc_Tagged_ISA) return 0; + ISAToParentIterator found = m_isa_to_parent_cache.find(isa); + ISAToParentIterator end = m_isa_to_parent_cache.end(); + + if (found != end) + return found->second; + uint8_t pointer_size = m_process->GetAddressByteSize(); Error error; lldb::addr_t parent_pointer = isa + pointer_size; @@ -711,6 +731,9 @@ error); if (error.Fail()) return 0; + + m_isa_to_parent_cache[isa] = parent_isa; + return parent_isa; } 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=137612&r1=137611&r2=137612&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Mon Aug 15 10:56:02 2011 @@ -12,6 +12,9 @@ // C Includes // C++ Includes + +#include + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -100,6 +103,13 @@ protected: private: + + typedef std::map ISAToNameCache; + typedef std::map ISAToParentCache; + + typedef ISAToNameCache::iterator ISAToNameIterator; + typedef ISAToParentCache::iterator ISAToParentIterator; + AppleObjCRuntimeV2(Process *process, ModuleSP &objc_module_sp); bool @@ -113,6 +123,9 @@ lldb::addr_t m_get_class_name_args; Mutex m_get_class_name_args_mutex; + ISAToNameCache m_isa_to_name_cache; + ISAToParentCache m_isa_to_parent_cache; + static const char *g_find_class_name_function_name; static const char *g_find_class_name_function_body; static const char *g_objc_class_symbol_prefix; From granata.enrico at gmail.com Mon Aug 15 13:01:31 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 15 Aug 2011 18:01:31 -0000 Subject: [Lldb-commits] [lldb] r137622 - in /lldb/trunk: include/lldb/Core/ValueObject.h include/lldb/Target/ObjCLanguageRuntime.h include/lldb/lldb-enumerations.h source/API/SBValue.cpp source/Commands/CommandObjectFrame.cpp source/Commands/CommandObjectTarget.cpp Message-ID: <20110815180131.636202A6C12C@llvm.org> Author: enrico Date: Mon Aug 15 13:01:31 2011 New Revision: 137622 URL: http://llvm.org/viewvc/llvm-project?rev=137622&view=rev Log: Refactoring of ValueObject::DumpValueObject and 'frame variable', 'target variable' commands to use an Options object instead of passing an ever-increasing number of arguments to the DumpValueObject() method, with the ultimate aim of making that call private implementation Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137622&r1=137621&r2=137622&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Aug 15 13:01:31 2011 @@ -201,6 +201,139 @@ } }; + + struct DumpValueObjectOptions + { + uint32_t m_ptr_depth; + uint32_t m_max_depth; + bool m_show_types; + bool m_show_location; + bool m_use_objc; + lldb::DynamicValueType m_use_dynamic; + lldb::SyntheticValueType m_use_synthetic; + bool m_scope_already_checked; + bool m_flat_output; + uint32_t m_omit_summary_depth; + bool m_ignore_cap; + + DumpValueObjectOptions() : + m_ptr_depth(0), + m_max_depth(UINT32_MAX), + m_show_types(false), + m_show_location(false), + m_use_objc(false), + m_use_dynamic(lldb::eNoDynamicValues), + m_use_synthetic(lldb::eUseSyntheticFilter), + m_scope_already_checked(false), + m_flat_output(false), + m_omit_summary_depth(0), + m_ignore_cap(false) + {} + + static const DumpValueObjectOptions + DefaultOptions() + { + static DumpValueObjectOptions g_default_options; + + return g_default_options; + } + + DumpValueObjectOptions& + SetPointerDepth(uint32_t depth = 0) + { + m_ptr_depth = depth; + return *this; + } + + DumpValueObjectOptions& + SetMaximumDepth(uint32_t depth = 0) + { + m_max_depth = depth; + return *this; + } + + DumpValueObjectOptions& + SetShowTypes(bool show = false) + { + m_show_types = show; + return *this; + } + + DumpValueObjectOptions& + SetShowLocation(bool show = false) + { + m_show_location = show; + return *this; + } + + DumpValueObjectOptions& + SetUseObjectiveC(bool use = false) + { + m_use_objc = use; + return *this; + } + + DumpValueObjectOptions& + SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues) + { + m_use_dynamic = dyn; + return *this; + } + + DumpValueObjectOptions& + SetUseSyntheticValue(lldb::SyntheticValueType syn = lldb::eUseSyntheticFilter) + { + m_use_synthetic = syn; + return *this; + } + + DumpValueObjectOptions& + SetScopeChecked(bool check = true) + { + m_scope_already_checked = check; + return *this; + } + + DumpValueObjectOptions& + SetFlatOutput(bool flat = false) + { + m_flat_output = flat; + return *this; + } + + DumpValueObjectOptions& + SetOmitSummaryDepth(uint32_t depth = 0) + { + m_omit_summary_depth = depth; + return *this; + } + + DumpValueObjectOptions& + SetIgnoreCap(bool ignore = false) + { + m_ignore_cap = ignore; + return *this; + } + + DumpValueObjectOptions& + SetRawDisplay(bool raw = false) + { + if (raw) + { + SetUseSyntheticValue(lldb::eNoSyntheticFilter); + SetOmitSummaryDepth(UINT32_MAX); + SetIgnoreCap(true); + } + else + { + SetUseSyntheticValue(lldb::eUseSyntheticFilter); + SetOmitSummaryDepth(0); + SetIgnoreCap(false); + } + return *this; + } + + }; class EvaluationPoint { @@ -601,8 +734,8 @@ CastPointerType (const char *name, lldb::TypeSP &type_sp); - // The backing bits of this value object were updated, clear any value - // values, summaries or descriptions so we refetch them. + // The backing bits of this value object were updated, clear any + // descriptive string, so we know we have to refetch them virtual void ValueUpdated () { @@ -616,10 +749,91 @@ { return false; } + + static void + DumpValueObject (Stream &s, + ValueObject *valobj) + { + + if (!valobj) + return; + + ValueObject::DumpValueObject(s, + valobj, + DumpValueObjectOptions::DefaultOptions()); + } + + static void + DumpValueObject (Stream &s, + ValueObject *valobj, + const char *root_valobj_name) + { + + if (!valobj) + return; + + ValueObject::DumpValueObject(s, + valobj, + root_valobj_name, + DumpValueObjectOptions::DefaultOptions()); + } static void DumpValueObject (Stream &s, ValueObject *valobj, + const DumpValueObjectOptions& options) + { + + if (!valobj) + return; + + ValueObject::DumpValueObject(s, + valobj, + valobj->GetName().AsCString(), + options.m_ptr_depth, + 0, + options.m_max_depth, + options.m_show_types, + options.m_show_location, + options.m_use_objc, + options.m_use_dynamic, + options.m_use_synthetic, + options.m_scope_already_checked, + options.m_flat_output, + options.m_omit_summary_depth, + options.m_ignore_cap); + } + + static void + DumpValueObject (Stream &s, + ValueObject *valobj, + const char *root_valobj_name, + const DumpValueObjectOptions& options) + { + + if (!valobj) + return; + + ValueObject::DumpValueObject(s, + valobj, + root_valobj_name, + options.m_ptr_depth, + 0, + options.m_max_depth, + options.m_show_types, + options.m_show_location, + options.m_use_objc, + options.m_use_dynamic, + options.m_use_synthetic, + options.m_scope_already_checked, + options.m_flat_output, + options.m_omit_summary_depth, + options.m_ignore_cap); + } + + static void + DumpValueObject (Stream &s, + ValueObject *valobj, const char *root_valobj_name, uint32_t ptr_depth, uint32_t curr_depth, Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=137622&r1=137621&r2=137622&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Mon Aug 15 13:01:31 2011 @@ -154,7 +154,9 @@ typedef std::map MsgImplMap; MsgImplMap m_impl_cache; +protected: typedef std::map ClassNameMap; + typedef ClassNameMap::iterator ClassNameIterator; ClassNameMap m_class_name_cache; DISALLOW_COPY_AND_ASSIGN (ObjCLanguageRuntime); Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=137622&r1=137621&r2=137622&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Mon Aug 15 13:01:31 2011 @@ -326,8 +326,8 @@ typedef enum SyntheticValueType { - eNoSyntheticFilter = 0, - eUseSyntheticFilter = 1 + eNoSyntheticFilter = false, + eUseSyntheticFilter = true } SyntheticValueType; typedef enum AccessType Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=137622&r1=137621&r2=137622&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Mon Aug 15 13:01:31 2011 @@ -925,7 +925,7 @@ { if (m_opaque_sp) { - uint32_t ptr_depth = 0; + /*uint32_t ptr_depth = 0; uint32_t curr_depth = 0; uint32_t max_depth = UINT32_MAX; bool show_types = false; @@ -936,21 +936,9 @@ bool flat_output = false; bool use_synthetic = true; uint32_t no_summary_depth = 0; - bool ignore_cap = false; + bool ignore_cap = false;*/ ValueObject::DumpValueObject (description.ref(), - m_opaque_sp.get(), - m_opaque_sp->GetName().GetCString(), - ptr_depth, - curr_depth, - max_depth, - show_types, show_location, - use_objc, - use_dynamic, - use_synthetic, - scope_already_checked, - flat_output, - no_summary_depth, - ignore_cap); + m_opaque_sp.get()); } else description.Printf ("No value"); Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=137622&r1=137621&r2=137622&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Aug 15 13:01:31 2011 @@ -442,7 +442,23 @@ SummaryFormatSP summary_format_sp; if (!m_option_variable.summary.empty()) Debugger::Formatting::NamedSummaryFormats::Get(ConstString(m_option_variable.summary.c_str()), summary_format_sp); - + + ValueObject::DumpValueObjectOptions options; + + options.SetPointerDepth(m_varobj_options.ptr_depth) + .SetMaximumDepth(m_varobj_options.max_depth) + .SetShowTypes(m_varobj_options.show_types) + .SetShowLocation(m_varobj_options.show_location) + .SetUseObjectiveC(m_varobj_options.use_objc) + .SetUseDynamicType(m_varobj_options.use_dynamic) + .SetUseSyntheticValue((lldb::SyntheticValueType)m_varobj_options.use_synth) + .SetFlatOutput(m_varobj_options.flat_output) + .SetOmitSummaryDepth(m_varobj_options.no_summary_depth) + .SetIgnoreCap(m_varobj_options.ignore_cap); + + if (m_varobj_options.be_raw) + options.SetRawDisplay(true); + if (variable_list) { if (command.GetArgumentCount() > 0) @@ -453,8 +469,6 @@ // variable objects from them... for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != NULL; ++idx) { - uint32_t ptr_depth = m_varobj_options.ptr_depth; - if (m_option_variable.use_regex) { const uint32_t regex_start_index = regex_var_list.GetSize(); @@ -490,20 +504,8 @@ if (summary_format_sp) valobj_sp->SetCustomSummaryFormat(summary_format_sp); ValueObject::DumpValueObject (result.GetOutputStream(), - valobj_sp.get(), - var_sp->GetName().AsCString(), - m_varobj_options.ptr_depth, - 0, - m_varobj_options.max_depth, - m_varobj_options.show_types, - m_varobj_options.show_location, - m_varobj_options.use_objc, - m_varobj_options.use_dynamic, - m_varobj_options.be_raw ? false : m_varobj_options.use_synth, - false, - m_varobj_options.flat_output, - m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth, - m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap); + valobj_sp.get(), + options); } } } @@ -545,19 +547,8 @@ valobj_sp->SetCustomSummaryFormat(summary_format_sp); ValueObject::DumpValueObject (result.GetOutputStream(), valobj_sp.get(), - valobj_sp->GetParent() ? name_cstr : NULL, - ptr_depth, - 0, - m_varobj_options.max_depth, - m_varobj_options.show_types, - m_varobj_options.show_location, - m_varobj_options.use_objc, - m_varobj_options.use_dynamic, - m_varobj_options.be_raw ? false : m_varobj_options.use_synth, - false, - m_varobj_options.flat_output, - m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth, - m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap); + valobj_sp->GetParent() ? name_cstr : NULL, + options); } else { @@ -638,19 +629,8 @@ valobj_sp->SetCustomSummaryFormat(summary_format_sp); ValueObject::DumpValueObject (result.GetOutputStream(), valobj_sp.get(), - name_cstr, - m_varobj_options.ptr_depth, - 0, - m_varobj_options.max_depth, - m_varobj_options.show_types, - m_varobj_options.show_location, - m_varobj_options.use_objc, - m_varobj_options.use_dynamic, - m_varobj_options.be_raw ? false : m_varobj_options.use_synth, - false, - m_varobj_options.flat_output, - m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth, - m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap); + name_cstr, + options); } } } Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=137622&r1=137621&r2=137622&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Mon Aug 15 13:01:31 2011 @@ -553,6 +553,19 @@ void DumpValueObject (Stream &s, VariableSP &var_sp, ValueObjectSP &valobj_sp, const char *root_name) { + ValueObject::DumpValueObjectOptions options; + + options.SetPointerDepth(m_varobj_options.ptr_depth) + .SetMaximumDepth(m_varobj_options.max_depth) + .SetShowTypes(m_varobj_options.show_types) + .SetShowLocation(m_varobj_options.show_location) + .SetUseObjectiveC(m_varobj_options.use_objc) + .SetUseDynamicType(m_varobj_options.use_dynamic) + .SetUseSyntheticValue((lldb::SyntheticValueType)m_varobj_options.use_synth) + .SetFlatOutput(m_varobj_options.flat_output) + .SetOmitSummaryDepth(m_varobj_options.no_summary_depth) + .SetIgnoreCap(m_varobj_options.ignore_cap); + if (m_option_variable.format != eFormatDefault) valobj_sp->SetFormat (m_option_variable.format); @@ -597,18 +610,7 @@ ValueObject::DumpValueObject (s, valobj_sp.get(), root_name, - m_varobj_options.ptr_depth, - 0, - m_varobj_options.max_depth, - m_varobj_options.show_types, - m_varobj_options.show_location, - m_varobj_options.use_objc, - m_varobj_options.use_dynamic, - m_varobj_options.be_raw ? false : m_varobj_options.use_synth, - false, - m_varobj_options.flat_output, - m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth, - m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap); + options); } From johnny.chen at apple.com Mon Aug 15 13:19:51 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 15 Aug 2011 18:19:51 -0000 Subject: [Lldb-commits] [lldb] r137625 - /lldb/trunk/test/python_api/default-constructor/sb_address.py Message-ID: <20110815181951.BB75F2A6C12C@llvm.org> Author: johnny Date: Mon Aug 15 13:19:51 2011 New Revision: 137625 URL: http://llvm.org/viewvc/llvm-project?rev=137625&view=rev Log: Add new SBAddress APIs to the fuzz tests. Modified: lldb/trunk/test/python_api/default-constructor/sb_address.py Modified: lldb/trunk/test/python_api/default-constructor/sb_address.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_address.py?rev=137625&r1=137624&r2=137625&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_address.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_address.py Mon Aug 15 13:19:51 2011 @@ -11,4 +11,12 @@ obj.SetLoadAddress(0xffff, lldb.SBTarget()) obj.OffsetAddress(sys.maxint) obj.GetDescription(lldb.SBStream()) + obj.GetSectionType() + obj.GetSymbolContext(lldb.eSymbolContextEverything) + obj.GetModule() + obj.GetCompileUnit() + obj.GetFunction() + obj.GetBlock() + obj.GetSymbol() + obj.GetLineEntry() obj.Clear() From gclayton at apple.com Mon Aug 15 13:24:44 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 15 Aug 2011 18:24:44 -0000 Subject: [Lldb-commits] [lldb] r137630 - /lldb/trunk/source/Core/Debugger.cpp Message-ID: <20110815182444.ED1882A6C12C@llvm.org> Author: gclayton Date: Mon Aug 15 13:24:44 2011 New Revision: 137630 URL: http://llvm.org/viewvc/llvm-project?rev=137630&view=rev Log: Removed debug printf that was left in. Modified: lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=137630&r1=137629&r2=137630&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Aug 15 13:24:44 2011 @@ -260,7 +260,6 @@ process_sp->Destroy(); } DisconnectInput(); - printf("\n\n\nDebugger::~Debugger\n\n\n"); } From granata.enrico at gmail.com Mon Aug 15 14:24:02 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 15 Aug 2011 19:24:02 -0000 Subject: [Lldb-commits] [lldb] r137640 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20110815192402.BFFE02A6C12C@llvm.org> Author: enrico Date: Mon Aug 15 14:24:02 2011 New Revision: 137640 URL: http://llvm.org/viewvc/llvm-project?rev=137640&view=rev Log: One-line fix for a possible spurious truncation warning Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=137640&r1=137639&r2=137640&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Aug 15 14:24:02 2011 @@ -72,7 +72,8 @@ m_script_interpreter_ap (), m_comment_char ('#'), m_repeat_char ('!'), - m_batch_command_mode (false) + m_batch_command_mode (false), + m_truncation_warning(eNoTruncation) { const char *dbg_name = debugger.GetInstanceName().AsCString(); std::string lang_name = ScriptInterpreter::LanguageToString (script_language); From johnny.chen at apple.com Mon Aug 15 18:09:08 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 15 Aug 2011 23:09:08 -0000 Subject: [Lldb-commits] [lldb] r137678 - in /lldb/trunk/test: dotest.py lldbtest.py Message-ID: <20110815230908.6D8112A6C12C@llvm.org> Author: johnny Date: Mon Aug 15 18:09:08 2011 New Revision: 137678 URL: http://llvm.org/viewvc/llvm-project?rev=137678&view=rev Log: Test driver should also report skipped tests because there were cases when tests were skipped due to incorrect skip-logic. Modified: lldb/trunk/test/dotest.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=137678&r1=137677&r2=137678&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Aug 15 18:09:08 2011 @@ -1023,6 +1023,14 @@ if method: method() + def addSkip(self, test, reason): + global sdir_has_content + sdir_has_content = True + super(LLDBTestResult, self).addSkip(test, reason) + method = getattr(test, "markSkippedTest", None) + if method: + method() + def addUnexpectedSuccess(self, test): global sdir_has_content sdir_has_content = True Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=137678&r1=137677&r2=137678&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Mon Aug 15 18:09:08 2011 @@ -652,6 +652,15 @@ # Once by the Python unittest framework, and a second time by us. print >> sbuf, "expected failure" + def markSkippedTest(self): + """Callback invoked when a test is skipped.""" + self.__skipped__ = True + with recording(self, False) as sbuf: + # False because there's no need to write "skipped test" to the + # stderr twice. + # Once by the Python unittest framework, and a second time by us. + print >> sbuf, "skipped test" + def markUnexpectedSuccess(self): """Callback invoked when an unexpected success occurred.""" self.__unexpected__ = True @@ -690,13 +699,15 @@ elif self.__expected__: pairs = lldb.test_result.expectedFailures prefix = 'ExpectedFailure' + elif self.__skipped__: + prefix = 'SkippedTest' elif self.__unexpected__: prefix = "UnexpectedSuccess" else: # Simply return, there's no session info to dump! return - if not self.__unexpected__: + if not self.__unexpected__ and not self.__skipped__: for test, traceback in pairs: if test is self: print >> self.session, traceback From jingham at apple.com Mon Aug 15 19:07:28 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 16 Aug 2011 00:07:28 -0000 Subject: [Lldb-commits] [lldb] r137692 - /lldb/trunk/source/Target/Thread.cpp Message-ID: <20110816000728.4FCB32A6C12C@llvm.org> Author: jingham Date: Mon Aug 15 19:07:28 2011 New Revision: 137692 URL: http://llvm.org/viewvc/llvm-project?rev=137692&view=rev Log: Add missing check for non-NULL frame_sp. Modified: lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=137692&r1=137691&r2=137692&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Mon Aug 15 19:07:28 2011 @@ -1116,10 +1116,13 @@ if (GetProcess().GetTarget().GetDebugger().GetUseExternalEditor()) { StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame); - SymbolContext frame_sc(frame_sp->GetSymbolContext (eSymbolContextLineEntry)); - if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file) + if (frame_sp) { - Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); + SymbolContext frame_sc(frame_sp->GetSymbolContext (eSymbolContextLineEntry)); + if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file) + { + Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); + } } } From gclayton at apple.com Mon Aug 15 19:44:29 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 16 Aug 2011 00:44:29 -0000 Subject: [Lldb-commits] [lldb] r137695 - /lldb/trunk/source/Core/ValueObjectChild.cpp Message-ID: <20110816004429.545802A6C12C@llvm.org> Author: gclayton Date: Mon Aug 15 19:44:29 2011 New Revision: 137695 URL: http://llvm.org/viewvc/llvm-project?rev=137695&view=rev Log: Fixed an issue where a variable that was a pointer whose location was in a register would not be able to dereference children when displaying "*var" or the derefence of the variable. Modified: lldb/trunk/source/Core/ValueObjectChild.cpp Modified: lldb/trunk/source/Core/ValueObjectChild.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=137695&r1=137694&r2=137695&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp (original) +++ lldb/trunk/source/Core/ValueObjectChild.cpp Mon Aug 15 19:44:29 2011 @@ -108,10 +108,11 @@ if (ClangASTContext::IsPointerOrReferenceType (parent->GetClangType())) { - uint32_t offset = 0; - m_value.GetScalar() = parent->GetDataExtractor().GetPointer(&offset); + const bool scalar_is_load_address = true; + AddressType address_type; - lldb::addr_t addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); + lldb::addr_t addr = parent->GetPointerValue (address_type, scalar_is_load_address); + m_value.GetScalar() = addr; if (addr == LLDB_INVALID_ADDRESS) { From johnny.chen at apple.com Mon Aug 15 19:48:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Aug 2011 00:48:58 -0000 Subject: [Lldb-commits] [lldb] r137696 - /lldb/trunk/test/lldbtest.py Message-ID: <20110816004858.631C02A6C12C@llvm.org> Author: johnny Date: Mon Aug 15 19:48:58 2011 New Revision: 137696 URL: http://llvm.org/viewvc/llvm-project?rev=137696&view=rev Log: Forgot to initialize the self.__skipped__ attribute lldbtest.Base. 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=137696&r1=137695&r2=137696&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Mon Aug 15 19:48:58 2011 @@ -518,6 +518,8 @@ self.__expected__ = False # We are also interested in unexpected success. self.__unexpected__ = False + # And skipped tests. + self.__skipped__ = False # See addTearDownHook(self, hook) which allows the client to add a hook # function to be run during tearDown() time. From johnny.chen at apple.com Mon Aug 15 19:56:41 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Aug 2011 00:56:41 -0000 Subject: [Lldb-commits] [lldb] r137698 - /lldb/trunk/test/lang/cpp/class_types/TestClassTypes.py Message-ID: <20110816005642.BDE492A6C12C@llvm.org> Author: johnny Date: Mon Aug 15 19:56:41 2011 New Revision: 137698 URL: http://llvm.org/viewvc/llvm-project?rev=137698&view=rev Log: Modify the expected substrings to accomodate clang, now that rdar://problem/8516141 has been fixed. Modified: lldb/trunk/test/lang/cpp/class_types/TestClassTypes.py Modified: lldb/trunk/test/lang/cpp/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/class_types/TestClassTypes.py?rev=137698&r1=137697&r2=137698&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/lang/cpp/class_types/TestClassTypes.py Mon Aug 15 19:56:41 2011 @@ -160,7 +160,7 @@ # # Break on the ctor function of class C. self.expect("breakpoint set -M C", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: name = 'C', locations = 1") + startstr = "Breakpoint created: 1: name = 'C'") self.runCmd("run", RUN_SUCCEEDED) From johnny.chen at apple.com Mon Aug 15 20:16:02 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Aug 2011 01:16:02 -0000 Subject: [Lldb-commits] [lldb] r137699 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110816011602.769C22A6C12C@llvm.org> Author: johnny Date: Mon Aug 15 20:16:02 2011 New Revision: 137699 URL: http://llvm.org/viewvc/llvm-project?rev=137699&view=rev Log: Fix two logic errors uncovered by the static analyzer. For the default case (illegal encoding type), just return false instead of break. A8.6.84 LDRSH (register) A8.6.309 VLD1 (single element to all lanes) 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=137699&r1=137698&r2=137699&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Aug 15 20:16:02 2011 @@ -7657,7 +7657,7 @@ break; default: - break; + return false; } uint64_t Rm = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + m, 0, &success); @@ -11960,10 +11960,10 @@ if (n == 15) return false; } - break; + break; default: - break; + return false; } RegisterInfo base_reg; From jmolenda at apple.com Mon Aug 15 20:23:22 2011 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 16 Aug 2011 01:23:22 -0000 Subject: [Lldb-commits] [lldb] r137701 - /lldb/trunk/source/Core/ArchSpec.cpp Message-ID: <20110816012322.EF9C52A6C12C@llvm.org> Author: jmolenda Date: Mon Aug 15 20:23:22 2011 New Revision: 137701 URL: http://llvm.org/viewvc/llvm-project?rev=137701&view=rev Log: Allow for a cpu subtype of 4 to still be recognized as an x86_64 processor; we may get this subtype ("CPU_SUBTYPE_X86_ARCH1") back when starting a kdp session. Modified: lldb/trunk/source/Core/ArchSpec.cpp Modified: lldb/trunk/source/Core/ArchSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=137701&r1=137700&r2=137701&view=diff ============================================================================== --- lldb/trunk/source/Core/ArchSpec.cpp (original) +++ lldb/trunk/source/Core/ArchSpec.cpp Mon Aug 15 20:23:22 2011 @@ -167,6 +167,7 @@ { ArchSpec::eCore_x86_32_i486sx , llvm::MachO::CPUTypeI386 , 0x84 }, { ArchSpec::eCore_x86_32_i386 , llvm::MachO::CPUTypeI386 , CPU_ANY }, { ArchSpec::eCore_x86_64_x86_64 , llvm::MachO::CPUTypeX86_64 , 3 }, + { ArchSpec::eCore_x86_64_x86_64 , llvm::MachO::CPUTypeX86_64 , 4 }, { ArchSpec::eCore_x86_64_x86_64 , llvm::MachO::CPUTypeX86_64 , CPU_ANY } }; static const ArchDefinition g_macho_arch_def = { From gclayton at apple.com Mon Aug 15 22:49:01 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 16 Aug 2011 03:49:01 -0000 Subject: [Lldb-commits] [lldb] r137710 - in /lldb/trunk: include/lldb/Core/ValueObject.h include/lldb/Core/ValueObjectRegister.h source/Core/ValueObjectRegister.cpp Message-ID: <20110816034901.6633D2A6C12C@llvm.org> Author: gclayton Date: Mon Aug 15 22:49:01 2011 New Revision: 137710 URL: http://llvm.org/viewvc/llvm-project?rev=137710&view=rev Log: Fixed register value objects to be able to return their values as unsigned and signed integers. Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectRegister.h lldb/trunk/source/Core/ValueObjectRegister.cpp Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137710&r1=137709&r2=137710&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Aug 15 22:49:01 2011 @@ -640,7 +640,7 @@ Value & GetValue(); - bool + virtual bool ResolveValue (Scalar &scalar); const char * Modified: lldb/trunk/include/lldb/Core/ValueObjectRegister.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectRegister.h?rev=137710&r1=137709&r2=137710&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectRegister.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectRegister.h Mon Aug 15 22:49:01 2011 @@ -160,6 +160,9 @@ virtual bool SetValueFromCString (const char *value_str); + virtual bool + ResolveValue (Scalar &scalar); + protected: virtual bool UpdateValue (); Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=137710&r1=137709&r2=137710&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectRegister.cpp (original) +++ lldb/trunk/source/Core/ValueObjectRegister.cpp Mon Aug 15 22:49:01 2011 @@ -404,3 +404,12 @@ return false; } +bool +ValueObjectRegister::ResolveValue (Scalar &scalar) +{ + if (UpdateValueIfNeeded(false)) // make sure that you are up to date before returning anything + return m_reg_value.GetScalarValue(scalar); + return false; +} + + From granata.enrico at gmail.com Tue Aug 16 11:49:25 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Tue, 16 Aug 2011 16:49:25 -0000 Subject: [Lldb-commits] [lldb] r137722 - in /lldb/trunk: include/lldb/Interpreter/ lldb.xcodeproj/ scripts/Python/ source/API/ source/Commands/ source/Interpreter/ test/functionalities/alias/ Message-ID: <20110816164925.709E62A6C12C@llvm.org> Author: enrico Date: Tue Aug 16 11:49:25 2011 New Revision: 137722 URL: http://llvm.org/viewvc/llvm-project?rev=137722&view=rev Log: Python commands: It is now possible to use 'command alias --python' to define a command name that actually triggers execution of a Python function (e.g. command alias --python foo foo_impl makes a command named 'foo' that runs Python function 'foo_impl') The Python function foo_impl should have as signature: def foo_impl(debugger, args, stream, dict): where debugger is an object wrapping an LLDB SBDebugger args is the command line arguments, as an unparsed Python string stream is an SBStream that represents the standard output dict is an internal utility parameter and should be left untouched The function should return None on no error, or an error string to describe any problems Added: lldb/trunk/source/Commands/CommandObjectPythonFunction.cpp lldb/trunk/source/Commands/CommandObjectPythonFunction.h lldb/trunk/test/functionalities/alias/py_import lldb/trunk/test/functionalities/alias/welcome.py Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/Python/python-wrapper.swig lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Interpreter/ScriptInterpreter.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/test/functionalities/alias/TestAliases.py Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=137722&r1=137721&r2=137722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Aug 16 11:49:25 2011 @@ -43,6 +43,13 @@ typedef int (*SWIGPythonGetIndexOfChildWithName) (void *implementor, const char* child_name); typedef lldb::SBValue* (*SWIGPythonCastPyObjectToSBValue) (void* data); typedef void (*SWIGPythonUpdateSynthProviderInstance) (void* data); + + typedef bool (*SWIGPythonCallCommand) (const char *python_function_name, + const char *session_dictionary_name, + lldb::DebuggerSP& debugger, + const char* args, + std::string& err_msg, + lldb::SBStream& stream); typedef enum { @@ -58,7 +65,8 @@ eLongLongUnsigned, eFloat, eDouble, - eChar + eChar, + eCharStrOrNone, } ReturnType; @@ -103,6 +111,12 @@ } virtual bool + GenerateScriptAliasFunction (StringList &input, StringList &output) + { + return false; + } + + virtual bool GenerateTypeSynthClass (StringList &input, StringList &output) { return false; @@ -168,6 +182,15 @@ { return NULL; } + + virtual bool + RunScriptBasedCommand(const char* impl_function, + const char* args, + lldb::SBStream& stream, + Error& error) + { + return false; + } const char * GetScriptInterpreterPtyName (); @@ -178,7 +201,7 @@ CommandInterpreter & GetCommandInterpreter (); - static std::string + static std::string LanguageToString (lldb::ScriptLanguage language); static void @@ -190,7 +213,8 @@ SWIGPythonGetChildAtIndex python_swig_get_child_index, SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, - SWIGPythonUpdateSynthProviderInstance python_swig_update_provider); + SWIGPythonUpdateSynthProviderInstance python_swig_update_provider, + SWIGPythonCallCommand python_swig_call_command); static void TerminateInterpreter (); Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=137722&r1=137721&r2=137722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Tue Aug 16 11:49:25 2011 @@ -59,6 +59,9 @@ bool GenerateTypeScriptFunction (const char* oneliner, StringList &output); + virtual bool + GenerateScriptAliasFunction (StringList &input, StringList &output); + void* CreateSyntheticScriptedProvider (std::string class_name, lldb::ValueObjectSP valobj); @@ -78,6 +81,12 @@ virtual lldb::SBValue* CastPyObjectToSBValue (void* data); + virtual bool + RunScriptBasedCommand(const char* impl_function, + const char* args, + lldb::SBStream& stream, + Error& error); + bool GenerateFunction(std::string& signature, StringList &input, StringList &output); @@ -131,7 +140,8 @@ SWIGPythonGetChildAtIndex python_swig_get_child_index, SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, - SWIGPythonUpdateSynthProviderInstance python_swig_update_provider); + SWIGPythonUpdateSynthProviderInstance python_swig_update_provider, + SWIGPythonCallCommand python_swig_call_command); protected: Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=137722&r1=137721&r2=137722&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Aug 16 11:49:25 2011 @@ -405,6 +405,8 @@ 94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94611EB113CCA4A4003A22AF /* RefCounter.cpp */; }; 9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */; }; 9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */; }; + 94A075BB13F9F58500D97961 /* CommandObjectPythonFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94A075B913F9F58500D97961 /* CommandObjectPythonFunction.cpp */; }; + 94A075BC13F9F58500D97961 /* CommandObjectPythonFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A075BA13F9F58500D97961 /* CommandObjectPythonFunction.h */; }; 94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.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 */; }; @@ -1174,6 +1176,8 @@ 9463D4CE13B179A500C230D4 /* CommandObjectType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommandObjectType.h; path = source/Commands/CommandObjectType.h; sourceTree = ""; }; 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeHierarchyNavigator.cpp; path = source/Symbol/TypeHierarchyNavigator.cpp; sourceTree = ""; }; 9467E65413C3D98900B3B6F3 /* TypeHierarchyNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeHierarchyNavigator.h; path = include/lldb/Symbol/TypeHierarchyNavigator.h; sourceTree = ""; }; + 94A075B913F9F58500D97961 /* CommandObjectPythonFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectPythonFunction.cpp; path = source/Commands/CommandObjectPythonFunction.cpp; sourceTree = ""; }; + 94A075BA13F9F58500D97961 /* CommandObjectPythonFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectPythonFunction.h; path = source/Commands/CommandObjectPythonFunction.h; sourceTree = ""; }; 94A9112B13D5DEF80046D8A6 /* FormatClasses.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatClasses.h; path = include/lldb/Core/FormatClasses.h; sourceTree = ""; }; 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatClasses.cpp; path = source/Core/FormatClasses.cpp; sourceTree = ""; }; 94B6E76013D8833C005F417F /* ValueObjectSyntheticFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectSyntheticFilter.h; path = include/lldb/Core/ValueObjectSyntheticFilter.h; sourceTree = ""; }; @@ -2123,6 +2127,8 @@ 26879CE71333F58B0012C1F8 /* CommandObjectPlatform.cpp */, 26BC7D1F10F1B76300F91463 /* CommandObjectProcess.h */, 26BC7E3810F1B84700F91463 /* CommandObjectProcess.cpp */, + 94A075BA13F9F58500D97961 /* CommandObjectPythonFunction.h */, + 94A075B913F9F58500D97961 /* CommandObjectPythonFunction.cpp */, 26BC7D2010F1B76300F91463 /* CommandObjectQuit.h */, 26BC7E3910F1B84700F91463 /* CommandObjectQuit.cpp */, 26BC7D2210F1B76300F91463 /* CommandObjectRegister.h */, @@ -2658,6 +2664,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 94A075BC13F9F58500D97961 /* CommandObjectPythonFunction.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3250,6 +3257,7 @@ 26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */, B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */, 94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */, + 94A075BB13F9F58500D97961 /* CommandObjectPythonFunction.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=137722&r1=137721&r2=137722&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Tue Aug 16 11:49:25 2011 @@ -582,4 +582,144 @@ return sb_ptr; } +SWIGEXPORT bool +LLDBSwigPythonCallCommand +( + const char *python_function_name, + const char *session_dictionary_name, + lldb::DebuggerSP& debugger, + const char* args, + std::string& err_msg, + lldb::SBStream& stream +) +{ + + bool retval = false; + + PyObject *DebuggerObj_PyObj = SWIG_NewPointerObj((void *) &debugger, SWIGTYPE_p_lldb__SBDebugger, 0); + PyObject *StreamObj_PyObj = SWIG_NewPointerObj((void *) &stream, SWIGTYPE_p_lldb__SBStream, 0); + + if (DebuggerObj_PyObj == NULL) + return retval; + + if (StreamObj_PyObj == NULL) + return retval; + + if (!python_function_name || !session_dictionary_name) + return retval; + + PyObject *pmodule, *main_dict, *session_dict, *pfunc; + PyObject *pargs, *pvalue; + + pmodule = PyImport_AddModule ("__main__"); + if (pmodule != NULL) + { + main_dict = PyModule_GetDict (pmodule); + if (main_dict != NULL) + { + PyObject *key, *value; + Py_ssize_t pos = 0; + + // Find the current session's dictionary in the main module's dictionary. + + if (PyDict_Check (main_dict)) + { + session_dict = NULL; + while (PyDict_Next (main_dict, &pos, &key, &value)) + { + // We have stolen references to the key and value objects in the dictionary; we need to increment + // them now so that Python's garbage collector doesn't collect them out from under us. + Py_INCREF (key); + Py_INCREF (value); + if (strcmp (PyString_AsString (key), session_dictionary_name) == 0) + { + session_dict = value; + break; + } + } + } + + if (!session_dict || !PyDict_Check (session_dict)) + return retval; + + // Find the function we need to call in the current session's dictionary. + + pos = 0; + pfunc = NULL; + while (PyDict_Next (session_dict, &pos, &key, &value)) + { + if (PyString_Check (key)) + { + // We have stolen references to the key and value objects in the dictionary; we need to increment + // them now so that Python's garbage collector doesn't collect them out from under us. + Py_INCREF (key); + Py_INCREF (value); + if (strcmp (PyString_AsString (key), python_function_name) == 0) + { + pfunc = value; + break; + } + } + } + + // Set up the arguments and call the function. + + if (pfunc && PyCallable_Check (pfunc)) + { + pargs = PyTuple_New (4); + if (pargs == NULL) + { + if (PyErr_Occurred()) + PyErr_Clear(); + return retval; + } + + PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj); // This "steals" a reference to DebuggerObj_PyObj + PyTuple_SetItem (pargs, 1, PyString_FromString(args)); + PyTuple_SetItem (pargs, 2, StreamObj_PyObj); // This "steals" a reference to StreamObj_PyObj + PyTuple_SetItem (pargs, 3, session_dict); // This "steals" a reference to session_dict + pvalue = PyObject_CallObject (pfunc, pargs); + Py_DECREF (pargs); + + if (pvalue != NULL) + { + if (pvalue == Py_None) // no error + { + err_msg.clear(); + retval = true; + } + else // return value is an error string + { + err_msg.assign(PyString_AsString(pvalue)); + retval = false; + } + Py_DECREF (pvalue); + } + else if (PyErr_Occurred ()) + { + PyErr_Print(); + PyErr_Clear(); + } + Py_INCREF (session_dict); + } + else if (PyErr_Occurred()) + { + PyErr_Print(); + PyErr_Clear(); + } + } + else if (PyErr_Occurred()) + { + PyErr_Print(); + PyErr_Clear(); + } + } + else if (PyErr_Occurred ()) + { + PyErr_Print(); + PyErr_Clear (); + } + return retval; +} + %} Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=137722&r1=137721&r2=137722&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Tue Aug 16 11:49:25 2011 @@ -337,6 +337,17 @@ extern "C" lldb::SBValue* LLDBSWIGPython_CastPyObjectToSBValue (void* data); extern "C" void LLDBSwigPython_UpdateSynthProviderInstance (void* implementor); +extern "C" bool LLDBSwigPythonCallCommand +( + const char *python_function_name, + const char *session_dictionary_name, + lldb::DebuggerSP& debugger, + const char* args, + std::string& err_msg, + lldb::SBStream& stream +); + + extern "C" void init_lldb(void); void @@ -354,6 +365,7 @@ LLDBSwigPython_GetChildAtIndex, LLDBSwigPython_GetIndexOfChildWithName, LLDBSWIGPython_CastPyObjectToSBValue, - LLDBSwigPython_UpdateSynthProviderInstance); + LLDBSwigPython_UpdateSynthProviderInstance, + LLDBSwigPythonCallCommand); } } Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=137722&r1=137721&r2=137722&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Aug 16 11:49:25 2011 @@ -15,8 +15,11 @@ #include "llvm/ADT/StringRef.h" // Project includes +#include "CommandObjectPythonFunction.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/InputReader.h" +#include "lldb/Core/InputReaderEZ.h" +#include "lldb/Core/StringList.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObjectRegexCommand.h" @@ -306,8 +309,131 @@ // CommandObjectCommandsAlias //------------------------------------------------------------------------- +static const char *g_python_command_instructions = "Enter your Python command(s). Type 'DONE' to end.\n" + "You must define a Python function with this signature:\n" + "def my_command_impl(debugger, args, stream, dict):"; + + class CommandObjectCommandsAlias : public CommandObject { + + class PythonAliasReader : public InputReaderEZ + { + private: + CommandInterpreter& m_interpreter; + std::string m_cmd_name; + StringList m_user_input; + DISALLOW_COPY_AND_ASSIGN (PythonAliasReader); + public: + PythonAliasReader(Debugger& debugger, + CommandInterpreter& interpreter, + std::string cmd_name) : + InputReaderEZ(debugger), + m_interpreter(interpreter), + m_cmd_name(cmd_name), + m_user_input() + {} + + virtual + ~PythonAliasReader() + { + } + + virtual void ActivateHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + bool batch_mode = data.GetBatchMode(); + if (!batch_mode) + { + out_stream->Printf ("%s\n", g_python_command_instructions); + if (data.reader.GetPrompt()) + out_stream->Printf ("%s", data.reader.GetPrompt()); + out_stream->Flush(); + } + } + + virtual void ReactivateHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + bool batch_mode = data.GetBatchMode(); + if (data.reader.GetPrompt() && !batch_mode) + { + out_stream->Printf ("%s", data.reader.GetPrompt()); + out_stream->Flush(); + } + } + virtual void GotTokenHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + bool batch_mode = data.GetBatchMode(); + if (data.bytes && data.bytes_len) + { + m_user_input.AppendString(data.bytes, data.bytes_len); + } + if (!data.reader.IsDone() && data.reader.GetPrompt() && !batch_mode) + { + out_stream->Printf ("%s", data.reader.GetPrompt()); + out_stream->Flush(); + } + } + virtual void InterruptHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + bool batch_mode = data.GetBatchMode(); + data.reader.SetIsDone (true); + if (!batch_mode) + { + out_stream->Printf ("Warning: No command attached to breakpoint.\n"); + out_stream->Flush(); + } + } + virtual void EOFHandler(HandlerData& data) + { + data.reader.SetIsDone (true); + } + virtual void DoneHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + + ScriptInterpreter *interpreter = data.reader.GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); + if (!interpreter) + { + out_stream->Printf ("Internal error #1: no script attached.\n"); + out_stream->Flush(); + return; + } + StringList funct_name_sl; + if (!interpreter->GenerateScriptAliasFunction (m_user_input, + funct_name_sl)) + { + out_stream->Printf ("Internal error #2: no script attached.\n"); + out_stream->Flush(); + return; + } + if (funct_name_sl.GetSize() == 0) + { + out_stream->Printf ("Internal error #3: no script attached.\n"); + out_stream->Flush(); + return; + } + const char *funct_name = funct_name_sl.GetStringAtIndex(0); + if (!funct_name || !funct_name[0]) + { + out_stream->Printf ("Internal error #4: no script attached.\n"); + out_stream->Flush(); + return; + } + + // everything should be fine now, let's add this alias + + CommandObjectSP command_obj_sp(new CommandObjectPythonFunction(m_interpreter, + m_cmd_name, + funct_name)); + + m_interpreter.AddAlias(m_cmd_name.c_str(), command_obj_sp); + } + }; + public: CommandObjectCommandsAlias (CommandInterpreter &interpreter) : CommandObject (interpreter, @@ -425,6 +551,98 @@ // Get the alias command. const std::string alias_command = args.GetArgumentAtIndex (0); + + if ( + (strcmp("--python",alias_command.c_str()) == 0) || + (strcmp("-P",alias_command.c_str()) == 0) + ) + { + + if (argc < 3) + { + // this is a definition of the form + // command alias --python foo_cmd + // and the user will type foo_cmd_impl by hand + std::string cmd_name = args.GetArgumentAtIndex(1); + // Verify that the command is alias-able. + if (m_interpreter.CommandExists (cmd_name.c_str())) + { + result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", + cmd_name.c_str()); + result.SetStatus (eReturnStatusFailed); + return false; + } + if (m_interpreter.AliasExists (cmd_name.c_str()) + || m_interpreter.UserCommandExists (cmd_name.c_str())) + { + result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", + cmd_name.c_str()); + } + + + InputReaderSP reader_sp (new PythonAliasReader (m_interpreter.GetDebugger(), + m_interpreter, + cmd_name)); + + if (reader_sp) + { + + InputReaderEZ::InitializationParameters ipr; + + Error err (reader_sp->Initialize (ipr.SetBaton(NULL).SetPrompt(" "))); + if (err.Success()) + { + m_interpreter.GetDebugger().PushInputReader (reader_sp); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendError (err.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + result.AppendError("out of memory"); + result.SetStatus (eReturnStatusFailed); + } + + result.SetStatus (eReturnStatusSuccessFinishNoResult); + return result.Succeeded(); + } + else + { + // this is a definition of the form + // command alias --python foo_cmd funct_impl_foo + std::string cmd_name = args.GetArgumentAtIndex(1); + std::string funct_name = args.GetArgumentAtIndex(2); + + // Verify that the command is alias-able. + if (m_interpreter.CommandExists (cmd_name.c_str())) + { + result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", + cmd_name.c_str()); + result.SetStatus (eReturnStatusFailed); + return false; + } + + CommandObjectSP command_obj_sp(new CommandObjectPythonFunction(m_interpreter, + cmd_name, + funct_name)); + + if (m_interpreter.AliasExists (cmd_name.c_str()) + || m_interpreter.UserCommandExists (cmd_name.c_str())) + { + result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", + cmd_name.c_str()); + } + + m_interpreter.AddAlias(cmd_name.c_str(), command_obj_sp); + + result.SetStatus (eReturnStatusSuccessFinishNoResult); + return result.Succeeded(); + } + } // Strip the new alias name off 'raw_command_string' (leave it on args, which gets passed to 'Execute', which // does the stripping itself. Added: lldb/trunk/source/Commands/CommandObjectPythonFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPythonFunction.cpp?rev=137722&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPythonFunction.cpp (added) +++ lldb/trunk/source/Commands/CommandObjectPythonFunction.cpp Tue Aug 16 11:49:25 2011 @@ -0,0 +1,88 @@ +//===-- CommandObjectPythonFunction.cpp --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "CommandObjectPythonFunction.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/Debugger.h" + +#include "lldb/Interpreter/Args.h" +#include "lldb/Interpreter/Options.h" + +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" + +#include "lldb/Interpreter/ScriptInterpreter.h" +#include "lldb/Interpreter/ScriptInterpreterPython.h" + +using namespace lldb; +using namespace lldb_private; + +//------------------------------------------------------------------------- +// CommandObjectApropos +//------------------------------------------------------------------------- + +CommandObjectPythonFunction::CommandObjectPythonFunction (CommandInterpreter &interpreter, + std::string name, + std::string funct) : + CommandObject (interpreter, + name.c_str(), + (std::string("Run Python function ") + funct).c_str(), + NULL), + m_function_name(funct) +{ + CommandArgumentEntry arg; + CommandArgumentData search_word_arg; + + // Define the first (and only) variant of this arg. + search_word_arg.arg_type = eArgTypeSearchWord; + search_word_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (search_word_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); +} + +CommandObjectPythonFunction::~CommandObjectPythonFunction() +{ +} + +bool +CommandObjectPythonFunction::ExecuteRawCommandString (const char *raw_command_line, + CommandReturnObject &result) +{ + ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); + + Error error; + + lldb::SBStream stream; + + if (scripter->RunScriptBasedCommand(m_function_name.c_str(), + raw_command_line, + stream, + error) == false) + { + result.AppendError(error.AsCString()); + result.SetStatus(eReturnStatusFailed); + } + else + result.SetStatus(eReturnStatusSuccessFinishNoResult); + + result.GetOutputStream() << stream.GetData(); + + return result.Succeeded(); +} Added: lldb/trunk/source/Commands/CommandObjectPythonFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPythonFunction.h?rev=137722&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPythonFunction.h (added) +++ lldb/trunk/source/Commands/CommandObjectPythonFunction.h Tue Aug 16 11:49:25 2011 @@ -0,0 +1,62 @@ +//===-- CommandObjectPythonFunction.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_CommandObjectPythonFunction_h_ +#define liblldb_CommandObjectPythonFunction_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/CommandObject.h" + +namespace lldb_private { + +//------------------------------------------------------------------------- +// CommandObjectApropos +//------------------------------------------------------------------------- + +class CommandObjectPythonFunction : public CommandObject +{ +private: + std::string m_function_name; + +public: + + CommandObjectPythonFunction (CommandInterpreter &interpreter, + std::string name, + std::string funct); + + virtual + ~CommandObjectPythonFunction (); + + virtual bool + ExecuteRawCommandString (const char *raw_command_line, CommandReturnObject &result); + + virtual bool + WantsRawCommandString () + { + return true; + } + + bool + Execute (Args& command, + CommandReturnObject &result) + { + std::string cmd_string; + command.GetCommandString(cmd_string); + return ExecuteRawCommandString(cmd_string.c_str(), result); + } + + +}; + +} // namespace lldb_private + +#endif // liblldb_CommandObjectPythonFunction_h_ Modified: lldb/trunk/source/Interpreter/ScriptInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreter.cpp?rev=137722&r1=137721&r2=137722&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreter.cpp Tue Aug 16 11:49:25 2011 @@ -99,7 +99,8 @@ SWIGPythonGetChildAtIndex python_swig_get_child_index, SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, - SWIGPythonUpdateSynthProviderInstance python_swig_update_provider) + SWIGPythonUpdateSynthProviderInstance python_swig_update_provider, + SWIGPythonCallCommand python_swig_call_command) { ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback, python_swig_breakpoint_callback, @@ -109,7 +110,8 @@ python_swig_get_child_index, python_swig_get_index_child, python_swig_cast_to_sbvalue, - python_swig_update_provider); + python_swig_update_provider, + python_swig_call_command); } void Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=137722&r1=137721&r2=137722&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Aug 16 11:49:25 2011 @@ -41,6 +41,7 @@ static ScriptInterpreter::SWIGPythonGetIndexOfChildWithName g_swig_get_index_child = NULL; static ScriptInterpreter::SWIGPythonCastPyObjectToSBValue g_swig_cast_to_sbvalue = NULL; static ScriptInterpreter::SWIGPythonUpdateSynthProviderInstance g_swig_update_provider = NULL; +static ScriptInterpreter::SWIGPythonCallCommand g_swig_call_command = NULL; static int _check_and_flush (FILE *stream) @@ -765,6 +766,12 @@ success = PyArg_Parse (py_return, format, (char **) &ret_value); break; } + case eCharStrOrNone: // char* or NULL if py_return == Py_None + { + const char format[3] = "z"; + success = PyArg_Parse (py_return, format, (char **) &ret_value); + break; + } case eBool: { const char format[2] = "b"; @@ -1251,6 +1258,70 @@ } bool +ScriptInterpreterPython::GenerateScriptAliasFunction (StringList &user_input, StringList &output) +{ + static int num_created_functions = 0; + user_input.RemoveBlankLines (); + int num_lines = user_input.GetSize (); + StreamString sstr; + + // Check to see if we have any data; if not, just return. + if (user_input.GetSize() == 0) + return false; + + // Take what the user wrote, wrap it all up inside one big auto-generated Python function, passing in the + // ValueObject as parameter to the function. + + sstr.Printf ("lldb_autogen_python_cmd_alias_func_%d", num_created_functions); + ++num_created_functions; + std::string auto_generated_function_name = sstr.GetData(); + + sstr.Clear(); + StringList auto_generated_function; + + // Create the function name & definition string. + + sstr.Printf ("def %s (debugger, args, dict):", auto_generated_function_name.c_str()); + auto_generated_function.AppendString (sstr.GetData()); + + // Pre-pend code for setting up the session dictionary. + + auto_generated_function.AppendString (" global_dict = globals()"); // Grab the global dictionary + auto_generated_function.AppendString (" new_keys = dict.keys()"); // Make a list of keys in the session dict + auto_generated_function.AppendString (" old_keys = global_dict.keys()"); // Save list of keys in global dict + auto_generated_function.AppendString (" global_dict.update (dict)"); // Add the session dictionary to the + // global dictionary. + + // Wrap everything up inside the function, increasing the indentation. + + for (int i = 0; i < num_lines; ++i) + { + sstr.Clear (); + sstr.Printf (" %s", user_input.GetStringAtIndex (i)); + auto_generated_function.AppendString (sstr.GetData()); + } + + // Append code to clean up the global dictionary and update the session dictionary (all updates in the function + // got written to the values in the global dictionary, not the session dictionary). + + auto_generated_function.AppendString (" for key in new_keys:"); // Iterate over all the keys from session dict + auto_generated_function.AppendString (" dict[key] = global_dict[key]"); // Update session dict values + auto_generated_function.AppendString (" if key not in old_keys:"); // If key was not originally in global dict + auto_generated_function.AppendString (" del global_dict[key]"); // ...then remove key/value from global dict + + // Verify that the results are valid Python. + + if (!ExportFunctionDefinitionToInterpreter (auto_generated_function)) + return false; + + // Store the name of the auto-generated function to be called. + + output.AppendString (auto_generated_function_name.c_str()); + return true; +} + + +bool ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, StringList &output) { static int num_created_classes = 0; @@ -1835,6 +1906,72 @@ return ret_val; } +bool +ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function, + const char* args, + lldb::SBStream& stream, + Error& error) +{ + if (!impl_function) + { + error.SetErrorString("no function to execute"); + return false; + } + + if (!g_swig_call_command) + { + error.SetErrorString("no helper function to run scripted commands"); + return false; + } + + ScriptInterpreterPython *python_interpreter = this; + + lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().GetSP(); + + bool ret_val; + + std::string err_msg; + + FILE *tmp_fh = (python_interpreter->m_dbg_stdout ? python_interpreter->m_dbg_stdout : stdout); + if (CurrentThreadHasPythonLock()) + { + python_interpreter->EnterSession (); + ret_val = g_swig_call_command (impl_function, + python_interpreter->m_dictionary_name.c_str(), + debugger_sp, + args, + err_msg, + stream); + python_interpreter->LeaveSession (); + } + else + { + while (!GetPythonLock (1)) + fprintf (tmp_fh, + "Python interpreter locked on another thread; waiting to acquire lock...\n"); + python_interpreter->EnterSession (); + ret_val = g_swig_call_command (impl_function, + python_interpreter->m_dictionary_name.c_str(), + debugger_sp, + args, + err_msg, + stream); + python_interpreter->LeaveSession (); + ReleasePythonLock (); + } + + if (!ret_val) + error.SetErrorString(err_msg.c_str()); + else + error.Clear(); + + return ret_val; + + + return true; + +} + void ScriptInterpreterPython::InitializeInterpreter (SWIGInitCallback python_swig_init_callback, @@ -1845,7 +1982,8 @@ SWIGPythonGetChildAtIndex python_swig_get_child_index, SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, - SWIGPythonUpdateSynthProviderInstance python_swig_update_provider) + SWIGPythonUpdateSynthProviderInstance python_swig_update_provider, + SWIGPythonCallCommand python_swig_call_command) { g_swig_init_callback = python_swig_init_callback; g_swig_breakpoint_callback = python_swig_breakpoint_callback; @@ -1856,6 +1994,7 @@ g_swig_get_index_child = python_swig_get_index_child; g_swig_cast_to_sbvalue = python_swig_cast_to_sbvalue; g_swig_update_provider = python_swig_update_provider; + g_swig_call_command = python_swig_call_command; } void Modified: lldb/trunk/test/functionalities/alias/TestAliases.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/TestAliases.py?rev=137722&r1=137721&r2=137722&view=diff ============================================================================== --- lldb/trunk/test/functionalities/alias/TestAliases.py (original) +++ lldb/trunk/test/functionalities/alias/TestAliases.py Tue Aug 16 11:49:25 2011 @@ -130,6 +130,30 @@ substrs = [ "use of undeclared identifier 'f'", "1 errors parsing expression" ]) + self.runCmd("command source py_import") + + self.expect('welcome Enrico', + substrs = ['Hello Enrico, welcome to LLDB']); + + self.runCmd("command unalias welcome"); + + self.expect('welcome Enrico', matching=False, error=True, + substrs = ['Hello Enrico, welcome to LLDB']); + + self.expect('targetname', + substrs = ['a.out']) + + self.expect('targetname fail', error=True, + substrs = ['a test for error in command']) + + self.expect('help', + substrs = ['targetname', + 'Run Python function target_name_impl']) + + self.expect("help targetname", + substrs = ['Run Python function target_name_imp', + 'This command takes \'raw\' input', + 'quote stuff']) if __name__ == '__main__': Added: lldb/trunk/test/functionalities/alias/py_import URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/py_import?rev=137722&view=auto ============================================================================== --- lldb/trunk/test/functionalities/alias/py_import (added) +++ lldb/trunk/test/functionalities/alias/py_import Tue Aug 16 11:49:25 2011 @@ -0,0 +1,5 @@ +script import sys, os +script sys.path.append(os.path.join(os.getcwd(), os.pardir)) +script from welcome import * +command alias --python welcome welcome_impl +command alias --python targetname target_name_impl \ No newline at end of file Added: lldb/trunk/test/functionalities/alias/welcome.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/welcome.py?rev=137722&view=auto ============================================================================== --- lldb/trunk/test/functionalities/alias/welcome.py (added) +++ lldb/trunk/test/functionalities/alias/welcome.py Tue Aug 16 11:49:25 2011 @@ -0,0 +1,14 @@ +import sys + +def welcome_impl(debugger, args, stream, dict): + stream.Printf('Hello ' + args + ', welcome to LLDB'); + return None; + +def target_name_impl(debugger, args, stream, dict): + target = debugger.GetSelectedTarget() + file = target.GetExecutable() + stream.Printf('Current target ' + file.GetFilename()) + if args == 'fail': + return 'a test for error in command' + else: + return None \ No newline at end of file From johnny.chen at apple.com Tue Aug 16 12:06:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Aug 2011 17:06:45 -0000 Subject: [Lldb-commits] [lldb] r137724 - /lldb/trunk/test/lldbtest.py Message-ID: <20110816170645.921F82A6C12C@llvm.org> Author: johnny Date: Tue Aug 16 12:06:45 2011 New Revision: 137724 URL: http://llvm.org/viewvc/llvm-project?rev=137724&view=rev Log: Fix the test suite error of: ... File "/Volumes/data/lldb/svn/trunk/test/lldbtest.py", line 243, in __init__ self.session = test.session if test else None AttributeError: 'StdCXXDisassembleTestCase' object has no attribute 'session' 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=137724&r1=137723&r2=137724&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Aug 16 12:06:45 2011 @@ -240,7 +240,7 @@ def __init__(self, test, trace): """Create a StringIO instance; record the session obj and trace flag.""" StringIO.StringIO.__init__(self) - self.session = test.session if test else None + self.session = getattr(test, "session", None) if test else None self.trace = trace def __enter__(self): From scallanan at apple.com Tue Aug 16 13:09:29 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 16 Aug 2011 18:09:29 -0000 Subject: [Lldb-commits] [lldb] r137731 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20110816180929.E656D2A6C12C@llvm.org> Author: spyffe Date: Tue Aug 16 13:09:29 2011 New Revision: 137731 URL: http://llvm.org/viewvc/llvm-project?rev=137731&view=rev Log: Fixed a performance problem where functions were being searched for in too heavyweight a way. Now, when asking for the address of a function, the expression parser just asks for a corresponding data symbol. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=137731&r1=137730&r2=137731&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Aug 16 13:09:29 2011 @@ -497,6 +497,21 @@ return true; } +static void +FindCodeSymbolInContext +( + const ConstString &name, + SymbolContext &sym_ctx, + SymbolContextList &sc_list +) +{ + if (sym_ctx.module_sp) + sym_ctx.module_sp->FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list); + + if (!sc_list.GetSize()) + sym_ctx.target_sp->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list); +} + bool ClangExpressionDeclMap::GetFunctionAddress ( @@ -515,10 +530,9 @@ return false; SymbolContextList sc_list; - const bool include_symbols = true; - const bool append = false; - m_parser_vars->m_sym_ctx.FindFunctionsByName(name, include_symbols, append, sc_list); + FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list); + if (!sc_list.GetSize()) { // We occasionally get debug information in which a const function is reported @@ -536,7 +550,7 @@ ConstString const_name(const_name_scratch.c_str()); - m_parser_vars->m_sym_ctx.FindFunctionsByName(const_name, include_symbols, append, sc_list); + FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list); if (log) log->Printf("Found %d results with const name %s", sc_list.GetSize(), const_name.GetCString()); From gclayton at apple.com Tue Aug 16 13:19:31 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 16 Aug 2011 18:19:31 -0000 Subject: [Lldb-commits] [lldb] r137732 - /lldb/trunk/source/Symbol/Function.cpp Message-ID: <20110816181931.767F22A6C12C@llvm.org> Author: gclayton Date: Tue Aug 16 13:19:31 2011 New Revision: 137732 URL: http://llvm.org/viewvc/llvm-project?rev=137732&view=rev Log: Fixed the logging output that appears when doing a: (lldb) target modules dump symfile Modified: lldb/trunk/source/Symbol/Function.cpp Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=137732&r1=137731&r2=137732&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Tue Aug 16 13:19:31 2011 @@ -361,16 +361,14 @@ m_mangled.Dump(s); -// FunctionInfo::Dump(s); if (m_type) { - *s << ", type = " << (void*)m_type; - /// << " ("; - ///m_type->DumpTypeName(s); - ///s->PutChar(')'); + s->Printf(", type = %.*p", (int)sizeof(void*) * 2, m_type); } else if (m_type_uid != LLDB_INVALID_UID) - *s << ", type_uid = " << m_type_uid; + { + s->Printf(", type_uid = 0x%8.8x", m_type_uid); + } s->EOL(); // Dump the root object From gclayton at apple.com Tue Aug 16 13:40:23 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 16 Aug 2011 18:40:23 -0000 Subject: [Lldb-commits] [lldb] r137737 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20110816184023.5E9022A6C12C@llvm.org> Author: gclayton Date: Tue Aug 16 13:40:23 2011 New Revision: 137737 URL: http://llvm.org/viewvc/llvm-project?rev=137737&view=rev Log: Fixed an issue where we could end up creating multiple C++ methods for a function depending on how the DWARF was created. Now we parse the class type from the definition, and all methods that use DW_AT_specification or DW_AT_abstract_origin attributes to point to the definition, now won't create duplicate entries. This is in response to how clang++ creates much different DWARF than gcc. 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=137737&r1=137736&r2=137737&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Aug 16 13:40:23 2011 @@ -3539,6 +3539,8 @@ bool is_static = false; bool is_virtual = false; bool is_explicit = false; + dw_offset_t specification_die_offset = DW_INVALID_OFFSET; + dw_offset_t abstract_origin_die_offset = DW_INVALID_OFFSET; unsigned type_quals = 0; clang::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern @@ -3582,6 +3584,15 @@ } break; + case DW_AT_specification: + specification_die_offset = form_value.Reference(dwarf_cu); + break; + + case DW_AT_abstract_origin: + abstract_origin_die_offset = form_value.Reference(dwarf_cu); + break; + + case DW_AT_allocated: case DW_AT_associated: case DW_AT_address_class: @@ -3600,13 +3611,11 @@ case DW_AT_recursive: case DW_AT_return_addr: case DW_AT_segment: - case DW_AT_specification: case DW_AT_start_scope: case DW_AT_static_link: case DW_AT_trampoline: case DW_AT_visibility: case DW_AT_vtable_elem_location: - case DW_AT_abstract_origin: case DW_AT_description: case DW_AT_sibling: break; @@ -3724,35 +3733,56 @@ Type *class_type = ResolveType (dwarf_cu, m_decl_ctx_to_die[containing_decl_ctx]); if (class_type) { - clang_type_t class_opaque_type = class_type->GetClangForwardType(); - if (ClangASTContext::IsCXXClassType (class_opaque_type)) + if (specification_die_offset != DW_INVALID_OFFSET) { - // Neither GCC 4.2 nor clang++ currently set a valid accessibility - // in the DWARF for C++ methods... Default to public for now... - if (accessibility == eAccessNone) - accessibility = eAccessPublic; - - if (!is_static && !die->HasChildren()) - { - // We have a C++ member function with no children (this pointer!) - // and clang will get mad if we try and make a function that isn't - // well formed in the DWARF, so we will just skip it... - type_handled = true; - } - else + // If we have a specification, then the function type should have been + // made with the specification and not with this die. + DWARFCompileUnitSP spec_cu_sp; + const DWARFDebugInfoEntry* spec_die = DebugInfo()->GetDIEPtr(specification_die_offset, &spec_cu_sp); + if (m_die_to_decl_ctx[spec_die] == NULL) + fprintf (stderr,"warning: 0x%8.8x: DW_AT_specification(0x%8.8x) has no decl\n", die->GetOffset(), specification_die_offset); + type_handled = true; + } + else if (abstract_origin_die_offset != DW_INVALID_OFFSET) + { + DWARFCompileUnitSP abs_cu_sp; + const DWARFDebugInfoEntry* abs_die = DebugInfo()->GetDIEPtr(abstract_origin_die_offset, &abs_cu_sp); + if (m_die_to_decl_ctx[abs_die] == NULL) + fprintf (stderr,"warning: 0x%8.8x: DW_AT_abstract_origin(0x%8.8x) has no decl\n", die->GetOffset(), abstract_origin_die_offset); + type_handled = true; + } + else + { + clang_type_t class_opaque_type = class_type->GetClangForwardType(); + if (ClangASTContext::IsCXXClassType (class_opaque_type)) { - clang::CXXMethodDecl *cxx_method_decl; - cxx_method_decl = ast.AddMethodToCXXRecordType (class_opaque_type, - type_name_cstr, - clang_type, - accessibility, - is_virtual, - is_static, - is_inline, - is_explicit); - LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(cxx_method_decl), die); + // Neither GCC 4.2 nor clang++ currently set a valid accessibility + // in the DWARF for C++ methods... Default to public for now... + if (accessibility == eAccessNone) + accessibility = eAccessPublic; + + if (!is_static && !die->HasChildren()) + { + // We have a C++ member function with no children (this pointer!) + // and clang will get mad if we try and make a function that isn't + // well formed in the DWARF, so we will just skip it... + type_handled = true; + } + else + { + clang::CXXMethodDecl *cxx_method_decl; + cxx_method_decl = ast.AddMethodToCXXRecordType (class_opaque_type, + type_name_cstr, + clang_type, + accessibility, + is_virtual, + is_static, + is_inline, + is_explicit); + LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(cxx_method_decl), die); - type_handled = cxx_method_decl != NULL; + type_handled = cxx_method_decl != NULL; + } } } } From jingham at apple.com Tue Aug 16 14:03:09 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 16 Aug 2011 19:03:09 -0000 Subject: [Lldb-commits] [lldb] r137738 - /lldb/trunk/test/python_api/value/change_values/TestValueAPI.py Message-ID: <20110816190309.5C0502A6C12C@llvm.org> Author: jingham Date: Tue Aug 16 14:03:09 2011 New Revision: 137738 URL: http://llvm.org/viewvc/llvm-project?rev=137738&view=rev Log: Re-enable the test for ValueAsUnsigned on a register Value. Modified: lldb/trunk/test/python_api/value/change_values/TestValueAPI.py Modified: lldb/trunk/test/python_api/value/change_values/TestValueAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/change_values/TestValueAPI.py?rev=137738&r1=137737&r2=137738&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/change_values/TestValueAPI.py (original) +++ lldb/trunk/test/python_api/value/change_values/TestValueAPI.py Tue Aug 16 14:03:09 2011 @@ -117,7 +117,6 @@ thread.StepOver() expected_value = "Val - 12345 Mine - 55, 98765, 55555555. Ptr - 66, 98765, 66666666" stdout = process.GetSTDOUT(1000) - print stdout self.assertTrue (expected_value in stdout, "STDOUT showed changed values.") # Finally, change the stack pointer to 0, and we should not make it to our end breakpoint. @@ -127,10 +126,9 @@ self.assertTrue (sp_value.IsValid(), "Got a stack pointer value") result = sp_value.SetValueFromCString("1") self.assertTrue (result, "Setting sp returned true.") - # GetValueAsUnsigned doesn't work for register value objects yet. - # actual_value = sp_value.GetValueAsUnsigned (error, 0) - # self.assertTrue (error.Success(), "Got a changed value for sp") - # self.assertTrue (actual_value == 1, "Got the right changed value for sp.") + actual_value = sp_value.GetValueAsUnsigned (error, 0) + self.assertTrue (error.Success(), "Got a changed value for sp") + self.assertTrue (actual_value == 1, "Got the right changed value for sp.") process.Continue() From johnny.chen at apple.com Tue Aug 16 14:59:22 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Aug 2011 19:59:22 -0000 Subject: [Lldb-commits] [lldb] r137739 - /lldb/trunk/test/lang/c/strings/TestCStrings.py Message-ID: <20110816195922.985F32A6C12C@llvm.org> Author: johnny Date: Tue Aug 16 14:59:22 2011 New Revision: 137739 URL: http://llvm.org/viewvc/llvm-project?rev=137739&view=rev Log: Take clang output into account. Modified: lldb/trunk/test/lang/c/strings/TestCStrings.py Modified: lldb/trunk/test/lang/c/strings/TestCStrings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/strings/TestCStrings.py?rev=137739&r1=137738&r2=137739&view=diff ============================================================================== --- lldb/trunk/test/lang/c/strings/TestCStrings.py (original) +++ lldb/trunk/test/lang/c/strings/TestCStrings.py Tue Aug 16 14:59:22 2011 @@ -36,7 +36,7 @@ self.runCmd("process launch", RUN_SUCCEEDED) self.expect("expression -- a[2]", - startstr = "(char) $0 = 'c'") + patterns = ["\((const )?char\) \$0 = 'c'"]) self.expect("expression -- z[2]", startstr = "(const char) $1 = 'x'") From johnny.chen at apple.com Tue Aug 16 15:03:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Aug 2011 20:03:00 -0000 Subject: [Lldb-commits] [lldb] r137741 - /lldb/trunk/test/redo.py Message-ID: <20110816200300.1AA462A6C12C@llvm.org> Author: johnny Date: Tue Aug 16 15:02:59 2011 New Revision: 137741 URL: http://llvm.org/viewvc/llvm-project?rev=137741&view=rev Log: The redo script did not take into account the compiler and architecture configuration of the failed tests. Modified: lldb/trunk/test/redo.py Modified: lldb/trunk/test/redo.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/redo.py?rev=137741&r1=137740&r2=137741&view=diff ============================================================================== --- lldb/trunk/test/redo.py (original) +++ lldb/trunk/test/redo.py Tue Aug 16 15:02:59 2011 @@ -23,6 +23,8 @@ # To be filled with the filterspecs found in the session logs. redo_specs = [] +comp_specs = set() +arch_specs = set() def usage(): print"""\ @@ -49,10 +51,17 @@ # This is the pattern for the line from the log file to redo a test. # We want the filter spec. -pattern = re.compile("^\./dotest\.py.*-f (.*)$") +filter_pattern = re.compile("^\./dotest\.py.*-f (.*)$") +comp_pattern = re.compile(" -C ([^ ]+) ") +arch_pattern = re.compile(" -A ([^ ]+) ") def redo(suffix, dir, names): """Visitor function for os.path.walk(path, visit, arg).""" global redo_specs + global comp_specs + global arch_specs + global filter_pattern + global comp_pattern + global arch_pattern for name in names: if name.endswith(suffix): @@ -61,11 +70,17 @@ with open(os.path.join(dir, name), 'r') as log: content = log.read() for line in content.splitlines(): - match = pattern.match(line) + match = filter_pattern.match(line) if match: filterspec = match.group(1) print "adding filterspec:", filterspec redo_specs.append(filterspec) + comp = comp_pattern.search(line) + if comp: + comp_specs.add(comp.group(1)) + arch = arch_pattern.search(line) + if arch: + arch_specs.add(arch.group(1)) else: continue @@ -104,8 +119,14 @@ os.chdir(test_dir) os.path.walk(session_dir_path, redo, ".log") - command = "./dotest.py -v %s -f " % ("" if no_trace else "-t") filters = " -f ".join(redo_specs) + compilers = (" -C %s" % "^".join(comp_specs)) if comp_specs else None + archs = (" -A %s" % "^".join(arch_specs)) if arch_specs else None + + command = "./dotest.py %s %s -v %s -f " % (compilers if compilers else "", + archs if archs else "", + "" if no_trace else "-t") + print "Running %s" % (command + filters) os.system(command + filters) From johnny.chen at apple.com Tue Aug 16 15:56:10 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Aug 2011 20:56:10 -0000 Subject: [Lldb-commits] [lldb] r137748 - /lldb/trunk/test/redo.py Message-ID: <20110816205610.2EF852A6C12C@llvm.org> Author: johnny Date: Tue Aug 16 15:56:10 2011 New Revision: 137748 URL: http://llvm.org/viewvc/llvm-project?rev=137748&view=rev Log: Add comment on known restrictions of the current implementation. Modified: lldb/trunk/test/redo.py Modified: lldb/trunk/test/redo.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/redo.py?rev=137748&r1=137747&r2=137748&view=diff ============================================================================== --- lldb/trunk/test/redo.py (original) +++ lldb/trunk/test/redo.py Tue Aug 16 15:56:10 2011 @@ -23,7 +23,14 @@ # To be filled with the filterspecs found in the session logs. redo_specs = [] + +# There is a known bug with respect to comp_specs and arch_specs, in that if we +# encountered "-C clang" and "-C gcc" when visiting the session files, both +# compilers will end up in the invocation of the test driver when rerunning. +# That is: ./dotest -v -C clang^gcc ... -f ...". Ditto for "-A" flags. +# The "-C compiler" for comp_specs. comp_specs = set() +# The "-A arch" for arch_specs. arch_specs = set() def usage(): From johnny.chen at apple.com Tue Aug 16 15:57:05 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Aug 2011 20:57:05 -0000 Subject: [Lldb-commits] [lldb] r137749 - /lldb/trunk/test/redo.py Message-ID: <20110816205705.2EC632A6C12C@llvm.org> Author: johnny Date: Tue Aug 16 15:57:05 2011 New Revision: 137749 URL: http://llvm.org/viewvc/llvm-project?rev=137749&view=rev Log: Comment change. Modified: lldb/trunk/test/redo.py Modified: lldb/trunk/test/redo.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/redo.py?rev=137749&r1=137748&r2=137749&view=diff ============================================================================== --- lldb/trunk/test/redo.py (original) +++ lldb/trunk/test/redo.py Tue Aug 16 15:57:05 2011 @@ -28,6 +28,7 @@ # encountered "-C clang" and "-C gcc" when visiting the session files, both # compilers will end up in the invocation of the test driver when rerunning. # That is: ./dotest -v -C clang^gcc ... -f ...". Ditto for "-A" flags. + # The "-C compiler" for comp_specs. comp_specs = set() # The "-A arch" for arch_specs. From johnny.chen at apple.com Tue Aug 16 17:06:17 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Aug 2011 22:06:17 -0000 Subject: [Lldb-commits] [lldb] r137776 - /lldb/trunk/test/lldbtest.py Message-ID: <20110816220617.377A72A6C12C@llvm.org> Author: johnny Date: Tue Aug 16 17:06:17 2011 New Revision: 137776 URL: http://llvm.org/viewvc/llvm-project?rev=137776&view=rev Log: Add comment about recent change. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=137776&r1=137775&r2=137776&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Aug 16 17:06:17 2011 @@ -240,6 +240,8 @@ def __init__(self, test, trace): """Create a StringIO instance; record the session obj and trace flag.""" StringIO.StringIO.__init__(self) + # The test might not have undergone the 'setUp(self)' phase yet, so that + # the attribute 'session' might not even exist yet. self.session = getattr(test, "session", None) if test else None self.trace = trace From gclayton at apple.com Tue Aug 16 18:11:04 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 16 Aug 2011 23:11:04 -0000 Subject: [Lldb-commits] [lldb] r137782 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20110816231104.1C79E2A6C12C@llvm.org> Author: gclayton Date: Tue Aug 16 18:11:03 2011 New Revision: 137782 URL: http://llvm.org/viewvc/llvm-project?rev=137782&view=rev Log: Bumped Xcode project versions for lldb-73 and debugserver-144. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=137782&r1=137781&r2=137782&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Aug 16 18:11:03 2011 @@ -3431,10 +3431,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 72; + DYLIB_CURRENT_VERSION = 73; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3483,11 +3483,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 72; + DYLIB_CURRENT_VERSION = 73; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3534,8 +3534,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 72; - DYLIB_CURRENT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; + DYLIB_CURRENT_VERSION = 73; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3573,9 +3573,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 72; + DYLIB_CURRENT_VERSION = 73; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3613,9 +3613,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 72; + DYLIB_CURRENT_VERSION = 73; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3683,7 +3683,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3714,11 +3714,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 72; + DYLIB_CURRENT_VERSION = 73; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3843,7 +3843,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3875,7 +3875,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 72; + CURRENT_PROJECT_VERSION = 73; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=137782&r1=137781&r2=137782&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Tue Aug 16 18:11:03 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 72 + 73 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=137782&r1=137781&r2=137782&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Tue Aug 16 18:11:03 2011 @@ -473,7 +473,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 143; + CURRENT_PROJECT_VERSION = 144; "GCC_VERSION[sdk=iphoneos*][arch=*]" = 4.2; "GCC_VERSION[sdk=macosx*][arch=*]" = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 143; + CURRENT_PROJECT_VERSION = 144; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 143; + CURRENT_PROJECT_VERSION = 144; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -533,7 +533,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 143; + CURRENT_PROJECT_VERSION = 144; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -573,7 +573,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 143; + CURRENT_PROJECT_VERSION = 144; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -613,7 +613,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 143; + CURRENT_PROJECT_VERSION = 144; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Tue Aug 16 18:11:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 16 Aug 2011 23:11:57 -0000 Subject: [Lldb-commits] [lldb] r137783 - /lldb/tags/lldb-73/ Message-ID: <20110816231157.0CDC62A6C12C@llvm.org> Author: gclayton Date: Tue Aug 16 18:11:56 2011 New Revision: 137783 URL: http://llvm.org/viewvc/llvm-project?rev=137783&view=rev Log: lldb-73 Added: lldb/tags/lldb-73/ - copied from r137782, lldb/trunk/ From jingham at apple.com Tue Aug 16 18:15:02 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 16 Aug 2011 23:15:02 -0000 Subject: [Lldb-commits] [lldb] r137784 - /lldb/trunk/tools/driver/Driver.cpp Message-ID: <20110816231502.62DD72A6C12C@llvm.org> Author: jingham Date: Tue Aug 16 18:15:02 2011 New Revision: 137784 URL: http://llvm.org/viewvc/llvm-project?rev=137784&view=rev Log: Document how to pass program args to lldb command-line. Modified: lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=137784&r1=137783&r2=137784&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Tue Aug 16 18:15:02 2011 @@ -65,7 +65,7 @@ // pass it. } OptionDefinition; - +#define LLDB_2_TO_4 LLDB_OPT_SET_2|LLDB_OPT_SET_3|LLDB_OPT_SET_4 static OptionDefinition g_options[] = { { LLDB_OPT_SET_1, true , "help" , 'h', no_argument , NULL, eArgTypeNone, "Prints out the usage information for the LLDB debugger." }, @@ -75,8 +75,8 @@ { LLDB_OPT_SET_3 | LLDB_OPT_SET_4, false, "debug" , 'd', no_argument , NULL, eArgTypeNone,"Tells the debugger to print out extra information for debugging itself." }, { LLDB_OPT_SET_3 | LLDB_OPT_SET_4, false, "source" , 's', required_argument, NULL, eArgTypeFilename, "Tells the debugger to read in and execute the file , which should contain lldb commands." }, { LLDB_OPT_SET_3, true , "file" , 'f', required_argument, NULL, eArgTypeFilename, "Tells the debugger to use the file as the program to be debugged." }, - { LLDB_OPT_SET_ALL, false, "editor" , 'e', no_argument , NULL, eArgTypeNone, "Tells the debugger to open source files using the host's \"external editor\" mechanism." }, - { LLDB_OPT_SET_ALL, false, "no-lldbinit" , 'n', no_argument , NULL, eArgTypeNone, "Do not automatically parse any '.lldbinit' files." }, + { LLDB_2_TO_4, false, "editor" , 'e', no_argument , NULL, eArgTypeNone, "Tells the debugger to open source files using the host's \"external editor\" mechanism." }, + { LLDB_2_TO_4, false, "no-lldbinit" , 'n', no_argument , NULL, eArgTypeNone, "Do not automatically parse any '.lldbinit' files." }, { 0, false, NULL , 0 , 0 , NULL, eArgTypeNone, NULL } }; @@ -227,6 +227,7 @@ if (opt_set > 0) fprintf (out, "\n"); fprintf (out, "%*s%s", indent_level, "", name); + bool is_help_line = false; for (uint32_t i = 0; i < num_options; ++i) { @@ -234,6 +235,11 @@ { CommandArgumentType arg_type = option_table[i].argument_type; const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString (arg_type); + // This is a bit of a hack, but there's no way to say certain options don't have arguments yet... + // so we do it by hand here. + if (option_table[i].short_option == 'h') + is_help_line = true; + if (option_table[i].required) { if (option_table[i].option_has_arg == required_argument) @@ -254,6 +260,8 @@ } } } + if (!is_help_line) + fprintf (out, " [[--] [ ...]]"); } fprintf (out, "\n\n"); From granata.enrico at gmail.com Tue Aug 16 18:24:13 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Tue, 16 Aug 2011 23:24:13 -0000 Subject: [Lldb-commits] [lldb] r137785 - in /lldb/trunk: include/lldb/API/ include/lldb/Interpreter/ lldb.xcodeproj/ scripts/ scripts/Python/ scripts/Python/interface/ source/API/ source/Commands/ source/Interpreter/ test/functionalities/abbreviation/ test/functionalities/alias/ Message-ID: <20110816232413.C6FBA2A6C12C@llvm.org> Author: enrico Date: Tue Aug 16 18:24:13 2011 New Revision: 137785 URL: http://llvm.org/viewvc/llvm-project?rev=137785&view=rev Log: Changes to Python commands: - They now have an SBCommandReturnObject instead of an SBStream as third argument - The class CommandObjectPythonFunction has been merged into CommandObjectCommands.cpp - The command to manage them is now: command script with subcommands add, list, delete, clear command alias is returned to its previous functionality - Python commands are now part of an user dictionary, instead of being seen as aliases Removed: lldb/trunk/source/Commands/CommandObjectPythonFunction.cpp lldb/trunk/source/Commands/CommandObjectPythonFunction.h Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i lldb/trunk/scripts/Python/python-wrapper.swig lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/API/SBCommandReturnObject.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectHelp.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py lldb/trunk/test/functionalities/alias/TestAliases.py lldb/trunk/test/functionalities/alias/py_import lldb/trunk/test/functionalities/alias/welcome.py Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original) +++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Tue Aug 16 18:24:13 2011 @@ -76,6 +76,12 @@ void SetImmediateErrorFile (FILE *fh); + void + PutCString(const char* string, int len = -1); + + size_t + Printf(const char* format, ...); + protected: friend class SBCommandInterpreter; friend class SBOptions; Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Tue Aug 16 18:24:13 2011 @@ -46,6 +46,14 @@ eUnwarnedTruncation = 1, // truncated but did not notify eWarnedTruncation = 2 // truncated and notified }; + + enum CommandTypes + { + eCommandTypesBuiltin = 0x0001, // native commands such as "frame" + eCommandTypesUserDef = 0x0002, // scripted commands + eCommandTypesAliases = 0x0004, // aliases such as "po" + eCommandTypesAllThem = 0xFFFF // all commands + }; void SourceInitFile (bool in_cwd, @@ -63,6 +71,11 @@ const lldb::CommandObjectSP &cmd_sp, bool can_replace); + bool + AddUserCommand (const char *name, + const lldb::CommandObjectSP &cmd_sp, + bool can_replace); + lldb::CommandObjectSP GetCommandSPExact (const char *cmd, bool include_aliases); @@ -93,6 +106,12 @@ bool RemoveUser (const char *alias_name); + + void + RemoveAllUser () + { + m_user_dict.clear(); + } OptionArgVectorSP GetAliasOptions (const char *alias_name); @@ -239,7 +258,8 @@ StringList &matches); void - GetHelp (CommandReturnObject &result); + GetHelp (CommandReturnObject &result, + CommandTypes types = eCommandTypesAllThem); void GetAliasHelp (const char *alias_name, Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Aug 16 18:24:13 2011 @@ -120,6 +120,12 @@ virtual bool IsCrossRefObject () { return false; } + // override this to return true if you want to enable the user to delete + // the Command object from the Command dictionary (aliases have their own + // deletion scheme, so they do not need to care about this) + virtual bool + IsRemovable() { return false; } + bool IsAlias () { return m_is_alias; } Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Aug 16 18:24:13 2011 @@ -49,7 +49,7 @@ lldb::DebuggerSP& debugger, const char* args, std::string& err_msg, - lldb::SBStream& stream); + lldb_private::CommandReturnObject& cmd_retobj); typedef enum { @@ -186,7 +186,7 @@ virtual bool RunScriptBasedCommand(const char* impl_function, const char* args, - lldb::SBStream& stream, + lldb_private::CommandReturnObject& cmd_retobj, Error& error) { return false; Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Tue Aug 16 18:24:13 2011 @@ -84,7 +84,7 @@ virtual bool RunScriptBasedCommand(const char* impl_function, const char* args, - lldb::SBStream& stream, + lldb_private::CommandReturnObject& cmd_retobj, Error& error); bool Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Aug 16 18:24:13 2011 @@ -405,8 +405,6 @@ 94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94611EB113CCA4A4003A22AF /* RefCounter.cpp */; }; 9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */; }; 9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */; }; - 94A075BB13F9F58500D97961 /* CommandObjectPythonFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94A075B913F9F58500D97961 /* CommandObjectPythonFunction.cpp */; }; - 94A075BC13F9F58500D97961 /* CommandObjectPythonFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A075BA13F9F58500D97961 /* CommandObjectPythonFunction.h */; }; 94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.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 */; }; @@ -1176,8 +1174,6 @@ 9463D4CE13B179A500C230D4 /* CommandObjectType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommandObjectType.h; path = source/Commands/CommandObjectType.h; sourceTree = ""; }; 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeHierarchyNavigator.cpp; path = source/Symbol/TypeHierarchyNavigator.cpp; sourceTree = ""; }; 9467E65413C3D98900B3B6F3 /* TypeHierarchyNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeHierarchyNavigator.h; path = include/lldb/Symbol/TypeHierarchyNavigator.h; sourceTree = ""; }; - 94A075B913F9F58500D97961 /* CommandObjectPythonFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectPythonFunction.cpp; path = source/Commands/CommandObjectPythonFunction.cpp; sourceTree = ""; }; - 94A075BA13F9F58500D97961 /* CommandObjectPythonFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectPythonFunction.h; path = source/Commands/CommandObjectPythonFunction.h; sourceTree = ""; }; 94A9112B13D5DEF80046D8A6 /* FormatClasses.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatClasses.h; path = include/lldb/Core/FormatClasses.h; sourceTree = ""; }; 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatClasses.cpp; path = source/Core/FormatClasses.cpp; sourceTree = ""; }; 94B6E76013D8833C005F417F /* ValueObjectSyntheticFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectSyntheticFilter.h; path = include/lldb/Core/ValueObjectSyntheticFilter.h; sourceTree = ""; }; @@ -2127,8 +2123,6 @@ 26879CE71333F58B0012C1F8 /* CommandObjectPlatform.cpp */, 26BC7D1F10F1B76300F91463 /* CommandObjectProcess.h */, 26BC7E3810F1B84700F91463 /* CommandObjectProcess.cpp */, - 94A075BA13F9F58500D97961 /* CommandObjectPythonFunction.h */, - 94A075B913F9F58500D97961 /* CommandObjectPythonFunction.cpp */, 26BC7D2010F1B76300F91463 /* CommandObjectQuit.h */, 26BC7E3910F1B84700F91463 /* CommandObjectQuit.cpp */, 26BC7D2210F1B76300F91463 /* CommandObjectRegister.h */, @@ -2664,7 +2658,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 94A075BC13F9F58500D97961 /* CommandObjectPythonFunction.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3257,7 +3250,6 @@ 26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */, B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */, 94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */, - 94A075BB13F9F58500D97961 /* CommandObjectPythonFunction.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i (original) +++ lldb/trunk/scripts/Python/interface/SBCommandReturnObject.i Tue Aug 16 18:24:13 2011 @@ -70,6 +70,13 @@ void SetImmediateErrorFile (FILE *fh); + + void + PutCString(const char* string, int len = -1); + + size_t + Printf(const char* format, ...); + }; } // namespace lldb Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Tue Aug 16 18:24:13 2011 @@ -590,19 +590,21 @@ lldb::DebuggerSP& debugger, const char* args, std::string& err_msg, - lldb::SBStream& stream + lldb_private::CommandReturnObject& cmd_retobj ) { + not_owning_ap auto_cmd_retobj(&cmd_retobj); + bool retval = false; PyObject *DebuggerObj_PyObj = SWIG_NewPointerObj((void *) &debugger, SWIGTYPE_p_lldb__SBDebugger, 0); - PyObject *StreamObj_PyObj = SWIG_NewPointerObj((void *) &stream, SWIGTYPE_p_lldb__SBStream, 0); + PyObject *CmdRetObj_PyObj = SWIG_NewPointerObj((void *) &auto_cmd_retobj, SWIGTYPE_p_lldb__SBCommandReturnObject, 0); if (DebuggerObj_PyObj == NULL) return retval; - if (StreamObj_PyObj == NULL) + if (CmdRetObj_PyObj == NULL) return retval; if (!python_function_name || !session_dictionary_name) @@ -676,7 +678,7 @@ PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj); // This "steals" a reference to DebuggerObj_PyObj PyTuple_SetItem (pargs, 1, PyString_FromString(args)); - PyTuple_SetItem (pargs, 2, StreamObj_PyObj); // This "steals" a reference to StreamObj_PyObj + PyTuple_SetItem (pargs, 2, CmdRetObj_PyObj); // This "steals" a reference to CmdRetObj_PyObj PyTuple_SetItem (pargs, 3, session_dict); // This "steals" a reference to session_dict pvalue = PyObject_CallObject (pfunc, pargs); Py_DECREF (pargs); Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Tue Aug 16 18:24:13 2011 @@ -78,6 +78,25 @@ #include "lldb/API/SBValueList.h" %} +%{ +template +class not_owning_ap +{ +private: + std::auto_ptr m_auto_ptr; +public: + explicit not_owning_ap (T* p=0) : m_auto_ptr(p) {} + not_owning_ap (not_owning_ap& a) : m_auto_ptr(a.m_auto_ptr) {} + template + not_owning_ap (not_owning_ap& a) : m_auto_ptr(a.m_auto_ptr) {} + not_owning_ap (const not_owning_ap& r) : m_auto_ptr(r.m_auto_ptr) {} + ~not_owning_ap() { m_auto_ptr.release(); } + T* get() const { return m_auto_ptr.get(); } + T& operator*() const { return *m_auto_ptr; } + void reset (T* p=0) { m_auto_ptr.release(); m_auto_ptr.reset(p); } +}; +%} + /* Various liblldb typedefs that SWIG needs to know about. */ #define __extension__ /* Undefine GCC keyword to make Swig happy when processing glibc's stdint.h. */ %include Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Tue Aug 16 18:24:13 2011 @@ -344,7 +344,7 @@ lldb::DebuggerSP& debugger, const char* args, std::string& err_msg, - lldb::SBStream& stream + lldb_private::CommandReturnObject& cmd_retobj ); Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandReturnObject.cpp (original) +++ lldb/trunk/source/API/SBCommandReturnObject.cpp Tue Aug 16 18:24:13 2011 @@ -248,3 +248,27 @@ if (m_opaque_ap.get()) m_opaque_ap->SetImmediateErrorFile (fh); } + +void +SBCommandReturnObject::PutCString(const char* string, int len) +{ + if (m_opaque_ap.get()) + { + m_opaque_ap->AppendMessage(string, len); + } +} + +size_t +SBCommandReturnObject::Printf(const char* format, ...) +{ + if (m_opaque_ap.get()) + { + va_list args; + va_start (args, format); + size_t result = m_opaque_ap->GetOutputStream().PrintfVarArg(format, args); + va_end (args); + return result; + } + return 0; +} + Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Aug 16 18:24:13 2011 @@ -15,7 +15,6 @@ #include "llvm/ADT/StringRef.h" // Project includes -#include "CommandObjectPythonFunction.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/InputReader.h" #include "lldb/Core/InputReaderEZ.h" @@ -311,128 +310,12 @@ static const char *g_python_command_instructions = "Enter your Python command(s). Type 'DONE' to end.\n" "You must define a Python function with this signature:\n" - "def my_command_impl(debugger, args, stream, dict):"; + "def my_command_impl(debugger, args, result, dict):"; class CommandObjectCommandsAlias : public CommandObject { - class PythonAliasReader : public InputReaderEZ - { - private: - CommandInterpreter& m_interpreter; - std::string m_cmd_name; - StringList m_user_input; - DISALLOW_COPY_AND_ASSIGN (PythonAliasReader); - public: - PythonAliasReader(Debugger& debugger, - CommandInterpreter& interpreter, - std::string cmd_name) : - InputReaderEZ(debugger), - m_interpreter(interpreter), - m_cmd_name(cmd_name), - m_user_input() - {} - - virtual - ~PythonAliasReader() - { - } - - virtual void ActivateHandler(HandlerData& data) - { - StreamSP out_stream = data.GetOutStream(); - bool batch_mode = data.GetBatchMode(); - if (!batch_mode) - { - out_stream->Printf ("%s\n", g_python_command_instructions); - if (data.reader.GetPrompt()) - out_stream->Printf ("%s", data.reader.GetPrompt()); - out_stream->Flush(); - } - } - - virtual void ReactivateHandler(HandlerData& data) - { - StreamSP out_stream = data.GetOutStream(); - bool batch_mode = data.GetBatchMode(); - if (data.reader.GetPrompt() && !batch_mode) - { - out_stream->Printf ("%s", data.reader.GetPrompt()); - out_stream->Flush(); - } - } - virtual void GotTokenHandler(HandlerData& data) - { - StreamSP out_stream = data.GetOutStream(); - bool batch_mode = data.GetBatchMode(); - if (data.bytes && data.bytes_len) - { - m_user_input.AppendString(data.bytes, data.bytes_len); - } - if (!data.reader.IsDone() && data.reader.GetPrompt() && !batch_mode) - { - out_stream->Printf ("%s", data.reader.GetPrompt()); - out_stream->Flush(); - } - } - virtual void InterruptHandler(HandlerData& data) - { - StreamSP out_stream = data.GetOutStream(); - bool batch_mode = data.GetBatchMode(); - data.reader.SetIsDone (true); - if (!batch_mode) - { - out_stream->Printf ("Warning: No command attached to breakpoint.\n"); - out_stream->Flush(); - } - } - virtual void EOFHandler(HandlerData& data) - { - data.reader.SetIsDone (true); - } - virtual void DoneHandler(HandlerData& data) - { - StreamSP out_stream = data.GetOutStream(); - - ScriptInterpreter *interpreter = data.reader.GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); - if (!interpreter) - { - out_stream->Printf ("Internal error #1: no script attached.\n"); - out_stream->Flush(); - return; - } - StringList funct_name_sl; - if (!interpreter->GenerateScriptAliasFunction (m_user_input, - funct_name_sl)) - { - out_stream->Printf ("Internal error #2: no script attached.\n"); - out_stream->Flush(); - return; - } - if (funct_name_sl.GetSize() == 0) - { - out_stream->Printf ("Internal error #3: no script attached.\n"); - out_stream->Flush(); - return; - } - const char *funct_name = funct_name_sl.GetStringAtIndex(0); - if (!funct_name || !funct_name[0]) - { - out_stream->Printf ("Internal error #4: no script attached.\n"); - out_stream->Flush(); - return; - } - - // everything should be fine now, let's add this alias - - CommandObjectSP command_obj_sp(new CommandObjectPythonFunction(m_interpreter, - m_cmd_name, - funct_name)); - - m_interpreter.AddAlias(m_cmd_name.c_str(), command_obj_sp); - } - }; public: CommandObjectCommandsAlias (CommandInterpreter &interpreter) : @@ -552,98 +435,6 @@ const std::string alias_command = args.GetArgumentAtIndex (0); - if ( - (strcmp("--python",alias_command.c_str()) == 0) || - (strcmp("-P",alias_command.c_str()) == 0) - ) - { - - if (argc < 3) - { - // this is a definition of the form - // command alias --python foo_cmd - // and the user will type foo_cmd_impl by hand - std::string cmd_name = args.GetArgumentAtIndex(1); - // Verify that the command is alias-able. - if (m_interpreter.CommandExists (cmd_name.c_str())) - { - result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", - cmd_name.c_str()); - result.SetStatus (eReturnStatusFailed); - return false; - } - if (m_interpreter.AliasExists (cmd_name.c_str()) - || m_interpreter.UserCommandExists (cmd_name.c_str())) - { - result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", - cmd_name.c_str()); - } - - - InputReaderSP reader_sp (new PythonAliasReader (m_interpreter.GetDebugger(), - m_interpreter, - cmd_name)); - - if (reader_sp) - { - - InputReaderEZ::InitializationParameters ipr; - - Error err (reader_sp->Initialize (ipr.SetBaton(NULL).SetPrompt(" "))); - if (err.Success()) - { - m_interpreter.GetDebugger().PushInputReader (reader_sp); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendError (err.AsCString()); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendError("out of memory"); - result.SetStatus (eReturnStatusFailed); - } - - result.SetStatus (eReturnStatusSuccessFinishNoResult); - return result.Succeeded(); - } - else - { - // this is a definition of the form - // command alias --python foo_cmd funct_impl_foo - std::string cmd_name = args.GetArgumentAtIndex(1); - std::string funct_name = args.GetArgumentAtIndex(2); - - // Verify that the command is alias-able. - if (m_interpreter.CommandExists (cmd_name.c_str())) - { - result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", - cmd_name.c_str()); - result.SetStatus (eReturnStatusFailed); - return false; - } - - CommandObjectSP command_obj_sp(new CommandObjectPythonFunction(m_interpreter, - cmd_name, - funct_name)); - - if (m_interpreter.AliasExists (cmd_name.c_str()) - || m_interpreter.UserCommandExists (cmd_name.c_str())) - { - result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", - cmd_name.c_str()); - } - - m_interpreter.AddAlias(cmd_name.c_str(), command_obj_sp); - - result.SetStatus (eReturnStatusSuccessFinishNoResult); - return result.Succeeded(); - } - } - // Strip the new alias name off 'raw_command_string' (leave it on args, which gets passed to 'Execute', which // does the stripping itself. size_t pos = raw_command_string.find (alias_command); @@ -1348,6 +1139,535 @@ }; +class CommandObjectPythonFunction : public CommandObject +{ +private: + std::string m_function_name; + +public: + + CommandObjectPythonFunction (CommandInterpreter &interpreter, + std::string name, + std::string funct) : + CommandObject (interpreter, + name.c_str(), + (std::string("Run Python function ") + funct).c_str(), + NULL), + m_function_name(funct) + { + } + + virtual + ~CommandObjectPythonFunction () + { + } + + virtual bool + ExecuteRawCommandString (const char *raw_command_line, CommandReturnObject &result) + { + ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); + + Error error; + + if (!scripter || scripter->RunScriptBasedCommand(m_function_name.c_str(), + raw_command_line, + result, + error) == false) + { + result.AppendError(error.AsCString()); + result.SetStatus(eReturnStatusFailed); + } + else + result.SetStatus(eReturnStatusSuccessFinishNoResult); + + return result.Succeeded(); + } + + virtual bool + WantsRawCommandString () + { + return true; + } + + bool + Execute (Args& command, + CommandReturnObject &result) + { + std::string cmd_string; + command.GetCommandString(cmd_string); + return ExecuteRawCommandString(cmd_string.c_str(), result); + } + + virtual bool + IsRemovable() { return true; } + +}; + + +//------------------------------------------------------------------------- +// CommandObjectCommandsScriptAdd +//------------------------------------------------------------------------- + +class CommandObjectCommandsScriptAdd : public CommandObject +{ +private: + + class CommandOptions : public Options + { + public: + + CommandOptions (CommandInterpreter &interpreter) : + Options (interpreter) + { + } + + virtual + ~CommandOptions (){} + + virtual Error + SetOptionValue (uint32_t option_idx, const char *option_arg) + { + Error error; + char short_option = (char) m_getopt_table[option_idx].val; + + switch (short_option) + { + case 'f': + m_funct_name = std::string(option_arg); + break; + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; + } + + void + OptionParsingStarting () + { + m_funct_name = ""; + } + + 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. + + std::string m_funct_name; + }; + + CommandOptions m_options; + + virtual Options * + GetOptions () + { + return &m_options; + } + + class PythonAliasReader : public InputReaderEZ + { + private: + CommandInterpreter& m_interpreter; + std::string m_cmd_name; + StringList m_user_input; + DISALLOW_COPY_AND_ASSIGN (PythonAliasReader); + public: + PythonAliasReader(Debugger& debugger, + CommandInterpreter& interpreter, + std::string cmd_name) : + InputReaderEZ(debugger), + m_interpreter(interpreter), + m_cmd_name(cmd_name), + m_user_input() + {} + + virtual + ~PythonAliasReader() + { + } + + virtual void ActivateHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + bool batch_mode = data.GetBatchMode(); + if (!batch_mode) + { + out_stream->Printf ("%s\n", g_python_command_instructions); + if (data.reader.GetPrompt()) + out_stream->Printf ("%s", data.reader.GetPrompt()); + out_stream->Flush(); + } + } + + virtual void ReactivateHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + bool batch_mode = data.GetBatchMode(); + if (data.reader.GetPrompt() && !batch_mode) + { + out_stream->Printf ("%s", data.reader.GetPrompt()); + out_stream->Flush(); + } + } + virtual void GotTokenHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + bool batch_mode = data.GetBatchMode(); + if (data.bytes && data.bytes_len) + { + m_user_input.AppendString(data.bytes, data.bytes_len); + } + if (!data.reader.IsDone() && data.reader.GetPrompt() && !batch_mode) + { + out_stream->Printf ("%s", data.reader.GetPrompt()); + out_stream->Flush(); + } + } + virtual void InterruptHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + bool batch_mode = data.GetBatchMode(); + data.reader.SetIsDone (true); + if (!batch_mode) + { + out_stream->Printf ("Warning: No command attached to breakpoint.\n"); + out_stream->Flush(); + } + } + virtual void EOFHandler(HandlerData& data) + { + data.reader.SetIsDone (true); + } + virtual void DoneHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + + ScriptInterpreter *interpreter = data.reader.GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); + if (!interpreter) + { + out_stream->Printf ("Internal error #1: no script attached.\n"); + out_stream->Flush(); + return; + } + StringList funct_name_sl; + if (!interpreter->GenerateScriptAliasFunction (m_user_input, + funct_name_sl)) + { + out_stream->Printf ("Internal error #2: no script attached.\n"); + out_stream->Flush(); + return; + } + if (funct_name_sl.GetSize() == 0) + { + out_stream->Printf ("Internal error #3: no script attached.\n"); + out_stream->Flush(); + return; + } + const char *funct_name = funct_name_sl.GetStringAtIndex(0); + if (!funct_name || !funct_name[0]) + { + out_stream->Printf ("Internal error #4: no script attached.\n"); + out_stream->Flush(); + return; + } + + // everything should be fine now, let's add this alias + + CommandObjectSP command_obj_sp(new CommandObjectPythonFunction(m_interpreter, + m_cmd_name, + funct_name)); + + if (!m_interpreter.AddUserCommand(m_cmd_name.c_str(), command_obj_sp, true)) + { + out_stream->Printf ("Internal error #5: no script attached.\n"); + out_stream->Flush(); + return; + } + } + }; + +public: + CommandObjectCommandsScriptAdd(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "command script add", + "Add a scripted function as an LLDB command.", + NULL), + m_options (interpreter) + { + CommandArgumentEntry arg1; + CommandArgumentData cmd_arg; + + // Define the first (and only) variant of this arg. + cmd_arg.arg_type = eArgTypeCommandName; + cmd_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (cmd_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + } + + ~CommandObjectCommandsScriptAdd () + { + } + + bool + Execute + ( + Args& args, + CommandReturnObject &result + ) + { + size_t argc = args.GetArgumentCount(); + + if (argc != 1) + { + result.AppendError ("'command script add' requires one argument"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + std::string cmd_name = args.GetArgumentAtIndex(0); + + if (m_options.m_funct_name.empty()) + { + InputReaderSP reader_sp (new PythonAliasReader (m_interpreter.GetDebugger(), + m_interpreter, + cmd_name)); + + if (reader_sp) + { + + InputReaderEZ::InitializationParameters ipr; + + Error err (reader_sp->Initialize (ipr.SetBaton(NULL).SetPrompt(" "))); + if (err.Success()) + { + m_interpreter.GetDebugger().PushInputReader (reader_sp); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendError (err.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + result.AppendError("out of memory"); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + CommandObjectSP new_cmd(new CommandObjectPythonFunction(m_interpreter, cmd_name, m_options.m_funct_name)); + if (m_interpreter.AddUserCommand(cmd_name.c_str(), new_cmd, true)) + { + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendError("cannot add command"); + result.SetStatus (eReturnStatusFailed); + } + } + + return result.Succeeded(); + + } +}; + +OptionDefinition +CommandObjectCommandsScriptAdd::CommandOptions::g_option_table[] = +{ + { LLDB_OPT_SET_1, false, "function", 'f', required_argument, NULL, 0, eArgTypeName, "Name of a Python function to use."}, + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +}; + +//------------------------------------------------------------------------- +// CommandObjectCommandsScriptList +//------------------------------------------------------------------------- + +class CommandObjectCommandsScriptList : public CommandObject +{ +private: + +public: + CommandObjectCommandsScriptList(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "command script list", + "List defined scripted commands.", + NULL) + { + } + + ~CommandObjectCommandsScriptList () + { + } + + bool + Execute + ( + Args& args, + CommandReturnObject &result + ) + { + + m_interpreter.GetHelp(result, + CommandInterpreter::eCommandTypesUserDef); + + result.SetStatus (eReturnStatusSuccessFinishResult); + + return true; + + + } +}; + +//------------------------------------------------------------------------- +// CommandObjectCommandsScriptClear +//------------------------------------------------------------------------- + +class CommandObjectCommandsScriptClear : public CommandObject +{ +private: + +public: + CommandObjectCommandsScriptClear(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "command script clear", + "Delete all scripted commands.", + NULL) + { + } + + ~CommandObjectCommandsScriptClear () + { + } + + bool + Execute + ( + Args& args, + CommandReturnObject &result + ) + { + + m_interpreter.RemoveAllUser(); + + result.SetStatus (eReturnStatusSuccessFinishResult); + + return true; + + + } +}; + +//------------------------------------------------------------------------- +// CommandObjectCommandsScriptDelete +//------------------------------------------------------------------------- + +class CommandObjectCommandsScriptDelete : public CommandObject +{ +private: + +public: + CommandObjectCommandsScriptDelete(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "command script delete", + "Delete a scripted command.", + NULL) + { + CommandArgumentEntry arg1; + CommandArgumentData cmd_arg; + + // Define the first (and only) variant of this arg. + cmd_arg.arg_type = eArgTypeCommandName; + cmd_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (cmd_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + } + + ~CommandObjectCommandsScriptDelete () + { + } + + bool + Execute + ( + Args& args, + CommandReturnObject &result + ) + { + + size_t argc = args.GetArgumentCount(); + + if (argc != 1) + { + result.AppendError ("'command script delete' requires one argument"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const char* cmd_name = args.GetArgumentAtIndex(0); + + if (cmd_name && *cmd_name && m_interpreter.HasUserCommands() && m_interpreter.UserCommandExists(cmd_name)) + { + m_interpreter.RemoveUser(cmd_name); + result.SetStatus (eReturnStatusSuccessFinishResult); + } + else + { + result.AppendErrorWithFormat ("command %s not found", cmd_name); + result.SetStatus (eReturnStatusFailed); + } + + return result.Succeeded(); + + } +}; + +#pragma mark CommandObjectMultiwordCommandsScript + +//------------------------------------------------------------------------- +// CommandObjectMultiwordCommandsScript +//------------------------------------------------------------------------- + +class CommandObjectMultiwordCommandsScript : public CommandObjectMultiword +{ +public: + CommandObjectMultiwordCommandsScript (CommandInterpreter &interpreter) : + CommandObjectMultiword (interpreter, + "command script", + "A set of commands for managing or customizing script commands.", + "command script []") + { + LoadSubCommand ("add", CommandObjectSP (new CommandObjectCommandsScriptAdd (interpreter))); + LoadSubCommand ("delete", CommandObjectSP (new CommandObjectCommandsScriptDelete (interpreter))); + LoadSubCommand ("clear", CommandObjectSP (new CommandObjectCommandsScriptClear (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectCommandsScriptList (interpreter))); + } + + ~CommandObjectMultiwordCommandsScript () + { + } + +}; + + #pragma mark CommandObjectMultiwordCommands //------------------------------------------------------------------------- @@ -1365,6 +1685,7 @@ LoadSubCommand ("unalias", CommandObjectSP (new CommandObjectCommandsUnalias (interpreter))); LoadSubCommand ("regex", CommandObjectSP (new CommandObjectCommandsAddRegex (interpreter))); LoadSubCommand ("history", CommandObjectSP (new CommandObjectCommandsHistory (interpreter))); + LoadSubCommand ("script", CommandObjectSP (new CommandObjectMultiwordCommandsScript (interpreter))); } CommandObjectMultiwordCommands::~CommandObjectMultiwordCommands () Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Tue Aug 16 18:24:13 2011 @@ -49,7 +49,6 @@ { } - bool CommandObjectHelp::Execute (Args& command, CommandReturnObject &result) { Removed: lldb/trunk/source/Commands/CommandObjectPythonFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPythonFunction.cpp?rev=137784&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPythonFunction.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectPythonFunction.cpp (removed) @@ -1,88 +0,0 @@ -//===-- CommandObjectPythonFunction.cpp --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectPythonFunction.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes - -#include "lldb/API/SBStream.h" - -#include "lldb/Core/Debugger.h" - -#include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/Options.h" - -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -#include "lldb/Interpreter/ScriptInterpreter.h" -#include "lldb/Interpreter/ScriptInterpreterPython.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectApropos -//------------------------------------------------------------------------- - -CommandObjectPythonFunction::CommandObjectPythonFunction (CommandInterpreter &interpreter, - std::string name, - std::string funct) : - CommandObject (interpreter, - name.c_str(), - (std::string("Run Python function ") + funct).c_str(), - NULL), - m_function_name(funct) -{ - CommandArgumentEntry arg; - CommandArgumentData search_word_arg; - - // Define the first (and only) variant of this arg. - search_word_arg.arg_type = eArgTypeSearchWord; - search_word_arg.arg_repetition = eArgRepeatPlain; - - // There is only one variant this argument could be; put it into the argument entry. - arg.push_back (search_word_arg); - - // Push the data for the first argument into the m_arguments vector. - m_arguments.push_back (arg); -} - -CommandObjectPythonFunction::~CommandObjectPythonFunction() -{ -} - -bool -CommandObjectPythonFunction::ExecuteRawCommandString (const char *raw_command_line, - CommandReturnObject &result) -{ - ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); - - Error error; - - lldb::SBStream stream; - - if (scripter->RunScriptBasedCommand(m_function_name.c_str(), - raw_command_line, - stream, - error) == false) - { - result.AppendError(error.AsCString()); - result.SetStatus(eReturnStatusFailed); - } - else - result.SetStatus(eReturnStatusSuccessFinishNoResult); - - result.GetOutputStream() << stream.GetData(); - - return result.Succeeded(); -} Removed: lldb/trunk/source/Commands/CommandObjectPythonFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPythonFunction.h?rev=137784&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPythonFunction.h (original) +++ lldb/trunk/source/Commands/CommandObjectPythonFunction.h (removed) @@ -1,62 +0,0 @@ -//===-- CommandObjectPythonFunction.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_CommandObjectPythonFunction_h_ -#define liblldb_CommandObjectPythonFunction_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectApropos -//------------------------------------------------------------------------- - -class CommandObjectPythonFunction : public CommandObject -{ -private: - std::string m_function_name; - -public: - - CommandObjectPythonFunction (CommandInterpreter &interpreter, - std::string name, - std::string funct); - - virtual - ~CommandObjectPythonFunction (); - - virtual bool - ExecuteRawCommandString (const char *raw_command_line, CommandReturnObject &result); - - virtual bool - WantsRawCommandString () - { - return true; - } - - bool - Execute (Args& command, - CommandReturnObject &result) - { - std::string cmd_string; - command.GetCommandString(cmd_string); - return ExecuteRawCommandString(cmd_string.c_str(), result); - } - - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectPythonFunction_h_ Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Aug 16 18:24:13 2011 @@ -264,7 +264,7 @@ m_command_dict["source"] = CommandObjectSP (new CommandObjectMultiwordSource (*this)); m_command_dict["target"] = CommandObjectSP (new CommandObjectMultiwordTarget (*this)); m_command_dict["thread"] = CommandObjectSP (new CommandObjectMultiwordThread (*this)); - m_command_dict["type"] = CommandObjectSP (new CommandObjectType (*this)); + m_command_dict["type"] = CommandObjectSP (new CommandObjectType (*this)); m_command_dict["version"] = CommandObjectSP (new CommandObjectVersion (*this)); std::auto_ptr @@ -457,6 +457,24 @@ return false; } +bool +CommandInterpreter::AddUserCommand (const char *name, + const lldb::CommandObjectSP &cmd_sp, + bool can_replace) +{ + if (name && name[0]) + { + std::string name_sstr(name); + if (!can_replace) + { + if (m_user_dict.find (name_sstr) != m_user_dict.end()) + return false; + } + m_user_dict[name_sstr] = cmd_sp; + return true; + } + return false; +} CommandObjectSP CommandInterpreter::GetCommandSPExact (const char *cmd_cstr, bool include_aliases) @@ -682,21 +700,28 @@ } void -CommandInterpreter::GetHelp (CommandReturnObject &result) +CommandInterpreter::GetHelp (CommandReturnObject &result, + CommandTypes cmd_types) { CommandObject::CommandMap::const_iterator pos; - result.AppendMessage("The following is a list of built-in, permanent debugger commands:"); - result.AppendMessage(""); uint32_t max_len = FindLongestCommandWord (m_command_dict); - - for (pos = m_command_dict.begin(); pos != m_command_dict.end(); ++pos) + + if ( (cmd_types & eCommandTypesBuiltin) == eCommandTypesBuiltin ) { - OutputFormattedHelpText (result.GetOutputStream(), pos->first.c_str(), "--", pos->second->GetHelp(), - max_len); + + result.AppendMessage("The following is a list of built-in, permanent debugger commands:"); + result.AppendMessage(""); + + for (pos = m_command_dict.begin(); pos != m_command_dict.end(); ++pos) + { + OutputFormattedHelpText (result.GetOutputStream(), pos->first.c_str(), "--", pos->second->GetHelp(), + max_len); + } + result.AppendMessage(""); + } - result.AppendMessage(""); - if (m_alias_dict.size() > 0) + if (m_alias_dict.size() > 0 && ( (cmd_types & eCommandTypesAliases) == eCommandTypesAliases )) { result.AppendMessage("The following is a list of your current command abbreviations " "(see 'help command alias' for more info):"); @@ -718,13 +743,15 @@ result.AppendMessage(""); } - if (m_user_dict.size() > 0) + if (m_user_dict.size() > 0 && ( (cmd_types & eCommandTypesUserDef) == eCommandTypesUserDef )) { result.AppendMessage ("The following is a list of your current user-defined commands:"); result.AppendMessage(""); + max_len = FindLongestCommandWord (m_user_dict); for (pos = m_user_dict.begin(); pos != m_user_dict.end(); ++pos) { - result.AppendMessageWithFormat ("%s -- %s\n", pos->first.c_str(), pos->second->GetHelp()); + OutputFormattedHelpText (result.GetOutputStream(), pos->first.c_str(), "--", pos->second->GetHelp(), + max_len); } result.AppendMessage(""); } Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Aug 16 18:24:13 2011 @@ -1909,7 +1909,7 @@ bool ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function, const char* args, - lldb::SBStream& stream, + lldb_private::CommandReturnObject& cmd_retobj, Error& error) { if (!impl_function) @@ -1941,7 +1941,7 @@ debugger_sp, args, err_msg, - stream); + cmd_retobj); python_interpreter->LeaveSession (); } else @@ -1955,7 +1955,7 @@ debugger_sp, args, err_msg, - stream); + cmd_retobj); python_interpreter->LeaveSession (); ReleasePythonLock (); } Modified: lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py (original) +++ lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py Tue Aug 16 18:24:13 2011 @@ -34,7 +34,7 @@ startstr = "The following is a list of built-in, permanent debugger commands:") - self.expect("com s ./change_prompt.lldb", + self.expect("com sou ./change_prompt.lldb", patterns = ["Executing commands in '.*change_prompt.lldb'"]) self.expect("settings show prompt", Modified: lldb/trunk/test/functionalities/alias/TestAliases.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/TestAliases.py?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/test/functionalities/alias/TestAliases.py (original) +++ lldb/trunk/test/functionalities/alias/TestAliases.py Tue Aug 16 18:24:13 2011 @@ -135,10 +135,10 @@ self.expect('welcome Enrico', substrs = ['Hello Enrico, welcome to LLDB']); - self.runCmd("command unalias welcome"); + self.runCmd("command script delete welcome"); self.expect('welcome Enrico', matching=False, error=True, - substrs = ['Hello Enrico, welcome to LLDB']); + substrs = ['Hello Enrico, welcome to LLDB']); self.expect('targetname', substrs = ['a.out']) @@ -146,7 +146,7 @@ self.expect('targetname fail', error=True, substrs = ['a test for error in command']) - self.expect('help', + self.expect('command script list', substrs = ['targetname', 'Run Python function target_name_impl']) @@ -155,6 +155,14 @@ 'This command takes \'raw\' input', 'quote stuff']) + self.expect("longwait", + substrs = ['Done; if you saw the delays I am doing OK']) + + self.runCmd("command script clear") + + self.expect('command script list', matching=False, + substrs = ['targetname', + 'longwait']) if __name__ == '__main__': import atexit Modified: lldb/trunk/test/functionalities/alias/py_import URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/py_import?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/test/functionalities/alias/py_import (original) +++ lldb/trunk/test/functionalities/alias/py_import Tue Aug 16 18:24:13 2011 @@ -1,5 +1,6 @@ script import sys, os script sys.path.append(os.path.join(os.getcwd(), os.pardir)) script from welcome import * -command alias --python welcome welcome_impl -command alias --python targetname target_name_impl \ No newline at end of file +command script add welcome --function welcome_impl +command script add targetname --function target_name_impl +command script add longwait --function print_wait_impl Modified: lldb/trunk/test/functionalities/alias/welcome.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/welcome.py?rev=137785&r1=137784&r2=137785&view=diff ============================================================================== --- lldb/trunk/test/functionalities/alias/welcome.py (original) +++ lldb/trunk/test/functionalities/alias/welcome.py Tue Aug 16 18:24:13 2011 @@ -1,14 +1,23 @@ import sys -def welcome_impl(debugger, args, stream, dict): - stream.Printf('Hello ' + args + ', welcome to LLDB'); +def welcome_impl(debugger, args, result, dict): + result.Printf('Hello ' + args + ', welcome to LLDB'); return None; -def target_name_impl(debugger, args, stream, dict): +def target_name_impl(debugger, args, result, dict): target = debugger.GetSelectedTarget() file = target.GetExecutable() - stream.Printf('Current target ' + file.GetFilename()) + result.PutCString('Current target ' + file.GetFilename()) if args == 'fail': return 'a test for error in command' else: - return None \ No newline at end of file + return None + +def print_wait_impl(debugger, args, result, dict): + print 'Trying to do long task..'; + import time + time.sleep(1) + print 'Still doing long task..'; + time.sleep(1) + result.PutCString('Done; if you saw the delays I am doing OK') + return None \ No newline at end of file From jingham at apple.com Tue Aug 16 18:57:58 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 16 Aug 2011 23:57:58 -0000 Subject: [Lldb-commits] [lldb] r137789 - /lldb/trunk/tools/driver/Driver.cpp Message-ID: <20110816235758.3E4232A6C12C@llvm.org> Author: jingham Date: Tue Aug 16 18:57:58 2011 New Revision: 137789 URL: http://llvm.org/viewvc/llvm-project?rev=137789&view=rev Log: Better help string for "lldb -- file arg1 arg2..." Modified: lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=137789&r1=137788&r2=137789&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Tue Aug 16 18:57:58 2011 @@ -306,8 +306,13 @@ indent_level -= 5; - fprintf (out, "\n%*s('%s ' also works, to specify the file to be debugged.)\n\n", - indent_level, "", name); + fprintf (out, "\n%*s(If you don't provide -f then the first argument will be the file to be debugged" + "\n%*s so '%s -- [ []]' also works." + "\n%*s Remember to end the options with \"--\" if any of your arguments have a \"-\" in them.)\n\n", + indent_level, "", + indent_level, "", + name, + indent_level, ""); } void From jingham at apple.com Tue Aug 16 19:23:09 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 17 Aug 2011 00:23:09 -0000 Subject: [Lldb-commits] [lldb] r137790 - /lldb/trunk/www/lldb-gdb.html Message-ID: <20110817002309.5BCD32A6C12C@llvm.org> Author: jingham Date: Tue Aug 16 19:23:09 2011 New Revision: 137790 URL: http://llvm.org/viewvc/llvm-project?rev=137790&view=rev Log: Add "--" before providing the file & command args when launching lldb from the command line. 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=137790&r1=137789&r2=137790&view=diff ============================================================================== --- lldb/trunk/www/lldb-gdb.html (original) +++ lldb/trunk/www/lldb-gdb.html Tue Aug 16 19:23:09 2011 @@ -63,7 +63,7 @@ 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 -- a.out 1 2 3
(lldb) run
...
(lldb) run
From granata.enrico at gmail.com Tue Aug 16 20:30:04 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 17 Aug 2011 01:30:04 -0000 Subject: [Lldb-commits] [lldb] r137801 - in /lldb/trunk: include/lldb/Interpreter/CommandObject.h include/lldb/Interpreter/ScriptInterpreter.h include/lldb/Interpreter/ScriptInterpreterPython.h source/Commands/CommandObjectCommands.cpp source/Interpreter/CommandObject.cpp source/Interpreter/ScriptInterpreterPython.cpp source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp test/functionalities/alias/TestAliases.py test/functionalities/alias/welcome.py Message-ID: <20110817013004.66E062A6C12C@llvm.org> Author: enrico Date: Tue Aug 16 20:30:04 2011 New Revision: 137801 URL: http://llvm.org/viewvc/llvm-project?rev=137801&view=rev Log: When defining a scripted command, it is possible to provide a docstring and that will be used as the help text for the command If no docstring is provided, a default help text is created LLDB will refuse to create scripted commands if the scripting language is anything but Python Some additional comments in AppleObjCRuntimeV2.cpp to describe the memory layout expected by the dynamic type lookup code Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/test/functionalities/alias/TestAliases.py lldb/trunk/test/functionalities/alias/welcome.py Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=137801&r1=137800&r2=137801&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Aug 16 20:30:04 2011 @@ -112,6 +112,9 @@ SetHelpLong (const char * str); void + SetHelpLong (std::string str); + + void SetSyntax (const char *str); virtual void Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=137801&r1=137800&r2=137801&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Aug 16 20:30:04 2011 @@ -191,6 +191,12 @@ { return false; } + + virtual std::string + GetDocumentationForItem(const char* item) + { + return std::string(""); + } const char * GetScriptInterpreterPtyName (); Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=137801&r1=137800&r2=137801&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Tue Aug 16 20:30:04 2011 @@ -109,6 +109,9 @@ static std::string CallPythonScriptFunction (const char *python_function_name, lldb::ValueObjectSP valobj); + + virtual std::string + GetDocumentationForItem(const char* item); void CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=137801&r1=137800&r2=137801&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Aug 16 20:30:04 2011 @@ -24,6 +24,8 @@ #include "lldb/Interpreter/CommandObjectRegexCommand.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/ScriptInterpreter.h" +#include "lldb/Interpreter/ScriptInterpreterPython.h" using namespace lldb; using namespace lldb_private; @@ -1155,6 +1157,13 @@ NULL), m_function_name(funct) { + ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); + if (scripter) + { + std::string docstring = scripter->GetDocumentationForItem(funct.c_str()); + if (!docstring.empty()) + SetHelpLong(docstring); + } } virtual @@ -1427,6 +1436,14 @@ CommandReturnObject &result ) { + + if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) + { + result.AppendError ("only scripting language supported for scripted commands is currently Python"); + result.SetStatus (eReturnStatusFailed); + return false; + } + size_t argc = args.GetArgumentCount(); if (argc != 1) Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=137801&r1=137800&r2=137801&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Aug 16 20:30:04 2011 @@ -129,6 +129,12 @@ } void +CommandObject::SetHelpLong (std::string str) +{ + m_cmd_help_long = str; +} + +void CommandObject::SetSyntax (const char *cstr) { m_cmd_syntax = cstr; Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=137801&r1=137800&r2=137801&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Aug 16 20:30:04 2011 @@ -763,13 +763,13 @@ case eCharPtr: // "char *" { const char format[3] = "s#"; - success = PyArg_Parse (py_return, format, (char **) &ret_value); + success = PyArg_Parse (py_return, format, (char **) ret_value); break; } case eCharStrOrNone: // char* or NULL if py_return == Py_None { const char format[3] = "z"; - success = PyArg_Parse (py_return, format, (char **) &ret_value); + success = PyArg_Parse (py_return, format, (char **) ret_value); break; } case eBool: @@ -1972,6 +1972,26 @@ } +// in Python, a special attribute __doc__ contains the docstring +// for an object (function, method, class, ...) if any is defined +// Otherwise, the attribute's value is None +std::string +ScriptInterpreterPython::GetDocumentationForItem(const char* item) +{ + std::string command(item); + command += ".__doc__"; + + char* result_ptr = NULL; // Python is going to point this to valid data if ExecuteOneLineWithReturn returns successfully + + if (ExecuteOneLineWithReturn (command.c_str(), + ScriptInterpreter::eCharStrOrNone, + &result_ptr) && result_ptr) + { + return std::string(result_ptr); + } + else + return std::string(""); +} void ScriptInterpreterPython::InitializeInterpreter (SWIGInitCallback python_swig_init_callback, 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=137801&r1=137800&r2=137801&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Tue Aug 16 20:30:04 2011 @@ -568,9 +568,9 @@ // tagged pointers are marked by having their least-significant bit // set. this makes them "invalid" as pointers because they violate -// the alignment requirements. this way, we can always know when -// we are dealing with a tagged pointer, and use the lookup approach -// that the runtime would +// the alignment requirements. of course, this detection algorithm +// is not accurate (it might become better by incorporating further +// knowledge about the internals of tagged pointers) bool AppleObjCRuntimeV2::IsTaggedPointer(lldb::addr_t ptr) { @@ -578,6 +578,9 @@ } +// this code relies on the assumption that an Objective-C object always starts +// with an ISA at offset 0. an ISA is effectively a pointer to an instance of +// struct class_t in the ObjCv2 runtime lldb_private::ObjCLanguageRuntime::ObjCISA AppleObjCRuntimeV2::GetISA(ValueObject& valobj) { @@ -587,8 +590,8 @@ { // when using the expression parser, an additional layer of "frozen data" // can be created, which is basically a byte-exact copy of the data returned - // by the expression, but in host memory. because Python code might need to read - // into the object memory in non-obvious ways, we need to hand it the target version + // by the expression, but in host memory. because this code reads memory without + // taking the debug-info-provided object layout, we need to hand it the target version // of the expression output lldb::addr_t tgt_address = valobj.GetValueAsUnsigned(); ValueObjectSP target_object = ValueObjectConstResult::Create (valobj.GetExecutionContextScope(), @@ -647,9 +650,20 @@ uint8_t pointer_size = m_process->GetAddressByteSize(); Error error; + + /* + struct class_t *isa; + struct class_t *superclass; + Cache cache; + IMP *vtable; +--> uintptr_t data_NEVER_USE; + WARNING: this data_NEVER_USE pointer might one day contain flags in the least-significant bits + currently, rdar://problem/8955342 prevents the runtime from doing so + it presently is just a pointer to a class_rw_t + */ + lldb::addr_t rw_pointer = isa + (4 * pointer_size); //printf("rw_pointer: %llx\n", rw_pointer); - uint64_t data_pointer = m_process->ReadUnsignedIntegerFromMemory(rw_pointer, pointer_size, 0, @@ -657,6 +671,12 @@ if (error.Fail()) return ConstString("unknown"); + /* + uint32_t flags; + uint32_t version; + +--> const class_ro_t *ro; + */ data_pointer += 8; //printf("data_pointer: %llx\n", data_pointer); uint64_t ro_pointer = m_process->ReadUnsignedIntegerFromMemory(data_pointer, @@ -666,6 +686,18 @@ if (error.Fail()) return ConstString("unknown"); + /* + uint32_t flags; + uint32_t instanceStart; + uint32_t instanceSize; + #ifdef __LP64__ + uint32_t reserved; + #endif + + const uint8_t * ivarLayout; + +--> const char * name; + */ ro_pointer += 12; if (pointer_size == 8) ro_pointer += 4; @@ -722,6 +754,10 @@ uint8_t pointer_size = m_process->GetAddressByteSize(); Error error; + /* + struct class_t *isa; +--> struct class_t *superclass; + */ lldb::addr_t parent_pointer = isa + pointer_size; //printf("rw_pointer: %llx\n", rw_pointer); Modified: lldb/trunk/test/functionalities/alias/TestAliases.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/TestAliases.py?rev=137801&r1=137800&r2=137801&view=diff ============================================================================== --- lldb/trunk/test/functionalities/alias/TestAliases.py (original) +++ lldb/trunk/test/functionalities/alias/TestAliases.py Tue Aug 16 20:30:04 2011 @@ -134,6 +134,10 @@ self.expect('welcome Enrico', substrs = ['Hello Enrico, welcome to LLDB']); + + self.expect("help welcome", + substrs = ['Just a docstring for welcome_impl', + 'A command that says hello to LLDB users']) self.runCmd("command script delete welcome"); Modified: lldb/trunk/test/functionalities/alias/welcome.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/welcome.py?rev=137801&r1=137800&r2=137801&view=diff ============================================================================== --- lldb/trunk/test/functionalities/alias/welcome.py (original) +++ lldb/trunk/test/functionalities/alias/welcome.py Tue Aug 16 20:30:04 2011 @@ -1,6 +1,10 @@ import sys def welcome_impl(debugger, args, result, dict): + """ + Just a docstring for welcome_impl + A command that says hello to LLDB users + """ result.Printf('Hello ' + args + ', welcome to LLDB'); return None; From granata.enrico at gmail.com Wed Aug 17 14:07:52 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 17 Aug 2011 19:07:52 -0000 Subject: [Lldb-commits] [lldb] r137850 - in /lldb/trunk: include/lldb/Core/Debugger.h lldb.xcodeproj/project.pbxproj scripts/Python/finish-swig-Python-LLDB.sh source/Commands/CommandObjectType.cpp source/Core/Debugger.cpp source/Interpreter/ScriptInterpreterPython.cpp source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp source/osxcpp.py test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Message-ID: <20110817190752.57AB32A6C12C@llvm.org> Author: enrico Date: Wed Aug 17 14:07:52 2011 New Revision: 137850 URL: http://llvm.org/viewvc/llvm-project?rev=137850&view=rev Log: New category "gnu-libstdc++" provides summary for std::string and synthetic children for types std::map, std::list and std::vector The category is enabled by default. If you run into issues with it, disable it and the previous behavior of LLDB is restored ** This is a temporary solution. The general solution to having formatters pulled in at startup should involve going through the Platform. Fixed an issue in type synthetic list where a category with synthetic providers in it was not shown if all the providers were regex-based Added: lldb/trunk/source/osxcpp.py Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=137850&r1=137849&r2=137850&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Wed Aug 17 14:07:52 2011 @@ -271,6 +271,12 @@ SettingsTerminate (); static void + FormatManagerInitialize(); + + static void + FormatManagerTerminate(); + + static void Destroy (lldb::DebuggerSP &debugger_sp); ~Debugger (); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=137850&r1=137849&r2=137850&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Aug 17 14:07:52 2011 @@ -654,7 +654,6 @@ 2669605E1199F4230075C61A /* lldb.swig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = lldb.swig; sourceTree = ""; }; 266960601199F4230075C61A /* build-swig-Python.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "build-swig-Python.sh"; sourceTree = ""; }; 266960611199F4230075C61A /* edit-swig-python-wrapper-file.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = "edit-swig-python-wrapper-file.py"; sourceTree = ""; }; - 266960621199F4230075C61A /* finish-swig-Python-lldb.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "finish-swig-Python-lldb.sh"; sourceTree = ""; }; 266960631199F4230075C61A /* sed-sources */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "sed-sources"; sourceTree = ""; }; 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangNamespaceDecl.cpp; path = source/Symbol/ClangNamespaceDecl.cpp; sourceTree = ""; }; 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangNamespaceDecl.h; path = include/lldb/Symbol/ClangNamespaceDecl.h; sourceTree = ""; }; @@ -1179,6 +1178,7 @@ 94B6E76013D8833C005F417F /* ValueObjectSyntheticFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectSyntheticFilter.h; path = include/lldb/Core/ValueObjectSyntheticFilter.h; sourceTree = ""; }; 94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectSyntheticFilter.cpp; path = source/Core/ValueObjectSyntheticFilter.cpp; sourceTree = ""; }; 94EBAC8313D9EE26009BA64E /* PythonPointer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PythonPointer.h; path = include/lldb/Utility/PythonPointer.h; sourceTree = ""; }; + 94FE476613FC1DA8001F8475 /* finish-swig-Python-LLDB.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "finish-swig-Python-LLDB.sh"; sourceTree = ""; }; 961FABB81235DE1600F93A47 /* FuncUnwinders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FuncUnwinders.cpp; path = source/Symbol/FuncUnwinders.cpp; sourceTree = ""; }; 961FABB91235DE1600F93A47 /* UnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindPlan.cpp; path = source/Symbol/UnwindPlan.cpp; sourceTree = ""; }; 961FABBA1235DE1600F93A47 /* UnwindTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindTable.cpp; path = source/Symbol/UnwindTable.cpp; sourceTree = ""; }; @@ -1734,7 +1734,7 @@ children = ( 266960601199F4230075C61A /* build-swig-Python.sh */, 266960611199F4230075C61A /* edit-swig-python-wrapper-file.py */, - 266960621199F4230075C61A /* finish-swig-Python-lldb.sh */, + 94FE476613FC1DA8001F8475 /* finish-swig-Python-LLDB.sh */, 9A48A3A7124AAA5A00922451 /* python-extensions.swig */, 94005E0313F438DF001EF42D /* python-wrapper.swig */, ); Modified: lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh?rev=137850&r1=137849&r2=137850&view=diff ============================================================================== --- lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh (original) +++ lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh Wed Aug 17 14:07:52 2011 @@ -165,5 +165,20 @@ fi fi +# Copy the OSX C++ STL formatters over to the framework Python directory +if [ -f "${SRC_ROOT}/source/osxcpp.py" ] +then + if [ $Debug == 1 ] + then + echo "Copying osxcpp.py to ${framework_python_dir}" + fi + cp "${SRC_ROOT}/source/osxcpp.py" "${framework_python_dir}" +else + if [ $Debug == 1 ] + then + echo "Unable to find ${SRC_ROOT}/source/osxcpp.py" + fi +fi + exit 0 Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=137850&r1=137849&r2=137850&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Wed Aug 17 14:07:52 2011 @@ -1538,7 +1538,7 @@ CommandReturnObject* result = param->result; // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->GetCount() == 0) && param->cate_regex == NULL) + if ((cate->IsEnabled() == false || cate->GetCount(FormatCategory::eSummary | FormatCategory::eRegexSummary) == 0) && param->cate_regex == NULL) return true; // if we have a regex and this category does not match it, just skip it @@ -2032,7 +2032,7 @@ CommandReturnObject* result = param->result; // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->Filter()->GetCount() == 0) && param->cate_regex == NULL) + if ((cate->IsEnabled() == false || cate->GetCount(FormatCategory::eFilter | FormatCategory::eRegexFilter) == 0) && param->cate_regex == NULL) return true; // if we have a regex and this category does not match it, just skip it @@ -2240,7 +2240,7 @@ CommandReturnObject* result = param->result; // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->Synth()->GetCount() == 0) && param->cate_regex == NULL) + if ((cate->IsEnabled() == false || cate->GetCount(FormatCategory::eSynth | FormatCategory::eRegexSynth) == 0) && param->cate_regex == NULL) return true; // if we have a regex and this category does not match it, just skip it Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=137850&r1=137849&r2=137850&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Wed Aug 17 14:07:52 2011 @@ -82,6 +82,7 @@ if (g_shared_debugger_refcount == 0) { lldb_private::Initialize(); + Debugger::FormatManagerInitialize(); } g_shared_debugger_refcount++; @@ -95,6 +96,7 @@ g_shared_debugger_refcount--; if (g_shared_debugger_refcount == 0) { + Debugger::FormatManagerTerminate(); lldb_private::WillTerminate(); lldb_private::Terminate(); @@ -1781,6 +1783,72 @@ return g_format_manager; } +// The platform should be responsible for initializing its own formatters +// (e.g. to handle versioning, different runtime libraries, ...) +// Currently, basic formatters for std:: objects as implemented by +// the GNU libstdc++ are defined regardless, and enabled by default +// This is going to be moved to some platform-dependent location +// (in the meanwhile, these formatters should work for Mac OS X & Linux) +void +Debugger::FormatManagerInitialize() +{ + static bool g_initialized = false; + + if (!g_initialized) + { + g_initialized = true; + ConstString gnulib("gnu-libstdc++"); + FormatManager& format_mgr = GetFormatManager(); + lldb::FormatCategorySP osxcpp = format_mgr.Category(gnulib.AsCString()); + osxcpp->Summary()->Add(ConstString("std::string").AsCString(), + SummaryFormatSP(new StringSummaryFormat(true, + false, + false, + true, + true, + false, + "${var._M_dataplus._M_p}"))); + osxcpp->Summary()->Add(ConstString("std::basic_string").AsCString(), + SummaryFormatSP(new StringSummaryFormat(true, + false, + false, + true, + true, + false, + "${var._M_dataplus._M_p}"))); + osxcpp->Summary()->Add(ConstString("std::basic_string,std::allocator >").AsCString(), + SummaryFormatSP(new StringSummaryFormat(true, + false, + false, + true, + true, + false, + "${var._M_dataplus._M_p}"))); + osxcpp->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::vector<")), + SyntheticChildrenSP(new SyntheticScriptProvider(true, + false, + false, + "StdVectorSynthProvider"))); + osxcpp->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::map<")), + SyntheticChildrenSP(new SyntheticScriptProvider(true, + false, + false, + "StdMapSynthProvider"))); + osxcpp->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::list<")), + SyntheticChildrenSP(new SyntheticScriptProvider(true, + false, + false, + "StdListSynthProvider"))); + + format_mgr.EnableCategory(gnulib.AsCString()); + + } +} + +void +Debugger::FormatManagerTerminate() +{} + void Debugger::Formatting::ForceUpdate() { Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=137850&r1=137849&r2=137850&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Wed Aug 17 14:07:52 2011 @@ -173,6 +173,11 @@ interpreter.GetDebugger().GetID()); PyRun_SimpleString (run_string.GetData()); + run_string.Clear(); + run_string.Printf ("run_one_line (%s, 'from osxcpp import *')", m_dictionary_name.c_str(), + interpreter.GetDebugger().GetID()); + PyRun_SimpleString (run_string.GetData()); + if (m_dbg_stdout != NULL) { m_new_sysout = PyFile_FromFile (m_dbg_stdout, (char *) "", (char *) "w", _check_and_flush); 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=137850&r1=137849&r2=137850&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Wed Aug 17 14:07:52 2011 @@ -656,10 +656,7 @@ struct class_t *superclass; Cache cache; IMP *vtable; ---> uintptr_t data_NEVER_USE; - WARNING: this data_NEVER_USE pointer might one day contain flags in the least-significant bits - currently, rdar://problem/8955342 prevents the runtime from doing so - it presently is just a pointer to a class_rw_t +--> class_rw_t data; */ lldb::addr_t rw_pointer = isa + (4 * pointer_size); Added: lldb/trunk/source/osxcpp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/osxcpp.py?rev=137850&view=auto ============================================================================== --- lldb/trunk/source/osxcpp.py (added) +++ lldb/trunk/source/osxcpp.py Wed Aug 17 14:07:52 2011 @@ -0,0 +1,231 @@ +import re + +# C++ STL formatters for LLDB +# These formatters are based upon the version of the STL that ships +# with Mac OS X Snow Leopard 10.6.8 and OS X Lion 10.7.0 +# The STL implementation *might* change on other releases of Apple's +# operating system and library infrastructure, and might be different on +# other operating systems + +class StdListSynthProvider: + + def __init__(self, valobj, dict): + self.valobj = valobj + self.update() + + def num_children(self): + next_val = self.next.GetValueAsUnsigned(0) + prev_val = self.prev.GetValueAsUnsigned(0) + # After a std::list has been initialized, both next and prev will be non-NULL + if next_val == 0 or prev_val == 0: + return 0 + if next_val == self.node_address: + return 0 + if next_val == prev_val: + return 1 + size = 2 + current = self.next + while current.GetChildMemberWithName('_M_next').GetValueAsUnsigned(0) != self.node_address: + size = size + 1 + current = current.GetChildMemberWithName('_M_next') + return (size - 1) + + def get_child_index(self,name): + return int(name.lstrip('[').rstrip(']')) + + def get_child_at_index(self,index): + if index >= self.num_children(): + return None; + offset = index + current = self.next + while offset > 0: + current = current.GetChildMemberWithName('_M_next') + offset = offset - 1 + return current.CreateChildAtOffset('['+str(index)+']',2*current.GetType().GetByteSize(),self.data_type) + + def extract_type_name(self,name): + self.type_name = name[16:] + index = 2 + count_of_template = 1 + while index < len(self.type_name): + if self.type_name[index] == '<': + count_of_template = count_of_template + 1 + elif self.type_name[index] == '>': + count_of_template = count_of_template - 1 + elif self.type_name[index] == ',' and count_of_template == 1: + self.type_name = self.type_name[:index] + break + index = index + 1 + self.type_name_nospaces = self.type_name.replace(", ", ",") + + def update(self): + impl = self.valobj.GetChildMemberWithName('_M_impl') + node = impl.GetChildMemberWithName('_M_node') + self.extract_type_name(impl.GetType().GetName()) + self.node_address = self.valobj.AddressOf().GetValueAsUnsigned(0) + self.next = node.GetChildMemberWithName('_M_next') + self.prev = node.GetChildMemberWithName('_M_prev') + self.data_type = node.GetTarget().FindFirstType(self.type_name) + # tries to fight against a difference in formatting type names between gcc and clang + if self.data_type.IsValid() == False: + self.data_type = node.GetTarget().FindFirstType(self.type_name_nospaces) + self.data_size = self.data_type.GetByteSize() + +class StdVectorSynthProvider: + + def __init__(self, valobj, dict): + self.valobj = valobj; + self.update() + + def num_children(self): + start_val = self.start.GetValueAsUnsigned(0) + finish_val = self.finish.GetValueAsUnsigned(0) + end_val = self.end.GetValueAsUnsigned(0) + # Before a vector has been constructed, it will contain bad values + # so we really need to be careful about the length we return since + # unitialized data can cause us to return a huge number. We need + # to also check for any of the start, finish or end of storage values + # being zero (NULL). If any are, then this vector has not been + # initialized yet and we should return zero + + # Make sure nothing is NULL + if start_val == 0 or finish_val == 0 or end_val == 0: + return 0 + # Make sure start is less than finish + if start_val >= finish_val: + return 0 + # Make sure finish is less than or equal to end of storage + if finish_val > end_val: + return 0 + + num_children = (finish_val-start_val)/self.data_size + return num_children + + def get_child_index(self,name): + return int(name.lstrip('[').rstrip(']')) + + def get_child_at_index(self,index): + if index >= self.num_children(): + return None; + offset = index * self.data_size + return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) + + def update(self): + impl = self.valobj.GetChildMemberWithName('_M_impl') + self.start = impl.GetChildMemberWithName('_M_start') + self.finish = impl.GetChildMemberWithName('_M_finish') + self.end = impl.GetChildMemberWithName('_M_end_of_storage') + self.data_type = self.start.GetType().GetPointeeType() + self.data_size = self.data_type.GetByteSize() + + +class StdMapSynthProvider: + + def __init__(self, valobj, dict): + self.valobj = valobj; + self.update() + + def update(self): + self.Mt = self.valobj.GetChildMemberWithName('_M_t') + self.Mimpl = self.Mt.GetChildMemberWithName('_M_impl') + self.Mheader = self.Mimpl.GetChildMemberWithName('_M_header') + # from libstdc++ implementation of _M_root for rbtree + self.Mroot = self.Mheader.GetChildMemberWithName('_M_parent') + # the stuff into the tree is actually a std::pair + # life would be much easier if gcc had a coherent way to print out + # template names in debug info + self.expand_clang_type_name() + self.expand_gcc_type_name() + self.data_type = self.Mt.GetTarget().FindFirstType(self.clang_type_name) + if self.data_type.IsValid() == False: + self.data_type = self.Mt.GetTarget().FindFirstType(self.gcc_type_name) + self.data_size = self.data_type.GetByteSize() + self.skip_size = self.Mheader.GetType().GetByteSize() + + def expand_clang_type_name(self): + type_name = self.Mimpl.GetType().GetName() + index = type_name.find("std::pair<") + type_name = type_name[index+5:] + index = 6 + template_count = 1 + while index < len(type_name): + if type_name[index] == '<': + template_count = template_count + 1 + elif type_name[index] == '>' and template_count == 1: + type_name = type_name[:index+1] + break + elif type_name[index] == '>': + template_count = template_count - 1 + index = index + 1; + self.clang_type_name = type_name + + def expand_gcc_type_name(self): + type_name = self.Mt.GetType().GetName() + index = type_name.find("std::pair<") + type_name = type_name[index+5:] + index = 6 + template_count = 1 + while index < len(type_name): + if type_name[index] == '<': + template_count = template_count + 1 + elif type_name[index] == '>' and template_count == 1: + type_name = type_name[:index+1] + break + elif type_name[index] == '>': + template_count = template_count - 1 + elif type_name[index] == ' ' and template_count == 1 and type_name[index-1] == ',': + type_name = type_name[0:index] + type_name[index+1:] + index = index - 1 + index = index + 1; + self.gcc_type_name = type_name + + def num_children(self): + root_ptr_val = self.node_ptr_value(self.Mroot) + if root_ptr_val == 0: + return 0; + return self.Mimpl.GetChildMemberWithName('_M_node_count').GetValueAsUnsigned(0) + + def get_child_index(self,name): + return int(name.lstrip('[').rstrip(']')) + + def get_child_at_index(self,index): + if index >= self.num_children(): + return None; + offset = index + current = self.left(self.Mheader); + while offset > 0: + current = self.increment_node(current) + offset = offset - 1; + # skip all the base stuff and get at the data + return current.CreateChildAtOffset('['+str(index)+']',self.skip_size,self.data_type) + + # utility functions + def node_ptr_value(self,node): + return node.GetValueAsUnsigned(0) + + def right(self,node): + return node.GetChildMemberWithName("_M_right"); + + def left(self,node): + return node.GetChildMemberWithName("_M_left"); + + def parent(self,node): + return node.GetChildMemberWithName("_M_parent"); + + # from libstdc++ implementation of iterator for rbtree + def increment_node(self,node): + if self.node_ptr_value(self.right(node)) != 0: + x = self.right(node); + while self.node_ptr_value(self.left(x)) != 0: + x = self.left(x); + return x; + else: + x = node; + y = self.parent(x) + while(self.node_ptr_value(x) == self.node_ptr_value(self.right(y))): + x = y; + y = self.parent(y); + if self.node_ptr_value(self.right(x)) != self.node_ptr_value(y): + x = y; + return x; + Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py?rev=137850&r1=137849&r2=137850&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Wed Aug 17 14:07:52 2011 @@ -222,9 +222,9 @@ # std::vector - self.runCmd("script from StdVectorSynthProvider import *") - self.runCmd("type synth add -l StdVectorSynthProvider std::int_vect int_vect") - self.runCmd("type synth add -l StdVectorSynthProvider std::string_vect string_vect") + #self.runCmd("script from StdVectorSynthProvider import *") + #self.runCmd("type synth add -l StdVectorSynthProvider std::int_vect int_vect") + #self.runCmd("type synth add -l StdVectorSynthProvider std::string_vect string_vect") self.runCmd("n") @@ -351,12 +351,12 @@ substrs = ['vector has 0 items']) # now test std::list - self.runCmd("script from StdListSynthProvider import *") + #self.runCmd("script from StdListSynthProvider import *") self.runCmd("n") self.runCmd("frame variable numbers_list -T") - self.runCmd("type synth add std::int_list std::string_list int_list string_list -l StdListSynthProvider") + #self.runCmd("type synth add std::int_list std::string_list int_list string_list -l StdListSynthProvider") self.runCmd("type summary add std::int_list std::string_list int_list string_list -f \"list has ${svar%#} items\" -e") self.runCmd("type format add -f hex int") @@ -467,13 +467,13 @@ self.runCmd("n") self.runCmd("frame variable ii -T") - self.runCmd("script from StdMapSynthProvider import *") + #self.runCmd("script from StdMapSynthProvider import *") self.runCmd("type summary add -x \"std::map<\" -f \"map has ${svar%#} items\" -e") #import time #time.sleep(30) - self.runCmd("type synth add -x \"std::map<\" -l StdMapSynthProvider") + #self.runCmd("type synth add -x \"std::map<\" -l StdMapSynthProvider") self.expect('frame variable ii', From granata.enrico at gmail.com Wed Aug 17 17:13:59 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 17 Aug 2011 22:13:59 -0000 Subject: [Lldb-commits] [lldb] r137886 - in /lldb/trunk: examples/synthetic/ include/lldb/Core/ scripts/Python/ source/ source/Commands/ source/Core/ source/Interpreter/ test/functionalities/data-formatter/data-formatter-skip-summary/ Message-ID: <20110817221359.6F7292A6C12C@llvm.org> Author: enrico Date: Wed Aug 17 17:13:59 2011 New Revision: 137886 URL: http://llvm.org/viewvc/llvm-project?rev=137886&view=rev Log: First round of code cleanups: - all instances of "vobj" have been renamed to "valobj" - class Debugger::Formatting has been renamed to DataVisualization (defined in FormatManager.h/cpp) The interface to this class has not changed - FormatCategory now uses ConstString's as keys to the navigators instead of repeatedly casting from ConstString to const char* and back all the time Next step is making the same happen for categories themselves - category gnu-libstdc++ is defined in the constructor for a FormatManager The source code for it is defined in gnu_libstdcpp.py, drawn from examples/synthetic at compile time All references to previous 'osxcpp' name have been removed from both code and file names Functional changes: - the name of the option to use a summary string for 'type summary add' has changed from the previous --format-string to the new --summary-string. It is expected that the short option will change from -f to -s, and -s for --python-script will become -o Added: lldb/trunk/examples/synthetic/gnu_libstdcpp.py Removed: lldb/trunk/source/osxcpp.py Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Core/FormatClasses.h lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/FormatClasses.cpp lldb/trunk/source/Core/FormatManager.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Interpreter/CommandObjectScript.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py Added: lldb/trunk/examples/synthetic/gnu_libstdcpp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/gnu_libstdcpp.py?rev=137886&view=auto ============================================================================== --- lldb/trunk/examples/synthetic/gnu_libstdcpp.py (added) +++ lldb/trunk/examples/synthetic/gnu_libstdcpp.py Wed Aug 17 17:13:59 2011 @@ -0,0 +1,231 @@ +import re + +# C++ STL formatters for LLDB +# These formatters are based upon the version of the STL that ships +# with Mac OS X Snow Leopard 10.6.8 and OS X Lion 10.7.0 +# The STL implementation *might* change on other releases of Apple's +# operating system and library infrastructure, and might be different on +# other operating systems + +class StdListSynthProvider: + + def __init__(self, valobj, dict): + self.valobj = valobj + self.update() + + def num_children(self): + next_val = self.next.GetValueAsUnsigned(0) + prev_val = self.prev.GetValueAsUnsigned(0) + # After a std::list has been initialized, both next and prev will be non-NULL + if next_val == 0 or prev_val == 0: + return 0 + if next_val == self.node_address: + return 0 + if next_val == prev_val: + return 1 + size = 2 + current = self.next + while current.GetChildMemberWithName('_M_next').GetValueAsUnsigned(0) != self.node_address: + size = size + 1 + current = current.GetChildMemberWithName('_M_next') + return (size - 1) + + def get_child_index(self,name): + return int(name.lstrip('[').rstrip(']')) + + def get_child_at_index(self,index): + if index >= self.num_children(): + return None; + offset = index + current = self.next + while offset > 0: + current = current.GetChildMemberWithName('_M_next') + offset = offset - 1 + return current.CreateChildAtOffset('['+str(index)+']',2*current.GetType().GetByteSize(),self.data_type) + + def extract_type_name(self,name): + self.type_name = name[16:] + index = 2 + count_of_template = 1 + while index < len(self.type_name): + if self.type_name[index] == '<': + count_of_template = count_of_template + 1 + elif self.type_name[index] == '>': + count_of_template = count_of_template - 1 + elif self.type_name[index] == ',' and count_of_template == 1: + self.type_name = self.type_name[:index] + break + index = index + 1 + self.type_name_nospaces = self.type_name.replace(", ", ",") + + def update(self): + impl = self.valobj.GetChildMemberWithName('_M_impl') + node = impl.GetChildMemberWithName('_M_node') + self.extract_type_name(impl.GetType().GetName()) + self.node_address = self.valobj.AddressOf().GetValueAsUnsigned(0) + self.next = node.GetChildMemberWithName('_M_next') + self.prev = node.GetChildMemberWithName('_M_prev') + self.data_type = node.GetTarget().FindFirstType(self.type_name) + # tries to fight against a difference in formatting type names between gcc and clang + if self.data_type.IsValid() == False: + self.data_type = node.GetTarget().FindFirstType(self.type_name_nospaces) + self.data_size = self.data_type.GetByteSize() + +class StdVectorSynthProvider: + + def __init__(self, valobj, dict): + self.valobj = valobj; + self.update() + + def num_children(self): + start_val = self.start.GetValueAsUnsigned(0) + finish_val = self.finish.GetValueAsUnsigned(0) + end_val = self.end.GetValueAsUnsigned(0) + # Before a vector has been constructed, it will contain bad values + # so we really need to be careful about the length we return since + # unitialized data can cause us to return a huge number. We need + # to also check for any of the start, finish or end of storage values + # being zero (NULL). If any are, then this vector has not been + # initialized yet and we should return zero + + # Make sure nothing is NULL + if start_val == 0 or finish_val == 0 or end_val == 0: + return 0 + # Make sure start is less than finish + if start_val >= finish_val: + return 0 + # Make sure finish is less than or equal to end of storage + if finish_val > end_val: + return 0 + + num_children = (finish_val-start_val)/self.data_size + return num_children + + def get_child_index(self,name): + return int(name.lstrip('[').rstrip(']')) + + def get_child_at_index(self,index): + if index >= self.num_children(): + return None; + offset = index * self.data_size + return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) + + def update(self): + impl = self.valobj.GetChildMemberWithName('_M_impl') + self.start = impl.GetChildMemberWithName('_M_start') + self.finish = impl.GetChildMemberWithName('_M_finish') + self.end = impl.GetChildMemberWithName('_M_end_of_storage') + self.data_type = self.start.GetType().GetPointeeType() + self.data_size = self.data_type.GetByteSize() + + +class StdMapSynthProvider: + + def __init__(self, valobj, dict): + self.valobj = valobj; + self.update() + + def update(self): + self.Mt = self.valobj.GetChildMemberWithName('_M_t') + self.Mimpl = self.Mt.GetChildMemberWithName('_M_impl') + self.Mheader = self.Mimpl.GetChildMemberWithName('_M_header') + # from libstdc++ implementation of _M_root for rbtree + self.Mroot = self.Mheader.GetChildMemberWithName('_M_parent') + # the stuff into the tree is actually a std::pair + # life would be much easier if gcc had a coherent way to print out + # template names in debug info + self.expand_clang_type_name() + self.expand_gcc_type_name() + self.data_type = self.Mt.GetTarget().FindFirstType(self.clang_type_name) + if self.data_type.IsValid() == False: + self.data_type = self.Mt.GetTarget().FindFirstType(self.gcc_type_name) + self.data_size = self.data_type.GetByteSize() + self.skip_size = self.Mheader.GetType().GetByteSize() + + def expand_clang_type_name(self): + type_name = self.Mimpl.GetType().GetName() + index = type_name.find("std::pair<") + type_name = type_name[index+5:] + index = 6 + template_count = 1 + while index < len(type_name): + if type_name[index] == '<': + template_count = template_count + 1 + elif type_name[index] == '>' and template_count == 1: + type_name = type_name[:index+1] + break + elif type_name[index] == '>': + template_count = template_count - 1 + index = index + 1; + self.clang_type_name = type_name + + def expand_gcc_type_name(self): + type_name = self.Mt.GetType().GetName() + index = type_name.find("std::pair<") + type_name = type_name[index+5:] + index = 6 + template_count = 1 + while index < len(type_name): + if type_name[index] == '<': + template_count = template_count + 1 + elif type_name[index] == '>' and template_count == 1: + type_name = type_name[:index+1] + break + elif type_name[index] == '>': + template_count = template_count - 1 + elif type_name[index] == ' ' and template_count == 1 and type_name[index-1] == ',': + type_name = type_name[0:index] + type_name[index+1:] + index = index - 1 + index = index + 1; + self.gcc_type_name = type_name + + def num_children(self): + root_ptr_val = self.node_ptr_value(self.Mroot) + if root_ptr_val == 0: + return 0; + return self.Mimpl.GetChildMemberWithName('_M_node_count').GetValueAsUnsigned(0) + + def get_child_index(self,name): + return int(name.lstrip('[').rstrip(']')) + + def get_child_at_index(self,index): + if index >= self.num_children(): + return None; + offset = index + current = self.left(self.Mheader); + while offset > 0: + current = self.increment_node(current) + offset = offset - 1; + # skip all the base stuff and get at the data + return current.CreateChildAtOffset('['+str(index)+']',self.skip_size,self.data_type) + + # utility functions + def node_ptr_value(self,node): + return node.GetValueAsUnsigned(0) + + def right(self,node): + return node.GetChildMemberWithName("_M_right"); + + def left(self,node): + return node.GetChildMemberWithName("_M_left"); + + def parent(self,node): + return node.GetChildMemberWithName("_M_parent"); + + # from libstdc++ implementation of iterator for rbtree + def increment_node(self,node): + if self.node_ptr_value(self.right(node)) != 0: + x = self.right(node); + while self.node_ptr_value(self.left(x)) != 0: + x = self.left(x); + return x; + else: + x = node; + y = self.parent(x) + while(self.node_ptr_value(x) == self.node_ptr_value(self.right(y))): + x = y; + y = self.parent(y); + if self.node_ptr_value(self.right(x)) != self.node_ptr_value(y): + x = y; + return x; + Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Wed Aug 17 17:13:59 2011 @@ -271,12 +271,6 @@ SettingsTerminate (); static void - FormatManagerInitialize(); - - static void - FormatManagerTerminate(); - - static void Destroy (lldb::DebuggerSP &debugger_sp); ~Debugger (); @@ -422,7 +416,7 @@ const Address *addr, Stream &s, const char **end, - ValueObject* vobj = NULL); + ValueObject* valobj = NULL); void @@ -478,117 +472,6 @@ DISALLOW_COPY_AND_ASSIGN (Debugger); -public: - - class Formatting - { - public: - - // use this call to force the FM to consider itself updated even when there is no apparent reason for that - static void - ForceUpdate(); - - class ValueFormats - { - public: - static bool - Get(ValueObject& vobj, lldb::DynamicValueType use_dynamic, ValueFormat::SharedPointer &entry); - - static void - Add(const ConstString &type, const ValueFormat::SharedPointer &entry); - - static bool - Delete(const ConstString &type); - - static void - Clear(); - - static void - LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton); - - static uint32_t - GetCurrentRevision(); - - static uint32_t - GetCount(); - }; - - static bool - GetSummaryFormat(ValueObject& vobj, - lldb::DynamicValueType use_dynamic, - lldb::SummaryFormatSP& entry); - static bool - GetSyntheticChildren(ValueObject& vobj, - lldb::DynamicValueType use_dynamic, - lldb::SyntheticChildrenSP& entry); - - static bool - AnyMatches(ConstString type_name, - FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, - bool only_enabled = true, - const char** matching_category = NULL, - FormatCategory::FormatCategoryItems* matching_type = NULL); - - class NamedSummaryFormats - { - public: - static bool - Get(const ConstString &type, SummaryFormat::SharedPointer &entry); - - static void - Add(const ConstString &type, const SummaryFormat::SharedPointer &entry); - - static bool - Delete(const ConstString &type); - - static void - Clear(); - - static void - LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton); - - static uint32_t - GetCurrentRevision(); - - static uint32_t - GetCount(); - }; - - class Categories - { - public: - - static bool - Get(const ConstString &category, lldb::FormatCategorySP &entry); - - static void - Add(const ConstString &category); - - static bool - Delete(const ConstString &category); - - static void - Clear(); - - static void - Clear(ConstString &category); - - static void - Enable(ConstString& category); - - static void - Disable(ConstString& category); - - static void - LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton); - - static uint32_t - GetCurrentRevision(); - - static uint32_t - GetCount(); - }; - }; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Core/FormatClasses.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatClasses.h (original) +++ lldb/trunk/include/lldb/Core/FormatClasses.h Wed Aug 17 17:13:59 2011 @@ -57,7 +57,7 @@ } typedef lldb::SharedPtr::Type SharedPointer; - typedef bool(*ValueCallback)(void*, const char*, const ValueFormat::SharedPointer&); + typedef bool(*ValueCallback)(void*, ConstString, const ValueFormat::SharedPointer&); ~ValueFormat() { @@ -169,7 +169,7 @@ GetFrontEnd(lldb::ValueObjectSP backend) = 0; typedef lldb::SharedPtr::Type SharedPointer; - typedef bool(*SyntheticChildrenCallback)(void*, const char*, const SyntheticChildren::SharedPointer&); + typedef bool(*SyntheticChildrenCallback)(void*, ConstString, const SyntheticChildren::SharedPointer&); }; @@ -453,7 +453,7 @@ GetDescription() = 0; typedef lldb::SharedPtr::Type SharedPointer; - typedef bool(*SummaryCallback)(void*, const char*, const SummaryFormat::SharedPointer&); + typedef bool(*SummaryCallback)(void*, ConstString, const SummaryFormat::SharedPointer&); typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const SummaryFormat::SharedPointer&); }; Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Wed Aug 17 17:13:59 2011 @@ -227,23 +227,23 @@ m_format_map.Add(type,entry); } - // using const char* instead of MapKeyType is necessary here + // using ConstString instead of MapKeyType is necessary here // to make the partial template specializations below work bool - Delete(const char *type) + Delete(ConstString type) { return m_format_map.Delete(type); } bool - Get(ValueObject& vobj, + Get(ValueObject& valobj, MapValueType& entry, lldb::DynamicValueType use_dynamic, uint32_t* why = NULL) { uint32_t value = lldb::eFormatterChoiceCriterionDirectChoice; - clang::QualType type = clang::QualType::getFromOpaquePtr(vobj.GetClangType()); - bool ret = Get(vobj, type, entry, use_dynamic, value); + clang::QualType type = clang::QualType::getFromOpaquePtr(valobj.GetClangType()); + bool ret = Get(valobj, type, entry, use_dynamic, value); if (ret) entry = MapValueType(entry); else @@ -277,15 +277,15 @@ ConstString m_id_cs; - // using const char* instead of MapKeyType is necessary here + // using ConstString instead of MapKeyType is necessary here // to make the partial template specializations below work bool - Get(const char* type, MapValueType& entry) + Get(ConstString type, MapValueType& entry) { return m_format_map.Get(type, entry); } - bool Get_ObjC(ValueObject& vobj, + bool Get_ObjC(ValueObject& valobj, ObjCLanguageRuntime::ObjCISA isa, MapValueType& entry, uint32_t& reason) @@ -293,7 +293,7 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); if (log) log->Printf("going to an Objective-C dynamic scanning"); - Process* process = vobj.GetUpdatePoint().GetProcessSP().get(); + Process* process = valobj.GetUpdatePoint().GetProcessSP().get(); ObjCLanguageRuntime* runtime = process->GetObjCLanguageRuntime(); if (runtime == NULL) { @@ -310,7 +310,7 @@ ConstString name = runtime->GetActualTypeName(isa); if (log) log->Printf("looking for formatter for %s", name.GetCString()); - if (Get(name.GetCString(), entry)) + if (Get(name, entry)) { if (log) log->Printf("direct match found, returning"); @@ -331,7 +331,7 @@ log->Printf("parent-child loop, bailing out"); return false; } - if (Get_ObjC(vobj, parent, entry, reason)) + if (Get_ObjC(valobj, parent, entry, reason)) { reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; return true; @@ -339,7 +339,7 @@ return false; } - bool Get(ValueObject& vobj, + bool Get(ValueObject& valobj, clang::QualType type, MapValueType& entry, lldb::DynamicValueType use_dynamic, @@ -361,17 +361,16 @@ log->Printf("type is NULL, returning"); return false; } - ConstString name(ClangASTType::GetTypeNameForQualType(type).c_str()); - const char* typeName = name.GetCString(); - if (vobj.GetBitfieldBitSize() > 0) + ConstString typeName(ClangASTType::GetTypeNameForQualType(type).c_str()); + if (valobj.GetBitfieldBitSize() > 0) { // for bitfields, append size to the typename so one can custom format them StreamString sstring; - sstring.Printf("%s:%d",typeName,vobj.GetBitfieldBitSize()); + sstring.Printf("%s:%d",typeName.AsCString(),valobj.GetBitfieldBitSize()); ConstString bitfieldname = ConstString(sstring.GetData()); if (log) log->Printf("appended bitfield info, final result is %s", bitfieldname.GetCString()); - if (Get(bitfieldname.AsCString(), entry)) + if (Get(bitfieldname, entry)) { if (log) log->Printf("bitfield direct match found, returning"); @@ -387,8 +386,8 @@ if (log) log->Printf("trying to get %s for VO name %s of type %s", m_name.c_str(), - vobj.GetName().AsCString(), - typeName); + valobj.GetName().AsCString(), + typeName.AsCString()); if (Get(typeName, entry)) { if (log) @@ -402,7 +401,7 @@ { if (log) log->Printf("stripping reference"); - if (Get(vobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->m_skip_references) + if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->m_skip_references) { reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; return true; @@ -410,11 +409,11 @@ } if (use_dynamic != lldb::eNoDynamicValues && (/*strstr(typeName, "id") == typeName ||*/ - ClangASTType::GetMinimumLanguage(vobj.GetClangAST(), vobj.GetClangType()) == lldb::eLanguageTypeObjC)) + ClangASTType::GetMinimumLanguage(valobj.GetClangAST(), valobj.GetClangType()) == lldb::eLanguageTypeObjC)) { if (log) log->Printf("this is an ObjC 'id', let's do dynamic search"); - Process* process = vobj.GetUpdatePoint().GetProcessSP().get(); + Process* process = valobj.GetUpdatePoint().GetProcessSP().get(); ObjCLanguageRuntime* runtime = process->GetObjCLanguageRuntime(); if (runtime == NULL) { @@ -423,7 +422,7 @@ } else { - if (Get_ObjC(vobj, runtime->GetISA(vobj), entry, reason)) + if (Get_ObjC(valobj, runtime->GetISA(valobj), entry, reason)) { reason |= lldb::eFormatterChoiceCriterionDynamicObjCHierarchy; return true; @@ -433,7 +432,7 @@ else if (use_dynamic != lldb::eNoDynamicValues && log) { log->Printf("typename: %s, typePtr = %p, id = %p", - name.AsCString(), typePtr, vobj.GetClangAST()->ObjCBuiltinIdTy.getTypePtr()); + typeName.AsCString(), typePtr, valobj.GetClangAST()->ObjCBuiltinIdTy.getTypePtr()); } else if (log) { @@ -444,7 +443,7 @@ if (log) log->Printf("stripping pointer"); clang::QualType pointee = typePtr->getPointeeType(); - if (Get(vobj, pointee, entry, use_dynamic, reason) && !entry->m_skip_pointers) + if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->m_skip_pointers) { reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; return true; @@ -453,11 +452,11 @@ if (typePtr->isObjCObjectPointerType()) { if (use_dynamic != lldb::eNoDynamicValues && - name.GetCString() == m_id_cs.GetCString()) + typeName == m_id_cs) { if (log) log->Printf("this is an ObjC 'id', let's do dynamic search"); - Process* process = vobj.GetUpdatePoint().GetProcessSP().get(); + Process* process = valobj.GetUpdatePoint().GetProcessSP().get(); ObjCLanguageRuntime* runtime = process->GetObjCLanguageRuntime(); if (runtime == NULL) { @@ -466,7 +465,7 @@ } else { - if (Get_ObjC(vobj, runtime->GetISA(vobj), entry, reason)) + if (Get_ObjC(valobj, runtime->GetISA(valobj), entry, reason)) { reason |= lldb::eFormatterChoiceCriterionDynamicObjCHierarchy; return true; @@ -482,7 +481,7 @@ // the VO refers to a pointer-to- at interface Error error; - ValueObject* target = vobj.Dereference(error).get(); + ValueObject* target = valobj.Dereference(error).get(); if (error.Fail() || !target) return false; if (Get(*target, typePtr->getPointeeType(), entry, use_dynamic, reason) && !entry->m_skip_pointers) @@ -496,8 +495,8 @@ { if (log) log->Printf("working with ObjC"); - clang::ASTContext *ast = vobj.GetClangAST(); - if (ClangASTContext::GetCompleteType(ast, vobj.GetClangType()) && !objc_class_type->isObjCId()) + clang::ASTContext *ast = valobj.GetClangAST(); + if (ClangASTContext::GetCompleteType(ast, valobj.GetClangType()) && !objc_class_type->isObjCId()) { clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); if (class_interface_decl) @@ -510,7 +509,7 @@ if (log) log->Printf("got a parent class for this ObjC class"); clang::QualType ivar_qual_type(ast->getObjCInterfaceType(superclass_interface_decl)); - if (Get(vobj, ivar_qual_type, entry, use_dynamic, reason) && entry->m_cascades) + if (Get(valobj, ivar_qual_type, entry, use_dynamic, reason) && entry->m_cascades) { reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; return true; @@ -528,7 +527,7 @@ if (record) { if (!record->hasDefinition()) - ClangASTContext::GetCompleteType(vobj.GetClangAST(), vobj.GetClangType()); + ClangASTContext::GetCompleteType(valobj.GetClangAST(), valobj.GetClangType()); if (record->hasDefinition()) { clang::CXXRecordDecl::base_class_iterator pos,end; @@ -539,7 +538,7 @@ end = record->bases_end(); for (pos = record->bases_begin(); pos != end; pos++) { - if ((Get(vobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades) + if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades) { reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; return true; @@ -553,7 +552,7 @@ end = record->vbases_end(); for (pos = record->vbases_begin(); pos != end; pos++) { - if ((Get(vobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades) + if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades) { reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; return true; @@ -569,7 +568,7 @@ { if (log) log->Printf("stripping typedef"); - if ((Get(vobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->m_cascades) + if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->m_cascades) { reason |= lldb::eFormatterChoiceCriterionNavigatedTypedefs; return true; @@ -581,27 +580,27 @@ template<> bool -FormatNavigator::Get(const char* key, SummaryFormat::SharedPointer& value); +FormatNavigator::Get(ConstString key, SummaryFormat::SharedPointer& value); template<> bool -FormatNavigator::Delete(const char* type); +FormatNavigator::Delete(ConstString type); template<> bool -FormatNavigator::Get(const char* key, SyntheticFilter::SharedPointer& value); +FormatNavigator::Get(ConstString key, SyntheticFilter::SharedPointer& value); template<> bool -FormatNavigator::Delete(const char* type); +FormatNavigator::Delete(ConstString type); template<> bool -FormatNavigator::Get(const char* key, SyntheticFilter::SharedPointer& value); +FormatNavigator::Get(ConstString key, SyntheticFilter::SharedPointer& value); template<> bool -FormatNavigator::Delete(const char* type); +FormatNavigator::Delete(ConstString type); class CategoryMap; @@ -609,13 +608,13 @@ { private: - typedef FormatNavigator SummaryNavigator; + typedef FormatNavigator SummaryNavigator; typedef FormatNavigator RegexSummaryNavigator; - typedef FormatNavigator FilterNavigator; + typedef FormatNavigator FilterNavigator; typedef FormatNavigator RegexFilterNavigator; - typedef FormatNavigator SynthNavigator; + typedef FormatNavigator SynthNavigator; typedef FormatNavigator RegexSynthNavigator; typedef SummaryNavigator::MapType SummaryMap; @@ -657,13 +656,13 @@ friend class CategoryMap; - friend class FormatNavigator; + friend class FormatNavigator; friend class FormatNavigator; - friend class FormatNavigator; + friend class FormatNavigator; friend class FormatNavigator; - friend class FormatNavigator; + friend class FormatNavigator; friend class FormatNavigator; public: @@ -745,23 +744,23 @@ } bool - Get(ValueObject& vobj, + Get(ValueObject& valobj, lldb::SummaryFormatSP& entry, lldb::DynamicValueType use_dynamic, uint32_t* reason = NULL) { if (!IsEnabled()) return false; - if (Summary()->Get(vobj, entry, use_dynamic, reason)) + if (Summary()->Get(valobj, entry, use_dynamic, reason)) return true; - bool regex = RegexSummary()->Get(vobj, entry, use_dynamic, reason); + bool regex = RegexSummary()->Get(valobj, entry, use_dynamic, reason); if (regex && reason) *reason |= lldb::eFormatterChoiceCriterionRegularExpressionSummary; return regex; } bool - Get(ValueObject& vobj, + Get(ValueObject& valobj, lldb::SyntheticChildrenSP& entry, lldb::DynamicValueType use_dynamic, uint32_t* reason = NULL) @@ -778,11 +777,11 @@ // first find both Filter and Synth, and then check which is most recent - if (!Filter()->Get(vobj, filter, use_dynamic, &reason_filter)) - regex_filter = RegexFilter()->Get(vobj, filter, use_dynamic, &reason_filter); + if (!Filter()->Get(valobj, filter, use_dynamic, &reason_filter)) + regex_filter = RegexFilter()->Get(valobj, filter, use_dynamic, &reason_filter); - if (!Synth()->Get(vobj, synth, use_dynamic, &reason_synth)) - regex_synth = RegexSynth()->Get(vobj, synth, use_dynamic, &reason_synth); + if (!Synth()->Get(valobj, synth, use_dynamic, &reason_synth)) + regex_synth = RegexSynth()->Get(valobj, synth, use_dynamic, &reason_synth); if (!filter.get() && !synth.get()) return false; @@ -826,7 +825,7 @@ // just a shortcut for (Summary()->Delete(name) || RegexSummary()->Delete(name)) bool - DeleteSummaries(const char* name) + DeleteSummaries(ConstString name) { return Delete(name, (eSummary | eRegexSummary)); } @@ -850,7 +849,7 @@ } bool - Delete(const char* name, + Delete(ConstString name, FormatCategoryItems items = ALL_ITEM_TYPES) { bool success = false; @@ -910,7 +909,7 @@ if ( (items & eSummary) == eSummary ) { - if (m_summary_nav->Get(type_name.AsCString(), summary)) + if (m_summary_nav->Get(type_name, summary)) { if (matching_category) *matching_category = m_name.c_str(); @@ -921,7 +920,7 @@ } if ( (items & eRegexSummary) == eRegexSummary ) { - if (m_regex_summary_nav->Get(type_name.AsCString(), summary)) + if (m_regex_summary_nav->Get(type_name, summary)) { if (matching_category) *matching_category = m_name.c_str(); @@ -932,7 +931,7 @@ } if ( (items & eFilter) == eFilter ) { - if (m_filter_nav->Get(type_name.AsCString(), filter)) + if (m_filter_nav->Get(type_name, filter)) { if (matching_category) *matching_category = m_name.c_str(); @@ -943,7 +942,7 @@ } if ( (items & eRegexFilter) == eRegexFilter ) { - if (m_regex_filter_nav->Get(type_name.AsCString(), filter)) + if (m_regex_filter_nav->Get(type_name, filter)) { if (matching_category) *matching_category = m_name.c_str(); @@ -954,7 +953,7 @@ } if ( (items & eSynth) == eSynth ) { - if (m_synth_nav->Get(type_name.AsCString(), synth)) + if (m_synth_nav->Get(type_name, synth)) { if (matching_category) *matching_category = m_name.c_str(); @@ -965,7 +964,7 @@ } if ( (items & eRegexSynth) == eRegexSynth ) { - if (m_regex_synth_nav->Get(type_name.AsCString(), synth)) + if (m_regex_synth_nav->Get(type_name, synth)) { if (matching_category) *matching_category = m_name.c_str(); @@ -1175,7 +1174,7 @@ } bool - Get(ValueObject& vobj, + Get(ValueObject& valobj, lldb::SummaryFormatSP& entry, lldb::DynamicValueType use_dynamic) { @@ -1188,7 +1187,7 @@ { FormatCategory::SharedPointer category = *begin; lldb::SummaryFormatSP current_format; - if (!category->Get(vobj, current_format, use_dynamic, &reason_why)) + if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) continue; /*if (reason_why == lldb::eFormatterChoiceCriterionDirectChoice) { @@ -1207,7 +1206,7 @@ } bool - Get(ValueObject& vobj, + Get(ValueObject& valobj, lldb::SyntheticChildrenSP& entry, lldb::DynamicValueType use_dynamic) { @@ -1221,7 +1220,7 @@ { FormatCategory::SharedPointer category = *begin; lldb::SyntheticChildrenSP current_format; - if (!category->Get(vobj, current_format, use_dynamic, &reason_why)) + if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) continue; /*if (reason_why == lldb::eFormatterChoiceCriterionDirectChoice) { @@ -1246,10 +1245,10 @@ { private: - typedef FormatNavigator ValueNavigator; + typedef FormatNavigator ValueNavigator; typedef ValueNavigator::MapType ValueMap; - typedef FormatMap NamedSummariesMap; + typedef FormatMap NamedSummariesMap; ValueNavigator m_value_nav; NamedSummariesMap m_named_summaries_map; @@ -1258,68 +1257,19 @@ const char* m_default_category_name; const char* m_system_category_name; + const char* m_gnu_cpp_category_name; typedef CategoryMap::MapType::iterator CategoryMapIterator; ConstString m_default_cs; ConstString m_system_cs; - ConstString m_charstar_cs; - ConstString m_constcharstar_cs; + ConstString m_gnu_stdcpp_cs; public: typedef bool (*CategoryCallback)(void*, const char*, const FormatCategory::SharedPointer&); - FormatManager() : - m_value_nav("format",this), - m_named_summaries_map(this), - m_last_revision(0), - m_categories_map(this), - m_default_cs(ConstString("default")), - m_system_cs(ConstString("system")), - m_charstar_cs(ConstString("char *")), - m_constcharstar_cs(ConstString("const char *")) - { - - // build default categories - - m_default_category_name = m_default_cs.GetCString(); - m_system_category_name = m_system_cs.GetCString(); - - // add some default stuff - // most formats, summaries, ... actually belong to the users' lldbinit file rather than here - SummaryFormat::SharedPointer string_format(new StringSummaryFormat(false, - true, - false, - true, - false, - false, - "${var%s}")); - - - SummaryFormat::SharedPointer string_array_format(new StringSummaryFormat(false, - true, - false, - false, - false, - false, - "${var%s}")); - - lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]")); - - - Category(m_system_category_name)->Summary()->Add(m_charstar_cs.GetCString(), string_format); - Category(m_system_category_name)->Summary()->Add(m_constcharstar_cs.GetCString(), string_format); - Category(m_system_category_name)->RegexSummary()->Add(any_size_char_arr, string_array_format); - - Category(m_default_category_name); // this call is there to force LLDB into creating an empty "default" category - - // the order of these two calls IS important, if you invert it "system" summaries will prevail over the user's - EnableCategory(m_system_category_name); - EnableCategory(m_default_category_name); - - } - + FormatManager(); CategoryMap& Categories() { return m_categories_map; } ValueNavigator& Value() { return m_value_nav; } @@ -1368,18 +1318,18 @@ } bool - Get(ValueObject& vobj, + Get(ValueObject& valobj, lldb::SummaryFormatSP& entry, lldb::DynamicValueType use_dynamic) { - return m_categories_map.Get(vobj, entry, use_dynamic); + return m_categories_map.Get(valobj, entry, use_dynamic); } bool - Get(ValueObject& vobj, + Get(ValueObject& valobj, lldb::SyntheticChildrenSP& entry, lldb::DynamicValueType use_dynamic) { - return m_categories_map.Get(vobj, entry, use_dynamic); + return m_categories_map.Get(valobj, entry, use_dynamic); } bool @@ -1430,6 +1380,117 @@ }; +class DataVisualization +{ +public: + + // use this call to force the FM to consider itself updated even when there is no apparent reason for that + static void + ForceUpdate(); + + class ValueFormats + { + public: + static bool + Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, ValueFormat::SharedPointer &entry); + + static void + Add(const ConstString &type, const ValueFormat::SharedPointer &entry); + + static bool + Delete(const ConstString &type); + + static void + Clear(); + + static void + LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton); + + static uint32_t + GetCurrentRevision(); + + static uint32_t + GetCount(); + }; + + static bool + GetSummaryFormat(ValueObject& valobj, + lldb::DynamicValueType use_dynamic, + lldb::SummaryFormatSP& entry); + static bool + GetSyntheticChildren(ValueObject& valobj, + lldb::DynamicValueType use_dynamic, + lldb::SyntheticChildrenSP& entry); + + static bool + AnyMatches(ConstString type_name, + FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = NULL, + FormatCategory::FormatCategoryItems* matching_type = NULL); + + class NamedSummaryFormats + { + public: + static bool + Get(const ConstString &type, lldb::SummaryFormatSP &entry); + + static void + Add(const ConstString &type, const lldb::SummaryFormatSP &entry); + + static bool + Delete(const ConstString &type); + + static void + Clear(); + + static void + LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton); + + static uint32_t + GetCurrentRevision(); + + static uint32_t + GetCount(); + }; + + class Categories + { + public: + + static bool + Get(const ConstString &category, lldb::FormatCategorySP &entry); + + static void + Add(const ConstString &category); + + static bool + Delete(const ConstString &category); + + static void + Clear(); + + static void + Clear(ConstString &category); + + static void + Enable(ConstString& category); + + static void + Disable(ConstString& category); + + static void + LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton); + + static uint32_t + GetCurrentRevision(); + + static uint32_t + GetCount(); + }; +}; + + } // namespace lldb_private #endif // lldb_FormatManager_h_ Modified: lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh (original) +++ lldb/trunk/scripts/Python/finish-swig-Python-LLDB.sh Wed Aug 17 17:13:59 2011 @@ -165,18 +165,18 @@ fi fi -# Copy the OSX C++ STL formatters over to the framework Python directory -if [ -f "${SRC_ROOT}/source/osxcpp.py" ] +# Copy the C++ STL formatters over to the framework Python directory +if [ -f "${SRC_ROOT}/examples/synthetic/gnu_libstdcpp.py" ] then if [ $Debug == 1 ] then - echo "Copying osxcpp.py to ${framework_python_dir}" + echo "Copying gnu_libstdcpp.py to ${framework_python_dir}" fi - cp "${SRC_ROOT}/source/osxcpp.py" "${framework_python_dir}" + cp "${SRC_ROOT}/examples/synthetic/gnu_libstdcpp.py" "${framework_python_dir}" else if [ $Debug == 1 ] then - echo "Unable to find ${SRC_ROOT}/source/osxcpp.py" + echo "Unable to find ${SRC_ROOT}/examples/synthetic/gnu_libstdcpp.py" fi fi Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Wed Aug 17 17:13:59 2011 @@ -14,6 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Debugger.h" +#include "lldb/Core/FormatManager.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Timer.h" @@ -441,7 +442,7 @@ SummaryFormatSP summary_format_sp; if (!m_option_variable.summary.empty()) - Debugger::Formatting::NamedSummaryFormats::Get(ConstString(m_option_variable.summary.c_str()), summary_format_sp); + DataVisualization::NamedSummaryFormats::Get(ConstString(m_option_variable.summary.c_str()), summary_format_sp); ValueObject::DumpValueObjectOptions options; Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Wed Aug 17 17:13:59 2011 @@ -199,7 +199,7 @@ const char* typeA = command.GetArgumentAtIndex(i); ConstString typeCS(typeA); if (typeCS) - Debugger::Formatting::ValueFormats::Add(typeCS, entry); + DataVisualization::ValueFormats::Add(typeCS, entry); else { result.AppendError("empty typenames not allowed"); @@ -276,7 +276,7 @@ } - if (Debugger::Formatting::ValueFormats::Delete(typeCS)) + if (DataVisualization::ValueFormats::Delete(typeCS)) { result.SetStatus(eReturnStatusSuccessFinishNoResult); return result.Succeeded(); @@ -314,7 +314,7 @@ bool Execute (Args& command, CommandReturnObject &result) { - Debugger::Formatting::ValueFormats::Clear(); + DataVisualization::ValueFormats::Clear(); result.SetStatus(eReturnStatusSuccessFinishResult); return result.Succeeded(); } @@ -325,7 +325,7 @@ // CommandObjectTypeFormatList //------------------------------------------------------------------------- -bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, const char* type, const ValueFormat::SharedPointer& entry); +bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const ValueFormat::SharedPointer& entry); class CommandObjectTypeFormatList; @@ -375,7 +375,7 @@ } else param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result); - Debugger::Formatting::ValueFormats::LoopThrough(CommandObjectTypeFormatList_LoopCallback, param); + DataVisualization::ValueFormats::LoopThrough(CommandObjectTypeFormatList_LoopCallback, param); delete param; result.SetStatus(eReturnStatusSuccessFinishResult); return result.Succeeded(); @@ -384,14 +384,14 @@ private: bool - LoopCallback (const char* type, + LoopCallback (ConstString type, const ValueFormat::SharedPointer& entry, RegularExpression* regex, CommandReturnObject *result) { - if (regex == NULL || regex->Execute(type)) + if (regex == NULL || regex->Execute(type.AsCString())) { - result->GetOutputStream().Printf ("%s: %s%s%s%s\n", type, + result->GetOutputStream().Printf ("%s: %s%s%s%s\n", type.AsCString(), FormatManager::GetFormatAsCString (entry->m_format), entry->m_cascades ? "" : " (not cascading)", entry->m_skip_pointers ? " (skip pointers)" : "", @@ -400,14 +400,14 @@ return true; } - friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, const char* type, const ValueFormat::SharedPointer& entry); + friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const ValueFormat::SharedPointer& entry); }; bool CommandObjectTypeFormatList_LoopCallback ( void* pt2self, - const char* type, + ConstString type, const ValueFormat::SharedPointer& entry) { CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self; @@ -971,23 +971,23 @@ "};\n" "AnotherDemo *another_object = new AnotherDemo('E',42,3.14);\n" "\n" - "type summary add -f \"the answer is ${*var.ptr}\" JustADemo\n" + "type summary add --summary-string \"the answer is ${*var.ptr}\" JustADemo\n" "when typing frame variable object you will get \"the answer is 42\"\n" - "type summary add -f \"the answer is ${*var.ptr}, and the question is ${var.value}\" JustADemo\n" + "type summary add --summary-string \"the answer is ${*var.ptr}, and the question is ${var.value}\" JustADemo\n" "when typing frame variable object you will get \"the answer is 42 and the question is 3.14\"\n" "\n" "Alternatively, you could also say\n" - "type summary add -f \"${var%V} -> ${*var}\" \"int *\"\n" + "type summary add --summary-string \"${var%V} -> ${*var}\" \"int *\"\n" "and replace the above summary string with\n" - "type summary add -f \"the answer is ${var.ptr}, and the question is ${var.value}\" JustADemo\n" + "type summary add --summary-string \"the answer is ${var.ptr}, and the question is ${var.value}\" JustADemo\n" "to obtain a similar result\n" "\n" "To add a summary valid for both JustADemo and AnotherDemo you can use the scoping operator, as in:\n" - "type summary add -f \"${var.ptr}, ${var.value},{${var.byte}}\" JustADemo -C yes\n" + "type summary add --summary-string \"${var.ptr}, ${var.value},{${var.byte}}\" JustADemo -C yes\n" "\n" "This will be used for both variables of type JustADemo and AnotherDemo. To prevent this, change the -C to read -C no\n" "If you do not want pointers to be shown using that summary, you can use the -p option, as in:\n" - "type summary add -f \"${var.ptr}, ${var.value},{${var.byte}}\" JustADemo -C yes -p\n" + "type summary add --summary-string \"${var.ptr}, ${var.value},{${var.byte}}\" JustADemo -C yes -p\n" "A similar option -r exists for references.\n" "\n" "If you simply want a one-line summary of the content of your variable, without typing an explicit string to that effect\n" @@ -997,7 +997,7 @@ "the output being similar to (ptr=0xsomeaddress, value=3.14)\n" "\n" "If you want to display some summary text, but also expand the structure of your object, you can add the -e option, as in:\n" - "type summary add -e -f \"*ptr = ${*var.ptr}\" JustADemo\n" + "type summary add -e --summary-string \"*ptr = ${*var.ptr}\" JustADemo\n" "Here the value of the int* is displayed, followed by the standard LLDB sequence of children objects, one per line.\n" "to get an output like:\n" "\n" @@ -1006,9 +1006,6 @@ " value = 3.14\n" "}\n" "\n" - "A command you may definitely want to try if you're doing C++ debugging is:\n" - "type summary add -f \"${var._M_dataplus._M_p}\" std::string\n" - "\n" "You can also add Python summaries, in which case you will use lldb public API to gather information from your variables" "and elaborate them to a meaningful summary inside a script written in Python. The variable object will be passed to your" "script as an SBValue object. The following example might help you when starting to use the Python summaries feature:\n" @@ -1040,7 +1037,7 @@ Error* error) { lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(category_name.c_str()), category); + DataVisualization::Categories::Get(ConstString(category_name.c_str()), category); if (type == eRegexSummary) { @@ -1052,7 +1049,7 @@ return false; } - category->RegexSummary()->Delete(type_name.GetCString()); + category->RegexSummary()->Delete(type_name); category->RegexSummary()->Add(typeRX, entry); return true; @@ -1060,12 +1057,12 @@ else if (type == eNamedSummary) { // system named summaries do not exist (yet?) - Debugger::Formatting::NamedSummaryFormats::Add(type_name,entry); + DataVisualization::NamedSummaryFormats::Add(type_name,entry); return true; } else { - category->Summary()->Add(type_name.GetCString(), entry); + category->Summary()->Add(type_name, entry); return true; } } @@ -1080,7 +1077,7 @@ { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeNone, "Don't use this format for references-to-type objects."}, { LLDB_OPT_SET_ALL, false, "regex", 'x', no_argument, NULL, 0, eArgTypeNone, "Type names are actually regular expressions."}, { LLDB_OPT_SET_1 , true, "inline-children", 'c', no_argument, NULL, 0, eArgTypeNone, "If true, inline all child values into summary string."}, - { LLDB_OPT_SET_2 , true, "format-string", 'f', required_argument, NULL, 0, eArgTypeSummaryString, "Format string used to display text and object contents."}, + { LLDB_OPT_SET_2 , true, "summary-string", 'f', required_argument, NULL, 0, eArgTypeSummaryString, "Summary string used to display text and object contents."}, { LLDB_OPT_SET_3, false, "python-script", 's', required_argument, NULL, 0, eArgTypeName, "Give a one-liner Python script as part of the command."}, { LLDB_OPT_SET_3, false, "python-function", 'F', required_argument, NULL, 0, eArgTypeName, "Give the name of a Python function to use for this type."}, { LLDB_OPT_SET_3, false, "input-python", 'P', no_argument, NULL, 0, eArgTypeNone, "Input Python code to use for this type manually."}, @@ -1168,8 +1165,8 @@ const char* cate_name, const FormatCategory::SharedPointer& cate) { - const char* name = (const char*)param; - cate->Delete(name, FormatCategory::eSummary | FormatCategory::eRegexSummary); + ConstString *name = (ConstString*)param; + cate->Delete(*name, FormatCategory::eSummary | FormatCategory::eRegexSummary); return true; } @@ -1220,16 +1217,16 @@ if (m_options.m_delete_all) { - Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, (void*)typeCS.GetCString()); + DataVisualization::Categories::LoopThrough(PerCategoryCallback, (void*)typeCS.GetCString()); result.SetStatus(eReturnStatusSuccessFinishNoResult); return result.Succeeded(); } lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); + DataVisualization::Categories::Get(ConstString(m_options.m_category.c_str()), category); - bool delete_category = category->DeleteSummaries(typeCS.GetCString()); - bool delete_named = Debugger::Formatting::NamedSummaryFormats::Delete(typeCS); + bool delete_category = category->DeleteSummaries(typeCS); + bool delete_named = DataVisualization::NamedSummaryFormats::Delete(typeCS); if (delete_category || delete_named) { @@ -1348,7 +1345,7 @@ { if (m_options.m_delete_all) - Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, NULL); + DataVisualization::Categories::LoopThrough(PerCategoryCallback, NULL); else { @@ -1357,14 +1354,14 @@ { const char* cat_name = command.GetArgumentAtIndex(0); ConstString cat_nameCS(cat_name); - Debugger::Formatting::Categories::Get(cat_nameCS, category); + DataVisualization::Categories::Get(cat_nameCS, category); } else - Debugger::Formatting::Categories::Get(ConstString(NULL), category); + DataVisualization::Categories::Get(ConstString(NULL), category); category->ClearSummaries(); } - Debugger::Formatting::NamedSummaryFormats::Clear(); + DataVisualization::NamedSummaryFormats::Clear(); result.SetStatus(eReturnStatusSuccessFinishResult); return result.Succeeded(); @@ -1383,7 +1380,7 @@ // CommandObjectTypeSummaryList //------------------------------------------------------------------------- -bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, const char* type, const StringSummaryFormat::SharedPointer& entry); +bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const StringSummaryFormat::SharedPointer& entry); bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const StringSummaryFormat::SharedPointer& entry); class CommandObjectTypeSummaryList; @@ -1502,9 +1499,9 @@ else param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,NULL,cate_regex); - Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback,param); + DataVisualization::Categories::LoopThrough(PerCategoryCallback,param); - if (Debugger::Formatting::NamedSummaryFormats::GetCount() > 0) + if (DataVisualization::NamedSummaryFormats::GetCount() > 0) { result.GetOutputStream().Printf("Named summaries:\n"); if (argc == 1) { @@ -1514,7 +1511,7 @@ } else param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result); - Debugger::Formatting::NamedSummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param); + DataVisualization::NamedSummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param); delete param; } @@ -1558,6 +1555,7 @@ } return true; } + bool LoopCallback (const char* type, @@ -1570,18 +1568,18 @@ return true; } - friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, const char* type, const SummaryFormat::SharedPointer& entry); + friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const SummaryFormat::SharedPointer& entry); friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SummaryFormat::SharedPointer& entry); }; bool CommandObjectTypeSummaryList_LoopCallback ( void* pt2self, - const char* type, + ConstString type, const SummaryFormat::SharedPointer& entry) { CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(type, entry, param->regex, param->result); + return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result); } bool @@ -1653,7 +1651,7 @@ result.SetStatus(eReturnStatusFailed); return false; } - Debugger::Formatting::Categories::Enable(typeCS); + DataVisualization::Categories::Enable(typeCS); } result.SetStatus(eReturnStatusSuccessFinishResult); @@ -1717,7 +1715,7 @@ result.SetStatus(eReturnStatusFailed); return false; } - if (!Debugger::Formatting::Categories::Delete(typeCS)) + if (!DataVisualization::Categories::Delete(typeCS)) success = false; // keep deleting even if we hit an error } if (success) @@ -1787,7 +1785,7 @@ result.SetStatus(eReturnStatusFailed); return false; } - Debugger::Formatting::Categories::Disable(typeCS); + DataVisualization::Categories::Disable(typeCS); } result.SetStatus(eReturnStatusSuccessFinishResult); @@ -1876,7 +1874,7 @@ CommandObjectTypeCategoryList_CallbackParam param(&result, regex); - Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, ¶m); + DataVisualization::Categories::LoopThrough(PerCategoryCallback, ¶m); if (regex) delete regex; @@ -1891,7 +1889,7 @@ // CommandObjectTypeFilterList //------------------------------------------------------------------------- -bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, const char* type, const SyntheticChildren::SharedPointer& entry); +bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry); bool CommandObjectTypeFilterRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); class CommandObjectTypeFilterList; @@ -2010,7 +2008,7 @@ else param = new CommandObjectTypeFilterList_LoopCallbackParam(this,&result,NULL,cate_regex); - Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback,param); + DataVisualization::Categories::LoopThrough(PerCategoryCallback,param); if (cate_regex) delete cate_regex; @@ -2065,17 +2063,17 @@ return true; } - friend bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, const char* type, const SyntheticChildren::SharedPointer& entry); + friend bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry); friend bool CommandObjectTypeFilterRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); }; bool CommandObjectTypeFilterList_LoopCallback (void* pt2self, - const char* type, + ConstString type, const SyntheticChildren::SharedPointer& entry) { CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(type, entry, param->regex, param->result); + return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result); } bool @@ -2099,7 +2097,7 @@ // CommandObjectTypeSynthList //------------------------------------------------------------------------- -bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, const char* type, const SyntheticChildren::SharedPointer& entry); +bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry); bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); class CommandObjectTypeSynthList; @@ -2218,7 +2216,7 @@ else param = new CommandObjectTypeSynthList_LoopCallbackParam(this,&result,NULL,cate_regex); - Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback,param); + DataVisualization::Categories::LoopThrough(PerCategoryCallback,param); if (cate_regex) delete cate_regex; @@ -2273,17 +2271,17 @@ return true; } - friend bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, const char* type, const SyntheticChildren::SharedPointer& entry); + friend bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, ConstString type, const SyntheticChildren::SharedPointer& entry); friend bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); }; bool CommandObjectTypeSynthList_LoopCallback (void* pt2self, - const char* type, + ConstString type, const SyntheticChildren::SharedPointer& entry) { CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)pt2self; - return param->self->LoopCallback(type, entry, param->regex, param->result); + return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result); } bool @@ -2381,8 +2379,8 @@ const char* cate_name, const FormatCategory::SharedPointer& cate) { - const char* name = (const char*)param; - return cate->Delete(name, FormatCategory::eFilter | FormatCategory::eRegexFilter); + ConstString *name = (ConstString*)param; + return cate->Delete(*name, FormatCategory::eFilter | FormatCategory::eRegexFilter); } public: @@ -2432,16 +2430,16 @@ if (m_options.m_delete_all) { - Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, (void*)typeCS.GetCString()); + DataVisualization::Categories::LoopThrough(PerCategoryCallback, (void*)&typeCS); result.SetStatus(eReturnStatusSuccessFinishNoResult); return result.Succeeded(); } lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); + DataVisualization::Categories::Get(ConstString(m_options.m_category.c_str()), category); - bool delete_category = category->Filter()->Delete(typeCS.GetCString()); - delete_category = category->RegexFilter()->Delete(typeCS.GetCString()) || delete_category; + bool delete_category = category->Filter()->Delete(typeCS); + delete_category = category->RegexFilter()->Delete(typeCS) || delete_category; if (delete_category) { @@ -2544,8 +2542,8 @@ const char* cate_name, const FormatCategory::SharedPointer& cate) { - const char* name = (const char*)param; - return cate->Delete(name, FormatCategory::eSynth | FormatCategory::eRegexSynth); + ConstString* name = (ConstString*)param; + return cate->Delete(*name, FormatCategory::eSynth | FormatCategory::eRegexSynth); } public: @@ -2595,16 +2593,16 @@ if (m_options.m_delete_all) { - Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, (void*)typeCS.GetCString()); + DataVisualization::Categories::LoopThrough(PerCategoryCallback, (void*)&typeCS); result.SetStatus(eReturnStatusSuccessFinishNoResult); return result.Succeeded(); } lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); + DataVisualization::Categories::Get(ConstString(m_options.m_category.c_str()), category); - bool delete_category = category->Synth()->Delete(typeCS.GetCString()); - delete_category = category->RegexSynth()->Delete(typeCS.GetCString()) || delete_category; + bool delete_category = category->Synth()->Delete(typeCS); + delete_category = category->RegexSynth()->Delete(typeCS) || delete_category; if (delete_category) { @@ -2726,7 +2724,7 @@ { if (m_options.m_delete_all) - Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, NULL); + DataVisualization::Categories::LoopThrough(PerCategoryCallback, NULL); else { @@ -2735,10 +2733,10 @@ { const char* cat_name = command.GetArgumentAtIndex(0); ConstString cat_nameCS(cat_name); - Debugger::Formatting::Categories::Get(cat_nameCS, category); + DataVisualization::Categories::Get(cat_nameCS, category); } else - Debugger::Formatting::Categories::Get(ConstString(NULL), category); + DataVisualization::Categories::Get(ConstString(NULL), category); category->Filter()->Clear(); category->RegexFilter()->Clear(); } @@ -2853,7 +2851,7 @@ { if (m_options.m_delete_all) - Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, NULL); + DataVisualization::Categories::LoopThrough(PerCategoryCallback, NULL); else { @@ -2862,10 +2860,10 @@ { const char* cat_name = command.GetArgumentAtIndex(0); ConstString cat_nameCS(cat_name); - Debugger::Formatting::Categories::Get(cat_nameCS, category); + DataVisualization::Categories::Get(cat_nameCS, category); } else - Debugger::Formatting::Categories::Get(ConstString(NULL), category); + DataVisualization::Categories::Get(ConstString(NULL), category); category->Synth()->Clear(); category->RegexSynth()->Clear(); } @@ -3016,7 +3014,7 @@ lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(options->m_category.c_str()), category); + DataVisualization::Categories::Get(ConstString(options->m_category.c_str()), category); Error error; @@ -3133,7 +3131,7 @@ // now I have a valid provider, let's add it to every type lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); + DataVisualization::Categories::Get(ConstString(m_options.m_category.c_str()), category); Error error; @@ -3191,7 +3189,7 @@ Error* error) { lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(category_name.c_str()), category); + DataVisualization::Categories::Get(ConstString(category_name.c_str()), category); if (category->AnyMatches(type_name, FormatCategory::eFilter | FormatCategory::eRegexFilter, @@ -3212,14 +3210,14 @@ return false; } - category->RegexSynth()->Delete(type_name.GetCString()); + category->RegexSynth()->Delete(type_name); category->RegexSynth()->Add(typeRX, entry); return true; } else { - category->Synth()->Add(type_name.GetCString(), entry); + category->Synth()->Add(type_name, entry); return true; } } @@ -3368,7 +3366,7 @@ Error* error) { lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(category_name.c_str()), category); + DataVisualization::Categories::Get(ConstString(category_name.c_str()), category); if (category->AnyMatches(type_name, FormatCategory::eSynth | FormatCategory::eRegexSynth, @@ -3389,14 +3387,14 @@ return false; } - category->RegexFilter()->Delete(type_name.GetCString()); + category->RegexFilter()->Delete(type_name); category->RegexFilter()->Add(typeRX, entry); return true; } else { - category->Filter()->Add(type_name.GetCString(), entry); + category->Filter()->Add(type_name, entry); return true; } } @@ -3464,7 +3462,7 @@ // now I have a valid provider, let's add it to every type lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); + DataVisualization::Categories::Get(ConstString(m_options.m_category.c_str()), category); Error error; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Wed Aug 17 17:13:59 2011 @@ -82,7 +82,6 @@ if (g_shared_debugger_refcount == 0) { lldb_private::Initialize(); - Debugger::FormatManagerInitialize(); } g_shared_debugger_refcount++; @@ -96,7 +95,6 @@ g_shared_debugger_refcount--; if (g_shared_debugger_refcount == 0) { - Debugger::FormatManagerTerminate(); lldb_private::WillTerminate(); lldb_private::Terminate(); @@ -829,7 +827,7 @@ static ValueObjectSP -ExpandExpressionPath(ValueObject* vobj, +ExpandExpressionPath(ValueObject* valobj, StackFrame* frame, bool* do_deref_pointer, const char* var_name_begin, @@ -846,7 +844,7 @@ log->Printf("been told to deref_pointer by caller"); sstring.PutChar('*'); } - else if (vobj->IsDereferenceOfParent() && ClangASTContext::IsPointerType(vobj->GetParent()->GetClangType()) && !vobj->IsArrayItemForPointer()) + else if (valobj->IsDereferenceOfParent() && ClangASTContext::IsPointerType(valobj->GetParent()->GetClangType()) && !valobj->IsArrayItemForPointer()) { if (log) log->Printf("decided to deref_pointer myself"); @@ -854,7 +852,7 @@ *do_deref_pointer = true; } - vobj->GetExpressionPath(sstring, true, ValueObject::eHonorPointers); + valobj->GetExpressionPath(sstring, true, ValueObject::eHonorPointers); if (log) log->Printf("expression path to expand in phase 0: %s",sstring.GetData()); sstring.PutRawBytes(var_name_begin+3, var_name_final-var_name_begin-3); @@ -870,7 +868,7 @@ } static ValueObjectSP -ExpandIndexedExpression(ValueObject* vobj, +ExpandIndexedExpression(ValueObject* valobj, uint32_t index, StackFrame* frame, bool deref_pointer) @@ -886,7 +884,7 @@ ValueObject::ExpressionPathEndResultType final_value_type; ValueObject::ExpressionPathScanEndReason reason_to_stop; ValueObject::ExpressionPathAftermath what_next = (deref_pointer ? ValueObject::eDereference : ValueObject::eNothing); - ValueObjectSP item = vobj->GetValueForExpressionPath (ptr_deref_buffer.get(), + ValueObjectSP item = valobj->GetValueForExpressionPath (ptr_deref_buffer.get(), &first_unparsed, &reason_to_stop, &final_value_type, @@ -918,19 +916,19 @@ const Address *addr, Stream &s, const char **end, - ValueObject* vobj + ValueObject* valobj ) { - ValueObject* realvobj = NULL; // makes it super-easy to parse pointers + ValueObject* realvalobj = NULL; // makes it super-easy to parse pointers bool success = true; const char *p; LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); for (p = format; *p != '\0'; ++p) { - if (realvobj) + if (realvalobj) { - vobj = realvobj; - realvobj = NULL; + valobj = realvalobj; + realvalobj = NULL; } size_t non_special_chars = ::strcspn (p, "${}\\"); if (non_special_chars > 0) @@ -959,7 +957,7 @@ ++p; // Skip the '{' - if (FormatPrompt (p, sc, exe_ctx, addr, sub_strm, &p, vobj)) + if (FormatPrompt (p, sc, exe_ctx, addr, sub_strm, &p, valobj)) { // The stream had all it needed s.Write(sub_strm.GetData(), sub_strm.GetSize()); @@ -1011,7 +1009,7 @@ case 'v': case 's': { - if (!vobj) + if (!valobj) break; if (log) @@ -1029,7 +1027,7 @@ if (*var_name_begin == 's') { - vobj = vobj->GetSyntheticValue(lldb::eUseSyntheticFilter).get(); + valobj = valobj->GetSyntheticValue(lldb::eUseSyntheticFilter).get(); var_name_begin++; } @@ -1058,18 +1056,18 @@ bool is_array_range = false; const char* first_unparsed; - if (!vobj) break; - // simplest case ${var}, just print vobj's value + if (!valobj) break; + // simplest case ${var}, just print valobj's value if (::strncmp (var_name_begin, "var}", strlen("var}")) == 0) { - target = vobj; + target = valobj; val_obj_display = ValueObject::eDisplayValue; } else if (::strncmp(var_name_begin,"var%",strlen("var%")) == 0) { // this is a variable with some custom format applied to it const char* percent_position; - target = vobj; + target = valobj; val_obj_display = ValueObject::eDisplayValue; ScanFormatDescriptor (var_name_begin, var_name_end, @@ -1111,7 +1109,7 @@ if (log) log->Printf("symbol to expand: %s",expr_path.get()); - target = vobj->GetValueForExpressionPath(expr_path.get(), + target = valobj->GetValueForExpressionPath(expr_path.get(), &first_unparsed, &reason_to_stop, &final_value_type, @@ -1200,7 +1198,7 @@ var_success = true; if (index_higher < 0) - index_higher = vobj->GetNumChildren() - 1; + index_higher = valobj->GetNumChildren() - 1; uint32_t max_num_children = target->GetUpdatePoint().GetTargetSP()->GetMaximumNumberOfChildrenToDisplay(); @@ -1776,267 +1774,6 @@ return success; } - -static FormatManager& -GetFormatManager() { - static FormatManager g_format_manager; - return g_format_manager; -} - -// The platform should be responsible for initializing its own formatters -// (e.g. to handle versioning, different runtime libraries, ...) -// Currently, basic formatters for std:: objects as implemented by -// the GNU libstdc++ are defined regardless, and enabled by default -// This is going to be moved to some platform-dependent location -// (in the meanwhile, these formatters should work for Mac OS X & Linux) -void -Debugger::FormatManagerInitialize() -{ - static bool g_initialized = false; - - if (!g_initialized) - { - g_initialized = true; - ConstString gnulib("gnu-libstdc++"); - FormatManager& format_mgr = GetFormatManager(); - lldb::FormatCategorySP osxcpp = format_mgr.Category(gnulib.AsCString()); - osxcpp->Summary()->Add(ConstString("std::string").AsCString(), - SummaryFormatSP(new StringSummaryFormat(true, - false, - false, - true, - true, - false, - "${var._M_dataplus._M_p}"))); - osxcpp->Summary()->Add(ConstString("std::basic_string").AsCString(), - SummaryFormatSP(new StringSummaryFormat(true, - false, - false, - true, - true, - false, - "${var._M_dataplus._M_p}"))); - osxcpp->Summary()->Add(ConstString("std::basic_string,std::allocator >").AsCString(), - SummaryFormatSP(new StringSummaryFormat(true, - false, - false, - true, - true, - false, - "${var._M_dataplus._M_p}"))); - osxcpp->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::vector<")), - SyntheticChildrenSP(new SyntheticScriptProvider(true, - false, - false, - "StdVectorSynthProvider"))); - osxcpp->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::map<")), - SyntheticChildrenSP(new SyntheticScriptProvider(true, - false, - false, - "StdMapSynthProvider"))); - osxcpp->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::list<")), - SyntheticChildrenSP(new SyntheticScriptProvider(true, - false, - false, - "StdListSynthProvider"))); - - format_mgr.EnableCategory(gnulib.AsCString()); - - } -} - -void -Debugger::FormatManagerTerminate() -{} - -void -Debugger::Formatting::ForceUpdate() -{ - GetFormatManager().Changed(); -} - -bool -Debugger::Formatting::ValueFormats::Get(ValueObject& vobj, lldb::DynamicValueType use_dynamic, ValueFormat::SharedPointer &entry) -{ - return GetFormatManager().Value().Get(vobj,entry, use_dynamic); -} - -void -Debugger::Formatting::ValueFormats::Add(const ConstString &type, const ValueFormat::SharedPointer &entry) -{ - GetFormatManager().Value().Add(type.AsCString(),entry); -} - -bool -Debugger::Formatting::ValueFormats::Delete(const ConstString &type) -{ - return GetFormatManager().Value().Delete(type.AsCString()); -} - -void -Debugger::Formatting::ValueFormats::Clear() -{ - GetFormatManager().Value().Clear(); -} - -void -Debugger::Formatting::ValueFormats::LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton) -{ - GetFormatManager().Value().LoopThrough(callback, callback_baton); -} - -uint32_t -Debugger::Formatting::ValueFormats::GetCurrentRevision() -{ - return GetFormatManager().GetCurrentRevision(); -} - -uint32_t -Debugger::Formatting::ValueFormats::GetCount() -{ - return GetFormatManager().Value().GetCount(); -} - -bool -Debugger::Formatting::GetSummaryFormat(ValueObject& vobj, - lldb::DynamicValueType use_dynamic, - lldb::SummaryFormatSP& entry) -{ - return GetFormatManager().Get(vobj, entry, use_dynamic); -} -bool -Debugger::Formatting::GetSyntheticChildren(ValueObject& vobj, - lldb::DynamicValueType use_dynamic, - lldb::SyntheticChildrenSP& entry) -{ - return GetFormatManager().Get(vobj, entry, use_dynamic); -} - -bool -Debugger::Formatting::AnyMatches(ConstString type_name, - FormatCategory::FormatCategoryItems items, - bool only_enabled, - const char** matching_category, - FormatCategory::FormatCategoryItems* matching_type) -{ - return GetFormatManager().AnyMatches(type_name, - items, - only_enabled, - matching_category, - matching_type); -} - -bool -Debugger::Formatting::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry) -{ - entry = GetFormatManager().Category(category.GetCString()); - return true; -} - -void -Debugger::Formatting::Categories::Add(const ConstString &category) -{ - GetFormatManager().Category(category.GetCString()); -} - -bool -Debugger::Formatting::Categories::Delete(const ConstString &category) -{ - GetFormatManager().DisableCategory(category.GetCString()); - return GetFormatManager().Categories().Delete(category.GetCString()); -} - -void -Debugger::Formatting::Categories::Clear() -{ - GetFormatManager().Categories().Clear(); -} - -void -Debugger::Formatting::Categories::Clear(ConstString &category) -{ - GetFormatManager().Category(category.GetCString())->ClearSummaries(); -} - -void -Debugger::Formatting::Categories::Enable(ConstString& category) -{ - if (GetFormatManager().Category(category.GetCString())->IsEnabled() == false) - GetFormatManager().EnableCategory(category.GetCString()); - else - { - GetFormatManager().DisableCategory(category.GetCString()); - GetFormatManager().EnableCategory(category.GetCString()); - } -} - -void -Debugger::Formatting::Categories::Disable(ConstString& category) -{ - if (GetFormatManager().Category(category.GetCString())->IsEnabled() == true) - GetFormatManager().DisableCategory(category.GetCString()); -} - -void -Debugger::Formatting::Categories::LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton) -{ - GetFormatManager().LoopThroughCategories(callback, callback_baton); -} - -uint32_t -Debugger::Formatting::Categories::GetCurrentRevision() -{ - return GetFormatManager().GetCurrentRevision(); -} - -uint32_t -Debugger::Formatting::Categories::GetCount() -{ - return GetFormatManager().Categories().GetCount(); -} - -bool -Debugger::Formatting::NamedSummaryFormats::Get(const ConstString &type, SummaryFormat::SharedPointer &entry) -{ - return GetFormatManager().NamedSummary().Get(type.AsCString(),entry); -} - -void -Debugger::Formatting::NamedSummaryFormats::Add(const ConstString &type, const SummaryFormat::SharedPointer &entry) -{ - GetFormatManager().NamedSummary().Add(type.AsCString(),entry); -} - -bool -Debugger::Formatting::NamedSummaryFormats::Delete(const ConstString &type) -{ - return GetFormatManager().NamedSummary().Delete(type.AsCString()); -} - -void -Debugger::Formatting::NamedSummaryFormats::Clear() -{ - GetFormatManager().NamedSummary().Clear(); -} - -void -Debugger::Formatting::NamedSummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton) -{ - GetFormatManager().NamedSummary().LoopThrough(callback, callback_baton); -} - -uint32_t -Debugger::Formatting::NamedSummaryFormats::GetCurrentRevision() -{ - return GetFormatManager().GetCurrentRevision(); -} - -uint32_t -Debugger::Formatting::NamedSummaryFormats::GetCount() -{ - return GetFormatManager().NamedSummary().GetCount(); -} - #pragma mark Debugger::SettingsController //-------------------------------------------------- Modified: lldb/trunk/source/Core/FormatClasses.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatClasses.cpp (original) +++ lldb/trunk/source/Core/FormatClasses.cpp Wed Aug 17 17:13:59 2011 @@ -69,15 +69,15 @@ if (m_show_members_oneliner) { - ValueObjectSP synth_vobj = object->GetSyntheticValue(lldb::eUseSyntheticFilter); - const uint32_t num_children = synth_vobj->GetNumChildren(); + ValueObjectSP synth_valobj = object->GetSyntheticValue(lldb::eUseSyntheticFilter); + const uint32_t num_children = synth_valobj->GetNumChildren(); if (num_children) { s.PutChar('('); for (uint32_t idx=0; idxGetChildAtIndex(idx, true)); + lldb::ValueObjectSP child_sp(synth_valobj->GetChildAtIndex(idx, true)); if (child_sp.get()) { if (idx) Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Wed Aug 17 17:13:59 2011 @@ -156,14 +156,14 @@ template<> bool -FormatNavigator::Get(const char* key, SummaryFormat::SharedPointer& value) +FormatNavigator::Get(ConstString key, SummaryFormat::SharedPointer& value) { Mutex::Locker(m_format_map.mutex()); MapIterator pos, end = m_format_map.map().end(); for (pos = m_format_map.map().begin(); pos != end; pos++) { lldb::RegularExpressionSP regex = pos->first; - if (regex->Execute(key)) + if (regex->Execute(key.AsCString())) { value = pos->second; return true; @@ -174,14 +174,14 @@ template<> bool -FormatNavigator::Delete(const char* type) +FormatNavigator::Delete(ConstString type) { Mutex::Locker(m_format_map.mutex()); MapIterator pos, end = m_format_map.map().end(); for (pos = m_format_map.map().begin(); pos != end; pos++) { lldb::RegularExpressionSP regex = pos->first; - if ( ::strcmp(type,regex->GetText()) == 0) + if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) { m_format_map.map().erase(pos); if (m_format_map.listener) @@ -194,14 +194,14 @@ template<> bool -FormatNavigator::Get(const char* key, SyntheticFilter::SharedPointer& value) +FormatNavigator::Get(ConstString key, SyntheticFilter::SharedPointer& value) { Mutex::Locker(m_format_map.mutex()); MapIterator pos, end = m_format_map.map().end(); for (pos = m_format_map.map().begin(); pos != end; pos++) { lldb::RegularExpressionSP regex = pos->first; - if (regex->Execute(key)) + if (regex->Execute(key.AsCString())) { value = pos->second; return true; @@ -212,14 +212,14 @@ template<> bool -FormatNavigator::Delete(const char* type) +FormatNavigator::Delete(ConstString type) { Mutex::Locker(m_format_map.mutex()); MapIterator pos, end = m_format_map.map().end(); for (pos = m_format_map.map().begin(); pos != end; pos++) { lldb::RegularExpressionSP regex = pos->first; - if ( ::strcmp(type,regex->GetText()) == 0) + if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) { m_format_map.map().erase(pos); if (m_format_map.listener) @@ -232,14 +232,14 @@ template<> bool -FormatNavigator::Get(const char* key, SyntheticFilter::SharedPointer& value) +FormatNavigator::Get(ConstString key, SyntheticFilter::SharedPointer& value) { Mutex::Locker(m_format_map.mutex()); MapIterator pos, end = m_format_map.map().end(); for (pos = m_format_map.map().begin(); pos != end; pos++) { lldb::RegularExpressionSP regex = pos->first; - if (regex->Execute(key)) + if (regex->Execute(key.AsCString())) { value = pos->second; return true; @@ -250,14 +250,14 @@ template<> bool -FormatNavigator::Delete(const char* type) +FormatNavigator::Delete(ConstString type) { Mutex::Locker(m_format_map.mutex()); MapIterator pos, end = m_format_map.map().end(); for (pos = m_format_map.map().begin(); pos != end; pos++) { lldb::RegularExpressionSP regex = pos->first; - if ( ::strcmp(type,regex->GetText()) == 0) + if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) { m_format_map.map().erase(pos); if (m_format_map.listener) @@ -297,3 +297,286 @@ return lldb::eFormatInvalid; } } + +FormatManager::FormatManager() : + m_value_nav("format",this), + m_named_summaries_map(this), + m_last_revision(0), + m_categories_map(this), + m_default_cs(ConstString("default")), + m_system_cs(ConstString("system")), + m_gnu_stdcpp_cs(ConstString("gnu-libstdc++")) +{ + + // build default categories + + m_default_category_name = m_default_cs.GetCString(); + m_system_category_name = m_system_cs.GetCString(); + m_gnu_cpp_category_name = m_gnu_stdcpp_cs.AsCString(); + + // add some default stuff + // most formats, summaries, ... actually belong to the users' lldbinit file rather than here + SummaryFormat::SharedPointer string_format(new StringSummaryFormat(false, + true, + false, + true, + false, + false, + "${var%s}")); + + + SummaryFormat::SharedPointer string_array_format(new StringSummaryFormat(false, + true, + false, + false, + false, + false, + "${var%s}")); + + lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]")); + + + Category(m_system_category_name)->Summary()->Add(ConstString("char *"), string_format); + Category(m_system_category_name)->Summary()->Add(ConstString("const char *"), string_format); + Category(m_system_category_name)->RegexSummary()->Add(any_size_char_arr, string_array_format); + + Category(m_default_category_name); // this call is there to force LLDB into creating an empty "default" category + + // WARNING: temporary code!! + // The platform should be responsible for initializing its own formatters + // (e.g. to handle versioning, different runtime libraries, ...) + // Currently, basic formatters for std:: objects as implemented by + // the GNU libstdc++ are defined regardless, and enabled by default + // This is going to be moved to some platform-dependent location + // (in the meanwhile, these formatters should work for Mac OS X & Linux) + lldb::SummaryFormatSP std_string_summary_sp(new StringSummaryFormat(true, + false, + false, + true, + true, + false, + "${var._M_dataplus._M_p}")); + Category(m_gnu_cpp_category_name)->Summary()->Add(ConstString("std::string"), + std_string_summary_sp); + Category(m_gnu_cpp_category_name)->Summary()->Add(ConstString("std::basic_string"), + std_string_summary_sp); + Category(m_gnu_cpp_category_name)->Summary()->Add(ConstString("std::basic_string,std::allocator >"), + std_string_summary_sp); + + Category(m_gnu_cpp_category_name)->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::vector<")), + SyntheticChildrenSP(new SyntheticScriptProvider(true, + false, + false, + "StdVectorSynthProvider"))); + Category(m_gnu_cpp_category_name)->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::map<")), + SyntheticChildrenSP(new SyntheticScriptProvider(true, + false, + false, + "StdMapSynthProvider"))); + Category(m_gnu_cpp_category_name)->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::list<")), + SyntheticChildrenSP(new SyntheticScriptProvider(true, + false, + false, + "StdListSynthProvider"))); + + // DO NOT change the order of these calls, unless you WANT a change in the priority of these categories + EnableCategory(m_system_category_name); + EnableCategory(m_gnu_cpp_category_name); + EnableCategory(m_default_category_name); + +} + + +static FormatManager& +GetFormatManager() { + static FormatManager g_format_manager; + return g_format_manager; +} + +void +DataVisualization::ForceUpdate() +{ + GetFormatManager().Changed(); +} + +bool +DataVisualization::ValueFormats::Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, ValueFormat::SharedPointer &entry) +{ + return GetFormatManager().Value().Get(valobj,entry, use_dynamic); +} + +void +DataVisualization::ValueFormats::Add(const ConstString &type, const ValueFormat::SharedPointer &entry) +{ + GetFormatManager().Value().Add(type,entry); +} + +bool +DataVisualization::ValueFormats::Delete(const ConstString &type) +{ + return GetFormatManager().Value().Delete(type); +} + +void +DataVisualization::ValueFormats::Clear() +{ + GetFormatManager().Value().Clear(); +} + +void +DataVisualization::ValueFormats::LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton) +{ + GetFormatManager().Value().LoopThrough(callback, callback_baton); +} + +uint32_t +DataVisualization::ValueFormats::GetCurrentRevision() +{ + return GetFormatManager().GetCurrentRevision(); +} + +uint32_t +DataVisualization::ValueFormats::GetCount() +{ + return GetFormatManager().Value().GetCount(); +} + +bool +DataVisualization::GetSummaryFormat(ValueObject& valobj, + lldb::DynamicValueType use_dynamic, + lldb::SummaryFormatSP& entry) +{ + return GetFormatManager().Get(valobj, entry, use_dynamic); +} +bool +DataVisualization::GetSyntheticChildren(ValueObject& valobj, + lldb::DynamicValueType use_dynamic, + lldb::SyntheticChildrenSP& entry) +{ + return GetFormatManager().Get(valobj, entry, use_dynamic); +} + +bool +DataVisualization::AnyMatches(ConstString type_name, + FormatCategory::FormatCategoryItems items, + bool only_enabled, + const char** matching_category, + FormatCategory::FormatCategoryItems* matching_type) +{ + return GetFormatManager().AnyMatches(type_name, + items, + only_enabled, + matching_category, + matching_type); +} + +bool +DataVisualization::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry) +{ + entry = GetFormatManager().Category(category.GetCString()); + return true; +} + +void +DataVisualization::Categories::Add(const ConstString &category) +{ + GetFormatManager().Category(category.GetCString()); +} + +bool +DataVisualization::Categories::Delete(const ConstString &category) +{ + GetFormatManager().DisableCategory(category.GetCString()); + return GetFormatManager().Categories().Delete(category.GetCString()); +} + +void +DataVisualization::Categories::Clear() +{ + GetFormatManager().Categories().Clear(); +} + +void +DataVisualization::Categories::Clear(ConstString &category) +{ + GetFormatManager().Category(category.GetCString())->ClearSummaries(); +} + +void +DataVisualization::Categories::Enable(ConstString& category) +{ + if (GetFormatManager().Category(category.GetCString())->IsEnabled() == false) + GetFormatManager().EnableCategory(category.GetCString()); + else + { + GetFormatManager().DisableCategory(category.GetCString()); + GetFormatManager().EnableCategory(category.GetCString()); + } +} + +void +DataVisualization::Categories::Disable(ConstString& category) +{ + if (GetFormatManager().Category(category.GetCString())->IsEnabled() == true) + GetFormatManager().DisableCategory(category.GetCString()); +} + +void +DataVisualization::Categories::LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton) +{ + GetFormatManager().LoopThroughCategories(callback, callback_baton); +} + +uint32_t +DataVisualization::Categories::GetCurrentRevision() +{ + return GetFormatManager().GetCurrentRevision(); +} + +uint32_t +DataVisualization::Categories::GetCount() +{ + return GetFormatManager().Categories().GetCount(); +} + +bool +DataVisualization::NamedSummaryFormats::Get(const ConstString &type, SummaryFormat::SharedPointer &entry) +{ + return GetFormatManager().NamedSummary().Get(type,entry); +} + +void +DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const SummaryFormat::SharedPointer &entry) +{ + GetFormatManager().NamedSummary().Add(type,entry); +} + +bool +DataVisualization::NamedSummaryFormats::Delete(const ConstString &type) +{ + return GetFormatManager().NamedSummary().Delete(type); +} + +void +DataVisualization::NamedSummaryFormats::Clear() +{ + GetFormatManager().NamedSummary().Clear(); +} + +void +DataVisualization::NamedSummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton) +{ + GetFormatManager().NamedSummary().LoopThrough(callback, callback_baton); +} + +uint32_t +DataVisualization::NamedSummaryFormats::GetCurrentRevision() +{ + return GetFormatManager().GetCurrentRevision(); +} + +uint32_t +DataVisualization::NamedSummaryFormats::GetCount() +{ + return GetFormatManager().NamedSummary().GetCount(); +} \ No newline at end of file Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Wed Aug 17 17:13:59 2011 @@ -20,6 +20,7 @@ // Project includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Debugger.h" +#include "lldb/Core/FormatManager.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectChild.h" @@ -223,13 +224,13 @@ log->Printf("checking for FormatManager revisions. VO named %s is at revision %d, while the format manager is at revision %d", GetName().GetCString(), m_last_format_mgr_revision, - Debugger::Formatting::ValueFormats::GetCurrentRevision()); + DataVisualization::ValueFormats::GetCurrentRevision()); if (HasCustomSummaryFormat() && m_update_point.GetModID() != m_user_id_of_forced_summary) { ClearCustomSummaryFormat(); m_summary_str.clear(); } - if ( (m_last_format_mgr_revision != Debugger::Formatting::ValueFormats::GetCurrentRevision()) || + if ( (m_last_format_mgr_revision != DataVisualization::ValueFormats::GetCurrentRevision()) || m_last_format_mgr_dynamic != use_dynamic) { if (m_last_summary_format.get()) @@ -241,11 +242,11 @@ m_synthetic_value = NULL; - Debugger::Formatting::ValueFormats::Get(*this, lldb::eNoDynamicValues, m_last_value_format); - Debugger::Formatting::GetSummaryFormat(*this, use_dynamic, m_last_summary_format); - Debugger::Formatting::GetSyntheticChildren(*this, use_dynamic, m_last_synthetic_filter); + DataVisualization::ValueFormats::Get(*this, lldb::eNoDynamicValues, m_last_value_format); + DataVisualization::GetSummaryFormat(*this, use_dynamic, m_last_summary_format); + DataVisualization::GetSyntheticChildren(*this, use_dynamic, m_last_synthetic_filter); - m_last_format_mgr_revision = Debugger::Formatting::ValueFormats::GetCurrentRevision(); + m_last_format_mgr_revision = DataVisualization::ValueFormats::GetCurrentRevision(); m_last_format_mgr_dynamic = use_dynamic; ClearUserVisibleData(); @@ -2852,10 +2853,10 @@ if (print_children && (!entry || entry->DoesPrintChildren() || !sum_cstr)) { - ValueObjectSP synth_vobj = valobj->GetSyntheticValue(use_synth ? + ValueObjectSP synth_valobj = valobj->GetSyntheticValue(use_synth ? lldb::eUseSyntheticFilter : lldb::eNoSyntheticFilter); - uint32_t num_children = synth_vobj->GetNumChildren(); + uint32_t num_children = synth_valobj->GetNumChildren(); bool print_dotdotdot = false; if (num_children) { @@ -2881,7 +2882,7 @@ for (uint32_t idx=0; idxGetChildAtIndex(idx, true)); + ValueObjectSP child_sp(synth_valobj->GetChildAtIndex(idx, true)); if (child_sp.get()) { DumpValueObject (s, Modified: lldb/trunk/source/Interpreter/CommandObjectScript.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.cpp?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectScript.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObjectScript.cpp Wed Aug 17 17:13:59 2011 @@ -15,7 +15,7 @@ // Project includes #include "lldb/Core/Debugger.h" - +#include "lldb/Core/FormatManager.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -57,7 +57,7 @@ result.SetStatus (eReturnStatusFailed); } - Debugger::Formatting::ForceUpdate(); // script might change Python code we use for formatting.. make sure we keep up to date with it + DataVisualization::ForceUpdate(); // script might change Python code we use for formatting.. make sure we keep up to date with it if (command == NULL || command[0] == '\0') { script_interpreter->ExecuteInterpreterLoop (); Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Wed Aug 17 17:13:59 2011 @@ -174,7 +174,7 @@ PyRun_SimpleString (run_string.GetData()); run_string.Clear(); - run_string.Printf ("run_one_line (%s, 'from osxcpp import *')", m_dictionary_name.c_str(), + run_string.Printf ("run_one_line (%s, 'from gnu_libstdcpp import *')", m_dictionary_name.c_str(), interpreter.GetDebugger().GetID()); PyRun_SimpleString (run_string.GetData()); Removed: lldb/trunk/source/osxcpp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/osxcpp.py?rev=137885&view=auto ============================================================================== --- lldb/trunk/source/osxcpp.py (original) +++ lldb/trunk/source/osxcpp.py (removed) @@ -1,231 +0,0 @@ -import re - -# C++ STL formatters for LLDB -# These formatters are based upon the version of the STL that ships -# with Mac OS X Snow Leopard 10.6.8 and OS X Lion 10.7.0 -# The STL implementation *might* change on other releases of Apple's -# operating system and library infrastructure, and might be different on -# other operating systems - -class StdListSynthProvider: - - def __init__(self, valobj, dict): - self.valobj = valobj - self.update() - - def num_children(self): - next_val = self.next.GetValueAsUnsigned(0) - prev_val = self.prev.GetValueAsUnsigned(0) - # After a std::list has been initialized, both next and prev will be non-NULL - if next_val == 0 or prev_val == 0: - return 0 - if next_val == self.node_address: - return 0 - if next_val == prev_val: - return 1 - size = 2 - current = self.next - while current.GetChildMemberWithName('_M_next').GetValueAsUnsigned(0) != self.node_address: - size = size + 1 - current = current.GetChildMemberWithName('_M_next') - return (size - 1) - - def get_child_index(self,name): - return int(name.lstrip('[').rstrip(']')) - - def get_child_at_index(self,index): - if index >= self.num_children(): - return None; - offset = index - current = self.next - while offset > 0: - current = current.GetChildMemberWithName('_M_next') - offset = offset - 1 - return current.CreateChildAtOffset('['+str(index)+']',2*current.GetType().GetByteSize(),self.data_type) - - def extract_type_name(self,name): - self.type_name = name[16:] - index = 2 - count_of_template = 1 - while index < len(self.type_name): - if self.type_name[index] == '<': - count_of_template = count_of_template + 1 - elif self.type_name[index] == '>': - count_of_template = count_of_template - 1 - elif self.type_name[index] == ',' and count_of_template == 1: - self.type_name = self.type_name[:index] - break - index = index + 1 - self.type_name_nospaces = self.type_name.replace(", ", ",") - - def update(self): - impl = self.valobj.GetChildMemberWithName('_M_impl') - node = impl.GetChildMemberWithName('_M_node') - self.extract_type_name(impl.GetType().GetName()) - self.node_address = self.valobj.AddressOf().GetValueAsUnsigned(0) - self.next = node.GetChildMemberWithName('_M_next') - self.prev = node.GetChildMemberWithName('_M_prev') - self.data_type = node.GetTarget().FindFirstType(self.type_name) - # tries to fight against a difference in formatting type names between gcc and clang - if self.data_type.IsValid() == False: - self.data_type = node.GetTarget().FindFirstType(self.type_name_nospaces) - self.data_size = self.data_type.GetByteSize() - -class StdVectorSynthProvider: - - def __init__(self, valobj, dict): - self.valobj = valobj; - self.update() - - def num_children(self): - start_val = self.start.GetValueAsUnsigned(0) - finish_val = self.finish.GetValueAsUnsigned(0) - end_val = self.end.GetValueAsUnsigned(0) - # Before a vector has been constructed, it will contain bad values - # so we really need to be careful about the length we return since - # unitialized data can cause us to return a huge number. We need - # to also check for any of the start, finish or end of storage values - # being zero (NULL). If any are, then this vector has not been - # initialized yet and we should return zero - - # Make sure nothing is NULL - if start_val == 0 or finish_val == 0 or end_val == 0: - return 0 - # Make sure start is less than finish - if start_val >= finish_val: - return 0 - # Make sure finish is less than or equal to end of storage - if finish_val > end_val: - return 0 - - num_children = (finish_val-start_val)/self.data_size - return num_children - - def get_child_index(self,name): - return int(name.lstrip('[').rstrip(']')) - - def get_child_at_index(self,index): - if index >= self.num_children(): - return None; - offset = index * self.data_size - return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) - - def update(self): - impl = self.valobj.GetChildMemberWithName('_M_impl') - self.start = impl.GetChildMemberWithName('_M_start') - self.finish = impl.GetChildMemberWithName('_M_finish') - self.end = impl.GetChildMemberWithName('_M_end_of_storage') - self.data_type = self.start.GetType().GetPointeeType() - self.data_size = self.data_type.GetByteSize() - - -class StdMapSynthProvider: - - def __init__(self, valobj, dict): - self.valobj = valobj; - self.update() - - def update(self): - self.Mt = self.valobj.GetChildMemberWithName('_M_t') - self.Mimpl = self.Mt.GetChildMemberWithName('_M_impl') - self.Mheader = self.Mimpl.GetChildMemberWithName('_M_header') - # from libstdc++ implementation of _M_root for rbtree - self.Mroot = self.Mheader.GetChildMemberWithName('_M_parent') - # the stuff into the tree is actually a std::pair - # life would be much easier if gcc had a coherent way to print out - # template names in debug info - self.expand_clang_type_name() - self.expand_gcc_type_name() - self.data_type = self.Mt.GetTarget().FindFirstType(self.clang_type_name) - if self.data_type.IsValid() == False: - self.data_type = self.Mt.GetTarget().FindFirstType(self.gcc_type_name) - self.data_size = self.data_type.GetByteSize() - self.skip_size = self.Mheader.GetType().GetByteSize() - - def expand_clang_type_name(self): - type_name = self.Mimpl.GetType().GetName() - index = type_name.find("std::pair<") - type_name = type_name[index+5:] - index = 6 - template_count = 1 - while index < len(type_name): - if type_name[index] == '<': - template_count = template_count + 1 - elif type_name[index] == '>' and template_count == 1: - type_name = type_name[:index+1] - break - elif type_name[index] == '>': - template_count = template_count - 1 - index = index + 1; - self.clang_type_name = type_name - - def expand_gcc_type_name(self): - type_name = self.Mt.GetType().GetName() - index = type_name.find("std::pair<") - type_name = type_name[index+5:] - index = 6 - template_count = 1 - while index < len(type_name): - if type_name[index] == '<': - template_count = template_count + 1 - elif type_name[index] == '>' and template_count == 1: - type_name = type_name[:index+1] - break - elif type_name[index] == '>': - template_count = template_count - 1 - elif type_name[index] == ' ' and template_count == 1 and type_name[index-1] == ',': - type_name = type_name[0:index] + type_name[index+1:] - index = index - 1 - index = index + 1; - self.gcc_type_name = type_name - - def num_children(self): - root_ptr_val = self.node_ptr_value(self.Mroot) - if root_ptr_val == 0: - return 0; - return self.Mimpl.GetChildMemberWithName('_M_node_count').GetValueAsUnsigned(0) - - def get_child_index(self,name): - return int(name.lstrip('[').rstrip(']')) - - def get_child_at_index(self,index): - if index >= self.num_children(): - return None; - offset = index - current = self.left(self.Mheader); - while offset > 0: - current = self.increment_node(current) - offset = offset - 1; - # skip all the base stuff and get at the data - return current.CreateChildAtOffset('['+str(index)+']',self.skip_size,self.data_type) - - # utility functions - def node_ptr_value(self,node): - return node.GetValueAsUnsigned(0) - - def right(self,node): - return node.GetChildMemberWithName("_M_right"); - - def left(self,node): - return node.GetChildMemberWithName("_M_left"); - - def parent(self,node): - return node.GetChildMemberWithName("_M_parent"); - - # from libstdc++ implementation of iterator for rbtree - def increment_node(self,node): - if self.node_ptr_value(self.right(node)) != 0: - x = self.right(node); - while self.node_ptr_value(self.left(x)) != 0: - x = self.left(x); - return x; - else: - x = node; - y = self.parent(x) - while(self.node_ptr_value(x) == self.node_ptr_value(self.right(y))): - x = y; - y = self.parent(y); - if self.node_ptr_value(self.right(x)) != self.node_ptr_value(y): - x = y; - return x; - Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py?rev=137886&r1=137885&r2=137886&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py Wed Aug 17 17:13:59 2011 @@ -54,7 +54,7 @@ self.addTearDownHook(cleanup) # Setup the summaries for this scenario - self.runCmd("type summary add -f \"${var._M_dataplus._M_p}\" std::string") # This works fine on OSX 10.6.8, if it differs on your implementation, submit a patch to adapt it to your C++ stdlib + #self.runCmd("type summary add -f \"${var._M_dataplus._M_p}\" std::string") self.runCmd("type summary add -f \"Level 1\" \"DeepData_1\"") self.runCmd("type summary add -f \"Level 2\" \"DeepData_2\" -e") self.runCmd("type summary add -f \"Level 3\" \"DeepData_3\"") From jingham at apple.com Wed Aug 17 21:29:05 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 18 Aug 2011 02:29:05 -0000 Subject: [Lldb-commits] [lldb] r137921 - /lldb/trunk/source/Commands/CommandObjectCommands.cpp Message-ID: <20110818022905.992802A6C12C@llvm.org> Author: jingham Date: Wed Aug 17 21:29:05 2011 New Revision: 137921 URL: http://llvm.org/viewvc/llvm-project?rev=137921&view=rev Log: Fix the "command alias" help string to make clear that the $ substitutions should be whole words in the output command. Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=137921&r1=137920&r2=137921&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Wed Aug 17 21:29:05 2011 @@ -351,11 +351,19 @@ user can now use 'bfl' instead. The '%1' and '%2' are positional placeholders \n\ for the actual arguments that will be passed when the alias command is used. \n\ The number in the placeholder refers to the position/order the actual value \n\ - occupies when the alias is used. So all the occurrences of '%1' in the alias \n\ + occupies when the alias is used. All the occurrences of '%1' in the alias \n\ will be replaced with the first argument, all the occurrences of '%2' in the \n\ alias will be replaced with the second argument, and so on. This also allows \n\ actual arguments to be used multiple times within an alias (see 'process \n\ - launch' example below). So in the 'bfl' case, the actual file value will be \n\ + launch' example below). \n\ + Note: the positional arguments must substitute as whole words in the resultant\n\ + command, so you can't at present do something like:\n\ + \n\ + commands alias bcppfl breakpoint set -f %1.cpp -l %2\n\ + \n\ + to get the file extension \".cpp\" automatically appended. For more complex\n\ + aliasing, use the \"command regex\" command instead.\n\ + \nSo in the 'bfl' case, the actual file value will be \n\ filled in with the first argument following 'bfl' and the actual line number \n\ value will be filled in with the second argument. The user would use this \n\ alias as follows: \n\ From granata.enrico at gmail.com Thu Aug 18 11:38:27 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Thu, 18 Aug 2011 16:38:27 -0000 Subject: [Lldb-commits] [lldb] r137944 - in /lldb/trunk: include/lldb/Core/ source/Commands/ source/Core/ source/Interpreter/ test/functionalities/data-formatter/data-formatter-smart-array/ test/functionalities/data-formatter/rdar-9973865/ Message-ID: <20110818163827.333362A6C12C@llvm.org> Author: enrico Date: Thu Aug 18 11:38:26 2011 New Revision: 137944 URL: http://llvm.org/viewvc/llvm-project?rev=137944&view=rev Log: Second round of code cleanups: - reorganizing classes layout to have public part first Typedefs that we want to keep private, but must be defined for some public code to work correctly are an exception - avoiding methods in the form T foo() { code; } all on one-line - moving method implementations from .h to .cpp whenever feasible Templatized code is an exception and so are very small methods - generally, adhering to coding conventions followed project-wide Functional changes: - fixed an issue where using ${var} in a summary for an aggregate, and then displaying a pointer-to-aggregate would lead to no summary being displayed The issue was not a major one because all ${var} was meant to do in that context was display an error for invalid use of pointer Accordingly fixed test cases and added a new test case Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973865/ lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Makefile lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py lldb/trunk/test/functionalities/data-formatter/rdar-9973865/main.cpp Modified: lldb/trunk/include/lldb/Core/FormatClasses.h lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/FormatManager.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Interpreter/CommandObjectScript.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py Modified: lldb/trunk/include/lldb/Core/FormatClasses.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=137944&r1=137943&r2=137944&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatClasses.h (original) +++ lldb/trunk/include/lldb/Core/FormatClasses.h Thu Aug 18 11:38:26 2011 @@ -57,7 +57,7 @@ } typedef lldb::SharedPtr::Type SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const ValueFormat::SharedPointer&); + typedef bool(*ValueCallback)(void*, ConstString, const lldb::ValueFormatSP&); ~ValueFormat() { @@ -295,7 +295,10 @@ std::string - GetPythonClassName() { return m_python_class; } + GetPythonClassName() + { + return m_python_class; + } std::string GetDescription(); @@ -453,8 +456,8 @@ GetDescription() = 0; typedef lldb::SharedPtr::Type SharedPointer; - typedef bool(*SummaryCallback)(void*, ConstString, const SummaryFormat::SharedPointer&); - typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const SummaryFormat::SharedPointer&); + typedef bool(*SummaryCallback)(void*, ConstString, const lldb::SummaryFormatSP&); + typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::SummaryFormatSP&); }; Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=137944&r1=137943&r2=137944&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Thu Aug 18 11:38:26 2011 @@ -69,13 +69,13 @@ { public: virtual void - Changed() = 0; + Changed () = 0; virtual - ~IFormatChangeListener() {} + ~IFormatChangeListener () {} virtual uint32_t - GetCurrentRevision() = 0; + GetCurrentRevision () = 0; }; @@ -85,9 +85,6 @@ template class FormatMap { - friend class FormatNavigator; - friend class FormatManager; - public: typedef typename ValueType::SharedPointer ValueSP; @@ -95,23 +92,6 @@ typedef typename MapType::iterator MapIterator; typedef bool(*CallbackType)(void*, KeyType, const ValueSP&); -private: - MapType m_map; - Mutex m_map_mutex; - IFormatChangeListener* listener; - - MapType& map() - { - return m_map; - } - - Mutex& mutex() - { - return m_map_mutex; - } - -public: - FormatMap(IFormatChangeListener* lst = NULL) : m_map(), m_map_mutex(Mutex::eMutexTypeRecursive), @@ -135,7 +115,7 @@ } bool - Delete(KeyType name) + Delete (KeyType name) { Mutex::Locker(m_map_mutex); MapIterator iter = m_map.find(name); @@ -148,7 +128,7 @@ } void - Clear() + Clear () { Mutex::Locker(m_map_mutex); m_map.clear(); @@ -169,7 +149,7 @@ } void - LoopThrough(CallbackType callback, void* param) + LoopThrough (CallbackType callback, void* param) { if (callback) { @@ -185,11 +165,31 @@ } uint32_t - GetCount() + GetCount () { return m_map.size(); } +private: + MapType m_map; + Mutex m_map_mutex; + IFormatChangeListener* listener; + + MapType& + map () + { + return m_map; + } + + Mutex& + mutex () + { + return m_map_mutex; + } + + friend class FormatNavigator; + friend class FormatManager; + }; template @@ -222,7 +222,7 @@ } void - Add(const MapKeyType &type, const MapValueType& entry) + Add (const MapKeyType &type, const MapValueType& entry) { m_format_map.Add(type,entry); } @@ -230,7 +230,7 @@ // using ConstString instead of MapKeyType is necessary here // to make the partial template specializations below work bool - Delete(ConstString type) + Delete (ConstString type) { return m_format_map.Delete(type); } @@ -254,19 +254,19 @@ } void - Clear() + Clear () { m_format_map.Clear(); } void - LoopThrough(CallbackType callback, void* param) + LoopThrough (CallbackType callback, void* param) { m_format_map.LoopThrough(callback,param); } uint32_t - GetCount() + GetCount () { return m_format_map.GetCount(); } @@ -280,7 +280,7 @@ // using ConstString instead of MapKeyType is necessary here // to make the partial template specializations below work bool - Get(ConstString type, MapValueType& entry) + Get (ConstString type, MapValueType& entry) { return m_format_map.Get(type, entry); } @@ -580,7 +580,7 @@ template<> bool -FormatNavigator::Get(ConstString key, SummaryFormat::SharedPointer& value); +FormatNavigator::Get(ConstString key, lldb::SummaryFormatSP& value); template<> bool @@ -624,47 +624,6 @@ typedef SynthNavigator::MapType SynthMap; typedef RegexSynthNavigator::MapType RegexSynthMap; - SummaryNavigator::SharedPointer m_summary_nav; - RegexSummaryNavigator::SharedPointer m_regex_summary_nav; - FilterNavigator::SharedPointer m_filter_nav; - RegexFilterNavigator::SharedPointer m_regex_filter_nav; - SynthNavigator::SharedPointer m_synth_nav; - RegexSynthNavigator::SharedPointer m_regex_synth_nav; - - bool m_enabled; - - IFormatChangeListener* m_change_listener; - - Mutex m_mutex; - - std::string m_name; - - void - Enable(bool value = true) - { - Mutex::Locker(m_mutex); - m_enabled = value; - if (m_change_listener) - m_change_listener->Changed(); - } - - void - Disable() - { - Enable(false); - } - - friend class CategoryMap; - - friend class FormatNavigator; - friend class FormatNavigator; - - friend class FormatNavigator; - friend class FormatNavigator; - - friend class FormatNavigator; - friend class FormatNavigator; - public: enum FormatCategoryItem @@ -688,57 +647,46 @@ typedef RegexSynthNavigator::SharedPointer RegexSynthNavigatorSP; FormatCategory(IFormatChangeListener* clist, - std::string name) : - m_summary_nav(new SummaryNavigator("summary",clist)), - m_regex_summary_nav(new RegexSummaryNavigator("regex-summary",clist)), - m_filter_nav(new FilterNavigator("filter",clist)), - m_regex_filter_nav(new RegexFilterNavigator("regex-filter",clist)), - m_synth_nav(new SynthNavigator("synth",clist)), - m_regex_synth_nav(new RegexSynthNavigator("regex-synth",clist)), - m_enabled(false), - m_change_listener(clist), - m_mutex(Mutex::eMutexTypeRecursive), - m_name(name) - {} + std::string name); SummaryNavigatorSP - Summary() + GetSummaryNavigator () { return SummaryNavigatorSP(m_summary_nav); } RegexSummaryNavigatorSP - RegexSummary() + GetRegexSummaryNavigator () { return RegexSummaryNavigatorSP(m_regex_summary_nav); } FilterNavigatorSP - Filter() + GetFilterNavigator () { return FilterNavigatorSP(m_filter_nav); } RegexFilterNavigatorSP - RegexFilter() + GetRegexFilterNavigator () { return RegexFilterNavigatorSP(m_regex_filter_nav); } SynthNavigatorSP - Synth() + GetSyntheticNavigator () { return SynthNavigatorSP(m_synth_nav); } RegexSynthNavigatorSP - RegexSynth() + GetRegexSyntheticNavigator () { return RegexSynthNavigatorSP(m_regex_synth_nav); } bool - IsEnabled() const + IsEnabled () const { return m_enabled; } @@ -751,9 +699,9 @@ { if (!IsEnabled()) return false; - if (Summary()->Get(valobj, entry, use_dynamic, reason)) + if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason)) return true; - bool regex = RegexSummary()->Get(valobj, entry, use_dynamic, reason); + bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason); if (regex && reason) *reason |= lldb::eFormatterChoiceCriterionRegularExpressionSummary; return regex; @@ -763,76 +711,25 @@ Get(ValueObject& valobj, lldb::SyntheticChildrenSP& entry, lldb::DynamicValueType use_dynamic, - uint32_t* reason = NULL) - { - if (!IsEnabled()) - return false; - SyntheticFilter::SharedPointer filter; - SyntheticScriptProvider::SharedPointer synth; - bool regex_filter, regex_synth; - uint32_t reason_filter; - uint32_t reason_synth; - - bool pick_synth = false; - - // first find both Filter and Synth, and then check which is most recent - - if (!Filter()->Get(valobj, filter, use_dynamic, &reason_filter)) - regex_filter = RegexFilter()->Get(valobj, filter, use_dynamic, &reason_filter); - - if (!Synth()->Get(valobj, synth, use_dynamic, &reason_synth)) - regex_synth = RegexSynth()->Get(valobj, synth, use_dynamic, &reason_synth); - - if (!filter.get() && !synth.get()) - return false; - - else if (!filter.get() && synth.get()) - pick_synth = true; - - else if (filter.get() && !synth.get()) - pick_synth = false; - - else /*if (filter.get() && synth.get())*/ - { - if (filter->m_my_revision > synth->m_my_revision) - pick_synth = false; - else - pick_synth = true; - } - - if (pick_synth) - { - if (regex_synth && reason) - *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter; - entry = synth; - return true; - } - else - { - if (regex_filter && reason) - *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter; - entry = filter; - return true; - } - } + uint32_t* reason = NULL); - // just a shortcut for Summary()->Clear; RegexSummary()->Clear() + // just a shortcut for GetSummaryNavigator()->Clear; GetRegexSummaryNavigator()->Clear() void - ClearSummaries() + ClearSummaries () { Clear(eSummary | eRegexSummary); } - // just a shortcut for (Summary()->Delete(name) || RegexSummary()->Delete(name)) + // just a shortcut for (GetSummaryNavigator()->Delete(name) || GetRegexSummaryNavigator()->Delete(name)) bool - DeleteSummaries(ConstString name) + DeleteSummaries (ConstString name) { return Delete(name, (eSummary | eRegexSummary)); } void - Clear(FormatCategoryItems items = ALL_ITEM_TYPES) + Clear (FormatCategoryItems items = ALL_ITEM_TYPES) { if ( (items & eSummary) == eSummary ) m_summary_nav->Clear(); @@ -869,7 +766,7 @@ } uint32_t - GetCount(FormatCategoryItems items = ALL_ITEM_TYPES) + GetCount (FormatCategoryItems items = ALL_ITEM_TYPES) { uint32_t count = 0; if ( (items & eSummary) == eSummary ) @@ -888,7 +785,7 @@ } std::string - GetName() + GetName () { return m_name; } @@ -898,127 +795,66 @@ FormatCategoryItems items = ALL_ITEM_TYPES, bool only_enabled = true, const char** matching_category = NULL, - FormatCategoryItems* matching_type = NULL) - { - if (!IsEnabled() && only_enabled) - return false; - - SummaryFormat::SharedPointer summary; - SyntheticFilter::SharedPointer filter; - SyntheticScriptProvider::SharedPointer synth; - - if ( (items & eSummary) == eSummary ) - { - if (m_summary_nav->Get(type_name, summary)) - { - if (matching_category) - *matching_category = m_name.c_str(); - if (matching_type) - *matching_type = eSummary; - return true; - } - } - if ( (items & eRegexSummary) == eRegexSummary ) - { - if (m_regex_summary_nav->Get(type_name, summary)) - { - if (matching_category) - *matching_category = m_name.c_str(); - if (matching_type) - *matching_type = eRegexSummary; - return true; - } - } - if ( (items & eFilter) == eFilter ) - { - if (m_filter_nav->Get(type_name, filter)) - { - if (matching_category) - *matching_category = m_name.c_str(); - if (matching_type) - *matching_type = eFilter; - return true; - } - } - if ( (items & eRegexFilter) == eRegexFilter ) - { - if (m_regex_filter_nav->Get(type_name, filter)) - { - if (matching_category) - *matching_category = m_name.c_str(); - if (matching_type) - *matching_type = eRegexFilter; - return true; - } - } - if ( (items & eSynth) == eSynth ) - { - if (m_synth_nav->Get(type_name, synth)) - { - if (matching_category) - *matching_category = m_name.c_str(); - if (matching_type) - *matching_type = eSynth; - return true; - } - } - if ( (items & eRegexSynth) == eRegexSynth ) - { - if (m_regex_synth_nav->Get(type_name, synth)) - { - if (matching_category) - *matching_category = m_name.c_str(); - if (matching_type) - *matching_type = eRegexSynth; - return true; - } - } - return false; - } + FormatCategoryItems* matching_type = NULL); typedef lldb::SharedPtr::Type SharedPointer; -}; - -class CategoryMap -{ -private: - typedef const char* KeyType; - typedef FormatCategory ValueType; - typedef ValueType::SharedPointer ValueSP; - typedef std::list ActiveCategoriesList; - typedef ActiveCategoriesList::iterator ActiveCategoriesIterator; - Mutex m_map_mutex; - IFormatChangeListener* listener; +private: + SummaryNavigator::SharedPointer m_summary_nav; + RegexSummaryNavigator::SharedPointer m_regex_summary_nav; + FilterNavigator::SharedPointer m_filter_nav; + RegexFilterNavigator::SharedPointer m_regex_filter_nav; + SynthNavigator::SharedPointer m_synth_nav; + RegexSynthNavigator::SharedPointer m_regex_synth_nav; + bool m_enabled; - friend class FormatNavigator; - friend class FormatManager; + IFormatChangeListener* m_change_listener; -public: - typedef std::map MapType; + Mutex m_mutex; -private: - MapType m_map; - ActiveCategoriesList m_active_categories; + std::string m_name; - MapType& map() + void + Enable (bool value = true) { - return m_map; + Mutex::Locker(m_mutex); + m_enabled = value; + if (m_change_listener) + m_change_listener->Changed(); } - ActiveCategoriesList& active_list() + void + Disable () { - return m_active_categories; + Enable(false); } - Mutex& mutex() - { - return m_map_mutex; - } + friend class CategoryMap; -public: + friend class FormatNavigator; + friend class FormatNavigator; + + friend class FormatNavigator; + friend class FormatNavigator; + friend class FormatNavigator; + friend class FormatNavigator; + + +}; + +class CategoryMap +{ +private: + typedef const char* KeyType; + typedef FormatCategory ValueType; + typedef ValueType::SharedPointer ValueSP; + typedef std::list ActiveCategoriesList; + typedef ActiveCategoriesList::iterator ActiveCategoriesIterator; + +public: + typedef std::map MapType; typedef MapType::iterator MapIterator; typedef bool(*CallbackType)(void*, KeyType, const ValueSP&); @@ -1041,7 +877,7 @@ } bool - Delete(KeyType name) + Delete (KeyType name) { Mutex::Locker(m_map_mutex); MapIterator iter = m_map.find(name); @@ -1055,7 +891,7 @@ } void - EnableCategory(KeyType category_name) + EnableCategory (KeyType category_name) { Mutex::Locker(m_map_mutex); ValueSP category; @@ -1067,19 +903,19 @@ class delete_matching_categories { - FormatCategory::SharedPointer ptr; + lldb::FormatCategorySP ptr; public: - delete_matching_categories(FormatCategory::SharedPointer p) : ptr(p) + delete_matching_categories(lldb::FormatCategorySP p) : ptr(p) {} - bool operator()(const FormatCategory::SharedPointer& other) + bool operator()(const lldb::FormatCategorySP& other) { return ptr.get() == other.get(); } }; void - DisableCategory(KeyType category_name) + DisableCategory (KeyType category_name) { Mutex::Locker(m_map_mutex); ValueSP category; @@ -1090,7 +926,7 @@ } void - Clear() + Clear () { Mutex::Locker(m_map_mutex); m_map.clear(); @@ -1112,38 +948,7 @@ } void - LoopThrough(CallbackType callback, void* param) - { - if (callback) - { - Mutex::Locker(m_map_mutex); - - // loop through enabled categories in respective order - { - ActiveCategoriesIterator begin, end = m_active_categories.end(); - for (begin = m_active_categories.begin(); begin != end; begin++) - { - FormatCategory::SharedPointer category = *begin; - const char* type = category->GetName().c_str(); - if (!callback(param, type, category)) - break; - } - } - - // loop through disabled categories in just any order - { - MapIterator pos, end = m_map.end(); - for (pos = m_map.begin(); pos != end; pos++) - { - if (pos->second->IsEnabled()) - continue; - KeyType type = pos->first; - if (!callback(param, type, pos->second)) - break; - } - } - } - } + LoopThrough (CallbackType callback, void* param); bool AnyMatches(ConstString type_name, @@ -1168,7 +973,7 @@ } uint32_t - GetCount() + GetCount () { return m_map.size(); } @@ -1185,20 +990,10 @@ for (begin = m_active_categories.begin(); begin != end; begin++) { - FormatCategory::SharedPointer category = *begin; + lldb::FormatCategorySP category = *begin; lldb::SummaryFormatSP current_format; if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) continue; - /*if (reason_why == lldb::eFormatterChoiceCriterionDirectChoice) - { - entry = current_format; - return true; - } - else if (first) - { - entry = current_format; - first = false; - }*/ entry = current_format; return true; } @@ -1218,26 +1013,40 @@ for (begin = m_active_categories.begin(); begin != end; begin++) { - FormatCategory::SharedPointer category = *begin; + lldb::FormatCategorySP category = *begin; lldb::SyntheticChildrenSP current_format; if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) continue; - /*if (reason_why == lldb::eFormatterChoiceCriterionDirectChoice) - { - entry = current_format; - return true; - } - else if (first) - { - entry = current_format; - first = false; - }*/ entry = current_format; return true; } return false; } - + +private: + Mutex m_map_mutex; + IFormatChangeListener* listener; + + MapType m_map; + ActiveCategoriesList m_active_categories; + + MapType& map () + { + return m_map; + } + + ActiveCategoriesList& active_list() + { + return m_active_categories; + } + + Mutex& mutex () + { + return m_map_mutex; + } + + friend class FormatNavigator; + friend class FormatManager; }; @@ -1249,46 +1058,46 @@ typedef ValueNavigator::MapType ValueMap; typedef FormatMap NamedSummariesMap; - - ValueNavigator m_value_nav; - NamedSummariesMap m_named_summaries_map; - uint32_t m_last_revision; - CategoryMap m_categories_map; - - const char* m_default_category_name; - const char* m_system_category_name; - const char* m_gnu_cpp_category_name; - typedef CategoryMap::MapType::iterator CategoryMapIterator; - - ConstString m_default_cs; - ConstString m_system_cs; - ConstString m_gnu_stdcpp_cs; public: - typedef bool (*CategoryCallback)(void*, const char*, const FormatCategory::SharedPointer&); + typedef bool (*CategoryCallback)(void*, const char*, const lldb::FormatCategorySP&); - FormatManager(); + FormatManager (); + + CategoryMap& + Categories () + { + return m_categories_map; + } + + ValueNavigator& + Value () + { + return m_value_nav; + } + + NamedSummariesMap& + NamedSummary () + { + return m_named_summaries_map; + } - CategoryMap& Categories() { return m_categories_map; } - ValueNavigator& Value() { return m_value_nav; } - NamedSummariesMap& NamedSummary() { return m_named_summaries_map; } - void - EnableCategory(const char* category_name) + EnableCategory (const char* category_name) { m_categories_map.EnableCategory(category_name); } void - DisableCategory(const char* category_name) + DisableCategory (const char* category_name) { m_categories_map.DisableCategory(category_name); } void - LoopThroughCategories(CategoryCallback callback, void* param) + LoopThroughCategories (CategoryCallback callback, void* param) { m_categories_map.LoopThrough(callback, param); } @@ -1296,17 +1105,17 @@ FormatCategory::SummaryNavigatorSP Summary(const char* category_name = NULL) { - return Category(category_name)->Summary(); + return Category(category_name)->GetSummaryNavigator(); } FormatCategory::RegexSummaryNavigatorSP - RegexSummary(const char* category_name = NULL) + RegexSummary (const char* category_name = NULL) { - return Category(category_name)->RegexSummary(); + return Category(category_name)->GetRegexSummaryNavigator(); } lldb::FormatCategorySP - Category(const char* category_name = NULL) + Category (const char* category_name = NULL) { if (!category_name) return Category(m_default_category_name); @@ -1363,21 +1172,34 @@ GetSingleItemFormat(lldb::Format vector_format); void - Changed() + Changed () { __sync_add_and_fetch(&m_last_revision, +1); } uint32_t - GetCurrentRevision() + GetCurrentRevision () { return m_last_revision; } - ~FormatManager() + ~FormatManager () { } +private: + ValueNavigator m_value_nav; + NamedSummariesMap m_named_summaries_map; + uint32_t m_last_revision; + CategoryMap m_categories_map; + + const char* m_default_category_name; + const char* m_system_category_name; + const char* m_gnu_cpp_category_name; + + ConstString m_default_cs; + ConstString m_system_cs; + ConstString m_gnu_stdcpp_cs; }; class DataVisualization @@ -1388,29 +1210,29 @@ static void ForceUpdate(); + static uint32_t + GetCurrentRevision (); + class ValueFormats { public: static bool - Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, ValueFormat::SharedPointer &entry); + Get (ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry); static void - Add(const ConstString &type, const ValueFormat::SharedPointer &entry); + Add (const ConstString &type, const lldb::ValueFormatSP &entry); static bool - Delete(const ConstString &type); + Delete (const ConstString &type); static void - Clear(); + Clear (); static void - LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton); - - static uint32_t - GetCurrentRevision(); + LoopThrough (ValueFormat::ValueCallback callback, void* callback_baton); static uint32_t - GetCount(); + GetCount (); }; static bool @@ -1433,25 +1255,22 @@ { public: static bool - Get(const ConstString &type, lldb::SummaryFormatSP &entry); + Get (const ConstString &type, lldb::SummaryFormatSP &entry); static void - Add(const ConstString &type, const lldb::SummaryFormatSP &entry); + Add (const ConstString &type, const lldb::SummaryFormatSP &entry); static bool - Delete(const ConstString &type); + Delete (const ConstString &type); static void - Clear(); + Clear (); static void - LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton); + LoopThrough (SummaryFormat::SummaryCallback callback, void* callback_baton); static uint32_t - GetCurrentRevision(); - - static uint32_t - GetCount(); + GetCount (); }; class Categories @@ -1459,34 +1278,31 @@ public: static bool - Get(const ConstString &category, lldb::FormatCategorySP &entry); + Get (const ConstString &category, lldb::FormatCategorySP &entry); static void - Add(const ConstString &category); + Add (const ConstString &category); static bool - Delete(const ConstString &category); + Delete (const ConstString &category); static void - Clear(); + Clear (); static void - Clear(ConstString &category); + Clear (ConstString &category); static void - Enable(ConstString& category); + Enable (ConstString& category); static void - Disable(ConstString& category); + Disable (ConstString& category); static void - LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton); - - static uint32_t - GetCurrentRevision(); + LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton); static uint32_t - GetCount(); + GetCount (); }; }; Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137944&r1=137943&r2=137944&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Aug 18 11:38:26 2011 @@ -660,7 +660,8 @@ bool DumpPrintableRepresentation(Stream& s, ValueObjectRepresentationStyle val_obj_display = eDisplaySummary, - lldb::Format custom_format = lldb::eFormatInvalid); + lldb::Format custom_format = lldb::eFormatInvalid, + bool only_special = false); bool GetValueIsValid () const; Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=137944&r1=137943&r2=137944&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Thu Aug 18 11:38:26 2011 @@ -195,7 +195,8 @@ // now I have a valid format, let's add it to every type - for (size_t i = 0; i < argc; i++) { + for (size_t i = 0; i < argc; i++) + { const char* typeA = command.GetArgumentAtIndex(i); ConstString typeCS(typeA); if (typeCS) @@ -325,7 +326,7 @@ // CommandObjectTypeFormatList //------------------------------------------------------------------------- -bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const ValueFormat::SharedPointer& entry); +bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::ValueFormatSP& entry); class CommandObjectTypeFormatList; @@ -368,7 +369,8 @@ CommandObjectTypeFormatList_LoopCallbackParam *param; - if (argc == 1) { + if (argc == 1) + { RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); regex->Compile(command.GetArgumentAtIndex(0)); param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,regex); @@ -385,7 +387,7 @@ bool LoopCallback (ConstString type, - const ValueFormat::SharedPointer& entry, + const lldb::ValueFormatSP& entry, RegularExpression* regex, CommandReturnObject *result) { @@ -400,7 +402,7 @@ return true; } - friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const ValueFormat::SharedPointer& entry); + friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::ValueFormatSP& entry); }; @@ -408,7 +410,7 @@ CommandObjectTypeFormatList_LoopCallback ( void* pt2self, ConstString type, - const ValueFormat::SharedPointer& entry) + const lldb::ValueFormatSP& entry) { CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(type, entry, param->regex, param->result); @@ -788,7 +790,8 @@ m_options.m_name, m_options.m_category); - for (size_t i = 0; i < argc; i++) { + for (size_t i = 0; i < argc; i++) + { const char* typeA = command.GetArgumentAtIndex(i); if (typeA && *typeA) options->m_target_types << typeA; @@ -872,7 +875,7 @@ Error error; - SummaryFormat::SharedPointer entry(new StringSummaryFormat(m_options.m_cascade, + lldb::SummaryFormatSP entry(new StringSummaryFormat(m_options.m_cascade, m_options.m_skip_pointers, m_options.m_skip_references, m_options.m_no_children, @@ -889,7 +892,8 @@ // now I have a valid format, let's add it to every type - for (size_t i = 0; i < argc; i++) { + for (size_t i = 0; i < argc; i++) + { const char* typeA = command.GetArgumentAtIndex(i); if (!typeA || typeA[0] == '\0') { @@ -1049,8 +1053,8 @@ return false; } - category->RegexSummary()->Delete(type_name); - category->RegexSummary()->Add(typeRX, entry); + category->GetRegexSummaryNavigator()->Delete(type_name); + category->GetRegexSummaryNavigator()->Add(typeRX, entry); return true; } @@ -1062,7 +1066,7 @@ } else { - category->Summary()->Add(type_name, entry); + category->GetSummaryNavigator()->Add(type_name, entry); return true; } } @@ -1163,7 +1167,7 @@ static bool PerCategoryCallback(void* param, const char* cate_name, - const FormatCategory::SharedPointer& cate) + const lldb::FormatCategorySP& cate) { ConstString *name = (ConstString*)param; cate->Delete(*name, FormatCategory::eSummary | FormatCategory::eRegexSummary); @@ -1319,10 +1323,10 @@ static bool PerCategoryCallback(void* param, const char* cate_name, - const FormatCategory::SharedPointer& cate) + const lldb::FormatCategorySP& cate) { - cate->Summary()->Clear(); - cate->RegexSummary()->Clear(); + cate->GetSummaryNavigator()->Clear(); + cate->GetRegexSummaryNavigator()->Clear(); return true; } @@ -1491,7 +1495,8 @@ m_options.m_category_regex.empty() ? NULL : new RegularExpression(m_options.m_category_regex.c_str()); - if (argc == 1) { + if (argc == 1) + { RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); regex->Compile(command.GetArgumentAtIndex(0)); param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex,cate_regex); @@ -1504,7 +1509,8 @@ if (DataVisualization::NamedSummaryFormats::GetCount() > 0) { result.GetOutputStream().Printf("Named summaries:\n"); - if (argc == 1) { + if (argc == 1) + { RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); regex->Compile(command.GetArgumentAtIndex(0)); param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex); @@ -1527,7 +1533,7 @@ static bool PerCategoryCallback(void* param_vp, const char* cate_name, - const FormatCategory::SharedPointer& cate) + const lldb::FormatCategorySP& cate) { CommandObjectTypeSummaryList_LoopCallbackParam* param = @@ -1546,12 +1552,12 @@ cate_name, (cate->IsEnabled() ? "enabled" : "disabled")); - cate->Summary()->LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param_vp); + cate->GetSummaryNavigator()->LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param_vp); - if (cate->RegexSummary()->GetCount() > 0) + if (cate->GetRegexSummaryNavigator()->GetCount() > 0) { result->GetOutputStream().Printf("Regex-based summaries (slower):\n"); - cate->RegexSummary()->LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, param_vp); + cate->GetRegexSummaryNavigator()->LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, param_vp); } return true; } @@ -1559,7 +1565,7 @@ bool LoopCallback (const char* type, - const SummaryFormat::SharedPointer& entry, + const lldb::SummaryFormatSP& entry, RegularExpression* regex, CommandReturnObject *result) { @@ -1568,15 +1574,15 @@ return true; } - friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const SummaryFormat::SharedPointer& entry); - friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SummaryFormat::SharedPointer& entry); + friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const lldb::SummaryFormatSP& entry); + friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::SummaryFormatSP& entry); }; bool CommandObjectTypeSummaryList_LoopCallback ( void* pt2self, ConstString type, - const SummaryFormat::SharedPointer& entry) + const lldb::SummaryFormatSP& entry) { CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result); @@ -1586,7 +1592,7 @@ CommandObjectTypeRXSummaryList_LoopCallback ( void* pt2self, lldb::RegularExpressionSP regex, - const SummaryFormat::SharedPointer& entry) + const lldb::SummaryFormatSP& entry) { CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result); @@ -1819,7 +1825,7 @@ static bool PerCategoryCallback(void* param_vp, const char* cate_name, - const FormatCategory::SharedPointer& cate) + const lldb::FormatCategorySP& cate) { CommandObjectTypeCategoryList_CallbackParam* param = (CommandObjectTypeCategoryList_CallbackParam*)param_vp; @@ -2000,7 +2006,8 @@ m_options.m_category_regex.empty() ? NULL : new RegularExpression(m_options.m_category_regex.c_str()); - if (argc == 1) { + if (argc == 1) + { RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); regex->Compile(command.GetArgumentAtIndex(0)); param = new CommandObjectTypeFilterList_LoopCallbackParam(this,&result,regex,cate_regex); @@ -2022,7 +2029,7 @@ static bool PerCategoryCallback(void* param_vp, const char* cate_name, - const FormatCategory::SharedPointer& cate) + const lldb::FormatCategorySP& cate) { CommandObjectTypeFilterList_LoopCallbackParam* param = @@ -2041,12 +2048,12 @@ cate_name, (cate->IsEnabled() ? "enabled" : "disabled")); - cate->Filter()->LoopThrough(CommandObjectTypeFilterList_LoopCallback, param_vp); + cate->GetFilterNavigator()->LoopThrough(CommandObjectTypeFilterList_LoopCallback, param_vp); - if (cate->RegexFilter()->GetCount() > 0) + if (cate->GetRegexFilterNavigator()->GetCount() > 0) { result->GetOutputStream().Printf("Regex-based filters (slower):\n"); - cate->RegexFilter()->LoopThrough(CommandObjectTypeFilterRXList_LoopCallback, param_vp); + cate->GetRegexFilterNavigator()->LoopThrough(CommandObjectTypeFilterRXList_LoopCallback, param_vp); } return true; @@ -2208,7 +2215,8 @@ m_options.m_category_regex.empty() ? NULL : new RegularExpression(m_options.m_category_regex.c_str()); - if (argc == 1) { + if (argc == 1) + { RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); regex->Compile(command.GetArgumentAtIndex(0)); param = new CommandObjectTypeSynthList_LoopCallbackParam(this,&result,regex,cate_regex); @@ -2230,7 +2238,7 @@ static bool PerCategoryCallback(void* param_vp, const char* cate_name, - const FormatCategory::SharedPointer& cate) + const lldb::FormatCategorySP& cate) { CommandObjectTypeSynthList_LoopCallbackParam* param = @@ -2249,12 +2257,12 @@ cate_name, (cate->IsEnabled() ? "enabled" : "disabled")); - cate->Synth()->LoopThrough(CommandObjectTypeSynthList_LoopCallback, param_vp); + cate->GetSyntheticNavigator()->LoopThrough(CommandObjectTypeSynthList_LoopCallback, param_vp); - if (cate->RegexSynth()->GetCount() > 0) + if (cate->GetRegexSyntheticNavigator()->GetCount() > 0) { result->GetOutputStream().Printf("Regex-based synthetic providers (slower):\n"); - cate->RegexSynth()->LoopThrough(CommandObjectTypeSynthRXList_LoopCallback, param_vp); + cate->GetRegexSyntheticNavigator()->LoopThrough(CommandObjectTypeSynthRXList_LoopCallback, param_vp); } return true; @@ -2377,7 +2385,7 @@ static bool PerCategoryCallback(void* param, const char* cate_name, - const FormatCategory::SharedPointer& cate) + const lldb::FormatCategorySP& cate) { ConstString *name = (ConstString*)param; return cate->Delete(*name, FormatCategory::eFilter | FormatCategory::eRegexFilter); @@ -2438,8 +2446,8 @@ lldb::FormatCategorySP category; DataVisualization::Categories::Get(ConstString(m_options.m_category.c_str()), category); - bool delete_category = category->Filter()->Delete(typeCS); - delete_category = category->RegexFilter()->Delete(typeCS) || delete_category; + bool delete_category = category->GetFilterNavigator()->Delete(typeCS); + delete_category = category->GetRegexFilterNavigator()->Delete(typeCS) || delete_category; if (delete_category) { @@ -2540,7 +2548,7 @@ static bool PerCategoryCallback(void* param, const char* cate_name, - const FormatCategory::SharedPointer& cate) + const lldb::FormatCategorySP& cate) { ConstString* name = (ConstString*)param; return cate->Delete(*name, FormatCategory::eSynth | FormatCategory::eRegexSynth); @@ -2601,8 +2609,8 @@ lldb::FormatCategorySP category; DataVisualization::Categories::Get(ConstString(m_options.m_category.c_str()), category); - bool delete_category = category->Synth()->Delete(typeCS); - delete_category = category->RegexSynth()->Delete(typeCS) || delete_category; + bool delete_category = category->GetSyntheticNavigator()->Delete(typeCS); + delete_category = category->GetRegexSyntheticNavigator()->Delete(typeCS) || delete_category; if (delete_category) { @@ -2699,7 +2707,7 @@ static bool PerCategoryCallback(void* param, const char* cate_name, - const FormatCategory::SharedPointer& cate) + const lldb::FormatCategorySP& cate) { cate->Clear(FormatCategory::eFilter | FormatCategory::eRegexFilter); return true; @@ -2737,8 +2745,8 @@ } else DataVisualization::Categories::Get(ConstString(NULL), category); - category->Filter()->Clear(); - category->RegexFilter()->Clear(); + category->GetFilterNavigator()->Clear(); + category->GetRegexFilterNavigator()->Clear(); } result.SetStatus(eReturnStatusSuccessFinishResult); @@ -2826,7 +2834,7 @@ static bool PerCategoryCallback(void* param, const char* cate_name, - const FormatCategory::SharedPointer& cate) + const lldb::FormatCategorySP& cate) { cate->Clear(FormatCategory::eSynth | FormatCategory::eRegexSynth); return true; @@ -2864,8 +2872,8 @@ } else DataVisualization::Categories::Get(ConstString(NULL), category); - category->Synth()->Clear(); - category->RegexSynth()->Clear(); + category->GetSyntheticNavigator()->Clear(); + category->GetRegexSyntheticNavigator()->Clear(); } result.SetStatus(eReturnStatusSuccessFinishResult); @@ -3018,7 +3026,8 @@ Error error; - for (size_t i = 0; i < options->m_target_types.GetSize(); i++) { + for (size_t i = 0; i < options->m_target_types.GetSize(); i++) + { const char *type_name = options->m_target_types.GetStringAtIndex(i); ConstString typeCS(type_name); if (typeCS) @@ -3084,7 +3093,8 @@ const size_t argc = command.GetArgumentCount(); - for (size_t i = 0; i < argc; i++) { + for (size_t i = 0; i < argc; i++) + { const char* typeA = command.GetArgumentAtIndex(i); if (typeA && *typeA) options->m_target_types << typeA; @@ -3135,7 +3145,8 @@ Error error; - for (size_t i = 0; i < argc; i++) { + for (size_t i = 0; i < argc; i++) + { const char* typeA = command.GetArgumentAtIndex(i); ConstString typeCS(typeA); if (typeCS) @@ -3210,14 +3221,14 @@ return false; } - category->RegexSynth()->Delete(type_name); - category->RegexSynth()->Add(typeRX, entry); + category->GetRegexSyntheticNavigator()->Delete(type_name); + category->GetRegexSyntheticNavigator()->Add(typeRX, entry); return true; } else { - category->Synth()->Add(type_name, entry); + category->GetSyntheticNavigator()->Add(type_name, entry); return true; } } @@ -3387,14 +3398,14 @@ return false; } - category->RegexFilter()->Delete(type_name); - category->RegexFilter()->Add(typeRX, entry); + category->GetRegexFilterNavigator()->Delete(type_name); + category->GetRegexFilterNavigator()->Add(typeRX, entry); return true; } else { - category->Filter()->Add(type_name, entry); + category->GetFilterNavigator()->Add(type_name, entry); return true; } } @@ -3466,7 +3477,8 @@ Error error; - for (size_t i = 0; i < argc; i++) { + for (size_t i = 0; i < argc; i++) + { const char* typeA = command.GetArgumentAtIndex(i); ConstString typeCS(typeA); if (typeCS) Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=137944&r1=137943&r2=137944&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Aug 18 11:38:26 2011 @@ -1055,16 +1055,20 @@ int64_t index_higher = -1; bool is_array_range = false; const char* first_unparsed; + bool was_plain_var = false; + bool was_var_format = false; if (!valobj) break; // simplest case ${var}, just print valobj's value if (::strncmp (var_name_begin, "var}", strlen("var}")) == 0) { + was_plain_var = true; target = valobj; val_obj_display = ValueObject::eDisplayValue; } else if (::strncmp(var_name_begin,"var%",strlen("var%")) == 0) { + was_var_format = true; // this is a variable with some custom format applied to it const char* percent_position; target = valobj; @@ -1151,19 +1155,38 @@ do_deref_pointer = false; } + // TODO use flags for these bool is_array = ClangASTContext::IsArrayType(target->GetClangType()); bool is_pointer = ClangASTContext::IsPointerType(target->GetClangType()); + bool is_aggregate = ClangASTContext::IsAggregateType(target->GetClangType()); if ((is_array || is_pointer) && (!is_array_range) && val_obj_display == ValueObject::eDisplayValue) // this should be wrong, but there are some exceptions { + StreamString str_temp; if (log) log->Printf("I am into array || pointer && !range"); // try to use the special cases - var_success = target->DumpPrintableRepresentation(s,val_obj_display, custom_format); - if (!var_success) - s << ""; + var_success = target->DumpPrintableRepresentation(str_temp, + val_obj_display, + custom_format); if (log) log->Printf("special cases did%s match", var_success ? "" : "n't"); + if (!var_success) + { + s << ""; + var_success = true; + } + else + s << str_temp.GetData(); + break; + } + + // if directly trying to print ${var} using its value, and this is an aggregate, display a nice + // error message about it (and avoid recursion in DumpPrintableRepresentation) + if (is_aggregate && ((was_var_format && val_obj_display == ValueObject::eDisplayValue) || was_plain_var)) + { + s << ""; + var_success = true; break; } Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=137944&r1=137943&r2=137944&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Thu Aug 18 11:38:26 2011 @@ -156,7 +156,7 @@ template<> bool -FormatNavigator::Get(ConstString key, SummaryFormat::SharedPointer& value) +FormatNavigator::Get(ConstString key, lldb::SummaryFormatSP& value) { Mutex::Locker(m_format_map.mutex()); MapIterator pos, end = m_format_map.map().end(); @@ -268,6 +268,194 @@ return false; } +FormatCategory::FormatCategory(IFormatChangeListener* clist, + std::string name) : + m_summary_nav(new SummaryNavigator("summary",clist)), + m_regex_summary_nav(new RegexSummaryNavigator("regex-summary",clist)), + m_filter_nav(new FilterNavigator("filter",clist)), + m_regex_filter_nav(new RegexFilterNavigator("regex-filter",clist)), + m_synth_nav(new SynthNavigator("synth",clist)), + m_regex_synth_nav(new RegexSynthNavigator("regex-synth",clist)), + m_enabled(false), + m_change_listener(clist), + m_mutex(Mutex::eMutexTypeRecursive), + m_name(name) +{} + +bool +FormatCategory::Get(ValueObject& valobj, + lldb::SyntheticChildrenSP& entry, + lldb::DynamicValueType use_dynamic, + uint32_t* reason) +{ + if (!IsEnabled()) + return false; + SyntheticFilter::SharedPointer filter; + SyntheticScriptProvider::SharedPointer synth; + bool regex_filter, regex_synth; + uint32_t reason_filter; + uint32_t reason_synth; + + bool pick_synth = false; + + // first find both Filter and Synth, and then check which is most recent + + if (!GetFilterNavigator()->Get(valobj, filter, use_dynamic, &reason_filter)) + regex_filter = GetRegexFilterNavigator()->Get(valobj, filter, use_dynamic, &reason_filter); + + if (!GetSyntheticNavigator()->Get(valobj, synth, use_dynamic, &reason_synth)) + regex_synth = GetRegexSyntheticNavigator()->Get(valobj, synth, use_dynamic, &reason_synth); + + if (!filter.get() && !synth.get()) + return false; + + else if (!filter.get() && synth.get()) + pick_synth = true; + + else if (filter.get() && !synth.get()) + pick_synth = false; + + else /*if (filter.get() && synth.get())*/ + { + if (filter->m_my_revision > synth->m_my_revision) + pick_synth = false; + else + pick_synth = true; + } + + if (pick_synth) + { + if (regex_synth && reason) + *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter; + entry = synth; + return true; + } + else + { + if (regex_filter && reason) + *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter; + entry = filter; + return true; + } +} + +bool +FormatCategory::AnyMatches(ConstString type_name, + FormatCategoryItems items, + bool only_enabled, + const char** matching_category, + FormatCategoryItems* matching_type) +{ + if (!IsEnabled() && only_enabled) + return false; + + lldb::SummaryFormatSP summary; + SyntheticFilter::SharedPointer filter; + SyntheticScriptProvider::SharedPointer synth; + + if ( (items & eSummary) == eSummary ) + { + if (m_summary_nav->Get(type_name, summary)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eSummary; + return true; + } + } + if ( (items & eRegexSummary) == eRegexSummary ) + { + if (m_regex_summary_nav->Get(type_name, summary)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eRegexSummary; + return true; + } + } + if ( (items & eFilter) == eFilter ) + { + if (m_filter_nav->Get(type_name, filter)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eFilter; + return true; + } + } + if ( (items & eRegexFilter) == eRegexFilter ) + { + if (m_regex_filter_nav->Get(type_name, filter)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eRegexFilter; + return true; + } + } + if ( (items & eSynth) == eSynth ) + { + if (m_synth_nav->Get(type_name, synth)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eSynth; + return true; + } + } + if ( (items & eRegexSynth) == eRegexSynth ) + { + if (m_regex_synth_nav->Get(type_name, synth)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eRegexSynth; + return true; + } + } + return false; +} + +void +CategoryMap::LoopThrough(CallbackType callback, void* param) +{ + if (callback) + { + Mutex::Locker(m_map_mutex); + + // loop through enabled categories in respective order + { + ActiveCategoriesIterator begin, end = m_active_categories.end(); + for (begin = m_active_categories.begin(); begin != end; begin++) + { + lldb::FormatCategorySP category = *begin; + const char* type = category->GetName().c_str(); + if (!callback(param, type, category)) + break; + } + } + + // loop through disabled categories in just any order + { + MapIterator pos, end = m_map.end(); + for (pos = m_map.begin(); pos != end; pos++) + { + if (pos->second->IsEnabled()) + continue; + KeyType type = pos->first; + if (!callback(param, type, pos->second)) + break; + } + } + } +} + lldb::Format FormatManager::GetSingleItemFormat(lldb::Format vector_format) { @@ -316,7 +504,7 @@ // add some default stuff // most formats, summaries, ... actually belong to the users' lldbinit file rather than here - SummaryFormat::SharedPointer string_format(new StringSummaryFormat(false, + lldb::SummaryFormatSP string_format(new StringSummaryFormat(false, true, false, true, @@ -325,7 +513,7 @@ "${var%s}")); - SummaryFormat::SharedPointer string_array_format(new StringSummaryFormat(false, + lldb::SummaryFormatSP string_array_format(new StringSummaryFormat(false, true, false, false, @@ -336,9 +524,9 @@ lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]")); - Category(m_system_category_name)->Summary()->Add(ConstString("char *"), string_format); - Category(m_system_category_name)->Summary()->Add(ConstString("const char *"), string_format); - Category(m_system_category_name)->RegexSummary()->Add(any_size_char_arr, string_array_format); + Category(m_system_category_name)->GetSummaryNavigator()->Add(ConstString("char *"), string_format); + Category(m_system_category_name)->GetSummaryNavigator()->Add(ConstString("const char *"), string_format); + Category(m_system_category_name)->GetRegexSummaryNavigator()->Add(any_size_char_arr, string_array_format); Category(m_default_category_name); // this call is there to force LLDB into creating an empty "default" category @@ -356,24 +544,24 @@ true, false, "${var._M_dataplus._M_p}")); - Category(m_gnu_cpp_category_name)->Summary()->Add(ConstString("std::string"), + Category(m_gnu_cpp_category_name)->GetSummaryNavigator()->Add(ConstString("std::string"), std_string_summary_sp); - Category(m_gnu_cpp_category_name)->Summary()->Add(ConstString("std::basic_string"), + Category(m_gnu_cpp_category_name)->GetSummaryNavigator()->Add(ConstString("std::basic_string"), std_string_summary_sp); - Category(m_gnu_cpp_category_name)->Summary()->Add(ConstString("std::basic_string,std::allocator >"), + Category(m_gnu_cpp_category_name)->GetSummaryNavigator()->Add(ConstString("std::basic_string,std::allocator >"), std_string_summary_sp); - Category(m_gnu_cpp_category_name)->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::vector<")), + Category(m_gnu_cpp_category_name)->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("std::vector<")), SyntheticChildrenSP(new SyntheticScriptProvider(true, false, false, "StdVectorSynthProvider"))); - Category(m_gnu_cpp_category_name)->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::map<")), + Category(m_gnu_cpp_category_name)->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("std::map<")), SyntheticChildrenSP(new SyntheticScriptProvider(true, false, false, "StdMapSynthProvider"))); - Category(m_gnu_cpp_category_name)->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::list<")), + Category(m_gnu_cpp_category_name)->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("std::list<")), SyntheticChildrenSP(new SyntheticScriptProvider(true, false, false, @@ -388,7 +576,8 @@ static FormatManager& -GetFormatManager() { +GetFormatManager() +{ static FormatManager g_format_manager; return g_format_manager; } @@ -399,14 +588,20 @@ GetFormatManager().Changed(); } +uint32_t +DataVisualization::GetCurrentRevision () +{ + return GetFormatManager().GetCurrentRevision(); +} + bool -DataVisualization::ValueFormats::Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, ValueFormat::SharedPointer &entry) +DataVisualization::ValueFormats::Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry) { return GetFormatManager().Value().Get(valobj,entry, use_dynamic); } void -DataVisualization::ValueFormats::Add(const ConstString &type, const ValueFormat::SharedPointer &entry) +DataVisualization::ValueFormats::Add(const ConstString &type, const lldb::ValueFormatSP &entry) { GetFormatManager().Value().Add(type,entry); } @@ -430,12 +625,6 @@ } uint32_t -DataVisualization::ValueFormats::GetCurrentRevision() -{ - return GetFormatManager().GetCurrentRevision(); -} - -uint32_t DataVisualization::ValueFormats::GetCount() { return GetFormatManager().Value().GetCount(); @@ -528,25 +717,19 @@ } uint32_t -DataVisualization::Categories::GetCurrentRevision() -{ - return GetFormatManager().GetCurrentRevision(); -} - -uint32_t DataVisualization::Categories::GetCount() { return GetFormatManager().Categories().GetCount(); } bool -DataVisualization::NamedSummaryFormats::Get(const ConstString &type, SummaryFormat::SharedPointer &entry) +DataVisualization::NamedSummaryFormats::Get(const ConstString &type, lldb::SummaryFormatSP &entry) { return GetFormatManager().NamedSummary().Get(type,entry); } void -DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const SummaryFormat::SharedPointer &entry) +DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const lldb::SummaryFormatSP &entry) { GetFormatManager().NamedSummary().Add(type,entry); } @@ -570,12 +753,6 @@ } uint32_t -DataVisualization::NamedSummaryFormats::GetCurrentRevision() -{ - return GetFormatManager().GetCurrentRevision(); -} - -uint32_t DataVisualization::NamedSummaryFormats::GetCount() { return GetFormatManager().NamedSummary().GetCount(); Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137944&r1=137943&r2=137944&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Thu Aug 18 11:38:26 2011 @@ -224,13 +224,13 @@ log->Printf("checking for FormatManager revisions. VO named %s is at revision %d, while the format manager is at revision %d", GetName().GetCString(), m_last_format_mgr_revision, - DataVisualization::ValueFormats::GetCurrentRevision()); + DataVisualization::GetCurrentRevision()); if (HasCustomSummaryFormat() && m_update_point.GetModID() != m_user_id_of_forced_summary) { ClearCustomSummaryFormat(); m_summary_str.clear(); } - if ( (m_last_format_mgr_revision != DataVisualization::ValueFormats::GetCurrentRevision()) || + if ( (m_last_format_mgr_revision != DataVisualization::GetCurrentRevision()) || m_last_format_mgr_dynamic != use_dynamic) { if (m_last_summary_format.get()) @@ -246,7 +246,7 @@ DataVisualization::GetSummaryFormat(*this, use_dynamic, m_last_summary_format); DataVisualization::GetSyntheticChildren(*this, use_dynamic, m_last_synthetic_filter); - m_last_format_mgr_revision = DataVisualization::ValueFormats::GetCurrentRevision(); + m_last_format_mgr_revision = DataVisualization::GetCurrentRevision(); m_last_format_mgr_dynamic = use_dynamic; ClearUserVisibleData(); @@ -1029,7 +1029,8 @@ bool ValueObject::DumpPrintableRepresentation(Stream& s, ValueObjectRepresentationStyle val_obj_display, - lldb::Format custom_format) + lldb::Format custom_format, + bool only_special) { clang_type_t elem_or_pointee_type; @@ -1147,6 +1148,10 @@ (custom_format == lldb::eFormatDefault)) // use the [] operator return false; } + + if (only_special) + return false; + bool var_success = GetPrintableRepresentation(s, val_obj_display, custom_format); if (custom_format != eFormatInvalid) SetFormat(eFormatDefault); @@ -1727,7 +1732,8 @@ { const bool is_deref_of_parent = IsDereferenceOfParent (); - if (is_deref_of_parent && epformat == eDereferencePointers) { + if (is_deref_of_parent && epformat == eDereferencePointers) + { // this is the original format of GetExpressionPath() producing code like *(a_ptr).memberName, which is entirely // fine, until you put this into StackFrame::GetValueForVariableExpressionPath() which prefers to see a_ptr->memberName. // the eHonorPointers mode is meant to produce strings in this latter format @@ -1789,7 +1795,8 @@ } } - if (is_deref_of_parent && epformat == eDereferencePointers) { + if (is_deref_of_parent && epformat == eDereferencePointers) + { s.PutChar(')'); } } Modified: lldb/trunk/source/Interpreter/CommandObjectScript.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.cpp?rev=137944&r1=137943&r2=137944&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectScript.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObjectScript.cpp Thu Aug 18 11:38:26 2011 @@ -59,7 +59,8 @@ DataVisualization::ForceUpdate(); // script might change Python code we use for formatting.. make sure we keep up to date with it - if (command == NULL || command[0] == '\0') { + if (command == NULL || command[0] == '\0') + { script_interpreter->ExecuteInterpreterLoop (); result.SetStatus (eReturnStatusSuccessFinishNoResult); return result.Succeeded(); Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py?rev=137944&r1=137943&r2=137944&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py Thu Aug 18 11:38:26 2011 @@ -57,7 +57,7 @@ self.runCmd("type summary add -f \"${var%V}\" SomeData") self.expect("frame variable data", - substrs = ['no printable representation']) + substrs = ['invalid use of aggregate type']) # ${var%s} self.runCmd("type summary add -f \"ptr = ${var%s}\" \"char *\"") @@ -169,12 +169,10 @@ self.runCmd("type summary add -f \"arr = ${var%x}\" \"int [5]\"") self.expect("frame variable intarr", - substrs = ['intarr = {', - '[0] = 1']) + substrs = ['']) self.expect("frame variable other.intarr", - substrs = ['intarr = {', - '[0] = 9']) + substrs = ['']) self.runCmd("type summary add -f \"arr = ${var[]%x}\" \"int [5]\"") Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Makefile?rev=137944&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Makefile (added) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Makefile Thu Aug 18 11:38:26 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py?rev=137944&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py (added) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py Thu Aug 18 11:38:26 2011 @@ -0,0 +1,76 @@ +""" +Test lldb data formatter subsystem. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class DataFormatterTestCase(TestBase): + + # test for rdar://problem/9973865 (If you use "${var}" in the summary string for an aggregate type, the summary doesn't print for a pointer to that type) + mydir = os.path.join("functionalities", "data-formatter", "rdar-9973865") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_run_command(self): + """Test data formatter commands.""" + self.buildDsym() + self.data_formatter_commands() + + def test_with_dwarf_and_run_command(self): + """Test data formatter commands.""" + self.buildDwarf() + self.data_formatter_commands() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break at. + self.line = line_number('main.cpp', '// Set break point at this line.') + + def data_formatter_commands(self): + """Test that that file and class static variables display correctly.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.expect("breakpoint set -f main.cpp -l %d" % self.line, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" % + self.line) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type summary clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var}\" Summarize") + + self.expect('frame variable mine_ptr', + substrs = ['SUMMARY SUCCESS ']) + + self.expect('frame variable *mine_ptr', + substrs = ['SUMMARY SUCCESS ']) + + self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var.first}\" Summarize") + + self.expect('frame variable mine_ptr', + substrs = ['SUMMARY SUCCESS 10']) + + self.expect('frame variable *mine_ptr', + substrs = ['SUMMARY SUCCESS 10']) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973865/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973865/main.cpp?rev=137944&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973865/main.cpp (added) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973865/main.cpp Thu Aug 18 11:38:26 2011 @@ -0,0 +1,30 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +struct Summarize +{ + int first; + int second; +}; + +typedef Summarize summarize_t; +typedef summarize_t *summarize_ptr_t; + +summarize_t global_mine = {30, 40}; + +int +main() +{ + summarize_t mine = {10, 20}; + summarize_ptr_t mine_ptr = &mine; + printf ("Summarize: first: %d second: %d and address: 0x%p\n", mine.first, mine.second, mine_ptr); // Set break point at this line. + printf ("Global summarize: first: %d second: %d.\n", global_mine.first, global_mine.second); + return 0; +} From scallanan at apple.com Thu Aug 18 13:18:33 2011 From: scallanan at apple.com (Sean Callanan) Date: Thu, 18 Aug 2011 18:18:33 -0000 Subject: [Lldb-commits] [lldb] r137965 - in /lldb/trunk: llvm.zip scripts/build-llvm.pl Message-ID: <20110818181833.48E9D2A6C12C@llvm.org> Author: spyffe Date: Thu Aug 18 13:18:33 2011 New Revision: 137965 URL: http://llvm.org/viewvc/llvm-project?rev=137965&view=rev Log: Because of disassembler crashes, I rolled back LLVM to pull in the older ARM disassembler. I also modified our build scripts to support building LLVM from one SVN revision and Clang from another. These are temporary measures; as soon as we get some solid testing in with the new ARM disassembler, we plan to switch right back. Modified: lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=137965&r1=137964&r2=137965&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=137965&r1=137964&r2=137965&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Thu Aug 18 13:18:33 2011 @@ -22,7 +22,9 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "137311"; +our $llvm_revision = "137143"; +our $clang_revision = "137311"; + our $llvm_source_dir = "$ENV{SRCROOT}"; our @archs = split (/\s+/, $ENV{ARCHS}); @@ -139,21 +141,21 @@ sub build_llvm { #my $extra_svn_options = $debug ? "" : "--quiet"; - my $svn_options = "--quiet --revision $llvm_revision"; + my $svn_options = "--quiet"; if (-d "$llvm_source_dir/llvm") { print "Using existing llvm sources in: '$llvm_source_dir/llvm'\n"; # print "Updating llvm to revision $llvm_revision\n"; - # do_command ("cd '$llvm_source_dir/llvm' && svn update $svn_options", "updating llvm from repository", 1); + # do_command ("cd '$llvm_source_dir/llvm' && svn update $svn_options --revision $llvm_revision", "updating llvm from repository", 1); # print "Updating clang to revision $llvm_revision\n"; - # do_command ("cd '$llvm_source_dir/llvm/tools/clang' && svn update $svn_options", "updating clang from repository", 1); + # do_command ("cd '$llvm_source_dir/llvm/tools/clang' && svn update $svn_options --revision $clang_revision", "updating clang from repository", 1); } else { print "Checking out llvm sources from revision $llvm_revision...\n"; - do_command ("cd '$llvm_source_dir' && svn co $svn_options http://llvm.org/svn/llvm-project/llvm/trunk llvm", "checking out llvm from repository", 1); - print "Checking out clang sources from revision $llvm_revision...\n"; - do_command ("cd '$llvm_source_dir/llvm/tools' && svn co $svn_options http://llvm.org/svn/llvm-project/cfe/trunk clang", "checking out clang from repository", 1); + do_command ("cd '$llvm_source_dir' && svn co $svn_options --revision $llvm_revision http://llvm.org/svn/llvm-project/llvm/trunk llvm", "checking out llvm from repository", 1); + print "Checking out clang sources from revision $clang_revision...\n"; + do_command ("cd '$llvm_source_dir/llvm/tools' && svn co $svn_options --revision $clang_revision http://llvm.org/svn/llvm-project/cfe/trunk clang", "checking out clang from repository", 1); print "Removing the llvm/test directory...\n"; do_command ("cd '$llvm_source_dir' && rm -rf llvm/test", "removing test directory", 1); } From filcab+lldb-dev at gmail.com Thu Aug 18 16:13:53 2011 From: filcab+lldb-dev at gmail.com (Filipe Cabecinhas) Date: Thu, 18 Aug 2011 14:13:53 -0700 Subject: [Lldb-commits] Fix and continue implementation Message-ID: Hi, I've implemented part of a fix-and-continue solution for lldb. As of right now, it works if you want to substitute functions from external libraries, by loading an additional copy of that library on the project's address space. The library must have a completely new name from the previously loaded libraries (otherwise, dlopen won't load it). We can make lldb copy the libraries to a temp folder and assign to them unique names, for example, or make the user responsible for that. At least I don't know of other ways to load the "same" library twice in the process. What's still not there: - Dealing with libraries' variables (global, static, etc), even if it's just by copying the old values; - Aborting if too much has changed (this would require some clang integration), like class/struct layouts, etc; - Making it work on ARM (normally we should only need to implement the two ABI functions; - Making sure there is enough space for a trampoline (Right now, the ProcessFix command doesn't check for space); Other features: - Update only some uses of the libraries (like Greg's idea of only changing the GOT of some of the modules). Please let me know what you think of this and maybe provide some feedback. Thanks, Filipe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110818/b2730ea4/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: fix-and-continue.patch Type: application/octet-stream Size: 16957 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110818/b2730ea4/attachment-0001.obj From johnny.chen at apple.com Thu Aug 18 17:04:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 18 Aug 2011 22:04:27 -0000 Subject: [Lldb-commits] [lldb] r137988 - /lldb/trunk/utils/test/lldb-disasm.py Message-ID: <20110818220427.ABA7C2A6C12C@llvm.org> Author: johnny Date: Thu Aug 18 17:04:27 2011 New Revision: 137988 URL: http://llvm.org/viewvc/llvm-project?rev=137988&view=rev Log: Add an option '-q' to have quiet disassembly by not printing out the disassembled result. This could be useful by reducing the strain on standard output. Example: utils/test/lldb-disasm.py -C "platform select remote-ios" -o "-b -n" -e '~/CoreFoundation' -n 50 -q Modified: lldb/trunk/utils/test/lldb-disasm.py Modified: lldb/trunk/utils/test/lldb-disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=137988&r1=137987&r2=137988&view=diff ============================================================================== --- lldb/trunk/utils/test/lldb-disasm.py (original) +++ lldb/trunk/utils/test/lldb-disasm.py Thu Aug 18 17:04:27 2011 @@ -76,7 +76,7 @@ print "run command failed!" print "run_command error:", res.GetError() -def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, symbols_to_disassemble): +def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, symbols_to_disassemble, quiet_disassembly): import lldb, atexit, re # Create the debugger instance now. @@ -115,7 +115,7 @@ return symbol.GetType() == lldb.eSymbolTypeCode # Define a generator for the symbols to disassemble. - def symbol_iter(num, symbols, target): + def symbol_iter(num, symbols, target, verbose): # If we specify the symbols to disassemble, ignore symbol table dump. if symbols: for i in range(len(symbols)): @@ -135,18 +135,20 @@ if IsCodeType(s): if limited: count = count + 1 - print "returning symbol:", s.GetName() + if verbose: + print "returning symbol:", s.GetName() yield s.GetName() - print "start address:", s.GetStartAddress() - print "end address:", s.GetEndAddress() - s.GetDescription(stream) - print "symbol description:", stream.GetData() - stream.Clear() + if verbose: + print "start address:", s.GetStartAddress() + print "end address:", s.GetEndAddress() + s.GetDescription(stream) + print "symbol description:", stream.GetData() + stream.Clear() # Disassembly time. - for symbol in symbol_iter(num_symbols, symbols_to_disassemble, target): + for symbol in symbol_iter(num_symbols, symbols_to_disassemble, target, not quiet_disassembly): cmd = "disassemble %s '%s'" % (disassemble_options, symbol) - run_command(ci, cmd, res) + run_command(ci, cmd, res, True, not quiet_disassembly) def main(): @@ -176,6 +178,10 @@ type='int', action='store', default=-1, dest='num_symbols', help="""The number of symbols to disassemble, if specified.""") + parser.add_option('-q', '--quiet-disassembly', + action='store_true', default=False, + dest='quiet_disassembly', + help="""The symbol(s) to invoke lldb's 'disassemble' command on, if specified.""") parser.add_option('-s', '--symbol', type='string', action='append', metavar='SYMBOL', default=[], dest='symbols_to_disassemble', @@ -192,6 +198,7 @@ executable = opts.executable disassemble_options = opts.disassemble_options num_symbols = opts.num_symbols + quiet_disassembly = opts.quiet_disassembly symbols_to_disassemble = opts.symbols_to_disassemble # We have parsed the options. @@ -199,10 +206,14 @@ print "executable:", executable print "disassemble options:", disassemble_options print "num of symbols to disassemble:", num_symbols + print "quiet disassembly output:", quiet_disassembly print "symbols to disassemble:", symbols_to_disassemble setupSysPath() - do_lldb_disassembly(lldb_commands, executable, disassemble_options, num_symbols, symbols_to_disassemble) + do_lldb_disassembly(lldb_commands, executable, disassemble_options, + num_symbols, + symbols_to_disassemble, + quiet_disassembly) if __name__ == '__main__': main() From johnny.chen at apple.com Thu Aug 18 17:05:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 18 Aug 2011 22:05:58 -0000 Subject: [Lldb-commits] [lldb] r137991 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110818220558.A23CF2A6C12C@llvm.org> Author: johnny Date: Thu Aug 18 17:05:58 2011 New Revision: 137991 URL: http://llvm.org/viewvc/llvm-project?rev=137991&view=rev Log: Apply some workaround for known crashers. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=137991&r1=137990&r2=137991&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Thu Aug 18 17:05:58 2011 @@ -132,6 +132,13 @@ if (!Str.empty() && Str.back() == c) Str = Str.substr(0, Str.size()-1); } +static inline void RStripNumber(llvm::StringRef &Str) +{ + while (!Str.empty() && isnumber(Str.back())) + Str = Str.substr(0, Str.size()-1); + if (!Str.empty() && Str.back() == '-') + Str = Str.substr(0, Str.size()-1); +} // Aligns the raw disassembly (passed as 'str') with the rest of edis'ed disassembly output. // This is called from non-raw mode when edis of the current m_inst fails for some reason. static void @@ -146,6 +153,19 @@ PadString(s, p.second, operandColWidth); } +static bool +apply_workaround(const char *str) +{ + llvm::StringRef Str(str); + StripSpaces(Str); + if (Str.startswith("mov.w")) { + RStripNumber(Str); + if (Str.endswith("#")) + return true; + } + return false; +} + #define AlignPC(pc_val) (pc_val & 0xFFFFFFFC) void InstructionLLVM::Dump @@ -212,7 +232,16 @@ */ /* .... when we fix the edis for arm/thumb. */ - if (!raw) + const char *lookahead; + bool workaround = false; + if (EDGetInstString(&lookahead, m_inst)) // 0 on success + return; + else if (m_arch_type == llvm::Triple::thumb) { + if (apply_workaround(lookahead)) + workaround = true; + } + + if (!raw && !workaround) numTokens = EDNumTokens(m_inst); int currentOpIndex = -1; From johnny.chen at apple.com Thu Aug 18 17:46:50 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 18 Aug 2011 22:46:50 -0000 Subject: [Lldb-commits] [lldb] r138002 - /lldb/trunk/utils/test/lldb-disasm.py Message-ID: <20110818224650.7C6012A6C12C@llvm.org> Author: johnny Date: Thu Aug 18 17:46:50 2011 New Revision: 138002 URL: http://llvm.org/viewvc/llvm-project?rev=138002&view=rev Log: Add an option (-p regexp-pattern) to specify the regular expression symbol pattern we're interested in disassembling. An example: utils/test/lldb-disasm.py -C "platform select remote-ios" -o "-b -n" -e '~/CoreFoundation' -n 20 -p '-\[NSArray .+\]' disassembles the first 20 NSArray instance methods found in the CoreFoundation module. Modified: lldb/trunk/utils/test/lldb-disasm.py Modified: lldb/trunk/utils/test/lldb-disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=138002&r1=138001&r2=138002&view=diff ============================================================================== --- lldb/trunk/utils/test/lldb-disasm.py (original) +++ lldb/trunk/utils/test/lldb-disasm.py Thu Aug 18 17:46:50 2011 @@ -6,6 +6,7 @@ """ import os +import re import sys from optparse import OptionParser @@ -76,7 +77,10 @@ print "run command failed!" print "run_command error:", res.GetError() -def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, symbols_to_disassemble, quiet_disassembly): +def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols, + symbols_to_disassemble, + re_symbol_pattern, + quiet_disassembly): import lldb, atexit, re # Create the debugger instance now. @@ -115,7 +119,7 @@ return symbol.GetType() == lldb.eSymbolTypeCode # Define a generator for the symbols to disassemble. - def symbol_iter(num, symbols, target, verbose): + def symbol_iter(num, symbols, re_symbol_pattern, target, verbose): # If we specify the symbols to disassemble, ignore symbol table dump. if symbols: for i in range(len(symbols)): @@ -125,12 +129,20 @@ limited = True if num != -1 else False if limited: count = 0 + pattern = re.compile(re_symbol_pattern) stream = lldb.SBStream() for m in target.module_iter(): print "module:", m for s in m: if limited and count >= num: return + # If a regexp symbol pattern is supplied, consult it. + if re_symbol_pattern: + # If the pattern does not match, look for the next symbol. + if not pattern.match(s.GetName()): + continue + + # If we come here, we're ready to disassemble the symbol. print "symbol:", s.GetName() if IsCodeType(s): if limited: @@ -146,7 +158,7 @@ stream.Clear() # Disassembly time. - for symbol in symbol_iter(num_symbols, symbols_to_disassemble, target, not quiet_disassembly): + for symbol in symbol_iter(num_symbols, symbols_to_disassemble, re_symbol_pattern, target, not quiet_disassembly): cmd = "disassemble %s '%s'" % (disassemble_options, symbol) run_command(ci, cmd, res, True, not quiet_disassembly) @@ -174,14 +186,18 @@ type='string', action='store', dest='disassemble_options', help="""Mandatory: the options passed to lldb's 'disassemble' command.""") - parser.add_option('-n', '--num-symbols', - type='int', action='store', default=-1, - dest='num_symbols', - help="""The number of symbols to disassemble, if specified.""") parser.add_option('-q', '--quiet-disassembly', action='store_true', default=False, dest='quiet_disassembly', help="""The symbol(s) to invoke lldb's 'disassemble' command on, if specified.""") + parser.add_option('-n', '--num-symbols', + type='int', action='store', default=-1, + dest='num_symbols', + help="""The number of symbols to disassemble, if specified.""") + parser.add_option('-p', '--symbol_pattern', + type='string', action='store', + dest='re_symbol_pattern', + help="""The regular expression of symbols to invoke lldb's 'disassemble' command.""") parser.add_option('-s', '--symbol', type='string', action='append', metavar='SYMBOL', default=[], dest='symbols_to_disassemble', @@ -197,22 +213,25 @@ executable = opts.executable disassemble_options = opts.disassemble_options - num_symbols = opts.num_symbols quiet_disassembly = opts.quiet_disassembly + num_symbols = opts.num_symbols symbols_to_disassemble = opts.symbols_to_disassemble + re_symbol_pattern = opts.re_symbol_pattern # We have parsed the options. print "lldb commands:", lldb_commands print "executable:", executable print "disassemble options:", disassemble_options - print "num of symbols to disassemble:", num_symbols print "quiet disassembly output:", quiet_disassembly + print "num of symbols to disassemble:", num_symbols print "symbols to disassemble:", symbols_to_disassemble + print "regular expression of symbols to disassemble:", re_symbol_pattern setupSysPath() do_lldb_disassembly(lldb_commands, executable, disassemble_options, num_symbols, symbols_to_disassemble, + re_symbol_pattern, quiet_disassembly) if __name__ == '__main__': From johnny.chen at apple.com Thu Aug 18 18:53:03 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 18 Aug 2011 23:53:03 -0000 Subject: [Lldb-commits] [lldb] r138011 - /lldb/trunk/test/lang/c/strings/TestCStrings.py Message-ID: <20110818235303.7868F2A6C12C@llvm.org> Author: johnny Date: Thu Aug 18 18:53:03 2011 New Revision: 138011 URL: http://llvm.org/viewvc/llvm-project?rev=138011&view=rev Log: Add expectedFailure decorator. Failed possibly due to rollback of llvm/clang. Modified: lldb/trunk/test/lang/c/strings/TestCStrings.py Modified: lldb/trunk/test/lang/c/strings/TestCStrings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/strings/TestCStrings.py?rev=138011&r1=138010&r2=138011&view=diff ============================================================================== --- lldb/trunk/test/lang/c/strings/TestCStrings.py (original) +++ lldb/trunk/test/lang/c/strings/TestCStrings.py Thu Aug 18 18:53:03 2011 @@ -8,12 +8,16 @@ mydir = os.path.join("lang", "c", "strings") + # Due to rollback of llvm/clang? + @unittest2.expectedFailure @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Tests that C strings work as expected in expressions""" self.buildDsym() self.static_method_commands() + # Due to rollback of llvm/clang? + @unittest2.expectedFailure def test_with_dwarf_and_run_command(self): """Tests that C strings work as expected in expressions""" self.buildDwarf() From johnny.chen at apple.com Thu Aug 18 19:00:55 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 19 Aug 2011 00:00:55 -0000 Subject: [Lldb-commits] [lldb] r138013 - /lldb/trunk/test/lang/c/strings/TestCStrings.py Message-ID: <20110819000055.E34B32A6C12D@llvm.org> Author: johnny Date: Thu Aug 18 19:00:55 2011 New Revision: 138013 URL: http://llvm.org/viewvc/llvm-project?rev=138013&view=rev Log: Revert the previous addition of expectedFailure decorators, it was a mistake. Modified: lldb/trunk/test/lang/c/strings/TestCStrings.py Modified: lldb/trunk/test/lang/c/strings/TestCStrings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/strings/TestCStrings.py?rev=138013&r1=138012&r2=138013&view=diff ============================================================================== --- lldb/trunk/test/lang/c/strings/TestCStrings.py (original) +++ lldb/trunk/test/lang/c/strings/TestCStrings.py Thu Aug 18 19:00:55 2011 @@ -8,16 +8,12 @@ mydir = os.path.join("lang", "c", "strings") - # Due to rollback of llvm/clang? - @unittest2.expectedFailure @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Tests that C strings work as expected in expressions""" self.buildDsym() self.static_method_commands() - # Due to rollback of llvm/clang? - @unittest2.expectedFailure def test_with_dwarf_and_run_command(self): """Tests that C strings work as expected in expressions""" self.buildDwarf() From johnny.chen at apple.com Thu Aug 18 19:54:28 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 19 Aug 2011 00:54:28 -0000 Subject: [Lldb-commits] [lldb] r138019 - in /lldb/trunk/test: lldbtest.py python_api/thread/TestThreadAPI.py Message-ID: <20110819005428.188A62A6C12C@llvm.org> Author: johnny Date: Thu Aug 18 19:54:27 2011 New Revision: 138019 URL: http://llvm.org/viewvc/llvm-project?rev=138019&view=rev Log: Add a decorator for marking clang only expectedFailure. Use it for the test_step_over_3_times_with_dsym/dwarf() test cases in TestThreadAPI.py by decorating it with @expectedFailureClang. Example: @expectedFailureClang @python_api_test def test_step_over_3_times_with_dwarf(self): """Test Python SBThread.StepOver() API.""" # We build a different executable than the default buildDwarf() does. d = {'CXX_SOURCES': 'main2.cpp', 'EXE': self.exe_name} self.buildDwarf(dictionary=d) self.setTearDownCleanup(dictionary=d) self.step_over_3_times(self.exe_name) Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/python_api/thread/TestThreadAPI.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=138019&r1=138018&r2=138019&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Aug 18 19:54:27 2011 @@ -351,7 +351,6 @@ wrapper.__python_api_test__ = True return wrapper -from functools import wraps def benchmarks_test(func): """Decorate the item as a benchmarks test.""" if isinstance(func, type) and issubclass(func, unittest2.TestCase): @@ -369,6 +368,27 @@ wrapper.__benchmarks_test__ = True return wrapper +def expectedFailureClang(func): + """Decorate the item as a Clang only expectedFailure.""" + if isinstance(func, type) and issubclass(func, unittest2.TestCase): + raise Exception("@expectedFailureClang can only be used to decorate a test method") + @wraps(func) + def wrapper(*args, **kwargs): + from unittest2 import case + self = args[0] + compiler = self.getCompiler() + try: + func(*args, **kwargs) + except Exception, e: + if "clang" in compiler: + raise case._ExpectedFailure(sys.exc_info()) + else: + raise e + + if "clang" in compiler: + raise case._UnexpectedSuccess + return wrapper + class Base(unittest2.TestCase): """ Abstract base for performing lldb (see TestBase) or other generic tests (see Modified: lldb/trunk/test/python_api/thread/TestThreadAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/thread/TestThreadAPI.py?rev=138019&r1=138018&r2=138019&view=diff ============================================================================== --- lldb/trunk/test/python_api/thread/TestThreadAPI.py (original) +++ lldb/trunk/test/python_api/thread/TestThreadAPI.py Thu Aug 18 19:54:27 2011 @@ -77,6 +77,7 @@ self.step_out_of_malloc_into_function_b(self.exe_name) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @expectedFailureClang @python_api_test def test_step_over_3_times_with_dsym(self): """Test Python SBThread.StepOver() API.""" @@ -86,6 +87,7 @@ self.setTearDownCleanup(dictionary=d) self.step_over_3_times(self.exe_name) + @expectedFailureClang @python_api_test def test_step_over_3_times_with_dwarf(self): """Test Python SBThread.StepOver() API.""" @@ -221,6 +223,8 @@ frame0 = thread.GetFrameAtIndex(0) lineEntry = frame0.GetLineEntry() self.assertTrue(thread.GetStopReason() == lldb.eStopReasonPlanComplete) + # Expected failure with clang as the compiler. + # rdar://problem/9223880 self.assertTrue(lineEntry.GetLine() == self.after_3_step_overs) def run_to_address(self, exe_name): From granata.enrico at gmail.com Thu Aug 18 20:14:49 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 19 Aug 2011 01:14:49 -0000 Subject: [Lldb-commits] [lldb] r138020 - in /lldb/trunk: include/lldb/Core/FormatManager.h include/lldb/Core/ValueObject.h include/lldb/Interpreter/ScriptInterpreter.h source/Commands/CommandObjectType.cpp source/Commands/CommandObjectType.h source/Core/FormatManager.cpp source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Message-ID: <20110819011449.EF8C02A6C12C@llvm.org> Author: enrico Date: Thu Aug 18 20:14:49 2011 New Revision: 138020 URL: http://llvm.org/viewvc/llvm-project?rev=138020&view=rev Log: Third round of code cleanups: - reorganizing the PTS (Partial Template Specializations) in FormatManager.h - applied a patch by Filipe Cabecinhas to make LLDB compile with GCC Functional changes: - fixed an issue where command type summary add for type "struct Foo" would not match any types. currently, "struct" will be stripped off and type "Foo" will be matched. similar behavior occurs for class, enum and union specifiers. Modified: lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Commands/CommandObjectType.h lldb/trunk/source/Core/FormatManager.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=138020&r1=138019&r2=138020&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Thu Aug 18 20:14:49 2011 @@ -79,6 +79,35 @@ }; +// if the user tries to add formatters for, say, "struct Foo" +// those will not match any type because of the way we strip qualifiers from typenames +// this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo +// and strips the unnecessary qualifier +static ConstString +GetValidTypeName_Impl(const ConstString& type) +{ + int strip_len = 0; + + if (type == false) + return type; + + const char* type_cstr = type.AsCString(); + + if ( ::strstr(type_cstr, "class ") == type_cstr) + strip_len = 6; + if ( ::strstr(type_cstr, "enum ") == type_cstr) + strip_len = 5; + if ( ::strstr(type_cstr, "struct ") == type_cstr) + strip_len = 7; + if ( ::strstr(type_cstr, "union ") == type_cstr) + strip_len = 6; + + if (strip_len == 0) + return type; + + return ConstString(type_cstr + strip_len); +} + template class FormatNavigator; @@ -170,7 +199,7 @@ return m_map.size(); } -private: +protected: MapType m_map; Mutex m_map_mutex; IFormatChangeListener* listener; @@ -195,20 +224,19 @@ template class FormatNavigator { -private: +protected: typedef FormatMap BackEndType; - BackEndType m_format_map; - - std::string m_name; - + template + struct Types { }; + public: typedef typename BackEndType::MapType MapType; typedef typename MapType::iterator MapIterator; typedef typename MapType::key_type MapKeyType; typedef typename MapType::mapped_type MapValueType; typedef typename BackEndType::CallbackType CallbackType; - + typedef typename lldb::SharedPtr >::Type SharedPointer; friend class FormatCategory; @@ -224,15 +252,13 @@ void Add (const MapKeyType &type, const MapValueType& entry) { - m_format_map.Add(type,entry); + Add_Impl(type, entry, Types()); } - // using ConstString instead of MapKeyType is necessary here - // to make the partial template specializations below work bool Delete (ConstString type) { - return m_format_map.Delete(type); + return Delete_Impl(type, Types()); } bool @@ -270,19 +296,88 @@ { return m_format_map.GetCount(); } + +protected: -private: + BackEndType m_format_map; + + std::string m_name; DISALLOW_COPY_AND_ASSIGN(FormatNavigator); ConstString m_id_cs; - - // using ConstString instead of MapKeyType is necessary here - // to make the partial template specializations below work + + template + void + Add_Impl (const MapKeyType &type, const MapValueType& entry, Types) + { + m_format_map.Add(type,entry); + } + + template + void Add_Impl (const ConstString &type, const MapValueType& entry, Types) + { + m_format_map.Add(GetValidTypeName_Impl(type), entry); + } + + template + bool + Delete_Impl (ConstString type, Types) + { + return m_format_map.Delete(type); + } + + template + bool + Delete_Impl (ConstString type, Types) + { + Mutex& x_mutex = m_format_map.mutex(); + lldb_private::Mutex::Locker locker(x_mutex); + MapIterator pos, end = m_format_map.map().end(); + for (pos = m_format_map.map().begin(); pos != end; pos++) + { + lldb::RegularExpressionSP regex = pos->first; + if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) + { + m_format_map.map().erase(pos); + if (m_format_map.listener) + m_format_map.listener->Changed(); + return true; + } + } + return false; + } + + template + bool + Get_Impl (ConstString type, MapValueType& entry, Types) + { + return m_format_map.Get(type, entry); + } + + template + bool + Get_Impl (ConstString key, MapValueType& value, Types) + { + Mutex& x_mutex = m_format_map.mutex(); + lldb_private::Mutex::Locker locker(x_mutex); + MapIterator pos, end = m_format_map.map().end(); + for (pos = m_format_map.map().begin(); pos != end; pos++) + { + lldb::RegularExpressionSP regex = pos->first; + if (regex->Execute(key.AsCString())) + { + value = pos->second; + return true; + } + } + return false; + } + bool Get (ConstString type, MapValueType& entry) { - return m_format_map.Get(type, entry); + return Get_Impl(type, entry, Types()); } bool Get_ObjC(ValueObject& valobj, @@ -577,30 +672,6 @@ return false; } }; - -template<> -bool -FormatNavigator::Get(ConstString key, lldb::SummaryFormatSP& value); - -template<> -bool -FormatNavigator::Delete(ConstString type); - -template<> -bool -FormatNavigator::Get(ConstString key, SyntheticFilter::SharedPointer& value); - -template<> -bool -FormatNavigator::Delete(ConstString type); - -template<> -bool -FormatNavigator::Get(ConstString key, SyntheticFilter::SharedPointer& value); - -template<> -bool -FormatNavigator::Delete(ConstString type); class CategoryMap; @@ -633,7 +704,7 @@ eFilter = 0x0002, eRegexFilter = 0x1002, eSynth = 0x0004, - eRegexSynth = 0x1004, + eRegexSynth = 0x1004 }; typedef uint16_t FormatCategoryItems; @@ -1166,6 +1237,13 @@ static const char * GetFormatAsCString (lldb::Format format); + // if the user tries to add formatters for, say, "struct Foo" + // those will not match any type because of the way we strip qualifiers from typenames + // this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo + // and strips the unnecessary qualifier + static ConstString + GetValidTypeName (const ConstString& type); + // when DataExtractor dumps a vectorOfT, it uses a predefined format for each item // this method returns it, or eFormatInvalid if vector_format is not a vectorOf static lldb::Format Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=138020&r1=138019&r2=138020&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Aug 18 20:14:49 2011 @@ -79,7 +79,7 @@ eDisplaySummary, eDisplayLanguageSpecific, eDisplayLocation, - eDisplayChildrenCount, + eDisplayChildrenCount }; enum ExpressionPathScanEndReason Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=138020&r1=138019&r2=138020&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Thu Aug 18 20:14:49 2011 @@ -66,7 +66,7 @@ eFloat, eDouble, eChar, - eCharStrOrNone, + eCharStrOrNone } ReturnType; Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=138020&r1=138019&r2=138020&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Thu Aug 18 20:14:49 2011 @@ -3366,7 +3366,7 @@ enum FilterFormatType { eRegularFilter, - eRegexFilter, + eRegexFilter }; bool Modified: lldb/trunk/source/Commands/CommandObjectType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.h?rev=138020&r1=138019&r2=138020&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.h (original) +++ lldb/trunk/source/Commands/CommandObjectType.h Thu Aug 18 20:14:49 2011 @@ -187,7 +187,7 @@ { eRegularSummary, eRegexSummary, - eNamedSummary, + eNamedSummary }; CommandObjectTypeSummaryAdd (CommandInterpreter &interpreter); @@ -330,7 +330,7 @@ enum SynthFormatType { eRegularSynth, - eRegexSynth, + eRegexSynth }; CommandObjectTypeSynthAdd (CommandInterpreter &interpreter); Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=138020&r1=138019&r2=138020&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Thu Aug 18 20:14:49 2011 @@ -154,120 +154,6 @@ return NULL; } -template<> -bool -FormatNavigator::Get(ConstString key, lldb::SummaryFormatSP& value) -{ - Mutex::Locker(m_format_map.mutex()); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) - { - lldb::RegularExpressionSP regex = pos->first; - if (regex->Execute(key.AsCString())) - { - value = pos->second; - return true; - } - } - return false; -} - -template<> -bool -FormatNavigator::Delete(ConstString type) -{ - Mutex::Locker(m_format_map.mutex()); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) - { - lldb::RegularExpressionSP regex = pos->first; - if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) - { - m_format_map.map().erase(pos); - if (m_format_map.listener) - m_format_map.listener->Changed(); - return true; - } - } - return false; -} - -template<> -bool -FormatNavigator::Get(ConstString key, SyntheticFilter::SharedPointer& value) -{ - Mutex::Locker(m_format_map.mutex()); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) - { - lldb::RegularExpressionSP regex = pos->first; - if (regex->Execute(key.AsCString())) - { - value = pos->second; - return true; - } - } - return false; -} - -template<> -bool -FormatNavigator::Delete(ConstString type) -{ - Mutex::Locker(m_format_map.mutex()); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) - { - lldb::RegularExpressionSP regex = pos->first; - if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) - { - m_format_map.map().erase(pos); - if (m_format_map.listener) - m_format_map.listener->Changed(); - return true; - } - } - return false; -} - -template<> -bool -FormatNavigator::Get(ConstString key, SyntheticFilter::SharedPointer& value) -{ - Mutex::Locker(m_format_map.mutex()); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) - { - lldb::RegularExpressionSP regex = pos->first; - if (regex->Execute(key.AsCString())) - { - value = pos->second; - return true; - } - } - return false; -} - -template<> -bool -FormatNavigator::Delete(ConstString type) -{ - Mutex::Locker(m_format_map.mutex()); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) - { - lldb::RegularExpressionSP regex = pos->first; - if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) - { - m_format_map.map().erase(pos); - if (m_format_map.listener) - m_format_map.listener->Changed(); - return true; - } - } - return false; -} - FormatCategory::FormatCategory(IFormatChangeListener* clist, std::string name) : m_summary_nav(new SummaryNavigator("summary",clist)), @@ -486,6 +372,12 @@ } } +ConstString +FormatManager::GetValidTypeName (const ConstString& type) +{ + return ::GetValidTypeName_Impl(type); +} + FormatManager::FormatManager() : m_value_nav("format",this), m_named_summaries_map(this), @@ -574,7 +466,6 @@ } - static FormatManager& GetFormatManager() { @@ -603,7 +494,7 @@ void DataVisualization::ValueFormats::Add(const ConstString &type, const lldb::ValueFormatSP &entry) { - GetFormatManager().Value().Add(type,entry); + GetFormatManager().Value().Add(FormatManager::GetValidTypeName(type),entry); } bool @@ -731,7 +622,7 @@ void DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const lldb::SummaryFormatSP &entry) { - GetFormatManager().NamedSummary().Add(type,entry); + GetFormatManager().NamedSummary().Add(FormatManager::GetValidTypeName(type),entry); } bool Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h?rev=138020&r1=138019&r2=138020&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h Thu Aug 18 20:14:49 2011 @@ -62,12 +62,12 @@ KDP_WRITEMEM64, KDP_BREAKPOINT_SET64, KDP_BREAKPOINT_REMOVE64, - KDP_KERNELVERSION, + KDP_KERNELVERSION } CommandType; enum { - KDP_FEATURE_BP = (1u << 0), + KDP_FEATURE_BP = (1u << 0) }; typedef enum Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp?rev=138020&r1=138019&r2=138020&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp Thu Aug 18 20:14:49 2011 @@ -98,7 +98,7 @@ fpu_fiseg = fpu_cs, fpu_fioff = fpu_ip, fpu_foseg = fpu_ds, - fpu_fooff = fpu_dp, + fpu_fooff = fpu_dp }; enum gcc_dwarf_regnums @@ -143,7 +143,7 @@ gcc_dwarf_fpu_stmm4, gcc_dwarf_fpu_stmm5, gcc_dwarf_fpu_stmm6, - gcc_dwarf_fpu_stmm7, + gcc_dwarf_fpu_stmm7 }; @@ -205,7 +205,7 @@ gdb_fpu_xmm13 = 53, gdb_fpu_xmm14 = 54, gdb_fpu_xmm15 = 55, - gdb_fpu_mxcsr = 56, + gdb_fpu_mxcsr = 56 }; RegisterContextDarwin_x86_64::RegisterContextDarwin_x86_64 (Thread &thread, uint32_t concrete_frame_idx) : Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py?rev=138020&r1=138019&r2=138020&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Thu Aug 18 20:14:49 2011 @@ -202,6 +202,34 @@ self.expect("frame variable the_coolest_guy", substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + # check that unwanted type specifiers are removed + self.runCmd("type summary delete i_am_cool") + self.runCmd("type summary add -f \"goofy\" \"class i_am_cool\"") + self.expect("frame variable the_coolest_guy", + substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + + self.runCmd("type summary delete i_am_cool") + self.runCmd("type summary add -f \"goofy\" \"enum i_am_cool\"") + self.expect("frame variable the_coolest_guy", + substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + + self.runCmd("type summary delete i_am_cool") + self.runCmd("type summary add -f \"goofy\" \"struct i_am_cool\"") + self.expect("frame variable the_coolest_guy", + substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + + self.runCmd("type summary delete i_am_cool") + self.runCmd("type summary add -f \"goofy\" \"union i_am_cool\"") + self.expect("frame variable the_coolest_guy", + substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + + # but that not *every* specifier is removed + self.runCmd("type summary delete i_am_cool") + self.runCmd("type summary add -f \"goofy\" \"wrong i_am_cool\"") + self.expect("frame variable the_coolest_guy", matching=False, + substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + + if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() From johnny.chen at apple.com Thu Aug 18 20:17:09 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 19 Aug 2011 01:17:09 -0000 Subject: [Lldb-commits] [lldb] r138021 - /lldb/trunk/test/lldbtest.py Message-ID: <20110819011709.644382A6C12C@llvm.org> Author: johnny Date: Thu Aug 18 20:17:09 2011 New Revision: 138021 URL: http://llvm.org/viewvc/llvm-project?rev=138021&view=rev Log: Minor change for the @expectedFailureClang logic. For the non-clang test failure, re-raise the exception to get more stack trace information. 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=138021&r1=138020&r2=138021&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Aug 18 20:17:09 2011 @@ -379,11 +379,11 @@ compiler = self.getCompiler() try: func(*args, **kwargs) - except Exception, e: + except Exception: if "clang" in compiler: raise case._ExpectedFailure(sys.exc_info()) else: - raise e + raise if "clang" in compiler: raise case._UnexpectedSuccess From granata.enrico at gmail.com Thu Aug 18 20:47:11 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 19 Aug 2011 01:47:11 -0000 Subject: [Lldb-commits] [lldb] r138026 - in /lldb/trunk: include/lldb/Core/FormatManager.h test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Message-ID: <20110819014711.486372A6C12C@llvm.org> Author: enrico Date: Thu Aug 18 20:47:11 2011 New Revision: 138026 URL: http://llvm.org/viewvc/llvm-project?rev=138026&view=rev Log: More thorough fix for the spaces-in-typename issue Modified: lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=138026&r1=138025&r2=138026&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Thu Aug 18 20:47:11 2011 @@ -79,12 +79,24 @@ }; +static inline bool +IsWhitespace (char c) +{ + return ( (c == ' ') || (c == '\t') || (c == '\v') || (c == '\f') ); +} + +static inline bool +HasPrefix (const char* str1, const char* str2) +{ + return ( ::strstr(str1, str2) == str1 ); +} + // if the user tries to add formatters for, say, "struct Foo" // those will not match any type because of the way we strip qualifiers from typenames // this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo // and strips the unnecessary qualifier static ConstString -GetValidTypeName_Impl(const ConstString& type) +GetValidTypeName_Impl (const ConstString& type) { int strip_len = 0; @@ -93,19 +105,23 @@ const char* type_cstr = type.AsCString(); - if ( ::strstr(type_cstr, "class ") == type_cstr) + if ( HasPrefix(type_cstr, "class ") ) strip_len = 6; - if ( ::strstr(type_cstr, "enum ") == type_cstr) + else if ( HasPrefix(type_cstr, "enum ") ) strip_len = 5; - if ( ::strstr(type_cstr, "struct ") == type_cstr) + else if ( HasPrefix(type_cstr, "struct ") ) strip_len = 7; - if ( ::strstr(type_cstr, "union ") == type_cstr) + else if ( HasPrefix(type_cstr, "union ") ) strip_len = 6; if (strip_len == 0) return type; - return ConstString(type_cstr + strip_len); + type_cstr += strip_len; + while (IsWhitespace(*type_cstr) && ++type_cstr) + ; + + return ConstString(type_cstr); } template Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py?rev=138026&r1=138025&r2=138026&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Thu Aug 18 20:47:11 2011 @@ -218,8 +218,9 @@ self.expect("frame variable the_coolest_guy", substrs = ['(i_am_cooler) the_coolest_guy = goofy']) + # many spaces, but we still do the right thing self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add -f \"goofy\" \"union i_am_cool\"") + self.runCmd("type summary add -f \"goofy\" \"union i_am_cool\"") self.expect("frame variable the_coolest_guy", substrs = ['(i_am_cooler) the_coolest_guy = goofy']) From scallanan at apple.com Fri Aug 19 01:19:26 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 19 Aug 2011 06:19:26 -0000 Subject: [Lldb-commits] [lldb] r138036 - in /lldb/trunk: lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme llvm.zip scripts/build-llvm.pl scripts/llvm.isreg.diff source/Symbol/ClangASTContext.cpp test/lang/c/function_types/TestFunctionTypes.py Message-ID: <20110819061926.1C58C2A6C12C@llvm.org> Author: spyffe Date: Fri Aug 19 01:19:25 2011 New Revision: 138036 URL: http://llvm.org/viewvc/llvm-project?rev=138036&view=rev Log: Refined the rollback to LLVM, picking up a newer revision and adding a patch that fixes an AsmParser crash on ARM. One feature that we unfortunately lost (for the moment!) is the ability to cast unknown code symbols to arbitrary function types and put the resulting function pointer in a result variable. This feature will be back, though. Added: lldb/trunk/scripts/llvm.isreg.diff Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py 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=138036&r1=138035&r2=138036&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Fri Aug 19 01:19:25 2011 @@ -1,6 +1,6 @@ + version = "1.3"> @@ -28,6 +28,15 @@ buildConfiguration = "Debug"> + + + + + debugDocumentVersioning = "YES" + allowLocationSimulation = "YES"> + ignoresPersistentStateOnLaunch = "YES" + debugDocumentVersioning = "YES"> 4 && + !static_cast(Operands[4])->isARMSOImm() && + static_cast(Operands[4])->isImm0_65535Expr() && ++ static_cast(Operands[1])->isReg() && + static_cast(Operands[1])->getReg() == 0) { + ARMOperand *Op = static_cast(Operands[1]); + Operands.erase(Operands.begin() + 1); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=138036&r1=138035&r2=138036&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Aug 19 01:19:25 2011 @@ -4960,12 +4960,12 @@ clang::DeclContext * ClangASTContext::GetAsDeclContext (clang::CXXMethodDecl *cxx_method_decl) { - return clang::dyn_cast(cxx_method_decl); + return llvm::dyn_cast(cxx_method_decl); } clang::DeclContext * ClangASTContext::GetAsDeclContext (clang::ObjCMethodDecl *objc_method_decl) { - return clang::dyn_cast(objc_method_decl); + return llvm::dyn_cast(objc_method_decl); } Modified: lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py?rev=138036&r1=138035&r2=138036&view=diff ============================================================================== --- lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py (original) +++ lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py Fri Aug 19 01:19:25 2011 @@ -24,12 +24,12 @@ def test_pointers_with_dsym(self): """Test that a function pointer to 'printf' works and can be called.""" self.buildDsym() - self.function_pointers() + #self.function_pointers() # ROLLED BACK def test_pointers_with_dwarf(self): """Test that a function pointer to 'printf' works and can be called.""" self.buildDwarf() - self.function_pointers() + #self.function_pointers() # ROLLED BACK def setUp(self): # Call super's setUp(). From scallanan at apple.com Fri Aug 19 12:18:31 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 19 Aug 2011 17:18:31 -0000 Subject: [Lldb-commits] [lldb] r138044 - /lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Message-ID: <20110819171832.016942A6C12C@llvm.org> Author: spyffe Date: Fri Aug 19 12:18:31 2011 New Revision: 138044 URL: http://llvm.org/viewvc/llvm-project?rev=138044&view=rev Log: Whoops, accidentally committed my local scheme. 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=138044&r1=138043&r2=138044&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Fri Aug 19 12:18:31 2011 @@ -1,6 +1,6 @@ + version = "1.8"> @@ -28,15 +28,6 @@ buildConfiguration = "Debug"> - - - - + enablesOpenGLESFrameCapture = "YES"> + ignoresPersistentStateOnLaunch = "YES"> Author: johnny Date: Fri Aug 19 12:28:25 2011 New Revision: 138045 URL: http://llvm.org/viewvc/llvm-project?rev=138045&view=rev Log: Fix TypeError exception for re.compile(). Modified: lldb/trunk/utils/test/lldb-disasm.py Modified: lldb/trunk/utils/test/lldb-disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=138045&r1=138044&r2=138045&view=diff ============================================================================== --- lldb/trunk/utils/test/lldb-disasm.py (original) +++ lldb/trunk/utils/test/lldb-disasm.py Fri Aug 19 12:28:25 2011 @@ -129,7 +129,8 @@ limited = True if num != -1 else False if limited: count = 0 - pattern = re.compile(re_symbol_pattern) + if re_symbol_pattern: + pattern = re.compile(re_symbol_pattern) stream = lldb.SBStream() for m in target.module_iter(): print "module:", m From johnny.chen at apple.com Fri Aug 19 12:31:59 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 19 Aug 2011 17:31:59 -0000 Subject: [Lldb-commits] [lldb] r138046 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110819173159.767DD2A6C12C@llvm.org> Author: johnny Date: Fri Aug 19 12:31:59 2011 New Revision: 138046 URL: http://llvm.org/viewvc/llvm-project?rev=138046&view=rev Log: Revert the workaround patch in the last check in. With the local patch to LLVM, it is no longer necessary. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=138046&r1=138045&r2=138046&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Fri Aug 19 12:31:59 2011 @@ -132,13 +132,6 @@ if (!Str.empty() && Str.back() == c) Str = Str.substr(0, Str.size()-1); } -static inline void RStripNumber(llvm::StringRef &Str) -{ - while (!Str.empty() && isnumber(Str.back())) - Str = Str.substr(0, Str.size()-1); - if (!Str.empty() && Str.back() == '-') - Str = Str.substr(0, Str.size()-1); -} // Aligns the raw disassembly (passed as 'str') with the rest of edis'ed disassembly output. // This is called from non-raw mode when edis of the current m_inst fails for some reason. static void @@ -153,19 +146,6 @@ PadString(s, p.second, operandColWidth); } -static bool -apply_workaround(const char *str) -{ - llvm::StringRef Str(str); - StripSpaces(Str); - if (Str.startswith("mov.w")) { - RStripNumber(Str); - if (Str.endswith("#")) - return true; - } - return false; -} - #define AlignPC(pc_val) (pc_val & 0xFFFFFFFC) void InstructionLLVM::Dump @@ -232,16 +212,7 @@ */ /* .... when we fix the edis for arm/thumb. */ - const char *lookahead; - bool workaround = false; - if (EDGetInstString(&lookahead, m_inst)) // 0 on success - return; - else if (m_arch_type == llvm::Triple::thumb) { - if (apply_workaround(lookahead)) - workaround = true; - } - - if (!raw && !workaround) + if (!raw) numTokens = EDNumTokens(m_inst); int currentOpIndex = -1; From johnso87 at crhc.illinois.edu Fri Aug 19 14:14:43 2011 From: johnso87 at crhc.illinois.edu (Matt Johnson) Date: Fri, 19 Aug 2011 14:14:43 -0500 Subject: [Lldb-commits] [PATCH] Use isdigit() instead of isnumber(), include cctype Message-ID: <4E4EB623.4050104@crhc.illinois.edu> DisassemblerLLVM.cpp uses isnumber() to discern whether a character is a decimal digit. isnumber() is found in BSD and OS X headers, but is not part of the C standard. isdigit() is the standardized counterpart; I haven't been able to find clear information on what the precise difference is between the two, but my feeling is that we can replace isnumber() with isdigit() with no change in functionality. The attached patch does so, and includes cctype to make the provenance of the function explicit. -Matt -------------- next part -------------- A non-text attachment was scrubbed... Name: isdigit.diff Type: text/x-diff Size: 739 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110819/9c39b261/attachment.bin From johnso87 at crhc.illinois.edu Fri Aug 19 14:15:03 2011 From: johnso87 at crhc.illinois.edu (Matt Johnson) Date: Fri, 19 Aug 2011 14:15:03 -0500 Subject: [Lldb-commits] [PATCH] Use isdigit() instead of isnumber(), include cctype Message-ID: <4E4EB637.2070101@crhc.illinois.edu> DisassemblerLLVM.cpp uses isnumber() to discern whether a character is a decimal digit. isnumber() is found in BSD and OS X headers, but is not part of the C standard. isdigit() is the standardized counterpart; I haven't been able to find clear information on what the precise difference is between the two, but my feeling is that we can replace isnumber() with isdigit() with no change in functionality. The attached patch does so, and includes cctype to make the provenance of the function explicit. The practical effect of the patch is to unbreak the build on Linux. -Matt -------------- next part -------------- A non-text attachment was scrubbed... Name: isdigit.diff Type: text/x-diff Size: 739 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110819/779742ee/attachment.bin From johnny.chen at apple.com Fri Aug 19 15:33:42 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 19 Aug 2011 13:33:42 -0700 Subject: [Lldb-commits] [PATCH] Use isdigit() instead of isnumber(), include cctype In-Reply-To: <4E4EB637.2070101@crhc.illinois.edu> References: <4E4EB637.2070101@crhc.illinois.edu> Message-ID: <3F8CB917-B7B8-432A-A694-F30DCE6C249C@apple.com> Hi Matt, The workaround which calls isnumber() has been reverted and the isnumber() calls are gone. Thanks! Johnny On Aug 19, 2011, at 12:15 PM, Matt Johnson wrote: > DisassemblerLLVM.cpp uses isnumber() to discern whether a character is a decimal digit. isnumber() is found in BSD and OS X headers, but is not part of the C standard. isdigit() is the standardized counterpart; I haven't been able to find clear information on what the precise difference is between the two, but my feeling is that we can replace isnumber() with isdigit() with no change in functionality. The attached patch does so, and includes cctype to make the provenance of the function explicit. > > The practical effect of the patch is to unbreak the build on Linux. > > -Matt > _______________________________________________ > 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 Aug 19 15:51:15 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 19 Aug 2011 20:51:15 -0000 Subject: [Lldb-commits] [lldb] r138078 - in /lldb/trunk/utils/test: lldb-disasm.py run-dis.py Message-ID: <20110819205115.E3B8F2A6C12C@llvm.org> Author: johnny Date: Fri Aug 19 15:51:15 2011 New Revision: 138078 URL: http://llvm.org/viewvc/llvm-project?rev=138078&view=rev Log: Add a Python script to locate each binary file under a root directory which matches some pathname pattern and to invoke lldb-disasm.py on the binary file to disassemble its symbols. The number of symbols can be specified by, for example, '-n 10000', to specify 10,000 symbols to disassemble for each module. By default, only 1000 symbols from each module are disassembled. Example: utils/test/run-dis.py -r '/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3/Symbols' -p '^/System/Library/.*Frameworks/.*\.framework/[^/]+$' tries to disassemble every public/private frameworks (by default only 1000 symbols are disassembled) under iOS4.3. Added: lldb/trunk/utils/test/run-dis.py (with props) Modified: lldb/trunk/utils/test/lldb-disasm.py Modified: lldb/trunk/utils/test/lldb-disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=138078&r1=138077&r2=138078&view=diff ============================================================================== --- lldb/trunk/utils/test/lldb-disasm.py (original) +++ lldb/trunk/utils/test/lldb-disasm.py Fri Aug 19 15:51:15 2011 @@ -62,18 +62,18 @@ # This is to locate the lldb.py module. Insert it right after sys.path[0]. sys.path[1:1] = [lldbPath] - print "sys.path:", sys.path + #print "sys.path:", sys.path -def run_command(ci, cmd, res, echoInput=True, echoOutput=True): - if echoInput: +def run_command(ci, cmd, res, echo=True): + if echo: print "run command:", cmd ci.HandleCommand(cmd, res) if res.Succeeded(): - if echoOutput: + if echo: print "run_command output:", res.GetOutput() else: - if echoOutput: + if echo: print "run command failed!" print "run_command error:", res.GetError() @@ -104,10 +104,10 @@ # See if there any extra command(s) to execute before we issue the file command. for cmd in lldb_commands: - run_command(ci, cmd, res) + run_command(ci, cmd, res, not quiet_disassembly) # Now issue the file command. - run_command(ci, 'file %s' % exe, res) + run_command(ci, 'file %s' % exe, res, not quiet_disassembly) # Create a target. #target = dbg.CreateTarget(exe) @@ -123,7 +123,8 @@ # If we specify the symbols to disassemble, ignore symbol table dump. if symbols: for i in range(len(symbols)): - print "symbol:", symbols[i] + if verbose: + print "symbol:", symbols[i] yield symbols[i] else: limited = True if num != -1 else False @@ -133,7 +134,8 @@ pattern = re.compile(re_symbol_pattern) stream = lldb.SBStream() for m in target.module_iter(): - print "module:", m + if verbose: + print "module:", m for s in m: if limited and count >= num: return @@ -144,7 +146,8 @@ continue # If we come here, we're ready to disassemble the symbol. - print "symbol:", s.GetName() + if verbose: + print "symbol:", s.GetName() if IsCodeType(s): if limited: count = count + 1 @@ -161,7 +164,7 @@ # Disassembly time. for symbol in symbol_iter(num_symbols, symbols_to_disassemble, re_symbol_pattern, target, not quiet_disassembly): cmd = "disassemble %s '%s'" % (disassemble_options, symbol) - run_command(ci, cmd, res, True, not quiet_disassembly) + run_command(ci, cmd, res, not quiet_disassembly) def main(): @@ -220,13 +223,14 @@ re_symbol_pattern = opts.re_symbol_pattern # We have parsed the options. - print "lldb commands:", lldb_commands - print "executable:", executable - print "disassemble options:", disassemble_options - print "quiet disassembly output:", quiet_disassembly - print "num of symbols to disassemble:", num_symbols - print "symbols to disassemble:", symbols_to_disassemble - print "regular expression of symbols to disassemble:", re_symbol_pattern + if not quiet_disassembly: + print "lldb commands:", lldb_commands + print "executable:", executable + print "disassemble options:", disassemble_options + print "quiet disassembly output:", quiet_disassembly + print "num of symbols to disassemble:", num_symbols + print "symbols to disassemble:", symbols_to_disassemble + print "regular expression of symbols to disassemble:", re_symbol_pattern setupSysPath() do_lldb_disassembly(lldb_commands, executable, disassemble_options, Added: lldb/trunk/utils/test/run-dis.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/run-dis.py?rev=138078&view=auto ============================================================================== --- lldb/trunk/utils/test/run-dis.py (added) +++ lldb/trunk/utils/test/run-dis.py Fri Aug 19 15:51:15 2011 @@ -0,0 +1,126 @@ +#!/usr/bin/env python + +""" +Run lldb disassembler on all the binaries specified by a combination of root dir +and path pattern. +""" + +import os, sys, subprocess +import re +from optparse import OptionParser + +# The directory of this Python script as well as the lldb-disasm.py workhorse. +scriptPath = None + +# The root directory for the SDK symbols. +root_dir = None + +# The regular expression pattern to match the desired pathname to the binaries. +path_pattern = None + +# And the re-compiled regular expression object. +path_regexp = None + +# If specified, number of symbols to disassemble for each qualified binary. +num_symbols = -1 + +# Command template of the invocation of lldb disassembler. +template = './lldb-disasm.py -C "platform select remote-ios" -o "-n" -q -e %s -n %s' + +# Regular expression for detecting file output for Mach-o binary. +mach_o = re.compile('\sMach-O.+binary') +def isbinary(path): + file_output = subprocess.Popen(["file", path], + stdout=subprocess.PIPE).stdout.read() + return (mach_o.search(file_output) is not None) + +def visit(suffix, dir, names): + """Look for matched file and invoke lldb disassembly on it.""" + global scriptPath + global root_dir + global path_pattern + global path_regexp + global num_symbols + + old_dir = os.getcwd() + for name in names: + path = os.path.join(dir, name) + if os.path.isdir(path): + continue + if name.endswith(".h"): + continue + + replaced_path = path.replace(root_dir, "", 1) + if not path_regexp.search(replaced_path): + continue + if suffix and not name.endswith(suffix): + continue + if not isbinary(path): + continue + + os.chdir(scriptPath) + command = template % (path, num_symbols if num_symbols > 0 else 1000) + print "Running %s" % (command) + os.system(command) + + os.chdir(old_dir) + +def main(): + """Read the root dir and the path spec, invoke lldb-disasm.py on the file.""" + global scriptPath + global root_dir + global path_pattern + global path_regexp + global num_symbols + + scriptPath = sys.path[0] + + parser = OptionParser(usage="""\ +Run lldb disassembler on all the binaries specified by a combination of root dir +and path pattern. +""") + parser.add_option('-r', '--root-dir', + type='string', action='store', + dest='root_dir', + help='Mandatory: the root directory for the SDK symbols.') + parser.add_option('-p', '--path-pattern', + type='string', action='store', + dest='path_pattern', + help='Mandatory: regular expression pattern for the desired binaries.') + parser.add_option('-s', '--suffix', + type='string', action='store', default=None, + dest='suffix', + help='Specify the suffix of the binaries to look for.') + parser.add_option('-n', '--num-symbols', + type='int', action='store', default=-1, + dest='num_symbols', + help="""The number of symbols to disassemble, if specified.""") + + + opts, args = parser.parse_args() + if not opts.root_dir or not opts.path_pattern: + parser.print_help() + sys.exit(1) + + # Sanity check the root directory. + root_dir = opts.root_dir + root_dir = os.path.abspath(root_dir) + if not os.path.isdir(root_dir): + parser.print_help() + sys.exit(1) + + path_pattern = opts.path_pattern + path_regexp = re.compile(path_pattern) + suffix = opts.suffix + num_symbols = opts.num_symbols + + print "Root directory for SDK symbols:", root_dir + print "Regular expression for the binaries:", path_pattern + print "Suffix of the binaries to look for:", suffix + print "num of symbols to disassemble:", num_symbols + + os.path.walk(root_dir, visit, suffix) + + +if __name__ == '__main__': + main() Propchange: lldb/trunk/utils/test/run-dis.py ------------------------------------------------------------------------------ svn:executable = * From granata.enrico at gmail.com Fri Aug 19 16:13:46 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 19 Aug 2011 21:13:46 -0000 Subject: [Lldb-commits] [lldb] r138080 - in /lldb/trunk: include/lldb/Core/ include/lldb/Target/ source/Core/ source/Target/ test/functionalities/data-formatter/data-formatter-cpp/ test/functionalities/data-formatter/rdar-9973865/ test/functionalities/data-formatter/rdar-9973992/ Message-ID: <20110819211347.1931A2A6C12C@llvm.org> Author: enrico Date: Fri Aug 19 16:13:46 2011 New Revision: 138080 URL: http://llvm.org/viewvc/llvm-project?rev=138080&view=rev Log: - Now using ${var} as the summary for an aggregate type will produce "name-of-type @ object-location" instead of giving an error e.g. you may get "foo_class @ 0x123456" when typing "type summary add -f ${var} foo_class" - Added a new special formatting token %T for summaries. This shows the type of the object. Using it, the new "type @ location" summary could be manually generated by writing ${var%T} @ ${var%L} - Bits and pieces required to support "frame variable array[n-m]" The feature is not enabled yet because some additional design and support code is required, but the basics are getting there - Fixed a potential issue where a ValueObjectSyntheticFilter was not holding on to its SyntheticChildrenSP Because of the way VOSF are being built now, this has never been an actual issue, but it is still sensible for a VOSF to hold on to the SyntheticChildrenSP as well as to its FrontEnd Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973992/ lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Makefile lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py lldb/trunk/test/functionalities/data-formatter/rdar-9973992/main.cpp Modified: lldb/trunk/include/lldb/Core/FormatClasses.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h lldb/trunk/include/lldb/Target/StackFrame.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/FormatClasses.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py Modified: lldb/trunk/include/lldb/Core/FormatClasses.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatClasses.h (original) +++ lldb/trunk/include/lldb/Core/FormatClasses.h Fri Aug 19 16:13:46 2011 @@ -384,6 +384,241 @@ }; +struct SyntheticArrayRange +{ +private: + int m_low; + int m_high; + SyntheticArrayRange* m_next; + +public: + + SyntheticArrayRange () : + m_low(-1), + m_high(-2), + m_next(NULL) + {} + + SyntheticArrayRange (int L) : + m_low(L), + m_high(L), + m_next(NULL) + {} + + SyntheticArrayRange (int L, int H) : + m_low(L), + m_high(H), + m_next(NULL) + {} + + SyntheticArrayRange (int L, int H, SyntheticArrayRange* N) : + m_low(L), + m_high(H), + m_next(N) + {} + + inline int + GetLow () + { + return m_low; + } + + inline int + GetHigh () + { + return m_high; + } + + inline void + SetLow (int L) + { + m_low = L; + } + + inline void + SetHigh (int H) + { + m_high = H; + } + + inline int + GetSelfCount() + { + return GetHigh() - GetLow() + 1; + } + + int + GetCount() + { + int count = GetSelfCount(); + if (m_next) + count += m_next->GetCount(); + return count; + } + + inline SyntheticArrayRange* + GetNext() + { + return m_next; + } + + void + SetNext(SyntheticArrayRange* N) + { + if (m_next) + delete m_next; + m_next = N; + } + + void + SetNext(int L, int H) + { + if (m_next) + delete m_next; + m_next = new SyntheticArrayRange(L, H); + } + + void + SetNext(int L) + { + if (m_next) + delete m_next; + m_next = new SyntheticArrayRange(L); + } + + ~SyntheticArrayRange() + { + delete m_next; + m_next = NULL; + } + +}; + +class SyntheticArrayView : public SyntheticChildren +{ + SyntheticArrayRange m_head; + SyntheticArrayRange *m_tail; +public: + SyntheticArrayView(bool casc = false, + bool skipptr = false, + bool skipref = false) : + SyntheticChildren(casc, skipptr, skipref), + m_head(), + m_tail(&m_head) + { + } + + void + AddRange(int L, int H) + { + m_tail->SetLow(L); + m_tail->SetHigh(H); + m_tail->SetNext(new SyntheticArrayRange()); + m_tail = m_tail->GetNext(); + } + + int + GetCount() + { + return m_head.GetCount(); + } + + const int + GetRealIndexForIndex(int i) + { + if (i >= GetCount()) + return -1; + + SyntheticArrayRange* ptr = &m_head; + + int residual = i; + + while(ptr && ptr != m_tail) + { + if (residual >= ptr->GetSelfCount()) + { + residual -= ptr->GetSelfCount(); + ptr = ptr->GetNext(); + } + + return ptr->GetLow() + residual; + } + + return -1; + + } + + bool + IsScripted() + { + return false; + } + + std::string + GetDescription(); + + class FrontEnd : public SyntheticChildrenFrontEnd + { + private: + SyntheticArrayView* filter; + public: + + FrontEnd(SyntheticArrayView* flt, + lldb::ValueObjectSP be) : + SyntheticChildrenFrontEnd(be), + filter(flt) + {} + + virtual + ~FrontEnd() + { + } + + virtual uint32_t + CalculateNumChildren() + { + return filter->GetCount(); + } + + virtual lldb::ValueObjectSP + GetChildAtIndex (uint32_t idx, bool can_create) + { + if (idx >= filter->GetCount()) + return lldb::ValueObjectSP(); + return m_backend->GetSyntheticArrayMember(filter->GetRealIndexForIndex(idx), can_create); + } + + virtual void + Update() {} + + virtual uint32_t + GetIndexOfChildWithName (const ConstString &name_cs) + { + const char* name_cstr = name_cs.GetCString(); + if (*name_cstr != '[') + return UINT32_MAX; + std::string name(name_cstr+1); + if (name[name.size()-1] != ']') + return UINT32_MAX; + name = name.erase(name.size()-1,1); + int index = Args::StringToSInt32 (name.c_str(), -1); + if (index < 0) + return UINT32_MAX; + return index; + } + + typedef lldb::SharedPtr::Type SharedPointer; + + }; + + virtual SyntheticChildrenFrontEnd::SharedPointer + GetFrontEnd(lldb::ValueObjectSP backend) + { + return SyntheticChildrenFrontEnd::SharedPointer(new FrontEnd(this, backend)); + } + +}; + struct SummaryFormat { Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Aug 19 16:13:46 2011 @@ -79,7 +79,8 @@ eDisplaySummary, eDisplayLanguageSpecific, eDisplayLocation, - eDisplayChildrenCount + eDisplayChildrenCount, + eDisplayType }; enum ExpressionPathScanEndReason @@ -658,6 +659,10 @@ lldb::Format custom_format = lldb::eFormatInvalid); bool + HasSpecialCasesForPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display, + lldb::Format custom_format); + + bool DumpPrintableRepresentation(Stream& s, ValueObjectRepresentationStyle val_obj_display = eDisplaySummary, lldb::Format custom_format = lldb::eFormatInvalid, @@ -693,6 +698,9 @@ public: lldb::ValueObjectSP GetSyntheticChild (const ConstString &key) const; + + lldb::ValueObjectSP + GetSyntheticArrayMember (int32_t index, bool can_create); lldb::ValueObjectSP GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create); @@ -704,6 +712,9 @@ GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_create); lldb::ValueObjectSP + GetSyntheticArrayRangeChild (uint32_t from, uint32_t to, bool can_create); + + lldb::ValueObjectSP GetSyntheticExpressionPathChild(const char* expression, bool can_create); virtual lldb::ValueObjectSP Modified: lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Fri Aug 19 16:13:46 2011 @@ -24,9 +24,9 @@ //---------------------------------------------------------------------- // A ValueObject that obtains its children from some source other than // real information -// This is currently used to implement children filtering, where only -// a subset of the real children are shown, but it can be used for any -// source of made-up children information +// This is currently used to implement Python-based children and filters +// but you can bind it to any source of synthetic information and have +// it behave accordingly //---------------------------------------------------------------------- class ValueObjectSynthetic : public ValueObject { @@ -121,6 +121,7 @@ lldb::TypeSP m_type_sp; lldb::ValueObjectSP m_owning_valobj_sp; lldb::SyntheticValueType m_use_synthetic; + lldb::SyntheticChildrenSP m_synth_sp; // hold on to your synthetic children provider lldb::SyntheticChildrenFrontEndSP m_synth_filter; typedef std::map ByIndexMap; Modified: lldb/trunk/include/lldb/Target/StackFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StackFrame.h (original) +++ lldb/trunk/include/lldb/Target/StackFrame.h Fri Aug 19 16:13:46 2011 @@ -32,9 +32,10 @@ public: enum ExpressionPathOption { - eExpressionPathOptionCheckPtrVsMember = (1u << 0), - eExpressionPathOptionsNoFragileObjcIvar = (1u << 1), - eExpressionPathOptionsNoSyntheticChildren = (1u << 2) + eExpressionPathOptionCheckPtrVsMember = (1u << 0), + eExpressionPathOptionsNoFragileObjcIvar = (1u << 1), + eExpressionPathOptionsNoSyntheticChildren = (1u << 2), + eExpressionPathOptionsNoSyntheticArrayRange = (1u << 3), }; //------------------------------------------------------------------ // Constructors and Destructors Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Aug 19 16:13:46 2011 @@ -744,6 +744,8 @@ *val_obj_display = ValueObject::eDisplaySummary; else if (*format_name == '#') *val_obj_display = ValueObject::eDisplayChildrenCount; + else if (*format_name == 'T') + *val_obj_display = ValueObject::eDisplayType; else if (log) log->Printf("%s is an error, leaving the previous value alone", format_name); } @@ -1165,25 +1167,52 @@ StreamString str_temp; if (log) log->Printf("I am into array || pointer && !range"); - // try to use the special cases - var_success = target->DumpPrintableRepresentation(str_temp, - val_obj_display, - custom_format); - if (log) - log->Printf("special cases did%s match", var_success ? "" : "n't"); - if (!var_success) + + if (target->HasSpecialCasesForPrintableRepresentation(val_obj_display, + custom_format)) { - s << ""; + // try to use the special cases + var_success = target->DumpPrintableRepresentation(str_temp, + val_obj_display, + custom_format); + if (log) + log->Printf("special cases did%s match", var_success ? "" : "n't"); + + // should not happen + if (!var_success) + s << ""; + else + s << str_temp.GetData(); var_success = true; + break; } else - s << str_temp.GetData(); + { + // if ${var} + if (was_plain_var) + { + s << target->GetTypeName() << " @ " << target->GetLocationAsCString(); + } + else + { + s << ""; + } + var_success = true; + break; + } + } + + // if directly trying to print ${var}, and this is an aggregate, display a nice + // type @ location message + if (is_aggregate && was_plain_var) + { + s << target->GetTypeName() << " @ " << target->GetLocationAsCString(); + var_success = true; break; } - // if directly trying to print ${var} using its value, and this is an aggregate, display a nice - // error message about it (and avoid recursion in DumpPrintableRepresentation) - if (is_aggregate && ((was_var_format && val_obj_display == ValueObject::eDisplayValue) || was_plain_var)) + // if directly trying to print ${var%V}, and this is an aggregate, do not let the user do it + if (is_aggregate && ((was_var_format && val_obj_display == ValueObject::eDisplayValue))) { s << ""; var_success = true; Modified: lldb/trunk/source/Core/FormatClasses.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatClasses.cpp (original) +++ lldb/trunk/source/Core/FormatClasses.cpp Fri Aug 19 16:13:46 2011 @@ -181,6 +181,31 @@ return sstr.GetString(); } +std::string +SyntheticArrayView::GetDescription() +{ + StreamString sstr; + sstr.Printf("%s%s%s {\n", + m_cascades ? "" : " (not cascading)", + m_skip_pointers ? " (skip pointers)" : "", + m_skip_references ? " (skip references)" : ""); + SyntheticArrayRange* ptr = &m_head; + while (ptr && ptr != m_tail) + { + if (ptr->GetLow() == ptr->GetHigh()) + sstr.Printf(" [%d]\n", + ptr->GetLow()); + else + sstr.Printf(" [%d-%d]\n", + ptr->GetLow(), + ptr->GetHigh()); + ptr = ptr->GetNext(); + } + + sstr.Printf("}"); + return sstr.GetString(); +} + SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass, lldb::ValueObjectSP be) : SyntheticChildrenFrontEnd(be), Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Aug 19 16:13:46 2011 @@ -989,6 +989,9 @@ snprintf((char*)return_value, 512, "%d", count); break; } + case eDisplayType: + return_value = GetTypeName().AsCString(); + break; default: break; } @@ -1007,7 +1010,11 @@ // this thing has no value, and it seems to have no summary // some combination of unitialized data and other factors can also // raise this condition, so let's print a nice generic error message - return_value = ""; + { + alloc_mem.resize(684); + return_value = &alloc_mem[0]; + snprintf((char*)return_value, 684, "%s @ %s", GetTypeName().AsCString(), GetLocationAsCString()); + } } else return_value = GetValueAsCString(); @@ -1026,6 +1033,50 @@ } +// if any more "special cases" are added to ValueObject::DumpPrintableRepresentation() please keep +// this call up to date by returning true for your new special cases. We will eventually move +// to checking this call result before trying to display special cases +bool +ValueObject::HasSpecialCasesForPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display, + lldb::Format custom_format) +{ + clang_type_t elem_or_pointee_type; + Flags flags(ClangASTContext::GetTypeInfo(GetClangType(), GetClangAST(), &elem_or_pointee_type)); + + if (flags.AnySet(ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer) + && val_obj_display == ValueObject::eDisplayValue) + { + if (IsCStringContainer(true) && + (custom_format == lldb::eFormatCString || + custom_format == lldb::eFormatCharArray || + custom_format == lldb::eFormatChar || + custom_format == lldb::eFormatVectorOfChar)) + return true; + + if (flags.Test(ClangASTContext::eTypeIsArray)) + { + if ((custom_format == lldb::eFormatBytes) || + (custom_format == lldb::eFormatBytesWithASCII)) + return true; + + if ((custom_format == lldb::eFormatVectorOfChar) || + (custom_format == lldb::eFormatVectorOfFloat32) || + (custom_format == lldb::eFormatVectorOfFloat64) || + (custom_format == lldb::eFormatVectorOfSInt16) || + (custom_format == lldb::eFormatVectorOfSInt32) || + (custom_format == lldb::eFormatVectorOfSInt64) || + (custom_format == lldb::eFormatVectorOfSInt8) || + (custom_format == lldb::eFormatVectorOfUInt128) || + (custom_format == lldb::eFormatVectorOfUInt16) || + (custom_format == lldb::eFormatVectorOfUInt32) || + (custom_format == lldb::eFormatVectorOfUInt64) || + (custom_format == lldb::eFormatVectorOfUInt8)) + return true; + } + } + return false; +} + bool ValueObject::DumpPrintableRepresentation(Stream& s, ValueObjectRepresentationStyle val_obj_display, @@ -1380,6 +1431,19 @@ return ClangASTContext::IsPossibleDynamicType (GetClangAST (), GetClangType()); } +lldb::ValueObjectSP +ValueObject::GetSyntheticArrayMember (int32_t index, bool can_create) +{ + if (IsArrayType()) + return GetSyntheticArrayMemberFromArray(index, can_create); + + if (IsPointerType()) + return GetSyntheticArrayMemberFromPointer(index, can_create); + + return ValueObjectSP(); + +} + ValueObjectSP ValueObject::GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create) { @@ -1497,6 +1561,42 @@ } lldb::ValueObjectSP +ValueObject::GetSyntheticArrayRangeChild (uint32_t from, uint32_t to, bool can_create) +{ + ValueObjectSP synthetic_child_sp; + if (IsArrayType () || IsPointerType ()) + { + char index_str[64]; + snprintf(index_str, sizeof(index_str), "[%i-%i]", from, to); + ConstString index_const_str(index_str); + // Check if we have already created a synthetic array member in this + // valid object. If we have we will re-use it. + synthetic_child_sp = GetSyntheticChild (index_const_str); + if (!synthetic_child_sp) + { + ValueObjectSynthetic *synthetic_child; + + // We haven't made a synthetic array member for INDEX yet, so + // lets make one and cache it for any future reference. + SyntheticArrayView *view = new SyntheticArrayView(); + view->AddRange(from,to); + SyntheticChildrenSP view_sp(view); + synthetic_child = new ValueObjectSynthetic(*this, view_sp); + + // Cache the value if we got one back... + if (synthetic_child) + { + AddSyntheticChild(index_const_str, synthetic_child); + synthetic_child_sp = synthetic_child->GetSP(); + synthetic_child_sp->SetName(ConstString(index_str)); + synthetic_child_sp->m_is_bitfield_for_scalar = true; + } + } + } + return synthetic_child_sp; +} + +lldb::ValueObjectSP ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create) { Modified: lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp (original) +++ lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp Fri Aug 19 16:13:46 2011 @@ -40,6 +40,7 @@ m_address (), m_type_sp(), m_use_synthetic (lldb::eUseSyntheticFilter), + m_synth_sp(filter), m_synth_filter(filter->GetFrontEnd(parent.GetSP())), m_children_byindex(), m_name_toindex() Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Fri Aug 19 16:13:46 2011 @@ -526,6 +526,7 @@ const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0; const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0; const bool no_synth_child = (options & eExpressionPathOptionsNoSyntheticChildren) != 0; + const bool no_synth_array = (options & eExpressionPathOptionsNoSyntheticArrayRange) != 0; error.Clear(); bool deref = false; bool address_of = false; @@ -861,6 +862,7 @@ // this is most probably a BitField, let's take a look char *real_end = NULL; long final_index = ::strtol (end+1, &real_end, 0); + bool expand_bitfield = true; if (real_end && *real_end == ']') { // if the format given is [high-low], swap range @@ -908,15 +910,31 @@ valobj_sp = temp; deref = false; } + /*else if (valobj_sp->IsArrayType() || valobj_sp->IsPointerType()) + { + child_valobj_sp = valobj_sp->GetSyntheticArrayRangeChild(child_index, final_index, true); + expand_bitfield = false; + if (!child_valobj_sp) + { + valobj_sp->GetExpressionPath (var_expr_path_strm, false); + error.SetErrorStringWithFormat ("array range %i-%i is not valid for \"(%s) %s\"", + child_index, final_index, + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + }*/ - child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, final_index, true); - if (!child_valobj_sp) + if (expand_bitfield) { - valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("bitfield range %i-%i is not valid for \"(%s) %s\"", - child_index, final_index, - valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, final_index, true); + if (!child_valobj_sp) + { + valobj_sp->GetExpressionPath (var_expr_path_strm, false); + error.SetErrorStringWithFormat ("bitfield range %i-%i is not valid for \"(%s) %s\"", + child_index, final_index, + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } } } Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Fri Aug 19 16:13:46 2011 @@ -195,7 +195,34 @@ '[2] = cool object @ 0x', '[3] = cool object @ 0x', '[4] = cool object @ 0x']) + + # test getting similar output by exploiting ${var} = 'type @ location' for aggregates + self.runCmd("type summary add -f \"${var}\" i_am_cool") + + # this test might fail if the compiler tries to store + # these values into registers.. hopefully this is not + # going to be the case + self.expect("frame variable cool_array", + substrs = ['[0] = i_am_cool @ 0x', + '[1] = i_am_cool @ 0x', + '[2] = i_am_cool @ 0x', + '[3] = i_am_cool @ 0x', + '[4] = i_am_cool @ 0x']) + + # test getting same output by exploiting %T and %L together for aggregates + self.runCmd("type summary add -f \"${var%T} @ ${var%L}\" i_am_cool") + + # this test might fail if the compiler tries to store + # these values into registers.. hopefully this is not + # going to be the case + self.expect("frame variable cool_array", + substrs = ['[0] = i_am_cool @ 0x', + '[1] = i_am_cool @ 0x', + '[2] = i_am_cool @ 0x', + '[3] = i_am_cool @ 0x', + '[4] = i_am_cool @ 0x']) + self.runCmd("type summary add -f \"goofy\" i_am_cool") self.runCmd("type summary add -f \"${var.second_cool%S}\" i_am_cooler") Modified: lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py?rev=138080&r1=138079&r2=138080&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py (original) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py Fri Aug 19 16:13:46 2011 @@ -56,10 +56,10 @@ self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var}\" Summarize") self.expect('frame variable mine_ptr', - substrs = ['SUMMARY SUCCESS ']) + substrs = ['SUMMARY SUCCESS summarize_ptr_t @ ']) self.expect('frame variable *mine_ptr', - substrs = ['SUMMARY SUCCESS ']) + substrs = ['SUMMARY SUCCESS summarize_t @']) self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var.first}\" Summarize") Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Makefile?rev=138080&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Makefile (added) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Makefile Fri Aug 19 16:13:46 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py?rev=138080&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py (added) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py Fri Aug 19 16:13:46 2011 @@ -0,0 +1,90 @@ +""" +Test lldb data formatter subsystem. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class DataFormatterTestCase(TestBase): + + # test for rdar://problem/9973992 (What should we do for "${var}" in summaries of aggregate types?) + mydir = os.path.join("functionalities", "data-formatter", "rdar-9973992") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_run_command(self): + """Test data formatter commands.""" + self.buildDsym() + self.data_formatter_commands() + + def test_with_dwarf_and_run_command(self): + """Test data formatter commands.""" + self.buildDwarf() + self.data_formatter_commands() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break at. + self.line = line_number('main.cpp', '// Set break point at this line.') + + def data_formatter_commands(self): + """Test that that file and class static variables display correctly.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.expect("breakpoint set -f main.cpp -l %d" % self.line, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" % + self.line) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type summary clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var}\" Summarize") + + self.expect('frame variable mine_ptr', + substrs = ['SUMMARY SUCCESS summarize_ptr_t @ ']) + + self.expect('frame variable *mine_ptr', + substrs = ['SUMMARY SUCCESS summarize_t @']) + + self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var.first}\" Summarize") + + self.expect('frame variable mine_ptr', + substrs = ['SUMMARY SUCCESS 10']) + + self.expect('frame variable *mine_ptr', + substrs = ['SUMMARY SUCCESS 10']) + + self.runCmd("type summary add -f \"${var}\" Summarize") + self.runCmd("type summary add -f \"${var}\" -e TwoSummarizes") + + self.expect('frame variable', + substrs = ['(TwoSummarizes) twos = TwoSummarizes @ ', + 'first = summarize_t @ ', + 'second = summarize_t @ ']) + + self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var.first}\" Summarize") + self.expect('frame variable', + substrs = ['(TwoSummarizes) twos = TwoSummarizes @ ', + 'first = SUMMARY SUCCESS 1', + 'second = SUMMARY SUCCESS 3']) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973992/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973992/main.cpp?rev=138080&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973992/main.cpp (added) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973992/main.cpp Fri Aug 19 16:13:46 2011 @@ -0,0 +1,41 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +struct Summarize +{ + int first; + int second; +}; + +typedef struct Summarize summarize_t; +typedef summarize_t *summarize_ptr_t; + +summarize_t global_mine = {30, 40}; + +struct TwoSummarizes +{ + summarize_t first; + summarize_t second; +}; + +int +main() +{ + summarize_t mine = {10, 20}; + summarize_ptr_t mine_ptr = &mine; + + TwoSummarizes twos = { {1,2}, {3,4} }; + + printf ("Summarize: first: %d second: %d and address: 0x%p\n", mine.first, mine.second, mine_ptr); // Set break point at this line. + printf ("Global summarize: first: %d second: %d.\n", global_mine.first, global_mine.second); + return 0; +} + + From granata.enrico at gmail.com Fri Aug 19 16:56:10 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 19 Aug 2011 21:56:10 -0000 Subject: [Lldb-commits] [lldb] r138105 - in /lldb/trunk: include/lldb/Interpreter/ScriptInterpreter.h scripts/Python/python-wrapper.swig source/API/SBCommandInterpreter.cpp source/Interpreter/ScriptInterpreterPython.cpp source/Target/StackFrame.cpp test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Message-ID: <20110819215610.AA0482A6C12C@llvm.org> Author: enrico Date: Fri Aug 19 16:56:10 2011 New Revision: 138105 URL: http://llvm.org/viewvc/llvm-project?rev=138105&view=rev Log: Taking care of an issue with using lldb_private types in SBCommandInterpreter.cpp ; Making NSString test case work on Snow Leopard ; Removing an unused variable warning Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/scripts/Python/python-wrapper.swig lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=138105&r1=138104&r2=138105&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Fri Aug 19 16:56:10 2011 @@ -49,7 +49,7 @@ lldb::DebuggerSP& debugger, const char* args, std::string& err_msg, - lldb_private::CommandReturnObject& cmd_retobj); + void* cmd_retobj); typedef enum { Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=138105&r1=138104&r2=138105&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Fri Aug 19 16:56:10 2011 @@ -590,11 +590,11 @@ lldb::DebuggerSP& debugger, const char* args, std::string& err_msg, - lldb_private::CommandReturnObject& cmd_retobj + void* cmd_retobj ) { - not_owning_ap auto_cmd_retobj(&cmd_retobj); + not_owning_ap auto_cmd_retobj((lldb_private::CommandReturnObject*)cmd_retobj); bool retval = false; Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=138105&r1=138104&r2=138105&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Fri Aug 19 16:56:10 2011 @@ -344,7 +344,7 @@ lldb::DebuggerSP& debugger, const char* args, std::string& err_msg, - lldb_private::CommandReturnObject& cmd_retobj + void* cmd_retobj ); Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=138105&r1=138104&r2=138105&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Aug 19 16:56:10 2011 @@ -1946,7 +1946,7 @@ debugger_sp, args, err_msg, - cmd_retobj); + (void*)&cmd_retobj); python_interpreter->LeaveSession (); } else @@ -1960,7 +1960,7 @@ debugger_sp, args, err_msg, - cmd_retobj); + (void*)&cmd_retobj); python_interpreter->LeaveSession (); ReleasePythonLock (); } Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=138105&r1=138104&r2=138105&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Fri Aug 19 16:56:10 2011 @@ -526,7 +526,7 @@ const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0; const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0; const bool no_synth_child = (options & eExpressionPathOptionsNoSyntheticChildren) != 0; - const bool no_synth_array = (options & eExpressionPathOptionsNoSyntheticArrayRange) != 0; + //const bool no_synth_array = (options & eExpressionPathOptionsNoSyntheticArrayRange) != 0; error.Clear(); bool deref = false; bool address_of = false; Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=138105&r1=138104&r2=138105&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Fri Aug 19 16:56:10 2011 @@ -178,7 +178,7 @@ 'inline = ', 'explicit = ', 'content = ', - '__NSCFString']) + 'NSCFString']) self.expect('frame variable processName -P 1 -Y', substrs = ['mutable =', @@ -223,7 +223,7 @@ self.expect('frame variable str10', substrs = ['This is a Unicode string \\xcf\\x83 number 4 right here']) self.expect('frame variable str11', - substrs = ['__NSCFString']) + substrs = ['NSCFString']) self.expect('frame variable processName', substrs = ['a.out']) self.expect('frame variable str12', From scallanan at apple.com Fri Aug 19 17:25:30 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 19 Aug 2011 22:25:30 -0000 Subject: [Lldb-commits] [lldb] r138119 - /lldb/tags/lldb-74/ Message-ID: <20110819222530.313C22A6C12C@llvm.org> Author: spyffe Date: Fri Aug 19 17:25:30 2011 New Revision: 138119 URL: http://llvm.org/viewvc/llvm-project?rev=138119&view=rev Log: Preparing for lldb-74. Added: lldb/tags/lldb-74/ - copied from r138118, lldb/tags/lldb-73/ From scallanan at apple.com Fri Aug 19 17:27:07 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 19 Aug 2011 22:27:07 -0000 Subject: [Lldb-commits] [lldb] r138122 - in /lldb/tags/lldb-74: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20110819222707.B5B8F2A6C12C@llvm.org> Author: spyffe Date: Fri Aug 19 17:27:07 2011 New Revision: 138122 URL: http://llvm.org/viewvc/llvm-project?rev=138122&view=rev Log: Updating Xcode project versions for lldb-74. Modified: lldb/tags/lldb-74/lldb.xcodeproj/project.pbxproj lldb/tags/lldb-74/resources/LLDB-Info.plist lldb/tags/lldb-74/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/tags/lldb-74/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-74/lldb.xcodeproj/project.pbxproj?rev=138122&r1=138121&r2=138122&view=diff ============================================================================== --- lldb/tags/lldb-74/lldb.xcodeproj/project.pbxproj (original) +++ lldb/tags/lldb-74/lldb.xcodeproj/project.pbxproj Fri Aug 19 17:27:07 2011 @@ -3431,10 +3431,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 73; + DYLIB_CURRENT_VERSION = 74; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3483,11 +3483,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 73; + DYLIB_CURRENT_VERSION = 74; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3534,8 +3534,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; - DYLIB_CURRENT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; + DYLIB_CURRENT_VERSION = 74; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3573,9 +3573,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 73; + DYLIB_CURRENT_VERSION = 74; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3613,9 +3613,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 73; + DYLIB_CURRENT_VERSION = 74; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3683,7 +3683,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3714,11 +3714,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 73; + DYLIB_CURRENT_VERSION = 74; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3843,7 +3843,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3875,7 +3875,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 73; + CURRENT_PROJECT_VERSION = 74; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/tags/lldb-74/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-74/resources/LLDB-Info.plist?rev=138122&r1=138121&r2=138122&view=diff ============================================================================== --- lldb/tags/lldb-74/resources/LLDB-Info.plist (original) +++ lldb/tags/lldb-74/resources/LLDB-Info.plist Fri Aug 19 17:27:07 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 73 + 74 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/tags/lldb-74/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-74/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=138122&r1=138121&r2=138122&view=diff ============================================================================== --- lldb/tags/lldb-74/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/tags/lldb-74/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Aug 19 17:27:07 2011 @@ -473,7 +473,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; "GCC_VERSION[sdk=iphoneos*][arch=*]" = 4.2; "GCC_VERSION[sdk=macosx*][arch=*]" = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -533,7 +533,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -573,7 +573,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -613,7 +613,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 144; + CURRENT_PROJECT_VERSION = 145; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Fri Aug 19 18:06:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 19 Aug 2011 23:06:38 -0000 Subject: [Lldb-commits] [lldb] r138133 - in /lldb/trunk: include/lldb/API/SBCommandReturnObject.h source/API/SBCommandReturnObject.cpp Message-ID: <20110819230638.D86D92A6C12C@llvm.org> Author: gclayton Date: Fri Aug 19 18:06:38 2011 New Revision: 138133 URL: http://llvm.org/viewvc/llvm-project?rev=138133&view=rev Log: Added the ability to create a SBCommandReturnObject object from a pointer and also to later release the ownership of the pointer object. This was needed for SWIG interaction. Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h lldb/trunk/source/API/SBCommandReturnObject.cpp Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=138133&r1=138132&r2=138133&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original) +++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Fri Aug 19 18:06:38 2011 @@ -25,8 +25,15 @@ SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs); #ifndef SWIG + const lldb::SBCommandReturnObject & operator = (const lldb::SBCommandReturnObject &rhs); + + + SBCommandReturnObject (lldb_private::CommandReturnObject *ptr); + + lldb_private::CommandReturnObject * + Release (); #endif ~SBCommandReturnObject (); Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=138133&r1=138132&r2=138133&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandReturnObject.cpp (original) +++ lldb/trunk/source/API/SBCommandReturnObject.cpp Fri Aug 19 18:06:38 2011 @@ -28,6 +28,17 @@ m_opaque_ap.reset (new CommandReturnObject (*rhs.m_opaque_ap)); } +SBCommandReturnObject::SBCommandReturnObject (CommandReturnObject *ptr) : + m_opaque_ap (ptr) +{ +} + +CommandReturnObject * +SBCommandReturnObject::Release () +{ + return m_opaque_ap.release(); +} + const SBCommandReturnObject & SBCommandReturnObject::operator = (const SBCommandReturnObject &rhs) { @@ -57,7 +68,7 @@ const char * SBCommandReturnObject::GetOutput () { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (m_opaque_ap.get()) { @@ -77,7 +88,7 @@ const char * SBCommandReturnObject::GetError () { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (m_opaque_ap.get()) { From scallanan at apple.com Fri Aug 19 18:10:19 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 19 Aug 2011 23:10:19 -0000 Subject: [Lldb-commits] [lldb] r138136 - in /lldb/tags/lldb-74: llvm.zip scripts/build-llvm.pl scripts/llvm.isreg.diff scripts/llvm.operand-leak.diff test/lang/c/function_types/TestFunctionTypes.py Message-ID: <20110819231019.DACE82A6C12C@llvm.org> Author: spyffe Date: Fri Aug 19 18:10:19 2011 New Revision: 138136 URL: http://llvm.org/viewvc/llvm-project?rev=138136&view=rev Log: Added the patches necessary to stabilize the ARM disassembler to lldb-74. Added: lldb/tags/lldb-74/scripts/llvm.isreg.diff lldb/tags/lldb-74/scripts/llvm.operand-leak.diff Modified: lldb/tags/lldb-74/llvm.zip lldb/tags/lldb-74/scripts/build-llvm.pl lldb/tags/lldb-74/test/lang/c/function_types/TestFunctionTypes.py Modified: lldb/tags/lldb-74/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-74/llvm.zip?rev=138136&r1=138135&r2=138136&view=diff ============================================================================== Binary files - no diff available. Modified: lldb/tags/lldb-74/scripts/build-llvm.pl URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-74/scripts/build-llvm.pl?rev=138136&r1=138135&r2=138136&view=diff ============================================================================== --- lldb/tags/lldb-74/scripts/build-llvm.pl (original) +++ lldb/tags/lldb-74/scripts/build-llvm.pl Fri Aug 19 18:10:19 2011 @@ -22,7 +22,9 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "137311"; +our $llvm_revision = "137143"; +our $clang_revision = "137143"; + our $llvm_source_dir = "$ENV{SRCROOT}"; our @archs = split (/\s+/, $ENV{ARCHS}); @@ -139,22 +141,31 @@ sub build_llvm { #my $extra_svn_options = $debug ? "" : "--quiet"; - my $svn_options = "--quiet --revision $llvm_revision"; + my $svn_options = "--quiet"; if (-d "$llvm_source_dir/llvm") { print "Using existing llvm sources in: '$llvm_source_dir/llvm'\n"; # print "Updating llvm to revision $llvm_revision\n"; - # do_command ("cd '$llvm_source_dir/llvm' && svn update $svn_options", "updating llvm from repository", 1); + # do_command ("cd '$llvm_source_dir/llvm' && svn update $svn_options --revision $llvm_revision", "updating llvm from repository", 1); # print "Updating clang to revision $llvm_revision\n"; - # do_command ("cd '$llvm_source_dir/llvm/tools/clang' && svn update $svn_options", "updating clang from repository", 1); + # do_command ("cd '$llvm_source_dir/llvm/tools/clang' && svn update $svn_options --revision $clang_revision", "updating clang from repository", 1); } else { print "Checking out llvm sources from revision $llvm_revision...\n"; - do_command ("cd '$llvm_source_dir' && svn co $svn_options http://llvm.org/svn/llvm-project/llvm/trunk llvm", "checking out llvm from repository", 1); - print "Checking out clang sources from revision $llvm_revision...\n"; - do_command ("cd '$llvm_source_dir/llvm/tools' && svn co $svn_options http://llvm.org/svn/llvm-project/cfe/trunk clang", "checking out clang from repository", 1); - print "Removing the llvm/test directory...\n"; + do_command ("cd '$llvm_source_dir' && svn co $svn_options --revision $llvm_revision http://llvm.org/svn/llvm-project/llvm/trunk llvm", "checking out llvm from repository", 1); + print "Checking out clang sources from revision $clang_revision...\n"; + do_command ("cd '$llvm_source_dir/llvm/tools' && svn co $svn_options --revision $clang_revision http://llvm.org/svn/llvm-project/cfe/trunk clang", "checking out clang from repository", 1); + print "Applying any local patches to LLVM..."; + + my @llvm_patches = bsd_glob("$ENV{SRCROOT}/scripts/llvm.*.diff"); + + foreach my $patch (@llvm_patches) + { + do_command ("cd '$llvm_source_dir/llvm' && patch -p0 < $patch"); + } + + print "Removing the llvm/test directory...\n"; do_command ("cd '$llvm_source_dir' && rm -rf llvm/test", "removing test directory", 1); } Added: lldb/tags/lldb-74/scripts/llvm.isreg.diff URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-74/scripts/llvm.isreg.diff?rev=138136&view=auto ============================================================================== --- lldb/tags/lldb-74/scripts/llvm.isreg.diff (added) +++ lldb/tags/lldb-74/scripts/llvm.isreg.diff Fri Aug 19 18:10:19 2011 @@ -0,0 +1,12 @@ +Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp +=================================================================== +--- lib/Target/ARM/AsmParser/ARMAsmParser.cpp (revision 137143) ++++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp (working copy) +@@ -2619,6 +2619,7 @@ + if (Mnemonic == "mov" && Operands.size() > 4 && + !static_cast(Operands[4])->isARMSOImm() && + static_cast(Operands[4])->isImm0_65535Expr() && ++ static_cast(Operands[1])->isReg() && + static_cast(Operands[1])->getReg() == 0) { + ARMOperand *Op = static_cast(Operands[1]); + Operands.erase(Operands.begin() + 1); Added: lldb/tags/lldb-74/scripts/llvm.operand-leak.diff URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-74/scripts/llvm.operand-leak.diff?rev=138136&view=auto ============================================================================== --- lldb/tags/lldb-74/scripts/llvm.operand-leak.diff (added) +++ lldb/tags/lldb-74/scripts/llvm.operand-leak.diff Fri Aug 19 18:10:19 2011 @@ -0,0 +1,18 @@ +Index: lib/MC/MCDisassembler/EDToken.cpp +=================================================================== +--- lib/MC/MCDisassembler/EDToken.cpp (revision 137143) ++++ lib/MC/MCDisassembler/EDToken.cpp (working copy) +@@ -93,8 +93,12 @@ + SmallVector asmTokens; + + if (disassembler.parseInst(parsedOperands, asmTokens, str)) ++ { ++ for (unsigned i = 0, e = parsedOperands.size(); i != e; ++i) ++ delete parsedOperands[i]; + return -1; +- ++ } ++ + SmallVectorImpl::iterator operandIterator; + unsigned int operandIndex; + SmallVectorImpl::iterator tokenIterator; Modified: lldb/tags/lldb-74/test/lang/c/function_types/TestFunctionTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-74/test/lang/c/function_types/TestFunctionTypes.py?rev=138136&r1=138135&r2=138136&view=diff ============================================================================== --- lldb/tags/lldb-74/test/lang/c/function_types/TestFunctionTypes.py (original) +++ lldb/tags/lldb-74/test/lang/c/function_types/TestFunctionTypes.py Fri Aug 19 18:10:19 2011 @@ -24,12 +24,12 @@ def test_pointers_with_dsym(self): """Test that a function pointer to 'printf' works and can be called.""" self.buildDsym() - self.function_pointers() + #self.function_pointers() # ROLLED BACK def test_pointers_with_dwarf(self): """Test that a function pointer to 'printf' works and can be called.""" self.buildDwarf() - self.function_pointers() + #self.function_pointers() # ROLLED BACK def setUp(self): # Call super's setUp(). From gclayton at apple.com Fri Aug 19 18:28:37 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 19 Aug 2011 23:28:37 -0000 Subject: [Lldb-commits] [lldb] r138146 - /lldb/trunk/source/Core/Communication.cpp Message-ID: <20110819232837.6E5CE2A6C12C@llvm.org> Author: gclayton Date: Fri Aug 19 18:28:37 2011 New Revision: 138146 URL: http://llvm.org/viewvc/llvm-project?rev=138146&view=rev Log: Fixed an issue where even if the communication object had Clear() called on it, it could try and call through to an installed callback. Modified: lldb/trunk/source/Core/Communication.cpp Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=138146&r1=138145&r2=138146&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Fri Aug 19 18:28:37 2011 @@ -64,6 +64,7 @@ void Communication::Clear() { + SetReadThreadBytesReceivedCallback (NULL, NULL); StopReadThread (NULL); Disconnect (NULL); } @@ -295,7 +296,7 @@ // If the user registered a callback, then call it and do not broadcast m_callback (m_callback_baton, bytes, len); } - else + else if (bytes != NULL && len > 0) { Mutex::Locker locker(m_bytes_mutex); m_bytes.append ((const char *)bytes, len); From gclayton at apple.com Fri Aug 19 18:45:49 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 19 Aug 2011 23:45:49 -0000 Subject: [Lldb-commits] [lldb] r138151 - /lldb/tags/lldb-74/source/Core/Communication.cpp Message-ID: <20110819234549.808252A6C12C@llvm.org> Author: gclayton Date: Fri Aug 19 18:45:49 2011 New Revision: 138151 URL: http://llvm.org/viewvc/llvm-project?rev=138151&view=rev Log: Porting revision 138146 over to the lldb-74 tag. Modified: lldb/tags/lldb-74/source/Core/Communication.cpp Modified: lldb/tags/lldb-74/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-74/source/Core/Communication.cpp?rev=138151&r1=138150&r2=138151&view=diff ============================================================================== --- lldb/tags/lldb-74/source/Core/Communication.cpp (original) +++ lldb/tags/lldb-74/source/Core/Communication.cpp Fri Aug 19 18:45:49 2011 @@ -64,6 +64,7 @@ void Communication::Clear() { + SetReadThreadBytesReceivedCallback (NULL, NULL); StopReadThread (NULL); Disconnect (NULL); } @@ -295,7 +296,7 @@ // If the user registered a callback, then call it and do not broadcast m_callback (m_callback_baton, bytes, len); } - else + else if (bytes != NULL && len > 0) { Mutex::Locker locker(m_bytes_mutex); m_bytes.append ((const char *)bytes, len); From granata.enrico at gmail.com Fri Aug 19 18:56:34 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 19 Aug 2011 23:56:34 -0000 Subject: [Lldb-commits] [lldb] r138154 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/Interpreter/ScriptInterpreter.h scripts/Python/python-wrapper.swig source/API/SBCommandInterpreter.cpp source/API/SBDebugger.cpp source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110819235634.DB25A2A6C12C@llvm.org> Author: enrico Date: Fri Aug 19 18:56:34 2011 New Revision: 138154 URL: http://llvm.org/viewvc/llvm-project?rev=138154&view=rev Log: Fixed some SWIG interoperability issues Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/scripts/Python/python-wrapper.swig lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=138154&r1=138153&r2=138154&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Fri Aug 19 18:56:34 2011 @@ -40,6 +40,8 @@ SBDebugger(const lldb::SBDebugger &rhs); #ifndef SWIG + SBDebugger(const lldb::DebuggerSP &debugger_sp); + lldb::SBDebugger & operator = (const lldb::SBDebugger &rhs); #endif Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=138154&r1=138153&r2=138154&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Fri Aug 19 18:56:34 2011 @@ -49,7 +49,7 @@ lldb::DebuggerSP& debugger, const char* args, std::string& err_msg, - void* cmd_retobj); + lldb_private::CommandReturnObject& cmd_retobj); typedef enum { Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=138154&r1=138153&r2=138154&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Fri Aug 19 18:56:34 2011 @@ -136,7 +136,7 @@ std::string retval = ""; - PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *) &valobj_sp, SWIGTYPE_p_lldb__SBValue, 0); + PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *) &sb_value, SWIGTYPE_p_lldb__SBValue, 0); if (ValObj_PyObj == NULL) return retval; @@ -263,9 +263,11 @@ if (python_class_name.empty() || !session_dictionary_name) Py_RETURN_NONE; - lldb::ValueObjectSP* valobj_sp_ptr = new lldb::ValueObjectSP(valobj_sp); + // I do not want the SBValue to be deallocated when going out of scope because python + // has ownership of it and will manage memory for this object by itself + lldb::SBValue *valobj_sb = new lldb::SBValue(valobj_sp); - PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *) valobj_sp_ptr, SWIGTYPE_p_lldb__SBValue, SWIG_POINTER_OWN); + PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *)valobj_sb, SWIGTYPE_p_lldb__SBValue, SWIG_POINTER_OWN); if (ValObj_PyObj == NULL) Py_RETURN_NONE; @@ -582,6 +584,14 @@ return sb_ptr; } +// we use this macro to bail out of LLDBSwigPythonCallCommand in order +// to make sure that the that the SBCommandReturnObject will not destroy +// the contained CommandReturnObject when going out of scope +#define RETURN_RETVAL { \ + cmd_retobj_sb.Release(); \ + return retval; \ +} + SWIGEXPORT bool LLDBSwigPythonCallCommand ( @@ -590,25 +600,26 @@ lldb::DebuggerSP& debugger, const char* args, std::string& err_msg, - void* cmd_retobj + lldb_private::CommandReturnObject& cmd_retobj ) { - not_owning_ap auto_cmd_retobj((lldb_private::CommandReturnObject*)cmd_retobj); + lldb::SBCommandReturnObject cmd_retobj_sb(&cmd_retobj); + lldb::SBDebugger debugger_sb(debugger); bool retval = false; - PyObject *DebuggerObj_PyObj = SWIG_NewPointerObj((void *) &debugger, SWIGTYPE_p_lldb__SBDebugger, 0); - PyObject *CmdRetObj_PyObj = SWIG_NewPointerObj((void *) &auto_cmd_retobj, SWIGTYPE_p_lldb__SBCommandReturnObject, 0); + PyObject *DebuggerObj_PyObj = SWIG_NewPointerObj((void *) &debugger_sb, SWIGTYPE_p_lldb__SBDebugger, 0); + PyObject *CmdRetObj_PyObj = SWIG_NewPointerObj((void *) &cmd_retobj_sb, SWIGTYPE_p_lldb__SBCommandReturnObject, 0); if (DebuggerObj_PyObj == NULL) - return retval; + RETURN_RETVAL; if (CmdRetObj_PyObj == NULL) - return retval; + RETURN_RETVAL; if (!python_function_name || !session_dictionary_name) - return retval; + RETURN_RETVAL; PyObject *pmodule, *main_dict, *session_dict, *pfunc; PyObject *pargs, *pvalue; @@ -642,7 +653,7 @@ } if (!session_dict || !PyDict_Check (session_dict)) - return retval; + RETURN_RETVAL; // Find the function we need to call in the current session's dictionary. @@ -673,7 +684,7 @@ { if (PyErr_Occurred()) PyErr_Clear(); - return retval; + RETURN_RETVAL; } PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj); // This "steals" a reference to DebuggerObj_PyObj @@ -721,7 +732,9 @@ PyErr_Print(); PyErr_Clear (); } - return retval; + RETURN_RETVAL; } +#undef RETURN_RETVAL + %} Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=138154&r1=138153&r2=138154&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Fri Aug 19 18:56:34 2011 @@ -344,7 +344,7 @@ lldb::DebuggerSP& debugger, const char* args, std::string& err_msg, - void* cmd_retobj + lldb_private::CommandReturnObject& cmd_retobj ); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=138154&r1=138153&r2=138154&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Fri Aug 19 18:56:34 2011 @@ -128,6 +128,11 @@ { } +SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) : + m_opaque_sp(debugger_sp) +{ +} + SBDebugger::SBDebugger(const SBDebugger &rhs) : m_opaque_sp (rhs.m_opaque_sp) { Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=138154&r1=138153&r2=138154&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Aug 19 18:56:34 2011 @@ -20,6 +20,7 @@ #include "lldb/API/SBFrame.h" #include "lldb/API/SBBreakpointLocation.h" +#include "lldb/API/SBCommandReturnObject.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Timer.h" @@ -1930,7 +1931,7 @@ } ScriptInterpreterPython *python_interpreter = this; - + lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().GetSP(); bool ret_val; @@ -1946,7 +1947,7 @@ debugger_sp, args, err_msg, - (void*)&cmd_retobj); + cmd_retobj); python_interpreter->LeaveSession (); } else @@ -1960,7 +1961,7 @@ debugger_sp, args, err_msg, - (void*)&cmd_retobj); + cmd_retobj); python_interpreter->LeaveSession (); ReleasePythonLock (); } @@ -1969,7 +1970,7 @@ error.SetErrorString(err_msg.c_str()); else error.Clear(); - + return ret_val; From johnny.chen at apple.com Fri Aug 19 19:12:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 20 Aug 2011 00:12:13 -0000 Subject: [Lldb-commits] [lldb] r138159 - /lldb/trunk/utils/test/run-dis.py Message-ID: <20110820001213.DD7CF2A6C12C@llvm.org> Author: johnny Date: Fri Aug 19 19:12:13 2011 New Revision: 138159 URL: http://llvm.org/viewvc/llvm-project?rev=138159&view=rev Log: No need to look further if the file is a symbolic link. Look for the real file. Plus add some comments. Modified: lldb/trunk/utils/test/run-dis.py Modified: lldb/trunk/utils/test/run-dis.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/run-dis.py?rev=138159&r1=138158&r2=138159&view=diff ============================================================================== --- lldb/trunk/utils/test/run-dis.py (original) +++ lldb/trunk/utils/test/run-dis.py Fri Aug 19 19:12:13 2011 @@ -45,14 +45,22 @@ old_dir = os.getcwd() for name in names: path = os.path.join(dir, name) + # No need to look further if path is a directory. if os.path.isdir(path): continue + # Is a symbolic link. + if os.path.islink(path): + continue + # Or a .h file. if name.endswith(".h"): continue + # We'll be pattern matching based on the path relative to the SDK root. replaced_path = path.replace(root_dir, "", 1) + # Check regular expression match for the replaced path. if not path_regexp.search(replaced_path): continue + # If a suffix is specified, check it, too. if suffix and not name.endswith(suffix): continue if not isbinary(path): From granata.enrico at gmail.com Fri Aug 19 19:26:17 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Sat, 20 Aug 2011 00:26:17 -0000 Subject: [Lldb-commits] [lldb] r138169 - /lldb/trunk/scripts/Python/python-wrapper.swig Message-ID: <20110820002617.460382A6C12C@llvm.org> Author: enrico Date: Fri Aug 19 19:26:17 2011 New Revision: 138169 URL: http://llvm.org/viewvc/llvm-project?rev=138169&view=rev Log: Further fix for SWIG interoperability; making sure the Release() method of SBCommandReturnObject is called at all times Modified: lldb/trunk/scripts/Python/python-wrapper.swig Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=138169&r1=138168&r2=138169&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Fri Aug 19 19:26:17 2011 @@ -584,13 +584,29 @@ return sb_ptr; } -// we use this macro to bail out of LLDBSwigPythonCallCommand in order -// to make sure that the that the SBCommandReturnObject will not destroy -// the contained CommandReturnObject when going out of scope -#define RETURN_RETVAL { \ - cmd_retobj_sb.Release(); \ - return retval; \ -} +// Currently, SBCommandReturnObjectReleaser wraps an std::auto_ptr to an +// lldb_private::CommandReturnObject. This means that the destructor for the +// SB object will deallocate its contained CommandReturnObject. Because that +// object is used as the real return object for Python-based commands, we want +// it to stay around. Thus, we release the auto_ptr before returning from +// LLDBSwigPythonCallCommand, and to guarantee that the release will occur no +// matter how we exit from the function, we have a releaser object whose +// destructor does the right thing for us +class SBCommandReturnObjectReleaser +{ +public: + SBCommandReturnObjectReleaser (lldb::SBCommandReturnObject &obj) : + m_command_return_object_ref (obj) + { + } + + ~SBCommandReturnObjectReleaser () + { + m_command_return_object_ref.Release(); + } +private: + lldb::SBCommandReturnObject &m_command_return_object_ref; +}; SWIGEXPORT bool LLDBSwigPythonCallCommand @@ -605,6 +621,7 @@ { lldb::SBCommandReturnObject cmd_retobj_sb(&cmd_retobj); + SBCommandReturnObjectReleaser cmd_retobj_sb_releaser(cmd_retobj_sb); lldb::SBDebugger debugger_sb(debugger); bool retval = false; @@ -613,13 +630,13 @@ PyObject *CmdRetObj_PyObj = SWIG_NewPointerObj((void *) &cmd_retobj_sb, SWIGTYPE_p_lldb__SBCommandReturnObject, 0); if (DebuggerObj_PyObj == NULL) - RETURN_RETVAL; + return retval; if (CmdRetObj_PyObj == NULL) - RETURN_RETVAL; + return retval; if (!python_function_name || !session_dictionary_name) - RETURN_RETVAL; + return retval; PyObject *pmodule, *main_dict, *session_dict, *pfunc; PyObject *pargs, *pvalue; @@ -653,7 +670,7 @@ } if (!session_dict || !PyDict_Check (session_dict)) - RETURN_RETVAL; + return retval; // Find the function we need to call in the current session's dictionary. @@ -684,7 +701,7 @@ { if (PyErr_Occurred()) PyErr_Clear(); - RETURN_RETVAL; + return retval; } PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj); // This "steals" a reference to DebuggerObj_PyObj @@ -732,7 +749,7 @@ PyErr_Print(); PyErr_Clear (); } - RETURN_RETVAL; +return retval; } #undef RETURN_RETVAL From johnny.chen at apple.com Fri Aug 19 20:00:16 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 20 Aug 2011 01:00:16 -0000 Subject: [Lldb-commits] [lldb] r138178 - /lldb/trunk/utils/test/run-dis.py Message-ID: <20110820010016.F02652A6C12C@llvm.org> Author: johnny Date: Fri Aug 19 20:00:16 2011 New Revision: 138178 URL: http://llvm.org/viewvc/llvm-project?rev=138178&view=rev Log: Use os.walk(), available since 2.3, instead of os.path.walk(), removed in 3.0, to walk the directory tree. Plus, we can concentrate only on leaf nodes, i.e., files. Modified: lldb/trunk/utils/test/run-dis.py Modified: lldb/trunk/utils/test/run-dis.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/run-dis.py?rev=138178&r1=138177&r2=138178&view=diff ============================================================================== --- lldb/trunk/utils/test/run-dis.py (original) +++ lldb/trunk/utils/test/run-dis.py Fri Aug 19 20:00:16 2011 @@ -25,7 +25,7 @@ num_symbols = -1 # Command template of the invocation of lldb disassembler. -template = './lldb-disasm.py -C "platform select remote-ios" -o "-n" -q -e %s -n %s' +template = '%s/lldb-disasm.py -C "platform select remote-ios" -o "-n" -q -e %s -n %s' # Regular expression for detecting file output for Mach-o binary. mach_o = re.compile('\sMach-O.+binary') @@ -34,44 +34,35 @@ stdout=subprocess.PIPE).stdout.read() return (mach_o.search(file_output) is not None) -def visit(suffix, dir, names): +def walk_and_invoke(sdk_root, path_regexp, suffix, num_symbols): """Look for matched file and invoke lldb disassembly on it.""" global scriptPath - global root_dir - global path_pattern - global path_regexp - global num_symbols - - old_dir = os.getcwd() - for name in names: - path = os.path.join(dir, name) - # No need to look further if path is a directory. - if os.path.isdir(path): - continue - # Is a symbolic link. - if os.path.islink(path): - continue - # Or a .h file. - if name.endswith(".h"): - continue - - # We'll be pattern matching based on the path relative to the SDK root. - replaced_path = path.replace(root_dir, "", 1) - # Check regular expression match for the replaced path. - if not path_regexp.search(replaced_path): - continue - # If a suffix is specified, check it, too. - if suffix and not name.endswith(suffix): - continue - if not isbinary(path): - continue - - os.chdir(scriptPath) - command = template % (path, num_symbols if num_symbols > 0 else 1000) - print "Running %s" % (command) - os.system(command) - os.chdir(old_dir) + for root, dirs, files in os.walk(sdk_root, topdown=False): + for name in files: + path = os.path.join(root, name) + + # We're not interested in .h file. + if name.endswith(".h"): + continue + # Neither a symboliccally link file. + if os.path.islink(path): + continue + + # We'll be pattern matching based on the path relative to the SDK root. + replaced_path = path.replace(root_dir, "", 1) + # Check regular expression match for the replaced path. + if not path_regexp.search(replaced_path): + continue + # If a suffix is specified, check it, too. + if suffix and not name.endswith(suffix): + continue + if not isbinary(path): + continue + + command = template % (scriptPath, path, num_symbols if num_symbols > 0 else 1000) + print "Running %s" % (command) + os.system(command) def main(): """Read the root dir and the path spec, invoke lldb-disasm.py on the file.""" @@ -127,7 +118,7 @@ print "Suffix of the binaries to look for:", suffix print "num of symbols to disassemble:", num_symbols - os.path.walk(root_dir, visit, suffix) + walk_and_invoke(root_dir, path_regexp, suffix, num_symbols) if __name__ == '__main__': From johnny.chen at apple.com Fri Aug 19 20:02:31 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 20 Aug 2011 01:02:31 -0000 Subject: [Lldb-commits] [lldb] r138179 - /lldb/trunk/utils/test/run-dis.py Message-ID: <20110820010231.C31A72A6C12C@llvm.org> Author: johnny Date: Fri Aug 19 20:02:31 2011 New Revision: 138179 URL: http://llvm.org/viewvc/llvm-project?rev=138179&view=rev Log: Fix typos in comment. Modified: lldb/trunk/utils/test/run-dis.py Modified: lldb/trunk/utils/test/run-dis.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/run-dis.py?rev=138179&r1=138178&r2=138179&view=diff ============================================================================== --- lldb/trunk/utils/test/run-dis.py (original) +++ lldb/trunk/utils/test/run-dis.py Fri Aug 19 20:02:31 2011 @@ -45,7 +45,7 @@ # We're not interested in .h file. if name.endswith(".h"): continue - # Neither a symboliccally link file. + # Neither a symbolically linked file. if os.path.islink(path): continue From gclayton at apple.com Sun Aug 21 21:49:39 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 22 Aug 2011 02:49:39 -0000 Subject: [Lldb-commits] [lldb] r138228 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Target/ lldb.xcodeproj/ source/ source/Core/ source/Plugins/ABI/MacOSX-arm/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/OperatingSystem/ source/Plugins/OperatingSystem/MacOSX-Kernel/ source/Plugins/Process/MacOSX-Kernel/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/ source/Target/ Message-ID: <20110822024940.1D4D52A6C12C@llvm.org> Author: gclayton Date: Sun Aug 21 21:49:39 2011 New Revision: 138228 URL: http://llvm.org/viewvc/llvm-project?rev=138228&view=rev Log: Added a new plug-in type: lldb_private::OperatingSystem. The operating system plug-ins are add on plug-ins for the lldb_private::Process class that can add thread contexts that are read from memory. It is common in kernels to have a lot of threads that are not currently executing on any cores (JTAG debugging also follows this sort of thing) and are context switched out whose state is stored in memory data structures. Clients can now subclass the OperatingSystem plug-ins and then make sure their Create functions correcltly only enable themselves when the right binary/target triple are being debugged. The operating system plug-ins get a chance to attach themselves to processes just after launching or attaching and are given a lldb_private::Process object pointer which can be inspected to see if the main executable, target triple, or any shared libraries match a case where the OS plug-in should be used. Currently the OS plug-ins can create new threads, define the register contexts for these threads (which can all be different if desired), and populate and manage the thread info (stop reason, registers in the register context) as the debug session goes on. Added: lldb/trunk/include/lldb/Target/OperatingSystem.h lldb/trunk/source/Plugins/OperatingSystem/ lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/ lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.cpp lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.h lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.h lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h lldb/trunk/source/Target/OperatingSystem.cpp Modified: lldb/trunk/include/lldb/Core/DataExtractor.h lldb/trunk/include/lldb/Core/PluginManager.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/include/lldb/Target/ThreadList.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/include/lldb/lldb-private-interfaces.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/FormatClasses.cpp lldb/trunk/source/Core/PluginManager.cpp lldb/trunk/source/Core/Section.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h 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/Plugins/Process/gdb-remote/ThreadGDBRemote.h lldb/trunk/source/Target/ABI.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadList.cpp lldb/trunk/source/lldb.cpp Modified: lldb/trunk/include/lldb/Core/DataExtractor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataExtractor.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/DataExtractor.h (original) +++ lldb/trunk/include/lldb/Core/DataExtractor.h Sun Aug 21 21:49:39 2011 @@ -999,6 +999,12 @@ uint64_t GetULEB128 (uint32_t *offset_ptr) const; + lldb::DataBufferSP & + GetSharedDataBuffer () + { + return m_data_sp; + } + //------------------------------------------------------------------ /// Peek at a C string at \a offset. /// Modified: lldb/trunk/include/lldb/Core/PluginManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/PluginManager.h (original) +++ lldb/trunk/include/lldb/Core/PluginManager.h Sun Aug 21 21:49:39 2011 @@ -97,6 +97,23 @@ GetEmulateInstructionCreateCallbackForPluginName (const char *name); //------------------------------------------------------------------ + // OperatingSystem + //------------------------------------------------------------------ + static bool + RegisterPlugin (const char *name, + const char *description, + OperatingSystemCreateInstance create_callback); + + static bool + UnregisterPlugin (OperatingSystemCreateInstance create_callback); + + static OperatingSystemCreateInstance + GetOperatingSystemCreateCallbackAtIndex (uint32_t idx); + + static OperatingSystemCreateInstance + GetOperatingSystemCreateCallbackForPluginName (const char *name); + + //------------------------------------------------------------------ // LanguageRuntime //------------------------------------------------------------------ static bool Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Sun Aug 21 21:49:39 2011 @@ -598,8 +598,8 @@ virtual const char * GetValueAsCString (); - virtual unsigned long long - GetValueAsUnsigned(); + virtual uint64_t + GetValueAsUnsigned (uint64_t fail_value); virtual bool SetValueFromCString (const char *value_str); Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Sun Aug 21 21:49:39 2011 @@ -67,6 +67,19 @@ virtual bool CodeAddressIsValid (lldb::addr_t pc) = 0; + virtual const RegisterInfo * + GetRegisterInfoArray (uint32_t &count) = 0; + + + + bool + GetRegisterInfoByName (const ConstString &name, RegisterInfo &info); + + bool + GetRegisterInfoByKind (lldb::RegisterKind reg_kind, + uint32_t reg_num, + RegisterInfo &info); + static lldb::ABISP FindPlugin (const ArchSpec &arch); Added: lldb/trunk/include/lldb/Target/OperatingSystem.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/OperatingSystem.h?rev=138228&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/OperatingSystem.h (added) +++ lldb/trunk/include/lldb/Target/OperatingSystem.h Sun Aug 21 21:49:39 2011 @@ -0,0 +1,90 @@ +//===-- OperatingSystem.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_OperatingSystem_h_ +#define liblldb_OperatingSystem_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes + +#include "lldb/lldb-private.h" +#include "lldb/Core/PluginInterface.h" + +namespace lldb_private { + +//---------------------------------------------------------------------- +/// @class OperatingSystem OperatingSystem.h "lldb/Target/OperatingSystem.h" +/// @brief A plug-in interface definition class for halted OS helpers. +/// +/// Halted OS plug-ins can be used by any process to locate and create +/// OS objects, like threads, during the lifetime of a debug session. +/// This is commonly used when attaching to an operating system that is +/// halted, such as when debugging over JTAG or connecting to low level +/// kernel debug services. +//---------------------------------------------------------------------- + +class OperatingSystem : + public PluginInterface + +{ +public: + //------------------------------------------------------------------ + /// Find a halted OS plugin for a given process. + /// + /// Scans the installed OperatingSystem plug-ins and tries to find + /// an instance that matches the current target triple and + /// executable. + /// + /// @param[in] process + /// The process for which to try and locate a halted OS + /// plug-in instance. + /// + /// @param[in] plugin_name + /// An optional name of a specific halted OS plug-in that + /// should be used. If NULL, pick the best plug-in. + //------------------------------------------------------------------ + static OperatingSystem* + FindPlugin (Process *process, const char *plugin_name); + + //------------------------------------------------------------------ + // Class Methods + //------------------------------------------------------------------ + OperatingSystem (Process *process); + + virtual + ~OperatingSystem(); + + //------------------------------------------------------------------ + // Plug-in Methods + //------------------------------------------------------------------ + virtual uint32_t + UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) = 0; + + virtual void + ThreadWasSelected (Thread *thread) = 0; + + virtual lldb::RegisterContextSP + CreateRegisterContextForThread (Thread *thread) = 0; + + virtual lldb::StopInfoSP + CreateThreadStopReason (Thread *thread) = 0; + +protected: + //------------------------------------------------------------------ + // Member variables. + //------------------------------------------------------------------ + Process* m_process; ///< The process that this dynamic loader plug-in is tracking. +private: + DISALLOW_COPY_AND_ASSIGN (OperatingSystem); +}; + +} // namespace lldb_private + +#endif // #ifndef liblldb_OperatingSystem_h_ Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Sun Aug 21 21:49:39 2011 @@ -2515,7 +2515,10 @@ // Thread Queries //------------------------------------------------------------------ virtual uint32_t - UpdateThreadListIfNeeded () = 0; + UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) = 0; + + void + UpdateThreadListIfNeeded (); ThreadList & GetThreadList () @@ -2523,11 +2526,6 @@ return m_thread_list; } - const ThreadList & - GetThreadList () const - { - return m_thread_list; - } uint32_t GetNextThreadIndexID (); @@ -2620,6 +2618,13 @@ return m_dyld_ap.get(); } + OperatingSystem * + GetOperatingSystem () + { + return m_os_ap.get(); + } + + virtual LanguageRuntime * GetLanguageRuntime (lldb::LanguageType language); @@ -2796,6 +2801,7 @@ ///< to insert in the target. std::auto_ptr m_dyld_ap; std::auto_ptr m_dynamic_checkers_ap; ///< The functions used by the expression parser to validate data that expressions use. + std::auto_ptr m_os_ap; UnixSignals m_unix_signals; /// This is the current signal set for this process. lldb::ABISP m_abi_sp; lldb::InputReaderSP m_process_input_reader; Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Sun Aug 21 21:49:39 2011 @@ -206,10 +206,16 @@ virtual ~Thread(); Process & - GetProcess() { return m_process; } + GetProcess() + { + return m_process; + } const Process & - GetProcess() const { return m_process; } + GetProcess() const + { + return m_process; + } int GetResumeSignal () const @@ -302,7 +308,10 @@ StopReasonAsCString (lldb::StopReason reason); virtual const char * - GetInfo () = 0; + GetInfo () + { + return NULL; + } virtual const char * GetName () @@ -757,7 +766,7 @@ RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint); virtual lldb_private::Unwind * - GetUnwinder () = 0; + GetUnwinder (); StackFrameList & GetStackFrameList (); Modified: lldb/trunk/include/lldb/Target/ThreadList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadList.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadList.h (original) +++ lldb/trunk/include/lldb/Target/ThreadList.h Sun Aug 21 21:49:39 2011 @@ -105,6 +105,9 @@ return m_threads_mutex; } + void + Update (ThreadList &rhs); + protected: typedef std::vector collection; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Sun Aug 21 21:49:39 2011 @@ -98,6 +98,7 @@ class ObjCLanguageRuntime; class ObjectContainer; class ObjectFile; +class OperatingSystem; class Options; class OptionValue; class NamedOption; Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-interfaces.h (original) +++ lldb/trunk/include/lldb/lldb-private-interfaces.h Sun Aug 21 21:49:39 2011 @@ -23,6 +23,7 @@ typedef ObjectFile* (*ObjectFileCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec* file, lldb::addr_t offset, lldb::addr_t length); typedef LogChannel* (*LogChannelCreateInstance) (); typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch, InstructionType inst_type); + typedef OperatingSystem* (*OperatingSystemCreateInstance) (Process *process, bool force); typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language); typedef Platform* (*PlatformCreateInstance) (); typedef Process* (*ProcessCreateInstance) (Target &target, Listener &listener); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun Aug 21 21:49:39 2011 @@ -14,6 +14,7 @@ 2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2628A4D513D4977900F5487A /* ThreadKDP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628A4D313D4977900F5487A /* ThreadKDP.cpp */; }; 262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; }; + 262D24E613FB8710002D1960 /* RegisterContextMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 262D24E413FB8710002D1960 /* RegisterContextMemory.cpp */; }; 26368A3C126B697600E8659F /* darwin-debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26368A3B126B697600E8659F /* darwin-debug.cpp */; }; 26368AF7126B960500E8659F /* darwin-debug in Resources */ = {isa = PBXBuildFile; fileRef = 26579F68126A25920007C5CB /* darwin-debug */; }; 263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263E949D13661AE400E7D1CE /* UnwindAssembly-x86.cpp */; }; @@ -70,6 +71,8 @@ 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 */; }; + 266DFE9413FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266DFE9213FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp */; }; + 266DFE9713FD656E00D0C574 /* OperatingSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266DFE9613FD656E00D0C574 /* OperatingSystem.cpp */; }; 266E8C6A13528ABC000C2042 /* lldb-platform in Resources */ = {isa = PBXBuildFile; fileRef = 26DC6A101337FE6900FF7998 /* lldb-platform */; }; 2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2671A0CF13482601003A87BB /* ConnectionMachPort.cpp */; }; 26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EED1338317700EF765A /* GDBRemoteCommunicationClient.cpp */; }; @@ -330,6 +333,7 @@ 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; 2690B3711381D5C300ECFBAE /* Memory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2690B3701381D5C300ECFBAE /* Memory.cpp */; }; 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */; }; + 26954EBE1401EE8B00294D09 /* DynamicRegisterInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26954EBC1401EE8B00294D09 /* DynamicRegisterInfo.cpp */; }; 26957D9813D381C900670048 /* RegisterContextDarwin_arm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26957D9213D381C900670048 /* RegisterContextDarwin_arm.cpp */; }; 26957D9A13D381C900670048 /* RegisterContextDarwin_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26957D9413D381C900670048 /* RegisterContextDarwin_i386.cpp */; }; 26957D9C13D381C900670048 /* RegisterContextDarwin_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26957D9613D381C900670048 /* RegisterContextDarwin_x86_64.cpp */; }; @@ -380,6 +384,7 @@ 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */; }; 26ED3D6D13C563810017D45E /* OptionGroupVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26ED3D6C13C563810017D45E /* OptionGroupVariable.cpp */; }; 26F4214413C6515B00E04E5E /* DynamicLoaderMacOSXKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F4214113C6515B00E04E5E /* DynamicLoaderMacOSXKernel.cpp */; }; + 26F4A21C13FBA31A0064B613 /* ThreadMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F4A21A13FBA31A0064B613 /* ThreadMemory.cpp */; }; 26F5C27710F3D9E4009D5894 /* Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27310F3D9E4009D5894 /* Driver.cpp */; }; 26F5C27810F3D9E4009D5894 /* IOChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27510F3D9E4009D5894 /* IOChannel.cpp */; }; 26F5C32510F3DF23009D5894 /* libpython.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython.dylib */; }; @@ -388,7 +393,6 @@ 26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; }; 26F5C39110F3FA26009D5894 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; 26F73062139D8FDB00FD51C7 /* History.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F73061139D8FDB00FD51C7 /* History.cpp */; }; - 49C850771384A02F007DB519 /* ProcessDataAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 49C850761384A02F007DB519 /* ProcessDataAllocator.h */; }; 49C8507C1384A786007DB519 /* ProcessDataAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C850781384A0CA007DB519 /* ProcessDataAllocator.cpp */; }; 49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; @@ -603,6 +607,8 @@ 2623096E13D0EFFB006381D9 /* StreamBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamBuffer.h; path = include/lldb/Core/StreamBuffer.h; sourceTree = ""; }; 2628A4D313D4977900F5487A /* ThreadKDP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadKDP.cpp; sourceTree = ""; }; 2628A4D413D4977900F5487A /* ThreadKDP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadKDP.h; sourceTree = ""; }; + 262D24E413FB8710002D1960 /* RegisterContextMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextMemory.cpp; path = Utility/RegisterContextMemory.cpp; sourceTree = ""; }; + 262D24E513FB8710002D1960 /* RegisterContextMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextMemory.h; path = Utility/RegisterContextMemory.h; sourceTree = ""; }; 263664921140A4930075843B /* Debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = Debugger.cpp; path = source/Core/Debugger.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 263664941140A4C10075843B /* Debugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Debugger.h; path = include/lldb/Core/Debugger.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 26368A3B126B697600E8659F /* darwin-debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "darwin-debug.cpp"; path = "tools/darwin-debug/darwin-debug.cpp"; sourceTree = ""; }; @@ -657,6 +663,10 @@ 266960631199F4230075C61A /* sed-sources */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "sed-sources"; sourceTree = ""; }; 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangNamespaceDecl.cpp; path = source/Symbol/ClangNamespaceDecl.cpp; sourceTree = ""; }; 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangNamespaceDecl.h; path = include/lldb/Symbol/ClangNamespaceDecl.h; sourceTree = ""; }; + 266DFE9213FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OperatingSystemMacOSXKernel.cpp; sourceTree = ""; }; + 266DFE9313FD64D200D0C574 /* OperatingSystemMacOSXKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OperatingSystemMacOSXKernel.h; sourceTree = ""; }; + 266DFE9613FD656E00D0C574 /* OperatingSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OperatingSystem.cpp; path = source/Target/OperatingSystem.cpp; sourceTree = ""; }; + 266DFE9813FD658300D0C574 /* OperatingSystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OperatingSystem.h; path = include/lldb/Target/OperatingSystem.h; sourceTree = ""; }; 266F5CBB12FC846200DFCE33 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/Config.h; sourceTree = ""; }; 2671A0CD134825F6003A87BB /* ConnectionMachPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ConnectionMachPort.h; path = include/lldb/Core/ConnectionMachPort.h; sourceTree = ""; }; 2671A0CF13482601003A87BB /* ConnectionMachPort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConnectionMachPort.cpp; path = source/Core/ConnectionMachPort.cpp; sourceTree = ""; }; @@ -698,6 +708,8 @@ 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnwindAssemblyInstEmulation.h; sourceTree = ""; }; 269416AD119A024800FF2715 /* CommandObjectTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectTarget.cpp; path = source/Commands/CommandObjectTarget.cpp; sourceTree = ""; }; 269416AE119A024800FF2715 /* CommandObjectTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectTarget.h; path = source/Commands/CommandObjectTarget.h; sourceTree = ""; }; + 26954EBC1401EE8B00294D09 /* DynamicRegisterInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DynamicRegisterInfo.cpp; path = Utility/DynamicRegisterInfo.cpp; sourceTree = ""; }; + 26954EBD1401EE8B00294D09 /* DynamicRegisterInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DynamicRegisterInfo.h; path = Utility/DynamicRegisterInfo.h; sourceTree = ""; }; 26957D9213D381C900670048 /* RegisterContextDarwin_arm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextDarwin_arm.cpp; path = Utility/RegisterContextDarwin_arm.cpp; sourceTree = ""; }; 26957D9313D381C900670048 /* RegisterContextDarwin_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextDarwin_arm.h; path = Utility/RegisterContextDarwin_arm.h; sourceTree = ""; }; 26957D9413D381C900670048 /* RegisterContextDarwin_i386.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextDarwin_i386.cpp; path = Utility/RegisterContextDarwin_i386.cpp; sourceTree = ""; }; @@ -1046,6 +1058,8 @@ 26ED3D6F13C5638A0017D45E /* OptionGroupVariable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupVariable.h; path = include/lldb/Interpreter/OptionGroupVariable.h; sourceTree = ""; }; 26F4214113C6515B00E04E5E /* DynamicLoaderMacOSXKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLoaderMacOSXKernel.cpp; sourceTree = ""; }; 26F4214213C6515B00E04E5E /* DynamicLoaderMacOSXKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicLoaderMacOSXKernel.h; sourceTree = ""; }; + 26F4A21A13FBA31A0064B613 /* ThreadMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadMemory.cpp; path = Utility/ThreadMemory.cpp; sourceTree = ""; }; + 26F4A21B13FBA31A0064B613 /* ThreadMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadMemory.h; path = Utility/ThreadMemory.h; sourceTree = ""; }; 26F5C26A10F3D9A4009D5894 /* lldb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lldb; sourceTree = BUILT_PRODUCTS_DIR; }; 26F5C27210F3D9E4009D5894 /* lldb-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "lldb-Info.plist"; path = "tools/driver/lldb-Info.plist"; sourceTree = ""; }; 26F5C27310F3D9E4009D5894 /* Driver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Driver.cpp; path = tools/driver/Driver.cpp; sourceTree = ""; }; @@ -1344,6 +1358,7 @@ 26BC7E7510F1B85900F91463 /* lldb-log.cpp */, 26BC7C2A10F1B3BC00F91463 /* lldb-private.h */, 26217932133BCB850083B112 /* lldb-private-enumerations.h */, + 26BC7C2810F1B3BC00F91463 /* lldb-private-interfaces.h */, 26BC7D5D10F1B77400F91463 /* lldb-private-log.h */, 26217930133BC8640083B112 /* lldb-private-types.h */, 262D3190111B4341004E6F88 /* API */, @@ -1384,6 +1399,7 @@ 4CCA643A13B40B82003BDF98 /* LanguageRuntime */, 260C897E10F57C5600BB2B04 /* ObjectContainer */, 260C898210F57C5600BB2B04 /* ObjectFile */, + 266DFE9013FD64D200D0C574 /* OperatingSystem */, 26C5577E132575B6008FD8FE /* Platform */, 260C898A10F57C5600BB2B04 /* Process */, 260C89B110F57C5600BB2B04 /* SymbolFile */, @@ -1424,8 +1440,8 @@ 260C897910F57C5600BB2B04 /* MacOSX-DYLD */ = { isa = PBXGroup; children = ( - 260C897B10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.h */, 260C897A10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.cpp */, + 260C897B10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.h */, ); path = "MacOSX-DYLD"; sourceTree = ""; @@ -1741,6 +1757,23 @@ path = Python; sourceTree = ""; }; + 266DFE9013FD64D200D0C574 /* OperatingSystem */ = { + isa = PBXGroup; + children = ( + 266DFE9113FD64D200D0C574 /* MacOSX-Kernel */, + ); + path = OperatingSystem; + sourceTree = ""; + }; + 266DFE9113FD64D200D0C574 /* MacOSX-Kernel */ = { + isa = PBXGroup; + children = ( + 266DFE9213FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp */, + 266DFE9313FD64D200D0C574 /* OperatingSystemMacOSXKernel.h */, + ); + path = "MacOSX-Kernel"; + sourceTree = ""; + }; 2682F168115ED9C800CCFF99 /* Utility */ = { isa = PBXGroup; children = ( @@ -1816,6 +1849,8 @@ B2D3033612EFA5C500F84EB3 /* InstructionUtils.h */, B287E63E12EFAE2C00C9BEFE /* ARMDefines.h */, B23DD24F12EDFAC1000C3894 /* ARMUtils.h */, + 26954EBC1401EE8B00294D09 /* DynamicRegisterInfo.cpp */, + 26954EBD1401EE8B00294D09 /* DynamicRegisterInfo.h */, B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */, B28058A2139988C6002D96D0 /* InferiorCallPOSIX.h */, AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */, @@ -1828,10 +1863,14 @@ 26957D9713D381C900670048 /* RegisterContextDarwin_x86_64.h */, AF68D2541255416E002FF25B /* RegisterContextLLDB.cpp */, AF68D2551255416E002FF25B /* RegisterContextLLDB.h */, + 262D24E413FB8710002D1960 /* RegisterContextMemory.cpp */, + 262D24E513FB8710002D1960 /* RegisterContextMemory.h */, 26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */, 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */, 2615DBC91208B5FC0021781D /* StopInfoMachException.h */, 2615DBC81208B5FC0021781D /* StopInfoMachException.cpp */, + 26F4A21A13FBA31A0064B613 /* ThreadMemory.cpp */, + 26F4A21B13FBA31A0064B613 /* ThreadMemory.h */, 26E3EEE411A9901300FBADB6 /* UnwindMacOSXFrameBackchain.h */, 26E3EEE311A9901300FBADB6 /* UnwindMacOSXFrameBackchain.cpp */, ); @@ -1922,6 +1961,8 @@ 26BC7E8310F1B85900F91463 /* ModuleList.cpp */, 26651A15133BF9CC005B64B7 /* Opcode.h */, 26651A17133BF9DF005B64B7 /* Opcode.cpp */, + 266DFE9813FD658300D0C574 /* OperatingSystem.h */, + 266DFE9613FD656E00D0C574 /* OperatingSystem.cpp */, 26BC7D7010F1B77400F91463 /* PluginInterface.h */, 26BC7D7110F1B77400F91463 /* PluginManager.h */, 26BC7E8A10F1B85900F91463 /* PluginManager.cpp */, @@ -2150,7 +2191,6 @@ 26BC7DBE10F1B78200F91463 /* Expression */ = { isa = PBXGroup; children = ( - 26BC7C2810F1B3BC00F91463 /* lldb-private-interfaces.h */, 49D7072611B5AD03001AD875 /* ClangASTSource.h */, 49D7072811B5AD11001AD875 /* ClangASTSource.cpp */, 26BC7DC010F1B79500F91463 /* ClangExpression.h */, @@ -2650,7 +2690,6 @@ 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */, 26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */, 26D265BC136B4269002EEE45 /* lldb-public.h in Headers */, - 49C850771384A02F007DB519 /* ProcessDataAllocator.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3250,6 +3289,11 @@ 26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */, B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */, 94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */, + 262D24E613FB8710002D1960 /* RegisterContextMemory.cpp in Sources */, + 26F4A21C13FBA31A0064B613 /* ThreadMemory.cpp in Sources */, + 266DFE9413FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp in Sources */, + 266DFE9713FD656E00D0C574 /* OperatingSystem.cpp in Sources */, + 26954EBE1401EE8B00294D09 /* DynamicRegisterInfo.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/FormatClasses.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatClasses.cpp (original) +++ lldb/trunk/source/Core/FormatClasses.cpp Sun Aug 21 21:49:39 2011 @@ -132,7 +132,7 @@ // by the expression, but in host memory. because Python code might need to read // into the object memory in non-obvious ways, we need to hand it the target version // of the expression output - lldb::addr_t tgt_address = object->GetValueAsUnsigned(); + lldb::addr_t tgt_address = object->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); target_object = ValueObjectConstResult::Create (object->GetExecutionContextScope(), object->GetClangAST(), object->GetClangType(), @@ -208,8 +208,8 @@ SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass, lldb::ValueObjectSP be) : -SyntheticChildrenFrontEnd(be), -m_python_class(pclass) + SyntheticChildrenFrontEnd(be), + m_python_class(pclass) { if (be.get() == NULL) { @@ -227,7 +227,7 @@ // by the expression, but in host memory. because Python code might need to read // into the object memory in non-obvious ways, we need to hand it the target version // of the expression output - lldb::addr_t tgt_address = be->GetValueAsUnsigned(); + lldb::addr_t tgt_address = be->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); m_backend = ValueObjectConstResult::Create (be->GetExecutionContextScope(), be->GetClangAST(), be->GetClangType(), Modified: lldb/trunk/source/Core/PluginManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Core/PluginManager.cpp (original) +++ lldb/trunk/source/Core/PluginManager.cpp Sun Aug 21 21:49:39 2011 @@ -640,6 +640,110 @@ } return NULL; } +#pragma mark OperatingSystem + + +struct OperatingSystemInstance +{ + OperatingSystemInstance() : + name(), + description(), + create_callback(NULL) + { + } + + std::string name; + std::string description; + OperatingSystemCreateInstance create_callback; +}; + +typedef std::vector OperatingSystemInstances; + +static Mutex & +GetOperatingSystemMutex () +{ + static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + return g_instances_mutex; +} + +static OperatingSystemInstances & +GetOperatingSystemInstances () +{ + static OperatingSystemInstances g_instances; + return g_instances; +} + +bool +PluginManager::RegisterPlugin +( + const char *name, + const char *description, + OperatingSystemCreateInstance create_callback + ) +{ + if (create_callback) + { + OperatingSystemInstance instance; + assert (name && name[0]); + instance.name = name; + if (description && description[0]) + instance.description = description; + instance.create_callback = create_callback; + Mutex::Locker locker (GetOperatingSystemMutex ()); + GetOperatingSystemInstances ().push_back (instance); + } + return false; +} + +bool +PluginManager::UnregisterPlugin (OperatingSystemCreateInstance create_callback) +{ + if (create_callback) + { + Mutex::Locker locker (GetOperatingSystemMutex ()); + OperatingSystemInstances &instances = GetOperatingSystemInstances (); + + OperatingSystemInstances::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; +} + +OperatingSystemCreateInstance +PluginManager::GetOperatingSystemCreateCallbackAtIndex (uint32_t idx) +{ + Mutex::Locker locker (GetOperatingSystemMutex ()); + OperatingSystemInstances &instances = GetOperatingSystemInstances (); + if (idx < instances.size()) + return instances[idx].create_callback; + return NULL; +} + +OperatingSystemCreateInstance +PluginManager::GetOperatingSystemCreateCallbackForPluginName (const char *name) +{ + if (name && name[0]) + { + llvm::StringRef name_sref(name); + Mutex::Locker locker (GetOperatingSystemMutex ()); + OperatingSystemInstances &instances = GetOperatingSystemInstances (); + + OperatingSystemInstances::iterator pos, end = instances.end(); + for (pos = instances.begin(); pos != end; ++ pos) + { + if (name_sref.equals (pos->name)) + return pos->create_callback; + } + } + return NULL; +} #pragma mark LanguageRuntime Modified: lldb/trunk/source/Core/Section.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Core/Section.cpp (original) +++ lldb/trunk/source/Core/Section.cpp Sun Aug 21 21:49:39 2011 @@ -117,7 +117,9 @@ addr_t load_base_addr = LLDB_INVALID_ADDRESS; if (m_linked_section) { - load_base_addr = m_linked_section->GetLoadBaseAddress(target) + m_linked_offset; + load_base_addr = m_linked_section->GetLoadBaseAddress(target); + if (load_base_addr != LLDB_INVALID_ADDRESS) + load_base_addr += m_linked_offset; } else if (m_parent) Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Sun Aug 21 21:49:39 2011 @@ -937,20 +937,17 @@ // if > 8bytes, 0 is returned. this method should mostly be used // to read address values out of pointers -unsigned long long -ValueObject::GetValueAsUnsigned() +uint64_t +ValueObject::GetValueAsUnsigned (uint64_t fail_value) { // If our byte size is zero this is an aggregate type that has children if (ClangASTContext::IsAggregateType (GetClangType()) == false) { - if (UpdateValueIfNeeded(true)) - { - uint32_t offset = 0; - return m_data.GetMaxU64(&offset, - m_data.GetByteSize()); - } + Scalar scalar; + if (ResolveValue (scalar)) + return scalar.GetRawBits64(fail_value); } - return 0; + return fail_value; } bool Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Sun Aug 21 21:49:39 2011 @@ -26,6 +26,7 @@ #include "llvm/ADT/Triple.h" #include "Utility/ARM_DWARF_Registers.h" +#include "Utility/ARM_GCC_Registers.h" #include "Plugins/Process/Utility/ARMDefines.h" #include @@ -37,6 +38,141 @@ static const char *pluginDesc = "Mac OS X ABI for arm targets"; static const char *pluginShort = "abi.macosx-arm"; + +static RegisterInfo g_register_infos[] = +{ + // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB NATIVE + // ========== ======= == === ============= ============ ======================= =================== =========================== ======================= ====================== + { "r0", "arg1", 4, 0, eEncodingUint , eFormatHex, { gcc_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, gdb_arm_r0, LLDB_INVALID_REGNUM }}, + { "r1", "arg2", 4, 0, eEncodingUint , eFormatHex, { gcc_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, gdb_arm_r1, LLDB_INVALID_REGNUM }}, + { "r2", "arg3", 4, 0, eEncodingUint , eFormatHex, { gcc_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, gdb_arm_r2, LLDB_INVALID_REGNUM }}, + { "r3", "arg4", 4, 0, eEncodingUint , eFormatHex, { gcc_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, gdb_arm_r3, LLDB_INVALID_REGNUM }}, + { "r4", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, gdb_arm_r4, LLDB_INVALID_REGNUM }}, + { "r5", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, gdb_arm_r5, LLDB_INVALID_REGNUM }}, + { "r6", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, gdb_arm_r6, LLDB_INVALID_REGNUM }}, + { "r7", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, gdb_arm_r7, LLDB_INVALID_REGNUM }}, + { "r8", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, gdb_arm_r8, LLDB_INVALID_REGNUM }}, + { "r9", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, gdb_arm_r9, LLDB_INVALID_REGNUM }}, + { "r10", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, gdb_arm_r10, LLDB_INVALID_REGNUM }}, + { "r11", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, gdb_arm_r11, LLDB_INVALID_REGNUM }}, + { "r12", NULL, 4, 0, eEncodingUint , eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, gdb_arm_r12, LLDB_INVALID_REGNUM }}, + { "sp", "r13", 4, 0, eEncodingUint , eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, gdb_arm_sp, LLDB_INVALID_REGNUM }}, + { "lr", "r14", 4, 0, eEncodingUint , eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, gdb_arm_lr, LLDB_INVALID_REGNUM }}, + { "pc", "r15", 4, 0, eEncodingUint , eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, gdb_arm_pc, LLDB_INVALID_REGNUM }}, + { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, gdb_arm_cpsr, LLDB_INVALID_REGNUM }}, + { "s0", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, gdb_arm_s0, LLDB_INVALID_REGNUM }}, + { "s1", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, gdb_arm_s1, LLDB_INVALID_REGNUM }}, + { "s2", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, gdb_arm_s2, LLDB_INVALID_REGNUM }}, + { "s3", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, gdb_arm_s3, LLDB_INVALID_REGNUM }}, + { "s4", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, gdb_arm_s4, LLDB_INVALID_REGNUM }}, + { "s5", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, gdb_arm_s5, LLDB_INVALID_REGNUM }}, + { "s6", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, gdb_arm_s6, LLDB_INVALID_REGNUM }}, + { "s7", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, gdb_arm_s7, LLDB_INVALID_REGNUM }}, + { "s8", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, gdb_arm_s8, LLDB_INVALID_REGNUM }}, + { "s9", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, gdb_arm_s9, LLDB_INVALID_REGNUM }}, + { "s10", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, gdb_arm_s10, LLDB_INVALID_REGNUM }}, + { "s11", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, gdb_arm_s11, LLDB_INVALID_REGNUM }}, + { "s12", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, gdb_arm_s12, LLDB_INVALID_REGNUM }}, + { "s13", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, gdb_arm_s13, LLDB_INVALID_REGNUM }}, + { "s14", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, gdb_arm_s14, LLDB_INVALID_REGNUM }}, + { "s15", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, gdb_arm_s15, LLDB_INVALID_REGNUM }}, + { "s16", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, gdb_arm_s16, LLDB_INVALID_REGNUM }}, + { "s17", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, gdb_arm_s17, LLDB_INVALID_REGNUM }}, + { "s18", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, gdb_arm_s18, LLDB_INVALID_REGNUM }}, + { "s19", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, gdb_arm_s19, LLDB_INVALID_REGNUM }}, + { "s20", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, gdb_arm_s20, LLDB_INVALID_REGNUM }}, + { "s21", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, gdb_arm_s21, LLDB_INVALID_REGNUM }}, + { "s22", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, gdb_arm_s22, LLDB_INVALID_REGNUM }}, + { "s23", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, gdb_arm_s23, LLDB_INVALID_REGNUM }}, + { "s24", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, gdb_arm_s24, LLDB_INVALID_REGNUM }}, + { "s25", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, gdb_arm_s25, LLDB_INVALID_REGNUM }}, + { "s26", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, gdb_arm_s26, LLDB_INVALID_REGNUM }}, + { "s27", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, gdb_arm_s27, LLDB_INVALID_REGNUM }}, + { "s28", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, gdb_arm_s28, LLDB_INVALID_REGNUM }}, + { "s29", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, gdb_arm_s29, LLDB_INVALID_REGNUM }}, + { "s30", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, gdb_arm_s30, LLDB_INVALID_REGNUM }}, + { "s31", NULL, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, gdb_arm_s31, LLDB_INVALID_REGNUM }}, + { "fpscr", NULL, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, gdb_arm_fpscr, LLDB_INVALID_REGNUM }}, + { "d0", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, gdb_arm_d0, LLDB_INVALID_REGNUM }}, + { "d1", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, gdb_arm_d1, LLDB_INVALID_REGNUM }}, + { "d2", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, gdb_arm_d2, LLDB_INVALID_REGNUM }}, + { "d3", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, gdb_arm_d3, LLDB_INVALID_REGNUM }}, + { "d4", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, gdb_arm_d4, LLDB_INVALID_REGNUM }}, + { "d5", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, gdb_arm_d5, LLDB_INVALID_REGNUM }}, + { "d6", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, gdb_arm_d6, LLDB_INVALID_REGNUM }}, + { "d7", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, gdb_arm_d7, LLDB_INVALID_REGNUM }}, + { "d8", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, gdb_arm_d8, LLDB_INVALID_REGNUM }}, + { "d9", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, gdb_arm_d9, LLDB_INVALID_REGNUM }}, + { "d10", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, gdb_arm_d10, LLDB_INVALID_REGNUM }}, + { "d11", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, gdb_arm_d11, LLDB_INVALID_REGNUM }}, + { "d12", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, gdb_arm_d12, LLDB_INVALID_REGNUM }}, + { "d13", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, gdb_arm_d13, LLDB_INVALID_REGNUM }}, + { "d14", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, gdb_arm_d14, LLDB_INVALID_REGNUM }}, + { "d15", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, gdb_arm_d15, LLDB_INVALID_REGNUM }}, + { "d16", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, gdb_arm_d16, LLDB_INVALID_REGNUM }}, + { "d17", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, gdb_arm_d17, LLDB_INVALID_REGNUM }}, + { "d18", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, gdb_arm_d18, LLDB_INVALID_REGNUM }}, + { "d19", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, gdb_arm_d19, LLDB_INVALID_REGNUM }}, + { "d20", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, gdb_arm_d20, LLDB_INVALID_REGNUM }}, + { "d21", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, gdb_arm_d21, LLDB_INVALID_REGNUM }}, + { "d22", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, gdb_arm_d22, LLDB_INVALID_REGNUM }}, + { "d23", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, gdb_arm_d23, LLDB_INVALID_REGNUM }}, + { "d24", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, gdb_arm_d24, LLDB_INVALID_REGNUM }}, + { "d25", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, gdb_arm_d25, LLDB_INVALID_REGNUM }}, + { "d26", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, gdb_arm_d26, LLDB_INVALID_REGNUM }}, + { "d27", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, gdb_arm_d27, LLDB_INVALID_REGNUM }}, + { "d28", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, gdb_arm_d28, LLDB_INVALID_REGNUM }}, + { "d29", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, gdb_arm_d29, LLDB_INVALID_REGNUM }}, + { "d30", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, gdb_arm_d30, LLDB_INVALID_REGNUM }}, + { "d31", NULL, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, gdb_arm_d31, LLDB_INVALID_REGNUM }}, + { "r8_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r8_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r9_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r9_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r10_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r10_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r11_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r11_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r12_usr", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r12_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r13_usr", "sp_usr", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r14_usr", "lr_usr", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r8_fiq", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r8_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r9_fiq", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r9_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r10_fiq", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r10_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r11_fiq", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r11_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r12_fiq", NULL, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r12_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r13_fiq", "sp_fiq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r14_fiq", "lr_fiq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r13_irq", "sp_irq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_irq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r14_irq", "lr_irq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_irq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r13_abt", "sp_abt", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_abt, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r14_abt", "lr_abt", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_abt, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r13_und", "sp_und", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_und, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r14_und", "lr_und", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_und, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r13_svc", "sp_svc", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_svc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }}, + { "r14_svc", "lr_svc", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_svc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }} +}; +static const uint32_t k_num_register_infos = sizeof(g_register_infos)/sizeof(RegisterInfo); +static bool g_register_info_names_constified = false; + +const lldb_private::RegisterInfo * +ABIMacOSX_arm::GetRegisterInfoArray (uint32_t &count) +{ + // Make the C-string names and alt_names for the register infos into const + // C-string values by having the ConstString unique the names in the global + // constant C-string pool. + if (!g_register_info_names_constified) + { + g_register_info_names_constified = true; + for (uint32_t i=0; iGetTarget().GetExecutableModulePointer(); + if (exe_module) + { + ObjectFile *object_file = exe_module->GetObjectFile(); + if (object_file) + { + SectionList *section_list = object_file->GetSectionList(); + if (section_list) + { + static ConstString g_kld_section_name ("__KLD"); + if (section_list->FindSectionByName (g_kld_section_name)) + { + create = true; + } + } + } + } + + // We can limit the creation of this plug-in to "*-apple-darwin" triples + // if we command out the lines below... +// if (create) +// { +// const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple(); +// create = triple_ref.getOS() == llvm::Triple::Darwin && triple_ref.getVendor() == llvm::Triple::Apple; +// } + } + + if (create) + return new OperatingSystemMacOSXKernel (process); +#endif + return NULL; +} + + +const char * +OperatingSystemMacOSXKernel::GetPluginNameStatic() +{ + return "macosx-kernel"; +} + +const char * +OperatingSystemMacOSXKernel::GetPluginDescriptionStatic() +{ + return "Operating system plug-in that gathers OS information from darwin kernels."; +} + + +OperatingSystemMacOSXKernel::OperatingSystemMacOSXKernel (lldb_private::Process *process) : + OperatingSystem (process), + m_thread_list_valobj_sp (), + m_register_info_ap () +{ +} + +OperatingSystemMacOSXKernel::~OperatingSystemMacOSXKernel () +{ +} + +ValueObjectSP +OperatingSystemMacOSXKernel::GetThreadListValueObject () +{ + if (m_thread_list_valobj_sp.get() == NULL) + { + VariableList variable_list; + const uint32_t max_matches = 1; + const bool append = true; + static ConstString g_thread_list_name("g_thread_list"); + Module *exe_module = m_process->GetTarget().GetExecutableModulePointer(); + if (exe_module) + { + if (exe_module->FindGlobalVariables (g_thread_list_name, + append, + max_matches, + variable_list)) + { + m_thread_list_valobj_sp = ValueObjectVariable::Create (m_process, variable_list.GetVariableAtIndex(0)); + } + } + } + return m_thread_list_valobj_sp; +} + +DynamicRegisterInfo * +OperatingSystemMacOSXKernel::GetDynamicRegisterInfo () +{ + if (m_register_info_ap.get() == NULL && m_thread_list_valobj_sp) + { + m_register_info_ap.reset (new DynamicRegisterInfo()); + ConstString empty_name; + const bool can_create = true; + AddressType addr_type; + addr_t base_addr = LLDB_INVALID_ADDRESS; + ValueObjectSP gpr_valobj_sp (m_thread_list_valobj_sp->GetChildMemberWithName(GetThreadGPRMemberName (), can_create)); + + if (gpr_valobj_sp->IsPointerType ()) + base_addr = gpr_valobj_sp->GetPointerValue (addr_type, true); + else + base_addr = gpr_valobj_sp->GetAddressOf (addr_type, true); + + ValueObjectSP child_valobj_sp; + if (gpr_valobj_sp) + { + ABI *abi = m_process->GetABI().get(); + assert (abi); + uint32_t num_children = gpr_valobj_sp->GetNumChildren(); + + ConstString gpr_name (gpr_valobj_sp->GetName()); + uint32_t reg_num = 0; + for (uint32_t i=0; iGetChildAtIndex(i, can_create); + + ConstString reg_name(child_valobj_sp->GetName()); + if (reg_name) + { + const char *reg_name_cstr = reg_name.GetCString(); + while (reg_name_cstr[0] == '_') + ++reg_name_cstr; + if (reg_name_cstr != reg_name.GetCString()) + reg_name.SetCString (reg_name_cstr); + } + + RegisterInfo reg_info; + if (abi->GetRegisterInfoByName(reg_name, reg_info)) + { + // Adjust the byte size and the offset to match the layout of registers in our struct + reg_info.byte_size = child_valobj_sp->GetByteSize(); + reg_info.byte_offset = child_valobj_sp->GetAddressOf(addr_type, true) - base_addr; + reg_info.kinds[eRegisterKindLLDB] = reg_num++; + m_register_info_ap->AddRegister (reg_info, reg_name, empty_name, gpr_name); + } + else + { + printf ("not able to find register info for %s\n", reg_name.GetCString()); // REMOVE THIS printf before checkin!!! + } + } + + m_register_info_ap->Finalize(); + } + } + assert (m_register_info_ap.get()); + return m_register_info_ap.get(); +} + +//------------------------------------------------------------------ +// PluginInterface protocol +//------------------------------------------------------------------ +const char * +OperatingSystemMacOSXKernel::GetPluginName() +{ + return "OperatingSystemMacOSXKernel"; +} + +const char * +OperatingSystemMacOSXKernel::GetShortPluginName() +{ + return GetPluginNameStatic(); +} + +uint32_t +OperatingSystemMacOSXKernel::GetPluginVersion() +{ + return 1; +} + +uint32_t +OperatingSystemMacOSXKernel::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) +{ + // Make any constant strings once and cache the uniqued C string values + // so we don't have to rehash them each time through this function call + static ConstString g_tid_member_name("tid"); + static ConstString g_next_member_name("next"); + + ValueObjectSP root_valobj_sp (GetThreadListValueObject ()); + ValueObjectSP valobj_sp = root_valobj_sp; + const bool can_create = true; + while (valobj_sp) + { + if (valobj_sp->GetValueAsUnsigned(0) == 0) + break; + + ValueObjectSP tid_valobj_sp(valobj_sp->GetChildMemberWithName(g_tid_member_name, can_create)); + if (!tid_valobj_sp) + break; + + tid_t tid = tid_valobj_sp->GetValueAsUnsigned (LLDB_INVALID_THREAD_ID); + if (tid == LLDB_INVALID_THREAD_ID) + break; + + ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false)); + if (!thread_sp) + thread_sp.reset (new ThreadMemory (*m_process, tid, valobj_sp)); + + new_thread_list.AddThread(thread_sp); + + ValueObjectSP next_valobj_sp (valobj_sp->GetChildMemberWithName(g_next_member_name, can_create)); + + if (next_valobj_sp) + { + // Watch for circular linked lists + if (next_valobj_sp.get() == root_valobj_sp.get()) + break; + } + next_valobj_sp.swap(valobj_sp); + } + return new_thread_list.GetSize(false); +} + +void +OperatingSystemMacOSXKernel::ThreadWasSelected (Thread *thread) +{ +} + +RegisterContextSP +OperatingSystemMacOSXKernel::CreateRegisterContextForThread (Thread *thread) +{ + ThreadMemory *generic_thread = (ThreadMemory *)thread; + RegisterContextSP reg_ctx_sp; + + ValueObjectSP thread_valobj_sp (generic_thread->GetValueObject()); + if (thread_valobj_sp) + { + const bool can_create = true; + AddressType addr_type; + addr_t base_addr = LLDB_INVALID_ADDRESS; + ValueObjectSP gpr_valobj_sp (thread_valobj_sp->GetChildMemberWithName(GetThreadGPRMemberName (), can_create)); + if (gpr_valobj_sp) + { + if (gpr_valobj_sp->IsPointerType ()) + base_addr = gpr_valobj_sp->GetPointerValue (addr_type, true); + else + base_addr = gpr_valobj_sp->GetAddressOf (addr_type, true); + reg_ctx_sp.reset (new RegisterContextMemory (*thread, 0, *GetDynamicRegisterInfo (), base_addr)); + } + } + return reg_ctx_sp; +} + +StopInfoSP +OperatingSystemMacOSXKernel::CreateThreadStopReason (lldb_private::Thread *thread) +{ + StopInfoSP stop_info_sp; //(StopInfo::CreateStopReasonWithSignal (*thread, SIGSTOP)); + return stop_info_sp; +} + + Added: lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.h?rev=138228&view=auto ============================================================================== --- lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.h (added) +++ lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.h Sun Aug 21 21:49:39 2011 @@ -0,0 +1,90 @@ +//===-- OperatingSystemMacOSXKernel.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_OperatingSystemMacOSXKernel_h_ +#define liblldb_OperatingSystemMacOSXKernel_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +#include "lldb/Target/OperatingSystem.h" + +class DynamicRegisterInfo; + +class OperatingSystemMacOSXKernel : public lldb_private::OperatingSystem +{ +public: + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + static lldb_private::OperatingSystem * + CreateInstance (lldb_private::Process *process, bool force); + + static void + Initialize(); + + static void + Terminate(); + + static const char * + GetPluginNameStatic(); + + static const char * + GetPluginDescriptionStatic(); + + //------------------------------------------------------------------ + // Class Methods + //------------------------------------------------------------------ + OperatingSystemMacOSXKernel (lldb_private::Process *process); + + virtual + ~OperatingSystemMacOSXKernel (); + + //------------------------------------------------------------------ + // lldb_private::PluginInterface Methods + //------------------------------------------------------------------ + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + + //------------------------------------------------------------------ + // lldb_private::OperatingSystem Methods + //------------------------------------------------------------------ + virtual uint32_t + UpdateThreadList (lldb_private::ThreadList &old_thread_list, + lldb_private::ThreadList &new_thread_list); + + virtual void + ThreadWasSelected (lldb_private::Thread *thread); + + virtual lldb::RegisterContextSP + CreateRegisterContextForThread (lldb_private::Thread *thread); + + virtual lldb::StopInfoSP + CreateThreadStopReason (lldb_private::Thread *thread); + +protected: + + lldb::ValueObjectSP + GetThreadListValueObject (); + + DynamicRegisterInfo * + GetDynamicRegisterInfo (); + + lldb::ValueObjectSP m_thread_list_valobj_sp; + std::auto_ptr m_register_info_ap; + +}; + +#endif // #ifndef liblldb_OperatingSystemMacOSXKernel_h_ \ No newline at end of file Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Sun Aug 21 21:49:39 2011 @@ -185,7 +185,7 @@ kernel_arch.SetArchitecture(eArchTypeMachO, cpu, sub); m_target.SetArchitecture(kernel_arch); SetID (1); - UpdateThreadListIfNeeded (); + GetThreadList (); SetPrivateState (eStateStopped); StreamSP async_strm_sp(m_target.GetDebugger().GetAsyncOutputStream()); if (async_strm_sp) @@ -289,34 +289,28 @@ } uint32_t -ProcessKDP::UpdateThreadListIfNeeded () +ProcessKDP::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) { // locker will keep a mutex locked until it goes out of scope LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_THREAD)); if (log && log->GetMask().Test(KDP_LOG_VERBOSE)) log->Printf ("ProcessKDP::%s (pid = %i)", __FUNCTION__, GetID()); - Mutex::Locker locker (m_thread_list.GetMutex ()); - const uint32_t stop_id = GetStopID(); - if (m_thread_list.GetSize(false) == 0) - { - // We currently are making only one thread per core and we - // actually don't know about actual threads. Eventually we - // want to get the thread list from memory and note which - // threads are on CPU as those are the only ones that we - // will be able to resume. - ThreadList curr_thread_list (this); - curr_thread_list.SetStopID(stop_id); - const uint32_t cpu_mask = m_comm.GetCPUMask(); - for (uint32_t cpu_mask_bit = 1; cpu_mask_bit & cpu_mask; cpu_mask_bit <<= 1) - { - // The thread ID is currently the CPU mask bit - ThreadSP thread_sp (new ThreadKDP (*this, cpu_mask_bit)); - curr_thread_list.AddThread(thread_sp); - } - m_thread_list = curr_thread_list; + // We currently are making only one thread per core and we + // actually don't know about actual threads. Eventually we + // want to get the thread list from memory and note which + // threads are on CPU as those are the only ones that we + // will be able to resume. + const uint32_t cpu_mask = m_comm.GetCPUMask(); + for (uint32_t cpu_mask_bit = 1; cpu_mask_bit & cpu_mask; cpu_mask_bit <<= 1) + { + lldb::tid_t tid = cpu_mask_bit; + ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false)); + if (!thread_sp) + thread_sp.reset(new ThreadKDP (*this, tid)); + new_thread_list.AddThread(thread_sp); } - return GetThreadList().GetSize(false); + return new_thread_list.GetSize(false); } Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h Sun Aug 21 21:49:39 2011 @@ -233,7 +233,8 @@ Clear ( ); uint32_t - UpdateThreadListIfNeeded (); + UpdateThreadList (lldb_private::ThreadList &old_thread_list, + lldb_private::ThreadList &new_thread_list); enum { Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp Sun Aug 21 21:49:39 2011 @@ -28,11 +28,6 @@ #include "RegisterContextKDP_arm.h" #include "RegisterContextKDP_i386.h" #include "RegisterContextKDP_x86_64.h" -#include "Plugins/Process/Utility/UnwindLLDB.h" - -#if defined(__APPLE__) -#include "UnwindMacOSXFrameBackchain.h" -#endif using namespace lldb; using namespace lldb_private; @@ -56,14 +51,6 @@ DestroyThread(); } - -const char * -ThreadKDP::GetInfo () -{ - return NULL; -} - - const char * ThreadKDP::GetName () { @@ -124,32 +111,6 @@ GetRegisterContext()->InvalidateIfNeeded (force); } -Unwind * -ThreadKDP::GetUnwinder () -{ - if (m_unwinder_ap.get() == NULL) - { - const ArchSpec target_arch (GetProcess().GetTarget().GetArchitecture ()); - const llvm::Triple::ArchType machine = target_arch.GetMachine(); - switch (machine) - { - case llvm::Triple::x86_64: - case llvm::Triple::x86: - case llvm::Triple::arm: - case llvm::Triple::thumb: - m_unwinder_ap.reset (new UnwindLLDB (*this)); - break; - - default: -#if defined(__APPLE__) - m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this)); -#endif - break; - } - } - return m_unwinder_ap.get(); -} - void ThreadKDP::ClearStackFrames () { Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h Sun Aug 21 21:49:39 2011 @@ -33,9 +33,6 @@ RefreshStateAfterStop(); virtual const char * - GetInfo (); - - virtual const char * GetName (); virtual const char * @@ -103,9 +100,6 @@ // Member variables. //------------------------------------------------------------------ - virtual lldb_private::Unwind * - GetUnwinder (); - virtual lldb::StopInfoSP GetPrivateStopReason (); Added: lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp?rev=138228&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp (added) +++ lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp Sun Aug 21 21:49:39 2011 @@ -0,0 +1,142 @@ +//===-- DynamicRegisterInfo.cpp ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "DynamicRegisterInfo.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + +using namespace lldb; +using namespace lldb_private; + +DynamicRegisterInfo::DynamicRegisterInfo () : + m_regs (), + m_sets (), + m_set_reg_nums (), + m_reg_names (), + m_reg_alt_names (), + m_set_names (), + m_reg_data_byte_size (0) +{ +} + +DynamicRegisterInfo::~DynamicRegisterInfo () +{ +} + +void +DynamicRegisterInfo::AddRegister (RegisterInfo ®_info, + ConstString ®_name, + ConstString ®_alt_name, + ConstString &set_name) +{ + const uint32_t reg_num = m_regs.size(); + m_reg_names.push_back (reg_name); + m_reg_alt_names.push_back (reg_alt_name); + reg_info.name = reg_name.AsCString(); + assert (reg_info.name); + reg_info.alt_name = reg_alt_name.AsCString(NULL); + m_regs.push_back (reg_info); + uint32_t set = GetRegisterSetIndexByName (set_name, true); + assert (set < m_sets.size()); + assert (set < m_set_reg_nums.size()); + assert (set < m_set_names.size()); + m_set_reg_nums[set].push_back(reg_num); + size_t end_reg_offset = reg_info.byte_offset + reg_info.byte_size; + if (m_reg_data_byte_size < end_reg_offset) + m_reg_data_byte_size = end_reg_offset; +} + +void +DynamicRegisterInfo::Finalize () +{ + for (uint32_t set = 0; set < m_sets.size(); ++set) + { + assert (m_sets.size() == m_set_reg_nums.size()); + m_sets[set].num_registers = m_set_reg_nums[set].size(); + m_sets[set].registers = &m_set_reg_nums[set][0]; + } +} + +size_t +DynamicRegisterInfo::GetNumRegisters() const +{ + return m_regs.size(); +} + +size_t +DynamicRegisterInfo::GetNumRegisterSets() const +{ + return m_sets.size(); +} + +size_t +DynamicRegisterInfo::GetRegisterDataByteSize() const +{ + return m_reg_data_byte_size; +} + +const RegisterInfo * +DynamicRegisterInfo::GetRegisterInfoAtIndex (uint32_t i) const +{ + if (i < m_regs.size()) + return &m_regs[i]; + return NULL; +} + +const RegisterSet * +DynamicRegisterInfo::GetRegisterSet (uint32_t i) const +{ + if (i < m_sets.size()) + return &m_sets[i]; + return NULL; +} + +uint32_t +DynamicRegisterInfo::GetRegisterSetIndexByName (ConstString &set_name, bool can_create) +{ + name_collection::iterator pos, end = m_set_names.end(); + for (pos = m_set_names.begin(); pos != end; ++pos) + { + if (*pos == set_name) + return std::distance (m_set_names.begin(), pos); + } + + m_set_names.push_back(set_name); + m_set_reg_nums.resize(m_set_reg_nums.size()+1); + RegisterSet new_set = { set_name.AsCString(), NULL, 0, NULL }; + m_sets.push_back (new_set); + return m_sets.size() - 1; +} + +uint32_t +DynamicRegisterInfo::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) const +{ + reg_collection::const_iterator pos, end = m_regs.end(); + for (pos = m_regs.begin(); pos != end; ++pos) + { + if (pos->kinds[kind] == num) + return std::distance (m_regs.begin(), pos); + } + + return LLDB_INVALID_REGNUM; +} + +void +DynamicRegisterInfo::Clear() +{ + m_regs.clear(); + m_sets.clear(); + m_set_reg_nums.clear(); + m_reg_names.clear(); + m_reg_alt_names.clear(); + m_set_names.clear(); +} Added: lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.h?rev=138228&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.h (added) +++ lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.h Sun Aug 21 21:49:39 2011 @@ -0,0 +1,82 @@ +//===-- DynamicRegisterInfo.h -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef lldb_DynamicRegisterInfo_h_ +#define lldb_DynamicRegisterInfo_h_ + +// C Includes +// C++ Includes +#include + +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/Core/ConstString.h" + +class DynamicRegisterInfo +{ +public: + DynamicRegisterInfo (); + + virtual + ~DynamicRegisterInfo (); + + void + AddRegister (lldb_private::RegisterInfo ®_info, + lldb_private::ConstString ®_name, + lldb_private::ConstString ®_alt_name, + lldb_private::ConstString &set_name); + + void + Finalize (); + + size_t + GetNumRegisters() const; + + size_t + GetNumRegisterSets() const; + + size_t + GetRegisterDataByteSize() const; + + const lldb_private::RegisterInfo * + GetRegisterInfoAtIndex (uint32_t i) const; + + const lldb_private::RegisterSet * + GetRegisterSet (uint32_t i) const; + + uint32_t + GetRegisterSetIndexByName (lldb_private::ConstString &set_name, bool can_create); + + uint32_t + ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) const; + + void + Clear(); + +protected: + //------------------------------------------------------------------ + // Classes that inherit from DynamicRegisterInfo can see and modify these + //------------------------------------------------------------------ + typedef std::vector reg_collection; + typedef std::vector set_collection; + typedef std::vector reg_num_collection; + typedef std::vector set_reg_num_collection; + typedef std::vector name_collection; + + reg_collection m_regs; + set_collection m_sets; + set_reg_num_collection m_set_reg_nums; + name_collection m_reg_names; + name_collection m_reg_alt_names; + name_collection m_set_names; + size_t m_reg_data_byte_size; // The number of bytes required to store all registers +}; + +#endif // lldb_DynamicRegisterInfo_h_ Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.cpp?rev=138228&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.cpp (added) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.cpp Sun Aug 21 21:49:39 2011 @@ -0,0 +1,158 @@ +//===-- RegisterContextMemory.cpp -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "RegisterContextMemory.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "DynamicRegisterInfo.h" +#include "lldb/Core/DataBufferHeap.h" +#include "lldb/Core/Error.h" +#include "lldb/Core/RegisterValue.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Thread.h" + +using namespace lldb; +using namespace lldb_private; + +//---------------------------------------------------------------------- +// RegisterContextMemory constructor +//---------------------------------------------------------------------- +RegisterContextMemory::RegisterContextMemory +( + Thread &thread, + uint32_t concrete_frame_idx, + DynamicRegisterInfo ®_infos, + addr_t reg_data_addr +) : + RegisterContext (thread, concrete_frame_idx), + m_reg_infos (reg_infos), + m_reg_valid (), + m_reg_data (), + m_reg_data_addr (reg_data_addr) +{ + // Resize our vector of bools to contain one bool for every register. + // We will use these boolean values to know when a register value + // is valid in m_reg_data. + const size_t num_regs = reg_infos.GetNumRegisters(); + assert (num_regs > 0); + m_reg_valid.resize (num_regs); + + // Make a heap based buffer that is big enough to store all registers + DataBufferSP reg_data_sp(new DataBufferHeap (reg_infos.GetRegisterDataByteSize(), 0)); + m_reg_data.SetData (reg_data_sp); +} + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +RegisterContextMemory::~RegisterContextMemory() +{ +} + +void +RegisterContextMemory::InvalidateAllRegisters () +{ + SetAllRegisterValid (false); +} + +void +RegisterContextMemory::SetAllRegisterValid (bool b) +{ + std::vector::iterator pos, end = m_reg_valid.end(); + for (pos = m_reg_valid.begin(); pos != end; ++pos) + *pos = b; +} + +size_t +RegisterContextMemory::GetRegisterCount () +{ + return m_reg_infos.GetNumRegisters (); +} + +const RegisterInfo * +RegisterContextMemory::GetRegisterInfoAtIndex (uint32_t reg) +{ + return m_reg_infos.GetRegisterInfoAtIndex (reg); +} + +size_t +RegisterContextMemory::GetRegisterSetCount () +{ + return m_reg_infos.GetNumRegisterSets (); +} + +const RegisterSet * +RegisterContextMemory::GetRegisterSet (uint32_t reg_set) +{ + return m_reg_infos.GetRegisterSet (reg_set); +} + +uint32_t +RegisterContextMemory::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) +{ + return m_reg_infos.ConvertRegisterKindToRegisterNumber (kind, num); +} + +bool +RegisterContextMemory::ReadRegister (const RegisterInfo *reg_info, RegisterValue ®_value) +{ + const uint32_t reg_num = reg_info->kinds[eRegisterKindLLDB]; + if (!m_reg_valid[reg_num]) + { + if (!ReadAllRegisterValues(m_reg_data.GetSharedDataBuffer ())) + return false; + } + const bool partial_data_ok = false; + return reg_value.SetValueFromData(reg_info, m_reg_data, reg_info->byte_offset, partial_data_ok).Success(); +} + +bool +RegisterContextMemory::WriteRegister (const RegisterInfo *reg_info, const RegisterValue ®_value) +{ + if (m_reg_data_addr != LLDB_INVALID_ADDRESS) + { + const uint32_t reg_num = reg_info->kinds[eRegisterKindLLDB]; + addr_t reg_addr = m_reg_data_addr + reg_info->byte_offset; + Error error (WriteRegisterValueToMemory(reg_info, reg_addr, reg_info->byte_size, reg_value)); + m_reg_valid[reg_num] = false; + return error.Success(); + } + return false; +} + +bool +RegisterContextMemory::ReadAllRegisterValues (DataBufferSP &data_sp) +{ + if (m_reg_data_addr != LLDB_INVALID_ADDRESS) + { + Error error; + if (m_thread.GetProcess().ReadMemory(m_reg_data_addr, data_sp->GetBytes(), data_sp->GetByteSize(), error) == data_sp->GetByteSize()) + { + SetAllRegisterValid (true); + return true; + } + } + return false; +} + +bool +RegisterContextMemory::WriteAllRegisterValues (const DataBufferSP &data_sp) +{ + if (m_reg_data_addr != LLDB_INVALID_ADDRESS) + { + Error error; + SetAllRegisterValid (false); + if (m_thread.GetProcess().WriteMemory(m_reg_data_addr, data_sp->GetBytes(), data_sp->GetByteSize(), error) == data_sp->GetByteSize()) + return true; + } + return false; +} Added: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.h?rev=138228&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.h (added) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMemory.h Sun Aug 21 21:49:39 2011 @@ -0,0 +1,100 @@ +//===-- RegisterContextMemory.h ---------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef lldb_RegisterContextMemory_h_ +#define lldb_RegisterContextMemory_h_ + +// C Includes +// C++ Includes +#include + +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/Core/DataExtractor.h" +#include "lldb/Target/RegisterContext.h" + +class DynamicRegisterInfo; + +class RegisterContextMemory : public lldb_private::RegisterContext +{ +public: + //------------------------------------------------------------------ + // Constructors and Destructors + //------------------------------------------------------------------ + RegisterContextMemory (lldb_private::Thread &thread, + uint32_t concrete_frame_idx, + DynamicRegisterInfo ®_info, + lldb::addr_t reg_data_addr); + + virtual + ~RegisterContextMemory (); + + //------------------------------------------------------------------ + // Subclasses must override these functions + //------------------------------------------------------------------ + virtual void + InvalidateAllRegisters (); + + virtual size_t + GetRegisterCount (); + + virtual const lldb_private::RegisterInfo * + GetRegisterInfoAtIndex (uint32_t reg); + + virtual size_t + GetRegisterSetCount (); + + virtual const lldb_private::RegisterSet * + GetRegisterSet (uint32_t reg_set); + + virtual uint32_t + ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num); + + + //------------------------------------------------------------------ + // If all of the thread register are in a contiguous buffer in + // memory, then the default ReadRegister/WriteRegiter and + // ReadAllRegisterValues/WriteAllRegisterValues will work. If thread + // registers are not contiguous, clients will want to subclass this + // class and modify the read/write functions as needed. + //------------------------------------------------------------------ + + virtual bool + ReadRegister (const lldb_private::RegisterInfo *reg_info, + lldb_private::RegisterValue ®_value); + + virtual bool + WriteRegister (const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue ®_value); + + virtual bool + ReadAllRegisterValues (lldb::DataBufferSP &data_sp); + + virtual bool + WriteAllRegisterValues (const lldb::DataBufferSP &data_sp); + +protected: + + void + SetAllRegisterValid (bool b); + + DynamicRegisterInfo &m_reg_infos; + std::vector m_reg_valid; + lldb_private::DataExtractor m_reg_data; + lldb::addr_t m_reg_data_addr; // If this is valid, then we have a register context that is stored in memmory + +private: + //------------------------------------------------------------------ + // For RegisterContextMemory only + //------------------------------------------------------------------ + DISALLOW_COPY_AND_ASSIGN (RegisterContextMemory); +}; + +#endif // lldb_RegisterContextMemory_h_ Added: lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp?rev=138228&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp (added) +++ lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp Sun Aug 21 21:49:39 2011 @@ -0,0 +1,112 @@ +//===-- ThreadMemory.cpp ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "Plugins/Process/Utility/ThreadMemory.h" +#include "lldb/Target/OperatingSystem.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/StopInfo.h" +#include "lldb/Target/Unwind.h" + +using namespace lldb; +using namespace lldb_private; + +ThreadMemory::ThreadMemory (Process &process, + tid_t tid, + const ValueObjectSP &thread_info_valobj_sp) : + Thread (process, tid), + m_thread_info_valobj_sp (thread_info_valobj_sp) +{ +} + + +ThreadMemory::~ThreadMemory() +{ + DestroyThread(); +} + +bool +ThreadMemory::WillResume (StateType resume_state) +{ + ClearStackFrames(); + // Call the Thread::WillResume first. If we stop at a signal, the stop info + // class for signal will set the resume signal that we need below. The signal + // stuff obeys the Process::UnixSignal defaults. + Thread::WillResume(resume_state); + return true; +} + +RegisterContextSP +ThreadMemory::GetRegisterContext () +{ + if (!m_reg_context_sp) + { + OperatingSystem *os = m_process.GetOperatingSystem (); + if (os) + m_reg_context_sp = os->CreateRegisterContextForThread (this); + } + return m_reg_context_sp; +} + +RegisterContextSP +ThreadMemory::CreateRegisterContextForFrame (StackFrame *frame) +{ + RegisterContextSP reg_ctx_sp; + uint32_t concrete_frame_idx = 0; + + if (frame) + concrete_frame_idx = frame->GetConcreteFrameIndex (); + + if (concrete_frame_idx == 0) + { + reg_ctx_sp = GetRegisterContext (); + } + else if (m_unwinder_ap.get()) + { + reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame (frame); + } + return reg_ctx_sp; +} + +lldb::StopInfoSP +ThreadMemory::GetPrivateStopReason () +{ + const uint32_t process_stop_id = GetProcess().GetStopID(); + if (m_thread_stop_reason_stop_id != process_stop_id || + (m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid())) + { + // If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason + // for this thread, then m_actual_stop_info_sp will not ever contain + // a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false" + // check will never be able to tell us if we have the correct stop info + // for this thread and we will continually send qThreadStopInfo packets + // down to the remote GDB server, so we need to keep our own notion + // of the stop ID that m_actual_stop_info_sp is valid for (even if it + // contains nothing). We use m_thread_stop_reason_stop_id for this below. + m_thread_stop_reason_stop_id = process_stop_id; + m_actual_stop_info_sp.reset(); + + OperatingSystem *os = m_process.GetOperatingSystem (); + if (os) + m_actual_stop_info_sp = os->CreateThreadStopReason (this); + } + return m_actual_stop_info_sp; + +} + +void +ThreadMemory::RefreshStateAfterStop() +{ + RegisterContextSP reg_ctx_sp(GetRegisterContext()); + if (reg_ctx_sp) + { + const bool force = true; + reg_ctx_sp->InvalidateIfNeeded (force); + } +} Added: lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h?rev=138228&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h (added) +++ lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h Sun Aug 21 21:49:39 2011 @@ -0,0 +1,64 @@ +//===-- ThreadMemory.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_ThreadMemory_h_ +#define liblldb_ThreadMemory_h_ + +#include "lldb/Target/Thread.h" + +class ThreadMemory : + public lldb_private::Thread +{ +public: + + ThreadMemory (lldb_private::Process &process, + lldb::tid_t tid, + const lldb::ValueObjectSP &thread_info_valobj_sp); + + virtual + ~ThreadMemory(); + + //------------------------------------------------------------------ + // lldb_private::Thread methods + //------------------------------------------------------------------ + virtual void + RefreshStateAfterStop(); + + virtual lldb::RegisterContextSP + GetRegisterContext (); + + virtual lldb::RegisterContextSP + CreateRegisterContextForFrame (lldb_private::StackFrame *frame); + + virtual lldb::StopInfoSP + GetPrivateStopReason (); + + virtual bool + WillResume (lldb::StateType resume_state); + + lldb::ValueObjectSP & + GetValueObject () + { + return m_thread_info_valobj_sp; + } + +protected: + //------------------------------------------------------------------ + // For ThreadMemory and subclasses + //------------------------------------------------------------------ + lldb::ValueObjectSP m_thread_info_valobj_sp; + +private: + //------------------------------------------------------------------ + // For ThreadMemory only + //------------------------------------------------------------------ + DISALLOW_COPY_AND_ASSIGN (ThreadMemory); +}; + +#endif // liblldb_ThreadMemory_h_ Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Sun Aug 21 21:49:39 2011 @@ -390,7 +390,7 @@ { // We have a valid process SetID (pid); - UpdateThreadListIfNeeded (); + GetThreadList(); if (m_gdb_comm.SendPacketAndWaitForResponse("?", 1, m_last_stop_packet, false)) { const StateType state = SetThreadStopInfo (m_last_stop_packet); @@ -1062,43 +1062,32 @@ } uint32_t -ProcessGDBRemote::UpdateThreadListIfNeeded () +ProcessGDBRemote::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) { // locker will keep a mutex locked until it goes out of scope LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_THREAD)); if (log && log->GetMask().Test(GDBR_LOG_VERBOSE)) log->Printf ("ProcessGDBRemote::%s (pid = %i)", __FUNCTION__, GetID()); + // Update the thread list's stop id immediately so we don't recurse into this function. - Mutex::Locker locker (m_thread_list.GetMutex ()); - const uint32_t stop_id = GetStopID(); - if (m_thread_list.GetSize(false) == 0 || stop_id != m_thread_list.GetStopID()) + std::vector thread_ids; + bool sequence_mutex_unavailable = false; + const size_t num_thread_ids = m_gdb_comm.GetCurrentThreadIDs (thread_ids, sequence_mutex_unavailable); + if (num_thread_ids > 0) { - // Update the thread list's stop id immediately so we don't recurse into this function. - ThreadList curr_thread_list (this); - curr_thread_list.SetStopID(stop_id); - - std::vector thread_ids; - bool sequence_mutex_unavailable = false; - const size_t num_thread_ids = m_gdb_comm.GetCurrentThreadIDs (thread_ids, sequence_mutex_unavailable); - if (num_thread_ids > 0) + for (size_t i=0; iSetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo)); + gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo)); } else { 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=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Sun Aug 21 21:49:39 2011 @@ -267,7 +267,8 @@ } uint32_t - UpdateThreadListIfNeeded (); + UpdateThreadList (lldb_private::ThreadList &old_thread_list, + lldb_private::ThreadList &new_thread_list); lldb_private::Error StartDebugserverProcess (const char *debugserver_url); 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=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Sun Aug 21 21:49:39 2011 @@ -23,13 +23,8 @@ #include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" -#include "Plugins/Process/Utility/UnwindLLDB.h" #include "Utility/StringExtractorGDBRemote.h" -#if defined(__APPLE__) -#include "UnwindMacOSXFrameBackchain.h" -#endif - using namespace lldb; using namespace lldb_private; @@ -52,14 +47,6 @@ DestroyThread(); } - -const char * -ThreadGDBRemote::GetInfo () -{ - return NULL; -} - - const char * ThreadGDBRemote::GetName () { @@ -135,32 +122,6 @@ GetRegisterContext()->InvalidateIfNeeded (force); } -Unwind * -ThreadGDBRemote::GetUnwinder () -{ - if (m_unwinder_ap.get() == NULL) - { - const ArchSpec target_arch (GetProcess().GetTarget().GetArchitecture ()); - const llvm::Triple::ArchType machine = target_arch.GetMachine(); - switch (machine) - { - case llvm::Triple::x86_64: - case llvm::Triple::x86: - case llvm::Triple::arm: - case llvm::Triple::thumb: - m_unwinder_ap.reset (new UnwindLLDB (*this)); - break; - - default: -#if defined(__APPLE__) - m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this)); -#endif - break; - } - } - return m_unwinder_ap.get(); -} - void ThreadGDBRemote::ClearStackFrames () { Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h Sun Aug 21 21:49:39 2011 @@ -33,9 +33,6 @@ RefreshStateAfterStop(); virtual const char * - GetInfo (); - - virtual const char * GetName (); virtual const char * @@ -113,9 +110,6 @@ // Member variables. //------------------------------------------------------------------ - virtual lldb_private::Unwind * - GetUnwinder (); - void SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id); Modified: lldb/trunk/source/Target/ABI.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ABI.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Target/ABI.cpp (original) +++ lldb/trunk/source/Target/ABI.cpp Sun Aug 21 21:49:39 2011 @@ -45,3 +45,55 @@ ABI::~ABI() { } + + +bool +ABI::GetRegisterInfoByName (const ConstString &name, RegisterInfo &info) +{ + uint32_t count = 0; + const RegisterInfo *register_info_array = GetRegisterInfoArray (count); + if (register_info_array) + { + const char *unique_name_cstr = name.GetCString(); + uint32_t i; + for (i=0; i= kNumRegisterKinds) + return false; + + uint32_t count = 0; + const RegisterInfo *register_info_array = GetRegisterInfoArray (count); + if (register_info_array) + { + for (uint32_t i=0; i instance_ap(create_callback(process, true)); + if (instance_ap.get()) + return instance_ap.release(); + } + } + else + { + for (uint32_t idx = 0; (create_callback = PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) != NULL; ++idx) + { + std::auto_ptr instance_ap(create_callback(process, false)); + if (instance_ap.get()) + return instance_ap.release(); + } + } + return NULL; +} + + +OperatingSystem::OperatingSystem (Process *process) : + m_process (process) +{ +} + +OperatingSystem::~OperatingSystem() +{ +} Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Sun Aug 21 21:49:39 2011 @@ -25,6 +25,7 @@ #include "lldb/Host/Host.h" #include "lldb/Target/ABI.h" #include "lldb/Target/DynamicLoader.h" +#include "lldb/Target/OperatingSystem.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/CPPLanguageRuntime.h" #include "lldb/Target/ObjCLanguageRuntime.h" @@ -646,8 +647,8 @@ // We need to destroy the loader before the derived Process class gets destroyed // since it is very likely that undoing the loader will require access to the real process. - if (m_dyld_ap.get() != NULL) - m_dyld_ap.reset(); + m_dyld_ap.reset(); + m_os_ap.reset(); } void @@ -1029,6 +1030,25 @@ } +void +Process::UpdateThreadListIfNeeded () +{ + const uint32_t stop_id = GetStopID(); + if (m_thread_list.GetSize(false) == 0 || stop_id != m_thread_list.GetStopID()) + { + Mutex::Locker locker (m_thread_list.GetMutex ()); + ThreadList new_thread_list(this); + // Always update the thread list with the protocol specific + // thread list + UpdateThreadList (m_thread_list, new_thread_list); + OperatingSystem *os = GetOperatingSystem (); + if (os) + os->UpdateThreadList (m_thread_list, new_thread_list); + m_thread_list.Update (new_thread_list); + m_thread_list.SetStopID (stop_id); + } +} + uint32_t Process::GetNextThreadIndexID () { @@ -2017,6 +2037,7 @@ Error error; m_abi_sp.reset(); m_dyld_ap.reset(); + m_os_ap.reset(); m_process_input_reader.reset(); Module *exe_module = m_target.GetExecutableModulePointer(); @@ -2101,10 +2122,11 @@ DidLaunch (); - m_dyld_ap.reset (DynamicLoader::FindPlugin(this, NULL)); + m_dyld_ap.reset (DynamicLoader::FindPlugin (this, NULL)); if (m_dyld_ap.get()) m_dyld_ap->DidLaunch(); + m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL)); // This delays passing the stopped event to listeners till DidLaunch gets // a chance to complete... HandlePrivateEvent (event_sp); @@ -2198,6 +2220,7 @@ } m_dyld_ap.reset(); + m_os_ap.reset(); Error error (WillAttachToProcessWithID(attach_pid)); if (error.Success()) @@ -2277,6 +2300,7 @@ if (error.Success()) { m_dyld_ap.reset(); + m_os_ap.reset(); error = WillAttachToProcessWithName(process_name, wait_for_launch); if (error.Success()) @@ -2318,6 +2342,7 @@ if (m_dyld_ap.get()) m_dyld_ap->DidAttach(); + m_os_ap.reset (OperatingSystem::FindPlugin (this, NULL)); // Figure out which one is the executable, and set that in our target: ModuleList &modules = m_target.GetImages(); Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Sun Aug 21 21:49:39 2011 @@ -36,6 +36,9 @@ #include "lldb/Target/ThreadPlanStepUntil.h" #include "lldb/Target/ThreadSpec.h" #include "lldb/Target/Unwind.h" +#include "Plugins/Process/Utility/UnwindLLDB.h" +#include "UnwindMacOSXFrameBackchain.h" + using namespace lldb; using namespace lldb_private; @@ -1196,6 +1199,32 @@ return false; } +Unwind * +Thread::GetUnwinder () +{ + if (m_unwinder_ap.get() == NULL) + { + const ArchSpec target_arch (GetProcess().GetTarget().GetArchitecture ()); + const llvm::Triple::ArchType machine = target_arch.GetMachine(); + switch (machine) + { + case llvm::Triple::x86_64: + case llvm::Triple::x86: + case llvm::Triple::arm: + case llvm::Triple::thumb: + m_unwinder_ap.reset (new UnwindLLDB (*this)); + break; + + default: + if (target_arch.GetTriple().getVendor() == llvm::Triple::Apple) + m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this)); + break; + } + } + return m_unwinder_ap.get(); +} + + #pragma mark "Thread::SettingsController" //-------------------------------------------------------------- // class Thread::SettingsController Modified: lldb/trunk/source/Target/ThreadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadList.cpp (original) +++ lldb/trunk/source/Target/ThreadList.cpp Sun Aug 21 21:49:39 2011 @@ -573,3 +573,20 @@ return m_selected_tid != LLDB_INVALID_THREAD_ID; } +void +ThreadList::Update (ThreadList &rhs) +{ + if (this != &rhs) + { + // Lock both mutexes to make sure neither side changes anyone on us + // while the assignement occurs + Mutex::Locker locker_lhs(m_threads_mutex); + Mutex::Locker locker_rhs(rhs.m_threads_mutex); + m_process = rhs.m_process; + m_stop_id = rhs.m_stop_id; + m_threads.swap(rhs.m_threads); + m_selected_tid = rhs.m_selected_tid; + } +} + + Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=138228&r1=138227&r2=138228&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Sun Aug 21 21:49:39 2011 @@ -39,6 +39,7 @@ #if defined (__APPLE__) #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" #include "Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.h" +#include "Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.h" #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h" @@ -100,6 +101,7 @@ //---------------------------------------------------------------------- DynamicLoaderMacOSXDYLD::Initialize(); DynamicLoaderMacOSXKernel::Initialize(); + OperatingSystemMacOSXKernel::Initialize(); SymbolFileDWARFDebugMap::Initialize(); ItaniumABILanguageRuntime::Initialize(); AppleObjCRuntimeV2::Initialize(); @@ -168,6 +170,7 @@ #if defined (__APPLE__) DynamicLoaderMacOSXDYLD::Terminate(); DynamicLoaderMacOSXKernel::Terminate(); + OperatingSystemMacOSXKernel::Terminate(); SymbolFileDWARFDebugMap::Terminate(); ItaniumABILanguageRuntime::Terminate(); AppleObjCRuntimeV2::Terminate();