From ctice at apple.com Mon Sep 27 11:58:16 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 27 Sep 2010 16:58:16 -0000 Subject: [Lldb-commits] [lldb] r114840 - /lldb/trunk/source/Commands/CommandObjectSettings.cpp Message-ID: <20100927165817.039552A6C12C@llvm.org> Author: ctice Date: Mon Sep 27 11:58:16 2010 New Revision: 114840 URL: http://llvm.org/viewvc/llvm-project?rev=114840&view=rev Log: Change command option "--no_override" to "--no-override" (hypen instead of underscore). Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=114840&r1=114839&r2=114840&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Mon Sep 27 11:58:16 2010 @@ -206,7 +206,7 @@ lldb::OptionDefinition CommandObjectSettingsSet::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "no_override", 'n', no_argument, NULL, NULL, NULL, "Prevents already existing instances and pending settings from being assigned this new value. Using this option means that only the default or specified instance setting values will be updated." }, + { LLDB_OPT_SET_1, false, "no-override", 'n', no_argument, NULL, NULL, NULL, "Prevents already existing instances and pending settings from being assigned this new value. Using this option means that only the default or specified instance setting values will be updated." }, { LLDB_OPT_SET_2, false, "reset", 'r', no_argument, NULL, NULL, NULL, "Causes value to be reset to the original default for this variable. No value needs to be specified when this option is used." }, }; From johnny.chen at apple.com Mon Sep 27 12:36:59 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 27 Sep 2010 17:36:59 -0000 Subject: [Lldb-commits] [lldb] r114846 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20100927173700.026A52A6C12C@llvm.org> Author: johnny Date: Mon Sep 27 12:36:59 2010 New Revision: 114846 URL: http://llvm.org/viewvc/llvm-project?rev=114846&view=rev Log: Updated test case to "settings set prompt 'lldb2'" since the '-o' option is gone. Also added "settings set -r prompt" to reset the prompt afterwards. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=114846&r1=114845&r2=114846&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Mon Sep 27 12:36:59 2010 @@ -19,8 +19,8 @@ def test_set_prompt(self): """Test that 'set prompt' actually changes the prompt.""" - # Use '-o' option to override the existing instance setting. - self.runCmd("settings set -o prompt 'lldb2'") + # Set prompt to 'lldb2'. + self.runCmd("settings set prompt 'lldb2'") # Immediately test the setting. self.expect("settings show prompt", @@ -30,6 +30,9 @@ self.expect("settings show", substrs = ["prompt (string) = 'lldb2'"]) + # Use '-r' option to reset to the original default prompt. + self.runCmd("settings set -r prompt") + def test_set_term_width(self): """Test that 'set term-width' actually changes the term-width.""" From ctice at apple.com Mon Sep 27 13:00:20 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 27 Sep 2010 18:00:20 -0000 Subject: [Lldb-commits] [lldb] r114849 - in /lldb/trunk: include/lldb/API/SBBreakpointLocation.h include/lldb/API/SBFrame.h scripts/lldb.swig source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20100927180020.60B7D2A6C12C@llvm.org> Author: ctice Date: Mon Sep 27 13:00:20 2010 New Revision: 114849 URL: http://llvm.org/viewvc/llvm-project?rev=114849&view=rev Log: Automatically wrap *all* Python code entered for a breakpoint command inside an auto-generated Python function, and pass the stoppoint context frame and breakpoint location as parameters to the function (named 'frame' and 'bp_loc'), to be used inside the breakpoint command Python code, if desired. Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/scripts/lldb.swig lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=114849&r1=114848&r2=114849&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Mon Sep 27 13:00:20 2010 @@ -76,6 +76,7 @@ private: friend class SBBreakpoint; + friend class lldb_private::ScriptInterpreterPython; SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp); Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=114849&r1=114848&r2=114849&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Mon Sep 27 13:00:20 2010 @@ -123,6 +123,7 @@ private: friend class SBThread; + friend class lldb_private::ScriptInterpreterPython; #ifndef SWIG Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=114849&r1=114848&r2=114849&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Mon Sep 27 13:00:20 2010 @@ -99,6 +99,15 @@ #include "lldb/API/SBType.h" #include "lldb/API/SBValue.h" #include "lldb/API/SBValueList.h" +#include "lldb/Interpreter/ScriptInterpreterPython.h" +#include "lldb/Breakpoint/Breakpoint.h" +#include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Breakpoint/StoppointCallbackContext.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" +#include "lldb/lldb-forward-rtti.h" using namespace lldb_private; %} @@ -157,3 +166,97 @@ %include "lldb/lldb-types.h" %include "./Python/python-extensions.swig" + + +%wrapper %{ + + +bool +ScriptInterpreterPython::BreakpointCallbackFunction (void *baton, + StoppointCallbackContext *context, + lldb::user_id_t break_id, + lldb::user_id_t break_loc_id) +{ + bool ret_value = true; + + BreakpointOptions::CommandData *bp_option_data = (BreakpointOptions::CommandData *) baton; + const char *python_function_name = bp_option_data->script_source.GetStringAtIndex (0); + + if (python_function_name != NULL + && python_function_name[0] != '\0') + { + Thread *thread = context->exe_ctx.thread; + Target *target = context->exe_ctx.target; + const lldb::StackFrameSP stop_frame_sp = thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame); + lldb::BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id); + const lldb::BreakpointLocationSP bp_loc_sp = breakpoint_sp->FindLocationByID (break_loc_id); + + lldb::SBFrame sb_frame (stop_frame_sp); + lldb::SBBreakpointLocation sb_bp_loc (bp_loc_sp); + + if (!sb_bp_loc.IsValid() || !sb_frame.IsValid()) + return ret_value; + + + 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 ret_value; + + PyObject *pmodule, *pdict, *pfunc; + PyObject *pargs, *pvalue; + + pmodule = PyImport_AddModule ("__main__"); + if (pmodule != NULL) + { + pdict = PyModule_GetDict (pmodule); + if (pdict != NULL) + { + pfunc = PyObject_GetAttrString (pmodule, python_function_name); + if (pfunc && PyCallable_Check (pfunc)) + { + pargs = PyTuple_New (2); + if (pargs == NULL) + { + if (PyErr_Occurred()) + PyErr_Clear(); + return ret_value; + } + + 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 + pvalue = PyObject_CallObject (pfunc, pargs); + Py_DECREF (pargs); + + if (pvalue != NULL) + { + Py_DECREF (pvalue); + } + else if (PyErr_Occurred ()) + { + PyErr_Clear(); + } + Py_DECREF (pfunc); + } + else if (PyErr_Occurred()) + { + PyErr_Clear(); + } + } + else if (PyErr_Occurred()) + { + PyErr_Clear(); + } + } + else if (PyErr_Occurred ()) + { + PyErr_Clear (); + } + } + + return ret_value; +} + +%} Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=114849&r1=114848&r2=114849&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Sep 27 13:00:20 2010 @@ -717,220 +717,44 @@ { static int num_created_functions = 0; user_input.RemoveBlankLines (); - int num_lines = user_input.GetSize(); + int num_lines = user_input.GetSize (); + StreamString sstr; - if (num_lines == 1) - { - callback_data.AppendString (user_input.GetStringAtIndex (0)); - return true; - } + // Take what the user wrote, wrap it all up inside one big auto-generated Python function, passing in the + // frame and breakpoint location as parameters to the function. - // Traverse user_input exactly once. At each line, either copy line into new, auto-generated function, - // increasing indentation by 5 spaces or copy it exactly as is into the user-written - // currently-to-be-pushed-to-Python function def. At the end of each Python function def, push the function - // to Python, and clear the function string, to start again. At the end of it all, if there is anything in - // the auto-generated function, push it to Python and add the function call to it to the callback data. - bool inside_user_python_function_def = false; - std::string whitespace = " \t"; + sstr.Printf ("lldb_autogen_python_bp_callback_func_%d", num_created_functions); + ++num_created_functions; + std::string auto_generated_function_name = sstr.GetData(); + sstr.Clear(); StringList auto_generated_function; - StringList user_defined_function; - StringList *current_function_def = &auto_generated_function; - std::string auto_generated_function_name ("lldb_autogen_python_bp_callback_func_"); + // Create the function name & definition string. - for (int i = 0; i < num_lines; ++i) - { - std::string current_line (user_input.GetStringAtIndex(i)); - size_t idx = current_line.find_first_of (whitespace); - if (idx != std::string::npos) - { - if (idx == 0) // line starts with indentation... - { - if (inside_user_python_function_def) - { - // Add this line to the user's python function definition. - current_function_def->AppendString (current_line.c_str()); - } - else - { - // Add this line to our auto-generated function; increase original indentation by 5. - StreamString tmp_str; - tmp_str.Printf (" %s", current_line.c_str()); - current_function_def->AppendString (tmp_str.GetData()); - } - } - else // line does not start with indentation... - { - // First, check to see if we just finished a user-written function definition; if so, - // wrap it up and send it to Python. - - if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) - { - if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) - { - // User entered incorrect Python syntax. We should not attempt to continue. - // Clear the callback data, and return immediately. - callback_data.Clear(); - return false; - } - - // User defined function was successfully sent to Python. Clean up after it. - user_defined_function.Clear(); - inside_user_python_function_def = false; - current_function_def = &auto_generated_function; - } - - // Next, check to see if we are at the start of a user-defined Python function. - std::string first_word = current_line.substr (0, idx); - if (first_word.compare ("def") == 0) - { - // Start the user defined function properly: - inside_user_python_function_def = true; - current_function_def = &user_defined_function; - current_function_def->AppendString (current_line.c_str()); - } - else - { - // We are in "loose" Python code that we need to collect and put into the auto-generated - // function. - StreamString tmp_str; - current_function_def = &auto_generated_function; - if (current_function_def->GetSize() == 0) - { - // Create the function name, and add insert the function def line. - tmp_str.Printf ("%d", num_created_functions); - ++num_created_functions; - auto_generated_function_name.append (tmp_str.GetData()); - - tmp_str.Clear(); - tmp_str.Printf ("def %s ():", auto_generated_function_name.c_str()); - current_function_def->AppendString (tmp_str.GetData()); - } - tmp_str.Clear(); - - // Indent the line an extra 5 spaces and add it to our auto-generated function. - tmp_str.Printf (" %s", current_line.c_str()); - current_function_def->AppendString (tmp_str.GetData()); - } // else we are in loose Python code - } // else current line does not start with indentatin - } - else - { - // There was no white space on the line (and therefore no indentation either). - - // First, check to see if we just finished a user-written function definition; if so, - // wrap it up and send it to Python. - - if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) - { - if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) - { - // User entered incorrect Python syntax. We should not attempt to continue. - // Clear the callback data, and return immediately. - callback_data.Clear(); - return false; - } - - // User defined function was successfully sent to Python. Clean up after it. - user_defined_function.Clear(); - inside_user_python_function_def = false; - current_function_def = &auto_generated_function; - } - - // We cannot be at the start of a function definition (they contain white space) so we - // must have "loose" python code. - - StreamString tmp_str; - current_function_def = &auto_generated_function; - if (current_function_def->GetSize() == 0) - { - // Create the function name, and add insert the function def line. - tmp_str.Printf ("%d", num_created_functions); - ++num_created_functions; - auto_generated_function_name.append (tmp_str.GetData()); - - tmp_str.Clear(); - tmp_str.Printf ("def %s ():", auto_generated_function_name.c_str()); - current_function_def->AppendString (tmp_str.GetData()); - } - tmp_str.Clear(); - - // Indent the line an extra 5 spaces and add it to our auto-generated function. - tmp_str.Printf (" %s", current_line.c_str()); - current_function_def->AppendString (tmp_str.GetData()); - - } // else there was no white space on the line. - } + sstr.Printf ("def %s (frame, bp_loc):", auto_generated_function_name.c_str()); + auto_generated_function.AppendString (sstr.GetData()); - // Perhaps the last line of input was also the last line of a user-defined function; if so, - // attempt to push the function down to Python. + // Wrap everything up inside the function, increasing the indentation. - if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) + for (int i = 0; i < num_lines; ++i) { - if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) - { - callback_data.Clear(); - return false; - } + sstr.Clear (); + sstr.Printf (" %s", user_input.GetStringAtIndex (i)); + auto_generated_function.AppendString (sstr.GetData()); } + // Verify that the results are valid Python. - if (auto_generated_function.GetSize() > 0) - { - // Export the auto-generated function to Python. - if (ExportFunctionDefinitionToInterpreter (auto_generated_function)) - { - // The export succeeded; the syntax must be ok. Generate the function call and put - // it in the callback data. - StreamString tmp_str; - tmp_str.Printf ("%s ()", auto_generated_function_name.c_str()); - callback_data.AppendString (tmp_str.GetData()); - return true; - } - else - { - // Syntax error! - callback_data.Clear(); - return false; - } - } - else + if (!ExportFunctionDefinitionToInterpreter (auto_generated_function)) { - // If there was any code, it consisted entirely of function defs, without any calls to the functions. - // No actual exectuable code was therefore generated. (Function calls would have looked like "loose" python, - // and would have been collected into the auto-generated function.) return false; } -} -bool -ScriptInterpreterPython::BreakpointCallbackFunction -( - void *baton, - StoppointCallbackContext *context, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id -) -{ - bool ret_value = true; - bool temp_bool; - - BreakpointOptions::CommandData *bp_option_data = (BreakpointOptions::CommandData *) baton; + // Store the name of the auto-generated function to be called. - const char *python_string = bp_option_data->script_source.GetStringAtIndex(0); - - if (python_string != NULL) - { - bool success = context->exe_ctx.target->GetDebugger(). - GetCommandInterpreter(). - GetScriptInterpreter()->ExecuteOneLineWithReturn (python_string, - ScriptInterpreter::eBool, - (void *) &temp_bool); - if (success) - ret_value = temp_bool; - } - - return ret_value; + callback_data.AppendString (auto_generated_function_name.c_str()); + return true; } + From johnny.chen at apple.com Mon Sep 27 14:17:42 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 27 Sep 2010 12:17:42 -0700 Subject: [Lldb-commits] [lldb] r114849 - in /lldb/trunk: include/lldb/API/SBBreakpointLocation.h include/lldb/API/SBFrame.h scripts/lldb.swig source/Interpreter/ScriptInterpreterPython.cpp In-Reply-To: <20100927180020.60B7D2A6C12C@llvm.org> References: <20100927180020.60B7D2A6C12C@llvm.org> Message-ID: Hi Caroline, This checkin seems to break the test suite: test/breakpoint_command, and maybe others.... On Sep 27, 2010, at 11:00 AM, Caroline Tice wrote: > Author: ctice > Date: Mon Sep 27 13:00:20 2010 > New Revision: 114849 > > URL: http://llvm.org/viewvc/llvm-project?rev=114849&view=rev > Log: > Automatically wrap *all* Python code entered for a breakpoint command inside > an auto-generated Python function, and pass the stoppoint context frame and > breakpoint location as parameters to the function (named 'frame' and 'bp_loc'), > to be used inside the breakpoint command Python code, if desired. > > > Modified: > lldb/trunk/include/lldb/API/SBBreakpointLocation.h > lldb/trunk/include/lldb/API/SBFrame.h > lldb/trunk/scripts/lldb.swig > lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp > > Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=114849&r1=114848&r2=114849&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original) > +++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Mon Sep 27 13:00:20 2010 > @@ -76,6 +76,7 @@ > > private: > friend class SBBreakpoint; > + friend class lldb_private::ScriptInterpreterPython; > > SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp); > > > Modified: lldb/trunk/include/lldb/API/SBFrame.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=114849&r1=114848&r2=114849&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/API/SBFrame.h (original) > +++ lldb/trunk/include/lldb/API/SBFrame.h Mon Sep 27 13:00:20 2010 > @@ -123,6 +123,7 @@ > > private: > friend class SBThread; > + friend class lldb_private::ScriptInterpreterPython; > > #ifndef SWIG > > > Modified: lldb/trunk/scripts/lldb.swig > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=114849&r1=114848&r2=114849&view=diff > ============================================================================== > --- lldb/trunk/scripts/lldb.swig (original) > +++ lldb/trunk/scripts/lldb.swig Mon Sep 27 13:00:20 2010 > @@ -99,6 +99,15 @@ > #include "lldb/API/SBType.h" > #include "lldb/API/SBValue.h" > #include "lldb/API/SBValueList.h" > +#include "lldb/Interpreter/ScriptInterpreterPython.h" > +#include "lldb/Breakpoint/Breakpoint.h" > +#include "lldb/Breakpoint/BreakpointLocation.h" > +#include "lldb/Breakpoint/StoppointCallbackContext.h" > +#include "lldb/Target/ExecutionContext.h" > +#include "lldb/Target/StackFrame.h" > +#include "lldb/Target/Target.h" > +#include "lldb/Target/Thread.h" > +#include "lldb/lldb-forward-rtti.h" > using namespace lldb_private; > %} > > @@ -157,3 +166,97 @@ > %include "lldb/lldb-types.h" > > %include "./Python/python-extensions.swig" > + > + > +%wrapper %{ > + > + > +bool > +ScriptInterpreterPython::BreakpointCallbackFunction (void *baton, > + StoppointCallbackContext *context, > + lldb::user_id_t break_id, > + lldb::user_id_t break_loc_id) > +{ > + bool ret_value = true; > + > + BreakpointOptions::CommandData *bp_option_data = (BreakpointOptions::CommandData *) baton; > + const char *python_function_name = bp_option_data->script_source.GetStringAtIndex (0); > + > + if (python_function_name != NULL > + && python_function_name[0] != '\0') > + { > + Thread *thread = context->exe_ctx.thread; > + Target *target = context->exe_ctx.target; > + const lldb::StackFrameSP stop_frame_sp = thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame); > + lldb::BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id); > + const lldb::BreakpointLocationSP bp_loc_sp = breakpoint_sp->FindLocationByID (break_loc_id); > + > + lldb::SBFrame sb_frame (stop_frame_sp); > + lldb::SBBreakpointLocation sb_bp_loc (bp_loc_sp); > + > + if (!sb_bp_loc.IsValid() || !sb_frame.IsValid()) > + return ret_value; > + > + > + 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 ret_value; > + > + PyObject *pmodule, *pdict, *pfunc; > + PyObject *pargs, *pvalue; > + > + pmodule = PyImport_AddModule ("__main__"); > + if (pmodule != NULL) > + { > + pdict = PyModule_GetDict (pmodule); > + if (pdict != NULL) > + { > + pfunc = PyObject_GetAttrString (pmodule, python_function_name); > + if (pfunc && PyCallable_Check (pfunc)) > + { > + pargs = PyTuple_New (2); > + if (pargs == NULL) > + { > + if (PyErr_Occurred()) > + PyErr_Clear(); > + return ret_value; > + } > + > + 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 > + pvalue = PyObject_CallObject (pfunc, pargs); > + Py_DECREF (pargs); > + > + if (pvalue != NULL) > + { > + Py_DECREF (pvalue); > + } > + else if (PyErr_Occurred ()) > + { > + PyErr_Clear(); > + } > + Py_DECREF (pfunc); > + } > + else if (PyErr_Occurred()) > + { > + PyErr_Clear(); > + } > + } > + else if (PyErr_Occurred()) > + { > + PyErr_Clear(); > + } > + } > + else if (PyErr_Occurred ()) > + { > + PyErr_Clear (); > + } > + } > + > + return ret_value; > +} > + > +%} > > Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=114849&r1=114848&r2=114849&view=diff > ============================================================================== > --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) > +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Sep 27 13:00:20 2010 > @@ -717,220 +717,44 @@ > { > static int num_created_functions = 0; > user_input.RemoveBlankLines (); > - int num_lines = user_input.GetSize(); > + int num_lines = user_input.GetSize (); > + StreamString sstr; > > - if (num_lines == 1) > - { > - callback_data.AppendString (user_input.GetStringAtIndex (0)); > - return true; > - } > + // Take what the user wrote, wrap it all up inside one big auto-generated Python function, passing in the > + // frame and breakpoint location as parameters to the function. > > - // Traverse user_input exactly once. At each line, either copy line into new, auto-generated function, > - // increasing indentation by 5 spaces or copy it exactly as is into the user-written > - // currently-to-be-pushed-to-Python function def. At the end of each Python function def, push the function > - // to Python, and clear the function string, to start again. At the end of it all, if there is anything in > - // the auto-generated function, push it to Python and add the function call to it to the callback data. > > - bool inside_user_python_function_def = false; > - std::string whitespace = " \t"; > + sstr.Printf ("lldb_autogen_python_bp_callback_func_%d", num_created_functions); > + ++num_created_functions; > + std::string auto_generated_function_name = sstr.GetData(); > > + sstr.Clear(); > StringList auto_generated_function; > - StringList user_defined_function; > > - StringList *current_function_def = &auto_generated_function; > - std::string auto_generated_function_name ("lldb_autogen_python_bp_callback_func_"); > + // Create the function name & definition string. > > - for (int i = 0; i < num_lines; ++i) > - { > - std::string current_line (user_input.GetStringAtIndex(i)); > - size_t idx = current_line.find_first_of (whitespace); > - if (idx != std::string::npos) > - { > - if (idx == 0) // line starts with indentation... > - { > - if (inside_user_python_function_def) > - { > - // Add this line to the user's python function definition. > - current_function_def->AppendString (current_line.c_str()); > - } > - else > - { > - // Add this line to our auto-generated function; increase original indentation by 5. > - StreamString tmp_str; > - tmp_str.Printf (" %s", current_line.c_str()); > - current_function_def->AppendString (tmp_str.GetData()); > - } > - } > - else // line does not start with indentation... > - { > - // First, check to see if we just finished a user-written function definition; if so, > - // wrap it up and send it to Python. > - > - if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) > - { > - if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) > - { > - // User entered incorrect Python syntax. We should not attempt to continue. > - // Clear the callback data, and return immediately. > - callback_data.Clear(); > - return false; > - } > - > - // User defined function was successfully sent to Python. Clean up after it. > - user_defined_function.Clear(); > - inside_user_python_function_def = false; > - current_function_def = &auto_generated_function; > - } > - > - // Next, check to see if we are at the start of a user-defined Python function. > - std::string first_word = current_line.substr (0, idx); > - if (first_word.compare ("def") == 0) > - { > - // Start the user defined function properly: > - inside_user_python_function_def = true; > - current_function_def = &user_defined_function; > - current_function_def->AppendString (current_line.c_str()); > - } > - else > - { > - // We are in "loose" Python code that we need to collect and put into the auto-generated > - // function. > - StreamString tmp_str; > - current_function_def = &auto_generated_function; > - if (current_function_def->GetSize() == 0) > - { > - // Create the function name, and add insert the function def line. > - tmp_str.Printf ("%d", num_created_functions); > - ++num_created_functions; > - auto_generated_function_name.append (tmp_str.GetData()); > - > - tmp_str.Clear(); > - tmp_str.Printf ("def %s ():", auto_generated_function_name.c_str()); > - current_function_def->AppendString (tmp_str.GetData()); > - } > - tmp_str.Clear(); > - > - // Indent the line an extra 5 spaces and add it to our auto-generated function. > - tmp_str.Printf (" %s", current_line.c_str()); > - current_function_def->AppendString (tmp_str.GetData()); > - } // else we are in loose Python code > - } // else current line does not start with indentatin > - } > - else > - { > - // There was no white space on the line (and therefore no indentation either). > - > - // First, check to see if we just finished a user-written function definition; if so, > - // wrap it up and send it to Python. > - > - if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) > - { > - if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) > - { > - // User entered incorrect Python syntax. We should not attempt to continue. > - // Clear the callback data, and return immediately. > - callback_data.Clear(); > - return false; > - } > - > - // User defined function was successfully sent to Python. Clean up after it. > - user_defined_function.Clear(); > - inside_user_python_function_def = false; > - current_function_def = &auto_generated_function; > - } > - > - // We cannot be at the start of a function definition (they contain white space) so we > - // must have "loose" python code. > - > - StreamString tmp_str; > - current_function_def = &auto_generated_function; > - if (current_function_def->GetSize() == 0) > - { > - // Create the function name, and add insert the function def line. > - tmp_str.Printf ("%d", num_created_functions); > - ++num_created_functions; > - auto_generated_function_name.append (tmp_str.GetData()); > - > - tmp_str.Clear(); > - tmp_str.Printf ("def %s ():", auto_generated_function_name.c_str()); > - current_function_def->AppendString (tmp_str.GetData()); > - } > - tmp_str.Clear(); > - > - // Indent the line an extra 5 spaces and add it to our auto-generated function. > - tmp_str.Printf (" %s", current_line.c_str()); > - current_function_def->AppendString (tmp_str.GetData()); > - > - } // else there was no white space on the line. > - } > + sstr.Printf ("def %s (frame, bp_loc):", auto_generated_function_name.c_str()); > + auto_generated_function.AppendString (sstr.GetData()); > > - // Perhaps the last line of input was also the last line of a user-defined function; if so, > - // attempt to push the function down to Python. > + // Wrap everything up inside the function, increasing the indentation. > > - if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) > + for (int i = 0; i < num_lines; ++i) > { > - if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) > - { > - callback_data.Clear(); > - return false; > - } > + sstr.Clear (); > + sstr.Printf (" %s", user_input.GetStringAtIndex (i)); > + auto_generated_function.AppendString (sstr.GetData()); > } > > + // Verify that the results are valid Python. > > - if (auto_generated_function.GetSize() > 0) > - { > - // Export the auto-generated function to Python. > - if (ExportFunctionDefinitionToInterpreter (auto_generated_function)) > - { > - // The export succeeded; the syntax must be ok. Generate the function call and put > - // it in the callback data. > - StreamString tmp_str; > - tmp_str.Printf ("%s ()", auto_generated_function_name.c_str()); > - callback_data.AppendString (tmp_str.GetData()); > - return true; > - } > - else > - { > - // Syntax error! > - callback_data.Clear(); > - return false; > - } > - } > - else > + if (!ExportFunctionDefinitionToInterpreter (auto_generated_function)) > { > - // If there was any code, it consisted entirely of function defs, without any calls to the functions. > - // No actual exectuable code was therefore generated. (Function calls would have looked like "loose" python, > - // and would have been collected into the auto-generated function.) > return false; > } > -} > > -bool > -ScriptInterpreterPython::BreakpointCallbackFunction > -( > - void *baton, > - StoppointCallbackContext *context, > - lldb::user_id_t break_id, > - lldb::user_id_t break_loc_id > -) > -{ > - bool ret_value = true; > - bool temp_bool; > - > - BreakpointOptions::CommandData *bp_option_data = (BreakpointOptions::CommandData *) baton; > + // Store the name of the auto-generated function to be called. > > - const char *python_string = bp_option_data->script_source.GetStringAtIndex(0); > - > - if (python_string != NULL) > - { > - bool success = context->exe_ctx.target->GetDebugger(). > - GetCommandInterpreter(). > - GetScriptInterpreter()->ExecuteOneLineWithReturn (python_string, > - ScriptInterpreter::eBool, > - (void *) &temp_bool); > - if (success) > - ret_value = temp_bool; > - } > - > - return ret_value; > + callback_data.AppendString (auto_generated_function_name.c_str()); > + return true; > } > + > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Mon Sep 27 15:44:47 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 27 Sep 2010 20:44:47 -0000 Subject: [Lldb-commits] [lldb] r114871 - in /lldb/trunk/test: make/Makefile.rules types/Makefile types/TestBasicTypes.py types/long_long.cpp types/unsigned_long.cpp types/unsigned_long_long.cpp Message-ID: <20100927204447.21B752A6C12C@llvm.org> Author: johnny Date: Mon Sep 27 15:44:46 2010 New Revision: 114871 URL: http://llvm.org/viewvc/llvm-project?rev=114871&view=rev Log: Added "long long" and "unsigned long long" to the TestBasicTypes.py. Added a special "clean" target to the types/Makefile to clean up all the *.o/.d files. The generic_type_tester() method is modified to take a set of atoms, instead of type string as a required parameter, for example: o unsigned int => set(['unsigned', 'int']) o unsigned long long => set(['unsigned', 'long long']) o long long => set(['long long']) Added: lldb/trunk/test/types/long_long.cpp lldb/trunk/test/types/unsigned_long_long.cpp Modified: lldb/trunk/test/make/Makefile.rules lldb/trunk/test/types/Makefile lldb/trunk/test/types/TestBasicTypes.py lldb/trunk/test/types/unsigned_long.cpp Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=114871&r1=114870&r2=114871&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Mon Sep 27 15:44:46 2010 @@ -152,7 +152,7 @@ .PHONY: clean dsym: $(DSYM) all: $(EXE) $(DSYM) -clean: +clean:: ifeq "$(DYLIB_NAME)" "" rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) else Modified: lldb/trunk/test/types/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/Makefile?rev=114871&r1=114870&r2=114871&view=diff ============================================================================== --- lldb/trunk/test/types/Makefile (original) +++ lldb/trunk/test/types/Makefile Mon Sep 27 15:44:46 2010 @@ -3,3 +3,7 @@ CXX_SOURCES := int.cpp include $(LEVEL)/Makefile.rules + +clean:: + rm -rf *.o *.d + Modified: lldb/trunk/test/types/TestBasicTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114871&r1=114870&r2=114871&view=diff ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (original) +++ lldb/trunk/test/types/TestBasicTypes.py Mon Sep 27 15:44:46 2010 @@ -131,39 +131,75 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_long_type() + def test_long_long_type_with_dsym(self): + """Test that 'long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_long_type() + + def test_long_long_type_with_dwarf(self): + """Test that 'long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_long_type() + + def test_unsigned_long_long_type_with_dsym(self): + """Test that 'unsigned long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_long_type() + + def test_unsigned_long_long_type_with_dwarf(self): + """Test that 'unsigned long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_long_type() + def char_type(self): """Test that char-type variables are displayed correctly.""" - self.generic_type_tester("char", quotedDisplay=True) + self.generic_type_tester(set(['char']), quotedDisplay=True) def unsigned_char_type(self): """Test that 'unsigned char'-type variables are displayed correctly.""" - self.generic_type_tester("unsigned char", quotedDisplay=True) + self.generic_type_tester(set(['unsigned', 'char']), quotedDisplay=True) def short_type(self): """Test that short-type variables are displayed correctly.""" - self.generic_type_tester("short") + self.generic_type_tester(set(['short'])) def unsigned_short_type(self): """Test that 'unsigned short'-type variables are displayed correctly.""" - self.generic_type_tester("unsigned short") + self.generic_type_tester(set(['unsigned', 'short'])) def int_type(self): """Test that int-type variables are displayed correctly.""" - self.generic_type_tester("int") + self.generic_type_tester(set(['int'])) def unsigned_int_type(self): """Test that 'unsigned int'-type variables are displayed correctly.""" - self.generic_type_tester("unsigned int") + self.generic_type_tester(set(['unsigned', 'int'])) def long_type(self): """Test that long-type variables are displayed correctly.""" - self.generic_type_tester("long") + self.generic_type_tester(set(['long'])) def unsigned_long_type(self): """Test that 'unsigned long'-type variables are displayed correctly.""" - self.generic_type_tester("unsigned long") + self.generic_type_tester(set(['unsigned', 'long'])) + + def long_long_type(self): + """Test that long long-type variables are displayed correctly.""" + self.generic_type_tester(set(['long long'])) + + def unsigned_long_long_type(self): + """Test that 'unsigned long long'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'long long'])) - def generic_type_tester(self, type, quotedDisplay=False): + def generic_type_tester(self, atoms, quotedDisplay=False): """Test that variables with basic types are displayed correctly.""" # First, capture the golden output emitted by the oracle, i.e., the @@ -217,16 +253,16 @@ self.runCmd("frame variable %s" % var) output = self.res.GetOutput() - # Extract the display type and canonicalize its atoms into a set. - # Same for the input type string. + # The input type is in a canonical form as a set named atoms. + # The display type string must conatin each and every element. dt = re.match("^\((.*)\)", output).group(1) - ds = set(dt.split()) - ts = set(type.split()) - # The display type set must be a superset of the input type set. - if not ds.issuperset(ts): - self.fail("The display type: %s must match the input type: %s" % - (dt, type)) + # Expect the display type string to contain each and every atoms. + self.expect(dt, + "Display type: '%s' must contain the type atoms: '%s'" % + (dt, atoms), + exe=False, + substrs = list(atoms)) # The (var, val) pair must match, too. nv = (" %s = '%s'" if quotedDisplay else " %s = %s") % (var, val) Added: lldb/trunk/test/types/long_long.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/long_long.cpp?rev=114871&view=auto ============================================================================== --- lldb/trunk/test/types/long_long.cpp (added) +++ lldb/trunk/test/types/long_long.cpp Mon Sep 27 15:44:46 2010 @@ -0,0 +1,18 @@ +#define T long long +#define T_CSTR "long long" + +#ifdef __LP64__ +#define T_VALUE_1 110011101111 +#define T_VALUE_2 220022202222 +#define T_VALUE_3 330033303333 +#define T_VALUE_4 440044404444 +#else +#define T_VALUE_1 110011101 +#define T_VALUE_2 220022202 +#define T_VALUE_3 330033303 +#define T_VALUE_4 440044404 +#endif + +#define T_PRINTF_FORMAT "%lld" + +#include "basic_type.cpp" Modified: lldb/trunk/test/types/unsigned_long.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/unsigned_long.cpp?rev=114871&r1=114870&r2=114871&view=diff ============================================================================== --- lldb/trunk/test/types/unsigned_long.cpp (original) +++ lldb/trunk/test/types/unsigned_long.cpp Mon Sep 27 15:44:46 2010 @@ -13,6 +13,6 @@ #define T_VALUE_4 440044404 #endif -#define T_PRINTF_FORMAT "%ld" +#define T_PRINTF_FORMAT "%lu" #include "basic_type.cpp" Added: lldb/trunk/test/types/unsigned_long_long.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/unsigned_long_long.cpp?rev=114871&view=auto ============================================================================== --- lldb/trunk/test/types/unsigned_long_long.cpp (added) +++ lldb/trunk/test/types/unsigned_long_long.cpp Mon Sep 27 15:44:46 2010 @@ -0,0 +1,18 @@ +#define T unsigned long long +#define T_CSTR "unsigned long long" + +#ifdef __LP64__ +#define T_VALUE_1 110011101111 +#define T_VALUE_2 220022202222 +#define T_VALUE_3 330033303333 +#define T_VALUE_4 440044404444 +#else +#define T_VALUE_1 110011101 +#define T_VALUE_2 220022202 +#define T_VALUE_3 330033303 +#define T_VALUE_4 440044404 +#endif + +#define T_PRINTF_FORMAT "%llu" + +#include "basic_type.cpp" From ctice at apple.com Mon Sep 27 15:56:52 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 27 Sep 2010 13:56:52 -0700 Subject: [Lldb-commits] [lldb] r114849 - in /lldb/trunk: include/lldb/API/SBBreakpointLocation.h include/lldb/API/SBFrame.h scripts/lldb.swig source/Interpreter/ScriptInterpreterPython.cpp In-Reply-To: References: <20100927180020.60B7D2A6C12C@llvm.org> Message-ID: <7C87A6D6-CC13-4EA4-A413-0489AEB7C09B@apple.com> I missed the fact that the "one-liner" breakpoint commands use a slightly different mechanism. I'll fix that. On Sep 27, 2010, at 12:17 PM, Johnny Chen wrote: > Hi Caroline, > > This checkin seems to break the test suite: test/breakpoint_command, and maybe others.... > > On Sep 27, 2010, at 11:00 AM, Caroline Tice wrote: > >> Author: ctice >> Date: Mon Sep 27 13:00:20 2010 >> New Revision: 114849 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=114849&view=rev >> Log: >> Automatically wrap *all* Python code entered for a breakpoint command inside >> an auto-generated Python function, and pass the stoppoint context frame and >> breakpoint location as parameters to the function (named 'frame' and 'bp_loc'), >> to be used inside the breakpoint command Python code, if desired. >> >> >> Modified: >> lldb/trunk/include/lldb/API/SBBreakpointLocation.h >> lldb/trunk/include/lldb/API/SBFrame.h >> lldb/trunk/scripts/lldb.swig >> lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp >> >> Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=114849&r1=114848&r2=114849&view=diff >> ============================================================================== >> --- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original) >> +++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Mon Sep 27 13:00:20 2010 >> @@ -76,6 +76,7 @@ >> >> private: >> friend class SBBreakpoint; >> + friend class lldb_private::ScriptInterpreterPython; >> >> SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp); >> >> >> Modified: lldb/trunk/include/lldb/API/SBFrame.h >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=114849&r1=114848&r2=114849&view=diff >> ============================================================================== >> --- lldb/trunk/include/lldb/API/SBFrame.h (original) >> +++ lldb/trunk/include/lldb/API/SBFrame.h Mon Sep 27 13:00:20 2010 >> @@ -123,6 +123,7 @@ >> >> private: >> friend class SBThread; >> + friend class lldb_private::ScriptInterpreterPython; >> >> #ifndef SWIG >> >> >> Modified: lldb/trunk/scripts/lldb.swig >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=114849&r1=114848&r2=114849&view=diff >> ============================================================================== >> --- lldb/trunk/scripts/lldb.swig (original) >> +++ lldb/trunk/scripts/lldb.swig Mon Sep 27 13:00:20 2010 >> @@ -99,6 +99,15 @@ >> #include "lldb/API/SBType.h" >> #include "lldb/API/SBValue.h" >> #include "lldb/API/SBValueList.h" >> +#include "lldb/Interpreter/ScriptInterpreterPython.h" >> +#include "lldb/Breakpoint/Breakpoint.h" >> +#include "lldb/Breakpoint/BreakpointLocation.h" >> +#include "lldb/Breakpoint/StoppointCallbackContext.h" >> +#include "lldb/Target/ExecutionContext.h" >> +#include "lldb/Target/StackFrame.h" >> +#include "lldb/Target/Target.h" >> +#include "lldb/Target/Thread.h" >> +#include "lldb/lldb-forward-rtti.h" >> using namespace lldb_private; >> %} >> >> @@ -157,3 +166,97 @@ >> %include "lldb/lldb-types.h" >> >> %include "./Python/python-extensions.swig" >> + >> + >> +%wrapper %{ >> + >> + >> +bool >> +ScriptInterpreterPython::BreakpointCallbackFunction (void *baton, >> + StoppointCallbackContext *context, >> + lldb::user_id_t break_id, >> + lldb::user_id_t break_loc_id) >> +{ >> + bool ret_value = true; >> + >> + BreakpointOptions::CommandData *bp_option_data = (BreakpointOptions::CommandData *) baton; >> + const char *python_function_name = bp_option_data->script_source.GetStringAtIndex (0); >> + >> + if (python_function_name != NULL >> + && python_function_name[0] != '\0') >> + { >> + Thread *thread = context->exe_ctx.thread; >> + Target *target = context->exe_ctx.target; >> + const lldb::StackFrameSP stop_frame_sp = thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame); >> + lldb::BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id); >> + const lldb::BreakpointLocationSP bp_loc_sp = breakpoint_sp->FindLocationByID (break_loc_id); >> + >> + lldb::SBFrame sb_frame (stop_frame_sp); >> + lldb::SBBreakpointLocation sb_bp_loc (bp_loc_sp); >> + >> + if (!sb_bp_loc.IsValid() || !sb_frame.IsValid()) >> + return ret_value; >> + >> + >> + 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 ret_value; >> + >> + PyObject *pmodule, *pdict, *pfunc; >> + PyObject *pargs, *pvalue; >> + >> + pmodule = PyImport_AddModule ("__main__"); >> + if (pmodule != NULL) >> + { >> + pdict = PyModule_GetDict (pmodule); >> + if (pdict != NULL) >> + { >> + pfunc = PyObject_GetAttrString (pmodule, python_function_name); >> + if (pfunc && PyCallable_Check (pfunc)) >> + { >> + pargs = PyTuple_New (2); >> + if (pargs == NULL) >> + { >> + if (PyErr_Occurred()) >> + PyErr_Clear(); >> + return ret_value; >> + } >> + >> + 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 >> + pvalue = PyObject_CallObject (pfunc, pargs); >> + Py_DECREF (pargs); >> + >> + if (pvalue != NULL) >> + { >> + Py_DECREF (pvalue); >> + } >> + else if (PyErr_Occurred ()) >> + { >> + PyErr_Clear(); >> + } >> + Py_DECREF (pfunc); >> + } >> + else if (PyErr_Occurred()) >> + { >> + PyErr_Clear(); >> + } >> + } >> + else if (PyErr_Occurred()) >> + { >> + PyErr_Clear(); >> + } >> + } >> + else if (PyErr_Occurred ()) >> + { >> + PyErr_Clear (); >> + } >> + } >> + >> + return ret_value; >> +} >> + >> +%} >> >> Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=114849&r1=114848&r2=114849&view=diff >> ============================================================================== >> --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) >> +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Sep 27 13:00:20 2010 >> @@ -717,220 +717,44 @@ >> { >> static int num_created_functions = 0; >> user_input.RemoveBlankLines (); >> - int num_lines = user_input.GetSize(); >> + int num_lines = user_input.GetSize (); >> + StreamString sstr; >> >> - if (num_lines == 1) >> - { >> - callback_data.AppendString (user_input.GetStringAtIndex (0)); >> - return true; >> - } >> + // Take what the user wrote, wrap it all up inside one big auto-generated Python function, passing in the >> + // frame and breakpoint location as parameters to the function. >> >> - // Traverse user_input exactly once. At each line, either copy line into new, auto-generated function, >> - // increasing indentation by 5 spaces or copy it exactly as is into the user-written >> - // currently-to-be-pushed-to-Python function def. At the end of each Python function def, push the function >> - // to Python, and clear the function string, to start again. At the end of it all, if there is anything in >> - // the auto-generated function, push it to Python and add the function call to it to the callback data. >> >> - bool inside_user_python_function_def = false; >> - std::string whitespace = " \t"; >> + sstr.Printf ("lldb_autogen_python_bp_callback_func_%d", num_created_functions); >> + ++num_created_functions; >> + std::string auto_generated_function_name = sstr.GetData(); >> >> + sstr.Clear(); >> StringList auto_generated_function; >> - StringList user_defined_function; >> >> - StringList *current_function_def = &auto_generated_function; >> - std::string auto_generated_function_name ("lldb_autogen_python_bp_callback_func_"); >> + // Create the function name & definition string. >> >> - for (int i = 0; i < num_lines; ++i) >> - { >> - std::string current_line (user_input.GetStringAtIndex(i)); >> - size_t idx = current_line.find_first_of (whitespace); >> - if (idx != std::string::npos) >> - { >> - if (idx == 0) // line starts with indentation... >> - { >> - if (inside_user_python_function_def) >> - { >> - // Add this line to the user's python function definition. >> - current_function_def->AppendString (current_line.c_str()); >> - } >> - else >> - { >> - // Add this line to our auto-generated function; increase original indentation by 5. >> - StreamString tmp_str; >> - tmp_str.Printf (" %s", current_line.c_str()); >> - current_function_def->AppendString (tmp_str.GetData()); >> - } >> - } >> - else // line does not start with indentation... >> - { >> - // First, check to see if we just finished a user-written function definition; if so, >> - // wrap it up and send it to Python. >> - >> - if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) >> - { >> - if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) >> - { >> - // User entered incorrect Python syntax. We should not attempt to continue. >> - // Clear the callback data, and return immediately. >> - callback_data.Clear(); >> - return false; >> - } >> - >> - // User defined function was successfully sent to Python. Clean up after it. >> - user_defined_function.Clear(); >> - inside_user_python_function_def = false; >> - current_function_def = &auto_generated_function; >> - } >> - >> - // Next, check to see if we are at the start of a user-defined Python function. >> - std::string first_word = current_line.substr (0, idx); >> - if (first_word.compare ("def") == 0) >> - { >> - // Start the user defined function properly: >> - inside_user_python_function_def = true; >> - current_function_def = &user_defined_function; >> - current_function_def->AppendString (current_line.c_str()); >> - } >> - else >> - { >> - // We are in "loose" Python code that we need to collect and put into the auto-generated >> - // function. >> - StreamString tmp_str; >> - current_function_def = &auto_generated_function; >> - if (current_function_def->GetSize() == 0) >> - { >> - // Create the function name, and add insert the function def line. >> - tmp_str.Printf ("%d", num_created_functions); >> - ++num_created_functions; >> - auto_generated_function_name.append (tmp_str.GetData()); >> - >> - tmp_str.Clear(); >> - tmp_str.Printf ("def %s ():", auto_generated_function_name.c_str()); >> - current_function_def->AppendString (tmp_str.GetData()); >> - } >> - tmp_str.Clear(); >> - >> - // Indent the line an extra 5 spaces and add it to our auto-generated function. >> - tmp_str.Printf (" %s", current_line.c_str()); >> - current_function_def->AppendString (tmp_str.GetData()); >> - } // else we are in loose Python code >> - } // else current line does not start with indentatin >> - } >> - else >> - { >> - // There was no white space on the line (and therefore no indentation either). >> - >> - // First, check to see if we just finished a user-written function definition; if so, >> - // wrap it up and send it to Python. >> - >> - if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) >> - { >> - if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) >> - { >> - // User entered incorrect Python syntax. We should not attempt to continue. >> - // Clear the callback data, and return immediately. >> - callback_data.Clear(); >> - return false; >> - } >> - >> - // User defined function was successfully sent to Python. Clean up after it. >> - user_defined_function.Clear(); >> - inside_user_python_function_def = false; >> - current_function_def = &auto_generated_function; >> - } >> - >> - // We cannot be at the start of a function definition (they contain white space) so we >> - // must have "loose" python code. >> - >> - StreamString tmp_str; >> - current_function_def = &auto_generated_function; >> - if (current_function_def->GetSize() == 0) >> - { >> - // Create the function name, and add insert the function def line. >> - tmp_str.Printf ("%d", num_created_functions); >> - ++num_created_functions; >> - auto_generated_function_name.append (tmp_str.GetData()); >> - >> - tmp_str.Clear(); >> - tmp_str.Printf ("def %s ():", auto_generated_function_name.c_str()); >> - current_function_def->AppendString (tmp_str.GetData()); >> - } >> - tmp_str.Clear(); >> - >> - // Indent the line an extra 5 spaces and add it to our auto-generated function. >> - tmp_str.Printf (" %s", current_line.c_str()); >> - current_function_def->AppendString (tmp_str.GetData()); >> - >> - } // else there was no white space on the line. >> - } >> + sstr.Printf ("def %s (frame, bp_loc):", auto_generated_function_name.c_str()); >> + auto_generated_function.AppendString (sstr.GetData()); >> >> - // Perhaps the last line of input was also the last line of a user-defined function; if so, >> - // attempt to push the function down to Python. >> + // Wrap everything up inside the function, increasing the indentation. >> >> - if (inside_user_python_function_def && (user_defined_function.GetSize() > 0)) >> + for (int i = 0; i < num_lines; ++i) >> { >> - if (! ExportFunctionDefinitionToInterpreter (user_defined_function)) >> - { >> - callback_data.Clear(); >> - return false; >> - } >> + sstr.Clear (); >> + sstr.Printf (" %s", user_input.GetStringAtIndex (i)); >> + auto_generated_function.AppendString (sstr.GetData()); >> } >> >> + // Verify that the results are valid Python. >> >> - if (auto_generated_function.GetSize() > 0) >> - { >> - // Export the auto-generated function to Python. >> - if (ExportFunctionDefinitionToInterpreter (auto_generated_function)) >> - { >> - // The export succeeded; the syntax must be ok. Generate the function call and put >> - // it in the callback data. >> - StreamString tmp_str; >> - tmp_str.Printf ("%s ()", auto_generated_function_name.c_str()); >> - callback_data.AppendString (tmp_str.GetData()); >> - return true; >> - } >> - else >> - { >> - // Syntax error! >> - callback_data.Clear(); >> - return false; >> - } >> - } >> - else >> + if (!ExportFunctionDefinitionToInterpreter (auto_generated_function)) >> { >> - // If there was any code, it consisted entirely of function defs, without any calls to the functions. >> - // No actual exectuable code was therefore generated. (Function calls would have looked like "loose" python, >> - // and would have been collected into the auto-generated function.) >> return false; >> } >> -} >> >> -bool >> -ScriptInterpreterPython::BreakpointCallbackFunction >> -( >> - void *baton, >> - StoppointCallbackContext *context, >> - lldb::user_id_t break_id, >> - lldb::user_id_t break_loc_id >> -) >> -{ >> - bool ret_value = true; >> - bool temp_bool; >> - >> - BreakpointOptions::CommandData *bp_option_data = (BreakpointOptions::CommandData *) baton; >> + // Store the name of the auto-generated function to be called. >> >> - const char *python_string = bp_option_data->script_source.GetStringAtIndex(0); >> - >> - if (python_string != NULL) >> - { >> - bool success = context->exe_ctx.target->GetDebugger(). >> - GetCommandInterpreter(). >> - GetScriptInterpreter()->ExecuteOneLineWithReturn (python_string, >> - ScriptInterpreter::eBool, >> - (void *) &temp_bool); >> - if (success) >> - ret_value = temp_bool; >> - } >> - >> - return ret_value; >> + callback_data.AppendString (auto_generated_function_name.c_str()); >> + return true; >> } >> + >> >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > From johnny.chen at apple.com Mon Sep 27 15:55:52 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 27 Sep 2010 20:55:52 -0000 Subject: [Lldb-commits] [lldb] r114872 - /lldb/trunk/test/types/TestBasicTypes.py Message-ID: <20100927205553.042B32A6C12C@llvm.org> Author: johnny Date: Mon Sep 27 15:55:52 2010 New Revision: 114872 URL: http://llvm.org/viewvc/llvm-project?rev=114872&view=rev Log: Added @expectedFailure decorator for the "long long" and "unsigned long long" test cases. Modified: lldb/trunk/test/types/TestBasicTypes.py Modified: lldb/trunk/test/types/TestBasicTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114872&r1=114871&r2=114872&view=diff ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (original) +++ lldb/trunk/test/types/TestBasicTypes.py Mon Sep 27 15:55:52 2010 @@ -131,6 +131,10 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_long_type() + # rdar://problem/8482903 + # test suite failure for types dir -- "long long" and "unsigned long long" + + @unittest2.expectedFailure def test_long_long_type_with_dsym(self): """Test that 'long long'-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'long_long.cpp'} @@ -138,6 +142,7 @@ self.setTearDownCleanup(dictionary=d) self.long_long_type() + @unittest2.expectedFailure def test_long_long_type_with_dwarf(self): """Test that 'long long'-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'long_long.cpp'} @@ -145,6 +150,7 @@ self.setTearDownCleanup(dictionary=d) self.long_long_type() + @unittest2.expectedFailure def test_unsigned_long_long_type_with_dsym(self): """Test that 'unsigned long long'-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} @@ -152,6 +158,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_long_long_type() + @unittest2.expectedFailure def test_unsigned_long_long_type_with_dwarf(self): """Test that 'unsigned long long'-type variables are displayed correctly.""" d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} From johnny.chen at apple.com Mon Sep 27 16:04:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 27 Sep 2010 21:04:54 -0000 Subject: [Lldb-commits] [lldb] r114875 - /lldb/trunk/test/types/TestBasicTypes.py Message-ID: <20100927210454.A74772A6C12C@llvm.org> Author: johnny Date: Mon Sep 27 16:04:54 2010 New Revision: 114875 URL: http://llvm.org/viewvc/llvm-project?rev=114875&view=rev Log: Modified doc string. Modified: lldb/trunk/test/types/TestBasicTypes.py Modified: lldb/trunk/test/types/TestBasicTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114875&r1=114874&r2=114875&view=diff ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (original) +++ lldb/trunk/test/types/TestBasicTypes.py Mon Sep 27 16:04:54 2010 @@ -1,5 +1,5 @@ """ -Test that variables of basic types are displayed correctly. +Test that variables of integer basic types are displayed correctly. """ import os, time From gclayton at apple.com Mon Sep 27 16:07:38 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 27 Sep 2010 21:07:38 -0000 Subject: [Lldb-commits] [lldb] r114876 - in /lldb/trunk/source/Plugins: Process/gdb-remote/ProcessGDBRemote.cpp SymbolFile/DWARF/DWARFDebugInfoEntry.h SymbolFile/DWARF/SymbolFileDWARF.cpp SymbolFile/DWARF/SymbolFileDWARF.h Message-ID: <20100927210738.D04DB2A6C12C@llvm.org> Author: gclayton Date: Mon Sep 27 16:07:38 2010 New Revision: 114876 URL: http://llvm.org/viewvc/llvm-project?rev=114876&view=rev Log: Hooked up detach for ProcessGDBRemote. Remove the GetUserData()/SetUserData() from the DWARFDebugInfoEntry class. We now track everything with dense maps. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=114876&r1=114875&r2=114876&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Sep 27 16:07:38 2010 @@ -1133,14 +1133,58 @@ ProcessGDBRemote::WillDetach () { Error error; - const StateType state = m_private_state.GetValue(); - - if (IsRunning(state)) - error.SetErrorString("Process must be stopped in order to detach."); + if (m_gdb_comm.IsRunning()) + { + bool timed_out = false; + Mutex::Locker locker; + if (!m_gdb_comm.SendInterrupt (locker, 2, &timed_out)) + { + if (timed_out) + error.SetErrorString("timed out sending interrupt packet"); + else + error.SetErrorString("unknown error sending interrupt packet"); + } + } return error; } +Error +ProcessGDBRemote::DoDetach() +{ + Error error; + Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS); + if (log) + log->Printf ("ProcessGDBRemote::DoDetach()"); + + DisableAllBreakpointSites (); + + StringExtractorGDBRemote response; + size_t response_size = m_gdb_comm.SendPacketAndWaitForResponse("D", response, 2, false); + if (response_size) + { + if (response.IsOKPacket()) + { + if (log) + log->Printf ("ProcessGDBRemote::DoDetach() detach was successful"); + + } + else if (log) + { + log->Printf ("ProcessGDBRemote::DoDestroy() detach failed: %s", response.GetStringRef().c_str()); + } + } + else if (log) + { + log->PutCString ("ProcessGDBRemote::DoDestroy() detach failed for unknown reasons"); + } + StopAsyncThread (); + m_gdb_comm.StopReadThread(); + KillDebugserverProcess (); + m_gdb_comm.Disconnect(); // Disconnect from the debug server. + SetPublicState (eStateDetached); + return error; +} Error ProcessGDBRemote::DoDestroy () @@ -1575,57 +1619,6 @@ return error; } - -Error -ProcessGDBRemote::DoDetach() -{ - Error error; - Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS); - if (log) - log->Printf ("ProcessGDBRemote::DoDetach()"); - - // if (DoSIGSTOP (true)) - // { - // CloseChildFileDescriptors (); - // - // // Scope for "locker" so we can reply to all of our exceptions (the SIGSTOP - // // exception). - // { - // Mutex::Locker locker(m_exception_messages_mutex); - // ReplyToAllExceptions(); - // } - // - // // Shut down the exception thread and cleanup our exception remappings - // Task().ShutDownExceptionThread(); - // - // pid_t pid = GetID(); - // - // // Detach from our process while we are stopped. - // errno = 0; - // - // // Detach from our process - // ::ptrace (PT_DETACH, pid, (caddr_t)1, 0); - // - // error.SetErrorToErrno(); - // - // if (log || error.Fail()) - // error.PutToLog(log, "::ptrace (PT_DETACH, %u, (caddr_t)1, 0)", pid); - // - // // Resume our task - // Task().Resume(); - // - // // NULL our task out as we have already retored all exception ports - // Task().Clear(); - // - // // Clear out any notion of the process we once were - // Clear(); - // - // SetPrivateState (eStateDetached); - // return true; - // } - return error; -} - void ProcessGDBRemote::STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h?rev=114876&r1=114875&r2=114876&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Mon Sep 27 16:07:38 2010 @@ -105,8 +105,7 @@ m_offset (DW_INVALID_OFFSET), m_parent_idx (0), m_sibling_idx (0), - m_abbrevDecl (NULL), - m_user_data (NULL) + m_abbrevDecl (NULL) { } @@ -319,14 +318,11 @@ } const DWARFAbbreviationDeclaration* GetAbbreviationDeclarationPtr() const { return m_abbrevDecl; } - void * GetUserData() const { return m_user_data; } - void SetUserData(void *d) const { m_user_data = d; } protected: dw_offset_t m_offset; // Offset within the .debug_info of the start of this entry uint32_t m_parent_idx; // How many to subtract from "this" to get the parent. If zero this die has no parent uint32_t m_sibling_idx; // How many to add to "this" to get the sibling. const DWARFAbbreviationDeclaration* m_abbrevDecl; - mutable void * m_user_data; // Flags for use by the parsers }; #endif // liblldb_DWARFDebugInfoEntry_h_ 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=114876&r1=114875&r2=114876&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Sep 27 16:07:38 2010 @@ -52,7 +52,7 @@ #include -#define DIE_IS_BEING_PARSED ((void*)1) +#define DIE_IS_BEING_PARSED ((lldb_private::Type*)1) using namespace lldb; using namespace lldb_private; @@ -609,10 +609,7 @@ if (decl_file != 0 || decl_line != 0 || decl_column != 0) decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line, decl_column)); - Type *func_type = NULL; - - if (die->GetUserData() != DIE_IS_BEING_PARSED) - func_type = (Type*)die->GetUserData(); + Type *func_type = m_die_to_type.lookup (die); assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED); @@ -1215,17 +1212,7 @@ DWARFCompileUnitSP cu_sp; const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, &cu_sp); if (type_die != NULL) - { - void *type = type_die->GetUserData(); - if (type == NULL) - { - TypeSP owning_type_sp; - GetTypeForDIE(cu_sp.get(), type_die, owning_type_sp, 0, 0); - type = type_die->GetUserData(); - } - if (type != DIE_IS_BEING_PARSED) - return (Type *)type; - } + return ResolveType (cu_sp.get(), type_die); } return NULL; } @@ -1235,15 +1222,14 @@ { if (type_die != NULL) { - void *type = type_die->GetUserData(); + Type *type = m_die_to_type.lookup (type_die); if (type == NULL) { TypeSP owning_type_sp; - TypeSP type_sp(GetTypeForDIE(cu, type_die, owning_type_sp, 0, 0)); - type = type_die->GetUserData(); + type = GetTypeForDIE(cu, type_die, owning_type_sp, 0, 0).get(); } - if (type != DIE_IS_BEING_PARSED) - return (Type *)type; + assert (type != DIE_IS_BEING_PARSED); + return type; } return NULL; } @@ -2238,38 +2224,26 @@ } } -Type* -SymbolFileDWARF::GetUniquedTypeForDIEOffset(dw_offset_t type_die_offset, TypeSP& owning_type_sp, int32_t child_type, uint32_t idx, bool safe) -{ - if (type_die_offset != DW_INVALID_OFFSET) - { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* type_die = DebugInfo()->GetDIEPtr(type_die_offset, &cu_sp); - assert(type_die != NULL); - GetTypeForDIE(cu_sp.get(), type_die, owning_type_sp, child_type, idx); - // Return the uniqued type if there is one - Type* type = (Type*)type_die->GetUserData(); - if (type == DIE_IS_BEING_PARSED && safe) - return NULL; - return type; - } - return NULL; -} - TypeSP -SymbolFileDWARF::GetTypeForDIE(DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die, TypeSP& owning_type_sp, int32_t child_type, uint32_t idx) +SymbolFileDWARF::GetTypeForDIE +( + DWARFCompileUnit *cu, + const DWARFDebugInfoEntry* die, + TypeSP& owning_type_sp, + int32_t child_type, + uint32_t idx +) { TypeSP type_sp; if (die != NULL) { assert(cu != NULL); - Type *type_ptr = (Type *)die->GetUserData(); + Type *type_ptr = m_die_to_type.lookup (die); if (type_ptr == NULL) { SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); bool type_is_new = false; type_sp = ParseType(sc, cu, die, type_is_new); - type_ptr = (Type *)die->GetUserData(); if (owning_type_sp.get() == NULL) owning_type_sp = type_sp; } @@ -2349,11 +2323,13 @@ AccessType accessibility = eAccessNone; if (die != NULL) { - const dw_tag_t tag = die->Tag(); - if (die->GetUserData() == NULL) + Type *type_ptr = m_die_to_type.lookup (die); + if (type_ptr == NULL) { type_is_new = true; + const dw_tag_t tag = die->Tag(); + bool is_forward_declaration = false; DWARFDebugInfoEntry::Attributes attributes; const char *type_name_cstr = NULL; @@ -2376,7 +2352,7 @@ { //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this - const_cast(die)->SetUserData(DIE_IS_BEING_PARSED); + m_die_to_type[die] = DIE_IS_BEING_PARSED; const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); Declaration decl; @@ -2480,8 +2456,7 @@ type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, encoding_uid_type, &decl, clang_type)); - const_cast(die)->SetUserData(type_sp.get()); - + m_die_to_type[die] = type_sp.get(); // Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false); // if (encoding_type != NULL) @@ -2500,7 +2475,7 @@ { //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this - const_cast(die)->SetUserData(DIE_IS_BEING_PARSED); + m_die_to_type[die] = DIE_IS_BEING_PARSED; size_t byte_size = 0; LanguageType class_language = eLanguageTypeUnknown; @@ -2589,7 +2564,7 @@ m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); - const_cast(die)->SetUserData(type_sp.get()); + m_die_to_type[die] = type_sp.get(); // assert(type_sp.get()); // if (accessibility) @@ -2655,7 +2630,7 @@ { //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this - const_cast(die)->SetUserData(DIE_IS_BEING_PARSED); + m_die_to_type[die] = DIE_IS_BEING_PARSED; size_t byte_size = 0; lldb::user_id_t encoding_uid = DW_INVALID_OFFSET; @@ -2707,7 +2682,7 @@ m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, Type::eIsTypeWithUID, &decl, clang_type)); - const_cast(die)->SetUserData(type_sp.get()); + m_die_to_type[die] = type_sp.get(); if (die->HasChildren()) { @@ -2725,7 +2700,7 @@ { //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this - const_cast(die)->SetUserData(DIE_IS_BEING_PARSED); + m_die_to_type[die] = DIE_IS_BEING_PARSED; const char *mangled = NULL; dw_offset_t type_die_offset = DW_INVALID_OFFSET; @@ -2820,6 +2795,10 @@ // Parse the function children for the parameters bool skip_artificial = true; + if (die->GetOffset() == 1340212) // REMOVE THIS BEFORE CHECKIN + { // REMOVE THIS BEFORE CHECKIN + printf("this one!\n"); // REMOVE THIS BEFORE CHECKIN + } // REMOVE THIS BEFORE CHECKIN ParseChildParameters (sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls); // clang_type will get the function prototype clang type after this call @@ -2908,7 +2887,7 @@ } type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, 0, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); - const_cast(die)->SetUserData(type_sp.get()); + m_die_to_type[die] = type_sp.get(); assert(type_sp.get()); } } @@ -2918,7 +2897,7 @@ { //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this - const_cast(die)->SetUserData(DIE_IS_BEING_PARSED); + m_die_to_type[die] = DIE_IS_BEING_PARSED; size_t byte_size = 0; lldb::user_id_t type_die_offset = DW_INVALID_OFFSET; @@ -2993,7 +2972,7 @@ } ConstString empty_name; type_sp.reset( new Type(die->GetOffset(), this, empty_name, array_element_bit_stride / 8, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); - const_cast(die)->SetUserData(type_sp.get()); + m_die_to_type[die] = type_sp.get(); } } } @@ -3035,7 +3014,7 @@ size_t byte_size = ClangASTType::GetClangTypeBitWidth (type_list->GetClangASTContext().getASTContext(), clang_type) / 8; type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, NULL, clang_type)); - const_cast(die)->SetUserData(type_sp.get()); + m_die_to_type[die] = type_sp.get(); } break; @@ -3078,43 +3057,14 @@ { // We are ready to put this type into the uniqued list up at the module level TypeSP uniqued_type_sp(m_obj_file->GetModule()->GetTypeList()->InsertUnique(type_sp)); - - const_cast(die)->SetUserData(uniqued_type_sp.get()); - type_sp = uniqued_type_sp; + m_die_to_type[die] = type_sp.get(); } } } - else + else if (type_ptr != DIE_IS_BEING_PARSED) { - switch (tag) - { - case DW_TAG_base_type: - case DW_TAG_pointer_type: - case DW_TAG_reference_type: - case DW_TAG_typedef: - case DW_TAG_const_type: - case DW_TAG_restrict_type: - case DW_TAG_volatile_type: - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_class_type: - case DW_TAG_enumeration_type: - case DW_TAG_subprogram: - case DW_TAG_subroutine_type: - case DW_TAG_array_type: - { - Type *existing_type = (Type*)die->GetUserData(); - if (existing_type != DIE_IS_BEING_PARSED) - { - type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(existing_type->GetID()); - } - } - break; - default: - //assert(!"invalid type tag..."); - break; - } + type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(type_ptr->GetID()); } } return type_sp; @@ -3280,7 +3230,6 @@ const char *mangled = NULL; Declaration decl; uint32_t i; - TypeSP type_sp; Type *var_type = NULL; DWARFExpression location; bool is_external = false; @@ -3300,7 +3249,7 @@ case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: name = form_value.AsCString(&get_debug_str_data()); break; case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break; - case DW_AT_type: var_type = GetUniquedTypeForDIEOffset(form_value.Reference(dwarf_cu), type_sp, 0, 0, false); break; + case DW_AT_type: var_type = ResolveTypeUID(form_value.Reference(dwarf_cu)); break; case DW_AT_external: is_external = form_value.Unsigned() != 0; break; case DW_AT_location: { @@ -3396,7 +3345,8 @@ location, is_external, is_artificial)); - const_cast(die)->SetUserData(var_sp.get()); + + m_die_to_variable_sp[die] = var_sp; } } return var_sp; @@ -3477,7 +3427,7 @@ dw_tag_t tag = die->Tag(); // Check to see if we have already parsed this variable or constant? - if (die->GetUserData() == NULL) + if (m_die_to_variable_sp[die].get() == NULL) { // We haven't already parsed it, lets do that now. if ((tag == DW_TAG_variable) || 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=114876&r1=114875&r2=114876&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Mon Sep 27 16:07:38 2010 @@ -280,8 +280,12 @@ const NameToDIE &name_to_die, lldb_private::SymbolContextList& sc_list); - lldb_private::Type* GetUniquedTypeForDIEOffset(dw_offset_t type_die_offset, lldb::TypeSP& owning_type_sp, int32_t child_type, uint32_t idx, bool safe); - lldb::TypeSP GetTypeForDIE(DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die, lldb::TypeSP& owning_type_sp, int32_t child_type, uint32_t idx); + lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu, + const DWARFDebugInfoEntry* die, + lldb::TypeSP& owning_type_sp, + int32_t child_type, + uint32_t idx); + uint32_t FindTypes(std::vector die_offsets, uint32_t max_matches, lldb_private::TypeList& types); void Index(); @@ -313,7 +317,11 @@ std::auto_ptr m_ranges; typedef llvm::DenseMap DIEToDeclContextMap; + typedef llvm::DenseMap DIEToTypePtr; + typedef llvm::DenseMap DIEToVariableSP; DIEToDeclContextMap m_die_to_decl_ctx; + DIEToTypePtr m_die_to_type; + DIEToVariableSP m_die_to_variable_sp; }; From ctice at apple.com Mon Sep 27 16:35:15 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 27 Sep 2010 21:35:15 -0000 Subject: [Lldb-commits] [lldb] r114894 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20100927213515.DD37F2A6C12C@llvm.org> Author: ctice Date: Mon Sep 27 16:35:15 2010 New Revision: 114894 URL: http://llvm.org/viewvc/llvm-project?rev=114894&view=rev Log: Fix one-liner Python breakpoint commands to be wrapped up in an automatically generated Python function, and passed the stoppoint context frame and bp_loc as parameters. Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=114894&r1=114893&r2=114894&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Sep 27 16:35:15 2010 @@ -627,7 +627,7 @@ } } else - ::fprintf (out_fh, "Warning: No command attached to breakpoint.\n"); + ::fprintf (out_fh, "Warning: No command attached to breakpoint.\n"); } else { @@ -684,12 +684,18 @@ // It's necessary to set both user_source and script_source to the oneliner. // The former is used to generate callback description (as in breakpoint command list) // while the latter is used for Python to interpret during the actual callback. - data_ap->user_source.AppendString (oneliner); - data_ap->script_source.AppendString (oneliner); - BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release())); - bp_options->SetCallback (ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp); + data_ap->user_source.AppendString (oneliner); + if (GenerateBreakpointCommandCallbackData (data_ap->user_source, data_ap->script_source)) + { + if (data_ap->script_source.GetSize() == 1) + { + BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release())); + bp_options->SetCallback (ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp); + } + } + return; } From johnny.chen at apple.com Mon Sep 27 18:29:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 27 Sep 2010 23:29:54 -0000 Subject: [Lldb-commits] [lldb] r114923 - in /lldb/trunk/test: dotest.py types/TestBasicTypes.py types/TestFloatTypes.py types/TestIntegerTypes.py types/double.cpp types/float.cpp Message-ID: <20100927232954.EC3712A6C12C@llvm.org> Author: johnny Date: Mon Sep 27 18:29:54 2010 New Revision: 114923 URL: http://llvm.org/viewvc/llvm-project?rev=114923&view=rev Log: Added "float" and "double" to types/TestBasicTypes.py. Abstracted the generic type tester method into its own abstarct base class 'AbstractBase'. And added TestIntegerTypes.py and TestFloatTypes.py. Added an option "-p reg-exp-pattern" to the test driver to specify a regular expression pattern to match against eligible filenames as our test cases. An example: /Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -p "TestFloat.*" types ---------------------------------------------------------------------- Collected 4 tests test_double_type_with_dsym (TestFloatTypes.FloatTypesTestCase) Test that double-type variables are displayed correctly. ... ok test_double_type_with_dwarf (TestFloatTypes.FloatTypesTestCase) Test that double-type variables are displayed correctly. ... ok test_float_type_with_dwarf (TestFloatTypes.FloatTypesTestCase) Test that float-type variables are displayed correctly. ... ok test_float_types_with_dsym (TestFloatTypes.FloatTypesTestCase) Test that float-type variables are displayed correctly. ... ok ---------------------------------------------------------------------- Ran 4 tests in 5.592s OK Added: lldb/trunk/test/types/TestFloatTypes.py lldb/trunk/test/types/TestIntegerTypes.py lldb/trunk/test/types/double.cpp lldb/trunk/test/types/float.cpp Modified: lldb/trunk/test/dotest.py lldb/trunk/test/types/TestBasicTypes.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=114923&r1=114922&r2=114923&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Sep 27 18:29:54 2010 @@ -57,6 +57,9 @@ # Ignore the build search path relative to this script to locate the lldb.py module. ignore = False +# The regular expression pattern to match against eligible filenames as our test cases. +regexp = None + # Default verbosity is 0. verbose = 0 @@ -77,6 +80,7 @@ -d : delay startup for 10 seconds (in order for the debugger to attach) -i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build tree relative to this script; use PYTHONPATH to locate the module +-p : specify a regexp filename pattern for inclusion in the test suite -t : trace lldb command execution and result -v : do verbose mode of unittest framework @@ -109,7 +113,8 @@ global configFile global delay - global inore + global ignore + global regexp global verbose global testdirs @@ -141,6 +146,13 @@ elif sys.argv[index].startswith('-i'): ignore = True index += 1 + elif sys.argv[index].startswith('-p'): + # Increment by 1 to fetch the reg exp pattern argument. + index += 1 + if index >= len(sys.argv) or sys.argv[index].startswith('-'): + usage() + regexp = sys.argv[index] + index += 1 elif sys.argv[index].startswith('-t'): os.environ["LLDB_COMMAND_TRACE"] = "YES" index += 1 @@ -246,13 +258,24 @@ """Visitor function for os.path.walk(path, visit, arg).""" global suite + global regexp for name in names: if os.path.isdir(os.path.join(dir, name)): continue if '.py' == os.path.splitext(name)[1] and name.startswith(prefix): - # We found a pattern match for our test case. Add it to the suite. + # Try to match the regexp pattern, if specified. + if regexp: + import re + if re.search(regexp, name): + #print "Filename: '%s' matches pattern: '%s'" % (name, regexp) + pass + else: + #print "Filename: '%s' does not match pattern: '%s'" % (name, regexp) + continue + + # We found a match for our test case. Add it to the suite. if not sys.path.count(dir): sys.path.append(dir) base = os.path.splitext(name)[0] Modified: lldb/trunk/test/types/TestBasicTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114923&r1=114922&r2=114923&view=diff ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (original) +++ lldb/trunk/test/types/TestBasicTypes.py Mon Sep 27 18:29:54 2010 @@ -1,211 +1,21 @@ """ -Test that variables of integer basic types are displayed correctly. +Abstract base class of basic types provides a generic type tester method. """ import os, time import re -import unittest2 import lldb from lldbtest import * def Msg(var, val): return "'frame variable %s' matches the compiler's output: %s" % (var, val) -class BasicTypesTestCase(TestBase): - - mydir = "types" +class AbstractBase(TestBase): # This is the pattern by design to match the " var = 'value'" output from # printf() stmts (see basic_type.cpp). pattern = re.compile(" (\*?a[^=]*) = '([^=]*)'$") - def test_char_type_with_dsym(self): - """Test that char-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'char.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.char_type() - - def test_char_type_with_dwarf(self): - """Test that char-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'char.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.char_type() - - def test_unsigned_char_type_with_dsym(self): - """Test that 'unsigned_char'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_char.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_char_type() - - def test_unsigned_char_type_with_dwarf(self): - """Test that 'unsigned char'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_char.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_char_type() - - def test_short_type_with_dsym(self): - """Test that short-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'short.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.short_type() - - def test_short_type_with_dwarf(self): - """Test that short-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'short.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.short_type() - - def test_unsigned_short_type_with_dsym(self): - """Test that 'unsigned_short'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_short.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_short_type() - - def test_unsigned_short_type_with_dwarf(self): - """Test that 'unsigned short'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_short.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_short_type() - - def test_int_type_with_dsym(self): - """Test that int-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'int.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type() - - def test_int_type_with_dwarf(self): - """Test that int-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'int.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type() - - def test_unsigned_int_type_with_dsym(self): - """Test that 'unsigned_int'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type() - - def test_unsigned_int_type_with_dwarf(self): - """Test that 'unsigned int'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type() - - def test_long_type_with_dsym(self): - """Test that long-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type() - - def test_long_type_with_dwarf(self): - """Test that long-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type() - - def test_unsigned_long_type_with_dsym(self): - """Test that 'unsigned long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type() - - def test_unsigned_long_type_with_dwarf(self): - """Test that 'unsigned long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type() - - # rdar://problem/8482903 - # test suite failure for types dir -- "long long" and "unsigned long long" - - @unittest2.expectedFailure - def test_long_long_type_with_dsym(self): - """Test that 'long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type() - - @unittest2.expectedFailure - def test_long_long_type_with_dwarf(self): - """Test that 'long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type() - - @unittest2.expectedFailure - def test_unsigned_long_long_type_with_dsym(self): - """Test that 'unsigned long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type() - - @unittest2.expectedFailure - def test_unsigned_long_long_type_with_dwarf(self): - """Test that 'unsigned long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type() - - def char_type(self): - """Test that char-type variables are displayed correctly.""" - self.generic_type_tester(set(['char']), quotedDisplay=True) - - def unsigned_char_type(self): - """Test that 'unsigned char'-type variables are displayed correctly.""" - self.generic_type_tester(set(['unsigned', 'char']), quotedDisplay=True) - - def short_type(self): - """Test that short-type variables are displayed correctly.""" - self.generic_type_tester(set(['short'])) - - def unsigned_short_type(self): - """Test that 'unsigned short'-type variables are displayed correctly.""" - self.generic_type_tester(set(['unsigned', 'short'])) - - def int_type(self): - """Test that int-type variables are displayed correctly.""" - self.generic_type_tester(set(['int'])) - - def unsigned_int_type(self): - """Test that 'unsigned int'-type variables are displayed correctly.""" - self.generic_type_tester(set(['unsigned', 'int'])) - - def long_type(self): - """Test that long-type variables are displayed correctly.""" - self.generic_type_tester(set(['long'])) - - def unsigned_long_type(self): - """Test that 'unsigned long'-type variables are displayed correctly.""" - self.generic_type_tester(set(['unsigned', 'long'])) - - def long_long_type(self): - """Test that long long-type variables are displayed correctly.""" - self.generic_type_tester(set(['long long'])) - - def unsigned_long_long_type(self): - """Test that 'unsigned long long'-type variables are displayed correctly.""" - self.generic_type_tester(set(['unsigned', 'long long'])) - def generic_type_tester(self, atoms, quotedDisplay=False): """Test that variables with basic types are displayed correctly.""" @@ -275,10 +85,3 @@ nv = (" %s = '%s'" if quotedDisplay else " %s = %s") % (var, val) self.expect(output, Msg(var, val), exe=False, substrs = [nv]) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() Added: lldb/trunk/test/types/TestFloatTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypes.py?rev=114923&view=auto ============================================================================== --- lldb/trunk/test/types/TestFloatTypes.py (added) +++ lldb/trunk/test/types/TestFloatTypes.py Mon Sep 27 18:29:54 2010 @@ -0,0 +1,54 @@ +""" +Test that variables of floating point types are displayed correctly. +""" + +import TestBasicTypes +import unittest2 +import lldb + +class FloatTypesTestCase(TestBasicTypes.AbstractBase): + + mydir = "types" + + def test_float_types_with_dsym(self): + """Test that float-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'float.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.float_type() + + def test_float_type_with_dwarf(self): + """Test that float-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'float.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.float_type() + + def test_double_type_with_dsym(self): + """Test that double-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'double.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.double_type() + + def test_double_type_with_dwarf(self): + """Test that double-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'double.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.double_type() + + def float_type(self): + """Test that float-type variables are displayed correctly.""" + self.generic_type_tester(set(['float'])) + + def double_type(self): + """Test that double-type variables are displayed correctly.""" + self.generic_type_tester(set(['double'])) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/types/TestIntegerTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypes.py?rev=114923&view=auto ============================================================================== --- lldb/trunk/test/types/TestIntegerTypes.py (added) +++ lldb/trunk/test/types/TestIntegerTypes.py Mon Sep 27 18:29:54 2010 @@ -0,0 +1,205 @@ +""" +Test that variables of integer basic types are displayed correctly. +""" + +import TestBasicTypes +import unittest2 +import lldb + +class IntegerTypesTestCase(TestBasicTypes.AbstractBase): + + mydir = "types" + + def test_char_type_with_dsym(self): + """Test that char-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'char.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.char_type() + + def test_char_type_with_dwarf(self): + """Test that char-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'char.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.char_type() + + def test_unsigned_char_type_with_dsym(self): + """Test that 'unsigned_char'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_char.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_char_type() + + def test_unsigned_char_type_with_dwarf(self): + """Test that 'unsigned char'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_char.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_char_type() + + def test_short_type_with_dsym(self): + """Test that short-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'short.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.short_type() + + def test_short_type_with_dwarf(self): + """Test that short-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'short.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.short_type() + + def test_unsigned_short_type_with_dsym(self): + """Test that 'unsigned_short'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_short.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_short_type() + + def test_unsigned_short_type_with_dwarf(self): + """Test that 'unsigned short'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_short.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_short_type() + + def test_int_type_with_dsym(self): + """Test that int-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'int.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.int_type() + + def test_int_type_with_dwarf(self): + """Test that int-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'int.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.int_type() + + def test_unsigned_int_type_with_dsym(self): + """Test that 'unsigned_int'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_int.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_int_type() + + def test_unsigned_int_type_with_dwarf(self): + """Test that 'unsigned int'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_int.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_int_type() + + def test_long_type_with_dsym(self): + """Test that long-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_type() + + def test_long_type_with_dwarf(self): + """Test that long-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_type() + + def test_unsigned_long_type_with_dsym(self): + """Test that 'unsigned long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_type() + + def test_unsigned_long_type_with_dwarf(self): + """Test that 'unsigned long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_type() + + # rdar://problem/8482903 + # test suite failure for types dir -- "long long" and "unsigned long long" + + @unittest2.expectedFailure + def test_long_long_type_with_dsym(self): + """Test that 'long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_long_type() + + @unittest2.expectedFailure + def test_long_long_type_with_dwarf(self): + """Test that 'long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'long_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_long_type() + + @unittest2.expectedFailure + def test_unsigned_long_long_type_with_dsym(self): + """Test that 'unsigned long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_long_type() + + @unittest2.expectedFailure + def test_unsigned_long_long_type_with_dwarf(self): + """Test that 'unsigned long long'-type variables are displayed correctly.""" + d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_long_type() + + def char_type(self): + """Test that char-type variables are displayed correctly.""" + self.generic_type_tester(set(['char']), quotedDisplay=True) + + def unsigned_char_type(self): + """Test that 'unsigned char'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'char']), quotedDisplay=True) + + def short_type(self): + """Test that short-type variables are displayed correctly.""" + self.generic_type_tester(set(['short'])) + + def unsigned_short_type(self): + """Test that 'unsigned short'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'short'])) + + def int_type(self): + """Test that int-type variables are displayed correctly.""" + self.generic_type_tester(set(['int'])) + + def unsigned_int_type(self): + """Test that 'unsigned int'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'int'])) + + def long_type(self): + """Test that long-type variables are displayed correctly.""" + self.generic_type_tester(set(['long'])) + + def unsigned_long_type(self): + """Test that 'unsigned long'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'long'])) + + def long_long_type(self): + """Test that long long-type variables are displayed correctly.""" + self.generic_type_tester(set(['long long'])) + + def unsigned_long_long_type(self): + """Test that 'unsigned long long'-type variables are displayed correctly.""" + self.generic_type_tester(set(['unsigned', 'long long'])) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/types/double.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/double.cpp?rev=114923&view=auto ============================================================================== --- lldb/trunk/test/types/double.cpp (added) +++ lldb/trunk/test/types/double.cpp Mon Sep 27 18:29:54 2010 @@ -0,0 +1,9 @@ +#define T double +#define T_CSTR "double" +#define T_VALUE_1 1100.125 +#define T_VALUE_2 2200.250 +#define T_VALUE_3 33.00 +#define T_VALUE_4 44.00 +#define T_PRINTF_FORMAT "%lg" + +#include "basic_type.cpp" Added: lldb/trunk/test/types/float.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/float.cpp?rev=114923&view=auto ============================================================================== --- lldb/trunk/test/types/float.cpp (added) +++ lldb/trunk/test/types/float.cpp Mon Sep 27 18:29:54 2010 @@ -0,0 +1,9 @@ +#define T float +#define T_CSTR "float" +#define T_VALUE_1 1100.125 +#define T_VALUE_2 2200.250 +#define T_VALUE_3 33.00 +#define T_VALUE_4 44.00 +#define T_PRINTF_FORMAT "%g" + +#include "basic_type.cpp" From johnny.chen at apple.com Mon Sep 27 18:46:46 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 27 Sep 2010 23:46:46 -0000 Subject: [Lldb-commits] [lldb] r114926 - in /lldb/trunk/test/types: AbstractBase.py TestBasicTypes.py TestFloatTypes.py TestIntegerTypes.py Message-ID: <20100927234646.B85212A6C12C@llvm.org> Author: johnny Date: Mon Sep 27 18:46:46 2010 New Revision: 114926 URL: http://llvm.org/viewvc/llvm-project?rev=114926&view=rev Log: Use a better name for the abstract base class which contains the generic_type_tester() method. Renamed it to be AbstractBase.py, which contains the GenericTester class that both IntegerTypesTestCase and FloatTypesTestCase inherit from. Added: lldb/trunk/test/types/AbstractBase.py - copied, changed from r114923, lldb/trunk/test/types/TestBasicTypes.py Removed: lldb/trunk/test/types/TestBasicTypes.py Modified: lldb/trunk/test/types/TestFloatTypes.py lldb/trunk/test/types/TestIntegerTypes.py Copied: lldb/trunk/test/types/AbstractBase.py (from r114923, lldb/trunk/test/types/TestBasicTypes.py) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?p2=lldb/trunk/test/types/AbstractBase.py&p1=lldb/trunk/test/types/TestBasicTypes.py&r1=114923&r2=114926&rev=114926&view=diff ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (original) +++ lldb/trunk/test/types/AbstractBase.py Mon Sep 27 18:46:46 2010 @@ -10,7 +10,7 @@ def Msg(var, val): return "'frame variable %s' matches the compiler's output: %s" % (var, val) -class AbstractBase(TestBase): +class GenericTester(TestBase): # This is the pattern by design to match the " var = 'value'" output from # printf() stmts (see basic_type.cpp). Removed: lldb/trunk/test/types/TestBasicTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestBasicTypes.py?rev=114925&view=auto ============================================================================== --- lldb/trunk/test/types/TestBasicTypes.py (original) +++ lldb/trunk/test/types/TestBasicTypes.py (removed) @@ -1,87 +0,0 @@ -""" -Abstract base class of basic types provides a generic type tester method. -""" - -import os, time -import re -import lldb -from lldbtest import * - -def Msg(var, val): - return "'frame variable %s' matches the compiler's output: %s" % (var, val) - -class AbstractBase(TestBase): - - # This is the pattern by design to match the " var = 'value'" output from - # printf() stmts (see basic_type.cpp). - pattern = re.compile(" (\*?a[^=]*) = '([^=]*)'$") - - def generic_type_tester(self, atoms, quotedDisplay=False): - """Test that variables with basic types are displayed correctly.""" - - # First, capture the golden output emitted by the oracle, i.e., the - # series of printf statements. - go = system("./a.out") - # This golden list contains a list of (variable, value) pairs extracted - # from the golden output. - gl = [] - - # Scan the golden output line by line, looking for the pattern: - # - # variable = 'value' - # - # Filter out the following lines, for the time being: - # - # 'a_ref = ...' - # 'a_class_ref.m_a = ...' - # 'a_class_ref.m_b = ...' - # 'a_struct_ref.a = ...' - # 'a_struct_ref.b = ...' - # 'a_union_zero_ref.a = ...' - # 'a_union_nonzero_ref.u.a = ...' - # - # rdar://problem/8471016 frame variable a_ref should display the referenced value as well - # rdar://problem/8470987 frame variable a_class_ref.m_a does not work - notnow = set(['a_ref', - 'a_class_ref.m_a', 'a_class_ref.m_b', - 'a_struct_ref.a', 'a_struct_ref.b', - 'a_union_zero_ref.a', 'a_union_nonzero_ref.u.a']) - for line in go.split(os.linesep): - match = self.pattern.search(line) - if match: - var, val = match.group(1), match.group(2) - if var in notnow: - continue - gl.append((var, val)) - #print "golden list:", gl - - # Bring the program to the point where we can issue a series of - # 'frame variable' command. - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - self.runCmd("breakpoint set --name Puts") - self.runCmd("run", RUN_SUCCEEDED) - self.runCmd("thread step-out", STEP_OUT_SUCCEEDED) - - #self.runCmd("frame variable") - - # Now iterate through the golden list, comparing against the output from - # 'frame variable var'. - for var, val in gl: - self.runCmd("frame variable %s" % var) - output = self.res.GetOutput() - - # The input type is in a canonical form as a set named atoms. - # The display type string must conatin each and every element. - dt = re.match("^\((.*)\)", output).group(1) - - # Expect the display type string to contain each and every atoms. - self.expect(dt, - "Display type: '%s' must contain the type atoms: '%s'" % - (dt, atoms), - exe=False, - substrs = list(atoms)) - - # The (var, val) pair must match, too. - nv = (" %s = '%s'" if quotedDisplay else " %s = %s") % (var, val) - self.expect(output, Msg(var, val), exe=False, - substrs = [nv]) Modified: lldb/trunk/test/types/TestFloatTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypes.py?rev=114926&r1=114925&r2=114926&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypes.py (original) +++ lldb/trunk/test/types/TestFloatTypes.py Mon Sep 27 18:46:46 2010 @@ -2,11 +2,11 @@ Test that variables of floating point types are displayed correctly. """ -import TestBasicTypes +import AbstractBase import unittest2 import lldb -class FloatTypesTestCase(TestBasicTypes.AbstractBase): +class FloatTypesTestCase(AbstractBase.GenericTester): mydir = "types" Modified: lldb/trunk/test/types/TestIntegerTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypes.py?rev=114926&r1=114925&r2=114926&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypes.py (original) +++ lldb/trunk/test/types/TestIntegerTypes.py Mon Sep 27 18:46:46 2010 @@ -2,11 +2,11 @@ Test that variables of integer basic types are displayed correctly. """ -import TestBasicTypes +import AbstractBase import unittest2 import lldb -class IntegerTypesTestCase(TestBasicTypes.AbstractBase): +class IntegerTypesTestCase(AbstractBase.GenericTester): mydir = "types" From johnny.chen at apple.com Mon Sep 27 18:53:07 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 27 Sep 2010 23:53:07 -0000 Subject: [Lldb-commits] [lldb] r114927 - /lldb/trunk/test/types/AbstractBase.py Message-ID: <20100927235307.346272A6C12C@llvm.org> Author: johnny Date: Mon Sep 27 18:53:07 2010 New Revision: 114927 URL: http://llvm.org/viewvc/llvm-project?rev=114927&view=rev Log: Trivial assert message modification. Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=114927&r1=114926&r2=114927&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Mon Sep 27 18:53:07 2010 @@ -8,7 +8,7 @@ from lldbtest import * def Msg(var, val): - return "'frame variable %s' matches the compiler's output: %s" % (var, val) + return "'frame variable %s' matches the output (from compiled code): %s" % (var, val) class GenericTester(TestBase): From scallanan at apple.com Mon Sep 27 18:54:58 2010 From: scallanan at apple.com (Sean Callanan) Date: Mon, 27 Sep 2010 23:54:58 -0000 Subject: [Lldb-commits] [lldb] r114928 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20100927235458.E9F792A6C12C@llvm.org> Author: spyffe Date: Mon Sep 27 18:54:58 2010 New Revision: 114928 URL: http://llvm.org/viewvc/llvm-project?rev=114928&view=rev Log: Added type lookup, so variables with user-defined types can be allocated and manipulated. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=114928&r1=114927&r2=114928&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon Sep 27 18:54:58 2010 @@ -19,6 +19,7 @@ // Other libraries and framework includes // Project includes +#include "llvm/ADT/DenseMap.h" #include "lldb/Core/ClangForward.h" #include "lldb/Core/Value.h" #include "lldb/Expression/ClangExpressionVariable.h" @@ -363,6 +364,16 @@ std::string m_result_name; ///< The name of the result variable ($1, for example) TypeFromUser m_object_pointer_type; ///< The type of the "this" variable, if one exists. + llvm::DenseMap m_lookedup_types; ///< Contains each type that has been looked up in the current type lookup stack. + ///< m_lookedup_types is used to gate the type search in GetDecls(). If a name is + ///< not in it, the following procedure occurs: + ///< 1 The name is added to m_lookedup_types. + ///< 2 The type is looked up and added, potentially causing more type loookups. + ///< 3 The name is removed from m_lookedup_types. + ///< There must be no non-fatal error path that permits the type search to complete + ///< without removing the name from m_lookedup_types at the end. + ///< m_lookedup_type assumes single threadedness. + //------------------------------------------------------------------ /// Given a stack frame, find a variable that matches the given name and /// type. We need this for expression re-use; we may not always get the @@ -383,12 +394,6 @@ /// @return /// The LLDB Variable found, or NULL if none was found. //------------------------------------------------------------------ -#ifdef OLD_CODE - Variable *FindVariableInScope(const SymbolContext &sym_ctx, - const char *name, - TypeFromUser *type = NULL); -#endif - Variable *FindVariableInScope(StackFrame &frame, const char *name, TypeFromUser *type = NULL); Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=114928&r1=114927&r2=114928&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Sep 27 18:54:58 2010 @@ -688,112 +688,6 @@ return true; } -#ifdef OLD_CODE -Variable* -ClangExpressionDeclMap::FindVariableInScope(const SymbolContext &sym_ctx, - const char *name, - TypeFromUser *type) -{ - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); - - if (m_sym_ctx->function == NULL || m_sym_ctx->block == NULL) - { - if (log) - log->Printf("function = %p, block = %p", m_sym_ctx->function, m_sym_ctx->block); - return NULL; - } - - ConstString name_cs(name); - - Block *current_block; - - for (current_block = m_sym_ctx->block; - current_block != NULL; - current_block = current_block->GetParent()) - { - lldb::VariableListSP var_list = current_block->GetVariableList(false, true); - - if (!var_list) - continue; - - lldb::VariableSP var = var_list->FindVariable(name_cs); - - if (!var) - continue; - - // var->GetType()->GetClangAST() is the program's AST context and holds - // var->GetType()->GetOpaqueClangQualType(). - - // type is m_type for one of the struct members, which was added by - // AddValueToStruct. That type was extracted from the AST context of - // the compiler in IRForTarget. The original for the type was copied - // out of the program's AST context by AddOneVariable. - - // So that we can compare these two without having to copy back - // something we already had in the original AST context, we maintain - // m_orig_type and m_ast_context (which are passed into - // MaterializeOneVariable by Materialize) for each variable. - - if (!type) - return var.get(); - - if (type->GetASTContext() == var->GetType()->GetClangAST()) - { - if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetOpaqueClangQualType())) - continue; - } - else - { - if (log) - log->PutCString("Skipping a candidate variable because of different AST contexts"); - continue; - } - - return var.get(); - } - - { - CompileUnit *compile_unit = m_sym_ctx->comp_unit; - - if (!compile_unit) - { - if (log) - log->Printf("compile_unit = %p", compile_unit); - return NULL; - } - - lldb::VariableListSP var_list = compile_unit->GetVariableList(true); - - if (!var_list) - return NULL; - - lldb::VariableSP var = var_list->FindVariable(name_cs); - - if (!var) - return NULL; - - if (!type) - return var.get(); - - if (type->GetASTContext() == var->GetType()->GetClangAST()) - { - if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetOpaqueClangQualType())) - return NULL; - } - else - { - if (log) - log->PutCString("Skipping a candidate variable because of different AST contexts"); - return NULL; - } - - return var.get(); - } - - return NULL; -} -#endif - Variable * ClangExpressionDeclMap::FindVariableInScope(StackFrame &frame, const char *name, @@ -926,12 +820,32 @@ if (pvar) AddOneVariable(context, pvar); - /* Commented out pending resolution of a loop when the TagType is imported - lldb::TypeSP type = m_sym_ctx->FindTypeByName(name_cs); - if (type.get()) - AddOneType(context, type.get()); - */ + // See information on gating of this operation next to the definition for + // m_lookedup_types. + + const char *name_uniq = name_cs.GetCString(); + + if (m_lookedup_types.find(name_uniq) == m_lookedup_types.end()) + { + // 1 The name is added to m_lookedup_types. + m_lookedup_types.insert(std::pair(name_uniq, true)); + + // 2 The type is looked up and added, potentially causing more type loookups. + lldb::TypeSP type = m_sym_ctx->FindTypeByName(name_cs); + + if (type.get()) + { + TypeFromUser user_type(type->GetOpaqueClangQualType(), + type->GetClangAST()); + + AddOneType(context, user_type, false); + } + + // 3 The name is removed from m_lookedup_types. + m_lookedup_types.erase(name_uniq); + } + } Value * From gclayton at apple.com Mon Sep 27 20:04:25 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 28 Sep 2010 01:04:25 -0000 Subject: [Lldb-commits] [lldb] r114932 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: SymbolFileDWARF.cpp SymbolFileDWARF.h Message-ID: <20100928010425.E7EBE2A6C12C@llvm.org> Author: gclayton Date: Mon Sep 27 20:04:25 2010 New Revision: 114932 URL: http://llvm.org/viewvc/llvm-project?rev=114932&view=rev Log: Added a DIE to clang opaque type map. Removed code that shouldn't have been checked in. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 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=114932&r1=114931&r2=114932&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Sep 27 20:04:25 2010 @@ -2561,6 +2561,10 @@ assert (tag_decl_kind != -1); clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language); + // Store a forward declaration to this class type in case any + // parameters in any class methods need it for the clang + // types for function prototypes. + m_die_to_clang_type[die] = clang_type; m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); @@ -2795,10 +2799,6 @@ // Parse the function children for the parameters bool skip_artificial = true; - if (die->GetOffset() == 1340212) // REMOVE THIS BEFORE CHECKIN - { // REMOVE THIS BEFORE CHECKIN - printf("this one!\n"); // REMOVE THIS BEFORE CHECKIN - } // REMOVE THIS BEFORE CHECKIN ParseChildParameters (sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls); // clang_type will get the function prototype clang type after this call 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=114932&r1=114931&r2=114932&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Mon Sep 27 20:04:25 2010 @@ -319,9 +319,11 @@ typedef llvm::DenseMap DIEToDeclContextMap; typedef llvm::DenseMap DIEToTypePtr; typedef llvm::DenseMap DIEToVariableSP; + typedef llvm::DenseMap DIEToClangType; DIEToDeclContextMap m_die_to_decl_ctx; DIEToTypePtr m_die_to_type; DIEToVariableSP m_die_to_variable_sp; + DIEToClangType m_die_to_clang_type; }; From jingham at apple.com Mon Sep 27 20:25:33 2010 From: jingham at apple.com (Jim Ingham) Date: Tue, 28 Sep 2010 01:25:33 -0000 Subject: [Lldb-commits] [lldb] r114935 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Target/ lldb.xcodeproj/ source/Core/ source/Expression/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/ source/Target/ Message-ID: <20100928012533.6DCC72A6C12C@llvm.org> Author: jingham Date: Mon Sep 27 20:25:32 2010 New Revision: 114935 URL: http://llvm.org/viewvc/llvm-project?rev=114935&view=rev Log: Replace the vestigial Value::GetOpaqueCLangQualType with the more correct Value::GetValueOpaqueClangQualType. But mostly, move the ObjC Trampoline handling code from the MacOSX dyld plugin to the AppleObjCRuntime classes. Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp - copied, changed from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h - copied, changed from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp - copied, changed from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h Removed: lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.h lldb/trunk/source/Target/ObjCObjectPrinter.cpp Modified: lldb/trunk/include/lldb/Core/Value.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h lldb/trunk/include/lldb/Target/LanguageRuntime.h lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/Value.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectChild.cpp lldb/trunk/source/Core/ValueObjectVariable.cpp lldb/trunk/source/Expression/ClangExpressionVariable.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h lldb/trunk/source/Target/CPPLanguageRuntime.cpp lldb/trunk/source/Target/LanguageRuntime.cpp lldb/trunk/source/Target/ObjCLanguageRuntime.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlanStepThrough.cpp Modified: lldb/trunk/include/lldb/Core/Value.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Value.h (original) +++ lldb/trunk/include/lldb/Core/Value.h Mon Sep 27 20:25:32 2010 @@ -119,9 +119,6 @@ lldb::Format GetValueDefaultFormat (); - void * - GetValueOpaqueClangQualType (); - size_t GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr); Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Sep 27 20:25:32 2010 @@ -59,6 +59,9 @@ virtual ConstString GetTypeName() = 0; + virtual lldb::LanguageType + GetObjectRuntimeLanguage(); + virtual void UpdateValue (ExecutionContextScope *exe_scope) = 0; Modified: lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h Mon Sep 27 20:25:32 2010 @@ -36,6 +36,9 @@ virtual bool IsVTableName (const char *name) = 0; + virtual bool + GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope); + protected: //------------------------------------------------------------------ // Classes that inherit from CPPLanguageRuntime can see and modify these Modified: lldb/trunk/include/lldb/Target/LanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/LanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Mon Sep 27 20:25:32 2010 @@ -14,8 +14,10 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/lldb-include.h" #include "lldb/Core/PluginInterface.h" #include "lldb/lldb-private.h" +#include "lldb/Target/ExecutionContextScope.h" namespace lldb_private { @@ -32,13 +34,19 @@ virtual lldb::LanguageType GetLanguageType () const = 0; + virtual bool + GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope) = 0; + + virtual lldb::ValueObjectSP + GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope) = 0; + protected: //------------------------------------------------------------------ // Classes that inherit from LanguageRuntime can see and modify these //------------------------------------------------------------------ LanguageRuntime(Process *process); + Process *m_process; private: - Process *m_process_ptr; DISALLOW_COPY_AND_ASSIGN (LanguageRuntime); }; Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Mon Sep 27 20:25:32 2010 @@ -12,10 +12,12 @@ // C Includes // C++ Includes +#include + // Other libraries and framework includes // Project includes -#include "lldb/Core/PluginInterface.h" #include "lldb/lldb-private.h" +#include "lldb/Core/PluginInterface.h" #include "lldb/Target/LanguageRuntime.h" namespace lldb_private { @@ -33,12 +35,79 @@ return lldb::eLanguageTypeObjC; } + virtual bool + IsModuleObjCLibrary (const lldb::ModuleSP &module_sp) = 0; + + virtual bool + ReadObjCLibrary (const lldb::ModuleSP &module_sp) = 0; + + virtual bool + HasReadObjCLibrary () = 0; + + virtual lldb::ThreadPlanSP + GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) = 0; + + lldb::addr_t + LookupInMethodCache (lldb::addr_t class_addr, lldb::addr_t sel); + + void + AddToMethodCache (lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr); + protected: //------------------------------------------------------------------ // Classes that inherit from ObjCLanguageRuntime can see and modify these //------------------------------------------------------------------ ObjCLanguageRuntime(Process *process); private: + // We keep a map of ->Implementation so we don't have to call the resolver + // function over and over. + + // FIXME: We need to watch for the loading of Protocols, and flush the cache for any + // class that we see so changed. + + struct ClassAndSel + { + ClassAndSel() + { + sel_addr = LLDB_INVALID_ADDRESS; + class_addr = LLDB_INVALID_ADDRESS; + } + ClassAndSel (lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) : + class_addr (in_class_addr), + sel_addr(in_sel_addr) + { + } + bool operator== (const ClassAndSel &rhs) + { + if (class_addr == rhs.class_addr + && sel_addr == rhs.sel_addr) + return true; + else + return false; + } + + bool operator< (const ClassAndSel &rhs) const + { + if (class_addr < rhs.class_addr) + return true; + else if (class_addr > rhs.class_addr) + return false; + else + { + if (sel_addr < rhs.sel_addr) + return true; + else + return false; + } + } + + lldb::addr_t class_addr; + lldb::addr_t sel_addr; + }; + + typedef std::map MsgImplMap; + MsgImplMap m_impl_cache; + DISALLOW_COPY_AND_ASSIGN (ObjCLanguageRuntime); }; Removed: lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h?rev=114934&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h (original) +++ lldb/trunk/include/lldb/Target/ObjCObjectPrinter.h (removed) @@ -1,49 +0,0 @@ -//===-- ObjCObjectPrinter.h ---------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_ObjCObjectPrinter_h_ -#define liblldb_ObjCObjectPrinter_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/ConstString.h" -#include "lldb/Core/Error.h" -// Project includes - -namespace lldb_private { - - class ObjCObjectPrinter - { - public: - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ - ObjCObjectPrinter (Process &process); - - virtual - ~ObjCObjectPrinter (); - - bool - PrintObject (Stream &str, Value &object_ptr, ExecutionContext &exe_ctx); - protected: - Process &m_process; - std::auto_ptr
m_PrintForDebugger_addr; - - Address *GetPrintForDebuggerAddr(); - private: - //------------------------------------------------------------------ - // For ObjCObjectPrinter only - //------------------------------------------------------------------ - DISALLOW_COPY_AND_ASSIGN (ObjCObjectPrinter); - }; - -} // namespace lldb_private - -#endif // liblldb_ObjCObjectPrinter_h_ Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon Sep 27 20:25:32 2010 @@ -30,7 +30,6 @@ #include "lldb/Expression/ClangPersistentVariables.h" #include "lldb/Expression/IRDynamicChecks.h" #include "lldb/Target/ExecutionContextScope.h" -#include "lldb/Target/ObjCObjectPrinter.h" #include "lldb/Target/ThreadList.h" #include "lldb/Target/UnixSignals.h" @@ -1598,9 +1597,6 @@ ClangPersistentVariables & GetPersistentVariables(); - ObjCObjectPrinter & - GetObjCObjectPrinter(); - protected: //------------------------------------------------------------------ // Member variables @@ -1627,7 +1623,6 @@ UnixSignals m_unix_signals; /// This is the current signal set for this process. ConstString m_target_triple; lldb::ABISP m_abi_sp; - ObjCObjectPrinter m_objc_object_printer; typedef std::map LanguageRuntimeCollection; LanguageRuntimeCollection m_language_runtimes; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Mon Sep 27 20:25:32 2010 @@ -87,7 +87,6 @@ class ModuleList; class Mutex; class ObjCLanguageRuntime; -class ObjCObjectPrinter; class ObjectContainer; class ObjectFile; class Options; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Sep 27 20:25:32 2010 @@ -290,14 +290,11 @@ 26D5B15111B07550009A862E /* unw_getcontext.s in Sources */ = {isa = PBXBuildFile; fileRef = 9654F7BA1197DA3F00F72B43 /* unw_getcontext.s */; }; 26D5B15211B07550009A862E /* LibUnwindRegisterContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B4666F11A2091600CF6220 /* LibUnwindRegisterContext.cpp */; }; 26D5B15311B07550009A862E /* ABIMacOSX_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 497650CE11A21BEE008DDB57 /* ABIMacOSX_i386.cpp */; }; - 26D5B15411B07550009A862E /* ObjCTrampolineHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C51FF1611A4C486007C962F /* ObjCTrampolineHandler.cpp */; }; 26D5B15511B07550009A862E /* Baton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A0604811A5D03C00F75969 /* Baton.cpp */; }; 26D5B15611B07550009A862E /* CommandObjectArgs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 499F381F11A5B3F300F5CE02 /* CommandObjectArgs.cpp */; }; - 26D5B15711B07550009A862E /* ThreadPlanStepThroughObjCTrampoline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF4473E11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.cpp */; }; 26D5B15911B07550009A862E /* UnwindLibUnwind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEBE11A98A1900FBADB6 /* UnwindLibUnwind.cpp */; }; 26D5B15A11B07550009A862E /* UnwindMacOSXFrameBackchain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEE311A9901300FBADB6 /* UnwindMacOSXFrameBackchain.cpp */; }; 26D5B15B11B07550009A862E /* RegisterContextMacOSXFrameBackchain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */; }; - 26D5B15C11B07550009A862E /* ObjCObjectPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49BF48DC11ADF356008863BD /* ObjCObjectPrinter.cpp */; }; 26D5B18E11B07979009A862E /* libuwind.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 9654F7B31197DA3F00F72B43 /* libuwind.cxx */; }; 26DE1E6B11616C2E00A093E2 /* lldb-forward-rtti.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE1E6911616C2E00A093E2 /* lldb-forward-rtti.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26DE1E6C11616C2E00A093E2 /* lldb-forward.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE1E6A11616C2E00A093E2 /* lldb-forward.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -351,6 +348,10 @@ 49FB515E121481B000DF8983 /* DWARFExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7ED810F1B86700F91463 /* DWARFExpression.cpp */; }; 4C08CDE811C81EF8001610A8 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; }; 4C08CDEC11C81F1E001610A8 /* ThreadSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */; }; + 4C0A91D812511CB900CA6636 /* AppleObjCTrampolineHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0A91D412511CB900CA6636 /* AppleObjCTrampolineHandler.cpp */; }; + 4C0A91D912511CB900CA6636 /* AppleObjCTrampolineHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C0A91D512511CB900CA6636 /* AppleObjCTrampolineHandler.h */; }; + 4C0A91DA12511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C0A91D612511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */; }; + 4C0A91DB12511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C0A91D712511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h */; }; 4C139EA5124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */; }; 4C139EA6124A8B03000BFF8D /* AppleObjCRuntimeV2.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */; }; 4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */; }; @@ -949,8 +950,6 @@ 49A8A39F11D568A300AD3B68 /* ASTResultSynthesizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTResultSynthesizer.cpp; path = source/Expression/ASTResultSynthesizer.cpp; sourceTree = ""; }; 49A8A3A311D568BF00AD3B68 /* ASTResultSynthesizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASTResultSynthesizer.h; path = include/lldb/Expression/ASTResultSynthesizer.h; sourceTree = ""; }; 49BB309511F79450001A4197 /* TaggedASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TaggedASTType.h; path = include/lldb/Symbol/TaggedASTType.h; sourceTree = ""; }; - 49BF48DC11ADF356008863BD /* ObjCObjectPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjCObjectPrinter.cpp; path = source/Target/ObjCObjectPrinter.cpp; sourceTree = ""; }; - 49BF48E011ADF37D008863BD /* ObjCObjectPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjCObjectPrinter.h; path = include/lldb/Target/ObjCObjectPrinter.h; sourceTree = ""; }; 49CF9829122C70BD007A0B96 /* IRDynamicChecks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRDynamicChecks.cpp; path = source/Expression/IRDynamicChecks.cpp; sourceTree = ""; }; 49CF9833122C718B007A0B96 /* IRDynamicChecks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRDynamicChecks.h; path = include/lldb/Expression/IRDynamicChecks.h; sourceTree = ""; }; 49D4FE821210B5FB00CDB854 /* ClangPersistentVariables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangPersistentVariables.h; path = include/lldb/Expression/ClangPersistentVariables.h; sourceTree = ""; }; @@ -971,6 +970,10 @@ 4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSpec.h; path = include/lldb/Target/ThreadSpec.h; sourceTree = ""; }; 4C09CB73116BD98B00C7A725 /* CommandCompletions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandCompletions.h; path = include/lldb/Interpreter/CommandCompletions.h; sourceTree = ""; }; 4C09CB74116BD98B00C7A725 /* CommandCompletions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandCompletions.cpp; path = source/Commands/CommandCompletions.cpp; sourceTree = ""; }; + 4C0A91D412511CB900CA6636 /* AppleObjCTrampolineHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCTrampolineHandler.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp; sourceTree = ""; }; + 4C0A91D512511CB900CA6636 /* AppleObjCTrampolineHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCTrampolineHandler.h; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h; sourceTree = ""; }; + 4C0A91D612511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleThreadPlanStepThroughObjCTrampoline.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp; sourceTree = ""; }; + 4C0A91D712511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleThreadPlanStepThroughObjCTrampoline.h; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h; sourceTree = ""; }; 4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppleObjCRuntimeV2.cpp; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp; sourceTree = ""; }; 4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppleObjCRuntimeV2.h; path = LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h; sourceTree = ""; }; 4C43DEF9110641F300E55CBF /* ThreadPlanShouldStopHere.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanShouldStopHere.h; path = include/lldb/Target/ThreadPlanShouldStopHere.h; sourceTree = ""; }; @@ -979,8 +982,6 @@ 4C43DF8611069BFD00E55CBF /* ThreadPlanStepOverRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepOverRange.h; path = include/lldb/Target/ThreadPlanStepOverRange.h; sourceTree = ""; }; 4C43DF8911069C3200E55CBF /* ThreadPlanStepInRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepInRange.cpp; path = source/Target/ThreadPlanStepInRange.cpp; sourceTree = ""; }; 4C43DF8A11069C3200E55CBF /* ThreadPlanStepOverRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepOverRange.cpp; path = source/Target/ThreadPlanStepOverRange.cpp; sourceTree = ""; }; - 4C51FF1511A4C485007C962F /* ObjCTrampolineHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCTrampolineHandler.h; sourceTree = ""; }; - 4C51FF1611A4C486007C962F /* ObjCTrampolineHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjCTrampolineHandler.cpp; sourceTree = ""; }; 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectCommands.cpp; path = source/Commands/CommandObjectCommands.cpp; sourceTree = ""; }; 4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectCommands.h; path = source/Commands/CommandObjectCommands.h; sourceTree = ""; }; 4C74CB6212288704006A8171 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = ""; }; @@ -1009,8 +1010,6 @@ 4CEE62FD1145F2130064CF93 /* ProcessGDBRemoteLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProcessGDBRemoteLog.h; path = "source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"; sourceTree = ""; }; 4CEE62FE1145F2130064CF93 /* ThreadGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadGDBRemote.cpp; path = "source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp"; sourceTree = ""; }; 4CEE62FF1145F2130064CF93 /* ThreadGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadGDBRemote.h; path = "source/Plugins/Process/gdb-remote/ThreadGDBRemote.h"; sourceTree = ""; }; - 4CF4473D11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadPlanStepThroughObjCTrampoline.h; sourceTree = ""; }; - 4CF4473E11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadPlanStepThroughObjCTrampoline.cpp; sourceTree = ""; }; 69A01E1B1236C5D400C660B5 /* Condition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Condition.cpp; sourceTree = ""; }; 69A01E1C1236C5D400C660B5 /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = ""; }; 69A01E1E1236C5D400C660B5 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mutex.cpp; sourceTree = ""; }; @@ -1239,14 +1238,10 @@ 260C897910F57C5600BB2B04 /* MacOSX-DYLD */ = { isa = PBXGroup; children = ( - 260C897A10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.cpp */, 260C897B10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.h */, - 260C897C10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.cpp */, + 260C897A10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.cpp */, 260C897D10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.h */, - 4C51FF1511A4C485007C962F /* ObjCTrampolineHandler.h */, - 4C51FF1611A4C486007C962F /* ObjCTrampolineHandler.cpp */, - 4CF4473D11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.h */, - 4CF4473E11A8687100EF971E /* ThreadPlanStepThroughObjCTrampoline.cpp */, + 260C897C10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.cpp */, ); path = "MacOSX-DYLD"; sourceTree = ""; @@ -2013,8 +2008,6 @@ 4CB4430A12491DDA00C13DC2 /* LanguageRuntime.cpp */, 4CB443F612499B6E00C13DC2 /* ObjCLanguageRuntime.h */, 4CB443F212499B5000C13DC2 /* ObjCLanguageRuntime.cpp */, - 49BF48E011ADF37D008863BD /* ObjCObjectPrinter.h */, - 49BF48DC11ADF356008863BD /* ObjCObjectPrinter.cpp */, 495BBACF119A0DE700418BEA /* PathMappingList.h */, 495BBACB119A0DBE00418BEA /* PathMappingList.cpp */, 26BC7DF310F1B81A00F91463 /* Process.h */, @@ -2188,8 +2181,12 @@ 4C139EA2124A8AE5000BFF8D /* AppleRuntimeV2 */ = { isa = PBXGroup; children = ( - 4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */, + 4C0A91D512511CB900CA6636 /* AppleObjCTrampolineHandler.h */, + 4C0A91D412511CB900CA6636 /* AppleObjCTrampolineHandler.cpp */, + 4C0A91D712511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h */, + 4C0A91D612511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */, 4C139EA4124A8B03000BFF8D /* AppleObjCRuntimeV2.h */, + 4C139EA3124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp */, ); name = AppleRuntimeV2; sourceTree = ""; @@ -2378,6 +2375,8 @@ 4CB443F712499B6E00C13DC2 /* ObjCLanguageRuntime.h in Headers */, 96A6D9CA1249D98800250B38 /* ArchVolatileRegs-x86.h in Headers */, 4C139EA6124A8B03000BFF8D /* AppleObjCRuntimeV2.h in Headers */, + 4C0A91D912511CB900CA6636 /* AppleObjCTrampolineHandler.h in Headers */, + 4C0A91DB12511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2432,7 +2431,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, @@ -2765,14 +2763,11 @@ 26D5B15111B07550009A862E /* unw_getcontext.s in Sources */, 26D5B15211B07550009A862E /* LibUnwindRegisterContext.cpp in Sources */, 26D5B15311B07550009A862E /* ABIMacOSX_i386.cpp in Sources */, - 26D5B15411B07550009A862E /* ObjCTrampolineHandler.cpp in Sources */, 26D5B15511B07550009A862E /* Baton.cpp in Sources */, 26D5B15611B07550009A862E /* CommandObjectArgs.cpp in Sources */, - 26D5B15711B07550009A862E /* ThreadPlanStepThroughObjCTrampoline.cpp in Sources */, 26D5B15911B07550009A862E /* UnwindLibUnwind.cpp in Sources */, 26D5B15A11B07550009A862E /* UnwindMacOSXFrameBackchain.cpp in Sources */, 26D5B15B11B07550009A862E /* RegisterContextMacOSXFrameBackchain.cpp in Sources */, - 26D5B15C11B07550009A862E /* ObjCObjectPrinter.cpp in Sources */, 26680324116005D9008E1FE4 /* SBThread.cpp in Sources */, 26680326116005DB008E1FE4 /* SBTarget.cpp in Sources */, 26680327116005DC008E1FE4 /* SBSourceManager.cpp in Sources */, @@ -2850,6 +2845,8 @@ 96A6D9C61249D96F00250B38 /* ArchVolatileRegs.cpp in Sources */, 96A6D9C91249D98800250B38 /* ArchVolatileRegs-x86.cpp in Sources */, 4C139EA5124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp in Sources */, + 4C0A91D812511CB900CA6636 /* AppleObjCTrampolineHandler.cpp in Sources */, + 4C0A91DA12511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/Value.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Core/Value.cpp (original) +++ lldb/trunk/source/Core/Value.cpp Mon Sep 27 20:25:32 2010 @@ -206,18 +206,6 @@ Value::GetContextTypeAsCString(m_context_type)); } -void * -Value::GetOpaqueClangQualType() -{ - if (m_context_type == eContextTypeValue) - return ((Value*)m_context)->GetOpaqueClangQualType (); - - if (m_context_type == eContextTypeOpaqueClangQualType) - return m_context; - - return NULL; -} - Value::ValueType Value::GetValueType() const { @@ -429,10 +417,10 @@ } void * -Value::GetValueOpaqueClangQualType () +Value::GetOpaqueClangQualType () { if (m_context_type == eContextTypeValue) - return ((Value*)m_context)->GetValueOpaqueClangQualType(); + return ((Value*)m_context)->GetOpaqueClangQualType(); switch (m_context_type) { Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Mon Sep 27 20:25:32 2010 @@ -15,6 +15,7 @@ // C++ Includes // Other libraries and framework includes #include "llvm/Support/raw_ostream.h" +#include "clang/AST/Type.h" // Project includes #include "lldb/Core/DataBufferHeap.h" @@ -27,6 +28,7 @@ #include "lldb/Symbol/Type.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" @@ -530,44 +532,25 @@ return m_summary_str.c_str(); } - const char * ValueObject::GetObjectDescription (ExecutionContextScope *exe_scope) { if (!m_object_desc_str.empty()) return m_object_desc_str.c_str(); - if (!ClangASTContext::IsPointerType (GetOpaqueClangQualType())) - return NULL; - if (!GetValueIsValid()) return NULL; Process *process = exe_scope->CalculateProcess(); - - if (!process) + if (process == NULL) return NULL; + + StreamString s; - Scalar scalar; - - if (!ClangASTType::GetValueAsScalar (GetClangAST(), - GetOpaqueClangQualType(), - GetDataExtractor(), - 0, - GetByteSize(), - scalar)) - return NULL; - - ExecutionContext exe_ctx; - exe_scope->Calculate(exe_ctx); + lldb::LanguageType language = GetObjectRuntimeLanguage(); + LanguageRuntime *runtime = process->GetLanguageRuntime(language); - Value val(scalar); - val.SetContext(Value::eContextTypeOpaqueClangQualType, - ClangASTContext::GetVoidPtrType(GetClangAST(), false)); - - StreamString s; - // FIXME: Check the runtime this object belongs to and get the appropriate object printer for the object kind. - if (process->GetObjCObjectPrinter().PrintObject(s, val, exe_ctx)) + if (runtime && runtime->GetObjectDescription(s, *this, exe_scope)) { m_object_desc_str.append (s.GetData()); } @@ -770,6 +753,39 @@ } +lldb::LanguageType +ValueObject::GetObjectRuntimeLanguage () +{ + void *opaque_qual_type = GetOpaqueClangQualType(); + 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; +} + void ValueObject::AddSyntheticChild (const ConstString &key, ValueObjectSP& valobj_sp) { @@ -832,8 +848,6 @@ // Check that the runtime class is correct for determining the most specific class. // If it is a C++ class, see if it is dynamic: - //if (!decl->isDynamicClass()) - // return false; - + return true; } Modified: lldb/trunk/source/Core/ValueObjectChild.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp (original) +++ lldb/trunk/source/Core/ValueObjectChild.cpp Mon Sep 27 20:25:32 2010 @@ -204,4 +204,3 @@ { return m_parent->IsInScope (frame); } - Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Mon Sep 27 20:25:32 2010 @@ -93,8 +93,6 @@ return lldb::eValueTypeInvalid; } - - void ValueObjectVariable::UpdateValue (ExecutionContextScope *exe_scope) { Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Mon Sep 27 20:25:32 2010 @@ -97,7 +97,7 @@ if (format == lldb::eFormatDefault) format = val.GetValueDefaultFormat (); - void *clang_type = val.GetValueOpaqueClangQualType (); + void *clang_type = val.GetOpaqueClangQualType (); output_stream.Printf("%s = ", m_name.c_str()); Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Mon Sep 27 20:25:32 2010 @@ -322,7 +322,7 @@ if (arg_value->GetValueType() == Value::eValueTypeHostAddress && arg_value->GetContextType() == Value::eContextTypeOpaqueClangQualType && - ClangASTContext::IsPointerType(arg_value->GetValueOpaqueClangQualType())) + ClangASTContext::IsPointerType(arg_value->GetOpaqueClangQualType())) continue; const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx, m_clang_ast_context->getASTContext()); Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Mon Sep 27 20:25:32 2010 @@ -15,6 +15,7 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -61,8 +62,7 @@ m_dyld_all_image_infos(), m_break_id(LLDB_INVALID_BREAK_ID), m_dyld_image_infos(), - m_mutex(Mutex::eMutexTypeRecursive), - m_objc_trampoline_handler_ap(NULL) + m_mutex(Mutex::eMutexTypeRecursive) { } @@ -648,14 +648,15 @@ // to save time. // Also, I'm assuming there can be only one libobjc dylib loaded... - if (m_objc_trampoline_handler_ap.get() == NULL) + ObjCLanguageRuntime *objc_runtime = m_process->GetObjCLanguageRuntime(); + if (objc_runtime != NULL && !objc_runtime->HasReadObjCLibrary()) { size_t num_modules = loaded_module_list.GetSize(); for (int i = 0; i < num_modules; i++) { - if (ObjCTrampolineHandler::ModuleIsObjCLibrary (loaded_module_list.GetModuleAtIndex (i))) + if (objc_runtime->IsModuleObjCLibrary (loaded_module_list.GetModuleAtIndex (i))) { - m_objc_trampoline_handler_ap.reset (new ObjCTrampolineHandler(m_process->GetSP(), loaded_module_list.GetModuleAtIndex (i))); + objc_runtime->ReadObjCLibrary (loaded_module_list.GetModuleAtIndex (i)); break; } } @@ -1137,9 +1138,6 @@ log->Printf ("Could not find symbol for step through."); } - if (thread_plan_sp == NULL && m_objc_trampoline_handler_ap.get()) - thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others); - return thread_plan_sp; } Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Mon Sep 27 20:25:32 2010 @@ -25,8 +25,6 @@ #include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" -#include "ObjCTrampolineHandler.h" - class DynamicLoaderMacOSXDYLD : public lldb_private::DynamicLoader { public: @@ -352,7 +350,6 @@ DYLDImageInfo::collection m_dyld_image_infos; // Current shared libraries information mutable lldb_private::Mutex m_mutex; lldb_private::Process::Notifications m_notification_callbacks; - std::auto_ptr m_objc_trampoline_handler_ap; private: DISALLOW_COPY_AND_ASSIGN (DynamicLoaderMacOSXDYLD); Removed: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp?rev=114934&view=auto ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp (removed) @@ -1,327 +0,0 @@ -//===-- ObjCTrampolineHandler.cpp ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "ObjCTrampolineHandler.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Module.h" -#include "lldb/Core/ConstString.h" -#include "lldb/Core/FileSpec.h" -#include "lldb/Target/Thread.h" -#include "lldb/Target/RegisterContext.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/Process.h" -#include "lldb/Core/Value.h" -#include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Expression/ClangFunction.h" -#include "lldb/Core/Log.h" -#include "lldb/Target/ExecutionContext.h" -#include "ThreadPlanStepThroughObjCTrampoline.h" -#include "lldb/Target/ThreadPlanRunToAddress.h" - -using namespace lldb; -using namespace lldb_private; - -const ObjCTrampolineHandler::DispatchFunction -ObjCTrampolineHandler::g_dispatch_functions[] = -{ - // NAME STRET SUPER FIXUP TYPE - {"objc_msgSend", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSend_fixup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSend_fixedup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {"objc_msgSend_stret", true, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSend_stret_fixup", true, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSend_stret_fixedup", true, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {"objc_msgSend_fpret", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSend_fpret_fixup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSend_fpret_fixedup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {"objc_msgSend_fp2ret", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSend_fp2ret_fixup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSend_fp2ret_fixedup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {"objc_msgSendSuper", false, true, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSendSuper_stret", true, true, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSendSuper2", false, true, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSendSuper2_fixup", false, true, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSendSuper2_fixedup", false, true, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {"objc_msgSendSuper2_stret", true, true, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSendSuper2_stret_fixup", true, true, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSendSuper2_stret_fixedup", true, true, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {NULL} -}; - -bool -ObjCTrampolineHandler::ModuleIsObjCLibrary (const ModuleSP &module_sp) -{ - const FileSpec &module_file_spec = module_sp->GetFileSpec(); - static ConstString ObjCName ("libobjc.A.dylib"); - - if (module_file_spec) - { - if (module_file_spec.GetFilename() == ObjCName) - return true; - } - - return false; -} - -ObjCTrampolineHandler::ObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module) : - m_process_sp (process_sp), - m_objc_module_sp (objc_module), - m_impl_fn_addr (LLDB_INVALID_ADDRESS), - m_impl_stret_fn_addr (LLDB_INVALID_ADDRESS) -{ - // Look up the known resolution functions: - - ConstString get_impl_name("class_getMethodImplementation"); - ConstString get_impl_stret_name("class_getMethodImplementation_stret"); - - Target *target = m_process_sp ? &m_process_sp->GetTarget() : NULL; - const Symbol *class_getMethodImplementation = m_objc_module_sp->FindFirstSymbolWithNameAndType (get_impl_name, eSymbolTypeCode); - const Symbol *class_getMethodImplementation_stret = m_objc_module_sp->FindFirstSymbolWithNameAndType (get_impl_stret_name, eSymbolTypeCode); - - if (class_getMethodImplementation) - m_impl_fn_addr = class_getMethodImplementation->GetValue().GetLoadAddress(target); - if (class_getMethodImplementation_stret) - m_impl_stret_fn_addr = class_getMethodImplementation_stret->GetValue().GetLoadAddress(target); - - // FIXME: Do some kind of logging here. - if (m_impl_fn_addr == LLDB_INVALID_ADDRESS || m_impl_stret_fn_addr == LLDB_INVALID_ADDRESS) - return; - - // Look up the addresses for the objc dispatch functions and cache them. For now I'm inspecting the symbol - // names dynamically to figure out how to dispatch to them. If it becomes more complicated than this we can - // turn the g_dispatch_functions char * array into a template table, and populate the DispatchFunction map - // from there. - - for (int i = 0; g_dispatch_functions[i].name != NULL; i++) - { - ConstString name_const_str(g_dispatch_functions[i].name); - const Symbol *msgSend_symbol = m_objc_module_sp->FindFirstSymbolWithNameAndType (name_const_str, eSymbolTypeCode); - if (msgSend_symbol) - { - // FixMe: Make g_dispatch_functions static table of DisptachFunctions, and have the map be address->index. - // Problem is we also need to lookup the dispatch function. For now we could have a side table of stret & non-stret - // dispatch functions. If that's as complex as it gets, we're fine. - - lldb::addr_t sym_addr = msgSend_symbol->GetValue().GetLoadAddress(target); - - m_msgSend_map.insert(std::pair(sym_addr, i)); - } - } -} - -ThreadPlanSP -ObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool stop_others) -{ - ThreadPlanSP ret_plan_sp; - lldb::addr_t curr_pc = thread.GetRegisterContext()->GetPC(); - - MsgsendMap::iterator pos; - pos = m_msgSend_map.find (curr_pc); - if (pos != m_msgSend_map.end()) - { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); - - const DispatchFunction *this_dispatch = &g_dispatch_functions[(*pos).second]; - - lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0); - - Process *process = thread.CalculateProcess(); - const ABI *abi = process->GetABI(); - if (abi == NULL) - return ret_plan_sp; - - Target *target = thread.CalculateTarget(); - - // FIXME: Since neither the value nor the Clang QualType know their ASTContext, - // we have to make sure the type we put in our value list comes from the same ASTContext - // the ABI will use to get the argument values. THis is the bottom-most frame's module. - - ClangASTContext *clang_ast_context = target->GetScratchClangASTContext(); - ValueList argument_values; - Value input_value; - void *clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false); - input_value.SetValueType (Value::eValueTypeScalar); - input_value.SetContext (Value::eContextTypeOpaqueClangQualType, clang_void_ptr_type); - - int obj_index; - int sel_index; - - // If this is a struct return dispatch, then the first argument is the - // return struct pointer, and the object is the second, and the selector is the third. - // Otherwise the object is the first and the selector the second. - if (this_dispatch->stret_return) - { - obj_index = 1; - sel_index = 2; - argument_values.PushValue(input_value); - argument_values.PushValue(input_value); - argument_values.PushValue(input_value); - } - else - { - obj_index = 0; - sel_index = 1; - argument_values.PushValue(input_value); - argument_values.PushValue(input_value); - } - - - bool success = abi->GetArgumentValues (thread, argument_values); - if (!success) - return ret_plan_sp; - - // Okay, the first value here is the object, we actually want the class of that object. - // For now we're just going with the ISA. - // FIXME: This should really be the return value of [object class] to properly handle KVO interposition. - - Value isa_value(*(argument_values.GetValueAtIndex(obj_index))); - - // This is a little cheesy, but since object->isa is the first field, - // making the object value a load address value and resolving it will get - // the pointer sized data pointed to by that value... - ExecutionContext exec_ctx; - thread.Calculate (exec_ctx); - - isa_value.SetValueType(Value::eValueTypeLoadAddress); - isa_value.ResolveValue(&exec_ctx, clang_ast_context->getASTContext()); - - if (this_dispatch->fixedup == DispatchFunction::eFixUpFixed) - { - // For the FixedUp method the Selector is actually a pointer to a - // structure, the second field of which is the selector number. - Value *sel_value = argument_values.GetValueAtIndex(sel_index); - sel_value->GetScalar() += process->GetAddressByteSize(); - sel_value->SetValueType(Value::eValueTypeLoadAddress); - sel_value->ResolveValue(&exec_ctx, clang_ast_context->getASTContext()); - } - else if (this_dispatch->fixedup == DispatchFunction::eFixUpToFix) - { - // FIXME: If the method dispatch is not "fixed up" then the selector is actually a - // pointer to the string name of the selector. We need to look that up... - // For now I'm going to punt on that and just return no plan. - if (log) - log->Printf ("Punting on stepping into un-fixed-up method dispatch."); - return ret_plan_sp; - } - - // FIXME: If this is a dispatch to the super-class, we need to get the super-class from - // the class, and disaptch to that instead. - // But for now I just punt and return no plan. - if (this_dispatch->is_super) - { - if (log) - log->Printf ("Punting on stepping into super method dispatch."); - return ret_plan_sp; - } - - ValueList dispatch_values; - dispatch_values.PushValue (isa_value); - dispatch_values.PushValue(*(argument_values.GetValueAtIndex(sel_index))); - - if (log) - { - log->Printf("Resolving method call for class - 0x%llx and selector - 0x%llx", - dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(), - dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong()); - } - - lldb::addr_t impl_addr = LookupInCache (dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(), - dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong()); - - if (impl_addr == LLDB_INVALID_ADDRESS) - { - - Address resolve_address(NULL, this_dispatch->stret_return ? m_impl_stret_fn_addr : m_impl_fn_addr); - - StreamString errors; - { - // Scope for mutex locker: - Mutex::Locker locker(m_impl_function_mutex); - if (!m_impl_function.get()) - { - m_impl_function.reset(new ClangFunction(process->GetTargetTriple().GetCString(), - clang_ast_context, - clang_void_ptr_type, - resolve_address, - dispatch_values)); - - unsigned num_errors = m_impl_function->CompileFunction(errors); - if (num_errors) - { - if (log) - log->Printf ("Error compiling function: \"%s\".", errors.GetData()); - return ret_plan_sp; - } - - errors.Clear(); - if (!m_impl_function->WriteFunctionWrapper(exec_ctx, errors)) - { - if (log) - log->Printf ("Error Inserting function: \"%s\".", errors.GetData()); - return ret_plan_sp; - } - } - - } - - errors.Clear(); - - // Now write down the argument values for this call. - lldb::addr_t args_addr = LLDB_INVALID_ADDRESS; - if (!m_impl_function->WriteFunctionArguments (exec_ctx, args_addr, resolve_address, dispatch_values, errors)) - return ret_plan_sp; - - ret_plan_sp.reset (new ThreadPlanStepThroughObjCTrampoline (thread, this, args_addr, - argument_values.GetValueAtIndex(0)->GetScalar().ULongLong(), - dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(), - dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong(), - stop_others)); - } - else - { - if (log) - log->Printf ("Found implementation address in cache: 0x%llx", impl_addr); - - ret_plan_sp.reset (new ThreadPlanRunToAddress (thread, impl_addr, stop_others)); - } - } - - return ret_plan_sp; -} - -void -ObjCTrampolineHandler::AddToCache (lldb::addr_t class_addr, lldb::addr_t selector, lldb::addr_t impl_addr) -{ - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); - if (log) - { - log->Printf ("Caching: class 0x%llx selector 0x%llx implementation 0x%llx.", class_addr, selector, impl_addr); - } - m_impl_cache.insert (std::pair (ClassAndSel(class_addr, selector), impl_addr)); -} - -lldb::addr_t -ObjCTrampolineHandler::LookupInCache (lldb::addr_t class_addr, lldb::addr_t selector) -{ - MsgImplMap::iterator pos, end = m_impl_cache.end(); - pos = m_impl_cache.find (ClassAndSel(class_addr, selector)); - if (pos != end) - return (*pos).second; - return LLDB_INVALID_ADDRESS; -} - -ClangFunction * -ObjCTrampolineHandler::GetLookupImplementationWrapperFunction () -{ - return m_impl_function.get(); -} Removed: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h?rev=114934&view=auto ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h (removed) @@ -1,132 +0,0 @@ -//===-- ObjCTrampolineHandler.h ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef lldb_ObjCTrampolineHandler_h_ -#define lldb_ObjCTrampolineHandler_h_ - -// C Includes -// C++ Includes -#include -#include -// Other libraries and framework includes -// Project includes -#include "lldb/Expression/ClangExpression.h" -#include "lldb/Expression/ClangFunction.h" -#include "lldb/Host/Mutex.h" - - -namespace lldb_private -{ -using namespace lldb; - -class ObjCTrampolineHandler { -public: - - ObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module_sp); - - ~ObjCTrampolineHandler() {} - - static bool ModuleIsObjCLibrary (const ModuleSP &module_sp); - - ThreadPlanSP - GetStepThroughDispatchPlan (Thread &thread, bool stop_others); - - void - AddToCache (lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr); - - lldb::addr_t - LookupInCache (lldb::addr_t class_addr, lldb::addr_t sel); - - ClangFunction * - GetLookupImplementationWrapperFunction (); - - - struct DispatchFunction { - public: - typedef enum - { - eFixUpNone, - eFixUpFixed, - eFixUpToFix - } FixUpState; - - const char *name; - bool stret_return; - bool is_super; - FixUpState fixedup; - }; - -private: - static const DispatchFunction g_dispatch_functions[]; - - typedef std::map MsgsendMap; // This table maps an dispatch fn address to the index in g_dispatch_functions - MsgsendMap m_msgSend_map; - ProcessSP m_process_sp; - ModuleSP m_objc_module_sp; - lldb::addr_t get_impl_addr; - std::auto_ptr m_impl_function; - Mutex m_impl_function_mutex; - lldb::addr_t m_impl_fn_addr; - lldb::addr_t m_impl_stret_fn_addr; - - - // We keep a map of ->Implementation so we don't have to call the resolver - // function over and over. - - // FIXME: We need to watch for the loading of Protocols, and flush the cache for any - // class that we see so changed. - - struct ClassAndSel - { - ClassAndSel() - { - sel_addr = LLDB_INVALID_ADDRESS; - class_addr = LLDB_INVALID_ADDRESS; - } - ClassAndSel (lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) : - class_addr (in_class_addr), - sel_addr(in_sel_addr) - { - } - bool operator== (const ClassAndSel &rhs) - { - if (class_addr == rhs.class_addr - && sel_addr == rhs.sel_addr) - return true; - else - return false; - } - - bool operator< (const ClassAndSel &rhs) const - { - if (class_addr < rhs.class_addr) - return true; - else if (class_addr > rhs.class_addr) - return false; - else - { - if (sel_addr < rhs.sel_addr) - return true; - else - return false; - } - } - - lldb::addr_t class_addr; - lldb::addr_t sel_addr; - }; - - typedef std::map MsgImplMap; - MsgImplMap m_impl_cache; - -}; - -} // using namespace lldb_private - -#endif // lldb_ObjCTrampolineHandler_h_ Removed: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp?rev=114934&view=auto ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp (removed) @@ -1,151 +0,0 @@ -//===-- ThreadPlanStepThroughObjCTrampoline.cpp --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "ThreadPlanStepThroughObjCTrampoline.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/Thread.h" -#include "lldb/Expression/ClangExpression.h" -#include "lldb/Expression/ClangFunction.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/ThreadPlanRunToAddress.h" -#include "lldb/Core/Log.h" - -using namespace lldb_private; - -//---------------------------------------------------------------------- -// ThreadPlanStepThroughObjCTrampoline constructor -//---------------------------------------------------------------------- -ThreadPlanStepThroughObjCTrampoline::ThreadPlanStepThroughObjCTrampoline( - Thread &thread, - ObjCTrampolineHandler *trampoline_handler, - lldb::addr_t args_addr, - lldb::addr_t object_ptr, - lldb::addr_t class_ptr, - lldb::addr_t sel_ptr, - bool stop_others) : - ThreadPlan (ThreadPlan::eKindGeneric, "MacOSX Step through ObjC Trampoline", thread, eVoteNoOpinion, eVoteNoOpinion), - m_args_addr (args_addr), - m_stop_others (stop_others), - m_objc_trampoline_handler (trampoline_handler), - m_impl_function (trampoline_handler->GetLookupImplementationWrapperFunction()), - m_object_ptr (object_ptr), - m_class_ptr (class_ptr), - m_sel_ptr (sel_ptr) -{ - -} - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -ThreadPlanStepThroughObjCTrampoline::~ThreadPlanStepThroughObjCTrampoline() -{ -} - -void -ThreadPlanStepThroughObjCTrampoline::DidPush () -{ - StreamString errors; - ExecutionContext exc_context; - m_thread.Calculate(exc_context); - m_func_sp.reset(m_impl_function->GetThreadPlanToCallFunction (exc_context, m_args_addr, errors, m_stop_others)); - m_func_sp->SetPrivate(true); - m_thread.QueueThreadPlan (m_func_sp, false); -} - -void -ThreadPlanStepThroughObjCTrampoline::GetDescription (Stream *s, - lldb::DescriptionLevel level) -{ - if (level == lldb::eDescriptionLevelBrief) - s->Printf("Step through ObjC trampoline"); - else - { - s->Printf ("Stepping to implementation of ObjC method - obj: 0x%llx class: 0x%llx selector: 0x%llx", - m_object_ptr, m_class_ptr, m_sel_ptr); - } -} - -bool -ThreadPlanStepThroughObjCTrampoline::ValidatePlan (Stream *error) -{ - return true; -} - -bool -ThreadPlanStepThroughObjCTrampoline::PlanExplainsStop () -{ - // This plan should actually never stop when it is on the top of the plan - // stack, since it does all it's running in client plans. - return false; -} - -lldb::StateType -ThreadPlanStepThroughObjCTrampoline::RunState () -{ - return eStateRunning; -} - -bool -ThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr) -{ - if (m_func_sp.get() == NULL || m_thread.IsThreadPlanDone(m_func_sp.get())) - { - m_func_sp.reset(); - if (!m_run_to_sp) - { - Value target_addr_value; - ExecutionContext exc_context; - m_thread.Calculate(exc_context); - m_impl_function->FetchFunctionResults (exc_context, m_args_addr, target_addr_value); - m_impl_function->DeallocateFunctionResults(exc_context, m_args_addr); - lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong(); - Address target_address(NULL, target_addr); - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); - if (log) - log->Printf("Running to ObjC method implementation: 0x%llx", target_addr); - - m_objc_trampoline_handler->AddToCache (m_class_ptr, m_sel_ptr, target_addr); - - // Extract the target address from the value: - - m_run_to_sp.reset(new ThreadPlanRunToAddress(m_thread, target_address, m_stop_others)); - m_thread.QueueThreadPlan(m_run_to_sp, false); - m_run_to_sp->SetPrivate(true); - return false; - } - else if (m_thread.IsThreadPlanDone(m_run_to_sp.get())) - { - SetPlanComplete(); - return true; - } - } - return false; -} - -// The base class MischiefManaged does some cleanup - so you have to call it -// in your MischiefManaged derived class. -bool -ThreadPlanStepThroughObjCTrampoline::MischiefManaged () -{ - if (IsPlanComplete()) - return true; - else - return false; -} - -bool -ThreadPlanStepThroughObjCTrampoline::WillStop() -{ - return true; -} Removed: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.h?rev=114934&view=auto ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.h (removed) @@ -1,95 +0,0 @@ -//===-- ThreadPlanStepThroughObjCTrampoline.h --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef lldb_ThreadPlanStepThroughObjCTrampoline_h_ -#define lldb_ThreadPlanStepThroughObjCTrampoline_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/lldb-types.h" -#include "lldb/lldb-enumerations.h" -#include "lldb/Target/ThreadPlan.h" -#include "ObjCTrampolineHandler.h" - -namespace lldb_private -{ - -class ThreadPlanStepThroughObjCTrampoline : public ThreadPlan -{ -public: - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ - ThreadPlanStepThroughObjCTrampoline(Thread &thread, - ObjCTrampolineHandler *trampoline_handler, - lldb::addr_t args_addr, - lldb::addr_t object_ptr, - lldb::addr_t class_ptr, - lldb::addr_t sel_ptr, - bool stop_others); - - virtual ~ThreadPlanStepThroughObjCTrampoline(); - - virtual void - GetDescription (Stream *s, - lldb::DescriptionLevel level); - - virtual bool - ValidatePlan (Stream *error); - - virtual bool - PlanExplainsStop (); - - - virtual lldb::StateType - RunState (); - - virtual bool - ShouldStop (Event *event_ptr); - - // The base class MischiefManaged does some cleanup - so you have to call it - // in your MischiefManaged derived class. - virtual bool - MischiefManaged (); - - virtual void - DidPush(); - - virtual bool - WillStop(); - - - -protected: - //------------------------------------------------------------------ - // Classes that inherit from ThreadPlanStepThroughObjCTrampoline can see and modify these - //------------------------------------------------------------------ - -private: - //------------------------------------------------------------------ - // For ThreadPlanStepThroughObjCTrampoline only - //------------------------------------------------------------------ - ThreadPlanSP m_func_sp; // This is the function call plan. We fill it at start, then set it - // to NULL when this plan is done. That way we know to go to: - lldb::addr_t m_args_addr; // Stores the address for our step through function result structure. - ThreadPlanSP m_run_to_sp; // The plan that runs to the target. - bool m_stop_others; - ObjCTrampolineHandler *m_objc_trampoline_handler; - ClangFunction *m_impl_function; // This is a pointer to a impl function that - // is owned by the client that pushes this plan. - lldb::addr_t m_object_ptr; - lldb::addr_t m_class_ptr; - lldb::addr_t m_sel_ptr; -}; - -} // namespace lldb_private - -#endif // lldb_ThreadPlanStepThroughObjCTrampoline_h_ 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=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Mon Sep 27 20:25:32 2010 @@ -29,6 +29,26 @@ static const char *pluginDesc = "Itanium ABI for the C++ language"; static const char *pluginShort = "language.itanium"; +lldb::ValueObjectSP +ItaniumABILanguageRuntime::GetDynamicValue (ValueObjectSP in_value, ExecutionContextScope *exe_scope) +{ + ValueObjectSP ret_sp; + return ret_sp; +} + +bool +ItaniumABILanguageRuntime::IsVTableName (const char *name) +{ + if (name == NULL) + return false; + + // Can we maybe ask Clang about this? + if (strstr (name, "_vptr$") == name) + return true; + else + return false; +} + //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ @@ -96,16 +116,3 @@ { return NULL; } - -bool -ItaniumABILanguageRuntime::IsVTableName (const char *name) -{ - if (name == NULL) - return false; - - // Can we maybe ask Clang about this? - if (strstr (name, "_vptr$") == name) - return true; - else - return false; -} Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h Mon Sep 27 20:25:32 2010 @@ -30,6 +30,9 @@ virtual bool IsVTableName (const char *name); + virtual lldb::ValueObjectSP + GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope); + //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp Mon Sep 27 20:25:32 2010 @@ -8,13 +8,18 @@ //===----------------------------------------------------------------------===// #include "AppleObjCRuntimeV2.h" +#include "AppleObjCTrampolineHandler.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/Error.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Scalar.h" +#include "lldb/Core/StreamString.h" +#include "lldb/Expression/ClangFunction.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Target.h" @@ -29,6 +34,162 @@ static const char *pluginDesc = "Apple Objective C Language Runtime - Version 2"; static const char *pluginShort = "language.apple.objc.v2"; +bool +AppleObjCRuntimeV2::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope) +{ + ExecutionContext exe_ctx; + exe_scope->Calculate(exe_ctx); + + if (!exe_ctx.process) + return false; + + // We need other parts of the exe_ctx, but the processes have to match. + assert (m_process == exe_ctx.process); + + // ObjC objects can only be pointers: + if (!ClangASTContext::IsPointerType (object.GetOpaqueClangQualType())) + return NULL; + + // Get the function address for the print function. + const Address *function_address = GetPrintForDebuggerAddr(); + if (!function_address) + return false; + + // Make the argument list: we pass one arg, the address of our pointer, to the print function. + Scalar scalar; + + if (!ClangASTType::GetValueAsScalar (object.GetClangAST(), + object.GetOpaqueClangQualType(), + object.GetDataExtractor(), + 0, + object.GetByteSize(), + scalar)) + return NULL; + + Value val(scalar); + val.SetContext(Value::eContextTypeOpaqueClangQualType, + ClangASTContext::GetVoidPtrType(object.GetClangAST(), false)); + + ValueList arg_value_list; + arg_value_list.PushValue(val); + + // This is the return value: + const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString(); + ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); + + void *return_qualtype = ast_context->GetCStringType(true); + Value ret; + ret.SetContext(Value::eContextTypeOpaqueClangQualType, return_qualtype); + + // Now we're ready to call the function: + ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list); + StreamString error_stream; + + lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS; + func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream); + + ClangFunction::ExecutionResults results + = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, true, 1000, true, ret); + if (results != ClangFunction::eExecutionCompleted) + { + str.Printf("Error evaluating Print Object function: %d.\n", results); + return false; + } + + addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); + + // FIXME: poor man's strcpy - we should have a "read memory as string interface... + + Error error; + std::vector desc; + while (1) + { + char byte = '\0'; + if (exe_ctx.process->ReadMemory(result_ptr + desc.size(), &byte, 1, error) != 1) + break; + + desc.push_back(byte); + + if (byte == '\0') + break; + } + + if (!desc.empty()) + { + str.PutCString(&desc.front()); + return true; + } + return false; + +} + +Address * +AppleObjCRuntimeV2::GetPrintForDebuggerAddr() +{ + if (!m_PrintForDebugger_addr.get()) + { + ModuleList &modules = m_process->GetTarget().GetImages(); + + SymbolContextList contexts; + SymbolContext context; + + if((!modules.FindSymbolsWithNameAndType(ConstString ("_NSPrintForDebugger"), eSymbolTypeCode, contexts)) && + (!modules.FindSymbolsWithNameAndType(ConstString ("_CFPrintForDebugger"), eSymbolTypeCode, contexts))) + return NULL; + + contexts.GetContextAtIndex(0, context); + + m_PrintForDebugger_addr.reset(new Address(context.symbol->GetValue())); + } + + return m_PrintForDebugger_addr.get(); +} + +lldb::ValueObjectSP +AppleObjCRuntimeV2::GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope) +{ + lldb::ValueObjectSP ret_sp; + return ret_sp; +} + +bool +AppleObjCRuntimeV2::IsModuleObjCLibrary (const ModuleSP &module_sp) +{ + const FileSpec &module_file_spec = module_sp->GetFileSpec(); + static ConstString ObjCName ("libobjc.A.dylib"); + + if (module_file_spec) + { + if (module_file_spec.GetFilename() == ObjCName) + return true; + } + + return false; +} + +bool +AppleObjCRuntimeV2::ReadObjCLibrary (const ModuleSP &module_sp) +{ + // Maybe check here and if we have a handler already, and the UUID of this module is the same as the one in the + // current module, then we don't have to reread it? + m_objc_trampoline_handler_ap.reset(new AppleObjCTrampolineHandler (m_process->GetSP(), module_sp)); + if (m_objc_trampoline_handler_ap.get() != NULL) + { + m_read_objc_library = true; + return true; + } + else + return false; +} + +ThreadPlanSP +AppleObjCRuntimeV2::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) +{ + ThreadPlanSP thread_plan_sp; + thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others); + return thread_plan_sp; +} + //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h Mon Sep 27 20:25:32 2010 @@ -17,53 +17,88 @@ #include "lldb/lldb-private.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/ObjCLanguageRuntime.h" -#include "lldb/Core/Value.h" +#include "lldb/Core/ValueObject.h" +#include "AppleObjCTrampolineHandler.h" +#include "AppleThreadPlanStepThroughObjCTrampoline.h" namespace lldb_private { - class AppleObjCRuntimeV2 : - public lldb_private::ObjCLanguageRuntime +class AppleObjCRuntimeV2 : + public lldb_private::ObjCLanguageRuntime +{ +public: + ~AppleObjCRuntimeV2() { } + + // These are generic runtime functions: + virtual bool + GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope); + + virtual lldb::ValueObjectSP + GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope); + + // These are the ObjC specific functions. + virtual bool + IsModuleObjCLibrary (const lldb::ModuleSP &module_sp); + + virtual bool + ReadObjCLibrary (const lldb::ModuleSP &module_sp); + + virtual bool + HasReadObjCLibrary () { - public: - ~AppleObjCRuntimeV2() { } - - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static lldb_private::LanguageRuntime * - CreateInstance (Process *process, lldb::LanguageType language); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - - virtual void - GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); - - virtual lldb_private::Error - ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); - - virtual lldb_private::Log * - EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); - protected: - private: - AppleObjCRuntimeV2(Process *process) : lldb_private::ObjCLanguageRuntime(process) { } // Call CreateInstance instead. - }; + return m_read_objc_library; + } + + virtual lldb::ThreadPlanSP + GetStepThroughTrampolinePlan (Thread &thread, bool stop_others); + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static lldb_private::LanguageRuntime * + CreateInstance (Process *process, lldb::LanguageType language); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + + virtual void + GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); + + virtual lldb_private::Error + ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); + + virtual lldb_private::Log * + EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); +protected: + Address * + GetPrintForDebuggerAddr(); + +private: + std::auto_ptr
m_PrintForDebugger_addr; + bool m_read_objc_library; + std::auto_ptr m_objc_trampoline_handler_ap; + + AppleObjCRuntimeV2(Process *process) : + lldb_private::ObjCLanguageRuntime(process), + m_read_objc_library (false), + m_objc_trampoline_handler_ap(NULL) + { } // Call CreateInstance instead. +}; } // namespace lldb_private Copied: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp (from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp?p2=lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp&p1=lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp&r1=114771&r2=114935&rev=114935&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp Mon Sep 27 20:25:32 2010 @@ -1,4 +1,4 @@ -//===-- ObjCTrampolineHandler.cpp ----------------------------*- C++ -*-===// +//===-- AppleObjCTrampolineHandler.cpp ----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,59 +7,61 @@ // //===----------------------------------------------------------------------===// -#include "ObjCTrampolineHandler.h" +#include "AppleObjCTrampolineHandler.h" // C Includes // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Core/Module.h" +#include "AppleThreadPlanStepThroughObjCTrampoline.h" + #include "lldb/Core/ConstString.h" #include "lldb/Core/FileSpec.h" -#include "lldb/Target/Thread.h" -#include "lldb/Target/RegisterContext.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/Process.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/Module.h" #include "lldb/Core/Value.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Expression/ClangFunction.h" -#include "lldb/Core/Log.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Target/ObjCLanguageRuntime.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" #include "lldb/Target/ExecutionContext.h" -#include "ThreadPlanStepThroughObjCTrampoline.h" #include "lldb/Target/ThreadPlanRunToAddress.h" using namespace lldb; using namespace lldb_private; -const ObjCTrampolineHandler::DispatchFunction -ObjCTrampolineHandler::g_dispatch_functions[] = +const AppleObjCTrampolineHandler::DispatchFunction +AppleObjCTrampolineHandler::g_dispatch_functions[] = { // NAME STRET SUPER FIXUP TYPE - {"objc_msgSend", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSend_fixup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSend_fixedup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {"objc_msgSend_stret", true, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSend_stret_fixup", true, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSend_stret_fixedup", true, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {"objc_msgSend_fpret", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSend_fpret_fixup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSend_fpret_fixedup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {"objc_msgSend_fp2ret", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSend_fp2ret_fixup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSend_fp2ret_fixedup", false, false, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {"objc_msgSendSuper", false, true, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSendSuper_stret", true, true, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSendSuper2", false, true, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSendSuper2_fixup", false, true, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSendSuper2_fixedup", false, true, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, - {"objc_msgSendSuper2_stret", true, true, ObjCTrampolineHandler::DispatchFunction::eFixUpNone }, - {"objc_msgSendSuper2_stret_fixup", true, true, ObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, - {"objc_msgSendSuper2_stret_fixedup", true, true, ObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, + {"objc_msgSend", false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone }, + {"objc_msgSend_fixup", false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, + {"objc_msgSend_fixedup", false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, + {"objc_msgSend_stret", true, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone }, + {"objc_msgSend_stret_fixup", true, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, + {"objc_msgSend_stret_fixedup", true, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, + {"objc_msgSend_fpret", false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone }, + {"objc_msgSend_fpret_fixup", false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, + {"objc_msgSend_fpret_fixedup", false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, + {"objc_msgSend_fp2ret", false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone }, + {"objc_msgSend_fp2ret_fixup", false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, + {"objc_msgSend_fp2ret_fixedup", false, false, AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, + {"objc_msgSendSuper", false, true, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone }, + {"objc_msgSendSuper_stret", true, true, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone }, + {"objc_msgSendSuper2", false, true, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone }, + {"objc_msgSendSuper2_fixup", false, true, AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, + {"objc_msgSendSuper2_fixedup", false, true, AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, + {"objc_msgSendSuper2_stret", true, true, AppleObjCTrampolineHandler::DispatchFunction::eFixUpNone }, + {"objc_msgSendSuper2_stret_fixup", true, true, AppleObjCTrampolineHandler::DispatchFunction::eFixUpToFix }, + {"objc_msgSendSuper2_stret_fixedup", true, true, AppleObjCTrampolineHandler::DispatchFunction::eFixUpFixed }, {NULL} }; bool -ObjCTrampolineHandler::ModuleIsObjCLibrary (const ModuleSP &module_sp) +AppleObjCTrampolineHandler::ModuleIsObjCLibrary (const ModuleSP &module_sp) { const FileSpec &module_file_spec = module_sp->GetFileSpec(); static ConstString ObjCName ("libobjc.A.dylib"); @@ -73,7 +75,7 @@ return false; } -ObjCTrampolineHandler::ObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module) : +AppleObjCTrampolineHandler::AppleObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module) : m_process_sp (process_sp), m_objc_module_sp (objc_module), m_impl_fn_addr (LLDB_INVALID_ADDRESS), @@ -120,7 +122,7 @@ } ThreadPlanSP -ObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool stop_others) +AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool stop_others) { ThreadPlanSP ret_plan_sp; lldb::addr_t curr_pc = thread.GetRegisterContext()->GetPC(); @@ -234,8 +236,9 @@ dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(), dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong()); } - - lldb::addr_t impl_addr = LookupInCache (dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(), + ObjCLanguageRuntime *objc_runtime = m_process_sp->GetObjCLanguageRuntime (); + assert(objc_runtime != NULL); + lldb::addr_t impl_addr = objc_runtime->LookupInMethodCache (dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(), dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong()); if (impl_addr == LLDB_INVALID_ADDRESS) @@ -281,7 +284,7 @@ if (!m_impl_function->WriteFunctionArguments (exec_ctx, args_addr, resolve_address, dispatch_values, errors)) return ret_plan_sp; - ret_plan_sp.reset (new ThreadPlanStepThroughObjCTrampoline (thread, this, args_addr, + ret_plan_sp.reset (new AppleThreadPlanStepThroughObjCTrampoline (thread, this, args_addr, argument_values.GetValueAtIndex(0)->GetScalar().ULongLong(), dispatch_values.GetValueAtIndex(0)->GetScalar().ULongLong(), dispatch_values.GetValueAtIndex(1)->GetScalar().ULongLong(), @@ -299,29 +302,8 @@ return ret_plan_sp; } -void -ObjCTrampolineHandler::AddToCache (lldb::addr_t class_addr, lldb::addr_t selector, lldb::addr_t impl_addr) -{ - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); - if (log) - { - log->Printf ("Caching: class 0x%llx selector 0x%llx implementation 0x%llx.", class_addr, selector, impl_addr); - } - m_impl_cache.insert (std::pair (ClassAndSel(class_addr, selector), impl_addr)); -} - -lldb::addr_t -ObjCTrampolineHandler::LookupInCache (lldb::addr_t class_addr, lldb::addr_t selector) -{ - MsgImplMap::iterator pos, end = m_impl_cache.end(); - pos = m_impl_cache.find (ClassAndSel(class_addr, selector)); - if (pos != end) - return (*pos).second; - return LLDB_INVALID_ADDRESS; -} - ClangFunction * -ObjCTrampolineHandler::GetLookupImplementationWrapperFunction () +AppleObjCTrampolineHandler::GetLookupImplementationWrapperFunction () { return m_impl_function.get(); } Copied: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h (from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h?p2=lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h&p1=lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h&r1=114771&r2=114935&rev=114935&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.h Mon Sep 27 20:25:32 2010 @@ -1,4 +1,4 @@ -//===-- ObjCTrampolineHandler.h ----------------------------*- C++ -*-===// +//===-- AppleObjCTrampolineHandler.h ----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_ObjCTrampolineHandler_h_ -#define lldb_ObjCTrampolineHandler_h_ +#ifndef lldb_AppleObjCTrampolineHandler_h_ +#define lldb_AppleObjCTrampolineHandler_h_ // C Includes // C++ Includes @@ -25,24 +25,18 @@ { using namespace lldb; -class ObjCTrampolineHandler { +class AppleObjCTrampolineHandler { public: - ObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module_sp); + AppleObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module_sp); - ~ObjCTrampolineHandler() {} + ~AppleObjCTrampolineHandler() {} static bool ModuleIsObjCLibrary (const ModuleSP &module_sp); ThreadPlanSP GetStepThroughDispatchPlan (Thread &thread, bool stop_others); - void - AddToCache (lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr); - - lldb::addr_t - LookupInCache (lldb::addr_t class_addr, lldb::addr_t sel); - ClangFunction * GetLookupImplementationWrapperFunction (); @@ -76,57 +70,8 @@ lldb::addr_t m_impl_stret_fn_addr; - // We keep a map of ->Implementation so we don't have to call the resolver - // function over and over. - - // FIXME: We need to watch for the loading of Protocols, and flush the cache for any - // class that we see so changed. - - struct ClassAndSel - { - ClassAndSel() - { - sel_addr = LLDB_INVALID_ADDRESS; - class_addr = LLDB_INVALID_ADDRESS; - } - ClassAndSel (lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) : - class_addr (in_class_addr), - sel_addr(in_sel_addr) - { - } - bool operator== (const ClassAndSel &rhs) - { - if (class_addr == rhs.class_addr - && sel_addr == rhs.sel_addr) - return true; - else - return false; - } - - bool operator< (const ClassAndSel &rhs) const - { - if (class_addr < rhs.class_addr) - return true; - else if (class_addr > rhs.class_addr) - return false; - else - { - if (sel_addr < rhs.sel_addr) - return true; - else - return false; - } - } - - lldb::addr_t class_addr; - lldb::addr_t sel_addr; - }; - - typedef std::map MsgImplMap; - MsgImplMap m_impl_cache; - }; } // using namespace lldb_private -#endif // lldb_ObjCTrampolineHandler_h_ +#endif // lldb_AppleObjCTrampolineHandler_h_ Copied: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp (from r114771, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp?p2=lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp&p1=lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp&r1=114771&r2=114935&rev=114935&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp Mon Sep 27 20:25:32 2010 @@ -1,4 +1,4 @@ -//===-- ThreadPlanStepThroughObjCTrampoline.cpp --------------------------*- C++ -*-===// +//===-- AppleThreadPlanStepThroughObjCTrampoline.cpp --------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,12 +11,14 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "ThreadPlanStepThroughObjCTrampoline.h" +#include "AppleThreadPlanStepThroughObjCTrampoline.h" +#include "AppleObjCTrampolineHandler.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangFunction.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/ThreadPlanRunToAddress.h" #include "lldb/Core/Log.h" @@ -25,22 +27,23 @@ //---------------------------------------------------------------------- // ThreadPlanStepThroughObjCTrampoline constructor //---------------------------------------------------------------------- -ThreadPlanStepThroughObjCTrampoline::ThreadPlanStepThroughObjCTrampoline( +AppleThreadPlanStepThroughObjCTrampoline::AppleThreadPlanStepThroughObjCTrampoline( Thread &thread, - ObjCTrampolineHandler *trampoline_handler, + AppleObjCTrampolineHandler *trampoline_handler, lldb::addr_t args_addr, lldb::addr_t object_ptr, lldb::addr_t class_ptr, lldb::addr_t sel_ptr, bool stop_others) : - ThreadPlan (ThreadPlan::eKindGeneric, "MacOSX Step through ObjC Trampoline", thread, eVoteNoOpinion, eVoteNoOpinion), - m_args_addr (args_addr), + ThreadPlan (ThreadPlan::eKindGeneric, "MacOSX Step through ObjC Trampoline", thread, + lldb::eVoteNoOpinion, lldb::eVoteNoOpinion), m_stop_others (stop_others), - m_objc_trampoline_handler (trampoline_handler), - m_impl_function (trampoline_handler->GetLookupImplementationWrapperFunction()), m_object_ptr (object_ptr), m_class_ptr (class_ptr), - m_sel_ptr (sel_ptr) + m_sel_ptr (sel_ptr), + m_args_addr (args_addr), + m_objc_trampoline_handler (trampoline_handler), + m_impl_function (trampoline_handler->GetLookupImplementationWrapperFunction()) { } @@ -48,12 +51,12 @@ //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -ThreadPlanStepThroughObjCTrampoline::~ThreadPlanStepThroughObjCTrampoline() +AppleThreadPlanStepThroughObjCTrampoline::~AppleThreadPlanStepThroughObjCTrampoline() { } void -ThreadPlanStepThroughObjCTrampoline::DidPush () +AppleThreadPlanStepThroughObjCTrampoline::DidPush () { StreamString errors; ExecutionContext exc_context; @@ -64,7 +67,7 @@ } void -ThreadPlanStepThroughObjCTrampoline::GetDescription (Stream *s, +AppleThreadPlanStepThroughObjCTrampoline::GetDescription (Stream *s, lldb::DescriptionLevel level) { if (level == lldb::eDescriptionLevelBrief) @@ -77,13 +80,13 @@ } bool -ThreadPlanStepThroughObjCTrampoline::ValidatePlan (Stream *error) +AppleThreadPlanStepThroughObjCTrampoline::ValidatePlan (Stream *error) { return true; } bool -ThreadPlanStepThroughObjCTrampoline::PlanExplainsStop () +AppleThreadPlanStepThroughObjCTrampoline::PlanExplainsStop () { // This plan should actually never stop when it is on the top of the plan // stack, since it does all it's running in client plans. @@ -91,13 +94,13 @@ } lldb::StateType -ThreadPlanStepThroughObjCTrampoline::RunState () +AppleThreadPlanStepThroughObjCTrampoline::RunState () { return eStateRunning; } bool -ThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr) +AppleThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr) { if (m_func_sp.get() == NULL || m_thread.IsThreadPlanDone(m_func_sp.get())) { @@ -115,7 +118,9 @@ if (log) log->Printf("Running to ObjC method implementation: 0x%llx", target_addr); - m_objc_trampoline_handler->AddToCache (m_class_ptr, m_sel_ptr, target_addr); + ObjCLanguageRuntime *objc_runtime = GetThread().GetProcess().GetObjCLanguageRuntime(); + assert (objc_runtime != NULL); + objc_runtime->AddToMethodCache (m_class_ptr, m_sel_ptr, target_addr); // Extract the target address from the value: @@ -136,7 +141,7 @@ // The base class MischiefManaged does some cleanup - so you have to call it // in your MischiefManaged derived class. bool -ThreadPlanStepThroughObjCTrampoline::MischiefManaged () +AppleThreadPlanStepThroughObjCTrampoline::MischiefManaged () { if (IsPlanComplete()) return true; @@ -145,7 +150,7 @@ } bool -ThreadPlanStepThroughObjCTrampoline::WillStop() +AppleThreadPlanStepThroughObjCTrampoline::WillStop() { return true; } Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h?rev=114935&view=auto ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h (added) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.h Mon Sep 27 20:25:32 2010 @@ -0,0 +1,96 @@ +//===-- AppleThreadPlanStepThroughObjCTrampoline.h --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef lldb_AppleThreadPlanStepThroughObjCTrampoline_h_ +#define lldb_AppleThreadPlanStepThroughObjCTrampoline_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-types.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/Target/ThreadPlan.h" +#include "AppleObjCTrampolineHandler.h" + +namespace lldb_private +{ + +class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan +{ +public: + //------------------------------------------------------------------ + // Constructors and Destructors + //------------------------------------------------------------------ + AppleThreadPlanStepThroughObjCTrampoline(Thread &thread, + AppleObjCTrampolineHandler *trampoline_handler, + lldb::addr_t args_addr, + lldb::addr_t object_ptr, + lldb::addr_t class_ptr, + lldb::addr_t sel_ptr, + bool stop_others); + + virtual ~AppleThreadPlanStepThroughObjCTrampoline(); + + virtual void + GetDescription (Stream *s, + lldb::DescriptionLevel level); + + virtual bool + ValidatePlan (Stream *error); + + virtual bool + PlanExplainsStop (); + + + virtual lldb::StateType + RunState (); + + virtual bool + ShouldStop (Event *event_ptr); + + // The base class MischiefManaged does some cleanup - so you have to call it + // in your MischiefManaged derived class. + virtual bool + MischiefManaged (); + + virtual void + DidPush(); + + virtual bool + WillStop(); + + + +protected: + //------------------------------------------------------------------ + // Classes that inherit from AppleThreadPlanStepThroughObjCTrampoline can see and modify these + //------------------------------------------------------------------ + +private: + //------------------------------------------------------------------ + // For AppleThreadPlanStepThroughObjCTrampoline only + //------------------------------------------------------------------ + bool m_stop_others; + lldb::addr_t m_object_ptr; + lldb::addr_t m_class_ptr; + lldb::addr_t m_sel_ptr; + + ThreadPlanSP m_func_sp; // This is the function call plan. We fill it at start, then set it + // to NULL when this plan is done. That way we know to go to: + lldb::addr_t m_args_addr; // Stores the address for our step through function result structure. + ThreadPlanSP m_run_to_sp; // The plan that runs to the target. + AppleObjCTrampolineHandler *m_objc_trampoline_handler; + ClangFunction *m_impl_function; // This is a pointer to a impl function that + // is owned by the client that pushes this plan. +}; + +} // namespace lldb_private + +#endif // lldb_AppleThreadPlanStepThroughObjCTrampoline_h_ Modified: lldb/trunk/source/Target/CPPLanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/CPPLanguageRuntime.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Target/CPPLanguageRuntime.cpp (original) +++ lldb/trunk/source/Target/CPPLanguageRuntime.cpp Mon Sep 27 20:25:32 2010 @@ -9,6 +9,7 @@ #include "lldb/Target/CPPLanguageRuntime.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Target/ExecutionContext.h" using namespace lldb; using namespace lldb_private; @@ -24,4 +25,11 @@ LanguageRuntime (process) { -} \ No newline at end of file +} + +bool +CPPLanguageRuntime::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope) +{ + // C++ has no generic way to do this. + return false; +} Modified: lldb/trunk/source/Target/LanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Target/LanguageRuntime.cpp (original) +++ lldb/trunk/source/Target/LanguageRuntime.cpp Mon Sep 27 20:25:32 2010 @@ -35,7 +35,8 @@ //---------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------- -LanguageRuntime::LanguageRuntime(Process *process) +LanguageRuntime::LanguageRuntime(Process *process) : + m_process (process) { } Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original) +++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Mon Sep 27 20:25:32 2010 @@ -7,8 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ObjCLanguageRuntime.h" +#include "lldb/Core/Log.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Target/ObjCLanguageRuntime.h" using namespace lldb; using namespace lldb_private; @@ -24,4 +25,26 @@ LanguageRuntime (process) { -} \ No newline at end of file +} + +void +ObjCLanguageRuntime::AddToMethodCache (lldb::addr_t class_addr, lldb::addr_t selector, lldb::addr_t impl_addr) +{ + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); + if (log) + { + log->Printf ("Caching: class 0x%llx selector 0x%llx implementation 0x%llx.", class_addr, selector, impl_addr); + } + m_impl_cache.insert (std::pair (ClassAndSel(class_addr, selector), impl_addr)); +} + +lldb::addr_t +ObjCLanguageRuntime::LookupInMethodCache (lldb::addr_t class_addr, lldb::addr_t selector) +{ + MsgImplMap::iterator pos, end = m_impl_cache.end(); + pos = m_impl_cache.find (ClassAndSel(class_addr, selector)); + if (pos != end) + return (*pos).second; + return LLDB_INVALID_ADDRESS; +} + Removed: lldb/trunk/source/Target/ObjCObjectPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCObjectPrinter.cpp?rev=114934&view=auto ============================================================================== --- lldb/trunk/source/Target/ObjCObjectPrinter.cpp (original) +++ lldb/trunk/source/Target/ObjCObjectPrinter.cpp (removed) @@ -1,122 +0,0 @@ -//===-- ObjCObjectPrinter.cpp -------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Core/StreamString.h" -#include "lldb/Expression/ClangFunction.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/Target.h" - -#include "lldb/Target/ObjCObjectPrinter.h" - -using namespace lldb; -using namespace lldb_private; - -//---------------------------------------------------------------------- -// ObjCObjectPrinter constructor -//---------------------------------------------------------------------- -ObjCObjectPrinter::ObjCObjectPrinter (Process &process) : - m_process(process) -{ -} - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -ObjCObjectPrinter::~ObjCObjectPrinter () -{ -} - -bool -ObjCObjectPrinter::PrintObject (Stream &str, Value &object_ptr, ExecutionContext &exe_ctx) -{ - if (!exe_ctx.process) - return false; - - const Address *function_address = GetPrintForDebuggerAddr(); - - if (!function_address) - return false; - - const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString(); - ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); - - void *return_qualtype = ast_context->GetCStringType(true); - Value ret; - ret.SetContext(Value::eContextTypeOpaqueClangQualType, return_qualtype); - - ValueList arg_value_list; - arg_value_list.PushValue(object_ptr); - - ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list); - StreamString error_stream; - - lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS; - func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream); - // FIXME: Check result of ExecuteFunction. - ClangFunction::ExecutionResults results - = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, true, 1000, true, ret); - if (results != ClangFunction::eExecutionCompleted) - { - str.Printf("Error evaluating Print Object function: %d.\n", results); - return false; - } - - addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - - // poor man's strcpy - - Error error; - std::vector desc; - while (1) - { - char byte = '\0'; - if (exe_ctx.process->ReadMemory(result_ptr + desc.size(), &byte, 1, error) != 1) - break; - - desc.push_back(byte); - - if (byte == '\0') - break; - } - - if (!desc.empty()) - { - str.PutCString(&desc.front()); - return true; - } - return false; -} - -Address * -ObjCObjectPrinter::GetPrintForDebuggerAddr() -{ - if (!m_PrintForDebugger_addr.get()) - { - ModuleList &modules = m_process.GetTarget().GetImages(); - - SymbolContextList contexts; - SymbolContext context; - - if((!modules.FindSymbolsWithNameAndType(ConstString ("_NSPrintForDebugger"), eSymbolTypeCode, contexts)) && - (!modules.FindSymbolsWithNameAndType(ConstString ("_CFPrintForDebugger"), eSymbolTypeCode, contexts))) - return NULL; - - contexts.GetContextAtIndex(0, context); - - m_PrintForDebugger_addr.reset(new Address(context.symbol->GetValue())); - } - - return m_PrintForDebugger_addr.get(); -} - Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Sep 27 20:25:32 2010 @@ -84,7 +84,6 @@ m_notifications (), m_listener(listener), m_unix_signals (), - m_objc_object_printer(*this), m_persistent_vars() { UpdateInstanceName(); @@ -1839,12 +1838,6 @@ return m_persistent_vars; } -ObjCObjectPrinter & -Process::GetObjCObjectPrinter() -{ - return m_objc_object_printer; -} - uint32_t Process::ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids) { Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Mon Sep 27 20:25:32 2010 @@ -16,6 +16,7 @@ #include "lldb/Host/Host.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" @@ -662,7 +663,16 @@ ThreadPlan * Thread::QueueThreadPlanForStepThrough (bool abort_other_plans, bool stop_other_threads) { + // Try the dynamic loader first: ThreadPlanSP thread_plan_sp(GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (*this, stop_other_threads)); + // If that didn't come up with anything, try the ObjC runtime plugin: + if (thread_plan_sp.get() == NULL) + { + ObjCLanguageRuntime *objc_runtime = GetProcess().GetObjCLanguageRuntime(); + if (objc_runtime) + thread_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (*this, stop_other_threads); + } + if (thread_plan_sp.get() == NULL) { thread_plan_sp.reset(new ThreadPlanStepThrough (*this, stop_other_threads)); Modified: lldb/trunk/source/Target/ThreadPlanStepThrough.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepThrough.cpp?rev=114935&r1=114934&r2=114935&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepThrough.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepThrough.cpp Mon Sep 27 20:25:32 2010 @@ -17,6 +17,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Target/DynamicLoader.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -93,6 +94,14 @@ if (current_plan) { ThreadPlanSP sub_plan_sp(m_thread.GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (m_thread, m_stop_others)); + // If that didn't come up with anything, try the ObjC runtime plugin: + if (sub_plan_sp == NULL) + { + ObjCLanguageRuntime *objc_runtime = m_thread.GetProcess().GetObjCLanguageRuntime(); + if (objc_runtime) + sub_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (m_thread, m_stop_others); + } + if (sub_plan_sp != NULL) PushPlan (sub_plan_sp); } From jingham at apple.com Tue Sep 28 11:06:32 2010 From: jingham at apple.com (Jim Ingham) Date: Tue, 28 Sep 2010 16:06:32 -0000 Subject: [Lldb-commits] [lldb] r114956 - /lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp Message-ID: <20100928160632.0DF972A6C12C@llvm.org> Author: jingham Date: Tue Sep 28 11:06:31 2010 New Revision: 114956 URL: http://llvm.org/viewvc/llvm-project?rev=114956&view=rev Log: Make sure we've read in the ObjC runtime library data before trying to use it... Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp?rev=114956&r1=114955&r2=114956&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp Tue Sep 28 11:06:31 2010 @@ -37,6 +37,10 @@ bool AppleObjCRuntimeV2::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope) { + + if (!m_read_objc_library) + return false; + ExecutionContext exe_ctx; exe_scope->Calculate(exe_ctx); @@ -186,7 +190,8 @@ AppleObjCRuntimeV2::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) { ThreadPlanSP thread_plan_sp; - thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others); + if (m_objc_trampoline_handler_ap.get()) + thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others); return thread_plan_sp; } From johnny.chen at apple.com Tue Sep 28 11:10:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 28 Sep 2010 16:10:54 -0000 Subject: [Lldb-commits] [lldb] r114957 - in /lldb/trunk/source: Core/ValueObject.cpp Symbol/ClangASTContext.cpp Message-ID: <20100928161054.8A01A2A6C12C@llvm.org> Author: johnny Date: Tue Sep 28 11:10:54 2010 New Revision: 114957 URL: http://llvm.org/viewvc/llvm-project?rev=114957&view=rev Log: Fix from Jean-Daniel. Thanks. Error in object runtime language detection code (spurious '; ') Also replace false by NULL in a place where the compiler expects a pointer instead of a bool. Modified: lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=114957&r1=114956&r2=114957&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Tue Sep 28 11:10:54 2010 @@ -779,7 +779,7 @@ { if (ClangASTContext::IsObjCClassType (opaque_qual_type)) return lldb::eLanguageTypeObjC; - if (ClangASTContext::IsCXXClassType (opaque_qual_type)); + if (ClangASTContext::IsCXXClassType (opaque_qual_type)) return lldb::eLanguageTypeC_plus_plus; } Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114957&r1=114956&r2=114957&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Sep 28 11:10:54 2010 @@ -817,7 +817,7 @@ ) { if (!record_opaque_type || !method_opaque_type || !name) - return false; + return NULL; assert(ast_context); From johnny.chen at apple.com Tue Sep 28 11:34:57 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 28 Sep 2010 16:34:57 -0000 Subject: [Lldb-commits] [lldb] r114962 - in /lldb/trunk/tools/debugserver/source: MacOSX/MachProcess.cpp MacOSX/i386/DNBArchImplI386.h MacOSX/x86_64/DNBArchImplX86_64.h PseudoTerminal.h RNBRemote.h Message-ID: <20100928163457.228A82A6C12C@llvm.org> Author: johnny Date: Tue Sep 28 11:34:56 2010 New Revision: 114962 URL: http://llvm.org/viewvc/llvm-project?rev=114962&view=rev Log: Another patch from Jean-Daniel. Thanks. Error in dbg server -> MachProcess::SetProcessID() and misc changes to make clang++ happy. Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h lldb/trunk/tools/debugserver/source/PseudoTerminal.h lldb/trunk/tools/debugserver/source/RNBRemote.h Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=114962&r1=114961&r2=114962&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Tue Sep 28 11:34:56 2010 @@ -130,7 +130,7 @@ Clear(); // Set the current PID appropriately if (pid == 0) - m_pid == ::getpid (); + m_pid = ::getpid (); else m_pid = pid; return m_pid; // Return actualy PID in case a zero pid was passed in Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=114962&r1=114961&r2=114962&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Tue Sep 28 11:34:56 2010 @@ -38,8 +38,8 @@ static const DNBRegisterSetInfo * GetRegisterSetInfo(nub_size_t *num_reg_sets); - virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *reg); - virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *reg); + virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *value); + virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *value); virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len); virtual nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len); virtual kern_return_t GetRegisterState (int set, bool force); Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h?rev=114962&r1=114961&r2=114962&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Tue Sep 28 11:34:56 2010 @@ -38,8 +38,8 @@ static const DNBRegisterSetInfo * GetRegisterSetInfo(nub_size_t *num_reg_sets); - virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *reg); - virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *reg); + virtual bool GetRegisterValue(int set, int reg, DNBRegisterValue *value); + virtual bool SetRegisterValue(int set, int reg, const DNBRegisterValue *value); virtual nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len); virtual nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len); Modified: lldb/trunk/tools/debugserver/source/PseudoTerminal.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/PseudoTerminal.h?rev=114962&r1=114961&r2=114962&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/PseudoTerminal.h (original) +++ lldb/trunk/tools/debugserver/source/PseudoTerminal.h Tue Sep 28 11:34:56 2010 @@ -26,7 +26,7 @@ invalid_pid = -1 }; - typedef enum Error + enum Error { success = 0, err_posix_openpt_failed = -2, Modified: lldb/trunk/tools/debugserver/source/RNBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.h?rev=114962&r1=114961&r2=114962&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.h (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.h Tue Sep 28 11:34:56 2010 @@ -239,7 +239,7 @@ // gdb can send multiple Z/z packets for the same address and // these calls must be ref counted. - typedef struct Breakpoint + struct Breakpoint { Breakpoint(nub_break_t breakID) : m_breakID(breakID), From johnny.chen at apple.com Tue Sep 28 13:13:05 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 28 Sep 2010 18:13:05 -0000 Subject: [Lldb-commits] [lldb] r114970 - /lldb/trunk/test/array_types/TestArrayTypes.py Message-ID: <20100928181305.2811C2A6C12C@llvm.org> Author: johnny Date: Tue Sep 28 13:13:04 2010 New Revision: 114970 URL: http://llvm.org/viewvc/llvm-project?rev=114970&view=rev Log: Sanity check the print representations of SBThread, SBFrame, and SBValue. Modified: lldb/trunk/test/array_types/TestArrayTypes.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=114970&r1=114969&r2=114970&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Tue Sep 28 13:13:04 2010 @@ -111,8 +111,13 @@ self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), STOPPED_DUE_TO_BREAKPOINT) - #thr = repr(thread) - #print "thr:", thr + # Sanity check the print representation of thread. + thr = repr(thread) + self.expect(thr, "Thread looks good with stop reason = breakpoint", exe=False, + substrs = ["thread #%d: tid = 0x%4.4x" % (thread.GetIndexID(), thread.GetThreadID()), + "stop reason = breakpoint", + "queue = %s" % thread.GetQueueName() if thread.GetQueueName() else "", + "%d frames" % thread.GetNumFrames()]) # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) @@ -125,13 +130,21 @@ "locations = 1", "resolved = 1"]) - # Lookup the "strings" string array variable. + # Sanity check the print representation of frame. frame = thread.GetFrameAtIndex(0) - #frm = repr(frame) - #print "frm:", frm + frm = repr(frame) + self.expect(frm, "Thread looks good with correct frame function", exe=False, + substrs = ["frame #%d" % frame.GetFrameID(), + "a.out`%s" % frame.GetFunction().GetName()]) + + # Lookup the "strings" string array variable and sanity check its print + # representation. variable = frame.LookupVar("strings") - #var = repr(variable) - #print "var:", var + var = repr(variable) + self.expect(var, "Variable for 'strings' looks good with correct type and size", exe=False, + substrs = ["name: '%s'" % variable.GetName(), + "type: %s" % variable.GetTypeName(), + "size: %d" % variable.GetByteSize()]) self.DebugSBValue(frame, variable) self.assertTrue(variable.GetNumChildren() == 4, "Variable 'strings' should have 4 children") From johnny.chen at apple.com Tue Sep 28 16:03:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 28 Sep 2010 21:03:58 -0000 Subject: [Lldb-commits] [lldb] r114987 - in /lldb/trunk/test/types: AbstractBase.py TestFloatTypesExpr.py TestIntegerTypesExpr.py Message-ID: <20100928210358.9ECD22A6C12C@llvm.org> Author: johnny Date: Tue Sep 28 16:03:58 2010 New Revision: 114987 URL: http://llvm.org/viewvc/llvm-project?rev=114987&view=rev Log: Added TestIntegerTypesExpr.py and TestFloatTypesExpr.py which exercise 'expr' command on the various basic types, similar to TestIntegerTypes.py and TestFloatTypes.py, which exercise 'frame variable' on the various basic types. Right now, they don't employ the self.expect() facility to compare against the golden output. They just invoke the self.runCmd() method to run the 'expr' command. Decorated the two classes with @unittest2.skip decorators for the time being. Added: lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=114987&r1=114986&r2=114987&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Tue Sep 28 16:03:58 2010 @@ -85,3 +85,55 @@ nv = (" %s = '%s'" if quotedDisplay else " %s = %s") % (var, val) self.expect(output, Msg(var, val), exe=False, substrs = [nv]) + + def generic_type_expr_tester(self, atoms, quotedDisplay=False): + """Test that variable expressions with basic types are evaluated correctly.""" + + # First, capture the golden output emitted by the oracle, i.e., the + # series of printf statements. + go = system("./a.out") + # This golden list contains a list of (variable, value) pairs extracted + # from the golden output. + gl = [] + + # Scan the golden output line by line, looking for the pattern: + # + # variable = 'value' + # + for line in go.split(os.linesep): + match = self.pattern.search(line) + if match: + var, val = match.group(1), match.group(2) + gl.append((var, val)) + #print "golden list:", gl + + # Bring the program to the point where we can issue a series of + # 'frame variable' command. + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("breakpoint set --name Puts") + self.runCmd("run", RUN_SUCCEEDED) + self.runCmd("thread step-out", STEP_OUT_SUCCEEDED) + + #self.runCmd("frame variable") + + # Now iterate through the golden list, comparing against the output from + # 'frame variable var'. + for var, val in gl: + self.runCmd("expr %s" % var) + output = self.res.GetOutput() + + # The input type is in a canonical form as a set named atoms. + # The display type string must conatin each and every element. + #dt = re.match("^\((.*)\)", output).group(1) + + # Expect the display type string to contain each and every atoms. + #self.expect(dt, + # "Display type: '%s' must contain the type atoms: '%s'" % + # (dt, atoms), + # exe=False, + # substrs = list(atoms)) + + # The (var, val) pair must match, too. + #nv = (" %s = '%s'" if quotedDisplay else " %s = %s") % (var, val) + #self.expect(output, Msg(var, val), exe=False, + # substrs = [nv]) Added: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=114987&view=auto ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (added) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Tue Sep 28 16:03:58 2010 @@ -0,0 +1,55 @@ +""" +Test that variable expressions of floating point types are evaluated correctly. +""" + +import AbstractBase +import unittest2 +import lldb + + at unittest2.skip("rdar://problem/8488437 test/types/TestIntegerTypesExpr.py asserts") +class FloatTypesTestCase(AbstractBase.GenericTester): + + mydir = "types" + + def test_float_types_with_dsym(self): + """Test that float-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'float.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.float_type_expr() + + def test_float_type_with_dwarf(self): + """Test that float-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'float.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.float_type_expr() + + def test_double_type_with_dsym(self): + """Test that double-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'double.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.double_type_expr() + + def test_double_type_with_dwarf(self): + """Test that double-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'double.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.double_type_expr() + + def float_type_expr(self): + """Test that float-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['float'])) + + def double_type_expr(self): + """Test that double-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['double'])) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=114987&view=auto ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (added) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Tue Sep 28 16:03:58 2010 @@ -0,0 +1,206 @@ +""" +Test that variable expressions of integer basic types are evaluated correctly. +""" + +import AbstractBase +import unittest2 +import lldb + + at unittest2.skip("rdar://problem/8488437 test/types/TestIntegerTypesExpr.py asserts") +class IntegerTypesTestCase(AbstractBase.GenericTester): + + mydir = "types" + + def test_char_type_with_dsym(self): + """Test that char-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'char.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.char_type_expr() + + def test_char_type_with_dwarf(self): + """Test that char-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'char.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.char_type_expr() + + def test_unsigned_char_type_with_dsym(self): + """Test that 'unsigned_char'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'unsigned_char.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_char_type_expr() + + def test_unsigned_char_type_with_dwarf(self): + """Test that 'unsigned char'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'unsigned_char.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_char_type_expr() + + def test_short_type_with_dsym(self): + """Test that short-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'short.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.short_type_expr() + + def test_short_type_with_dwarf(self): + """Test that short-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'short.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.short_type_expr() + + def test_unsigned_short_type_with_dsym(self): + """Test that 'unsigned_short'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'unsigned_short.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_short_type_expr() + + def test_unsigned_short_type_with_dwarf(self): + """Test that 'unsigned short'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'unsigned_short.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_short_type_expr() + + def test_int_type_with_dsym(self): + """Test that int-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'int.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.int_type_expr() + + def test_int_type_with_dwarf(self): + """Test that int-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'int.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.int_type_expr() + + def test_unsigned_int_type_with_dsym(self): + """Test that 'unsigned_int'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'unsigned_int.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_int_type_expr() + + def test_unsigned_int_type_with_dwarf(self): + """Test that 'unsigned int'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'unsigned_int.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_int_type_expr() + + def test_long_type_with_dsym(self): + """Test that long-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_type_expr() + + def test_long_type_with_dwarf(self): + """Test that long-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_type_expr() + + def test_unsigned_long_type_with_dsym(self): + """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'unsigned_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_type_expr() + + def test_unsigned_long_type_with_dwarf(self): + """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'unsigned_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_type_expr() + + # rdar://problem/8482903 + # test suite failure for types dir -- "long long" and "unsigned long long" + + @unittest2.expectedFailure + def test_long_long_type_with_dsym(self): + """Test that 'long long'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'long_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_long_type_expr() + + @unittest2.expectedFailure + def test_long_long_type_with_dwarf(self): + """Test that 'long long'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'long_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.long_long_type_expr() + + @unittest2.expectedFailure + def test_unsigned_long_long_type_with_dsym(self): + """Test that 'unsigned long long'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_long_type_expr() + + @unittest2.expectedFailure + def test_unsigned_long_long_type_with_dwarf(self): + """Test that 'unsigned long long'-type variable expressions are evaluated correctly.""" + d = {'CXX_SOURCES': 'unsigned_long_long.cpp'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.unsigned_long_long_type_expr() + + def char_type_expr(self): + """Test that char-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['char']), quotedDisplay=True) + + def unsigned_char_type_expr(self): + """Test that 'unsigned char'-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['unsigned', 'char']), quotedDisplay=True) + + def short_type_expr(self): + """Test that short-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['short'])) + + def unsigned_short_type_expr(self): + """Test that 'unsigned short'-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['unsigned', 'short'])) + + def int_type_expr(self): + """Test that int-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['int'])) + + def unsigned_int_type_expr(self): + """Test that 'unsigned int'-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['unsigned', 'int'])) + + def long_type_expr(self): + """Test that long-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['long'])) + + def unsigned_long_type_expr(self): + """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['unsigned', 'long'])) + + def long_long_type_expr(self): + """Test that long long-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['long long'])) + + def unsigned_long_long_type_expr(self): + """Test that 'unsigned long long'-type variable expressions are evaluated correctly.""" + self.generic_type_expr_tester(set(['unsigned', 'long long'])) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From scallanan at apple.com Tue Sep 28 16:13:03 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 28 Sep 2010 21:13:03 -0000 Subject: [Lldb-commits] [lldb] r114990 - /lldb/trunk/source/Expression/IRForTarget.cpp Message-ID: <20100928211303.3F75D2A6C12C@llvm.org> Author: spyffe Date: Tue Sep 28 16:13:03 2010 New Revision: 114990 URL: http://llvm.org/viewvc/llvm-project?rev=114990&view=rev Log: Fixed two bugs in the expression parser: - the guard variable for the static result variable was being mistaken for the actual result value, causing IRForTarget to fail - LLVM builtins like memcpy were not being properly resolved; now they are resolved to the corresponding function in the target Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=114990&r1=114989&r2=114990&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Sep 28 16:13:03 2010 @@ -80,8 +80,12 @@ vi != ve; ++vi) { - if (strstr(vi->first(), "___clang_expr_result")) + if (strstr(vi->first(), "___clang_expr_result") && + !strstr(vi->first(), "GV")) + { result_name = vi->first(); + break; + } } if (!result_name) @@ -92,6 +96,9 @@ return true; } + if (log) + log->Printf("Result name: %s", result_name); + Value *result_value = M.getNamedValue(result_name); if (!result_value) @@ -626,6 +633,36 @@ } } + std::string str = fun->getName().str(); + + if (str.find("llvm.") == 0) + { + // Probably a LLVM built-in. Let's try again, but looking up the original. + // + // +- builtin_name_offset [in this case, 5] + // | + // |====| builtin_name_length [in this case, 6] + // 0 | + // | | +- builtin_name_end [in this case, 11] + // V V V + // llvm.______.i32.u8 + // 012345678901234567 + // 0 1 + + size_t builtin_name_offset = sizeof("llvm.") - 1; + size_t builtin_name_end = str.find('.', builtin_name_offset); + + if (builtin_name_end == str.npos) + builtin_name_end = str.size() + 1; + + size_t builtin_name_length = builtin_name_end - builtin_name_offset; + + str = str.substr(builtin_name_offset, builtin_name_length); + + if (log) + log->Printf("Extracted builtin function name %s", str.c_str()); + } + clang::NamedDecl *fun_decl = DeclForGlobalValue(M, fun); uint64_t fun_addr; Value **fun_value_ptr = NULL; @@ -636,10 +673,10 @@ { fun_value_ptr = NULL; - if (!m_decl_map->GetFunctionAddress(fun->getName().str().c_str(), fun_addr)) + if (!m_decl_map->GetFunctionAddress(str.c_str(), fun_addr)) { if (log) - log->Printf("Function %s had no address", fun->getName().str().c_str()); + log->Printf("Function %s had no address", str.c_str()); return false; } @@ -647,16 +684,15 @@ } else { - if (!m_decl_map->GetFunctionAddress(fun->getName().str().c_str(), fun_addr)) + if (!m_decl_map->GetFunctionAddress(str.c_str(), fun_addr)) { if (log) - log->Printf("Metadataless function %s had no address", fun->getName().str().c_str()); - return false; + log->Printf("Metadataless function %s had no address", str.c_str()); } } if (log) - log->Printf("Found %s at %llx", fun->getName().str().c_str(), fun_addr); + log->Printf("Found %s at %llx", str.c_str(), fun_addr); Value *fun_addr_ptr; @@ -678,7 +714,7 @@ C->setCalledFunction(fun_addr_ptr); - ConstantArray *func_name = (ConstantArray*)ConstantArray::get(M.getContext(), fun->getName()); + ConstantArray *func_name = (ConstantArray*)ConstantArray::get(M.getContext(), str); Value *values[1]; values[0] = func_name; From johnny.chen at apple.com Tue Sep 28 17:47:28 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 28 Sep 2010 22:47:28 -0000 Subject: [Lldb-commits] [lldb] r115000 - /lldb/trunk/test/persistent_variables/TestPersistentVariables.py Message-ID: <20100928224728.4B72C2A6C12C@llvm.org> Author: johnny Date: Tue Sep 28 17:47:28 2010 New Revision: 115000 URL: http://llvm.org/viewvc/llvm-project?rev=115000&view=rev Log: Removed the @expectedFailure decorator from test_persistent_variables(). Modified: lldb/trunk/test/persistent_variables/TestPersistentVariables.py Modified: lldb/trunk/test/persistent_variables/TestPersistentVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/persistent_variables/TestPersistentVariables.py?rev=115000&r1=114999&r2=115000&view=diff ============================================================================== --- lldb/trunk/test/persistent_variables/TestPersistentVariables.py (original) +++ lldb/trunk/test/persistent_variables/TestPersistentVariables.py Tue Sep 28 17:47:28 2010 @@ -11,8 +11,6 @@ mydir = "persistent_variables" - @unittest2.expectedFailure - # Fails as of r114384. def test_persistent_variables(self): """Test that lldb persistent variables works correctly.""" self.buildDefault() From clattner at apple.com Tue Sep 28 18:38:54 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 28 Sep 2010 16:38:54 -0700 Subject: [Lldb-commits] [lldb] r114990 - /lldb/trunk/source/Expression/IRForTarget.cpp In-Reply-To: <20100928211303.3F75D2A6C12C@llvm.org> References: <20100928211303.3F75D2A6C12C@llvm.org> Message-ID: <36D43A00-EF64-4BF2-8BC5-63F76D94D4D3@apple.com> On Sep 28, 2010, at 2:13 PM, Sean Callanan wrote: > Author: spyffe > Date: Tue Sep 28 16:13:03 2010 > New Revision: 114990 > > URL: http://llvm.org/viewvc/llvm-project?rev=114990&view=rev > Log: > Fixed two bugs in the expression parser: > > - the guard variable for the static result > variable was being mistaken for the actual > result value, causing IRForTarget to fail > > - LLVM builtins like memcpy were not being > properly resolved; now they are resolved > to the corresponding function in the target Hi Sean, What problem are you trying to solve here? If you're trying to figure out what intrinsic something is, you can use Function::getIntrinsicID(). You shouldn't have to parse out the string like this. -Chris > > Modified: > lldb/trunk/source/Expression/IRForTarget.cpp > > Modified: lldb/trunk/source/Expression/IRForTarget.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=114990&r1=114989&r2=114990&view=diff > ============================================================================== > --- lldb/trunk/source/Expression/IRForTarget.cpp (original) > +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Sep 28 16:13:03 2010 > @@ -80,8 +80,12 @@ > vi != ve; > ++vi) > { > - if (strstr(vi->first(), "___clang_expr_result")) > + if (strstr(vi->first(), "___clang_expr_result") && > + !strstr(vi->first(), "GV")) > + { > result_name = vi->first(); > + break; > + } > } > > if (!result_name) > @@ -92,6 +96,9 @@ > return true; > } > > + if (log) > + log->Printf("Result name: %s", result_name); > + > Value *result_value = M.getNamedValue(result_name); > > if (!result_value) > @@ -626,6 +633,36 @@ > } > } > > + std::string str = fun->getName().str(); > + > + if (str.find("llvm.") == 0) > + { > + // Probably a LLVM built-in. Let's try again, but looking up the original. > + // > + // +- builtin_name_offset [in this case, 5] > + // | > + // |====| builtin_name_length [in this case, 6] > + // 0 | > + // | | +- builtin_name_end [in this case, 11] > + // V V V > + // llvm.______.i32.u8 > + // 012345678901234567 > + // 0 1 > + > + size_t builtin_name_offset = sizeof("llvm.") - 1; > + size_t builtin_name_end = str.find('.', builtin_name_offset); > + > + if (builtin_name_end == str.npos) > + builtin_name_end = str.size() + 1; > + > + size_t builtin_name_length = builtin_name_end - builtin_name_offset; > + > + str = str.substr(builtin_name_offset, builtin_name_length); > + > + if (log) > + log->Printf("Extracted builtin function name %s", str.c_str()); > + } > + > clang::NamedDecl *fun_decl = DeclForGlobalValue(M, fun); > uint64_t fun_addr; > Value **fun_value_ptr = NULL; > @@ -636,10 +673,10 @@ > { > fun_value_ptr = NULL; > > - if (!m_decl_map->GetFunctionAddress(fun->getName().str().c_str(), fun_addr)) > + if (!m_decl_map->GetFunctionAddress(str.c_str(), fun_addr)) > { > if (log) > - log->Printf("Function %s had no address", fun->getName().str().c_str()); > + log->Printf("Function %s had no address", str.c_str()); > > return false; > } > @@ -647,16 +684,15 @@ > } > else > { > - if (!m_decl_map->GetFunctionAddress(fun->getName().str().c_str(), fun_addr)) > + if (!m_decl_map->GetFunctionAddress(str.c_str(), fun_addr)) > { > if (log) > - log->Printf("Metadataless function %s had no address", fun->getName().str().c_str()); > - return false; > + log->Printf("Metadataless function %s had no address", str.c_str()); > } > } > > if (log) > - log->Printf("Found %s at %llx", fun->getName().str().c_str(), fun_addr); > + log->Printf("Found %s at %llx", str.c_str(), fun_addr); > > Value *fun_addr_ptr; > > @@ -678,7 +714,7 @@ > > C->setCalledFunction(fun_addr_ptr); > > - ConstantArray *func_name = (ConstantArray*)ConstantArray::get(M.getContext(), fun->getName()); > + ConstantArray *func_name = (ConstantArray*)ConstantArray::get(M.getContext(), str); > > Value *values[1]; > values[0] = func_name; > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From scallanan at apple.com Tue Sep 28 18:55:00 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 28 Sep 2010 23:55:00 -0000 Subject: [Lldb-commits] [lldb] r115006 - /lldb/trunk/source/Expression/IRForTarget.cpp Message-ID: <20100928235500.3D0402A6C12C@llvm.org> Author: spyffe Date: Tue Sep 28 18:55:00 2010 New Revision: 115006 URL: http://llvm.org/viewvc/llvm-project?rev=115006&view=rev Log: Removed a dreadful hack to get at the name of the intrinsic being used. Thanks to Chris Lattner for pointing out the proper way to do it. Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=115006&r1=115005&r2=115006&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Sep 28 18:55:00 2010 @@ -12,6 +12,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/InstrTypes.h" #include "llvm/Instructions.h" +#include "llvm/Intrinsics.h" #include "llvm/Module.h" #include "llvm/Target/TargetData.h" #include "llvm/ValueSymbolTable.h" @@ -633,34 +634,29 @@ } } - std::string str = fun->getName().str(); + std::string str; - if (str.find("llvm.") == 0) + if (fun->isIntrinsic()) { - // Probably a LLVM built-in. Let's try again, but looking up the original. - // - // +- builtin_name_offset [in this case, 5] - // | - // |====| builtin_name_length [in this case, 6] - // 0 | - // | | +- builtin_name_end [in this case, 11] - // V V V - // llvm.______.i32.u8 - // 012345678901234567 - // 0 1 - - size_t builtin_name_offset = sizeof("llvm.") - 1; - size_t builtin_name_end = str.find('.', builtin_name_offset); + Intrinsic::ID intrinsic_id = (Intrinsic::ID)fun->getIntrinsicID(); - if (builtin_name_end == str.npos) - builtin_name_end = str.size() + 1; - - size_t builtin_name_length = builtin_name_end - builtin_name_offset; - - str = str.substr(builtin_name_offset, builtin_name_length); + switch (intrinsic_id) + { + default: + if (log) + log->Printf("Unresolved intrinsic %s", Intrinsic::getName(intrinsic_id).c_str()); + return false; + case Intrinsic::memcpy: + str = "memcpy"; + break; + } if (log) - log->Printf("Extracted builtin function name %s", str.c_str()); + log->Printf("Resolved intrinsic name %s", str.c_str()); + } + else + { + str = fun->getName().str(); } clang::NamedDecl *fun_decl = DeclForGlobalValue(M, fun); From scallanan at apple.com Tue Sep 28 18:56:46 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 28 Sep 2010 16:56:46 -0700 Subject: [Lldb-commits] [lldb] r114990 - /lldb/trunk/source/Expression/IRForTarget.cpp In-Reply-To: <36D43A00-EF64-4BF2-8BC5-63F76D94D4D3@apple.com> References: <20100928211303.3F75D2A6C12C@llvm.org> <36D43A00-EF64-4BF2-8BC5-63F76D94D4D3@apple.com> Message-ID: <7E08EFDB-D2BE-4E66-B5A1-49CE342EF17C@apple.com> Thanks. This would have failed in many cases in odd ways, and is now fixed. Sean On Sep 28, 2010, at 4:38 PM, Chris Lattner wrote: > > On Sep 28, 2010, at 2:13 PM, Sean Callanan wrote: > >> Author: spyffe >> Date: Tue Sep 28 16:13:03 2010 >> New Revision: 114990 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=114990&view=rev >> Log: >> Fixed two bugs in the expression parser: >> >> - the guard variable for the static result >> variable was being mistaken for the actual >> result value, causing IRForTarget to fail >> >> - LLVM builtins like memcpy were not being >> properly resolved; now they are resolved >> to the corresponding function in the target > > Hi Sean, > > What problem are you trying to solve here? If you're trying to figure out what intrinsic something is, you can use Function::getIntrinsicID(). You shouldn't have to parse out the string like this. > > -Chris > >> >> Modified: >> lldb/trunk/source/Expression/IRForTarget.cpp >> >> Modified: lldb/trunk/source/Expression/IRForTarget.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=114990&r1=114989&r2=114990&view=diff >> ============================================================================== >> --- lldb/trunk/source/Expression/IRForTarget.cpp (original) >> +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Sep 28 16:13:03 2010 >> @@ -80,8 +80,12 @@ >> vi != ve; >> ++vi) >> { >> - if (strstr(vi->first(), "___clang_expr_result")) >> + if (strstr(vi->first(), "___clang_expr_result") && >> + !strstr(vi->first(), "GV")) >> + { >> result_name = vi->first(); >> + break; >> + } >> } >> >> if (!result_name) >> @@ -92,6 +96,9 @@ >> return true; >> } >> >> + if (log) >> + log->Printf("Result name: %s", result_name); >> + >> Value *result_value = M.getNamedValue(result_name); >> >> if (!result_value) >> @@ -626,6 +633,36 @@ >> } >> } >> >> + std::string str = fun->getName().str(); >> + >> + if (str.find("llvm.") == 0) >> + { >> + // Probably a LLVM built-in. Let's try again, but looking up the original. >> + // >> + // +- builtin_name_offset [in this case, 5] >> + // | >> + // |====| builtin_name_length [in this case, 6] >> + // 0 | >> + // | | +- builtin_name_end [in this case, 11] >> + // V V V >> + // llvm.______.i32.u8 >> + // 012345678901234567 >> + // 0 1 >> + >> + size_t builtin_name_offset = sizeof("llvm.") - 1; >> + size_t builtin_name_end = str.find('.', builtin_name_offset); >> + >> + if (builtin_name_end == str.npos) >> + builtin_name_end = str.size() + 1; >> + >> + size_t builtin_name_length = builtin_name_end - builtin_name_offset; >> + >> + str = str.substr(builtin_name_offset, builtin_name_length); >> + >> + if (log) >> + log->Printf("Extracted builtin function name %s", str.c_str()); >> + } >> + >> clang::NamedDecl *fun_decl = DeclForGlobalValue(M, fun); >> uint64_t fun_addr; >> Value **fun_value_ptr = NULL; >> @@ -636,10 +673,10 @@ >> { >> fun_value_ptr = NULL; >> >> - if (!m_decl_map->GetFunctionAddress(fun->getName().str().c_str(), fun_addr)) >> + if (!m_decl_map->GetFunctionAddress(str.c_str(), fun_addr)) >> { >> if (log) >> - log->Printf("Function %s had no address", fun->getName().str().c_str()); >> + log->Printf("Function %s had no address", str.c_str()); >> >> return false; >> } >> @@ -647,16 +684,15 @@ >> } >> else >> { >> - if (!m_decl_map->GetFunctionAddress(fun->getName().str().c_str(), fun_addr)) >> + if (!m_decl_map->GetFunctionAddress(str.c_str(), fun_addr)) >> { >> if (log) >> - log->Printf("Metadataless function %s had no address", fun->getName().str().c_str()); >> - return false; >> + log->Printf("Metadataless function %s had no address", str.c_str()); >> } >> } >> >> if (log) >> - log->Printf("Found %s at %llx", fun->getName().str().c_str(), fun_addr); >> + log->Printf("Found %s at %llx", str.c_str(), fun_addr); >> >> Value *fun_addr_ptr; >> >> @@ -678,7 +714,7 @@ >> >> C->setCalledFunction(fun_addr_ptr); >> >> - ConstantArray *func_name = (ConstantArray*)ConstantArray::get(M.getContext(), fun->getName()); >> + ConstantArray *func_name = (ConstantArray*)ConstantArray::get(M.getContext(), str); >> >> Value *values[1]; >> values[0] = func_name; >> >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > From clattner at apple.com Tue Sep 28 18:59:06 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 28 Sep 2010 16:59:06 -0700 Subject: [Lldb-commits] [lldb] r114990 - /lldb/trunk/source/Expression/IRForTarget.cpp In-Reply-To: <7E08EFDB-D2BE-4E66-B5A1-49CE342EF17C@apple.com> References: <20100928211303.3F75D2A6C12C@llvm.org> <36D43A00-EF64-4BF2-8BC5-63F76D94D4D3@apple.com> <7E08EFDB-D2BE-4E66-B5A1-49CE342EF17C@apple.com> Message-ID: On Sep 28, 2010, at 4:56 PM, Sean Callanan wrote: > Thanks. This would have failed in many cases in odd ways, and is now fixed. Cool. More generally, do you care about memmove and the many other intrinsics here? Why do you need to get the C name backing them, and what happens if there is none? -Chris From gclayton at apple.com Tue Sep 28 20:12:09 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 29 Sep 2010 01:12:09 -0000 Subject: [Lldb-commits] [lldb] r115012 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Symbol/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/ source/Plugins/SymbolFile/DWARF/ source/Plugins/SymbolFile/Symtab/ source/Symbol/ tools/debugserver/debugserver.xcodeproj/ Message-ID: <20100929011209.C72C12A6C12C@llvm.org> Author: gclayton Date: Tue Sep 28 20:12:09 2010 New Revision: 115012 URL: http://llvm.org/viewvc/llvm-project?rev=115012&view=rev Log: Fixed the forward declaration issue that was present in the DWARF parser after adding methods to C++ and objective C classes. In order to make methods, we need the function prototype which means we need the arguments. Parsing these could cause a circular reference that caused an assertion. Added a new typedef for the clang opaque types which are just void pointers: lldb::clang_type_t. This appears in lldb-types.h. This was fixed by enabling struct, union, class, and enum types to only get a forward declaration when we make the clang opaque qual type for these types. When they need to actually be resolved, lldb_private::Type will call a new function in the SymbolFile protocol to resolve a clang type when it is not fully defined (clang::TagDecl::getDefinition() returns NULL). This allows us to be a lot more lazy when parsing clang types and keeps down the amount of data that gets parsed into the ASTContext for each module. Getting the clang type from a "lldb_private::Type" object now takes a boolean that indicates if a forward declaration is ok: clang_type_t lldb_private::Type::GetClangType (bool forward_decl_is_ok); So function prototypes that define parameters that are "const T&" can now just parse the forward declaration for type 'T' and we avoid circular references in the type system. Modified: lldb/trunk/include/lldb/Core/Value.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectChild.h lldb/trunk/include/lldb/Core/ValueObjectRegister.h lldb/trunk/include/lldb/Core/ValueObjectVariable.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/include/lldb/Symbol/ClangASTType.h lldb/trunk/include/lldb/Symbol/SymbolFile.h lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/include/lldb/Symbol/TypeList.h lldb/trunk/include/lldb/lldb-types.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Core/Value.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectChild.cpp lldb/trunk/source/Core/ValueObjectRegister.cpp lldb/trunk/source/Core/ValueObjectVariable.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionVariable.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/DWARFExpression.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Symbol/TypeList.cpp lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/include/lldb/Core/Value.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Value.h (original) +++ lldb/trunk/include/lldb/Core/Value.h Tue Sep 28 20:12:09 2010 @@ -72,7 +72,7 @@ GetProxyTarget(); void * - GetOpaqueClangQualType(); + GetClangType(); ValueType GetValueType() const; Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Tue Sep 28 20:12:09 2010 @@ -45,7 +45,7 @@ GetClangAST () = 0; virtual void * - GetOpaqueClangQualType () = 0; + GetClangType () = 0; virtual lldb::ValueType GetValueType() const = 0; Modified: lldb/trunk/include/lldb/Core/ValueObjectChild.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectChild.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectChild.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectChild.h Tue Sep 28 20:12:09 2010 @@ -52,7 +52,7 @@ GetClangAST (); virtual void * - GetOpaqueClangQualType (); + GetClangType (); virtual lldb::ValueType GetValueType() const; Modified: lldb/trunk/include/lldb/Core/ValueObjectRegister.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectRegister.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectRegister.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectRegister.h Tue Sep 28 20:12:09 2010 @@ -38,7 +38,7 @@ GetClangAST (); virtual void * - GetOpaqueClangQualType (); + GetClangType (); virtual lldb::ValueType GetValueType () const @@ -83,7 +83,7 @@ GetClangAST (); virtual void * - GetOpaqueClangQualType (); + GetClangType (); virtual lldb::ValueType GetValueType () const @@ -131,7 +131,7 @@ GetClangAST (); virtual void * - GetOpaqueClangQualType (); + GetClangType (); virtual lldb::ValueType GetValueType () const Modified: lldb/trunk/include/lldb/Core/ValueObjectVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectVariable.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectVariable.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectVariable.h Tue Sep 28 20:12:09 2010 @@ -37,7 +37,7 @@ GetClangAST (); virtual void * - GetOpaqueClangQualType (); + GetClangType (); virtual ConstString GetTypeName(); Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Sep 28 20:12:09 2010 @@ -77,61 +77,61 @@ // Basic Types //------------------------------------------------------------------ - void * + lldb::clang_type_t GetBuiltinTypeForEncodingAndBitSize (lldb::Encoding encoding, uint32_t bit_size); - static void * + static lldb::clang_type_t GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast_context, lldb::Encoding encoding, uint32_t bit_size); - void * + lldb::clang_type_t GetBuiltinTypeForDWARFEncodingAndBitSize ( const char *type_name, uint32_t dw_ate, uint32_t bit_size); - static void * + static lldb::clang_type_t GetBuiltInType_void(clang::ASTContext *ast_context); - void * + lldb::clang_type_t GetBuiltInType_void() { return GetBuiltInType_void(getASTContext()); } - void * + lldb::clang_type_t GetBuiltInType_objc_id(); - void * + lldb::clang_type_t GetBuiltInType_objc_Class(); - void * + lldb::clang_type_t GetBuiltInType_objc_selector(); - void * + lldb::clang_type_t GetCStringType(bool is_const); - void * + lldb::clang_type_t GetVoidPtrType(bool is_const); - static void * + static lldb::clang_type_t GetVoidPtrType(clang::ASTContext *ast_context, bool is_const); - static void * + static lldb::clang_type_t CopyType(clang::ASTContext *dest_context, clang::ASTContext *source_context, - void *clang_type); + lldb::clang_type_t clang_type); static bool AreTypesSame(clang::ASTContext *ast_context, - void *type1, - void *type2); + lldb::clang_type_t type1, + lldb::clang_type_t type2); bool - AreTypesSame(void *type1, - void *type2) + AreTypesSame(lldb::clang_type_t type1, + lldb::clang_type_t type2) { return ClangASTContext::AreTypesSame(getASTContext(), type1, type2); } @@ -140,20 +140,20 @@ // CVR modifiers //------------------------------------------------------------------ - static void * - AddConstModifier (void *clang_type); + static lldb::clang_type_t + AddConstModifier (lldb::clang_type_t clang_type); - static void * - AddRestrictModifier (void *clang_type); + static lldb::clang_type_t + AddRestrictModifier (lldb::clang_type_t clang_type); - static void * - AddVolatileModifier (void *clang_type); + static lldb::clang_type_t + AddVolatileModifier (lldb::clang_type_t clang_type); //------------------------------------------------------------------ // Structure, Unions, Classes //------------------------------------------------------------------ - void * + lldb::clang_type_t CreateRecordType (const char *name, int kind, clang::DeclContext *decl_ctx, @@ -161,16 +161,16 @@ static bool AddFieldToRecordType (clang::ASTContext *ast_context, - void *record_qual_type, + lldb::clang_type_t record_qual_type, const char *name, - void *field_type, + lldb::clang_type_t field_type, lldb::AccessType access, uint32_t bitfield_bit_size); bool - AddFieldToRecordType (void *record_qual_type, + AddFieldToRecordType (lldb::clang_type_t record_qual_type, const char *name, - void *field_type, + lldb::clang_type_t field_type, lldb::AccessType access, uint32_t bitfield_bit_size) { @@ -184,18 +184,18 @@ static clang::CXXMethodDecl * AddMethodToCXXRecordType (clang::ASTContext *ast_context, - void *record_opaque_type, + lldb::clang_type_t record_opaque_type, const char *name, - void *method_type, + lldb::clang_type_t method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline); clang::CXXMethodDecl * - AddMethodToCXXRecordType (void *record_opaque_type, + AddMethodToCXXRecordType (lldb::clang_type_t record_opaque_type, const char *name, - void *method_type, + lldb::clang_type_t method_type, lldb::AccessType access, bool is_virtual, bool is_static, @@ -225,12 +225,12 @@ RecordHasFields (const clang::RecordDecl *record_decl); void - SetDefaultAccessForRecordFields (void *clang_type, + SetDefaultAccessForRecordFields (lldb::clang_type_t clang_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities); - void * + lldb::clang_type_t CreateObjCClass (const char *name, clang::DeclContext *decl_ctx, bool isForwardDecl, @@ -238,17 +238,17 @@ static bool AddObjCClassIVar (clang::ASTContext *ast_context, - void *class_opaque_type, + lldb::clang_type_t class_opaque_type, const char *name, - void *ivar_opaque_type, + lldb::clang_type_t ivar_opaque_type, lldb::AccessType access, uint32_t bitfield_bit_size, bool isSynthesized); bool - AddObjCClassIVar (void *class_opaque_type, + AddObjCClassIVar (lldb::clang_type_t class_opaque_type, const char *name, - void *ivar_opaque_type, + lldb::clang_type_t ivar_opaque_type, lldb::AccessType access, uint32_t bitfield_bit_size, bool isSynthesized) @@ -263,11 +263,11 @@ } bool - SetObjCSuperClass (void *class_clang_type, - void *superclass_clang_type); + SetObjCSuperClass (lldb::clang_type_t class_clang_type, + lldb::clang_type_t superclass_clang_type); static bool - ObjCTypeHasIVars (void *class_clang_type, bool check_superclass); + ObjCTypeHasIVars (lldb::clang_type_t class_clang_type, bool check_superclass); static bool ObjCDeclHasIVars (clang::ObjCInterfaceDecl *class_interface_decl, @@ -276,15 +276,15 @@ static clang::ObjCMethodDecl * AddMethodToObjCObjectType (clang::ASTContext *ast_context, - void *class_opaque_type, + lldb::clang_type_t class_opaque_type, const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") - void *method_opaque_type, + lldb::clang_type_t method_opaque_type, lldb::AccessType access); clang::ObjCMethodDecl * - AddMethodToObjCObjectType (void *class_opaque_type, + AddMethodToObjCObjectType (lldb::clang_type_t class_opaque_type, const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") - void *method_opaque_type, + lldb::clang_type_t method_opaque_type, lldb::AccessType access) { return AddMethodToObjCObjectType (getASTContext(), @@ -299,15 +299,15 @@ // Aggregate Types //------------------------------------------------------------------ static bool - IsAggregateType (void *clang_type); + IsAggregateType (lldb::clang_type_t clang_type); static uint32_t - GetNumChildren (void *clang_type, + GetNumChildren (lldb::clang_type_t clang_type, bool omit_empty_base_classes); - void * + lldb::clang_type_t GetChildClangTypeAtIndex (const char *parent_name, - void * parent_clang_type, + lldb::clang_type_t parent_clang_type, uint32_t idx, bool transparent_pointers, bool omit_empty_base_classes, @@ -317,10 +317,10 @@ uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset); - static void * + static lldb::clang_type_t GetChildClangTypeAtIndex (clang::ASTContext *ast_context, const char *parent_name, - void * parent_clang_type, + lldb::clang_type_t parent_clang_type, uint32_t idx, bool transparent_pointers, bool omit_empty_base_classes, @@ -334,7 +334,7 @@ // and member member names in "clang_type" only, not descendants. static uint32_t GetIndexOfChildWithName (clang::ASTContext *ast_context, - void *clang_type, + lldb::clang_type_t clang_type, const char *name, bool omit_empty_base_classes); @@ -345,7 +345,7 @@ // so we catch all names that match a given child name, not just the first. static size_t GetIndexOfChildMemberWithName (clang::ASTContext *ast_context, - void *clang_type, + lldb::clang_type_t clang_type, const char *name, bool omit_empty_base_classes, std::vector& child_indexes); @@ -355,7 +355,7 @@ //------------------------------------------------------------------ bool - SetTagTypeKind (void * tag_qual_type, + SetTagTypeKind (lldb::clang_type_t tag_qual_type, int kind); //------------------------------------------------------------------ @@ -363,7 +363,7 @@ //------------------------------------------------------------------ clang::CXXBaseSpecifier * - CreateBaseClassSpecifier (void * base_class_type, + CreateBaseClassSpecifier (lldb::clang_type_t base_class_type, lldb::AccessType access, bool is_virtual, bool base_of_class); @@ -373,7 +373,7 @@ unsigned num_base_classes); bool - SetBaseClassesForClassType (void * class_clang_type, + SetBaseClassesForClassType (lldb::clang_type_t class_clang_type, clang::CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes); @@ -382,7 +382,7 @@ //------------------------------------------------------------------ static clang::DeclContext * - GetDeclContextForType (void * qual_type); + GetDeclContextForType (lldb::clang_type_t qual_type); //------------------------------------------------------------------ // Namespace Declarations @@ -399,21 +399,21 @@ clang::FunctionDecl * CreateFunctionDeclaration (const char *name, - void * function_Type, + lldb::clang_type_t function_Type, int storage, bool is_inline); - static void * + static lldb::clang_type_t CreateFunctionType (clang::ASTContext *ast_context, - void *result_type, - void **args, + lldb::clang_type_t result_type, + lldb::clang_type_t *args, unsigned num_args, bool is_variadic, unsigned type_quals); - void * - CreateFunctionType (void *result_type, - void **args, + lldb::clang_type_t + CreateFunctionType (lldb::clang_type_t result_type, + lldb::clang_type_t *args, unsigned num_args, bool is_variadic, unsigned type_quals) @@ -428,7 +428,7 @@ clang::ParmVarDecl * CreateParameterDeclaration (const char *name, - void *param_type, + lldb::clang_type_t param_type, int storage); void @@ -440,8 +440,8 @@ // Array Types //------------------------------------------------------------------ - void * - CreateArrayType (void * element_type, + lldb::clang_type_t + CreateArrayType (lldb::clang_type_t element_type, size_t element_count, uint32_t bit_stride); @@ -449,20 +449,23 @@ // Tag Declarations //------------------------------------------------------------------ bool - StartTagDeclarationDefinition (void * qual_type); + StartTagDeclarationDefinition (lldb::clang_type_t qual_type); bool - CompleteTagDeclarationDefinition (void * qual_type); + CompleteTagDeclarationDefinition (lldb::clang_type_t qual_type); //------------------------------------------------------------------ // Enumeration Types //------------------------------------------------------------------ - void * - CreateEnumerationType (const Declaration &decl, const char *name, void *integer_qual_type); + lldb::clang_type_t + CreateEnumerationType (const Declaration &decl, const char *name, lldb::clang_type_t integer_qual_type); + static lldb::clang_type_t + GetEnumerationIntegerType (lldb::clang_type_t enum_clang_type); + bool - AddEnumerationValueToEnumerationType (void * enum_qual_type, - void * enumerator_qual_type, + AddEnumerationValueToEnumerationType (lldb::clang_type_t enum_qual_type, + lldb::clang_type_t enumerator_qual_type, const Declaration &decl, const char *name, int64_t enum_value, @@ -471,66 +474,66 @@ //------------------------------------------------------------------ // Pointers & References //------------------------------------------------------------------ - void * - CreatePointerType (void *clang_type); + lldb::clang_type_t + CreatePointerType (lldb::clang_type_t clang_type); - void * - CreateLValueReferenceType (void *clang_type); + lldb::clang_type_t + CreateLValueReferenceType (lldb::clang_type_t clang_type); - void * - CreateRValueReferenceType (void *clang_type); + lldb::clang_type_t + CreateRValueReferenceType (lldb::clang_type_t clang_type); - void * - CreateMemberPointerType (void * clang_pointee_type, - void * clang_class_type); + lldb::clang_type_t + CreateMemberPointerType (lldb::clang_type_t clang_pointee_type, + lldb::clang_type_t clang_class_type); size_t GetPointerBitSize (); static bool - IsIntegerType (void *clang_type, bool &is_signed); + IsIntegerType (lldb::clang_type_t clang_type, bool &is_signed); static bool - IsPointerType (void *clang_type, void **target_type = NULL); + IsPointerType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); static bool - IsPointerOrReferenceType (void *clang_type, void **target_type = NULL); + IsPointerOrReferenceType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); static bool - IsCStringType (void *clang_type, uint32_t &length); + IsCStringType (lldb::clang_type_t clang_type, uint32_t &length); static bool - IsFunctionPointerType (void *clang_type); + IsFunctionPointerType (lldb::clang_type_t clang_type); static bool - IsArrayType (void *clang_type, void **member_type = NULL, uint64_t *size = NULL); + IsArrayType (lldb::clang_type_t clang_type, lldb::clang_type_t *member_type = NULL, uint64_t *size = NULL); //------------------------------------------------------------------ // Typedefs //------------------------------------------------------------------ - void * + lldb::clang_type_t CreateTypedefType (const char *name, - void *clang_type, + lldb::clang_type_t clang_type, clang::DeclContext *decl_ctx); //------------------------------------------------------------------ // Type names //------------------------------------------------------------------ static std::string - GetTypeName(void *clang_type); + GetTypeName(lldb::clang_type_t clang_type); static bool - IsFloatingPointType (void *clang_type, uint32_t &count, bool &is_complex); + IsFloatingPointType (lldb::clang_type_t clang_type, uint32_t &count, bool &is_complex); static bool - IsCXXClassType (void *clang_type); + IsCXXClassType (lldb::clang_type_t clang_type); static bool - IsObjCClassType (void *clang_type); + IsObjCClassType (lldb::clang_type_t clang_type); //static bool //ConvertFloatValueToString (clang::ASTContext *ast_context, - // void *clang_type, + // lldb::clang_type_t clang_type, // const uint8_t* bytes, // size_t byte_size, // int apint_byte_order, @@ -538,7 +541,7 @@ static size_t ConvertStringToFloatValue (clang::ASTContext *ast_context, - void *clang_type, + lldb::clang_type_t clang_type, const char *s, uint8_t *dst, size_t dst_size); @@ -547,7 +550,7 @@ // Qualifiers //------------------------------------------------------------------ static unsigned - GetTypeQualifiers(void *clang_type); + GetTypeQualifiers(lldb::clang_type_t clang_type); protected: //------------------------------------------------------------------ // Classes that inherit from ClangASTContext can see and modify these Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Tue Sep 28 20:12:09 2010 @@ -189,6 +189,13 @@ size_t data_byte_size, Scalar &value); + + bool + IsDefined(); + + static bool + IsDefined (void *opaque_clang_qual_type); + bool SetValueFromScalar (const Scalar &value, Stream &strm); Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Tue Sep 28 20:12:09 2010 @@ -70,6 +70,7 @@ virtual size_t ParseTypes (const SymbolContext& sc) = 0; virtual size_t ParseVariablesForContext (const SymbolContext& sc) = 0; virtual Type* ResolveTypeUID (lldb::user_id_t type_uid) = 0; + virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type) = 0; virtual clang::DeclContext* GetClangDeclContextForTypeUID (lldb::user_id_t type_uid) { return NULL; } virtual uint32_t ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) = 0; virtual uint32_t ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) = 0; Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Tue Sep 28 20:12:09 2010 @@ -35,16 +35,16 @@ eTypeUIDSynthetic } EncodingUIDType; - Type(lldb::user_id_t uid, - SymbolFile* symbol_file, - const ConstString &name, - uint64_t byte_size, - SymbolContextScope *context, - lldb::user_id_t encoding_uid, - EncodingUIDType encoding_type, - const Declaration& decl, - void *clang_qual_type); - + Type (lldb::user_id_t uid, + SymbolFile* symbol_file, + const ConstString &name, + uint64_t byte_size, + SymbolContextScope *context, + lldb::user_id_t encoding_uid, + EncodingUIDType encoding_type, + const Declaration& decl, + lldb::clang_type_t clang_qual_type); + // This makes an invalid type. Used for functions that return a Type when they // get an error. Type(); @@ -171,8 +171,8 @@ const lldb_private::Declaration & GetDeclaration () const; - void * - GetOpaqueClangQualType (); + lldb::clang_type_t + GetClangType (bool forward_decl_is_ok = false); clang::ASTContext * GetClangAST (); @@ -180,7 +180,7 @@ ClangASTContext & GetClangASTContext (); - void * + lldb::clang_type_t GetChildClangTypeAtIndex (const char *parent_name, uint32_t idx, bool transparent_pointers, @@ -202,9 +202,9 @@ lldb::user_id_t m_encoding_uid; EncodingUIDType m_encoding_uid_type; Declaration m_decl; - void *m_clang_qual_type; + lldb::clang_type_t m_clang_qual_type; - bool ResolveClangType(); + bool ResolveClangType(bool forward_decl_is_ok = false); }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Symbol/TypeList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeList.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/TypeList.h (original) +++ lldb/trunk/include/lldb/Symbol/TypeList.h Tue Sep 28 20:12:09 2010 @@ -56,27 +56,18 @@ GetClangASTContext (); void * - CreateClangPointerType (Type *type); + CreateClangPointerType (Type *type, bool forward_decl_is_ok); void * - CreateClangTypedefType (Type *typedef_type, Type *base_type); + CreateClangTypedefType (Type *typedef_type, Type *base_type, bool forward_decl_is_ok); // For C++98 references (&) void * - CreateClangLValueReferenceType (Type *type); + CreateClangLValueReferenceType (Type *type, bool forward_decl_is_ok); // For C++0x references (&&) void * - CreateClangRValueReferenceType (Type *type); - - void * - GetConstClangType (Type *type); - - void * - GetRestrictClangType (Type *type); - - void * - GetVolatileClangType (Type *type); + CreateClangRValueReferenceType (Type *type, bool forward_decl_is_ok); private: typedef std::vector collection; Modified: lldb/trunk/include/lldb/lldb-types.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-types.h (original) +++ lldb/trunk/include/lldb/lldb-types.h Tue Sep 28 20:12:09 2010 @@ -93,6 +93,7 @@ typedef int32_t pid_t; typedef uint32_t tid_t; typedef int32_t break_id_t; + typedef void * clang_type_t; //---------------------------------------------------------------------- // Every register is described in detail including its name, alternate Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Sep 28 20:12:09 2010 @@ -2431,6 +2431,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Tue Sep 28 20:12:09 2010 @@ -241,7 +241,7 @@ SBValue::GetOpaqueType() { if (m_opaque_sp) - return m_opaque_sp->GetOpaqueClangQualType(); + return m_opaque_sp->GetClangType(); return NULL; } Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Sep 28 20:12:09 2010 @@ -360,7 +360,7 @@ { const char *sum_cstr = valobj->GetSummaryAsCString(exe_scope); - const bool is_aggregate = ClangASTContext::IsAggregateType (valobj->GetOpaqueClangQualType()); + const bool is_aggregate = ClangASTContext::IsAggregateType (valobj->GetClangType()); if (val_cstr) s.PutCString(val_cstr); @@ -384,7 +384,7 @@ if (is_aggregate) s.PutChar('{'); - bool is_ptr_or_ref = ClangASTContext::IsPointerOrReferenceType (valobj->GetOpaqueClangQualType()); + bool is_ptr_or_ref = ClangASTContext::IsPointerOrReferenceType (valobj->GetClangType()); if (is_ptr_or_ref && ptr_depth == 0) return; Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Tue Sep 28 20:12:09 2010 @@ -429,7 +429,7 @@ { // Resolve the clang type so that any forward references // to types that haven't yet been parsed will get parsed. - type_sp->GetOpaqueClangQualType (); + type_sp->GetClangType (); type_sp->GetDescription (&strm, eDescriptionLevelFull, true); } strm.EOL(); Modified: lldb/trunk/source/Core/Value.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Core/Value.cpp (original) +++ lldb/trunk/source/Core/Value.cpp Tue Sep 28 20:12:09 2010 @@ -417,10 +417,10 @@ } void * -Value::GetOpaqueClangQualType () +Value::GetClangType () { if (m_context_type == eContextTypeValue) - return ((Value*)m_context)->GetOpaqueClangQualType(); + return ((Value*)m_context)->GetClangType(); switch (m_context_type) { @@ -436,12 +436,12 @@ case eContextTypeDCType: if (GetType()) - return GetType()->GetOpaqueClangQualType(); + return GetType()->GetClangType(); break; case eContextTypeDCVariable: if (GetVariable()) - return GetVariable()->GetType()->GetOpaqueClangQualType(); + return GetVariable()->GetType()->GetClangType(); break; } @@ -669,7 +669,7 @@ if (m_context_type == eContextTypeOpaqueClangQualType) { - void *opaque_clang_qual_type = GetOpaqueClangQualType(); + void *opaque_clang_qual_type = GetClangType(); switch (m_value_type) { case eValueTypeScalar: // raw scalar value Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Tue Sep 28 20:12:09 2010 @@ -263,7 +263,7 @@ { bool omit_empty_base_classes = true; return ClangASTContext::GetIndexOfChildWithName (GetClangAST(), - GetOpaqueClangQualType(), + GetClangType(), name.AsCString(), omit_empty_base_classes); } @@ -276,7 +276,7 @@ // need a vector of indexes that can get us down to the correct child std::vector child_indexes; clang::ASTContext *clang_ast = GetClangAST(); - void *clang_type = GetOpaqueClangQualType(); + void *clang_type = GetClangType(); bool omit_empty_base_classes = true; const size_t num_child_indexes = ClangASTContext::GetIndexOfChildMemberWithName (clang_ast, clang_type, @@ -349,7 +349,7 @@ uint32_t child_bitfield_bit_offset = 0; const bool transparent_pointers = synthetic_array_member == false; clang::ASTContext *clang_ast = GetClangAST(); - void *clang_type = GetOpaqueClangQualType(); + void *clang_type = GetClangType(); void *child_clang_type; child_clang_type = ClangASTContext::GetChildClangTypeAtIndex (clang_ast, GetName().AsCString(), @@ -390,7 +390,7 @@ { if (m_summary_str.empty()) { - void *clang_type = GetOpaqueClangQualType(); + void *clang_type = GetClangType(); // See if this is a pointer to a C string? uint32_t fixed_length = 0; @@ -561,7 +561,7 @@ ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope) { // If our byte size is zero this is an aggregate type that has children - if (ClangASTContext::IsAggregateType (GetOpaqueClangQualType()) == false) + if (ClangASTContext::IsAggregateType (GetClangType()) == false) { if (UpdateValueIfNeeded(exe_scope)) { @@ -575,7 +575,7 @@ case Value::eContextTypeDCType: case Value::eContextTypeDCVariable: { - void *clang_type = GetOpaqueClangQualType (); + void *clang_type = GetClangType (); if (clang_type) { StreamString sstr; @@ -665,7 +665,7 @@ return false; uint32_t count = 0; - lldb::Encoding encoding = ClangASTType::GetEncoding (GetOpaqueClangQualType(), count); + lldb::Encoding encoding = ClangASTType::GetEncoding (GetClangType(), count); char *end = NULL; const size_t byte_size = GetByteSize(); @@ -717,7 +717,7 @@ m_data.SetByteOrder(eByteOrderHost); const size_t converted_byte_size = ClangASTContext::ConvertStringToFloatValue ( GetClangAST(), - GetOpaqueClangQualType(), + GetClangType(), value_str, dst, byte_size); @@ -756,7 +756,7 @@ lldb::LanguageType ValueObject::GetObjectRuntimeLanguage () { - void *opaque_qual_type = GetOpaqueClangQualType(); + void *opaque_qual_type = GetClangType(); if (opaque_qual_type == NULL) return lldb::eLanguageTypeC; @@ -805,13 +805,13 @@ bool ValueObject::IsPointerType () { - return ClangASTContext::IsPointerType (GetOpaqueClangQualType()); + return ClangASTContext::IsPointerType (GetClangType()); } bool ValueObject::IsPointerOrReferenceType () { - return ClangASTContext::IsPointerOrReferenceType(GetOpaqueClangQualType()); + return ClangASTContext::IsPointerOrReferenceType(GetClangType()); } ValueObjectSP Modified: lldb/trunk/source/Core/ValueObjectChild.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp (original) +++ lldb/trunk/source/Core/ValueObjectChild.cpp Tue Sep 28 20:12:09 2010 @@ -52,7 +52,7 @@ } void * -ValueObjectChild::GetOpaqueClangQualType() +ValueObjectChild::GetClangType() { return m_clang_type; } @@ -104,7 +104,7 @@ { if (m_type_name.IsEmpty()) { - m_type_name = ClangASTType::GetClangTypeName (GetOpaqueClangQualType()); + m_type_name = ClangASTType::GetClangTypeName (GetClangType()); if (m_type_name) { if (m_bitfield_bit_size > 0) @@ -139,13 +139,13 @@ Value::ValueType value_type = parent->GetValue().GetValueType(); m_value.SetValueType (value_type); - if (ClangASTContext::IsPointerOrReferenceType (parent->GetOpaqueClangQualType())) + if (ClangASTContext::IsPointerOrReferenceType (parent->GetClangType())) { uint32_t offset = 0; m_value.GetScalar() = parent->GetDataExtractor().GetPointer(&offset); // For pointers, m_byte_offset should only ever be set if we // ValueObject::GetSyntheticArrayMemberFromPointer() was called - if (ClangASTContext::IsPointerType (parent->GetOpaqueClangQualType()) && m_byte_offset) + if (ClangASTContext::IsPointerType (parent->GetClangType()) && m_byte_offset) m_value.GetScalar() += m_byte_offset; if (value_type == Value::eValueTypeScalar || value_type == Value::eValueTypeFileAddress) Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectRegister.cpp (original) +++ lldb/trunk/source/Core/ValueObjectRegister.cpp Tue Sep 28 20:12:09 2010 @@ -43,7 +43,7 @@ } void * -ValueObjectRegisterContext::GetOpaqueClangQualType () +ValueObjectRegisterContext::GetClangType () { return NULL; } @@ -120,7 +120,7 @@ } void * -ValueObjectRegisterSet::GetOpaqueClangQualType () +ValueObjectRegisterSet::GetClangType () { return NULL; } @@ -228,7 +228,7 @@ } void * -ValueObjectRegister::GetOpaqueClangQualType () +ValueObjectRegister::GetClangType () { if (m_clang_type == NULL && m_reg_info) { @@ -251,7 +251,7 @@ ValueObjectRegister::GetTypeName() { if (m_type_name.IsEmpty()) - m_type_name = ClangASTType::GetClangTypeName (GetOpaqueClangQualType()); + m_type_name = ClangASTType::GetClangTypeName (GetClangType()); return m_type_name; } Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Tue Sep 28 20:12:09 2010 @@ -46,11 +46,11 @@ } void * -ValueObjectVariable::GetOpaqueClangQualType () +ValueObjectVariable::GetClangType () { Type *var_type = m_variable_sp->GetType(); if (var_type) - return var_type->GetOpaqueClangQualType(); + return var_type->GetClangType(); return NULL; } @@ -172,7 +172,7 @@ } } - if (ClangASTContext::IsAggregateType (GetOpaqueClangQualType())) + if (ClangASTContext::IsAggregateType (GetClangType())) { // this value object represents an aggregate type whose // children have values, but this object does not. So we Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Sep 28 20:12:09 2010 @@ -709,7 +709,7 @@ if (type->GetASTContext() == var->GetType()->GetClangAST()) { - if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetOpaqueClangQualType())) + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetClangType())) return NULL; } else @@ -759,7 +759,7 @@ if (!this_type) return; - TypeFromUser this_user_type(this_type->GetOpaqueClangQualType(), + TypeFromUser this_user_type(this_type->GetClangType(), this_type->GetClangAST()); m_object_pointer_type = this_user_type; @@ -836,7 +836,7 @@ if (type.get()) { - TypeFromUser user_type(type->GetOpaqueClangQualType(), + TypeFromUser user_type(type->GetClangType(), type->GetClangAST()); AddOneType(context, user_type, false); @@ -866,7 +866,7 @@ return NULL; } - void *var_opaque_type = var_type->GetOpaqueClangQualType(); + void *var_opaque_type = var_type->GetClangType(); if (!var_opaque_type) { @@ -1043,7 +1043,7 @@ return; } - fun_opaque_type = fun_type->GetOpaqueClangQualType(); + fun_opaque_type = fun_type->GetClangType(); if (!fun_opaque_type) { Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Tue Sep 28 20:12:09 2010 @@ -97,7 +97,7 @@ if (format == lldb::eFormatDefault) format = val.GetValueDefaultFormat (); - void *clang_type = val.GetOpaqueClangQualType (); + void *clang_type = val.GetClangType (); output_stream.Printf("%s = ", m_name.c_str()); Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Tue Sep 28 20:12:09 2010 @@ -83,7 +83,7 @@ m_JITted (false) { m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress(); - m_function_return_qual_type = m_function_ptr->GetReturnType().GetOpaqueClangQualType(); + m_function_return_qual_type = m_function_ptr->GetReturnType().GetClangType(); } //---------------------------------------------------------------------- @@ -153,7 +153,7 @@ else { Value *arg_value = m_arg_values.GetValueAtIndex(i); - void *clang_qual_type = arg_value->GetOpaqueClangQualType (); + void *clang_qual_type = arg_value->GetClangType (); if (clang_qual_type != NULL) { type_stdstr = ClangASTContext::GetTypeName(clang_qual_type); @@ -322,7 +322,7 @@ if (arg_value->GetValueType() == Value::eValueTypeHostAddress && arg_value->GetContextType() == Value::eContextTypeOpaqueClangQualType && - ClangASTContext::IsPointerType(arg_value->GetOpaqueClangQualType())) + ClangASTContext::IsPointerType(arg_value->GetClangType())) continue; const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx, m_clang_ast_context->getASTContext()); Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Tue Sep 28 20:12:09 2010 @@ -2136,7 +2136,7 @@ return false; } - void *array_type = array_val.GetOpaqueClangQualType(); + void *array_type = array_val.GetClangType(); void *member_type; uint64_t size = 0; @@ -2214,7 +2214,7 @@ { case Value::eContextTypeOpaqueClangQualType: { - void *clang_type = stack.back().GetOpaqueClangQualType(); + void *clang_type = stack.back().GetClangType(); if (ClangASTContext::IsAggregateType (clang_type)) { @@ -2434,7 +2434,7 @@ return false; } - void *ptr_type = tmp.GetOpaqueClangQualType(); + void *ptr_type = tmp.GetClangType(); void *target_type; if (!ClangASTContext::IsPointerType(ptr_type, &target_type)) @@ -2483,7 +2483,7 @@ Value *proxy = expr_local_variable->CreateProxy(); stack.push_back(*proxy); delete proxy; - //stack.back().SetContext (Value::eContextTypeOpaqueClangQualType, expr_local_variable->GetOpaqueClangQualType()); + //stack.back().SetContext (Value::eContextTypeOpaqueClangQualType, expr_local_variable->GetClangType()); */ } break; Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Tue Sep 28 20:12:09 2010 @@ -236,7 +236,7 @@ return false; case Value::eContextTypeOpaqueClangQualType: { - void *val_type = val->GetOpaqueClangQualType(); + void *val_type = val->GetClangType(); uint32_t cstr_length; if (ClangASTContext::IsCStringType (val_type, cstr_length)) @@ -435,7 +435,7 @@ return false; case Value::eContextTypeOpaqueClangQualType: { - void *value_type = value->GetOpaqueClangQualType(); + void *value_type = value->GetClangType(); bool is_signed; if (ClangASTContext::IsIntegerType (value_type, is_signed)) @@ -484,7 +484,7 @@ RegisterContext *reg_ctx = thread.GetRegisterContext(); - void *value_type = value.GetOpaqueClangQualType(); + void *value_type = value.GetClangType(); bool is_signed; if (ClangASTContext::IsIntegerType (value_type, is_signed)) Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Tue Sep 28 20:12:09 2010 @@ -266,7 +266,7 @@ return false; case Value::eContextTypeOpaqueClangQualType: { - void *value_type = value->GetOpaqueClangQualType(); + void *value_type = value->GetClangType(); bool is_signed; if (ClangASTContext::IsIntegerType (value_type, is_signed)) @@ -309,7 +309,7 @@ return false; case Value::eContextTypeOpaqueClangQualType: { - void *value_type = value.GetOpaqueClangQualType(); + void *value_type = value.GetClangType(); bool is_signed; RegisterContext *reg_ctx = thread.GetRegisterContext(); Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp Tue Sep 28 20:12:09 2010 @@ -51,7 +51,7 @@ assert (m_process == exe_ctx.process); // ObjC objects can only be pointers: - if (!ClangASTContext::IsPointerType (object.GetOpaqueClangQualType())) + if (!ClangASTContext::IsPointerType (object.GetClangType())) return NULL; // Get the function address for the print function. @@ -63,7 +63,7 @@ Scalar scalar; if (!ClangASTType::GetValueAsScalar (object.GetClangAST(), - object.GetOpaqueClangQualType(), + object.GetClangType(), object.GetDataExtractor(), 0, object.GetByteSize(), 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=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Sep 28 20:12:09 2010 @@ -1007,10 +1007,9 @@ SymbolFileDWARF::ParseChildMembers ( const SymbolContext& sc, - TypeSP& type_sp, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, - void *class_clang_type, + clang_type_t class_clang_type, const LanguageType class_language, std::vector& base_classes, std::vector& member_accessibilities, @@ -1098,7 +1097,7 @@ accessibility = default_accessibility; member_accessibilities.push_back(accessibility); - type_list->GetClangASTContext().AddFieldToRecordType (type_sp->GetOpaqueClangQualType(), name, member_type->GetOpaqueClangQualType(), accessibility, bit_size); + type_list->GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangType(), accessibility, bit_size); } } break; @@ -1170,11 +1169,11 @@ if (class_language == eLanguageTypeObjC) { - type_list->GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetOpaqueClangQualType()); + type_list->GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetClangType()); } else { - base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetOpaqueClangQualType(), accessibility, is_virtual, is_base_of_class)); + base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetClangType(), accessibility, is_virtual, is_base_of_class)); assert(base_classes.back()); } } @@ -1217,6 +1216,124 @@ return NULL; } +lldb::clang_type_t +SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type) +{ + // We have a struct/union/class/enum that needs to be fully resolved. + const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type); + assert (die); + if (die == NULL) + return NULL; + + DWARFCompileUnit *cu = DebugInfo()->GetCompileUnitContainingDIE (die->GetOffset()).get(); + Type *type = m_die_to_type.lookup (die); + + const dw_tag_t tag = die->Tag(); + + assert (clang_type); + DWARFDebugInfoEntry::Attributes attributes; + + TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); + + switch (tag) + { + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_class_type: + type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); + if (die->HasChildren()) + { + LanguageType class_language = eLanguageTypeUnknown; + if (ClangASTContext::IsObjCClassType (clang_type)) + class_language = eLanguageTypeObjC; + + int tag_decl_kind = -1; + AccessType default_accessibility = eAccessNone; + if (tag == DW_TAG_structure_type) + { + tag_decl_kind = clang::TTK_Struct; + default_accessibility = eAccessPublic; + } + else if (tag == DW_TAG_union_type) + { + tag_decl_kind = clang::TTK_Union; + default_accessibility = eAccessPublic; + } + else if (tag == DW_TAG_class_type) + { + tag_decl_kind = clang::TTK_Class; + default_accessibility = eAccessPrivate; + } + + SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); + std::vector base_classes; + std::vector member_accessibilities; + bool is_a_class = false; + ParseChildMembers (sc, + cu, + die, + clang_type, + class_language, + base_classes, + member_accessibilities, + default_accessibility, + is_a_class); + + // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we + // need to tell the clang type it is actually a class. + if (class_language != eLanguageTypeObjC) + { + if (is_a_class && tag_decl_kind != clang::TTK_Class) + type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class); + } + + // Since DW_TAG_structure_type gets used for both classes + // and structures, we may need to set any DW_TAG_member + // fields to have a "private" access if none was specified. + // When we parsed the child members we tracked that actual + // accessibility value for each DW_TAG_member in the + // "member_accessibilities" array. If the value for the + // member is zero, then it was set to the "default_accessibility" + // which for structs was "public". Below we correct this + // by setting any fields to "private" that weren't correctly + // set. + if (is_a_class && !member_accessibilities.empty()) + { + // This is a class and all members that didn't have + // their access specified are private. + type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size()); + } + + if (!base_classes.empty()) + { + type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size()); + + // Clang will copy each CXXBaseSpecifier in "base_classes" + // so we have to free them all. + ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size()); + } + + } + type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); + return clang_type; + + case DW_TAG_enumeration_type: + type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); + if (die->HasChildren()) + { + SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); + ParseChildEnumerators(sc, clang_type, type->GetByteSize(), cu, die); + } + type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); + return clang_type; + + default: + assert(false && "not a forward clang type decl!"); + break; + } + return NULL; +} + Type* SymbolFileDWARF::ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die) { @@ -1224,10 +1341,7 @@ { Type *type = m_die_to_type.lookup (type_die); if (type == NULL) - { - TypeSP owning_type_sp; - type = GetTypeForDIE(cu, type_die, owning_type_sp, 0, 0).get(); - } + type = GetTypeForDIE (cu, type_die).get(); assert (type != DIE_IS_BEING_PARSED); return type; } @@ -1889,7 +2003,7 @@ const DWARFDebugInfoEntry *parent_die, bool skip_artificial, TypeList* type_list, - std::vector& function_param_types, + std::vector& function_param_types, std::vector& function_param_decls ) { @@ -1983,9 +2097,9 @@ Type *type = ResolveTypeUID(param_type_die_offset); if (type) { - function_param_types.push_back (type->GetOpaqueClangQualType()); + function_param_types.push_back (type->GetClangType(true)); - clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetOpaqueClangQualType(), storage); + clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetClangType(), storage); assert(param_var_decl); function_param_decls.push_back(param_var_decl); } @@ -2005,8 +2119,7 @@ SymbolFileDWARF::ParseChildEnumerators ( const SymbolContext& sc, - TypeSP& type_sp, - void * enumerator_qual_type, + clang_type_t enumerator_clang_type, uint32_t enumerator_byte_size, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die @@ -2065,7 +2178,12 @@ if (name && name[0] && got_value) { TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); - type_list->GetClangASTContext().AddEnumerationValueToEnumerationType (type_sp->GetOpaqueClangQualType(), enumerator_qual_type, decl, name, enum_value, enumerator_byte_size * 8); + type_list->GetClangASTContext().AddEnumerationValueToEnumerationType (enumerator_clang_type, + enumerator_clang_type, + decl, + name, + enum_value, + enumerator_byte_size * 8); ++enumerators_added; } } @@ -2194,8 +2312,6 @@ break; default: - //printf("0x%8.8x: %-30s skipping attribute at 0x%8.8x: %s\n", die->GetOffset(), DW_TAG_value_to_name(tag), attributes.die_offsets[i], DW_AT_value_to_name(attr)); // remove this, debug only - case DW_AT_abstract_origin: case DW_AT_accessibility: case DW_AT_allocated: @@ -2225,14 +2341,7 @@ } TypeSP -SymbolFileDWARF::GetTypeForDIE -( - DWARFCompileUnit *cu, - const DWARFDebugInfoEntry* die, - TypeSP& owning_type_sp, - int32_t child_type, - uint32_t idx -) +SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die) { TypeSP type_sp; if (die != NULL) @@ -2242,10 +2351,7 @@ if (type_ptr == NULL) { SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); - bool type_is_new = false; - type_sp = ParseType(sc, cu, die, type_is_new); - if (owning_type_sp.get() == NULL) - owning_type_sp = type_sp; + type_sp = ParseType(sc, cu, die, NULL); } else if (type_ptr != DIE_IS_BEING_PARSED) { @@ -2316,17 +2422,21 @@ } TypeSP -SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new) +SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new_ptr) { TypeSP type_sp; + if (type_is_new_ptr) + *type_is_new_ptr = false; + AccessType accessibility = eAccessNone; if (die != NULL) { Type *type_ptr = m_die_to_type.lookup (die); if (type_ptr == NULL) { - type_is_new = true; + if (type_is_new_ptr) + *type_is_new_ptr = true; const dw_tag_t tag = die->Tag(); @@ -2335,7 +2445,7 @@ const char *type_name_cstr = NULL; ConstString type_name_dbstr; Type::EncodingUIDType encoding_uid_type = Type::eIsTypeWithUID; - void *clang_type = NULL; + clang_type_t clang_type = NULL; TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); dw_attr_t attr; @@ -2350,7 +2460,6 @@ case DW_TAG_restrict_type: case DW_TAG_volatile_type: { - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; @@ -2398,37 +2507,37 @@ case DW_TAG_pointer_type: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::ePointerToTypeWithUID; break; case DW_TAG_reference_type: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::eLValueReferenceToTypeWithUID; break; case DW_TAG_typedef: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::eTypedefToTypeWithUID; break; case DW_TAG_const_type: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::eIsConstTypeWithUID; //ClangASTContext::AddConstModifier (clang_type); break; case DW_TAG_restrict_type: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::eIsRestrictTypeWithUID; //ClangASTContext::AddRestrictModifier (clang_type); break; case DW_TAG_volatile_type: // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetOpaqueClangQualType() + // Type object and will be looked up when the Type::GetClangType() encoding_uid_type = Type::eIsVolatileTypeWithUID; //ClangASTContext::AddVolatileModifier (clang_type); break; } @@ -2473,7 +2582,6 @@ case DW_TAG_union_type: case DW_TAG_class_type: { - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; @@ -2559,21 +2667,34 @@ } assert (tag_decl_kind != -1); - clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language); + bool clang_type_was_created = false; + clang_type = m_forward_decl_die_to_clang_type.lookup (die); + if (clang_type == NULL) + { + clang_type_was_created = true; + clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language); + } // Store a forward declaration to this class type in case any // parameters in any class methods need it for the clang // types for function prototypes. - m_die_to_clang_type[die] = clang_type; m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); m_die_to_type[die] = type_sp.get(); -// assert(type_sp.get()); -// if (accessibility) -// type_sp->SetAccess(accessibility); -// + // Leave this as a forward declaration until we need + // to know the details of the type. lldb_private::Type + // will automatically call the SymbolFile virtual function + // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)" + // When the definition needs to be defined. + if (clang_type_was_created) + { + m_forward_decl_die_to_clang_type[die] = clang_type; + m_forward_decl_clang_type_to_die[clang_type] = die; + } + +#if 0 type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); if (die->HasChildren()) { @@ -2581,7 +2702,6 @@ std::vector member_accessibilities; bool is_a_class = false; ParseChildMembers (sc, - type_sp, dwarf_cu, die, clang_type, @@ -2627,12 +2747,12 @@ } type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); +#endif // #if 0 } break; case DW_TAG_enumeration_type: { - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; @@ -2679,21 +2799,41 @@ } } } - - void *enumerator_qual_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8); - clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_qual_type); + clang_type_t enumerator_clang_type = NULL; + clang_type = m_forward_decl_die_to_clang_type.lookup (die); + if (clang_type == NULL) + { + enumerator_clang_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8); + clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_clang_type); + } + else + { + enumerator_clang_type = ClangASTContext::GetEnumerationIntegerType (clang_type); + assert (enumerator_clang_type != NULL); + } + m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, Type::eIsTypeWithUID, &decl, clang_type)); m_die_to_type[die] = type_sp.get(); + // Leave this as a forward declaration until we need + // to know the details of the type. lldb_private::Type + // will automatically call the SymbolFile virtual function + // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)" + // When the definition needs to be defined. + m_forward_decl_die_to_clang_type[die] = clang_type; + m_forward_decl_clang_type_to_die[clang_type] = die; + +#if 0 if (die->HasChildren()) { type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); - ParseChildEnumerators(sc, type_sp, enumerator_qual_type, byte_size, dwarf_cu, die); + ParseChildEnumerators(sc, enumerator_clang_type, byte_size, dwarf_cu, die); type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); } +#endif // #if 0 } } break; @@ -2702,7 +2842,6 @@ case DW_TAG_subprogram: case DW_TAG_subroutine_type: { - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; @@ -2787,14 +2926,14 @@ } } - void *return_clang_type = NULL; + clang_type_t return_clang_type = NULL; Type *func_type = ResolveTypeUID(type_die_offset); if (func_type) - return_clang_type = func_type->GetOpaqueClangQualType(); + return_clang_type = func_type->GetClangType(true); else return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); - std::vector function_param_types; + std::vector function_param_types; std::vector function_param_decls; // Parse the function children for the parameters @@ -2817,7 +2956,7 @@ const char *class_name_start = type_name_cstr + 2; const char *class_name_end = ::strchr (class_name_start, ' '); SymbolContext empty_sc; - void *class_opaque_type = NULL; + clang_type_t class_opaque_type = NULL; if (class_name_start < class_name_end) { ConstString class_name (class_name_start, class_name_end - class_name_start); @@ -2828,9 +2967,9 @@ for (uint32_t i=0; iGetOpaqueClangQualType())) + if (ClangASTContext::IsObjCClassType (type->GetClangType())) { - class_opaque_type = type->GetOpaqueClangQualType(); + class_opaque_type = type->GetClangType(); break; } } @@ -2856,7 +2995,7 @@ Type *class_type = ResolveType (dwarf_cu, parent_die); if (class_type) { - void *class_opaque_type = class_type->GetOpaqueClangQualType (); + clang_type_t class_opaque_type = class_type->GetClangType (true); if (ClangASTContext::IsCXXClassType (class_opaque_type)) { clang::CXXMethodDecl *cxx_method_decl; @@ -2895,7 +3034,6 @@ case DW_TAG_array_type: { - //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; @@ -2958,7 +3096,7 @@ element_orders.push_back (1); if (byte_stride == 0 && bit_stride == 0) byte_stride = element_type->GetByteSize(); - void *array_element_type = element_type->GetOpaqueClangQualType(); + clang_type_t array_element_type = element_type->GetClangType(); uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride; uint64_t num_elements = 0; std::vector::const_reverse_iterator pos; @@ -3006,8 +3144,8 @@ Type *pointee_type = ResolveTypeUID(type_die_offset); Type *class_type = ResolveTypeUID(containing_type_die_offset); - void *pointee_clang_type = pointee_type->GetOpaqueClangQualType(); - void *class_clang_type = class_type->GetOpaqueClangQualType(); + clang_type_t pointee_clang_type = pointee_type->GetClangType(); + clang_type_t class_clang_type = class_type->GetClangType(); clang_type = type_list->GetClangASTContext().CreateMemberPointerType(pointee_clang_type, class_clang_type); @@ -3071,13 +3209,20 @@ } size_t -SymbolFileDWARF::ParseTypes (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children) +SymbolFileDWARF::ParseTypes +( + const SymbolContext& sc, + DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *die, + bool parse_siblings, + bool parse_children +) { size_t types_added = 0; while (die != NULL) { bool type_is_new = false; - if (ParseType(sc, dwarf_cu, die, type_is_new).get()) + if (ParseType(sc, dwarf_cu, die, &type_is_new).get()) { if (type_is_new) ++types_added; @@ -3400,7 +3545,7 @@ Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); assert (block != NULL); - variables = block->GetVariableList(false, true); + variables = block->GetVariableList(false, false); if (variables.get() == NULL) { variables.reset(new VariableList()); 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=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Tue Sep 28 20:12:09 2010 @@ -94,6 +94,8 @@ virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc); virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid); + virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_opaque_type); + virtual lldb_private::Type* ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die); virtual clang::DeclContext* GetClangDeclContextForTypeUID (lldb::user_id_t type_uid); @@ -214,7 +216,7 @@ bool parse_siblings, bool parse_children); size_t ParseTypes (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children); - lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new); + lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new); lldb::VariableSP ParseVariableDIE( const lldb_private::SymbolContext& sc, @@ -233,10 +235,9 @@ size_t ParseChildMembers( const lldb_private::SymbolContext& sc, - lldb::TypeSP& type_sp, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, - void *class_clang_type, + lldb::clang_type_t class_clang_type, const lldb::LanguageType class_language, std::vector& base_classes, std::vector& member_accessibilities, @@ -250,13 +251,12 @@ const DWARFDebugInfoEntry *parent_die, bool skip_artificial, lldb_private::TypeList* type_list, - std::vector& function_args, + std::vector& function_args, std::vector& function_param_decls); size_t ParseChildEnumerators( const lldb_private::SymbolContext& sc, - lldb::TypeSP& type_sp, - void *enumerator_qual_type, + lldb::clang_type_t enumerator_qual_type, uint32_t enumerator_byte_size, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *enum_die); @@ -281,10 +281,7 @@ lldb_private::SymbolContextList& sc_list); lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu, - const DWARFDebugInfoEntry* die, - lldb::TypeSP& owning_type_sp, - int32_t child_type, - uint32_t idx); + const DWARFDebugInfoEntry* die); uint32_t FindTypes(std::vector die_offsets, uint32_t max_matches, lldb_private::TypeList& types); @@ -319,12 +316,13 @@ typedef llvm::DenseMap DIEToDeclContextMap; typedef llvm::DenseMap DIEToTypePtr; typedef llvm::DenseMap DIEToVariableSP; - typedef llvm::DenseMap DIEToClangType; + typedef llvm::DenseMap DIEToClangType; + typedef llvm::DenseMap ClangTypeToDIE; DIEToDeclContextMap m_die_to_decl_ctx; DIEToTypePtr m_die_to_type; DIEToVariableSP m_die_to_variable_sp; - DIEToClangType m_die_to_clang_type; - + DIEToClangType m_forward_decl_die_to_clang_type; + ClangTypeToDIE m_forward_decl_clang_type_to_die; }; #endif // liblldb_SymbolFileDWARF_h_ Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Tue Sep 28 20:12:09 2010 @@ -592,6 +592,12 @@ return NULL; } +lldb::clang_type_t +SymbolFileDWARFDebugMap::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type) +{ + // We have a struct/union/class/enum that needs to be fully resolved. + return NULL; +} uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext (const Address& exe_so_addr, uint32_t resolve_scope, SymbolContext& sc) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Tue Sep 28 20:12:09 2010 @@ -59,7 +59,8 @@ virtual size_t ParseTypes (const lldb_private::SymbolContext& sc); virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc); - virtual lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid); + virtual lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid); + virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type); virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc); virtual uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list); virtual uint32_t FindGlobalVariables (const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::VariableList& variables); Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Tue Sep 28 20:12:09 2010 @@ -271,6 +271,11 @@ return NULL; } +lldb::clang_type_t +SymbolFileSymtab::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type) +{ + return NULL; +} uint32_t Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Tue Sep 28 20:12:09 2010 @@ -74,6 +74,9 @@ virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid); + virtual lldb::clang_type_t + ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type); + virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Sep 28 20:12:09 2010 @@ -398,7 +398,7 @@ return false; } -void * +clang_type_t ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (Encoding encoding, uint32_t bit_size) { ASTContext *ast_context = getASTContext(); @@ -408,8 +408,8 @@ return GetBuiltinTypeForEncodingAndBitSize (ast_context, encoding, bit_size); } -void * -ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast_context, Encoding encoding, uint32_t bit_size) +clang_type_t +ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (ASTContext *ast_context, Encoding encoding, uint32_t bit_size) { if (!ast_context) return NULL; @@ -468,7 +468,7 @@ return NULL; } -void * +clang_type_t ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name, uint32_t dw_ate, uint32_t bit_size) { ASTContext *ast_context = getASTContext(); @@ -657,31 +657,31 @@ return NULL; } -void * -ClangASTContext::GetBuiltInType_void(clang::ASTContext *ast_context) +clang_type_t +ClangASTContext::GetBuiltInType_void(ASTContext *ast_context) { return ast_context->VoidTy.getAsOpaquePtr(); } -void * +clang_type_t ClangASTContext::GetBuiltInType_objc_id() { return getASTContext()->getObjCIdType().getAsOpaquePtr(); } -void * +clang_type_t ClangASTContext::GetBuiltInType_objc_Class() { return getASTContext()->getObjCClassType().getAsOpaquePtr(); } -void * +clang_type_t ClangASTContext::GetBuiltInType_objc_selector() { return getASTContext()->getObjCSelType().getAsOpaquePtr(); } -void * +clang_type_t ClangASTContext::GetCStringType (bool is_const) { QualType char_type(getASTContext()->CharTy); @@ -692,14 +692,14 @@ return getASTContext()->getPointerType(char_type).getAsOpaquePtr(); } -void * +clang_type_t ClangASTContext::GetVoidPtrType (bool is_const) { return GetVoidPtrType(getASTContext(), is_const); } -void * -ClangASTContext::GetVoidPtrType (clang::ASTContext *ast_context, bool is_const) +clang_type_t +ClangASTContext::GetVoidPtrType (ASTContext *ast_context, bool is_const) { QualType void_ptr_type(ast_context->VoidPtrTy); @@ -709,10 +709,10 @@ return void_ptr_type.getAsOpaquePtr(); } -void * -ClangASTContext::CopyType(clang::ASTContext *dest_context, - clang::ASTContext *source_context, - void *clang_type) +clang_type_t +ClangASTContext::CopyType (ASTContext *dest_context, + ASTContext *source_context, + clang_type_t clang_type) { Diagnostic diagnostics; FileManager file_manager; @@ -724,9 +724,9 @@ } bool -ClangASTContext::AreTypesSame(clang::ASTContext *ast_context, - void *type1, - void *type2) +ClangASTContext::AreTypesSame(ASTContext *ast_context, + clang_type_t type1, + clang_type_t type2) { return ast_context->hasSameType(QualType::getFromOpaquePtr(type1), QualType::getFromOpaquePtr(type2)); @@ -734,8 +734,8 @@ #pragma mark CVR modifiers -void * -ClangASTContext::AddConstModifier (void *clang_type) +clang_type_t +ClangASTContext::AddConstModifier (clang_type_t clang_type) { if (clang_type) { @@ -746,8 +746,8 @@ return NULL; } -void * -ClangASTContext::AddRestrictModifier (void *clang_type) +clang_type_t +ClangASTContext::AddRestrictModifier (clang_type_t clang_type) { if (clang_type) { @@ -758,8 +758,8 @@ return NULL; } -void * -ClangASTContext::AddVolatileModifier (void *clang_type) +clang_type_t +ClangASTContext::AddVolatileModifier (clang_type_t clang_type) { if (clang_type) { @@ -772,7 +772,7 @@ #pragma mark Structure, Unions, Classes -void * +clang_type_t ClangASTContext::CreateRecordType (const char *name, int kind, DeclContext *decl_ctx, LanguageType language) { ASTContext *ast_context = getASTContext(); @@ -806,10 +806,10 @@ CXXMethodDecl * ClangASTContext::AddMethodToCXXRecordType ( - clang::ASTContext *ast_context, - void *record_opaque_type, + ASTContext *ast_context, + clang_type_t record_opaque_type, const char *name, - void *method_opaque_type, + clang_type_t method_opaque_type, lldb::AccessType access, bool is_virtual, bool is_static, @@ -859,7 +859,7 @@ is_inline); - clang::AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access); + AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access); cxx_method_decl->setAccess (access_specifier); cxx_method_decl->setVirtualAsWritten (is_virtual); @@ -904,10 +904,10 @@ bool ClangASTContext::AddFieldToRecordType ( - clang::ASTContext *ast_context, - void *record_clang_type, + ASTContext *ast_context, + clang_type_t record_clang_type, const char *name, - void *field_type, + clang_type_t field_type, AccessType access, uint32_t bitfield_bit_size ) @@ -1069,7 +1069,7 @@ } void -ClangASTContext::SetDefaultAccessForRecordFields (void *clang_qual_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities) +ClangASTContext::SetDefaultAccessForRecordFields (clang_type_t clang_qual_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities) { if (clang_qual_type) { @@ -1102,7 +1102,7 @@ #pragma mark C++ Base Classes CXXBaseSpecifier * -ClangASTContext::CreateBaseClassSpecifier (void *base_class_type, AccessType access, bool is_virtual, bool base_of_class) +ClangASTContext::CreateBaseClassSpecifier (clang_type_t base_class_type, AccessType access, bool is_virtual, bool base_of_class) { if (base_class_type) return new CXXBaseSpecifier (SourceRange(), @@ -1124,7 +1124,7 @@ } bool -ClangASTContext::SetBaseClassesForClassType (void *class_clang_type, CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes) +ClangASTContext::SetBaseClassesForClassType (clang_type_t class_clang_type, CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes) { if (class_clang_type) { @@ -1188,7 +1188,7 @@ } #pragma mark Objective C Classes -void * +clang_type_t ClangASTContext::CreateObjCClass ( const char *name, @@ -1220,7 +1220,7 @@ } bool -ClangASTContext::SetObjCSuperClass (void *class_opaque_type, void *super_opaque_type) +ClangASTContext::SetObjCSuperClass (clang_type_t class_opaque_type, clang_type_t super_opaque_type) { if (class_opaque_type && super_opaque_type) { @@ -1251,10 +1251,10 @@ bool ClangASTContext::AddObjCClassIVar ( - clang::ASTContext *ast_context, - void *class_opaque_type, + ASTContext *ast_context, + clang_type_t class_opaque_type, const char *name, - void *ivar_opaque_type, + clang_type_t ivar_opaque_type, AccessType access, uint32_t bitfield_bit_size, bool is_synthesized @@ -1311,7 +1311,7 @@ bool -ClangASTContext::ObjCTypeHasIVars (void *class_opaque_type, bool check_superclass) +ClangASTContext::ObjCTypeHasIVars (clang_type_t class_opaque_type, bool check_superclass) { QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type)); @@ -1342,13 +1342,13 @@ return false; } -clang::ObjCMethodDecl * +ObjCMethodDecl * ClangASTContext::AddMethodToObjCObjectType ( - clang::ASTContext *ast_context, - void *class_opaque_type, + ASTContext *ast_context, + clang_type_t class_opaque_type, const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]") - void *method_opaque_type, + clang_type_t method_opaque_type, lldb::AccessType access ) { @@ -1471,7 +1471,7 @@ #pragma mark Aggregate Types bool -ClangASTContext::IsAggregateType (void *clang_type) +ClangASTContext::IsAggregateType (clang_type_t clang_type) { if (clang_type == NULL) return false; @@ -1505,7 +1505,7 @@ } uint32_t -ClangASTContext::GetNumChildren (void *clang_qual_type, bool omit_empty_base_classes) +ClangASTContext::GetNumChildren (clang_type_t clang_qual_type, bool omit_empty_base_classes) { if (clang_qual_type == NULL) return 0; @@ -1642,11 +1642,11 @@ } -void * +clang_type_t ClangASTContext::GetChildClangTypeAtIndex ( const char *parent_name, - void *parent_clang_type, + clang_type_t parent_clang_type, uint32_t idx, bool transparent_pointers, bool omit_empty_base_classes, @@ -1673,12 +1673,12 @@ return NULL; } -void * +clang_type_t ClangASTContext::GetChildClangTypeAtIndex ( ASTContext *ast_context, const char *parent_name, - void *parent_clang_type, + clang_type_t parent_clang_type, uint32_t idx, bool transparent_pointers, bool omit_empty_base_classes, @@ -2186,7 +2186,7 @@ ClangASTContext::GetIndexOfChildMemberWithName ( ASTContext *ast_context, - void *clang_type, + clang_type_t clang_type, const char *name, bool omit_empty_base_classes, std::vector& child_indexes @@ -2464,7 +2464,7 @@ ClangASTContext::GetIndexOfChildWithName ( ASTContext *ast_context, - void *clang_type, + clang_type_t clang_type, const char *name, bool omit_empty_base_classes ) @@ -2668,7 +2668,7 @@ #pragma mark TagType bool -ClangASTContext::SetTagTypeKind (void *tag_clang_type, int kind) +ClangASTContext::SetTagTypeKind (clang_type_t tag_clang_type, int kind) { if (tag_clang_type) { @@ -2695,7 +2695,7 @@ #pragma mark DeclContext Functions DeclContext * -ClangASTContext::GetDeclContextForType (void *clang_type) +ClangASTContext::GetDeclContextForType (clang_type_t clang_type) { if (clang_type == NULL) return NULL; @@ -2756,7 +2756,7 @@ #pragma mark Function Types FunctionDecl * -ClangASTContext::CreateFunctionDeclaration (const char *name, void *function_clang_type, int storage, bool is_inline) +ClangASTContext::CreateFunctionDeclaration (const char *name, clang_type_t function_clang_type, int storage, bool is_inline) { if (name) { @@ -2791,10 +2791,10 @@ return NULL; } -void * -ClangASTContext::CreateFunctionType (clang::ASTContext *ast_context, - void *result_type, - void **args, +clang_type_t +ClangASTContext::CreateFunctionType (ASTContext *ast_context, + clang_type_t result_type, + clang_type_t *args, unsigned num_args, bool is_variadic, unsigned type_quals) @@ -2818,7 +2818,7 @@ } ParmVarDecl * -ClangASTContext::CreateParameterDeclaration (const char *name, void *param_type, int storage) +ClangASTContext::CreateParameterDeclaration (const char *name, clang_type_t param_type, int storage) { ASTContext *ast_context = getASTContext(); assert (ast_context != NULL); @@ -2843,8 +2843,8 @@ #pragma mark Array Types -void * -ClangASTContext::CreateArrayType (void *element_type, size_t element_count, uint32_t bit_stride) +clang_type_t +ClangASTContext::CreateArrayType (clang_type_t element_type, size_t element_count, uint32_t bit_stride) { if (element_type) { @@ -2863,7 +2863,7 @@ #pragma mark TagDecl bool -ClangASTContext::StartTagDeclarationDefinition (void *clang_type) +ClangASTContext::StartTagDeclarationDefinition (clang_type_t clang_type) { if (clang_type) { @@ -2887,7 +2887,7 @@ } bool -ClangASTContext::CompleteTagDeclarationDefinition (void *clang_type) +ClangASTContext::CompleteTagDeclarationDefinition (clang_type_t clang_type) { if (clang_type) { @@ -2913,8 +2913,8 @@ #pragma mark Enumeration Types -void * -ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *name, void *integer_qual_type) +clang_type_t +ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *name, clang_type_t integer_qual_type) { // TODO: Do something intelligent with the Declaration object passed in // like maybe filling in the SourceLocation with it... @@ -2935,11 +2935,29 @@ return NULL; } +clang_type_t +ClangASTContext::GetEnumerationIntegerType (clang_type_t enum_clang_type) +{ + QualType enum_qual_type (QualType::getFromOpaquePtr(enum_clang_type)); + + clang::Type *clang_type = enum_qual_type.getTypePtr(); + if (clang_type) + { + const EnumType *enum_type = dyn_cast(clang_type); + if (enum_type) + { + EnumDecl *enum_decl = enum_type->getDecl(); + if (enum_decl) + return enum_decl->getIntegerType().getAsOpaquePtr(); + } + } + return NULL; +} bool ClangASTContext::AddEnumerationValueToEnumerationType ( - void *enum_clang_type, - void *enumerator_clang_type, + clang_type_t enum_clang_type, + clang_type_t enumerator_clang_type, const Declaration &decl, const char *name, int64_t enum_value, @@ -2988,8 +3006,8 @@ #pragma mark Pointers & References -void * -ClangASTContext::CreatePointerType (void *clang_type) +clang_type_t +ClangASTContext::CreatePointerType (clang_type_t clang_type) { if (clang_type) { @@ -3009,24 +3027,24 @@ return NULL; } -void * -ClangASTContext::CreateLValueReferenceType (void *clang_type) +clang_type_t +ClangASTContext::CreateLValueReferenceType (clang_type_t clang_type) { if (clang_type) return getASTContext()->getLValueReferenceType (QualType::getFromOpaquePtr(clang_type)).getAsOpaquePtr(); return NULL; } -void * -ClangASTContext::CreateRValueReferenceType (void *clang_type) +clang_type_t +ClangASTContext::CreateRValueReferenceType (clang_type_t clang_type) { if (clang_type) return getASTContext()->getRValueReferenceType (QualType::getFromOpaquePtr(clang_type)).getAsOpaquePtr(); return NULL; } -void * -ClangASTContext::CreateMemberPointerType (void *clang_pointee_type, void *clang_class_type) +clang_type_t +ClangASTContext::CreateMemberPointerType (clang_type_t clang_pointee_type, clang_type_t clang_class_type) { if (clang_pointee_type && clang_pointee_type) return getASTContext()->getMemberPointerType(QualType::getFromOpaquePtr(clang_pointee_type), @@ -3042,7 +3060,7 @@ } bool -ClangASTContext::IsPointerOrReferenceType (void *clang_type, void **target_type) +ClangASTContext::IsPointerOrReferenceType (clang_type_t clang_type, clang_type_t*target_type) { if (clang_type == NULL) return false; @@ -3084,7 +3102,7 @@ } bool -ClangASTContext::IsIntegerType (void *clang_type, bool &is_signed) +ClangASTContext::IsIntegerType (clang_type_t clang_type, bool &is_signed) { if (!clang_type) return false; @@ -3104,7 +3122,7 @@ } bool -ClangASTContext::IsPointerType (void *clang_type, void **target_type) +ClangASTContext::IsPointerType (clang_type_t clang_type, clang_type_t*target_type) { if (clang_type) { @@ -3138,7 +3156,7 @@ } bool -ClangASTContext::IsFloatingPointType (void *clang_type, uint32_t &count, bool &is_complex) +ClangASTContext::IsFloatingPointType (clang_type_t clang_type, uint32_t &count, bool &is_complex) { if (clang_type) { @@ -3177,7 +3195,7 @@ } bool -ClangASTContext::IsCXXClassType (void *clang_type) +ClangASTContext::IsCXXClassType (clang_type_t clang_type) { if (clang_type) { @@ -3189,7 +3207,7 @@ } bool -ClangASTContext::IsObjCClassType (void *clang_type) +ClangASTContext::IsObjCClassType (clang_type_t clang_type) { if (clang_type) { @@ -3204,7 +3222,7 @@ bool -ClangASTContext::IsCStringType (void *clang_type, uint32_t &length) +ClangASTContext::IsCStringType (clang_type_t clang_type, uint32_t &length) { if (clang_type) { @@ -3268,7 +3286,7 @@ } bool -ClangASTContext::IsFunctionPointerType (void *clang_type) +ClangASTContext::IsFunctionPointerType (clang_type_t clang_type) { if (clang_type) { @@ -3300,7 +3318,7 @@ bool -ClangASTContext::IsArrayType (void *clang_type, void **member_type, uint64_t *size) +ClangASTContext::IsArrayType (clang_type_t clang_type, clang_type_t*member_type, uint64_t *size) { if (!clang_type) return false; @@ -3340,8 +3358,8 @@ #pragma mark Typedefs -void * -ClangASTContext::CreateTypedefType (const char *name, void *clang_type, DeclContext *decl_ctx) +clang_type_t +ClangASTContext::CreateTypedefType (const char *name, clang_type_t clang_type, DeclContext *decl_ctx) { if (clang_type) { @@ -3366,16 +3384,16 @@ std::string -ClangASTContext::GetTypeName (void *opaque_qual_type) +ClangASTContext::GetTypeName (clang_type_t opaque_qual_type) { std::string return_name; - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_qual_type)); + QualType qual_type(QualType::getFromOpaquePtr(opaque_qual_type)); - const clang::TypedefType *typedef_type = qual_type->getAs(); + const TypedefType *typedef_type = qual_type->getAs(); if (typedef_type) { - const clang::TypedefDecl *typedef_decl = typedef_type->getDecl(); + const TypedefDecl *typedef_decl = typedef_type->getDecl(); return_name = typedef_decl->getQualifiedNameAsString(); } else @@ -3393,7 +3411,7 @@ // so we can support remote targets. The code below also requires a patch to // llvm::APInt. //bool -//ClangASTContext::ConvertFloatValueToString (ASTContext *ast_context, void *clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str) +//ClangASTContext::ConvertFloatValueToString (ASTContext *ast_context, clang_type_t clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str) //{ // uint32_t count = 0; // bool is_complex = false; @@ -3428,7 +3446,7 @@ //} size_t -ClangASTContext::ConvertStringToFloatValue (ASTContext *ast_context, void *clang_type, const char *s, uint8_t *dst, size_t dst_size) +ClangASTContext::ConvertStringToFloatValue (ASTContext *ast_context, clang_type_t clang_type, const char *s, uint8_t *dst, size_t dst_size) { if (clang_type) { @@ -3467,7 +3485,7 @@ } unsigned -ClangASTContext::GetTypeQualifiers(void *clang_type) +ClangASTContext::GetTypeQualifiers(clang_type_t clang_type) { assert (clang_type); Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Tue Sep 28 20:12:09 2010 @@ -804,6 +804,29 @@ return 0; } + +bool +ClangASTType::IsDefined() +{ + return ClangASTType::IsDefined (m_type); +} + + +bool +ClangASTType::IsDefined (void *opaque_clang_qual_type) +{ + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::TagType *tag_type = dyn_cast(qual_type.getTypePtr()); + if (tag_type) + { + clang::TagDecl *tag_decl = tag_type->getDecl(); + if (tag_decl) + return tag_decl->getDefinition() != NULL; + return false; + } + return true; +} + void ClangASTType::DumpTypeDescription (Stream *s) { Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Tue Sep 28 20:12:09 2010 @@ -402,7 +402,7 @@ Type Function::GetReturnType () { - clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetOpaqueClangQualType())); + clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType())); assert (clang_type->isFunctionType()); clang::FunctionType *function_type = dyn_cast (clang_type); clang::QualType fun_return_qualtype = function_type->getResultType(); @@ -421,7 +421,7 @@ int Function::GetArgumentCount () { - clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetOpaqueClangQualType())); + clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType())); assert (clang_type->isFunctionType()); if (!clang_type->isFunctionProtoType()) return -1; @@ -436,7 +436,7 @@ const Type Function::GetArgumentTypeAtIndex (size_t idx) { - clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetOpaqueClangQualType())); + clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType())); assert (clang_type->isFunctionType()); if (!clang_type->isFunctionProtoType()) return Type(); @@ -465,7 +465,7 @@ const char * Function::GetArgumentNameAtIndex (size_t idx) { - clang::Type *clang_type = static_cast(GetType()->GetOpaqueClangQualType())->getTypePtr(); + clang::Type *clang_type = static_cast(GetType()->GetClangType())->getTypePtr(); assert (clang_type->isFunctionType()); if (!clang_type->isFunctionProtoType()) return NULL; @@ -475,7 +475,7 @@ bool Function::IsVariadic () { - const clang::Type *clang_type = static_cast(GetType()->GetOpaqueClangQualType())->getTypePtr(); + const clang::Type *clang_type = static_cast(GetType()->GetClangType())->getTypePtr(); assert (clang_type->isFunctionType()); if (!clang_type->isFunctionProtoType()) return false; Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Tue Sep 28 20:12:09 2010 @@ -26,6 +26,8 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" +using namespace lldb; + lldb_private::Type::Type ( lldb::user_id_t uid, @@ -36,7 +38,7 @@ lldb::user_id_t encoding_uid, EncodingUIDType encoding_uid_type, const Declaration& decl, - void *clang_type + clang_type_t clang_type ) : UserID (uid), m_name (name), @@ -176,7 +178,7 @@ { if (!(m_name)) { - if (ResolveClangType()) + if (ResolveClangType(true)) { std::string type_name = ClangASTContext::GetTypeName (m_clang_qual_type); if (!type_name.empty()) @@ -206,7 +208,7 @@ lldb::Format format ) { - if (ResolveClangType()) + if (ResolveClangType(true)) { if (show_types) { @@ -254,7 +256,7 @@ } if (m_byte_size == 0) { - uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetOpaqueClangQualType()); + uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetClangType()); m_byte_size = (bit_width + 7 ) / 8; } break; @@ -396,7 +398,7 @@ } bool -lldb_private::Type::ResolveClangType() +lldb_private::Type::ResolveClangType (bool forward_decl_is_ok) { if (m_clang_qual_type == NULL) { @@ -410,38 +412,38 @@ switch (m_encoding_uid_type) { case eIsTypeWithUID: - m_clang_qual_type = encoding_type->GetOpaqueClangQualType(); + m_clang_qual_type = encoding_type->GetClangType(); break; case eIsConstTypeWithUID: - m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetOpaqueClangQualType()); + m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangType(forward_decl_is_ok)); break; case eIsRestrictTypeWithUID: - m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetOpaqueClangQualType()); + m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangType(forward_decl_is_ok)); break; case eIsVolatileTypeWithUID: - m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetOpaqueClangQualType()); + m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangType(forward_decl_is_ok)); break; case eTypedefToTypeWithUID: - m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type); + m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type, forward_decl_is_ok); // Clear the name so it can get fully qualified in case the // typedef is in a namespace. m_name.Clear(); break; case ePointerToTypeWithUID: - m_clang_qual_type = type_list->CreateClangPointerType (encoding_type); + m_clang_qual_type = type_list->CreateClangPointerType (encoding_type, forward_decl_is_ok); break; case eLValueReferenceToTypeWithUID: - m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type); + m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type, forward_decl_is_ok); break; case eRValueReferenceToTypeWithUID: - m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type); + m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type, forward_decl_is_ok); break; default: @@ -449,11 +451,14 @@ break; } } + // Return here since we won't need to check if this is a forward + // declaration below since we already obeyed this above. + return m_clang_qual_type != NULL; } else { // We have no encoding type, return void? - void *void_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); + clang_type_t void_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); switch (m_encoding_uid_type) { case eIsTypeWithUID: @@ -494,10 +499,18 @@ } } } + + // Check if we have a forward reference to a class/struct/union/enum? + if (!forward_decl_is_ok && !ClangASTType::IsDefined (m_clang_qual_type)) + { + // We have a forward declaration, we need to resolve it to a complete + // definition. + m_symbol_file->ResolveClangOpaqueTypeDefinition (m_clang_qual_type); + } return m_clang_qual_type != NULL; } -void * +clang_type_t lldb_private::Type::GetChildClangTypeAtIndex ( const char *parent_name, @@ -515,7 +528,7 @@ return NULL; std::string name_str; - void *child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex ( + clang_type_t child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex ( parent_name, m_clang_qual_type, idx, @@ -539,10 +552,10 @@ -void * -lldb_private::Type::GetOpaqueClangQualType () +clang_type_t +lldb_private::Type::GetClangType (bool forward_decl_is_ok) { - ResolveClangType(); + ResolveClangType(forward_decl_is_ok); return m_clang_qual_type; } Modified: lldb/trunk/source/Symbol/TypeList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeList.cpp?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/source/Symbol/TypeList.cpp (original) +++ lldb/trunk/source/Symbol/TypeList.cpp Tue Sep 28 20:12:09 2010 @@ -208,31 +208,31 @@ } void * -TypeList::CreateClangPointerType (Type *type) +TypeList::CreateClangPointerType (Type *type, bool forward_decl_is_ok) { assert(type); - return m_ast.CreatePointerType(type->GetOpaqueClangQualType()); + return m_ast.CreatePointerType(type->GetClangType(forward_decl_is_ok)); } void * -TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type) +TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type, bool forward_decl_is_ok) { assert(typedef_type && base_type); - return m_ast.CreateTypedefType(typedef_type->GetName().AsCString(), base_type->GetOpaqueClangQualType(), typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID())); + return m_ast.CreateTypedefType(typedef_type->GetName().AsCString(), base_type->GetClangType(forward_decl_is_ok), typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID())); } void * -TypeList::CreateClangLValueReferenceType (Type *type) +TypeList::CreateClangLValueReferenceType (Type *type, bool forward_decl_is_ok) { assert(type); - return m_ast.CreateLValueReferenceType(type->GetOpaqueClangQualType()); + return m_ast.CreateLValueReferenceType(type->GetClangType(forward_decl_is_ok)); } void * -TypeList::CreateClangRValueReferenceType (Type *type) +TypeList::CreateClangRValueReferenceType (Type *type, bool forward_decl_is_ok) { assert(type); - return m_ast.CreateRValueReferenceType (type->GetOpaqueClangQualType()); + return m_ast.CreateRValueReferenceType (type->GetClangType(forward_decl_is_ok)); } Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=115012&r1=115011&r2=115012&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Tue Sep 28 20:12:09 2010 @@ -369,7 +369,6 @@ isa = PBXProject; buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "debugserver" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, From gclayton at apple.com Tue Sep 28 20:57:38 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 29 Sep 2010 01:57:38 -0000 Subject: [Lldb-commits] [lldb] r115016 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20100929015738.0F0712A6C12C@llvm.org> Author: gclayton Date: Tue Sep 28 20:57:37 2010 New Revision: 115016 URL: http://llvm.org/viewvc/llvm-project?rev=115016&view=rev Log: Fixed an LLVM/Clang assertion that would happen for C++ and ObjC methods if the DWARF doesn't specify the accessibility for the method. Currently gcc 4.2 and clang++ do not set the accessibility correctly on methods. We currently shouldn't default to private since public methods don't have the accessibility specified. Bottom line: we currently default to public for both C++ and ObjC if the accessibility isn't set. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=115016&r1=115015&r2=115016&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Sep 28 20:57:37 2010 @@ -2694,60 +2694,6 @@ m_forward_decl_clang_type_to_die[clang_type] = die; } -#if 0 - type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); - if (die->HasChildren()) - { - std::vector base_classes; - std::vector member_accessibilities; - bool is_a_class = false; - ParseChildMembers (sc, - dwarf_cu, - die, - clang_type, - class_language, - base_classes, - member_accessibilities, - default_accessibility, - is_a_class); - - // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we - // need to tell the clang type it is actually a class. - if (class_language != eLanguageTypeObjC) - { - if (is_a_class && tag_decl_kind != clang::TTK_Class) - type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class); - } - - // Since DW_TAG_structure_type gets used for both classes - // and structures, we may need to set any DW_TAG_member - // fields to have a "private" access if none was specified. - // When we parsed the child members we tracked that actual - // accessibility value for each DW_TAG_member in the - // "member_accessibilities" array. If the value for the - // member is zero, then it was set to the "default_accessibility" - // which for structs was "public". Below we correct this - // by setting any fields to "private" that weren't correctly - // set. - if (is_a_class && !member_accessibilities.empty()) - { - // This is a class and all members that didn't have - // their access specified are private. - type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size()); - } - - if (!base_classes.empty()) - { - type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size()); - - // Clang will copy each CXXBaseSpecifier in "base_classes" - // so we have to free them all. - ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size()); - } - - } - type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); -#endif // #if 0 } break; @@ -2826,14 +2772,6 @@ m_forward_decl_die_to_clang_type[die] = clang_type; m_forward_decl_clang_type_to_die[clang_type] = die; -#if 0 - if (die->HasChildren()) - { - type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); - ParseChildEnumerators(sc, enumerator_clang_type, byte_size, dwarf_cu, die); - type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); - } -#endif // #if 0 } } break; @@ -2978,6 +2916,11 @@ if (class_opaque_type) { + // If accessibility isn't set to anything valid, assume public for + // now... + if (accessibility == eAccessNone) + accessibility = eAccessPublic; + clang::ObjCMethodDecl *objc_method_decl; objc_method_decl = type_list->GetClangASTContext().AddMethodToObjCObjectType (class_opaque_type, type_name_cstr, @@ -2998,6 +2941,11 @@ clang_type_t class_opaque_type = class_type->GetClangType (true); if (ClangASTContext::IsCXXClassType (class_opaque_type)) { + // Neither GCC 4.2 nor clang++ currently set a valid accessibility + // in the DWARF for C++ methods... Default to public for now... + if (accessibility == eAccessNone) + accessibility = eAccessPublic; + clang::CXXMethodDecl *cxx_method_decl; cxx_method_decl = type_list->GetClangASTContext().AddMethodToCXXRecordType (class_opaque_type, type_name_cstr, From gclayton at apple.com Tue Sep 28 22:44:17 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 29 Sep 2010 03:44:17 -0000 Subject: [Lldb-commits] [lldb] r115023 - in /lldb/trunk: llvm.zip scripts/build-llvm.pl source/Symbol/ClangASTContext.cpp Message-ID: <20100929034417.D302E2A6C12C@llvm.org> Author: gclayton Date: Tue Sep 28 22:44:17 2010 New Revision: 115023 URL: http://llvm.org/viewvc/llvm-project?rev=115023&view=rev Log: Updated LLVM to: --revision '{2010-09-28T19:30}' This gets us the new clang::CXXRecordDecl improvments in clang so that when we add fields, methods and other things to the clang::CXXRecordDecl, the correct bits are automatically set by clang::CXXRecordDecl itself instead of having SEMA and our lldb_private::ClangASTContext functions that create types for DWARF do it all manually. This allows the clang::ASTContext deep copying of types to work correctly and it means that the expression parser can now evaluate expressions in the context of a class method correctly. Previously when a class was copied from the DWARF generated ASTContext over into the expression ASTContext, we were losing CXXRecordDecl bits in the conversion which caused all classes to think they were at offset zero because the the bools for empty, POD, and others would end up being incorrect. Modified: lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=115023&r1=115022&r2=115023&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=115023&r1=115022&r2=115023&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Tue Sep 28 22:44:17 2010 @@ -25,7 +25,7 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "'{2010-09-22T21:20}'"; +our $llvm_revision = "'{2010-09-28T19:30}'"; our $llvm_source_dir = "$ENV{SRCROOT}"; our $cc = "$ENV{DEVELOPER_BIN_DIR}/gcc-4.2"; our $cxx = "$ENV{DEVELOPER_BIN_DIR}/g++-4.2"; Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=115023&r1=115022&r2=115023&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Sep 28 22:44:17 2010 @@ -931,25 +931,6 @@ { RecordDecl *record_decl = record_type->getDecl(); - CXXRecordDecl *cxx_record_decl = dyn_cast(record_decl); - if (cxx_record_decl) - { - // NOTE: we currently have some fixes that should be placed - // into clang that will automatically set if a record is empty - // when each field is added (during the addDecl() method call - // below) so this code should be able to come out when those - // changes make it into llvm/clang, then we can remove this - // code... - // Currently SEMA is using the accessors manually to set - // whether a class is empty, is POD, is aggregate, and more. - // This code will be moved into CXXRecordDecl so everyone - // can benefit. - // This will currently work for everything except zero sized - // bitfields which we currently aren't detecting anyway from the - // DWARF so it should be ok for now. - cxx_record_decl->setEmpty (false); - } - clang::Expr *bit_width = NULL; if (bitfield_bit_size != 0) { @@ -970,24 +951,6 @@ if (field) { record_decl->addDecl(field); - - // NOTE: we currently have some fixes that should be placed - // into clang that will automatically set if a record is POD - // when each field is added (during the addDecl() method call - // above) so this code should be able to come out when those - // changes make it into llvm/clang, then we can remove this - // code... - // Currently SEMA is using the accessors manually to set - // whether a class is empty, is POD, is aggregate, and more. - // This code will be moved into CXXRecordDecl so everyone - // can benefit. - - if (cxx_record_decl->isPOD()) - { - if (!field->getType()->isPODType()) - cxx_record_decl->setPOD (false); - return true; - } } } else @@ -1138,47 +1101,6 @@ if (cxx_record_decl) { cxx_record_decl->setBases(base_classes, num_base_classes); - - // NOTE: we currently have some fixes that should be placed - // into clang that will automatically set these things when - // they are added (during the setBases() method call above) - // so this code should be able to come out when those changes - // make it into llvm/clang, then we can remove this code... - // Currently SEMA is using the accessors manually to set - // whether a class is empty, is POD, is aggregate, and more. - // This code will be moved into CXXRecordDecl so everyone - // can benefit. - if (cxx_record_decl->isEmpty() || cxx_record_decl->isPOD()) - { - // set empty to false if any bases are virtual, or not empty. - - CXXRecordDecl::base_class_const_iterator base_class, base_class_end; - for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end(); - base_class != base_class_end; - ++base_class) - { - if (base_class->isVirtual()) - { - cxx_record_decl->setEmpty (false); - cxx_record_decl->setPOD (false); - break; - } - else - { - QualType base_type (base_class->getType()); - - if (!base_type->isPODType()) - cxx_record_decl->setPOD (false); - - const CXXRecordDecl *base_class_decl = cast(base_type->getAs()->getDecl()); - if (!base_class_decl->isEmpty()) - { - cxx_record_decl->setEmpty (false); - break; - } - } - } - } return true; } } @@ -2892,18 +2814,31 @@ if (clang_type) { QualType qual_type (QualType::getFromOpaquePtr(clang_type)); - clang::Type *t = qual_type.getTypePtr(); - if (t) + + CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + + if (cxx_record_decl) { - TagType *tag_type = dyn_cast(t); - if (tag_type) + cxx_record_decl->completeDefinition(); + + return true; + } + + const EnumType *enum_type = dyn_cast(qual_type.getTypePtr()); + + if (enum_type) + { + EnumDecl *enum_decl = enum_type->getDecl(); + + if (enum_decl) { - TagDecl *tag_decl = tag_type->getDecl(); - if (tag_decl) - { - tag_decl->completeDefinition(); - return true; - } + /// TODO This really needs to be fixed. + + unsigned NumPositiveBits = 1; + unsigned NumNegativeBits = 0; + + enum_decl->completeDefinition(enum_decl->getIntegerType(), enum_decl->getIntegerType(), NumPositiveBits, NumNegativeBits); + return true; } } } From johnny.chen at apple.com Wed Sep 29 12:29:14 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 17:29:14 -0000 Subject: [Lldb-commits] [lldb] r115042 - /lldb/trunk/test/class_types/TestClassTypes.py Message-ID: <20100929172914.0B09C2A6C12C@llvm.org> Author: johnny Date: Wed Sep 29 12:29:13 2010 New Revision: 115042 URL: http://llvm.org/viewvc/llvm-project?rev=115042&view=rev Log: Removed the two @expectedFailure decorators for expression parser, they have been fixed. Also chnaged the expected string for 'frame variable this' from '(class C *const) this =' to 'C *const) this =' for the time being, while investigating the different output for tot r115023. runCmd: frame variable this output: (struct C *const) this = 0x0000000100000c2e Modified: lldb/trunk/test/class_types/TestClassTypes.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115042&r1=115041&r2=115042&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Wed Sep 29 12:29:13 2010 @@ -35,13 +35,11 @@ self.breakpoint_creation_by_filespec_python() @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @unittest2.expectedFailure def test_with_dsym_and_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.buildDsym() self.class_types_expr_parser() - @unittest2.expectedFailure def test_with_dwarf_and_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.buildDwarf() @@ -69,7 +67,7 @@ # We should be stopped on the ctor function of class C. self.expect("frame variable this", VARIABLES_DISPLAYED_CORRECTLY, - startstr = '(class C *const) this = ') + substrs = ['C *const) this = ']) def breakpoint_creation_by_filespec_python(self): """Use Python APIs to create a breakpoint by (filespec, line).""" From johnny.chen at apple.com Wed Sep 29 12:50:35 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 17:50:35 -0000 Subject: [Lldb-commits] [lldb] r115046 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20100929175035.4B8672A6C12C@llvm.org> Author: johnny Date: Wed Sep 29 12:50:35 2010 New Revision: 115046 URL: http://llvm.org/viewvc/llvm-project?rev=115046&view=rev Log: Updated to reflect the updated tot r115023. Will be filing a bug next. Modified: lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=115046&r1=115045&r2=115046&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Wed Sep 29 12:50:35 2010 @@ -96,12 +96,12 @@ # Lookup objc data type MyString and evaluate some expressions. self.expect("image lookup -t NSString", DATA_TYPES_DISPLAYED_CORRECTLY, - substrs = ["@interface NSString : NSObject at end"]) + substrs = ['name = "NSString"', + 'clang_type = "@interface NSString at end"']) self.expect("image lookup -t MyString", DATA_TYPES_DISPLAYED_CORRECTLY, - substrs = ["@interface MyString : NSObject", - "NSString * str;", - "NSDate * date;"]) + substrs = ['name = "MyString"', + 'clang_type = "@interface MyString']) self.expect("frame variable -s", VARIABLES_DISPLAYED_CORRECTLY, substrs = ["ARG: (MyString *) self", From johnny.chen at apple.com Wed Sep 29 12:58:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 17:58:12 -0000 Subject: [Lldb-commits] [lldb] r115050 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20100929175812.8909E2A6C12C@llvm.org> Author: johnny Date: Wed Sep 29 12:58:12 2010 New Revision: 115050 URL: http://llvm.org/viewvc/llvm-project?rev=115050&view=rev Log: Added two @expectedFailure decorators for test_data_type_and_expr_with_dsym() and test_data_type_and_expr_with_dwarf(). rdar://problem/8492646 test/foundation fails after updating to tot r115023: self->str displays nothing as output Modified: lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=115050&r1=115049&r2=115050&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Wed Sep 29 12:58:12 2010 @@ -23,11 +23,15 @@ self.buildDwarf() self.break_on_objc_methods() + @unittest2.expectedFailure + # rdar://problem/8492646 def test_data_type_and_expr_with_dsym(self): """Lookup objective-c data types and evaluate expressions.""" self.buildDsym() self.data_type_and_expr_objc() + @unittest2.expectedFailure + # rdar://problem/8492646 def test_data_type_and_expr_with_dwarf(self): """Lookup objective-c data types and evaluate expressions.""" self.buildDwarf() @@ -110,6 +114,9 @@ self.expect("expr self->non_existent_member", COMMAND_FAILED_AS_EXPECTED, error=True, startstr = "error: 'MyString' does not have a member named 'non_existent_member'") + # rdar://problem/8492646 + # test/foundation fails after updating to tot r115023 + # self->str displays nothing as output self.expect("frame variable self->str", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(NSString *) self->str") From johnny.chen at apple.com Wed Sep 29 13:05:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 18:05:04 -0000 Subject: [Lldb-commits] [lldb] r115052 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20100929180504.0B9392A6C12C@llvm.org> Author: johnny Date: Wed Sep 29 13:05:03 2010 New Revision: 115052 URL: http://llvm.org/viewvc/llvm-project?rev=115052&view=rev Log: Updated the comment section for running 'expr self->string' and 'expr self->date'. The failures are similar in nature to the radar already filed: # rdar://problem/8492646 # test/foundation fails after updating to tot r115023 # self->str displays nothing as output Modified: lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=115052&r1=115051&r2=115052&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Wed Sep 29 13:05:03 2010 @@ -126,12 +126,15 @@ startstr = "(NSDate *) self->date") # TODO: use expression parser. + # self.runCmd("expr self->str") + # self.runCmd("expr self->date") + # (lldb) expr self->str - # error: instance variable 'str' is protected + # error: 'MyString' does not have a member named 'str' # error: 1 errors parsing expression # Couldn't parse the expresssion # (lldb) expr self->date - # error: instance variable 'date' is protected + # error: 'MyString' does not have a member named 'date' # error: 1 errors parsing expression # Couldn't parse the expresssion From johnny.chen at apple.com Wed Sep 29 13:14:50 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 18:14:50 -0000 Subject: [Lldb-commits] [lldb] r115055 - in /lldb/trunk/test/types: TestFloatTypesExpr.py TestIntegerTypesExpr.py Message-ID: <20100929181450.DA4BA2A6C12C@llvm.org> Author: johnny Date: Wed Sep 29 13:14:50 2010 New Revision: 115055 URL: http://llvm.org/viewvc/llvm-project?rev=115055&view=rev Log: Removed the two @skip class decorators. The assert failures have been fixed. Modified: lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=115055&r1=115054&r2=115055&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Wed Sep 29 13:14:50 2010 @@ -6,7 +6,6 @@ import unittest2 import lldb - at unittest2.skip("rdar://problem/8488437 test/types/TestIntegerTypesExpr.py asserts") class FloatTypesTestCase(AbstractBase.GenericTester): mydir = "types" Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=115055&r1=115054&r2=115055&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Wed Sep 29 13:14:50 2010 @@ -6,7 +6,6 @@ import unittest2 import lldb - at unittest2.skip("rdar://problem/8488437 test/types/TestIntegerTypesExpr.py asserts") class IntegerTypesTestCase(AbstractBase.GenericTester): mydir = "types" From ctice at apple.com Wed Sep 29 13:35:42 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 29 Sep 2010 18:35:42 -0000 Subject: [Lldb-commits] [lldb] r115059 - in /lldb/trunk/tools/driver: Driver.cpp Driver.h IOChannel.cpp IOChannel.h Message-ID: <20100929183542.912D92A6C12C@llvm.org> Author: ctice Date: Wed Sep 29 13:35:42 2010 New Revision: 115059 URL: http://llvm.org/viewvc/llvm-project?rev=115059&view=rev Log: Fix various timing/threading problems in IOChannel & Driver that were causing the prompt to be stomped on, mangled or omitted occasionally. Modified: lldb/trunk/tools/driver/Driver.cpp lldb/trunk/tools/driver/Driver.h lldb/trunk/tools/driver/IOChannel.cpp lldb/trunk/tools/driver/IOChannel.h Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=115059&r1=115058&r2=115059&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Wed Sep 29 13:35:42 2010 @@ -625,24 +625,34 @@ return error; } -void +size_t Driver::GetProcessSTDOUT () { // The process has stuff waiting for stdout; get it and write it out to the appropriate place. char stdio_buffer[1024]; size_t len; + size_t total_bytes = 0; while ((len = m_debugger.GetSelectedTarget().GetProcess().GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) + { m_io_channel_ap->OutWrite (stdio_buffer, len); + total_bytes += len; + } + return total_bytes; } -void +size_t Driver::GetProcessSTDERR () { // The process has stuff waiting for stderr; get it and write it out to the appropriate place. char stdio_buffer[1024]; size_t len; + size_t total_bytes = 0; while ((len = m_debugger.GetSelectedTarget().GetProcess().GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) + { m_io_channel_ap->ErrWrite (stdio_buffer, len); + total_bytes += len; + } + return total_bytes; } void @@ -721,20 +731,23 @@ { // The process has stdout available, get it and write it out to the // appropriate place. - GetProcessSTDOUT (); + if (GetProcessSTDOUT ()) + m_io_channel_ap->RefreshPrompt(); } else if (event_type & SBProcess::eBroadcastBitSTDERR) { // The process has stderr available, get it and write it out to the // appropriate place. - GetProcessSTDERR (); + if (GetProcessSTDERR ()) + m_io_channel_ap->RefreshPrompt(); } else if (event_type & SBProcess::eBroadcastBitStateChanged) { // Drain all stout and stderr so we don't see any output come after // we print our prompts - GetProcessSTDOUT (); - GetProcessSTDERR (); + if (GetProcessSTDOUT () + || GetProcessSTDERR ()) + m_io_channel_ap->RefreshPrompt(); // Something changed in the process; get the event and report the process's current status and location to // the user. @@ -766,8 +779,13 @@ break; case eStateExited: - m_debugger.HandleCommand("process status"); - m_io_channel_ap->RefreshPrompt(); + { + SBCommandReturnObject result; + m_debugger.GetCommandInterpreter().HandleCommand("process status", result, false); + m_io_channel_ap->ErrWrite (result.GetError(), result.GetErrorSize()); + m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize()); + m_io_channel_ap->RefreshPrompt(); + } break; case eStateStopped: @@ -781,12 +799,16 @@ int message_len = ::snprintf (message, sizeof(message), "Process %d stopped and was programmatically restarted.\n", process.GetProcessID()); m_io_channel_ap->OutWrite(message, message_len); + m_io_channel_ap->RefreshPrompt (); } else { + SBCommandReturnObject result; UpdateSelectedThread (); - m_debugger.HandleCommand("process status"); - m_io_channel_ap->RefreshPrompt(); + m_debugger.GetCommandInterpreter().HandleCommand("process status", result, false); + m_io_channel_ap->ErrWrite (result.GetError(), result.GetErrorSize()); + m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize()); + m_io_channel_ap->RefreshPrompt (); } break; } Modified: lldb/trunk/tools/driver/Driver.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.h?rev=115059&r1=115058&r2=115059&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.h (original) +++ lldb/trunk/tools/driver/Driver.h Wed Sep 29 13:35:42 2010 @@ -133,10 +133,10 @@ void ResetOptionValues (); - void + size_t GetProcessSTDOUT (); - void + size_t GetProcessSTDERR (); void Modified: lldb/trunk/tools/driver/IOChannel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/IOChannel.cpp?rev=115059&r1=115058&r2=115059&view=diff ============================================================================== --- lldb/trunk/tools/driver/IOChannel.cpp (original) +++ lldb/trunk/tools/driver/IOChannel.cpp Wed Sep 29 13:35:42 2010 @@ -29,6 +29,10 @@ const char *g_default_prompt = "(lldb) "; PromptMap g_prompt_map; +#define NSEC_PER_USEC 1000ull +#define USEC_PER_SEC 1000000ull +#define NSEC_PER_SEC 1000000000ull + static const char* el_prompt(EditLine *el) { @@ -156,6 +160,8 @@ Driver *driver ) : SBBroadcaster ("IOChannel"), + m_output_mutex (), + m_enter_elgets_time (), m_driver (driver), m_read_thread (LLDB_INVALID_HOST_THREAD), m_read_thread_should_exit (false), @@ -187,6 +193,25 @@ ::history (m_history, &m_history_event, H_SETUNIQUE, 1); // Load history HistorySaveLoad (false); + + // Set up mutex to make sure OutErr, OutWrite and RefreshPrompt do not interfere + // with each other when writing. + + int error; + ::pthread_mutexattr_t attr; + error = ::pthread_mutexattr_init (&attr); + assert (error == 0); + error = ::pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); + assert (error == 0); + error = ::pthread_mutex_init (&m_output_mutex, &attr); + assert (error == 0); + error = ::pthread_mutexattr_destroy (&attr); + assert (error == 0); + + // Initialize time that ::el_gets was last called. + + m_enter_elgets_time.tv_sec = 0; + m_enter_elgets_time.tv_usec = 0; } IOChannel::~IOChannel () @@ -205,6 +230,8 @@ ::el_end (m_edit_line); m_edit_line = NULL; } + + ::pthread_mutex_destroy (&m_output_mutex); } void @@ -231,7 +258,23 @@ if (m_edit_line != NULL) { int line_len = 0; + + // Set boolean indicating whether or not el_gets is trying to get input (i.e. whether or not to attempt + // to refresh the prompt after writing data). + SetGettingCommand (true); + + // Get the current time just before calling el_gets; this is used by OutWrite, ErrWrite, and RefreshPrompt + // to make sure they have given el_gets enough time to write the prompt before they attempt to write + // anything. + + ::gettimeofday (&m_enter_elgets_time, NULL); + + // Call el_gets to prompt the user and read the user's input. const char *line = ::el_gets (m_edit_line, &line_len); + + // Re-set the boolean indicating whether or not el_gets is trying to get input. + SetGettingCommand (false); + if (line) { // strip any newlines off the end of the string... @@ -399,6 +442,23 @@ void IOChannel::RefreshPrompt () { + // If we are not in the middle of getting input from the user, there is no need to + // refresh the prompt. + + if (! IsGettingCommand()) + return; + + // Compare the current time versus the last time el_gets was called. If less than + // 10000 microseconds (10000000 nanoseconds) have elapsed, wait 10000 microseconds, to ensure el_gets had time + // to finish writing the prompt before we start writing here. + + if (ElapsedNanoSecondsSinceEnteringElGets() < 10000000) + usleep (10000); + + // Use the mutex to make sure OutWrite, ErrWrite and Refresh prompt do not interfere with + // each other's output. + + IOLocker locker (m_output_mutex); ::el_set (m_edit_line, EL_REFRESH); } @@ -407,7 +467,20 @@ { if (len == 0) return; - ::fwrite (buffer, 1, len, m_out_file); + + // Compare the current time versus the last time el_gets was called. If less than + // 10000 microseconds (10000000 nanoseconds) have elapsed, wait 10000 microseconds, to ensure el_gets had time + // to finish writing the prompt before we start writing here. + + if (ElapsedNanoSecondsSinceEnteringElGets() < 10000000) + usleep (10000); + + { + // Use the mutex to make sure OutWrite, ErrWrite and Refresh prompt do not interfere with + // each other's output. + IOLocker locker (m_output_mutex); + ::fwrite (buffer, 1, len, m_out_file); + } } void @@ -415,7 +488,20 @@ { if (len == 0) return; - ::fwrite (buffer, 1, len, m_err_file); + + // Compare the current time versus the last time el_gets was called. If less than + // 10000 microseconds (10000000 nanoseconds) have elapsed, wait 10000 microseconds, to ensure el_gets had time + // to finish writing the prompt before we start writing here. + + if (ElapsedNanoSecondsSinceEnteringElGets() < 10000000) + usleep (10000); + + { + // Use the mutex to make sure OutWrite, ErrWrite and Refresh prompt do not interfere with + // each other's output. + IOLocker locker (m_output_mutex); + ::fwrite (buffer, 1, len, m_err_file); + } } void @@ -452,3 +538,48 @@ { return m_command_queue.empty(); } + +bool +IOChannel::IsGettingCommand () const +{ + return m_getting_command; +} + +void +IOChannel::SetGettingCommand (bool new_value) +{ + m_getting_command = new_value; +} + +uint64_t +IOChannel::Nanoseconds (const struct timeval &time_val) const +{ + uint64_t nanoseconds = time_val.tv_sec * NSEC_PER_SEC + time_val.tv_usec * NSEC_PER_USEC; + + return nanoseconds; +} + +uint64_t +IOChannel::ElapsedNanoSecondsSinceEnteringElGets () +{ + if (! IsGettingCommand()) + return 0; + + struct timeval current_time; + ::gettimeofday (¤t_time, NULL); + return (Nanoseconds (current_time) - Nanoseconds (m_enter_elgets_time)); +} + +IOLocker::IOLocker (pthread_mutex_t &mutex) : + m_mutex_ptr (&mutex) +{ + if (m_mutex_ptr) + ::pthread_mutex_lock (m_mutex_ptr); + +} + +IOLocker::~IOLocker () +{ + if (m_mutex_ptr) + ::pthread_mutex_unlock (m_mutex_ptr); +} Modified: lldb/trunk/tools/driver/IOChannel.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/IOChannel.h?rev=115059&r1=115058&r2=115059&view=diff ============================================================================== --- lldb/trunk/tools/driver/IOChannel.h (original) +++ lldb/trunk/tools/driver/IOChannel.h Wed Sep 29 13:35:42 2010 @@ -15,6 +15,8 @@ #include #include +#include +#include #include "Driver.h" @@ -89,11 +91,25 @@ static unsigned char ElCompletionFn (EditLine *e, int ch); +protected: + bool IsGettingCommand () const; + void + SetGettingCommand (bool new_value); + + uint64_t + Nanoseconds (const struct timeval &time_val) const; + + uint64_t + ElapsedNanoSecondsSinceEnteringElGets (); + private: + pthread_mutex_t m_output_mutex; + struct timeval m_enter_elgets_time; + Driver *m_driver; lldb::thread_t m_read_thread; bool m_read_thread_should_exit; @@ -114,4 +130,22 @@ HandleCompletion (EditLine *e, int ch); }; +class IOLocker +{ +public: + + IOLocker (pthread_mutex_t &mutex); + + ~IOLocker (); + +protected: + + pthread_mutex_t *m_mutex_ptr; + +private: + + IOLocker (const IOLocker&); + const IOLocker& operator= (const IOLocker&); +}; + #endif // lldb_IOChannel_h_ From johnny.chen at apple.com Wed Sep 29 13:46:14 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 18:46:14 -0000 Subject: [Lldb-commits] [lldb] r115063 - /lldb/trunk/test/types/AbstractBase.py Message-ID: <20100929184614.826A72A6C12C@llvm.org> Author: johnny Date: Wed Sep 29 13:46:14 2010 New Revision: 115063 URL: http://llvm.org/viewvc/llvm-project?rev=115063&view=rev Log: Turn on generic type tester for expression parser; preparing to file bugs. Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=115063&r1=115062&r2=115063&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Wed Sep 29 13:46:14 2010 @@ -124,16 +124,24 @@ # The input type is in a canonical form as a set named atoms. # The display type string must conatin each and every element. - #dt = re.match("^\((.*)\)", output).group(1) + # + # Example: + # runCmd: expr a + # output: $0 = (double) 1100.12 + # + try: + dt = re.match("^\$[0-9]+ = \((.*)\)", output).group(1) + except: + self.fail("Data type from expression parser is parsed correctly") # Expect the display type string to contain each and every atoms. - #self.expect(dt, - # "Display type: '%s' must contain the type atoms: '%s'" % - # (dt, atoms), - # exe=False, - # substrs = list(atoms)) + self.expect(dt, + "Display type: '%s' must contain the type atoms: '%s'" % + (dt, atoms), + exe=False, + substrs = list(atoms)) - # The (var, val) pair must match, too. - #nv = (" %s = '%s'" if quotedDisplay else " %s = %s") % (var, val) - #self.expect(output, Msg(var, val), exe=False, - # substrs = [nv]) + # The val part must match, too. + valPart = ("'%s'" if quotedDisplay else "%s") % val + self.expect(output, Msg(var, val), exe=False, + substrs = [valPart]) From johnny.chen at apple.com Wed Sep 29 14:02:20 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 19:02:20 -0000 Subject: [Lldb-commits] [lldb] r115065 - in /lldb/trunk/test/types: TestFloatTypesExpr.py TestIntegerTypesExpr.py Message-ID: <20100929190220.6C8B42A6C12C@llvm.org> Author: johnny Date: Wed Sep 29 14:02:20 2010 New Revision: 115065 URL: http://llvm.org/viewvc/llvm-project?rev=115065&view=rev Log: Added @expectedFailure decorators for test suite failures: # rdar://problem/8493023 # test/types failures for Test*TypesExpr.py: element offset computed wrong? Modified: lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=115065&r1=115064&r2=115065&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Wed Sep 29 14:02:20 2010 @@ -10,6 +10,9 @@ mydir = "types" + @unittest2.expectedFailure + # rdar://problem/8493023 + # test/types failures for Test*TypesExpr.py: element offset computed wrong? def test_float_types_with_dsym(self): """Test that float-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'float.cpp'} @@ -17,6 +20,7 @@ self.setTearDownCleanup(dictionary=d) self.float_type_expr() + @unittest2.expectedFailure def test_float_type_with_dwarf(self): """Test that float-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'float.cpp'} @@ -24,6 +28,7 @@ self.setTearDownCleanup(dictionary=d) self.float_type_expr() + @unittest2.expectedFailure def test_double_type_with_dsym(self): """Test that double-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'double.cpp'} @@ -31,6 +36,7 @@ self.setTearDownCleanup(dictionary=d) self.double_type_expr() + @unittest2.expectedFailure def test_double_type_with_dwarf(self): """Test that double-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'double.cpp'} Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=115065&r1=115064&r2=115065&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Wed Sep 29 14:02:20 2010 @@ -10,6 +10,9 @@ mydir = "types" + @unittest2.expectedFailure + # rdar://problem/8493023 + # test/types failures for Test*TypesExpr.py: element offset computed wrong? def test_char_type_with_dsym(self): """Test that char-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'char.cpp'} @@ -17,6 +20,7 @@ self.setTearDownCleanup(dictionary=d) self.char_type_expr() + @unittest2.expectedFailure def test_char_type_with_dwarf(self): """Test that char-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'char.cpp'} @@ -24,6 +28,7 @@ self.setTearDownCleanup(dictionary=d) self.char_type_expr() + @unittest2.expectedFailure def test_unsigned_char_type_with_dsym(self): """Test that 'unsigned_char'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_char.cpp'} @@ -31,6 +36,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_char_type_expr() + @unittest2.expectedFailure def test_unsigned_char_type_with_dwarf(self): """Test that 'unsigned char'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_char.cpp'} @@ -38,6 +44,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_char_type_expr() + @unittest2.expectedFailure def test_short_type_with_dsym(self): """Test that short-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'short.cpp'} @@ -45,6 +52,7 @@ self.setTearDownCleanup(dictionary=d) self.short_type_expr() + @unittest2.expectedFailure def test_short_type_with_dwarf(self): """Test that short-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'short.cpp'} @@ -52,6 +60,7 @@ self.setTearDownCleanup(dictionary=d) self.short_type_expr() + @unittest2.expectedFailure def test_unsigned_short_type_with_dsym(self): """Test that 'unsigned_short'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_short.cpp'} @@ -59,6 +68,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_short_type_expr() + @unittest2.expectedFailure def test_unsigned_short_type_with_dwarf(self): """Test that 'unsigned short'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_short.cpp'} @@ -66,6 +76,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_short_type_expr() + @unittest2.expectedFailure def test_int_type_with_dsym(self): """Test that int-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'int.cpp'} @@ -73,6 +84,7 @@ self.setTearDownCleanup(dictionary=d) self.int_type_expr() + @unittest2.expectedFailure def test_int_type_with_dwarf(self): """Test that int-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'int.cpp'} @@ -80,6 +92,7 @@ self.setTearDownCleanup(dictionary=d) self.int_type_expr() + @unittest2.expectedFailure def test_unsigned_int_type_with_dsym(self): """Test that 'unsigned_int'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_int.cpp'} @@ -87,6 +100,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_int_type_expr() + @unittest2.expectedFailure def test_unsigned_int_type_with_dwarf(self): """Test that 'unsigned int'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_int.cpp'} @@ -94,6 +108,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_int_type_expr() + @unittest2.expectedFailure def test_long_type_with_dsym(self): """Test that long-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'long.cpp'} @@ -101,6 +116,7 @@ self.setTearDownCleanup(dictionary=d) self.long_type_expr() + @unittest2.expectedFailure def test_long_type_with_dwarf(self): """Test that long-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'long.cpp'} @@ -108,6 +124,7 @@ self.setTearDownCleanup(dictionary=d) self.long_type_expr() + @unittest2.expectedFailure def test_unsigned_long_type_with_dsym(self): """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_long.cpp'} @@ -115,6 +132,7 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_long_type_expr() + @unittest2.expectedFailure def test_unsigned_long_type_with_dwarf(self): """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_long.cpp'} From johnny.chen at apple.com Wed Sep 29 14:12:10 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 19:12:10 -0000 Subject: [Lldb-commits] [lldb] r115070 - /lldb/trunk/test/types/AbstractBase.py Message-ID: <20100929191210.A63DA2A6C12C@llvm.org> Author: johnny Date: Wed Sep 29 14:12:10 2010 New Revision: 115070 URL: http://llvm.org/viewvc/llvm-project?rev=115070&view=rev Log: Added an example 'frame variable' output to demonstrate how the generic_type_tester groks the data type of the variable. Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=115070&r1=115069&r2=115070&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Wed Sep 29 14:12:10 2010 @@ -72,6 +72,11 @@ # The input type is in a canonical form as a set named atoms. # The display type string must conatin each and every element. + # + # Example: + # runCmd: frame variable a_array_bounded[0] + # output: (char) a_array_bounded[0] = 'a' + # dt = re.match("^\((.*)\)", output).group(1) # Expect the display type string to contain each and every atoms. From johnny.chen at apple.com Wed Sep 29 14:29:42 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 19:29:42 -0000 Subject: [Lldb-commits] [lldb] r115073 - /lldb/trunk/test/types/AbstractBase.py Message-ID: <20100929192942.D88A62A6C12C@llvm.org> Author: johnny Date: Wed Sep 29 14:29:42 2010 New Revision: 115073 URL: http://llvm.org/viewvc/llvm-project?rev=115073&view=rev Log: Wrapped the regexp grokking of data type within a try:expect: instead of letting the Python runtime take over in case there isn't a match. Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=115073&r1=115072&r2=115073&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Wed Sep 29 14:29:42 2010 @@ -77,7 +77,10 @@ # runCmd: frame variable a_array_bounded[0] # output: (char) a_array_bounded[0] = 'a' # - dt = re.match("^\((.*)\)", output).group(1) + try: + dt = re.match("^\((.*)\)", output).group(1) + except: + self.fail("Data type from expression parser is parsed correctly") # Expect the display type string to contain each and every atoms. self.expect(dt, From johnny.chen at apple.com Wed Sep 29 14:36:25 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 19:36:25 -0000 Subject: [Lldb-commits] [lldb] r115075 - /lldb/trunk/test/types/AbstractBase.py Message-ID: <20100929193625.C1DA42A6C12C@llvm.org> Author: johnny Date: Wed Sep 29 14:36:25 2010 New Revision: 115075 URL: http://llvm.org/viewvc/llvm-project?rev=115075&view=rev Log: Simple refactoring. Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=115075&r1=115074&r2=115075&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Wed Sep 29 14:36:25 2010 @@ -16,6 +16,9 @@ # printf() stmts (see basic_type.cpp). pattern = re.compile(" (\*?a[^=]*) = '([^=]*)'$") + # Assert message. + DATA_TYPE_GROKKED = "Data type from expr parser output is parsed correctly" + def generic_type_tester(self, atoms, quotedDisplay=False): """Test that variables with basic types are displayed correctly.""" @@ -80,7 +83,7 @@ try: dt = re.match("^\((.*)\)", output).group(1) except: - self.fail("Data type from expression parser is parsed correctly") + self.fail(self.DATA_TYPE_GROKKED) # Expect the display type string to contain each and every atoms. self.expect(dt, @@ -140,7 +143,7 @@ try: dt = re.match("^\$[0-9]+ = \((.*)\)", output).group(1) except: - self.fail("Data type from expression parser is parsed correctly") + self.fail(self.DATA_TYPE_GROKKED) # Expect the display type string to contain each and every atoms. self.expect(dt, From ctice at apple.com Wed Sep 29 14:42:34 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 29 Sep 2010 19:42:34 -0000 Subject: [Lldb-commits] [lldb] r115077 - in /lldb/trunk/source: Breakpoint/BreakpointIDList.cpp Commands/CommandObjectBreakpoint.cpp Message-ID: <20100929194234.20B4D2A6C12C@llvm.org> Author: ctice Date: Wed Sep 29 14:42:33 2010 New Revision: 115077 URL: http://llvm.org/viewvc/llvm-project?rev=115077&view=rev Log: Fix breakpoint id range testing to disallow ranges that specify breakpoint locations from crossing major breakpoint boundaries (must be within a single breakpoint if specifying locations). Add .* as a means of specifying all the breakpoint locations under a major breakpoint, e.g. "3.*" means "all the breakpoint locations of breakpoint 3". Fix error message to make more sense, if user attempts to specify a breakpoint command when there isn't a target yet. Modified: lldb/trunk/source/Breakpoint/BreakpointIDList.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Modified: lldb/trunk/source/Breakpoint/BreakpointIDList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointIDList.cpp?rev=115077&r1=115076&r2=115077&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointIDList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Wed Sep 29 14:42:33 2010 @@ -195,6 +195,35 @@ is_range = true; i = i+2; } + else + { + // See if user has specified id.* + std::string tmp_str = old_args.GetArgumentAtIndex (i); + size_t pos = tmp_str.find ('.'); + if (pos != std::string::npos) + { + std::string bp_id_str = tmp_str.substr (0, pos); + if (BreakpointID::IsValidIDExpression (bp_id_str.c_str()) + && tmp_str[pos+1] == '*' + && tmp_str.length() == (pos + 2)) + { + break_id_t bp_id; + break_id_t bp_loc_id; + + BreakpointID::ParseCanonicalReference (bp_id_str.c_str(), &bp_id, &bp_loc_id); + BreakpointSP breakpoint_sp = target->GetBreakpointByID (bp_id); + const size_t num_locations = breakpoint_sp->GetNumLocations(); + for (size_t j = 0; j < num_locations; ++j) + { + BreakpointLocation *bp_loc = breakpoint_sp->GetLocationAtIndex(j).get(); + StreamString canonical_id_str; + BreakpointID::GetCanonicalReference (&canonical_id_str, bp_id, bp_loc->GetID()); + new_args.AppendArgument (canonical_id_str.GetData()); + } + } + + } + } if (is_range) { @@ -226,6 +255,25 @@ // We have valid range starting & ending breakpoint IDs. Go through all the breakpoints in the // target and find all the breakpoints that fit into this range, and add them to new_args. + + // Next check to see if we have location id's. If so, make sure the start_bp_id and end_bp_id are + // for the same breakpoint; otherwise we have an illegal range: breakpoint id ranges that specify + // bp locations are NOT allowed to cross major bp id numbers. + + if ((start_loc_id != LLDB_INVALID_BREAK_ID) + || (end_loc_id != LLDB_INVALID_BREAK_ID)) + { + if (start_bp_id != end_bp_id) + { + new_args.Clear(); + result.AppendErrorWithFormat ("Invalid range: Ranges that specify particular breakpoint locations" + " must be within the same major breakpoint; you specified two" + " different major breakpoints, %d and %d.\n", + start_bp_id, end_bp_id); + result.SetStatus (eReturnStatusFailed); + return; + } + } const BreakpointList& breakpoints = target->GetBreakpointList(); const size_t num_breakpoints = breakpoints.GetSize(); @@ -284,7 +332,9 @@ } bool -BreakpointIDList::StringContainsIDRangeExpression (const char *in_string, uint32_t *range_start_len, uint32_t *range_end_pos) +BreakpointIDList::StringContainsIDRangeExpression (const char *in_string, + uint32_t *range_start_len, + uint32_t *range_end_pos) { bool is_range_expression = false; std::string arg_str = in_string; Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=115077&r1=115076&r2=115077&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Wed Sep 29 14:42:33 2010 @@ -275,7 +275,7 @@ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { - result.AppendError ("Invalid target, set executable file using 'file' command."); + result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'file' command)."); result.SetStatus (eReturnStatusFailed); return false; } @@ -709,7 +709,7 @@ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { - result.AppendError ("Invalid target, set executable file using 'file' command."); + result.AppendError ("Invalid target. No current target or breakpoints."); result.SetStatus (eReturnStatusSuccessFinishNoResult); return true; } @@ -800,7 +800,7 @@ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { - result.AppendError ("Invalid target, set executable file using 'file' command."); + result.AppendError ("Invalid target. No existing target or breakpoints."); result.SetStatus (eReturnStatusFailed); return false; } @@ -900,7 +900,7 @@ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { - result.AppendError ("Invalid target, set executable file using 'file' command."); + result.AppendError ("Invalid target. No existing target or breakpoints."); result.SetStatus (eReturnStatusFailed); return false; } @@ -996,7 +996,7 @@ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { - result.AppendError ("Invalid target, set executable file using 'file' command."); + result.AppendError ("Invalid target. No existing target or breakpoints."); result.SetStatus (eReturnStatusFailed); return false; } @@ -1229,7 +1229,7 @@ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { - result.AppendError ("Invalid target, set executable file using 'file' command."); + result.AppendError ("Invalid target. No existing target or breakpoints."); result.SetStatus (eReturnStatusFailed); return false; } From johnny.chen at apple.com Wed Sep 29 16:57:51 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 29 Sep 2010 21:57:51 -0000 Subject: [Lldb-commits] [lldb] r115092 - /lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Message-ID: <20100929215751.AFD662A6C12E@llvm.org> Author: johnny Date: Wed Sep 29 16:57:51 2010 New Revision: 115092 URL: http://llvm.org/viewvc/llvm-project?rev=115092&view=rev Log: Verify that we have a valid breakpoint ID before proceeding with retrieving its number of locations. This fixed a crasher. Modified: lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Modified: lldb/trunk/source/Breakpoint/BreakpointIDList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointIDList.cpp?rev=115092&r1=115091&r2=115092&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointIDList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Wed Sep 29 16:57:51 2010 @@ -212,6 +212,13 @@ BreakpointID::ParseCanonicalReference (bp_id_str.c_str(), &bp_id, &bp_loc_id); BreakpointSP breakpoint_sp = target->GetBreakpointByID (bp_id); + if (! breakpoint_sp) + { + new_args.Clear(); + result.AppendErrorWithFormat ("'%d' is not a valid breakpoint ID.\n", bp_id); + result.SetStatus (eReturnStatusFailed); + return; + } const size_t num_locations = breakpoint_sp->GetNumLocations(); for (size_t j = 0; j < num_locations; ++j) { From jingham at apple.com Wed Sep 29 19:54:27 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 30 Sep 2010 00:54:27 -0000 Subject: [Lldb-commits] [lldb] r115115 - in /lldb/trunk: include/lldb/Expression/ include/lldb/Target/ lldb.xcodeproj/ source/Commands/ source/Expression/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/ source/Target/ Message-ID: <20100930005428.247ED2A6C12E@llvm.org> Author: jingham Date: Wed Sep 29 19:54:27 2010 New Revision: 115115 URL: http://llvm.org/viewvc/llvm-project?rev=115115&view=rev Log: Add "-o" option to "expression" which prints the object description if available. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h lldb/trunk/include/lldb/Target/LanguageRuntime.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h lldb/trunk/source/Expression/ClangExpressionVariable.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h lldb/trunk/source/Target/CPPLanguageRuntime.cpp lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Wed Sep 29 19:54:27 2010 @@ -65,17 +65,22 @@ ClangExpressionVariable(const ClangExpressionVariable &cev); //---------------------------------------------------------------------- - /// If the variable contains its own data, make a Value point at it + /// If the variable contains its own data, make a Value point at it. + /// If \a exe_ctx in not NULL, the value will be resolved in with + /// that execution context. /// /// @param[in] value /// The value to point at the data. /// + /// @param[in] exe_ctx + /// The execution context to use to resolve \a value. + /// /// @return /// True on success; false otherwise (in particular, if this variable /// does not contain its own data). //---------------------------------------------------------------------- bool - PointValueAtData(Value &value); + PointValueAtData(Value &value, ExecutionContext *exe_ctx); //---------------------------------------------------------------------- /// The following values should stay valid for the life of the variable Modified: lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h Wed Sep 29 19:54:27 2010 @@ -39,6 +39,9 @@ virtual bool GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope); + virtual bool + GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope); + protected: //------------------------------------------------------------------ // Classes that inherit from CPPLanguageRuntime can see and modify these Modified: lldb/trunk/include/lldb/Target/LanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/LanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Wed Sep 29 19:54:27 2010 @@ -17,6 +17,8 @@ #include "lldb/lldb-include.h" #include "lldb/Core/PluginInterface.h" #include "lldb/lldb-private.h" +#include "lldb/Core/ValueObject.h" +#include "lldb/Core/Value.h" #include "lldb/Target/ExecutionContextScope.h" namespace lldb_private { @@ -37,6 +39,9 @@ virtual bool GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope) = 0; + virtual bool + GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) = 0; + virtual lldb::ValueObjectSP GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope) = 0; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 29 19:54:27 2010 @@ -2431,7 +2431,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Wed Sep 29 19:54:27 2010 @@ -16,6 +16,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/Value.h" #include "lldb/Core/InputReader.h" +#include "lldb/Core/ValueObjectVariable.h" #include "lldb/Expression/ClangExpressionVariable.h" #include "lldb/Expression/ClangUserExpression.h" #include "lldb/Expression/ClangFunction.h" @@ -24,6 +25,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" #include "lldb/Target/Process.h" @@ -69,6 +71,10 @@ case 'f': error = Args::StringToFormat(option_arg, format); break; + + case 'o': + print_object = true; + break; default: error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); @@ -85,6 +91,7 @@ //language.Clear(); debug = false; format = eFormatDefault; + print_object = false; show_types = true; show_summary = true; } @@ -230,16 +237,36 @@ { StreamString ss; - Error rc = expr_result->Print (ss, - m_exe_ctx, - m_options.format, - m_options.show_types, - m_options.show_summary, - m_options.debug); - - if (rc.Fail()) { - error_stream.Printf ("Couldn't print result : %s\n", rc.AsCString()); - return false; + if (m_options.print_object) + { + Value result_value; + if (expr_result->PointValueAtData(result_value, &m_exe_ctx)) + { + bool obj_result; + ObjCLanguageRuntime *runtime = m_exe_ctx.process->GetObjCLanguageRuntime(); + obj_result = runtime->GetObjectDescription (ss, result_value, m_exe_ctx.GetBestExecutionContextScope()); + if (!obj_result) + { + error_stream.Printf ("Could not get object description: %s.\n", ss.GetData()); + return false; + } + // Sometimes the description doesn't have a newline on the end. For now, I'll just add one here, if + ss.Printf("\n"); + } + } + else + { + Error rc = expr_result->Print (ss, + m_exe_ctx, + m_options.format, + m_options.show_types, + m_options.show_summary, + m_options.debug); + + if (rc.Fail()) { + error_stream.Printf ("Couldn't print result : %s\n", rc.AsCString()); + return false; + } } output_stream.PutCString(ss.GetString().c_str()); @@ -345,7 +372,8 @@ CommandObjectExpression::CommandOptions::g_option_table[] = { //{ LLDB_OPT_SET_ALL, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."}, -{ LLDB_OPT_SET_ALL, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."}, +{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."}, +{ LLDB_OPT_SET_2, false, "object-description", 'o', no_argument, NULL, 0, NULL, "Print the object description of the value resulting from the expression"}, { LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, NULL, "Enable verbose debug logging of the expression parsing and evaluation."}, { LLDB_OPT_SET_ALL, false, "use-ir", 'i', no_argument, NULL, 0, NULL, "[Temporary] Instructs the expression evaluator to use IR instead of ASTs."}, { 0, false, NULL, 0, 0, NULL, NULL, NULL, NULL } Modified: lldb/trunk/source/Commands/CommandObjectExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.h (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.h Wed Sep 29 19:54:27 2010 @@ -50,6 +50,7 @@ lldb::Encoding encoding; lldb::Format format; bool debug; + bool print_object; bool show_types; bool show_summary; }; Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Wed Sep 29 19:54:27 2010 @@ -50,23 +50,14 @@ { Error err; - if (!m_data_vars.get() || !m_data_vars->m_data) + Value val; + if (!PointValueAtData (val, &exe_ctx)) { err.SetErrorToGenericError(); err.SetErrorStringWithFormat("Variable doesn't contain a value"); return err; } - Value val; - - clang::ASTContext *ast_context = m_user_type.GetASTContext(); - - val.SetContext (Value::eContextTypeOpaqueClangQualType, m_user_type.GetOpaqueQualType ()); - val.SetValueType (Value::eValueTypeHostAddress); - val.GetScalar() = (uint64_t)m_data_vars->m_data->GetBytes (); - - val.ResolveValue (&exe_ctx, ast_context); - if (val.GetContextType () == Value::eContextTypeInvalid && val.GetValueType () == Value::eValueTypeScalar && format == lldb::eFormatDefault) @@ -77,6 +68,8 @@ return err; } + clang::ASTContext *ast_context = m_user_type.GetASTContext(); + // The expression result is more complex and requires special handling DataExtractor data; Error expr_error = val.GetValueAsData (&exe_ctx, ast_context, data, 0); @@ -165,14 +158,18 @@ } bool -ClangExpressionVariable::PointValueAtData(Value &value) +ClangExpressionVariable::PointValueAtData(Value &value, ExecutionContext *exe_ctx) { - if (!m_data_vars.get()) + if (!m_data_vars.get() || !m_data_vars->m_data) return false; value.SetContext(Value::eContextTypeOpaqueClangQualType, m_user_type.GetOpaqueQualType()); value.SetValueType(Value::eValueTypeHostAddress); value.GetScalar() = (uint64_t)m_data_vars->m_data->GetBytes(); + clang::ASTContext *ast_context = m_user_type.GetASTContext(); + + if (exe_ctx) + value.ResolveValue (exe_ctx, ast_context); return true; } Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Wed Sep 29 19:54:27 2010 @@ -667,7 +667,8 @@ // Thread we ran the function in may have gone away because we ran the target // Check that it's still there. exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(tid, true).get(); - exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex(0).get(); + if (exe_ctx.thread) + exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex(0).get(); // Also restore the current process'es selected frame & thread, since this function calling may // be done behind the user's back. Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp Wed Sep 29 19:54:27 2010 @@ -10,6 +10,8 @@ #include "AppleObjCRuntimeV2.h" #include "AppleObjCTrampolineHandler.h" +#include "clang/AST/Type.h" + #include "lldb/Core/ConstString.h" #include "lldb/Core/Error.h" #include "lldb/Core/Log.h" @@ -38,6 +40,28 @@ AppleObjCRuntimeV2::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope) { + // ObjC objects can only be pointers: + if (!ClangASTContext::IsPointerType (object.GetClangType())) + return NULL; + + // Make the argument list: we pass one arg, the address of our pointer, to the print function. + Scalar scalar; + + if (!ClangASTType::GetValueAsScalar (object.GetClangAST(), + object.GetClangType(), + object.GetDataExtractor(), + 0, + object.GetByteSize(), + scalar)) + return NULL; + + Value val(scalar); + return GetObjectDescription(str, val, exe_scope); + +} +bool +AppleObjCRuntimeV2::GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) +{ if (!m_read_objc_library) return false; @@ -50,32 +74,41 @@ // We need other parts of the exe_ctx, but the processes have to match. assert (m_process == exe_ctx.process); - // ObjC objects can only be pointers: - if (!ClangASTContext::IsPointerType (object.GetClangType())) - return NULL; - // Get the function address for the print function. const Address *function_address = GetPrintForDebuggerAddr(); if (!function_address) return false; - // Make the argument list: we pass one arg, the address of our pointer, to the print function. - Scalar scalar; - - if (!ClangASTType::GetValueAsScalar (object.GetClangAST(), - object.GetClangType(), - object.GetDataExtractor(), - 0, - object.GetByteSize(), - scalar)) - return NULL; - - Value val(scalar); - val.SetContext(Value::eContextTypeOpaqueClangQualType, - ClangASTContext::GetVoidPtrType(object.GetClangAST(), false)); - + if (value.GetClangType()) + { + clang::QualType value_type = clang::QualType::getFromOpaquePtr (value.GetClangType()); + if (!value_type->isObjCObjectPointerType()) + { + str.Printf ("Value doesn't point to an ObjC object.\n"); + return false; + } + // FIXME: If we use the real types here then we end up crashing in the expression parser. + // For now, forcing this to be a generic pointer makes it work... +#if 1 + ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); + if (value.GetContextType() == Value::eContextTypeOpaqueClangQualType) + { + value.SetContext(Value::eContextTypeOpaqueClangQualType, ast_context->GetVoidPtrType(false)); + } +#endif + } + else + { + // If it is not a pointer, see if we can make it into a pointer. + ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); + void *opaque_type_ptr = ast_context->GetBuiltInType_objc_id(); + if (opaque_type_ptr == NULL) + opaque_type_ptr = ast_context->GetVoidPtrType(false); + value.SetContext(Value::eContextTypeOpaqueClangQualType, opaque_type_ptr); + } + ValueList arg_value_list; - arg_value_list.PushValue(val); + arg_value_list.PushValue(value); // This is the return value: const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString(); Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.h Wed Sep 29 19:54:27 2010 @@ -31,6 +31,9 @@ // These are generic runtime functions: virtual bool + GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope); + + virtual bool GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope); virtual lldb::ValueObjectSP Modified: lldb/trunk/source/Target/CPPLanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/CPPLanguageRuntime.cpp?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/source/Target/CPPLanguageRuntime.cpp (original) +++ lldb/trunk/source/Target/CPPLanguageRuntime.cpp Wed Sep 29 19:54:27 2010 @@ -33,3 +33,10 @@ // C++ has no generic way to do this. return false; } + +bool +CPPLanguageRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) +{ + // C++ has no generic way to do this. + return false; +} Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=115115&r1=115114&r2=115115&view=diff ============================================================================== --- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original) +++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Wed Sep 29 19:54:27 2010 @@ -6,9 +6,12 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +#include "clang/AST/Type.h" #include "lldb/Core/Log.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/ValueObject.h" +#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Target/ObjCLanguageRuntime.h" using namespace lldb; From johnny.chen at apple.com Wed Sep 29 20:22:34 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 01:22:34 -0000 Subject: [Lldb-commits] [lldb] r115125 - /lldb/trunk/test/make/Makefile.rules Message-ID: <20100930012234.826042A6C12E@llvm.org> Author: johnny Date: Wed Sep 29 20:22:34 2010 New Revision: 115125 URL: http://llvm.org/viewvc/llvm-project?rev=115125&view=rev Log: Added a utility function to return the counterpart C++ compiler of $(CC) and use it inside Makefile.rules to return clang++ on clang and llvm-g++ on llvm-gcc. Removed CPLUSPLUSFLAGS which is simply wrong and CPPFLAGS which is unnecessary. Modified: lldb/trunk/test/make/Makefile.rules Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=115125&r1=115124&r2=115125&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Wed Sep 29 20:22:34 2010 @@ -24,14 +24,16 @@ DSFLAGS = CC = gcc CFLAGS ?=-arch $(ARCH) -gdwarf-2 -O0 -CPLUSPLUSFLAGS +=$(CFLAGS) -CPPFLAGS +=$(CFLAGS) +CXXFLAGS +=$(CFLAGS) LD = $(CC) LDFLAGS ?= $(CFLAGS) OBJECTS = EXE = a.out DSYM = $(EXE).dSYM +# Function that returns the counterpart C++ compiler. +cxx_compiler = $(if $(findstring clang,$(1)), clang++, $(if $(findstring llvm-gcc,$(1)), llvm-g++, g++)) + #---------------------------------------------------------------------- # dylib settings #---------------------------------------------------------------------- @@ -52,6 +54,7 @@ #---------------------------------------------------------------------- ifneq "$(strip $(CXX_SOURCES))" "" OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o)) + CXX = $(call cxx_compiler,$(CC)) LD = g++ endif @@ -68,6 +71,7 @@ #---------------------------------------------------------------------- ifneq "$(strip $(OBJCXX_SOURCES))" "" OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o)) + CXX = $(call cxx_compiler,$(CC)) LD = g++ ifeq $(findstring lobjc,$(LDFLAGS)) "" LDFLAGS +=-lobjc From johnny.chen at apple.com Thu Sep 30 11:00:13 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 16:00:13 -0000 Subject: [Lldb-commits] [lldb] r115150 - /lldb/trunk/test/set_values/TestSetValues.py Message-ID: <20100930160013.241082A6C12E@llvm.org> Author: johnny Date: Thu Sep 30 11:00:12 2010 New Revision: 115150 URL: http://llvm.org/viewvc/llvm-project?rev=115150&view=rev Log: Add extra value string to self.expect(). Modified: lldb/trunk/test/set_values/TestSetValues.py Modified: lldb/trunk/test/set_values/TestSetValues.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/set_values/TestSetValues.py?rev=115150&r1=115149&r2=115150&view=diff ============================================================================== --- lldb/trunk/test/set_values/TestSetValues.py (original) +++ lldb/trunk/test/set_values/TestSetValues.py Thu Sep 30 11:00:12 2010 @@ -97,7 +97,7 @@ # rdar://problem/8422727 # set_values test directory: 'frame variable' shows only (long double) i = self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "(long double) i = ") + startstr = "(long double) i = 3.14159") # TODO: # Now set variable 'i' and check that it is correctly displayed. From johnny.chen at apple.com Thu Sep 30 12:06:24 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 17:06:24 -0000 Subject: [Lldb-commits] [lldb] r115166 - /lldb/trunk/test/lldbtest.py Message-ID: <20100930170624.F03142A6C12E@llvm.org> Author: johnny Date: Thu Sep 30 12:06:24 2010 New Revision: 115166 URL: http://llvm.org/viewvc/llvm-project?rev=115166&view=rev Log: These prints should go to stderr as well. Plus add a global assert string. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=115166&r1=115165&r2=115166&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Sep 30 12:06:24 2010 @@ -132,6 +132,8 @@ BREAKPOINT_HIT_ONCE = "Breakpoint resolved with hit cout = 1" +BREAKPOINT_HIT_TWICE = "Breakpoint resolved with hit cout = 2" + STEP_OUT_SUCCEEDED = "Thread step-out succeeded" STOPPED_DUE_TO_BREAKPOINT = "Process state is stopped due to breakpoint" @@ -294,7 +296,7 @@ # See also dotest.py which sets up ${LLDB_TEST}. if ("LLDB_TEST" in os.environ): if traceAlways: - print "Change dir to:", os.path.join(os.environ["LLDB_TEST"], cls.mydir) + print >> sys.stderr, "Change dir to:", os.path.join(os.environ["LLDB_TEST"], cls.mydir) os.chdir(os.path.join(os.environ["LLDB_TEST"], cls.mydir)) @classmethod @@ -309,7 +311,7 @@ # Subclass might have specific cleanup function defined. if getattr(cls, "classCleanup", None): if traceAlways: - print "Call class-specific cleanup function for class:", cls + print >> sys.stderr, "Call class-specific cleanup function for class:", cls try: cls.classCleanup() except: @@ -318,7 +320,7 @@ # Restore old working directory. if traceAlways: - print "Restore dir to:", cls.oldcwd + print >> sys.stderr, "Restore dir to:", cls.oldcwd os.chdir(cls.oldcwd) def setUp(self): @@ -521,7 +523,7 @@ name + "is a method name of object: " + str(obj)) result = method() if trace: - print str(method) + ":", result + print >> sys.stderr, str(method) + ":", result return result def breakAfterLaunch(self, process, func, trace=False): From johnny.chen at apple.com Thu Sep 30 12:06:27 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 17:06:27 -0000 Subject: [Lldb-commits] [lldb] r115167 - /lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Message-ID: <20100930170627.2F3822A6C12F@llvm.org> Author: johnny Date: Thu Sep 30 12:06:27 2010 New Revision: 115167 URL: http://llvm.org/viewvc/llvm-project?rev=115167&view=rev Log: These prints should go to stderr as well. Plus add a global assert string. Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=115167&r1=115166&r2=115167&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Thu Sep 30 12:06:27 2010 @@ -104,7 +104,7 @@ 'stop reason = breakpoint']) # The breakpoint should have a hit count of 2. - self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, + self.expect("breakpoint list", BREAKPOINT_HIT_TWICE, substrs = ['resolved, hit count = 2']) From johnny.chen at apple.com Thu Sep 30 12:11:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 17:11:58 -0000 Subject: [Lldb-commits] [lldb] r115169 - in /lldb/trunk/test: dotest.py make/Makefile.rules plugins/darwin.py Message-ID: <20100930171159.0120D2A6C12E@llvm.org> Author: johnny Date: Thu Sep 30 12:11:58 2010 New Revision: 115169 URL: http://llvm.org/viewvc/llvm-project?rev=115169&view=rev Log: Stop using LLDB_CC/LLDB_ARCH in the plugins for test configurations. Use make friendly CC and ARCH, instead. Modified: lldb/trunk/test/dotest.py lldb/trunk/test/make/Makefile.rules lldb/trunk/test/plugins/darwin.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=115169&r1=115168&r2=115169&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Sep 30 12:11:58 2010 @@ -386,11 +386,11 @@ for ia in range(len(archs) if iterArchs else 1): archConfig = "" if iterArchs: - os.environ["LLDB_ARCH"] = archs[ia] + os.environ["ARCH"] = archs[ia] archConfig = "arch=%s" % archs[ia] for ic in range(len(compilers) if iterCompilers else 1): if iterCompilers: - os.environ["LLDB_CC"] = compilers[ic] + os.environ["CC"] = compilers[ic] configString = "%s compiler=%s" % (archConfig, compilers[ic]) else: configString = archConfig Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=115169&r1=115168&r2=115169&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Thu Sep 30 12:11:58 2010 @@ -22,7 +22,7 @@ #---------------------------------------------------------------------- DS := /usr/bin/dsymutil DSFLAGS = -CC = gcc +CC ?= gcc CFLAGS ?=-arch $(ARCH) -gdwarf-2 -O0 CXXFLAGS +=$(CFLAGS) LD = $(CC) Modified: lldb/trunk/test/plugins/darwin.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/darwin.py?rev=115169&r1=115168&r2=115169&view=diff ============================================================================== --- lldb/trunk/test/plugins/darwin.py (original) +++ lldb/trunk/test/plugins/darwin.py Thu Sep 30 12:11:58 2010 @@ -23,8 +23,8 @@ used for the make system. """ arch = architecture if architecture else None - if not arch and "LLDB_ARCH" in os.environ: - arch = os.environ["LLDB_ARCH"] + if not arch and "ARCH" in os.environ: + arch = os.environ["ARCH"] # Note the leading space character. return (" ARCH=" + arch) if arch else "" @@ -35,8 +35,8 @@ used for the make system. """ cc = compiler if compiler else None - if not cc and "LLDB_CC" in os.environ: - cc = os.environ["LLDB_CC"] + if not cc and "CC" in os.environ: + cc = os.environ["CC"] # Note the leading space character. return (" CC=" + cc) if cc else "" From johnny.chen at apple.com Thu Sep 30 13:02:47 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 18:02:47 -0000 Subject: [Lldb-commits] [lldb] r115182 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20100930180247.AE78D2A6C12E@llvm.org> Author: johnny Date: Thu Sep 30 13:02:47 2010 New Revision: 115182 URL: http://llvm.org/viewvc/llvm-project?rev=115182&view=rev Log: Test new feature with r115115: Add "-o" option to "expression" which prints the object description if available. Modified: lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=115182&r1=115181&r2=115182&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Thu Sep 30 13:02:47 2010 @@ -111,6 +111,12 @@ substrs = ["ARG: (MyString *) self", "ARG: (struct objc_selector *) _cmd"]) + # Test new feature with r115115: + # Add "-o" option to "expression" which prints the object description if available. + self.expect("expr -o -- self", "Object description displayed correctly", + startstr = "Hello from ", + substrs = ["a.out", "with timestamp: "]) + self.expect("expr self->non_existent_member", COMMAND_FAILED_AS_EXPECTED, error=True, startstr = "error: 'MyString' does not have a member named 'non_existent_member'") From gclayton at apple.com Thu Sep 30 13:10:44 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 30 Sep 2010 18:10:44 -0000 Subject: [Lldb-commits] [lldb] r115184 - in /lldb/trunk/tools/debugserver/source/MacOSX: MachTask.cpp MachTask.h Message-ID: <20100930181044.AC7A42A6C12E@llvm.org> Author: gclayton Date: Thu Sep 30 13:10:44 2010 New Revision: 115184 URL: http://llvm.org/viewvc/llvm-project?rev=115184&view=rev Log: Retry task_for_pid a few times to avoid some cases where task_for_pid fails. Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp?rev=115184&r1=115183&r2=115184&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp Thu Sep 30 13:10:44 2010 @@ -214,29 +214,40 @@ // MachTask::TaskPortForProcessID //---------------------------------------------------------------------- task_t -MachTask::TaskPortForProcessID (pid_t pid, DNBError &err) +MachTask::TaskPortForProcessID (pid_t pid, DNBError &err, uint32_t num_retries, uint32_t usec_interval) { - task_t task = TASK_NULL; - if (pid != INVALID_NUB_PROCESS) - { - mach_port_t task_self = mach_task_self (); - err = ::task_for_pid ( task_self, pid, &task); - if (DNBLogCheckLogBit(LOG_TASK) || err.Fail()) - { - char str[1024]; - ::snprintf (str, - sizeof(str), - "::task_for_pid ( target_tport = 0x%4.4x, pid = %d, &task ) => err = 0x%8.8x (%s)", - task_self, - pid, - err.Error(), - err.AsString() ? err.AsString() : "success"); - if (err.Fail()) - err.SetErrorString(str); - err.LogThreaded(str); - } - } - return task; + if (pid != INVALID_NUB_PROCESS) + { + DNBError err; + mach_port_t task_self = mach_task_self (); + task_t task = TASK_NULL; + for (uint32_t i=0; i err = 0x%8.8x (%s)", + task_self, + pid, + err.Error(), + err.AsString() ? err.AsString() : "success"); + if (err.Fail()) + err.SetErrorString(str); + err.LogThreaded(str); + } + + if (err.Success()) + return task; + + // Sleep a bit and try again + ::usleep (usec_interval); + } + } + return TASK_NULL; } Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h?rev=115184&r1=115183&r2=115184&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h Thu Sep 30 13:10:44 2010 @@ -66,7 +66,7 @@ static void * ExceptionThread (void *arg); task_t TaskPort () const { return m_task; } task_t TaskPortForProcessID (DNBError &err); - static task_t TaskPortForProcessID (pid_t pid, DNBError &err); + static task_t TaskPortForProcessID (pid_t pid, DNBError &err, uint32_t num_retries = 10, uint32_t usec_interval = 10000); MachProcess * Process () { return m_process; } const MachProcess * Process () const { return m_process; } From johnny.chen at apple.com Thu Sep 30 13:16:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 18:16:58 -0000 Subject: [Lldb-commits] [lldb] r115185 - /lldb/trunk/source/Commands/CommandObjectExpression.cpp Message-ID: <20100930181658.D2AE82A6C12E@llvm.org> Author: johnny Date: Thu Sep 30 13:16:58 2010 New Revision: 115185 URL: http://llvm.org/viewvc/llvm-project?rev=115185&view=rev Log: Fixed 'expr' help message. Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=115185&r1=115184&r2=115185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Sep 30 13:16:58 2010 @@ -105,7 +105,7 @@ CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interpreter) : CommandObject (interpreter, "expression", - "Evaluate an Objective-C++ expression in the current program context, using variables currently in scope.", + "Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope.", "expression [] "), m_expr_line_count (0), m_expr_lines () From johnny.chen at apple.com Thu Sep 30 13:30:25 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 18:30:25 -0000 Subject: [Lldb-commits] [lldb] r115186 - /lldb/trunk/source/Commands/CommandObjectExpression.cpp Message-ID: <20100930183025.7A3AE2A6C12E@llvm.org> Author: johnny Date: Thu Sep 30 13:30:25 2010 New Revision: 115186 URL: http://llvm.org/viewvc/llvm-project?rev=115186&view=rev Log: Fixed indentation. Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=115186&r1=115185&r2=115186&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Sep 30 13:30:25 2010 @@ -107,7 +107,7 @@ "expression", "Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope.", "expression [] "), -m_expr_line_count (0), + m_expr_line_count (0), m_expr_lines () { SetHelpLong( From johnny.chen at apple.com Thu Sep 30 15:46:47 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 20:46:47 -0000 Subject: [Lldb-commits] [lldb] r115202 - in /lldb/trunk/test/breakpoint_locations: ./ Makefile TestBreakpointLocations.py main.c Message-ID: <20100930204647.6B6D82A6C12E@llvm.org> Author: johnny Date: Thu Sep 30 15:46:47 2010 New Revision: 115202 URL: http://llvm.org/viewvc/llvm-project?rev=115202&view=rev Log: Add a more complex test scenario for breakpoint locations, with breakpoint enable/disable. Added: lldb/trunk/test/breakpoint_locations/ lldb/trunk/test/breakpoint_locations/Makefile lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py lldb/trunk/test/breakpoint_locations/main.c Added: lldb/trunk/test/breakpoint_locations/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_locations/Makefile?rev=115202&view=auto ============================================================================== --- lldb/trunk/test/breakpoint_locations/Makefile (added) +++ lldb/trunk/test/breakpoint_locations/Makefile Thu Sep 30 15:46:47 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py?rev=115202&view=auto ============================================================================== --- lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py (added) +++ lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py Thu Sep 30 15:46:47 2010 @@ -0,0 +1,90 @@ +""" +Test breakpoint commands for a breakpoint ID with multiple locations. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class BreakpointLocationsTestCase(TestBase): + + mydir = "breakpoint_locations" + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym(self): + """Test breakpoint enable/disable for a breakpoint ID with multiple locations.""" + self.buildDsym() + self.breakpoint_locations_test() + + def test_with_dwarf(self): + """Test breakpoint enable/disable for a breakpoint ID with multiple locations.""" + self.buildDwarf() + self.breakpoint_locations_test() + + def breakpoint_locations_test(self): + """Test breakpoint enable/disable for a breakpoint ID with multiple locations.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # This should create a breakpoint with 3 locations. + self.expect("breakpoint set -f main.c -l 19", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.c', line = 19, locations = 3") + + # The breakpoint list should show 3 locations. + self.expect("breakpoint list", "Breakpoint locations shown correctly", + substrs = ["1: file ='main.c', line = 19, locations = 3"], + patterns = ["1\.1: where = a.out`func_inlined .+unresolved, hit count = 0", + "1\.2: where = a.out`main .+\[inlined\].+unresolved, hit count = 0", + "1\.3: where = a.out`main .+\[inlined\].+unresolved, hit count = 0"]) + + # The 'breakpoint disable 3.*' command should fail gracefully. + self.expect("breakpoint disable 3.*", + "Disabling an invalid breakpoint should fail gracefully", + error=True, + startstr = "error: '3' is not a valid breakpoint ID.") + + # The 'breakpoint disable 1.*' command should disable all 3 locations. + self.expect("breakpoint disable 1.*", "All 3 breakpoint locatons disabled correctly", + startstr = "3 breakpoints disabled.") + + # Run the program. + self.runCmd("run", RUN_SUCCEEDED) + + # We should not stopped on any breakpoint at all. + self.expect("process status", "No stopping on any disabled breakpoint", + patterns = ["^Process [0-9]+ exited with status = 0"]) + + # The 'breakpoint enable 1.*' command should enable all 3 breakpoints. + self.expect("breakpoint enable 1.*", "All 3 breakpoint locatons enabled correctly", + startstr = "3 breakpoints enabled.") + + # The 'breakpoint disable 1.1' command should disable 1 location. + self.expect("breakpoint disable 1.1", "1 breakpoint locatons disabled correctly", + startstr = "1 breakpoints disabled.") + + # Run the program againt. We should stop on the two breakpoint locations. + self.runCmd("run", RUN_SUCCEEDED) + + self.expect("thread backtrace", "Stopped on an inlined location", + substrs = ["stop reason = breakpoint 1.2"], + patterns = ["frame #0: .+\[inlined\]"]) + + self.runCmd("process continue") + + self.expect("thread backtrace", "Stopped on an inlined location", + substrs = ["stop reason = breakpoint 1.3"], + patterns = ["frame #0: .+\[inlined\]"]) + + # At this point, the 3 locations should all have "hit count = 2". + self.expect("breakpoint list", "Expect all 3 breakpoints with hit count of 2", + patterns = ["1\.1: where = a.out`func_inlined .+ resolved, hit count = 2 +Options: disabled", + "1\.2: where = a.out`main .+\[inlined\].+ resolved, hit count = 2", + "1\.3: where = a.out`main .+\[inlined\].+ resolved, hit count = 2"]) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/breakpoint_locations/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_locations/main.c?rev=115202&view=auto ============================================================================== --- lldb/trunk/test/breakpoint_locations/main.c (added) +++ lldb/trunk/test/breakpoint_locations/main.c Thu Sep 30 15:46:47 2010 @@ -0,0 +1,41 @@ +#include + +#define INLINE_ME __inline__ __attribute__((always_inline)) + +int +func_not_inlined (void) +{ + printf ("Called func_not_inlined.\n"); + return 0; +} + +INLINE_ME int +func_inlined (void) +{ + static int func_inline_call_count = 0; + printf ("Called func_inlined.\n"); + ++func_inline_call_count; + printf ("Returning func_inlined call count: %d.\n", func_inline_call_count); + return func_inline_call_count; +} + +int +main (int argc, char **argv) +{ + printf ("Starting...\n"); + + int (*func_ptr) (void); + func_ptr = func_inlined; + + int a = func_inlined(); + printf("First call to func_inlined() returns: %d.\n", a); + + func_not_inlined (); + + func_ptr (); + + printf("Last call to func_inlined() returns: %d.\n", func_inlined ()); + return 0; +} + + From scallanan at apple.com Thu Sep 30 16:18:25 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 30 Sep 2010 21:18:25 -0000 Subject: [Lldb-commits] [lldb] r115208 - in /lldb/trunk: include/lldb/Expression/IRForTarget.h source/Expression/ClangExpressionParser.cpp source/Expression/IRForTarget.cpp Message-ID: <20100930211825.BE65E2A6C12E@llvm.org> Author: spyffe Date: Thu Sep 30 16:18:25 2010 New Revision: 115208 URL: http://llvm.org/viewvc/llvm-project?rev=115208&view=rev Log: Switched the expression parser from using TargetData to using Clang to get type sizes. This fixes a bug where the type size for a double[2] was being wrongly reported as 8 instead of 16 bytes, causing problems for IRForTarget. Also improved logging so that the next bug in this area will be easier to find. Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRForTarget.h?rev=115208&r1=115207&r2=115208&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/IRForTarget.h (original) +++ lldb/trunk/include/lldb/Expression/IRForTarget.h Thu Sep 30 16:18:25 2010 @@ -19,7 +19,6 @@ class Function; class Instruction; class Module; - class TargetData; class Value; } @@ -52,11 +51,6 @@ /// for use in looking up globals and allocating the argument /// struct. See the documentation for ClangExpressionDeclMap. /// - /// @param[in] target_data - /// The data layout information for the target. This information is - /// used to determine the sizes of types that have been lowered into - /// IR types. - /// /// @param[in] func_name /// The name of the function to prepare for execution in the target. /// @@ -66,7 +60,6 @@ /// are resolved. //------------------------------------------------------------------ IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map, - const llvm::TargetData *target_data, bool resolve_vars, const char* func_name = "___clang_expr"); @@ -305,7 +298,6 @@ std::string m_func_name; ///< The name of the function to translate lldb_private::ClangExpressionDeclMap *m_decl_map; ///< The DeclMap containing the Decls - const llvm::TargetData *m_target_data; ///< The TargetData for use in determining type sizes llvm::Constant *m_sel_registerName; ///< The address of the function sel_registerName, cast to the appropriate function pointer type }; Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=115208&r1=115207&r2=115208&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Thu Sep 30 16:18:25 2010 @@ -436,21 +436,7 @@ if (decl_map) { - std::string target_error; - - const llvm::Target *target = llvm::TargetRegistry::lookupTarget(m_target_triple, target_error); - - if (!target) - { - err.SetErrorToGenericError(); - err.SetErrorStringWithFormat("Couldn't find a target for %s", m_target_triple.c_str()); - return err; - } - - std::auto_ptr target_machine(target->createTargetMachine(m_target_triple, "")); - IRForTarget ir_for_target(decl_map, - target_machine->getTargetData(), m_expr.NeedsVariableResolution(), function_name.c_str()); Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=115208&r1=115207&r2=115208&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Thu Sep 30 16:18:25 2010 @@ -32,22 +32,20 @@ static char ID; IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map, - const TargetData *target_data, bool resolve_vars, const char *func_name) : ModulePass(ID), m_decl_map(decl_map), - m_target_data(target_data), m_sel_registerName(NULL), m_func_name(func_name), m_resolve_vars(resolve_vars) { } -/* A handy utility function used at several places in the code */ +/* Handy utility functions used at several places in the code */ static std::string -PrintValue(Value *V, bool truncate = false) +PrintValue(const Value *V, bool truncate = false) { std::string s; raw_string_ostream rso(s); @@ -58,6 +56,18 @@ return s; } +static std::string +PrintType(const Type *T, bool truncate = false) +{ + std::string s; + raw_string_ostream rso(s); + T->print(rso); + rso.flush(); + if (truncate) + s.resize(s.length() - 1); + return s; +} + IRForTarget::~IRForTarget() { } @@ -578,23 +588,34 @@ std::string name = named_decl->getName().str(); - void *qual_type = NULL; + void *opaque_type = NULL; clang::ASTContext *ast_context = NULL; if (clang::ValueDecl *value_decl = dyn_cast(named_decl)) { - qual_type = value_decl->getType().getAsOpaquePtr(); + opaque_type = value_decl->getType().getAsOpaquePtr(); ast_context = &value_decl->getASTContext(); } else { return false; } + + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_type)); const Type *value_type = global_variable->getType(); - - size_t value_size = m_target_data->getTypeStoreSize(value_type); - off_t value_alignment = m_target_data->getPrefTypeAlignment(value_type); + + size_t value_size = (ast_context->getTypeSize(qual_type) + 7) / 8; + off_t value_alignment = (ast_context->getTypeAlign(qual_type) + 7) / 8; + + if (log) + log->Printf("Type of %s is [clang %s, lldb %s] [size %d, align %d]", + name.c_str(), + qual_type.getAsString().c_str(), + PrintType(value_type).c_str(), + value_size, + value_alignment); + if (named_decl && !m_decl_map->AddValueToStruct(named_decl, name.c_str(), @@ -1103,6 +1124,13 @@ return false; } + /////////////////////////////// + // Run function-level passes + // + + if (!replaceVariables(M, *function)) + return false; + if (log) { std::string s; @@ -1115,13 +1143,6 @@ log->Printf("Module after preparing for execution: \n%s", s.c_str()); } - /////////////////////////////// - // Run function-level passes - // - - if (!replaceVariables(M, *function)) - return false; - return true; } From jingham at apple.com Thu Sep 30 16:21:43 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 30 Sep 2010 21:21:43 -0000 Subject: [Lldb-commits] [lldb] r115210 - /lldb/trunk/source/API/SBTarget.cpp Message-ID: <20100930212143.83EB22A6C12E@llvm.org> Author: jingham Date: Thu Sep 30 16:21:43 2010 New Revision: 115210 URL: http://llvm.org/viewvc/llvm-project?rev=115210&view=rev Log: Change how we call Target::CreateBreakpoint to account for the new "name type" parameter. Modified: lldb/trunk/source/API/SBTarget.cpp Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115210&r1=115209&r2=115210&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Thu Sep 30 16:21:43 2010 @@ -225,11 +225,11 @@ if (module_name && module_name[0]) { FileSpec module_file_spec(module_name); - *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, symbol_name, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); } else { - *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, symbol_name, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); } } return sb_bp; From gclayton at apple.com Thu Sep 30 16:49:04 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 30 Sep 2010 21:49:04 -0000 Subject: [Lldb-commits] [lldb] r115213 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Host/Host.h include/lldb/Symbol/Type.h lldb.xcodeproj/project.pbxproj source/Core/Debugger.cpp source/Host/macosx/Host.mm source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/Function.cpp source/Symbol/Type.cpp tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20100930214904.2AE1D2A6C12E@llvm.org> Author: gclayton Date: Thu Sep 30 16:49:03 2010 New Revision: 115213 URL: http://llvm.org/viewvc/llvm-project?rev=115213&view=rev Log: Cleaned up a unused member variable in Debugger. Added the start of Host specific launch services, though it currently isn't hookup up to anything. We want to be able to launch a process and use the native launch services to launch an app like it would be launched by the user double clicking on the app. We also eventually want to be able to run a command line app in a newly spawned terminal to avoid terminal sharing. Fixed an issue with the new DWARF forward type declaration stuff. A crasher was found that was happening when trying to properly expand the forward declarations. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Thu Sep 30 16:49:03 2010 @@ -333,7 +333,6 @@ std::stack m_input_readers; std::string m_input_reader_data; - bool m_use_external_editor; // FIXME: Convert this to a set/show variable on the debugger. private: Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Thu Sep 30 16:49:03 2010 @@ -268,8 +268,11 @@ static ArchSpec GetArchSpecForExistingProcess (const char *process_name); + static lldb::pid_t + LaunchApplication (const FileSpec &file_spec); + static bool - OpenFileInExternalEditor (FileSpec &file_spec, uint32_t line_no); + OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no); }; Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Thu Sep 30 16:49:03 2010 @@ -23,27 +23,29 @@ public: typedef enum { - eTypeInvalid, - eIsTypeWithUID, ///< This type is the type whose UID is m_encoding_uid - eIsConstTypeWithUID, ///< This type is the type whose UID is m_encoding_uid with the const qualifier added - eIsRestrictTypeWithUID, ///< This type is the type whose UID is m_encoding_uid with the restrict qualifier added - eIsVolatileTypeWithUID, ///< This type is the type whose UID is m_encoding_uid with the volatile qualifier added - eTypedefToTypeWithUID, ///< This type is pointer to a type whose UID is m_encoding_uid - ePointerToTypeWithUID, ///< This type is pointer to a type whose UID is m_encoding_uid - eLValueReferenceToTypeWithUID, ///< This type is L value reference to a type whose UID is m_encoding_uid - eRValueReferenceToTypeWithUID, ///< This type is R value reference to a type whose UID is m_encoding_uid - eTypeUIDSynthetic - } EncodingUIDType; + eEncodingInvalid, + eEncodingIsUID, ///< This type is the type whose UID is m_encoding_uid + eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid with the const qualifier added + eEncodingIsRestrictUID, ///< This type is the type whose UID is m_encoding_uid with the restrict qualifier added + eEncodingIsVolatileUID, ///< This type is the type whose UID is m_encoding_uid with the volatile qualifier added + eEncodingIsTypedefUID, ///< This type is pointer to a type whose UID is m_encoding_uid + eEncodingIsPointerUID, ///< This type is pointer to a type whose UID is m_encoding_uid + eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type whose UID is m_encoding_uid + eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type whose UID is m_encoding_uid + eEncodingIsSyntheticUID, + eEncodingIsTypePtr ///< m_encoding_data is a "lldb_private::Type *" + } EncodingDataType; Type (lldb::user_id_t uid, SymbolFile* symbol_file, const ConstString &name, - uint64_t byte_size, + uint32_t byte_size, SymbolContextScope *context, - lldb::user_id_t encoding_uid, - EncodingUIDType encoding_type, + uintptr_t encoding_uid, + EncodingDataType encoding_type, const Declaration& decl, - lldb::clang_type_t clang_qual_type); + lldb::clang_type_t clang_qual_type, + bool is_forward_decl); // This makes an invalid type. Used for functions that return a Type when they // get an error. @@ -91,7 +93,7 @@ bool IsValidType () { - return m_encoding_uid_type != eTypeInvalid; + return m_encoding_data_type != eEncodingInvalid; } void @@ -196,14 +198,22 @@ protected: ConstString m_name; - uint64_t m_byte_size; SymbolFile *m_symbol_file; SymbolContextScope *m_context; // The symbol context in which this type is defined - lldb::user_id_t m_encoding_uid; - EncodingUIDType m_encoding_uid_type; + uint64_t m_byte_size; + EncodingDataType m_encoding_data_type; + uintptr_t m_encoding_data; Declaration m_decl; lldb::clang_type_t m_clang_qual_type; + bool m_is_forward_decl; + Type * + GetEncodingType () + { + if (m_encoding_data_type == eEncodingIsTypePtr) + return (Type *)m_encoding_data; + return NULL; + } bool ResolveClangType(bool forward_decl_is_ok = false); }; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Sep 30 16:49:03 2010 @@ -2431,6 +2431,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Sep 30 16:49:03 2010 @@ -155,8 +155,7 @@ m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)), m_exe_ctx (), m_input_readers (), - m_input_reader_data (), - m_use_external_editor(false) + m_input_reader_data () { m_command_interpreter_ap->Initialize (); } Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Thu Sep 30 16:49:03 2010 @@ -12,11 +12,13 @@ #include "lldb/Core/Log.h" #include "cfcpp/CFCBundle.h" +#include "cfcpp/CFCMutableDictionary.h" #include "cfcpp/CFCReleaser.h" #include "cfcpp/CFCString.h" #include +#include #include #include @@ -112,8 +114,44 @@ return false; } +lldb::pid_t +Host::LaunchApplication (const FileSpec &app_file_spec) +{ + char app_path[PATH_MAX]; + app_file_spec.GetPath(app_path, sizeof(app_path)); + + LSApplicationParameters app_params; + ::bzero (&app_params, sizeof (app_params)); + app_params.flags = kLSLaunchDefaults | + kLSLaunchDontAddToRecents | + kLSLaunchDontSwitch | + kLSLaunchNewInstance;// | 0x00001000; + + FSRef app_fsref; + CFCString app_cfstr (app_path, kCFStringEncodingUTF8); + + OSStatus error = ::FSPathMakeRef ((const UInt8 *)app_path, &app_fsref, false); + + // If we found the app, then store away the name so we don't have to re-look it up. + if (error != noErr) + return LLDB_INVALID_PROCESS_ID; + + app_params.application = &app_fsref; + + ProcessSerialNumber psn; + + error = ::LSOpenApplication (&app_params, &psn); + + if (error != noErr) + return LLDB_INVALID_PROCESS_ID; + + ::pid_t pid = LLDB_INVALID_PROCESS_ID; + error = ::GetProcessPID(&psn, &pid); + return pid; +} + bool -Host::OpenFileInExternalEditor (FileSpec &file_spec, uint32_t line_no) +Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no) { // We attach this to an 'odoc' event to specify a particular selection typedef struct { Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Sep 30 16:49:03 2010 @@ -366,6 +366,7 @@ return error; } +//#define LAUNCH_WITH_LAUNCH_SERVICES 1 //---------------------------------------------------------------------- // Process Control //---------------------------------------------------------------------- @@ -381,10 +382,18 @@ const char *stderr_path ) { + Error error; +#if defined (LAUNCH_WITH_LAUNCH_SERVICES) + FileSpec app_file_spec (argv[0]); + pid_t pid = Host::LaunchApplication (app_file_spec); + if (pid != LLDB_INVALID_PROCESS_ID) + error = DoAttachToProcessWithID (pid); + else + error.SetErrorString("failed"); +#else // ::LogSetBitMask (GDBR_LOG_DEFAULT); // ::LogSetOptions (LLDB_LOG_OPTION_THREADSAFE | LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD); // ::LogSetLogFile ("/dev/stdout"); - Error error; ObjectFile * object_file = module->GetObjectFile(); if (object_file) @@ -497,9 +506,9 @@ SetID(LLDB_INVALID_PROCESS_ID); error.SetErrorStringWithFormat("Failed to get object file from '%s' for arch %s.\n", module->GetFileSpec().GetFilename().AsCString(), module->GetArchitecture().AsCString()); } - - // Return the process ID we have +#endif return error; + } @@ -621,9 +630,13 @@ void ProcessGDBRemote::DidLaunch () { +#if defined (LAUNCH_WITH_LAUNCH_SERVICES) + DidAttach (); +#else DidLaunchOrAttach (); if (m_dynamic_loader_ap.get()) m_dynamic_loader_ap->DidLaunch(); +#endif } Error 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=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Sep 30 16:49:03 2010 @@ -2444,7 +2444,7 @@ DWARFDebugInfoEntry::Attributes attributes; const char *type_name_cstr = NULL; ConstString type_name_dbstr; - Type::EncodingUIDType encoding_uid_type = Type::eIsTypeWithUID; + Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID; clang_type_t clang_type = NULL; TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); @@ -2508,37 +2508,37 @@ case DW_TAG_pointer_type: // The encoding_uid will be embedded into the // Type object and will be looked up when the Type::GetClangType() - encoding_uid_type = Type::ePointerToTypeWithUID; + encoding_data_type = Type::eEncodingIsPointerUID; break; case DW_TAG_reference_type: // The encoding_uid will be embedded into the // Type object and will be looked up when the Type::GetClangType() - encoding_uid_type = Type::eLValueReferenceToTypeWithUID; + encoding_data_type = Type::eEncodingIsLValueReferenceUID; break; case DW_TAG_typedef: // The encoding_uid will be embedded into the // Type object and will be looked up when the Type::GetClangType() - encoding_uid_type = Type::eTypedefToTypeWithUID; + encoding_data_type = Type::eEncodingIsTypedefUID; break; case DW_TAG_const_type: // The encoding_uid will be embedded into the // Type object and will be looked up when the Type::GetClangType() - encoding_uid_type = Type::eIsConstTypeWithUID; //ClangASTContext::AddConstModifier (clang_type); + encoding_data_type = Type::eEncodingIsConstUID; //ClangASTContext::AddConstModifier (clang_type); break; case DW_TAG_restrict_type: // The encoding_uid will be embedded into the // Type object and will be looked up when the Type::GetClangType() - encoding_uid_type = Type::eIsRestrictTypeWithUID; //ClangASTContext::AddRestrictModifier (clang_type); + encoding_data_type = Type::eEncodingIsRestrictUID; //ClangASTContext::AddRestrictModifier (clang_type); break; case DW_TAG_volatile_type: // The encoding_uid will be embedded into the // Type object and will be looked up when the Type::GetClangType() - encoding_uid_type = Type::eIsVolatileTypeWithUID; //ClangASTContext::AddVolatileModifier (clang_type); + encoding_data_type = Type::eEncodingIsVolatileUID; //ClangASTContext::AddVolatileModifier (clang_type); break; } @@ -2563,7 +2563,7 @@ } } - type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, encoding_uid_type, &decl, clang_type)); + type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, encoding_data_type, &decl, clang_type, clang_type == NULL)); m_die_to_type[die] = type_sp.get(); @@ -2679,21 +2679,27 @@ // parameters in any class methods need it for the clang // types for function prototypes. m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); - type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); + type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, true)); m_die_to_type[die] = type_sp.get(); - // Leave this as a forward declaration until we need - // to know the details of the type. lldb_private::Type - // will automatically call the SymbolFile virtual function - // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)" - // When the definition needs to be defined. - if (clang_type_was_created) + if (die->HasChildren() == false) { + // No children for this struct/union/class, lets finish it + type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); + type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); + } + else if (clang_type_was_created) + { + // Leave this as a forward declaration until we need + // to know the details of the type. lldb_private::Type + // will automatically call the SymbolFile virtual function + // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)" + // When the definition needs to be defined. m_forward_decl_die_to_clang_type[die] = clang_type; m_forward_decl_clang_type_to_die[clang_type] = die; } - + } break; @@ -2760,7 +2766,7 @@ } m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); - type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, Type::eIsTypeWithUID, &decl, clang_type)); + type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, Type::eEncodingIsUID, &decl, clang_type, true)); m_die_to_type[die] = type_sp.get(); @@ -2972,7 +2978,7 @@ type_list->GetClangASTContext().SetFunctionParameters (function_decl, &function_param_decls.front(), function_param_decls.size()); } } - type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, 0, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); + type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, 0, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, false)); m_die_to_type[die] = type_sp.get(); assert(type_sp.get()); @@ -3057,7 +3063,7 @@ array_element_bit_stride = array_element_bit_stride * num_elements; } ConstString empty_name; - type_sp.reset( new Type(die->GetOffset(), this, empty_name, array_element_bit_stride / 8, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); + type_sp.reset( new Type(die->GetOffset(), this, empty_name, array_element_bit_stride / 8, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, false)); m_die_to_type[die] = type_sp.get(); } } @@ -3099,7 +3105,7 @@ size_t byte_size = ClangASTType::GetClangTypeBitWidth (type_list->GetClangASTContext().getASTContext(), clang_type) / 8; - type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, NULL, clang_type)); + type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, NULL, clang_type, false)); m_die_to_type[die] = type_sp.get(); } Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Thu Sep 30 16:49:03 2010 @@ -414,7 +414,7 @@ // Null out everything below the CompUnit 'cause we don't actually know these. size_t bit_size = ClangASTType::GetClangTypeBitWidth ((GetType()->GetClangASTContext().getASTContext()), fun_return_qualtype.getAsOpaquePtr()); - Type return_type (0, GetType()->GetSymbolFile(), fun_return_name, bit_size, sc.comp_unit, 0, Type::eTypeUIDSynthetic, Declaration(), fun_return_qualtype.getAsOpaquePtr()); + Type return_type (0, GetType()->GetSymbolFile(), fun_return_name, bit_size, sc.comp_unit, 0, Type::eEncodingIsSyntheticUID, Declaration(), fun_return_qualtype.getAsOpaquePtr(), false); return return_type; } @@ -455,7 +455,7 @@ // Null out everything below the CompUnit 'cause we don't actually know these. size_t bit_size = ClangASTType::GetClangTypeBitWidth ((GetType()->GetClangASTContext().getASTContext()), arg_qualtype.getAsOpaquePtr()); - Type arg_type (0, GetType()->GetSymbolFile(), arg_return_name, bit_size, sc.comp_unit, 0, Type::eTypeUIDSynthetic, Declaration(), arg_qualtype.getAsOpaquePtr()); + Type arg_type (0, GetType()->GetSymbolFile(), arg_return_name, bit_size, sc.comp_unit, 0, Type::eEncodingIsSyntheticUID, Declaration(), arg_qualtype.getAsOpaquePtr(), false); return arg_type; } Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Thu Sep 30 16:49:03 2010 @@ -33,22 +33,24 @@ lldb::user_id_t uid, SymbolFile* symbol_file, const ConstString &name, - uint64_t byte_size, + uint32_t byte_size, SymbolContextScope *context, - lldb::user_id_t encoding_uid, - EncodingUIDType encoding_uid_type, + uintptr_t encoding_data, + EncodingDataType encoding_data_type, const Declaration& decl, - clang_type_t clang_type + clang_type_t clang_type, + bool is_forward_decl ) : UserID (uid), m_name (name), - m_byte_size (byte_size), m_symbol_file (symbol_file), m_context (context), - m_encoding_uid (encoding_uid), - m_encoding_uid_type (encoding_uid_type), + m_byte_size (byte_size), + m_encoding_data_type (encoding_data_type), + m_encoding_data (encoding_data), m_decl (decl), - m_clang_qual_type (clang_type) + m_clang_qual_type (clang_type), + m_is_forward_decl (is_forward_decl) { } @@ -58,10 +60,11 @@ m_byte_size (0), m_symbol_file (NULL), m_context (), - m_encoding_uid (0), - m_encoding_uid_type (eTypeInvalid), + m_encoding_data (0), + m_encoding_data_type (eEncodingInvalid), m_decl (), - m_clang_qual_type (NULL) + m_clang_qual_type (NULL), + m_is_forward_decl (false) { } @@ -76,7 +79,7 @@ m_byte_size = rhs.m_byte_size; m_symbol_file = rhs.m_symbol_file; m_context = rhs.m_context; - m_encoding_uid = rhs.m_encoding_uid; + m_encoding_data = rhs.m_encoding_data; m_decl = rhs.m_decl; m_clang_qual_type = rhs.m_clang_qual_type; } @@ -105,19 +108,21 @@ ClangASTType::DumpTypeDescription (GetClangAST(), m_clang_qual_type, s); *s << '"'; } - else if (m_encoding_uid != LLDB_INVALID_UID) + else if (m_encoding_data != LLDB_INVALID_UID) { - s->Printf(", type_uid = 0x%8.8x", m_encoding_uid); - switch (m_encoding_uid_type) + s->Printf(", type_uid = 0x%8.8x", m_encoding_data); + switch (m_encoding_data_type) { - case eIsTypeWithUID: s->PutCString(" (unresolved type)"); break; - case eIsConstTypeWithUID: s->PutCString(" (unresolved const type)"); break; - case eIsRestrictTypeWithUID: s->PutCString(" (unresolved restrict type)"); break; - case eIsVolatileTypeWithUID: s->PutCString(" (unresolved volatile type)"); break; - case eTypedefToTypeWithUID: s->PutCString(" (unresolved typedef)"); break; - case ePointerToTypeWithUID: s->PutCString(" (unresolved pointer)"); break; - case eLValueReferenceToTypeWithUID: s->PutCString(" (unresolved L value reference)"); break; - case eRValueReferenceToTypeWithUID: s->PutCString(" (unresolved R value reference)"); break; + case eEncodingIsUID: s->PutCString(" (unresolved type)"); break; + case eEncodingIsConstUID: s->PutCString(" (unresolved const type)"); break; + case eEncodingIsRestrictUID: s->PutCString(" (unresolved restrict type)"); break; + case eEncodingIsVolatileUID: s->PutCString(" (unresolved volatile type)"); break; + case eEncodingIsTypedefUID: s->PutCString(" (unresolved typedef)"); break; + case eEncodingIsPointerUID: s->PutCString(" (unresolved pointer)"); break; + case eEncodingIsLValueReferenceUID: s->PutCString(" (unresolved L value reference)"); break; + case eEncodingIsRValueReferenceUID: s->PutCString(" (unresolved R value reference)"); break; + case eEncodingIsSyntheticUID: s->PutCString(" (synthetic type)"); break; + case eEncodingIsTypePtr: s->PutCString(" (Type *)"); break; } } } @@ -151,19 +156,21 @@ ClangASTType::DumpTypeDescription (GetClangAST(), m_clang_qual_type, s); } - else if (m_encoding_uid != LLDB_INVALID_UID) + else if (m_encoding_data != LLDB_INVALID_UID) { - *s << ", type_uid = " << m_encoding_uid; - switch (m_encoding_uid_type) + *s << ", type_data = " << (uint64_t)m_encoding_data; + switch (m_encoding_data_type) { - case eIsTypeWithUID: s->PutCString(" (unresolved type)"); break; - case eIsConstTypeWithUID: s->PutCString(" (unresolved const type)"); break; - case eIsRestrictTypeWithUID: s->PutCString(" (unresolved restrict type)"); break; - case eIsVolatileTypeWithUID: s->PutCString(" (unresolved volatile type)"); break; - case eTypedefToTypeWithUID: s->PutCString(" (unresolved typedef)"); break; - case ePointerToTypeWithUID: s->PutCString(" (unresolved pointer)"); break; - case eLValueReferenceToTypeWithUID: s->PutCString(" (unresolved L value reference)"); break; - case eRValueReferenceToTypeWithUID: s->PutCString(" (unresolved R value reference)"); break; + case eEncodingIsUID: s->PutCString(" (unresolved type)"); break; + case eEncodingIsConstUID: s->PutCString(" (unresolved const type)"); break; + case eEncodingIsRestrictUID: s->PutCString(" (unresolved restrict type)"); break; + case eEncodingIsVolatileUID: s->PutCString(" (unresolved volatile type)"); break; + case eEncodingIsTypedefUID: s->PutCString(" (unresolved typedef)"); break; + case eEncodingIsPointerUID: s->PutCString(" (unresolved pointer)"); break; + case eEncodingIsLValueReferenceUID: s->PutCString(" (unresolved L value reference)"); break; + case eEncodingIsRValueReferenceUID: s->PutCString(" (unresolved R value reference)"); break; + case eEncodingIsSyntheticUID: s->PutCString(" (synthetic type)"); break; + case eEncodingIsTypePtr: s->PutCString(" (Type *)"); break; } } @@ -241,16 +248,16 @@ { if (m_byte_size == 0) { - switch (m_encoding_uid_type) + switch (m_encoding_data_type) { - case eIsTypeWithUID: - case eIsConstTypeWithUID: - case eIsRestrictTypeWithUID: - case eIsVolatileTypeWithUID: - case eTypedefToTypeWithUID: - if (m_encoding_uid != LLDB_INVALID_UID) + case eEncodingIsUID: + case eEncodingIsConstUID: + case eEncodingIsRestrictUID: + case eEncodingIsVolatileUID: + case eEncodingIsTypedefUID: + if (m_encoding_data != LLDB_INVALID_UID) { - Type *encoding_type = m_symbol_file->ResolveTypeUID (m_encoding_uid); + Type *encoding_type = m_symbol_file->ResolveTypeUID (m_encoding_data); if (encoding_type) m_byte_size = encoding_type->GetByteSize(); } @@ -262,9 +269,9 @@ break; // If we are a pointer or reference, then this is just a pointer size; - case ePointerToTypeWithUID: - case eLValueReferenceToTypeWithUID: - case eRValueReferenceToTypeWithUID: + case eEncodingIsPointerUID: + case eEncodingIsLValueReferenceUID: + case eEncodingIsRValueReferenceUID: m_byte_size = GetTypeList()->GetClangASTContext().GetPointerBitSize() / 8; break; } @@ -400,113 +407,132 @@ bool lldb_private::Type::ResolveClangType (bool forward_decl_is_ok) { +// static int g_depth = 0; +// g_depth++; +// printf ("%.*sType::ResolveClangType (forward = %i) uid = 0x%8.8x, name = %s\n", g_depth, "", forward_decl_is_ok, m_uid, m_name.AsCString()); + Type *encoding_type = NULL; if (m_clang_qual_type == NULL) { TypeList *type_list = GetTypeList(); - if (m_encoding_uid != LLDB_INVALID_UID) + if (m_encoding_data != LLDB_INVALID_UID) { - Type *encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_uid); + encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_data); if (encoding_type) { - - switch (m_encoding_uid_type) + switch (m_encoding_data_type) { - case eIsTypeWithUID: + case eEncodingIsUID: m_clang_qual_type = encoding_type->GetClangType(); break; - case eIsConstTypeWithUID: - m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangType(forward_decl_is_ok)); + case eEncodingIsConstUID: + m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangType(true)); break; - case eIsRestrictTypeWithUID: - m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangType(forward_decl_is_ok)); + case eEncodingIsRestrictUID: + m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangType(true)); break; - case eIsVolatileTypeWithUID: - m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangType(forward_decl_is_ok)); + case eEncodingIsVolatileUID: + m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangType(true)); break; - case eTypedefToTypeWithUID: - m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type, forward_decl_is_ok); + case eEncodingIsTypedefUID: + m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type, true); // Clear the name so it can get fully qualified in case the // typedef is in a namespace. m_name.Clear(); break; - case ePointerToTypeWithUID: - m_clang_qual_type = type_list->CreateClangPointerType (encoding_type, forward_decl_is_ok); + case eEncodingIsPointerUID: + m_clang_qual_type = type_list->CreateClangPointerType (encoding_type, true); break; - case eLValueReferenceToTypeWithUID: - m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type, forward_decl_is_ok); + case eEncodingIsLValueReferenceUID: + m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type, true); break; - case eRValueReferenceToTypeWithUID: - m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type, forward_decl_is_ok); + case eEncodingIsRValueReferenceUID: + m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type, true); break; default: - assert(!"Unhandled encoding_uid_type."); + assert(!"Unhandled encoding_data_type."); break; } + + if (encoding_type) + { + m_encoding_data_type = eEncodingIsTypePtr; + m_encoding_data = (uintptr_t)encoding_type; + } } - // Return here since we won't need to check if this is a forward - // declaration below since we already obeyed this above. - return m_clang_qual_type != NULL; } else { // We have no encoding type, return void? clang_type_t void_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); - switch (m_encoding_uid_type) + switch (m_encoding_data_type) { - case eIsTypeWithUID: + case eEncodingIsUID: m_clang_qual_type = void_clang_type; break; - case eIsConstTypeWithUID: + case eEncodingIsConstUID: m_clang_qual_type = ClangASTContext::AddConstModifier (void_clang_type); break; - case eIsRestrictTypeWithUID: + case eEncodingIsRestrictUID: m_clang_qual_type = ClangASTContext::AddRestrictModifier (void_clang_type); break; - case eIsVolatileTypeWithUID: + case eEncodingIsVolatileUID: m_clang_qual_type = ClangASTContext::AddVolatileModifier (void_clang_type); break; - case eTypedefToTypeWithUID: + case eEncodingIsTypedefUID: m_clang_qual_type = type_list->GetClangASTContext().CreateTypedefType (m_name.AsCString(), void_clang_type, NULL); break; - case ePointerToTypeWithUID: + case eEncodingIsPointerUID: m_clang_qual_type = type_list->GetClangASTContext().CreatePointerType (void_clang_type); break; - case eLValueReferenceToTypeWithUID: + case eEncodingIsLValueReferenceUID: m_clang_qual_type = type_list->GetClangASTContext().CreateLValueReferenceType (void_clang_type); break; - case eRValueReferenceToTypeWithUID: + case eEncodingIsRValueReferenceUID: m_clang_qual_type = type_list->GetClangASTContext().CreateRValueReferenceType (void_clang_type); break; default: - assert(!"Unhandled encoding_uid_type."); + assert(!"Unhandled encoding_data_type."); break; } } } // Check if we have a forward reference to a class/struct/union/enum? - if (!forward_decl_is_ok && !ClangASTType::IsDefined (m_clang_qual_type)) + if (m_is_forward_decl && m_clang_qual_type && !forward_decl_is_ok) { - // We have a forward declaration, we need to resolve it to a complete - // definition. - m_symbol_file->ResolveClangOpaqueTypeDefinition (m_clang_qual_type); + m_is_forward_decl = false; + if (!ClangASTType::IsDefined (m_clang_qual_type)) + { + // We have a forward declaration, we need to resolve it to a complete + // definition. + m_symbol_file->ResolveClangOpaqueTypeDefinition (m_clang_qual_type); + } + else + { + if (encoding_type == NULL) + encoding_type = GetEncodingType (); + if (encoding_type != NULL) + encoding_type->ResolveClangType (forward_decl_is_ok); + } } +// if (g_depth > 0) +// --g_depth; return m_clang_qual_type != NULL; } Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=115213&r1=115212&r2=115213&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Thu Sep 30 16:49:03 2010 @@ -369,6 +369,7 @@ isa = PBXProject; buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "debugserver" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, From johnny.chen at apple.com Thu Sep 30 17:11:33 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 22:11:33 -0000 Subject: [Lldb-commits] [lldb] r115216 - in /lldb/trunk/test/breakpoint_locations: TestBreakpointLocations.py main.c Message-ID: <20100930221133.5922A2A6C12E@llvm.org> Author: johnny Date: Thu Sep 30 17:11:33 2010 New Revision: 115216 URL: http://llvm.org/viewvc/llvm-project?rev=115216&view=rev Log: Modification required to test clang, gcc, and llvm-gcc. Modified: lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py lldb/trunk/test/breakpoint_locations/main.c Modified: lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py?rev=115216&r1=115215&r2=115216&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py (original) +++ lldb/trunk/test/breakpoint_locations/TestBreakpointLocations.py Thu Sep 30 17:11:33 2010 @@ -34,9 +34,8 @@ # The breakpoint list should show 3 locations. self.expect("breakpoint list", "Breakpoint locations shown correctly", substrs = ["1: file ='main.c', line = 19, locations = 3"], - patterns = ["1\.1: where = a.out`func_inlined .+unresolved, hit count = 0", - "1\.2: where = a.out`main .+\[inlined\].+unresolved, hit count = 0", - "1\.3: where = a.out`main .+\[inlined\].+unresolved, hit count = 0"]) + patterns = ["where = a.out`func_inlined .+unresolved, hit count = 0", + "where = a.out`main .+\[inlined\].+unresolved, hit count = 0"]) # The 'breakpoint disable 3.*' command should fail gracefully. self.expect("breakpoint disable 3.*", @@ -66,21 +65,22 @@ # Run the program againt. We should stop on the two breakpoint locations. self.runCmd("run", RUN_SUCCEEDED) - self.expect("thread backtrace", "Stopped on an inlined location", - substrs = ["stop reason = breakpoint 1.2"], - patterns = ["frame #0: .+\[inlined\]"]) + # Stopped once. + self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, + substrs = ["stop reason = breakpoint 1."]) + # Continue the program, there should be another stop. self.runCmd("process continue") - self.expect("thread backtrace", "Stopped on an inlined location", - substrs = ["stop reason = breakpoint 1.3"], - patterns = ["frame #0: .+\[inlined\]"]) + # Stopped again. + self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, + substrs = ["stop reason = breakpoint 1."]) # At this point, the 3 locations should all have "hit count = 2". self.expect("breakpoint list", "Expect all 3 breakpoints with hit count of 2", - patterns = ["1\.1: where = a.out`func_inlined .+ resolved, hit count = 2 +Options: disabled", - "1\.2: where = a.out`main .+\[inlined\].+ resolved, hit count = 2", - "1\.3: where = a.out`main .+\[inlined\].+ resolved, hit count = 2"]) + patterns = ["1\.1: .+ resolved, hit count = 2 +Options: disabled", + "1\.2: .+ resolved, hit count = 2", + "1\.3: .+ resolved, hit count = 2"]) if __name__ == '__main__': Modified: lldb/trunk/test/breakpoint_locations/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_locations/main.c?rev=115216&r1=115215&r2=115216&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_locations/main.c (original) +++ lldb/trunk/test/breakpoint_locations/main.c Thu Sep 30 17:11:33 2010 @@ -1,6 +1,6 @@ #include -#define INLINE_ME __inline__ __attribute__((always_inline)) +#define INLINE inline __attribute__((always_inline)) int func_not_inlined (void) @@ -9,7 +9,7 @@ return 0; } -INLINE_ME int +INLINE int func_inlined (void) { static int func_inline_call_count = 0; @@ -19,6 +19,8 @@ return func_inline_call_count; } +extern int func_inlined (void); + int main (int argc, char **argv) { From gclayton at apple.com Thu Sep 30 17:25:10 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 30 Sep 2010 22:25:10 -0000 Subject: [Lldb-commits] [lldb] r115223 - in /lldb/trunk: include/lldb/Symbol/Type.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/Type.cpp Message-ID: <20100930222510.2CF9F2A6C12E@llvm.org> Author: gclayton Date: Thu Sep 30 17:25:09 2010 New Revision: 115223 URL: http://llvm.org/viewvc/llvm-project?rev=115223&view=rev Log: Fixed an issue where byte sizes were not able to be calculated for forward declarations because we lost the original context which was needed to be able to figure out the byte size. Modified: lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=115223&r1=115222&r2=115223&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Thu Sep 30 17:25:09 2010 @@ -32,8 +32,7 @@ eEncodingIsPointerUID, ///< This type is pointer to a type whose UID is m_encoding_uid eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type whose UID is m_encoding_uid eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type whose UID is m_encoding_uid - eEncodingIsSyntheticUID, - eEncodingIsTypePtr ///< m_encoding_data is a "lldb_private::Type *" + eEncodingIsSyntheticUID } EncodingDataType; Type (lldb::user_id_t uid, @@ -93,7 +92,7 @@ bool IsValidType () { - return m_encoding_data_type != eEncodingInvalid; + return m_encoding_uid_type != eEncodingInvalid; } void @@ -200,20 +199,17 @@ ConstString m_name; SymbolFile *m_symbol_file; SymbolContextScope *m_context; // The symbol context in which this type is defined - uint64_t m_byte_size; - EncodingDataType m_encoding_data_type; - uintptr_t m_encoding_data; + Type *m_encoding_type; + EncodingDataType m_encoding_uid_type; + uint32_t m_encoding_uid; + uint32_t m_byte_size; + bool m_is_forward_decl; Declaration m_decl; lldb::clang_type_t m_clang_qual_type; - bool m_is_forward_decl; Type * - GetEncodingType () - { - if (m_encoding_data_type == eEncodingIsTypePtr) - return (Type *)m_encoding_data; - return NULL; - } + GetEncodingType (); + bool ResolveClangType(bool forward_decl_is_ok = false); }; 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=115223&r1=115222&r2=115223&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Sep 30 17:25:09 2010 @@ -2679,7 +2679,8 @@ // parameters in any class methods need it for the clang // types for function prototypes. m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); - type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, true)); + const bool is_forward_decl = die->HasChildren(); + type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, is_forward_decl)); m_die_to_type[die] = type_sp.get(); Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=115223&r1=115222&r2=115223&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Thu Sep 30 17:25:09 2010 @@ -45,26 +45,28 @@ m_name (name), m_symbol_file (symbol_file), m_context (context), + m_encoding_type (NULL), + m_encoding_uid_type (encoding_data_type), + m_encoding_uid (encoding_data), m_byte_size (byte_size), - m_encoding_data_type (encoding_data_type), - m_encoding_data (encoding_data), + m_is_forward_decl (is_forward_decl), m_decl (decl), - m_clang_qual_type (clang_type), - m_is_forward_decl (is_forward_decl) + m_clang_qual_type (clang_type) { } lldb_private::Type::Type () : UserID (0), m_name (""), - m_byte_size (0), m_symbol_file (NULL), - m_context (), - m_encoding_data (0), - m_encoding_data_type (eEncodingInvalid), + m_context (NULL), + m_encoding_type (NULL), + m_encoding_uid_type (eEncodingInvalid), + m_encoding_uid (0), + m_byte_size (0), + m_is_forward_decl (false), m_decl (), - m_clang_qual_type (NULL), - m_is_forward_decl (false) + m_clang_qual_type (NULL) { } @@ -76,10 +78,13 @@ { UserID::operator= (rhs); m_name = rhs.m_name; - m_byte_size = rhs.m_byte_size; m_symbol_file = rhs.m_symbol_file; m_context = rhs.m_context; - m_encoding_data = rhs.m_encoding_data; + m_encoding_type = rhs.m_encoding_type; + m_encoding_uid_type = rhs.m_encoding_uid_type; + m_encoding_uid = rhs.m_encoding_uid; + m_byte_size = rhs.m_byte_size; + m_is_forward_decl = rhs.m_is_forward_decl; m_decl = rhs.m_decl; m_clang_qual_type = rhs.m_clang_qual_type; } @@ -108,10 +113,10 @@ ClangASTType::DumpTypeDescription (GetClangAST(), m_clang_qual_type, s); *s << '"'; } - else if (m_encoding_data != LLDB_INVALID_UID) + else if (m_encoding_uid != LLDB_INVALID_UID) { - s->Printf(", type_uid = 0x%8.8x", m_encoding_data); - switch (m_encoding_data_type) + s->Printf(", type_uid = 0x%8.8x", m_encoding_uid); + switch (m_encoding_uid_type) { case eEncodingIsUID: s->PutCString(" (unresolved type)"); break; case eEncodingIsConstUID: s->PutCString(" (unresolved const type)"); break; @@ -122,7 +127,6 @@ case eEncodingIsLValueReferenceUID: s->PutCString(" (unresolved L value reference)"); break; case eEncodingIsRValueReferenceUID: s->PutCString(" (unresolved R value reference)"); break; case eEncodingIsSyntheticUID: s->PutCString(" (synthetic type)"); break; - case eEncodingIsTypePtr: s->PutCString(" (Type *)"); break; } } } @@ -156,10 +160,10 @@ ClangASTType::DumpTypeDescription (GetClangAST(), m_clang_qual_type, s); } - else if (m_encoding_data != LLDB_INVALID_UID) + else if (m_encoding_uid != LLDB_INVALID_UID) { - *s << ", type_data = " << (uint64_t)m_encoding_data; - switch (m_encoding_data_type) + *s << ", type_data = " << (uint64_t)m_encoding_uid; + switch (m_encoding_uid_type) { case eEncodingIsUID: s->PutCString(" (unresolved type)"); break; case eEncodingIsConstUID: s->PutCString(" (unresolved const type)"); break; @@ -170,7 +174,6 @@ case eEncodingIsLValueReferenceUID: s->PutCString(" (unresolved L value reference)"); break; case eEncodingIsRValueReferenceUID: s->PutCString(" (unresolved R value reference)"); break; case eEncodingIsSyntheticUID: s->PutCString(" (synthetic type)"); break; - case eEncodingIsTypePtr: s->PutCString(" (Type *)"); break; } } @@ -243,28 +246,40 @@ } } +lldb_private::Type * +lldb_private::Type::GetEncodingType () +{ + if (m_encoding_type == NULL) + { + if (m_encoding_uid != LLDB_INVALID_UID) + m_encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_uid); + } + return m_encoding_type; +} + + + uint64_t lldb_private::Type::GetByteSize() { if (m_byte_size == 0) { - switch (m_encoding_data_type) + switch (m_encoding_uid_type) { case eEncodingIsUID: case eEncodingIsConstUID: case eEncodingIsRestrictUID: case eEncodingIsVolatileUID: case eEncodingIsTypedefUID: - if (m_encoding_data != LLDB_INVALID_UID) { - Type *encoding_type = m_symbol_file->ResolveTypeUID (m_encoding_data); + Type *encoding_type = GetEncodingType (); if (encoding_type) m_byte_size = encoding_type->GetByteSize(); - } - if (m_byte_size == 0) - { - uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetClangType()); - m_byte_size = (bit_width + 7 ) / 8; + if (m_byte_size == 0) + { + uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetClangType()); + m_byte_size = (bit_width + 7 ) / 8; + } } break; @@ -410,69 +425,60 @@ // static int g_depth = 0; // g_depth++; // printf ("%.*sType::ResolveClangType (forward = %i) uid = 0x%8.8x, name = %s\n", g_depth, "", forward_decl_is_ok, m_uid, m_name.AsCString()); - Type *encoding_type = NULL; if (m_clang_qual_type == NULL) { TypeList *type_list = GetTypeList(); - if (m_encoding_data != LLDB_INVALID_UID) + Type *encoding_type = GetEncodingType(); + + if (encoding_type) { - encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_data); - if (encoding_type) + switch (m_encoding_uid_type) { - switch (m_encoding_data_type) - { - case eEncodingIsUID: - m_clang_qual_type = encoding_type->GetClangType(); - break; - - case eEncodingIsConstUID: - m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangType(true)); - break; - - case eEncodingIsRestrictUID: - m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangType(true)); - break; - - case eEncodingIsVolatileUID: - m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangType(true)); - break; - - case eEncodingIsTypedefUID: - m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type, true); - // Clear the name so it can get fully qualified in case the - // typedef is in a namespace. - m_name.Clear(); - break; - - case eEncodingIsPointerUID: - m_clang_qual_type = type_list->CreateClangPointerType (encoding_type, true); - break; - - case eEncodingIsLValueReferenceUID: - m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type, true); - break; - - case eEncodingIsRValueReferenceUID: - m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type, true); - break; - - default: - assert(!"Unhandled encoding_data_type."); - break; - } - - if (encoding_type) - { - m_encoding_data_type = eEncodingIsTypePtr; - m_encoding_data = (uintptr_t)encoding_type; - } + case eEncodingIsUID: + m_clang_qual_type = encoding_type->GetClangType(); + break; + + case eEncodingIsConstUID: + m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangType(true)); + break; + + case eEncodingIsRestrictUID: + m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangType(true)); + break; + + case eEncodingIsVolatileUID: + m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangType(true)); + break; + + case eEncodingIsTypedefUID: + m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type, true); + // Clear the name so it can get fully qualified in case the + // typedef is in a namespace. + m_name.Clear(); + break; + + case eEncodingIsPointerUID: + m_clang_qual_type = type_list->CreateClangPointerType (encoding_type, true); + break; + + case eEncodingIsLValueReferenceUID: + m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type, true); + break; + + case eEncodingIsRValueReferenceUID: + m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type, true); + break; + + default: + assert(!"Unhandled encoding_data_type."); + break; } } else { // We have no encoding type, return void? clang_type_t void_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); - switch (m_encoding_data_type) + switch (m_encoding_uid_type) { case eEncodingIsUID: m_clang_qual_type = void_clang_type; @@ -525,8 +531,9 @@ } else { - if (encoding_type == NULL) - encoding_type = GetEncodingType (); + // If we have an encoding type, then we need to make sure it is + // resolved appropriately + Type *encoding_type = GetEncodingType (); if (encoding_type != NULL) encoding_type->ResolveClangType (forward_decl_is_ok); } From johnny.chen at apple.com Thu Sep 30 17:49:07 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 30 Sep 2010 22:49:07 -0000 Subject: [Lldb-commits] [lldb] r115229 - in /lldb/trunk/test/types: TestFloatTypesExpr.py TestIntegerTypesExpr.py Message-ID: <20100930224907.5A5772A6C12E@llvm.org> Author: johnny Date: Thu Sep 30 17:49:07 2010 New Revision: 115229 URL: http://llvm.org/viewvc/llvm-project?rev=115229&view=rev Log: Updated to remove most of the @expectedFailure decorators for: # rdar://problem/8493023 # test/types failures for Test*TypesExpr.py: element offset computed wrong and sign error? Two failures remain for test_short* test cases. Modified: lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=115229&r1=115228&r2=115229&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Thu Sep 30 17:49:07 2010 @@ -10,9 +10,9 @@ mydir = "types" - @unittest2.expectedFailure # rdar://problem/8493023 - # test/types failures for Test*TypesExpr.py: element offset computed wrong? + # test/types failures for Test*TypesExpr.py: element offset computed wrong and sign error? + def test_float_types_with_dsym(self): """Test that float-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'float.cpp'} @@ -20,7 +20,6 @@ self.setTearDownCleanup(dictionary=d) self.float_type_expr() - @unittest2.expectedFailure def test_float_type_with_dwarf(self): """Test that float-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'float.cpp'} @@ -28,7 +27,6 @@ self.setTearDownCleanup(dictionary=d) self.float_type_expr() - @unittest2.expectedFailure def test_double_type_with_dsym(self): """Test that double-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'double.cpp'} @@ -36,7 +34,6 @@ self.setTearDownCleanup(dictionary=d) self.double_type_expr() - @unittest2.expectedFailure def test_double_type_with_dwarf(self): """Test that double-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'double.cpp'} Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=115229&r1=115228&r2=115229&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Thu Sep 30 17:49:07 2010 @@ -10,9 +10,9 @@ mydir = "types" - @unittest2.expectedFailure # rdar://problem/8493023 - # test/types failures for Test*TypesExpr.py: element offset computed wrong? + # test/types failures for Test*TypesExpr.py: element offset computed wrong and sign error? + def test_char_type_with_dsym(self): """Test that char-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'char.cpp'} @@ -20,7 +20,6 @@ self.setTearDownCleanup(dictionary=d) self.char_type_expr() - @unittest2.expectedFailure def test_char_type_with_dwarf(self): """Test that char-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'char.cpp'} @@ -28,7 +27,6 @@ self.setTearDownCleanup(dictionary=d) self.char_type_expr() - @unittest2.expectedFailure def test_unsigned_char_type_with_dsym(self): """Test that 'unsigned_char'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_char.cpp'} @@ -36,7 +34,6 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_char_type_expr() - @unittest2.expectedFailure def test_unsigned_char_type_with_dwarf(self): """Test that 'unsigned char'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_char.cpp'} @@ -60,7 +57,6 @@ self.setTearDownCleanup(dictionary=d) self.short_type_expr() - @unittest2.expectedFailure def test_unsigned_short_type_with_dsym(self): """Test that 'unsigned_short'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_short.cpp'} @@ -68,7 +64,6 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_short_type_expr() - @unittest2.expectedFailure def test_unsigned_short_type_with_dwarf(self): """Test that 'unsigned short'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_short.cpp'} @@ -76,7 +71,6 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_short_type_expr() - @unittest2.expectedFailure def test_int_type_with_dsym(self): """Test that int-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'int.cpp'} @@ -84,7 +78,6 @@ self.setTearDownCleanup(dictionary=d) self.int_type_expr() - @unittest2.expectedFailure def test_int_type_with_dwarf(self): """Test that int-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'int.cpp'} @@ -92,7 +85,6 @@ self.setTearDownCleanup(dictionary=d) self.int_type_expr() - @unittest2.expectedFailure def test_unsigned_int_type_with_dsym(self): """Test that 'unsigned_int'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_int.cpp'} @@ -100,7 +92,6 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_int_type_expr() - @unittest2.expectedFailure def test_unsigned_int_type_with_dwarf(self): """Test that 'unsigned int'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_int.cpp'} @@ -108,7 +99,6 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_int_type_expr() - @unittest2.expectedFailure def test_long_type_with_dsym(self): """Test that long-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'long.cpp'} @@ -116,7 +106,6 @@ self.setTearDownCleanup(dictionary=d) self.long_type_expr() - @unittest2.expectedFailure def test_long_type_with_dwarf(self): """Test that long-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'long.cpp'} @@ -124,7 +113,6 @@ self.setTearDownCleanup(dictionary=d) self.long_type_expr() - @unittest2.expectedFailure def test_unsigned_long_type_with_dsym(self): """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_long.cpp'} @@ -132,7 +120,6 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_long_type_expr() - @unittest2.expectedFailure def test_unsigned_long_type_with_dwarf(self): """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'unsigned_long.cpp'} From echristo at apple.com Thu Sep 30 18:03:50 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 30 Sep 2010 16:03:50 -0700 Subject: [Lldb-commits] [lldb] r115208 - in /lldb/trunk: include/lldb/Expression/IRForTarget.h source/Expression/ClangExpressionParser.cpp source/Expression/IRForTarget.cpp In-Reply-To: <20100930211825.BE65E2A6C12E@llvm.org> References: <20100930211825.BE65E2A6C12E@llvm.org> Message-ID: On Sep 30, 2010, at 2:18 PM, Sean Callanan wrote: > Switched the expression parser from using TargetData > to using Clang to get type sizes. This fixes a bug > where the type size for a double[2] was being wrongly > reported as 8 instead of 16 bytes, causing problems > for IRForTarget. Actually it was giving you the answer you asked for, but not the answer you were wanting. You needed to check if it was an array type and then the size of the array. I hope that the clang and llvm bits agree on type size though. :) -eric From johnny.chen at apple.com Thu Sep 30 19:10:17 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 01 Oct 2010 00:10:17 -0000 Subject: [Lldb-commits] [lldb] r115249 - in /lldb/trunk/test/foundation: TestDisassemble.py main.m Message-ID: <20101001001017.396372A6C12E@llvm.org> Author: johnny Date: Thu Sep 30 19:10:17 2010 New Revision: 115249 URL: http://llvm.org/viewvc/llvm-project?rev=115249&view=rev Log: Add a simple test for the lldb 'disassemble' command. The initial version just sets some breakpoints and invokes 'disassemble' when the breakpoint hits, which just disassembles the bytes in the current function, i.e., frame #0's function. Added: lldb/trunk/test/foundation/TestDisassemble.py Modified: lldb/trunk/test/foundation/main.m Added: lldb/trunk/test/foundation/TestDisassemble.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestDisassemble.py?rev=115249&view=auto ============================================================================== --- lldb/trunk/test/foundation/TestDisassemble.py (added) +++ lldb/trunk/test/foundation/TestDisassemble.py Thu Sep 30 19:10:17 2010 @@ -0,0 +1,87 @@ +""" +Test the lldb disassemble command. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + + at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") +class FoundationDisassembleTestCase(TestBase): + + mydir = "foundation" + + def test_simple_disasm_with_dsym(self): + """Test the lldb 'disassemble' command""" + self.buildDsym() + self.do_simple_disasm() + + def test_simple_disasm_with_dwarf(self): + """Test the lldb 'disassemble' command""" + self.buildDwarf() + self.do_simple_disasm() + + def do_simple_disasm(self): + """Do a bunch of simple disassemble commands.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Stop at +[NSString stringWithFormat:]. + self.expect("regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1") + + # Stop at -[MyString initWithNSString:]. + self.expect("breakpoint set -n '-[MyString initWithNSString:]'", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 2: name = '-[MyString initWithNSString:]', locations = 1") + + # Stop at the "description" selector. + self.expect("breakpoint set -S description", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 3: name = 'description', locations = 1") + + # Stop at -[NSAutoreleasePool release]. + self.expect("regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 4: name = '-[NSAutoreleasePool release]', locations = 1") + + self.runCmd("run", RUN_SUCCEEDED) + + # First stop is +[NSString stringWithFormat:]. + self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", + substrs = ["Foundation`+[NSString stringWithFormat:]"]) + + # Do the disassemble for the currently stopped function. + self.runCmd("disassemble") + + self.runCmd("process continue") + + # Followed by a.out`-[MyString initWithNSString:]. + self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", + substrs = ["a.out`-[MyString initWithNSString:]"]) + + # Do the disassemble for the currently stopped function. + self.runCmd("disassemble") + + self.runCmd("process continue") + + # Followed by -[MyString description]. + self.expect("thread backtrace", "Stop at -[MyString description]", + substrs = ["a.out`-[MyString description]"]) + + # Do the disassemble for the currently stopped function. + self.runCmd("disassemble") + + self.runCmd("process continue") + + # Followed by -[NSAutoreleasePool release]. + self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", + substrs = ["Foundation`-[NSAutoreleasePool release]"]) + + # Do the disassemble for the currently stopped function. + self.runCmd("disassemble") + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Modified: lldb/trunk/test/foundation/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/main.m?rev=115249&r1=115248&r2=115249&view=diff ============================================================================== --- lldb/trunk/test/foundation/main.m (original) +++ lldb/trunk/test/foundation/main.m Thu Sep 30 19:10:17 2010 @@ -44,7 +44,7 @@ printf("sizeof(id) = %zu\n", sizeof(id)); printf("sizeof(Class) = %zu\n", sizeof(Class)); printf("sizeof(SEL) = %zu\n", sizeof(SEL)); - printf("[str length] = %zu\n", [str length]); + printf("[str length] = %zu\n", (size_t)[str length]); printf("str = '%s'\n", [str cStringUsingEncoding: [NSString defaultCStringEncoding]]); [pool release]; From scallanan at apple.com Thu Sep 30 21:06:46 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 01 Oct 2010 02:06:46 -0000 Subject: [Lldb-commits] [lldb] r115267 - in /lldb/trunk/source: Expression/ClangExpressionVariable.cpp Symbol/ClangASTType.cpp Message-ID: <20101001020646.390552A6C12E@llvm.org> Author: spyffe Date: Thu Sep 30 21:06:46 2010 New Revision: 115267 URL: http://llvm.org/viewvc/llvm-project?rev=115267&view=rev Log: Fixed handling of signed short types in expressions. Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=115267&r1=115266&r2=115267&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Thu Sep 30 21:06:46 2010 @@ -51,7 +51,7 @@ Error err; Value val; - if (!PointValueAtData (val, &exe_ctx)) + if (!PointValueAtData (val, NULL)) { err.SetErrorToGenericError(); err.SetErrorStringWithFormat("Variable doesn't contain a value"); Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=115267&r1=115266&r2=115267&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Thu Sep 30 21:06:46 2010 @@ -975,7 +975,7 @@ case lldb::eEncodingSint: if (byte_size <= sizeof(long long)) { - int64_t sval64 = (int64_t)data.GetMaxU64 (&offset, byte_size); + int64_t sval64 = data.GetMaxS64 (&offset, byte_size); if (byte_size <= sizeof(int)) { value = (int)sval64; From gclayton at apple.com Thu Sep 30 21:31:07 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 01 Oct 2010 02:31:07 -0000 Subject: [Lldb-commits] [lldb] r115268 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Expression/ClangExpressionDeclMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/ClangASTContext.cpp Message-ID: <20101001023107.8ED2E2A6C12E@llvm.org> Author: gclayton Date: Thu Sep 30 21:31:07 2010 New Revision: 115268 URL: http://llvm.org/viewvc/llvm-project?rev=115268&view=rev Log: Make C++ constructors and destructors correctly within the clang types we generate from DWARF. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=115268&r1=115267&r2=115268&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Sep 30 21:31:07 2010 @@ -190,7 +190,8 @@ lldb::AccessType access, bool is_virtual, bool is_static, - bool is_inline); + bool is_inline, + bool is_explicit); clang::CXXMethodDecl * AddMethodToCXXRecordType (lldb::clang_type_t record_opaque_type, @@ -199,7 +200,8 @@ lldb::AccessType access, bool is_virtual, bool is_static, - bool is_inline) + bool is_inline, + bool is_explicit) { return ClangASTContext::AddMethodToCXXRecordType (getASTContext(), @@ -209,7 +211,8 @@ access, is_virtual, is_static, - is_inline); + is_inline, + is_explicit); } bool Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=115268&r1=115267&r2=115268&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Sep 30 21:31:07 2010 @@ -1119,11 +1119,12 @@ 1, false, ClangASTContext::GetTypeQualifiers(copied_type)); - + const bool is_virtual = false; const bool is_static = false; const bool is_inline = false; - + const bool is_explicit = false; + ClangASTContext::AddMethodToCXXRecordType (parser_ast_context, copied_type, "___clang_expr", @@ -1131,7 +1132,8 @@ lldb::eAccessPublic, is_virtual, is_static, - is_inline); + is_inline, + is_explicit); } context.AddTypeDecl(copied_type); 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=115268&r1=115267&r2=115268&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Sep 30 21:31:07 2010 @@ -2797,6 +2797,7 @@ bool is_inline = false; bool is_static = false; bool is_virtual = false; + bool is_explicit = false; unsigned type_quals = 0; clang::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern @@ -2828,6 +2829,8 @@ case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; case DW_AT_inline: is_inline = form_value.Unsigned() != 0; break; case DW_AT_virtuality: is_virtual = form_value.Unsigned() != 0; break; + case DW_AT_explicit: is_explicit = form_value.Unsigned() != 0; break; + case DW_AT_external: if (form_value.Unsigned()) { @@ -2846,7 +2849,6 @@ case DW_AT_data_location: case DW_AT_elemental: case DW_AT_entry_pc: - case DW_AT_explicit: case DW_AT_frame_base: case DW_AT_high_pc: case DW_AT_low_pc: @@ -2872,12 +2874,17 @@ } clang_type_t return_clang_type = NULL; - Type *func_type = ResolveTypeUID(type_die_offset); + Type *func_type = NULL; + + if (type_die_offset != DW_INVALID_OFFSET) + func_type = ResolveTypeUID(type_die_offset); + if (func_type) return_clang_type = func_type->GetClangType(true); else return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); + std::vector function_param_types; std::vector function_param_decls; @@ -2887,6 +2894,7 @@ // clang_type will get the function prototype clang type after this call clang_type = type_list->GetClangASTContext().CreateFunctionType (return_clang_type, &function_param_types[0], function_param_types.size(), is_variadic, type_quals); + if (type_name_cstr) { bool type_handled = false; @@ -2960,7 +2968,8 @@ accessibility, is_virtual, is_static, - is_inline); + is_inline, + is_explicit); type_handled = cxx_method_decl != NULL; } } Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=115268&r1=115267&r2=115268&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Sep 30 21:31:07 2010 @@ -813,7 +813,8 @@ lldb::AccessType access, bool is_virtual, bool is_static, - bool is_inline + bool is_inline, + bool is_explicit ) { if (!record_opaque_type || !method_opaque_type || !name) @@ -849,15 +850,34 @@ QualType method_qual_type (QualType::getFromOpaquePtr (method_opaque_type)); - CXXMethodDecl *cxx_method_decl = CXXMethodDecl::Create (*ast_context, - cxx_record_decl, - DeclarationNameInfo (DeclarationName (&identifier_table->get(name)), SourceLocation()), - method_qual_type, - NULL, // TypeSourceInfo * - is_static, - SC_None, - is_inline); + CXXMethodDecl *cxx_method_decl = NULL; + + DeclarationName decl_name (&identifier_table->get(name)); + if (name[0] == '~' || decl_name == record_decl->getDeclName()) + { + bool is_implicitly_declared = false; + cxx_method_decl = CXXConstructorDecl::Create (*ast_context, + cxx_record_decl, + DeclarationNameInfo (decl_name, SourceLocation()), + method_qual_type, + NULL, // TypeSourceInfo * + is_explicit, + is_inline, + is_implicitly_declared); + } + else + { + cxx_method_decl = CXXMethodDecl::Create (*ast_context, + cxx_record_decl, + DeclarationNameInfo (decl_name, SourceLocation()), + method_qual_type, + NULL, // TypeSourceInfo * + is_static, + SC_None, + is_inline); + } + AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access); From bugzilla-daemon at llvm.org Thu Sep 30 15:47:10 2010 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Thu, 30 Sep 2010 15:47:10 -0500 (CDT) Subject: [Lldb-commits] [Bug 8260] New: Invalid case in switch statement Message-ID: http://llvm.org/bugs/show_bug.cgi?id=8260 Summary: Invalid case in switch statement Product: lldb Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: wlynch at wlynch.cx Created an attachment (id=5541) --> (http://llvm.org/bugs/attachment.cgi?id=5541) Patch to remove the invalid case. Looking at: source/Core/Value.cpp Within the method: Scalar & Value::ResolveValue(ExecutionContext *exe_ctx, clang::ASTContext *ast_context) When the context type is eContextTypeOpaqueClangQualType, we then enter a switch statement over ValueTypes. One of the case statements is for eContextTypeValue. However, that is a ContextType, not a ValueType. I've attached a patch removing this case. -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From bugzilla-daemon at llvm.org Thu Sep 30 16:13:21 2010 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Thu, 30 Sep 2010 16:13:21 -0500 (CDT) Subject: [Lldb-commits] [Bug 8261] New: Initialization Order Warnings Message-ID: http://llvm.org/bugs/show_bug.cgi?id=8261 Summary: Initialization Order Warnings Product: lldb Version: unspecified Platform: PC OS/Version: All Status: NEW Severity: normal Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: wlynch at wlynch.cx Hello, I've attached a patch that fixes some initialization order warnings. These look like: /home/wlynch/Documents/llvm/tools/lldb/source/Target/../../include/lldb/Target/StackFrame.h: In constructor ?lldb_private::StackFrame::StackFrame(lldb::user_id_t, lldb::user_id_t, lldb_private::Thread&, const lldb::RegisterContextSP&, lldb::addr_t, lldb::addr_t, const lldb_private::SymbolContext*)?: /home/wlynch/Documents/llvm/tools/lldb/source/Target/../../include/lldb/Target/StackFrame.h:170: warning: ?lldb_private::StackFrame::m_unwind_frame_index? will be initialized after /home/wlynch/Documents/llvm/tools/lldb/source/Target/../../include/lldb/Target/StackFrame.h:168: warning: ?lldb_private::Thread& lldb_private::StackFrame::m_thread? -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From bugzilla-daemon at llvm.org Thu Sep 30 16:18:29 2010 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Thu, 30 Sep 2010 16:18:29 -0500 (CDT) Subject: [Lldb-commits] [Bug 8262] New: String to Octal conversion Message-ID: http://llvm.org/bugs/show_bug.cgi?id=8262 Summary: String to Octal conversion Product: lldb Version: unspecified Platform: PC OS/Version: All Status: NEW Severity: normal Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: wlynch at wlynch.cx Created an attachment (id=5543) --> (http://llvm.org/bugs/attachment.cgi?id=5543) The referenced patch Hello, In source/Core/Debugger.cpp, there is a piece of code which takes a string containing an octal number ("01231" for example), and returns it as an integer. This code currently does not work properly due to order of operations. Within a for loop, iterating over characters, this currently happens: octal_value = octal_value << 3 + (((uint8_t)*p) - '0'); The problem, however, is that it computes (3 + *p - '0') to shift with. Instead, we'd like to shift by 3, and then add (*p - '0'). I've written this as: octal_value = octal_value * 8 + (((uint8_t)*p) - '0'); The attached patch implements this. -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From gclayton at apple.com Thu Sep 30 22:45:20 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 01 Oct 2010 03:45:20 -0000 Subject: [Lldb-commits] [lldb] r115290 - in /lldb/trunk: source/Symbol/ClangASTContext.cpp test/class_types/main.cpp Message-ID: <20101001034521.05C7F2A6C12E@llvm.org> Author: gclayton Date: Thu Sep 30 22:45:20 2010 New Revision: 115290 URL: http://llvm.org/viewvc/llvm-project?rev=115290&view=rev Log: Added correct C++ method declarations for destructors and for conversion operators. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/test/class_types/main.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=115290&r1=115289&r2=115290&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Sep 30 22:45:20 2010 @@ -853,13 +853,36 @@ CXXMethodDecl *cxx_method_decl = NULL; DeclarationName decl_name (&identifier_table->get(name)); + + DeclarationNameInfo decl_name_info (decl_name, SourceLocation()); + const bool is_implicitly_declared = false; + + clang::Type *method_type(method_qual_type.getTypePtr()); + + if (method_type == NULL) + return NULL; + + FunctionProtoType *method_function_prototype (dyn_cast(method_type)); - if (name[0] == '~' || decl_name == record_decl->getDeclName()) + if (!method_function_prototype) + return NULL; + + unsigned int num_params = method_function_prototype->getNumArgs(); + + if (name[0] == '~') + { + cxx_method_decl = CXXDestructorDecl::Create (*ast_context, + cxx_record_decl, + decl_name_info, + method_qual_type, + is_inline, + is_implicitly_declared); + } + else if (decl_name == record_decl->getDeclName()) { - bool is_implicitly_declared = false; cxx_method_decl = CXXConstructorDecl::Create (*ast_context, cxx_record_decl, - DeclarationNameInfo (decl_name, SourceLocation()), + decl_name_info, method_qual_type, NULL, // TypeSourceInfo * is_explicit, @@ -867,15 +890,33 @@ is_implicitly_declared); } else - { - cxx_method_decl = CXXMethodDecl::Create (*ast_context, - cxx_record_decl, - DeclarationNameInfo (decl_name, SourceLocation()), - method_qual_type, - NULL, // TypeSourceInfo * - is_static, - SC_None, - is_inline); + { + // TODO: verify this is an ok way to see if this is a C++ conversion + // operator. I am currently checking for "operator " following by a valid + // first character of a type name (A-Z, a-z, or _)... + if ((num_params == 0) && + (::strstr(name, "operator ") == name) && + (::isalpha(name[9]) || name[9] == '_')) + { + cxx_method_decl = CXXConversionDecl::Create (*ast_context, + cxx_record_decl, + decl_name_info, + method_qual_type, + NULL, // TypeSourceInfo * + is_inline, + is_explicit); + } + else + { + cxx_method_decl = CXXMethodDecl::Create (*ast_context, + cxx_record_decl, + decl_name_info, + method_qual_type, + NULL, // TypeSourceInfo * + is_static, + SC_None, + is_inline); + } } @@ -885,17 +926,6 @@ cxx_method_decl->setVirtualAsWritten (is_virtual); // Populate the method decl with parameter decls - clang::Type *method_type(method_qual_type.getTypePtr()); - - if (method_type == NULL) - return NULL; - - FunctionProtoType *method_function_prototype (dyn_cast(method_type)); - - if (!method_function_prototype) - return NULL; - - unsigned int num_params = method_function_prototype->getNumArgs(); ParmVarDecl *params[num_params]; Modified: lldb/trunk/test/class_types/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/main.cpp?rev=115290&r1=115289&r2=115290&view=diff ============================================================================== --- lldb/trunk/test/class_types/main.cpp (original) +++ lldb/trunk/test/class_types/main.cpp Thu Sep 30 22:45:20 2010 @@ -7,6 +7,22 @@ // //===----------------------------------------------------------------------===// +class Conversion +{ +public: + Conversion (int i) : + m_i (i) + {} + + operator bool() + { + return m_i != 0; + } + +private: + int m_i; +}; + class A { public: @@ -103,5 +119,8 @@ A a(12); B b(22,33); C c(44,55,66); - return b.GetIntegerB() - a.GetInteger() + c.GetInteger(); + Conversion conv(1); + if (conv) + return b.GetIntegerB() - a.GetInteger() + c.GetInteger(); + return 0; } From bugzilla-daemon at llvm.org Fri Oct 1 10:41:28 2010 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Fri, 1 Oct 2010 10:41:28 -0500 (CDT) Subject: [Lldb-commits] [Bug 8271] New: Extraneous Files (Building under linux / makefiles) Message-ID: http://llvm.org/bugs/show_bug.cgi?id=8271 Summary: Extraneous Files (Building under linux / makefiles) Product: lldb Version: unspecified Platform: PC OS/Version: All Status: NEW Severity: normal Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: wlynch at wlynch.cx Hello, When comparing the makefile system to the xcode project, I've found that the makefiles refer to a few files that the xcode project believes don't exist. If possible, could these files be removed from the repository? If you would rather leave them in the repo, I can put together a patch to have the makefiles ignore them. * source/gdbserver * source/Commands/CommandObjectCall.h * source/Commands/CommandObjectCall.cpp -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From johnny.chen at apple.com Fri Oct 1 11:26:43 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 01 Oct 2010 16:26:43 -0000 Subject: [Lldb-commits] [lldb] r115316 - in /lldb/trunk/test: class_types/TestClassTypes.py types/TestFloatTypesExpr.py types/TestIntegerTypesExpr.py Message-ID: <20101001162643.146762A6C12E@llvm.org> Author: johnny Date: Fri Oct 1 11:26:42 2010 New Revision: 115316 URL: http://llvm.org/viewvc/llvm-project?rev=115316&view=rev Log: These currently crash (from running 'expr' command). Disable the entire class for the time being. Modified: lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115316&r1=115315&r2=115316&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Fri Oct 1 11:26:42 2010 @@ -5,6 +5,7 @@ import lldb from lldbtest import * + at unittest2.skip("crash currently") class ClassTypesTestCase(TestBase): mydir = "class_types" Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=115316&r1=115315&r2=115316&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Fri Oct 1 11:26:42 2010 @@ -6,6 +6,7 @@ import unittest2 import lldb + at unittest2.skip("crash currently") class FloatTypesTestCase(AbstractBase.GenericTester): mydir = "types" Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=115316&r1=115315&r2=115316&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Fri Oct 1 11:26:42 2010 @@ -6,6 +6,7 @@ import unittest2 import lldb + at unittest2.skip("crash currently") class IntegerTypesTestCase(AbstractBase.GenericTester): mydir = "types" From johnny.chen at apple.com Fri Oct 1 11:34:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 01 Oct 2010 16:34:54 -0000 Subject: [Lldb-commits] [lldb] r115317 - in /lldb/trunk/test: class_types/TestClassTypes.py types/TestFloatTypesExpr.py types/TestIntegerTypesExpr.py Message-ID: <20101001163454.2B1982A6C12E@llvm.org> Author: johnny Date: Fri Oct 1 11:34:53 2010 New Revision: 115317 URL: http://llvm.org/viewvc/llvm-project?rev=115317&view=rev Log: Added bug number to the @skip decorator. Modified: lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115317&r1=115316&r2=115317&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Fri Oct 1 11:34:53 2010 @@ -5,7 +5,7 @@ import lldb from lldbtest import * - at unittest2.skip("crash currently") + at unittest2.skip("crash currently: rdar://problem/8502549") class ClassTypesTestCase(TestBase): mydir = "class_types" Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=115317&r1=115316&r2=115317&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Fri Oct 1 11:34:53 2010 @@ -6,7 +6,7 @@ import unittest2 import lldb - at unittest2.skip("crash currently") + at unittest2.skip("crash currently: rdar://problem/8502549") class FloatTypesTestCase(AbstractBase.GenericTester): mydir = "types" Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=115317&r1=115316&r2=115317&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Fri Oct 1 11:34:53 2010 @@ -6,7 +6,7 @@ import unittest2 import lldb - at unittest2.skip("crash currently") + at unittest2.skip("crash currently: rdar://problem/8502549") class IntegerTypesTestCase(AbstractBase.GenericTester): mydir = "types" From ctice at apple.com Fri Oct 1 12:46:38 2010 From: ctice at apple.com (Caroline Tice) Date: Fri, 01 Oct 2010 17:46:38 -0000 Subject: [Lldb-commits] [lldb] r115318 - in /lldb/trunk: include/lldb/Interpreter/CommandObject.h include/lldb/lldb-enumerations.h source/Commands/CommandObjectBreakpoint.cpp source/Commands/CommandObjectHelp.cpp source/Commands/CommandObjectMultiword.cpp source/Interpreter/CommandObject.cpp source/Interpreter/Options.cpp Message-ID: <20101001174638.6C9082A6C12E@llvm.org> Author: ctice Date: Fri Oct 1 12:46:38 2010 New Revision: 115318 URL: http://llvm.org/viewvc/llvm-project?rev=115318&view=rev Log: Add infrastructure for standardizing arguments for commands and command options; makes it easier to ensure that the same type of argument will have the same name everywhere, hooks up help for command arguments, so that users can ask for help when they are confused about what an argument should be; puts in the beginnings of the ability to do tab-completion for certain types of arguments, allows automatic syntax help generation for commands with arguments, and adds command arguments into command options help correctly. Currently only the breakpoint-id and breakpoint-id-range arguments, in the breakpoint commands, have been hooked up to use the new mechanism. The next steps will be to fix the command options arguments to use this mechanism, and to fix the rest of the regular command arguments to use this mechanism. Most of the help text is currently missing or dummy text; this will need to be filled in, and the existing argument help text will need to be cleaned up a bit (it was thrown in quickly, mostly for testing purposes). Help command now works for all argument types, although the help may not be very helpful yet. Those commands that take "raw" command strings now indicate it in their help text. Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectHelp.cpp lldb/trunk/source/Commands/CommandObjectMultiword.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/Options.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=115318&r1=115317&r2=115318&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Fri Oct 1 12:46:38 2010 @@ -17,6 +17,7 @@ #include "lldb/lldb-private.h" #include "lldb/Interpreter/Args.h" +#include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Core/StringList.h" #include "lldb/Core/Flags.h" @@ -25,8 +26,29 @@ class CommandObject { public: - typedef std::map CommandMap; + typedef const char *(ArgumentHelpCallbackFunction) (); + + struct ArgumentTableEntry // Entries in the main argument information table + { + lldb::CommandArgumentType arg_type; + const char *arg_name; + CommandCompletions::CommonCompletionTypes completion_type; + ArgumentHelpCallbackFunction *help_function; + const char *help_text; + }; + + struct CommandArgumentData // Used to build individual command argument lists + { + lldb::CommandArgumentType arg_type; + lldb::ArgumentRepetitionType arg_repetition; + }; + + typedef std::vector CommandArgumentEntry; // Used to build individual command argument lists + + static ArgumentTableEntry g_arguments_data[lldb::eArgTypeLastArg]; // Main argument information table + + typedef std::map CommandMap; CommandObject (CommandInterpreter &interpreter, const char *name, @@ -88,6 +110,30 @@ virtual Options * GetOptions (); + static const ArgumentTableEntry* + GetArgumentTable (); + + static const lldb::CommandArgumentType + LookupArgumentName (const char *arg_name); + + static ArgumentTableEntry * + FindArgumentDataByType (lldb::CommandArgumentType arg_type); + + int + GetNumArgumentEntries (); + + CommandArgumentEntry * + GetArgumentEntryAtIndex (int idx); + + static void + GetArgumentHelp (Stream &str, lldb::CommandArgumentType arg_type, CommandInterpreter &interpreter); + + const char * + GetArgumentName (lldb::CommandArgumentType arg_type); + + void + GetFormattedCommandArguments (Stream &str); + enum { eFlagProcessMustBeLaunched = (1 << 0), @@ -277,6 +323,7 @@ std::string m_cmd_syntax; bool m_is_alias; Flags m_flags; + std::vector m_arguments; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=115318&r1=115317&r2=115318&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Oct 1 12:46:38 2010 @@ -503,6 +503,75 @@ eVarSetOperationInvalid } VarSetOperationType; +//---------------------------------------------------------------------- +/// Command argument types. +/// +//---------------------------------------------------------------------- + +typedef enum CommandArgumentType +{ + eArgTypeAddress = 0, + eArgTypeArchitecture, + eArgTypeBoolean, + eArgTypeBreakpointID, + eArgTypeBreakpointIDRange, + eArgTypeByteSize, + eArgTypeChannel, + eArgTypeCount, + eArgTypeExpression, + eArgTypeFilename, + eArgTypeFormat, + eArgTypeFullName, + eArgTypeFunctionName, + eArgTypeIndex, + eArgTypeLineNum, + eArgTypeMethod, + eArgTypeName, + eArgTypeNumLines, + eArgTypeNumberPerLine, + eArgTypeOffset, + eArgTypeOther, + eArgTypePath, + eArgTypePathPrefix, + eArgTypePathPrefixPair, + eArgTypePid, + eArgTypePlugin, + eArgTypeProcessName, + eArgTypeQueueName, + eArgTypeRegisterName, + eArgTypeRegularExpression, + eArgTypeRunMode, + eArgTypeSearchWord, + eArgTypeSelector, + eArgTypeSettingIndex, + eArgTypeSettingKey, + eArgTypeSettingPrefix, + eArgTypeSettingVariableName, + eArgTypeShlibName, + eArgTypeSourceFile, + eArgTypeStartAddress, + eArgTypeSymbol, + eArgTypeThreadID, + eArgTypeThreadIndex, + eArgTypeThreadName, + eArgTypeUUID, + eArgTypeUnixSignalNumber, + eArgTypeVarName, + eArgTypeValue, + eArgTypeWidth, + eArgTypeNone, + eArgTypeLastArg // Always keep this entry as the last entry in this enumeration!! +} CommandArgumentType; + +typedef enum ArgumentRepetitionType +{ + eArgRepeatPlain, // Exactly one occurrence + eArgRepeatOptional, // At most one occurrence, but it's optional + eArgRepeatPlus, // One or more occurrences + eArgRepeatStar // Zero or more occurrences +} ArgumentRepetitionType; + + } // namespace lldb Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=115318&r1=115317&r2=115318&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Oct 1 12:46:38 2010 @@ -685,8 +685,20 @@ CommandObject (interpreter, "breakpoint list", "List some or all breakpoints at configurable levels of detail.", - "breakpoint list []") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData bp_id_arg; + + // Define the first (and only) variant of this arg. + bp_id_arg.arg_type = eArgTypeBreakpointID; + bp_id_arg.arg_repetition = eArgRepeatStar; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (bp_id_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectBreakpointList::~CommandObjectBreakpointList () @@ -774,14 +786,28 @@ CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) : CommandObject (interpreter, "enable", - "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", - "breakpoint enable [ | ]") + "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", + NULL) { - // This command object can either be called via 'enable' or 'breakpoint enable'. Because it has two different - // potential invocation methods, we need to be a little tricky about generating the syntax string. - //StreamString tmp_string; - //tmp_string.Printf ("%s ", GetCommandName()); - //m_cmd_syntax.assign (tmp_string.GetData(), tmp_string.GetSize()); + CommandArgumentEntry arg; + CommandArgumentData bp_id_arg; + CommandArgumentData bp_id_range_arg; + + // Create the first variant for the first (and only) argument for this command. + bp_id_arg.arg_type = eArgTypeBreakpointID; + bp_id_arg.arg_repetition = eArgRepeatStar; + + // Create the second variant for the first (and only) argument for this command. + bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; + bp_id_range_arg.arg_repetition = eArgRepeatStar; + + // The first (and only) argument for this command could be either a bp_id or a bp_id_range. + // Push both variants into the entry for the first argument for this command. + arg.push_back (bp_id_arg); + arg.push_back (bp_id_range_arg); + + // Add the entry for the first argument for this command to the object's arguments vector. + m_arguments.push_back (arg); } @@ -875,15 +901,29 @@ CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) : CommandObject (interpreter, - "disable", + "breakpoint disable", "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.", - "disable [ | ]") + NULL) { - // This command object can either be called via 'enable' or 'breakpoint enable'. Because it has two different - // potential invocation methods, we need to be a little tricky about generating the syntax string. - //StreamString tmp_string; - //tmp_string.Printf ("%s ", GetCommandName()); - //m_cmd_syntax.assign(tmp_string.GetData(), tmp_string.GetSize()); + CommandArgumentEntry arg; + CommandArgumentData bp_id_arg; + CommandArgumentData bp_id_range_arg; + + // Create the first variant for the first (and only) argument for this command. + bp_id_arg.arg_type = eArgTypeBreakpointID; + bp_id_arg.arg_repetition = eArgRepeatStar; + + // Create the second variant for the first (and only) argument for this command. + bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; + bp_id_range_arg.arg_repetition = eArgRepeatStar; + + // The first (and only) argument for this command could be either a bp_id or a bp_id_range. + // Push both variants into the entry for the first argument for this command. + arg.push_back (bp_id_arg); + arg.push_back (bp_id_range_arg); + + // Add the entry for the first argument for this command to the object's arguments vector. + m_arguments.push_back (arg); } CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable () @@ -977,8 +1017,27 @@ CommandObject (interpreter, "breakpoint delete", "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.", - "breakpoint delete [ | ]") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData bp_id_arg; + CommandArgumentData bp_id_range_arg; + + // Create the first variant for the first (and only) argument for this command. + bp_id_arg.arg_type = eArgTypeBreakpointID; + bp_id_arg.arg_repetition = eArgRepeatStar; + + // Create the second variant for the first (and only) argument for this command. + bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; + bp_id_range_arg.arg_repetition = eArgRepeatStar; + + // The first (and only) argument for this command could be either a bp_id or a bp_id_range. + // Push both variants into the entry for the first argument for this command. + arg.push_back (bp_id_arg); + arg.push_back (bp_id_range_arg); + + // Add the entry for the first argument for this command to the object's arguments vector. + m_arguments.push_back (arg); } @@ -1198,8 +1257,27 @@ CommandObject (interpreter, "breakpoint modify", "Modify the options on a breakpoint or set of breakpoints in the executable.", - "breakpoint modify [ ...]") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData bp_id_arg; + CommandArgumentData bp_id_range_arg; + + // Create the first variant for the first (and only) argument for this command. + bp_id_arg.arg_type = eArgTypeBreakpointID; + bp_id_arg.arg_repetition = eArgRepeatPlus; + + // Create the second variant for the first (and only) argument for this command. + bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; + bp_id_range_arg.arg_repetition = eArgRepeatPlus; + + // The first (and only) argument for this command could be either a bp_id or a bp_id_range. + // Push both variants into the entry for the first argument for this command. + arg.push_back (bp_id_arg); + arg.push_back (bp_id_range_arg); + + // Add the entry for the first argument for this command to the object's arguments vector. + m_arguments.push_back (arg); } CommandObjectBreakpointModify::~CommandObjectBreakpointModify () Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=115318&r1=115317&r2=115318&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Fri Oct 1 12:46:38 2010 @@ -95,7 +95,14 @@ Stream &output_strm = result.GetOutputStream(); if (sub_cmd_obj->GetOptions() != NULL) { - m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); + if (sub_cmd_obj->WantsRawCommandString()) + { + std::string help_text (sub_cmd_obj->GetHelp()); + help_text.append (" This command takes 'raw' input (no need to quote stuff)."); + m_interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); + } + else + m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); sub_cmd_obj->GetOptions()->GenerateOptionUsage (m_interpreter, output_strm, sub_cmd_obj); const char *long_help = sub_cmd_obj->GetHelpLong(); @@ -105,7 +112,14 @@ } else if (sub_cmd_obj->IsMultiwordObject()) { - m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); + if (sub_cmd_obj->WantsRawCommandString()) + { + std::string help_text (sub_cmd_obj->GetHelp()); + help_text.append (" This command takes 'raw' input (no need to quote stuff)."); + m_interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); + } + else + m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (result); } else @@ -114,6 +128,12 @@ if ((long_help != NULL) && (strlen (long_help) > 0)) output_strm.Printf ("\n%s", long_help); + else if (sub_cmd_obj->WantsRawCommandString()) + { + std::string help_text (sub_cmd_obj->GetHelp()); + help_text.append (" This command takes 'raw' input (no need to quote stuff)."); + m_interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); + } else m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); @@ -132,10 +152,21 @@ } else { - result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); - result.SetStatus (eReturnStatusFailed); + // Maybe the user is asking for help about a command argument rather than a command. + const CommandArgumentType arg_type = CommandObject::LookupArgumentName (command.GetArgumentAtIndex (0)); + if (arg_type != eArgTypeLastArg) + { + Stream &output_strm = result.GetOutputStream (); + CommandObject::GetArgumentHelp (output_strm, arg_type, m_interpreter); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendErrorWithFormat + ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", + command.GetArgumentAtIndex(0)); + result.SetStatus (eReturnStatusFailed); + } } } Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=115318&r1=115317&r2=115318&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Fri Oct 1 12:46:38 2010 @@ -196,11 +196,22 @@ { std::string indented_command (" "); indented_command.append (pos->first); - m_interpreter.OutputFormattedHelpText (result.GetOutputStream(), - indented_command.c_str(), - "--", - pos->second->GetHelp(), - max_len); + if (pos->second->WantsRawCommandString ()) + { + std::string help_text (pos->second->GetHelp()); + help_text.append (" This command takes 'raw' input (no need to quote stuff)."); + m_interpreter.OutputFormattedHelpText (result.GetOutputStream(), + indented_command.c_str(), + "--", + help_text.c_str(), + max_len); + } + else + m_interpreter.OutputFormattedHelpText (result.GetOutputStream(), + indented_command.c_str(), + "--", + pos->second->GetHelp(), + max_len); } output_stream.PutCString ("\nFor more help on any particular subcommand, type 'help '.\n"); Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=115318&r1=115317&r2=115318&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Fri Oct 1 12:46:38 2010 @@ -52,7 +52,8 @@ m_cmd_help_long (), m_cmd_syntax (), m_is_alias (false), - m_flags (flags) + m_flags (flags), + m_arguments() { if (help && help[0]) m_cmd_help_short = help; @@ -79,6 +80,20 @@ const char * CommandObject::GetSyntax () { + if (m_cmd_syntax.length() == 0) + { + StreamString syntax_str; + syntax_str.Printf ("%s", GetCommandName()); + if (GetOptions() != NULL) + syntax_str.Printf (" "); + if (m_arguments.size() > 0) + { + syntax_str.Printf (" "); + GetFormattedCommandArguments (syntax_str); + } + m_cmd_syntax = syntax_str.GetData (); + } + return m_cmd_syntax.c_str(); } @@ -431,3 +446,188 @@ return found_word; } + +int +CommandObject::GetNumArgumentEntries () +{ + return m_arguments.size(); +} + +CommandObject::CommandArgumentEntry * +CommandObject::GetArgumentEntryAtIndex (int idx) +{ + if (idx < m_arguments.size()) + return &(m_arguments[idx]); + + return NULL; +} + +CommandObject::ArgumentTableEntry * +CommandObject::FindArgumentDataByType (CommandArgumentType arg_type) +{ + const ArgumentTableEntry *table = CommandObject::GetArgumentTable(); + + for (int i = 0; i < eArgTypeLastArg; ++i) + if (table[i].arg_type == arg_type) + return (ArgumentTableEntry *) &(table[i]); + + return NULL; +} + +void +CommandObject::GetArgumentHelp (Stream &str, CommandArgumentType arg_type, CommandInterpreter &interpreter) +{ + const ArgumentTableEntry* table = CommandObject::GetArgumentTable(); + ArgumentTableEntry *entry = (ArgumentTableEntry *) &(table[arg_type]); + + // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... + + if (entry->arg_type != arg_type) + entry = CommandObject::FindArgumentDataByType (arg_type); + + if (!entry) + return; + + StreamString name_str; + name_str.Printf ("<%s>", entry->arg_name); + + if (entry->help_function != NULL) + interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", (*(entry->help_function)) (), + name_str.GetSize()); + else + interpreter.OutputFormattedHelpText (str, name_str.GetData(), "--", entry->help_text, name_str.GetSize()); +} + +const char * +CommandObject::GetArgumentName (CommandArgumentType arg_type) +{ + return CommandObject::GetArgumentTable()[arg_type].arg_name; +} + +void +CommandObject::GetFormattedCommandArguments (Stream &str) +{ + int num_args = m_arguments.size(); + for (int i = 0; i < num_args; ++i) + { + if (i > 0) + str.Printf (" "); + CommandArgumentEntry arg_entry = m_arguments[i]; + int num_alternatives = arg_entry.size(); + StreamString names; + for (int j = 0; j < num_alternatives; ++j) + { + if (j > 0) + names.Printf (" | "); + names.Printf ("%s", GetArgumentName (arg_entry[j].arg_type)); + } + switch (arg_entry[0].arg_repetition) + { + case eArgRepeatPlain: + str.Printf ("<%s>", names.GetData()); + break; + case eArgRepeatPlus: + str.Printf ("<%s> [<%s> [...]]", names.GetData(), names.GetData()); + break; + case eArgRepeatStar: + str.Printf ("[<%s> [<%s> [...]]]", names.GetData(), names.GetData()); + break; + case eArgRepeatOptional: + str.Printf ("[<%s>]", names.GetData()); + break; + } + } +} + +const CommandArgumentType +CommandObject::LookupArgumentName (const char *arg_name) +{ + CommandArgumentType return_type = eArgTypeLastArg; + + std::string arg_name_str (arg_name); + size_t len = arg_name_str.length(); + if (arg_name[0] == '<' + && arg_name[len-1] == '>') + arg_name_str = arg_name_str.substr (1, len-2); + + for (int i = 0; i < eArgTypeLastArg; ++i) + if (arg_name_str.compare (g_arguments_data[i].arg_name) == 0) + return_type = g_arguments_data[i].arg_type; + + return return_type; +} + +static const char * +BreakpointIDHelpTextCallback () +{ + return "Breakpoint ID's consist major and minor numbers; the major number corresponds to the single entity that was created with a 'breakpoint set' command; the minor numbers correspond to all the locations that were actually found/set based on the major breakpoint. A full breakpoint ID might look like 3.14, meaning the 14th location set for the 3rd breakpoint. You can specify all the locations of a breakpoint by just indicating the major breakpoint number. A valid breakpoint id consists either of just the major id number, or the major number, a dot, and the location number (e.g. 3 or 3.2 could both be valid breakpoint ids)."; +} + +static const char * +BreakpointIDRangeHelpTextCallback () +{ + return "A 'breakpoint id range' is a manner of specifying multiple breakpoints. This can be done through several mechanisms. The easiest way is to just enter a space-separated list of breakpoint ids. To specify all the breakpoint locations under a major breakpoint, you can use the major breakpoint number followed by '.*', eg. '5.*' means all the locations under breakpoint 5. You can also indicate a range of breakpoints by using - . The start-bp-id and end-bp-id for a range can be any valid breakpoint ids. It is not legal, however, to specify a range using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7 is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal."; +} + +CommandObject::ArgumentTableEntry +CommandObject::g_arguments_data[] = +{ + { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeArchitecture, "architecture", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeBreakpointID, "breakpoint-id", CommandCompletions::eNoCompletion, BreakpointIDHelpTextCallback, NULL }, + { eArgTypeBreakpointIDRange, "breakpoint-id-range", CommandCompletions::eNoCompletion, BreakpointIDRangeHelpTextCallback, NULL }, + { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeChannel, "channel", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeCount, "count", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeExpression, "expression", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeFilename, "filename", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeFullName, "full-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeLineNum, "line-num", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeName, "name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeOther, "other", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypePath, "path", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypePathPrefix, "path-prefix", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypePathPrefixPair, "path-prefix-pair", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypePid, "pid", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeSourceFile, "source-file", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeSymbol, "symbol", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeUUID, "UUID", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeUnixSignalNumber, "unix-signal-number", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeVarName, "var-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeValue, "value", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeNone, "none", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, +}; + +const CommandObject::ArgumentTableEntry* +CommandObject::GetArgumentTable () +{ + return CommandObject::g_arguments_data; +} + + Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=115318&r1=115317&r2=115318&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Fri Oct 1 12:46:38 2010 @@ -372,8 +372,13 @@ const uint32_t save_indent_level = strm.GetIndentLevel(); const char *name; + StreamString arguments_str; + if (cmd) + { name = cmd->GetCommandName(); + cmd->GetFormattedCommandArguments (arguments_str); + } else name = ""; @@ -517,6 +522,8 @@ } } } + if (arguments_str.GetSize() > 0) + strm.Printf (" %s", arguments_str.GetData()); } strm.Printf ("\n\n"); From johnny.chen at apple.com Fri Oct 1 13:08:29 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 01 Oct 2010 18:08:29 -0000 Subject: [Lldb-commits] [lldb] r115320 - /lldb/trunk/test/class_types/TestClassTypes.py Message-ID: <20101001180829.D44CE2A6C12E@llvm.org> Author: johnny Date: Fri Oct 1 13:08:29 2010 New Revision: 115320 URL: http://llvm.org/viewvc/llvm-project?rev=115320&view=rev Log: Only skip the test cases which are currently crashing, instead of the whole class. Also, the break by location needs to be modified after changees made to the main.cpp source code. Modified: lldb/trunk/test/class_types/TestClassTypes.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115320&r1=115319&r2=115320&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Fri Oct 1 13:08:29 2010 @@ -5,7 +5,6 @@ import lldb from lldbtest import * - at unittest2.skip("crash currently: rdar://problem/8502549") class ClassTypesTestCase(TestBase): mydir = "class_types" @@ -35,12 +34,14 @@ self.buildDwarf() self.breakpoint_creation_by_filespec_python() + @unittest2.skip("crash currently: rdar://problem/8502549") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.buildDsym() self.class_types_expr_parser() + @unittest2.skip("crash currently: rdar://problem/8502549") def test_with_dwarf_and_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.buildDwarf() @@ -52,8 +53,8 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break on the ctor function of class C. - self.expect("breakpoint set -f main.cpp -l 73", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = 73, locations = 1") + self.expect("breakpoint set -f main.cpp -l 93", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = 93, locations = 1") self.runCmd("run", RUN_SUCCEEDED) @@ -88,12 +89,12 @@ bpfilespec = lldb.SBFileSpec("main.cpp") - breakpoint = target.BreakpointCreateByLocation(bpfilespec, 73) + breakpoint = target.BreakpointCreateByLocation(bpfilespec, 93) self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) # Verify the breakpoint just created. self.expect("breakpoint list", BREAKPOINT_CREATED, - substrs = ['main.cpp:73']) + substrs = ['main.cpp:93']) self.runCmd("run", RUN_SUCCEEDED) From ctice at apple.com Fri Oct 1 14:59:14 2010 From: ctice at apple.com (Caroline Tice) Date: Fri, 01 Oct 2010 19:59:14 -0000 Subject: [Lldb-commits] [lldb] r115335 - in /lldb/trunk: include/lldb/ include/lldb/Interpreter/ source/Commands/ source/Interpreter/ tools/driver/ Message-ID: <20101001195914.ACF4B2A6C12F@llvm.org> Author: ctice Date: Fri Oct 1 14:59:14 2010 New Revision: 115335 URL: http://llvm.org/viewvc/llvm-project?rev=115335&view=rev Log: Modify command options to use the new arguments mechanism. Now all command option arguments are specified in a standardized way, will have a standardized name, and have functioning help. The next step is to start writing useful help for all the argument types. Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/include/lldb/lldb-types.h lldb/trunk/source/Commands/CommandObjectArgs.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectLog.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Fri Oct 1 14:59:14 2010 @@ -128,7 +128,7 @@ static void GetArgumentHelp (Stream &str, lldb::CommandArgumentType arg_type, CommandInterpreter &interpreter); - const char * + static const char * GetArgumentName (lldb::CommandArgumentType arg_type); void Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Oct 1 14:59:14 2010 @@ -519,8 +519,10 @@ eArgTypeChannel, eArgTypeCount, eArgTypeExpression, + eArgTypeExprFormat, eArgTypeFilename, eArgTypeFormat, + eArgTypeFrameNum, eArgTypeFullName, eArgTypeFunctionName, eArgTypeIndex, @@ -530,6 +532,7 @@ eArgTypeNumLines, eArgTypeNumberPerLine, eArgTypeOffset, + eArgTypeOneLiner, eArgTypeOther, eArgTypePath, eArgTypePathPrefix, @@ -541,6 +544,7 @@ eArgTypeRegisterName, eArgTypeRegularExpression, eArgTypeRunMode, + eArgTypeScriptLang, eArgTypeSearchWord, eArgTypeSelector, eArgTypeSettingIndex, Modified: lldb/trunk/include/lldb/lldb-types.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-types.h (original) +++ lldb/trunk/include/lldb/lldb-types.h Fri Oct 1 14:59:14 2010 @@ -139,7 +139,7 @@ int option_has_arg; // no_argument, required_argument or optional_argument OptionEnumValueElement *enum_values;// If non-NULL an array of enum values. uint32_t completionType; // Cookie the option class can use to do define the argument completion. - CONST_CHAR_PTR argument_name; // Text name to be use in usage text to refer to the option's value. + lldb::CommandArgumentType argument_type; // Type of argument this option takes CONST_CHAR_PTR usage_text; // Full text explaining what this options does and what (if any) argument to // pass it. } OptionDefinition; Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Fri Oct 1 14:59:14 2010 @@ -276,7 +276,7 @@ lldb::OptionDefinition CommandObjectArgs::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "debug", 'g', no_argument, NULL, 0, NULL, "Enable verbose debug logging of the expression parsing and evaluation."}, - { 0, false, NULL, 0, 0, NULL, NULL, NULL, NULL } + { LLDB_OPT_SET_1, false, "debug", 'g', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation."}, + { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Oct 1 14:59:14 2010 @@ -71,28 +71,28 @@ lldb::OptionDefinition CommandObjectBreakpointSet::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, "", + { LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Set the breakpoint only in this shared library (can use this option multiple times for multiple shlibs)."}, - { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, "", - "Set the number of times this breakpoint is sKipped before stopping." }, + { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, + "Set the number of times this breakpoint is skipped before stopping." }, - { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose index matches this argument."}, - { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."}, - { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."}, - { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."}, - { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "", + { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "Set the breakpoint by source location in this particular file."}, - { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, "", + { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, "Set the breakpoint by source location at this particular line."}, // Comment out this option for the moment, as we don't actually use it, but will in the future. @@ -100,26 +100,26 @@ // { 0, false, "column", 'c', required_argument, NULL, "", // "Set the breakpoint by source location at this particular column."}, - { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, "
", + { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress, "Set the breakpoint by address, at the specified address."}, - { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, "", + { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Set the breakpoint by function name - for C++ this means namespaces and arguments will be ignored." }, - { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, "", + { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName, "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguemnts, and " "for Objective C this means a full function prototype with class and selector." }, - { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, "", + { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, eArgTypeSelector, "Set the breakpoint by ObjC selector name." }, - { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, "", + { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, eArgTypeMethod, "Set the breakpoint by C++ method names." }, - { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, "", + { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, eArgTypeRegularExpression, "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." }, - { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; const lldb::OptionDefinition* @@ -616,21 +616,21 @@ lldb::OptionDefinition CommandObjectBreakpointList::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, NULL, + { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone, "Show debugger internal breakpoints" }, - { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, NULL, + { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone, "Give a brief description of the breakpoint (no location info)."}, // FIXME: We need to add an "internal" command, and then add this sort of thing to it. // But I need to see it for now, and don't want to wait. - { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, NULL, + { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone, "Give a full description of the breakpoint and its locations."}, - { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, NULL, + { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, "Explain everything we know about the breakpoint (for debugging debugger bugs)." }, - { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; const lldb::OptionDefinition* @@ -1157,14 +1157,14 @@ lldb::OptionDefinition CommandObjectBreakpointModify::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, NULL, "", "Set the number of times this breakpoint is skipped before stopping." }, -{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, "", "The breakpoint stops only for the thread whose indeX matches this argument."}, -{ LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, "", "The breakpoint stops only for the thread whose TID matches this argument."}, -{ LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, "", "The breakpoint stops only for the thread whose thread name matches this argument."}, -{ LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, "", "The breakpoint stops only for threads in the queue whose name is given by this argument."}, -{ LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, NULL, NULL, "Enable the breakpoint."}, -{ LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, NULL, NULL, "Disable the breakpoint."}, -{ 0, false, NULL, 0 , 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, NULL, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." }, +{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose indeX matches this argument."}, +{ LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."}, +{ LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."}, +{ LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."}, +{ LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, NULL, eArgTypeNone, "Enable the breakpoint."}, +{ LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, NULL, eArgTypeNone, "Disable the breakpoint."}, +{ 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL } }; const lldb::OptionDefinition* Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Oct 1 14:59:14 2010 @@ -48,19 +48,19 @@ lldb::OptionDefinition CommandObjectBreakpointCommandAdd::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "one-liner", 'o', required_argument, NULL, 0, "", + { LLDB_OPT_SET_ALL, false, "one-liner", 'o', required_argument, NULL, NULL, eArgTypeOneLiner, "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." }, - { LLDB_OPT_SET_1, true, "script", 's', no_argument, NULL, 0, NULL, + { LLDB_OPT_SET_1, true, "script", 's', no_argument, NULL, NULL, eArgTypeNone, "Write the breakpoint command script in the default scripting language."}, - { LLDB_OPT_SET_2, true, "python", 'p', no_argument, NULL, 0, NULL, + { LLDB_OPT_SET_2, true, "python", 'p', no_argument, NULL, NULL, eArgTypeNone, "Write the breakpoint command script in the Python scripting language."}, - - { LLDB_OPT_SET_3, true, "commands", 'c', no_argument, NULL, 0, NULL, + + { LLDB_OPT_SET_3, true, "commands", 'c', no_argument, NULL, NULL, eArgTypeNone, "Write the breakpoint command script using standard debugger commands."}, - { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; const lldb::OptionDefinition* Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Fri Oct 1 14:59:14 2010 @@ -120,19 +120,19 @@ lldb::OptionDefinition CommandObjectDisassemble::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_ALL, false, "bytes", 'b', no_argument, NULL, 0, NULL, "Show opcode bytes when disassembling."}, -{ LLDB_OPT_SET_ALL, false, "context", 'c', required_argument, NULL, 0, "", "Number of context lines of source to show."}, -{ LLDB_OPT_SET_ALL, false, "mixed", 'm', no_argument, NULL, 0, NULL, "Enable mixed source and assembly display."}, -{ LLDB_OPT_SET_ALL, false, "raw", 'r', no_argument, NULL, 0, NULL, "Print raw disassembly with no symbol information."}, +{ LLDB_OPT_SET_ALL, false, "bytes", 'b', no_argument, NULL, 0, eArgTypeNone, "Show opcode bytes when disassembling."}, +{ LLDB_OPT_SET_ALL, false, "context", 'c', required_argument, NULL, 0, eArgTypeNumLines, "Number of context lines of source to show."}, +{ LLDB_OPT_SET_ALL, false, "mixed", 'm', no_argument, NULL, 0, eArgTypeNone, "Enable mixed source and assembly display."}, +{ LLDB_OPT_SET_ALL, false, "raw", 'r', no_argument, NULL, 0, eArgTypeNone, "Print raw disassembly with no symbol information."}, -{ LLDB_OPT_SET_1, true, "start-address", 's', required_argument, NULL, 0, "", "Address to start disassembling."}, -{ LLDB_OPT_SET_1, false, "end-address", 'e', required_argument, NULL, 0, "", "Address to start disassembling."}, +{ LLDB_OPT_SET_1, true, "start-address", 's', required_argument, NULL, 0, eArgTypeAddress, "Address to start disassembling."}, +{ LLDB_OPT_SET_1, false, "end-address", 'e', required_argument, NULL, 0, eArgTypeAddress, "Address to start disassembling."}, -{ LLDB_OPT_SET_2, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, "", "Disassemble entire contents of the given function name."}, +{ LLDB_OPT_SET_2, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Disassemble entire contents of the given function name."}, -{ LLDB_OPT_SET_3, false, "current-frame", 'f', no_argument, NULL, 0, "", "Disassemble entire contents of the current frame's function."}, +//{ LLDB_OPT_SET_3, false, "current-frame", 'f', no_argument, NULL, 0, "", "Disassemble entire contents of the current frame's function."}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Fri Oct 1 14:59:14 2010 @@ -372,10 +372,11 @@ CommandObjectExpression::CommandOptions::g_option_table[] = { //{ LLDB_OPT_SET_ALL, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."}, -{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."}, -{ LLDB_OPT_SET_2, false, "object-description", 'o', no_argument, NULL, 0, NULL, "Print the object description of the value resulting from the expression"}, -{ LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, NULL, "Enable verbose debug logging of the expression parsing and evaluation."}, -{ LLDB_OPT_SET_ALL, false, "use-ir", 'i', no_argument, NULL, 0, NULL, "[Temporary] Instructs the expression evaluator to use IR instead of ASTs."}, -{ 0, false, NULL, 0, 0, NULL, NULL, NULL, NULL } +//{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."}, +{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the expression output should use."}, +{ LLDB_OPT_SET_2, false, "object-description", 'o', no_argument, NULL, 0, eArgTypeNone, "Print the object description of the value resulting from the expression"}, +{ LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation."}, +{ LLDB_OPT_SET_ALL, false, "use-ir", 'i', no_argument, NULL, 0, eArgTypeNone, "[Temporary] Instructs the expression evaluator to use IR instead of ASTs."}, +{ 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Fri Oct 1 14:59:14 2010 @@ -38,8 +38,8 @@ lldb::OptionDefinition CommandObjectFile::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "arch", 'a', required_argument, NULL, 0, "", "Specify the architecture to be used when the process is launched."}, - { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } + { LLDB_OPT_SET_1, false, "arch", 'a', required_argument, NULL, 0, eArgTypeArchitecture, "Specify the architecture to be used when the process is launched."}, + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; const lldb::OptionDefinition * Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Oct 1 14:59:14 2010 @@ -768,22 +768,22 @@ lldb::OptionDefinition CommandObjectFrameVariable::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "debug", 'D', no_argument, NULL, 0, NULL, "Enable verbose debug information."}, -{ LLDB_OPT_SET_1, false, "depth", 'd', required_argument, NULL, 0, "", "Set the max recurse depth when dumping aggregate types (default is infinity)."}, -{ LLDB_OPT_SET_1, false, "show-globals",'g', no_argument, NULL, 0, NULL, "Show the current frame source file global and static variables."}, -{ LLDB_OPT_SET_1, false, "find-global",'G', required_argument, NULL, 0, "", "Find a global variable by name (which might not be in the current stack frame source file)."}, -{ LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, NULL, "Show variable location information."}, -{ LLDB_OPT_SET_1, false, "show-declaration", 'c', no_argument, NULL, 0, NULL, "Show variable declaration information (source file and line where the variable was declared)."}, -{ LLDB_OPT_SET_1, false, "name", 'n', required_argument, NULL, 0, "", "Lookup a variable by name or regex (--regex) for the current execution context."}, -{ LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, NULL, "Omit function arguments."}, -{ LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, NULL, "Omit local variables."}, -{ LLDB_OPT_SET_1, false, "no-types", 't', no_argument, NULL, 0, NULL, "Omit variable type names."}, -{ LLDB_OPT_SET_1, false, "no-summary", 'y', no_argument, NULL, 0, NULL, "Omit summary information."}, -{ LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, NULL, "Show variable scope (argument, local, global, static)."}, -{ LLDB_OPT_SET_1, false, "objc", 'o', no_argument, NULL, 0, NULL, "When looking up a variable by name (--name), print as an Objective-C object."}, -{ LLDB_OPT_SET_1, false, "ptr-depth", 'p', required_argument, NULL, 0, "", "The number of pointers to be traversed when dumping values (default is zero)."}, -{ LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, NULL, "The argument for name lookups are regular expressions."}, -{ 0, false, NULL, 0, 0, NULL, NULL, NULL, NULL } +{ LLDB_OPT_SET_1, false, "debug", 'D', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug information."}, +{ LLDB_OPT_SET_1, false, "depth", 'd', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, +{ LLDB_OPT_SET_1, false, "show-globals",'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."}, +{ LLDB_OPT_SET_1, false, "find-global",'G', required_argument, NULL, 0, eArgTypeVarName, "Find a global variable by name (which might not be in the current stack frame source file)."}, +{ LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, +{ LLDB_OPT_SET_1, false, "show-declaration", 'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."}, +{ LLDB_OPT_SET_1, false, "name", 'n', required_argument, NULL, 0, eArgTypeVarName, "Lookup a variable by name or regex (--regex) for the current execution context."}, +{ LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."}, +{ LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."}, +{ LLDB_OPT_SET_1, false, "no-types", 't', no_argument, NULL, 0, eArgTypeNone, "Omit variable type names."}, +{ LLDB_OPT_SET_1, false, "no-summary", 'y', no_argument, NULL, 0, eArgTypeNone, "Omit summary information."}, +{ LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."}, +{ LLDB_OPT_SET_1, false, "objc", 'o', no_argument, NULL, 0, eArgTypeNone, "When looking up a variable by name (--name), print as an Objective-C object."}, +{ LLDB_OPT_SET_1, false, "ptr-depth", 'p', required_argument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."}, +{ LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeCount, "The argument for name lookups are regular expressions."}, +{ 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; #pragma mark CommandObjectMultiwordFrame Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Fri Oct 1 14:59:14 2010 @@ -1174,14 +1174,14 @@ lldb::OptionDefinition CommandObjectImageList::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "arch", 'a', optional_argument, NULL, 0, "", "Display the architecture when listing images."}, -{ LLDB_OPT_SET_1, false, "uuid", 'u', no_argument, NULL, 0, NULL, "Display the UUID when listing images."}, -{ LLDB_OPT_SET_1, false, "fullpath", 'f', optional_argument, NULL, 0, "", "Display the fullpath to the image object file."}, -{ LLDB_OPT_SET_1, false, "directory", 'd', optional_argument, NULL, 0, "", "Display the directory with optional width for the image object file."}, -{ LLDB_OPT_SET_1, false, "basename", 'b', optional_argument, NULL, 0, "", "Display the basename with optional width for the image object file."}, -{ LLDB_OPT_SET_1, false, "symfile", 's', optional_argument, NULL, 0, "", "Display the fullpath to the image symbol file with optional width."}, -{ LLDB_OPT_SET_1, false, "symfile-basename", 'S', optional_argument, NULL, 0, "", "Display the basename to the image symbol file with optional width."}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_1, false, "arch", 'a', optional_argument, NULL, 0, eArgTypeWidth, "Display the architecture when listing images."}, +{ LLDB_OPT_SET_1, false, "uuid", 'u', no_argument, NULL, 0, eArgTypeNone, "Display the UUID when listing images."}, +{ LLDB_OPT_SET_1, false, "fullpath", 'f', optional_argument, NULL, 0, eArgTypeWidth, "Display the fullpath to the image object file."}, +{ LLDB_OPT_SET_1, false, "directory", 'd', optional_argument, NULL, 0, eArgTypeWidth, "Display the directory with optional width for the image object file."}, +{ LLDB_OPT_SET_1, false, "basename", 'b', optional_argument, NULL, 0, eArgTypeWidth, "Display the basename with optional width for the image object file."}, +{ LLDB_OPT_SET_1, false, "symfile", 's', optional_argument, NULL, 0, eArgTypeWidth, "Display the fullpath to the image symbol file with optional width."}, +{ LLDB_OPT_SET_1, false, "symfile-basename", 'S', optional_argument, NULL, 0, eArgTypeWidth, "Display the basename to the image symbol file with optional width."}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -1531,17 +1531,17 @@ lldb::OptionDefinition CommandObjectImageLookup::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, true, "address", 'a', required_argument, NULL, 0, "", "Lookup an address in one or more executable images."}, -{ LLDB_OPT_SET_1, false, "offset", 'o', required_argument, NULL, 0, "", "When looking up an address subtract from any addresses before doing the lookup."}, -{ LLDB_OPT_SET_2, true, "symbol", 's', required_argument, NULL, 0, "", "Lookup a symbol by name in the symbol tables in one or more executable images."}, -{ LLDB_OPT_SET_2, false, "regex", 'r', no_argument, NULL, 0, NULL, "The argument for name lookups are regular expressions."}, -{ LLDB_OPT_SET_3, true, "file", 'f', required_argument, NULL, 0, "", "Lookup a file by fullpath or basename in one or more executable images."}, -{ LLDB_OPT_SET_3, false, "line", 'l', required_argument, NULL, 0, "", "Lookup a line number in a file (must be used in conjunction with --file)."}, -{ LLDB_OPT_SET_3, false, "no-inlines", 'i', no_argument, NULL, 0, NULL, "Check inline line entries (must be used in conjunction with --file)."}, -{ LLDB_OPT_SET_4, true, "function", 'n', required_argument, NULL, 0, "", "Lookup a function by name in the debug symbols in one or more executable images."}, -{ LLDB_OPT_SET_5, true, "type", 't', required_argument, NULL, 0, "", "Lookup a type by name in the debug symbols in one or more executable images."}, -{ LLDB_OPT_SET_ALL, false, "verbose", 'v', no_argument, NULL, 0, NULL, "Enable verbose lookup information."}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_1, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress, "Lookup an address in one or more executable images."}, +{ LLDB_OPT_SET_1, false, "offset", 'o', required_argument, NULL, 0, eArgTypeOffset, "When looking up an address subtract from any addresses before doing the lookup."}, +{ LLDB_OPT_SET_2, true, "symbol", 's', required_argument, NULL, 0, eArgTypeSymbol, "Lookup a symbol by name in the symbol tables in one or more executable images."}, +{ LLDB_OPT_SET_2, false, "regex", 'r', no_argument, NULL, 0, eArgTypeNone, "The argument for name lookups are regular expressions."}, +{ LLDB_OPT_SET_3, true, "file", 'f', required_argument, NULL, 0, eArgTypeFilename, "Lookup a file by fullpath or basename in one or more executable images."}, +{ LLDB_OPT_SET_3, false, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, "Lookup a line number in a file (must be used in conjunction with --file)."}, +{ LLDB_OPT_SET_3, false, "no-inlines", 'i', no_argument, NULL, 0, eArgTypeNone, "Check inline line entries (must be used in conjunction with --file)."}, +{ LLDB_OPT_SET_4, true, "function", 'n', required_argument, NULL, 0, eArgTypeFunctionName, "Lookup a function by name in the debug symbols in one or more executable images."}, +{ LLDB_OPT_SET_5, true, "type", 't', required_argument, NULL, 0, eArgTypeName, "Lookup a type by name in the debug symbols in one or more executable images."}, +{ LLDB_OPT_SET_ALL, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, "Enable verbose lookup information."}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectLog.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectLog.cpp Fri Oct 1 14:59:14 2010 @@ -217,15 +217,15 @@ lldb::OptionDefinition CommandObjectLogEnable::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, 0, "", "Set the destination file to log to."}, -{ LLDB_OPT_SET_1, false, "threadsafe", 't', no_argument, NULL, 0, NULL, "Enable thread safe logging to avoid interweaved log lines." }, -{ LLDB_OPT_SET_1, false, "verbose", 'v', no_argument, NULL, 0, NULL, "Enable verbose logging." }, -{ LLDB_OPT_SET_1, false, "debug", 'g', no_argument, NULL, 0, NULL, "Enable debug logging." }, -{ LLDB_OPT_SET_1, false, "sequence", 's', no_argument, NULL, 0, NULL, "Prepend all log lines with an increasing integer sequence id." }, -{ LLDB_OPT_SET_1, false, "timestamp", 'T', no_argument, NULL, 0, NULL, "Prepend all log lines with a timestamp." }, -{ LLDB_OPT_SET_1, false, "pid-tid", 'p', no_argument, NULL, 0, NULL, "Prepend all log lines with the process and thread ID that generates the log line." }, -{ LLDB_OPT_SET_1, false, "thread-name",'n', no_argument, NULL, 0, NULL, "Prepend all log lines with the thread name for the thread that generates the log line." }, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, 0, eArgTypeFilename, "Set the destination file to log to."}, +{ LLDB_OPT_SET_1, false, "threadsafe", 't', no_argument, NULL, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." }, +{ LLDB_OPT_SET_1, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, "Enable verbose logging." }, +{ LLDB_OPT_SET_1, false, "debug", 'g', no_argument, NULL, 0, eArgTypeNone, "Enable debug logging." }, +{ LLDB_OPT_SET_1, false, "sequence", 's', no_argument, NULL, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." }, +{ LLDB_OPT_SET_1, false, "timestamp", 'T', no_argument, NULL, 0, eArgTypeNone, "Prepend all log lines with a timestamp." }, +{ LLDB_OPT_SET_1, false, "pid-tid", 'p', no_argument, NULL, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." }, +{ LLDB_OPT_SET_1, false, "thread-name",'n', no_argument, NULL, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." }, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; class CommandObjectLogDisable : public CommandObject Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Fri Oct 1 14:59:14 2010 @@ -317,11 +317,11 @@ lldb::OptionDefinition CommandObjectMemoryRead::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "", "The format that will be used to display the memory. Defaults to bytes with ASCII (--format=Y)."}, - { LLDB_OPT_SET_1, false, "size", 's', required_argument, NULL, 0, "","The size in bytes to use when displaying with the selected format."}, - { LLDB_OPT_SET_1, false, "num-per-line", 'l', required_argument, NULL, 0, "", "The number of items per line to display."}, - { LLDB_OPT_SET_1, false, "count", 'c', required_argument, NULL, 0, "", "The number of total items to display."}, - { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } + { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat, "The format that will be used to display the memory. Defaults to bytes with ASCII (--format=Y)."}, + { LLDB_OPT_SET_1, false, "size", 's', required_argument, NULL, 0, eArgTypeByteSize,"The size in bytes to use when displaying with the selected format."}, + { LLDB_OPT_SET_1, false, "num-per-line", 'l', required_argument, NULL, 0, eArgTypeNumberPerLine, "The number of items per line to display."}, + { LLDB_OPT_SET_1, false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "The number of total items to display."}, + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -666,9 +666,9 @@ lldb::OptionDefinition CommandObjectMemoryWrite::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "", "The format value types that will be decoded and written to memory."}, - { LLDB_OPT_SET_1, false, "size", 's', required_argument, NULL, 0, "","The size in bytes of the values to write to memory."}, - { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } + { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat, "The format value types that will be decoded and written to memory."}, + { LLDB_OPT_SET_1, false, "size", 's', required_argument, NULL, 0, eArgTypeByteSize,"The size in bytes of the values to write to memory."}, + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Oct 1 14:59:14 2010 @@ -261,12 +261,12 @@ lldb::OptionDefinition CommandObjectProcessLaunch::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "stop-at-entry", 's', no_argument, NULL, 0, NULL, "Stop at the entry point of the program when launching a process."}, -{ LLDB_OPT_SET_1, false, "stdin", 'i', required_argument, NULL, 0, "", "Redirect stdin for the process to ."}, -{ LLDB_OPT_SET_1, false, "stdout", 'o', required_argument, NULL, 0, "", "Redirect stdout for the process to ."}, -{ LLDB_OPT_SET_1, false, "stderr", 'e', required_argument, NULL, 0, "", "Redirect stderr for the process to ."}, -{ LLDB_OPT_SET_1, false, "plugin", 'p', required_argument, NULL, 0, "", "Name of the process plugin you want to use."}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_1, false, "stop-at-entry", 's', no_argument, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."}, +{ LLDB_OPT_SET_1, false, "stdin", 'i', required_argument, NULL, 0, eArgTypePath, "Redirect stdin for the process to ."}, +{ LLDB_OPT_SET_1, false, "stdout", 'o', required_argument, NULL, 0, eArgTypePath, "Redirect stdout for the process to ."}, +{ LLDB_OPT_SET_1, false, "stderr", 'e', required_argument, NULL, 0, eArgTypePath, "Redirect stderr for the process to ."}, +{ LLDB_OPT_SET_1, false, "plugin", 'p', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -643,11 +643,11 @@ lldb::OptionDefinition CommandObjectProcessAttach::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_ALL, false, "plugin", 'P', required_argument, NULL, 0, "", "Name of the process plugin you want to use."}, -{ LLDB_OPT_SET_1, false, "pid", 'p', required_argument, NULL, 0, "", "The process ID of an existing process to attach to."}, -{ LLDB_OPT_SET_2, false, "name", 'n', required_argument, NULL, 0, "", "The name of the process to attach to."}, -{ LLDB_OPT_SET_2, false, "waitfor",'w', no_argument, NULL, 0, NULL, "Wait for the the process with to launch."}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_ALL, false, "plugin", 'P', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, +{ LLDB_OPT_SET_1, false, "pid", 'p', required_argument, NULL, 0, eArgTypePid, "The process ID of an existing process to attach to."}, +{ LLDB_OPT_SET_2, false, "name", 'n', required_argument, NULL, 0, eArgTypeProcessName, "The name of the process to attach to."}, +{ LLDB_OPT_SET_2, false, "waitfor",'w', no_argument, NULL, 0, eArgTypeNone, "Wait for the the process with to launch."}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; //------------------------------------------------------------------------- Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Fri Oct 1 14:59:14 2010 @@ -206,8 +206,9 @@ lldb::OptionDefinition CommandObjectSettingsSet::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "no-override", 'n', no_argument, NULL, NULL, NULL, "Prevents already existing instances and pending settings from being assigned this new value. Using this option means that only the default or specified instance setting values will be updated." }, - { LLDB_OPT_SET_2, false, "reset", 'r', no_argument, NULL, NULL, NULL, "Causes value to be reset to the original default for this variable. No value needs to be specified when this option is used." }, + { LLDB_OPT_SET_1, false, "no-override", 'n', no_argument, NULL, NULL, eArgTypeNone, "Prevents already existing instances and pending settings from being assigned this new value. Using this option means that only the default or specified instance setting values will be updated." }, + { LLDB_OPT_SET_2, false, "reset", 'r', no_argument, NULL, NULL, eArgTypeNone, "Causes value to be reset to the original default for this variable. No value needs to be specified when this option is used." }, + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; const lldb::OptionDefinition* Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Fri Oct 1 14:59:14 2010 @@ -134,9 +134,9 @@ lldb::OptionDefinition CommandObjectSourceInfo::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "line", 'l', required_argument, NULL, 0, "", "The line number at which to start the display source."}, -{ LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "", "The file from which to display source."}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_1, false, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, "The line number at which to start the display source."}, +{ LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "The file from which to display source."}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; #pragma mark CommandObjectSourceList @@ -558,12 +558,12 @@ lldb::OptionDefinition CommandObjectSourceList::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_ALL, false, "count", 'c', required_argument, NULL, 0, "", "The number of source lines to display."}, -{ LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, "", "Look up the source file in the given shared library."}, -{ LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "", "The file from which to display source."}, -{ LLDB_OPT_SET_1, false, "line", 'l', required_argument, NULL, 0, "", "The line number at which to start the display source."}, -{ LLDB_OPT_SET_2, false, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, "", "The name of a function whose source to display."}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_ALL, false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "The number of source lines to display."}, +{ LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Look up the source file in the given shared library."}, +{ LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "The file from which to display source."}, +{ LLDB_OPT_SET_1, false, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, "The line number at which to start the display source."}, +{ LLDB_OPT_SET_2, false, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeSymbol, "The name of a function whose source to display."}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; #pragma mark CommandObjectMultiwordSource Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Oct 1 14:59:14 2010 @@ -467,9 +467,9 @@ lldb::OptionDefinition CommandObjectThreadBacktrace::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "count", 'c', required_argument, NULL, 0, "", "How many frames to display (-1 for all)"}, -{ LLDB_OPT_SET_1, false, "start", 's', required_argument, NULL, 0, "", "Frame in which to start the backtrace"}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_1, false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "How many frames to display (-1 for all)"}, +{ LLDB_OPT_SET_1, false, "start", 's', required_argument, NULL, 0, eArgTypeFrameNum, "Frame in which to start the backtrace"}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; enum StepScope @@ -772,10 +772,10 @@ lldb::OptionDefinition CommandObjectThreadStepWithTypeAndScope::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "avoid-no-debug", 'a', required_argument, NULL, 0, "", "A boolean value that sets whether step-in will step over functions with no debug information."}, -{ LLDB_OPT_SET_1, false, "run-mode", 'm', required_argument, g_tri_running_mode, 0, "", "Determine how to run other threads while stepping the current thread."}, -{ LLDB_OPT_SET_1, false, "step-over-regexp",'r', required_argument, NULL, 0, "", "A regular expression that defines function names to step over."}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_1, false, "avoid-no-debug", 'a', required_argument, NULL, 0, eArgTypeBoolean, "A boolean value that sets whether step-in will step over functions with no debug information."}, +{ LLDB_OPT_SET_1, false, "run-mode", 'm', required_argument, g_tri_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping the current thread."}, +{ LLDB_OPT_SET_1, false, "step-over-regexp",'r', required_argument, NULL, 0, eArgTypeRegularExpression, "A regular expression that defines function names to step over."}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -1215,10 +1215,10 @@ lldb::OptionDefinition CommandObjectThreadUntil::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "frame", 'f', required_argument, NULL, 0, "", "Frame index for until operation - defaults to 0"}, -{ LLDB_OPT_SET_1, false, "thread", 't', required_argument, NULL, 0, "", "Thread index for the thread for until operation"}, -{ LLDB_OPT_SET_1, false, "run-mode",'m', required_argument, g_duo_running_mode, 0, "","Determine how to run other threads while stepping this one"}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_1, false, "frame", 'f', required_argument, NULL, 0, eArgTypeFrameNum, "Frame index for until operation - defaults to 0"}, +{ LLDB_OPT_SET_1, false, "thread", 't', required_argument, NULL, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation"}, +{ LLDB_OPT_SET_1, false, "run-mode",'m', required_argument, g_duo_running_mode, 0, eArgTypeRunMode,"Determine how to run other threads while stepping this one"}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Fri Oct 1 14:59:14 2010 @@ -501,7 +501,14 @@ const char * CommandObject::GetArgumentName (CommandArgumentType arg_type) { - return CommandObject::GetArgumentTable()[arg_type].arg_name; + ArgumentTableEntry *entry = (ArgumentTableEntry *) &(CommandObject::GetArgumentTable()[arg_type]); + + // The table is *supposed* to be kept in arg_type order, but someone *could* have messed it up... + + if (entry->arg_type != arg_type) + entry = CommandObject::FindArgumentDataByType (arg_type); + + return entry->arg_name; } void @@ -574,15 +581,17 @@ { { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeArchitecture, "architecture", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, NULL, "A Boolean value: 'true' or 'false'" }, { eArgTypeBreakpointID, "breakpoint-id", CommandCompletions::eNoCompletion, BreakpointIDHelpTextCallback, NULL }, { eArgTypeBreakpointIDRange, "breakpoint-id-range", CommandCompletions::eNoCompletion, BreakpointIDRangeHelpTextCallback, NULL }, { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeChannel, "channel", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeCount, "count", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeCount, "count", CommandCompletions::eNoCompletion, NULL, "An unsigned integer." }, { eArgTypeExpression, "expression", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeFilename, "filename", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, NULL, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" }, + { eArgTypeFilename, "filename", CommandCompletions::eNoCompletion, NULL, "The name of a file (can include path)." }, { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeFrameNum, "frame-num", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeFullName, "full-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, @@ -592,6 +601,7 @@ { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeOneLiner, "one-line-breakpoint-command", CommandCompletions::eNoCompletion, NULL, "A breakpoint command that is entered as a single line of text." }, { eArgTypeOther, "other", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypePath, "path", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypePathPrefix, "path-prefix", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, @@ -603,6 +613,7 @@ { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Fri Oct 1 14:59:14 2010 @@ -484,20 +484,21 @@ if (full_options_table[i].usage_mask & opt_set_mask) { // Add current option to the end of out_stream. - + CommandArgumentType arg_type = full_options_table[i].argument_type; + if (full_options_table[i].required) { if (full_options_table[i].option_has_arg == required_argument) { - strm.Printf (" -%c %s", - full_options_table[i].short_option, - full_options_table[i].argument_name); + strm.Printf (" -%c <%s>", + full_options_table[i].short_option, + CommandObject::GetArgumentName (arg_type)); } else if (full_options_table[i].option_has_arg == optional_argument) { - strm.Printf (" -%c [%s]", + strm.Printf (" -%c [<%s>]", full_options_table[i].short_option, - full_options_table[i].argument_name); + CommandObject::GetArgumentName (arg_type)); } } } @@ -511,14 +512,16 @@ { // Add current option to the end of out_stream. + CommandArgumentType arg_type = full_options_table[i].argument_type; + if (! full_options_table[i].required) { if (full_options_table[i].option_has_arg == required_argument) - strm.Printf (" [-%c %s]", full_options_table[i].short_option, - full_options_table[i].argument_name); + strm.Printf (" [-%c <%s>]", full_options_table[i].short_option, + CommandObject::GetArgumentName (arg_type)); else if (full_options_table[i].option_has_arg == optional_argument) - strm.Printf (" [-%c [%s]]", full_options_table[i].short_option, - full_options_table[i].argument_name); + strm.Printf (" [-%c [<%s>]]", full_options_table[i].short_option, + CommandObject::GetArgumentName (arg_type)); } } } @@ -578,13 +581,18 @@ else strm.EOL(); + CommandArgumentType arg_type = full_options_table[i].argument_type; + + StreamString arg_name_str; + arg_name_str.Printf ("<%s>", CommandObject::GetArgumentName (arg_type)); + strm.Indent (); strm.Printf ("-%c", full_options_table[i].short_option); - if (full_options_table[i].argument_name != NULL) - strm.Printf (" %s", full_options_table[i].argument_name); + if (arg_type != eArgTypeNone) + strm.Printf (" <%s>", CommandObject::GetArgumentName (arg_type)); strm.Printf (" ( --%s", full_options_table[i].long_option); - if (full_options_table[i].argument_name != NULL) - strm.Printf (" %s", full_options_table[i].argument_name); + if (arg_type != eArgTypeNone) + strm.Printf (" <%s>", CommandObject::GetArgumentName (arg_type)); strm.PutCString(" )\n"); strm.IndentMore (5); Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=115335&r1=115334&r2=115335&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Fri Oct 1 14:59:14 2010 @@ -51,34 +51,34 @@ static lldb::OptionDefinition g_options[] = { - { LLDB_OPT_SET_1, true, "help", 'h', no_argument, NULL, NULL, NULL, + { LLDB_OPT_SET_1, true, "help", 'h', no_argument, NULL, NULL, eArgTypeNone, "Prints out the usage information for the LLDB debugger." }, - { LLDB_OPT_SET_2, true, "version", 'v', no_argument, NULL, NULL, NULL, + { LLDB_OPT_SET_2, true, "version", 'v', no_argument, NULL, NULL, eArgTypeNone, "Prints out the current version number of the LLDB debugger." }, - { LLDB_OPT_SET_3, true, "arch", 'a', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_3, true, "arch", 'a', required_argument, NULL, NULL, eArgTypeArchitecture, "Tells the debugger to use the specified architecture when starting and running the program. must be one of the architectures for which the program was compiled." }, - { LLDB_OPT_SET_3 | LLDB_OPT_SET_4, false, "script-language",'l', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_3 | LLDB_OPT_SET_4, false, "script-language",'l', required_argument, NULL, NULL, eArgTypeScriptLang, "Tells the debugger to use the specified scripting language for user-defined scripts, rather than the default. Valid scripting languages that can be specified include Python, Perl, Ruby and Tcl. Currently only the Python extensions have been implemented." }, - { LLDB_OPT_SET_3 | LLDB_OPT_SET_4, false, "debug", 'd', no_argument, NULL, NULL, NULL, + { LLDB_OPT_SET_3 | LLDB_OPT_SET_4, false, "debug", 'd', no_argument, NULL, NULL, eArgTypeNone, "Tells the debugger to print out extra information for debugging itself." }, - { LLDB_OPT_SET_3 | LLDB_OPT_SET_4, false, "source", 's', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_3 | LLDB_OPT_SET_4, false, "source", 's', required_argument, NULL, NULL, eArgTypeFilename, "Tells the debugger to read in and execute the file , which should contain lldb commands." }, - { LLDB_OPT_SET_3, true, "file", 'f', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_3, true, "file", 'f', required_argument, NULL, NULL, eArgTypeFilename, "Tells the debugger to use the file as the program to be debugged." }, - { LLDB_OPT_SET_ALL, false, "editor", 'e', no_argument, NULL, NULL, NULL, + { LLDB_OPT_SET_ALL, false, "editor", 'e', no_argument, NULL, NULL, eArgTypeNone, "Tells the debugger to open source files using the host's \"external editor\" mechanism." }, -// { LLDB_OPT_SET_4, true, "crash-log", 'c', required_argument, NULL, NULL, "", +// { LLDB_OPT_SET_4, true, "crash-log", 'c', required_argument, NULL, NULL, eArgTypeFilename, // "Load executable images from a crash log for symbolication." }, - { 0, false, NULL, 0, 0, NULL, NULL, NULL, NULL } + { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; @@ -173,6 +173,35 @@ } } +void +GetArgumentName (const CommandArgumentType arg_type, std::string &arg_name) +{ + //Fudge this function here, since we can't call the "real" version in lldb_private::CommandObject... + + switch (arg_type) + { + // Make cases for all the arg_types used in Driver.cpp + + case eArgTypeNone: + arg_name = ""; + break; + + case eArgTypeArchitecture: + arg_name = "architecture"; + break; + + case eArgTypeScriptLang: + arg_name = "script-language"; + break; + + case eArgTypeFilename: + arg_name = "filename"; + break; + } + return; +} + + void ShowUsage (FILE *out, lldb::OptionDefinition *option_table, Driver::OptionData data) { @@ -227,21 +256,24 @@ { if (option_table[i].usage_mask & opt_set_mask) { + CommandArgumentType arg_type = option_table[i].argument_type; + std::string arg_name; + GetArgumentName (arg_type, arg_name); if (option_table[i].required) { if (option_table[i].option_has_arg == required_argument) - fprintf (out, " -%c %s", option_table[i].short_option, option_table[i].argument_name); + fprintf (out, " -%c <%s>", option_table[i].short_option, arg_name.c_str()); else if (option_table[i].option_has_arg == optional_argument) - fprintf (out, " -%c [%s]", option_table[i].short_option, option_table[i].argument_name); + fprintf (out, " -%c [<%s>]", option_table[i].short_option, arg_name.c_str()); else fprintf (out, " -%c", option_table[i].short_option); } else { if (option_table[i].option_has_arg == required_argument) - fprintf (out, " [-%c %s]", option_table[i].short_option, option_table[i].argument_name); + fprintf (out, " [-%c <%s>]", option_table[i].short_option, arg_name.c_str()); else if (option_table[i].option_has_arg == optional_argument) - fprintf (out, " [-%c [%s]]", option_table[i].short_option, option_table[i].argument_name); + fprintf (out, " [-%c [<%s>]]", option_table[i].short_option, arg_name.c_str()); else fprintf (out, " [-%c]", option_table[i].short_option); } @@ -270,14 +302,18 @@ pos = options_seen.find (option_table[i].short_option); if (pos == options_seen.end()) { + CommandArgumentType arg_type = option_table[i].argument_type; + std::string arg_name; + GetArgumentName (arg_type, arg_name); + options_seen.insert (option_table[i].short_option); fprintf (out, "%*s-%c ", indent_level, "", option_table[i].short_option); - if (option_table[i].argument_name != NULL) - fprintf (out, "%s", option_table[i].argument_name); + if (arg_type != eArgTypeNone) + fprintf (out, "<%s>", arg_name.c_str()); fprintf (out, "\n"); fprintf (out, "%*s--%s ", indent_level, "", option_table[i].long_option); - if (option_table[i].argument_name != NULL) - fprintf (out, "%s", option_table[i].argument_name); + if (arg_type != eArgTypeNone) + fprintf (out, "<%s>", arg_name.c_str()); fprintf (out, "\n"); indent_level += 5; OutputFormattedUsageText (out, indent_level, option_table[i].usage_text, screen_width); From gclayton at apple.com Fri Oct 1 15:48:32 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 01 Oct 2010 20:48:32 -0000 Subject: [Lldb-commits] [lldb] r115343 - in /lldb/trunk: include/lldb/Symbol/ClangASTType.h include/lldb/Symbol/Type.h include/lldb/Symbol/TypeList.h source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/ClangASTType.cpp source/Symbol/Type.cpp source/Symbol/TypeList.cpp Message-ID: <20101001204832.8760F2A6C12E@llvm.org> Author: gclayton Date: Fri Oct 1 15:48:32 2010 New Revision: 115343 URL: http://llvm.org/viewvc/llvm-project?rev=115343&view=rev Log: Fixed an issue where if a method funciton was asked to be parsed before its containing class was parsed, we would crash. Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/include/lldb/Symbol/TypeList.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Symbol/TypeList.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Fri Oct 1 15:48:32 2010 @@ -28,7 +28,7 @@ class ClangASTType { protected: - ClangASTType (void *type, clang::ASTContext *ast_context) : + ClangASTType (lldb::clang_type_t type, clang::ASTContext *ast_context) : m_type (type), m_ast (ast_context) { @@ -57,7 +57,7 @@ } public: - void * + lldb::clang_type_t GetOpaqueQualType() const { return m_type; @@ -73,19 +73,19 @@ GetClangTypeName (); static ConstString - GetClangTypeName (void *clang_type); + GetClangTypeName (lldb::clang_type_t clang_type); uint64_t GetClangTypeBitWidth (); static uint64_t - GetClangTypeBitWidth (clang::ASTContext *ast_context, void *opaque_clang_qual_type); + GetClangTypeBitWidth (clang::ASTContext *ast_context, lldb::clang_type_t opaque_clang_qual_type); size_t GetTypeBitAlign (); static size_t - GetTypeBitAlign (clang::ASTContext *ast_context, void *clang_type); + GetTypeBitAlign (clang::ASTContext *ast_context, lldb::clang_type_t clang_type); void DumpValue (ExecutionContext *exe_ctx, @@ -103,7 +103,7 @@ static void DumpValue (clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + lldb::clang_type_t opaque_clang_qual_type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, @@ -129,7 +129,7 @@ static bool DumpTypeValue (clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + lldb::clang_type_t opaque_clang_qual_type, Stream *s, lldb::Format format, const DataExtractor &data, @@ -148,7 +148,7 @@ static void DumpSummary (clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + lldb::clang_type_t opaque_clang_qual_type, ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data, @@ -160,20 +160,20 @@ static void DumpTypeDescription (clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + lldb::clang_type_t opaque_clang_qual_type, Stream *s); lldb::Encoding GetEncoding (uint32_t &count); static lldb::Encoding - GetEncoding (void *opaque_clang_qual_type, uint32_t &count); + GetEncoding (lldb::clang_type_t opaque_clang_qual_type, uint32_t &count); lldb::Format GetFormat (); static lldb::Format - GetFormat (void *opaque_clang_qual_type); + GetFormat (lldb::clang_type_t opaque_clang_qual_type); bool GetValueAsScalar (const DataExtractor &data, @@ -183,7 +183,7 @@ static bool GetValueAsScalar (clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + lldb::clang_type_t opaque_clang_qual_type, const DataExtractor &data, uint32_t data_offset, size_t data_byte_size, @@ -194,7 +194,7 @@ IsDefined(); static bool - IsDefined (void *opaque_clang_qual_type); + IsDefined (lldb::clang_type_t opaque_clang_qual_type); bool SetValueFromScalar (const Scalar &value, @@ -202,7 +202,7 @@ static bool SetValueFromScalar (clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + lldb::clang_type_t opaque_clang_qual_type, const Scalar &value, Stream &strm); @@ -214,7 +214,7 @@ static bool ReadFromMemory (clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + lldb::clang_type_t opaque_clang_qual_type, ExecutionContext *exe_ctx, lldb::addr_t addr, lldb::AddressType address_type, @@ -228,17 +228,20 @@ static bool WriteToMemory (clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + lldb::clang_type_t opaque_clang_qual_type, ExecutionContext *exe_ctx, lldb::addr_t addr, lldb::AddressType address_type, StreamString &new_value); - void * + lldb::clang_type_t GetPointeeType (); - static void * - GetPointeeType (void *opaque_clang_qual_type); + static lldb::clang_type_t + GetPointeeType (lldb::clang_type_t opaque_clang_qual_type); + + static lldb::clang_type_t + RemoveFastQualifiers (lldb::clang_type_t); private: void *m_type; Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Fri Oct 1 15:48:32 2010 @@ -172,8 +172,15 @@ const lldb_private::Declaration & GetDeclaration () const; + // Get the clang type, and resolve definitions for any + // class/struct/union/enum types completely. lldb::clang_type_t - GetClangType (bool forward_decl_is_ok = false); + GetClangType (); + + // Get the clang type and leave class/struct/union/enum types as forward + // declarations if they haven't already been fully defined. + lldb::clang_type_t + GetClangForwardType (); clang::ASTContext * GetClangAST (); Modified: lldb/trunk/include/lldb/Symbol/TypeList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeList.h?rev=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/TypeList.h (original) +++ lldb/trunk/include/lldb/Symbol/TypeList.h Fri Oct 1 15:48:32 2010 @@ -56,18 +56,18 @@ GetClangASTContext (); void * - CreateClangPointerType (Type *type, bool forward_decl_is_ok); + CreateClangPointerType (Type *type); void * - CreateClangTypedefType (Type *typedef_type, Type *base_type, bool forward_decl_is_ok); + CreateClangTypedefType (Type *typedef_type, Type *base_type); // For C++98 references (&) void * - CreateClangLValueReferenceType (Type *type, bool forward_decl_is_ok); + CreateClangLValueReferenceType (Type *type); // For C++0x references (&&) void * - CreateClangRValueReferenceType (Type *type, bool forward_decl_is_ok); + CreateClangRValueReferenceType (Type *type); private: typedef std::vector collection; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Fri Oct 1 15:48:32 2010 @@ -530,7 +530,7 @@ for (pos = m_die_array.begin(); pos != end; ++pos) { if (pos->Tag() == tag) - dies.Insert(&(*pos)); + dies.Append (&(*pos)); } // Return the number of DIEs added to the collection Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp?rev=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp Fri Oct 1 15:48:32 2010 @@ -29,6 +29,12 @@ return true; } +void +DWARFDIECollection::Append (const DWARFDebugInfoEntry *die) +{ + m_dies.push_back (die); +} + const DWARFDebugInfoEntry * DWARFDIECollection::GetDIEPtrAtIndex(uint32_t idx) const { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h?rev=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h Fri Oct 1 15:48:32 2010 @@ -25,6 +25,9 @@ } void + Append (const DWARFDebugInfoEntry *die); + + void Dump(lldb_private::Stream *s, const char* title) const; const DWARFDebugInfoEntry* 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=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Oct 1 15:48:32 2010 @@ -52,6 +52,15 @@ #include +//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN + +#ifdef ENABLE_DEBUG_PRINTF +#include +#define DEBUG_PRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__) +#else +#define DEBUG_PRINTF(fmt, ...) +#endif + #define DIE_IS_BEING_PARSED ((lldb_private::Type*)1) using namespace lldb; @@ -579,8 +588,30 @@ int call_column = 0; DWARFExpression frame_base; - // Parse the function prototype as a type that can then be added to concrete function instance - ParseTypes (sc, dwarf_cu, die, false, false); + assert (die->Tag() == DW_TAG_subprogram); + + if (die->Tag() != DW_TAG_subprogram) + return NULL; + + const DWARFDebugInfoEntry *parent_die = die->GetParent(); + switch (parent_die->Tag()) + { + case DW_TAG_structure_type: + case DW_TAG_class_type: + // We have methods of a class or struct + { + Type *class_type = ResolveType (dwarf_cu, parent_die); + if (class_type) + class_type->GetClangType(); + } + break; + + default: + // Parse the function prototype as a type that can then be added to concrete function instance + ParseTypes (sc, dwarf_cu, die, false, false); + break; + } + //FixupTypes(); if (die->GetDIENamesAndRanges(this, dwarf_cu, name, mangled, func_ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column, &frame_base)) @@ -1013,6 +1044,7 @@ const LanguageType class_language, std::vector& base_classes, std::vector& member_accessibilities, + DWARFDIECollection& member_function_dies, AccessType& default_accessibility, bool &is_a_class ) @@ -1103,8 +1135,8 @@ break; case DW_TAG_subprogram: - // Let the type parsing code handle this one for us... - ResolveType (dwarf_cu, die); + // Let the type parsing code handle this one for us. + member_function_dies.Append (die); break; case DW_TAG_inheritance: @@ -1220,7 +1252,7 @@ SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type) { // We have a struct/union/class/enum that needs to be fully resolved. - const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type); + const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (ClangASTType::RemoveFastQualifiers(clang_type)); assert (die); if (die == NULL) return NULL; @@ -1230,6 +1262,7 @@ const dw_tag_t tag = die->Tag(); + DEBUG_PRINTF ("0x%8.8x: %s (\"%s\") - resolve forward declaration...\n", die->GetOffset(), DW_TAG_value_to_name(tag), type->GetName().AsCString()); assert (clang_type); DWARFDebugInfoEntry::Attributes attributes; @@ -1240,82 +1273,96 @@ case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_class_type: - type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); - if (die->HasChildren()) + type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); + if (die->HasChildren()) + { + LanguageType class_language = eLanguageTypeUnknown; + if (ClangASTContext::IsObjCClassType (clang_type)) + class_language = eLanguageTypeObjC; + + int tag_decl_kind = -1; + AccessType default_accessibility = eAccessNone; + if (tag == DW_TAG_structure_type) + { + tag_decl_kind = clang::TTK_Struct; + default_accessibility = eAccessPublic; + } + else if (tag == DW_TAG_union_type) { - LanguageType class_language = eLanguageTypeUnknown; - if (ClangASTContext::IsObjCClassType (clang_type)) - class_language = eLanguageTypeObjC; + tag_decl_kind = clang::TTK_Union; + default_accessibility = eAccessPublic; + } + else if (tag == DW_TAG_class_type) + { + tag_decl_kind = clang::TTK_Class; + default_accessibility = eAccessPrivate; + } - int tag_decl_kind = -1; - AccessType default_accessibility = eAccessNone; - if (tag == DW_TAG_structure_type) - { - tag_decl_kind = clang::TTK_Struct; - default_accessibility = eAccessPublic; - } - else if (tag == DW_TAG_union_type) - { - tag_decl_kind = clang::TTK_Union; - default_accessibility = eAccessPublic; - } - else if (tag == DW_TAG_class_type) + SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); + std::vector base_classes; + std::vector member_accessibilities; + bool is_a_class = false; + // Parse members and base classes first + DWARFDIECollection member_function_dies; + + ParseChildMembers (sc, + cu, + die, + clang_type, + class_language, + base_classes, + member_accessibilities, + member_function_dies, + default_accessibility, + is_a_class); + + // Now parse any methods if there were any... + size_t num_functions = member_function_dies.Size(); + if (num_functions > 0) + { + for (size_t i=0; i base_classes; - std::vector member_accessibilities; - bool is_a_class = false; - ParseChildMembers (sc, - cu, - die, - clang_type, - class_language, - base_classes, - member_accessibilities, - default_accessibility, - is_a_class); - - // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we - // need to tell the clang type it is actually a class. - if (class_language != eLanguageTypeObjC) - { - if (is_a_class && tag_decl_kind != clang::TTK_Class) - type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class); - } - - // Since DW_TAG_structure_type gets used for both classes - // and structures, we may need to set any DW_TAG_member - // fields to have a "private" access if none was specified. - // When we parsed the child members we tracked that actual - // accessibility value for each DW_TAG_member in the - // "member_accessibilities" array. If the value for the - // member is zero, then it was set to the "default_accessibility" - // which for structs was "public". Below we correct this - // by setting any fields to "private" that weren't correctly - // set. - if (is_a_class && !member_accessibilities.empty()) - { - // This is a class and all members that didn't have - // their access specified are private. - type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size()); - } - - if (!base_classes.empty()) - { - type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size()); - - // Clang will copy each CXXBaseSpecifier in "base_classes" - // so we have to free them all. - ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size()); + ResolveType(cu, member_function_dies.GetDIEPtrAtIndex(i)); } - } - type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); - return clang_type; + + // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we + // need to tell the clang type it is actually a class. + if (class_language != eLanguageTypeObjC) + { + if (is_a_class && tag_decl_kind != clang::TTK_Class) + type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class); + } + + // Since DW_TAG_structure_type gets used for both classes + // and structures, we may need to set any DW_TAG_member + // fields to have a "private" access if none was specified. + // When we parsed the child members we tracked that actual + // accessibility value for each DW_TAG_member in the + // "member_accessibilities" array. If the value for the + // member is zero, then it was set to the "default_accessibility" + // which for structs was "public". Below we correct this + // by setting any fields to "private" that weren't correctly + // set. + if (is_a_class && !member_accessibilities.empty()) + { + // This is a class and all members that didn't have + // their access specified are private. + type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size()); + } + + if (!base_classes.empty()) + { + type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size()); + + // Clang will copy each CXXBaseSpecifier in "base_classes" + // so we have to free them all. + ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size()); + } + + } + type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); + return clang_type; case DW_TAG_enumeration_type: type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); @@ -2097,9 +2144,9 @@ Type *type = ResolveTypeUID(param_type_die_offset); if (type) { - function_param_types.push_back (type->GetClangType(true)); + function_param_types.push_back (type->GetClangForwardType()); - clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetClangType(), storage); + clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetClangForwardType(), storage); assert(param_var_decl); function_param_decls.push_back(param_var_decl); } @@ -2498,6 +2545,8 @@ } } + DEBUG_PRINTF ("0x%8.8x: %s (\"%s\") type => 0x%8.8x\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid); + switch (tag) { default: @@ -2648,6 +2697,8 @@ } } + DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr); + int tag_decl_kind = -1; AccessType default_accessibility = eAccessNone; if (tag == DW_TAG_structure_type) @@ -2698,7 +2749,7 @@ // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)" // When the definition needs to be defined. m_forward_decl_die_to_clang_type[die] = clang_type; - m_forward_decl_clang_type_to_die[clang_type] = die; + m_forward_decl_clang_type_to_die[ClangASTType::RemoveFastQualifiers (clang_type)] = die; } } @@ -2753,6 +2804,8 @@ } } + DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr); + clang_type_t enumerator_clang_type = NULL; clang_type = m_forward_decl_die_to_clang_type.lookup (die); if (clang_type == NULL) @@ -2777,7 +2830,7 @@ // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)" // When the definition needs to be defined. m_forward_decl_die_to_clang_type[die] = clang_type; - m_forward_decl_clang_type_to_die[clang_type] = die; + m_forward_decl_clang_type_to_die[ClangASTType::RemoveFastQualifiers (clang_type)] = die; } } @@ -2873,6 +2926,8 @@ } } + DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr); + clang_type_t return_clang_type = NULL; Type *func_type = NULL; @@ -2880,7 +2935,7 @@ func_type = ResolveTypeUID(type_die_offset); if (func_type) - return_clang_type = func_type->GetClangType(true); + return_clang_type = func_type->GetClangForwardType(); else return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); @@ -2953,7 +3008,7 @@ Type *class_type = ResolveType (dwarf_cu, parent_die); if (class_type) { - clang_type_t class_opaque_type = class_type->GetClangType (true); + clang_type_t class_opaque_type = class_type->GetClangForwardType(); if (ClangASTContext::IsCXXClassType (class_opaque_type)) { // Neither GCC 4.2 nor clang++ currently set a valid accessibility @@ -3049,6 +3104,8 @@ } } + DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr); + Type *element_type = ResolveTypeUID(type_die_offset); if (element_type) 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=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Oct 1 15:48:32 2010 @@ -241,6 +241,7 @@ const lldb::LanguageType class_language, std::vector& base_classes, std::vector& member_accessibilities, + DWARFDIECollection& member_function_dies, lldb::AccessType &default_accessibility, bool &is_a_class); Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Oct 1 15:48:32 2010 @@ -36,6 +36,7 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" +using namespace lldb; using namespace lldb_private; ClangASTType::~ClangASTType() @@ -49,12 +50,12 @@ } ConstString -ClangASTType::GetClangTypeName (void *opaque_clang_qual_type) +ClangASTType::GetClangTypeName (clang_type_t clang_type) { ConstString clang_type_name; - if (opaque_clang_qual_type) + if (clang_type) { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); const clang::TypedefType *typedef_type = qual_type->getAs(); if (typedef_type) @@ -80,18 +81,18 @@ } -void * +clang_type_t ClangASTType::GetPointeeType () { return GetPointeeType (m_type); } -void * -ClangASTType::GetPointeeType (void *opaque_clang_qual_type) +clang_type_t +ClangASTType::GetPointeeType (clang_type_t clang_type) { - if (opaque_clang_qual_type) + if (clang_type) { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); return qual_type.getTypePtr()->getPointeeType().getAsOpaquePtr(); } @@ -106,10 +107,10 @@ lldb::Encoding -ClangASTType::GetEncoding (void *opaque_clang_qual_type, uint32_t &count) +ClangASTType::GetEncoding (clang_type_t clang_type, uint32_t &count) { count = 1; - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); switch (qual_type->getTypeClass()) { @@ -201,9 +202,9 @@ } lldb::Format -ClangASTType::GetFormat (void *opaque_clang_qual_type) +ClangASTType::GetFormat (clang_type_t clang_type) { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); switch (qual_type->getTypeClass()) { @@ -321,7 +322,7 @@ ClangASTType::DumpValue ( clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + clang_type_t clang_type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, @@ -336,7 +337,7 @@ uint32_t depth ) { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); switch (qual_type->getTypeClass()) { case clang::Type::Record: @@ -588,7 +589,7 @@ data.Dump(s, data_byte_offset, format, data_byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size, bitfield_bit_offset); if (show_summary) - DumpSummary (ast_context, opaque_clang_qual_type, exe_ctx, s, data, data_byte_offset, data_byte_size); + DumpSummary (ast_context, clang_type, exe_ctx, s, data, data_byte_offset, data_byte_size); break; } } @@ -623,7 +624,7 @@ ClangASTType::DumpTypeValue ( clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + clang_type_t clang_type, Stream *s, lldb::Format format, const lldb_private::DataExtractor &data, @@ -633,8 +634,8 @@ uint32_t bitfield_bit_offset ) { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); - if (ClangASTContext::IsAggregateType (opaque_clang_qual_type)) + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); + if (ClangASTContext::IsAggregateType (clang_type)) { return 0; } @@ -729,7 +730,7 @@ ClangASTType::DumpSummary ( clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + clang_type_t clang_type, ExecutionContext *exe_ctx, Stream *s, const lldb_private::DataExtractor &data, @@ -738,8 +739,8 @@ ) { uint32_t length = 0; - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); - if (ClangASTContext::IsCStringType (opaque_clang_qual_type, length)) + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); + if (ClangASTContext::IsCStringType (clang_type, length)) { if (exe_ctx && exe_ctx->process) @@ -783,10 +784,10 @@ } uint64_t -ClangASTType::GetClangTypeBitWidth (clang::ASTContext *ast_context, void *opaque_clang_qual_type) +ClangASTType::GetClangTypeBitWidth (clang::ASTContext *ast_context, clang_type_t clang_type) { - if (ast_context && opaque_clang_qual_type) - return ast_context->getTypeSize(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + if (ast_context && clang_type) + return ast_context->getTypeSize(clang::QualType::getFromOpaquePtr(clang_type)); return 0; } @@ -797,10 +798,10 @@ } size_t -ClangASTType::GetTypeBitAlign (clang::ASTContext *ast_context, void *opaque_clang_qual_type) +ClangASTType::GetTypeBitAlign (clang::ASTContext *ast_context, clang_type_t clang_type) { - if (ast_context && opaque_clang_qual_type) - return ast_context->getTypeAlign(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + if (ast_context && clang_type) + return ast_context->getTypeAlign(clang::QualType::getFromOpaquePtr(clang_type)); return 0; } @@ -813,9 +814,9 @@ bool -ClangASTType::IsDefined (void *opaque_clang_qual_type) +ClangASTType::IsDefined (clang_type_t clang_type) { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); clang::TagType *tag_type = dyn_cast(qual_type.getTypePtr()); if (tag_type) { @@ -836,11 +837,11 @@ // Dump the full description of a type. For classes this means all of the // ivars and member functions, for structs/unions all of the members. void -ClangASTType::DumpTypeDescription (clang::ASTContext *ast_context, void *opaque_clang_qual_type, Stream *s) +ClangASTType::DumpTypeDescription (clang::ASTContext *ast_context, clang_type_t clang_type, Stream *s) { - if (opaque_clang_qual_type) + if (clang_type) { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); llvm::SmallVector buf; llvm::raw_svector_ostream llvm_ostrm (buf); @@ -922,23 +923,23 @@ ClangASTType::GetValueAsScalar ( clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + clang_type_t clang_type, const lldb_private::DataExtractor &data, uint32_t data_byte_offset, size_t data_byte_size, Scalar &value ) { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - if (ClangASTContext::IsAggregateType (opaque_clang_qual_type)) + if (ClangASTContext::IsAggregateType (clang_type)) { return false; // Aggregate types don't have scalar values } else { uint32_t count = 0; - lldb::Encoding encoding = GetEncoding (opaque_clang_qual_type, count); + lldb::Encoding encoding = GetEncoding (clang_type, count); if (encoding == lldb::eEncodingInvalid || count != 1) return false; @@ -1065,19 +1066,19 @@ ClangASTType::SetValueFromScalar ( clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + clang_type_t clang_type, const Scalar &value, Stream &strm ) { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); // Aggregate types don't have scalar values - if (!ClangASTContext::IsAggregateType (opaque_clang_qual_type)) + if (!ClangASTContext::IsAggregateType (clang_type)) { strm.GetFlags().Set(Stream::eBinary); uint32_t count = 0; - lldb::Encoding encoding = GetEncoding (opaque_clang_qual_type, count); + lldb::Encoding encoding = GetEncoding (clang_type, count); if (encoding == lldb::eEncodingInvalid || count != 1) return false; @@ -1163,7 +1164,7 @@ ClangASTType::ReadFromMemory ( clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + clang_type_t clang_type, lldb_private::ExecutionContext *exe_ctx, lldb::addr_t addr, lldb::AddressType address_type, @@ -1176,7 +1177,7 @@ // context (which Module it came from) return false; } - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8; if (data.GetByteSize() < byte_size) @@ -1227,7 +1228,7 @@ ClangASTType::WriteToMemory ( clang::ASTContext *ast_context, - void *opaque_clang_qual_type, + clang_type_t clang_type, lldb_private::ExecutionContext *exe_ctx, lldb::addr_t addr, lldb::AddressType address_type, @@ -1240,7 +1241,7 @@ // context (which Module it came from) return false; } - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8; if (byte_size > 0) @@ -1264,3 +1265,10 @@ } +lldb::clang_type_t +ClangASTType::RemoveFastQualifiers (lldb::clang_type_t clang_type) +{ + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); + qual_type.removeFastQualifiers(); + return qual_type.getAsOpaquePtr(); +} Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Fri Oct 1 15:48:32 2010 @@ -439,34 +439,34 @@ break; case eEncodingIsConstUID: - m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangType(true)); + m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangForwardType()); break; case eEncodingIsRestrictUID: - m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangType(true)); + m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangForwardType()); break; case eEncodingIsVolatileUID: - m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangType(true)); + m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangForwardType()); break; case eEncodingIsTypedefUID: - m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type, true); + m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type); // Clear the name so it can get fully qualified in case the // typedef is in a namespace. m_name.Clear(); break; case eEncodingIsPointerUID: - m_clang_qual_type = type_list->CreateClangPointerType (encoding_type, true); + m_clang_qual_type = type_list->CreateClangPointerType (encoding_type); break; case eEncodingIsLValueReferenceUID: - m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type, true); + m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type); break; case eEncodingIsRValueReferenceUID: - m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type, true); + m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type); break; default: @@ -584,14 +584,22 @@ } - clang_type_t -lldb_private::Type::GetClangType (bool forward_decl_is_ok) +lldb_private::Type::GetClangType () { + const bool forward_decl_is_ok = false; ResolveClangType(forward_decl_is_ok); return m_clang_qual_type; } +clang_type_t +lldb_private::Type::GetClangForwardType () +{ + const bool forward_decl_is_ok = true; + ResolveClangType (forward_decl_is_ok); + return m_clang_qual_type; +} + clang::ASTContext * lldb_private::Type::GetClangAST () { Modified: lldb/trunk/source/Symbol/TypeList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeList.cpp?rev=115343&r1=115342&r2=115343&view=diff ============================================================================== --- lldb/trunk/source/Symbol/TypeList.cpp (original) +++ lldb/trunk/source/Symbol/TypeList.cpp Fri Oct 1 15:48:32 2010 @@ -208,31 +208,33 @@ } void * -TypeList::CreateClangPointerType (Type *type, bool forward_decl_is_ok) +TypeList::CreateClangPointerType (Type *type) { assert(type); - return m_ast.CreatePointerType(type->GetClangType(forward_decl_is_ok)); + return m_ast.CreatePointerType(type->GetClangForwardType()); } void * -TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type, bool forward_decl_is_ok) +TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type) { assert(typedef_type && base_type); - return m_ast.CreateTypedefType(typedef_type->GetName().AsCString(), base_type->GetClangType(forward_decl_is_ok), typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID())); + return m_ast.CreateTypedefType (typedef_type->GetName().AsCString(), + base_type->GetClangForwardType(), + typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID())); } void * -TypeList::CreateClangLValueReferenceType (Type *type, bool forward_decl_is_ok) +TypeList::CreateClangLValueReferenceType (Type *type) { assert(type); - return m_ast.CreateLValueReferenceType(type->GetClangType(forward_decl_is_ok)); + return m_ast.CreateLValueReferenceType(type->GetClangForwardType()); } void * -TypeList::CreateClangRValueReferenceType (Type *type, bool forward_decl_is_ok) +TypeList::CreateClangRValueReferenceType (Type *type) { assert(type); - return m_ast.CreateRValueReferenceType (type->GetClangType(forward_decl_is_ok)); + return m_ast.CreateRValueReferenceType (type->GetClangForwardType()); } From ctice at apple.com Fri Oct 1 16:34:54 2010 From: ctice at apple.com (Caroline Tice) Date: Fri, 01 Oct 2010 21:34:54 -0000 Subject: [Lldb-commits] [lldb] r115351 - /lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Message-ID: <20101001213454.D9D202A6C12E@llvm.org> Author: ctice Date: Fri Oct 1 16:34:54 2010 New Revision: 115351 URL: http://llvm.org/viewvc/llvm-project?rev=115351&view=rev Log: Uncomment/fix "-f" command option for disassemble command. Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=115351&r1=115350&r2=115351&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Fri Oct 1 16:34:54 2010 @@ -130,7 +130,7 @@ { LLDB_OPT_SET_2, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Disassemble entire contents of the given function name."}, -//{ LLDB_OPT_SET_3, false, "current-frame", 'f', no_argument, NULL, 0, "", "Disassemble entire contents of the current frame's function."}, +{ LLDB_OPT_SET_3, false, "current-frame", 'f', no_argument, NULL, 0, eArgTypeNone, "Disassemble entire contents of the current frame's function."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; From johnny.chen at apple.com Fri Oct 1 17:59:49 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 01 Oct 2010 22:59:49 -0000 Subject: [Lldb-commits] [lldb] r115368 - in /lldb/trunk/test: dotest.py foundation/TestDisassemble.py lldbtest.py Message-ID: <20101001225949.EE8D92A6C12E@llvm.org> Author: johnny Date: Fri Oct 1 17:59:49 2010 New Revision: 115368 URL: http://llvm.org/viewvc/llvm-project?rev=115368&view=rev Log: o Added a new feature to the test framework to skip long running tests conditionally. To not skip long running tests, pass '-l' to the test driver (dotest.py). An example: @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") def test_foundation_disasm(self): ... o Added a long running disassemble test to the foundation directory, which iterates the code symbols from Foundation.framework and kicks off a disassemble command for for the named function symbol. Found a crasher: rdar://problem/8504895. o Plus added/updated some comments for the TestBase class. Modified: lldb/trunk/test/dotest.py lldb/trunk/test/foundation/TestDisassemble.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=115368&r1=115367&r2=115368&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Oct 1 17:59:49 2010 @@ -57,6 +57,9 @@ # Ignore the build search path relative to this script to locate the lldb.py module. ignore = False +# By default, we skip long running test case. Use "-l" option to override. +skipLongRunningTest = True + # The regular expression pattern to match against eligible filenames as our test cases. regexp = None @@ -80,6 +83,7 @@ -d : delay startup for 10 seconds (in order for the debugger to attach) -i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build tree relative to this script; use PYTHONPATH to locate the module +-l : don't skip long running test -p : specify a regexp filename pattern for inclusion in the test suite -t : trace lldb command execution and result -v : do verbose mode of unittest framework @@ -114,6 +118,7 @@ global configFile global delay global ignore + global skipLongRunningTest global regexp global verbose global testdirs @@ -146,6 +151,9 @@ elif sys.argv[index].startswith('-i'): ignore = True index += 1 + elif sys.argv[index].startswith('-l'): + skipLongRunningTest = False + index += 1 elif sys.argv[index].startswith('-p'): # Increment by 1 to fetch the reg exp pattern argument. index += 1 @@ -335,6 +343,11 @@ doDelay(10) # +# If '-l' is specified, do not skip the long running tests. +if not skipLongRunningTest: + os.environ["LLDB_SKIP_LONG_RUNNING_TEST"] = "NO" + +# # Walk through the testdirs while collecting test cases. # for testdir in testdirs: Modified: lldb/trunk/test/foundation/TestDisassemble.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestDisassemble.py?rev=115368&r1=115367&r2=115368&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestDisassemble.py (original) +++ lldb/trunk/test/foundation/TestDisassemble.py Fri Oct 1 17:59:49 2010 @@ -12,6 +12,39 @@ mydir = "foundation" + # rdar://problem/8504895 + # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]" + @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") + def test_foundation_disasm(self): + """Do 'disassemble -n func' on each and every 'Code' symbol entry from the Foundation.framework.""" + self.buildDefault() + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + self.runCmd("run", RUN_SUCCEEDED) + + self.runCmd("image list") + raw_output = self.res.GetOutput() + # Grok the full path to the foundation framework. + for line in raw_output.split(os.linesep): + match = re.search(" (/.*/Foundation.framework/.*)$", line) + if match: + foundation_framework = match.group(1) + break + + self.assertTrue(match, "Foundation.framework path located") + self.runCmd("image dump symtab %s" % foundation_framework) + raw_output = self.res.GetOutput() + # Now, grab every 'Code' symbol and feed it into the 'disassemble -n func' command. + for line in raw_output.split(os.linesep): + # The symbol name is on the last column and trails the flag column which ends with '0000'. + match = re.search(" Code .+0000 (.+)$", line) + if match: + func = match.group(1) + print "line:", line + print "func:", func + self.runCmd('disassemble -n "%s"' % func) + + def test_simple_disasm_with_dsym(self): """Test the lldb 'disassemble' command""" self.buildDsym() Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=115368&r1=115367&r2=115368&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Oct 1 17:59:49 2010 @@ -264,6 +264,17 @@ class TestBase(unittest2.TestCase): """This LLDB abstract base class is meant to be subclassed.""" + @classmethod + def skipLongRunningTest(cls): + """ + By default, we skip long running test case. + This can be overridden by passing '-l' to the test driver (dotest.py). + """ + if "LLDB_SKIP_LONG_RUNNING_TEST" in os.environ and "NO" == os.environ["LLDB_SKIP_LONG_RUNNING_TEST"]: + return False + else: + return True + # The concrete subclass should override this attribute. mydir = None @@ -286,6 +297,11 @@ @classmethod def setUpClass(cls): + """ + Python unittest framework class setup fixture. + Do current directory manipulation. + """ + # Fail fast if 'mydir' attribute is not overridden. if not cls.mydir or len(cls.mydir) == 0: raise Exception("Subclasses must override the 'mydir' attribute.") @@ -301,7 +317,10 @@ @classmethod def tearDownClass(cls): - """Do class-wide cleanup.""" + """ + Python unittest framework class teardown fixture. + Do class-wide cleanup. + """ # First, let's do the platform-specific cleanup. module = __import__(sys.platform) From johnny.chen at apple.com Fri Oct 1 18:05:03 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 01 Oct 2010 23:05:03 -0000 Subject: [Lldb-commits] [lldb] r115369 - /lldb/trunk/test/foundation/TestDisassemble.py Message-ID: <20101001230503.8551D2A6C12E@llvm.org> Author: johnny Date: Fri Oct 1 18:05:03 2010 New Revision: 115369 URL: http://llvm.org/viewvc/llvm-project?rev=115369&view=rev Log: Commented out two debug prints. Modified: lldb/trunk/test/foundation/TestDisassemble.py Modified: lldb/trunk/test/foundation/TestDisassemble.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestDisassemble.py?rev=115369&r1=115368&r2=115369&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestDisassemble.py (original) +++ lldb/trunk/test/foundation/TestDisassemble.py Fri Oct 1 18:05:03 2010 @@ -40,8 +40,8 @@ match = re.search(" Code .+0000 (.+)$", line) if match: func = match.group(1) - print "line:", line - print "func:", func + #print "line:", line + #print "func:", func self.runCmd('disassemble -n "%s"' % func) From gclayton at apple.com Fri Oct 1 18:13:49 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 01 Oct 2010 23:13:49 -0000 Subject: [Lldb-commits] [lldb] r115371 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20101001231349.E7CFB2A6C12E@llvm.org> Author: gclayton Date: Fri Oct 1 18:13:49 2010 New Revision: 115371 URL: http://llvm.org/viewvc/llvm-project?rev=115371&view=rev Log: Get the declaration names for C++ ctors, dtors, and operators from the right name pools. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=115371&r1=115370&r2=115371&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Oct 1 18:13:49 2010 @@ -803,6 +803,197 @@ return ast_context->getTagDeclType(decl).getAsOpaquePtr(); } +static bool +IsOperator (const char *name, OverloadedOperatorKind &op_kind) +{ + if (name == NULL || name[0] == '\0') + return false; + + if (::strstr(name, "operator ") != name) + return false; + + const char *post_op_name = name + 9; + + // This is an operator, set the overloaded operator kind to invalid + // in case this is a conversion operator... + op_kind = NUM_OVERLOADED_OPERATORS; + + switch (post_op_name[0]) + { + case 'n': + if (strcmp (post_op_name, "new") == 0) + op_kind = OO_New; + else if (strcmp (post_op_name, "new[]") == 0) + op_kind = OO_Array_New; + break; + + case 'd': + if (strcmp (post_op_name, "delete") == 0) + op_kind = OO_Delete; + else if (strcmp (post_op_name, "delete[]") == 0) + op_kind = OO_Array_Delete; + break; + + case '+': + if (post_op_name[1] == '\0') + op_kind = OO_Plus; + else if (post_op_name[2] == '\0') + { + if (post_op_name[1] == '=') + op_kind = OO_PlusEqual; + else if (post_op_name[1] == '+') + op_kind = OO_PlusPlus; + } + break; + + case '-': + if (post_op_name[1] == '\0') + op_kind = OO_Minus; + else if (post_op_name[2] == '\0') + { + switch (post_op_name[1]) + { + case '=': op_kind = OO_MinusEqual; break; + case '-': op_kind = OO_MinusMinus; break; + case '>': op_kind = OO_Arrow; break; + } + } + else if (post_op_name[3] == '\0') + { + if (post_op_name[2] == '*') + op_kind = OO_ArrowStar; break; + } + break; + + case '*': + if (post_op_name[1] == '\0') + op_kind = OO_Star; + else if (post_op_name[1] == '=' && post_op_name[2] == '\0') + op_kind = OO_StarEqual; + break; + + case '/': + if (post_op_name[1] == '\0') + op_kind = OO_Slash; + else if (post_op_name[1] == '=' && post_op_name[2] == '\0') + op_kind = OO_SlashEqual; + break; + + case '%': + if (post_op_name[1] == '\0') + op_kind = OO_Percent; + else if (post_op_name[1] == '=' && post_op_name[2] == '\0') + op_kind = OO_PercentEqual; + break; + + + case '^': + if (post_op_name[1] == '\0') + op_kind = OO_Caret; + else if (post_op_name[1] == '=' && post_op_name[2] == '\0') + op_kind = OO_CaretEqual; + break; + + case '&': + if (post_op_name[1] == '\0') + op_kind = OO_Amp; + else if (post_op_name[2] == '\0') + { + switch (post_op_name[1]) + { + case '=': op_kind = OO_AmpEqual; break; + case '&': op_kind = OO_AmpAmp; break; + } + } + break; + + case '|': + if (post_op_name[1] == '\0') + op_kind = OO_Pipe; + else if (post_op_name[2] == '\0') + { + switch (post_op_name[1]) + { + case '=': op_kind = OO_PipeEqual; break; + case '|': op_kind = OO_PipePipe; break; + } + } + break; + + case '~': + if (post_op_name[1] == '\0') + op_kind = OO_Tilde; + break; + + case '!': + if (post_op_name[1] == '\0') + op_kind = OO_Exclaim; + else if (post_op_name[1] == '=' && post_op_name[2] == '\0') + op_kind = OO_ExclaimEqual; + break; + + case '=': + if (post_op_name[1] == '\0') + op_kind = OO_Equal; + else if (post_op_name[1] == '=' && post_op_name[2] == '\0') + op_kind = OO_EqualEqual; + break; + + case '<': + if (post_op_name[1] == '\0') + op_kind = OO_Less; + else if (post_op_name[2] == '\0') + { + switch (post_op_name[1]) + { + case '<': op_kind = OO_LessLess; break; + case '=': op_kind = OO_LessEqual; break; + } + } + else if (post_op_name[3] == '\0') + { + if (post_op_name[2] == '=') + op_kind = OO_LessLessEqual; + } + break; + + case '>': + if (post_op_name[1] == '\0') + op_kind = OO_Greater; + else if (post_op_name[2] == '\0') + { + switch (post_op_name[1]) + { + case '>': op_kind = OO_GreaterGreater; break; + case '=': op_kind = OO_GreaterEqual; break; + } + } + else if (post_op_name[1] == '>' && + post_op_name[2] == '=' && + post_op_name[3] == '\0') + { + op_kind = OO_GreaterGreaterEqual; + } + break; + + case ',': + if (post_op_name[1] == '\0') + op_kind = OO_Comma; + break; + + case '(': + if (post_op_name[1] == ')' && post_op_name[2] == '\0') + op_kind = OO_Call; + break; + + case '[': + if (post_op_name[1] == ']' && post_op_name[2] == '\0') + op_kind = OO_Subscript; + break; + } + + return true; +} CXXMethodDecl * ClangASTContext::AddMethodToCXXRecordType ( @@ -854,7 +1045,7 @@ DeclarationName decl_name (&identifier_table->get(name)); - DeclarationNameInfo decl_name_info (decl_name, SourceLocation()); + ; const bool is_implicitly_declared = false; clang::Type *method_type(method_qual_type.getTypePtr()); @@ -873,7 +1064,7 @@ { cxx_method_decl = CXXDestructorDecl::Create (*ast_context, cxx_record_decl, - decl_name_info, + DeclarationNameInfo (ast_context->DeclarationNames.getCXXDestructorName (ast_context->getCanonicalType (method_qual_type)), SourceLocation()), method_qual_type, is_inline, is_implicitly_declared); @@ -882,7 +1073,7 @@ { cxx_method_decl = CXXConstructorDecl::Create (*ast_context, cxx_record_decl, - decl_name_info, + DeclarationNameInfo (ast_context->DeclarationNames.getCXXConstructorName (ast_context->getCanonicalType (method_qual_type)), SourceLocation()), method_qual_type, NULL, // TypeSourceInfo * is_explicit, @@ -891,26 +1082,39 @@ } else { - // TODO: verify this is an ok way to see if this is a C++ conversion - // operator. I am currently checking for "operator " following by a valid - // first character of a type name (A-Z, a-z, or _)... - if ((num_params == 0) && - (::strstr(name, "operator ") == name) && - (::isalpha(name[9]) || name[9] == '_')) + + OverloadedOperatorKind op_kind = NUM_OVERLOADED_OPERATORS; + if (IsOperator (name, op_kind)) { - cxx_method_decl = CXXConversionDecl::Create (*ast_context, + if (op_kind != NUM_OVERLOADED_OPERATORS) + { + cxx_method_decl = CXXMethodDecl::Create (*ast_context, cxx_record_decl, - decl_name_info, + DeclarationNameInfo (ast_context->DeclarationNames.getCXXOperatorName (op_kind), SourceLocation()), method_qual_type, NULL, // TypeSourceInfo * - is_inline, - is_explicit); + is_static, + SC_None, + is_inline); + } + else if (num_params == 0) + { + // Conversion operators don't take params... + cxx_method_decl = CXXConversionDecl::Create (*ast_context, + cxx_record_decl, + DeclarationNameInfo (ast_context->DeclarationNames.getCXXConversionFunctionName (ast_context->getCanonicalType (method_qual_type)), SourceLocation()), + method_qual_type, + NULL, // TypeSourceInfo * + is_inline, + is_explicit); + } } - else + + if (cxx_method_decl == NULL) { cxx_method_decl = CXXMethodDecl::Create (*ast_context, cxx_record_decl, - decl_name_info, + DeclarationNameInfo (decl_name, SourceLocation()), method_qual_type, NULL, // TypeSourceInfo * is_static, @@ -918,8 +1122,7 @@ is_inline); } } - - + AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access); cxx_method_decl->setAccess (access_specifier); From johnny.chen at apple.com Fri Oct 1 18:21:20 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 01 Oct 2010 23:21:20 -0000 Subject: [Lldb-commits] [lldb] r115372 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20101001232120.B53E32A6C12E@llvm.org> Author: johnny Date: Fri Oct 1 18:21:20 2010 New Revision: 115372 URL: http://llvm.org/viewvc/llvm-project?rev=115372&view=rev Log: Updated the expected match string when stopped on an objc instance method from: ARG: (struct objc_selector *) _cmd to ARG: (SEL) _cmd The change most likely resulted from an update from the llvm tot with a newer clang. Modified: lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=115372&r1=115371&r2=115372&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Fri Oct 1 18:21:20 2010 @@ -109,7 +109,7 @@ self.expect("frame variable -s", VARIABLES_DISPLAYED_CORRECTLY, substrs = ["ARG: (MyString *) self", - "ARG: (struct objc_selector *) _cmd"]) + "ARG: (SEL) _cmd"]) # Test new feature with r115115: # Add "-o" option to "expression" which prints the object description if available. From johnny.chen at apple.com Fri Oct 1 18:34:28 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 01 Oct 2010 23:34:28 -0000 Subject: [Lldb-commits] [lldb] r115380 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20101001233428.BFF442A6C12E@llvm.org> Author: johnny Date: Fri Oct 1 18:34:28 2010 New Revision: 115380 URL: http://llvm.org/viewvc/llvm-project?rev=115380&view=rev Log: I committed too fast. Both "struct objc_selector *" and "SEL" are possible, depending on the compiler used. Former if gcc/llvm-gcc, and latter if clang. Modified: lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=115380&r1=115379&r2=115380&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Fri Oct 1 18:34:28 2010 @@ -108,8 +108,9 @@ 'clang_type = "@interface MyString']) self.expect("frame variable -s", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["ARG: (MyString *) self", - "ARG: (SEL) _cmd"]) + substrs = ["ARG: (MyString *) self"], + patterns = ["ARG: \(.*\) _cmd", + "(struct objc_selector *)|(SEL)"]) # Test new feature with r115115: # Add "-o" option to "expression" which prints the object description if available. From scallanan at apple.com Fri Oct 1 20:07:50 2010 From: scallanan at apple.com (Sean Callanan) Date: Sat, 02 Oct 2010 01:07:50 -0000 Subject: [Lldb-commits] [lldb] r115394 - in /lldb/trunk: llvm.zip scripts/build-llvm.pl Message-ID: <20101002010750.3FE912A6C12E@llvm.org> Author: spyffe Date: Fri Oct 1 20:07:50 2010 New Revision: 115394 URL: http://llvm.org/viewvc/llvm-project?rev=115394&view=rev Log: Update to the latest Clang, which fixes a problem with importing class/struct types. Modified: lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=115394&r1=115393&r2=115394&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=115394&r1=115393&r2=115394&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Fri Oct 1 20:07:50 2010 @@ -25,7 +25,7 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "'{2010-09-28T19:30}'"; +our $llvm_revision = "'{2010-10-01T17:00}'"; our $llvm_source_dir = "$ENV{SRCROOT}"; our $cc = "$ENV{DEVELOPER_BIN_DIR}/gcc-4.2"; our $cxx = "$ENV{DEVELOPER_BIN_DIR}/g++-4.2"; From johnny.chen at apple.com Fri Oct 1 20:23:40 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 02 Oct 2010 01:23:40 -0000 Subject: [Lldb-commits] [lldb] r115397 - /lldb/trunk/test/foundation/TestDisassemble.py Message-ID: <20101002012340.967CA2A6C12E@llvm.org> Author: johnny Date: Fri Oct 1 20:23:40 2010 New Revision: 115397 URL: http://llvm.org/viewvc/llvm-project?rev=115397&view=rev Log: Use a more robust regexp to search for the 'Code' symbol. Plus compile the regexp once and use it within the for loop for some speedup. Modified: lldb/trunk/test/foundation/TestDisassemble.py Modified: lldb/trunk/test/foundation/TestDisassemble.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestDisassemble.py?rev=115397&r1=115396&r2=115397&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestDisassemble.py (original) +++ lldb/trunk/test/foundation/TestDisassemble.py Fri Oct 1 20:23:40 2010 @@ -34,10 +34,19 @@ self.assertTrue(match, "Foundation.framework path located") self.runCmd("image dump symtab %s" % foundation_framework) raw_output = self.res.GetOutput() - # Now, grab every 'Code' symbol and feed it into the 'disassemble -n func' command. + # Now, grab every 'Code' symbol and feed it into the command: + # 'disassemble -n func'. + # + # The symbol name is on the last column and trails the flag column which + # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits. + codeRE = re.compile(r""" + \ Code\ {9} # ' Code' followed by 9 SPCs, + .* # the wildcard chars, + 0x[0-9a-f]{8} # the flag column, and + \ (.+)$ # finally the function symbol. + """, re.VERBOSE) for line in raw_output.split(os.linesep): - # The symbol name is on the last column and trails the flag column which ends with '0000'. - match = re.search(" Code .+0000 (.+)$", line) + match = codeRE.search(line) if match: func = match.group(1) #print "line:", line From gclayton at apple.com Fri Oct 1 20:40:05 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 02 Oct 2010 01:40:05 -0000 Subject: [Lldb-commits] [lldb] r115398 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20101002014005.529DC2A6C12E@llvm.org> Author: gclayton Date: Fri Oct 1 20:40:05 2010 New Revision: 115398 URL: http://llvm.org/viewvc/llvm-project?rev=115398&view=rev Log: One final patch for all of this class constructor, destructor, and conversion operator naming stuff. We now get the constructor and destructor names right after passing in the type, and we get the correct conversion operator name after passing in the return type when getting the DeclarationNameInfo. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=115398&r1=115397&r2=115398&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Oct 1 20:40:05 2010 @@ -1045,15 +1045,14 @@ DeclarationName decl_name (&identifier_table->get(name)); - ; const bool is_implicitly_declared = false; - clang::Type *method_type(method_qual_type.getTypePtr()); + clang::FunctionType *function_Type = dyn_cast(method_qual_type.getTypePtr()); - if (method_type == NULL) + if (function_Type == NULL) return NULL; - FunctionProtoType *method_function_prototype (dyn_cast(method_type)); + FunctionProtoType *method_function_prototype (dyn_cast(function_Type)); if (!method_function_prototype) return NULL; @@ -1064,7 +1063,7 @@ { cxx_method_decl = CXXDestructorDecl::Create (*ast_context, cxx_record_decl, - DeclarationNameInfo (ast_context->DeclarationNames.getCXXDestructorName (ast_context->getCanonicalType (method_qual_type)), SourceLocation()), + DeclarationNameInfo (ast_context->DeclarationNames.getCXXDestructorName (ast_context->getCanonicalType (record_qual_type)), SourceLocation()), method_qual_type, is_inline, is_implicitly_declared); @@ -1073,7 +1072,7 @@ { cxx_method_decl = CXXConstructorDecl::Create (*ast_context, cxx_record_decl, - DeclarationNameInfo (ast_context->DeclarationNames.getCXXConstructorName (ast_context->getCanonicalType (method_qual_type)), SourceLocation()), + DeclarationNameInfo (ast_context->DeclarationNames.getCXXConstructorName (ast_context->getCanonicalType (record_qual_type)), SourceLocation()), method_qual_type, NULL, // TypeSourceInfo * is_explicit, @@ -1102,7 +1101,7 @@ // Conversion operators don't take params... cxx_method_decl = CXXConversionDecl::Create (*ast_context, cxx_record_decl, - DeclarationNameInfo (ast_context->DeclarationNames.getCXXConversionFunctionName (ast_context->getCanonicalType (method_qual_type)), SourceLocation()), + DeclarationNameInfo (ast_context->DeclarationNames.getCXXConversionFunctionName (ast_context->getCanonicalType (function_Type->getResultType())), SourceLocation()), method_qual_type, NULL, // TypeSourceInfo * is_inline, From johnny.chen at apple.com Fri Oct 1 20:46:20 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 02 Oct 2010 01:46:20 -0000 Subject: [Lldb-commits] [lldb] r115399 - in /lldb/trunk/test: class_types/TestClassTypes.py types/TestFloatTypesExpr.py types/TestIntegerTypesExpr.py Message-ID: <20101002014620.470002A6C12E@llvm.org> Author: johnny Date: Fri Oct 1 20:46:20 2010 New Revision: 115399 URL: http://llvm.org/viewvc/llvm-project?rev=115399&view=rev Log: Remove the @skip() and @expectedFaiure decorators, the previously affected tests have now all passed. rdar://problem/8502549 and rdar://problem/8493023 are fixed Modified: lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115399&r1=115398&r2=115399&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Fri Oct 1 20:46:20 2010 @@ -34,14 +34,12 @@ self.buildDwarf() self.breakpoint_creation_by_filespec_python() - @unittest2.skip("crash currently: rdar://problem/8502549") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.buildDsym() self.class_types_expr_parser() - @unittest2.skip("crash currently: rdar://problem/8502549") def test_with_dwarf_and_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.buildDwarf() Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=115399&r1=115398&r2=115399&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Fri Oct 1 20:46:20 2010 @@ -6,7 +6,6 @@ import unittest2 import lldb - at unittest2.skip("crash currently: rdar://problem/8502549") class FloatTypesTestCase(AbstractBase.GenericTester): mydir = "types" Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=115399&r1=115398&r2=115399&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Fri Oct 1 20:46:20 2010 @@ -6,14 +6,10 @@ import unittest2 import lldb - at unittest2.skip("crash currently: rdar://problem/8502549") class IntegerTypesTestCase(AbstractBase.GenericTester): mydir = "types" - # rdar://problem/8493023 - # test/types failures for Test*TypesExpr.py: element offset computed wrong and sign error? - def test_char_type_with_dsym(self): """Test that char-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'char.cpp'} @@ -42,7 +38,6 @@ self.setTearDownCleanup(dictionary=d) self.unsigned_char_type_expr() - @unittest2.expectedFailure def test_short_type_with_dsym(self): """Test that short-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'short.cpp'} @@ -50,7 +45,6 @@ self.setTearDownCleanup(dictionary=d) self.short_type_expr() - @unittest2.expectedFailure def test_short_type_with_dwarf(self): """Test that short-type variable expressions are evaluated correctly.""" d = {'CXX_SOURCES': 'short.cpp'} From gclayton at apple.com Sun Oct 3 20:05:56 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 04 Oct 2010 01:05:56 -0000 Subject: [Lldb-commits] [lldb] r115485 - in /lldb/trunk: include/lldb/Core/ include/lldb/Target/ source/API/ source/Commands/ source/Core/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/ source/Target/ Message-ID: <20101004010556.873152A6C12E@llvm.org> Author: gclayton Date: Sun Oct 3 20:05:56 2010 New Revision: 115485 URL: http://llvm.org/viewvc/llvm-project?rev=115485&view=rev Log: There are now to new "settings set" variables that live in each debugger instance: settings set frame-format settings set thread-format This allows users to control the information that is seen when dumping threads and frames. The default values are set such that they do what they used to do prior to changing over the the user defined formats. This allows users with terminals that can display color to make different items different colors using the escape control codes. A few alias examples that will colorize your thread and frame prompts are: settings set frame-format 'frame #${frame.index}: \033[0;33m${frame.pc}\033[0m{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{ \033[0;35mat \033[1;35m${line.file.basename}:${line.number}}\033[0m\n' settings set thread-format 'thread #${thread.index}: \033[1;33mtid\033[0;33m = ${thread.id}\033[0m{, \033[0;33m${frame.pc}\033[0m}{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{, \033[1;35mstop reason\033[0;35m = ${thread.stop-reason}\033[0m}{, \033[1;36mname = \033[0;36m${thread.name}\033[0m}{, \033[1;32mqueue = \033[0;32m${thread.queue}}\033[0m\n' A quick web search for "colorize terminal output" should allow you to see what you can do to make your output look like you want it. The "settings set" commands above can of course be added to your ~/.lldbinit file for permanent use. Changed the pure virtual void ExecutionContextScope::Calculate (ExecutionContext&); To: void ExecutionContextScope::CalculateExecutionContext (ExecutionContext&); I did this because this is a class that anything in the execution context heirarchy inherits from and "target->Calculate (exe_ctx)" didn't always tell you what it was really trying to do unless you look at the parameter. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Target/ExecutionContextScope.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/RegisterContext.h lldb/trunk/include/lldb/Target/StackFrame.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp lldb/trunk/source/Target/ExecutionContext.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/RegisterContext.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/StackFrameList.cpp lldb/trunk/source/Target/StopInfo.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Sun Oct 3 20:05:56 2010 @@ -93,7 +93,41 @@ m_prompt.assign ("(lldb) "); BroadcastPromptChange (m_instance_name, m_prompt.c_str()); } - + + const char * + GetFrameFormat() const + { + return m_frame_format.c_str(); + } + + bool + SetFrameFormat(const char *frame_format) + { + if (frame_format && frame_format[0]) + { + m_frame_format.assign (frame_format); + return true; + } + return false; + } + + const char * + GetThreadFormat() const + { + return m_thread_format.c_str(); + } + + bool + SetThreadFormat(const char *thread_format) + { + if (thread_format && thread_format[0]) + { + m_thread_format.assign (thread_format); + return true; + } + return false; + } + lldb::ScriptLanguage GetScriptLanguage() const { @@ -139,6 +173,12 @@ PromptVarName (); static const ConstString & + GetFrameFormatName (); + + static const ConstString & + GetThreadFormatName (); + + static const ConstString & ScriptLangVarName (); static const ConstString & @@ -151,6 +191,8 @@ uint32_t m_term_width; std::string m_prompt; + std::string m_frame_format; + std::string m_thread_format; lldb::ScriptLanguage m_script_lang; bool m_use_external_editor; }; Modified: lldb/trunk/include/lldb/Target/ExecutionContextScope.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ExecutionContextScope.h?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ExecutionContextScope.h (original) +++ lldb/trunk/include/lldb/Target/ExecutionContextScope.h Sun Oct 3 20:05:56 2010 @@ -63,7 +63,7 @@ /// in. //------------------------------------------------------------------ virtual void - Calculate (ExecutionContext &exe_ctx) = 0; + CalculateExecutionContext (ExecutionContext &exe_ctx) = 0; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Sun Oct 3 20:05:56 2010 @@ -1589,7 +1589,7 @@ CalculateStackFrame (); virtual void - Calculate (ExecutionContext &exe_ctx); + CalculateExecutionContext (ExecutionContext &exe_ctx); lldb::ProcessSP GetSP (); Modified: lldb/trunk/include/lldb/Target/RegisterContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/RegisterContext.h?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/RegisterContext.h (original) +++ lldb/trunk/include/lldb/Target/RegisterContext.h Sun Oct 3 20:05:56 2010 @@ -161,7 +161,7 @@ CalculateStackFrame (); virtual void - Calculate (ExecutionContext &exe_ctx); + CalculateExecutionContext (ExecutionContext &exe_ctx); protected: //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/StackFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StackFrame.h (original) +++ lldb/trunk/include/lldb/Target/StackFrame.h Sun Oct 3 20:05:56 2010 @@ -103,6 +103,9 @@ Disassemble (); void + DumpUsingSettingsFormat (Stream *strm); + + void Dump (Stream *strm, bool show_frame_index, bool show_fullpaths); bool @@ -142,7 +145,7 @@ CalculateStackFrame (); virtual void - Calculate (ExecutionContext &exe_ctx); + CalculateExecutionContext (ExecutionContext &exe_ctx); lldb::StackFrameSP GetSP (); Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Sun Oct 3 20:05:56 2010 @@ -402,6 +402,11 @@ return m_section_load_list; } + + static Target * + GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, + const SymbolContext *sc_ptr); + //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions //------------------------------------------------------------------ @@ -418,7 +423,7 @@ CalculateStackFrame (); virtual void - Calculate (ExecutionContext &exe_ctx); + CalculateExecutionContext (ExecutionContext &exe_ctx); PathMappingList & GetImageSearchPathList (); Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Sun Oct 3 20:05:56 2010 @@ -287,11 +287,7 @@ ClearStackFrames (); void - DumpInfo (Stream &strm, - bool show_stop_reason, - bool show_name, - bool show_queue, - uint32_t frame_idx);// = UINT32_MAX); + DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx); //------------------------------------------------------------------ // Thread Plan Providers: @@ -613,7 +609,7 @@ CalculateStackFrame (); virtual void - Calculate (ExecutionContext &exe_ctx); + CalculateExecutionContext (ExecutionContext &exe_ctx); lldb::StackFrameSP GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr); Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Sun Oct 3 20:05:56 2010 @@ -395,7 +395,7 @@ if (m_opaque_sp) { description.ref(); - m_opaque_sp->Dump (description.get(), true, false); + m_opaque_sp->DumpUsingSettingsFormat (description.get()); } else description.Printf ("No value"); Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Sun Oct 3 20:05:56 2010 @@ -431,9 +431,9 @@ ExecutionContext exe_ctx; if (process) - process->Calculate(exe_ctx); + process->CalculateExecutionContext(exe_ctx); else - m_opaque_sp->Calculate(exe_ctx); + m_opaque_sp->CalculateExecutionContext(exe_ctx); if (end_addr == LLDB_INVALID_ADDRESS || end_addr < start_addr) range.SetByteSize( DEFAULT_DISASM_BYTE_SIZE); @@ -484,9 +484,9 @@ process = NULL; if (process) - process->Calculate(exe_ctx); + process->CalculateExecutionContext(exe_ctx); else - m_opaque_sp->Calculate(exe_ctx); + m_opaque_sp->CalculateExecutionContext(exe_ctx); StreamFile out_stream (out); Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Sun Oct 3 20:05:56 2010 @@ -419,7 +419,7 @@ { if (m_opaque_sp) { - m_opaque_sp->DumpInfo (description.ref(), true, true, true, LLDB_INVALID_INDEX32); + m_opaque_sp->DumpUsingSettingsFormat (description.ref(), LLDB_INVALID_INDEX32); description.Printf (" %d frames, (instance name: %s)", GetNumFrames(), m_opaque_sp->GetInstanceName().AsCString()); } Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Sun Oct 3 20:05:56 2010 @@ -70,14 +70,10 @@ // char '#' while (pos != commands.end()) { - bool remove_string = false; size_t non_space = pos->find_first_not_of (k_space_characters); - if (non_space == std::string::npos) - remove_string = true; // Empty line - else if ((*pos)[non_space] == '#') - remove_string = true; // Comment line that starts with '#' - - if (remove_string) + // Check for empty line or comment line (lines whose first + // non-space character is a '#') + if (non_space == std::string::npos || (*pos)[non_space] == '#') pos = commands.erase(pos); else ++pos; Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Sun Oct 3 20:05:56 2010 @@ -71,7 +71,7 @@ ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame) { - exe_ctx.frame->Dump (&result.GetOutputStream(), true, false); + exe_ctx.frame->DumpUsingSettingsFormat (&result.GetOutputStream()); result.GetOutputStream().EOL(); result.SetStatus (eReturnStatusSuccessFinishResult); } Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Sun Oct 3 20:05:56 2010 @@ -80,13 +80,7 @@ } else { - thread->DumpInfo (strm, - true, // Dump the stop reason? - true, // Dump the thread name? - true, // Dump the queue name? - 0); // Display context info for stack frame zero - - strm.EOL(); + thread->DumpUsingSettingsFormat (strm, 0); } return true; @@ -164,12 +158,7 @@ if (num_frames == 0) return 0; - thread->DumpInfo (strm, - true, // Dump the stop reason? - true, // Dump the thread name? - true, // Dump the queue name? - num_frames > 1 ? UINT32_MAX : first_frame); // Dump info for the first stack frame if we are showing only on frame - strm.EOL(); + thread->DumpUsingSettingsFormat (strm, num_frames > 1 ? UINT32_MAX : first_frame); strm.IndentMore(); StackFrameSP frame_sp; @@ -224,8 +213,7 @@ if (show_frame_info) { strm.Indent(); - frame->Dump (&strm, true, false); - strm.EOL(); + frame->DumpUsingSettingsFormat (&strm); } SymbolContext sc (frame->GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry)); Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Sun Oct 3 20:05:56 2010 @@ -140,7 +140,7 @@ if (success) { ExecutionContext exe_ctx; - exe_scope->Calculate(exe_ctx); + exe_scope->CalculateExecutionContext(exe_ctx); // If we have any sections that are loaded, try and resolve using the // section load list if (exe_ctx.target && !exe_ctx.target->GetSectionLoadList().IsEmpty()) Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Sun Oct 3 20:05:56 2010 @@ -622,7 +622,7 @@ SymbolContext sc (frame->GetSymbolContext(eSymbolContextEverything)); ExecutionContext exe_ctx; - frame->Calculate(exe_ctx); + frame->CalculateExecutionContext(exe_ctx); const char *end = NULL; if (Debugger::FormatPrompt (prompt_format, &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, &end)) { @@ -814,12 +814,9 @@ } else if (::strncmp (var_name_begin, "target.", strlen("target.")) == 0) { - if (sc->target_sp || (exe_ctx && exe_ctx->process)) + Target *target = Target::GetTargetFromContexts (exe_ctx, sc); + if (target) { - Target *target = sc->target_sp.get(); - if (target == NULL) - target = &exe_ctx->process->GetTarget(); - assert (target); var_name_begin += ::strlen ("target."); if (::strncmp (var_name_begin, "arch}", strlen("arch}")) == 0) { @@ -838,10 +835,9 @@ case 'm': if (::strncmp (var_name_begin, "module.", strlen("module.")) == 0) { - Module *module = sc->module_sp.get(); - - if (module) + if (sc && sc->module_sp.get()) { + Module *module = sc->module_sp.get(); var_name_begin += ::strlen ("module."); if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0) @@ -1078,47 +1074,62 @@ // If format addr is valid, then we need to print an address if (format_addr.IsValid()) { + var_success = false; + if (calculate_format_addr_function_offset) { Address func_addr; - if (sc->function) - func_addr = sc->function->GetAddressRange().GetBaseAddress(); - else if (sc->symbol && sc->symbol->GetAddressRangePtr()) - func_addr = sc->symbol->GetAddressRangePtr()->GetBaseAddress(); - else - var_success = false; - if (var_success) + if (sc) + { + if (sc->function) + func_addr = sc->function->GetAddressRange().GetBaseAddress(); + else if (sc->symbol && sc->symbol->GetAddressRangePtr()) + func_addr = sc->symbol->GetAddressRangePtr()->GetBaseAddress(); + } + + if (func_addr.IsValid()) { if (func_addr.GetSection() == format_addr.GetSection()) { addr_t func_file_addr = func_addr.GetFileAddress(); addr_t addr_file_addr = format_addr.GetFileAddress(); if (addr_file_addr > func_file_addr) - { s.Printf(" + %llu", addr_file_addr - func_file_addr); - } else if (addr_file_addr < func_file_addr) - { s.Printf(" - %llu", func_file_addr - addr_file_addr); - } + var_success = true; } else - var_success = false; + { + Target *target = Target::GetTargetFromContexts (exe_ctx, sc); + if (target) + { + addr_t func_load_addr = func_addr.GetLoadAddress (target); + addr_t addr_load_addr = format_addr.GetLoadAddress (target); + if (addr_load_addr > func_load_addr) + s.Printf(" + %llu", addr_load_addr - func_load_addr); + else if (addr_load_addr < func_load_addr) + s.Printf(" - %llu", func_load_addr - addr_load_addr); + var_success = true; + } + } } } else { + Target *target = Target::GetTargetFromContexts (exe_ctx, sc); addr_t vaddr = LLDB_INVALID_ADDRESS; - if (exe_ctx && exe_ctx->process && !exe_ctx->process->GetTarget().GetSectionLoadList().IsEmpty()) - vaddr = format_addr.GetLoadAddress (&exe_ctx->process->GetTarget()); + if (exe_ctx && !target->GetSectionLoadList().IsEmpty()) + vaddr = format_addr.GetLoadAddress (target); if (vaddr == LLDB_INVALID_ADDRESS) vaddr = format_addr.GetFileAddress (); if (vaddr != LLDB_INVALID_ADDRESS) + { s.Printf("0x%16.16llx", vaddr); - else - var_success = false; + var_success = true; + } } } } @@ -1154,47 +1165,57 @@ case '0': // 1 to 3 octal chars { - unsigned long octal_value = 0; - ++p; - int i=0; - for (; i<3; ++i) + // Make a string that can hold onto the initial zero char, + // up to 3 octal digits, and a terminating NULL. + char oct_str[5] = { 0, 0, 0, 0, 0 }; + + int i; + for (i=0; (p[i] >= '0' && p[i] <= '7') && i<4; ++i) + oct_str[i] = p[i]; + + // We don't want to consume the last octal character since + // the main for loop will do this for us, so we advance p by + // one less than i (even if i is zero) + p += i - 1; + unsigned long octal_value = ::strtoul (oct_str, NULL, 8); + if (octal_value <= UINT8_MAX) { - if (*p >= '0' && *p <= '7') - octal_value = octal_value << 3 + (((uint8_t)*p) - '0'); - else - break; + char octal_char = octal_value; + s.Write (&octal_char, 1); } - if (i>0) - s.PutChar (octal_value); - else - s.PutCString ("\\0"); } break; case 'x': // hex number in the format + if (isxdigit(p[1])) { - ++p; + ++p; // Skip the 'x' - if (isxdigit(*p)) - { - char hex_str[3] = { 0,0,0 }; - hex_str[0] = *p; - ++p; - if (isxdigit(*p)) - hex_str[1] = *p; - unsigned long hex_value = strtoul (hex_str, NULL, 16); - s.PutChar (hex_value); - } - else + // Make a string that can hold onto two hex chars plus a + // NULL terminator + char hex_str[3] = { 0,0,0 }; + hex_str[0] = *p; + if (isxdigit(p[1])) { - s.PutCString ("\\x"); + ++p; // Skip the first of the two hex chars + hex_str[1] = *p; } + + unsigned long hex_value = strtoul (hex_str, NULL, 16); + if (hex_value <= UINT8_MAX) + s.PutChar (hex_value); + } + else + { + s.PutChar('x'); } break; default: - s << '\\' << *p; + // Just desensitize any other character by just printing what + // came after the '\' + s << *p; break; } @@ -1247,6 +1268,8 @@ InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance), m_term_width (80), m_prompt (), + m_frame_format (), + m_thread_format (), m_script_lang (), m_use_external_editor (false) { @@ -1265,13 +1288,14 @@ { const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); CopyInstanceSettings (pending_settings, false); - //m_owner.RemovePendingSettings (m_instance_name); } } DebuggerInstanceSettings::DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs) : InstanceSettings (*(Debugger::GetSettingsController().get()), CreateInstanceName ().AsCString()), m_prompt (rhs.m_prompt), + m_frame_format (rhs.m_frame_format), + m_thread_format (rhs.m_thread_format), m_script_lang (rhs.m_script_lang), m_use_external_editor (rhs.m_use_external_editor) { @@ -1291,6 +1315,8 @@ { m_term_width = rhs.m_term_width; m_prompt = rhs.m_prompt; + m_frame_format = rhs.m_frame_format; + m_thread_format = rhs.m_thread_format; m_script_lang = rhs.m_script_lang; m_use_external_editor = rhs.m_use_external_editor; } @@ -1338,7 +1364,15 @@ Error &err, bool pending) { - if (var_name == PromptVarName()) + + if (var_name == TermWidthVarName()) + { + if (ValidTermWidthValue (value, err)) + { + m_term_width = ::strtoul (value, NULL, 0); + } + } + else if (var_name == PromptVarName()) { UserSettingsController::UpdateStringVariable (op, m_prompt, value, err); if (!pending) @@ -1355,19 +1389,20 @@ BroadcastPromptChange (new_name, m_prompt.c_str()); } } + else if (var_name == GetFrameFormatName()) + { + UserSettingsController::UpdateStringVariable (op, m_frame_format, value, err); + } + else if (var_name == GetThreadFormatName()) + { + UserSettingsController::UpdateStringVariable (op, m_thread_format, value, err); + } else if (var_name == ScriptLangVarName()) { bool success; m_script_lang = Args::StringToScriptLanguage (value, eScriptLanguageDefault, &success); } - else if (var_name == TermWidthVarName()) - { - if (ValidTermWidthValue (value, err)) - { - m_term_width = ::strtoul (value, NULL, 0); - } - } else if (var_name == UseExternalEditorVarName ()) { UserSettingsController::UpdateBooleanVariable (op, m_use_external_editor, value, err); @@ -1382,7 +1417,7 @@ { if (var_name == PromptVarName()) { - value.AppendString (m_prompt.c_str()); + value.AppendString (m_prompt.c_str(), m_prompt.size()); } else if (var_name == ScriptLangVarName()) @@ -1395,6 +1430,14 @@ width_str.Printf ("%d", m_term_width); value.AppendString (width_str.GetData()); } + else if (var_name == GetFrameFormatName ()) + { + value.AppendString(m_frame_format.c_str(), m_frame_format.size()); + } + else if (var_name == GetThreadFormatName ()) + { + value.AppendString(m_thread_format.c_str(), m_thread_format.size()); + } else if (var_name == UseExternalEditorVarName()) { if (m_use_external_editor) @@ -1434,7 +1477,8 @@ BroadcastPromptChange (new_name, m_prompt.c_str()); } - + m_frame_format = new_debugger_settings->m_frame_format; + m_thread_format = new_debugger_settings->m_thread_format; m_term_width = new_debugger_settings->m_term_width; m_script_lang = new_debugger_settings->m_script_lang; m_use_external_editor = new_debugger_settings->m_use_external_editor; @@ -1500,6 +1544,22 @@ } const ConstString & +DebuggerInstanceSettings::GetFrameFormatName () +{ + static ConstString prompt_var_name ("frame-format"); + + return prompt_var_name; +} + +const ConstString & +DebuggerInstanceSettings::GetThreadFormatName () +{ + static ConstString prompt_var_name ("thread-format"); + + return prompt_var_name; +} + +const ConstString & DebuggerInstanceSettings::ScriptLangVarName () { static ConstString script_lang_var_name ("script-lang"); @@ -1537,15 +1597,32 @@ { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } }; +#define MODULE_WITH_FUNC "{ ${module.file.basename}`${function.name}{${function.pc-offset}}}" +#define FILE_AND_LINE "{ at ${line.file.basename}:${line.number}}" +#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\ + "{, ${frame.pc}}"\ + MODULE_WITH_FUNC\ + "{, stop reason = ${thread.stop-reason}}"\ + "{, name = ${thread.name}}"\ + "{, queue = ${thread.queue}}"\ + "\\n" + +#define DEFAULT_FRAME_FORMAT "frame #${frame.index}: ${frame.pc}"\ + MODULE_WITH_FUNC\ + FILE_AND_LINE\ + "\\n" SettingEntry Debugger::SettingsController::instance_settings_table[] = { - //{ "var-name", var-type , "default", enum-table, init'd, hidden, "help-text"}, - { "term-width" , eSetVarTypeInt, "80" , NULL, false , false , "The maximum number of columns to use for displaying text." }, - { "script-lang" , eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." }, - { "prompt" , eSetVarTypeString, "(lldb)", NULL, false, false, "The debugger command line prompt displayed for the user." }, - { "use-external-editor", eSetVarTypeBool, "false", NULL, false, false, "Whether to use an external editor or not." }, - { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } +// NAME Setting variable type Default Enum Init'd Hidden Help +// ======================= ======================= ====================== ==== ====== ====== ====================== +{ "term-width", eSetVarTypeInt, "80" , NULL, false, false, "The maximum number of columns to use for displaying text." }, +{ "script-lang", eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." }, +{ "prompt", eSetVarTypeString, "(lldb)", NULL, false, false, "The debugger command line prompt displayed for the user." }, +{ "frame-format", eSetVarTypeString, DEFAULT_FRAME_FORMAT, NULL, false, false, "The default frame format string to use when displaying thread information." }, +{ "thread-format", eSetVarTypeString, DEFAULT_THREAD_FORMAT, NULL, false, false, "The default thread format string to use when displaying thread information." }, +{ "use-external-editor", eSetVarTypeBool, "false", NULL, false, false, "Whether to use an external editor or not." }, +{ NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL } }; Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp Sun Oct 3 20:05:56 2010 @@ -66,7 +66,7 @@ return false; ExecutionContext exe_ctx; - exe_scope->Calculate(exe_ctx); + exe_scope->CalculateExecutionContext(exe_ctx); if (!exe_ctx.process) return false; Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp Sun Oct 3 20:05:56 2010 @@ -192,7 +192,7 @@ // making the object value a load address value and resolving it will get // the pointer sized data pointed to by that value... ExecutionContext exec_ctx; - thread.Calculate (exec_ctx); + thread.CalculateExecutionContext (exec_ctx); isa_value.SetValueType(Value::eValueTypeLoadAddress); isa_value.ResolveValue(&exec_ctx, clang_ast_context->getASTContext()); Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp Sun Oct 3 20:05:56 2010 @@ -60,7 +60,7 @@ { StreamString errors; ExecutionContext exc_context; - m_thread.Calculate(exc_context); + m_thread.CalculateExecutionContext(exc_context); m_func_sp.reset(m_impl_function->GetThreadPlanToCallFunction (exc_context, m_args_addr, errors, m_stop_others)); m_func_sp->SetPrivate(true); m_thread.QueueThreadPlan (m_func_sp, false); @@ -109,7 +109,7 @@ { Value target_addr_value; ExecutionContext exc_context; - m_thread.Calculate(exc_context); + m_thread.CalculateExecutionContext(exc_context); m_impl_function->FetchFunctionResults (exc_context, m_args_addr, target_addr_value); m_impl_function->DeallocateFunctionResults(exc_context, m_args_addr); lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong(); Modified: lldb/trunk/source/Target/ExecutionContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ExecutionContext.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Target/ExecutionContext.cpp (original) +++ lldb/trunk/source/Target/ExecutionContext.cpp Sun Oct 3 20:05:56 2010 @@ -59,7 +59,7 @@ ExecutionContext::ExecutionContext (ExecutionContextScope *exe_scope_ptr) { if (exe_scope_ptr) - exe_scope_ptr->Calculate (*this); + exe_scope_ptr->CalculateExecutionContext (*this); else { target = NULL; @@ -71,7 +71,7 @@ ExecutionContext::ExecutionContext (ExecutionContextScope &exe_scope_ref) { - exe_scope_ref.Calculate (*this); + exe_scope_ref.CalculateExecutionContext (*this); } void Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Sun Oct 3 20:05:56 2010 @@ -1818,7 +1818,7 @@ } void -Process::Calculate (ExecutionContext &exe_ctx) +Process::CalculateExecutionContext (ExecutionContext &exe_ctx) { exe_ctx.target = &m_target; exe_ctx.process = this; Modified: lldb/trunk/source/Target/RegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/RegisterContext.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Target/RegisterContext.cpp (original) +++ lldb/trunk/source/Target/RegisterContext.cpp Sun Oct 3 20:05:56 2010 @@ -226,12 +226,12 @@ } void -RegisterContext::Calculate (ExecutionContext &exe_ctx) +RegisterContext::CalculateExecutionContext (ExecutionContext &exe_ctx) { if (m_frame) - m_frame->Calculate (exe_ctx); + m_frame->CalculateExecutionContext (exe_ctx); else - m_thread.Calculate (exe_ctx); + m_thread.CalculateExecutionContext (exe_ctx); } Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Sun Oct 3 20:05:56 2010 @@ -14,6 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Module.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectVariable.h" @@ -248,7 +249,7 @@ if (m_disassembly.GetSize() == 0) { ExecutionContext exe_ctx; - Calculate(exe_ctx); + CalculateExecutionContext(exe_ctx); Target &target = m_thread.GetProcess().GetTarget(); Disassembler::Disassemble (target.GetDebugger(), target.GetArchitecture(), @@ -615,13 +616,36 @@ void -StackFrame::Calculate (ExecutionContext &exe_ctx) +StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx) { - m_thread.Calculate (exe_ctx); + m_thread.CalculateExecutionContext (exe_ctx); exe_ctx.frame = this; } void +StackFrame::DumpUsingSettingsFormat (Stream *strm) +{ + if (strm == NULL) + return; + + GetSymbolContext(eSymbolContextEverything); + ExecutionContext exe_ctx; + CalculateExecutionContext(exe_ctx); + const char *end = NULL; + StreamString s; + const char *frame_format = m_thread.GetProcess().GetTarget().GetDebugger().GetFrameFormat(); + if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s, &end)) + { + strm->Write(s.GetData(), s.GetSize()); + } + else + { + Dump (strm, true, false); + strm->EOL(); + } +} + +void StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths) { if (strm == NULL) Modified: lldb/trunk/source/Target/StackFrameList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrameList.cpp (original) +++ lldb/trunk/source/Target/StackFrameList.cpp Sun Oct 3 20:05:56 2010 @@ -260,7 +260,7 @@ if (frame) { frame->GetStackID().Dump (s); - frame->Dump(s, true, false); + frame->DumpUsingSettingsFormat (s); } else s->Printf("frame #%u", std::distance (begin, pos)); Modified: lldb/trunk/source/Target/StopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Target/StopInfo.cpp (original) +++ lldb/trunk/source/Target/StopInfo.cpp Sun Oct 3 20:05:56 2010 @@ -276,9 +276,9 @@ StreamString strm; const char *signal_name = m_thread.GetProcess().GetUnixSignals().GetSignalAsCString (m_value); if (signal_name) - strm.Printf("signal = %s", signal_name); + strm.Printf("signal %s", signal_name); else - strm.Printf("signal = %lli", m_value); + strm.Printf("signal %lli", m_value); m_description.swap (strm.GetString()); } return m_description.c_str(); Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Sun Oct 3 20:05:56 2010 @@ -708,7 +708,7 @@ } void -Target::Calculate (ExecutionContext &exe_ctx) +Target::CalculateExecutionContext (ExecutionContext &exe_ctx) { exe_ctx.target = this; exe_ctx.process = NULL; // Do NOT fill in process... @@ -794,6 +794,25 @@ lldb::eVarSetOperationAssign, false, "[]"); } +Target * +Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr) +{ + // The target can either exist in the "process" of ExecutionContext, or in + // the "target_sp" member of SymbolContext. This accessor helper function + // will get the target from one of these locations. + + Target *target = NULL; + if (sc_ptr != NULL) + target = sc_ptr->target_sp.get(); + if (target == NULL) + { + if (exe_ctx_ptr != NULL && exe_ctx_ptr->process != NULL) + target = &exe_ctx_ptr->process->GetTarget(); + } + return target; +} + + void Target::UpdateInstanceName () { Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=115485&r1=115484&r2=115485&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Sun Oct 3 20:05:56 2010 @@ -9,6 +9,7 @@ #include "lldb/lldb-private-log.h" #include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamString.h" @@ -810,9 +811,9 @@ } void -Thread::Calculate (ExecutionContext &exe_ctx) +Thread::CalculateExecutionContext (ExecutionContext &exe_ctx) { - m_process.Calculate (exe_ctx); + m_process.CalculateExecutionContext (exe_ctx); exe_ctx.thread = this; exe_ctx.frame = NULL; } @@ -872,52 +873,31 @@ } void -Thread::DumpInfo -( - Stream &strm, - bool show_stop_reason, - bool show_name, - bool show_queue, - uint32_t idx -) +Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx) { - strm.Printf("thread #%u: tid = 0x%4.4x", GetIndexID(), GetID()); + ExecutionContext exe_ctx; + SymbolContext frame_sc; + CalculateExecutionContext (exe_ctx); - if (idx != LLDB_INVALID_INDEX32) + if (frame_idx != LLDB_INVALID_INDEX32) { - StackFrameSP frame_sp(GetStackFrameAtIndex (idx)); + StackFrameSP frame_sp(GetStackFrameAtIndex (frame_idx)); if (frame_sp) { - strm.PutCString(", "); - frame_sp->Dump (&strm, false, false); + exe_ctx.frame = frame_sp.get(); + frame_sc = exe_ctx.frame->GetSymbolContext(eSymbolContextEverything); } } - if (show_stop_reason) - { - StopInfo *stop_info = GetStopInfo(); - - if (stop_info) - { - const char *stop_description = stop_info->GetDescription(); - if (stop_description) - strm.Printf (", stop reason = %s", stop_description); - } - } - - if (show_name) - { - const char *name = GetName(); - if (name && name[0]) - strm.Printf(", name = %s", name); - } - - if (show_queue) - { - const char *queue = GetQueueName(); - if (queue && queue[0]) - strm.Printf(", queue = %s", queue); - } + const char *thread_format = GetProcess().GetTarget().GetDebugger().GetThreadFormat(); + assert (thread_format); + const char *end = NULL; + Debugger::FormatPrompt (thread_format, + exe_ctx.frame ? &frame_sc : NULL, + &exe_ctx, + NULL, + strm, + &end); } lldb::ThreadSP From clattner at apple.com Sun Oct 3 20:18:43 2010 From: clattner at apple.com (Chris Lattner) Date: Sun, 3 Oct 2010 18:18:43 -0700 Subject: [Lldb-commits] [lldb] r115485 - in /lldb/trunk: include/lldb/Core/ include/lldb/Target/ source/API/ source/Commands/ source/Core/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/ source/Target/ In-Reply-To: <20101004010556.873152A6C12E@llvm.org> References: <20101004010556.873152A6C12E@llvm.org> Message-ID: On Oct 3, 2010, at 6:05 PM, Greg Clayton wrote: > Author: gclayton > Date: Sun Oct 3 20:05:56 2010 > New Revision: 115485 > > URL: http://llvm.org/viewvc/llvm-project?rev=115485&view=rev > Log: > There are now to new "settings set" variables that live in each debugger > instance: > > settings set frame-format > settings set thread-format > > This allows users to control the information that is seen when dumping > threads and frames. The default values are set such that they do what they > used to do prior to changing over the the user defined formats. Very cool. If you're interested, llvm::raw_ostream has ANSI color support, allowing you to do stuff like: OS.changeColor(raw_ostream::RED, /*bold*/true); OS << "whatever"; This is used by clang for its color diagnostics. -Chris From gclayton at apple.com Sun Oct 3 21:33:45 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 04 Oct 2010 02:33:45 -0000 Subject: [Lldb-commits] [lldb] r115488 - in /lldb/trunk/www: formats.html sidebar.incl Message-ID: <20101004023345.F234C2A6C12E@llvm.org> Author: gclayton Date: Sun Oct 3 21:33:45 2010 New Revision: 115488 URL: http://llvm.org/viewvc/llvm-project?rev=115488&view=rev Log: Added documentation for the new frame and thread format strings. Added: lldb/trunk/www/formats.html (with props) Modified: lldb/trunk/www/sidebar.incl Added: lldb/trunk/www/formats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/formats.html?rev=115488&view=auto ============================================================================== --- lldb/trunk/www/formats.html (added) +++ lldb/trunk/www/formats.html Sun Oct 3 21:33:45 2010 @@ -0,0 +1,225 @@ + + + + + +LLDB Homepage + + + +
+ The LLDB Debugger +
+ +
+
+ + +
+
+

Stack Frame and Thread Format

+
+

LLDB was recently modified to allow users to define the + format of the information that generates the descriptions + for threads and stack frames. Typically when your program stops + at a breakpoint you will get a line that describes why + your thread stopped:

+ +

* thread #1: tid = 0x2e03, 0x0000000100000e85 a.out`main + 4, stop reason = breakpoint 1.1

+ +

Stack backtraces frames also have a similar information line:

+ +

(lldb) thread backtrace +
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1 +
  frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19 +
  frame #1: 0x0000000100000e40 a.out`start + 52 +

+ +

The two format strings can currently be set using the settings set command:

+

(lldb) settings set frame-prompt STRING +
(lldb) settings set thread-prompt STRING +

+ +
+ +
+ +
+

Format Strings

+
+ +

So what is the format of the format strings? Format strings can + contain plain text, control characters and variables that have access + to the current program state.

+ +

Normal characters are any text that doesn't contain a '{', '}', '$', + or '\' character.

+ +

Variable names are found in between a "${" prefix, and + end with a "}" suffix. In other words, a variable looks like + "${frame.pc}".

+ +
+ +
+ +
+

Variables

+
+ +

A complete list of currently supported format string variables is listed below:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Variable NameDescription
file.basenameThe current compile unit file basename for the current frame.
file.fullpathThe current compile unit file fullpath for the current frame.
frame.indexThe frame index (0, 1, 2, 3...)
frame.pcThe generic frame register for the program counter.
frame.spThe generic frame register for the stack pointer.
frame.fpThe generic frame register for the frame pointer.
frame.flagsThe generic frame register for the flags register.
frame.reg.NAMEAccess to any platform specific register by name (replace NAME with the name of the desired register).
function.nameThe name of the current function or symbol
function.pc-offsetThe program counter offset within the current function or symbol
line.file.basenameThe line table entry basename to the file for the current line entry in the current frame.
line.file.fullpathThe line table entry fullpath to the file for the current line entry in the current frame.
line.numberThe line table entry line number for the current line entry in the current frame.
line.start-addrThe line table entry start address for the current line entry in the current frame.
line.end-addrThe line table entry end address for the current line entry in the current frame.
module.file.basenameThe basename of the current module (shared library or executable)
module.file.fullpathThe basename of the current module (shared library or executable)
process.file.basenameThe basename of the file for the process
process.file.fullpathThe fullname of the file for the process
process.idThe process ID native the the system on which the inferior runs.
process.nameThe name of the process at runtime
thread.idThe thread identifier for the current thread
thread.indexThe unique one based thread index ID which is guaranteed to be unique as threads come and go.
thread.nameThe name of the thread if the target OS supports naming threads
thread.queueThe queue name of the thread if the target OS supports dispatch queues
thread.stop-reasonA textual reason each thread stopped
target.archThe architecture of the current target
+ +
+ +
+ +
+

Control Characters

+
+ +

Control characters include '{', + '}', and '\'.

+ +

The '{' and '}' are used for scoping blocks, and the '\' character + allows you to desensitize control characters and also emit non-printable + characters. + +

+ +
+ +
+

Desensitizing Characters in the format string

+
+

The backslash control character allows your to enter the typical + "\a", "\b", "\f", "\n", + "\r", "\t", "\v", "\\", characters + and along with the standard octal representation "\0123" + and hex "\xAB" characters. This allows you to enter + escape characters into your format strings and will + allow colorized output for terminals that support color. + +

+ +
+ +
+

Scoping

+
+

Many times the information that you might have in your prompt might not be + available and you won't want it to print out if it isn't valid. To take care + of this you can enclose everything that must resolve into a scope. A scope + is starts with '{' and ends with + '}'. For example in order to only display + the current frame line table entry basename and line number when the information + is available for the current frame: + +

"{ at {$line.file.basename}:${line.number}}"

+ +

Broken down this is: +

    +
  • The start the scope

    "{"

  • +
  • format whose content will only be displayed if all information is available: +

    "at {$line.file.basename}:${line.number}"

  • +
  • end the scope:

    "}"

  • +
+ +
+ +
+ +
+

Making the Frame Format

+
+

The information that we see when stopped in a frame: + +

frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19

+ +

can be displayed with the following format:

+ +

"frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n"

+ +

This breaks down to: + +

    +
  • Always print the frame index and frame PC: + +

    "frame #${frame.index}: ${frame.pc}"

    + +
  • only print the module followed by a tick if there is a valid + module for the current frame: + +

    "{ ${module.file.basename}`}"

    + +
  • print the function name with optional offset:

    +

    "{${function.name}{${function.pc-offset}}}"

    + +
  • print the line info if it is available:

    + +

    "{ at ${line.file.basename}:${line.number}}"

    + +
  • then finish off with a newline:

    + +

    "\n"

    +
+ +
+ +
+ +
+

Making Your Own Formats

+
+ +

When modifying your own format strings, it is useful + to start with the default values for the frame and + thread format strings. These can be accessed with the + "settings show" command: + +

(lldb) settings show thread-format +
thread-format (string) = 'thread #${thread.index}: tid = ${thread.id}{, ${frame.pc}}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{, stop reason = ${thread.stop-reason}}{, name = ${thread.name}}{, queue = ${thread.queue}}\n' +
(lldb) settings show frame-format +
frame-format (string) = 'frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n' +

+ + +
+ +
+ +
+
+
+ + \ No newline at end of file Propchange: lldb/trunk/www/formats.html ------------------------------------------------------------------------------ svn:executable = * Modified: lldb/trunk/www/sidebar.incl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/sidebar.incl?rev=115488&r1=115487&r2=115488&view=diff ============================================================================== --- lldb/trunk/www/sidebar.incl (original) +++ lldb/trunk/www/sidebar.incl Sun Oct 3 21:33:45 2010 @@ -13,9 +13,10 @@ From gclayton at apple.com Sun Oct 3 21:44:26 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 04 Oct 2010 02:44:26 -0000 Subject: [Lldb-commits] [lldb] r115490 - /lldb/trunk/source/Core/Debugger.cpp Message-ID: <20101004024426.EB61F2A6C12E@llvm.org> Author: gclayton Date: Sun Oct 3 21:44:26 2010 New Revision: 115490 URL: http://llvm.org/viewvc/llvm-project?rev=115490&view=rev Log: Fixed an issue with the default frame format settings string where if a frame was stopped in a module, yet had no valid function for the PC, no module would be displayed. Modified: lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=115490&r1=115489&r2=115490&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Sun Oct 3 21:44:26 2010 @@ -1597,7 +1597,7 @@ { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } }; -#define MODULE_WITH_FUNC "{ ${module.file.basename}`${function.name}{${function.pc-offset}}}" +#define MODULE_WITH_FUNC "{ ${module.file.basename}{`${function.name}${function.pc-offset}}}" #define FILE_AND_LINE "{ at ${line.file.basename}:${line.number}}" #define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\ From gclayton at apple.com Sun Oct 3 22:06:05 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 04 Oct 2010 03:06:05 -0000 Subject: [Lldb-commits] [lldb] r115491 - /lldb/trunk/www/formats.html Message-ID: <20101004030605.294E82A6C12E@llvm.org> Author: gclayton Date: Sun Oct 3 22:06:05 2010 New Revision: 115491 URL: http://llvm.org/viewvc/llvm-project?rev=115491&view=rev Log: Clarified some caveats for thread format strings. Modified: lldb/trunk/www/formats.html Modified: lldb/trunk/www/formats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/formats.html?rev=115491&r1=115490&r2=115491&view=diff ============================================================================== --- lldb/trunk/www/formats.html (original) +++ lldb/trunk/www/formats.html Sun Oct 3 22:06:05 2010 @@ -214,6 +214,37 @@

+

When making thread formats, you will need surround any + of the information that comes from a stack frame with scopes ({ frame-content }) + as the thread format doesn't always want to show frame information. + When displaying the backtrace for a thread, we don't need to duplicate + the information for frame zero in the thread information: + +

(lldb) thread backtrace +
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1 2.1 +
  frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19 +
  frame #1: 0x0000000100000e40 a.out`start + 52 +
+

+ +

The frame related variables are: +

    +
  • ${file.*}
  • +
  • ${frame.*}
  • +
  • ${function.*}
  • +
  • ${line.*}
  • +
  • ${module.*}
  • +
+

+ +

Looking at the default format for the thread, and underlining + the frame information: +

'thread #${thread.index}: tid = ${thread.id}{, ${frame.pc}}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{, stop reason = ${thread.stop-reason}}{, name = ${thread.name}}{, queue = ${thread.queue}}\n' +

+

We can see that all frame information is contained in scopes so + that when the thread information is displayed in a context where + we only want to show thread information, we can do so. +