From granata.enrico at gmail.com Mon Jul 25 11:59:05 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 25 Jul 2011 16:59:05 -0000 Subject: [Lldb-commits] [lldb] r135916 - in /lldb/trunk: include/lldb/Core/ include/lldb/Interpreter/ source/Commands/ source/Core/ source/Interpreter/ test/functionalities/data-formatter/data-formatter-python-synth/ Message-ID: <20110725165906.01E272A6C12C@llvm.org> Author: enrico Date: Mon Jul 25 11:59:05 2011 New Revision: 135916 URL: http://llvm.org/viewvc/llvm-project?rev=135916&view=rev Log: new flag -P to type synth add lets you type a Python class interactively added a final newline to fooSynthProvider.py new option to automatically save user input in InputReaderEZ checking for NULL pointers in several new places Modified: lldb/trunk/include/lldb/Core/FormatClasses.h lldb/trunk/include/lldb/Core/InputReader.h lldb/trunk/include/lldb/Core/InputReaderEZ.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Commands/CommandObjectType.h lldb/trunk/source/Core/FormatClasses.cpp lldb/trunk/source/Core/InputReader.cpp lldb/trunk/source/Core/InputReaderEZ.cpp lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py Modified: lldb/trunk/include/lldb/Core/FormatClasses.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatClasses.h (original) +++ lldb/trunk/include/lldb/Core/FormatClasses.h Mon Jul 25 11:59:05 2011 @@ -303,7 +303,7 @@ virtual uint32_t CalculateNumChildren() { - if (m_wrapper == NULL) + if (m_wrapper == NULL || m_interpreter == NULL) return 0; return m_interpreter->CalculateNumChildren(m_wrapper); } @@ -311,7 +311,7 @@ virtual lldb::ValueObjectSP GetChildAtIndex (uint32_t idx, bool can_create) { - if (m_wrapper == NULL) + if (m_wrapper == NULL || m_interpreter == NULL) return lldb::ValueObjectSP(); PyObject* py_return = (PyObject*)m_interpreter->GetChildAtIndex(m_wrapper, idx); @@ -323,7 +323,7 @@ lldb::SBValue *sb_ptr = m_interpreter->CastPyObjectToSBValue(py_return); - if (py_return == NULL) + if (py_return == NULL || sb_ptr == NULL) return lldb::ValueObjectSP(); return sb_ptr->m_opaque_sp; @@ -332,7 +332,7 @@ virtual uint32_t GetIndexOfChildWithName (const ConstString &name) { - if (m_wrapper == NULL) + if (m_wrapper == NULL || m_interpreter == NULL) return UINT32_MAX; return m_interpreter->GetIndexOfChildWithName(m_wrapper, name.GetCString()); } Modified: lldb/trunk/include/lldb/Core/InputReader.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/InputReader.h?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/InputReader.h (original) +++ lldb/trunk/include/lldb/Core/InputReader.h Mon Jul 25 11:59:05 2011 @@ -15,6 +15,7 @@ #include "lldb/lldb-public.h" #include "lldb/lldb-enumerations.h" #include "lldb/Core/Error.h" +#include "lldb/Core/StringList.h" #include "lldb/Host/Predicate.h" @@ -63,11 +64,13 @@ char* m_end_token; char* m_prompt; bool m_echo; + bool m_save_user_input; public: InitializationParameters() : m_baton(NULL), m_token_size(lldb::eInputReaderGranularityLine), - m_echo(true) + m_echo(true), + m_save_user_input(false) { SetEndToken("DONE"); SetPrompt("> "); @@ -81,6 +84,13 @@ } InitializationParameters& + SetSaveUserInput(bool s) + { + m_save_user_input = s; + return *this; + } + + InitializationParameters& SetBaton(void* b) { m_baton = b; @@ -191,6 +201,18 @@ { return m_echo; } + + StringList& + GetUserInput() + { + return m_user_input; + } + + virtual bool + GetSaveUserInput() + { + return false; + } // Subclasses _can_ override this function to get input as it comes in // without any granularity @@ -239,6 +261,8 @@ bool m_echo; bool m_active; Predicate m_reader_done; + StringList m_user_input; + bool m_save_user_input; private: DISALLOW_COPY_AND_ASSIGN (InputReader); Modified: lldb/trunk/include/lldb/Core/InputReaderEZ.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/InputReaderEZ.h?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/InputReaderEZ.h (original) +++ lldb/trunk/include/lldb/Core/InputReaderEZ.h Mon Jul 25 11:59:05 2011 @@ -75,6 +75,12 @@ virtual void DoneHandler(HandlerData&) {} + virtual bool + GetSaveUserInput() + { + return m_save_user_input; + } + protected: friend class Debugger; Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Mon Jul 25 11:59:05 2011 @@ -101,6 +101,12 @@ return false; } + virtual bool + GenerateTypeSynthClass (StringList &input, StringList &output) + { + return false; + } + virtual void* CreateSyntheticScriptedProvider (std::string class_name, lldb::ValueObjectSP valobj) Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Mon Jul 25 11:59:05 2011 @@ -52,6 +52,9 @@ bool GenerateTypeScriptFunction (StringList &input, StringList &output); + bool + GenerateTypeSynthClass (StringList &input, StringList &output); + // use this if the function code is just a one-liner script bool GenerateTypeScriptFunction (const char* oneliner, StringList &output); Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Mon Jul 25 11:59:05 2011 @@ -691,7 +691,6 @@ result.AppendError("out of memory"); result.SetStatus (eReturnStatusFailed); } - } bool @@ -2372,6 +2371,148 @@ // CommandObjectTypeSynthAdd //------------------------------------------------------------------------- +static const char *g_synth_addreader_instructions = "Enter your Python command(s). Type 'DONE' to end.\n" + "You must define a Python class with three methods:\n" + "def __init__(self, valobj, dict):\n" + "def get_child_at_index(self, index):\n" + "def get_child_index(self, name):\n" + "class synthProvider:"; + +class TypeSynthAddInputReader : public InputReaderEZ +{ +private: + DISALLOW_COPY_AND_ASSIGN (TypeSynthAddInputReader); +public: + TypeSynthAddInputReader(Debugger& debugger) : + InputReaderEZ(debugger) + {} + + virtual + ~TypeSynthAddInputReader() + { + } + + virtual void ActivateHandler(HandlerData& data) + { + StreamSP out_stream = data.GetOutStream(); + bool batch_mode = data.GetBatchMode(); + if (!batch_mode) + { + out_stream->Printf ("%s\n", g_synth_addreader_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 && data.baton) + { + ((SynthAddOptions*)data.baton)->m_user_source.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(); + SynthAddOptions *options_ptr = ((SynthAddOptions*)data.baton); + if (!options_ptr) + { + out_stream->Printf ("Internal error #1: no script attached.\n"); + out_stream->Flush(); + return; + } + + SynthAddOptions::SharedPointer options(options_ptr); // this will ensure that we get rid of the pointer when going out of scope + + ScriptInterpreter *interpreter = data.reader.GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); + if (!interpreter) + { + out_stream->Printf ("Internal error #2: no script attached.\n"); + out_stream->Flush(); + return; + } + StringList class_name_sl; + if (!interpreter->GenerateTypeSynthClass (options->m_user_source, + class_name_sl)) + { + out_stream->Printf ("Internal error #3: no script attached.\n"); + out_stream->Flush(); + return; + } + if (class_name_sl.GetSize() == 0) + { + out_stream->Printf ("Internal error #4: no script attached.\n"); + out_stream->Flush(); + return; + } + const char *class_name = class_name_sl.GetStringAtIndex(0); + if (!class_name || !class_name[0]) + { + out_stream->Printf ("Internal error #5: no script attached.\n"); + out_stream->Flush(); + return; + } + + // everything should be fine now, let's add the synth provider class + + SyntheticChildrenSP synth_provider; + synth_provider.reset(new SyntheticScriptProvider(options->m_cascade, + options->m_skip_pointers, + options->m_skip_references, + std::string(class_name))); + + + lldb::FormatCategorySP category; + Debugger::Formatting::Categories::Get(ConstString(options->m_category), category); + + 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) + category->Filter()->Add(typeCS.GetCString(), synth_provider); + else + { + out_stream->Printf ("Internal error #6: no script attached.\n"); + out_stream->Flush(); + return; + } + } + } +}; + class CommandObjectTypeSynthAdd : public CommandObject { @@ -2406,6 +2547,10 @@ break; case 'c': m_expr_paths.push_back(option_arg); + has_child_list = true; + break; + case 'P': + handwrite_python = true; break; case 'l': m_class_name = std::string(option_arg); @@ -2438,6 +2583,8 @@ m_category = NULL; m_expr_paths.clear(); is_class_based = false; + handwrite_python = false; + has_child_list = false; } const OptionDefinition* @@ -2462,6 +2609,10 @@ bool is_class_based; + bool handwrite_python; + + bool has_child_list; + typedef option_vector::iterator ExpressionPathsIterator; }; @@ -2473,6 +2624,61 @@ return &m_options; } + void + CollectPythonScript (SynthAddOptions *options, + CommandReturnObject &result) + { + InputReaderSP reader_sp (new TypeSynthAddInputReader(m_interpreter.GetDebugger())); + if (reader_sp && options) + { + + InputReaderEZ::InitializationParameters ipr; + + Error err (reader_sp->Initialize (ipr.SetBaton(options).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); + } + } + + bool + Execute_HandwritePython (Args& command, CommandReturnObject &result) + { + SynthAddOptions *options = new SynthAddOptions ( m_options.m_skip_pointers, + m_options.m_skip_references, + m_options.m_cascade, + m_options.m_category); + + const size_t argc = command.GetArgumentCount(); + + for (size_t i = 0; i < argc; i++) { + const char* typeA = command.GetArgumentAtIndex(i); + if (typeA && *typeA) + options->m_target_types << typeA; + else + { + result.AppendError("empty typenames not allowed"); + result.SetStatus(eReturnStatusFailed); + return false; + } + } + + CollectPythonScript(options,result); + return result.Succeeded(); + } + bool Execute_ChildrenList (Args& command, CommandReturnObject &result) { @@ -2606,10 +2812,18 @@ bool Execute (Args& command, CommandReturnObject &result) { - if (m_options.is_class_based) + if (m_options.handwrite_python) + return Execute_HandwritePython(command, result); + else if (m_options.is_class_based) return Execute_PythonClass(command, result); - else + else if (m_options.has_child_list) return Execute_ChildrenList(command, result); + else + { + result.AppendError("must either provide a children list, a Python class name, or use -P and type a Python class line-by-line"); + result.SetStatus(eReturnStatusFailed); + return false; + } } }; @@ -2622,6 +2836,7 @@ { LLDB_OPT_SET_ALL, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."}, { LLDB_OPT_SET_1, false, "child", 'c', required_argument, NULL, 0, eArgTypeName, "Include this expression path in the synthetic view."}, { LLDB_OPT_SET_2, false, "python-class", 'l', required_argument, NULL, 0, eArgTypeName, "Use this Python class to produce synthetic children."}, + { LLDB_OPT_SET_3, false, "input-python", 'P', no_argument, NULL, 0, eArgTypeBoolean, "Type Python code to generate a class that provides synthetic children."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Commands/CommandObjectType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.h?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.h (original) +++ lldb/trunk/source/Commands/CommandObjectType.h Mon Jul 25 11:59:05 2011 @@ -70,6 +70,37 @@ }; +class SynthAddOptions +{ + +public: + + bool m_skip_pointers; + bool m_skip_references; + bool m_cascade; + StringList m_user_source; + StringList m_target_types; + + const char* m_category; + + SynthAddOptions(bool sptr, + bool sref, + bool casc, + const char* catg) : + m_skip_pointers(sptr), + m_skip_references(sref), + m_cascade(casc), + m_user_source(), + m_target_types(), + m_category(catg) + { + } + + typedef lldb::SharedPtr::Type SharedPointer; + +}; + + class CommandObjectType : public CommandObjectMultiword { public: Modified: lldb/trunk/source/Core/FormatClasses.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatClasses.cpp (original) +++ lldb/trunk/source/Core/FormatClasses.cpp Mon Jul 25 11:59:05 2011 @@ -164,15 +164,26 @@ SyntheticChildrenFrontEnd(be), m_python_class(pclass) { + if (be.get() == NULL) + { + m_interpreter = NULL; + m_wrapper = NULL; + return; + } + m_interpreter = be->GetUpdatePoint().GetTarget()->GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); - m_wrapper = (PyObject*)m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend); + + if (m_interpreter == NULL) + m_wrapper = NULL; + else + m_wrapper = (PyObject*)m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend); } std::string SyntheticScriptProvider::GetDescription() { StreamString sstr; - sstr.Printf("%s%s%s Python class: %s", + sstr.Printf("%s%s%s Python class %s", m_cascades ? "" : " (not cascading)", m_skip_pointers ? " (skip pointers)" : "", m_skip_references ? " (skip references)" : "", Modified: lldb/trunk/source/Core/InputReader.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/InputReader.cpp?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/source/Core/InputReader.cpp (original) +++ lldb/trunk/source/Core/InputReader.cpp Mon Jul 25 11:59:05 2011 @@ -25,7 +25,9 @@ m_done (true), m_echo (true), m_active (false), - m_reader_done (false) + m_reader_done (false), + m_user_input(), + m_save_user_input(false) { } Modified: lldb/trunk/source/Core/InputReaderEZ.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/InputReaderEZ.cpp?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/source/Core/InputReaderEZ.cpp (original) +++ lldb/trunk/source/Core/InputReaderEZ.cpp Mon Jul 25 11:59:05 2011 @@ -45,7 +45,11 @@ reader.AsynchronousOutputWrittenHandler(hand_data); break; case eInputReaderGotToken: + { + if (reader.GetSaveUserInput()) + reader.GetUserInput().AppendString(bytes, bytes_len); reader.GotTokenHandler(hand_data); + } break; case eInputReaderInterrupt: reader.InterruptHandler(hand_data); @@ -78,11 +82,13 @@ Error InputReaderEZ::Initialize(InitializationParameters& params) { - return Initialize(params.m_baton, - params.m_token_size, - params.m_end_token, - params.m_prompt, - params.m_echo); + Error ret = Initialize(params.m_baton, + params.m_token_size, + params.m_end_token, + params.m_prompt, + params.m_echo); + m_save_user_input = params.m_save_user_input; + return ret; } InputReaderEZ::~InputReaderEZ () Modified: lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp (original) +++ lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp Mon Jul 25 11:59:05 2011 @@ -131,7 +131,7 @@ if (iter == m_children_byindex.end()) { - if (can_create) + if (can_create && m_synth_filter != NULL) { lldb::ValueObjectSP synth_guy = m_synth_filter->GetChildAtIndex (idx, can_create); m_children_byindex[idx]= synth_guy; @@ -161,13 +161,16 @@ { NameToIndexIterator iter = m_name_toindex.find(name.GetCString()); - if (iter == m_name_toindex.end()) + if (iter == m_name_toindex.end() && m_synth_filter != NULL) { uint32_t index = m_synth_filter->GetIndexOfChildWithName (name); m_name_toindex[name.GetCString()] = index; return index; } - return iter->second; + else if (iter == m_name_toindex.end() && m_synth_filter == NULL) + return UINT32_MAX; + else /*if (iter != m_name_toindex.end())*/ + return iter->second; } bool Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Jul 25 11:59:05 2011 @@ -1249,6 +1249,54 @@ return true; } +bool +ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, StringList &output) +{ + static int num_created_classes = 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; + + // Wrap all user input into a Python class + + sstr.Printf ("lldb_autogen_python_type_synth_class_%d", num_created_classes); + ++num_created_classes; + std::string auto_generated_class_name = sstr.GetData(); + + sstr.Clear(); + StringList auto_generated_class; + + // Create the function name & definition string. + + sstr.Printf ("class %s:", auto_generated_class_name.c_str()); + auto_generated_class.AppendString (sstr.GetData()); + + // Wrap everything up inside the class, increasing the indentation. + + for (int i = 0; i < num_lines; ++i) + { + sstr.Clear (); + sstr.Printf (" %s", user_input.GetStringAtIndex (i)); + auto_generated_class.AppendString (sstr.GetData()); + } + + + // Verify that the results are valid Python. + // (even though the method is ExportFunctionDefinitionToInterpreter, a class will actually be exported) + // (TODO: rename that method to ExportDefinitionToInterpreter) + if (!ExportFunctionDefinitionToInterpreter (auto_generated_class)) + return false; + + // Store the name of the auto-generated class + + output.AppendString (auto_generated_class_name.c_str()); + return true; +} + void* ScriptInterpreterPython::CreateSyntheticScriptedProvider (std::string class_name, lldb::ValueObjectSP valobj) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py?rev=135916&r1=135915&r2=135916&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py Mon Jul 25 11:59:05 2011 @@ -13,4 +13,4 @@ if name == 'a': return 1; else: - return 0; \ No newline at end of file + return 0; From granata.enrico at gmail.com Mon Jul 25 13:59:15 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 25 Jul 2011 18:59:15 -0000 Subject: [Lldb-commits] [lldb] r135933 - /lldb/trunk/source/Commands/CommandObjectType.cpp Message-ID: <20110725185915.462852A6C12C@llvm.org> Author: enrico Date: Mon Jul 25 13:59:15 2011 New Revision: 135933 URL: http://llvm.org/viewvc/llvm-project?rev=135933&view=rev Log: Python synthetic providers must provide a num_children call; this was not specified in the docs up to now Modified: lldb/trunk/source/Commands/CommandObjectType.cpp Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=135933&r1=135932&r2=135933&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Mon Jul 25 13:59:15 2011 @@ -2372,10 +2372,11 @@ //------------------------------------------------------------------------- static const char *g_synth_addreader_instructions = "Enter your Python command(s). Type 'DONE' to end.\n" - "You must define a Python class with three methods:\n" - "def __init__(self, valobj, dict):\n" - "def get_child_at_index(self, index):\n" - "def get_child_index(self, name):\n" + "You must define a Python class with these methods:\n" + " def __init__(self, valobj, dict):\n" + " def num_children(self):\n" + " def get_child_at_index(self, index):\n" + " def get_child_index(self, name):\n" "class synthProvider:"; class TypeSynthAddInputReader : public InputReaderEZ From johnny.chen at apple.com Mon Jul 25 14:32:35 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 25 Jul 2011 19:32:35 -0000 Subject: [Lldb-commits] [lldb] r135938 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/value/linked_list/ test/python_api/value/linked_list/Makefile test/python_api/value/linked_list/TestValueAPILinkedList.py test/python_api/value/linked_list/main.cpp Message-ID: <20110725193235.C3C282A6C12C@llvm.org> Author: johnny Date: Mon Jul 25 14:32:35 2011 New Revision: 135938 URL: http://llvm.org/viewvc/llvm-project?rev=135938&view=rev Log: Provide an add-on API to SBValue class by post-processing to provide a way to iterate through an SBValue instance by treating it as the head of a linked list. API program must provide two args to the linked_list_iter() method: the first being the child member name which points to the next item on the list and the second being a Python function which an SBValue (for the next item) and returns True if end of list is reached, otherwise it returns False. For example, suppose we have the following sample program. #include class Task { public: int id; Task *next; Task(int i, Task *n): id(i), next(n) {} }; int main (int argc, char const *argv[]) { Task *task_head = new Task(-1, NULL); Task *task1 = new Task(1, NULL); Task *task2 = new Task(2, NULL); Task *task3 = new Task(3, NULL); // Orphaned. Task *task4 = new Task(4, NULL); Task *task5 = new Task(5, NULL); task_head->next = task1; task1->next = task2; task2->next = task4; task4->next = task5; int total = 0; // Break at this line Task *t = task_head; while (t != NULL) { if (t->id >= 0) ++total; t = t->next; } printf("We have a total number of %d tasks\n", total); return 0; } The test program produces the following output while exercising the linked_list_iter() SBVAlue API: task_head: TypeName -> Task * ByteSize -> 8 NumChildren -> 2 Value -> 0x0000000106400380 ValueType -> local_variable Summary -> None IsPointerType -> True Location -> 0x00007fff65f06e60 (Task *) next = 0x0000000106400390 (int) id = 1 (Task *) next = 0x00000001064003a0 (Task *) next = 0x00000001064003a0 (int) id = 2 (Task *) next = 0x00000001064003c0 (Task *) next = 0x00000001064003c0 (int) id = 4 (Task *) next = 0x00000001064003d0 (Task *) next = 0x00000001064003d0 (int) id = 5 (Task *) next = 0x0000000000000000 Added: lldb/trunk/test/python_api/value/linked_list/ lldb/trunk/test/python_api/value/linked_list/Makefile lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py lldb/trunk/test/python_api/value/linked_list/main.cpp Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=135938&r1=135937&r2=135938&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Mon Jul 25 14:32:35 2011 @@ -82,6 +82,63 @@ # ============================================================================== ''' +# +# linked_list_iter() is a special purpose iterator to treat the SBValue as a +# list data structure, where you specify the child member name which points to +# the next item on the list and you specify the end-of-list function which takes +# an SBValue and returns True if EOL is reached and False if not. +# +linked_list_iter_def = ''' + # ================================================== + # Iterator for lldb.SBValue treated as a linked list + # ================================================== + def linked_list_iter(self, next_item_name, end_of_list): + """A generator adaptor to support iteration for SBValue as a linked list. + + For example, + + # Test function to determine end of list. + def eol(val): + if not val: + return True + try: + # Test the semantics of the item we got. + id = val.GetChildMemberWithName("id") + if int(id.GetValue()) > 0: + return False + except: + pass + + # If we fall through to here. It could be that exception + # occurred or the "id" child member does not qualify as a + # valid item. Return True for EOL. + return True + + # Get Frame #0. + ... + + # Get variable 'task_head'. + task_head = frame0.FindVariable('task_head') + ... + + for t in task_head.linked_list_iter('next', eol): + print t + """ + try: + item = self.GetChildMemberWithName(next_item_name) + while item: + yield item + # Prepare for the next iteration. + item = item.GetChildMemberWithName(next_item_name) + if end_of_list(item): + break + except: + # Exception occurred. Stop the generator. + pass + + return +''' + # This supports the iteration protocol. iter_def = " def __iter__(self): return lldb_iter(self, '%s', '%s')" module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')" @@ -266,6 +323,10 @@ new_content.add_line(eq_def % (cls, list_to_frag(e[cls]))) new_content.add_line(ne_def) + # This special purpose iterator is for SBValue only!!! + if cls == "SBValue": + new_content.add_line(linked_list_iter_def) + # Next state will be NORMAL. state = NORMAL Added: lldb/trunk/test/python_api/value/linked_list/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/Makefile?rev=135938&view=auto ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/Makefile (added) +++ lldb/trunk/test/python_api/value/linked_list/Makefile Mon Jul 25 14:32:35 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py?rev=135938&view=auto ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py (added) +++ lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Mon Jul 25 14:32:35 2011 @@ -0,0 +1,96 @@ +""" +Test SBValue API linked_list_iter which treats the SBValue as a linked list and +supports iteration till the end of list is reached. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class ValueAsLinkedListTestCase(TestBase): + + mydir = os.path.join("python_api", "value", "linked_list") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_with_dsym(self): + """Exercise SBValue API linked_list_iter.""" + d = {'EXE': self.exe_name} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.linked_list_api(self.exe_name) + + @python_api_test + def test_with_dwarf(self): + """Exercise SBValue API linked_list_iter.""" + d = {'EXE': self.exe_name} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.linked_list_api(self.exe_name) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # We'll use the test method name as the exe_name. + self.exe_name = self.testMethodName + # Find the line number to break at. + self.line = line_number('main.cpp', '// Break at this line') + + def linked_list_api(self, exe_name): + """Exercise SBValue API linked_list-iter.""" + exe = os.path.join(os.getcwd(), exe_name) + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Create the breakpoint inside function 'main'. + breakpoint = target.BreakpointCreateByLocation('main.cpp', self.line) + self.assertTrue(breakpoint, VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) + + def eol(val): + """Test to determine end of list.""" + if not val: + return True + try: + id = val.GetChildMemberWithName("id") + if int(id.GetValue()) > 0: + return False + except: + #exc_type, exc_value, exc_tb = sys.exc_info() + #traceback.print_exception(exc_type, exc_value, exc_tb) + pass + + # If we fall through to here. It could be that exception + # occurred or the "id" child member does not qualify as a + # valid item. Return True for EOL. + return True + + # Get Frame #0. + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") + frame0 = thread.GetFrameAtIndex(0) + + # Get variable 'task_head'. + task_head = frame0.FindVariable('task_head') + self.assertTrue(task_head, VALID_VARIABLE) + self.DebugSBValue(task_head) + + cvf = lldbutil.ChildVisitingFormatter(indent_child=2) + for t in task_head.linked_list_iter('next', eol): + self.assertTrue(t, VALID_VARIABLE) + if self.TraceOn(): + print cvf.format(t) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/value/linked_list/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/main.cpp?rev=135938&view=auto ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/main.cpp (added) +++ lldb/trunk/test/python_api/value/linked_list/main.cpp Mon Jul 25 14:32:35 2011 @@ -0,0 +1,45 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +class Task { +public: + int id; + Task *next; + Task(int i, Task *n): + id(i), + next(n) + {} +}; + + +int main (int argc, char const *argv[]) +{ + Task *task_head = new Task(-1, NULL); + Task *task1 = new Task(1, NULL); + Task *task2 = new Task(2, NULL); + Task *task3 = new Task(3, NULL); // Orphaned. + Task *task4 = new Task(4, NULL); + Task *task5 = new Task(5, NULL); + + task_head->next = task1; + task1->next = task2; + task2->next = task4; + task4->next = task5; + + int total = 0; // Break at this line + Task *t = task_head; + while (t != NULL) { + if (t->id >= 0) + ++total; + t = t->next; + } + printf("We have a total number of %d tasks\n", total); + return 0; +} From johnny.chen at apple.com Mon Jul 25 14:57:44 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 25 Jul 2011 19:57:44 -0000 Subject: [Lldb-commits] [lldb] r135944 - /lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Message-ID: <20110725195744.1EAFC2A6C12C@llvm.org> Author: johnny Date: Mon Jul 25 14:57:43 2011 New Revision: 135944 URL: http://llvm.org/viewvc/llvm-project?rev=135944&view=rev Log: Add a stronger assert for the test to ensure that the visited items from iterating through the SBValue.linked_list_iter() API is equal to [1, 2, 4, 5]. Modified: lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Modified: lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py?rev=135944&r1=135943&r2=135944&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py (original) +++ lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Mon Jul 25 14:57:43 2011 @@ -83,11 +83,20 @@ self.assertTrue(task_head, VALID_VARIABLE) self.DebugSBValue(task_head) + # By design (see main.cpp), the visited id's are: [1, 2, 4, 5]. + visitedIDs = [1, 2, 4, 5] + list = [] + cvf = lldbutil.ChildVisitingFormatter(indent_child=2) for t in task_head.linked_list_iter('next', eol): self.assertTrue(t, VALID_VARIABLE) + list.append(int(t.GetChildMemberWithName("id").GetValue())) if self.TraceOn(): print cvf.format(t) + + # Sanity checks that the we visited all the items (no more, no less). + #print "list:", list + self.assertTrue(visitedIDs == list) if __name__ == '__main__': import atexit From granata.enrico at gmail.com Mon Jul 25 17:19:19 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 25 Jul 2011 22:19:19 -0000 Subject: [Lldb-commits] [lldb] r135989 - /lldb/trunk/source/Symbol/ClangASTType.cpp Message-ID: <20110725221919.DEEBA2A6C12C@llvm.org> Author: enrico Date: Mon Jul 25 17:19:19 2011 New Revision: 135989 URL: http://llvm.org/viewvc/llvm-project?rev=135989&view=rev Log: bug fix in ClangASTType when trying to get size of a non-complete type Modified: lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=135989&r1=135988&r2=135989&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Mon Jul 25 17:19:19 2011 @@ -1373,9 +1373,13 @@ clang::ASTContext *ast_context, lldb::clang_type_t opaque_clang_qual_type) { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); - return (ast_context->getTypeSize (qual_type) + 7) / 8; + if (ClangASTContext::GetCompleteType (ast_context, opaque_clang_qual_type)) + { + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + return (ast_context->getTypeSize (qual_type) + 7) / 8; + } + return UINT32_MAX; } From johnny.chen at apple.com Mon Jul 25 17:47:55 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 25 Jul 2011 22:47:55 -0000 Subject: [Lldb-commits] [lldb] r135997 - /lldb/trunk/examples/summaries/lldb Message-ID: <20110725224755.24D762A6C12C@llvm.org> Author: johnny Date: Mon Jul 25 17:47:54 2011 New Revision: 135997 URL: http://llvm.org/viewvc/llvm-project?rev=135997&view=rev Log: Add an example type summary -- for lldb::ConnectionStatus. Modified: lldb/trunk/examples/summaries/lldb Modified: lldb/trunk/examples/summaries/lldb URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/lldb?rev=135997&r1=135996&r2=135997&view=diff ============================================================================== --- lldb/trunk/examples/summaries/lldb (original) +++ lldb/trunk/examples/summaries/lldb Mon Jul 25 17:47:54 2011 @@ -11,3 +11,4 @@ type summary add -w lldb lldb_private::Variable -f "${var.m_type.m_name} ${var.m_name}" type summary add -w lldb lldb_private::StopInfo -f "ID: ${var.m_stop_id}, ${var.m_description}" type summary add -w lldb lldb_private::FileSpec -f "file: ${var.m_filename} dir: ${var.m_directory}" +type summary add -w lldb lldb::ConnectionStatus -f "[enum=${var%E} val=${var%i}]" From johnny.chen at apple.com Mon Jul 25 18:41:08 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 25 Jul 2011 23:41:08 -0000 Subject: [Lldb-commits] [lldb] r136015 - in /lldb/trunk/scripts/Python: interface/SBValue.i modify-python-lldb.py Message-ID: <20110725234108.858A82A6C12C@llvm.org> Author: johnny Date: Mon Jul 25 18:41:08 2011 New Revision: 136015 URL: http://llvm.org/viewvc/llvm-project?rev=136015&view=rev Log: Add cross references between the docstrings for regular SBValue iteration: for child in value: # do something with the child value and SBValue.linked_list_iter(): for task in task_head.linked_list_iter('next', eol_test): # visit each item in the linked list Modified: lldb/trunk/scripts/Python/interface/SBValue.i lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/interface/SBValue.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=136015&r1=136014&r2=136015&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBValue.i (original) +++ lldb/trunk/scripts/Python/interface/SBValue.i Mon Jul 25 18:41:08 2011 @@ -49,7 +49,11 @@ Name: rflags Value: 0x0000000000000206 Name: cs Value: 0x0000000000000027 Name: fs Value: 0x0000000000000010 -Name: gs Value: 0x0000000000000048" +Name: gs Value: 0x0000000000000048 + +See also linked_list_iter() for another perspective on how to iterate through an +SBValue instance which interprets the value object as representing the head of a +linked list." ) SBValue; class SBValue { Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=136015&r1=136014&r2=136015&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Mon Jul 25 18:41:08 2011 @@ -83,17 +83,23 @@ ''' # -# linked_list_iter() is a special purpose iterator to treat the SBValue as a -# list data structure, where you specify the child member name which points to -# the next item on the list and you specify the end-of-list function which takes -# an SBValue and returns True if EOL is reached and False if not. +# linked_list_iter() is a special purpose iterator to treat the SBValue as the +# head of a list data structure, where you specify the child member name which +# points to the next item on the list and you specify the end-of-list function +# which takes an SBValue and returns True if EOL is reached and False if not. # linked_list_iter_def = ''' # ================================================== # Iterator for lldb.SBValue treated as a linked list # ================================================== def linked_list_iter(self, next_item_name, end_of_list): - """A generator adaptor to support iteration for SBValue as a linked list. + """Generator adaptor to support iteration for SBValue as a linked list. + + linked_list_iter() is a special purpose iterator to treat the SBValue as + the head of a list data structure, where you specify the child member + name which points to the next item on the list and you specify the + end-of-list test function which takes an SBValue for an item and returns + True if EOL is reached and False if not. For example, From johnny.chen at apple.com Mon Jul 25 18:44:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 25 Jul 2011 23:44:48 -0000 Subject: [Lldb-commits] [lldb] r136016 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110725234448.813002A6C12C@llvm.org> Author: johnny Date: Mon Jul 25 18:44:48 2011 New Revision: 136016 URL: http://llvm.org/viewvc/llvm-project?rev=136016&view=rev Log: Rename the parameter for the end-of-list test function from end_of_list to end_of_list_test. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=136016&r1=136015&r2=136016&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Mon Jul 25 18:44:48 2011 @@ -92,7 +92,7 @@ # ================================================== # Iterator for lldb.SBValue treated as a linked list # ================================================== - def linked_list_iter(self, next_item_name, end_of_list): + def linked_list_iter(self, next_item_name, end_of_list_test): """Generator adaptor to support iteration for SBValue as a linked list. linked_list_iter() is a special purpose iterator to treat the SBValue as @@ -136,7 +136,7 @@ yield item # Prepare for the next iteration. item = item.GetChildMemberWithName(next_item_name) - if end_of_list(item): + if end_of_list_test(item): break except: # Exception occurred. Stop the generator. From johnny.chen at apple.com Mon Jul 25 19:22:59 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Jul 2011 00:22:59 -0000 Subject: [Lldb-commits] [lldb] r136026 - /lldb/trunk/examples/summaries/lldb Message-ID: <20110726002259.2715B2A6C12C@llvm.org> Author: johnny Date: Mon Jul 25 19:22:58 2011 New Revision: 136026 URL: http://llvm.org/viewvc/llvm-project?rev=136026&view=rev Log: Minor modification. Modified: lldb/trunk/examples/summaries/lldb Modified: lldb/trunk/examples/summaries/lldb URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/lldb?rev=136026&r1=136025&r2=136026&view=diff ============================================================================== --- lldb/trunk/examples/summaries/lldb (original) +++ lldb/trunk/examples/summaries/lldb Mon Jul 25 19:22:58 2011 @@ -11,4 +11,5 @@ type summary add -w lldb lldb_private::Variable -f "${var.m_type.m_name} ${var.m_name}" type summary add -w lldb lldb_private::StopInfo -f "ID: ${var.m_stop_id}, ${var.m_description}" type summary add -w lldb lldb_private::FileSpec -f "file: ${var.m_filename} dir: ${var.m_directory}" -type summary add -w lldb lldb::ConnectionStatus -f "[enum=${var%E} val=${var%i}]" +type summary add -w lldb -v lldb::ConnectionStatus -f "[enum=${var%E} val=${var%i}]" +# Where '-v' tells type summary not to show the value itself, but just use the summary format. \ No newline at end of file From johnny.chen at apple.com Mon Jul 25 19:24:30 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Jul 2011 00:24:30 -0000 Subject: [Lldb-commits] [lldb] r136028 - /lldb/trunk/examples/summaries/lldb Message-ID: <20110726002430.6F0EB2A6C12C@llvm.org> Author: johnny Date: Mon Jul 25 19:24:30 2011 New Revision: 136028 URL: http://llvm.org/viewvc/llvm-project?rev=136028&view=rev Log: Add newline at end of file. Modified: lldb/trunk/examples/summaries/lldb Modified: lldb/trunk/examples/summaries/lldb URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/lldb?rev=136028&r1=136027&r2=136028&view=diff ============================================================================== --- lldb/trunk/examples/summaries/lldb (original) +++ lldb/trunk/examples/summaries/lldb Mon Jul 25 19:24:30 2011 @@ -12,4 +12,4 @@ type summary add -w lldb lldb_private::StopInfo -f "ID: ${var.m_stop_id}, ${var.m_description}" type summary add -w lldb lldb_private::FileSpec -f "file: ${var.m_filename} dir: ${var.m_directory}" type summary add -w lldb -v lldb::ConnectionStatus -f "[enum=${var%E} val=${var%i}]" -# Where '-v' tells type summary not to show the value itself, but just use the summary format. \ No newline at end of file +# Where '-v' tells type summary not to show the value itself, but just use the summary format. From jingham at apple.com Mon Jul 25 21:39:59 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 26 Jul 2011 02:39:59 -0000 Subject: [Lldb-commits] [lldb] r136052 - in /lldb/trunk/source: Commands/CommandObjectThread.cpp Target/Thread.cpp Message-ID: <20110726023959.F294F2A6C12C@llvm.org> Author: jingham Date: Mon Jul 25 21:39:59 2011 New Revision: 136052 URL: http://llvm.org/viewvc/llvm-project?rev=136052&view=rev Log: Indent the frames in the "thread.GetStatus" frame listing. Also put the same space after each thread listing for "thread backtrace all" as "thread backtrace 1 3 5" Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=136052&r1=136051&r2=136052&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Mon Jul 25 21:39:59 2011 @@ -196,6 +196,10 @@ result.SetStatus (eReturnStatusFailed); return false; } + + if (i < num_threads - 1) + result.AppendMessage(""); + } } else Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=136052&r1=136051&r2=136052&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Mon Jul 25 21:39:59 2011 @@ -1126,6 +1126,7 @@ const bool show_frame_info = true; const uint32_t source_lines_before = 3; const uint32_t source_lines_after = 3; + strm.IndentMore (); num_frames_shown = GetStackFrameList ().GetStatus (strm, start_frame, num_frames, @@ -1134,6 +1135,7 @@ source_lines_before, source_lines_after); strm.IndentLess(); + strm.IndentLess(); } return num_frames_shown; } From jmolenda at apple.com Mon Jul 25 22:34:52 2011 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 26 Jul 2011 03:34:52 -0000 Subject: [Lldb-commits] [lldb] r136055 - in /lldb/trunk/tools/debugserver/source: RNBRemote.cpp RNBRemote.h Message-ID: <20110726033452.E0B142A6C12C@llvm.org> Author: jmolenda Date: Mon Jul 25 22:34:52 2011 New Revision: 136055 URL: http://llvm.org/viewvc/llvm-project?rev=136055&view=rev Log: RNBRemote.cpp, RNBRemote.h: Add a new qGetPid packet which returns the pid of the process currently being debugged by debugserer in hex, or 0 if unavailable. This is effectively the same as the qC packet but that packet is not clear in either its documentation or implementation (in gdb et al) as to whether it is intended to return a pid or a thread id. qGetPid is unambiguous. If qGetPid is unimplemented in the remote debugserver, the debugger may try qC and see what kind of value is returned.. Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp lldb/trunk/tools/debugserver/source/RNBRemote.h Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=136055&r1=136054&r2=136055&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Mon Jul 25 22:34:52 2011 @@ -154,6 +154,7 @@ // t.push_back (Packet (insert_access_watch_bp, &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "Z4", "Insert access watchpoint")); // t.push_back (Packet (remove_access_watch_bp, &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "z4", "Remove access watchpoint")); t.push_back (Packet (query_current_thread_id, &RNBRemote::HandlePacket_qC, NULL, "qC", "Query current thread ID")); + t.push_back (Packet (query_get_pid, &RNBRemote::HandlePacket_qGetPid, NULL, "qGetPid", "Query process id")); // t.push_back (Packet (query_memory_crc, &RNBRemote::HandlePacket_UNIMPLEMENTED, NULL, "qCRC:", "Compute CRC of memory region")); t.push_back (Packet (query_thread_ids_first, &RNBRemote::HandlePacket_qThreadInfo, NULL, "qfThreadInfo", "Get list of active threads (first req)")); t.push_back (Packet (query_thread_ids_subsequent, &RNBRemote::HandlePacket_qThreadInfo, NULL, "qsThreadInfo", "Get list of active threads (subsequent req)")); @@ -1394,6 +1395,21 @@ } rnb_err_t +RNBRemote::HandlePacket_qGetPid (const char *p) +{ + nub_process_t pid; + std::ostringstream rep; + // If we haven't run the process yet, we tell the debugger the + // pid is 0. That way it can know to tell use to run later on. + if (m_ctx.HasValidProcessID()) + pid = m_ctx.ProcessID(); + else + pid = 0; + rep << std::hex << pid; + return SendPacket (rep.str()); +} + +rnb_err_t RNBRemote::HandlePacket_qRegisterInfo (const char *p) { if (g_num_reg_entries == 0) Modified: lldb/trunk/tools/debugserver/source/RNBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.h?rev=136055&r1=136054&r2=136055&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.h (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.h Mon Jul 25 22:34:52 2011 @@ -79,6 +79,7 @@ remove_access_watch_bp, // 'z4' query_current_thread_id, // 'qC' + query_get_pid, // 'qGetPid' query_memory_crc, // 'qCRC:' query_thread_ids_first, // 'qfThreadInfo' query_thread_ids_subsequent, // 'qsThreadInfo' @@ -155,6 +156,7 @@ rnb_err_t HandlePacket_A (const char *p); rnb_err_t HandlePacket_H (const char *p); rnb_err_t HandlePacket_qC (const char *p); + rnb_err_t HandlePacket_qGetPid (const char *p); rnb_err_t HandlePacket_qLaunchSuccess (const char *p); rnb_err_t HandlePacket_qRegisterInfo (const char *p); rnb_err_t HandlePacket_qShlibInfoAddr (const char *p); From johnny.chen at apple.com Tue Jul 26 14:09:03 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Jul 2011 19:09:03 -0000 Subject: [Lldb-commits] [lldb] r136117 - in /lldb/trunk/scripts: Python/python-typemaps.swig Python/python-wrapper.swig lldb.swig Message-ID: <20110726190903.D00B92A6C12C@llvm.org> Author: johnny Date: Tue Jul 26 14:09:03 2011 New Revision: 136117 URL: http://llvm.org/viewvc/llvm-project?rev=136117&view=rev Log: lldb.swig (the SWIG input file) has become too large. Modularize a bit by introducing two files to be included from lldb.swig: python-typemaps.swig and python-wrapper.swig. Added: lldb/trunk/scripts/Python/python-typemaps.swig lldb/trunk/scripts/Python/python-wrapper.swig Modified: lldb/trunk/scripts/lldb.swig Added: lldb/trunk/scripts/Python/python-typemaps.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-typemaps.swig?rev=136117&view=auto ============================================================================== --- lldb/trunk/scripts/Python/python-typemaps.swig (added) +++ lldb/trunk/scripts/Python/python-typemaps.swig Tue Jul 26 14:09:03 2011 @@ -0,0 +1,110 @@ +/* Typemap definitions, to allow SWIG to properly handle 'char**' data types. */ + +%typemap(in) char ** { + /* Check if is a list */ + if (PyList_Check($input)) { + int size = PyList_Size($input); + int i = 0; + $1 = (char **) malloc((size+1) * sizeof(char*)); + for (i = 0; i < size; i++) { + PyObject *o = PyList_GetItem($input,i); + if (PyString_Check(o)) + $1[i] = PyString_AsString(o); + else { + PyErr_SetString(PyExc_TypeError,"list must contain strings"); + free($1); + return NULL; + } + } + $1[i] = 0; + } else if ($input == Py_None) { + $1 = NULL; + } else { + PyErr_SetString(PyExc_TypeError,"not a list"); + return NULL; + } +} + +%typemap(freearg) char** { + free((char *) $1); +} + +%typemap(out) char** { + int len; + int i; + len = 0; + while ($1[len]) len++; + $result = PyList_New(len); + for (i = 0; i < len; i++) { + PyList_SetItem($result, i, PyString_FromString($1[i])); + } +} + +/* Typemap definitions to allow SWIG to properly handle char buffer. */ + +// typemap for a char buffer +// See also SBThread::GetStopDescription. +%typemap(in) (char *dst, size_t dst_len) { + if (!PyInt_Check($input)) { + PyErr_SetString(PyExc_ValueError, "Expecting an integer"); + return NULL; + } + $2 = PyInt_AsLong($input); + if ($2 <= 0) { + PyErr_SetString(PyExc_ValueError, "Positive integer expected"); + return NULL; + } + $1 = (char *) malloc($2); +} + +// Return the char buffer. Discarding any previous return result +// See also SBThread::GetStopDescription. +%typemap(argout) (char *dst, size_t dst_len) { + Py_XDECREF($result); /* Blow away any previous result */ + $result = PyString_FromStringAndSize(($1),result); + free($1); +} + + +// typemap for an outgoing buffer +// See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len). +%typemap(in) (const char *cstr, uint32_t cstr_len) { + if (!PyString_Check($input)) { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; + } + $1 = (char *) PyString_AsString($input); + $2 = PyString_Size($input); +} +// And SBProcess::WriteMemory. +%typemap(in) (const void *buf, size_t size) { + if (!PyString_Check($input)) { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; + } + $1 = (void *) PyString_AsString($input); + $2 = PyString_Size($input); +} + +// typemap for an incoming buffer +// See also SBProcess::ReadMemory. +%typemap(in) (void *buf, size_t size) { + if (!PyInt_Check($input)) { + PyErr_SetString(PyExc_ValueError, "Expecting an integer"); + return NULL; + } + $2 = PyInt_AsLong($input); + if ($2 <= 0) { + PyErr_SetString(PyExc_ValueError, "Positive integer expected"); + return NULL; + } + $1 = (void *) malloc($2); +} + +// Return the buffer. Discarding any previous return result +// See also SBProcess::ReadMemory. +%typemap(argout) (void *buf, size_t size) { + Py_XDECREF($result); /* Blow away any previous result */ + $result = PyString_FromStringAndSize(static_cast($1),result); + free($1); +} Added: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=136117&view=auto ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (added) +++ lldb/trunk/scripts/Python/python-wrapper.swig Tue Jul 26 14:09:03 2011 @@ -0,0 +1,527 @@ +%wrapper %{ + +// This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...) +// and is used when a script command is attached to a breakpoint for execution. + +SWIGEXPORT bool +LLDBSwigPythonBreakpointCallbackFunction +( + const char *python_function_name, + const char *session_dictionary_name, + const lldb::StackFrameSP& frame_sp, + const lldb::BreakpointLocationSP& bp_loc_sp +) +{ + lldb::SBFrame sb_frame (frame_sp); + lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp); + + bool stop_at_breakpoint = true; + PyObject *Frame_PyObj = SWIG_NewPointerObj((void *) &sb_frame, SWIGTYPE_p_lldb__SBFrame, 0); + PyObject *Bp_Loc_PyObj = SWIG_NewPointerObj ((void *) &sb_bp_loc, SWIGTYPE_p_lldb__SBBreakpointLocation, 0); + + if (Frame_PyObj == NULL || Bp_Loc_PyObj == NULL) + return stop_at_breakpoint; + + if (!python_function_name || !session_dictionary_name) + return stop_at_breakpoint; + + 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 stop_at_breakpoint; + + // 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 (3); + if (pargs == NULL) + { + if (PyErr_Occurred()) + PyErr_Clear(); + return stop_at_breakpoint; + } + + PyTuple_SetItem (pargs, 0, Frame_PyObj); // This "steals" a reference to Frame_PyObj + PyTuple_SetItem (pargs, 1, Bp_Loc_PyObj); // This "steals" a reference to Bp_Loc_PyObj + PyTuple_SetItem (pargs, 2, session_dict); // This "steals" a reference to session_dict + pvalue = PyObject_CallObject (pfunc, pargs); + Py_DECREF (pargs); + + if (pvalue != NULL) + { + Py_DECREF (pvalue); + } + else if (PyErr_Occurred ()) + { + PyErr_Clear(); + } + Py_INCREF (session_dict); + } + else if (PyErr_Occurred()) + { + PyErr_Clear(); + } + } + else if (PyErr_Occurred()) + { + PyErr_Clear(); + } + } + else if (PyErr_Occurred ()) + { + PyErr_Clear (); + } + return stop_at_breakpoint; +} + +SWIGEXPORT std::string +LLDBSwigPythonCallTypeScript +( + const char *python_function_name, + const char *session_dictionary_name, + const lldb::ValueObjectSP& valobj_sp +) +{ + lldb::SBValue sb_value (valobj_sp); + + std::string retval = ""; + + PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *) &valobj_sp, SWIGTYPE_p_lldb__SBValue, 0); + + if (ValObj_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 (2); + if (pargs == NULL) + { + if (PyErr_Occurred()) + PyErr_Clear(); + return retval; + } + + PyTuple_SetItem (pargs, 0, ValObj_PyObj); // This "steals" a reference to ValObj_PyObj + PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict + pvalue = PyObject_CallObject (pfunc, pargs); + Py_DECREF (pargs); + + if (pvalue != NULL) + { + if (pvalue != Py_None) + retval = std::string(PyString_AsString(pvalue)); + else + retval = "None"; + 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; +} + +SWIGEXPORT void* +LLDBSwigPythonCreateSyntheticProvider +( + const std::string python_class_name, + const char *session_dictionary_name, + const lldb::ValueObjectSP& valobj_sp +) +{ + PyObject* retval = NULL; + + if (python_class_name.empty() || !session_dictionary_name) + Py_RETURN_NONE; + + lldb::ValueObjectSP* valobj_sp_ptr = new lldb::ValueObjectSP(valobj_sp); + + PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *) valobj_sp_ptr, SWIGTYPE_p_lldb__SBValue, SWIG_POINTER_OWN); + + if (ValObj_PyObj == NULL) + Py_RETURN_NONE; + + const char* python_function_name = python_class_name.c_str(); + + PyObject *pmodule, *main_dict, *session_dict, *pfunc; + PyObject *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)) + { + PyObject *argList = Py_BuildValue("SS", ValObj_PyObj, session_dict); + + if (PyErr_Occurred ()) + { + PyErr_Print(); + PyErr_Clear(); + return retval; + } + + if (argList == NULL) + { + return retval; + } + + Py_INCREF(ValObj_PyObj); + + pvalue = PyObject_CallObject(pfunc, argList); + + Py_DECREF(argList); + + if (pvalue != NULL) + { + if (pvalue != Py_None) + retval = pvalue; + else + { + retval = Py_None; + Py_INCREF(retval); + } + } + 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 (); + } + if (retval) + return retval; + else + Py_RETURN_NONE; +} + +/* +these four calls below are meant to support +Python-based synthetic children providers +they essentially mimic the four pure virtual +method calls provided by the frontend class +*/ + +SWIGEXPORT uint32_t +LLDBSwigPython_CalculateNumChildren +( + PyObject *implementor +) +{ + + static char callee_name[] = "num_children"; + + if (implementor == NULL || implementor == Py_None) + return 0; + PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL); + if (PyErr_Occurred()) + { + PyErr_Print(); + PyErr_Clear(); + } + + if (py_return == NULL || py_return == Py_None) + { + Py_XDECREF(py_return); + return UINT32_MAX; + } + long retval = PyInt_AsLong(py_return); + Py_DECREF(py_return); + if (retval >= 0) + return (uint32_t)retval; + if (PyErr_Occurred()) + { + PyErr_Print(); + PyErr_Clear(); + } + return 0; +} + +SWIGEXPORT PyObject* +LLDBSwigPython_GetChildAtIndex +( + PyObject *implementor, + uint32_t idx +) +{ + + static char callee_name[] = "get_child_at_index"; + static char param_format[] = "i"; + + if (implementor == NULL || implementor == Py_None) + return NULL; + PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, idx); + if (PyErr_Occurred()) + { + PyErr_Print(); + PyErr_Clear(); + } + + if (py_return == NULL || py_return == Py_None) + { + Py_XDECREF(py_return); + return NULL; + } + + lldb::SBValue* sbvalue_ptr = NULL; + + if (SWIG_ConvertPtr(py_return, (void**)&sbvalue_ptr, SWIGTYPE_p_lldb__SBValue, 0) == -1) + { + Py_DECREF(py_return); + return NULL; + } + + if (sbvalue_ptr == NULL) + return NULL; + + return py_return; +} + +SWIGEXPORT int +LLDBSwigPython_GetIndexOfChildWithName +( + PyObject *implementor, + const char* child_name +) +{ + static char callee_name[] = "get_child_index"; + static char param_format[] = "s"; + + if (implementor == NULL || implementor == Py_None) + return 0; + PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, child_name); + if (PyErr_Occurred()) + { + PyErr_Print(); + PyErr_Clear(); + } + + if (py_return == NULL || py_return == Py_None) + { + Py_XDECREF(py_return); + return UINT32_MAX; + } + long retval = PyInt_AsLong(py_return); + Py_DECREF(py_return); + if (retval >= 0) + return (uint32_t)retval; + if (PyErr_Occurred()) + { + PyErr_Print(); + PyErr_Clear(); + } + return 0; +} + +SWIGEXPORT lldb::SBValue* +LLDBSWIGPython_CastPyObjectToSBValue +( + PyObject* data +) +{ + lldb::SBValue* sb_ptr = NULL; + + int valid_cast = SWIG_ConvertPtr(data, (void**)&sb_ptr, SWIGTYPE_p_lldb__SBValue, 0); + + if (valid_cast == -1) + return NULL; + + return sb_ptr; +} + +%} Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=136117&r1=136116&r2=136117&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Tue Jul 26 14:09:03 2011 @@ -37,119 +37,9 @@ // Parameter types will be used in the autodoc string. %feature("autodoc", "1"); -/* Typemap definitions, to allow SWIG to properly handle 'char**' data types. */ - -%typemap(in) char ** { - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $1 = (char **) malloc((size+1) * sizeof(char*)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyString_Check(o)) - $1[i] = PyString_AsString(o); - else { - PyErr_SetString(PyExc_TypeError,"list must contain strings"); - free($1); - return NULL; - } - } - $1[i] = 0; - } else if ($input == Py_None) { - $1 = NULL; - } else { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} - -%typemap(freearg) char** { - free((char *) $1); -} - -%typemap(out) char** { - int len; - int i; - len = 0; - while ($1[len]) len++; - $result = PyList_New(len); - for (i = 0; i < len; i++) { - PyList_SetItem($result, i, PyString_FromString($1[i])); - } -} - -/* Typemap definitions to allow SWIG to properly handle char buffer. */ - -// typemap for a char buffer -// See also SBThread::GetStopDescription. -%typemap(in) (char *dst, size_t dst_len) { - if (!PyInt_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting an integer"); - return NULL; - } - $2 = PyInt_AsLong($input); - if ($2 <= 0) { - PyErr_SetString(PyExc_ValueError, "Positive integer expected"); - return NULL; - } - $1 = (char *) malloc($2); -} - -// Return the char buffer. Discarding any previous return result -// See also SBThread::GetStopDescription. -%typemap(argout) (char *dst, size_t dst_len) { - Py_XDECREF($result); /* Blow away any previous result */ - $result = PyString_FromStringAndSize(($1),result); - free($1); -} - - -// typemap for an outgoing buffer -// See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len). -%typemap(in) (const char *cstr, uint32_t cstr_len) { - if (!PyString_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; - } - $1 = (char *) PyString_AsString($input); - $2 = PyString_Size($input); -} -// And SBProcess::WriteMemory. -%typemap(in) (const void *buf, size_t size) { - if (!PyString_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; - } - $1 = (void *) PyString_AsString($input); - $2 = PyString_Size($input); -} - -// typemap for an incoming buffer -// See also SBProcess::ReadMemory. -%typemap(in) (void *buf, size_t size) { - if (!PyInt_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting an integer"); - return NULL; - } - $2 = PyInt_AsLong($input); - if ($2 <= 0) { - PyErr_SetString(PyExc_ValueError, "Positive integer expected"); - return NULL; - } - $1 = (void *) malloc($2); -} - -// Return the buffer. Discarding any previous return result -// See also SBProcess::ReadMemory. -%typemap(argout) (void *buf, size_t size) { - Py_XDECREF($result); /* Blow away any previous result */ - $result = PyString_FromStringAndSize(static_cast($1),result); - free($1); -} +%include "./Python/python-typemaps.swig" /* The liblldb header files to be included. */ - %{ #include "lldb/lldb-public.h" #include "lldb/API/SBAddress.h" @@ -238,531 +128,4 @@ %include "./Python/python-extensions.swig" - -%wrapper %{ - -// This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...) -// and is used when a script command is attached to a breakpoint for execution. - -SWIGEXPORT bool -LLDBSwigPythonBreakpointCallbackFunction -( - const char *python_function_name, - const char *session_dictionary_name, - const lldb::StackFrameSP& frame_sp, - const lldb::BreakpointLocationSP& bp_loc_sp -) -{ - lldb::SBFrame sb_frame (frame_sp); - lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp); - - bool stop_at_breakpoint = true; - PyObject *Frame_PyObj = SWIG_NewPointerObj((void *) &sb_frame, SWIGTYPE_p_lldb__SBFrame, 0); - PyObject *Bp_Loc_PyObj = SWIG_NewPointerObj ((void *) &sb_bp_loc, SWIGTYPE_p_lldb__SBBreakpointLocation, 0); - - if (Frame_PyObj == NULL || Bp_Loc_PyObj == NULL) - return stop_at_breakpoint; - - if (!python_function_name || !session_dictionary_name) - return stop_at_breakpoint; - - 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 stop_at_breakpoint; - - // 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 (3); - if (pargs == NULL) - { - if (PyErr_Occurred()) - PyErr_Clear(); - return stop_at_breakpoint; - } - - PyTuple_SetItem (pargs, 0, Frame_PyObj); // This "steals" a reference to Frame_PyObj - PyTuple_SetItem (pargs, 1, Bp_Loc_PyObj); // This "steals" a reference to Bp_Loc_PyObj - PyTuple_SetItem (pargs, 2, session_dict); // This "steals" a reference to session_dict - pvalue = PyObject_CallObject (pfunc, pargs); - Py_DECREF (pargs); - - if (pvalue != NULL) - { - Py_DECREF (pvalue); - } - else if (PyErr_Occurred ()) - { - PyErr_Clear(); - } - Py_INCREF (session_dict); - } - else if (PyErr_Occurred()) - { - PyErr_Clear(); - } - } - else if (PyErr_Occurred()) - { - PyErr_Clear(); - } - } - else if (PyErr_Occurred ()) - { - PyErr_Clear (); - } - return stop_at_breakpoint; -} - -SWIGEXPORT std::string -LLDBSwigPythonCallTypeScript -( - const char *python_function_name, - const char *session_dictionary_name, - const lldb::ValueObjectSP& valobj_sp -) -{ - lldb::SBValue sb_value (valobj_sp); - - std::string retval = ""; - - PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *) &valobj_sp, SWIGTYPE_p_lldb__SBValue, 0); - - if (ValObj_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 (2); - if (pargs == NULL) - { - if (PyErr_Occurred()) - PyErr_Clear(); - return retval; - } - - PyTuple_SetItem (pargs, 0, ValObj_PyObj); // This "steals" a reference to ValObj_PyObj - PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict - pvalue = PyObject_CallObject (pfunc, pargs); - Py_DECREF (pargs); - - if (pvalue != NULL) - { - if (pvalue != Py_None) - retval = std::string(PyString_AsString(pvalue)); - else - retval = "None"; - 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; -} - -SWIGEXPORT void* -LLDBSwigPythonCreateSyntheticProvider -( - const std::string python_class_name, - const char *session_dictionary_name, - const lldb::ValueObjectSP& valobj_sp -) -{ - PyObject* retval = NULL; - - if (python_class_name.empty() || !session_dictionary_name) - Py_RETURN_NONE; - - lldb::ValueObjectSP* valobj_sp_ptr = new lldb::ValueObjectSP(valobj_sp); - - PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *) valobj_sp_ptr, SWIGTYPE_p_lldb__SBValue, SWIG_POINTER_OWN); - - if (ValObj_PyObj == NULL) - Py_RETURN_NONE; - - const char* python_function_name = python_class_name.c_str(); - - PyObject *pmodule, *main_dict, *session_dict, *pfunc; - PyObject *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)) - { - PyObject *argList = Py_BuildValue("SS", ValObj_PyObj, session_dict); - - if (PyErr_Occurred ()) - { - PyErr_Print(); - PyErr_Clear(); - return retval; - } - - if (argList == NULL) - { - return retval; - } - - Py_INCREF(ValObj_PyObj); - - pvalue = PyObject_CallObject(pfunc, argList); - - Py_DECREF(argList); - - if (pvalue != NULL) - { - if (pvalue != Py_None) - retval = pvalue; - else - { - retval = Py_None; - Py_INCREF(retval); - } - } - 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 (); - } - if (retval) - return retval; - else - Py_RETURN_NONE; -} - -/* -these four calls below are meant to support -Python-based synthetic children providers -they essentially mimic the four pure virtual -method calls provided by the frontend class -*/ - -SWIGEXPORT uint32_t -LLDBSwigPython_CalculateNumChildren -( - PyObject *implementor -) -{ - - static char callee_name[] = "num_children"; - - if (implementor == NULL || implementor == Py_None) - return 0; - PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL); - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - - if (py_return == NULL || py_return == Py_None) - { - Py_XDECREF(py_return); - return UINT32_MAX; - } - long retval = PyInt_AsLong(py_return); - Py_DECREF(py_return); - if (retval >= 0) - return (uint32_t)retval; - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - return 0; -} - -SWIGEXPORT PyObject* -LLDBSwigPython_GetChildAtIndex -( - PyObject *implementor, - uint32_t idx -) -{ - - static char callee_name[] = "get_child_at_index"; - static char param_format[] = "i"; - - if (implementor == NULL || implementor == Py_None) - return NULL; - PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, idx); - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - - if (py_return == NULL || py_return == Py_None) - { - Py_XDECREF(py_return); - return NULL; - } - - lldb::SBValue* sbvalue_ptr = NULL; - - if (SWIG_ConvertPtr(py_return, (void**)&sbvalue_ptr, SWIGTYPE_p_lldb__SBValue, 0) == -1) - { - Py_DECREF(py_return); - return NULL; - } - - if (sbvalue_ptr == NULL) - return NULL; - - return py_return; -} - -SWIGEXPORT int -LLDBSwigPython_GetIndexOfChildWithName -( - PyObject *implementor, - const char* child_name -) -{ - static char callee_name[] = "get_child_index"; - static char param_format[] = "s"; - - if (implementor == NULL || implementor == Py_None) - return 0; - PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, child_name); - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - - if (py_return == NULL || py_return == Py_None) - { - Py_XDECREF(py_return); - return UINT32_MAX; - } - long retval = PyInt_AsLong(py_return); - Py_DECREF(py_return); - if (retval >= 0) - return (uint32_t)retval; - if (PyErr_Occurred()) - { - PyErr_Print(); - PyErr_Clear(); - } - return 0; -} - -SWIGEXPORT lldb::SBValue* -LLDBSWIGPython_CastPyObjectToSBValue -( - PyObject* data -) -{ - lldb::SBValue* sb_ptr = NULL; - - int valid_cast = SWIG_ConvertPtr(data, (void**)&sb_ptr, SWIGTYPE_p_lldb__SBValue, 0); - - if (valid_cast == -1) - return NULL; - - return sb_ptr; -} - -%} +%include "./Python/python-wrapper.swig" From johnny.chen at apple.com Tue Jul 26 15:20:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Jul 2011 20:20:13 -0000 Subject: [Lldb-commits] [lldb] r136123 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/value/linked_list/TestValueAPILinkedList.py Message-ID: <20110726202013.84B062A6C12C@llvm.org> Author: johnny Date: Tue Jul 26 15:20:13 2011 New Revision: 136123 URL: http://llvm.org/viewvc/llvm-project?rev=136123&view=rev Log: The test function to determine whether we have reached the end of the list was too complex in the test case. We can just simply test that the SBValue object is a valid object and it does not correspond to a null pointer in order to say that EOL has not been reached. Modify the test case and the lldb.py docstring to have a more compact test function. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=136123&r1=136122&r2=136123&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue Jul 26 15:20:13 2011 @@ -103,22 +103,15 @@ For example, - # Test function to determine end of list. def eol(val): - if not val: + \'\'\'Test function to determine end of list.\'\'\' + # End of list is reached if either the value object is invalid + # or it corresponds to a null pointer. + if not val or int(val.GetValue(), 16) == 0: return True - try: - # Test the semantics of the item we got. - id = val.GetChildMemberWithName("id") - if int(id.GetValue()) > 0: - return False - except: - pass - - # If we fall through to here. It could be that exception - # occurred or the "id" child member does not qualify as a - # valid item. Return True for EOL. - return True + + # Otherwise, return False. + return False # Get Frame #0. ... Modified: lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py?rev=136123&r1=136122&r2=136123&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py (original) +++ lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Tue Jul 26 15:20:13 2011 @@ -55,22 +55,14 @@ self.assertTrue(process, PROCESS_IS_VALID) def eol(val): - """Test to determine end of list.""" - if not val: + """Test function to determine end of list.""" + # End of list is reached if either the value object is invalid + # or it corresponds to a null pointer. + if not val or int(val.GetValue(), 16) == 0: return True - try: - id = val.GetChildMemberWithName("id") - if int(id.GetValue()) > 0: - return False - except: - #exc_type, exc_value, exc_tb = sys.exc_info() - #traceback.print_exception(exc_type, exc_value, exc_tb) - pass - - # If we fall through to here. It could be that exception - # occurred or the "id" child member does not qualify as a - # valid item. Return True for EOL. - return True + + # Otherwise, return False. + return False # Get Frame #0. self.assertTrue(process.GetState() == lldb.eStateStopped) @@ -90,12 +82,15 @@ cvf = lldbutil.ChildVisitingFormatter(indent_child=2) for t in task_head.linked_list_iter('next', eol): self.assertTrue(t, VALID_VARIABLE) - list.append(int(t.GetChildMemberWithName("id").GetValue())) + # Make sure that 'next' corresponds to an SBValue with pointer type. + self.assertTrue(t.TypeIsPointerType()) if self.TraceOn(): print cvf.format(t) + list.append(int(t.GetChildMemberWithName("id").GetValue())) # Sanity checks that the we visited all the items (no more, no less). - #print "list:", list + if self.TraceOn(): + print "visited IDs:", list self.assertTrue(visitedIDs == list) if __name__ == '__main__': From johnny.chen at apple.com Tue Jul 26 15:57:10 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Jul 2011 20:57:10 -0000 Subject: [Lldb-commits] [lldb] r136144 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/value/linked_list/TestValueAPILinkedList.py Message-ID: <20110726205710.388B22A6C12C@llvm.org> Author: johnny Date: Tue Jul 26 15:57:10 2011 New Revision: 136144 URL: http://llvm.org/viewvc/llvm-project?rev=136144&view=rev Log: We can do better with the SBValue.linked_list_iter() API by supplying a default end of list test function as __eol_test__. The simple example can be reduced to: for t in task_head.linked_list_iter('next'): print t Modify the test program to exercise the API for both cases: supplying or not supplying an end of list test function. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=136144&r1=136143&r2=136144&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue Jul 26 15:57:10 2011 @@ -89,10 +89,21 @@ # which takes an SBValue and returns True if EOL is reached and False if not. # linked_list_iter_def = ''' + def __eol_test__(val): + """Default function for end of list test takes an SBValue object. + + Return True if val is invalid or it corresponds to a null pointer. + Otherwise, return False. + """ + if not val or int(val.GetValue(), 0) == 0: + return True + else: + return False + # ================================================== # Iterator for lldb.SBValue treated as a linked list # ================================================== - def linked_list_iter(self, next_item_name, end_of_list_test): + def linked_list_iter(self, next_item_name, end_of_list_test=__eol_test__): """Generator adaptor to support iteration for SBValue as a linked list. linked_list_iter() is a special purpose iterator to treat the SBValue as @@ -101,17 +112,10 @@ end-of-list test function which takes an SBValue for an item and returns True if EOL is reached and False if not. - For example, - - def eol(val): - \'\'\'Test function to determine end of list.\'\'\' - # End of list is reached if either the value object is invalid - # or it corresponds to a null pointer. - if not val or int(val.GetValue(), 16) == 0: - return True + The end_of_list_test arg, if omitted, defaults to the __eol_test__ + function above. - # Otherwise, return False. - return False + For example, # Get Frame #0. ... @@ -120,7 +124,7 @@ task_head = frame0.FindVariable('task_head') ... - for t in task_head.linked_list_iter('next', eol): + for t in task_head.linked_list_iter('next'): print t """ try: Modified: lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py?rev=136144&r1=136143&r2=136144&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py (original) +++ lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Tue Jul 26 15:57:10 2011 @@ -54,16 +54,6 @@ process = target.LaunchSimple(None, None, os.getcwd()) self.assertTrue(process, PROCESS_IS_VALID) - def eol(val): - """Test function to determine end of list.""" - # End of list is reached if either the value object is invalid - # or it corresponds to a null pointer. - if not val or int(val.GetValue(), 16) == 0: - return True - - # Otherwise, return False. - return False - # Get Frame #0. self.assertTrue(process.GetState() == lldb.eStateStopped) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) @@ -80,6 +70,32 @@ list = [] cvf = lldbutil.ChildVisitingFormatter(indent_child=2) + for t in task_head.linked_list_iter('next'): + self.assertTrue(t, VALID_VARIABLE) + # Make sure that 'next' corresponds to an SBValue with pointer type. + self.assertTrue(t.TypeIsPointerType()) + if self.TraceOn(): + print cvf.format(t) + list.append(int(t.GetChildMemberWithName("id").GetValue())) + + # Sanity checks that the we visited all the items (no more, no less). + if self.TraceOn(): + print "visited IDs:", list + self.assertTrue(visitedIDs == list) + + # Let's exercise the linked_list_iter() API again, this time supplying + # our end of list test function. + def eol(val): + """Test function to determine end of list.""" + # End of list is reached if either the value object is invalid + # or it corresponds to a null pointer. + if not val or int(val.GetValue(), 16) == 0: + return True + + # Otherwise, return False. + return False + + list = [] for t in task_head.linked_list_iter('next', eol): self.assertTrue(t, VALID_VARIABLE) # Make sure that 'next' corresponds to an SBValue with pointer type. From granata.enrico at gmail.com Tue Jul 26 16:02:56 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Tue, 26 Jul 2011 21:02:56 -0000 Subject: [Lldb-commits] [lldb] r136147 - /lldb/trunk/scripts/Python/python-wrapper.swig Message-ID: <20110726210257.011382A6C12C@llvm.org> Author: enrico Date: Tue Jul 26 16:02:56 2011 New Revision: 136147 URL: http://llvm.org/viewvc/llvm-project?rev=136147&view=rev Log: adding required utility function to SWIG interface 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=136147&r1=136146&r2=136147&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Tue Jul 26 16:02:56 2011 @@ -508,6 +508,49 @@ return 0; } +SWIGEXPORT void +LLDBSwigPython_UpdateSynthProviderInstance +( + PyObject *implementor +) +{ + static char callee_name[] = "update"; + + if (implementor == NULL || implementor == Py_None) + return; + + // all this code is here because update is optional, so we don't want to bother trying to call it unless it's been def:ined for us + // other synth provider calls are mandatory, so we want to fail in a very obvious way if they are missing! + PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name); + + if (pmeth == NULL || pmeth == Py_None) + { + Py_XDECREF(pmeth); + return; + } + + if (PyCallable_Check(pmeth) == 0) + { + Py_XDECREF(pmeth); + return; + } + + Py_XDECREF(pmeth); + + // right now we know this function exists and is callable.. + PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL); + + // if it fails, print the error but otherwise go on + if (PyErr_Occurred()) + { + PyErr_Print(); + PyErr_Clear(); + } + + Py_XDECREF(py_return); + +} + SWIGEXPORT lldb::SBValue* LLDBSWIGPython_CastPyObjectToSBValue ( From johnny.chen at apple.com Tue Jul 26 18:35:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Jul 2011 23:35:39 -0000 Subject: [Lldb-commits] [lldb] r136184 - /lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py Message-ID: <20110726233539.17E322A6C12C@llvm.org> Author: johnny Date: Tue Jul 26 18:35:38 2011 New Revision: 136184 URL: http://llvm.org/viewvc/llvm-project?rev=136184&view=rev Log: Add skip test for clang, which has insufficient debug info for call site in main(). Modified: lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py Modified: lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py?rev=136184&r1=136183&r2=136184&view=diff ============================================================================== --- lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py (original) +++ lldb/trunk/test/python_api/frame/inlines/TestInlinedFrame.py Tue Jul 26 18:35:38 2011 @@ -14,7 +14,7 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @python_api_test - def test_stop_at_outer_inline_dsym(self): + def test_stop_at_outer_inline_with_dsym(self): """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName().""" self.buildDsym() self.do_stop_at_outer_inline() @@ -70,6 +70,8 @@ # frame0 = process.GetThreadAtIndex(0).GetFrameAtIndex(0) if frame0.IsInlined(): + if self.getCompiler().endswith('clang'): + self.skipTest("clang: insufficient debug info for call site in main()") filename = frame0.GetLineEntry().GetFileSpec().GetFilename() self.assertTrue(filename == self.source) self.expect(stack_traces1, "First stop at %s:%d" % (self.source, self.first_stop), exe=False, From johnny.chen at apple.com Tue Jul 26 18:42:01 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 26 Jul 2011 23:42:01 -0000 Subject: [Lldb-commits] [lldb] r136187 - /lldb/trunk/scripts/Python/interface/SBAddress.i Message-ID: <20110726234201.8C7EB2A6C12C@llvm.org> Author: johnny Date: Tue Jul 26 18:42:01 2011 New Revision: 136187 URL: http://llvm.org/viewvc/llvm-project?rev=136187&view=rev Log: Fix indentation and add a docstring for the ctor. Modified: lldb/trunk/scripts/Python/interface/SBAddress.i Modified: lldb/trunk/scripts/Python/interface/SBAddress.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBAddress.i?rev=136187&r1=136186&r2=136187&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBAddress.i (original) +++ lldb/trunk/scripts/Python/interface/SBAddress.i Tue Jul 26 18:42:01 2011 @@ -50,7 +50,9 @@ SBAddress (const lldb::SBAddress &rhs); - // Create an address by resolving a load address using the supplied target + %feature("docstring", " + Create an address by resolving a load address using the supplied target. + ") SBAddress; SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target); ~SBAddress (); @@ -67,9 +69,9 @@ addr_t GetLoadAddress (const lldb::SBTarget &target) const; - void - SetLoadAddress (lldb::addr_t load_addr, - lldb::SBTarget &target); + void + SetLoadAddress (lldb::addr_t load_addr, + lldb::SBTarget &target); bool OffsetAddress (addr_t offset); From johnny.chen at apple.com Tue Jul 26 19:08:59 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 27 Jul 2011 00:08:59 -0000 Subject: [Lldb-commits] [lldb] r136194 - /lldb/trunk/scripts/Python/interface/SBValue.i Message-ID: <20110727000859.E5FCC2A6C12C@llvm.org> Author: johnny Date: Tue Jul 26 19:08:59 2011 New Revision: 136194 URL: http://llvm.org/viewvc/llvm-project?rev=136194&view=rev Log: Add deprecation docstrings for some APIs which take an SBFrame - SBValues know their own frames. Modified: lldb/trunk/scripts/Python/interface/SBValue.i Modified: lldb/trunk/scripts/Python/interface/SBValue.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=136194&r1=136193&r2=136194&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBValue.i (original) +++ lldb/trunk/scripts/Python/interface/SBValue.i Tue Jul 26 19:08:59 2011 @@ -82,8 +82,13 @@ size_t GetByteSize (); + %define DEPRECATED + "The method which takes an SBFrame is deprecated - SBValues know their own frames." + %enddef + + %feature("docstring", DEPRECATED) IsInScope; bool - IsInScope (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. + IsInScope (const lldb::SBFrame &frame); bool IsInScope (); @@ -94,8 +99,9 @@ void SetFormat (lldb::Format format); + %feature("docstring", DEPRECATED) GetValue; const char * - GetValue (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. + GetValue (const lldb::SBFrame &frame); const char * GetValue (); @@ -103,32 +109,37 @@ ValueType GetValueType (); + %feature("docstring", DEPRECATED) GetValueDidChange; bool - GetValueDidChange (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. + GetValueDidChange (const lldb::SBFrame &frame); bool GetValueDidChange (); + %feature("docstring", DEPRECATED) GetSummary; const char * - GetSummary (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. + GetSummary (const lldb::SBFrame &frame); const char * GetSummary (); + %feature("docstring", DEPRECATED) GetObjectDescription; const char * - GetObjectDescription (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. + GetObjectDescription (const lldb::SBFrame &frame); const char * GetObjectDescription (); + %feature("docstring", DEPRECATED) GetLocation; const char * - GetLocation (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. + GetLocation (const lldb::SBFrame &frame); const char * GetLocation (); + %feature("docstring", DEPRECATED) SetValueFromCString; bool - SetValueFromCString (const lldb::SBFrame &frame, const char *value_str); // DEPRECATED - SBValues know their own frames. + SetValueFromCString (const lldb::SBFrame &frame, const char *value_str); bool SetValueFromCString (const char *value_str); From johnny.chen at apple.com Wed Jul 27 13:13:32 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 27 Jul 2011 18:13:32 -0000 Subject: [Lldb-commits] [lldb] r136227 - /lldb/trunk/scripts/Python/interface/SBFrame.i Message-ID: <20110727181332.87E182A6C12C@llvm.org> Author: johnny Date: Wed Jul 27 13:13:32 2011 New Revision: 136227 URL: http://llvm.org/viewvc/llvm-project?rev=136227&view=rev Log: Add cross reference to SBThread from the SBFrame docstring. Also add a simple iteration example. Modified: lldb/trunk/scripts/Python/interface/SBFrame.i Modified: lldb/trunk/scripts/Python/interface/SBFrame.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFrame.i?rev=136227&r1=136226&r2=136227&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBFrame.i (original) +++ lldb/trunk/scripts/Python/interface/SBFrame.i Wed Jul 27 13:13:32 2011 @@ -37,7 +37,13 @@ args=get_args_as_string(frame, showFuncName=False) if not frame.IsInlined() else '()') ... -" + +And, + + for frame in thread: + print frame + +See also SBThread." ) SBFrame; class SBFrame { From johnny.chen at apple.com Wed Jul 27 13:28:07 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 27 Jul 2011 18:28:07 -0000 Subject: [Lldb-commits] [lldb] r136230 - in /lldb/trunk/scripts/Python/interface: SBCompileUnit.i SBLineEntry.i Message-ID: <20110727182807.F30282A6C12C@llvm.org> Author: johnny Date: Wed Jul 27 13:28:07 2011 New Revision: 136230 URL: http://llvm.org/viewvc/llvm-project?rev=136230&view=rev Log: Add docstrings and cross refs to SBCompileUnit and SBLineEntry. Modified: lldb/trunk/scripts/Python/interface/SBCompileUnit.i lldb/trunk/scripts/Python/interface/SBLineEntry.i Modified: lldb/trunk/scripts/Python/interface/SBCompileUnit.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCompileUnit.i?rev=136230&r1=136229&r2=136230&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBCompileUnit.i (original) +++ lldb/trunk/scripts/Python/interface/SBCompileUnit.i Wed Jul 27 13:28:07 2011 @@ -14,6 +14,12 @@ SBCompileUnit supports line entry iteration. For example, + # Now get the SBSymbolContext from this frame. We want everything. :-) + context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) + ... + + compileUnit = context.GetCompileUnit() + for lineEntry in compileUnit: print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()), lineEntry.GetLine()) @@ -35,7 +41,9 @@ start addr: a.out[0x100000db6] end addr: a.out[0x100000dbc] ... -") SBCompileUnit; + +See also SBSymbolContext and SBLineEntry" +) SBCompileUnit; class SBCompileUnit { public: Modified: lldb/trunk/scripts/Python/interface/SBLineEntry.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBLineEntry.i?rev=136230&r1=136229&r2=136230&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBLineEntry.i (original) +++ lldb/trunk/scripts/Python/interface/SBLineEntry.i Wed Jul 27 13:28:07 2011 @@ -11,9 +11,31 @@ %feature("docstring", "Specifies an association with a contiguous range of instructions and -a source file location. SBCompileUnit contains SBLineEntry(s). +a source file location. SBCompileUnit contains SBLineEntry(s). For example, -See also SBCompileUnit for example usage of SBLineEntry API." + for lineEntry in compileUnit: + print 'line entry: %s:%d' % (str(lineEntry.GetFileSpec()), + lineEntry.GetLine()) + print 'start addr: %s' % str(lineEntry.GetStartAddress()) + print 'end addr: %s' % str(lineEntry.GetEndAddress()) + +produces: + +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20 +start addr: a.out[0x100000d98] +end addr: a.out[0x100000da3] +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21 +start addr: a.out[0x100000da3] +end addr: a.out[0x100000da9] +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22 +start addr: a.out[0x100000da9] +end addr: a.out[0x100000db6] +line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23 +start addr: a.out[0x100000db6] +end addr: a.out[0x100000dbc] +... + +See also SBCompileUnit." ) SBLineEntry; class SBLineEntry { From granata.enrico at gmail.com Wed Jul 27 14:01:15 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 27 Jul 2011 19:01:15 -0000 Subject: [Lldb-commits] [lldb] r136246 - /lldb/trunk/examples/summaries/essentials Message-ID: <20110727190115.138DE2A6C12C@llvm.org> Author: enrico Date: Wed Jul 27 14:01:14 2011 New Revision: 136246 URL: http://llvm.org/viewvc/llvm-project?rev=136246&view=rev Log: make the C++stdlib string summary work even if for some reason std::basic_string ends up in the debug info instead of std::string Modified: lldb/trunk/examples/summaries/essentials Modified: lldb/trunk/examples/summaries/essentials URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/essentials?rev=136246&r1=136245&r2=136246&view=diff ============================================================================== --- lldb/trunk/examples/summaries/essentials (original) +++ lldb/trunk/examples/summaries/essentials Wed Jul 27 14:01:14 2011 @@ -1,2 +1,2 @@ -type summary add -f "${var._M_dataplus._M_p}" std::string +type summary add -f "${var._M_dataplus._M_p}" std::string std::basic_string type summary add -f "\"${var%@}\"" "NSString *" From johnny.chen at apple.com Wed Jul 27 16:14:01 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 27 Jul 2011 21:14:01 -0000 Subject: [Lldb-commits] [lldb] r136265 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/value/linked_list/TestValueAPILinkedList.py test/python_api/value/linked_list/main.cpp Message-ID: <20110727211401.609F02A6C12C@llvm.org> Author: johnny Date: Wed Jul 27 16:14:01 2011 New Revision: 136265 URL: http://llvm.org/viewvc/llvm-project?rev=136265&view=rev Log: The SBValue.linked_list_iter() API failed for an empty list. Fix the bug and add a test case. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py lldb/trunk/test/python_api/value/linked_list/main.cpp Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=136265&r1=136264&r2=136265&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Wed Jul 27 16:14:01 2011 @@ -129,12 +129,10 @@ """ try: item = self.GetChildMemberWithName(next_item_name) - while item: + while not end_of_list_test(item): yield item # Prepare for the next iteration. item = item.GetChildMemberWithName(next_item_name) - if end_of_list_test(item): - break except: # Exception occurred. Stop the generator. pass Modified: lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py?rev=136265&r1=136264&r2=136265&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py (original) +++ lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Wed Jul 27 16:14:01 2011 @@ -91,6 +91,10 @@ # or it corresponds to a null pointer. if not val or int(val.GetValue(), 16) == 0: return True + # Also check the "id" for correct semantics. If id <= 0, the item + # is corrupted, let's return True to signify end of list. + if int(val.GetChildMemberWithName("id").GetValue(), 0) <= 0: + return True # Otherwise, return False. return False @@ -109,6 +113,20 @@ print "visited IDs:", list self.assertTrue(visitedIDs == list) + # Get variable 'empty_task_head'. + empty_task_head = frame0.FindVariable('empty_task_head') + self.assertTrue(empty_task_head, VALID_VARIABLE) + self.DebugSBValue(empty_task_head) + + list = [] + # There is no iterable item from empty_task_head.linked_list_iter(). + for t in empty_task_head.linked_list_iter('next', eol): + if self.TraceOn(): + print cvf.format(t) + list.append(int(t.GetChildMemberWithName("id").GetValue())) + + self.assertTrue(len(list) == 0) + if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() Modified: lldb/trunk/test/python_api/value/linked_list/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/main.cpp?rev=136265&r1=136264&r2=136265&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/main.cpp (original) +++ lldb/trunk/test/python_api/value/linked_list/main.cpp Wed Jul 27 16:14:01 2011 @@ -33,7 +33,7 @@ task2->next = task4; task4->next = task5; - int total = 0; // Break at this line + int total = 0; Task *t = task_head; while (t != NULL) { if (t->id >= 0) @@ -41,5 +41,9 @@ t = t->next; } printf("We have a total number of %d tasks\n", total); - return 0; + + // This corresponds to an empty task list. + Task *empty_task_head = new Task(-1, NULL); + + return 0; // Break at this line } From johnny.chen at apple.com Wed Jul 27 18:17:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 27 Jul 2011 23:17:56 -0000 Subject: [Lldb-commits] [lldb] r136290 - /lldb/trunk/test/lang/cpp/namespace/TestNamespace.py Message-ID: <20110727231756.58EDD2A6C12C@llvm.org> Author: johnny Date: Wed Jul 27 18:17:56 2011 New Revision: 136290 URL: http://llvm.org/viewvc/llvm-project?rev=136290&view=rev Log: Modify: self.expect("expression -- '(anonymous namespace)::i'", VARIABLES_DISPLAYED_CORRECTLY, substrs = [" = 3"]) to get rid of the '(anonymous namespace)', which is not c++ syntax, thingy fed to the expression parser. According to rdar://problem/8668674. It is still marked expectedFailure since the bug has not been fixed. Modified: lldb/trunk/test/lang/cpp/namespace/TestNamespace.py Modified: lldb/trunk/test/lang/cpp/namespace/TestNamespace.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/namespace/TestNamespace.py?rev=136290&r1=136289&r2=136290&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/namespace/TestNamespace.py (original) +++ lldb/trunk/test/lang/cpp/namespace/TestNamespace.py Wed Jul 27 18:17:56 2011 @@ -100,7 +100,7 @@ # rdar://problem/8668674 # expression command with fully qualified namespace for a variable does not work - self.expect("expression -- '(anonymous namespace)::i'", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("expression -- '::i'", VARIABLES_DISPLAYED_CORRECTLY, substrs = [" = 3"]) self.expect("expression -- 'A::B::j'", VARIABLES_DISPLAYED_CORRECTLY, substrs = [" = 4"]) From granata.enrico at gmail.com Wed Jul 27 18:33:58 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 27 Jul 2011 23:33:58 -0000 Subject: [Lldb-commits] [lldb] r136293 - /lldb/trunk/examples/summaries/essentials Message-ID: <20110727233358.8C9992A6C12C@llvm.org> Author: enrico Date: Wed Jul 27 18:33:58 2011 New Revision: 136293 URL: http://llvm.org/viewvc/llvm-project?rev=136293&view=rev Log: another possible incarnation of a C++ string straight from llvm-gcc build 5658 Modified: lldb/trunk/examples/summaries/essentials Modified: lldb/trunk/examples/summaries/essentials URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/essentials?rev=136293&r1=136292&r2=136293&view=diff ============================================================================== --- lldb/trunk/examples/summaries/essentials (original) +++ lldb/trunk/examples/summaries/essentials Wed Jul 27 18:33:58 2011 @@ -1,2 +1,2 @@ -type summary add -f "${var._M_dataplus._M_p}" std::string std::basic_string +type summary add -f "${var._M_dataplus._M_p}" std::string std::basic_string "std::basic_string,std::allocator >" type summary add -f "\"${var%@}\"" "NSString *" From johnny.chen at apple.com Wed Jul 27 19:52:23 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 28 Jul 2011 00:52:23 -0000 Subject: [Lldb-commits] [lldb] r136316 - /lldb/trunk/test/lang/cpp/namespace/TestNamespace.py Message-ID: <20110728005223.48C942A6C12C@llvm.org> Author: johnny Date: Wed Jul 27 19:52:23 2011 New Revision: 136316 URL: http://llvm.org/viewvc/llvm-project?rev=136316&view=rev Log: Make the test criteria more stringent with respect to rdar://problem/8668674 to prevent accidental pass. Modified: lldb/trunk/test/lang/cpp/namespace/TestNamespace.py Modified: lldb/trunk/test/lang/cpp/namespace/TestNamespace.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/namespace/TestNamespace.py?rev=136316&r1=136315&r2=136316&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/namespace/TestNamespace.py (original) +++ lldb/trunk/test/lang/cpp/namespace/TestNamespace.py Wed Jul 27 19:52:23 2011 @@ -82,11 +82,13 @@ # 'frame variable' with fully qualified name 'A::B::j' should work. self.expect("frame variable A::B::j", VARIABLES_DISPLAYED_CORRECTLY, - startstr = '(int) A::B::j = 4') + startstr = '(int) A::B::j = 4', + patterns = [' = 4$']) # So should the anonymous namespace case. self.expect("frame variable '(anonymous namespace)::i'", VARIABLES_DISPLAYED_CORRECTLY, - startstr = '(int) (anonymous namespace)::i = 3') + startstr = '(int) (anonymous namespace)::i = 3', + patterns = [' = 3$']) # rdar://problem/8660275 # test/namespace: 'expression -- i+j' not working @@ -101,9 +103,9 @@ # rdar://problem/8668674 # expression command with fully qualified namespace for a variable does not work self.expect("expression -- '::i'", VARIABLES_DISPLAYED_CORRECTLY, - substrs = [" = 3"]) + patterns = [' = 3$']) self.expect("expression -- 'A::B::j'", VARIABLES_DISPLAYED_CORRECTLY, - substrs = [" = 4"]) + patterns = [' = 4$']) if __name__ == '__main__': From johnny.chen at apple.com Thu Jul 28 15:46:14 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 28 Jul 2011 20:46:14 -0000 Subject: [Lldb-commits] [lldb] r136386 - in /lldb/trunk/test/lang: cpp/namespace/main.cpp objc/radar-9691614/ objc/radar-9691614/Makefile objc/radar-9691614/TestObjCMethodReturningBOOL.py objc/radar-9691614/main.m Message-ID: <20110728204614.526732A6C12C@llvm.org> Author: johnny Date: Thu Jul 28 15:46:14 2011 New Revision: 136386 URL: http://llvm.org/viewvc/llvm-project?rev=136386&view=rev Log: Add a reproducible test case (expression parser crashes) to the lldb test suite. rdar://problem/9691614. Added: lldb/trunk/test/lang/objc/radar-9691614/ lldb/trunk/test/lang/objc/radar-9691614/Makefile lldb/trunk/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py lldb/trunk/test/lang/objc/radar-9691614/main.m Modified: lldb/trunk/test/lang/cpp/namespace/main.cpp Modified: lldb/trunk/test/lang/cpp/namespace/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/namespace/main.cpp?rev=136386&r1=136385&r2=136386&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/namespace/main.cpp (original) +++ lldb/trunk/test/lang/cpp/namespace/main.cpp Thu Jul 28 15:46:14 2011 @@ -51,6 +51,7 @@ } } +#include int Foo::myfunc(int a) { ::my_uint_t anon_uint = 0; @@ -59,6 +60,8 @@ Y::uint_t y_uint = 3; i = 3; j = 4; + printf("::i=%d\n", ::i); + printf("A::B::j=%d\n", A::B::j); return myfunc2(3) + j + i + a + 2 + anon_uint + a_uint + b_uint + y_uint; // Set break point at this line. } Added: lldb/trunk/test/lang/objc/radar-9691614/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/radar-9691614/Makefile?rev=136386&view=auto ============================================================================== --- lldb/trunk/test/lang/objc/radar-9691614/Makefile (added) +++ lldb/trunk/test/lang/objc/radar-9691614/Makefile Thu Jul 28 15:46:14 2011 @@ -0,0 +1,7 @@ +LEVEL = ../../../make + +OBJC_SOURCES := main.m + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation Added: lldb/trunk/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py?rev=136386&view=auto ============================================================================== --- lldb/trunk/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py (added) +++ lldb/trunk/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py Thu Jul 28 15:46:14 2011 @@ -0,0 +1,62 @@ +""" +Test that objective-c method returning BOOL works correctly. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + + at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") +class MethodReturningBOOLTestCase(TestBase): + + mydir = os.path.join("lang", "objc", "radar-9691614") + + def test_method_ret_BOOL_with_dsym(self): + """Test that objective-c method returning BOOL works correctly.""" + d = {'EXE': self.exe_name} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.objc_method_ret_BOOL(self.exe_name) + + def test_method_ret_BOOL_with_dwarf(self): + """Test that objective-c method returning BOOL works correctly.""" + d = {'EXE': self.exe_name} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.objc_method_ret_BOOL(self.exe_name) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # We'll use the test method name as the exe_name. + self.exe_name = self.testMethodName + # Find the line number to break inside main(). + self.main_source = "main.m" + self.line = line_number(self.main_source, '// Set breakpoint here.') + + @unittest2.skip("rdar://problem/9691614 Expression parser crashes") + def objc_method_ret_BOOL(self, exe_name): + """Test that objective-c method returning BOOL works correctly.""" + exe = os.path.join(os.getcwd(), exe_name) + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + self.expect("breakpoint set -f %s -l %d" % (self.main_source, self.line), + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % + (self.main_source, self.line)) + + self.runCmd("run", RUN_SUCCEEDED) + self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, + substrs = [" at %s:%d" % (self.main_source, self.line), + "stop reason = breakpoint"]) + + # rdar://problem/9691614 + self.runCmd('p (int)[my isValid]') + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/lang/objc/radar-9691614/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/radar-9691614/main.m?rev=136386&view=auto ============================================================================== --- lldb/trunk/test/lang/objc/radar-9691614/main.m (added) +++ lldb/trunk/test/lang/objc/radar-9691614/main.m Thu Jul 28 15:46:14 2011 @@ -0,0 +1,67 @@ +#import +#include + + at interface MyString : NSObject { + NSString *str; + NSDate *date; + BOOL _is_valid; +} + +- (id)initWithNSString:(NSString *)string; +- (BOOL)isValid; + at end + + at implementation MyString +- (id)initWithNSString:(NSString *)string +{ + if (self = [super init]) + { + str = [NSString stringWithString:string]; + date = [NSDate date]; + } + _is_valid = YES; + return self; +} + +- (BOOL)isValid +{ + return _is_valid; +} + +- (void)dealloc +{ + [date release]; + [str release]; + [super dealloc]; +} + +- (NSString *)description +{ + return [str stringByAppendingFormat:@" with timestamp: %@", date]; +} + at end + +void +Test_MyString (const char *program) +{ + NSString *str = [NSString stringWithFormat:@"Hello from '%s'", program]; + MyString *my = [[MyString alloc] initWithNSString:str]; + if ([my isValid]) + printf("my is valid!\n"); + + NSLog(@"NSString instance: %@", [str description]); // Set breakpoint here. + // Test 'p (int)[my isValid]'. + // The expression parser should not crash -- rdar://problem/9691614. + + NSLog(@"MyString instance: %@", [my description]); +} + +int main (int argc, char const *argv[]) +{ + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + Test_MyString (argv[0]); + + [pool release]; + return 0; +} From johnny.chen at apple.com Thu Jul 28 16:15:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 28 Jul 2011 21:15:39 -0000 Subject: [Lldb-commits] [lldb] r136394 - /lldb/trunk/test/README-TestSuite Message-ID: <20110728211539.2AB582A6C12C@llvm.org> Author: johnny Date: Thu Jul 28 16:15:39 2011 New Revision: 136394 URL: http://llvm.org/viewvc/llvm-project?rev=136394&view=rev Log: Add some descriptions about the default executable name being 'a.out' and can be overwritten by specifying your EXE make variable via your Makefile or within the Python test script. Modified: lldb/trunk/test/README-TestSuite Modified: lldb/trunk/test/README-TestSuite URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/README-TestSuite?rev=136394&r1=136393&r2=136394&view=diff ============================================================================== --- lldb/trunk/test/README-TestSuite (original) +++ lldb/trunk/test/README-TestSuite Thu Jul 28 16:15:39 2011 @@ -57,7 +57,39 @@ o make directory Contains Makefile.rules, which can be utilized by test cases to write Makefile - based rules to build native binaries. + based rules to build binaries for the inferiors. + + By default, the built executable name is a.out, which can be overwritten by + specifying your EXE make variable, via the Makefile under the specfic test + directory or via supplying a Python dictionary to the build method in your + Python test script. An example of the latter can be found in + test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py, where: + + def test_method_ret_BOOL_with_dsym(self): + """Test that objective-c method returning BOOL works correctly.""" + d = {'EXE': self.exe_name} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.objc_method_ret_BOOL(self.exe_name) + + def test_method_ret_BOOL_with_dwarf(self): + """Test that objective-c method returning BOOL works correctly.""" + d = {'EXE': self.exe_name} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.objc_method_ret_BOOL(self.exe_name) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # We'll use the test method name as the exe_name. + self.exe_name = self.testMethodName + # Find the line number to break inside main(). + self.main_source = "main.m" + self.line = line_number(self.main_source, '// Set breakpoint here.') + + The exe names for the two test methods are equal to the test method names and + are therefore guaranteed different. o plugins directory From johnny.chen at apple.com Thu Jul 28 17:12:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 28 Jul 2011 22:12:13 -0000 Subject: [Lldb-commits] [lldb] r136409 - in /lldb/trunk/test/expression_command/radar_9673664: ./ Makefile TestExprHelpExamples.py main.c Message-ID: <20110728221213.23F6B2A6C12D@llvm.org> Author: johnny Date: Thu Jul 28 17:12:12 2011 New Revision: 136409 URL: http://llvm.org/viewvc/llvm-project?rev=136409&view=rev Log: Add test case for rdar://problem/9673664. Added: lldb/trunk/test/expression_command/radar_9673664/ lldb/trunk/test/expression_command/radar_9673664/Makefile lldb/trunk/test/expression_command/radar_9673664/TestExprHelpExamples.py lldb/trunk/test/expression_command/radar_9673664/main.c Added: lldb/trunk/test/expression_command/radar_9673664/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_9673664/Makefile?rev=136409&view=auto ============================================================================== --- lldb/trunk/test/expression_command/radar_9673664/Makefile (added) +++ lldb/trunk/test/expression_command/radar_9673664/Makefile Thu Jul 28 17:12:12 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/expression_command/radar_9673664/TestExprHelpExamples.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_9673664/TestExprHelpExamples.py?rev=136409&view=auto ============================================================================== --- lldb/trunk/test/expression_command/radar_9673664/TestExprHelpExamples.py (added) +++ lldb/trunk/test/expression_command/radar_9673664/TestExprHelpExamples.py Thu Jul 28 17:12:12 2011 @@ -0,0 +1,47 @@ +""" +Test example snippets from the lldb 'help expression' output. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class Radar9673644TestCase(TestBase): + + mydir = os.path.join("expression_command", "radar_9673664") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break inside main(). + self.main_source = "main.c" + self.line = line_number(self.main_source, '// Set breakpoint here.') + + # rdar://problem/9673664 + @unittest2.expectedFailure + def test_expr_commands(self): + """The following expression commands should just work.""" + self.buildDefault() + + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.expect("breakpoint set -f %s -l %d" % (self.main_source, self.line), + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % + (self.main_source, self.line)) + + self.runCmd("run", RUN_SUCCEEDED) + + # rdar://problem/9673664 lldb expression evaluation problem + + self.runCmd('expr char c[] = "foo"; c[0]') + # Fill in an example output here. + # And change self.runCmd() -> self.expect()... + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/expression_command/radar_9673664/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_9673664/main.c?rev=136409&view=auto ============================================================================== --- lldb/trunk/test/expression_command/radar_9673664/main.c (added) +++ lldb/trunk/test/expression_command/radar_9673664/main.c Thu Jul 28 17:12:12 2011 @@ -0,0 +1,16 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +int main (int argc, char const *argv[]) +{ + printf("Hello, world.\n"); // Set breakpoint here. + + return 0; +} From johnny.chen at apple.com Thu Jul 28 18:17:20 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 28 Jul 2011 23:17:20 -0000 Subject: [Lldb-commits] [lldb] r136425 - in /lldb/trunk/test/expression_command/radar_9531204: ./ Makefile TestPrintfAfterUp.py main.c Message-ID: <20110728231720.541D32A6C12C@llvm.org> Author: johnny Date: Thu Jul 28 18:17:20 2011 New Revision: 136425 URL: http://llvm.org/viewvc/llvm-project?rev=136425&view=rev Log: Add regression test for rdar://problem/9531204. Added: lldb/trunk/test/expression_command/radar_9531204/ lldb/trunk/test/expression_command/radar_9531204/Makefile lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py lldb/trunk/test/expression_command/radar_9531204/main.c Added: lldb/trunk/test/expression_command/radar_9531204/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_9531204/Makefile?rev=136425&view=auto ============================================================================== --- lldb/trunk/test/expression_command/radar_9531204/Makefile (added) +++ lldb/trunk/test/expression_command/radar_9531204/Makefile Thu Jul 28 18:17:20 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py?rev=136425&view=auto ============================================================================== --- lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py (added) +++ lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py Thu Jul 28 18:17:20 2011 @@ -0,0 +1,47 @@ +""" +The evaluating printf(...) after break stop and then up a stack frame. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class Radar9531204TestCase(TestBase): + + mydir = os.path.join("expression_command", "radar_9531204") + + # rdar://problem/9531204 + @unittest2.expectedFailure + def test_expr_commands(self): + """The evaluating printf(...) after break stop and then up a stack frame.""" + self.buildDefault() + + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.expect("breakpoint set -n foo", + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: name = 'foo', locations = 1") + + self.runCmd("run", RUN_SUCCEEDED) + + self.runCmd("frame variable") + + # This works fine. + self.runCmd('expression (int)printf("value is: %d.\\n", value);') + + # rdar://problem/9531204 + # "Error dematerializing struct" error when evaluating expressions "up" on the stack + self.runCmd('up') # frame select -r 1 + + self.runCmd("frame variable") + + # This does not currently. + self.runCmd('expression (int)printf("argc is: %d.\\n", argc)') + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/expression_command/radar_9531204/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_9531204/main.c?rev=136425&view=auto ============================================================================== --- lldb/trunk/test/expression_command/radar_9531204/main.c (added) +++ lldb/trunk/test/expression_command/radar_9531204/main.c Thu Jul 28 18:17:20 2011 @@ -0,0 +1,24 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +// breakpoint set -n foo +// +// +int foo (int value) +{ + printf ("I got the value: %d.\n", value); +} + +int main (int argc, char **argv) +{ + foo (argc); + printf ("Hello there: %d.\n", argc); + return 0; +} From granata.enrico at gmail.com Fri Jul 29 14:53:35 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 29 Jul 2011 19:53:35 -0000 Subject: [Lldb-commits] [lldb] r136504 - in /lldb/trunk: examples/synthetic/ include/lldb/ include/lldb/API/ include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Symbol/ scripts/Python/interface/ source/API/ source/Commands/ source/Core/ source/Interpreter/ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Symbol/ test/functionalities/data-formatter/data-formatter-python-synth/ test/python_api/default-constructor/ Message-ID: <20110729195336.52ECE2A6C12D@llvm.org> Author: enrico Date: Fri Jul 29 14:53:35 2011 New Revision: 136504 URL: http://llvm.org/viewvc/llvm-project?rev=136504&view=rev Log: Public API changes: - Completely new implementation of SBType - Various enhancements in several other classes Python synthetic children providers for std::vector, std::list and std::map: - these return the actual elements into the container as the children of the container - basic template name parsing that works (hopefully) on both Clang and GCC - find them in examples/synthetic and in the test suite in functionalities/data-formatter/data-formatter-python-synth New summary string token ${svar : - the syntax is just the same as in ${var but this new token lets you read the values coming from the synthetic children provider instead of the actual children - Python providers above provide a synthetic child len that returns the number of elements into the container Full bug fix for the issue in which getting byte size for a non-complete type would crash LLDB Several other fixes, including: - inverted the order of arguments in the ClangASTType constructor - EvaluationPoint now only returns SharedPointer's to Target and Process - the help text for several type subcommands now correctly indicates argument-less options as such Added: lldb/trunk/examples/synthetic/ lldb/trunk/examples/synthetic/StdListSynthProvider.py lldb/trunk/examples/synthetic/StdMapSynthProvider.py lldb/trunk/examples/synthetic/StdVectorSynthProvider.py lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdMapSynthProvider.py lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py Modified: lldb/trunk/include/lldb/API/SBDefines.h lldb/trunk/include/lldb/API/SBModule.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/API/SBType.h lldb/trunk/include/lldb/API/SBValue.h lldb/trunk/include/lldb/Core/FormatClasses.h lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/include/lldb/Core/Module.h lldb/trunk/include/lldb/Core/ModuleList.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/include/lldb/Symbol/ClangASTType.h lldb/trunk/include/lldb/Symbol/TaggedASTType.h lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/scripts/Python/interface/SBModule.i lldb/trunk/scripts/Python/interface/SBTarget.i lldb/trunk/scripts/Python/interface/SBType.i lldb/trunk/scripts/Python/interface/SBValue.i lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/API/SBModule.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/API/SBType.cpp lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/FormatClasses.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectDynamicValue.cpp lldb/trunk/source/Core/ValueObjectMemory.cpp lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp lldb/trunk/source/Interpreter/ScriptInterpreter.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py Added: lldb/trunk/examples/synthetic/StdListSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/StdListSynthProvider.py?rev=136504&view=auto ============================================================================== --- lldb/trunk/examples/synthetic/StdListSynthProvider.py (added) +++ lldb/trunk/examples/synthetic/StdListSynthProvider.py Fri Jul 29 14:53:35 2011 @@ -0,0 +1,61 @@ +import re +class StdListSynthProvider: + def __init__(self, valobj, dict): + self.valobj = valobj; + self.update() + def num_children(self): + next_val = int(self.Mnext.GetValue(),0) + prev_val = int(self.Mprev.GetValue(),0) + if next_val == 0: + return 0; + if next_val == self.Mnode_address: + return 0; + if next_val == prev_val: + return 1; + size = 2 + current = self.Mnext + while int(current.GetChildMemberWithName('_M_next').GetValue(),0) != self.Mnode_address: + size = size + 1; + current = current.GetChildMemberWithName('_M_next') + return (size - 1) + def get_child_index(self,name): + if name == "len": + return self.num_children(); + else: + return int(name.lstrip('[').rstrip(']')) + def get_child_at_index(self,index): + if index == self.num_children(): + return self.valobj.CreateValueFromExpression("len",str(self.num_children())) + else: + offset = index + current = self.Mnext; + 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): + self.Mimpl = self.valobj.GetChildMemberWithName('_M_impl') + self.Mnode = self.Mimpl.GetChildMemberWithName('_M_node') + self.extract_type_name(self.Mimpl.GetType().GetName()) + self.Mnode_address = int(self.valobj.AddressOf().GetValue(), 0) + self.Mnext = self.Mnode.GetChildMemberWithName('_M_next') + self.Mprev = self.Mnode.GetChildMemberWithName('_M_prev') + self.data_type = self.Mnode.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 = self.Mnode.GetTarget().FindFirstType(self.type_name_nospaces) + self.data_size = self.data_type.GetByteSize() Added: lldb/trunk/examples/synthetic/StdMapSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/StdMapSynthProvider.py?rev=136504&view=auto ============================================================================== --- lldb/trunk/examples/synthetic/StdMapSynthProvider.py (added) +++ lldb/trunk/examples/synthetic/StdMapSynthProvider.py Fri Jul 29 14:53:35 2011 @@ -0,0 +1,103 @@ +import re +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 int(self.Mimpl.GetChildMemberWithName('_M_node_count').GetValue(), 0); + def get_child_index(self,name): + if name == "len": + return self.num_children(); + else: + return int(name.lstrip('[').rstrip(']')) + def get_child_at_index(self,index): + if index == self.num_children(): + return self.valobj.CreateValueFromExpression("len",str(self.num_children())) + else: + 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 int(node.GetValue(),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; + Added: lldb/trunk/examples/synthetic/StdVectorSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/StdVectorSynthProvider.py?rev=136504&view=auto ============================================================================== --- lldb/trunk/examples/synthetic/StdVectorSynthProvider.py (added) +++ lldb/trunk/examples/synthetic/StdVectorSynthProvider.py Fri Jul 29 14:53:35 2011 @@ -0,0 +1,25 @@ +class StdVectorSynthProvider: + def __init__(self, valobj, dict): + self.valobj = valobj; + self.update() + def num_children(self): + start_val = int(self.Mstart.GetValue(),0) + finish_val = int(self.Mfinish.GetValue(),0) + return (finish_val-start_val)/self.data_size + def get_child_index(self,name): + if name == "len": + return self.num_children(); + else: + return int(name.lstrip('[').rstrip(']')) + def get_child_at_index(self,index): + if index == self.num_children(): + return self.valobj.CreateValueFromExpression("len",str(self.num_children())) + else: + offset = index * self.data_size + return self.Mstart.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) + def update(self): + self.Mimpl = self.valobj.GetChildMemberWithName('_M_impl') + self.Mstart = self.Mimpl.GetChildMemberWithName('_M_start') + self.Mfinish = self.Mimpl.GetChildMemberWithName('_M_finish') + self.data_type = self.Mstart.GetType().GetPointeeType() + self.data_size = self.data_type.GetByteSize() Modified: lldb/trunk/include/lldb/API/SBDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDefines.h (original) +++ lldb/trunk/include/lldb/API/SBDefines.h Fri Jul 29 14:53:35 2011 @@ -56,6 +56,8 @@ class SBSymbolContextList; class SBTarget; class SBThread; +class SBType; +class SBTypeList; class SBValue; class SBValueList; Modified: lldb/trunk/include/lldb/API/SBModule.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBModule.h (original) +++ lldb/trunk/include/lldb/API/SBModule.h Fri Jul 29 14:53:35 2011 @@ -153,6 +153,11 @@ const char *name, uint32_t max_matches); + lldb::SBType + FindFirstType (const char* name); + + lldb::SBTypeList + FindTypes (const char* type); private: friend class SBAddress; Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Fri Jul 29 14:53:35 2011 @@ -14,6 +14,7 @@ #include "lldb/API/SBAddress.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBType.h" namespace lldb { @@ -342,6 +343,12 @@ lldb::SBBroadcaster GetBroadcaster () const; + + lldb::SBType + FindFirstType (const char* type); + + lldb::SBTypeList + FindTypes (const char* type); #ifndef SWIG bool @@ -367,6 +374,7 @@ friend class SBProcess; friend class SBSymbol; friend class SBModule; + friend class SBValue; //------------------------------------------------------------------ // Constructors are private, use static Target::Create function to Modified: lldb/trunk/include/lldb/API/SBType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBType.h (original) +++ lldb/trunk/include/lldb/API/SBType.h Fri Jul 29 14:53:35 2011 @@ -11,128 +11,109 @@ #define LLDB_SBType_h_ #include "lldb/API/SBDefines.h" +#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/Type.h" namespace lldb { -class SBTypeMember; +class SBTypeList; class SBType { public: - SBType (void *ast = NULL, void *clang_type = NULL); - SBType (const SBType &rhs); ~SBType (); #ifndef SWIG - const SBType & - operator =(const SBType &rhs); -#endif - - bool - IsValid(); - - const char * - GetName(); - - uint64_t - GetByteSize(); - -#ifndef SWIG - lldb::Encoding - GetEncoding (uint32_t &count); -#endif - - uint64_t - GetNumberChildren (bool omit_empty_base_classes); - - bool - GetChildAtIndex (bool omit_empty_base_classes, uint32_t idx, SBTypeMember &member); - - uint32_t - GetChildIndexForName (bool omit_empty_base_classes, const char *name); - + const lldb::SBType & + operator = (const lldb::SBType &rhs); + bool - IsAPointerType (); - - SBType - GetPointeeType (); - - static bool - IsPointerType (void *opaque_type); - + operator == (const lldb::SBType &rhs) const; + bool - GetDescription (lldb::SBStream &description); - -protected: - void *m_ast; - void *m_type; -}; - -class SBTypeMember -{ -public: - - SBTypeMember (); + operator != (const lldb::SBType &rhs) const; + + lldb_private::TypeImpl & + ref (); + + const lldb_private::TypeImpl & + ref () const; - SBTypeMember (const SBTypeMember &rhs); - -#ifndef SWIG - const SBTypeMember& - operator =(const SBTypeMember &rhs); #endif - - ~SBTypeMember (); - + bool - IsBaseClass (); + IsValid() const; + + size_t + GetByteSize() const; bool - IsValid (); - - void - Clear(); - + IsPointerType() const; + bool - IsBitfield (); + IsReferenceType() const; - size_t - GetBitfieldWidth (); + SBType + GetPointerType() const; - size_t - GetBitfieldOffset (); - - size_t - GetOffset (); - - const char * - GetName (); - SBType - GetType(); - + GetPointeeType() const; + SBType - GetParentType(); - - void - SetName (const char *name); - + GetReferenceType() const; + + SBType + GetDereferencedType() const; + + SBType + GetBasicType(lldb::BasicType type) const; + + const char* + GetName(); + protected: - friend class SBType; + std::auto_ptr m_opaque_ap; + + friend class SBModule; + friend class SBTarget; + friend class SBValue; + friend class SBTypeList; - void *m_ast; - void *m_parent_type; - void *m_member_type; - char *m_member_name; - int32_t m_offset; - uint32_t m_bit_size; - uint32_t m_bit_offset; - bool m_is_base_class; - bool m_is_deref_of_paremt; + SBType (clang::ASTContext*, clang_type_t); + SBType (lldb_private::ClangASTType type); + SBType (lldb::TypeSP type); + SBType (lldb_private::TypeImpl impl); + SBType(); + +}; + +class SBTypeList +{ +public: + SBTypeList(); + + SBTypeList(const SBTypeList& rhs); + + SBTypeList& + operator = (const SBTypeList& rhs); + + void + AppendType(SBType type); + + SBType + GetTypeAtIndex(int index) const; + + int + GetSize() const; + + ~SBTypeList(); + +private: + std::auto_ptr m_opaque_ap; }; - } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBValue.h (original) +++ lldb/trunk/include/lldb/API/SBValue.h Fri Jul 29 14:53:35 2011 @@ -11,6 +11,7 @@ #define LLDB_SBValue_h_ #include "lldb/API/SBDefines.h" +#include "lldb/API/SBType.h" #include @@ -105,6 +106,18 @@ lldb::SBValue GetChildAtIndex (uint32_t idx); + + lldb::SBValue + CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type); + + lldb::SBValue + Cast(const SBType& type); + + lldb::SBValue + CreateValueFromExpression (const char *name, const char* expression); + + lldb::SBValue + CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type); //------------------------------------------------------------------ /// Get a child value by index from a value. @@ -179,6 +192,9 @@ // Expands nested expressions like .a->b[0].c[1]->d lldb::SBValue GetValueForExpressionPath(const char* expr_path); + + lldb::SBValue + AddressOf(); uint32_t GetNumChildren (); @@ -186,12 +202,26 @@ void * GetOpaqueType(); + lldb::SBTarget + GetTarget(); + + lldb::SBProcess + GetProcess(); + + lldb::SBThread + GetThread(); + lldb::SBFrame + GetFrame(); + lldb::SBValue Dereference (); bool TypeIsPointerType (); + + SBType + GetType(); bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/include/lldb/Core/FormatClasses.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatClasses.h (original) +++ lldb/trunk/include/lldb/Core/FormatClasses.h Fri Jul 29 14:53:35 2011 @@ -113,6 +113,9 @@ virtual uint32_t GetIndexOfChildWithName (const ConstString &name) = 0; + virtual void + Update() = 0; + typedef lldb::SharedPtr::Type SharedPointer; }; @@ -238,6 +241,9 @@ return m_backend->GetSyntheticExpressionPathChild(filter->GetExpressionPathAtIndex(idx).c_str(), can_create); } + virtual void + Update() {} + virtual uint32_t GetIndexOfChildWithName (const ConstString &name) { @@ -328,6 +334,15 @@ return sb_ptr->m_opaque_sp; } + + virtual void + Update() + { + if (m_wrapper == NULL || m_interpreter == NULL) + return; + + m_interpreter->UpdateSynthProviderInstance(m_wrapper); + } virtual uint32_t GetIndexOfChildWithName (const ConstString &name) Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Fri Jul 29 14:53:35 2011 @@ -225,7 +225,7 @@ MapValueType& entry, uint32_t* why = NULL) { - uint32_t value = lldb::eFormatterDirectChoice; + uint32_t value = lldb::eFormatterChoiceCriterionDirectChoice; clang::QualType type = clang::QualType::getFromOpaquePtr(vobj.GetClangType()); bool ret = Get(vobj, type, entry, value); if (ret) @@ -315,7 +315,7 @@ log->Printf("stripping reference"); if (Get(vobj,type.getNonReferenceType(),entry, reason) && !entry->m_skip_references) { - reason |= lldb::eFormatterStrippedPointerReference; + reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; return true; } } @@ -325,7 +325,7 @@ log->Printf("stripping pointer"); if (Get(vobj, typePtr->getPointeeType(), entry, reason) && !entry->m_skip_pointers) { - reason |= lldb::eFormatterStrippedPointerReference; + reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; return true; } } @@ -345,7 +345,7 @@ return false; if (Get(*target, typePtr->getPointeeType(), entry, reason) && !entry->m_skip_pointers) { - reason |= lldb::eFormatterStrippedPointerReference; + reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; return true; } } @@ -370,7 +370,7 @@ clang::QualType ivar_qual_type(ast->getObjCInterfaceType(superclass_interface_decl)); if (Get(vobj, ivar_qual_type, entry, reason) && entry->m_cascades) { - reason |= lldb::eFormatterNavigatedBaseClasses; + reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; return true; } } @@ -399,7 +399,7 @@ { if ((Get(vobj, pos->getType(), entry, reason)) && entry->m_cascades) { - reason |= lldb::eFormatterNavigatedBaseClasses; + reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; return true; } } @@ -413,7 +413,7 @@ { if ((Get(vobj, pos->getType(), entry, reason)) && entry->m_cascades) { - reason |= lldb::eFormatterNavigatedBaseClasses; + reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; return true; } } @@ -429,7 +429,7 @@ log->Printf("stripping typedef"); if ((Get(vobj, type_tdef->getDecl()->getUnderlyingType(), entry, reason)) && entry->m_cascades) { - reason |= lldb::eFormatterNavigatedTypedefs; + reason |= lldb::eFormatterChoiceCriterionNavigatedTypedefs; return true; } } @@ -539,7 +539,7 @@ return true; bool regex = RegexSummary()->Get(vobj, entry, reason); if (regex && reason) - *reason |= lldb::eFormatterRegularExpressionSummary; + *reason |= lldb::eFormatterChoiceCriterionRegularExpressionSummary; return regex; } @@ -775,7 +775,7 @@ lldb::SummaryFormatSP current_format; if (!category->Get(vobj, current_format, &reason_why)) continue; - if (reason_why == lldb::eFormatterDirectChoice) + if (reason_why == lldb::eFormatterChoiceCriterionDirectChoice) { entry = current_format; return true; @@ -806,7 +806,7 @@ lldb::SyntheticChildrenSP current_format; if (!category->Get(vobj, current_format, &reason_why)) continue; - if (reason_why == lldb::eFormatterDirectChoice) + if (reason_why == lldb::eFormatterChoiceCriterionDirectChoice) { entry = current_format; return true; Modified: lldb/trunk/include/lldb/Core/Module.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Module.h (original) +++ lldb/trunk/include/lldb/Core/Module.h Fri Jul 29 14:53:35 2011 @@ -686,6 +686,15 @@ SetArchitecture (const ArchSpec &new_arch); private: + + uint32_t + FindTypes_Impl (const SymbolContext& sc, + const ConstString &name, + bool append, + uint32_t max_matches, + TypeList& types); + + DISALLOW_COPY_AND_ASSIGN (Module); }; Modified: lldb/trunk/include/lldb/Core/ModuleList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ModuleList.h (original) +++ lldb/trunk/include/lldb/Core/ModuleList.h Fri Jul 29 14:53:35 2011 @@ -440,6 +440,13 @@ collection m_modules; ///< The collection of modules. mutable Mutex m_modules_mutex; +private: + uint32_t + FindTypes_Impl (const SymbolContext& sc, + const ConstString &name, + bool append, + uint32_t max_matches, + TypeList& types); }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Jul 29 14:53:35 2011 @@ -197,17 +197,17 @@ ExecutionContextScope * GetExecutionContextScope (); - - Target * - GetTarget () const + + lldb::TargetSP + GetTargetSP () const { - return m_target_sp.get(); + return m_target_sp; } - Process * - GetProcess () const + lldb::ProcessSP + GetProcessSP () const { - return m_process_sp.get(); + return m_process_sp; } // Set the EvaluationPoint to the values in exe_scope, @@ -548,6 +548,9 @@ lldb::ValueObjectSP GetSyntheticExpressionPathChild(const char* expression, bool can_create); + virtual lldb::ValueObjectSP + GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create); + lldb::ValueObjectSP GetDynamicValue (lldb::DynamicValueType valueType); @@ -755,7 +758,8 @@ m_is_deref_of_parent:1, m_is_array_item_for_pointer:1, m_is_bitfield_for_scalar:1, - m_is_expression_path_child:1; + m_is_expression_path_child:1, + m_is_child_at_offset:1; // used to prevent endless looping into GetpPrintableRepresentation() uint32_t m_dump_printable_counter; @@ -806,12 +810,6 @@ CalculateNumChildren() = 0; void - SetName (const char *name); - - void - SetName (const ConstString &name); - - void SetNumChildren (uint32_t num_children); void @@ -824,6 +822,10 @@ ClearUserVisibleData(); public: + + void + SetName (const ConstString &name); + lldb::addr_t GetPointerValue (AddressType &address_type, bool scalar_is_load_address); Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Fri Jul 29 14:53:35 2011 @@ -38,10 +38,11 @@ const char *session_dictionary_name, const lldb::ValueObjectSP& valobj_sp); - typedef uint32_t (*SWIGPythonCalculateNumChildren) (void *implementor); - typedef void* (*SWIGPythonGetChildAtIndex) (void *implementor, uint32_t idx); - typedef int (*SWIGPythonGetIndexOfChildWithName) (void *implementor, const char* child_name); - typedef lldb::SBValue* (*SWIGPythonCastPyObjectToSBValue) (void* data); + typedef uint32_t (*SWIGPythonCalculateNumChildren) (void *implementor); + typedef void* (*SWIGPythonGetChildAtIndex) (void *implementor, uint32_t idx); + typedef int (*SWIGPythonGetIndexOfChildWithName) (void *implementor, const char* child_name); + typedef lldb::SBValue* (*SWIGPythonCastPyObjectToSBValue) (void* data); + typedef void (*SWIGPythonUpdateSynthProviderInstance) (void* data); typedef enum { @@ -157,6 +158,11 @@ return UINT32_MAX; } + virtual void + UpdateSynthProviderInstance (void* implementor) + { + } + virtual lldb::SBValue* CastPyObjectToSBValue (void* data) { @@ -183,7 +189,8 @@ SWIGPythonCalculateNumChildren python_swig_calc_children, SWIGPythonGetChildAtIndex python_swig_get_child_index, SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, - SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue); + SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, + SWIGPythonUpdateSynthProviderInstance python_swig_update_provider); 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=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Fri Jul 29 14:53:35 2011 @@ -72,6 +72,9 @@ virtual int GetIndexOfChildWithName (void *implementor, const char* child_name); + virtual void + UpdateSynthProviderInstance (void* implementor); + virtual lldb::SBValue* CastPyObjectToSBValue (void* data); @@ -127,7 +130,8 @@ SWIGPythonCalculateNumChildren python_swig_calc_children, SWIGPythonGetChildAtIndex python_swig_get_child_index, SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, - SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalu); + SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, + SWIGPythonUpdateSynthProviderInstance python_swig_update_provider); protected: Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Fri Jul 29 14:53:35 2011 @@ -29,9 +29,10 @@ class ClangASTType { public: - ClangASTType (lldb::clang_type_t type, clang::ASTContext *ast_context) : - m_type (type), - m_ast (ast_context) + + ClangASTType (clang::ASTContext *ast_context, lldb::clang_type_t type) : + m_type (type), + m_ast (ast_context) { } @@ -188,7 +189,7 @@ GetFormat (lldb::clang_type_t opaque_clang_qual_type); uint32_t - GetTypeByteSize(); + GetTypeByteSize() const; static uint32_t GetTypeByteSize(clang::ASTContext *ast_context, Modified: lldb/trunk/include/lldb/Symbol/TaggedASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TaggedASTType.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/TaggedASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/TaggedASTType.h Fri Jul 29 14:53:35 2011 @@ -21,7 +21,7 @@ { public: TaggedASTType (lldb::clang_type_t type, clang::ASTContext *ast_context) : - ClangASTType(type, ast_context) { } + ClangASTType(ast_context, type) { } TaggedASTType (const TaggedASTType &tw) : ClangASTType(tw) { } Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Fri Jul 29 14:53:35 2011 @@ -18,7 +18,7 @@ #include namespace lldb_private { - + class Type : public UserID { public: @@ -293,6 +293,99 @@ ConstString m_type_name; }; +// the two classes here are used by the public API as a backend to +// the SBType and SBTypeList classes + +class TypeImpl +{ +private: + std::auto_ptr m_clang_ast_type; + lldb::TypeSP m_lldb_type; + +public: + + TypeImpl() : + m_clang_ast_type(NULL), + m_lldb_type(lldb::TypeSP()) + {} + + TypeImpl(const TypeImpl& rhs) : + m_clang_ast_type(rhs.m_clang_ast_type.get()), + m_lldb_type(rhs.m_lldb_type) + {} + + TypeImpl& + operator = (const TypeImpl& rhs); + + bool + operator == (const TypeImpl& rhs) + { + return (m_clang_ast_type.get() == rhs.m_clang_ast_type.get()) && + (m_lldb_type.get() == rhs.m_lldb_type.get()); + } + + bool + operator != (const TypeImpl& rhs) + { + return (m_clang_ast_type.get() != rhs.m_clang_ast_type.get()) || + (m_lldb_type.get() != rhs.m_lldb_type.get()); + } + + TypeImpl(const lldb_private::ClangASTType& type); + + TypeImpl(lldb::TypeSP type); + + bool + IsValid() + { + return (m_lldb_type.get() != NULL) || (m_clang_ast_type.get() != NULL); + } + + lldb_private::ClangASTType* + GetClangASTType() + { + return m_clang_ast_type.get(); + } + + clang::ASTContext* + GetASTContext(); + + lldb::clang_type_t + GetOpaqueQualType(); +}; + +class TypeListImpl +{ +public: + TypeListImpl() : + m_content() {} + + void + AppendType(TypeImpl& type) + { + m_content.push_back(type); + } + + TypeImpl + GetTypeAtIndex(int index) + { + if (index < 0 || index >= GetSize()) + return TypeImpl(); + + return m_content[index]; + } + + int + GetSize() + { + return m_content.size(); + } + +private: + std::vector m_content; +}; + + } // namespace lldb_private #endif // liblldb_Type_h_ Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Jul 29 14:53:35 2011 @@ -496,19 +496,52 @@ eFunctionNameTypeSelector = (1u << 5) // Find function by selector name (ObjC) names } FunctionNameType; - // this enum determines how a FormatNavigator picked a specific format for a datatype - // these values can be used together (e.g. eFormatterStrippedPointerReference | eFormatterNavigatedBaseClasses - // if you went from DerivedType& to BaseType to find a valid format) + //---------------------------------------------------------------------- + // Ways that the FormatManager picks a particular format for a type + //---------------------------------------------------------------------- typedef enum FormatterChoiceCriterion { - eFormatterDirectChoice = 0x00000000, - eFormatterStrippedPointerReference = 0x00000001, - eFormatterNavigatedTypedefs = 0x00000002, - eFormatterNavigatedBaseClasses = 0x00000004, - eFormatterRegularExpressionSummary = 0x00000008 + eFormatterChoiceCriterionDirectChoice = 0x00000000, + eFormatterChoiceCriterionStrippedPointerReference = 0x00000001, + eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002, + eFormatterChoiceCriterionNavigatedBaseClasses = 0x00000004, + eFormatterChoiceCriterionRegularExpressionSummary = 0x00000008 } FormatterChoiceCriterion; - + //---------------------------------------------------------------------- + // Basic types enumeration for the public API SBType::GetBasicType() + //---------------------------------------------------------------------- + typedef enum BasicType + { + eBasicTypeInvalid = 0, + eBasicTypeVoid = 1, + eBasicTypeChar, + eBasicTypeSignedChar, + eBasicTypeWChar, + eBasicTypeChar16, + eBasicTypeChar32, + eBasicTypeShort, + eBasicTypeUnsignedShort, + eBasicTypeInt, + eBasicTypeUnsignedInt, + eBasicTypeLong, + eBasicTypeUnsignedLong, + eBasicTypeLongLong, + eBasicTypeUnsignedLongLong, + eBasicTypeInt128, + eBasicTypeUnsignedInt128, + eBasicTypeBool, + eBasicTypeFloat, + eBasicTypeDouble, + eBasicTypeLongDouble, + eBasicTypeFloatComplex, + eBasicTypeDoubleComplex, + eBasicTypeLongDoubleComplex, + eBasicTypeObjCID, + eBasicTypeObjCClass, + eBasicTypeObjCSel + } BasicType; + } // namespace lldb Modified: lldb/trunk/scripts/Python/interface/SBModule.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBModule.i (original) +++ lldb/trunk/scripts/Python/interface/SBModule.i Fri Jul 29 14:53:35 2011 @@ -137,6 +137,13 @@ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits bool append, lldb::SBSymbolContextList& sc_list); + + lldb::SBType + FindFirstType (const char* name); + + lldb::SBTypeList + FindTypes (const char* type); + %feature("docstring", " //------------------------------------------------------------------ Modified: lldb/trunk/scripts/Python/interface/SBTarget.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBTarget.i (original) +++ lldb/trunk/scripts/Python/interface/SBTarget.i Fri Jul 29 14:53:35 2011 @@ -320,6 +320,12 @@ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits bool append, lldb::SBSymbolContextList& sc_list); + + lldb::SBType + FindFirstType (const char* type); + + lldb::SBTypeList + FindTypes (const char* type); %feature("docstring", " //------------------------------------------------------------------ Modified: lldb/trunk/scripts/Python/interface/SBType.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBType.i?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBType.i (original) +++ lldb/trunk/scripts/Python/interface/SBType.i Fri Jul 29 14:53:35 2011 @@ -9,91 +9,63 @@ namespace lldb { -class SBTypeMember; - -class SBType -{ -public: - - SBType (void *ast = NULL, void *clang_type = NULL); - - SBType (const SBType &rhs); - - ~SBType (); - - bool - IsValid(); - - const char * - GetName(); - - uint64_t - GetByteSize(); - - uint64_t - GetNumberChildren (bool omit_empty_base_classes); - - bool - GetChildAtIndex (bool omit_empty_base_classes, uint32_t idx, SBTypeMember &member); - - uint32_t - GetChildIndexForName (bool omit_empty_base_classes, const char *name); - - bool - IsAPointerType (); - - SBType - GetPointeeType (); - - static bool - IsPointerType (void *opaque_type); - - bool - GetDescription (lldb::SBStream &description); -}; - -class SBTypeMember -{ -public: - - SBTypeMember (); - - SBTypeMember (const SBTypeMember &rhs); - - ~SBTypeMember (); - - bool - IsBaseClass (); - - bool - IsValid (); - - void - Clear(); - - bool - IsBitfield (); - - size_t - GetBitfieldWidth (); + class SBType + { + public: + + SBType (const SBType &rhs); + + ~SBType (); + + bool + IsValid() const; + + size_t + GetByteSize() const; + + bool + IsPointerType() const; + + bool + IsReferenceType() const; + + SBType + GetPointerType() const; + + SBType + GetPointeeType() const; + + SBType + GetReferenceType() const; + + SBType + GetDereferencedType() const; + + SBType + GetBasicType(lldb::BasicType type) const; + + const char* + GetName(); + }; - size_t - GetBitfieldOffset (); - - size_t - GetOffset (); - - const char * - GetName (); - - SBType - GetType(); - - SBType - GetParentType(); - - void - SetName (const char *name); -}; + class SBTypeList + { + public: + SBTypeList(); + + void + AppendType(SBType type); + + SBType + GetTypeAtIndex(int index); + + int + GetSize(); + + ~SBTypeList(); + + private: + std::auto_ptr m_content; + }; } // namespace lldb Modified: lldb/trunk/scripts/Python/interface/SBValue.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBValue.i (original) +++ lldb/trunk/scripts/Python/interface/SBValue.i Fri Jul 29 14:53:35 2011 @@ -203,7 +203,22 @@ GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic); + + lldb::SBValue + CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type); + + lldb::SBValue + SBValue::Cast(const SBType& type); + lldb::SBValue + CreateValueFromExpression (const char *name, const char* expression); + + lldb::SBValue + CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type); + + lldb::SBType + GetType(); + %feature("docstring", " //------------------------------------------------------------------ /// Returns the child member index. @@ -257,13 +272,27 @@ void * GetOpaqueType(); - lldb::SBValue Dereference (); + lldb::SBValue + AddressOf(); + bool TypeIsPointerType (); + + lldb::SBTarget + GetTarget(); + lldb::SBProcess + GetProcess(); + + lldb::SBThread + GetThread(); + + lldb::SBFrame + GetFrame(); + bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Fri Jul 29 14:53:35 2011 @@ -331,10 +331,11 @@ ); -extern "C" uint32_t LLDBSwigPython_CalculateNumChildren (void *implementor); -extern "C" void* LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx); -extern "C" int LLDBSwigPython_GetIndexOfChildWithName (void *implementor, const char* child_name); -extern "C" lldb::SBValue* LLDBSWIGPython_CastPyObjectToSBValue (void* data); +extern "C" uint32_t LLDBSwigPython_CalculateNumChildren (void *implementor); +extern "C" void* LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx); +extern "C" int LLDBSwigPython_GetIndexOfChildWithName (void *implementor, const char* child_name); +extern "C" lldb::SBValue* LLDBSWIGPython_CastPyObjectToSBValue (void* data); +extern "C" void LLDBSwigPython_UpdateSynthProviderInstance (void* implementor); extern "C" void init_lldb(void); @@ -352,6 +353,7 @@ LLDBSwigPython_CalculateNumChildren, LLDBSwigPython_GetChildAtIndex, LLDBSwigPython_GetIndexOfChildWithName, - LLDBSWIGPython_CastPyObjectToSBValue); + LLDBSWIGPython_CastPyObjectToSBValue, + LLDBSwigPython_UpdateSynthProviderInstance); } } Modified: lldb/trunk/source/API/SBModule.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/API/SBModule.cpp (original) +++ lldb/trunk/source/API/SBModule.cpp Fri Jul 29 14:53:35 2011 @@ -17,6 +17,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/Target.h" @@ -342,3 +343,59 @@ return sb_value_list; } + +lldb::SBType +SBModule::FindFirstType (const char* name_cstr) +{ + if (!IsValid()) + return lldb::SBType(); + + SymbolContext sc; + TypeList type_list; + uint32_t num_matches = 0; + ConstString name(name_cstr); + + num_matches = m_opaque_sp->FindTypes(sc, + name, + false, + 1, + type_list); + + if (num_matches) + { + TypeSP type_sp (type_list.GetTypeAtIndex(0)); + return lldb::SBType(type_sp); + } + else + return lldb::SBType(); +} + +lldb::SBTypeList +SBModule::FindTypes (const char* type) +{ + + SBTypeList retval; + + if (!IsValid()) + return retval; + + SymbolContext sc; + TypeList type_list; + uint32_t num_matches = 0; + ConstString name(type); + + num_matches = m_opaque_sp->FindTypes(sc, + name, + false, + UINT32_MAX, + type_list); + + for (size_t idx = 0; idx < num_matches; idx++) + { + TypeSP sp_at_idx = type_list.GetTypeAtIndex(idx); + + retval.AppendType(SBType(sp_at_idx)); + } + + return retval; +} \ No newline at end of file Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Fri Jul 29 14:53:35 2011 @@ -38,6 +38,7 @@ #include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/Args.h" +#include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -879,6 +880,52 @@ return 0; } +lldb::SBType +SBTarget::FindFirstType (const char* type) +{ + if (m_opaque_sp) + { + size_t count = m_opaque_sp->GetImages().GetSize(); + for (size_t idx = 0; idx < count; idx++) + { + SBType found_at_idx = GetModuleAtIndex(idx).FindFirstType(type); + + if (found_at_idx.IsValid()) + return found_at_idx; + } + } + return SBType(); +} + +lldb::SBTypeList +SBTarget::FindTypes (const char* type) +{ + + SBTypeList retval; + + if (m_opaque_sp) + { + ModuleList& images = m_opaque_sp->GetImages(); + ConstString name_const(type); + SymbolContext sc; + TypeList type_list; + + uint32_t num_matches = images.FindTypes(sc, + name_const, + true, + UINT32_MAX, + type_list); + + for (size_t idx = 0; idx < num_matches; idx++) + { + TypeSP sp_at_idx = type_list.GetTypeAtIndex(idx); + + retval.AppendType(SBType(sp_at_idx)); + } + } + return retval; +} + SBValueList SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches) { Modified: lldb/trunk/source/API/SBType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/API/SBType.cpp (original) +++ lldb/trunk/source/API/SBType.cpp Fri Jul 29 14:53:35 2011 @@ -9,6 +9,12 @@ #include +#include "clang/AST/ASTContext.h" +#include "clang/AST/TemplateBase.h" +#include "clang/AST/Type.h" + +#include "lldb/API/SBDefines.h" + #include "lldb/API/SBType.h" #include "lldb/API/SBStream.h" #include "lldb/Core/ConstString.h" @@ -18,334 +24,340 @@ using namespace lldb; using namespace lldb_private; +using namespace clang; - -bool -SBType::IsPointerType (void *opaque_type) +SBType::SBType (lldb_private::ClangASTType type) : +m_opaque_ap(new TypeImpl(ClangASTType(type.GetASTContext(), + type.GetOpaqueQualType()))) { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - - //if (log) - // log->Printf ("SBType::IsPointerType (%p)", opaque_type); - - bool ret_value = ClangASTContext::IsPointerType (opaque_type); - - if (log) - log->Printf ("SBType::IsPointerType (opaque_type=%p) ==> '%s'", opaque_type, (ret_value ? "true" : "false")); - - return ret_value; } +SBType::SBType (lldb::TypeSP type) : +m_opaque_ap(new TypeImpl(type)) +{} -SBType::SBType (void *ast, void *clang_type) : - m_ast (ast), - m_type (clang_type) +SBType::SBType (const SBType &rhs) { + if (rhs.m_opaque_ap.get() != NULL) + { + m_opaque_ap = std::auto_ptr(new TypeImpl(ClangASTType(rhs.m_opaque_ap->GetASTContext(), + rhs.m_opaque_ap->GetOpaqueQualType()))); + } } -SBType::SBType (const SBType &rhs) : - m_ast (rhs.m_ast), - m_type (rhs.m_type) +SBType::SBType (clang::ASTContext *ctx, clang_type_t ty) : +m_opaque_ap(new TypeImpl(ClangASTType(ctx, ty))) { } -const SBType & -SBType::operator =(const SBType &rhs) +SBType::SBType() : +m_opaque_ap(NULL) { - m_ast = rhs.m_ast; - m_type = rhs.m_type; - return *this; } -SBType::~SBType () -{ -} +SBType::SBType (TypeImpl impl) : +m_opaque_ap(&impl) +{} bool -SBType::IsValid () +SBType::operator == (const lldb::SBType &rhs) const { - return m_ast != NULL && m_type != NULL; + if (IsValid() == false) + return !rhs.IsValid(); + + return (rhs.m_opaque_ap->GetASTContext() == m_opaque_ap->GetASTContext()) + && + (rhs.m_opaque_ap->GetOpaqueQualType() == m_opaque_ap->GetOpaqueQualType()); } -const char * -SBType::GetName () -{ - if (IsValid ()) - return ClangASTType::GetConstTypeName (m_type).AsCString(NULL); - return NULL; +bool +SBType::operator != (const lldb::SBType &rhs) const +{ + if (IsValid() == false) + return rhs.IsValid(); + + return (rhs.m_opaque_ap->GetASTContext() != m_opaque_ap->GetASTContext()) + || + (rhs.m_opaque_ap->GetOpaqueQualType() != m_opaque_ap->GetOpaqueQualType()); } -uint64_t -SBType::GetByteSize() + +const lldb::SBType & +SBType::operator = (const lldb::SBType &rhs) { - if (IsValid ()) - return ClangASTType::GetClangTypeBitWidth (static_cast(m_ast), m_type); - return NULL; + if (*this != rhs) + { + if (!rhs.IsValid()) + m_opaque_ap.reset(NULL); + else + m_opaque_ap = std::auto_ptr(new TypeImpl(ClangASTType(rhs.m_opaque_ap->GetASTContext(), + rhs.m_opaque_ap->GetOpaqueQualType()))); + } + return *this; } -Encoding -SBType::GetEncoding (uint32_t &count) +SBType::~SBType () +{} + +lldb_private::TypeImpl & +SBType::ref () { - if (IsValid ()) - return ClangASTType::GetEncoding (m_type, count); - count = 0; - return eEncodingInvalid; + if (m_opaque_ap.get() == NULL) + m_opaque_ap.reset (new lldb_private::TypeImpl()); + return *m_opaque_ap; } -uint64_t -SBType::GetNumberChildren (bool omit_empty_base_classes) +const lldb_private::TypeImpl & +SBType::ref () const { - if (IsValid ()) - return ClangASTContext::GetNumChildren (static_cast(m_ast), - m_type, - omit_empty_base_classes); - return 0; + // "const SBAddress &addr" should already have checked "addr.IsValid()" + // prior to calling this function. In case you didn't we will assert + // and die to let you know. + assert (m_opaque_ap.get()); + return *m_opaque_ap; } - bool -SBType::GetChildAtIndex (bool omit_empty_base_classes, uint32_t idx, SBTypeMember &member) +SBType::IsValid() const { - void *child_clang_type = NULL; - bool ignore_array_bounds = false; - std::string child_name; - uint32_t child_byte_size = 0; - int32_t child_byte_offset = 0; - uint32_t child_bitfield_bit_size = 0; - uint32_t child_bitfield_bit_offset = 0; - bool child_is_base_class = false; - bool child_is_deref_of_parent = false; - - if (IsValid ()) - { - - child_clang_type = ClangASTContext::GetChildClangTypeAtIndex (NULL, - static_cast(m_ast), - NULL, - m_type, - idx, - false, // transparent pointers - omit_empty_base_classes, - ignore_array_bounds, - child_name, - child_byte_size, - child_byte_offset, - child_bitfield_bit_size, - child_bitfield_bit_offset, - child_is_base_class, - child_is_deref_of_parent); - - } + if (m_opaque_ap.get() == NULL) + return false; - if (child_clang_type) - { - member.m_ast = m_ast; - member.m_parent_type = m_type; - member.m_member_type = child_clang_type, - member.SetName (child_name.c_str()); - member.m_offset = child_byte_offset; - member.m_bit_size = child_bitfield_bit_size; - member.m_bit_offset = child_bitfield_bit_offset; - member.m_is_base_class = child_is_base_class; - member.m_is_deref_of_paremt = child_is_deref_of_parent; - } - else - { - member.Clear(); - } - - return child_clang_type != NULL; + return m_opaque_ap->IsValid(); } -uint32_t -SBType::GetChildIndexForName (bool omit_empty_base_classes, const char *name) +size_t +SBType::GetByteSize() const { - return ClangASTContext::GetIndexOfChildWithName (static_cast(m_ast), - m_type, - name, - omit_empty_base_classes); + if (!IsValid()) + return 0; + + return ClangASTType::GetTypeByteSize(m_opaque_ap->GetASTContext(), m_opaque_ap->GetOpaqueQualType()); + } bool -SBType::IsAPointerType () +SBType::IsPointerType() const { - return ClangASTContext::IsPointerType (m_type); -} - -SBType -SBType::GetPointeeType () -{ - void *pointee_type = NULL; - if (IsAPointerType ()) - { - pointee_type = ClangASTType::GetPointeeType (m_type); - } - return SBType (pointee_type ? m_ast : NULL, pointee_type); + if (!IsValid()) + return false; + + QualType qt = QualType::getFromOpaquePtr(m_opaque_ap->GetOpaqueQualType()); + const clang::Type* typePtr = qt.getTypePtrOrNull(); + + if (typePtr) + return typePtr->isAnyPointerType(); + return false; } bool -SBType::GetDescription (SBStream &description) +SBType::IsReferenceType() const { - const char *name = GetName(); - uint64_t byte_size = GetByteSize(); - uint64_t num_children = GetNumberChildren (true); - bool is_ptr = IsAPointerType (); + if (!IsValid()) + return false; - description.Printf ("type_name: %s, size: %d bytes", (name != NULL ? name : ""), byte_size); - if (is_ptr) - { - SBType pointee_type = GetPointeeType(); - const char *pointee_name = pointee_type.GetName(); - description.Printf (", (* %s)", (pointee_name != NULL ? pointee_name : "")); - } - else if (num_children > 0) - { - description.Printf (", %d members:\n", num_children); - for (uint32_t i = 0; i < num_children; ++i) - { - SBTypeMember field; - GetChildAtIndex (true, i, field); - const char *field_name = field.GetName(); - SBType field_type = field.GetType(); - const char *field_type_name = field_type.GetName(); - - description.Printf (" %s (type: %s", (field_name != NULL ? field_name : ""), - (field_type_name != NULL ? field_type_name : "")); - - if (field.IsBitfield()) - { - size_t width = field.GetBitfieldWidth (); - description.Printf (" , %d bits", (int) width); - } - description.Printf (")\n"); - } - } - return true; -} - -SBTypeMember::SBTypeMember () : - m_ast (NULL), - m_parent_type (NULL), - m_member_type (NULL), - m_member_name (NULL), - m_offset (0), - m_bit_size (0), - m_bit_offset (0), - m_is_base_class (false) + QualType qt = QualType::getFromOpaquePtr(m_opaque_ap->GetOpaqueQualType()); + const clang::Type* typePtr = qt.getTypePtrOrNull(); -{ + if (typePtr) + return typePtr->isReferenceType(); + return false; } -SBTypeMember::SBTypeMember (const SBTypeMember &rhs) : - m_ast (rhs.m_ast), - m_parent_type (rhs.m_parent_type), - m_member_type (rhs.m_member_type), - m_member_name (rhs.m_member_name), - m_offset (rhs.m_offset), - m_bit_size (rhs.m_bit_size), - m_bit_offset (rhs.m_bit_offset), - m_is_base_class (rhs.m_is_base_class) +SBType +SBType::GetPointerType() const { -} + if (!IsValid()) + return SBType(); -const SBTypeMember& -SBTypeMember::operator =(const SBTypeMember &rhs) -{ - if (this != &rhs) - { - m_ast = rhs.m_ast; - m_parent_type = rhs.m_parent_type; - m_member_type = rhs.m_member_type; - m_member_name = rhs.m_member_name; - m_offset = rhs.m_offset; - m_bit_size = rhs.m_bit_size; - m_bit_offset = rhs.m_bit_offset; - m_is_base_class = rhs.m_is_base_class; - } - return *this; + return SBType(m_opaque_ap->GetASTContext(), + ClangASTContext::CreatePointerType(m_opaque_ap->GetASTContext(), m_opaque_ap->GetOpaqueQualType())); } -SBTypeMember::~SBTypeMember () +SBType +SBType::GetPointeeType() const { - SetName (NULL); -} + if (!IsValid()) + return SBType(); -void -SBTypeMember::SetName (const char *name) -{ - if (m_member_name) - free (m_member_name); - if (name && name[0]) - m_member_name = ::strdup (name); - else - m_member_name = NULL; + QualType qt = QualType::getFromOpaquePtr(m_opaque_ap->GetOpaqueQualType()); + const clang::Type* typePtr = qt.getTypePtrOrNull(); + + if (typePtr) + return SBType(m_opaque_ap->GetASTContext(),typePtr->getPointeeType().getAsOpaquePtr()); + return SBType(); } -void -SBTypeMember::Clear() +SBType +SBType::GetReferenceType() const { - m_ast = NULL; - m_parent_type = NULL; - m_member_type = NULL; - SetName (NULL); - m_offset = 0; - m_bit_size = 0; - m_bit_offset = 0; - m_is_base_class = false; + if (!IsValid()) + return SBType(); + + return SBType(m_opaque_ap->GetASTContext(), + ClangASTContext::CreateLValueReferenceType(m_opaque_ap->GetASTContext(), m_opaque_ap->GetOpaqueQualType())); } -bool -SBTypeMember::IsValid () +SBType +SBType::GetDereferencedType() const { - return m_member_type != NULL; + if (!IsValid()) + return SBType(); + + QualType qt = QualType::getFromOpaquePtr(m_opaque_ap->GetOpaqueQualType()); + + return SBType(m_opaque_ap->GetASTContext(),qt.getNonReferenceType().getAsOpaquePtr()); } -bool -SBTypeMember::IsBitfield () +SBType +SBType::GetBasicType(lldb::BasicType type) const { - return m_bit_size != 0; + + if (!IsValid()) + return SBType(); + + clang::CanQualType base_type_qual; + + switch (type) + { + case eBasicTypeChar: + base_type_qual = m_opaque_ap->GetASTContext()->CharTy; + break; + case eBasicTypeSignedChar: + base_type_qual = m_opaque_ap->GetASTContext()->SignedCharTy; + break; + case eBasicTypeShort: + base_type_qual = m_opaque_ap->GetASTContext()->ShortTy; + break; + case eBasicTypeUnsignedShort: + base_type_qual = m_opaque_ap->GetASTContext()->UnsignedShortTy; + break; + case eBasicTypeInt: + base_type_qual = m_opaque_ap->GetASTContext()->IntTy; + break; + case eBasicTypeUnsignedInt: + base_type_qual = m_opaque_ap->GetASTContext()->UnsignedIntTy; + break; + case eBasicTypeLong: + base_type_qual = m_opaque_ap->GetASTContext()->LongTy; + break; + case eBasicTypeUnsignedLong: + base_type_qual = m_opaque_ap->GetASTContext()->UnsignedLongTy; + break; + case eBasicTypeBool: + base_type_qual = m_opaque_ap->GetASTContext()->BoolTy; + break; + case eBasicTypeFloat: + base_type_qual = m_opaque_ap->GetASTContext()->FloatTy; + break; + case eBasicTypeDouble: + base_type_qual = m_opaque_ap->GetASTContext()->DoubleTy; + break; + case eBasicTypeObjCID: + base_type_qual = m_opaque_ap->GetASTContext()->ObjCBuiltinIdTy; + break; + case eBasicTypeVoid: + base_type_qual = m_opaque_ap->GetASTContext()->VoidTy; + break; + case eBasicTypeWChar: + base_type_qual = m_opaque_ap->GetASTContext()->WCharTy; + break; + case eBasicTypeChar16: + base_type_qual = m_opaque_ap->GetASTContext()->Char16Ty; + break; + case eBasicTypeChar32: + base_type_qual = m_opaque_ap->GetASTContext()->Char32Ty; + break; + case eBasicTypeLongLong: + base_type_qual = m_opaque_ap->GetASTContext()->LongLongTy; + break; + case eBasicTypeUnsignedLongLong: + base_type_qual = m_opaque_ap->GetASTContext()->UnsignedLongLongTy; + break; + case eBasicTypeInt128: + base_type_qual = m_opaque_ap->GetASTContext()->Int128Ty; + break; + case eBasicTypeUnsignedInt128: + base_type_qual = m_opaque_ap->GetASTContext()->UnsignedInt128Ty; + break; + case eBasicTypeLongDouble: + base_type_qual = m_opaque_ap->GetASTContext()->LongDoubleTy; + break; + case eBasicTypeFloatComplex: + base_type_qual = m_opaque_ap->GetASTContext()->FloatComplexTy; + break; + case eBasicTypeDoubleComplex: + base_type_qual = m_opaque_ap->GetASTContext()->DoubleComplexTy; + break; + case eBasicTypeLongDoubleComplex: + base_type_qual = m_opaque_ap->GetASTContext()->LongDoubleComplexTy; + break; + case eBasicTypeObjCClass: + base_type_qual = m_opaque_ap->GetASTContext()->ObjCBuiltinClassTy; + break; + case eBasicTypeObjCSel: + base_type_qual = m_opaque_ap->GetASTContext()->ObjCBuiltinSelTy; + break; + default: + return SBType(); + } + + return SBType(m_opaque_ap->GetASTContext(), + base_type_qual.getAsOpaquePtr()); } -size_t -SBTypeMember::GetBitfieldWidth () +const char* +SBType::GetName() { - return m_bit_size; + if (!IsValid()) + return ""; + + return ClangASTType::GetConstTypeName(m_opaque_ap->GetOpaqueQualType()).GetCString(); } -size_t -SBTypeMember::GetBitfieldOffset () +SBTypeList::SBTypeList() : +m_opaque_ap(new TypeListImpl()) { - return m_bit_offset; } -bool -SBTypeMember::IsBaseClass () +SBTypeList::SBTypeList(const SBTypeList& rhs) : +m_opaque_ap(new TypeListImpl()) { - return m_is_base_class; + for (int j = 0; j < rhs.GetSize(); j++) + AppendType(rhs.GetTypeAtIndex(j)); } -size_t -SBTypeMember::GetOffset () +SBTypeList& +SBTypeList::operator = (const SBTypeList& rhs) { - return m_offset; + if (m_opaque_ap.get() != rhs.m_opaque_ap.get()) + { + m_opaque_ap.reset(new TypeListImpl()); + for (int j = 0; j < rhs.GetSize(); j++) + AppendType(rhs.GetTypeAtIndex(j)); + } + return *this; } -SBType -SBTypeMember::GetType() +void +SBTypeList::AppendType(SBType type) { - return SBType (m_ast, m_member_type); + if (type.IsValid()) + m_opaque_ap->AppendType(*type.m_opaque_ap.get()); } SBType -SBTypeMember::GetParentType() +SBTypeList::GetTypeAtIndex(int index) const { - return SBType (m_ast, m_parent_type); + return SBType(m_opaque_ap->GetTypeAtIndex(index)); } - -const char * -SBTypeMember::GetName () +int +SBTypeList::GetSize() const { - return m_member_name; + return m_opaque_ap->GetSize(); } +SBTypeList::~SBTypeList() +{ +} \ No newline at end of file Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Fri Jul 29 14:53:35 2011 @@ -17,6 +17,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" @@ -156,9 +157,9 @@ if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); result = m_opaque_sp->IsInScope (); } } @@ -182,9 +183,9 @@ const char *cstr = NULL; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); cstr = m_opaque_sp->GetValueAsCString (); } } @@ -237,9 +238,9 @@ const char *cstr = NULL; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); cstr = m_opaque_sp->GetObjectDescription (); } } @@ -260,15 +261,39 @@ return GetValueDidChange (); } +SBType +SBValue::GetType() +{ + SBType result; + if (m_opaque_sp) + { + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) + { + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); + result = SBType(m_opaque_sp->GetClangAST(), + m_opaque_sp->GetClangType()); + } + } + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + if (result.IsValid()) + log->Printf ("SBValue(%p)::GetType => %p", m_opaque_sp.get(), &result); + else + log->Printf ("SBValue(%p)::GetType => NULL", m_opaque_sp.get()); + } + return result; +} + bool SBValue::GetValueDidChange () { bool result = false; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); result = m_opaque_sp->GetValueDidChange (); } } @@ -291,9 +316,9 @@ const char *cstr = NULL; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); cstr = m_opaque_sp->GetSummaryAsCString(); } } @@ -320,9 +345,9 @@ const char *cstr = NULL; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); cstr = m_opaque_sp->GetLocationAsCString(); } } @@ -349,22 +374,109 @@ bool success = false; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); success = m_opaque_sp->SetValueFromCString (value_str); } } return success; } +lldb::SBValue +SBValue::CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type) +{ + lldb::SBValue result; + if (m_opaque_sp) + { + if (type.IsValid()) + { + result = SBValue(m_opaque_sp->GetSyntheticChildAtOffset(offset, *type.m_opaque_ap->GetClangASTType(), true)); + result.m_opaque_sp->SetName(ConstString(name)); + } + } + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + if (result.IsValid()) + log->Printf ("SBValue(%p)::GetChildAtOffset => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get()); + else + log->Printf ("SBValue(%p)::GetChildAtOffset => NULL", m_opaque_sp.get()); + } + return result; +} + +lldb::SBValue +SBValue::Cast(const SBType& type) +{ + return CreateChildAtOffset(m_opaque_sp->GetName().GetCString(), 0, type); +} + +lldb::SBValue +SBValue::CreateValueFromExpression (const char *name, const char* expression) +{ + lldb::SBValue result; + if (m_opaque_sp) + { + ValueObjectSP result_valobj_sp; + m_opaque_sp->GetUpdatePoint().GetTargetSP()->EvaluateExpression(expression, + m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame(), + true, true, eNoDynamicValues, + result_valobj_sp); + result_valobj_sp->SetName(ConstString(name)); + result = SBValue(result_valobj_sp); + } + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + if (result.IsValid()) + log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get()); + else + log->Printf ("SBValue(%p)::GetChildFromExpression => NULL", m_opaque_sp.get()); + } + return result; +} + +lldb::SBValue +SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type) +{ + lldb::SBValue result; + if (m_opaque_sp) + { + + SBType real_type(type.GetPointerType()); + + lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t))); + + ValueObjectSP result_valobj_sp(ValueObjectConstResult::Create(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope(), + real_type.m_opaque_ap->GetASTContext(), + real_type.m_opaque_ap->GetOpaqueQualType(), + ConstString(name), + buffer, + lldb::endian::InlHostByteOrder(), + GetTarget().GetProcess().GetAddressByteSize())); + + result_valobj_sp->SetName(ConstString(name)); + result = SBValue(result_valobj_sp); + } + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + if (result.IsValid()) + log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get()); + else + log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get()); + } + return result; +} + SBValue SBValue::GetChildAtIndex (uint32_t idx) { const bool can_create_synthetic = false; lldb::DynamicValueType use_dynamic = eNoDynamicValues; if (m_opaque_sp) - use_dynamic = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue(); + use_dynamic = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue(); return GetChildAtIndex (idx, use_dynamic, can_create_synthetic); } @@ -375,9 +487,9 @@ if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); const bool can_create = true; child_sp = m_opaque_sp->GetChildAtIndex (idx, can_create); if (can_create_synthetic && !child_sp) @@ -418,9 +530,9 @@ uint32_t idx = UINT32_MAX; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name)); } @@ -441,7 +553,7 @@ { if (m_opaque_sp) { - lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTarget()->GetPreferDynamicValue(); + lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue(); return GetChildMemberWithName (name, use_dynamic_value); } else @@ -457,9 +569,9 @@ if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true); if (use_dynamic_value != lldb::eNoDynamicValues) { @@ -488,9 +600,9 @@ lldb::ValueObjectSP child_sp; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); // using default values for all the fancy options, just do it if you can child_sp = m_opaque_sp->GetValueForExpressionPath(expr_path); } @@ -512,9 +624,9 @@ if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); num_children = m_opaque_sp->GetNumChildren(); } @@ -534,9 +646,9 @@ SBValue sb_value; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); Error error; sb_value = m_opaque_sp->Dereference (error); @@ -556,9 +668,9 @@ if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); is_ptr_type = m_opaque_sp->IsPointerType(); } @@ -577,9 +689,9 @@ { if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetTarget()) + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) { - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); return m_opaque_sp->GetClangType(); } @@ -587,6 +699,95 @@ return NULL; } +lldb::SBTarget +SBValue::GetTarget() +{ + SBTarget result; + if (m_opaque_sp) + { + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) + { + result = SBTarget(lldb::TargetSP(m_opaque_sp->GetUpdatePoint().GetTargetSP())); + } + } + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + if (result.get() == NULL) + log->Printf ("SBValue(%p)::GetTarget () => NULL", m_opaque_sp.get()); + else + log->Printf ("SBValue(%p)::GetTarget () => %p", m_opaque_sp.get(), result.get()); + } + return result; +} + +lldb::SBProcess +SBValue::GetProcess() +{ + SBProcess result; + if (m_opaque_sp) + { + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) + { + result = SBProcess(lldb::ProcessSP(m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetProcessSP())); + } + } + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + if (result.get() == NULL) + log->Printf ("SBValue(%p)::GetProcess () => NULL", m_opaque_sp.get()); + else + log->Printf ("SBValue(%p)::GetProcess () => %p", m_opaque_sp.get(), result.get()); + } + return result; +} + +lldb::SBThread +SBValue::GetThread() +{ + SBThread result; + if (m_opaque_sp) + { + if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()) + { + result = SBThread(lldb::ThreadSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateThread())); + } + } + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + if (result.get() == NULL) + log->Printf ("SBValue(%p)::GetThread () => NULL", m_opaque_sp.get()); + else + log->Printf ("SBValue(%p)::GetThread () => %p", m_opaque_sp.get(), result.get()); + } + return result; +} + +lldb::SBFrame +SBValue::GetFrame() +{ + SBFrame result; + if (m_opaque_sp) + { + if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()) + { + result = SBFrame(lldb::StackFrameSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame())); + } + } + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + if (result.get() == NULL) + log->Printf ("SBValue(%p)::GetFrame () => NULL", m_opaque_sp.get()); + else + log->Printf ("SBValue(%p)::GetFrame () => %p", m_opaque_sp.get(), result.get()); + } + return result; +} + + // Mimic shared pointer... lldb_private::ValueObject * SBValue::get() const @@ -685,3 +886,23 @@ m_opaque_sp->SetFormat(format); } +lldb::SBValue +SBValue::AddressOf() +{ + SBValue sb_value; + if (m_opaque_sp) + { + if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) + { + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); + + Error error; + sb_value = m_opaque_sp->AddressOf (error); + } + } + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + log->Printf ("SBValue(%p)::GetPointerToObject () => SBValue(%p)", m_opaque_sp.get(), sb_value.get()); + + return sb_value; +} \ No newline at end of file Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Jul 29 14:53:35 2011 @@ -1367,11 +1367,11 @@ { if (module && name_cstr && name_cstr[0]) { - SymbolContextList sc_list; + /*SymbolContextList sc_list; SymbolVendor *symbol_vendor = module->GetSymbolVendor(); if (symbol_vendor) - { + {*/ TypeList type_list; uint32_t num_matches = 0; SymbolContext sc; @@ -1383,7 +1383,7 @@ // else // { ConstString name(name_cstr); - num_matches = symbol_vendor->FindTypes(sc, name, true, UINT32_MAX, type_list); + num_matches = module->FindTypes(sc, name, true, UINT32_MAX, type_list); // } if (num_matches) @@ -1407,7 +1407,7 @@ } } return num_matches; - } + //} } return 0; } Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Fri Jul 29 14:53:35 2011 @@ -218,8 +218,8 @@ { { LLDB_OPT_SET_ALL, false, "cascade", 'C', required_argument, NULL, 0, eArgTypeBoolean, "If true, cascade to derived typedefs."}, { LLDB_OPT_SET_ALL, false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat, "The format to use to display this type."}, - { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeBoolean, "Don't use this format for pointers-to-type objects."}, - { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeBoolean, "Don't use this format for references-to-type objects."}, + { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."}, + { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeNone, "Don't use this format for references-to-type objects."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -1074,16 +1074,16 @@ { { LLDB_OPT_SET_ALL, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."}, { LLDB_OPT_SET_ALL, false, "cascade", 'C', required_argument, NULL, 0, eArgTypeBoolean, "If true, cascade to derived typedefs."}, - { LLDB_OPT_SET_ALL, false, "no-value", 'v', no_argument, NULL, 0, eArgTypeBoolean, "Don't show the value, just show the summary, for this type."}, - { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeBoolean, "Don't use this format for pointers-to-type objects."}, - { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeBoolean, "Don't use this format for references-to-type objects."}, - { LLDB_OPT_SET_ALL, false, "regex", 'x', no_argument, NULL, 0, eArgTypeBoolean, "Type names are actually regular expressions."}, - { LLDB_OPT_SET_1 , true, "inline-children", 'c', no_argument, NULL, 0, eArgTypeBoolean, "If true, inline all child values into summary string."}, + { LLDB_OPT_SET_ALL, false, "no-value", 'v', no_argument, NULL, 0, eArgTypeNone, "Don't show the value, just show the summary, for this type."}, + { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."}, + { 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_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, eArgTypeName, "Input Python code to use for this type manually."}, - { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "expand", 'e', no_argument, NULL, 0, eArgTypeBoolean, "Expand aggregate data types to show children on separate lines."}, + { LLDB_OPT_SET_3, false, "input-python", 'P', no_argument, NULL, 0, eArgTypeNone, "Input Python code to use for this type manually."}, + { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "expand", 'e', no_argument, NULL, 0, eArgTypeNone, "Expand aggregate data types to show children on separate lines."}, { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "name", 'n', required_argument, NULL, 0, eArgTypeName, "A name for this summary string."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -1249,7 +1249,7 @@ OptionDefinition CommandObjectTypeSummaryDelete::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "all", 'a', no_argument, NULL, 0, eArgTypeBoolean, "Delete from every category."}, + { LLDB_OPT_SET_1, false, "all", 'a', no_argument, NULL, 0, eArgTypeNone, "Delete from every category."}, { LLDB_OPT_SET_2, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Delete from given category."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -1375,7 +1375,7 @@ OptionDefinition CommandObjectTypeSummaryClear::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "all", 'a', no_argument, NULL, 0, eArgTypeBoolean, "Clear every category."}, + { LLDB_OPT_SET_ALL, false, "all", 'a', no_argument, NULL, 0, eArgTypeNone, "Clear every category."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -2236,7 +2236,7 @@ OptionDefinition CommandObjectTypeSynthDelete::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "all", 'a', no_argument, NULL, 0, eArgTypeBoolean, "Delete from every category."}, + { LLDB_OPT_SET_1, false, "all", 'a', no_argument, NULL, 0, eArgTypeNone, "Delete from every category."}, { LLDB_OPT_SET_2, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Delete from given category."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -2363,7 +2363,7 @@ OptionDefinition CommandObjectTypeSynthClear::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "all", 'a', no_argument, NULL, 0, eArgTypeBoolean, "Clear every category."}, + { LLDB_OPT_SET_ALL, false, "all", 'a', no_argument, NULL, 0, eArgTypeNone, "Clear every category."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -2377,6 +2377,9 @@ " def num_children(self):\n" " def get_child_at_index(self, index):\n" " def get_child_index(self, name):\n" + "Optionally, you can also define a method:\n" + " def update(self):\n" + "if your synthetic provider is holding on to any per-object state variables (currently, this is not implemented because of the way LLDB handles instances of SBValue and you should not rely on object persistence and per-object state)\n" "class synthProvider:"; class TypeSynthAddInputReader : public InputReaderEZ @@ -2832,12 +2835,12 @@ CommandObjectTypeSynthAdd::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_ALL, false, "cascade", 'C', required_argument, NULL, 0, eArgTypeBoolean, "If true, cascade to derived typedefs."}, - { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeBoolean, "Don't use this format for pointers-to-type objects."}, - { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeBoolean, "Don't use this format for references-to-type objects."}, + { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."}, + { 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, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."}, { LLDB_OPT_SET_1, false, "child", 'c', required_argument, NULL, 0, eArgTypeName, "Include this expression path in the synthetic view."}, { LLDB_OPT_SET_2, false, "python-class", 'l', required_argument, NULL, 0, eArgTypeName, "Use this Python class to produce synthetic children."}, - { LLDB_OPT_SET_3, false, "input-python", 'P', no_argument, NULL, 0, eArgTypeBoolean, "Type Python code to generate a class that provides synthetic children."}, + { LLDB_OPT_SET_3, false, "input-python", 'P', no_argument, NULL, 0, eArgTypeNone, "Type Python code to generate a class that provides synthetic children."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Jul 29 14:53:35 2011 @@ -1004,16 +1004,28 @@ switch (var_name_begin[0]) { case '*': - { - if (!vobj) - break; - do_deref_pointer = true; - var_name_begin++; - } - // Fall through... - case 'v': + case 's': { + if (!vobj) + break; + + // check for *var and *svar + if (*var_name_begin == '*') + { + do_deref_pointer = true; + var_name_begin++; + } + if (*var_name_begin == 's') + { + vobj = vobj->GetSyntheticValue(lldb::eUseSyntheticFilter).get(); + var_name_begin++; + } + + // should be a 'v' by now + if (*var_name_begin != 'v') + break; + ValueObject::ExpressionPathAftermath what_next = (do_deref_pointer ? ValueObject::eDereference : ValueObject::eNothing); ValueObject::GetValueForExpressionPathOptions options; Modified: lldb/trunk/source/Core/FormatClasses.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatClasses.cpp (original) +++ lldb/trunk/source/Core/FormatClasses.cpp Fri Jul 29 14:53:35 2011 @@ -171,7 +171,7 @@ return; } - m_interpreter = be->GetUpdatePoint().GetTarget()->GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); + m_interpreter = be->GetUpdatePoint().GetTargetSP()->GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); if (m_interpreter == NULL) m_wrapper = NULL; Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Fri Jul 29 14:53:35 2011 @@ -422,7 +422,7 @@ } uint32_t -Module::FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) +Module::FindTypes_Impl (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) { Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); if (sc.module_sp.get() == NULL || sc.module_sp.get() == this) @@ -434,6 +434,41 @@ return 0; } +// depending on implementation details, type lookup might fail because of +// embedded spurious namespace:: prefixes. this call strips them, paying +// attention to the fact that a type might have namespace'd type names as +// arguments to templates, and those must not be stripped off +static const char* +StripTypeName(const char* name_cstr) +{ + const char* skip_namespace = strstr(name_cstr, "::"); + const char* template_arg_char = strchr(name_cstr, '<'); + while (skip_namespace != NULL) + { + if (template_arg_char != NULL && + skip_namespace > template_arg_char) // but namespace'd template arguments are still good to go + break; + name_cstr = skip_namespace+2; + skip_namespace = strstr(name_cstr, "::"); + } + return name_cstr; +} + +uint32_t +Module::FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) +{ + uint32_t retval = FindTypes_Impl(sc, name, append, max_matches, types); + + if (retval == 0) + { + const char *stripped = StripTypeName(name.GetCString()); + return FindTypes_Impl(sc, ConstString(stripped), append, max_matches, types); + } + else + return retval; + +} + //uint32_t //Module::FindTypes(const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, const char *udt_name, TypeList& types) //{ Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Fri Jul 29 14:53:35 2011 @@ -389,7 +389,7 @@ uint32_t -ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) +ModuleList::FindTypes_Impl (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) { Mutex::Locker locker(m_modules_mutex); @@ -409,6 +409,40 @@ return total_matches; } +// depending on implementation details, type lookup might fail because of +// embedded spurious namespace:: prefixes. this call strips them, paying +// attention to the fact that a type might have namespace'd type names as +// arguments to templates, and those must not be stripped off +static const char* +StripTypeName(const char* name_cstr) +{ + const char* skip_namespace = strstr(name_cstr, "::"); + const char* template_arg_char = strchr(name_cstr, '<'); + while (skip_namespace != NULL) + { + if (template_arg_char != NULL && + skip_namespace > template_arg_char) // but namespace'd template arguments are still good to go + break; + name_cstr = skip_namespace+2; + skip_namespace = strstr(name_cstr, "::"); + } + return name_cstr; +} + +uint32_t +ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) +{ + uint32_t retval = FindTypes_Impl(sc, name, append, max_matches, types); + + if (retval == 0) + { + const char *stripped = StripTypeName(name.GetCString()); + return FindTypes_Impl(sc, ConstString(stripped), append, max_matches, types); + } + else + return retval; + +} ModuleSP ModuleList::FindFirstModuleForFileSpec (const FileSpec &file_spec, Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Jul 29 14:53:35 2011 @@ -20,6 +20,7 @@ // Project includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Debugger.h" +#include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectChild.h" #include "lldb/Core/ValueObjectConstResult.h" @@ -89,6 +90,7 @@ m_is_array_item_for_pointer(false), m_is_bitfield_for_scalar(false), m_is_expression_path_child(false), + m_is_child_at_offset(false), m_dump_printable_counter(0) { m_manager->ManageObject(this); @@ -132,6 +134,7 @@ m_is_array_item_for_pointer(false), m_is_bitfield_for_scalar(false), m_is_expression_path_child(false), + m_is_child_at_offset(false), m_dump_printable_counter(0) { m_manager = new ValueObjectManager(); @@ -203,9 +206,12 @@ void ValueObject::UpdateFormatsIfNeeded() { - /*printf("CHECKING FOR UPDATES. I am at revision %d, while the format manager is at revision %d\n", + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); + if (log) + 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::ValueFormats::GetCurrentRevision());*/ + Debugger::Formatting::ValueFormats::GetCurrentRevision()); if (HasCustomSummaryFormat() && m_update_point.GetUpdateID() != m_user_id_of_forced_summary) { ClearCustomSummaryFormat(); @@ -441,12 +447,6 @@ } void -ValueObject::SetName (const char *name) -{ - m_name.SetCString(name); -} - -void ValueObject::SetName (const ConstString &name) { m_name = name; @@ -640,7 +640,11 @@ if (exe_scope) { Target *target = exe_scope->CalculateTarget(); - if (target != NULL) + if (target == NULL) + { + s << ""; + } + else { lldb::addr_t cstr_address = LLDB_INVALID_ADDRESS; AddressType cstr_address_type = eAddressTypeInvalid; @@ -663,7 +667,11 @@ // We have a pointer cstr_address = GetPointerValue (cstr_address_type, true); } - if (cstr_address != LLDB_INVALID_ADDRESS) + if (cstr_address == LLDB_INVALID_ADDRESS) + { + s << ""; + } + else { Address cstr_so_addr (NULL, cstr_address); DataExtractor data; @@ -695,6 +703,8 @@ s << "..."; s << '"'; } + else + s << "\"\""; } else { @@ -706,6 +716,8 @@ s << '"'; + bool any_data = false; + data.SetData (&data_buffer.front(), data_buffer.size(), endian::InlHostByteOrder()); while ((bytes_read = target->ReadMemory (cstr_so_addr, prefer_file_cache, @@ -713,6 +725,7 @@ k_max_buf_size, error)) > 0) { + any_data = true; size_t len = strlen(&data_buffer.front()); if (len == 0) break; @@ -741,6 +754,10 @@ cstr_len -= len; cstr_so_addr.Slide (k_max_buf_size); } + + if (any_data == false) + s << ""; + s << '"'; } } @@ -750,6 +767,7 @@ else { error.SetErrorString("impossible to read a string from this object"); + s << ""; } } @@ -1350,7 +1368,7 @@ { AddSyntheticChild(index_const_str, synthetic_child); synthetic_child_sp = synthetic_child->GetSP(); - synthetic_child_sp->SetName(index_str); + synthetic_child_sp->SetName(ConstString(index_str)); synthetic_child_sp->m_is_array_item_for_pointer = true; } } @@ -1393,7 +1411,7 @@ { AddSyntheticChild(index_const_str, synthetic_child); synthetic_child_sp = synthetic_child->GetSP(); - synthetic_child_sp->SetName(index_str); + synthetic_child_sp->SetName(ConstString(index_str)); synthetic_child_sp->m_is_array_item_for_pointer = true; } } @@ -1434,7 +1452,7 @@ { AddSyntheticChild(index_const_str, synthetic_child); synthetic_child_sp = synthetic_child->GetSP(); - synthetic_child_sp->SetName(index_str); + synthetic_child_sp->SetName(ConstString(index_str)); synthetic_child_sp->m_is_bitfield_for_scalar = true; } } @@ -1442,6 +1460,46 @@ return synthetic_child_sp; } +lldb::ValueObjectSP +ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create) +{ + + ValueObjectSP synthetic_child_sp; + + char name_str[64]; + snprintf(name_str, sizeof(name_str), "@%i", offset); + ConstString name_const_str(name_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 (name_const_str); + + if (synthetic_child_sp.get()) + return synthetic_child_sp; + + if (!can_create) + return lldb::ValueObjectSP(); + + ValueObjectChild *synthetic_child = new ValueObjectChild(*this, + type.GetASTContext(), + type.GetOpaqueQualType(), + name_const_str, + type.GetTypeByteSize(), + offset, + 0, + 0, + false, + false); + if (synthetic_child) + { + AddSyntheticChild(name_const_str, synthetic_child); + synthetic_child_sp = synthetic_child->GetSP(); + synthetic_child_sp->SetName(name_const_str); + synthetic_child_sp->m_is_child_at_offset = true; + } + return synthetic_child_sp; +} + // your expression path needs to have a leading . or -> // (unless it somehow "looks like" an array, in which case it has // a leading [ symbol). while the [ is meaningful and should be shown @@ -1477,7 +1535,7 @@ if (synthetic_child_sp.get()) { AddSyntheticChild(name_const_string, synthetic_child_sp.get()); - synthetic_child_sp->SetName(SkipLeadingExpressionPathSeparators(expression)); + synthetic_child_sp->SetName(ConstString(SkipLeadingExpressionPathSeparators(expression))); synthetic_child_sp->m_is_expression_path_child = true; } } @@ -1508,7 +1566,7 @@ if (!m_dynamic_value && !IsDynamic()) { - Process *process = m_update_point.GetProcess(); + Process *process = m_update_point.GetProcessSP().get(); bool worth_having_dynamic_value = false; Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original) +++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Fri Jul 29 14:53:35 2011 @@ -40,7 +40,7 @@ m_type_sp(), m_use_dynamic (use_dynamic) { - SetName (parent.GetName().AsCString()); + SetName (parent.GetName()); } ValueObjectDynamicValue::~ValueObjectDynamicValue() @@ -134,7 +134,7 @@ } // First make sure our Type and/or Address haven't changed: - Process *process = m_update_point.GetProcess(); + Process *process = m_update_point.GetProcessSP().get(); if (!process) return false; @@ -201,7 +201,7 @@ // We've moved, so we should be fine... m_address = dynamic_address; - lldb::addr_t load_address = m_address.GetLoadAddress(m_update_point.GetTarget()); + lldb::addr_t load_address = m_address.GetLoadAddress(m_update_point.GetTargetSP().get()); m_value.GetScalar() = load_address; } Modified: lldb/trunk/source/Core/ValueObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectMemory.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectMemory.cpp (original) +++ lldb/trunk/source/Core/ValueObjectMemory.cpp Fri Jul 29 14:53:35 2011 @@ -62,9 +62,9 @@ { // Do not attempt to construct one of these objects with no variable! assert (m_type_sp.get() != NULL); - SetName (name); + SetName (ConstString(name)); m_value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get()); - lldb::addr_t load_address = m_address.GetLoadAddress(m_update_point.GetTarget()); + lldb::addr_t load_address = m_address.GetLoadAddress(m_update_point.GetTargetSP().get()); if (load_address != LLDB_INVALID_ADDRESS) { m_value.SetValueType(Value::eValueTypeLoadAddress); @@ -99,9 +99,9 @@ assert (m_clang_type.GetASTContext()); assert (m_clang_type.GetOpaqueQualType()); - SetName (name); + SetName (ConstString(name)); m_value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType()); - lldb::addr_t load_address = m_address.GetLoadAddress(m_update_point.GetTarget()); + lldb::addr_t load_address = m_address.GetLoadAddress(m_update_point.GetTargetSP().get()); if (load_address != LLDB_INVALID_ADDRESS) { m_value.SetValueType(Value::eValueTypeLoadAddress); Modified: lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp (original) +++ lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp Fri Jul 29 14:53:35 2011 @@ -44,7 +44,7 @@ m_children_byindex(), m_name_toindex() { - SetName (parent.GetName().AsCString()); + SetName (parent.GetName()); } ValueObjectSynthetic::~ValueObjectSynthetic() @@ -120,6 +120,10 @@ m_children_byindex.clear(); m_name_toindex.clear(); + // let our backend do its update + + m_synth_filter->Update(); + SetValueIsValid(true); return true; } Modified: lldb/trunk/source/Interpreter/ScriptInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreter.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreter.cpp Fri Jul 29 14:53:35 2011 @@ -98,7 +98,8 @@ SWIGPythonCalculateNumChildren python_swig_calc_children, SWIGPythonGetChildAtIndex python_swig_get_child_index, SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, - SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue) + SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, + SWIGPythonUpdateSynthProviderInstance python_swig_update_provider) { ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback, python_swig_breakpoint_callback, @@ -107,7 +108,8 @@ python_swig_calc_children, python_swig_get_child_index, python_swig_get_index_child, - python_swig_cast_to_sbvalue); + python_swig_cast_to_sbvalue, + python_swig_update_provider); } void Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Jul 29 14:53:35 2011 @@ -40,6 +40,7 @@ static ScriptInterpreter::SWIGPythonGetChildAtIndex g_swig_get_child_index = NULL; 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 int _check_and_flush (FILE *stream) @@ -1307,7 +1308,7 @@ if (!valobj.get()) return NULL; - Target *target = valobj->GetUpdatePoint().GetTarget(); + Target *target = valobj->GetUpdatePoint().GetTargetSP().get(); if (!target) return NULL; @@ -1430,7 +1431,7 @@ if (!valobj.get()) return ""; - Target *target = valobj->GetUpdatePoint().GetTarget(); + Target *target = valobj->GetUpdatePoint().GetTargetSP().get(); if (!target) return ""; @@ -1768,6 +1769,38 @@ return ret_val; } +void +ScriptInterpreterPython::UpdateSynthProviderInstance (void* implementor) +{ + if (!implementor) + return; + + if (!g_swig_update_provider) + return; + + ScriptInterpreterPython *python_interpreter = this; + + FILE *tmp_fh = (python_interpreter->m_dbg_stdout ? python_interpreter->m_dbg_stdout : stdout); + if (CurrentThreadHasPythonLock()) + { + python_interpreter->EnterSession (); + g_swig_update_provider (implementor); + python_interpreter->LeaveSession (); + } + else + { + while (!GetPythonLock (1)) + fprintf (tmp_fh, + "Python interpreter locked on another thread; waiting to acquire lock...\n"); + python_interpreter->EnterSession (); + g_swig_update_provider (implementor); + python_interpreter->LeaveSession (); + ReleasePythonLock (); + } + + return; +} + lldb::SBValue* ScriptInterpreterPython::CastPyObjectToSBValue (void* data) { @@ -1811,7 +1844,8 @@ SWIGPythonCalculateNumChildren python_swig_calc_children, SWIGPythonGetChildAtIndex python_swig_get_child_index, SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, - SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue) + SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, + SWIGPythonUpdateSynthProviderInstance python_swig_update_provider) { g_swig_init_callback = python_swig_init_callback; g_swig_breakpoint_callback = python_swig_breakpoint_callback; @@ -1821,6 +1855,7 @@ g_swig_get_child_index = python_swig_get_child_index; 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; } void Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Fri Jul 29 14:53:35 2011 @@ -66,8 +66,8 @@ if (original_ptr == LLDB_INVALID_ADDRESS) return false; - Target *target = in_value.GetUpdatePoint().GetTarget(); - Process *process = in_value.GetUpdatePoint().GetProcess(); + Target *target = in_value.GetUpdatePoint().GetTargetSP().get(); + Process *process = in_value.GetUpdatePoint().GetProcessSP().get(); char memory_buffer[16]; DataExtractor data(memory_buffer, sizeof(memory_buffer), 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=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Fri Jul 29 14:53:35 2011 @@ -235,7 +235,7 @@ Address &address) { // The Runtime is attached to a particular process, you shouldn't pass in a value from another process. - assert (in_value.GetUpdatePoint().GetProcess() == m_process); + assert (in_value.GetUpdatePoint().GetProcessSP().get() == m_process); // Make sure we can have a dynamic value before starting... if (CouldHaveDynamicValue (in_value)) Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Jul 29 14:53:35 2011 @@ -2725,7 +2725,7 @@ ObjCLanguageRuntime *objc_runtime = exe_ctx->process->GetObjCLanguageRuntime(); if (objc_runtime != NULL) { - ClangASTType parent_ast_type (parent_qual_type.getAsOpaquePtr(), ast); + ClangASTType parent_ast_type (ast, parent_qual_type.getAsOpaquePtr()); child_byte_offset = objc_runtime->GetByteOffsetForIvar (parent_ast_type, ivar_decl->getNameAsString().c_str()); } } Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Jul 29 14:53:35 2011 @@ -63,7 +63,7 @@ } // There is no call to a clang type to get the type name without the - // class/struct/union on the front, so lets strip it here + // class/struct/union/enum on the front, so lets strip it here const char *type_name_cstr = type_name.c_str(); if (type_name_cstr[0] == 'c' && type_name_cstr[1] == 'l' && @@ -93,6 +93,15 @@ { type_name.erase (0, 6); } + else if (type_name_cstr[0] == 'e' && + type_name_cstr[1] == 'n' && + type_name_cstr[2] == 'u' && + type_name_cstr[3] == 'm' && + type_name_cstr[4] == ' ') + { + type_name.erase (0, 5); + } + return type_name; } @@ -943,8 +952,11 @@ uint32_t ClangASTType::GetClangTypeBitWidth (clang::ASTContext *ast_context, clang_type_t clang_type) { - if (ast_context && clang_type) - return ast_context->getTypeSize(clang::QualType::getFromOpaquePtr(clang_type)); + if (ClangASTContext::GetCompleteType (ast_context, clang_type)) + { + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); + return ast_context->getTypeSize (qual_type); + } return 0; } @@ -957,7 +969,7 @@ size_t ClangASTType::GetTypeBitAlign (clang::ASTContext *ast_context, clang_type_t clang_type) { - if (ast_context && clang_type) + if (ClangASTContext::GetCompleteType (ast_context, clang_type)) return ast_context->getTypeAlign(clang::QualType::getFromOpaquePtr(clang_type)); return 0; } @@ -1362,7 +1374,7 @@ } uint32_t -ClangASTType::GetTypeByteSize() +ClangASTType::GetTypeByteSize() const { return GetTypeByteSize(m_ast, m_type); @@ -1379,7 +1391,7 @@ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); return (ast_context->getTypeSize (qual_type) + 7) / 8; } - return UINT32_MAX; + return 0; } Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Fri Jul 29 14:53:35 2011 @@ -730,3 +730,44 @@ else return true; } + +TypeImpl::TypeImpl(const lldb_private::ClangASTType& type) : +m_clang_ast_type(new ClangASTType(type.GetASTContext(), + type.GetOpaqueQualType())), +m_lldb_type(lldb::TypeSP()) +{} + +TypeImpl::TypeImpl(lldb::TypeSP type) : +m_clang_ast_type(new ClangASTType(type->GetClangAST(), + type->GetClangFullType())), +m_lldb_type(type) +{} + +TypeImpl& +TypeImpl::operator = (const TypeImpl& rhs) +{ + if (*this != rhs) + { + m_clang_ast_type = std::auto_ptr(rhs.m_clang_ast_type.get()); + m_lldb_type = lldb::TypeSP(rhs.m_lldb_type); + } + return *this; +} + +clang::ASTContext* +TypeImpl::GetASTContext() +{ + if (!IsValid()) + return NULL; + + return m_clang_ast_type->GetASTContext(); +} + +lldb::clang_type_t +TypeImpl::GetOpaqueQualType() +{ + if (!IsValid()) + return NULL; + + return m_clang_ast_type->GetOpaqueQualType(); +} Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py?rev=136504&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py (added) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py Fri Jul 29 14:53:35 2011 @@ -0,0 +1,61 @@ +import re +class StdListSynthProvider: + def __init__(self, valobj, dict): + self.valobj = valobj; + self.update() + def num_children(self): + next_val = int(self.Mnext.GetValue(),0) + prev_val = int(self.Mprev.GetValue(),0) + if next_val == 0: + return 0; + if next_val == self.Mnode_address: + return 0; + if next_val == prev_val: + return 1; + size = 2 + current = self.Mnext + while int(current.GetChildMemberWithName('_M_next').GetValue(),0) != self.Mnode_address: + size = size + 1; + current = current.GetChildMemberWithName('_M_next') + return (size - 1) + def get_child_index(self,name): + if name == "len": + return self.num_children(); + else: + return int(name.lstrip('[').rstrip(']')) + def get_child_at_index(self,index): + if index == self.num_children(): + return self.valobj.CreateValueFromExpression("len",str(self.num_children())) + else: + offset = index + current = self.Mnext; + 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): + self.Mimpl = self.valobj.GetChildMemberWithName('_M_impl') + self.Mnode = self.Mimpl.GetChildMemberWithName('_M_node') + self.extract_type_name(self.Mimpl.GetType().GetName()) + self.Mnode_address = int(self.valobj.AddressOf().GetValue(), 0) + self.Mnext = self.Mnode.GetChildMemberWithName('_M_next') + self.Mprev = self.Mnode.GetChildMemberWithName('_M_prev') + self.data_type = self.Mnode.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 = self.Mnode.GetTarget().FindFirstType(self.type_name_nospaces) + self.data_size = self.data_type.GetByteSize() Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdMapSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdMapSynthProvider.py?rev=136504&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdMapSynthProvider.py (added) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdMapSynthProvider.py Fri Jul 29 14:53:35 2011 @@ -0,0 +1,103 @@ +import re +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 int(self.Mimpl.GetChildMemberWithName('_M_node_count').GetValue(), 0); + def get_child_index(self,name): + if name == "len": + return self.num_children(); + else: + return int(name.lstrip('[').rstrip(']')) + def get_child_at_index(self,index): + if index == self.num_children(): + return self.valobj.CreateValueFromExpression("len",str(self.num_children())) + else: + 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 int(node.GetValue(),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; + Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py?rev=136504&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py (added) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py Fri Jul 29 14:53:35 2011 @@ -0,0 +1,25 @@ +class StdVectorSynthProvider: + def __init__(self, valobj, dict): + self.valobj = valobj; + self.update() + def num_children(self): + start_val = int(self.Mstart.GetValue(),0) + finish_val = int(self.Mfinish.GetValue(),0) + return (finish_val-start_val)/self.data_size + def get_child_index(self,name): + if name == "len": + return self.num_children(); + else: + return int(name.lstrip('[').rstrip(']')) + def get_child_at_index(self,index): + if index == self.num_children(): + return self.valobj.CreateValueFromExpression("len",str(self.num_children())) + else: + offset = index * self.data_size + return self.Mstart.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) + def update(self): + self.Mimpl = self.valobj.GetChildMemberWithName('_M_impl') + self.Mstart = self.Mimpl.GetChildMemberWithName('_M_start') + self.Mfinish = self.Mimpl.GetChildMemberWithName('_M_finish') + self.data_type = self.Mstart.GetType().GetPointeeType() + self.data_size = self.data_type.GetByteSize() 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=136504&r1=136503&r2=136504&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 Fri Jul 29 14:53:35 2011 @@ -64,9 +64,10 @@ self.runCmd("script from fooSynthProvider import *") self.runCmd("type synth add -l fooSynthProvider foo") - # check that we get only the two variables + # check that we get the two real vars and the fake_a variables self.expect("frame variable f00_1", substrs = ['r = 33', + 'fake_a = 16777216', 'a = 0']); # check that we do not get the extra vars and that we cache results @@ -79,15 +80,389 @@ self.expect("frame variable f00_1", substrs = ['r = 33', + 'fake_a = 16777216', 'a = 1']); + # check that altering the object also alters fake_a + self.runCmd("expr f00_1.a = 280") + self.expect("frame variable f00_1", + substrs = ['r = 33', + 'fake_a = 16777217', + 'a = 280']); + + # check that expanding a pointer does the right thing + self.expect("frame variable -P 1 f00_ptr", + substrs = ['r = 45', + 'fake_a = 218103808', + 'a = 12']) + # delete the synth and check that we get good output self.runCmd("type synth delete foo") self.expect("frame variable f00_1", - substrs = ['a = 1', + substrs = ['a = 280', 'b = 1', 'r = 33']); + self.expect("frame variable f00_1", matching=False, + substrs = ['fake_a = ']) + + self.runCmd("n") + + self.runCmd("script from ftsp import *") + self.runCmd("type synth add -l ftsp wrapint") + + self.expect('frame variable test_cast', + substrs = ['A', + 'B', + 'C', + 'D']) + + # now start playing with STL containers + # having std:: here is a workaround for rdar://problem/9835692 + + + # 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("n") + + # empty vectors (and storage pointers SHOULD BOTH BE NULL..) + self.expect("frame variable numbers", + substrs = ['numbers = {}']) + + self.runCmd("n") + + # first value added + self.expect("frame variable numbers", + substrs = ['numbers = {', + '[0] = 1', + '}']) + + # add some more data + self.runCmd("n");self.runCmd("n");self.runCmd("n"); + + self.expect("frame variable numbers", + substrs = ['numbers = {', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) + + # add some more data + self.runCmd("n");self.runCmd("n");self.runCmd("n"); + + self.expect("frame variable numbers", + substrs = ['numbers = {', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) + + # clear out the vector and see that we do the right thing once again + self.runCmd("n") + + self.expect("frame variable numbers", + substrs = ['numbers = {}']) + + self.runCmd("n") + + # first value added + self.expect("frame variable numbers", + substrs = ['numbers = {', + '[0] = 7', + '}']) + + # check if we can display strings + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") + + self.expect("frame variable strings", + substrs = ['goofy', + 'is', + 'smart']) + + # test summaries based on synthetic children + self.runCmd("type summary add std::string_vect string_vect -f \"vector has ${svar.len} items\" -e") + self.expect("frame variable strings", + substrs = ['vector has 3 items', + 'goofy', + 'is', + 'smart']) + + self.runCmd("n"); + + self.expect("frame variable strings", + substrs = ['vector has 4 items']) + + self.runCmd("n") + + self.expect("frame variable strings", + substrs = ['vector has 0 items']) + + # now test std::list + 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 summary add std::int_list std::string_list int_list string_list -f \"list has ${svar.len} items\" -e") + self.runCmd("type format add -f hex int") + + self.expect("frame variable numbers_list", + substrs = ['list has 0x00000000 items', + '{}']) + + self.runCmd("n") + + self.expect("frame variable numbers_list", + substrs = ['list has 0x00000001 items', + '[0] = ', + '0x12345678']) + + self.runCmd("n");self.runCmd("n");self.runCmd("n"); + + self.expect("frame variable numbers_list", + substrs = ['list has 0x00000004 items', + '[0] = ', + '0x12345678', + '[1] =', + '0x11223344', + '[2] =', + '0xbeeffeed', + '[3] =', + '0x00abba00']) + + self.runCmd("n");self.runCmd("n"); + + self.expect("frame variable numbers_list", + substrs = ['list has 0x00000006 items', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) + + self.runCmd("n") + + self.expect("frame variable numbers_list", + substrs = ['list has 0x00000000 items', + '{}']) + + + self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); + + self.expect("frame variable numbers_list", + substrs = ['list has 0x00000004 items', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) + + self.runCmd("type format delete int") + + self.runCmd("n") + + self.expect("frame variable text_list", + substrs = ['list has 0 items', + '{}']) + + self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); + + self.expect("frame variable text_list", + substrs = ['list has 4 items', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart', + '[3]', '!!!']) + + # let's prettify string display + self.runCmd("type summary add -f \"${var._M_dataplus._M_p}\" std::string std::basic_string \"std::basic_string,std::allocator >\"") + + self.expect("frame variable text_list", + substrs = ['list has 4 items', + '[0] = \"goofy\"', + '[1] = \"is\"', + '[2] = \"smart\"', + '[3] = \"!!!\"']) + + # now std::map + + self.runCmd("n") + self.runCmd("frame variable ii -T") + + self.runCmd("script from StdMapSynthProvider import *") + self.runCmd("type summary add std::intint_map intint_map -f \"map has ${svar.len} items\" -e") + self.runCmd("type synth add std::intint_map intint_map -l StdMapSynthProvider") + + + self.expect('frame variable ii', + substrs = ['map has 0 items', + '{}']) + + self.runCmd("n");self.runCmd("n"); + + self.expect('frame variable ii', + substrs = ['map has 2 items', + '[0] = {', + 'first = 0', + 'second = 0', + '[1] = {', + 'first = 1', + 'second = 1']) + + self.runCmd("n");self.runCmd("n"); + + self.expect('frame variable ii', + substrs = ['map has 4 items', + '[2] = {', + 'first = 2', + 'second = 0', + '[3] = {', + 'first = 3', + 'second = 1']) + + self.runCmd("n");self.runCmd("n"); + self.runCmd("n");self.runCmd("n");self.runCmd("n"); + + self.expect('frame variable ii', + substrs = ['map has 9 items', + '[5] = {', + 'first = 5', + 'second = 0', + '[7] = {', + 'first = 7', + 'second = 1']) + + self.runCmd("n") + + self.expect('frame variable ii', + substrs = ['map has 0 items', + '{}']) + + self.runCmd("n") + self.runCmd("frame variable si -T") + + self.runCmd("type summary add std::strint_map strint_map -f \"map has ${svar.len} items\" -e") + self.runCmd("type synth add std::strint_map strint_map -l StdMapSynthProvider") + + self.expect('frame variable si', + substrs = ['map has 0 items', + '{}']) + + self.runCmd("n") + + self.expect('frame variable si', + substrs = ['map has 1 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0']) + + self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); + + self.expect('frame variable si', + substrs = ['map has 5 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3', + '[4] = ', + 'first = \"four\"', + 'second = 4']) + + self.runCmd("n") + + self.expect('frame variable si', + substrs = ['map has 0 items', + '{}']) + + self.runCmd("n") + self.runCmd("frame variable is -T") + + self.runCmd("type summary add std::intstr_map intstr_map -f \"map has ${svar.len} items\" -e") + self.runCmd("type synth add std::intstr_map intstr_map -l StdMapSynthProvider") + + self.expect('frame variable is', + substrs = ['map has 0 items', + '{}']) + + self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); + + self.expect('frame variable is', + substrs = ['map has 4 items', + '[0] = ', + 'second = \"goofy\"', + 'first = 0', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) + + self.runCmd("n") + + self.expect('frame variable is', + substrs = ['map has 0 items', + '{}']) + + self.runCmd("n") + self.runCmd("frame variable ss -T") + + self.runCmd("type summary add std::strstr_map strstr_map -f \"map has ${svar.len} items\" -e") + self.runCmd("type synth add std::strstr_map strstr_map -l StdMapSynthProvider") + + self.expect('frame variable ss', + substrs = ['map has 0 items', + '{}']) + + self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); + + self.expect('frame variable ss', + substrs = ['map has 4 items', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"', + '[3] = ', + 'second = \"..is always a Mac!\"', + 'first = \"a Mac..\"']) + + self.runCmd("n") + + self.expect('frame variable ss', + substrs = ['map has 0 items', + '{}']) + if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py Fri Jul 29 14:53:35 2011 @@ -1,16 +1,21 @@ +import lldb class fooSynthProvider: def __init__(self, valobj, dict): self.valobj = valobj; + self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt) def num_children(self): - return 2; + return 3; def get_child_at_index(self, index): - if index == 1: + if index == 0: child = self.valobj.GetChildMemberWithName('a'); - else: + if index == 1: + child = self.valobj.CreateChildAtOffset ('fake_a', 1, self.int_type); + if index == 2: child = self.valobj.GetChildMemberWithName('r'); return child; def get_child_index(self, name): if name == 'a': - return 1; - else: return 0; + if name == 'fake_a': + return 1; + return 2; Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py?rev=136504&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py (added) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/ftsp.py Fri Jul 29 14:53:35 2011 @@ -0,0 +1,20 @@ +import lldb +class ftsp: + def __init__(self, valobj, dict): + self.valobj = valobj; + self.update() + def num_children(self): + if self.char.IsValid(): + return 4; + return 0; + def get_child_index(self,name): + return 0; + def get_child_at_index(self,index): + if index == 0: + return self.x.Cast(self.char) + return self.x.CreateChildAtOffset(str(index), + index, + self.char); + def update(self): + self.x = self.valobj.GetChildMemberWithName('x'); + self.char = self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp Fri Jul 29 14:53:35 2011 @@ -1,3 +1,18 @@ +#include +#include +#include +#include +typedef std::vector int_vect; +typedef std::vector string_vect; + +typedef std::list int_list; +typedef std::list string_list; + +typedef std::map intint_map; +typedef std::map strint_map; +typedef std::map intstr_map; +typedef std::map strstr_map; + struct foo { int a; @@ -40,14 +55,110 @@ r(X+33) {} }; +struct wrapint +{ + int x; + wrapint(int X) : x(X) {} +}; + int main() { foo f00_1(0); - foo f00_2(6); - foo *f00_3 = new foo(12); - foo& f00_4 = *(new foo(18)); + foo *f00_ptr = new foo(12); f00_1.a++; // Set break point at this line. + wrapint test_cast('A' + + 256*'B' + + 256*256*'C'+ + 256*256*256*'D'); + + int_vect numbers; + numbers.push_back(1); + numbers.push_back(12); + numbers.push_back(123); + numbers.push_back(1234); + numbers.push_back(12345); + numbers.push_back(123456); + numbers.push_back(1234567); + + numbers.clear(); + + numbers.push_back(7); + + string_vect strings; + strings.push_back(std::string("goofy")); + strings.push_back(std::string("is")); + strings.push_back(std::string("smart")); + + strings.push_back(std::string("!!!")); + + strings.clear(); + + int_list numbers_list; + + numbers_list.push_back(0x12345678); + numbers_list.push_back(0x11223344); + numbers_list.push_back(0xBEEFFEED); + numbers_list.push_back(0x00ABBA00); + numbers_list.push_back(0x0ABCDEF0); + numbers_list.push_back(0x0CAB0CAB); + + numbers_list.clear(); + + numbers_list.push_back(1); + numbers_list.push_back(2); + numbers_list.push_back(3); + numbers_list.push_back(4); + + string_list text_list; + text_list.push_back(std::string("goofy")); + text_list.push_back(std::string("is")); + text_list.push_back(std::string("smart")); + + text_list.push_back(std::string("!!!")); + + intint_map ii; + + ii[0] = 0; + ii[1] = 1; + ii[2] = 0; + ii[3] = 1; + ii[4] = 0; + ii[5] = 1; + ii[6] = 0; + ii[7] = 1; + ii[8] = 0; + + ii.clear(); + + strint_map si; + + si["zero"] = 0; + si["one"] = 1; + si["two"] = 2; + si["three"] = 3; + si["four"] = 4; + + si.clear(); + + intstr_map is; + + is[0] = "goofy"; + is[1] = "is"; + is[2] = "smart"; + is[3] = "!!!"; + + is.clear(); + + strstr_map ss; + + ss["ciao"] = "hello"; + ss["casa"] = "house"; + ss["gatto"] = "cat"; + ss["a Mac.."] = "..is always a Mac!"; + + ss.clear(); + return 0; } \ No newline at end of file Modified: lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py?rev=136504&r1=136503&r2=136504&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py (original) +++ lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py Fri Jul 29 14:53:35 2011 @@ -294,6 +294,7 @@ sb_thread.fuzz_obj(obj) @python_api_test + @unittest2.expectedFailure def test_SBType(self): obj = lldb.SBType() if self.TraceOn(): @@ -304,6 +305,7 @@ sb_type.fuzz_obj(obj) @python_api_test + @unittest2.expectedFailure def test_SBTypeMember(self): obj = lldb.SBTypeMember() if self.TraceOn(): From granata.enrico at gmail.com Fri Jul 29 16:31:47 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 29 Jul 2011 21:31:47 -0000 Subject: [Lldb-commits] [lldb] r136525 - in /lldb/trunk: examples/synthetic/CFString.py test/functionalities/data-formatter/data-formatter-objc/CFString.py test/functionalities/data-formatter/data-formatter-objc/Makefile test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py test/functionalities/data-formatter/data-formatter-objc/main.m Message-ID: <20110729213147.3021C2A6C12C@llvm.org> Author: enrico Date: Fri Jul 29 16:31:46 2011 New Revision: 136525 URL: http://llvm.org/viewvc/llvm-project?rev=136525&view=rev Log: new synthetic children provider for CFString and related classes ; test case for it Added: lldb/trunk/examples/synthetic/CFString.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/Makefile lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m Added: lldb/trunk/examples/synthetic/CFString.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/CFString.py?rev=136525&view=auto ============================================================================== --- lldb/trunk/examples/synthetic/CFString.py (added) +++ lldb/trunk/examples/synthetic/CFString.py Fri Jul 29 16:31:46 2011 @@ -0,0 +1,206 @@ +# synthetic children provider for CFString +# (and related NSString class) +import lldb +class CFStringSynthProvider: + def __init__(self,valobj,dict): + self.valobj = valobj; + self.update() + # children other than "content" are for debugging only and must not be used in production code + def num_children(self): + return 6; + def read_unicode(self, pointer): + process = self.valobj.GetTarget().GetProcess() + error = lldb.SBError() + pystr = u'' + # cannot do the read at once because the length value has + # a weird encoding. better play it safe here + while True: + content = process.ReadMemory(pointer, 2, error) + new_bytes = bytearray(content) + b0 = new_bytes[0] + b1 = new_bytes[1] + pointer = pointer + 2 + if b0 == 0 and b1 == 0: + break + # rearrange bytes depending on endianness + # (do we really need this or is Cocoa going to + # use Windows-compatible little-endian even + # if the target is big endian?) + if self.is_little: + value = b1 * 256 + b0 + else: + value = b0 * 256 + b1 + pystr = pystr + unichr(value) + return pystr + # handle the special case strings + # only use the custom code for the tested LP64 case + def handle_special(self): + if self.lp64 == False: + # for 32bit targets, use safe ObjC code + return self.handle_unicode_string_safe() + offset = 12 + pointer = int(self.valobj.GetValue(), 0) + offset + pystr = self.read_unicode(pointer) + return self.valobj.CreateValueFromExpression("content", + "(char*)\"" + pystr.encode('utf-8') + "\"") + # last resort call, use ObjC code to read; the final aim is to + # be able to strip this call away entirely and only do the read + # ourselves + def handle_unicode_string_safe(self): + return self.valobj.CreateValueFromExpression("content", + "(char*)\"" + self.valobj.GetObjectDescription() + "\""); + def handle_unicode_string(self): + # step 1: find offset + if self.inline: + pointer = int(self.valobj.GetValue(), 0) + self.size_of_cfruntime_base(); + if self.explicit == False: + # untested, use the safe code path + return self.handle_unicode_string_safe(); + else: + # not sure why 8 bytes are skipped here + # (lldb) mem read -c 50 0x00000001001154f0 + # 0x1001154f0: 98 1a 85 71 ff 7f 00 00 90 07 00 00 01 00 00 00 ...q?........... + # 0x100115500: 03 00 00 00 00 00 00 00 *c3 03 78 00 78 00 00 00 ........?.x.x... + # 0x100115510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + # 0x100115520: 00 00 .. + # content begins at * (i.e. 8 bytes into variants, skipping void* buffer in + # __notInlineImmutable1 entirely, while the length byte is correctly located + # for an inline string) + pointer = pointer + 8; + else: + pointer = int(self.valobj.GetValue(), 0) + self.size_of_cfruntime_base(); + # read 8 bytes here and make an address out of them + vopointer = self.valobj.CreateChildAtOffset("dummy", + pointer,self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar).GetPointerType()); + pointer = int(vopointer.GetValue(), 0) + # step 2: read Unicode data at pointer + pystr = self.read_unicode(pointer) + # step 3: return it + return self.valobj.CreateValueFromExpression("content", + "(char*)\"" + pystr.encode('utf-8') + "\"") + # we read at "the right place" into the __CFString object instead of running code + # we are replicating the functionality of __CFStrContents in CFString.c here + def handle_UTF8_inline(self): + offset = int(self.valobj.GetValue(), 0) + self.size_of_cfruntime_base(); + if self.explicit == False: + offset = offset + 1; + return self.valobj.CreateValueFromAddress("content", + offset, self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)); + def handle_UTF8_not_inline(self): + offset = self.size_of_cfruntime_base(); + return self.valobj.CreateChildAtOffset("content", + offset,self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar).GetPointerType()); + def get_child_at_index(self,index): + if index == 0: + return self.valobj.CreateValueFromExpression("mutable", + str(int(self.mutable))); + if index == 1: + return self.valobj.CreateValueFromExpression("inline", + str(int(self.inline))); + if index == 2: + return self.valobj.CreateValueFromExpression("explicit", + str(int(self.explicit))); + if index == 3: + return self.valobj.CreateValueFromExpression("unicode", + str(int(self.unicode))); + if index == 4: + return self.valobj.CreateValueFromExpression("special", + str(int(self.special))); + if index == 5: + if self.unicode == True: + return self.handle_unicode_string(); + elif self.special == True: + return self.handle_special(); + elif self.inline == True: + return self.handle_UTF8_inline(); + else: + return self.handle_UTF8_not_inline(); + def get_child_index(self,name): + if name == "content": + return self.num_children() - 1; + if name == "mutable": + return 0; + if name == "inline": + return 1; + if name == "explicit": + return 2; + if name == "unicode": + return 3; + if name == "special": + return 4; + def is_64bit(self): + if self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8: + return True; + else: + return False; + def is_little_endian(self): + # 4 is eByteOrderLittle + if self.valobj.GetTarget().GetProcess().GetByteOrder() == 4: + return True; + else: + return False; + # CFRuntimeBase is defined as having an additional + # 4 bytes (padding?) on LP64 architectures + # to get its size we add up sizeof(pointer)+4 + # and then add 4 more bytes if we are on a 64bit system + def size_of_cfruntime_base(self): + if self.lp64 == True: + return 8+4+4; + else: + return 4+4; + # the info bits are part of the CFRuntimeBase structure + # to get at them we have to skip a uintptr_t and then get + # at the least-significant byte of a 4 byte array. If we are + # on big-endian this means going to byte 3, if we are on + # little endian (OSX & iOS), this means reading byte 0 + def offset_of_info_bits(self): + if self.lp64 == True: + offset = 8; + else: + offset = 4; + if self.is_little == False: + offset = offset + 3; + return offset; + def read_info_bits(self): + cfinfo = self.valobj.CreateChildAtOffset("cfinfo", + self.offset_of_info_bits(), + self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)); + cfinfo.SetFormat(11) + info = cfinfo.GetValue(); + return int(info,0); + # calculating internal flag bits of the CFString object + # this stuff is defined and discussed in CFString.c + def is_mutable(self): + return (self.info_bits & 1) == 1; + def is_inline(self): + return (self.info_bits & 0x60) == 0; + # this flag's name is ambiguous, it turns out + # we must skip a length byte to get at the data + # when this flag is False + def has_explicit_length(self): + return (self.info_bits & (1 | 4)) != 4; + # probably a subclass of NSString. obtained this from [str pathExtension] + # here info_bits = 0 and Unicode data at the start of the padding word + # in the long run using the isa value might be safer as a way to identify this + # instead of reading the info_bits + def is_special_case(self): + return self.info_bits == 0; + def is_unicode(self): + return (self.info_bits & 0x10) == 0x10; + # preparing ourselves to read into memory + # by adjusting architecture-specific info + def adjust_for_architecture(self): + self.lp64 = self.is_64bit(); + self.is_little = self.is_little_endian(); + # reading info bits out of the CFString and computing + # useful values to get at the real data + def compute_flags(self): + self.info_bits = self.read_info_bits(); + self.mutable = self.is_mutable(); + self.inline = self.is_inline(); + self.explicit = self.has_explicit_length(); + self.unicode = self.is_unicode(); + self.special = self.is_special_case(); + def update(self): + self.adjust_for_architecture(); + self.compute_flags(); Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py?rev=136525&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py (added) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py Fri Jul 29 16:31:46 2011 @@ -0,0 +1,206 @@ +# synthetic children provider for CFString +# (and related NSString class) +import lldb +class CFStringSynthProvider: + def __init__(self,valobj,dict): + self.valobj = valobj; + self.update() + # children other than "content" are for debugging only and must not be used in production code + def num_children(self): + return 6; + def read_unicode(self, pointer): + process = self.valobj.GetTarget().GetProcess() + error = lldb.SBError() + pystr = u'' + # cannot do the read at once because the length value has + # a weird encoding. better play it safe here + while True: + content = process.ReadMemory(pointer, 2, error) + new_bytes = bytearray(content) + b0 = new_bytes[0] + b1 = new_bytes[1] + pointer = pointer + 2 + if b0 == 0 and b1 == 0: + break + # rearrange bytes depending on endianness + # (do we really need this or is Cocoa going to + # use Windows-compatible little-endian even + # if the target is big endian?) + if self.is_little: + value = b1 * 256 + b0 + else: + value = b0 * 256 + b1 + pystr = pystr + unichr(value) + return pystr + # handle the special case strings + # only use the custom code for the tested LP64 case + def handle_special(self): + if self.lp64 == False: + # for 32bit targets, use safe ObjC code + return self.handle_unicode_string_safe() + offset = 12 + pointer = int(self.valobj.GetValue(), 0) + offset + pystr = self.read_unicode(pointer) + return self.valobj.CreateValueFromExpression("content", + "(char*)\"" + pystr.encode('utf-8') + "\"") + # last resort call, use ObjC code to read; the final aim is to + # be able to strip this call away entirely and only do the read + # ourselves + def handle_unicode_string_safe(self): + return self.valobj.CreateValueFromExpression("content", + "(char*)\"" + self.valobj.GetObjectDescription() + "\""); + def handle_unicode_string(self): + # step 1: find offset + if self.inline: + pointer = int(self.valobj.GetValue(), 0) + self.size_of_cfruntime_base(); + if self.explicit == False: + # untested, use the safe code path + return self.handle_unicode_string_safe(); + else: + # not sure why 8 bytes are skipped here + # (lldb) mem read -c 50 0x00000001001154f0 + # 0x1001154f0: 98 1a 85 71 ff 7f 00 00 90 07 00 00 01 00 00 00 ...q?........... + # 0x100115500: 03 00 00 00 00 00 00 00 *c3 03 78 00 78 00 00 00 ........?.x.x... + # 0x100115510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ + # 0x100115520: 00 00 .. + # content begins at * (i.e. 8 bytes into variants, skipping void* buffer in + # __notInlineImmutable1 entirely, while the length byte is correctly located + # for an inline string) + pointer = pointer + 8; + else: + pointer = int(self.valobj.GetValue(), 0) + self.size_of_cfruntime_base(); + # read 8 bytes here and make an address out of them + vopointer = self.valobj.CreateChildAtOffset("dummy", + pointer,self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar).GetPointerType()); + pointer = int(vopointer.GetValue(), 0) + # step 2: read Unicode data at pointer + pystr = self.read_unicode(pointer) + # step 3: return it + return self.valobj.CreateValueFromExpression("content", + "(char*)\"" + pystr.encode('utf-8') + "\"") + # we read at "the right place" into the __CFString object instead of running code + # we are replicating the functionality of __CFStrContents in CFString.c here + def handle_UTF8_inline(self): + offset = int(self.valobj.GetValue(), 0) + self.size_of_cfruntime_base(); + if self.explicit == False: + offset = offset + 1; + return self.valobj.CreateValueFromAddress("content", + offset, self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)); + def handle_UTF8_not_inline(self): + offset = self.size_of_cfruntime_base(); + return self.valobj.CreateChildAtOffset("content", + offset,self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar).GetPointerType()); + def get_child_at_index(self,index): + if index == 0: + return self.valobj.CreateValueFromExpression("mutable", + str(int(self.mutable))); + if index == 1: + return self.valobj.CreateValueFromExpression("inline", + str(int(self.inline))); + if index == 2: + return self.valobj.CreateValueFromExpression("explicit", + str(int(self.explicit))); + if index == 3: + return self.valobj.CreateValueFromExpression("unicode", + str(int(self.unicode))); + if index == 4: + return self.valobj.CreateValueFromExpression("special", + str(int(self.special))); + if index == 5: + if self.unicode == True: + return self.handle_unicode_string(); + elif self.special == True: + return self.handle_special(); + elif self.inline == True: + return self.handle_UTF8_inline(); + else: + return self.handle_UTF8_not_inline(); + def get_child_index(self,name): + if name == "content": + return self.num_children() - 1; + if name == "mutable": + return 0; + if name == "inline": + return 1; + if name == "explicit": + return 2; + if name == "unicode": + return 3; + if name == "special": + return 4; + def is_64bit(self): + if self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8: + return True; + else: + return False; + def is_little_endian(self): + # 4 is eByteOrderLittle + if self.valobj.GetTarget().GetProcess().GetByteOrder() == 4: + return True; + else: + return False; + # CFRuntimeBase is defined as having an additional + # 4 bytes (padding?) on LP64 architectures + # to get its size we add up sizeof(pointer)+4 + # and then add 4 more bytes if we are on a 64bit system + def size_of_cfruntime_base(self): + if self.lp64 == True: + return 8+4+4; + else: + return 4+4; + # the info bits are part of the CFRuntimeBase structure + # to get at them we have to skip a uintptr_t and then get + # at the least-significant byte of a 4 byte array. If we are + # on big-endian this means going to byte 3, if we are on + # little endian (OSX & iOS), this means reading byte 0 + def offset_of_info_bits(self): + if self.lp64 == True: + offset = 8; + else: + offset = 4; + if self.is_little == False: + offset = offset + 3; + return offset; + def read_info_bits(self): + cfinfo = self.valobj.CreateChildAtOffset("cfinfo", + self.offset_of_info_bits(), + self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)); + cfinfo.SetFormat(11) + info = cfinfo.GetValue(); + return int(info,0); + # calculating internal flag bits of the CFString object + # this stuff is defined and discussed in CFString.c + def is_mutable(self): + return (self.info_bits & 1) == 1; + def is_inline(self): + return (self.info_bits & 0x60) == 0; + # this flag's name is ambiguous, it turns out + # we must skip a length byte to get at the data + # when this flag is False + def has_explicit_length(self): + return (self.info_bits & (1 | 4)) != 4; + # probably a subclass of NSString. obtained this from [str pathExtension] + # here info_bits = 0 and Unicode data at the start of the padding word + # in the long run using the isa value might be safer as a way to identify this + # instead of reading the info_bits + def is_special_case(self): + return self.info_bits == 0; + def is_unicode(self): + return (self.info_bits & 0x10) == 0x10; + # preparing ourselves to read into memory + # by adjusting architecture-specific info + def adjust_for_architecture(self): + self.lp64 = self.is_64bit(); + self.is_little = self.is_little_endian(); + # reading info bits out of the CFString and computing + # useful values to get at the real data + def compute_flags(self): + self.info_bits = self.read_info_bits(); + self.mutable = self.is_mutable(); + self.inline = self.is_inline(); + self.explicit = self.has_explicit_length(); + self.unicode = self.is_unicode(); + self.special = self.is_special_case(); + def update(self): + self.adjust_for_architecture(); + self.compute_flags(); Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/Makefile?rev=136525&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/Makefile (added) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/Makefile Fri Jul 29 16:31:46 2011 @@ -0,0 +1,7 @@ +LEVEL = ../../../make + +OBJC_SOURCES := main.m + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation Added: 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=136525&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (added) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Fri Jul 29 16:31:46 2011 @@ -0,0 +1,231 @@ +""" +Test lldb data formatter subsystem. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class DataFormatterTestCase(TestBase): + + mydir = os.path.join("functionalities", "data-formatter", "data-formatter-objc") + + @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.m', '// 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.m -l %d" % self.line, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.m', 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 format clear', check=False) + self.runCmd('type summary clear', check=False) + self.runCmd('type synth clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + self.runCmd("type summary add -f \"${var%@}\" MyClass") + + self.expect("frame variable object2", + substrs = ['MyOtherClass']); + + self.expect("frame variable *object2", + substrs = ['MyOtherClass']); + + # Now let's delete the 'MyClass' custom summary. + self.runCmd("type summary delete MyClass") + + # The type format list should not show 'MyClass' at this point. + self.expect("type summary list", matching=False, + substrs = ['MyClass']) + + self.runCmd("type summary add -f \"a test\" MyClass") + + self.expect("frame variable object2", + substrs = ['a test']); + + self.expect("frame variable *object2", + substrs = ['a test']); + + self.expect("frame variable object", + substrs = ['a test']); + + self.expect("frame variable *object", + substrs = ['a test']); + + self.runCmd("type summary add -f \"a test\" MyClass -C no") + + self.expect("frame variable *object2", + substrs = ['*object2 = {', + 'MyClass = a test', + 'backup = ']); + + self.expect("frame variable object2", matching=False, + substrs = ['a test']); + + self.expect("frame variable object", + substrs = ['a test']); + + self.expect("frame variable *object", + substrs = ['a test']); + + # Now check that the synth for CFString works + self.runCmd("script from CFString import *") + self.runCmd("type synth add -l CFStringSynthProvider NSString") + + self.expect('frame variable str -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + 'A rather short ASCII NSString object is here']) + + self.expect('frame variable str2 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + 'A rather short UTF8 NSString object is here']) + + self.expect('frame variable str3 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + 'A string made with the at sign is here']) + + self.expect('frame variable str4 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + 'This is string number 4 right here']) + + self.expect('frame variable str5 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + '{{1, 1}, {5, 5}}']) + + self.expect('frame variable str6 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + '1ST']) + + self.expect('frame variable str7 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + '\\xcf\\x83xx']) + + self.expect('frame variable str8 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + 'hasVeryLongExtensionThisTime']) + + self.expect('frame variable str9 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + 'a very much boring task to write a string this way!!\\xe4\\x8c\\xb3']) + + self.expect('frame variable str10 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + 'This is a Unicode string \\xcf\\x83 number 4 right here']) + + self.expect('frame variable str11 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + '__NSCFString']) + + self.expect('frame variable processName -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + 'a.out']) + + self.expect('frame variable str12 -P 1', + substrs = ['mutable =', + 'inline = ', + 'explicit = ', + 'content = ', + 'Process Name: a.out Process Id:']) + + # make it a summary + self.runCmd("type summary add -f \"${svar.content}\" NSString") + + self.expect('frame variable str', + substrs = ['A rather short ASCII NSString object is here']) + self.expect('frame variable str2', + substrs = ['A rather short UTF8 NSString object is here']) + self.expect('frame variable str3', + substrs = ['A string made with the at sign is here']) + self.expect('frame variable str4', + substrs = ['This is string number 4 right here']) + self.expect('frame variable str5', + substrs = ['{{1, 1}, {5, 5}}']) + self.expect('frame variable str6', + substrs = ['1ST']) + self.expect('frame variable str7', + substrs = ['\\xcf\\x83xx']) + self.expect('frame variable str8', + substrs = ['hasVeryLongExtensionThisTime']) + self.expect('frame variable str9', + substrs = ['a very much boring task to write a string this way!!\\xe4\\x8c\\xb3']) + self.expect('frame variable str10', + substrs = ['This is a Unicode string \\xcf\\x83 number 4 right here']) + self.expect('frame variable str11', + substrs = ['__NSCFString']) + self.expect('frame variable processName', + substrs = ['a.out']) + self.expect('frame variable str12', + substrs = ['Process Name: a.out Process Id:']) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m?rev=136525&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m (added) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m Fri Jul 29 16:31:46 2011 @@ -0,0 +1,124 @@ +//===-- main.m ------------------------------------------------*- ObjC -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#import + + at interface MyClass : NSObject +{ + int i; + char c; + float f; +} + +- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z; +- (int)doIncrementByInt: (int)x; + + at end + + at interface MyOtherClass : MyClass +{ + int i2; + MyClass *backup; +} +- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q; + + at end + + at implementation MyClass + +- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z +{ + self = [super init]; + if (self) { + self->i = x; + self->f = y; + self->c = z; + } + return self; +} + +- (int)doIncrementByInt: (int)x +{ + self->i += x; + return self->i; +} + + at end + + at implementation MyOtherClass + +- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q +{ + self = [super initWithInt:x andFloat:y andChar:z]; + if (self) { + self->i2 = q; + self->backup = [[MyClass alloc] initWithInt:x andFloat:y andChar:z]; + } + return self; +} + + at end + +int main (int argc, const char * argv[]) +{ + + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + MyClass *object = [[MyClass alloc] initWithInt:1 andFloat:3.14 andChar: 'E']; + + [object doIncrementByInt:3]; + + MyOtherClass *object2 = [[MyOtherClass alloc] initWithInt:2 andFloat:6.28 andChar: 'G' andOtherInt:-1]; + + [object2 doIncrementByInt:3]; + + NSString *str = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding]; + + NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"]; + + NSString *str3 = @"A string made with the at sign is here"; + + NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; + + NSRect rect = NSMakeRect(1,1,5,5); + + NSString* str5 = NSStringFromRect(rect); + + NSString* str6 = [@"/usr/doc/README.1ST" pathExtension]; + + const unichar myCharacters[] = {0x03C3,'x','x'}; + NSString *str7 = [NSString stringWithCharacters: myCharacters + length: sizeof myCharacters / sizeof *myCharacters]; + + NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension]; + + const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ', + 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k', + ' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', + 't','h','i','s',' ','w','a','y','!','!','0x03C3'}; + NSString *str9 = [NSString stringWithCharacters: myOtherCharacters + length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; + + const unichar myNextCharacters[] = {0x03C3, 0x0000}; + + NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4]; + + NSString *str11 = [str10 className]; + + NSString *label1 = @"Process Name: "; + NSString *label2 = @"Process Id: "; + NSString *processName = [[NSProcessInfo processInfo] processName]; + NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]]; + NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; + + // Set break point at this line. + [pool drain]; + return 0; +} + From gclayton at apple.com Fri Jul 29 17:26:36 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 29 Jul 2011 22:26:36 -0000 Subject: [Lldb-commits] [lldb] r136530 - /lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Message-ID: <20110729222636.8354C2A6C12C@llvm.org> Author: gclayton Date: Fri Jul 29 17:26:36 2011 New Revision: 136530 URL: http://llvm.org/viewvc/llvm-project?rev=136530&view=rev Log: Logging and return code fixes. Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=136530&r1=136529&r2=136530&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Fri Jul 29 17:26:36 2011 @@ -753,7 +753,7 @@ { const uint32_t error = packet.GetU32 (&offset); const uint32_t count = packet.GetByteSize() - offset; - s.Printf(" (error = 0x%8.8x <0x%x>:\n", error, count); + s.Printf(" (error = 0x%8.8x:\n", error); if (count > 0) packet.Dump (&s, // Stream to dump to offset, // Offset within "packet" @@ -770,7 +770,7 @@ { const uint32_t error = packet.GetU32 (&offset); const uint32_t count = packet.GetByteSize() - offset; - s.Printf(" (error = 0x%8.8x <0x%x> regs:\n", error, count); + s.Printf(" (error = 0x%8.8x regs:\n", error); if (count > 0) packet.Dump (&s, // Stream to dump to offset, // Offset within "packet" @@ -817,7 +817,7 @@ { const uint16_t reply_port = packet.GetU16 (&offset); const uint16_t exc_port = packet.GetU16 (&offset); - s.Printf(" (reply_port=%u, exc_port=%u, greeting=\"%s\")", reply_port, exc_port, packet.GetCStr(&offset)); + s.Printf(" (reply_port = %u, exc_port = %u, greeting = \"%s\")", reply_port, exc_port, packet.GetCStr(&offset)); } break; @@ -845,7 +845,7 @@ { const uint32_t addr = packet.GetU32 (&offset); const uint32_t size = packet.GetU32 (&offset); - s.Printf(" (addr = 0x%8.8x, size=%u)", addr, size); + s.Printf(" (addr = 0x%8.8x, size = %u)", addr, size); m_last_read_memory_addr = addr; } break; @@ -854,7 +854,7 @@ { const uint32_t addr = packet.GetU32 (&offset); const uint32_t size = packet.GetU32 (&offset); - s.Printf(" (addr = 0x%8.8x, size=%u, bytes:\n", addr, size); + s.Printf(" (addr = 0x%8.8x, size = %u, bytes = \n", addr, size); if (size > 0) DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr); } @@ -864,7 +864,7 @@ { const uint64_t addr = packet.GetU64 (&offset); const uint32_t size = packet.GetU32 (&offset); - s.Printf(" (addr = 0x%16.16llx, size=%u)", addr, size); + s.Printf(" (addr = 0x%16.16llx, size = %u)", addr, size); m_last_read_memory_addr = addr; } break; @@ -873,7 +873,7 @@ { const uint64_t addr = packet.GetU64 (&offset); const uint32_t size = packet.GetU32 (&offset); - s.Printf(" (addr = 0x%16.16llx, size=%u, bytes:", addr, size); + s.Printf(" (addr = 0x%16.16llx, size = %u, bytes = \n", addr, size); if (size > 0) DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr); } @@ -883,7 +883,7 @@ { const uint32_t cpu = packet.GetU32 (&offset); const uint32_t flavor = packet.GetU32 (&offset); - s.Printf(" (cpu = %u, flavor=%u)", cpu, flavor); + s.Printf(" (cpu = %u, flavor = %u)", cpu, flavor); } break; @@ -892,7 +892,7 @@ const uint32_t cpu = packet.GetU32 (&offset); const uint32_t flavor = packet.GetU32 (&offset); const uint32_t nbytes = packet.GetByteSize() - offset; - s.Printf(" (cpu = %u, flavor=%u, regs:\n", cpu, flavor); + s.Printf(" (cpu = %u, flavor = %u, regs = \n", cpu, flavor); if (nbytes > 0) packet.Dump (&s, // Stream to dump to offset, // Offset within "packet" @@ -975,7 +975,7 @@ case KDP_REATTACH: { const uint16_t reply_port = packet.GetU16 (&offset); - s.Printf(" (reply_port=%u)", reply_port); + s.Printf(" (reply_port = %u)", reply_port); } break; } @@ -1080,7 +1080,12 @@ DataExtractor reply_packet; if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet)) - return true; + { + uint32_t offset = 8; + uint32_t kdp_error = reply_packet.GetU32 (&offset); + if (kdp_error == 0) + return true; + } return false; } From johnny.chen at apple.com Fri Jul 29 17:54:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 29 Jul 2011 22:54:56 -0000 Subject: [Lldb-commits] [lldb] r136533 - in /lldb/trunk/test: dotest.py redo.py Message-ID: <20110729225456.EFB442A6C12C@llvm.org> Author: johnny Date: Fri Jul 29 17:54:56 2011 New Revision: 136533 URL: http://llvm.org/viewvc/llvm-project?rev=136533&view=rev Log: Add a redo.py script which takes a session directory name as arg and digs into the directory to find out the tests which failed/errored and need re-running. The dotest.py test driver script is modified to allow specifying multiple -f testclass.testmethod in the command line to accommodate the redo functionality. An example, $ ./redo.py -n 2011-07-29-11_50_14 adding filterspec: TargetAPITestCase.test_find_global_variables_with_dwarf adding filterspec: DisasmAPITestCase.test_with_dsym Running ./dotest.py -v -f TargetAPITestCase.test_find_global_variables_with_dwarf -f DisasmAPITestCase.test_with_dsym ... ---------------------------------------------------------------------- Collected 2 tests 1: test_with_dsym (TestDisasmAPI.DisasmAPITestCase) Exercise getting SBAddress objects, disassembly, and SBAddress APIs. ... ok 2: test_find_global_variables_with_dwarf (TestTargetAPI.TargetAPITestCase) Exercise SBTarget.FindGlobalVariables() API. ... ok ---------------------------------------------------------------------- Ran 2 tests in 15.328s OK Added: lldb/trunk/test/redo.py (with props) Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=136533&r1=136532&r2=136533&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Jul 29 17:54:56 2011 @@ -102,8 +102,8 @@ # By default, failfast is False. Use '-F' to overwrite it. failfast = False -# The filter (testclass.testmethod) used to admit tests into our test suite. -filterspec = None +# The filters (testclass.testmethod) used to admit tests into our test suite. +filters = [] # If '-g' is specified, the filterspec is not exclusive. If a test module does # not contain testclass.testmethod which matches the filterspec, the whole test @@ -296,7 +296,7 @@ global delay global dumpSysPath global failfast - global filterspec + global filters global fs4all global ignore global skipLongRunningTest @@ -381,7 +381,7 @@ index += 1 if index >= len(sys.argv) or sys.argv[index].startswith('-'): usage() - filterspec = sys.argv[index] + filters.append(sys.argv[index]) index += 1 elif sys.argv[index].startswith('-g'): fs4all = False @@ -662,7 +662,7 @@ global suite global regexp - global filterspec + global filters global fs4all for name in names: @@ -689,7 +689,8 @@ # Thoroughly check the filterspec against the base module and admit # the (base, filterspec) combination only when it makes sense. - if filterspec: + filterspec = None + for filterspec in filters: # Optimistically set the flag to True. filtered = True module = __import__(base) @@ -702,13 +703,19 @@ # The filterspec has failed. filtered = False break - # Forgo this module if the (base, filterspec) combo is invalid - # and no '-g' option is specified - if fs4all and not filtered: - continue + + # If we reach here, we have a good filterspec. Add it. + if filtered: + break + + # Forgo this module if the (base, filterspec) combo is invalid + # and no '-g' option is specified + if filters and fs4all and not filtered: + continue # Add either the filtered test case or the entire test class. if filterspec and filtered: + #print "adding filter spec %s to module %s" % (filterspec, module) suite.addTests( unittest2.defaultTestLoader.loadTestsFromName(filterspec, module)) else: Added: lldb/trunk/test/redo.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/redo.py?rev=136533&view=auto ============================================================================== --- lldb/trunk/test/redo.py (added) +++ lldb/trunk/test/redo.py Fri Jul 29 17:54:56 2011 @@ -0,0 +1,114 @@ +#!/usr/bin/env python + +""" +A simple utility to redo the failed/errored tests. + +You need to specify the session directory in order for this script to locate the +tests which need to be re-run. + +See also dotest.py, the test driver running the test suite. + +Type: + +./dotest.py -h + +for help. +""" + +import os, sys +import re + +# If True, redo with no '-t' option for the test driver. +no_trace = False + +# To be filled with the filterspecs found in the session logs. +redo_specs = [] + +def usage(): + print"""\ +Usage: redo.py [-n] session_dir +where options: +-n : when running the tests, do not turn on trace mode, i.e, no '-t' option + is passed to the test driver (this will run the tests faster) + +and session_dir specifies the session directory which contains previously +recorded session infos for all the test cases which either failed or errored.""" + sys.exit(0) + +def where(session_dir, test_dir): + """Returns the full path to the session directory; None if non-existent.""" + abspath = os.path.abspath(session_dir) + if os.path.isdir(abspath): + return abspath + + session_dir_path = os.path.join(test_dir, session_dir) + if os.path.isdir(session_dir_path): + return session_dir_path + + return None + +# 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 (.*)$") +def redo(suffix, dir, names): + """Visitor function for os.path.walk(path, visit, arg).""" + global redo_specs + + for name in names: + if name.endswith(suffix): + #print "Find a log file:", name + if name.startswith("Error") or name.startswith("Failure"): + with open(os.path.join(dir, name), 'r') as log: + content = log.read() + for line in content.splitlines(): + match = pattern.match(line) + if match: + filterspec = match.group(1) + print "adding filterspec:", filterspec + redo_specs.append(filterspec) + else: + continue + +def main(): + """Read the session directory and run the failed test cases one by one.""" + global no_trace + global redo_specs + + if len(sys.argv) < 2 or len(sys.argv) > 3: + usage() + + index = 1 + while index < len(sys.argv): + if sys.argv[index].startswith('-'): + # We should continue processing... + pass + else: + # End of option processing. + break + + if sys.argv[index] == '-n': + no_trace = True + index += 1 + + session_dir = sys.argv[index] + + test_dir = sys.path[0] + if not test_dir.endswith('test'): + print "This script expects to reside in lldb's test directory." + sys.exit(-1) + + #print "The test directory:", test_dir + session_dir_path = where(session_dir, test_dir) + + #print "Session dir path:", session_dir_path + 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) + + print "Running %s" % (command + filters) + os.system(command + filters) + +if __name__ == '__main__': + main() Propchange: lldb/trunk/test/redo.py ------------------------------------------------------------------------------ svn:executable = * From gclayton at apple.com Fri Jul 29 18:21:00 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 29 Jul 2011 23:21:00 -0000 Subject: [Lldb-commits] [lldb] r136536 - in /lldb/trunk: include/lldb/Symbol/ClangASTType.h source/Core/ValueObject.cpp source/Symbol/ClangASTType.cpp Message-ID: <20110729232100.567872A6C12C@llvm.org> Author: gclayton Date: Fri Jul 29 18:21:00 2011 New Revision: 136536 URL: http://llvm.org/viewvc/llvm-project?rev=136536&view=rev Log: Moved some functionality from ValueObject to ClangASTType. Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=136536&r1=136535&r2=136536&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Fri Jul 29 18:21:00 2011 @@ -94,6 +94,12 @@ static size_t GetTypeBitAlign (clang::ASTContext *ast_context, lldb::clang_type_t clang_type); + lldb::LanguageType + GetMinimumLanguage (); + + static lldb::LanguageType + GetMinimumLanguage (lldb::clang_type_t clang_type); + void DumpValue (ExecutionContext *exe_ctx, Stream *s, Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=136536&r1=136535&r2=136536&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Jul 29 18:21:00 2011 @@ -1256,34 +1256,7 @@ lldb::LanguageType ValueObject::GetObjectRuntimeLanguage () { - clang_type_t opaque_qual_type = GetClangType(); - if (opaque_qual_type == NULL) - return lldb::eLanguageTypeC; - - // If the type is a reference, then resolve it to what it refers to first: - clang::QualType qual_type (clang::QualType::getFromOpaquePtr(opaque_qual_type).getNonReferenceType()); - if (qual_type->isAnyPointerType()) - { - if (qual_type->isObjCObjectPointerType()) - return lldb::eLanguageTypeObjC; - - clang::QualType pointee_type (qual_type->getPointeeType()); - if (pointee_type->getCXXRecordDeclForPointerType() != NULL) - return lldb::eLanguageTypeC_plus_plus; - if (pointee_type->isObjCObjectOrInterfaceType()) - return lldb::eLanguageTypeObjC; - if (pointee_type->isObjCClassType()) - return lldb::eLanguageTypeObjC; - } - else - { - if (ClangASTContext::IsObjCClassType (opaque_qual_type)) - return lldb::eLanguageTypeObjC; - if (ClangASTContext::IsCXXClassType (opaque_qual_type)) - return lldb::eLanguageTypeC_plus_plus; - } - - return lldb::eLanguageTypeC; + return ClangASTType::GetMinimumLanguage (GetClangType()); } void Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=136536&r1=136535&r2=136536&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Jul 29 18:21:00 2011 @@ -156,6 +156,92 @@ } +lldb::LanguageType +ClangASTType::GetMinimumLanguage () +{ + return ClangASTType::GetMinimumLanguage (m_type); +} + +lldb::LanguageType +ClangASTType::GetMinimumLanguage (lldb::clang_type_t clang_type) +{ + if (clang_type == NULL) + return lldb::eLanguageTypeC; + + // If the type is a reference, then resolve it to what it refers to first: + clang::QualType qual_type (clang::QualType::getFromOpaquePtr(clang_type).getNonReferenceType()); + if (qual_type->isAnyPointerType()) + { + if (qual_type->isObjCObjectPointerType()) + return lldb::eLanguageTypeObjC; + + clang::QualType pointee_type (qual_type->getPointeeType()); + if (pointee_type->getCXXRecordDeclForPointerType() != NULL) + return lldb::eLanguageTypeC_plus_plus; + if (pointee_type->isObjCObjectOrInterfaceType()) + return lldb::eLanguageTypeObjC; + if (pointee_type->isObjCClassType()) + return lldb::eLanguageTypeObjC; + } + else + { + if (qual_type->isObjCObjectOrInterfaceType()) + return lldb::eLanguageTypeObjC; + if (qual_type->getAsCXXRecordDecl()) + return lldb::eLanguageTypeC_plus_plus; + switch (qual_type->getTypeClass()) + { + default: + break; + case clang::Type::Builtin: + switch (cast(qual_type)->getKind()) + { + default: + case clang::BuiltinType::Void: + case clang::BuiltinType::Bool: + case clang::BuiltinType::Char_U: + case clang::BuiltinType::UChar: + case clang::BuiltinType::WChar_U: + case clang::BuiltinType::Char16: + case clang::BuiltinType::Char32: + case clang::BuiltinType::UShort: + case clang::BuiltinType::UInt: + case clang::BuiltinType::ULong: + case clang::BuiltinType::ULongLong: + case clang::BuiltinType::UInt128: + case clang::BuiltinType::Char_S: + case clang::BuiltinType::SChar: + case clang::BuiltinType::WChar_S: + case clang::BuiltinType::Short: + case clang::BuiltinType::Int: + case clang::BuiltinType::Long: + case clang::BuiltinType::LongLong: + case clang::BuiltinType::Int128: + case clang::BuiltinType::Float: + case clang::BuiltinType::Double: + case clang::BuiltinType::LongDouble: + break; + + case clang::BuiltinType::NullPtr: + return eLanguageTypeC_plus_plus; + + case clang::BuiltinType::ObjCId: + case clang::BuiltinType::ObjCClass: + case clang::BuiltinType::ObjCSel: + return eLanguageTypeObjC; + + case clang::BuiltinType::Dependent: + case clang::BuiltinType::Overload: + case clang::BuiltinType::BoundMember: + case clang::BuiltinType::UnknownAny: + break; + } + break; + } + } + return lldb::eLanguageTypeC; +} + lldb::Encoding ClangASTType::GetEncoding (clang_type_t clang_type, uint32_t &count) { From granata.enrico at gmail.com Fri Jul 29 18:59:08 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 29 Jul 2011 23:59:08 -0000 Subject: [Lldb-commits] [lldb] r136544 - in /lldb/trunk: examples/synthetic/CFString.py source/Symbol/ClangASTType.cpp test/functionalities/data-formatter/data-formatter-objc/CFString.py test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py test/functionalities/data-formatter/data-formatter-objc/main.m Message-ID: <20110729235908.E22202A6C12C@llvm.org> Author: enrico Date: Fri Jul 29 18:59:08 2011 New Revision: 136544 URL: http://llvm.org/viewvc/llvm-project?rev=136544&view=rev Log: changes in the new GetMinimumLanguages() ; robustness improvements in the CFStringSynthProvider object ; made a CFString_SummaryProvider function you can use if all you care about is the summary string for your NSString objects Modified: lldb/trunk/examples/synthetic/CFString.py lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m Modified: lldb/trunk/examples/synthetic/CFString.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/CFString.py?rev=136544&r1=136543&r2=136544&view=diff ============================================================================== --- lldb/trunk/examples/synthetic/CFString.py (original) +++ lldb/trunk/examples/synthetic/CFString.py Fri Jul 29 18:59:08 2011 @@ -7,6 +7,8 @@ self.update() # children other than "content" are for debugging only and must not be used in production code def num_children(self): + if self.invalid: + return 0; return 6; def read_unicode(self, pointer): process = self.valobj.GetTarget().GetProcess() @@ -167,7 +169,12 @@ self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)); cfinfo.SetFormat(11) info = cfinfo.GetValue(); - return int(info,0); + if info != None: + self.invalid = False; + return int(info,0); + else: + self.invalid = True; + return None; # calculating internal flag bits of the CFString object # this stuff is defined and discussed in CFString.c def is_mutable(self): @@ -196,6 +203,8 @@ # useful values to get at the real data def compute_flags(self): self.info_bits = self.read_info_bits(); + if self.info_bits == None: + return; self.mutable = self.is_mutable(); self.inline = self.is_inline(); self.explicit = self.has_explicit_length(); @@ -204,3 +213,9 @@ def update(self): self.adjust_for_architecture(); self.compute_flags(); +def CFString_SummaryProvider (valobj,dict): + provider = CFStringSynthProvider(valobj,dict); + if provider.invalid == True: + return ""; + return provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); + Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=136544&r1=136543&r2=136544&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Jul 29 18:59:08 2011 @@ -235,6 +235,8 @@ case clang::BuiltinType::BoundMember: case clang::BuiltinType::UnknownAny: break; + case clang::Type::Typedef: + return GetMinimumLanguage(cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); } break; } Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py?rev=136544&r1=136543&r2=136544&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py Fri Jul 29 18:59:08 2011 @@ -7,6 +7,8 @@ self.update() # children other than "content" are for debugging only and must not be used in production code def num_children(self): + if self.invalid: + return 0; return 6; def read_unicode(self, pointer): process = self.valobj.GetTarget().GetProcess() @@ -167,7 +169,12 @@ self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)); cfinfo.SetFormat(11) info = cfinfo.GetValue(); - return int(info,0); + if info != None: + self.invalid = False; + return int(info,0); + else: + self.invalid = True; + return None; # calculating internal flag bits of the CFString object # this stuff is defined and discussed in CFString.c def is_mutable(self): @@ -196,6 +203,8 @@ # useful values to get at the real data def compute_flags(self): self.info_bits = self.read_info_bits(); + if self.info_bits == None: + return; self.mutable = self.is_mutable(); self.inline = self.is_inline(); self.explicit = self.has_explicit_length(); @@ -204,3 +213,9 @@ def update(self): self.adjust_for_architecture(); self.compute_flags(); +def CFString_SummaryProvider (valobj,dict): + provider = CFStringSynthProvider(valobj,dict); + if provider.invalid == True: + return ""; + return provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); + 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=136544&r1=136543&r2=136544&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 Jul 29 18:59:08 2011 @@ -103,99 +103,100 @@ self.runCmd("script from CFString import *") self.runCmd("type synth add -l CFStringSynthProvider NSString") - self.expect('frame variable str -P 1', + self.expect('frame variable str -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'A rather short ASCII NSString object is here']) - self.expect('frame variable str2 -P 1', + self.expect('frame variable str2 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'A rather short UTF8 NSString object is here']) - self.expect('frame variable str3 -P 1', + self.expect('frame variable str3 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'A string made with the at sign is here']) - self.expect('frame variable str4 -P 1', + self.expect('frame variable str4 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'This is string number 4 right here']) - self.expect('frame variable str5 -P 1', + self.expect('frame variable str5 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', '{{1, 1}, {5, 5}}']) - self.expect('frame variable str6 -P 1', + self.expect('frame variable str6 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', '1ST']) - self.expect('frame variable str7 -P 1', + self.expect('frame variable str7 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', '\\xcf\\x83xx']) - self.expect('frame variable str8 -P 1', + self.expect('frame variable str8 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'hasVeryLongExtensionThisTime']) - self.expect('frame variable str9 -P 1', + self.expect('frame variable str9 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'a very much boring task to write a string this way!!\\xe4\\x8c\\xb3']) - self.expect('frame variable str10 -P 1', + self.expect('frame variable str10 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'This is a Unicode string \\xcf\\x83 number 4 right here']) - self.expect('frame variable str11 -P 1', + self.expect('frame variable str11 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', '__NSCFString']) - self.expect('frame variable processName -P 1', + self.expect('frame variable processName -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'a.out']) - self.expect('frame variable str12 -P 1', + self.expect('frame variable str12 -P 1 -Y', substrs = ['mutable =', 'inline = ', 'explicit = ', 'content = ', 'Process Name: a.out Process Id:']) - # make it a summary - self.runCmd("type summary add -f \"${svar.content}\" NSString") + # delete the synth and set a summary + self.runCmd("type synth delete NSString") + self.runCmd("type summary add -F CFString_SummaryProvider NSString") self.expect('frame variable str', substrs = ['A rather short ASCII NSString object is here']) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m?rev=136544&r1=136543&r2=136544&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m Fri Jul 29 18:59:08 2011 @@ -86,7 +86,7 @@ NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; - NSRect rect = NSMakeRect(1,1,5,5); + NSRect rect = {{1,1},{5,5}}; NSString* str5 = NSStringFromRect(rect); From gclayton at apple.com Fri Jul 29 20:26:03 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 30 Jul 2011 01:26:03 -0000 Subject: [Lldb-commits] [lldb] r136551 - in /lldb/trunk/source/Symbol: ClangASTContext.cpp ClangASTType.cpp Message-ID: <20110730012603.2DA982A6C12C@llvm.org> Author: gclayton Date: Fri Jul 29 20:26:02 2011 New Revision: 136551 URL: http://llvm.org/viewvc/llvm-project?rev=136551&view=rev Log: Fixed a compile error. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=136551&r1=136550&r2=136551&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Jul 29 20:26:02 2011 @@ -368,7 +368,7 @@ { if (target_triple && target_triple[0]) - m_target_triple.assign (target_triple); + SetTargetTriple (target_triple); } //---------------------------------------------------------------------- @@ -413,13 +413,18 @@ { Clear(); m_target_triple.assign(target_triple); + if (m_target_triple.find("armv7s") == 0) + m_target_triple.erase(5,1); + else if (m_target_triple.find("armv7f") == 0) + m_target_triple.erase(5,1); + else if (m_target_triple.find("armv7k") == 0) + m_target_triple.erase(5,1); } void ClangASTContext::SetArchitecture (const ArchSpec &arch) { - Clear(); - m_target_triple.assign(arch.GetTriple().str()); + SetTargetTriple(arch.GetTriple().str().c_str()); } bool Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=136551&r1=136550&r2=136551&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Jul 29 20:26:02 2011 @@ -235,10 +235,10 @@ case clang::BuiltinType::BoundMember: case clang::BuiltinType::UnknownAny: break; - case clang::Type::Typedef: - return GetMinimumLanguage(cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); } break; + case clang::Type::Typedef: + return GetMinimumLanguage(cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); } } return lldb::eLanguageTypeC; From johnny.chen at apple.com Fri Jul 29 20:39:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 30 Jul 2011 01:39:58 -0000 Subject: [Lldb-commits] [lldb] r136553 - in /lldb/trunk/test: benchmarks/ benchmarks/example/ benchmarks/example/Makefile benchmarks/example/TestRepeatedExprs.py benchmarks/example/main.c dotest.py lldbtest.py python_api/lldbutil/frame/TestFrameUtils.py python_api/lldbutil/iter/TestLLDBIterator.py python_api/lldbutil/iter/TestRegistersIterator.py python_api/lldbutil/process/TestPrintStackTraces.py Message-ID: <20110730013958.E6F4C2A6C12C@llvm.org> Author: johnny Date: Fri Jul 29 20:39:58 2011 New Revision: 136553 URL: http://llvm.org/viewvc/llvm-project?rev=136553&view=rev Log: Add a @benchmarks_test decorator for test method we want to categorize as benchmarks test. The test driver now takes an option "+b" which enables to run just the benchmarks tests. By default, tests decorated with the @benchmarks_test decorator do not get run. Add an example benchmarks test directory which contains nothing for the time being, just to demonstrate the @benchmarks_test concept. For example, $ ./dotest.py -v benchmarks ... ---------------------------------------------------------------------- Collected 2 tests 1: test_with_gdb (TestRepeatedExprs.RepeatedExprssCase) Test repeated expressions with gdb. ... skipped 'benchmarks tests' 2: test_with_lldb (TestRepeatedExprs.RepeatedExprssCase) Test repeated expressions with lldb. ... skipped 'benchmarks tests' ---------------------------------------------------------------------- Ran 2 tests in 0.047s OK (skipped=2) $ ./dotest.py -v +b benchmarks ... ---------------------------------------------------------------------- Collected 2 tests 1: test_with_gdb (TestRepeatedExprs.RepeatedExprssCase) Test repeated expressions with gdb. ... running test_with_gdb benchmarks result for test_with_gdb ok 2: test_with_lldb (TestRepeatedExprs.RepeatedExprssCase) Test repeated expressions with lldb. ... running test_with_lldb benchmarks result for test_with_lldb ok ---------------------------------------------------------------------- Ran 2 tests in 0.270s OK Also mark some Python API tests which are missing the @python_api_test decorator. Added: lldb/trunk/test/benchmarks/ lldb/trunk/test/benchmarks/example/ lldb/trunk/test/benchmarks/example/Makefile lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py lldb/trunk/test/benchmarks/example/main.c Modified: lldb/trunk/test/dotest.py lldb/trunk/test/lldbtest.py lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py Added: lldb/trunk/test/benchmarks/example/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/example/Makefile?rev=136553&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/example/Makefile (added) +++ lldb/trunk/test/benchmarks/example/Makefile Fri Jul 29 20:39:58 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py?rev=136553&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py (added) +++ lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py Fri Jul 29 20:39:58 2011 @@ -0,0 +1,37 @@ +"""Test evaluating expressions repeatedly comparing lldb against gdb.""" + +import os +import unittest2 +import lldb +import pexpect +from lldbtest import * + +class RepeatedExprssCase(TestBase): + + mydir = os.path.join("benchmarks", "example") + + @benchmarks_test + def test_with_lldb(self): + """Test repeated expressions with lldb.""" + self.buildDefault() + self.run_lldb_repeated_exprs() + + @benchmarks_test + def test_with_gdb(self): + """Test repeated expressions with gdb.""" + self.buildDefault() + self.run_gdb_repeated_exprs() + + def run_lldb_repeated_exprs(self): + print "running "+self.testMethodName + print "benchmarks result for "+self.testMethodName + + def run_gdb_repeated_exprs(self): + print "running "+self.testMethodName + print "benchmarks result for "+self.testMethodName + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/benchmarks/example/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/example/main.c?rev=136553&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/example/main.c (added) +++ lldb/trunk/test/benchmarks/example/main.c Fri Jul 29 20:39:58 2011 @@ -0,0 +1,6 @@ +#include + +int main(int argc, char const *argv[]) { + printf("Hello world.\n"); + return 0; +} Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=136553&r1=136552&r2=136553&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Jul 29 20:39:58 2011 @@ -70,6 +70,9 @@ # By default, both command line and Python API tests are performed. just_do_python_api_test = False +# By default, benchmarks tests are not run. +just_do_benchmarks_test = False + # The blacklist is optional (-b blacklistFile) and allows a central place to skip # testclass's and/or testclass.testmethod's. blacklist = None @@ -162,6 +165,8 @@ use @python_api_test to decorate a test case as lldb Python API test +a : just do lldb Python API tests do not specify both '-a' and '+a' at the same time ++b : just do benchmark tests + use @benchmark_test to decorate a test case as such -b : read a blacklist file specified after this option -c : read a config file specified after this option the architectures and compilers (note the plurals) specified via '-A' and '-C' @@ -287,6 +292,7 @@ global dont_do_python_api_test global just_do_python_api_test + global just_do_benchmarks_test global blacklist global blacklistConfig global configFile @@ -347,6 +353,9 @@ elif sys.argv[index].startswith('+a'): just_do_python_api_test = True index += 1 + elif sys.argv[index].startswith('+b'): + just_do_benchmarks_test = True + index += 1 elif sys.argv[index].startswith('-b'): # Increment by 1 to fetch the blacklist file name option argument. index += 1 @@ -815,6 +824,7 @@ # Put dont/just_do_python_api_test in the lldb namespace, too. lldb.dont_do_python_api_test = dont_do_python_api_test lldb.just_do_python_api_test = just_do_python_api_test +lldb.just_do_benchmarks_test = just_do_benchmarks_test # Turn on lldb loggings if necessary. lldbLoggings() Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=136553&r1=136552&r2=136553&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Jul 29 20:39:58 2011 @@ -240,7 +240,7 @@ def wrapper(self, *args, **kwargs): try: if lldb.dont_do_python_api_test: - self.skipTest("Skip Python API tests") + self.skipTest("python api tests") except AttributeError: pass return func(self, *args, **kwargs) @@ -249,6 +249,24 @@ 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): + raise Exception("@benchmarks_test can only be used to decorate a test method") + @wraps(func) + def wrapper(self, *args, **kwargs): + try: + if not lldb.just_do_benchmarks_test: + self.skipTest("benchmarks tests") + except AttributeError: + pass + return func(self, *args, **kwargs) + + # Mark this function as such to separate them from the regular tests. + wrapper.__benchmarks_test__ = True + return wrapper + class recording(StringIO.StringIO): """ A nice little context manager for recording the debugger interactions into @@ -514,7 +532,20 @@ if getattr(testMethod, "__python_api_test__", False): pass else: - self.skipTest("Skip lldb command line test") + self.skipTest("non python api test") + except AttributeError: + pass + + # Benchmarks test is decorated with @benchmarks_test, + # which also sets the "__benchmarks_test__" attribute of the + # function object to True. + try: + if lldb.just_do_benchmarks_test: + testMethod = getattr(self, self._testMethodName) + if getattr(testMethod, "__benchmarks_test__", False): + pass + else: + self.skipTest("non benchmarks test") except AttributeError: pass Modified: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py?rev=136553&r1=136552&r2=136553&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py (original) +++ lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Fri Jul 29 20:39:58 2011 @@ -18,6 +18,7 @@ self.line = line_number('main.c', "// Find the line number here.") + @python_api_test def test_frame_utils(self): """Test utility functions for the frame object.""" self.buildDefault() Modified: lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py?rev=136553&r1=136552&r2=136553&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py Fri Jul 29 20:39:58 2011 @@ -19,16 +19,19 @@ self.line1 = line_number('main.cpp', '// Set break point at this line.') self.line2 = line_number('main.cpp', '// And that line.') + @python_api_test def test_lldb_iter_module(self): """Test module_iter works correctly for SBTarget -> SBModule.""" self.buildDefault() self.lldb_iter_module() + @python_api_test def test_lldb_iter_breakpoint(self): """Test breakpoint_iter works correctly for SBTarget -> SBBreakpoint.""" self.buildDefault() self.lldb_iter_breakpoint() + @python_api_test def test_lldb_iter_frame(self): """Test iterator works correctly for SBProcess->SBThread->SBFrame.""" self.buildDefault() Modified: lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py?rev=136553&r1=136552&r2=136553&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py Fri Jul 29 20:39:58 2011 @@ -18,6 +18,7 @@ # Find the line number to break inside main(). self.line1 = line_number('main.cpp', '// Set break point at this line.') + @python_api_test def test_iter_registers(self): """Test iterator works correctly for lldbutil.iter_registers().""" self.buildDefault() Modified: lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py?rev=136553&r1=136552&r2=136553&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py (original) +++ lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py Fri Jul 29 20:39:58 2011 @@ -18,6 +18,7 @@ # Find the line number to break inside main(). self.line = line_number('main.cpp', '// Set break point at this line.') + @python_api_test def test_stack_traces(self): """Test SBprocess and SBThread APIs with printing of the stack traces.""" self.buildDefault() From gclayton at apple.com Fri Jul 29 20:47:41 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 30 Jul 2011 01:47:41 -0000 Subject: [Lldb-commits] [lldb] r136554 - in /lldb/trunk: examples/synthetic/CFString.py test/functionalities/data-formatter/data-formatter-objc/CFString.py test/functionalities/data-formatter/data-formatter-objc/main.m Message-ID: <20110730014741.A23662A6C12C@llvm.org> Author: gclayton Date: Fri Jul 29 20:47:41 2011 New Revision: 136554 URL: http://llvm.org/viewvc/llvm-project?rev=136554&view=rev Log: Cleaned up the NSString summary formatter to not print "" when we have a nil NSString *. Also added blank lines between functions in the CFString.py files. Modified: lldb/trunk/examples/synthetic/CFString.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m Modified: lldb/trunk/examples/synthetic/CFString.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/CFString.py?rev=136554&r1=136553&r2=136554&view=diff ============================================================================== --- lldb/trunk/examples/synthetic/CFString.py (original) +++ lldb/trunk/examples/synthetic/CFString.py Fri Jul 29 20:47:41 2011 @@ -1,15 +1,18 @@ # synthetic children provider for CFString # (and related NSString class) import lldb + class CFStringSynthProvider: def __init__(self,valobj,dict): self.valobj = valobj; self.update() + # children other than "content" are for debugging only and must not be used in production code def num_children(self): if self.invalid: return 0; return 6; + def read_unicode(self, pointer): process = self.valobj.GetTarget().GetProcess() error = lldb.SBError() @@ -34,6 +37,7 @@ value = b0 * 256 + b1 pystr = pystr + unichr(value) return pystr + # handle the special case strings # only use the custom code for the tested LP64 case def handle_special(self): @@ -45,12 +49,14 @@ pystr = self.read_unicode(pointer) return self.valobj.CreateValueFromExpression("content", "(char*)\"" + pystr.encode('utf-8') + "\"") + # last resort call, use ObjC code to read; the final aim is to # be able to strip this call away entirely and only do the read # ourselves def handle_unicode_string_safe(self): return self.valobj.CreateValueFromExpression("content", "(char*)\"" + self.valobj.GetObjectDescription() + "\""); + def handle_unicode_string(self): # step 1: find offset if self.inline: @@ -80,6 +86,7 @@ # step 3: return it return self.valobj.CreateValueFromExpression("content", "(char*)\"" + pystr.encode('utf-8') + "\"") + # we read at "the right place" into the __CFString object instead of running code # we are replicating the functionality of __CFStrContents in CFString.c here def handle_UTF8_inline(self): @@ -88,10 +95,12 @@ offset = offset + 1; return self.valobj.CreateValueFromAddress("content", offset, self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)); + def handle_UTF8_not_inline(self): offset = self.size_of_cfruntime_base(); return self.valobj.CreateChildAtOffset("content", offset,self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar).GetPointerType()); + def get_child_at_index(self,index): if index == 0: return self.valobj.CreateValueFromExpression("mutable", @@ -117,6 +126,7 @@ return self.handle_UTF8_inline(); else: return self.handle_UTF8_not_inline(); + def get_child_index(self,name): if name == "content": return self.num_children() - 1; @@ -130,17 +140,13 @@ return 3; if name == "special": return 4; + def is_64bit(self): - if self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8: - return True; - else: - return False; + return self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8 + def is_little_endian(self): - # 4 is eByteOrderLittle - if self.valobj.GetTarget().GetProcess().GetByteOrder() == 4: - return True; - else: - return False; + return self.valobj.GetTarget().GetProcess().GetByteOrder() == lldb.eByteOrderLittle + # CFRuntimeBase is defined as having an additional # 4 bytes (padding?) on LP64 architectures # to get its size we add up sizeof(pointer)+4 @@ -150,6 +156,7 @@ return 8+4+4; else: return 4+4; + # the info bits are part of the CFRuntimeBase structure # to get at them we have to skip a uintptr_t and then get # at the least-significant byte of a 4 byte array. If we are @@ -163,6 +170,7 @@ if self.is_little == False: offset = offset + 3; return offset; + def read_info_bits(self): cfinfo = self.valobj.CreateChildAtOffset("cfinfo", self.offset_of_info_bits(), @@ -175,30 +183,37 @@ else: self.invalid = True; return None; + # calculating internal flag bits of the CFString object # this stuff is defined and discussed in CFString.c def is_mutable(self): return (self.info_bits & 1) == 1; + def is_inline(self): return (self.info_bits & 0x60) == 0; + # this flag's name is ambiguous, it turns out # we must skip a length byte to get at the data # when this flag is False def has_explicit_length(self): return (self.info_bits & (1 | 4)) != 4; + # probably a subclass of NSString. obtained this from [str pathExtension] # here info_bits = 0 and Unicode data at the start of the padding word # in the long run using the isa value might be safer as a way to identify this # instead of reading the info_bits def is_special_case(self): return self.info_bits == 0; + def is_unicode(self): return (self.info_bits & 0x10) == 0x10; + # preparing ourselves to read into memory # by adjusting architecture-specific info def adjust_for_architecture(self): self.lp64 = self.is_64bit(); self.is_little = self.is_little_endian(); + # reading info bits out of the CFString and computing # useful values to get at the real data def compute_flags(self): @@ -210,12 +225,14 @@ self.explicit = self.has_explicit_length(); self.unicode = self.is_unicode(); self.special = self.is_special_case(); + def update(self): self.adjust_for_architecture(); self.compute_flags(); + def CFString_SummaryProvider (valobj,dict): provider = CFStringSynthProvider(valobj,dict); - if provider.invalid == True: - return ""; - return provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); + if provider.invalid == False: + return provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); + return '' Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py?rev=136554&r1=136553&r2=136554&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py Fri Jul 29 20:47:41 2011 @@ -1,15 +1,18 @@ # synthetic children provider for CFString # (and related NSString class) import lldb + class CFStringSynthProvider: def __init__(self,valobj,dict): self.valobj = valobj; self.update() + # children other than "content" are for debugging only and must not be used in production code def num_children(self): if self.invalid: return 0; return 6; + def read_unicode(self, pointer): process = self.valobj.GetTarget().GetProcess() error = lldb.SBError() @@ -34,6 +37,7 @@ value = b0 * 256 + b1 pystr = pystr + unichr(value) return pystr + # handle the special case strings # only use the custom code for the tested LP64 case def handle_special(self): @@ -45,12 +49,14 @@ pystr = self.read_unicode(pointer) return self.valobj.CreateValueFromExpression("content", "(char*)\"" + pystr.encode('utf-8') + "\"") + # last resort call, use ObjC code to read; the final aim is to # be able to strip this call away entirely and only do the read # ourselves def handle_unicode_string_safe(self): return self.valobj.CreateValueFromExpression("content", "(char*)\"" + self.valobj.GetObjectDescription() + "\""); + def handle_unicode_string(self): # step 1: find offset if self.inline: @@ -80,6 +86,7 @@ # step 3: return it return self.valobj.CreateValueFromExpression("content", "(char*)\"" + pystr.encode('utf-8') + "\"") + # we read at "the right place" into the __CFString object instead of running code # we are replicating the functionality of __CFStrContents in CFString.c here def handle_UTF8_inline(self): @@ -88,10 +95,12 @@ offset = offset + 1; return self.valobj.CreateValueFromAddress("content", offset, self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)); + def handle_UTF8_not_inline(self): offset = self.size_of_cfruntime_base(); return self.valobj.CreateChildAtOffset("content", offset,self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar).GetPointerType()); + def get_child_at_index(self,index): if index == 0: return self.valobj.CreateValueFromExpression("mutable", @@ -117,6 +126,7 @@ return self.handle_UTF8_inline(); else: return self.handle_UTF8_not_inline(); + def get_child_index(self,name): if name == "content": return self.num_children() - 1; @@ -130,17 +140,13 @@ return 3; if name == "special": return 4; + def is_64bit(self): - if self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8: - return True; - else: - return False; + return self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8 + def is_little_endian(self): - # 4 is eByteOrderLittle - if self.valobj.GetTarget().GetProcess().GetByteOrder() == 4: - return True; - else: - return False; + return self.valobj.GetTarget().GetProcess().GetByteOrder() == lldb.eByteOrderLittle + # CFRuntimeBase is defined as having an additional # 4 bytes (padding?) on LP64 architectures # to get its size we add up sizeof(pointer)+4 @@ -150,6 +156,7 @@ return 8+4+4; else: return 4+4; + # the info bits are part of the CFRuntimeBase structure # to get at them we have to skip a uintptr_t and then get # at the least-significant byte of a 4 byte array. If we are @@ -163,6 +170,7 @@ if self.is_little == False: offset = offset + 3; return offset; + def read_info_bits(self): cfinfo = self.valobj.CreateChildAtOffset("cfinfo", self.offset_of_info_bits(), @@ -175,30 +183,37 @@ else: self.invalid = True; return None; + # calculating internal flag bits of the CFString object # this stuff is defined and discussed in CFString.c def is_mutable(self): return (self.info_bits & 1) == 1; + def is_inline(self): return (self.info_bits & 0x60) == 0; + # this flag's name is ambiguous, it turns out # we must skip a length byte to get at the data # when this flag is False def has_explicit_length(self): return (self.info_bits & (1 | 4)) != 4; + # probably a subclass of NSString. obtained this from [str pathExtension] # here info_bits = 0 and Unicode data at the start of the padding word # in the long run using the isa value might be safer as a way to identify this # instead of reading the info_bits def is_special_case(self): return self.info_bits == 0; + def is_unicode(self): return (self.info_bits & 0x10) == 0x10; + # preparing ourselves to read into memory # by adjusting architecture-specific info def adjust_for_architecture(self): self.lp64 = self.is_64bit(); self.is_little = self.is_little_endian(); + # reading info bits out of the CFString and computing # useful values to get at the real data def compute_flags(self): @@ -210,12 +225,14 @@ self.explicit = self.has_explicit_length(); self.unicode = self.is_unicode(); self.special = self.is_special_case(); + def update(self): self.adjust_for_architecture(); self.compute_flags(); + def CFString_SummaryProvider (valobj,dict): provider = CFStringSynthProvider(valobj,dict); - if provider.invalid == True: - return ""; - return provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); + if provider.invalid == False: + return provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); + return '' Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m?rev=136554&r1=136553&r2=136554&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/main.m Fri Jul 29 20:47:41 2011 @@ -101,7 +101,7 @@ const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ', 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k', ' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', - 't','h','i','s',' ','w','a','y','!','!','0x03C3'}; + 't','h','i','s',' ','w','a','y','!','!',0x03C3, 0}; NSString *str9 = [NSString stringWithCharacters: myOtherCharacters length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; From scallanan at apple.com Fri Jul 29 21:42:07 2011 From: scallanan at apple.com (Sean Callanan) Date: Sat, 30 Jul 2011 02:42:07 -0000 Subject: [Lldb-commits] [lldb] r136555 - in /lldb/trunk: ./ include/lldb/Expression/ include/lldb/Symbol/ scripts/ source/Expression/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ Message-ID: <20110730024207.8EEE22A6C12C@llvm.org> Author: spyffe Date: Fri Jul 29 21:42:06 2011 New Revision: 136555 URL: http://llvm.org/viewvc/llvm-project?rev=136555&view=rev Log: This change brings in the latest LLVM/Clang, and completes the support in the LLDB expression parser for incomplete types. Clang now imports types lazily, and we complete those types as necessary. Changes include: - ClangASTSource now supports three APIs which it passes to ClangExpressionDeclMap. CompleteType completes a TagDecl or an ObjCInterfaceDecl when needed; FindExternalVisibleDecls finds named entities that are visible in the expression's scope; and FindExternalLexicalDecls performs a (potentially restricted) search for entities inside a lexical scope like a namespace. These changes mean that entities in namespaces should work normally. - The SymbolFileDWARF code for searching a context for a specific name is now more general, and can search arbitrary contexts. - We are continuing to adapt our calls into LLVM from interfaces that take start and end iterators when accepting multiple items to interfaces that use ArrayRef. - I have cleaned up some code, especially our use of namespaces. This change is neutral for our testsuite and greatly improves correctness for large programs (like Clang) with complicated type systems. It should also lay the groundwork for improving the expression parser's performance as we are lazier and lazier about providing type information. Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/IRForTarget.h lldb/trunk/include/lldb/Symbol/ClangASTImporter.h lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/source/Expression/ASTDumper.cpp lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/IRDynamicChecks.cpp lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTImporter.cpp lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/source/Symbol/Function.cpp Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original) +++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Fri Jul 29 21:42:06 2011 @@ -141,7 +141,7 @@ //------------------------------------------------------------------ /// Interface stub that returns true. //------------------------------------------------------------------ - virtual bool + virtual clang::ExternalLoadResult FindExternalLexicalDecls (const clang::DeclContext *DC, bool (*isKindWeWant)(clang::Decl::Kind), llvm::SmallVectorImpl &Decls); Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Fri Jul 29 21:42:06 2011 @@ -21,6 +21,7 @@ // Project includes #include "llvm/ADT/APInt.h" #include "llvm/ADT/DenseMap.h" +#include "clang/AST/Decl.h" #include "lldb/lldb-public.h" #include "lldb/Core/ClangForward.h" #include "lldb/Core/Value.h" @@ -472,21 +473,42 @@ const ConstString &name); //------------------------------------------------------------------ - /// [Used by ClangASTSource] Fill in all the members of a (potentially - /// incomplete) DeclContext. - /// - /// @param[in] ast_context - /// The parser's AST context, in which the DeclContext is resident + /// [Used by ClangASTSource] Find all Decls in a context that match + /// a given criterion. /// /// @param[in] decl_context - /// The DeclContext that needs to be filled in. + /// The DeclContext to search. /// - /// @return - /// The completed context on success; NULL otherwise. + /// @param[in] predicate + /// Returns True if a DeclKind is desired; False if not. + /// + /// @param[in] decls + /// A list to add all found Decls that have a desired DeclKind + /// into. + //------------------------------------------------------------------ + clang::ExternalLoadResult + FindExternalLexicalDecls (const clang::DeclContext *decl_context, + bool (*predicate)(clang::Decl::Kind), + llvm::SmallVectorImpl &decls); + + //------------------------------------------------------------------ + /// [Used by ClangASTSource] Complete the definition of a TagDecl. + /// + /// @param[in] tag_decl + /// The TagDecl to be completed. //------------------------------------------------------------------ - const clang::DeclContext * - CompleteDeclContext (clang::ASTContext *ast_context, - const clang::DeclContext *decl_context); + void + CompleteTagDecl (clang::TagDecl *tag_decl); + + //------------------------------------------------------------------ + /// [Used by ClangASTSource] Complete the definition of an + /// ObjCInterfaceDecl. + /// + /// @param[in] tag_decl + /// The ObjCInterfaceDecl to be completed. + //------------------------------------------------------------------ + void + CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl); //------------------------------------------------------------------ /// [Used by ClangASTSource] Report whether a $__lldb variable has Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRForTarget.h?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/IRForTarget.h (original) +++ lldb/trunk/include/lldb/Expression/IRForTarget.h Fri Jul 29 21:42:06 2011 @@ -554,7 +554,7 @@ /// The Constant for the reference, usually a ConstantExpr. //------------------------------------------------------------------ llvm::Constant * - BuildRelocation(const llvm::Type *type, + BuildRelocation(llvm::Type *type, uint64_t offset); //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Fri Jul 29 21:42:06 2011 @@ -42,9 +42,12 @@ clang::Decl * CopyDecl (clang::ASTContext *src_ctx, clang::Decl *decl); + + void + CompleteTagDecl (clang::TagDecl *decl); - const clang::DeclContext * - CompleteDeclContext (const clang::DeclContext *decl_context); + void + CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl); bool ResolveDeclOrigin (const clang::Decl *decl, clang::Decl **original_decl, clang::ASTContext **original_ctx) @@ -111,12 +114,7 @@ { } - clang::Decl *Imported (clang::Decl *from, clang::Decl *to) - { - m_master.m_origins[to] = DeclOrigin (m_source_ctx, from); - - return clang::ASTImporter::Imported(from, to); - } + clang::Decl *Imported (clang::Decl *from, clang::Decl *to); ClangASTImporter &m_master; clang::ASTContext *m_source_ctx; @@ -130,6 +128,8 @@ { MinionMap *minions; + minimal = true; // This override is temporary, while I sort out the attendant issues. + if (minimal) minions = &m_minimal_minions; else Modified: lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h Fri Jul 29 21:42:06 2011 @@ -118,15 +118,14 @@ return; } - virtual bool + virtual clang::ExternalLoadResult FindExternalLexicalDecls (const clang::DeclContext *decl_ctx, bool (*isKindWeWant)(clang::Decl::Kind), llvm::SmallVectorImpl &decls) { // This is used to support iterating through an entire lexical context, // which isn't something the debugger should ever need to do. - // true is for error, that's good enough for me - return true; + return clang::ELR_Failure; } virtual clang::DeclContextLookupResult Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=136555&r1=136554&r2=136555&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=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Fri Jul 29 21:42:06 2011 @@ -26,7 +26,7 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "131657"; +our $llvm_revision = "136537"; our $llvm_source_dir = "$ENV{SRCROOT}"; our @archs = split (/\s+/, $ENV{ARCHS}); @@ -51,6 +51,7 @@ "$llvm_configuration/lib/libLLVMARMAsmParser.a", "$llvm_configuration/lib/libLLVMARMAsmPrinter.a", "$llvm_configuration/lib/libLLVMARMCodeGen.a", + "$llvm_configuration/lib/libLLVMARMDesc.a", "$llvm_configuration/lib/libLLVMARMDisassembler.a", "$llvm_configuration/lib/libLLVMARMInfo.a", "$llvm_configuration/lib/libLLVMAsmParser.a", @@ -81,6 +82,7 @@ "$llvm_configuration/lib/libLLVMX86AsmParser.a", "$llvm_configuration/lib/libLLVMX86AsmPrinter.a", "$llvm_configuration/lib/libLLVMX86CodeGen.a", + "$llvm_configuration/lib/libLLVMX86Desc.a", "$llvm_configuration/lib/libLLVMX86Disassembler.a", "$llvm_configuration/lib/libLLVMX86Info.a", "$llvm_configuration/lib/libLLVMX86Utils.a", Modified: lldb/trunk/source/Expression/ASTDumper.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTDumper.cpp?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTDumper.cpp (original) +++ lldb/trunk/source/Expression/ASTDumper.cpp Fri Jul 29 21:42:06 2011 @@ -406,7 +406,6 @@ m_stream.Indent(); m_stream.Printf("isCanonicalUnqualified() : %s\n", SfB(type->isCanonicalUnqualified())); m_stream.Indent(); m_stream.Printf("isIncompleteType() : %s\n", SfB(type->isIncompleteType())); m_stream.Indent(); m_stream.Printf("isObjectType() : %s\n", SfB(type->isObjectType())); - m_stream.Indent(); m_stream.Printf("isPODType() : %s\n", SfB(type->isPODType())); m_stream.Indent(); m_stream.Printf("isLiteralType() : %s\n", SfB(type->isLiteralType())); m_stream.Indent(); m_stream.Printf("isBuiltinType() : %s\n", SfB(type->isBuiltinType())); m_stream.Indent(); m_stream.Printf("isPlaceholderType() : %s\n", SfB(type->isPlaceholderType())); Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Fri Jul 29 21:42:06 2011 @@ -114,13 +114,13 @@ void ClangASTSource::CompleteType (TagDecl *tag_decl) { - puts(__PRETTY_FUNCTION__); + m_decl_map.CompleteTagDecl (tag_decl); } void ClangASTSource::CompleteType (ObjCInterfaceDecl *objc_decl) { - puts(__PRETTY_FUNCTION__); + m_decl_map.CompleteObjCInterfaceDecl (objc_decl); } void @@ -131,7 +131,7 @@ // This is used to support iterating through an entire lexical context, // which isn't something the debugger should ever need to do. -bool +clang::ExternalLoadResult ClangASTSource::FindExternalLexicalDecls ( const DeclContext *DC, @@ -139,8 +139,7 @@ llvm::SmallVectorImpl &Decls ) { - // true is for error, that's good enough for me - return true; + return m_decl_map.FindExternalLexicalDecls (DC, isKindWeWant, Decls); } clang::ASTContext * Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Jul 29 21:42:06 2011 @@ -134,7 +134,7 @@ { assert (m_parser_vars.get()); ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx; - clang::ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); + ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); TypeFromUser user_type(ClangASTContext::CopyType(context, type.GetASTContext(), @@ -203,7 +203,7 @@ lldb::ClangExpressionVariableSP ClangExpressionDeclMap::BuildCastVariable (const ConstString &name, - clang::VarDecl *decl, + VarDecl *decl, lldb_private::TypeFromParser type) { assert (m_parser_vars.get()); @@ -211,7 +211,7 @@ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx; - clang::ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); + ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl)); @@ -273,7 +273,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable ( - const clang::NamedDecl *decl, + const NamedDecl *decl, const ConstString &name, TypeFromParser parser_type, bool is_result, @@ -285,7 +285,7 @@ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx; - clang::ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); + ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); TypeFromUser user_type(ClangASTContext::CopyType(context, parser_type.GetASTContext(), @@ -333,7 +333,7 @@ bool ClangExpressionDeclMap::AddValueToStruct ( - const clang::NamedDecl *decl, + const NamedDecl *decl, const ConstString &name, llvm::Value *value, size_t size, @@ -439,7 +439,7 @@ bool ClangExpressionDeclMap::GetStructElement ( - const clang::NamedDecl *&decl, + const NamedDecl *&decl, llvm::Value *&value, off_t &offset, ConstString &name, @@ -472,7 +472,7 @@ bool ClangExpressionDeclMap::GetFunctionInfo ( - const clang::NamedDecl *decl, + const NamedDecl *decl, llvm::Value**& value, uint64_t &ptr ) @@ -915,7 +915,7 @@ if (log) log->PutCString("Not bothering to allocate a struct because no arguments are needed"); - m_material_vars->m_allocated_area = 0; + m_material_vars->m_allocated_area = NULL; return true; } @@ -1674,61 +1674,57 @@ if (isa(context.m_decl_context)) break; - if (log) - log->Printf("'%s' is in something other than a translation unit", name.GetCString()); + if (!isa(context.m_decl_context)) + return; const Decl *context_decl = dyn_cast(context.m_decl_context); - - if (!context_decl) - return; - if (const NamespaceDecl *namespace_decl = dyn_cast(context_decl)) + if (log) + log->Printf("Searching for '%s' in a '%s'", name.GetCString(), context_decl->getDeclKindName()); + + Decl *original_decl = NULL; + ASTContext *original_ctx = NULL; + + if (!m_parser_vars->GetASTImporter(context.GetASTContext())->ResolveDeclOrigin(context_decl, &original_decl, &original_ctx)) + break; + + if (TagDecl *original_tag_decl = dyn_cast(original_decl)) { - Decl *original_decl = NULL; - ASTContext *original_ctx = NULL; - - if (log) - log->Printf("Resolving the containing context's origin..."); + ExternalASTSource *external_source = original_ctx->getExternalSource(); - if (!m_parser_vars->GetASTImporter(context.GetASTContext())->ResolveDeclOrigin(namespace_decl, &original_decl, &original_ctx)) + if (!external_source) break; - - if (log) - log->Printf("Casting it to a DeclContext..."); - - DeclContext *original_decl_context = dyn_cast(original_decl); - - if (!original_decl_context) + + if (!original_tag_decl) break; - if (log) - { - std::string s; - llvm::raw_string_ostream os(s); - original_decl->print(os); - os.flush(); - - log->Printf("Containing context:"); - log->Printf("%s", s.c_str()); - } - - if (!original_ctx->getExternalSource()) - break; + external_source->CompleteType (original_tag_decl); + } + + DeclContext *original_decl_context = dyn_cast(original_decl); + + if (!original_decl_context) + break; - DeclContextLookupConstResult original_lookup_result = original_ctx->getExternalSource()->FindExternalVisibleDeclsByName(original_decl_context, context.m_decl_name); - - NamedDecl *const *iter = NULL; + for (TagDecl::decl_iterator iter = original_decl_context->decls_begin(); + iter != original_decl_context->decls_end(); + ++iter) + { + NamedDecl *named_decl = dyn_cast(*iter); - for (iter = original_lookup_result.first; - iter != original_lookup_result.second; - ++iter) + if (named_decl && named_decl->getName().equals(name.GetCString())) { - clang::NamedDecl *copied_result = dyn_cast(m_parser_vars->GetASTImporter(context.GetASTContext())->CopyDecl(original_ctx, *iter)); + Decl *copied_decl = m_parser_vars->GetASTImporter(context.GetASTContext())->CopyDecl(original_ctx, named_decl); + NamedDecl *copied_named_decl = dyn_cast(copied_decl); + + if (!copied_named_decl) + continue; - if (copied_result) - context.AddNamedDecl(copied_result); + context.AddNamedDecl (copied_named_decl); } } + + return; } while (0); @@ -1824,7 +1820,7 @@ log->Printf("%s", s.c_str()); } - clang::NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decl); + NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decl); if (clang_namespace_decl) clang_namespace_decl->setHasExternalLexicalStorage(); } @@ -1976,44 +1972,103 @@ } } -const clang::DeclContext * -ClangExpressionDeclMap::CompleteDeclContext (clang::ASTContext *ast_context, - const clang::DeclContext *decl_context) +clang::ExternalLoadResult +ClangExpressionDeclMap::FindExternalLexicalDecls (const DeclContext *decl_context, + bool (*predicate)(Decl::Kind), + llvm::SmallVectorImpl &decls) { + assert (m_parser_vars.get()); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + + const Decl *context_decl = dyn_cast(decl_context); + + if (!context_decl) + return ELR_Failure; + + ASTContext *ast_context = &context_decl->getASTContext(); + + if (log) + log->Printf("Finding lexical decls in a '%s' with %s predicate", context_decl->getDeclKindName(), (predicate ? "non-null" : "null")); + + Decl *original_decl = NULL; + ASTContext *original_ctx = NULL; + + ClangASTImporter *ast_importer = m_parser_vars->GetASTImporter(ast_context); + + if (!ast_importer) + return ELR_Failure; + + if (!ast_importer->ResolveDeclOrigin(context_decl, &original_decl, &original_ctx)) + return ELR_Failure; + if (log) { - const NamedDecl *named_decl = dyn_cast(decl_context); + std::string decl_print_string; + llvm::raw_string_ostream decl_print_stream(decl_print_string); + original_decl->print(decl_print_stream); + decl_print_stream.flush(); + log->Printf("Original decl:\n%s", decl_print_string.c_str()); + } + + if (TagDecl *original_tag_decl = dyn_cast(original_decl)) + { + ExternalASTSource *external_source = original_ctx->getExternalSource(); - if (named_decl) - log->Printf("Completing a '%s' DeclContext named '%s'", decl_context->getDeclKindName(), named_decl->getDeclName().getAsString().c_str()); - else - log->Printf("Completing a '%s' DeclContext", decl_context->getDeclKindName()); + if (!external_source) + return ELR_Failure; + + if (!original_tag_decl) + return ELR_Failure; + + external_source->CompleteType (original_tag_decl); } - assert (m_parser_vars.get()); + DeclContext *original_decl_context = dyn_cast(original_decl); - if (!m_parser_vars->GetASTImporter (ast_context)->CompleteDeclContext(decl_context)) - return NULL; + if (!original_decl_context) + return ELR_Failure; - if (log) + for (TagDecl::decl_iterator iter = original_decl_context->decls_begin(); + iter != original_decl_context->decls_end(); + ++iter) { - const Decl *decl = dyn_cast(decl_context); + Decl *decl = *iter; - if (decl) + if (!predicate || predicate(decl->getKind())) { - std::string s; - llvm::raw_string_ostream os(s); - decl->print(os); - os.flush(); + if (log) + { + std::string decl_print_string; + llvm::raw_string_ostream decl_print_stream(decl_print_string); + decl->print(decl_print_stream); + decl_print_stream.flush(); + log->Printf(" Adding lexical decl %s", decl_print_string.c_str()); + } + + Decl *copied_decl = ast_importer->CopyDecl(original_ctx, decl); - log->Printf("After:"); - log->Printf("%s", s.c_str()); + decls.push_back(copied_decl); } } - return decl_context; + return ELR_AlreadyLoaded; +} + +void +ClangExpressionDeclMap::CompleteTagDecl (TagDecl *tag_decl) +{ + assert (m_parser_vars.get()); + + m_parser_vars->GetASTImporter(&tag_decl->getASTContext())->CompleteTagDecl (tag_decl); +} + +void +ClangExpressionDeclMap::CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl) +{ + assert (m_parser_vars.get()); + + m_parser_vars->GetASTImporter(&interface_decl->getASTContext())->CompleteObjCInterfaceDecl (interface_decl); } Value * @@ -2021,7 +2076,7 @@ ( ExecutionContext &exe_ctx, VariableSP var, - clang::ASTContext *parser_ast_context, + ASTContext *parser_ast_context, TypeFromUser *user_type, TypeFromParser *parser_type ) @@ -2046,7 +2101,7 @@ return NULL; } - clang::ASTContext *ast = var_type->GetClangASTContext().getASTContext(); + ASTContext *ast = var_type->GetClangASTContext().getASTContext(); if (!ast) { @@ -2170,12 +2225,12 @@ log->Printf("Found variable %s, returned %s", decl_name.c_str(), var_decl_print_string.c_str()); - if (log->GetVerbose()) - { - StreamString var_decl_dump_string; - ASTDumper::DumpDecl(var_decl_dump_string, var_decl); - log->Printf("%s\n", var_decl_dump_string.GetData()); - } + //if (log->GetVerbose()) + //{ + // StreamString var_decl_dump_string; + // ASTDumper::DumpDecl(var_decl_dump_string, var_decl); + // log->Printf("%s\n", var_decl_dump_string.GetData()); + //} } } @@ -2219,7 +2274,7 @@ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - clang::ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext(); + ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext(); TypeFromUser user_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(scratch_ast_context, true)), scratch_ast_context); @@ -2265,12 +2320,12 @@ log->Printf("Found variable %s, returned %s", decl_name.c_str(), var_decl_print_string.c_str()); - if (log->GetVerbose()) - { - StreamString var_decl_dump_string; - ASTDumper::DumpDecl(var_decl_dump_string, var_decl); - log->Printf("%s\n", var_decl_dump_string.GetData()); - } + //if (log->GetVerbose()) + //{ + // StreamString var_decl_dump_string; + // ASTDumper::DumpDecl(var_decl_dump_string, var_decl); + // log->Printf("%s\n", var_decl_dump_string.GetData()); + //} } } @@ -2279,7 +2334,7 @@ { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - clang::ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext(); + ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext(); for (size_t index = 0, num_entities = m_found_entities.GetSize(); index < num_entities; @@ -2374,17 +2429,17 @@ } } -clang::NamespaceDecl * +NamespaceDecl * ClangExpressionDeclMap::AddNamespace (NameSearchContext &context, const ClangNamespaceDecl &namespace_decl) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); assert (m_parser_vars.get()); - clang::Decl *copied_decl = m_parser_vars->GetASTImporter(context.GetASTContext())->CopyDecl(namespace_decl.GetASTContext(), + Decl *copied_decl = m_parser_vars->GetASTImporter(context.GetASTContext())->CopyDecl(namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl()); - return dyn_cast(copied_decl); + return dyn_cast(copied_decl); } void @@ -2402,7 +2457,7 @@ // only valid for Functions, not for Symbols void *fun_opaque_type = NULL; - clang::ASTContext *fun_ast_context = NULL; + ASTContext *fun_ast_context = NULL; if (fun) { @@ -2478,8 +2533,8 @@ TypeFromUser &ut, bool add_method) { - clang::ASTContext *parser_ast_context = context.GetASTContext(); - clang::ASTContext *user_ast_context = ut.GetASTContext(); + ASTContext *parser_ast_context = context.GetASTContext(); + ASTContext *user_ast_context = ut.GetASTContext(); void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType()); Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Fri Jul 29 21:42:06 2011 @@ -123,7 +123,6 @@ case ASTPrint: return new ASTPrintAction(); case ASTDumpXML: return new ASTDumpXMLAction(); case ASTView: return new ASTViewAction(); - case BoostCon: return new BoostConAction(); case DumpRawTokens: return new DumpRawTokensAction(); case DumpTokens: return new DumpTokensAction(); case EmitAssembly: return new EmitAssemblyAction(); @@ -199,6 +198,7 @@ InitializeLLVM() { llvm::InitializeAllTargets(); llvm::InitializeAllAsmPrinters(); + llvm::InitializeAllTargetMCs(); } } InitializeLLVM; @@ -557,9 +557,7 @@ RecordingMemoryManager *jit_memory_manager = new RecordingMemoryManager(); std::string error_string; - - llvm::TargetMachine::setRelocationModel(llvm::Reloc::PIC_); - + #if defined (USE_STANDARD_JIT) m_execution_engine.reset(llvm::ExecutionEngine::createJIT (module, &error_string, @@ -571,11 +569,12 @@ EngineBuilder builder(module); builder.setEngineKind(EngineKind::JIT) .setErrorStr(&error_string) + .setRelocationModel(llvm::Reloc::PIC_) .setJITMemoryManager(jit_memory_manager) .setOptLevel(CodeGenOpt::Less) .setAllocateGVsWithCode(true) .setCodeModel(CodeModel::Small) - .setUseMCJIT(true); + .setUseMCJIT(true); m_execution_engine.reset(builder.create()); #endif Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original) +++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Fri Jul 29 21:42:06 2011 @@ -258,12 +258,14 @@ //------------------------------------------------------------------ llvm::Value *BuildPointerValidatorFunc(lldb::addr_t start_address) { - std::vector params; - - const IntegerType *intptr_ty = llvm::Type::getIntNTy(m_module.getContext(), + IntegerType *intptr_ty = llvm::Type::getIntNTy(m_module.getContext(), (m_module.getPointerSize() == llvm::Module::Pointer64) ? 64 : 32); - params.push_back(GetI8PtrTy()); + llvm::Type *param_array[1]; + + param_array[0] = const_cast(GetI8PtrTy()); + + ArrayRef params(param_array, 1); FunctionType *fun_ty = FunctionType::get(llvm::Type::getVoidTy(m_module.getContext()), params, true); PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty); @@ -271,7 +273,7 @@ return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty); } - const PointerType *GetI8PtrTy() + PointerType *GetI8PtrTy() { if (!m_i8ptr_ty) m_i8ptr_ty = llvm::Type::getInt8PtrTy(m_module.getContext()); @@ -286,7 +288,7 @@ llvm::Module &m_module; ///< The module which is being instrumented DynamicCheckerFunctions &m_checker_functions; ///< The dynamic checker functions for the process private: - const PointerType *m_i8ptr_ty; + PointerType *m_i8ptr_ty; }; class ValidPointerChecker : public Instrumenter @@ -332,12 +334,14 @@ // Insert an instruction to call the helper with the result - SmallVector args; - args.push_back(bit_cast); + llvm::Value *arg_array[1]; + + arg_array[0] = bit_cast; + + llvm::ArrayRef args(arg_array, 1); CallInst::Create(m_valid_pointer_check_func, - args.begin(), - args.end(), + args, "", inst); @@ -397,12 +401,14 @@ // Insert an instruction to call the helper with the result - SmallVector args; - args.push_back(bit_cast); + llvm::Value *arg_array[1]; + + arg_array[0] = bit_cast; + + ArrayRef args(arg_array, 1); CallInst::Create(m_objc_object_check_func, - args.begin(), - args.end(), + args, "", inst); Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Fri Jul 29 21:42:06 2011 @@ -310,24 +310,28 @@ ValueSymbolTable& value_symbol_table = m_module->getValueSymbolTable(); + std::string result_name_str; const char *result_name = NULL; for (ValueSymbolTable::iterator vi = value_symbol_table.begin(), ve = value_symbol_table.end(); vi != ve; ++vi) { - if (strstr(vi->first(), "$__lldb_expr_result_ptr") && - !strstr(vi->first(), "GV")) + result_name_str = vi->first().str(); + const char *value_name = result_name_str.c_str(); + + if (strstr(value_name, "$__lldb_expr_result_ptr") && + !strstr(value_name, "GV")) { - result_name = vi->first(); + result_name = value_name; m_result_is_pointer = true; break; } - if (strstr(vi->first(), "$__lldb_expr_result") && - !strstr(vi->first(), "GV")) + if (strstr(value_name, "$__lldb_expr_result") && + !strstr(value_name, "GV")) { - result_name = vi->first(); + result_name = value_name; m_result_is_pointer = false; break; } @@ -580,13 +584,13 @@ { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - const Type *ns_str_ty = ns_str->getType(); + Type *ns_str_ty = ns_str->getType(); - const Type *i8_ptr_ty = Type::getInt8PtrTy(m_module->getContext()); - const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + Type *i8_ptr_ty = Type::getInt8PtrTy(m_module->getContext()); + IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); - const Type *i32_ty = Type::getInt32Ty(m_module->getContext()); - const Type *i8_ty = Type::getInt8Ty(m_module->getContext()); + Type *i32_ty = Type::getInt32Ty(m_module->getContext()); + Type *i8_ty = Type::getInt8Ty(m_module->getContext()); if (!m_CFStringCreateWithBytes) { @@ -627,12 +631,16 @@ // CFStringEncoding -> i32 // Boolean -> i8 - std::vector CFSCWB_arg_types; - CFSCWB_arg_types.push_back(i8_ptr_ty); - CFSCWB_arg_types.push_back(i8_ptr_ty); - CFSCWB_arg_types.push_back(intptr_ty); - CFSCWB_arg_types.push_back(i32_ty); - CFSCWB_arg_types.push_back(i8_ty); + Type *arg_type_array[5]; + + arg_type_array[0] = i8_ptr_ty; + arg_type_array[1] = i8_ptr_ty; + arg_type_array[2] = intptr_ty; + arg_type_array[3] = i32_ty; + arg_type_array[4] = i8_ty; + + ArrayRef CFSCWB_arg_types(arg_type_array, 5); + llvm::Type *CFSCWB_ty = FunctionType::get(ns_str_ty, CFSCWB_arg_types, false); // Build the constant containing the pointer to the function @@ -645,24 +653,25 @@ if (cstr) string_array = dyn_cast(cstr->getInitializer()); - - SmallVector CFSCWB_arguments; - + Constant *alloc_arg = Constant::getNullValue(i8_ptr_ty); Constant *bytes_arg = cstr ? ConstantExpr::getBitCast(cstr, i8_ptr_ty) : Constant::getNullValue(i8_ptr_ty); Constant *numBytes_arg = ConstantInt::get(intptr_ty, cstr ? string_array->getType()->getNumElements() - 1 : 0, false); Constant *encoding_arg = ConstantInt::get(i32_ty, 0x0600, false); /* 0x0600 is kCFStringEncodingASCII */ Constant *isExternal_arg = ConstantInt::get(i8_ty, 0x0, false); /* 0x0 is false */ - CFSCWB_arguments.push_back(alloc_arg); - CFSCWB_arguments.push_back(bytes_arg); - CFSCWB_arguments.push_back(numBytes_arg); - CFSCWB_arguments.push_back(encoding_arg); - CFSCWB_arguments.push_back(isExternal_arg); + Value *argument_array[5]; + + argument_array[0] = alloc_arg; + argument_array[1] = bytes_arg; + argument_array[2] = numBytes_arg; + argument_array[3] = encoding_arg; + argument_array[4] = isExternal_arg; + + ArrayRef CFSCWB_arguments(argument_array, 5); CallInst *CFSCWB_call = CallInst::Create(m_CFStringCreateWithBytes, - CFSCWB_arguments.begin(), - CFSCWB_arguments.end(), + CFSCWB_arguments, "CFStringCreateWithBytes", FirstEntryInstruction); @@ -707,7 +716,10 @@ vi != ve; ++vi) { - if (strstr(vi->first(), "_unnamed_cfstring_")) + std::string value_name = vi->first().str(); + const char *value_name_cstr = value_name.c_str(); + + if (strstr(value_name_cstr, "_unnamed_cfstring_")) { Value *nsstring_value = vi->second; @@ -860,9 +872,9 @@ if (log) { if (cstr_array) - log->Printf("Found NSString constant %s, which contains \"%s\"", vi->first(), cstr_array->getAsString().c_str()); + log->Printf("Found NSString constant %s, which contains \"%s\"", value_name_cstr, cstr_array->getAsString().c_str()); else - log->Printf("Found NSString constant %s, which contains \"\"", vi->first()); + log->Printf("Found NSString constant %s, which contains \"\"", value_name_cstr); } if (!cstr_array) @@ -884,7 +896,10 @@ vi != ve; ++vi) { - if (!strcmp(vi->first(), "__CFConstantStringClassReference")) + std::string value_name = vi->first().str(); + const char *value_name_cstr = value_name.c_str(); + + if (!strcmp(value_name_cstr, "__CFConstantStringClassReference")) { GlobalVariable *gv = dyn_cast(vi->second); @@ -995,29 +1010,34 @@ // The below code would be "more correct," but in actuality what's required is uint8_t* //Type *sel_type = StructType::get(m_module->getContext()); //Type *sel_ptr_type = PointerType::getUnqual(sel_type); - const Type *sel_ptr_type = Type::getInt8PtrTy(m_module->getContext()); + Type *sel_ptr_type = Type::getInt8PtrTy(m_module->getContext()); + + Type *type_array[1]; + + type_array[0] = llvm::Type::getInt8PtrTy(m_module->getContext()); + + ArrayRef srN_arg_types(type_array, 1); - std::vector srN_arg_types; - srN_arg_types.push_back(Type::getInt8PtrTy(m_module->getContext())); llvm::Type *srN_type = FunctionType::get(sel_ptr_type, srN_arg_types, false); // Build the constant containing the pointer to the function - const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), - (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); + IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); PointerType *srN_ptr_ty = PointerType::getUnqual(srN_type); Constant *srN_addr_int = ConstantInt::get(intptr_ty, sel_registerName_addr, false); m_sel_registerName = ConstantExpr::getIntToPtr(srN_addr_int, srN_ptr_ty); } - SmallVector srN_arguments; - + Value *argument_array[1]; + Constant *omvn_pointer = ConstantExpr::getBitCast(_objc_meth_var_name_, Type::getInt8PtrTy(m_module->getContext())); - srN_arguments.push_back(omvn_pointer); + argument_array[0] = omvn_pointer; + ArrayRef srN_arguments(argument_array, 1); + CallInst *srN_call = CallInst::Create(m_sel_registerName, - srN_arguments.begin(), - srN_arguments.end(), + srN_arguments, "sel_registerName", selector_load); @@ -1338,10 +1358,10 @@ if (log) log->Printf("Found \"%s\" at 0x%llx", name.GetCString(), symbol_addr); - const Type *symbol_type = symbol->getType(); + Type *symbol_type = symbol->getType(); - const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), - (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); + IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); Constant *symbol_addr_int = ConstantInt::get(intptr_ty, symbol_addr, false); @@ -1398,7 +1418,7 @@ if (!fun) { if (m_error_stream) - m_error_stream->Printf("Internal error [IRForTarget]: Called entity is a cast of something not a function\n"); + m_error_stream->Printf("Internal error [IRForTaget]: Called entity is a cast of something not a function\n"); return false; } @@ -1495,9 +1515,9 @@ if (!fun_value_ptr || !*fun_value_ptr) { - const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), - (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); - const FunctionType *fun_ty = fun->getFunctionType(); + IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); + FunctionType *fun_ty = fun->getFunctionType(); PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty); Constant *fun_addr_int = ConstantInt::get(intptr_ty, fun_addr, false); fun_addr_ptr = ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty); @@ -1636,7 +1656,7 @@ m_data_allocator->GetStream().Write(str.c_str(), str.length() + 1); } - const Type *char_ptr_ty = Type::getInt8PtrTy(m_module->getContext()); + Type *char_ptr_ty = Type::getInt8PtrTy(m_module->getContext()); for (OffsetsTy::iterator oi = offsets.begin(), oe = offsets.end(); oi != oe; @@ -1789,7 +1809,7 @@ m_data_allocator->GetStream().Write(data.GetBytes(), operand_data_size); - const llvm::Type *fp_ptr_ty = operand_constant_fp->getType()->getPointerTo(); + llvm::Type *fp_ptr_ty = operand_constant_fp->getType()->getPointerTo(); Constant *new_pointer = BuildRelocation(fp_ptr_ty, offset); @@ -1961,8 +1981,8 @@ if (ptr == old_constant) ptr = new_constant; - - SmallVector indices; + + std::vector index_vector; unsigned operand_index; unsigned num_operands = constant_expr->getNumOperands(); @@ -1976,10 +1996,12 @@ if (operand == old_constant) operand = new_constant; - indices.push_back(operand); + index_vector.push_back(operand); } - GetElementPtrInst *get_element_ptr(GetElementPtrInst::Create(ptr, indices.begin(), indices.end(), "", first_entry_inst)); + ArrayRef indices(index_vector); + + GetElementPtrInst *get_element_ptr(GetElementPtrInst::Create(ptr, indices, "", first_entry_inst)); UnfoldConstant(constant_expr, get_element_ptr, first_entry_inst); } @@ -2107,7 +2129,7 @@ } LLVMContext &context(m_module->getContext()); - const IntegerType *offset_type(Type::getInt32Ty(context)); + IntegerType *offset_type(Type::getInt32Ty(context)); if (!offset_type) { @@ -2139,7 +2161,7 @@ PrintValue(value, true).c_str(), offset); - ConstantInt *offset_int(ConstantInt::getSigned(offset_type, offset)); + ConstantInt *offset_int(ConstantInt::get(offset_type, offset, true)); GetElementPtrInst *get_element_ptr = GetElementPtrInst::Create(argument, offset_int, "", FirstEntryInstruction); Value *replacement = NULL; @@ -2178,16 +2200,23 @@ } llvm::Constant * -IRForTarget::BuildRelocation(const llvm::Type *type, +IRForTarget::BuildRelocation(llvm::Type *type, uint64_t offset) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), - (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); + IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); llvm::Constant *offset_int = ConstantInt::get(intptr_ty, offset); - llvm::Constant *reloc_getelementptr = ConstantExpr::getGetElementPtr(m_reloc_placeholder, &offset_int, 1); + + llvm::Constant *offset_array[1]; + + offset_array[0] = offset_int; + + llvm::ArrayRef offsets(offset_array, 1); + + llvm::Constant *reloc_getelementptr = ConstantExpr::getGetElementPtr(m_reloc_placeholder, offsets); llvm::Constant *reloc_getbitcast = ConstantExpr::getBitCast(reloc_getelementptr, type); return reloc_getbitcast; @@ -2214,8 +2243,8 @@ if (!allocation) return false; - const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), - (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); + IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); Constant *relocated_addr = ConstantInt::get(intptr_ty, (uint64_t)allocation); Constant *relocated_bitcast = ConstantExpr::getIntToPtr(relocated_addr, llvm::Type::getInt8PtrTy(m_module->getContext())); @@ -2255,7 +2284,7 @@ return false; } - const llvm::Type *intptr_ty = Type::getInt8Ty(m_module->getContext()); + llvm::Type *intptr_ty = Type::getInt8Ty(m_module->getContext()); m_reloc_placeholder = new llvm::GlobalVariable((*m_module), intptr_ty, 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=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Jul 29 21:42:06 2011 @@ -22,6 +22,8 @@ #include "clang/Basic/Specifiers.h" #include "clang/Sema/DeclSpec.h" +#include "llvm/Support/Casting.h" + #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/RegularExpression.h" @@ -4437,16 +4439,35 @@ } void -SymbolFileDWARF::SearchNamespace (const clang::NamespaceDecl *namespace_decl, - const char *name, - llvm::SmallVectorImpl *results) +SymbolFileDWARF::DumpIndexes () +{ + StreamFile s(stdout, false); + + s.Printf ("DWARF index for (%s) '%s/%s':", + GetObjectFile()->GetModule()->GetArchitecture().GetArchitectureName(), + GetObjectFile()->GetFileSpec().GetDirectory().AsCString(), + GetObjectFile()->GetFileSpec().GetFilename().AsCString()); + s.Printf("\nFunction basenames:\n"); m_function_basename_index.Dump (&s); + s.Printf("\nFunction fullnames:\n"); m_function_fullname_index.Dump (&s); + s.Printf("\nFunction methods:\n"); m_function_method_index.Dump (&s); + s.Printf("\nFunction selectors:\n"); m_function_selector_index.Dump (&s); + s.Printf("\nObjective C class selectors:\n"); m_objc_class_selectors_index.Dump (&s); + s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s); + s.Printf("\nTypes:\n"); m_type_index.Dump (&s); + s.Printf("\nNamepaces:\n"); m_namespace_index.Dump (&s); +} + +void +SymbolFileDWARF::SearchDeclContext (const clang::DeclContext *decl_context, + const char *name, + llvm::SmallVectorImpl *results) { - DeclContextToDIEMap::iterator iter = m_decl_ctx_to_die.find((const clang::DeclContext*)namespace_decl); + DeclContextToDIEMap::iterator iter = m_decl_ctx_to_die.find(decl_context); if (iter == m_decl_ctx_to_die.end()) return; - const DWARFDebugInfoEntry *namespace_die = iter->second; + const DWARFDebugInfoEntry *context_die = iter->second; if (!results) return; @@ -4467,7 +4488,7 @@ compile_unit->ExtractDIEsIfNeeded (false); const DWARFDebugInfoEntry *die = compile_unit->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); - if (die->GetParent() != namespace_die) + if (die->GetParent() != context_die) continue; Type *matching_type = ResolveType (compile_unit, die); @@ -4475,13 +4496,12 @@ lldb::clang_type_t type = matching_type->GetClangFullType(); clang::QualType qual_type = clang::QualType::getFromOpaquePtr(type); - - if (const clang::TagType *tag_type = dyn_cast(qual_type.getTypePtr())) + if (const clang::TagType *tag_type = llvm::dyn_cast(qual_type.getTypePtr())) { clang::TagDecl *tag_decl = tag_type->getDecl(); results->push_back(tag_decl); } - else if (const clang::TypedefType *typedef_type = dyn_cast(qual_type.getTypePtr())) + else if (const clang::TypedefType *typedef_type = llvm::dyn_cast(qual_type.getTypePtr())) { clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl(); results->push_back(typedef_decl); @@ -4498,7 +4518,5 @@ { SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton; - const clang::NamespaceDecl *DC_namespace = llvm::dyn_cast(DC); - - symbol_file_dwarf->SearchNamespace (DC_namespace, Name.getAsString().c_str(), results); + symbol_file_dwarf->SearchDeclContext (DC, Name.getAsString().c_str(), results); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Jul 29 21:42:06 2011 @@ -189,10 +189,10 @@ GetClangDeclContextForDIEOffset (dw_offset_t die_offset); void - SearchNamespace (const clang::NamespaceDecl *namespace_decl, - const char *name, - llvm::SmallVectorImpl *results); - + SearchDeclContext (const clang::DeclContext *decl_context, + const char *name, + llvm::SmallVectorImpl *results); + lldb_private::Flags& GetFlags () { @@ -317,6 +317,8 @@ uint32_t FindTypes(std::vector die_offsets, uint32_t max_matches, lldb_private::TypeList& types); void Index(); + + void DumpIndexes(); void SetDebugMapSymfile (SymbolFileDWARFDebugMap *debug_map_symfile) { Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Jul 29 21:42:06 2011 @@ -1607,9 +1607,10 @@ SourceLocation(), name ? &identifier_table->get(name) : NULL, // Identifier QualType::getFromOpaquePtr(field_type), // Field type - NULL, // DeclaratorInfo * + NULL, // TInfo * bit_width, // BitWidth - false); // Mutable + false, // Mutable + false); // HasInit field->setAccess (ConvertAccessTypeToAccessSpecifier (access)); @@ -3170,7 +3171,7 @@ //const Decl *root_cdecl = cxx_record_decl->getCanonicalDecl(); // Didn't find things easily, lets let clang do its thang... - IdentifierInfo & ident_ref = ast->Idents.get(name, name + strlen (name)); + IdentifierInfo & ident_ref = ast->Idents.get(name_sref); DeclarationName decl_name(&ident_ref); CXXBasePaths paths; @@ -3647,6 +3648,7 @@ const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { + case clang::Type::UnaryTransform: break; case clang::Type::FunctionNoProto: break; case clang::Type::FunctionProto: break; case clang::Type::IncompleteArray: break; Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Fri Jul 29 21:42:06 2011 @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// #include "clang/AST/Decl.h" +#include "clang/AST/DeclObjC.h" +#include "lldb/Core/Log.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTImporter.h" @@ -19,8 +21,10 @@ clang::QualType type) { MinionSP minion_sp (GetMinion(src_ast, false)); + if (minion_sp) return minion_sp->Import(type); + return QualType(); } @@ -37,28 +41,84 @@ if (minion_sp) return minion_sp->Import(decl); + return NULL; } -const clang::DeclContext * -ClangASTImporter::CompleteDeclContext (const clang::DeclContext *decl_context) +void +ClangASTImporter::CompleteTagDecl (clang::TagDecl *decl) { - const Decl *context_decl = dyn_cast(decl_context); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (log) + log->Printf("Completing a TagDecl named %s", decl->getName().str().c_str()); - if (!context_decl) - return NULL; + DeclOrigin decl_origin = GetDeclOrigin(decl); - DeclOrigin context_decl_origin = GetDeclOrigin(context_decl); + if (!decl_origin.Valid()) + return; - if (!context_decl_origin.Valid()) - return NULL; + if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl)) + return; - if (!ClangASTContext::GetCompleteDecl(context_decl_origin.ctx, context_decl_origin.decl)) - return NULL; + MinionSP minion_sp (GetMinion(decl_origin.ctx, false)); - MinionSP minion_sp (GetMinion(context_decl_origin.ctx, false)); if (minion_sp) - minion_sp->ImportDefinition(context_decl_origin.decl); + minion_sp->ImportDefinition(decl_origin.decl); - return decl_context; + return; } + +void +ClangASTImporter::CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl) +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (log) + log->Printf("Completing an ObjCInterfaceDecl named %s", interface_decl->getName().str().c_str()); + + DeclOrigin decl_origin = GetDeclOrigin(interface_decl); + + if (!decl_origin.Valid()) + return; + + if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl)) + return; + + MinionSP minion_sp (GetMinion(decl_origin.ctx, false)); + + if (minion_sp) + minion_sp->ImportDefinition(decl_origin.decl); + + return; +} + +clang::Decl +*ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + m_master.m_origins[to] = DeclOrigin (m_source_ctx, from); + + if (TagDecl *from_tag_decl = dyn_cast(from)) + { + TagDecl *to_tag_decl = dyn_cast(to); + + to_tag_decl->setHasExternalLexicalStorage(); + + if (log) + log->Printf("Imported a TagDecl named %s%s%s", + from_tag_decl->getName().str().c_str(), + (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""), + (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : "")); + } + + if (isa(from)) + { + ObjCInterfaceDecl *to_interface_decl = dyn_cast(to); + + to_interface_decl->setExternallyCompleted(); + } + + return clang::ASTImporter::Imported(from, to); +} \ No newline at end of file Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Jul 29 21:42:06 2011 @@ -194,7 +194,7 @@ default: break; case clang::Type::Builtin: - switch (cast(qual_type)->getKind()) + switch (llvm::cast(qual_type)->getKind()) { default: case clang::BuiltinType::Void: @@ -238,7 +238,7 @@ } break; case clang::Type::Typedef: - return GetMinimumLanguage(cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); + return GetMinimumLanguage(llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); } } return lldb::eLanguageTypeC; @@ -252,6 +252,9 @@ switch (qual_type->getTypeClass()) { + case clang::Type::UnaryTransform: + break; + case clang::Type::FunctionNoProto: case clang::Type::FunctionProto: break; @@ -269,7 +272,7 @@ break; case clang::Type::Builtin: - switch (cast(qual_type)->getKind()) + switch (llvm::cast(qual_type)->getKind()) { default: assert(0 && "Unknown builtin type!"); case clang::BuiltinType::Void: @@ -337,7 +340,7 @@ case clang::Type::Record: break; case clang::Type::Enum: return lldb::eEncodingSint; case clang::Type::Typedef: - return GetEncoding(cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), count); + return GetEncoding(llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), count); break; case clang::Type::DependentSizedArray: @@ -379,6 +382,9 @@ switch (qual_type->getTypeClass()) { + case clang::Type::UnaryTransform: + break; + case clang::Type::FunctionNoProto: case clang::Type::FunctionProto: break; @@ -395,7 +401,7 @@ break; case clang::Type::Builtin: - switch (cast(qual_type)->getKind()) + switch (llvm::cast(qual_type)->getKind()) { //default: assert(0 && "Unknown builtin type!"); case clang::BuiltinType::UnknownAny: @@ -450,7 +456,7 @@ case clang::Type::Record: break; case clang::Type::Enum: return lldb::eFormatEnum; case clang::Type::Typedef: - return ClangASTType::GetFormat(cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); + return ClangASTType::GetFormat(llvm::cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: @@ -538,7 +544,7 @@ case clang::Type::Record: if (ClangASTContext::GetCompleteType (ast_context, clang_type)) { - const clang::RecordType *record_type = cast(qual_type.getTypePtr()); + const clang::RecordType *record_type = llvm::cast(qual_type.getTypePtr()); const clang::RecordDecl *record_decl = record_type->getDecl(); assert(record_decl); uint32_t field_bit_offset = 0; @@ -547,7 +553,7 @@ uint32_t child_idx = 0; - const clang::CXXRecordDecl *cxx_record_decl = dyn_cast(record_decl); + const clang::CXXRecordDecl *cxx_record_decl = llvm::dyn_cast(record_decl); if (cxx_record_decl) { // We might have base classes to print out first @@ -556,7 +562,7 @@ base_class != base_class_end; ++base_class) { - const clang::CXXRecordDecl *base_class_decl = cast(base_class->getType()->getAs()->getDecl()); + const clang::CXXRecordDecl *base_class_decl = llvm::cast(base_class->getType()->getAs()->getDecl()); // Skip empty base classes if (verbose == false && ClangASTContext::RecordHasFields(base_class_decl) == false) @@ -667,7 +673,7 @@ case clang::Type::Enum: if (ClangASTContext::GetCompleteType (ast_context, clang_type)) { - const clang::EnumType *enum_type = cast(qual_type.getTypePtr()); + const clang::EnumType *enum_type = llvm::cast(qual_type.getTypePtr()); const clang::EnumDecl *enum_decl = enum_type->getDecl(); assert(enum_decl); clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; @@ -689,7 +695,7 @@ case clang::Type::ConstantArray: { - const clang::ConstantArrayType *array = cast(qual_type.getTypePtr()); + const clang::ConstantArrayType *array = llvm::cast(qual_type.getTypePtr()); bool is_array_of_characters = false; clang::QualType element_qual_type = array->getElementType(); @@ -759,7 +765,7 @@ case clang::Type::Typedef: { - clang::QualType typedef_qual_type = cast(qual_type)->getDecl()->getUnderlyingType(); + clang::QualType typedef_qual_type = llvm::cast(qual_type)->getDecl()->getUnderlyingType(); lldb::Format typedef_format = ClangASTType::GetFormat(typedef_qual_type.getAsOpaquePtr()); std::pair typedef_type_info = ast_context->getTypeInfo(typedef_qual_type); uint64_t typedef_byte_size = typedef_type_info.first / 8; @@ -844,7 +850,7 @@ { case clang::Type::Typedef: { - clang::QualType typedef_qual_type = cast(qual_type)->getDecl()->getUnderlyingType(); + clang::QualType typedef_qual_type = llvm::cast(qual_type)->getDecl()->getUnderlyingType(); if (format == eFormatDefault) format = ClangASTType::GetFormat(typedef_qual_type.getAsOpaquePtr()); std::pair typedef_type_info = ast_context->getTypeInfo(typedef_qual_type); @@ -867,7 +873,7 @@ // its enumeration string value, else just display it as requested. if ((format == eFormatEnum || format == eFormatDefault) && ClangASTContext::GetCompleteType (ast_context, clang_type)) { - const clang::EnumType *enum_type = cast(qual_type.getTypePtr()); + const clang::EnumType *enum_type = llvm::cast(qual_type.getTypePtr()); const clang::EnumDecl *enum_decl = enum_type->getDecl(); assert(enum_decl); clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; @@ -1073,7 +1079,7 @@ ClangASTType::IsDefined (clang_type_t clang_type) { clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - const clang::TagType *tag_type = dyn_cast(qual_type.getTypePtr()); + const clang::TagType *tag_type = llvm::dyn_cast(qual_type.getTypePtr()); if (tag_type) { clang::TagDecl *tag_decl = tag_type->getDecl(); @@ -1083,7 +1089,7 @@ } else { - const clang::ObjCObjectType *objc_class_type = dyn_cast(qual_type); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast(qual_type); if (objc_class_type) { clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); @@ -1126,7 +1132,7 @@ llvm::SmallVector buf; llvm::raw_svector_ostream llvm_ostrm (buf); - const clang::TagType *tag_type = dyn_cast(qual_type.getTypePtr()); + const clang::TagType *tag_type = llvm::dyn_cast(qual_type.getTypePtr()); if (tag_type) { clang::TagDecl *tag_decl = tag_type->getDecl(); @@ -1141,7 +1147,7 @@ case clang::Type::ObjCObject: case clang::Type::ObjCInterface: { - const clang::ObjCObjectType *objc_class_type = dyn_cast(qual_type.getTypePtr()); + const clang::ObjCObjectType *objc_class_type = llvm::dyn_cast(qual_type.getTypePtr()); assert (objc_class_type); if (objc_class_type) { Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=136555&r1=136554&r2=136555&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Fri Jul 29 21:42:06 2011 @@ -17,6 +17,7 @@ #include "lldb/Symbol/SymbolVendor.h" #include "clang/AST/Type.h" #include "clang/AST/CanonicalType.h" +#include "llvm/Support/Casting.h" using namespace lldb; using namespace lldb_private; @@ -414,7 +415,7 @@ Function::GetReturnClangType () { clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType())); - const clang::FunctionType *function_type = dyn_cast (clang_type); + const clang::FunctionType *function_type = llvm::dyn_cast (clang_type); if (function_type) return function_type->getResultType().getAsOpaquePtr(); return NULL; @@ -428,7 +429,7 @@ if (!clang_type->isFunctionProtoType()) return -1; - const clang::FunctionProtoType *function_proto_type = dyn_cast(clang_type); + const clang::FunctionProtoType *function_proto_type = llvm::dyn_cast(clang_type); if (function_proto_type != NULL) return function_proto_type->getNumArgs(); @@ -439,7 +440,7 @@ Function::GetArgumentTypeAtIndex (size_t idx) { clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType())); - const clang::FunctionProtoType *function_proto_type = dyn_cast(clang_type); + const clang::FunctionProtoType *function_proto_type = llvm::dyn_cast(clang_type); if (function_proto_type) { unsigned num_args = function_proto_type->getNumArgs(); @@ -459,7 +460,7 @@ if (!clang_type->isFunctionProtoType()) return false; - const clang::FunctionProtoType *function_proto_type = dyn_cast(clang_type); + const clang::FunctionProtoType *function_proto_type = llvm::dyn_cast(clang_type); if (function_proto_type) return function_proto_type->isVariadic(); From johnso87 at crhc.illinois.edu Fri Jul 29 22:18:30 2011 From: johnso87 at crhc.illinois.edu (Matt Johnson) Date: Fri, 29 Jul 2011 22:18:30 -0500 Subject: [Lldb-commits] [PATCH] Add reloc arg to standard JIT createJIT() Message-ID: <4E337806.5040800@crhc.illinois.edu> This patch fixes non-__APPLE__ builds by adding the extra reloc model argument to createJIT() (introduced in r135468). With this one-liner, LLDB r136555 with ToT LLVM/Clang compiles under Ubuntu 11.04, G++ 4.5.2. -Matt -------------- next part -------------- A non-text attachment was scrubbed... Name: reloc.diff Type: text/x-diff Size: 711 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110729/059eea59/attachment.bin From gclayton at apple.com Sat Jul 30 17:25:25 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 30 Jul 2011 22:25:25 -0000 Subject: [Lldb-commits] [lldb] r136578 - /lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py Message-ID: <20110730222525.C4E942A6C12C@llvm.org> Author: gclayton Date: Sat Jul 30 17:25:25 2011 New Revision: 136578 URL: http://llvm.org/viewvc/llvm-project?rev=136578&view=rev Log: Protect a bit better against uninitialized vectors. Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py?rev=136578&r1=136577&r2=136578&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdVectorSynthProvider.py Sat Jul 30 17:25:25 2011 @@ -1,25 +1,55 @@ class StdVectorSynthProvider: + def __init__(self, valobj, dict): self.valobj = valobj; self.update() + def num_children(self): - start_val = int(self.Mstart.GetValue(),0) - finish_val = int(self.Mfinish.GetValue(),0) - return (finish_val-start_val)/self.data_size + start_val = int(self.start.GetValue(),0) + finish_val = int(self.finish.GetValue(),0) + end_val = int(self.end.GetValue(),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 + + # We might still get things wrong, so cap things at 256 items for now + # TODO: read a target "settings set" variable for this to allow it to + # be customized + num_children = (finish_val-start_val)/self.data_size + if num_children > 256: + return 256 + return num_children + def get_child_index(self,name): if name == "len": return self.num_children(); else: return int(name.lstrip('[').rstrip(']')) + def get_child_at_index(self,index): if index == self.num_children(): return self.valobj.CreateValueFromExpression("len",str(self.num_children())) else: offset = index * self.data_size - return self.Mstart.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) + return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) + def update(self): - self.Mimpl = self.valobj.GetChildMemberWithName('_M_impl') - self.Mstart = self.Mimpl.GetChildMemberWithName('_M_start') - self.Mfinish = self.Mimpl.GetChildMemberWithName('_M_finish') - self.data_type = self.Mstart.GetType().GetPointeeType() + 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() From gclayton at apple.com Sat Jul 30 17:26:17 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 30 Jul 2011 22:26:17 -0000 Subject: [Lldb-commits] [lldb] r136579 - /lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py Message-ID: <20110730222618.063462A6C12C@llvm.org> Author: gclayton Date: Sat Jul 30 17:26:17 2011 New Revision: 136579 URL: http://llvm.org/viewvc/llvm-project?rev=136579&view=rev Log: Protect a bit against uninitialized std::list objects, but there is more work to be done. Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py?rev=136579&r1=136578&r2=136579&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/StdListSynthProvider.py Sat Jul 30 17:26:17 2011 @@ -1,61 +1,68 @@ import re class StdListSynthProvider: + def __init__(self, valobj, dict): - self.valobj = valobj; + self.valobj = valobj self.update() + def num_children(self): - next_val = int(self.Mnext.GetValue(),0) - prev_val = int(self.Mprev.GetValue(),0) - if next_val == 0: - return 0; - if next_val == self.Mnode_address: - return 0; + next_val = int(self.next.GetValue(),0) + prev_val = int(self.prev.GetValue(),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; + return 1 size = 2 - current = self.Mnext - while int(current.GetChildMemberWithName('_M_next').GetValue(),0) != self.Mnode_address: - size = size + 1; + current = self.next + while int(current.GetChildMemberWithName('_M_next').GetValue(),0) != self.node_address: + size = size + 1 current = current.GetChildMemberWithName('_M_next') return (size - 1) + def get_child_index(self,name): if name == "len": - return self.num_children(); + return self.num_children() else: return int(name.lstrip('[').rstrip(']')) + def get_child_at_index(self,index): if index == self.num_children(): return self.valobj.CreateValueFromExpression("len",str(self.num_children())) else: offset = index - current = self.Mnext; + current = self.next while offset > 0: - current = current.GetChildMemberWithName('_M_next'); - offset = offset - 1; + 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; + count_of_template = count_of_template + 1 elif self.type_name[index] == '>': - count_of_template = count_of_template - 1; + 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; + index = index + 1 self.type_name_nospaces = self.type_name.replace(", ", ",") + def update(self): - self.Mimpl = self.valobj.GetChildMemberWithName('_M_impl') - self.Mnode = self.Mimpl.GetChildMemberWithName('_M_node') - self.extract_type_name(self.Mimpl.GetType().GetName()) - self.Mnode_address = int(self.valobj.AddressOf().GetValue(), 0) - self.Mnext = self.Mnode.GetChildMemberWithName('_M_next') - self.Mprev = self.Mnode.GetChildMemberWithName('_M_prev') - self.data_type = self.Mnode.GetTarget().FindFirstType(self.type_name) + impl = self.valobj.GetChildMemberWithName('_M_impl') + node = impl.GetChildMemberWithName('_M_node') + self.extract_type_name(impl.GetType().GetName()) + self.node_address = int(self.valobj.AddressOf().GetValue(), 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 = self.Mnode.GetTarget().FindFirstType(self.type_name_nospaces) + self.data_type = node.GetTarget().FindFirstType(self.type_name_nospaces) self.data_size = self.data_type.GetByteSize() From peter at pcc.me.uk Sat Jul 30 17:42:24 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Sat, 30 Jul 2011 22:42:24 -0000 Subject: [Lldb-commits] [lldb] r136580 - /lldb/trunk/source/Expression/ClangExpressionParser.cpp Message-ID: <20110730224224.E7B0C2A6C12C@llvm.org> Author: pcc Date: Sat Jul 30 17:42:24 2011 New Revision: 136580 URL: http://llvm.org/viewvc/llvm-project?rev=136580&view=rev Log: Add reloc arg to standard JIT createJIT() Fixes non-__APPLE__ build. Patch by Matt Johnson! Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=136580&r1=136579&r2=136580&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Sat Jul 30 17:42:24 2011 @@ -564,6 +564,7 @@ jit_memory_manager, CodeGenOpt::Less, true, + Reloc::Default, CodeModel::Small)); #else EngineBuilder builder(module); From peter at pcc.me.uk Sat Jul 30 17:44:36 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Sat, 30 Jul 2011 23:44:36 +0100 Subject: [Lldb-commits] [PATCH] Add reloc arg to standard JIT createJIT() In-Reply-To: <4E337806.5040800@crhc.illinois.edu> References: <4E337806.5040800@crhc.illinois.edu> Message-ID: <20110730224436.GA11551@pcc.me.uk> On Fri, Jul 29, 2011 at 10:18:30PM -0500, Matt Johnson wrote: > This patch fixes non-__APPLE__ builds by adding the extra reloc model > argument to createJIT() (introduced in r135468). With this one-liner, > LLDB r136555 with ToT LLVM/Clang compiles under Ubuntu 11.04, G++ 4.5.2. > -Matt Thanks Matt, applied in r136580. -- Peter From vasil.georgiev.vasilev at cern.ch Sun Jul 31 08:12:57 2011 From: vasil.georgiev.vasilev at cern.ch (Vassil Vassilev) Date: Sun, 31 Jul 2011 15:12:57 +0200 Subject: [Lldb-commits] [Patch] Doxygen Documentation Message-ID: <4E3554D9.7060805@cern.ch> Hi, Same thing with more concrete subject name. Vassil -------- Original Message -------- Subject: Re: [Lldb-commits] Hi All! Date: Sat, 9 Jul 2011 13:20:08 +0200 From: Vassil Vassilev To: Peter Collingbourne CC: Hi Peter, Sorry for the delayed answer I didn't have much time. I spent a great deal of time on cling's error recovery. You are right make doxygen is much easier than setting flags just to get the doxygen.cfg. I am attaching the new patches. Please let me know if I misunderstood something or something needs to be fixed. Cheers, Vassil On 06/30/2011 01:50 AM, Peter Collingbourne wrote: > Hi Vassil, > > On Fri, Jun 10, 2011 at 04:49:32PM +0200, Vassil Vassilev wrote: >> Hi, >> Can I say Hi to lldb community with the attached patch. >> I saw that lldb didn't have doxygen documentation on the website and >> decided to see what I could do. Recently I did that for cling so I've >> made few changes to adapt it for lldb. It is customization of clang's >> approach of generating documentation. Be careful it's slow and space >> consuming ;) > Thanks for the patch. > > I don't think we can accept it yet, because it will only work for a > website-style build (i.e. if BUILD_FOR_WEBSITE is set) because there > is no way to build the doxygen.cfg otherwise. Ideally we would like > "make doxygen" in the docs directory to work for a standard build. > For LLVM and clang this is done by having LLVM's configure script > run an AC_CONFIG_FILES pass over the doxygen.cfg.in file (yes, this > isn't ideal for a large number of projects, but I don't think we're > at that point yet). You can see the necessary changes I made in > clang r131282 and LLVM r131279. > > Thanks, -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110731/a8d199a7/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: lldb-doxygen-enabled.diff Type: text/x-patch Size: 90996 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110731/a8d199a7/attachment-0002.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-autoconf-lldb.diff Type: text/x-patch Size: 1504 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110731/a8d199a7/attachment-0003.bin -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Attached Message Part Url: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110731/a8d199a7/attachment-0001.pl