From granata.enrico at gmail.com Mon Aug 22 11:10:25 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 22 Aug 2011 16:10:25 -0000 Subject: [Lldb-commits] [lldb] r138236 - in /lldb/trunk: examples/synthetic/StdVectorSynthProvider.py examples/synthetic/gnu_libstdcpp.py www/varformats.html Message-ID: <20110822161025.C19432A6C12C@llvm.org> Author: enrico Date: Mon Aug 22 11:10:25 2011 New Revision: 138236 URL: http://llvm.org/viewvc/llvm-project?rev=138236&view=rev Log: Exception-awareness for gnu_libstdcpp formatters ; Documentation update Modified: lldb/trunk/examples/synthetic/StdVectorSynthProvider.py lldb/trunk/examples/synthetic/gnu_libstdcpp.py lldb/trunk/www/varformats.html Modified: lldb/trunk/examples/synthetic/StdVectorSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/StdVectorSynthProvider.py?rev=138236&r1=138235&r2=138236&view=diff ============================================================================== --- lldb/trunk/examples/synthetic/StdVectorSynthProvider.py (original) +++ lldb/trunk/examples/synthetic/StdVectorSynthProvider.py Mon Aug 22 11:10:25 2011 @@ -25,12 +25,7 @@ if finish_val > end_val: return 0 - # We might still get things wrong, so cap things at 256 items for now - # TODO: read a target "settings set" variable for this to allow it to - # be customized num_children = (finish_val-start_val)/self.data_size - if num_children > 256: - return 256 return num_children def get_child_index(self,name): Modified: lldb/trunk/examples/synthetic/gnu_libstdcpp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/gnu_libstdcpp.py?rev=138236&r1=138235&r2=138236&view=diff ============================================================================== --- lldb/trunk/examples/synthetic/gnu_libstdcpp.py (original) +++ lldb/trunk/examples/synthetic/gnu_libstdcpp.py Mon Aug 22 11:10:25 2011 @@ -1,11 +1,10 @@ import re # C++ STL formatters for LLDB -# These formatters are based upon the version of the STL that ships -# with Mac OS X Snow Leopard 10.6.8 and OS X Lion 10.7.0 -# The STL implementation *might* change on other releases of Apple's -# operating system and library infrastructure, and might be different on -# other operating systems +# These formatters are based upon the version of the GNU libstdc++ +# as it ships with Mac OS X 10.6.8 and 10.7.0 +# You are encouraged to look at the STL implementation for your platform +# before relying on these formatters to do the right thing for your setup class StdListSynthProvider: @@ -14,34 +13,45 @@ self.update() def num_children(self): - next_val = self.next.GetValueAsUnsigned(0) - prev_val = self.prev.GetValueAsUnsigned(0) - # After a std::list has been initialized, both next and prev will be non-NULL - if next_val == 0 or prev_val == 0: - return 0 - if next_val == self.node_address: - return 0 - if next_val == prev_val: - return 1 - size = 2 - current = self.next - while current.GetChildMemberWithName('_M_next').GetValueAsUnsigned(0) != self.node_address: - size = size + 1 - current = current.GetChildMemberWithName('_M_next') - return (size - 1) + try: + next_val = self.next.GetValueAsUnsigned(0) + prev_val = self.prev.GetValueAsUnsigned(0) + # After a std::list has been initialized, both next and prev will be non-NULL + if next_val == 0 or prev_val == 0: + return 0 + if next_val == self.node_address: + return 0 + if next_val == prev_val: + return 1 + size = 2 + current = self.next + while current.GetChildMemberWithName('_M_next').GetValueAsUnsigned(0) != self.node_address: + size = size + 1 + current = current.GetChildMemberWithName('_M_next') + return (size - 1) + except: + return 0; def get_child_index(self,name): - return int(name.lstrip('[').rstrip(']')) + try: + return int(name.lstrip('[').rstrip(']')) + except: + return -1 def get_child_at_index(self,index): + if index < 0: + return None; if index >= self.num_children(): return None; - offset = index - current = self.next - while offset > 0: - current = current.GetChildMemberWithName('_M_next') - offset = offset - 1 - return current.CreateChildAtOffset('['+str(index)+']',2*current.GetType().GetByteSize(),self.data_type) + try: + offset = index + current = self.next + while offset > 0: + current = current.GetChildMemberWithName('_M_next') + offset = offset - 1 + return current.CreateChildAtOffset('['+str(index)+']',2*current.GetType().GetByteSize(),self.data_type) + except: + return None: def extract_type_name(self,name): self.type_name = name[16:] @@ -59,17 +69,20 @@ self.type_name_nospaces = self.type_name.replace(", ", ",") def update(self): - impl = self.valobj.GetChildMemberWithName('_M_impl') - node = impl.GetChildMemberWithName('_M_node') - self.extract_type_name(impl.GetType().GetName()) - self.node_address = self.valobj.AddressOf().GetValueAsUnsigned(0) - self.next = node.GetChildMemberWithName('_M_next') - self.prev = node.GetChildMemberWithName('_M_prev') - self.data_type = node.GetTarget().FindFirstType(self.type_name) - # tries to fight against a difference in formatting type names between gcc and clang - if self.data_type.IsValid() == False: - self.data_type = node.GetTarget().FindFirstType(self.type_name_nospaces) - self.data_size = self.data_type.GetByteSize() + try: + impl = self.valobj.GetChildMemberWithName('_M_impl') + node = impl.GetChildMemberWithName('_M_node') + self.extract_type_name(impl.GetType().GetName()) + self.node_address = self.valobj.AddressOf().GetValueAsUnsigned(0) + self.next = node.GetChildMemberWithName('_M_next') + self.prev = node.GetChildMemberWithName('_M_prev') + self.data_type = node.GetTarget().FindFirstType(self.type_name) + # tries to fight against a difference in formatting type names between gcc and clang + if self.data_type.IsValid() == False: + self.data_type = node.GetTarget().FindFirstType(self.type_name_nospaces) + self.data_size = self.data_type.GetByteSize() + except: + pass class StdVectorSynthProvider: @@ -78,45 +91,59 @@ self.update() def num_children(self): - start_val = self.start.GetValueAsUnsigned(0) - finish_val = self.finish.GetValueAsUnsigned(0) - end_val = self.end.GetValueAsUnsigned(0) - # Before a vector has been constructed, it will contain bad values - # so we really need to be careful about the length we return since - # unitialized data can cause us to return a huge number. We need - # to also check for any of the start, finish or end of storage values - # being zero (NULL). If any are, then this vector has not been - # initialized yet and we should return zero - - # Make sure nothing is NULL - if start_val == 0 or finish_val == 0 or end_val == 0: - return 0 - # Make sure start is less than finish - if start_val >= finish_val: - return 0 - # Make sure finish is less than or equal to end of storage - if finish_val > end_val: - return 0 - - num_children = (finish_val-start_val)/self.data_size - return num_children + try: + start_val = self.start.GetValueAsUnsigned(0) + finish_val = self.finish.GetValueAsUnsigned(0) + end_val = self.end.GetValueAsUnsigned(0) + # Before a vector has been constructed, it will contain bad values + # so we really need to be careful about the length we return since + # unitialized data can cause us to return a huge number. We need + # to also check for any of the start, finish or end of storage values + # being zero (NULL). If any are, then this vector has not been + # initialized yet and we should return zero + + # Make sure nothing is NULL + if start_val == 0 or finish_val == 0 or end_val == 0: + return 0 + # Make sure start is less than finish + if start_val >= finish_val: + return 0 + # Make sure finish is less than or equal to end of storage + if finish_val > end_val: + return 0 + + num_children = (finish_val-start_val)/self.data_size + return num_children + except: + return 0; def get_child_index(self,name): - return int(name.lstrip('[').rstrip(']')) + try: + return int(name.lstrip('[').rstrip(']')) + except: + return -1 def get_child_at_index(self,index): + if index < 0: + return None; if index >= self.num_children(): return None; - offset = index * self.data_size - return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) + try: + offset = index * self.data_size + return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) + except: + return None def update(self): - impl = self.valobj.GetChildMemberWithName('_M_impl') - self.start = impl.GetChildMemberWithName('_M_start') - self.finish = impl.GetChildMemberWithName('_M_finish') - self.end = impl.GetChildMemberWithName('_M_end_of_storage') - self.data_type = self.start.GetType().GetPointeeType() - self.data_size = self.data_type.GetByteSize() + try: + impl = self.valobj.GetChildMemberWithName('_M_impl') + self.start = impl.GetChildMemberWithName('_M_start') + self.finish = impl.GetChildMemberWithName('_M_finish') + self.end = impl.GetChildMemberWithName('_M_end_of_storage') + self.data_type = self.start.GetType().GetPointeeType() + self.data_size = self.data_type.GetByteSize() + except: + pass class StdMapSynthProvider: @@ -126,21 +153,24 @@ self.update() def update(self): - self.Mt = self.valobj.GetChildMemberWithName('_M_t') - self.Mimpl = self.Mt.GetChildMemberWithName('_M_impl') - self.Mheader = self.Mimpl.GetChildMemberWithName('_M_header') - # from libstdc++ implementation of _M_root for rbtree - self.Mroot = self.Mheader.GetChildMemberWithName('_M_parent') - # the stuff into the tree is actually a std::pair - # life would be much easier if gcc had a coherent way to print out - # template names in debug info - self.expand_clang_type_name() - self.expand_gcc_type_name() - self.data_type = self.Mt.GetTarget().FindFirstType(self.clang_type_name) - if self.data_type.IsValid() == False: - self.data_type = self.Mt.GetTarget().FindFirstType(self.gcc_type_name) - self.data_size = self.data_type.GetByteSize() - self.skip_size = self.Mheader.GetType().GetByteSize() + try: + self.Mt = self.valobj.GetChildMemberWithName('_M_t') + self.Mimpl = self.Mt.GetChildMemberWithName('_M_impl') + self.Mheader = self.Mimpl.GetChildMemberWithName('_M_header') + # from libstdc++ implementation of _M_root for rbtree + self.Mroot = self.Mheader.GetChildMemberWithName('_M_parent') + # the stuff into the tree is actually a std::pair + # life would be much easier if gcc had a coherent way to print out + # template names in debug info + self.expand_clang_type_name() + self.expand_gcc_type_name() + self.data_type = self.Mt.GetTarget().FindFirstType(self.clang_type_name) + if self.data_type.IsValid() == False: + self.data_type = self.Mt.GetTarget().FindFirstType(self.gcc_type_name) + self.data_size = self.data_type.GetByteSize() + self.skip_size = self.Mheader.GetType().GetByteSize() + except: + pass def expand_clang_type_name(self): type_name = self.Mimpl.GetType().GetName() @@ -180,24 +210,35 @@ self.gcc_type_name = type_name def num_children(self): - root_ptr_val = self.node_ptr_value(self.Mroot) - if root_ptr_val == 0: + try: + root_ptr_val = self.node_ptr_value(self.Mroot) + if root_ptr_val == 0: + return 0; + return self.Mimpl.GetChildMemberWithName('_M_node_count').GetValueAsUnsigned(0) + except: return 0; - return self.Mimpl.GetChildMemberWithName('_M_node_count').GetValueAsUnsigned(0) def get_child_index(self,name): - return int(name.lstrip('[').rstrip(']')) + try: + return int(name.lstrip('[').rstrip(']')) + except: + return -1 def get_child_at_index(self,index): + if index < 0: + return None if index >= self.num_children(): return None; - offset = index - current = self.left(self.Mheader); - while offset > 0: - current = self.increment_node(current) - offset = offset - 1; - # skip all the base stuff and get at the data - return current.CreateChildAtOffset('['+str(index)+']',self.skip_size,self.data_type) + try: + offset = index + current = self.left(self.Mheader); + while offset > 0: + current = self.increment_node(current) + offset = offset - 1; + # skip all the base stuff and get at the data + return current.CreateChildAtOffset('['+str(index)+']',self.skip_size,self.data_type) + except: + return None # utility functions def node_ptr_value(self,node): Modified: lldb/trunk/www/varformats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/varformats.html?rev=138236&r1=138235&r2=138236&view=diff ============================================================================== --- lldb/trunk/www/varformats.html (original) +++ lldb/trunk/www/varformats.html Mon Aug 22 11:10:25 2011 @@ -51,20 +51,21 @@ -> -2, z="3")

-

There are two kinds of printing options: summary and format. While a - detailed description of both will be given below, one - can briefly say that a summary is mainly used for - aggregate types, while a format is attached to primitive - types.

+

There are several features related to data visualization: formats, summaries, filters, synthetic children.

-

To reflect this, the the type command has two +

To reflect this, the the type command has four subcommands:

type format

type summary

+

type filter

+

type synthetic

+

These commands are meant to bind printing options to types. When variables are printed, LLDB will first check @@ -73,8 +74,7 @@ the default choices.

-

The two commands type format and type - summary each have four subcommands:
+

Each of the commands has four subcommands available:

add: associates a new printing option to one or more types

@@ -524,6 +524,14 @@ %L Use this object's location (memory address, register name, ...) + + %# + Use the count of the children of this object + + + %T + Use this object's datatype name + @@ -939,19 +947,77 @@ +
+

Synthetic children

+
+

Summaries work well when one is able to navigate through an expression path. + In order for LLDB to do so, appropriate debugging information must be available.

+

Some types are opaque, i.e. no knowledge of their internals is provided. + When that's the case, expression paths do not work correctly.

+

In other cases, the internals are available to use in expression paths, but they + do not provide a user-friendly representation of the object's value.

+

For instance, consider an STL vector:

+ + (lldb) frame variable numbers -T
+ (std::vector) numbers = {
+    (std::_Vector_base >) std::_Vector_base > = {
+        (std::_Vector_base >::_Vector_impl) _M_impl = {
+            (int *) _M_start = 0x00000001001008a0
+            (int *) _M_finish = 0x00000001001008a8
+            (int *) _M_end_of_storage = 0x00000001001008a8
+        }
+    }
+ }
+
+

Here, you can see how the type is implemented, and you can write a summary for that implementation + but that is not going to help you infer what items are actually stored in the vector.

+

What you would like to see is probably something like:

+ + (lldb) frame variable numbers -T
+ (std::vector) numbers = {
+     (int) [0] = 1
+     (int) [1] = 12
+     (int) [2] = 123
+     (int) [3] = 1234
+ }
+
+

Synthetic children are a way to get that result.

+

The feature is based upon the idea of providing a new set of children for a variable that replaces the ones + available by default through the debug information. In the example, we can use synthetic children to provide + the vector items as children for the std::vector object.

+

In order to create synthetic children, you need to provide a Python class that adheres to a given interface + (the word is italicized because Python has no explicit notion of interface. By that word we mean a given set of methods + must be implemented by the Python class):

+ + class SyntheticChildrenProvider:
+     def __init__(self, valobj, dict):
+         this call should initialize the Python object using valobj as the variable to provide synthetic children for
+     def num_children(self):
+         this call should return the number of children that you want your object to have
+     def get_child_index(self,name):
+         this call should return the index of the synthetic child whose name is given as argument
+     def get_child_at_index(self,index):
+         this call should return a new LLDB SBValue object representing the child at the index given as argument
+     def update(self):
+         this call should be used to update the internal state of this Python object whenever the state of the variables in LLDB changes. + Currently this method is optional, because the internal state of synthetic children providers will not be preserved. However, this is meant to change in future versions + of LLDB.
+
+

For examples of how synthetic children are created, you are encouraged to look at examples/synthetic in the LLDB trunk.

+
+
-

Finding summaries 101

+

Finding formatters 101

While the rules for finding an appropriate format for a type are relatively simple (just go through typedef - hierarchies), summaries follow a more complicated - process in finding the right summary string for a - variable. Namely, what happens is:

+ hierarchies), searching formatters for a type goes through + a rather intricate set of rules. Namely, what happens is:

    -
  • If there is a summary for the type of the variable, +
  • If there is a formatter for the type of the variable, use it
  • -
  • If this object is a pointer, and there is a summary +
  • If this object is a pointer, and there is a formatter for the pointee type that does not skip pointers, use it
  • If this object is a reference, and there is a @@ -959,7 +1025,11 @@ references, use it
  • If this object is an Objective-C class with a parent class, look at the parent class (and parent of parent, - ...)
  • + ...). This phase can be based upon the actual type of + the object as inferred by the value of its isa + pointer, or upon the debugging information inferred by the + debugger. The user can use the dynamic typing settings to + elect one or the other behavior.
  • If this object is a C++ class with base classes, look at base classes (and bases of bases, ...)
  • If this object is a C++ class with virtual base @@ -986,6 +1056,7 @@
  • There's no way to do multiple dereferencing, and you need to be careful what the dereferencing operation is binding to in complicated scenarios
  • +
  • Synthetic children providers cannot have a permanent state
  • type format add does not support the -x option
  • Object location cannot be printed in the summary From granata.enrico at gmail.com Mon Aug 22 11:38:44 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 22 Aug 2011 16:38:44 -0000 Subject: [Lldb-commits] [lldb] r138237 - /lldb/trunk/examples/synthetic/gnu_libstdcpp.py Message-ID: <20110822163844.B14252A6C12C@llvm.org> Author: enrico Date: Mon Aug 22 11:38:44 2011 New Revision: 138237 URL: http://llvm.org/viewvc/llvm-project?rev=138237&view=rev Log: Fixing a startup error Modified: lldb/trunk/examples/synthetic/gnu_libstdcpp.py Modified: lldb/trunk/examples/synthetic/gnu_libstdcpp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/gnu_libstdcpp.py?rev=138237&r1=138236&r2=138237&view=diff ============================================================================== --- lldb/trunk/examples/synthetic/gnu_libstdcpp.py (original) +++ lldb/trunk/examples/synthetic/gnu_libstdcpp.py Mon Aug 22 11:38:44 2011 @@ -51,7 +51,7 @@ offset = offset - 1 return current.CreateChildAtOffset('['+str(index)+']',2*current.GetType().GetByteSize(),self.data_type) except: - return None: + return None def extract_type_name(self,name): self.type_name = name[16:] From granata.enrico at gmail.com Mon Aug 22 12:34:48 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 22 Aug 2011 17:34:48 -0000 Subject: [Lldb-commits] [lldb] r138244 - in /lldb/trunk: scripts/Python/python-wrapper.swig source/Core/FormatManager.cpp source/Interpreter/ScriptInterpreterPython.cpp test/functionalities/alias/TestAliases.py test/functionalities/alias/py_import Message-ID: <20110822173448.265A32A6C12C@llvm.org> Author: enrico Date: Mon Aug 22 12:34:47 2011 New Revision: 138244 URL: http://llvm.org/viewvc/llvm-project?rev=138244&view=rev Log: - Support for Python namespaces: If you have a Python module foo, in order to use its contained objects in LLDB you do not need to use 'from foo import *'. You can use 'import foo', and then refer to items in foo as 'foo.bar', and LLDB will know how to resolve bar as a member of foo. Accordingly, GNU libstdc++ formatters have been moved from the global namespace to gnu_libstdcpp and a few test cases are also updated to reflect the new convention. Python docs suggest using a plain 'import' en lieu of 'from-import'. Modified: lldb/trunk/scripts/Python/python-wrapper.swig lldb/trunk/source/Core/FormatManager.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/test/functionalities/alias/TestAliases.py lldb/trunk/test/functionalities/alias/py_import Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=138244&r1=138243&r2=138244&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Mon Aug 22 12:34:47 2011 @@ -1,5 +1,112 @@ %wrapper %{ +class PyErr_Cleaner +{ +public: + PyErr_Cleaner(bool print=false) : + m_print(print) + { + } + + ~PyErr_Cleaner() + { + if (PyErr_Occurred()) + { + if(m_print) + PyErr_Print(); + PyErr_Clear(); + } + } + +private: + bool m_print; +}; + +// resolve a dotted Python name in the form +// foo.bar.baz.Foobar to an actual Python object +// if pmodule is NULL, the __main__ module will be used +// as the starting point for the search + +static PyObject* +ResolvePythonName(const char* name, + PyObject* pmodule = NULL) +{ + + //printf("Resolving %s\n", name); + + if (!name || !name[0]) + return pmodule; + + PyErr_Cleaner pyerr_cleanup(true); // show Python errors + + PyObject* main_dict; + + if (!pmodule) + { + pmodule = PyImport_AddModule ("__main__"); + if (!pmodule) + return NULL; + } + + if (!PyDict_Check(pmodule)) + { + main_dict = PyModule_GetDict (pmodule); + if (!main_dict) + return NULL; + } + else + main_dict = pmodule; + + const char* dot_pos = ::strchr(name, '.'); + + PyObject *dest_object; + PyObject *key, *value; + Py_ssize_t pos = 0; + + if (!dot_pos) + { + if (PyDict_Check (main_dict)) + { + dest_object = NULL; + while (PyDict_Next (main_dict, &pos, &key, &value)) + { + // We have stolen references to the key and value objects in the dictionary; we need to increment + // them now so that Python's garbage collector doesn't collect them out from under us. + Py_INCREF (key); + Py_INCREF (value); + //printf("Comparing %s and %s\n", name, PyString_AsString (key)); + if (strcmp (PyString_AsString (key), name) == 0) + { + dest_object = value; + break; + } + } + } + + if (!dest_object || dest_object == Py_None) + return NULL; + return dest_object; + } + // foo.bar.ba + // 0123456789 + // len = 3 - 0 + size_t len = dot_pos - name; + std::string piece(name,len); + dest_object = ResolvePythonName(piece.c_str(), main_dict); + //printf("Resolved %s to %p\n", piece.c_str(), dest_object); + if (!dest_object) + return NULL; + //printf("Now moving to resolve %s\n", dot_pos+1); + return ResolvePythonName(dot_pos+1,dest_object); // tail recursion.. should be optimized by the compiler + +} + +static PyObject* +FindSessionDictionary(const char *session_dictionary_name) +{ + return ResolvePythonName(session_dictionary_name, NULL); +} + // This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...) // and is used when a script command is attached to a breakpoint for execution. @@ -25,63 +132,18 @@ if (!python_function_name || !session_dictionary_name) return stop_at_breakpoint; - PyObject *pmodule, *main_dict, *session_dict, *pfunc; + PyObject *session_dict, *pfunc; PyObject *pargs, *pvalue; - pmodule = PyImport_AddModule ("__main__"); - if (pmodule != NULL) + session_dict = FindSessionDictionary (session_dictionary_name); + if (session_dict != NULL) { - main_dict = PyModule_GetDict (pmodule); - if (main_dict != NULL) + pfunc = ResolvePythonName (python_function_name, session_dict); + if (pfunc != NULL) { - PyObject *key, *value; - Py_ssize_t pos = 0; - - // Find the current session's dictionary in the main module's dictionary. - - if (PyDict_Check (main_dict)) - { - session_dict = NULL; - while (PyDict_Next (main_dict, &pos, &key, &value)) - { - // We have stolen references to the key and value objects in the dictionary; we need to increment - // them now so that Python's garbage collector doesn't collect them out from under us. - Py_INCREF (key); - Py_INCREF (value); - if (strcmp (PyString_AsString (key), session_dictionary_name) == 0) - { - session_dict = value; - break; - } - } - } - - if (!session_dict || !PyDict_Check (session_dict)) - return stop_at_breakpoint; - - // Find the function we need to call in the current session's dictionary. - - pos = 0; - pfunc = NULL; - while (PyDict_Next (session_dict, &pos, &key, &value)) - { - if (PyString_Check (key)) - { - // We have stolen references to the key and value objects in the dictionary; we need to increment - // them now so that Python's garbage collector doesn't collect them out from under us. - Py_INCREF (key); - Py_INCREF (value); - if (strcmp (PyString_AsString (key), python_function_name) == 0) - { - pfunc = value; - break; - } - } - } - // Set up the arguments and call the function. - if (pfunc && PyCallable_Check (pfunc)) + if (PyCallable_Check (pfunc)) { pargs = PyTuple_New (3); if (pargs == NULL) @@ -144,63 +206,18 @@ if (!python_function_name || !session_dictionary_name) return retval; - PyObject *pmodule, *main_dict, *session_dict, *pfunc; + PyObject *session_dict, *pfunc; PyObject *pargs, *pvalue; - pmodule = PyImport_AddModule ("__main__"); - if (pmodule != NULL) + session_dict = FindSessionDictionary (session_dictionary_name); + if (session_dict != NULL) { - main_dict = PyModule_GetDict (pmodule); - if (main_dict != NULL) + pfunc = ResolvePythonName (python_function_name, session_dict); + if (pfunc != NULL) { - PyObject *key, *value; - Py_ssize_t pos = 0; - - // Find the current session's dictionary in the main module's dictionary. - - if (PyDict_Check (main_dict)) - { - session_dict = NULL; - while (PyDict_Next (main_dict, &pos, &key, &value)) - { - // We have stolen references to the key and value objects in the dictionary; we need to increment - // them now so that Python's garbage collector doesn't collect them out from under us. - Py_INCREF (key); - Py_INCREF (value); - if (strcmp (PyString_AsString (key), session_dictionary_name) == 0) - { - session_dict = value; - break; - } - } - } - - if (!session_dict || !PyDict_Check (session_dict)) - return retval; - - // Find the function we need to call in the current session's dictionary. - - pos = 0; - pfunc = NULL; - while (PyDict_Next (session_dict, &pos, &key, &value)) - { - if (PyString_Check (key)) - { - // We have stolen references to the key and value objects in the dictionary; we need to increment - // them now so that Python's garbage collector doesn't collect them out from under us. - Py_INCREF (key); - Py_INCREF (value); - if (strcmp (PyString_AsString (key), python_function_name) == 0) - { - pfunc = value; - break; - } - } - } - // Set up the arguments and call the function. - if (pfunc && PyCallable_Check (pfunc)) + if (PyCallable_Check (pfunc)) { pargs = PyTuple_New (2); if (pargs == NULL) @@ -274,63 +291,18 @@ const char* python_function_name = python_class_name.c_str(); - PyObject *pmodule, *main_dict, *session_dict, *pfunc; + PyObject *session_dict, *pfunc; PyObject *pvalue; - - pmodule = PyImport_AddModule ("__main__"); - if (pmodule != NULL) + + session_dict = FindSessionDictionary (session_dictionary_name); + if (session_dict != NULL) { - main_dict = PyModule_GetDict (pmodule); - if (main_dict != NULL) + pfunc = ResolvePythonName (python_function_name, session_dict); + if (pfunc != NULL) { - PyObject *key, *value; - Py_ssize_t pos = 0; - - // Find the current session's dictionary in the main module's dictionary. - - if (PyDict_Check (main_dict)) - { - session_dict = NULL; - while (PyDict_Next (main_dict, &pos, &key, &value)) - { - // We have stolen references to the key and value objects in the dictionary; we need to increment - // them now so that Python's garbage collector doesn't collect them out from under us. - Py_INCREF (key); - Py_INCREF (value); - if (strcmp (PyString_AsString (key), session_dictionary_name) == 0) - { - session_dict = value; - break; - } - } - } - - if (!session_dict || !PyDict_Check (session_dict)) - return retval; - - // Find the function we need to call in the current session's dictionary. - - pos = 0; - pfunc = NULL; - while (PyDict_Next (session_dict, &pos, &key, &value)) - { - if (PyString_Check (key)) - { - // We have stolen references to the key and value objects in the dictionary; we need to increment - // them now so that Python's garbage collector doesn't collect them out from under us. - Py_INCREF (key); - Py_INCREF (value); - if (strcmp (PyString_AsString (key), python_function_name) == 0) - { - pfunc = value; - break; - } - } - } - // Set up the arguments and call the function. - - if (pfunc && PyCallable_Check (pfunc)) + + if (PyCallable_Check (pfunc)) { PyObject *argList = Py_BuildValue("SS", ValObj_PyObj, session_dict); @@ -638,63 +610,18 @@ if (!python_function_name || !session_dictionary_name) return retval; - PyObject *pmodule, *main_dict, *session_dict, *pfunc; + PyObject *session_dict, *pfunc; PyObject *pargs, *pvalue; - pmodule = PyImport_AddModule ("__main__"); - if (pmodule != NULL) + session_dict = FindSessionDictionary (session_dictionary_name); + if (session_dict != NULL) { - main_dict = PyModule_GetDict (pmodule); - if (main_dict != NULL) + pfunc = ResolvePythonName (python_function_name, session_dict); + if (pfunc != NULL) { - PyObject *key, *value; - Py_ssize_t pos = 0; - - // Find the current session's dictionary in the main module's dictionary. - - if (PyDict_Check (main_dict)) - { - session_dict = NULL; - while (PyDict_Next (main_dict, &pos, &key, &value)) - { - // We have stolen references to the key and value objects in the dictionary; we need to increment - // them now so that Python's garbage collector doesn't collect them out from under us. - Py_INCREF (key); - Py_INCREF (value); - if (strcmp (PyString_AsString (key), session_dictionary_name) == 0) - { - session_dict = value; - break; - } - } - } - - if (!session_dict || !PyDict_Check (session_dict)) - return retval; - - // Find the function we need to call in the current session's dictionary. - - pos = 0; - pfunc = NULL; - while (PyDict_Next (session_dict, &pos, &key, &value)) - { - if (PyString_Check (key)) - { - // We have stolen references to the key and value objects in the dictionary; we need to increment - // them now so that Python's garbage collector doesn't collect them out from under us. - Py_INCREF (key); - Py_INCREF (value); - if (strcmp (PyString_AsString (key), python_function_name) == 0) - { - pfunc = value; - break; - } - } - } - // Set up the arguments and call the function. - if (pfunc && PyCallable_Check (pfunc)) + if (PyCallable_Check (pfunc)) { pargs = PyTuple_New (4); if (pargs == NULL) Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=138244&r1=138243&r2=138244&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Mon Aug 22 12:34:47 2011 @@ -447,17 +447,17 @@ SyntheticChildrenSP(new SyntheticScriptProvider(true, false, false, - "StdVectorSynthProvider"))); + "gnu_libstdcpp.StdVectorSynthProvider"))); Category(m_gnu_cpp_category_name)->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("std::map<")), SyntheticChildrenSP(new SyntheticScriptProvider(true, false, false, - "StdMapSynthProvider"))); + "gnu_libstdcpp.StdMapSynthProvider"))); Category(m_gnu_cpp_category_name)->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("std::list<")), SyntheticChildrenSP(new SyntheticScriptProvider(true, false, false, - "StdListSynthProvider"))); + "gnu_libstdcpp.StdListSynthProvider"))); // DO NOT change the order of these calls, unless you WANT a change in the priority of these categories EnableCategory(m_system_category_name); Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=138244&r1=138243&r2=138244&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Aug 22 12:34:47 2011 @@ -175,7 +175,7 @@ PyRun_SimpleString (run_string.GetData()); run_string.Clear(); - run_string.Printf ("run_one_line (%s, 'from gnu_libstdcpp import *')", m_dictionary_name.c_str(), + run_string.Printf ("run_one_line (%s, 'import gnu_libstdcpp')", m_dictionary_name.c_str(), interpreter.GetDebugger().GetID()); PyRun_SimpleString (run_string.GetData()); Modified: lldb/trunk/test/functionalities/alias/TestAliases.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/TestAliases.py?rev=138244&r1=138243&r2=138244&view=diff ============================================================================== --- lldb/trunk/test/functionalities/alias/TestAliases.py (original) +++ lldb/trunk/test/functionalities/alias/TestAliases.py Mon Aug 22 12:34:47 2011 @@ -152,10 +152,10 @@ self.expect('command script list', substrs = ['targetname', - 'Run Python function target_name_impl']) + 'Run Python function welcome.target_name_impl']) self.expect("help targetname", - substrs = ['Run Python function target_name_imp', + substrs = ['Run Python function welcome.target_name_imp', 'This command takes \'raw\' input', 'quote stuff']) Modified: lldb/trunk/test/functionalities/alias/py_import URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/py_import?rev=138244&r1=138243&r2=138244&view=diff ============================================================================== --- lldb/trunk/test/functionalities/alias/py_import (original) +++ lldb/trunk/test/functionalities/alias/py_import Mon Aug 22 12:34:47 2011 @@ -1,6 +1,6 @@ script import sys, os script sys.path.append(os.path.join(os.getcwd(), os.pardir)) -script from welcome import * -command script add welcome --function welcome_impl -command script add targetname --function target_name_impl -command script add longwait --function print_wait_impl +script import welcome +command script add welcome --function welcome.welcome_impl +command script add targetname --function welcome.target_name_impl +command script add longwait --function welcome.print_wait_impl From johnny.chen at apple.com Mon Aug 22 12:58:15 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 22 Aug 2011 17:58:15 -0000 Subject: [Lldb-commits] [lldb] r138247 - /lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py Message-ID: <20110822175815.0DAF82A6C12C@llvm.org> Author: johnny Date: Mon Aug 22 12:58:14 2011 New Revision: 138247 URL: http://llvm.org/viewvc/llvm-project?rev=138247&view=rev Log: Modify test cases to use 'target variable' to display global variables. Modified: lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py Modified: lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py?rev=138247&r1=138246&r2=138247&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py (original) +++ lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py Mon Aug 22 12:58:14 2011 @@ -57,18 +57,16 @@ substrs = ['stopped', 'stop reason = breakpoint']) - # On Mac OS X, gcc 4.2 emits the wrong debug info for A::g_points. - slist = ['(PointType [2]) g_points', 'A::g_points'] - -# global variables are no longer displayed with the "frame variable" command. -# add tests for the "target variable" command soon - # 'frame variable -G' finds and displays global variable(s) by name. - # self.expect('frame variable -G g_points', VARIABLES_DISPLAYED_CORRECTLY, - # substrs = slist) + # global variables are no longer displayed with the "frame variable" command. + self.expect('target variable A::g_points', VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['(PointType [2]) A::g_points']) + self.expect('target variable g_points', VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['(PointType [2]) g_points']) + # On Mac OS X, gcc 4.2 emits the wrong debug info for A::g_points. # A::g_points is an array of two elements. if sys.platform.startswith("darwin") and self.getCompiler() in ['clang', 'llvm-gcc']: - self.expect("frame variable A::g_points[1].x", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("target variable A::g_points[1].x", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(int) A::g_points[1].x = 11") def static_variable_python(self): From granata.enrico at gmail.com Mon Aug 22 13:36:52 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 22 Aug 2011 18:36:52 -0000 Subject: [Lldb-commits] [lldb] r138254 - in /lldb/trunk: include/lldb/Core/FormatManager.h source/Commands/CommandObjectType.cpp source/Core/FormatManager.cpp Message-ID: <20110822183652.741B02A6C12C@llvm.org> Author: enrico Date: Mon Aug 22 13:36:52 2011 New Revision: 138254 URL: http://llvm.org/viewvc/llvm-project?rev=138254&view=rev Log: Code cleanup and refactoring (round 4): - FormatCategories now are directly mapped by ConstString objects instead of going through const char* -> ConstString -> const char* - FormatCategory callback does not pass category name anymore. This is not necessary because FormatCategory objects themselves hold their name as a member variable Modified: lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Core/FormatManager.cpp Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=138254&r1=138253&r2=138254&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Mon Aug 22 13:36:52 2011 @@ -934,7 +934,7 @@ class CategoryMap { private: - typedef const char* KeyType; + typedef ConstString KeyType; typedef FormatCategory ValueType; typedef ValueType::SharedPointer ValueSP; typedef std::list ActiveCategoriesList; @@ -943,7 +943,7 @@ public: typedef std::map MapType; typedef MapType::iterator MapIterator; - typedef bool(*CallbackType)(void*, KeyType, const ValueSP&); + typedef bool(*CallbackType)(void*, const ValueSP&); CategoryMap(IFormatChangeListener* lst = NULL) : m_map_mutex(Mutex::eMutexTypeRecursive), @@ -1149,7 +1149,7 @@ public: - typedef bool (*CategoryCallback)(void*, const char*, const lldb::FormatCategorySP&); + typedef CategoryMap::CallbackType CategoryCallback; FormatManager (); @@ -1172,18 +1172,30 @@ } void - EnableCategory (const char* category_name) + EnableCategory (const ConstString& category_name) { m_categories_map.EnableCategory(category_name); } void - DisableCategory (const char* category_name) + DisableCategory (const ConstString& category_name) { m_categories_map.DisableCategory(category_name); } void + EnableCategory (const char* category_name) + { + EnableCategory(ConstString(category_name)); + } + + void + DisableCategory (const char* category_name) + { + DisableCategory(ConstString(category_name)); + } + + void LoopThroughCategories (CategoryCallback callback, void* param) { m_categories_map.LoopThrough(callback, param); @@ -1206,10 +1218,18 @@ { if (!category_name) return Category(m_default_category_name); + return Category(ConstString(category_name)); + } + + lldb::FormatCategorySP + Category (const ConstString& category_name) + { + if (!category_name) + return Category(m_default_category_name); lldb::FormatCategorySP category; if (m_categories_map.Get(category_name, category)) return category; - Categories().Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name))); + Categories().Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name.AsCString()))); return Category(category_name); } @@ -1287,13 +1307,9 @@ uint32_t m_last_revision; CategoryMap m_categories_map; - const char* m_default_category_name; - const char* m_system_category_name; - const char* m_gnu_cpp_category_name; - - ConstString m_default_cs; - ConstString m_system_cs; - ConstString m_gnu_stdcpp_cs; + ConstString m_default_category_name; + ConstString m_system_category_name; + ConstString m_gnu_cpp_category_name; }; class DataVisualization Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=138254&r1=138253&r2=138254&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Mon Aug 22 13:36:52 2011 @@ -1166,7 +1166,6 @@ static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { ConstString *name = (ConstString*)param; @@ -1322,7 +1321,6 @@ static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { cate->GetSummaryNavigator()->Clear(); @@ -1532,7 +1530,6 @@ static bool PerCategoryCallback(void* param_vp, - const char* cate_name, const lldb::FormatCategorySP& cate) { @@ -1540,6 +1537,8 @@ (CommandObjectTypeSummaryList_LoopCallbackParam*)param_vp; CommandReturnObject* result = param->result; + const char* cate_name = cate->GetName().c_str(); + // if the category is disabled or empty and there is no regex, just skip it if ((cate->IsEnabled() == false || cate->GetCount(FormatCategory::eSummary | FormatCategory::eRegexSummary) == 0) && param->cate_regex == NULL) return true; @@ -1615,7 +1614,7 @@ CommandObjectTypeCategoryEnable (CommandInterpreter &interpreter) : CommandObject (interpreter, "type category enable", - "Enable a category as a source of summaries.", + "Enable a category as a source of formatters.", NULL) { CommandArgumentEntry type_arg; @@ -1658,6 +1657,14 @@ return false; } DataVisualization::Categories::Enable(typeCS); + lldb::FormatCategorySP cate; + if (DataVisualization::Categories::Get(typeCS, cate) && cate.get()) + { + if (cate->GetCount() == 0) + { + result.AppendWarning("empty category enabled (typo?)"); + } + } } result.SetStatus(eReturnStatusSuccessFinishResult); @@ -1676,7 +1683,7 @@ CommandObjectTypeCategoryDelete (CommandInterpreter &interpreter) : CommandObject (interpreter, "type category delete", - "Delete a category and all associated summaries.", + "Delete a category and all associated formatters.", NULL) { CommandArgumentEntry type_arg; @@ -1748,7 +1755,7 @@ CommandObjectTypeCategoryDisable (CommandInterpreter &interpreter) : CommandObject (interpreter, "type category disable", - "Disable a category as a source of summaries.", + "Disable a category as a source of formatters.", NULL) { CommandArgumentEntry type_arg; @@ -1824,7 +1831,6 @@ static bool PerCategoryCallback(void* param_vp, - const char* cate_name, const lldb::FormatCategorySP& cate) { CommandObjectTypeCategoryList_CallbackParam* param = @@ -1832,6 +1838,8 @@ CommandReturnObject* result = param->result; RegularExpression* regex = param->regex; + const char* cate_name = cate->GetName().c_str(); + if (regex == NULL || regex->Execute(cate_name)) result->GetOutputStream().Printf("Category %s is%s enabled\n", cate_name, @@ -2028,10 +2036,11 @@ static bool PerCategoryCallback(void* param_vp, - const char* cate_name, const lldb::FormatCategorySP& cate) { + const char* cate_name = cate->GetName().c_str(); + CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)param_vp; CommandReturnObject* result = param->result; @@ -2237,7 +2246,6 @@ static bool PerCategoryCallback(void* param_vp, - const char* cate_name, const lldb::FormatCategorySP& cate) { @@ -2245,6 +2253,8 @@ (CommandObjectTypeSynthList_LoopCallbackParam*)param_vp; CommandReturnObject* result = param->result; + const char* cate_name = cate->GetName().c_str(); + // if the category is disabled or empty and there is no regex, just skip it if ((cate->IsEnabled() == false || cate->GetCount(FormatCategory::eSynth | FormatCategory::eRegexSynth) == 0) && param->cate_regex == NULL) return true; @@ -2384,7 +2394,6 @@ static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { ConstString *name = (ConstString*)param; @@ -2547,7 +2556,6 @@ static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { ConstString* name = (ConstString*)param; @@ -2706,7 +2714,6 @@ static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { cate->Clear(FormatCategory::eFilter | FormatCategory::eRegexFilter); @@ -2833,7 +2840,6 @@ static bool PerCategoryCallback(void* param, - const char* cate_name, const lldb::FormatCategorySP& cate) { cate->Clear(FormatCategory::eSynth | FormatCategory::eRegexSynth); Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=138254&r1=138253&r2=138254&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Mon Aug 22 13:36:52 2011 @@ -321,8 +321,8 @@ for (begin = m_active_categories.begin(); begin != end; begin++) { lldb::FormatCategorySP category = *begin; - const char* type = category->GetName().c_str(); - if (!callback(param, type, category)) + ConstString type = ConstString(category->GetName().c_str()); + if (!callback(param, category)) break; } } @@ -335,7 +335,7 @@ if (pos->second->IsEnabled()) continue; KeyType type = pos->first; - if (!callback(param, type, pos->second)) + if (!callback(param, pos->second)) break; } } @@ -383,17 +383,11 @@ m_named_summaries_map(this), m_last_revision(0), m_categories_map(this), - m_default_cs(ConstString("default")), - m_system_cs(ConstString("system")), - m_gnu_stdcpp_cs(ConstString("gnu-libstdc++")) + m_default_category_name(ConstString("default")), + m_system_category_name(ConstString("system")), + m_gnu_cpp_category_name(ConstString("gnu-libstdc++")) { - // build default categories - - m_default_category_name = m_default_cs.GetCString(); - m_system_category_name = m_system_cs.GetCString(); - m_gnu_cpp_category_name = m_gnu_stdcpp_cs.AsCString(); - // add some default stuff // most formats, summaries, ... actually belong to the users' lldbinit file rather than here lldb::SummaryFormatSP string_format(new StringSummaryFormat(false, @@ -553,21 +547,21 @@ bool DataVisualization::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry) { - entry = GetFormatManager().Category(category.GetCString()); + entry = GetFormatManager().Category(category); return true; } void DataVisualization::Categories::Add(const ConstString &category) { - GetFormatManager().Category(category.GetCString()); + GetFormatManager().Category(category); } bool DataVisualization::Categories::Delete(const ConstString &category) { - GetFormatManager().DisableCategory(category.GetCString()); - return GetFormatManager().Categories().Delete(category.GetCString()); + GetFormatManager().DisableCategory(category); + return GetFormatManager().Categories().Delete(category); } void @@ -579,26 +573,26 @@ void DataVisualization::Categories::Clear(ConstString &category) { - GetFormatManager().Category(category.GetCString())->ClearSummaries(); + GetFormatManager().Category(category)->ClearSummaries(); } void DataVisualization::Categories::Enable(ConstString& category) { - if (GetFormatManager().Category(category.GetCString())->IsEnabled() == false) - GetFormatManager().EnableCategory(category.GetCString()); + if (GetFormatManager().Category(category)->IsEnabled() == false) + GetFormatManager().EnableCategory(category); else { - GetFormatManager().DisableCategory(category.GetCString()); - GetFormatManager().EnableCategory(category.GetCString()); + GetFormatManager().DisableCategory(category); + GetFormatManager().EnableCategory(category); } } void DataVisualization::Categories::Disable(ConstString& category) { - if (GetFormatManager().Category(category.GetCString())->IsEnabled() == true) - GetFormatManager().DisableCategory(category.GetCString()); + if (GetFormatManager().Category(category)->IsEnabled() == true) + GetFormatManager().DisableCategory(category); } void From jingham at apple.com Mon Aug 22 14:10:09 2011 From: jingham at apple.com (Jim Ingham) Date: Mon, 22 Aug 2011 19:10:09 -0000 Subject: [Lldb-commits] [lldb] r138262 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110822191009.3ADBF2A6C12C@llvm.org> Author: jingham Date: Mon Aug 22 14:10:09 2011 New Revision: 138262 URL: http://llvm.org/viewvc/llvm-project?rev=138262&view=rev Log: Don't let Python write its .pyc files, that's not really polite... 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=138262&r1=138261&r2=138262&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Aug 22 14:10:09 2011 @@ -2079,6 +2079,7 @@ PyRun_SimpleString ("import sys"); PyRun_SimpleString ("sys.path.append ('.')"); + PyRun_SimpleString ("sys.dont_write_bytecode = 1"); PyRun_SimpleString ("import embedded_interpreter"); From granata.enrico at gmail.com Mon Aug 22 17:03:47 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 22 Aug 2011 22:03:47 -0000 Subject: [Lldb-commits] [lldb] r138279 - in /lldb/trunk: include/lldb/Core/DataVisualization.h include/lldb/Core/FormatManager.h lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectFrame.cpp source/Commands/CommandObjectType.cpp source/Core/DataVisualization.cpp source/Core/FormatManager.cpp source/Core/ValueObject.cpp source/Interpreter/CommandObjectScript.cpp Message-ID: <20110822220348.14E112A6C12C@llvm.org> Author: enrico Date: Mon Aug 22 17:03:47 2011 New Revision: 138279 URL: http://llvm.org/viewvc/llvm-project?rev=138279&view=rev Log: More cleanups ; Separated implementation of FormatManager from class DataVisualization as a front-end by using separate .h/.cpp files - Final aim is to break up FormatManager.h/cpp into several separate files Added: lldb/trunk/include/lldb/Core/DataVisualization.h lldb/trunk/source/Core/DataVisualization.cpp Modified: lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Core/FormatManager.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Interpreter/CommandObjectScript.cpp Added: lldb/trunk/include/lldb/Core/DataVisualization.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataVisualization.h?rev=138279&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/DataVisualization.h (added) +++ lldb/trunk/include/lldb/Core/DataVisualization.h Mon Aug 22 17:03:47 2011 @@ -0,0 +1,144 @@ +//===-- DataVisualization.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_DataVisualization_h_ +#define lldb_DataVisualization_h_ + +// C Includes +// C++ Includes + +// is not strictly-speaking a requirement for DataVisualization.h +// but including it ensures a smooth compilation of STLUtils.h. if +// is not included, a macro definition of isspace() and other cctype functions occurs +// which prevents from getting included correctly. at least, this is what +// happens on OSX Lion. If other OSs don't have this side effect, you may want to +// #if defined (__APPLE__) this include directive +#include + +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-forward-rtti.h" +#include "lldb/Core/ConstString.h" +#include "lldb/Core/FormatClasses.h" +#include "lldb/Core/FormatManager.h" + +namespace lldb_private { + +// this class is the high-level front-end of LLDB Data Visualization +// code in FormatManager.h/cpp is the low-level implementation of this feature +// clients should refer to this class as the entry-point into the data formatters +// unless they have a good reason to bypass this and go to the backend +class DataVisualization +{ +public: + + // use this call to force the FM to consider itself updated even when there is no apparent reason for that + static void + ForceUpdate(); + + static uint32_t + GetCurrentRevision (); + + class ValueFormats + { + public: + static bool + Get (ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry); + + static void + Add (const ConstString &type, const lldb::ValueFormatSP &entry); + + static bool + Delete (const ConstString &type); + + static void + Clear (); + + static void + LoopThrough (ValueFormat::ValueCallback callback, void* callback_baton); + + static uint32_t + GetCount (); + }; + + static bool + GetSummaryFormat(ValueObject& valobj, + lldb::DynamicValueType use_dynamic, + lldb::SummaryFormatSP& entry); + static bool + GetSyntheticChildren(ValueObject& valobj, + lldb::DynamicValueType use_dynamic, + lldb::SyntheticChildrenSP& entry); + + static bool + AnyMatches(ConstString type_name, + FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = NULL, + FormatCategory::FormatCategoryItems* matching_type = NULL); + + class NamedSummaryFormats + { + public: + static bool + Get (const ConstString &type, lldb::SummaryFormatSP &entry); + + static void + Add (const ConstString &type, const lldb::SummaryFormatSP &entry); + + static bool + Delete (const ConstString &type); + + static void + Clear (); + + static void + LoopThrough (SummaryFormat::SummaryCallback callback, void* callback_baton); + + static uint32_t + GetCount (); + }; + + class Categories + { + public: + + static bool + Get (const ConstString &category, lldb::FormatCategorySP &entry); + + static void + Add (const ConstString &category); + + static bool + Delete (const ConstString &category); + + static void + Clear (); + + static void + Clear (ConstString &category); + + static void + Enable (ConstString& category); + + static void + Disable (ConstString& category); + + static void + LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton); + + static uint32_t + GetCount (); + }; +}; + + +} // namespace lldb_private + +#endif // lldb_DataVisualization_h_ Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=138279&r1=138278&r2=138279&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Mon Aug 22 17:03:47 2011 @@ -65,6 +65,10 @@ namespace lldb_private { +// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization +// class DataVisualization is the high-level front-end of this feature +// clients should refer to that class as the entry-point into the data formatters +// unless they have a good reason to bypass it and prefer to use this file's objects directly class IFormatChangeListener { public: @@ -137,7 +141,7 @@ typedef typename MapType::iterator MapIterator; typedef bool(*CallbackType)(void*, KeyType, const ValueSP&); - FormatMap(IFormatChangeListener* lst = NULL) : + FormatMap(IFormatChangeListener* lst) : m_map(), m_map_mutex(Mutex::eMutexTypeRecursive), listener(lst) @@ -258,7 +262,7 @@ friend class FormatCategory; FormatNavigator(std::string name, - IFormatChangeListener* lst = NULL) : + IFormatChangeListener* lst) : m_format_map(lst), m_name(name), m_id_cs(ConstString("id")) @@ -713,15 +717,19 @@ public: - enum FormatCategoryItem + //------------------------------------------------------------------ + /// Format category entry types + //------------------------------------------------------------------ + typedef enum FormatCategoryItem { eSummary = 0x0001, eRegexSummary = 0x1001, eFilter = 0x0002, eRegexFilter = 0x1002, eSynth = 0x0004, - eRegexSynth = 0x1004 - }; + eRegexSynth = 0x1004, + eAllItems = 0xFFFF + } FormatCategoryItem; typedef uint16_t FormatCategoryItems; static const uint16_t ALL_ITEM_TYPES = 0xFFFF; @@ -816,60 +824,14 @@ void - Clear (FormatCategoryItems items = ALL_ITEM_TYPES) - { - if ( (items & eSummary) == eSummary ) - m_summary_nav->Clear(); - if ( (items & eRegexSummary) == eRegexSummary ) - m_regex_summary_nav->Clear(); - if ( (items & eFilter) == eFilter ) - m_filter_nav->Clear(); - if ( (items & eRegexFilter) == eRegexFilter ) - m_regex_filter_nav->Clear(); - if ( (items & eSynth) == eSynth ) - m_synth_nav->Clear(); - if ( (items & eRegexSynth) == eRegexSynth ) - m_regex_synth_nav->Clear(); - } + Clear (FormatCategoryItems items = ALL_ITEM_TYPES); bool - Delete(ConstString name, - FormatCategoryItems items = ALL_ITEM_TYPES) - { - bool success = false; - if ( (items & eSummary) == eSummary ) - success = m_summary_nav->Delete(name) || success; - if ( (items & eRegexSummary) == eRegexSummary ) - success = m_regex_summary_nav->Delete(name) || success; - if ( (items & eFilter) == eFilter ) - success = m_filter_nav->Delete(name) || success; - if ( (items & eRegexFilter) == eRegexFilter ) - success = m_regex_filter_nav->Delete(name) || success; - if ( (items & eSynth) == eSynth ) - success = m_synth_nav->Delete(name) || success; - if ( (items & eRegexSynth) == eRegexSynth ) - success = m_regex_synth_nav->Delete(name) || success; - return success; - } + Delete (ConstString name, + FormatCategoryItems items = ALL_ITEM_TYPES); uint32_t - GetCount (FormatCategoryItems items = ALL_ITEM_TYPES) - { - uint32_t count = 0; - if ( (items & eSummary) == eSummary ) - count += m_summary_nav->GetCount(); - if ( (items & eRegexSummary) == eRegexSummary ) - count += m_regex_summary_nav->GetCount(); - if ( (items & eFilter) == eFilter ) - count += m_filter_nav->GetCount(); - if ( (items & eRegexFilter) == eRegexFilter ) - count += m_regex_filter_nav->GetCount(); - if ( (items & eSynth) == eSynth ) - count += m_synth_nav->GetCount(); - if ( (items & eRegexSynth) == eRegexSynth ) - count += m_regex_synth_nav->GetCount(); - return count; - } + GetCount (FormatCategoryItems items = ALL_ITEM_TYPES); std::string GetName () @@ -945,7 +907,7 @@ typedef MapType::iterator MapIterator; typedef bool(*CallbackType)(void*, const ValueSP&); - CategoryMap(IFormatChangeListener* lst = NULL) : + CategoryMap(IFormatChangeListener* lst) : m_map_mutex(Mutex::eMutexTypeRecursive), listener(lst), m_map(), @@ -971,14 +933,14 @@ if (iter == m_map.end()) return false; m_map.erase(name); - DisableCategory(name); + Disable(name); if (listener) listener->Changed(); return true; } void - EnableCategory (KeyType category_name) + Enable (KeyType category_name) { Mutex::Locker(m_map_mutex); ValueSP category; @@ -1002,7 +964,7 @@ }; void - DisableCategory (KeyType category_name) + Disable (KeyType category_name) { Mutex::Locker(m_map_mutex); ValueSP category; @@ -1136,7 +1098,6 @@ friend class FormatManager; }; - class FormatManager : public IFormatChangeListener { private: @@ -1153,20 +1114,14 @@ FormatManager (); - CategoryMap& - Categories () - { - return m_categories_map; - } - ValueNavigator& - Value () + GetValueNavigator () { return m_value_nav; } NamedSummariesMap& - NamedSummary () + GetNamedSummaryNavigator () { return m_named_summaries_map; } @@ -1174,13 +1129,13 @@ void EnableCategory (const ConstString& category_name) { - m_categories_map.EnableCategory(category_name); + m_categories_map.Enable(category_name); } void DisableCategory (const ConstString& category_name) { - m_categories_map.DisableCategory(category_name); + m_categories_map.Disable(category_name); } void @@ -1201,20 +1156,9 @@ m_categories_map.LoopThrough(callback, param); } - FormatCategory::SummaryNavigatorSP - Summary(const char* category_name = NULL) - { - return Category(category_name)->GetSummaryNavigator(); - } - - FormatCategory::RegexSummaryNavigatorSP - RegexSummary (const char* category_name = NULL) - { - return Category(category_name)->GetRegexSummaryNavigator(); - } - lldb::FormatCategorySP - Category (const char* category_name = NULL) + Category (const char* category_name = NULL, + bool can_create = true) { if (!category_name) return Category(m_default_category_name); @@ -1222,14 +1166,19 @@ } lldb::FormatCategorySP - Category (const ConstString& category_name) + Category (const ConstString& category_name, + bool can_create = true) { if (!category_name) return Category(m_default_category_name); lldb::FormatCategorySP category; if (m_categories_map.Get(category_name, category)) return category; - Categories().Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name.AsCString()))); + + if (!can_create) + return lldb::FormatCategorySP(); + + m_categories_map.Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name.AsCString()))); return Category(category_name); } @@ -1300,6 +1249,12 @@ ~FormatManager () { } + + CategoryMap& + GetCategories () + { + return m_categories_map; + } private: ValueNavigator m_value_nav; @@ -1310,112 +1265,8 @@ ConstString m_default_category_name; ConstString m_system_category_name; ConstString m_gnu_cpp_category_name; -}; - -class DataVisualization -{ -public: - - // use this call to force the FM to consider itself updated even when there is no apparent reason for that - static void - ForceUpdate(); - static uint32_t - GetCurrentRevision (); - - class ValueFormats - { - public: - static bool - Get (ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry); - - static void - Add (const ConstString &type, const lldb::ValueFormatSP &entry); - - static bool - Delete (const ConstString &type); - - static void - Clear (); - - static void - LoopThrough (ValueFormat::ValueCallback callback, void* callback_baton); - - static uint32_t - GetCount (); - }; - - static bool - GetSummaryFormat(ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - lldb::SummaryFormatSP& entry); - static bool - GetSyntheticChildren(ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - lldb::SyntheticChildrenSP& entry); - - static bool - AnyMatches(ConstString type_name, - FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, - bool only_enabled = true, - const char** matching_category = NULL, - FormatCategory::FormatCategoryItems* matching_type = NULL); - - class NamedSummaryFormats - { - public: - static bool - Get (const ConstString &type, lldb::SummaryFormatSP &entry); - - static void - Add (const ConstString &type, const lldb::SummaryFormatSP &entry); - - static bool - Delete (const ConstString &type); - - static void - Clear (); - - static void - LoopThrough (SummaryFormat::SummaryCallback callback, void* callback_baton); - - static uint32_t - GetCount (); - }; - - class Categories - { - public: - - static bool - Get (const ConstString &category, lldb::FormatCategorySP &entry); - - static void - Add (const ConstString &category); - - static bool - Delete (const ConstString &category); - - static void - Clear (); - - static void - Clear (ConstString &category); - - static void - Enable (ConstString& category); - - static void - Disable (ConstString& category); - - static void - LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton); - - static uint32_t - GetCount (); - }; }; - } // namespace lldb_private Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=138279&r1=138278&r2=138279&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Aug 22 17:03:47 2011 @@ -409,6 +409,7 @@ 94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94611EB113CCA4A4003A22AF /* RefCounter.cpp */; }; 9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */; }; 9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */; }; + 9470A8F01402DFFB0056FF61 /* DataVisualization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9470A8EF1402DFFB0056FF61 /* DataVisualization.cpp */; }; 94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.cpp */; }; 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; }; @@ -1187,6 +1188,8 @@ 9463D4CE13B179A500C230D4 /* CommandObjectType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommandObjectType.h; path = source/Commands/CommandObjectType.h; sourceTree = ""; }; 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeHierarchyNavigator.cpp; path = source/Symbol/TypeHierarchyNavigator.cpp; sourceTree = ""; }; 9467E65413C3D98900B3B6F3 /* TypeHierarchyNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeHierarchyNavigator.h; path = include/lldb/Symbol/TypeHierarchyNavigator.h; sourceTree = ""; }; + 9470A8EE1402DF940056FF61 /* DataVisualization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DataVisualization.h; path = include/lldb/Core/DataVisualization.h; sourceTree = ""; }; + 9470A8EF1402DFFB0056FF61 /* DataVisualization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataVisualization.cpp; path = source/Core/DataVisualization.cpp; sourceTree = ""; }; 94A9112B13D5DEF80046D8A6 /* FormatClasses.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatClasses.h; path = include/lldb/Core/FormatClasses.h; sourceTree = ""; }; 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatClasses.cpp; path = source/Core/FormatClasses.cpp; sourceTree = ""; }; 94B6E76013D8833C005F417F /* ValueObjectSyntheticFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectSyntheticFilter.h; path = include/lldb/Core/ValueObjectSyntheticFilter.h; sourceTree = ""; }; @@ -1916,6 +1919,8 @@ 26BC7E7310F1B85900F91463 /* DataBufferMemoryMap.cpp */, 26BC7D5A10F1B77400F91463 /* DataExtractor.h */, 26BC7E7110F1B85900F91463 /* DataExtractor.cpp */, + 9470A8EE1402DF940056FF61 /* DataVisualization.h */, + 9470A8EF1402DFFB0056FF61 /* DataVisualization.cpp */, 263664941140A4C10075843B /* Debugger.h */, 263664921140A4930075843B /* Debugger.cpp */, 26BC7D5E10F1B77400F91463 /* Disassembler.h */, @@ -3294,6 +3299,7 @@ 266DFE9413FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp in Sources */, 266DFE9713FD656E00D0C574 /* OperatingSystem.cpp in Sources */, 26954EBE1401EE8B00294D09 /* DynamicRegisterInfo.cpp in Sources */, + 9470A8F01402DFFB0056FF61 /* DataVisualization.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=138279&r1=138278&r2=138279&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Aug 22 17:03:47 2011 @@ -13,8 +13,8 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/DataVisualization.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/FormatManager.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Timer.h" Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=138279&r1=138278&r2=138279&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Mon Aug 22 17:03:47 2011 @@ -15,9 +15,9 @@ // C++ Includes +#include "lldb/Core/DataVisualization.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/FormatManager.h" #include "lldb/Core/InputReaderEZ.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Core/State.h" Added: lldb/trunk/source/Core/DataVisualization.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataVisualization.cpp?rev=138279&view=auto ============================================================================== --- lldb/trunk/source/Core/DataVisualization.cpp (added) +++ lldb/trunk/source/Core/DataVisualization.cpp Mon Aug 22 17:03:47 2011 @@ -0,0 +1,203 @@ +//===-- DataVisualization.cpp ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Core/DataVisualization.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + +#include "lldb/Core/Debugger.h" + +using namespace lldb; +using namespace lldb_private; + +static FormatManager& +GetFormatManager() +{ + static FormatManager g_format_manager; + return g_format_manager; +} + +void +DataVisualization::ForceUpdate() +{ + GetFormatManager().Changed(); +} + +uint32_t +DataVisualization::GetCurrentRevision () +{ + return GetFormatManager().GetCurrentRevision(); +} + +bool +DataVisualization::ValueFormats::Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry) +{ + return GetFormatManager().GetValueNavigator().Get(valobj,entry, use_dynamic); +} + +void +DataVisualization::ValueFormats::Add(const ConstString &type, const lldb::ValueFormatSP &entry) +{ + GetFormatManager().GetValueNavigator().Add(FormatManager::GetValidTypeName(type),entry); +} + +bool +DataVisualization::ValueFormats::Delete(const ConstString &type) +{ + return GetFormatManager().GetValueNavigator().Delete(type); +} + +void +DataVisualization::ValueFormats::Clear() +{ + GetFormatManager().GetValueNavigator().Clear(); +} + +void +DataVisualization::ValueFormats::LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton) +{ + GetFormatManager().GetValueNavigator().LoopThrough(callback, callback_baton); +} + +uint32_t +DataVisualization::ValueFormats::GetCount() +{ + return GetFormatManager().GetValueNavigator().GetCount(); +} + +bool +DataVisualization::GetSummaryFormat(ValueObject& valobj, + lldb::DynamicValueType use_dynamic, + lldb::SummaryFormatSP& entry) +{ + return GetFormatManager().Get(valobj, entry, use_dynamic); +} +bool +DataVisualization::GetSyntheticChildren(ValueObject& valobj, + lldb::DynamicValueType use_dynamic, + lldb::SyntheticChildrenSP& entry) +{ + return GetFormatManager().Get(valobj, entry, use_dynamic); +} + +bool +DataVisualization::AnyMatches(ConstString type_name, + FormatCategory::FormatCategoryItems items, + bool only_enabled, + const char** matching_category, + FormatCategory::FormatCategoryItems* matching_type) +{ + return GetFormatManager().AnyMatches(type_name, + items, + only_enabled, + matching_category, + matching_type); +} + +bool +DataVisualization::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry) +{ + entry = GetFormatManager().Category(category); + return true; +} + +void +DataVisualization::Categories::Add(const ConstString &category) +{ + GetFormatManager().Category(category); +} + +bool +DataVisualization::Categories::Delete(const ConstString &category) +{ + GetFormatManager().DisableCategory(category); + return GetFormatManager().GetCategories().Delete(category); +} + +void +DataVisualization::Categories::Clear() +{ + GetFormatManager().GetCategories().Clear(); +} + +void +DataVisualization::Categories::Clear(ConstString &category) +{ + GetFormatManager().Category(category)->ClearSummaries(); +} + +void +DataVisualization::Categories::Enable(ConstString& category) +{ + if (GetFormatManager().Category(category)->IsEnabled() == false) + GetFormatManager().EnableCategory(category); + else + { + GetFormatManager().DisableCategory(category); + GetFormatManager().EnableCategory(category); + } +} + +void +DataVisualization::Categories::Disable(ConstString& category) +{ + if (GetFormatManager().Category(category)->IsEnabled() == true) + GetFormatManager().DisableCategory(category); +} + +void +DataVisualization::Categories::LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton) +{ + GetFormatManager().LoopThroughCategories(callback, callback_baton); +} + +uint32_t +DataVisualization::Categories::GetCount() +{ + return GetFormatManager().GetCategories().GetCount(); +} + +bool +DataVisualization::NamedSummaryFormats::Get(const ConstString &type, lldb::SummaryFormatSP &entry) +{ + return GetFormatManager().GetNamedSummaryNavigator().Get(type,entry); +} + +void +DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const lldb::SummaryFormatSP &entry) +{ + GetFormatManager().GetNamedSummaryNavigator().Add(FormatManager::GetValidTypeName(type),entry); +} + +bool +DataVisualization::NamedSummaryFormats::Delete(const ConstString &type) +{ + return GetFormatManager().GetNamedSummaryNavigator().Delete(type); +} + +void +DataVisualization::NamedSummaryFormats::Clear() +{ + GetFormatManager().GetNamedSummaryNavigator().Clear(); +} + +void +DataVisualization::NamedSummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton) +{ + GetFormatManager().GetNamedSummaryNavigator().LoopThrough(callback, callback_baton); +} + +uint32_t +DataVisualization::NamedSummaryFormats::GetCount() +{ + return GetFormatManager().GetNamedSummaryNavigator().GetCount(); +} \ No newline at end of file Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=138279&r1=138278&r2=138279&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Mon Aug 22 17:03:47 2011 @@ -225,6 +225,62 @@ } } +void +FormatCategory::Clear (FormatCategoryItems items) +{ + if ( (items & eSummary) == eSummary ) + m_summary_nav->Clear(); + if ( (items & eRegexSummary) == eRegexSummary ) + m_regex_summary_nav->Clear(); + if ( (items & eFilter) == eFilter ) + m_filter_nav->Clear(); + if ( (items & eRegexFilter) == eRegexFilter ) + m_regex_filter_nav->Clear(); + if ( (items & eSynth) == eSynth ) + m_synth_nav->Clear(); + if ( (items & eRegexSynth) == eRegexSynth ) + m_regex_synth_nav->Clear(); +} + +bool +FormatCategory::Delete (ConstString name, + FormatCategoryItems items) +{ + bool success = false; + if ( (items & eSummary) == eSummary ) + success = m_summary_nav->Delete(name) || success; + if ( (items & eRegexSummary) == eRegexSummary ) + success = m_regex_summary_nav->Delete(name) || success; + if ( (items & eFilter) == eFilter ) + success = m_filter_nav->Delete(name) || success; + if ( (items & eRegexFilter) == eRegexFilter ) + success = m_regex_filter_nav->Delete(name) || success; + if ( (items & eSynth) == eSynth ) + success = m_synth_nav->Delete(name) || success; + if ( (items & eRegexSynth) == eRegexSynth ) + success = m_regex_synth_nav->Delete(name) || success; + return success; +} + +uint32_t +FormatCategory::GetCount (FormatCategoryItems items) +{ + uint32_t count = 0; + if ( (items & eSummary) == eSummary ) + count += m_summary_nav->GetCount(); + if ( (items & eRegexSummary) == eRegexSummary ) + count += m_regex_summary_nav->GetCount(); + if ( (items & eFilter) == eFilter ) + count += m_filter_nav->GetCount(); + if ( (items & eRegexFilter) == eRegexFilter ) + count += m_regex_filter_nav->GetCount(); + if ( (items & eSynth) == eSynth ) + count += m_synth_nav->GetCount(); + if ( (items & eRegexSynth) == eRegexSynth ) + count += m_regex_synth_nav->GetCount(); + return count; +} + bool FormatCategory::AnyMatches(ConstString type_name, FormatCategoryItems items, @@ -458,187 +514,4 @@ EnableCategory(m_gnu_cpp_category_name); EnableCategory(m_default_category_name); -} - -static FormatManager& -GetFormatManager() -{ - static FormatManager g_format_manager; - return g_format_manager; -} - -void -DataVisualization::ForceUpdate() -{ - GetFormatManager().Changed(); -} - -uint32_t -DataVisualization::GetCurrentRevision () -{ - return GetFormatManager().GetCurrentRevision(); -} - -bool -DataVisualization::ValueFormats::Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry) -{ - return GetFormatManager().Value().Get(valobj,entry, use_dynamic); -} - -void -DataVisualization::ValueFormats::Add(const ConstString &type, const lldb::ValueFormatSP &entry) -{ - GetFormatManager().Value().Add(FormatManager::GetValidTypeName(type),entry); -} - -bool -DataVisualization::ValueFormats::Delete(const ConstString &type) -{ - return GetFormatManager().Value().Delete(type); -} - -void -DataVisualization::ValueFormats::Clear() -{ - GetFormatManager().Value().Clear(); -} - -void -DataVisualization::ValueFormats::LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton) -{ - GetFormatManager().Value().LoopThrough(callback, callback_baton); -} - -uint32_t -DataVisualization::ValueFormats::GetCount() -{ - return GetFormatManager().Value().GetCount(); -} - -bool -DataVisualization::GetSummaryFormat(ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - lldb::SummaryFormatSP& entry) -{ - return GetFormatManager().Get(valobj, entry, use_dynamic); -} -bool -DataVisualization::GetSyntheticChildren(ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - lldb::SyntheticChildrenSP& entry) -{ - return GetFormatManager().Get(valobj, entry, use_dynamic); -} - -bool -DataVisualization::AnyMatches(ConstString type_name, - FormatCategory::FormatCategoryItems items, - bool only_enabled, - const char** matching_category, - FormatCategory::FormatCategoryItems* matching_type) -{ - return GetFormatManager().AnyMatches(type_name, - items, - only_enabled, - matching_category, - matching_type); -} - -bool -DataVisualization::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry) -{ - entry = GetFormatManager().Category(category); - return true; -} - -void -DataVisualization::Categories::Add(const ConstString &category) -{ - GetFormatManager().Category(category); -} - -bool -DataVisualization::Categories::Delete(const ConstString &category) -{ - GetFormatManager().DisableCategory(category); - return GetFormatManager().Categories().Delete(category); -} - -void -DataVisualization::Categories::Clear() -{ - GetFormatManager().Categories().Clear(); -} - -void -DataVisualization::Categories::Clear(ConstString &category) -{ - GetFormatManager().Category(category)->ClearSummaries(); -} - -void -DataVisualization::Categories::Enable(ConstString& category) -{ - if (GetFormatManager().Category(category)->IsEnabled() == false) - GetFormatManager().EnableCategory(category); - else - { - GetFormatManager().DisableCategory(category); - GetFormatManager().EnableCategory(category); - } -} - -void -DataVisualization::Categories::Disable(ConstString& category) -{ - if (GetFormatManager().Category(category)->IsEnabled() == true) - GetFormatManager().DisableCategory(category); -} - -void -DataVisualization::Categories::LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton) -{ - GetFormatManager().LoopThroughCategories(callback, callback_baton); -} - -uint32_t -DataVisualization::Categories::GetCount() -{ - return GetFormatManager().Categories().GetCount(); -} - -bool -DataVisualization::NamedSummaryFormats::Get(const ConstString &type, lldb::SummaryFormatSP &entry) -{ - return GetFormatManager().NamedSummary().Get(type,entry); -} - -void -DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const lldb::SummaryFormatSP &entry) -{ - GetFormatManager().NamedSummary().Add(FormatManager::GetValidTypeName(type),entry); -} - -bool -DataVisualization::NamedSummaryFormats::Delete(const ConstString &type) -{ - return GetFormatManager().NamedSummary().Delete(type); -} - -void -DataVisualization::NamedSummaryFormats::Clear() -{ - GetFormatManager().NamedSummary().Clear(); -} - -void -DataVisualization::NamedSummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton) -{ - GetFormatManager().NamedSummary().LoopThrough(callback, callback_baton); -} - -uint32_t -DataVisualization::NamedSummaryFormats::GetCount() -{ - return GetFormatManager().NamedSummary().GetCount(); } \ No newline at end of file Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=138279&r1=138278&r2=138279&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Mon Aug 22 17:03:47 2011 @@ -19,8 +19,8 @@ // Project includes #include "lldb/Core/DataBufferHeap.h" +#include "lldb/Core/DataVisualization.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/FormatManager.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectChild.h" Modified: lldb/trunk/source/Interpreter/CommandObjectScript.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.cpp?rev=138279&r1=138278&r2=138279&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectScript.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObjectScript.cpp Mon Aug 22 17:03:47 2011 @@ -14,8 +14,8 @@ // Other libraries and framework includes // Project includes +#include "lldb/Core/DataVisualization.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/FormatManager.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandReturnObject.h" From johnny.chen at apple.com Mon Aug 22 17:10:57 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 22 Aug 2011 22:10:57 -0000 Subject: [Lldb-commits] [lldb] r138280 - /lldb/trunk/scripts/Python/build-swig-Python.sh Message-ID: <20110822221057.5BD122A6C12C@llvm.org> Author: johnny Date: Mon Aug 22 17:10:57 2011 New Revision: 138280 URL: http://llvm.org/viewvc/llvm-project?rev=138280&view=rev Log: Check the timesatmps of includees python-extensions.swig and python-wrapper.swig and force a re-SWIG if newer than the SWIG-generated LLDBWrapPython.cpp file. Modified: lldb/trunk/scripts/Python/build-swig-Python.sh Modified: lldb/trunk/scripts/Python/build-swig-Python.sh URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=138280&r1=138279&r2=138280&view=diff ============================================================================== --- lldb/trunk/scripts/Python/build-swig-Python.sh (original) +++ lldb/trunk/scripts/Python/build-swig-Python.sh Mon Aug 22 17:10:57 2011 @@ -20,8 +20,8 @@ swig_output_file=${SRC_ROOT}/source/LLDBWrapPython.cpp swig_input_file=${SRC_ROOT}/scripts/lldb.swig -swig_input_file2=${SRC_ROOT}/scripts/Python/python-extensions.swig - +swig_python_extensions=${SRC_ROOT}/scripts/Python/python-extensions.swig +swig_python_wrapper=${SRC_ROOT}/scripts/Python/python-wrapper.swig if [ -n "$debug_flag" -a "$debug_flag" == "-debug" ] then @@ -123,12 +123,25 @@ if [ $NeedToUpdate == 0 ] then - if [ ${swig_input_file2} -nt ${swig_output_file} ] + if [ ${swig_python_extensions} -nt ${swig_output_file} ] + then + NeedToUpdate=1 + if [ $Debug == 1 ] + then + echo "${swig_python_extensions} is newer than ${swig_output_file}" + echo "swig file will need to be re-built." + fi + fi +fi + +if [ $NeedToUpdate == 0 ] +then + if [ ${swig_python_wrapper} -nt ${swig_output_file} ] then NeedToUpdate=1 if [ $Debug == 1 ] then - echo "${swig_input_file2} is newer than ${swig_output_file}" + echo "${swig_python_wrapper} is newer than ${swig_output_file}" echo "swig file will need to be re-built." fi fi From johnny.chen at apple.com Mon Aug 22 17:22:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 22 Aug 2011 22:22:00 -0000 Subject: [Lldb-commits] [lldb] r138281 - in /lldb/trunk: source/Commands/CommandObjectTarget.cpp test/help/TestHelp.py Message-ID: <20110822222200.6F1BA2A6C12C@llvm.org> Author: johnny Date: Mon Aug 22 17:22:00 2011 New Revision: 138281 URL: http://llvm.org/viewvc/llvm-project?rev=138281&view=rev Log: Fix the 'target variable' help syntax to output one or more 's. Add a simple test case for that. Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/test/help/TestHelp.py Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=138281&r1=138280&r2=138281&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Mon Aug 22 17:22:00 2011 @@ -538,6 +538,19 @@ m_option_shared_libraries (LLDB_OPT_SET_1, false, "shlib",'s', 0, eArgTypePath, "A basename or fullpath to a shared library to use in the search for global variables. This option can be specified multiple times."), m_varobj_options() { + CommandArgumentEntry arg; + CommandArgumentData var_name_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeVarName; + var_name_arg.arg_repetition = eArgRepeatPlus; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (var_name_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); + m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Append (&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); m_option_group.Append (&m_option_compile_units, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); Modified: lldb/trunk/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=138281&r1=138280&r2=138281&view=diff ============================================================================== --- lldb/trunk/test/help/TestHelp.py (original) +++ lldb/trunk/test/help/TestHelp.py Mon Aug 22 17:22:00 2011 @@ -93,6 +93,11 @@ self.expect("help image du line", substrs = ['Dump the debug symbol file for one or more target modules']) + def test_help_target_variable_syntax(self): + """Command 'help target variable' should display ...""" + self.expect("help target variable", + substrs = [' [ [...]]']) + if __name__ == '__main__': import atexit From gclayton at apple.com Mon Aug 22 17:23:48 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 22 Aug 2011 22:23:48 -0000 Subject: [Lldb-commits] [lldb] r138282 - in /lldb/trunk/source/Plugins: DynamicLoader/Darwin-Kernel/ DynamicLoader/MacOSX-Kernel/ OperatingSystem/Darwin-Kernel/ OperatingSystem/MacOSX-Kernel/ Message-ID: <20110822222348.B43032A6C12C@llvm.org> Author: gclayton Date: Mon Aug 22 17:23:48 2011 New Revision: 138282 URL: http://llvm.org/viewvc/llvm-project?rev=138282&view=rev Log: Renaming "MacOSX-Kernel" to "Darwin-Kernel". The file contents and project commit will come shortly after this commit. Added: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/ - copied from r138280, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp - copied unchanged from r138280, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h - copied unchanged from r138280, lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.h lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/ - copied from r138280, lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/ lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp - copied unchanged from r138280, lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.cpp lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h - copied unchanged from r138280, lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.h Removed: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderMacOSXKernel.cpp lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderMacOSXKernel.h lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/ lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemMacOSXKernel.cpp lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemMacOSXKernel.h lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/ Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/Makefile Removed: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderMacOSXKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp?rev=138280&view=auto ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderMacOSXKernel.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderMacOSXKernel.cpp (removed) @@ -1,1096 +0,0 @@ -//===-- DynamicLoaderMacOSXKernel.cpp -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Breakpoint/StoppointCallbackContext.h" -#include "lldb/Core/DataBuffer.h" -#include "lldb/Core/DataBufferHeap.h" -#include "lldb/Core/Debugger.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/Module.h" -#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" -#include "lldb/Target/ThreadPlanRunToAddress.h" -#include "lldb/Target/StackFrame.h" - -#include "DynamicLoaderMacOSXKernel.h" - -//#define ENABLE_DEBUG_PRINTF // COMMENT THIS LINE OUT PRIOR TO CHECKIN -#ifdef ENABLE_DEBUG_PRINTF -#include -#define DEBUG_PRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__) -#else -#define DEBUG_PRINTF(fmt, ...) -#endif - -using namespace lldb; -using namespace lldb_private; - -/// FIXME - The ObjC Runtime trampoline handler doesn't really belong here. -/// I am putting it here so I can invoke it in the Trampoline code here, but -/// it should be moved to the ObjC Runtime support when it is set up. - - -//---------------------------------------------------------------------- -// Create an instance of this class. This function is filled into -// the plugin info class that gets handed out by the plugin factory and -// allows the lldb to instantiate an instance of this class. -//---------------------------------------------------------------------- -DynamicLoader * -DynamicLoaderMacOSXKernel::CreateInstance (Process* process, bool force) -{ - bool create = force; - if (!create) - { - Module* exe_module = process->GetTarget().GetExecutableModulePointer(); - if (exe_module) - { - ObjectFile *object_file = exe_module->GetObjectFile(); - if (object_file) - { - SectionList *section_list = object_file->GetSectionList(); - if (section_list) - { - static ConstString g_kld_section_name ("__KLD"); - if (section_list->FindSectionByName (g_kld_section_name)) - { - create = true; - } - } - } - } - - if (create) - { - const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple(); - create = triple_ref.getOS() == llvm::Triple::Darwin && triple_ref.getVendor() == llvm::Triple::Apple; - } - } - - if (create) - return new DynamicLoaderMacOSXKernel (process); - return NULL; -} - -//---------------------------------------------------------------------- -// Constructor -//---------------------------------------------------------------------- -DynamicLoaderMacOSXKernel::DynamicLoaderMacOSXKernel (Process* process) : - DynamicLoader(process), - m_kernel(), - m_kext_summary_header_ptr_addr (), - m_kext_summary_header_addr (), - m_kext_summary_header (), - m_break_id (LLDB_INVALID_BREAK_ID), - m_kext_summaries(), - m_mutex(Mutex::eMutexTypeRecursive) -{ -} - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -DynamicLoaderMacOSXKernel::~DynamicLoaderMacOSXKernel() -{ - Clear(true); -} - -void -DynamicLoaderMacOSXKernel::UpdateIfNeeded() -{ - LoadKernelModuleIfNeeded(); - SetNotificationBreakpointIfNeeded (); -} -//------------------------------------------------------------------ -/// Called after attaching a process. -/// -/// Allow DynamicLoader plug-ins to execute some code after -/// attaching to a process. -//------------------------------------------------------------------ -void -DynamicLoaderMacOSXKernel::DidAttach () -{ - PrivateInitialize(m_process); - UpdateIfNeeded(); -} - -//------------------------------------------------------------------ -/// Called after attaching a process. -/// -/// Allow DynamicLoader plug-ins to execute some code after -/// attaching to a process. -//------------------------------------------------------------------ -void -DynamicLoaderMacOSXKernel::DidLaunch () -{ - PrivateInitialize(m_process); - UpdateIfNeeded(); -} - - -//---------------------------------------------------------------------- -// Clear out the state of this class. -//---------------------------------------------------------------------- -void -DynamicLoaderMacOSXKernel::Clear (bool clear_process) -{ - Mutex::Locker locker(m_mutex); - - if (m_process->IsAlive() && LLDB_BREAK_ID_IS_VALID(m_break_id)) - m_process->ClearBreakpointSiteByID(m_break_id); - - if (clear_process) - m_process = NULL; - m_kernel.Clear(false); - m_kext_summary_header_ptr_addr.Clear(); - m_kext_summary_header_addr.Clear(); - m_kext_summaries.clear(); - m_break_id = LLDB_INVALID_BREAK_ID; -} - - -//---------------------------------------------------------------------- -// Load the kernel module and initialize the "m_kernel" member. Return -// true _only_ if the kernel is loaded the first time through (subsequent -// calls to this function should return false after the kernel has been -// already loaded). -//---------------------------------------------------------------------- -void -DynamicLoaderMacOSXKernel::LoadKernelModuleIfNeeded() -{ - if (!m_kext_summary_header_ptr_addr.IsValid()) - { - m_kernel.Clear(false); - m_kernel.module_sp = m_process->GetTarget().GetExecutableModule(); - if (m_kernel.module_sp) - { - static ConstString mach_header_name ("_mh_execute_header"); - static ConstString kext_summary_symbol ("gLoadedKextSummaries"); - const Symbol *symbol = NULL; - symbol = m_kernel.module_sp->FindFirstSymbolWithNameAndType (kext_summary_symbol, eSymbolTypeData); - if (symbol) - m_kext_summary_header_ptr_addr = symbol->GetValue(); - - symbol = m_kernel.module_sp->FindFirstSymbolWithNameAndType (mach_header_name, eSymbolTypeAbsolute); - if (symbol) - { - // The "_mh_execute_header" symbol is absolute and not a section based - // symbol that will have a valid address, so we need to resolve it... - m_process->GetTarget().GetImages().ResolveFileAddress (symbol->GetValue().GetFileAddress(), m_kernel.so_address); - DataExtractor data; // Load command data - if (ReadMachHeader (m_kernel, &data)) - { - if (m_kernel.header.filetype == llvm::MachO::HeaderFileTypeExecutable) - { - if (ParseLoadCommands (data, m_kernel)) - UpdateImageLoadAddress (m_kernel); - - // Update all image infos - ReadAllKextSummaries (); - } - } - else - { - m_kernel.Clear(false); - } - } - } - } -} - -bool -DynamicLoaderMacOSXKernel::FindTargetModule (OSKextLoadedKextSummary &image_info, bool can_create, bool *did_create_ptr) -{ - if (did_create_ptr) - *did_create_ptr = false; - - const bool image_info_uuid_is_valid = image_info.uuid.IsValid(); - - if (image_info.module_sp) - { - if (image_info_uuid_is_valid) - { - if (image_info.module_sp->GetUUID() == image_info.uuid) - return true; - else - image_info.module_sp.reset(); - } - else - return true; - } - - ModuleList &target_images = m_process->GetTarget().GetImages(); - if (image_info_uuid_is_valid) - image_info.module_sp = target_images.FindModule(image_info.uuid); - - if (image_info.module_sp) - return true; - - ArchSpec arch (image_info.GetArchitecture ()); - if (can_create) - { - if (image_info_uuid_is_valid) - { - image_info.module_sp = m_process->GetTarget().GetSharedModule (FileSpec(), - arch, - &image_info.uuid); - if (did_create_ptr) - *did_create_ptr = image_info.module_sp; - } - } - return image_info.module_sp; -} - -bool -DynamicLoaderMacOSXKernel::UpdateCommPageLoadAddress(Module *module) -{ - bool changed = false; - if (module) - { - ObjectFile *image_object_file = module->GetObjectFile(); - if (image_object_file) - { - SectionList *section_list = image_object_file->GetSectionList (); - if (section_list) - { - uint32_t num_sections = section_list->GetSize(); - for (uint32_t i=0; iGetSectionAtIndex (i).get(); - if (section) - { - const addr_t new_section_load_addr = section->GetFileAddress (); - const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section); - if (old_section_load_addr == LLDB_INVALID_ADDRESS || - old_section_load_addr != new_section_load_addr) - { - if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section, section->GetFileAddress ())) - changed = true; - } - } - } - } - } - } - return changed; -} - -//---------------------------------------------------------------------- -// Update the load addresses for all segments in MODULE using the -// updated INFO that is passed in. -//---------------------------------------------------------------------- -bool -DynamicLoaderMacOSXKernel::UpdateImageLoadAddress (OSKextLoadedKextSummary& info) -{ - Module *module = info.module_sp.get(); - bool changed = false; - if (module) - { - ObjectFile *image_object_file = module->GetObjectFile(); - if (image_object_file) - { - SectionList *section_list = image_object_file->GetSectionList (); - if (section_list) - { - // We now know the slide amount, so go through all sections - // and update the load addresses with the correct values. - uint32_t num_segments = info.segments.size(); - for (uint32_t i=0; iFindSectionByName(info.segments[i].name)) - { - SectionSP section_sp(section_list->FindSectionByName(info.segments[i].name)); - if (section_sp) - { - const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section_sp.get()); - if (old_section_load_addr == LLDB_INVALID_ADDRESS || - old_section_load_addr != new_section_load_addr) - { - if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), new_section_load_addr)) - changed = true; - } - } - else - { - fprintf (stderr, - "warning: unable to find and load segment named '%s' at 0x%llx in '%s/%s' in macosx dynamic loader plug-in.\n", - info.segments[i].name.AsCString(""), - (uint64_t)new_section_load_addr, - image_object_file->GetFileSpec().GetDirectory().AsCString(), - image_object_file->GetFileSpec().GetFilename().AsCString()); - } - } - else - { - // The segment name is empty which means this is a .o file. - // Object files in LLDB end up getting reorganized so that - // the segment name that is in the section is promoted into - // an actual segment, so we just need to go through all sections - // and slide them by a single amount. - - uint32_t num_sections = section_list->GetSize(); - for (uint32_t i=0; iGetSectionAtIndex (i).get(); - if (section) - { - if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section, section->GetFileAddress() + new_section_load_addr)) - changed = true; - } - } - } - } - } - } - } - return changed; -} - -//---------------------------------------------------------------------- -// Update the load addresses for all segments in MODULE using the -// updated INFO that is passed in. -//---------------------------------------------------------------------- -bool -DynamicLoaderMacOSXKernel::UnloadImageLoadAddress (OSKextLoadedKextSummary& info) -{ - Module *module = info.module_sp.get(); - bool changed = false; - if (module) - { - ObjectFile *image_object_file = module->GetObjectFile(); - if (image_object_file) - { - SectionList *section_list = image_object_file->GetSectionList (); - if (section_list) - { - uint32_t num_segments = info.segments.size(); - for (uint32_t i=0; iFindSectionByName(info.segments[i].name)); - if (section_sp) - { - const addr_t old_section_load_addr = info.segments[i].vmaddr; - if (m_process->GetTarget().GetSectionLoadList().SetSectionUnloaded (section_sp.get(), old_section_load_addr)) - changed = true; - } - else - { - fprintf (stderr, - "warning: unable to find and unload segment named '%s' in '%s/%s' in macosx dynamic loader plug-in.\n", - info.segments[i].name.AsCString(""), - image_object_file->GetFileSpec().GetDirectory().AsCString(), - image_object_file->GetFileSpec().GetFilename().AsCString()); - } - } - } - } - } - return changed; -} - - -//---------------------------------------------------------------------- -// Static callback function that gets called when our DYLD notification -// breakpoint gets hit. We update all of our image infos and then -// let our super class DynamicLoader class decide if we should stop -// or not (based on global preference). -//---------------------------------------------------------------------- -bool -DynamicLoaderMacOSXKernel::BreakpointHitCallback (void *baton, - StoppointCallbackContext *context, - user_id_t break_id, - user_id_t break_loc_id) -{ - return static_cast(baton)->BreakpointHit (context, break_id, break_loc_id); -} - -bool -DynamicLoaderMacOSXKernel::BreakpointHit (StoppointCallbackContext *context, - user_id_t break_id, - user_id_t break_loc_id) -{ - LogSP log(GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); - if (log) - log->Printf ("DynamicLoaderMacOSXKernel::BreakpointHit (...)\n"); - - ReadAllKextSummaries (); - - if (log) - PutToLog(log.get()); - - return GetStopWhenImagesChange(); -} - - -bool -DynamicLoaderMacOSXKernel::ReadKextSummaryHeader () -{ - Mutex::Locker locker(m_mutex); - - // the all image infos is already valid for this process stop ID - - m_kext_summaries.clear(); - if (m_kext_summary_header_ptr_addr.IsValid()) - { - const uint32_t addr_size = m_kernel.GetAddressByteSize (); - const ByteOrder byte_order = m_kernel.GetByteOrder(); - Error error; - // Read enough bytes for a "OSKextLoadedKextSummaryHeader" structure - // which is currenty 4 uint32_t and a pointer. - uint8_t buf[24]; - DataExtractor data (buf, sizeof(buf), byte_order, addr_size); - const size_t count = 4 * sizeof(uint32_t) + addr_size; - const bool prefer_file_cache = false; - if (m_process->GetTarget().ReadPointerFromMemory (m_kext_summary_header_ptr_addr, - prefer_file_cache, - error, - m_kext_summary_header_addr)) - { - // We got a valid address for our kext summary header and make sure it isn't NULL - if (m_kext_summary_header_addr.IsValid() && - m_kext_summary_header_addr.GetFileAddress() != 0) - { - const size_t bytes_read = m_process->GetTarget().ReadMemory (m_kext_summary_header_addr, prefer_file_cache, buf, count, error); - if (bytes_read == count) - { - uint32_t offset = 0; - m_kext_summary_header.version = data.GetU32(&offset); - if (m_kext_summary_header.version >= 2) - { - m_kext_summary_header.entry_size = data.GetU32(&offset); - } - else - { - // Versions less than 2 didn't have an entry size, it was hard coded - m_kext_summary_header.entry_size = KERNEL_MODULE_ENTRY_SIZE_VERSION_1; - } - m_kext_summary_header.entry_count = data.GetU32(&offset); - return true; - } - } - } - } - m_kext_summary_header_addr.Clear(); - return false; -} - - -bool -DynamicLoaderMacOSXKernel::ParseKextSummaries (const Address &kext_summary_addr, - uint32_t count) -{ - OSKextLoadedKextSummary::collection kext_summaries; - LogSP log(GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); - if (log) - log->Printf ("Adding %d modules.\n"); - - Mutex::Locker locker(m_mutex); - - if (!ReadKextSummaries (kext_summary_addr, count, kext_summaries)) - return false; - - Stream *s = &m_process->GetTarget().GetDebugger().GetOutputStream(); - for (uint32_t i = 0; i < count; i++) - { - if (s) - { - const uint8_t *u = (const uint8_t *)kext_summaries[i].uuid.GetBytes(); - if (u) - { - s->Printf("Loading kext: %2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X 0x%16.16llx \"%s\"...\n", - u[ 0], u[ 1], u[ 2], u[ 3], u[ 4], u[ 5], u[ 6], u[ 7], - u[ 8], u[ 9], u[10], u[11], u[12], u[13], u[14], u[15], - kext_summaries[i].address, kext_summaries[i].name); - } - else - { - s->Printf("0x%16.16llx \"%s\"...\n", kext_summaries[i].address, kext_summaries[i].name); - } - } - - DataExtractor data; // Load command data - if (ReadMachHeader (kext_summaries[i], &data)) - { - ParseLoadCommands (data, kext_summaries[i]); - } - - if (s) - { - if (kext_summaries[i].module_sp) - s->Printf(" found kext: %s/%s\n", - kext_summaries[i].module_sp->GetFileSpec().GetDirectory().AsCString(), - kext_summaries[i].module_sp->GetFileSpec().GetFilename().AsCString()); - } - - if (log) - kext_summaries[i].PutToLog (log.get()); - } - bool return_value = AddModulesUsingImageInfos (kext_summaries); - return return_value; -} - -// Adds the modules in image_infos to m_kext_summaries. -// NB don't call this passing in m_kext_summaries. - -bool -DynamicLoaderMacOSXKernel::AddModulesUsingImageInfos (OSKextLoadedKextSummary::collection &image_infos) -{ - // Now add these images to the main list. - ModuleList loaded_module_list; - - for (uint32_t idx = 0; idx < image_infos.size(); ++idx) - { - m_kext_summaries.push_back(image_infos[idx]); - - if (FindTargetModule (image_infos[idx], true, NULL)) - { - // UpdateImageLoadAddress will return true if any segments - // change load address. We need to check this so we don't - // mention that all loaded shared libraries are newly loaded - // each time we hit out dyld breakpoint since dyld will list all - // shared libraries each time. - if (UpdateImageLoadAddress (image_infos[idx])) - { - loaded_module_list.AppendIfNeeded (image_infos[idx].module_sp); - } - } - } - - if (loaded_module_list.GetSize() > 0) - { - // FIXME: This should really be in the Runtime handlers class, which should get - // called by the target's ModulesDidLoad, but we're doing it all locally for now - // to save time. - // Also, I'm assuming there can be only one libobjc dylib loaded... - - 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 (objc_runtime->IsModuleObjCLibrary (loaded_module_list.GetModuleAtIndex (i))) - { - objc_runtime->ReadObjCLibrary (loaded_module_list.GetModuleAtIndex (i)); - break; - } - } - } -// if (log) -// loaded_module_list.LogUUIDAndPaths (log, "DynamicLoaderMacOSXKernel::ModulesDidLoad"); - m_process->GetTarget().ModulesDidLoad (loaded_module_list); - } - return true; -} - - -uint32_t -DynamicLoaderMacOSXKernel::ReadKextSummaries (const Address &kext_summary_addr, - uint32_t image_infos_count, - OSKextLoadedKextSummary::collection &image_infos) -{ - const ByteOrder endian = m_kernel.GetByteOrder(); - const uint32_t addr_size = m_kernel.GetAddressByteSize(); - - image_infos.resize(image_infos_count); - const size_t count = image_infos.size() * m_kext_summary_header.entry_size; - DataBufferHeap data(count, 0); - Error error; - - Stream *s = &m_process->GetTarget().GetDebugger().GetOutputStream(); - - if (s) - s->Printf ("Reading %u kext summaries...\n", image_infos_count); - const bool prefer_file_cache = false; - const size_t bytes_read = m_process->GetTarget().ReadMemory (kext_summary_addr, - prefer_file_cache, - data.GetBytes(), - data.GetByteSize(), - error); - if (bytes_read == count) - { - - DataExtractor extractor (data.GetBytes(), data.GetByteSize(), endian, addr_size); - uint32_t i=0; - for (uint32_t kext_summary_offset = 0; - i < image_infos.size() && extractor.ValidOffsetForDataOfSize(kext_summary_offset, m_kext_summary_header.entry_size); - ++i, kext_summary_offset += m_kext_summary_header.entry_size) - { - uint32_t offset = kext_summary_offset; - const void *name_data = extractor.GetData(&offset, KERNEL_MODULE_MAX_NAME); - if (name_data == NULL) - break; - memcpy (image_infos[i].name, name_data, KERNEL_MODULE_MAX_NAME); - image_infos[i].uuid.SetBytes(extractor.GetData (&offset, 16)); - image_infos[i].address = extractor.GetU64(&offset); - if (!image_infos[i].so_address.SetLoadAddress (image_infos[i].address, &m_process->GetTarget())) - m_process->GetTarget().GetImages().ResolveFileAddress (image_infos[i].address, image_infos[i].so_address); - image_infos[i].size = extractor.GetU64(&offset); - image_infos[i].version = extractor.GetU64(&offset); - image_infos[i].load_tag = extractor.GetU32(&offset); - image_infos[i].flags = extractor.GetU32(&offset); - if ((offset - kext_summary_offset) < m_kext_summary_header.entry_size) - { - image_infos[i].reference_list = extractor.GetU64(&offset); - } - else - { - image_infos[i].reference_list = 0; - } - } - if (i < image_infos.size()) - image_infos.resize(i); - } - else - { - image_infos.clear(); - } - return image_infos.size(); -} - -bool -DynamicLoaderMacOSXKernel::ReadAllKextSummaries () -{ - LogSP log(GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); - - Mutex::Locker locker(m_mutex); - - if (ReadKextSummaryHeader ()) - { - if (m_kext_summary_header.entry_count > 0 && m_kext_summary_header_addr.IsValid()) - { - Address summary_addr (m_kext_summary_header_addr); - summary_addr.Slide(m_kext_summary_header.GetSize()); - if (!ParseKextSummaries (summary_addr, m_kext_summary_header.entry_count)) - { - m_kext_summaries.clear(); - } - return true; - } - } - return false; -} - -//---------------------------------------------------------------------- -// Read a mach_header at ADDR into HEADER, and also fill in the load -// command data into LOAD_COMMAND_DATA if it is non-NULL. -// -// Returns true if we succeed, false if we fail for any reason. -//---------------------------------------------------------------------- -bool -DynamicLoaderMacOSXKernel::ReadMachHeader (OSKextLoadedKextSummary& kext_summary, DataExtractor *load_command_data) -{ - DataBufferHeap header_bytes(sizeof(llvm::MachO::mach_header), 0); - Error error; - const bool prefer_file_cache = false; - size_t bytes_read = m_process->GetTarget().ReadMemory (kext_summary.so_address, - prefer_file_cache, - header_bytes.GetBytes(), - header_bytes.GetByteSize(), - error); - if (bytes_read == sizeof(llvm::MachO::mach_header)) - { - uint32_t offset = 0; - ::memset (&kext_summary.header, 0, sizeof(kext_summary.header)); - - // Get the magic byte unswapped so we can figure out what we are dealing with - DataExtractor data(header_bytes.GetBytes(), header_bytes.GetByteSize(), endian::InlHostByteOrder(), 4); - kext_summary.header.magic = data.GetU32(&offset); - Address load_cmd_addr = kext_summary.so_address; - data.SetByteOrder(DynamicLoaderMacOSXKernel::GetByteOrderFromMagic(kext_summary.header.magic)); - switch (kext_summary.header.magic) - { - case llvm::MachO::HeaderMagic32: - case llvm::MachO::HeaderMagic32Swapped: - data.SetAddressByteSize(4); - load_cmd_addr.Slide (sizeof(llvm::MachO::mach_header)); - break; - - case llvm::MachO::HeaderMagic64: - case llvm::MachO::HeaderMagic64Swapped: - data.SetAddressByteSize(8); - load_cmd_addr.Slide (sizeof(llvm::MachO::mach_header_64)); - break; - - default: - return false; - } - - // Read the rest of dyld's mach header - if (data.GetU32(&offset, &kext_summary.header.cputype, (sizeof(llvm::MachO::mach_header)/sizeof(uint32_t)) - 1)) - { - if (load_command_data == NULL) - return true; // We were able to read the mach_header and weren't asked to read the load command bytes - - DataBufferSP load_cmd_data_sp(new DataBufferHeap(kext_summary.header.sizeofcmds, 0)); - - size_t load_cmd_bytes_read = m_process->GetTarget().ReadMemory (load_cmd_addr, - prefer_file_cache, - load_cmd_data_sp->GetBytes(), - load_cmd_data_sp->GetByteSize(), - error); - - if (load_cmd_bytes_read == kext_summary.header.sizeofcmds) - { - // Set the load command data and also set the correct endian - // swap settings and the correct address size - load_command_data->SetData(load_cmd_data_sp, 0, kext_summary.header.sizeofcmds); - load_command_data->SetByteOrder(data.GetByteOrder()); - load_command_data->SetAddressByteSize(data.GetAddressByteSize()); - return true; // We successfully read the mach_header and the load command data - } - - return false; // We weren't able to read the load command data - } - } - return false; // We failed the read the mach_header -} - - -//---------------------------------------------------------------------- -// Parse the load commands for an image -//---------------------------------------------------------------------- -uint32_t -DynamicLoaderMacOSXKernel::ParseLoadCommands (const DataExtractor& data, OSKextLoadedKextSummary& image_info) -{ - uint32_t offset = 0; - uint32_t cmd_idx; - Segment segment; - image_info.Clear (true); - - for (cmd_idx = 0; cmd_idx < image_info.header.ncmds; cmd_idx++) - { - // Clear out any load command specific data from image_info since - // we are about to read it. - - if (data.ValidOffsetForDataOfSize (offset, sizeof(llvm::MachO::load_command))) - { - llvm::MachO::load_command load_cmd; - uint32_t load_cmd_offset = offset; - load_cmd.cmd = data.GetU32 (&offset); - load_cmd.cmdsize = data.GetU32 (&offset); - switch (load_cmd.cmd) - { - case llvm::MachO::LoadCommandSegment32: - { - segment.name.SetTrimmedCStringWithLength ((const char *)data.GetData(&offset, 16), 16); - // We are putting 4 uint32_t values 4 uint64_t values so - // we have to use multiple 32 bit gets below. - segment.vmaddr = data.GetU32 (&offset); - segment.vmsize = data.GetU32 (&offset); - segment.fileoff = data.GetU32 (&offset); - segment.filesize = data.GetU32 (&offset); - // Extract maxprot, initprot, nsects and flags all at once - data.GetU32(&offset, &segment.maxprot, 4); - image_info.segments.push_back (segment); - } - break; - - case llvm::MachO::LoadCommandSegment64: - { - segment.name.SetTrimmedCStringWithLength ((const char *)data.GetData(&offset, 16), 16); - // Extract vmaddr, vmsize, fileoff, and filesize all at once - data.GetU64(&offset, &segment.vmaddr, 4); - // Extract maxprot, initprot, nsects and flags all at once - data.GetU32(&offset, &segment.maxprot, 4); - image_info.segments.push_back (segment); - } - break; - - case llvm::MachO::LoadCommandUUID: - image_info.uuid.SetBytes(data.GetData (&offset, 16)); - break; - - default: - break; - } - // Set offset to be the beginning of the next load command. - offset = load_cmd_offset + load_cmd.cmdsize; - } - } -#if 0 - // No slide in the kernel... - - // All sections listed in the dyld image info structure will all - // either be fixed up already, or they will all be off by a single - // slide amount that is determined by finding the first segment - // that is at file offset zero which also has bytes (a file size - // that is greater than zero) in the object file. - - // Determine the slide amount (if any) - const size_t num_sections = image_info.segments.size(); - for (size_t i = 0; i < num_sections; ++i) - { - // Iterate through the object file sections to find the - // first section that starts of file offset zero and that - // has bytes in the file... - if (image_info.segments[i].fileoff == 0 && image_info.segments[i].filesize > 0) - { - image_info.slide = image_info.address - image_info.segments[i].vmaddr; - // We have found the slide amount, so we can exit - // this for loop. - break; - } - } -#endif - if (image_info.uuid.IsValid()) - { - bool did_create = false; - if (FindTargetModule(image_info, true, &did_create)) - { - if (did_create) - image_info.module_create_stop_id = m_process->GetStopID(); - } - } - return cmd_idx; -} - -//---------------------------------------------------------------------- -// Dump a Segment to the file handle provided. -//---------------------------------------------------------------------- -void -DynamicLoaderMacOSXKernel::Segment::PutToLog (Log *log, addr_t slide) const -{ - if (log) - { - if (slide == 0) - log->Printf ("\t\t%16s [0x%16.16llx - 0x%16.16llx)", - name.AsCString(""), - vmaddr + slide, - vmaddr + slide + vmsize); - else - log->Printf ("\t\t%16s [0x%16.16llx - 0x%16.16llx) slide = 0x%llx", - name.AsCString(""), - vmaddr + slide, - vmaddr + slide + vmsize, - slide); - } -} - -const DynamicLoaderMacOSXKernel::Segment * -DynamicLoaderMacOSXKernel::OSKextLoadedKextSummary::FindSegment (const ConstString &name) const -{ - const size_t num_segments = segments.size(); - for (size_t i=0; iPrintf("\tuuid=%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X name=\"%s\" (UNLOADED)", - u[ 0], u[ 1], u[ 2], u[ 3], - u[ 4], u[ 5], u[ 6], u[ 7], - u[ 8], u[ 9], u[10], u[11], - u[12], u[13], u[14], u[15], - name); - } - else - log->Printf("\tname=\"%s\" (UNLOADED)", name); - } - else - { - if (u) - { - log->Printf("\taddr=0x%16.16llx size=0x%16.16llx version=0x%16.16llx load-tag=0x%8.8x flags=0x%8.8x ref-list=0x%16.16llx uuid=%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X name=\"%s\"", - address, size, version, load_tag, flags, reference_list, - u[ 0], u[ 1], u[ 2], u[ 3], u[ 4], u[ 5], u[ 6], u[ 7], - u[ 8], u[ 9], u[10], u[11], u[12], u[13], u[14], u[15], - name); - } - else - { - log->Printf("\t[0x%16.16llx - 0x%16.16llx) version=0x%16.16llx load-tag=0x%8.8x flags=0x%8.8x ref-list=0x%16.16llx name=\"%s\"", - address, address+size, version, load_tag, flags, reference_list, - name); - } - for (uint32_t i=0; iPrintf("gLoadedKextSummaries = 0x%16.16llx { version=%u, entry_size=%u, entry_count=%u }", - m_kext_summary_header_addr.GetFileAddress(), - m_kext_summary_header.version, - m_kext_summary_header.entry_size, - m_kext_summary_header.entry_count); - - size_t i; - const size_t count = m_kext_summaries.size(); - if (count > 0) - { - log->PutCString("Loaded:"); - for (i = 0; iGetState())); - Clear(true); - m_process = process; - m_process->GetTarget().GetSectionLoadList().Clear(); -} - -void -DynamicLoaderMacOSXKernel::SetNotificationBreakpointIfNeeded () -{ - if (m_break_id == LLDB_INVALID_BREAK_ID) - { - DEBUG_PRINTF("DynamicLoaderMacOSXKernel::%s() process state = %s\n", __FUNCTION__, StateAsCString(m_process->GetState())); - - - const bool internal_bp = false; - const LazyBool skip_prologue = eLazyBoolNo; - Breakpoint *bp = m_process->GetTarget().CreateBreakpoint (&m_kernel.module_sp->GetFileSpec(), - "OSKextLoadedKextSummariesUpdated", - eFunctionNameTypeFull, - internal_bp, - skip_prologue).get(); - - bp->SetCallback (DynamicLoaderMacOSXKernel::BreakpointHitCallback, this, true); - m_break_id = bp->GetID(); - } -} - -//---------------------------------------------------------------------- -// Member function that gets called when the process state changes. -//---------------------------------------------------------------------- -void -DynamicLoaderMacOSXKernel::PrivateProcessStateChanged (Process *process, StateType state) -{ - DEBUG_PRINTF("DynamicLoaderMacOSXKernel::%s(%s)\n", __FUNCTION__, StateAsCString(state)); - switch (state) - { - case eStateConnected: - case eStateAttaching: - case eStateLaunching: - case eStateInvalid: - case eStateUnloaded: - case eStateExited: - case eStateDetached: - Clear(false); - break; - - case eStateStopped: - UpdateIfNeeded(); - break; - - case eStateRunning: - case eStateStepping: - case eStateCrashed: - case eStateSuspended: - break; - - default: - break; - } -} - -ThreadPlanSP -DynamicLoaderMacOSXKernel::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) -{ - ThreadPlanSP thread_plan_sp; - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); - if (log) - log->Printf ("Could not find symbol for step through."); - return thread_plan_sp; -} - -Error -DynamicLoaderMacOSXKernel::CanLoadImage () -{ - Error error; - error.SetErrorString("always unsafe to load or unload shared libraries in the darwin kernel"); - return error; -} - -void -DynamicLoaderMacOSXKernel::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -DynamicLoaderMacOSXKernel::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - - -const char * -DynamicLoaderMacOSXKernel::GetPluginNameStatic() -{ - return "dynamic-loader.macosx-kernel"; -} - -const char * -DynamicLoaderMacOSXKernel::GetPluginDescriptionStatic() -{ - return "Dynamic loader plug-in that watches for shared library loads/unloads in the MacOSX kernel."; -} - - -//------------------------------------------------------------------ -// PluginInterface protocol -//------------------------------------------------------------------ -const char * -DynamicLoaderMacOSXKernel::GetPluginName() -{ - return "DynamicLoaderMacOSXKernel"; -} - -const char * -DynamicLoaderMacOSXKernel::GetShortPluginName() -{ - return GetPluginNameStatic(); -} - -uint32_t -DynamicLoaderMacOSXKernel::GetPluginVersion() -{ - return 1; -} - Removed: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderMacOSXKernel.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.h?rev=138280&view=auto ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderMacOSXKernel.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderMacOSXKernel.h (removed) @@ -1,443 +0,0 @@ -//===-- DynamicLoaderMacOSXKernel.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_DynamicLoaderMacOSXKernel_h_ -#define liblldb_DynamicLoaderMacOSXKernel_h_ - -// C Includes -// C++ Includes -#include -#include -#include - -// Other libraries and framework includes -#include "llvm/Support/MachO.h" - -#include "lldb/Target/DynamicLoader.h" -#include "lldb/Host/FileSpec.h" -#include "lldb/Host/TimeValue.h" -#include "lldb/Core/UUID.h" -#include "lldb/Host/Mutex.h" -#include "lldb/Target/Process.h" - -class DynamicLoaderMacOSXKernel : public lldb_private::DynamicLoader -{ -public: - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - static lldb_private::DynamicLoader * - CreateInstance (lldb_private::Process *process, bool force); - - DynamicLoaderMacOSXKernel (lldb_private::Process *process); - - virtual - ~DynamicLoaderMacOSXKernel (); - //------------------------------------------------------------------ - /// Called after attaching a process. - /// - /// Allow DynamicLoader plug-ins to execute some code after - /// attaching to a process. - //------------------------------------------------------------------ - virtual void - DidAttach (); - - virtual void - DidLaunch (); - - virtual lldb::ThreadPlanSP - GetStepThroughTrampolinePlan (lldb_private::Thread &thread, - bool stop_others); - - virtual lldb_private::Error - CanLoadImage (); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - -protected: - void - PrivateInitialize (lldb_private::Process *process); - - void - PrivateProcessStateChanged (lldb_private::Process *process, - lldb::StateType state); - - void - UpdateIfNeeded(); - - void - LoadKernelModuleIfNeeded (); - - void - Clear (bool clear_process); - - void - PutToLog (lldb_private::Log *log) const; - - static bool - BreakpointHitCallback (void *baton, - lldb_private::StoppointCallbackContext *context, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id); - - bool - BreakpointHit (lldb_private::StoppointCallbackContext *context, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id); - uint32_t - AddrByteSize() - { - switch (m_kernel.header.magic) - { - case llvm::MachO::HeaderMagic32: - case llvm::MachO::HeaderMagic32Swapped: - return 4; - - case llvm::MachO::HeaderMagic64: - case llvm::MachO::HeaderMagic64Swapped: - return 8; - - default: - break; - } - return 0; - } - - static lldb::ByteOrder - GetByteOrderFromMagic (uint32_t magic) - { - switch (magic) - { - case llvm::MachO::HeaderMagic32: - case llvm::MachO::HeaderMagic64: - return lldb::endian::InlHostByteOrder(); - - case llvm::MachO::HeaderMagic32Swapped: - case llvm::MachO::HeaderMagic64Swapped: - if (lldb::endian::InlHostByteOrder() == lldb::eByteOrderBig) - return lldb::eByteOrderLittle; - else - return lldb::eByteOrderBig; - - default: - break; - } - return lldb::eByteOrderInvalid; - } - - class Segment - { - public: - - Segment() : - name(), - vmaddr(LLDB_INVALID_ADDRESS), - vmsize(0), - fileoff(0), - filesize(0), - maxprot(0), - initprot(0), - nsects(0), - flags(0) - { - } - - lldb_private::ConstString name; - lldb::addr_t vmaddr; - lldb::addr_t vmsize; - lldb::addr_t fileoff; - lldb::addr_t filesize; - uint32_t maxprot; - uint32_t initprot; - uint32_t nsects; - uint32_t flags; - - bool - operator==(const Segment& rhs) const - { - return name == rhs.name && vmaddr == rhs.vmaddr && vmsize == rhs.vmsize; - } - - void - PutToLog (lldb_private::Log *log, - lldb::addr_t slide) const; - - }; - - enum - { - KERNEL_MODULE_MAX_NAME = 64u, - // Versions less than 2 didn't have an entry size, - // they had a 64 bit name, 16 byte UUID, 8 byte addr, - // 8 byte size, 8 byte version, 4 byte load tag, and - // 4 byte flags - KERNEL_MODULE_ENTRY_SIZE_VERSION_1 = 64u + 16u + 8u + 8u + 8u + 4u + 4u - }; - - struct OSKextLoadedKextSummary - { - char name[KERNEL_MODULE_MAX_NAME]; - lldb::ModuleSP module_sp; - uint32_t module_create_stop_id; - lldb_private::UUID uuid; // UUID for this dylib if it has one, else all zeros - lldb_private::Address so_address; // The section offset address for this kext in case it can be read from object files - uint64_t address; - uint64_t size; - uint64_t version; - uint32_t load_tag; - uint32_t flags; - uint64_t reference_list; - llvm::MachO::mach_header header; // The mach header for this image - std::vector segments; // All segment vmaddr and vmsize pairs for this executable (from memory of inferior) - - OSKextLoadedKextSummary() : - module_sp (), - module_create_stop_id (UINT32_MAX), - uuid (), - so_address (), - address (LLDB_INVALID_ADDRESS), - size (0), - version (0), - load_tag (0), - flags (0), - reference_list (0), - header(), - segments() - { - name[0] = '\0'; - } - - void - Clear (bool load_cmd_data_only) - { - if (!load_cmd_data_only) - { - so_address.Clear(); - address = LLDB_INVALID_ADDRESS; - size = 0; - version = 0; - load_tag = 0; - flags = 0; - reference_list = 0; - name[0] = '\0'; - ::memset (&header, 0, sizeof(header)); - } - module_sp.reset(); - module_create_stop_id = UINT32_MAX; - uuid.Clear(); - segments.clear(); - } - - bool - operator == (const OSKextLoadedKextSummary& rhs) const - { - return address == rhs.address - && size == rhs.size - //&& module_sp.get() == rhs.module_sp.get() - && uuid == rhs.uuid - && version == rhs.version - && load_tag == rhs.load_tag - && flags == rhs.flags - && reference_list == rhs.reference_list - && strncmp (name, rhs.name, KERNEL_MODULE_MAX_NAME) == 0 - && memcmp(&header, &rhs.header, sizeof(header)) == 0 - && segments == rhs.segments; - } - - bool - UUIDValid() const - { - return uuid.IsValid(); - } - - uint32_t - GetAddressByteSize () - { - if (header.cputype) - { - if (header.cputype & llvm::MachO::CPUArchABI64) - return 8; - else - return 4; - } - return 0; - } - - lldb::ByteOrder - GetByteOrder() - { - switch (header.magic) - { - case llvm::MachO::HeaderMagic32: // MH_MAGIC - case llvm::MachO::HeaderMagic64: // MH_MAGIC_64 - return lldb::endian::InlHostByteOrder(); - - case llvm::MachO::HeaderMagic32Swapped: // MH_CIGAM - case llvm::MachO::HeaderMagic64Swapped: // MH_CIGAM_64 - if (lldb::endian::InlHostByteOrder() == lldb::eByteOrderLittle) - return lldb::eByteOrderBig; - else - return lldb::eByteOrderLittle; - default: - assert (!"invalid header.magic value"); - break; - } - return lldb::endian::InlHostByteOrder(); - } - - lldb_private::ArchSpec - GetArchitecture () const - { - return lldb_private::ArchSpec (lldb_private::eArchTypeMachO, header.cputype, header.cpusubtype); - } - - const Segment * - FindSegment (const lldb_private::ConstString &name) const; - - void - PutToLog (lldb_private::Log *log) const; - - typedef std::vector collection; - typedef collection::iterator iterator; - typedef collection::const_iterator const_iterator; - }; - - struct OSKextLoadedKextSummaryHeader - { - uint32_t version; - uint32_t entry_size; - uint32_t entry_count; - lldb::addr_t image_infos_addr; - - OSKextLoadedKextSummaryHeader() : - version (0), - entry_size (0), - entry_count (0), - image_infos_addr (LLDB_INVALID_ADDRESS) - { - } - - uint32_t - GetSize() - { - switch (version) - { - case 0: return 0; // Can't know the size without a valid version - case 1: return 8; // Version 1 only had a version + entry_count - default: break; - } - // Version 2 and above has version, entry_size, entry_count, and reserved - return 16; - } - - void - Clear() - { - version = 0; - entry_size = 0; - entry_count = 0; - image_infos_addr = LLDB_INVALID_ADDRESS; - } - - bool - IsValid() const - { - return version >= 1 || version <= 2; - } - }; - - bool - ReadMachHeader (OSKextLoadedKextSummary& kext_summary, - lldb_private::DataExtractor *load_command_data); - - void - RegisterNotificationCallbacks(); - - void - UnregisterNotificationCallbacks(); - - uint32_t - ParseLoadCommands (const lldb_private::DataExtractor& data, - OSKextLoadedKextSummary& dylib_info); - - bool - UpdateImageLoadAddress(OSKextLoadedKextSummary& info); - - bool - FindTargetModule (OSKextLoadedKextSummary &image_info, - bool can_create, - bool *did_create_ptr); - - void - SetNotificationBreakpointIfNeeded (); - - bool - ReadAllKextSummaries (); - - bool - ReadKextSummaryHeader (); - - bool - ParseKextSummaries (const lldb_private::Address &kext_summary_addr, - uint32_t count); - - bool - AddModulesUsingImageInfos (OSKextLoadedKextSummary::collection &image_infos); - - void - UpdateImageInfosHeaderAndLoadCommands(OSKextLoadedKextSummary::collection &image_infos, - uint32_t infos_count, - bool update_executable); - - bool - UpdateCommPageLoadAddress (lldb_private::Module *module); - - uint32_t - ReadKextSummaries (const lldb_private::Address &kext_summary_addr, - uint32_t image_infos_count, - OSKextLoadedKextSummary::collection &image_infos); - - bool - UnloadImageLoadAddress (OSKextLoadedKextSummary& info); - - OSKextLoadedKextSummary m_kernel; // Info about the current kernel image being used - lldb_private::Address m_kext_summary_header_ptr_addr; - lldb_private::Address m_kext_summary_header_addr; - OSKextLoadedKextSummaryHeader m_kext_summary_header; - OSKextLoadedKextSummary::collection m_kext_summaries; - mutable lldb_private::Mutex m_mutex; - lldb::user_id_t m_break_id; - -private: - DISALLOW_COPY_AND_ASSIGN (DynamicLoaderMacOSXKernel); -}; - -#endif // liblldb_DynamicLoaderMacOSXKernel_h_ Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/Makefile?rev=138282&r1=138280&r2=138282&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/Makefile (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/Makefile Mon Aug 22 17:23:48 2011 @@ -8,7 +8,7 @@ ##===----------------------------------------------------------------------===## LLDB_LEVEL := ../../../.. -LIBRARYNAME := lldbPluginDynamicLoaderMacOSXKernel +LIBRARYNAME := lldbPluginDynamicLoaderDarwinKernel BUILD_ARCHIVE = 1 include $(LLDB_LEVEL)/Makefile Removed: lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemMacOSXKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.cpp?rev=138280&view=auto ============================================================================== --- lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemMacOSXKernel.cpp (original) +++ lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemMacOSXKernel.cpp (removed) @@ -1,309 +0,0 @@ -//===-- OperatingSystemMacOSXKernel.cpp --------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "OperatingSystemMacOSXKernel.h" -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "llvm/ADT/Triple.h" - -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/DataBufferHeap.h" -#include "lldb/Core/Module.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Core/RegisterValue.h" -#include "lldb/Core/ValueObjectVariable.h" -#include "lldb/Symbol/ObjectFile.h" -#include "lldb/Symbol/VariableList.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/StopInfo.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/ThreadList.h" -#include "lldb/Target/Thread.h" -#include "Plugins/Process/Utility/DynamicRegisterInfo.h" -#include "Plugins/Process/Utility/RegisterContextMemory.h" -#include "Plugins/Process/Utility/ThreadMemory.h" - -using namespace lldb; -using namespace lldb_private; - -static ConstString & -GetThreadGPRMemberName () -{ - static ConstString g_gpr_member_name("gpr"); - return g_gpr_member_name; -} - -void -OperatingSystemMacOSXKernel::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); -} - -void -OperatingSystemMacOSXKernel::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); -} - -OperatingSystem * -OperatingSystemMacOSXKernel::CreateInstance (Process *process, bool force) -{ -#if 0 - bool create = force; - if (!create) - { - Module* exe_module = process->GetTarget().GetExecutableModulePointer(); - if (exe_module) - { - ObjectFile *object_file = exe_module->GetObjectFile(); - if (object_file) - { - SectionList *section_list = object_file->GetSectionList(); - if (section_list) - { - static ConstString g_kld_section_name ("__KLD"); - if (section_list->FindSectionByName (g_kld_section_name)) - { - create = true; - } - } - } - } - - // We can limit the creation of this plug-in to "*-apple-darwin" triples - // if we command out the lines below... -// if (create) -// { -// const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple(); -// create = triple_ref.getOS() == llvm::Triple::Darwin && triple_ref.getVendor() == llvm::Triple::Apple; -// } - } - - if (create) - return new OperatingSystemMacOSXKernel (process); -#endif - return NULL; -} - - -const char * -OperatingSystemMacOSXKernel::GetPluginNameStatic() -{ - return "macosx-kernel"; -} - -const char * -OperatingSystemMacOSXKernel::GetPluginDescriptionStatic() -{ - return "Operating system plug-in that gathers OS information from darwin kernels."; -} - - -OperatingSystemMacOSXKernel::OperatingSystemMacOSXKernel (lldb_private::Process *process) : - OperatingSystem (process), - m_thread_list_valobj_sp (), - m_register_info_ap () -{ -} - -OperatingSystemMacOSXKernel::~OperatingSystemMacOSXKernel () -{ -} - -ValueObjectSP -OperatingSystemMacOSXKernel::GetThreadListValueObject () -{ - if (m_thread_list_valobj_sp.get() == NULL) - { - VariableList variable_list; - const uint32_t max_matches = 1; - const bool append = true; - static ConstString g_thread_list_name("g_thread_list"); - Module *exe_module = m_process->GetTarget().GetExecutableModulePointer(); - if (exe_module) - { - if (exe_module->FindGlobalVariables (g_thread_list_name, - append, - max_matches, - variable_list)) - { - m_thread_list_valobj_sp = ValueObjectVariable::Create (m_process, variable_list.GetVariableAtIndex(0)); - } - } - } - return m_thread_list_valobj_sp; -} - -DynamicRegisterInfo * -OperatingSystemMacOSXKernel::GetDynamicRegisterInfo () -{ - if (m_register_info_ap.get() == NULL && m_thread_list_valobj_sp) - { - m_register_info_ap.reset (new DynamicRegisterInfo()); - ConstString empty_name; - const bool can_create = true; - AddressType addr_type; - addr_t base_addr = LLDB_INVALID_ADDRESS; - ValueObjectSP gpr_valobj_sp (m_thread_list_valobj_sp->GetChildMemberWithName(GetThreadGPRMemberName (), can_create)); - - if (gpr_valobj_sp->IsPointerType ()) - base_addr = gpr_valobj_sp->GetPointerValue (addr_type, true); - else - base_addr = gpr_valobj_sp->GetAddressOf (addr_type, true); - - ValueObjectSP child_valobj_sp; - if (gpr_valobj_sp) - { - ABI *abi = m_process->GetABI().get(); - assert (abi); - uint32_t num_children = gpr_valobj_sp->GetNumChildren(); - - ConstString gpr_name (gpr_valobj_sp->GetName()); - uint32_t reg_num = 0; - for (uint32_t i=0; iGetChildAtIndex(i, can_create); - - ConstString reg_name(child_valobj_sp->GetName()); - if (reg_name) - { - const char *reg_name_cstr = reg_name.GetCString(); - while (reg_name_cstr[0] == '_') - ++reg_name_cstr; - if (reg_name_cstr != reg_name.GetCString()) - reg_name.SetCString (reg_name_cstr); - } - - RegisterInfo reg_info; - if (abi->GetRegisterInfoByName(reg_name, reg_info)) - { - // Adjust the byte size and the offset to match the layout of registers in our struct - reg_info.byte_size = child_valobj_sp->GetByteSize(); - reg_info.byte_offset = child_valobj_sp->GetAddressOf(addr_type, true) - base_addr; - reg_info.kinds[eRegisterKindLLDB] = reg_num++; - m_register_info_ap->AddRegister (reg_info, reg_name, empty_name, gpr_name); - } - else - { - printf ("not able to find register info for %s\n", reg_name.GetCString()); // REMOVE THIS printf before checkin!!! - } - } - - m_register_info_ap->Finalize(); - } - } - assert (m_register_info_ap.get()); - return m_register_info_ap.get(); -} - -//------------------------------------------------------------------ -// PluginInterface protocol -//------------------------------------------------------------------ -const char * -OperatingSystemMacOSXKernel::GetPluginName() -{ - return "OperatingSystemMacOSXKernel"; -} - -const char * -OperatingSystemMacOSXKernel::GetShortPluginName() -{ - return GetPluginNameStatic(); -} - -uint32_t -OperatingSystemMacOSXKernel::GetPluginVersion() -{ - return 1; -} - -uint32_t -OperatingSystemMacOSXKernel::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) -{ - // Make any constant strings once and cache the uniqued C string values - // so we don't have to rehash them each time through this function call - static ConstString g_tid_member_name("tid"); - static ConstString g_next_member_name("next"); - - ValueObjectSP root_valobj_sp (GetThreadListValueObject ()); - ValueObjectSP valobj_sp = root_valobj_sp; - const bool can_create = true; - while (valobj_sp) - { - if (valobj_sp->GetValueAsUnsigned(0) == 0) - break; - - ValueObjectSP tid_valobj_sp(valobj_sp->GetChildMemberWithName(g_tid_member_name, can_create)); - if (!tid_valobj_sp) - break; - - tid_t tid = tid_valobj_sp->GetValueAsUnsigned (LLDB_INVALID_THREAD_ID); - if (tid == LLDB_INVALID_THREAD_ID) - break; - - ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false)); - if (!thread_sp) - thread_sp.reset (new ThreadMemory (*m_process, tid, valobj_sp)); - - new_thread_list.AddThread(thread_sp); - - ValueObjectSP next_valobj_sp (valobj_sp->GetChildMemberWithName(g_next_member_name, can_create)); - - if (next_valobj_sp) - { - // Watch for circular linked lists - if (next_valobj_sp.get() == root_valobj_sp.get()) - break; - } - next_valobj_sp.swap(valobj_sp); - } - return new_thread_list.GetSize(false); -} - -void -OperatingSystemMacOSXKernel::ThreadWasSelected (Thread *thread) -{ -} - -RegisterContextSP -OperatingSystemMacOSXKernel::CreateRegisterContextForThread (Thread *thread) -{ - ThreadMemory *generic_thread = (ThreadMemory *)thread; - RegisterContextSP reg_ctx_sp; - - ValueObjectSP thread_valobj_sp (generic_thread->GetValueObject()); - if (thread_valobj_sp) - { - const bool can_create = true; - AddressType addr_type; - addr_t base_addr = LLDB_INVALID_ADDRESS; - ValueObjectSP gpr_valobj_sp (thread_valobj_sp->GetChildMemberWithName(GetThreadGPRMemberName (), can_create)); - if (gpr_valobj_sp) - { - if (gpr_valobj_sp->IsPointerType ()) - base_addr = gpr_valobj_sp->GetPointerValue (addr_type, true); - else - base_addr = gpr_valobj_sp->GetAddressOf (addr_type, true); - reg_ctx_sp.reset (new RegisterContextMemory (*thread, 0, *GetDynamicRegisterInfo (), base_addr)); - } - } - return reg_ctx_sp; -} - -StopInfoSP -OperatingSystemMacOSXKernel::CreateThreadStopReason (lldb_private::Thread *thread) -{ - StopInfoSP stop_info_sp; //(StopInfo::CreateStopReasonWithSignal (*thread, SIGSTOP)); - return stop_info_sp; -} - - Removed: lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemMacOSXKernel.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.h?rev=138280&view=auto ============================================================================== --- lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemMacOSXKernel.h (original) +++ lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemMacOSXKernel.h (removed) @@ -1,90 +0,0 @@ -//===-- OperatingSystemMacOSXKernel.h ----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_OperatingSystemMacOSXKernel_h_ -#define liblldb_OperatingSystemMacOSXKernel_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "lldb/Target/OperatingSystem.h" - -class DynamicRegisterInfo; - -class OperatingSystemMacOSXKernel : public lldb_private::OperatingSystem -{ -public: - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - static lldb_private::OperatingSystem * - CreateInstance (lldb_private::Process *process, bool force); - - static void - Initialize(); - - static void - Terminate(); - - static const char * - GetPluginNameStatic(); - - static const char * - GetPluginDescriptionStatic(); - - //------------------------------------------------------------------ - // Class Methods - //------------------------------------------------------------------ - OperatingSystemMacOSXKernel (lldb_private::Process *process); - - virtual - ~OperatingSystemMacOSXKernel (); - - //------------------------------------------------------------------ - // lldb_private::PluginInterface Methods - //------------------------------------------------------------------ - virtual const char * - GetPluginName(); - - virtual const char * - GetShortPluginName(); - - virtual uint32_t - GetPluginVersion(); - - //------------------------------------------------------------------ - // lldb_private::OperatingSystem Methods - //------------------------------------------------------------------ - virtual uint32_t - UpdateThreadList (lldb_private::ThreadList &old_thread_list, - lldb_private::ThreadList &new_thread_list); - - virtual void - ThreadWasSelected (lldb_private::Thread *thread); - - virtual lldb::RegisterContextSP - CreateRegisterContextForThread (lldb_private::Thread *thread); - - virtual lldb::StopInfoSP - CreateThreadStopReason (lldb_private::Thread *thread); - -protected: - - lldb::ValueObjectSP - GetThreadListValueObject (); - - DynamicRegisterInfo * - GetDynamicRegisterInfo (); - - lldb::ValueObjectSP m_thread_list_valobj_sp; - std::auto_ptr m_register_info_ap; - -}; - -#endif // #ifndef liblldb_OperatingSystemMacOSXKernel_h_ \ No newline at end of file From gclayton at apple.com Mon Aug 22 17:30:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 22 Aug 2011 22:30:57 -0000 Subject: [Lldb-commits] [lldb] r138283 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h source/lldb.cpp Message-ID: <20110822223057.767C62A6C12C@llvm.org> Author: gclayton Date: Mon Aug 22 17:30:57 2011 New Revision: 138283 URL: http://llvm.org/viewvc/llvm-project?rev=138283&view=rev Log: Finishing the renaming from "MacOSX-Kernel" to "Darwin-Kernel". Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h lldb/trunk/source/lldb.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=138283&r1=138282&r2=138283&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Aug 22 17:30:57 2011 @@ -12,6 +12,8 @@ 260E07C8136FAB9200CF21D3 /* OptionGroupFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260E07C7136FAB9200CF21D3 /* OptionGroupFile.cpp */; }; 261744781168585B005ADD65 /* SBType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261744771168585B005ADD65 /* SBType.cpp */; }; 2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 26274FA214030EEF006BA130 /* OperatingSystemDarwinKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26274FA014030EEF006BA130 /* OperatingSystemDarwinKernel.cpp */; }; + 26274FA714030F79006BA130 /* DynamicLoaderDarwinKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26274FA514030F79006BA130 /* DynamicLoaderDarwinKernel.cpp */; }; 2628A4D513D4977900F5487A /* ThreadKDP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628A4D313D4977900F5487A /* ThreadKDP.cpp */; }; 262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; }; 262D24E613FB8710002D1960 /* RegisterContextMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 262D24E413FB8710002D1960 /* RegisterContextMemory.cpp */; }; @@ -71,7 +73,6 @@ 26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */; }; 26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */; }; 2668035C11601108008E1FE4 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; - 266DFE9413FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266DFE9213FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp */; }; 266DFE9713FD656E00D0C574 /* OperatingSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266DFE9613FD656E00D0C574 /* OperatingSystem.cpp */; }; 266E8C6A13528ABC000C2042 /* lldb-platform in Resources */ = {isa = PBXBuildFile; fileRef = 26DC6A101337FE6900FF7998 /* lldb-platform */; }; 2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2671A0CF13482601003A87BB /* ConnectionMachPort.cpp */; }; @@ -383,7 +384,6 @@ 26DE20651161904E00A093E2 /* SBSymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20641161904E00A093E2 /* SBSymbol.cpp */; }; 26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */; }; 26ED3D6D13C563810017D45E /* OptionGroupVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26ED3D6C13C563810017D45E /* OptionGroupVariable.cpp */; }; - 26F4214413C6515B00E04E5E /* DynamicLoaderMacOSXKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F4214113C6515B00E04E5E /* DynamicLoaderMacOSXKernel.cpp */; }; 26F4A21C13FBA31A0064B613 /* ThreadMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F4A21A13FBA31A0064B613 /* ThreadMemory.cpp */; }; 26F5C27710F3D9E4009D5894 /* Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27310F3D9E4009D5894 /* Driver.cpp */; }; 26F5C27810F3D9E4009D5894 /* IOChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27510F3D9E4009D5894 /* IOChannel.cpp */; }; @@ -606,6 +606,10 @@ 26217930133BC8640083B112 /* lldb-private-types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-types.h"; path = "include/lldb/lldb-private-types.h"; sourceTree = ""; }; 26217932133BCB850083B112 /* lldb-private-enumerations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-enumerations.h"; path = "include/lldb/lldb-private-enumerations.h"; sourceTree = ""; }; 2623096E13D0EFFB006381D9 /* StreamBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamBuffer.h; path = include/lldb/Core/StreamBuffer.h; sourceTree = ""; }; + 26274FA014030EEF006BA130 /* OperatingSystemDarwinKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OperatingSystemDarwinKernel.cpp; sourceTree = ""; }; + 26274FA114030EEF006BA130 /* OperatingSystemDarwinKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OperatingSystemDarwinKernel.h; sourceTree = ""; }; + 26274FA514030F79006BA130 /* DynamicLoaderDarwinKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLoaderDarwinKernel.cpp; sourceTree = ""; }; + 26274FA614030F79006BA130 /* DynamicLoaderDarwinKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicLoaderDarwinKernel.h; sourceTree = ""; }; 2628A4D313D4977900F5487A /* ThreadKDP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadKDP.cpp; sourceTree = ""; }; 2628A4D413D4977900F5487A /* ThreadKDP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadKDP.h; sourceTree = ""; }; 262D24E413FB8710002D1960 /* RegisterContextMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextMemory.cpp; path = Utility/RegisterContextMemory.cpp; sourceTree = ""; }; @@ -664,8 +668,6 @@ 266960631199F4230075C61A /* sed-sources */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "sed-sources"; sourceTree = ""; }; 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangNamespaceDecl.cpp; path = source/Symbol/ClangNamespaceDecl.cpp; sourceTree = ""; }; 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangNamespaceDecl.h; path = include/lldb/Symbol/ClangNamespaceDecl.h; sourceTree = ""; }; - 266DFE9213FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OperatingSystemMacOSXKernel.cpp; sourceTree = ""; }; - 266DFE9313FD64D200D0C574 /* OperatingSystemMacOSXKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OperatingSystemMacOSXKernel.h; sourceTree = ""; }; 266DFE9613FD656E00D0C574 /* OperatingSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OperatingSystem.cpp; path = source/Target/OperatingSystem.cpp; sourceTree = ""; }; 266DFE9813FD658300D0C574 /* OperatingSystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OperatingSystem.h; path = include/lldb/Target/OperatingSystem.h; sourceTree = ""; }; 266F5CBB12FC846200DFCE33 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/Config.h; sourceTree = ""; }; @@ -1057,8 +1059,6 @@ 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ARM_DWARF_Registers.cpp; path = source/Utility/ARM_DWARF_Registers.cpp; sourceTree = ""; }; 26ED3D6C13C563810017D45E /* OptionGroupVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupVariable.cpp; path = source/Interpreter/OptionGroupVariable.cpp; sourceTree = ""; }; 26ED3D6F13C5638A0017D45E /* OptionGroupVariable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupVariable.h; path = include/lldb/Interpreter/OptionGroupVariable.h; sourceTree = ""; }; - 26F4214113C6515B00E04E5E /* DynamicLoaderMacOSXKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLoaderMacOSXKernel.cpp; sourceTree = ""; }; - 26F4214213C6515B00E04E5E /* DynamicLoaderMacOSXKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicLoaderMacOSXKernel.h; sourceTree = ""; }; 26F4A21A13FBA31A0064B613 /* ThreadMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadMemory.cpp; path = Utility/ThreadMemory.cpp; sourceTree = ""; }; 26F4A21B13FBA31A0064B613 /* ThreadMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadMemory.h; path = Utility/ThreadMemory.h; sourceTree = ""; }; 26F5C26A10F3D9A4009D5894 /* lldb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lldb; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1433,8 +1433,8 @@ 260C897810F57C5600BB2B04 /* DynamicLoader */ = { isa = PBXGroup; children = ( + 26274FA414030F79006BA130 /* Darwin-Kernel */, 260C897910F57C5600BB2B04 /* MacOSX-DYLD */, - 26F4214013C6515B00E04E5E /* MacOSX-Kernel */, 268A683C1321B505000E3FB8 /* Static */, ); path = DynamicLoader; @@ -1595,6 +1595,24 @@ path = MacOSX; sourceTree = ""; }; + 26274F9F14030EEF006BA130 /* Darwin-Kernel */ = { + isa = PBXGroup; + children = ( + 26274FA014030EEF006BA130 /* OperatingSystemDarwinKernel.cpp */, + 26274FA114030EEF006BA130 /* OperatingSystemDarwinKernel.h */, + ); + path = "Darwin-Kernel"; + sourceTree = ""; + }; + 26274FA414030F79006BA130 /* Darwin-Kernel */ = { + isa = PBXGroup; + children = ( + 26274FA514030F79006BA130 /* DynamicLoaderDarwinKernel.cpp */, + 26274FA614030F79006BA130 /* DynamicLoaderDarwinKernel.h */, + ); + path = "Darwin-Kernel"; + sourceTree = ""; + }; 262D3190111B4341004E6F88 /* API */ = { isa = PBXGroup; children = ( @@ -1763,20 +1781,11 @@ 266DFE9013FD64D200D0C574 /* OperatingSystem */ = { isa = PBXGroup; children = ( - 266DFE9113FD64D200D0C574 /* MacOSX-Kernel */, + 26274F9F14030EEF006BA130 /* Darwin-Kernel */, ); path = OperatingSystem; sourceTree = ""; }; - 266DFE9113FD64D200D0C574 /* MacOSX-Kernel */ = { - isa = PBXGroup; - children = ( - 266DFE9213FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp */, - 266DFE9313FD64D200D0C574 /* OperatingSystemMacOSXKernel.h */, - ); - path = "MacOSX-Kernel"; - sourceTree = ""; - }; 2682F168115ED9C800CCFF99 /* Utility */ = { isa = PBXGroup; children = ( @@ -2507,15 +2516,6 @@ name = "lldb-platform"; sourceTree = ""; }; - 26F4214013C6515B00E04E5E /* MacOSX-Kernel */ = { - isa = PBXGroup; - children = ( - 26F4214113C6515B00E04E5E /* DynamicLoaderMacOSXKernel.cpp */, - 26F4214213C6515B00E04E5E /* DynamicLoaderMacOSXKernel.h */, - ); - path = "MacOSX-Kernel"; - sourceTree = ""; - }; 26F5C22410F3D950009D5894 /* Tools */ = { isa = PBXGroup; children = ( @@ -3278,7 +3278,6 @@ 49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */, 9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */, 26ED3D6D13C563810017D45E /* OptionGroupVariable.cpp in Sources */, - 26F4214413C6515B00E04E5E /* DynamicLoaderMacOSXKernel.cpp in Sources */, 94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */, 94031A9E13CF486700DCFF3C /* InputReaderEZ.cpp in Sources */, 2642FBAE13D003B400ED6808 /* CommunicationKDP.cpp in Sources */, @@ -3296,10 +3295,11 @@ 94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */, 262D24E613FB8710002D1960 /* RegisterContextMemory.cpp in Sources */, 26F4A21C13FBA31A0064B613 /* ThreadMemory.cpp in Sources */, - 266DFE9413FD64D200D0C574 /* OperatingSystemMacOSXKernel.cpp in Sources */, 266DFE9713FD656E00D0C574 /* OperatingSystem.cpp in Sources */, 26954EBE1401EE8B00294D09 /* DynamicRegisterInfo.cpp in Sources */, 9470A8F01402DFFB0056FF61 /* DataVisualization.cpp in Sources */, + 26274FA214030EEF006BA130 /* OperatingSystemDarwinKernel.cpp in Sources */, + 26274FA714030F79006BA130 /* DynamicLoaderDarwinKernel.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=138283&r1=138282&r2=138283&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Mon Aug 22 17:30:57 2011 @@ -1,4 +1,4 @@ -//===-- DynamicLoaderMacOSXKernel.cpp -----------------------------*- C++ -*-===// +//===-- DynamicLoaderDarwinKernel.cpp -----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -23,7 +23,7 @@ #include "lldb/Target/ThreadPlanRunToAddress.h" #include "lldb/Target/StackFrame.h" -#include "DynamicLoaderMacOSXKernel.h" +#include "DynamicLoaderDarwinKernel.h" //#define ENABLE_DEBUG_PRINTF // COMMENT THIS LINE OUT PRIOR TO CHECKIN #ifdef ENABLE_DEBUG_PRINTF @@ -47,7 +47,7 @@ // allows the lldb to instantiate an instance of this class. //---------------------------------------------------------------------- DynamicLoader * -DynamicLoaderMacOSXKernel::CreateInstance (Process* process, bool force) +DynamicLoaderDarwinKernel::CreateInstance (Process* process, bool force) { bool create = force; if (!create) @@ -78,14 +78,14 @@ } if (create) - return new DynamicLoaderMacOSXKernel (process); + return new DynamicLoaderDarwinKernel (process); return NULL; } //---------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------- -DynamicLoaderMacOSXKernel::DynamicLoaderMacOSXKernel (Process* process) : +DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel (Process* process) : DynamicLoader(process), m_kernel(), m_kext_summary_header_ptr_addr (), @@ -100,13 +100,13 @@ //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -DynamicLoaderMacOSXKernel::~DynamicLoaderMacOSXKernel() +DynamicLoaderDarwinKernel::~DynamicLoaderDarwinKernel() { Clear(true); } void -DynamicLoaderMacOSXKernel::UpdateIfNeeded() +DynamicLoaderDarwinKernel::UpdateIfNeeded() { LoadKernelModuleIfNeeded(); SetNotificationBreakpointIfNeeded (); @@ -118,7 +118,7 @@ /// attaching to a process. //------------------------------------------------------------------ void -DynamicLoaderMacOSXKernel::DidAttach () +DynamicLoaderDarwinKernel::DidAttach () { PrivateInitialize(m_process); UpdateIfNeeded(); @@ -131,7 +131,7 @@ /// attaching to a process. //------------------------------------------------------------------ void -DynamicLoaderMacOSXKernel::DidLaunch () +DynamicLoaderDarwinKernel::DidLaunch () { PrivateInitialize(m_process); UpdateIfNeeded(); @@ -142,7 +142,7 @@ // Clear out the state of this class. //---------------------------------------------------------------------- void -DynamicLoaderMacOSXKernel::Clear (bool clear_process) +DynamicLoaderDarwinKernel::Clear (bool clear_process) { Mutex::Locker locker(m_mutex); @@ -166,7 +166,7 @@ // already loaded). //---------------------------------------------------------------------- void -DynamicLoaderMacOSXKernel::LoadKernelModuleIfNeeded() +DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() { if (!m_kext_summary_header_ptr_addr.IsValid()) { @@ -209,7 +209,7 @@ } bool -DynamicLoaderMacOSXKernel::FindTargetModule (OSKextLoadedKextSummary &image_info, bool can_create, bool *did_create_ptr) +DynamicLoaderDarwinKernel::FindTargetModule (OSKextLoadedKextSummary &image_info, bool can_create, bool *did_create_ptr) { if (did_create_ptr) *did_create_ptr = false; @@ -252,7 +252,7 @@ } bool -DynamicLoaderMacOSXKernel::UpdateCommPageLoadAddress(Module *module) +DynamicLoaderDarwinKernel::UpdateCommPageLoadAddress(Module *module) { bool changed = false; if (module) @@ -290,7 +290,7 @@ // updated INFO that is passed in. //---------------------------------------------------------------------- bool -DynamicLoaderMacOSXKernel::UpdateImageLoadAddress (OSKextLoadedKextSummary& info) +DynamicLoaderDarwinKernel::UpdateImageLoadAddress (OSKextLoadedKextSummary& info) { Module *module = info.module_sp.get(); bool changed = false; @@ -362,7 +362,7 @@ // updated INFO that is passed in. //---------------------------------------------------------------------- bool -DynamicLoaderMacOSXKernel::UnloadImageLoadAddress (OSKextLoadedKextSummary& info) +DynamicLoaderDarwinKernel::UnloadImageLoadAddress (OSKextLoadedKextSummary& info) { Module *module = info.module_sp.get(); bool changed = false; @@ -407,22 +407,22 @@ // or not (based on global preference). //---------------------------------------------------------------------- bool -DynamicLoaderMacOSXKernel::BreakpointHitCallback (void *baton, +DynamicLoaderDarwinKernel::BreakpointHitCallback (void *baton, StoppointCallbackContext *context, user_id_t break_id, user_id_t break_loc_id) { - return static_cast(baton)->BreakpointHit (context, break_id, break_loc_id); + return static_cast(baton)->BreakpointHit (context, break_id, break_loc_id); } bool -DynamicLoaderMacOSXKernel::BreakpointHit (StoppointCallbackContext *context, +DynamicLoaderDarwinKernel::BreakpointHit (StoppointCallbackContext *context, user_id_t break_id, user_id_t break_loc_id) { LogSP log(GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); if (log) - log->Printf ("DynamicLoaderMacOSXKernel::BreakpointHit (...)\n"); + log->Printf ("DynamicLoaderDarwinKernel::BreakpointHit (...)\n"); ReadAllKextSummaries (); @@ -434,7 +434,7 @@ bool -DynamicLoaderMacOSXKernel::ReadKextSummaryHeader () +DynamicLoaderDarwinKernel::ReadKextSummaryHeader () { Mutex::Locker locker(m_mutex); @@ -487,7 +487,7 @@ bool -DynamicLoaderMacOSXKernel::ParseKextSummaries (const Address &kext_summary_addr, +DynamicLoaderDarwinKernel::ParseKextSummaries (const Address &kext_summary_addr, uint32_t count) { OSKextLoadedKextSummary::collection kext_summaries; @@ -544,7 +544,7 @@ // NB don't call this passing in m_kext_summaries. bool -DynamicLoaderMacOSXKernel::AddModulesUsingImageInfos (OSKextLoadedKextSummary::collection &image_infos) +DynamicLoaderDarwinKernel::AddModulesUsingImageInfos (OSKextLoadedKextSummary::collection &image_infos) { // Now add these images to the main list. ModuleList loaded_module_list; @@ -588,7 +588,7 @@ } } // if (log) -// loaded_module_list.LogUUIDAndPaths (log, "DynamicLoaderMacOSXKernel::ModulesDidLoad"); +// loaded_module_list.LogUUIDAndPaths (log, "DynamicLoaderDarwinKernel::ModulesDidLoad"); m_process->GetTarget().ModulesDidLoad (loaded_module_list); } return true; @@ -596,7 +596,7 @@ uint32_t -DynamicLoaderMacOSXKernel::ReadKextSummaries (const Address &kext_summary_addr, +DynamicLoaderDarwinKernel::ReadKextSummaries (const Address &kext_summary_addr, uint32_t image_infos_count, OSKextLoadedKextSummary::collection &image_infos) { @@ -660,7 +660,7 @@ } bool -DynamicLoaderMacOSXKernel::ReadAllKextSummaries () +DynamicLoaderDarwinKernel::ReadAllKextSummaries () { LogSP log(GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); @@ -689,7 +689,7 @@ // Returns true if we succeed, false if we fail for any reason. //---------------------------------------------------------------------- bool -DynamicLoaderMacOSXKernel::ReadMachHeader (OSKextLoadedKextSummary& kext_summary, DataExtractor *load_command_data) +DynamicLoaderDarwinKernel::ReadMachHeader (OSKextLoadedKextSummary& kext_summary, DataExtractor *load_command_data) { DataBufferHeap header_bytes(sizeof(llvm::MachO::mach_header), 0); Error error; @@ -708,7 +708,7 @@ DataExtractor data(header_bytes.GetBytes(), header_bytes.GetByteSize(), endian::InlHostByteOrder(), 4); kext_summary.header.magic = data.GetU32(&offset); Address load_cmd_addr = kext_summary.so_address; - data.SetByteOrder(DynamicLoaderMacOSXKernel::GetByteOrderFromMagic(kext_summary.header.magic)); + data.SetByteOrder(DynamicLoaderDarwinKernel::GetByteOrderFromMagic(kext_summary.header.magic)); switch (kext_summary.header.magic) { case llvm::MachO::HeaderMagic32: @@ -762,7 +762,7 @@ // Parse the load commands for an image //---------------------------------------------------------------------- uint32_t -DynamicLoaderMacOSXKernel::ParseLoadCommands (const DataExtractor& data, OSKextLoadedKextSummary& image_info) +DynamicLoaderDarwinKernel::ParseLoadCommands (const DataExtractor& data, OSKextLoadedKextSummary& image_info) { uint32_t offset = 0; uint32_t cmd_idx; @@ -860,7 +860,7 @@ // Dump a Segment to the file handle provided. //---------------------------------------------------------------------- void -DynamicLoaderMacOSXKernel::Segment::PutToLog (Log *log, addr_t slide) const +DynamicLoaderDarwinKernel::Segment::PutToLog (Log *log, addr_t slide) const { if (log) { @@ -878,8 +878,8 @@ } } -const DynamicLoaderMacOSXKernel::Segment * -DynamicLoaderMacOSXKernel::OSKextLoadedKextSummary::FindSegment (const ConstString &name) const +const DynamicLoaderDarwinKernel::Segment * +DynamicLoaderDarwinKernel::OSKextLoadedKextSummary::FindSegment (const ConstString &name) const { const size_t num_segments = segments.size(); for (size_t i=0; iGetState())); + DEBUG_PRINTF("DynamicLoaderDarwinKernel::%s() process state = %s\n", __FUNCTION__, StateAsCString(m_process->GetState())); Clear(true); m_process = process; m_process->GetTarget().GetSectionLoadList().Clear(); } void -DynamicLoaderMacOSXKernel::SetNotificationBreakpointIfNeeded () +DynamicLoaderDarwinKernel::SetNotificationBreakpointIfNeeded () { if (m_break_id == LLDB_INVALID_BREAK_ID) { - DEBUG_PRINTF("DynamicLoaderMacOSXKernel::%s() process state = %s\n", __FUNCTION__, StateAsCString(m_process->GetState())); + DEBUG_PRINTF("DynamicLoaderDarwinKernel::%s() process state = %s\n", __FUNCTION__, StateAsCString(m_process->GetState())); const bool internal_bp = false; @@ -988,7 +988,7 @@ internal_bp, skip_prologue).get(); - bp->SetCallback (DynamicLoaderMacOSXKernel::BreakpointHitCallback, this, true); + bp->SetCallback (DynamicLoaderDarwinKernel::BreakpointHitCallback, this, true); m_break_id = bp->GetID(); } } @@ -997,9 +997,9 @@ // Member function that gets called when the process state changes. //---------------------------------------------------------------------- void -DynamicLoaderMacOSXKernel::PrivateProcessStateChanged (Process *process, StateType state) +DynamicLoaderDarwinKernel::PrivateProcessStateChanged (Process *process, StateType state) { - DEBUG_PRINTF("DynamicLoaderMacOSXKernel::%s(%s)\n", __FUNCTION__, StateAsCString(state)); + DEBUG_PRINTF("DynamicLoaderDarwinKernel::%s(%s)\n", __FUNCTION__, StateAsCString(state)); switch (state) { case eStateConnected: @@ -1028,7 +1028,7 @@ } ThreadPlanSP -DynamicLoaderMacOSXKernel::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) +DynamicLoaderDarwinKernel::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) { ThreadPlanSP thread_plan_sp; LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); @@ -1038,7 +1038,7 @@ } Error -DynamicLoaderMacOSXKernel::CanLoadImage () +DynamicLoaderDarwinKernel::CanLoadImage () { Error error; error.SetErrorString("always unsafe to load or unload shared libraries in the darwin kernel"); @@ -1046,7 +1046,7 @@ } void -DynamicLoaderMacOSXKernel::Initialize() +DynamicLoaderDarwinKernel::Initialize() { PluginManager::RegisterPlugin (GetPluginNameStatic(), GetPluginDescriptionStatic(), @@ -1054,20 +1054,20 @@ } void -DynamicLoaderMacOSXKernel::Terminate() +DynamicLoaderDarwinKernel::Terminate() { PluginManager::UnregisterPlugin (CreateInstance); } const char * -DynamicLoaderMacOSXKernel::GetPluginNameStatic() +DynamicLoaderDarwinKernel::GetPluginNameStatic() { return "dynamic-loader.macosx-kernel"; } const char * -DynamicLoaderMacOSXKernel::GetPluginDescriptionStatic() +DynamicLoaderDarwinKernel::GetPluginDescriptionStatic() { return "Dynamic loader plug-in that watches for shared library loads/unloads in the MacOSX kernel."; } @@ -1077,19 +1077,19 @@ // PluginInterface protocol //------------------------------------------------------------------ const char * -DynamicLoaderMacOSXKernel::GetPluginName() +DynamicLoaderDarwinKernel::GetPluginName() { - return "DynamicLoaderMacOSXKernel"; + return "DynamicLoaderDarwinKernel"; } const char * -DynamicLoaderMacOSXKernel::GetShortPluginName() +DynamicLoaderDarwinKernel::GetShortPluginName() { return GetPluginNameStatic(); } uint32_t -DynamicLoaderMacOSXKernel::GetPluginVersion() +DynamicLoaderDarwinKernel::GetPluginVersion() { return 1; } Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h?rev=138283&r1=138282&r2=138283&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h Mon Aug 22 17:30:57 2011 @@ -1,4 +1,4 @@ -//===-- DynamicLoaderMacOSXKernel.h -----------------------------*- C++ -*-===// +//===-- DynamicLoaderDarwinKernel.h -----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DynamicLoaderMacOSXKernel_h_ -#define liblldb_DynamicLoaderMacOSXKernel_h_ +#ifndef liblldb_DynamicLoaderDarwinKernel_h_ +#define liblldb_DynamicLoaderDarwinKernel_h_ // C Includes // C++ Includes @@ -26,7 +26,7 @@ #include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" -class DynamicLoaderMacOSXKernel : public lldb_private::DynamicLoader +class DynamicLoaderDarwinKernel : public lldb_private::DynamicLoader { public: //------------------------------------------------------------------ @@ -47,10 +47,10 @@ static lldb_private::DynamicLoader * CreateInstance (lldb_private::Process *process, bool force); - DynamicLoaderMacOSXKernel (lldb_private::Process *process); + DynamicLoaderDarwinKernel (lldb_private::Process *process); virtual - ~DynamicLoaderMacOSXKernel (); + ~DynamicLoaderDarwinKernel (); //------------------------------------------------------------------ /// Called after attaching a process. /// @@ -437,7 +437,7 @@ lldb::user_id_t m_break_id; private: - DISALLOW_COPY_AND_ASSIGN (DynamicLoaderMacOSXKernel); + DISALLOW_COPY_AND_ASSIGN (DynamicLoaderDarwinKernel); }; -#endif // liblldb_DynamicLoaderMacOSXKernel_h_ +#endif // liblldb_DynamicLoaderDarwinKernel_h_ Modified: lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp?rev=138283&r1=138282&r2=138283&view=diff ============================================================================== --- lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp (original) +++ lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.cpp Mon Aug 22 17:30:57 2011 @@ -1,4 +1,4 @@ -//===-- OperatingSystemMacOSXKernel.cpp --------------------------------*- C++ -*-===// +//===-- OperatingSystemDarwinKernel.cpp --------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "OperatingSystemMacOSXKernel.h" +#include "OperatingSystemDarwinKernel.h" // C Includes // C++ Includes // Other libraries and framework includes @@ -41,7 +41,7 @@ } void -OperatingSystemMacOSXKernel::Initialize() +OperatingSystemDarwinKernel::Initialize() { PluginManager::RegisterPlugin (GetPluginNameStatic(), GetPluginDescriptionStatic(), @@ -49,13 +49,13 @@ } void -OperatingSystemMacOSXKernel::Terminate() +OperatingSystemDarwinKernel::Terminate() { PluginManager::UnregisterPlugin (CreateInstance); } OperatingSystem * -OperatingSystemMacOSXKernel::CreateInstance (Process *process, bool force) +OperatingSystemDarwinKernel::CreateInstance (Process *process, bool force) { #if 0 bool create = force; @@ -89,38 +89,38 @@ } if (create) - return new OperatingSystemMacOSXKernel (process); + return new OperatingSystemDarwinKernel (process); #endif return NULL; } const char * -OperatingSystemMacOSXKernel::GetPluginNameStatic() +OperatingSystemDarwinKernel::GetPluginNameStatic() { return "macosx-kernel"; } const char * -OperatingSystemMacOSXKernel::GetPluginDescriptionStatic() +OperatingSystemDarwinKernel::GetPluginDescriptionStatic() { return "Operating system plug-in that gathers OS information from darwin kernels."; } -OperatingSystemMacOSXKernel::OperatingSystemMacOSXKernel (lldb_private::Process *process) : +OperatingSystemDarwinKernel::OperatingSystemDarwinKernel (lldb_private::Process *process) : OperatingSystem (process), m_thread_list_valobj_sp (), m_register_info_ap () { } -OperatingSystemMacOSXKernel::~OperatingSystemMacOSXKernel () +OperatingSystemDarwinKernel::~OperatingSystemDarwinKernel () { } ValueObjectSP -OperatingSystemMacOSXKernel::GetThreadListValueObject () +OperatingSystemDarwinKernel::GetThreadListValueObject () { if (m_thread_list_valobj_sp.get() == NULL) { @@ -144,7 +144,7 @@ } DynamicRegisterInfo * -OperatingSystemMacOSXKernel::GetDynamicRegisterInfo () +OperatingSystemDarwinKernel::GetDynamicRegisterInfo () { if (m_register_info_ap.get() == NULL && m_thread_list_valobj_sp) { @@ -209,25 +209,25 @@ // PluginInterface protocol //------------------------------------------------------------------ const char * -OperatingSystemMacOSXKernel::GetPluginName() +OperatingSystemDarwinKernel::GetPluginName() { - return "OperatingSystemMacOSXKernel"; + return "OperatingSystemDarwinKernel"; } const char * -OperatingSystemMacOSXKernel::GetShortPluginName() +OperatingSystemDarwinKernel::GetShortPluginName() { return GetPluginNameStatic(); } uint32_t -OperatingSystemMacOSXKernel::GetPluginVersion() +OperatingSystemDarwinKernel::GetPluginVersion() { return 1; } uint32_t -OperatingSystemMacOSXKernel::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) +OperatingSystemDarwinKernel::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list) { // Make any constant strings once and cache the uniqued C string values // so we don't have to rehash them each time through this function call @@ -270,12 +270,12 @@ } void -OperatingSystemMacOSXKernel::ThreadWasSelected (Thread *thread) +OperatingSystemDarwinKernel::ThreadWasSelected (Thread *thread) { } RegisterContextSP -OperatingSystemMacOSXKernel::CreateRegisterContextForThread (Thread *thread) +OperatingSystemDarwinKernel::CreateRegisterContextForThread (Thread *thread) { ThreadMemory *generic_thread = (ThreadMemory *)thread; RegisterContextSP reg_ctx_sp; @@ -300,7 +300,7 @@ } StopInfoSP -OperatingSystemMacOSXKernel::CreateThreadStopReason (lldb_private::Thread *thread) +OperatingSystemDarwinKernel::CreateThreadStopReason (lldb_private::Thread *thread) { StopInfoSP stop_info_sp; //(StopInfo::CreateStopReasonWithSignal (*thread, SIGSTOP)); return stop_info_sp; Modified: lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h?rev=138283&r1=138282&r2=138283&view=diff ============================================================================== --- lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h (original) +++ lldb/trunk/source/Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h Mon Aug 22 17:30:57 2011 @@ -1,4 +1,4 @@ -//===-- OperatingSystemMacOSXKernel.h ----------------------------------*- C++ -*-===// +//===-- OperatingSystemDarwinKernel.h ---------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_OperatingSystemMacOSXKernel_h_ -#define liblldb_OperatingSystemMacOSXKernel_h_ +#ifndef liblldb_OperatingSystemDarwinKernel_h_ +#define liblldb_OperatingSystemDarwinKernel_h_ // C Includes // C++ Includes @@ -17,7 +17,7 @@ class DynamicRegisterInfo; -class OperatingSystemMacOSXKernel : public lldb_private::OperatingSystem +class OperatingSystemDarwinKernel : public lldb_private::OperatingSystem { public: //------------------------------------------------------------------ @@ -41,10 +41,10 @@ //------------------------------------------------------------------ // Class Methods //------------------------------------------------------------------ - OperatingSystemMacOSXKernel (lldb_private::Process *process); + OperatingSystemDarwinKernel (lldb_private::Process *process); virtual - ~OperatingSystemMacOSXKernel (); + ~OperatingSystemDarwinKernel (); //------------------------------------------------------------------ // lldb_private::PluginInterface Methods @@ -87,4 +87,4 @@ }; -#endif // #ifndef liblldb_OperatingSystemMacOSXKernel_h_ \ No newline at end of file +#endif // #ifndef liblldb_OperatingSystemDarwinKernel_h_ \ No newline at end of file Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=138283&r1=138282&r2=138283&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Mon Aug 22 17:30:57 2011 @@ -38,8 +38,8 @@ #if defined (__APPLE__) #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" -#include "Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.h" -#include "Plugins/OperatingSystem/MacOSX-Kernel/OperatingSystemMacOSXKernel.h" +#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h" +#include "Plugins/OperatingSystem/Darwin-Kernel/OperatingSystemDarwinKernel.h" #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h" @@ -100,8 +100,8 @@ // Apple/Darwin hosted plugins //---------------------------------------------------------------------- DynamicLoaderMacOSXDYLD::Initialize(); - DynamicLoaderMacOSXKernel::Initialize(); - OperatingSystemMacOSXKernel::Initialize(); + DynamicLoaderDarwinKernel::Initialize(); + OperatingSystemDarwinKernel::Initialize(); SymbolFileDWARFDebugMap::Initialize(); ItaniumABILanguageRuntime::Initialize(); AppleObjCRuntimeV2::Initialize(); @@ -169,8 +169,8 @@ #if defined (__APPLE__) DynamicLoaderMacOSXDYLD::Terminate(); - DynamicLoaderMacOSXKernel::Terminate(); - OperatingSystemMacOSXKernel::Terminate(); + DynamicLoaderDarwinKernel::Terminate(); + OperatingSystemDarwinKernel::Terminate(); SymbolFileDWARFDebugMap::Terminate(); ItaniumABILanguageRuntime::Terminate(); AppleObjCRuntimeV2::Terminate(); From scallanan at apple.com Mon Aug 22 17:34:22 2011 From: scallanan at apple.com (Sean Callanan) Date: Mon, 22 Aug 2011 22:34:22 -0000 Subject: [Lldb-commits] [lldb] r138284 - in /lldb/trunk: llvm.zip scripts/build-llvm.pl scripts/llvm.isreg.diff test/lang/c/function_types/TestFunctionTypes.py Message-ID: <20110822223422.DFC092A6C12C@llvm.org> Author: spyffe Date: Mon Aug 22 17:34:22 2011 New Revision: 138284 URL: http://llvm.org/viewvc/llvm-project?rev=138284&view=rev Log: Restored the version of LLVM that we previously rolled back, and the testcase that the rollback broke. The new LLVM has a new ARM disassembler, which may cause instability. Keeping the old one would force us into a contorted position vis-a-vis the LLVM sources we bring in, so we will address issues on the new one rather than keeping the old one around. Removed: lldb/trunk/scripts/llvm.isreg.diff Modified: lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=138284&r1=138283&r2=138284&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=138284&r1=138283&r2=138284&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Mon Aug 22 17:34:22 2011 @@ -22,8 +22,8 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "137143"; -our $clang_revision = "137143"; +our $llvm_revision = "137311"; +our $clang_revision = "137311"; our $llvm_source_dir = "$ENV{SRCROOT}"; our @archs = split (/\s+/, $ENV{ARCHS}); Removed: lldb/trunk/scripts/llvm.isreg.diff URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/llvm.isreg.diff?rev=138283&view=auto ============================================================================== --- lldb/trunk/scripts/llvm.isreg.diff (original) +++ lldb/trunk/scripts/llvm.isreg.diff (removed) @@ -1,12 +0,0 @@ -Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp -=================================================================== ---- lib/Target/ARM/AsmParser/ARMAsmParser.cpp (revision 137143) -+++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp (working copy) -@@ -2619,6 +2619,7 @@ - if (Mnemonic == "mov" && Operands.size() > 4 && - !static_cast(Operands[4])->isARMSOImm() && - static_cast(Operands[4])->isImm0_65535Expr() && -+ static_cast(Operands[1])->isReg() && - static_cast(Operands[1])->getReg() == 0) { - ARMOperand *Op = static_cast(Operands[1]); - Operands.erase(Operands.begin() + 1); Modified: lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py?rev=138284&r1=138283&r2=138284&view=diff ============================================================================== --- lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py (original) +++ lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py Mon Aug 22 17:34:22 2011 @@ -24,12 +24,12 @@ def test_pointers_with_dsym(self): """Test that a function pointer to 'printf' works and can be called.""" self.buildDsym() - #self.function_pointers() # ROLLED BACK + self.function_pointers() def test_pointers_with_dwarf(self): """Test that a function pointer to 'printf' works and can be called.""" self.buildDwarf() - #self.function_pointers() # ROLLED BACK + self.function_pointers() def setUp(self): # Call super's setUp(). From granata.enrico at gmail.com Mon Aug 22 18:45:15 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 22 Aug 2011 23:45:15 -0000 Subject: [Lldb-commits] [lldb] r138307 - in /lldb/trunk: include/lldb/Core/FormatManager.h include/lldb/Core/FormatNavigator.h include/lldb/lldb-private-enumerations.h lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectType.cpp source/Core/DataVisualization.cpp source/Core/FormatManager.cpp Message-ID: <20110822234515.967F02A6C12D@llvm.org> Author: enrico Date: Mon Aug 22 18:45:15 2011 New Revision: 138307 URL: http://llvm.org/viewvc/llvm-project?rev=138307&view=rev Log: Separated FormatNavigator and FormatManager in two different files ; moved FormatCategoryItem enum out of FormatManager.h as a debugger-wide lldb_private enum ; minor style cleanups Added: lldb/trunk/include/lldb/Core/FormatNavigator.h Modified: lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/include/lldb/lldb-private-enumerations.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Core/DataVisualization.cpp lldb/trunk/source/Core/FormatManager.cpp Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=138307&r1=138306&r2=138307&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Mon Aug 22 18:45:15 2011 @@ -11,55 +11,17 @@ #define lldb_FormatManager_h_ // C Includes - -#include -#include - // C++ Includes -#ifdef __GNUC__ -#include - -namespace std -{ - using namespace __gnu_cxx; -} - -#else -#include -#endif - -#include -#include -#include - // Other libraries and framework includes -#include "clang/AST/DeclCXX.h" -#include "clang/AST/Type.h" -#include "clang/AST/DeclObjC.h" - // Project includes #include "lldb/lldb-public.h" #include "lldb/lldb-enumerations.h" -#include "lldb/Core/Communication.h" -#include "lldb/Core/FormatClasses.h" -#include "lldb/Core/InputReaderStack.h" -#include "lldb/Core/Listener.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/RegularExpression.h" -#include "lldb/Core/StreamFile.h" -#include "lldb/Core/SourceManager.h" -#include "lldb/Core/UserID.h" -#include "lldb/Core/UserSettingsController.h" -#include "lldb/Core/ValueObject.h" +#include "lldb/Core/FormatNavigator.h" #include "lldb/Interpreter/ScriptInterpreterPython.h" #include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Platform.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/StackFrame.h" -#include "lldb/Target/TargetList.h" using lldb::LogSP; @@ -69,629 +31,6 @@ // class DataVisualization is the high-level front-end of this feature // clients should refer to that class as the entry-point into the data formatters // unless they have a good reason to bypass it and prefer to use this file's objects directly -class IFormatChangeListener -{ -public: - virtual void - Changed () = 0; - - virtual - ~IFormatChangeListener () {} - - virtual uint32_t - GetCurrentRevision () = 0; - -}; - -static inline bool -IsWhitespace (char c) -{ - return ( (c == ' ') || (c == '\t') || (c == '\v') || (c == '\f') ); -} - -static inline bool -HasPrefix (const char* str1, const char* str2) -{ - return ( ::strstr(str1, str2) == str1 ); -} - -// if the user tries to add formatters for, say, "struct Foo" -// those will not match any type because of the way we strip qualifiers from typenames -// this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo -// and strips the unnecessary qualifier -static ConstString -GetValidTypeName_Impl (const ConstString& type) -{ - int strip_len = 0; - - if (type == false) - return type; - - const char* type_cstr = type.AsCString(); - - if ( HasPrefix(type_cstr, "class ") ) - strip_len = 6; - else if ( HasPrefix(type_cstr, "enum ") ) - strip_len = 5; - else if ( HasPrefix(type_cstr, "struct ") ) - strip_len = 7; - else if ( HasPrefix(type_cstr, "union ") ) - strip_len = 6; - - if (strip_len == 0) - return type; - - type_cstr += strip_len; - while (IsWhitespace(*type_cstr) && ++type_cstr) - ; - - return ConstString(type_cstr); -} - -template -class FormatNavigator; - -template -class FormatMap -{ -public: - - typedef typename ValueType::SharedPointer ValueSP; - typedef std::map MapType; - typedef typename MapType::iterator MapIterator; - typedef bool(*CallbackType)(void*, KeyType, const ValueSP&); - - FormatMap(IFormatChangeListener* lst) : - m_map(), - m_map_mutex(Mutex::eMutexTypeRecursive), - listener(lst) - { - } - - void - Add(KeyType name, - const ValueSP& entry) - { - if (listener) - entry->m_my_revision = listener->GetCurrentRevision(); - else - entry->m_my_revision = 0; - - Mutex::Locker(m_map_mutex); - m_map[name] = entry; - if (listener) - listener->Changed(); - } - - bool - Delete (KeyType name) - { - Mutex::Locker(m_map_mutex); - MapIterator iter = m_map.find(name); - if (iter == m_map.end()) - return false; - m_map.erase(name); - if (listener) - listener->Changed(); - return true; - } - - void - Clear () - { - Mutex::Locker(m_map_mutex); - m_map.clear(); - if (listener) - listener->Changed(); - } - - bool - Get(KeyType name, - ValueSP& entry) - { - Mutex::Locker(m_map_mutex); - MapIterator iter = m_map.find(name); - if (iter == m_map.end()) - return false; - entry = iter->second; - return true; - } - - void - LoopThrough (CallbackType callback, void* param) - { - if (callback) - { - Mutex::Locker(m_map_mutex); - MapIterator pos, end = m_map.end(); - for (pos = m_map.begin(); pos != end; pos++) - { - KeyType type = pos->first; - if (!callback(param, type, pos->second)) - break; - } - } - } - - uint32_t - GetCount () - { - return m_map.size(); - } - -protected: - MapType m_map; - Mutex m_map_mutex; - IFormatChangeListener* listener; - - MapType& - map () - { - return m_map; - } - - Mutex& - mutex () - { - return m_map_mutex; - } - - friend class FormatNavigator; - friend class FormatManager; - -}; - -template -class FormatNavigator -{ -protected: - typedef FormatMap BackEndType; - - template - struct Types { }; - -public: - typedef typename BackEndType::MapType MapType; - typedef typename MapType::iterator MapIterator; - typedef typename MapType::key_type MapKeyType; - typedef typename MapType::mapped_type MapValueType; - typedef typename BackEndType::CallbackType CallbackType; - - typedef typename lldb::SharedPtr >::Type SharedPointer; - - friend class FormatCategory; - - FormatNavigator(std::string name, - IFormatChangeListener* lst) : - m_format_map(lst), - m_name(name), - m_id_cs(ConstString("id")) - { - } - - void - Add (const MapKeyType &type, const MapValueType& entry) - { - Add_Impl(type, entry, Types()); - } - - bool - Delete (ConstString type) - { - return Delete_Impl(type, Types()); - } - - bool - Get(ValueObject& valobj, - MapValueType& entry, - lldb::DynamicValueType use_dynamic, - uint32_t* why = NULL) - { - uint32_t value = lldb::eFormatterChoiceCriterionDirectChoice; - clang::QualType type = clang::QualType::getFromOpaquePtr(valobj.GetClangType()); - bool ret = Get(valobj, type, entry, use_dynamic, value); - if (ret) - entry = MapValueType(entry); - else - entry = MapValueType(); - if (why) - *why = value; - return ret; - } - - void - Clear () - { - m_format_map.Clear(); - } - - void - LoopThrough (CallbackType callback, void* param) - { - m_format_map.LoopThrough(callback,param); - } - - uint32_t - GetCount () - { - return m_format_map.GetCount(); - } - -protected: - - BackEndType m_format_map; - - std::string m_name; - - DISALLOW_COPY_AND_ASSIGN(FormatNavigator); - - ConstString m_id_cs; - - template - void - Add_Impl (const MapKeyType &type, const MapValueType& entry, Types) - { - m_format_map.Add(type,entry); - } - - template - void Add_Impl (const ConstString &type, const MapValueType& entry, Types) - { - m_format_map.Add(GetValidTypeName_Impl(type), entry); - } - - template - bool - Delete_Impl (ConstString type, Types) - { - return m_format_map.Delete(type); - } - - template - bool - Delete_Impl (ConstString type, Types) - { - Mutex& x_mutex = m_format_map.mutex(); - lldb_private::Mutex::Locker locker(x_mutex); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) - { - lldb::RegularExpressionSP regex = pos->first; - if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) - { - m_format_map.map().erase(pos); - if (m_format_map.listener) - m_format_map.listener->Changed(); - return true; - } - } - return false; - } - - template - bool - Get_Impl (ConstString type, MapValueType& entry, Types) - { - return m_format_map.Get(type, entry); - } - - template - bool - Get_Impl (ConstString key, MapValueType& value, Types) - { - Mutex& x_mutex = m_format_map.mutex(); - lldb_private::Mutex::Locker locker(x_mutex); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) - { - lldb::RegularExpressionSP regex = pos->first; - if (regex->Execute(key.AsCString())) - { - value = pos->second; - return true; - } - } - return false; - } - - bool - Get (ConstString type, MapValueType& entry) - { - return Get_Impl(type, entry, Types()); - } - - bool Get_ObjC(ValueObject& valobj, - ObjCLanguageRuntime::ObjCISA isa, - MapValueType& entry, - uint32_t& reason) - { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); - if (log) - log->Printf("going to an Objective-C dynamic scanning"); - Process* process = valobj.GetUpdatePoint().GetProcessSP().get(); - ObjCLanguageRuntime* runtime = process->GetObjCLanguageRuntime(); - if (runtime == NULL) - { - if (log) - log->Printf("no valid ObjC runtime, bailing out"); - return false; - } - if (runtime->IsValidISA(isa) == false) - { - if (log) - log->Printf("invalid ISA, bailing out"); - return false; - } - ConstString name = runtime->GetActualTypeName(isa); - if (log) - log->Printf("looking for formatter for %s", name.GetCString()); - if (Get(name, entry)) - { - if (log) - log->Printf("direct match found, returning"); - return true; - } - if (log) - log->Printf("no direct match"); - ObjCLanguageRuntime::ObjCISA parent = runtime->GetParentClass(isa); - if (runtime->IsValidISA(parent) == false) - { - if (log) - log->Printf("invalid parent ISA, bailing out"); - return false; - } - if (parent == isa) - { - if (log) - log->Printf("parent-child loop, bailing out"); - return false; - } - if (Get_ObjC(valobj, parent, entry, reason)) - { - reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; - return true; - } - return false; - } - - bool Get(ValueObject& valobj, - clang::QualType type, - MapValueType& entry, - lldb::DynamicValueType use_dynamic, - uint32_t& reason) - { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); - if (type.isNull()) - { - if (log) - log->Printf("type is NULL, returning"); - return false; - } - // clang::QualType type = q_type.getUnqualifiedType(); - type.removeLocalConst(); type.removeLocalVolatile(); type.removeLocalRestrict(); - const clang::Type* typePtr = type.getTypePtrOrNull(); - if (!typePtr) - { - if (log) - log->Printf("type is NULL, returning"); - return false; - } - ConstString typeName(ClangASTType::GetTypeNameForQualType(type).c_str()); - if (valobj.GetBitfieldBitSize() > 0) - { - // for bitfields, append size to the typename so one can custom format them - StreamString sstring; - sstring.Printf("%s:%d",typeName.AsCString(),valobj.GetBitfieldBitSize()); - ConstString bitfieldname = ConstString(sstring.GetData()); - if (log) - log->Printf("appended bitfield info, final result is %s", bitfieldname.GetCString()); - if (Get(bitfieldname, entry)) - { - if (log) - log->Printf("bitfield direct match found, returning"); - return true; - } - else - { - reason |= lldb::eFormatterChoiceCriterionStrippedBitField; - if (log) - log->Printf("no bitfield direct match"); - } - } - if (log) - log->Printf("trying to get %s for VO name %s of type %s", - m_name.c_str(), - valobj.GetName().AsCString(), - typeName.AsCString()); - if (Get(typeName, entry)) - { - if (log) - log->Printf("direct match found, returning"); - return true; - } - if (log) - log->Printf("no direct match"); - // look for a "base type", whatever that means - if (typePtr->isReferenceType()) - { - if (log) - log->Printf("stripping reference"); - if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->m_skip_references) - { - reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; - return true; - } - } - if (use_dynamic != lldb::eNoDynamicValues && - (/*strstr(typeName, "id") == typeName ||*/ - ClangASTType::GetMinimumLanguage(valobj.GetClangAST(), valobj.GetClangType()) == lldb::eLanguageTypeObjC)) - { - if (log) - log->Printf("this is an ObjC 'id', let's do dynamic search"); - Process* process = valobj.GetUpdatePoint().GetProcessSP().get(); - ObjCLanguageRuntime* runtime = process->GetObjCLanguageRuntime(); - if (runtime == NULL) - { - if (log) - log->Printf("no valid ObjC runtime, skipping dynamic"); - } - else - { - if (Get_ObjC(valobj, runtime->GetISA(valobj), entry, reason)) - { - reason |= lldb::eFormatterChoiceCriterionDynamicObjCHierarchy; - return true; - } - } - } - else if (use_dynamic != lldb::eNoDynamicValues && log) - { - log->Printf("typename: %s, typePtr = %p, id = %p", - typeName.AsCString(), typePtr, valobj.GetClangAST()->ObjCBuiltinIdTy.getTypePtr()); - } - else if (log) - { - log->Printf("no dynamic"); - } - if (typePtr->isPointerType()) - { - if (log) - log->Printf("stripping pointer"); - clang::QualType pointee = typePtr->getPointeeType(); - if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->m_skip_pointers) - { - reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; - return true; - } - } - if (typePtr->isObjCObjectPointerType()) - { - if (use_dynamic != lldb::eNoDynamicValues && - typeName == m_id_cs) - { - if (log) - log->Printf("this is an ObjC 'id', let's do dynamic search"); - Process* process = valobj.GetUpdatePoint().GetProcessSP().get(); - ObjCLanguageRuntime* runtime = process->GetObjCLanguageRuntime(); - if (runtime == NULL) - { - if (log) - log->Printf("no valid ObjC runtime, skipping dynamic"); - } - else - { - if (Get_ObjC(valobj, runtime->GetISA(valobj), entry, reason)) - { - reason |= lldb::eFormatterChoiceCriterionDynamicObjCHierarchy; - return true; - } - } - } - if (log) - log->Printf("stripping ObjC pointer"); - - // For some reason, C++ can quite easily obtain the type hierarchy for a ValueObject - // even if the VO represent a pointer-to-class, as long as the typePtr is right - // Objective-C on the other hand cannot really complete an @interface when - // the VO refers to a pointer-to- at interface - - Error error; - ValueObject* target = valobj.Dereference(error).get(); - if (error.Fail() || !target) - return false; - if (Get(*target, typePtr->getPointeeType(), entry, use_dynamic, reason) && !entry->m_skip_pointers) - { - reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; - return true; - } - } - const clang::ObjCObjectType *objc_class_type = typePtr->getAs(); - if (objc_class_type) - { - if (log) - log->Printf("working with ObjC"); - clang::ASTContext *ast = valobj.GetClangAST(); - if (ClangASTContext::GetCompleteType(ast, valobj.GetClangType()) && !objc_class_type->isObjCId()) - { - clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); - if (class_interface_decl) - { - if (log) - log->Printf("got an ObjCInterfaceDecl"); - clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); - if (superclass_interface_decl) - { - if (log) - log->Printf("got a parent class for this ObjC class"); - clang::QualType ivar_qual_type(ast->getObjCInterfaceType(superclass_interface_decl)); - if (Get(valobj, ivar_qual_type, entry, use_dynamic, reason) && entry->m_cascades) - { - reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; - return true; - } - } - } - } - } - // for C++ classes, navigate up the hierarchy - if (typePtr->isRecordType()) - { - if (log) - log->Printf("working with C++"); - clang::CXXRecordDecl* record = typePtr->getAsCXXRecordDecl(); - if (record) - { - if (!record->hasDefinition()) - ClangASTContext::GetCompleteType(valobj.GetClangAST(), valobj.GetClangType()); - if (record->hasDefinition()) - { - clang::CXXRecordDecl::base_class_iterator pos,end; - if (record->getNumBases() > 0) - { - if (log) - log->Printf("look into bases"); - end = record->bases_end(); - for (pos = record->bases_begin(); pos != end; pos++) - { - if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades) - { - reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; - return true; - } - } - } - if (record->getNumVBases() > 0) - { - if (log) - log->Printf("look into VBases"); - end = record->vbases_end(); - for (pos = record->vbases_begin(); pos != end; pos++) - { - if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades) - { - reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; - return true; - } - } - } - } - } - } - // try to strip typedef chains - const clang::TypedefType* type_tdef = type->getAs(); - if (type_tdef) - { - if (log) - log->Printf("stripping typedef"); - if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->m_cascades) - { - reason |= lldb::eFormatterChoiceCriterionNavigatedTypedefs; - return true; - } - } - return false; - } -}; class CategoryMap; @@ -716,21 +55,7 @@ typedef RegexSynthNavigator::MapType RegexSynthMap; public: - - //------------------------------------------------------------------ - /// Format category entry types - //------------------------------------------------------------------ - typedef enum FormatCategoryItem - { - eSummary = 0x0001, - eRegexSummary = 0x1001, - eFilter = 0x0002, - eRegexFilter = 0x1002, - eSynth = 0x0004, - eRegexSynth = 0x1004, - eAllItems = 0xFFFF - } FormatCategoryItem; - + typedef uint16_t FormatCategoryItems; static const uint16_t ALL_ITEM_TYPES = 0xFFFF; @@ -741,8 +66,8 @@ typedef SynthNavigator::SharedPointer SynthNavigatorSP; typedef RegexSynthNavigator::SharedPointer RegexSynthNavigatorSP; - FormatCategory(IFormatChangeListener* clist, - std::string name); + FormatCategory (IFormatChangeListener* clist, + std::string name); SummaryNavigatorSP GetSummaryNavigator () @@ -787,10 +112,10 @@ } bool - Get(ValueObject& valobj, - lldb::SummaryFormatSP& entry, - lldb::DynamicValueType use_dynamic, - uint32_t* reason = NULL) + Get (ValueObject& valobj, + lldb::SummaryFormatSP& entry, + lldb::DynamicValueType use_dynamic, + uint32_t* reason = NULL) { if (!IsEnabled()) return false; @@ -803,23 +128,23 @@ } bool - Get(ValueObject& valobj, - lldb::SyntheticChildrenSP& entry, - lldb::DynamicValueType use_dynamic, - uint32_t* reason = NULL); + Get (ValueObject& valobj, + lldb::SyntheticChildrenSP& entry, + lldb::DynamicValueType use_dynamic, + uint32_t* reason = NULL); // just a shortcut for GetSummaryNavigator()->Clear; GetRegexSummaryNavigator()->Clear() void ClearSummaries () { - Clear(eSummary | eRegexSummary); + Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); } // just a shortcut for (GetSummaryNavigator()->Delete(name) || GetRegexSummaryNavigator()->Delete(name)) bool DeleteSummaries (ConstString name) { - return Delete(name, (eSummary | eRegexSummary)); + return Delete(name, (eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary)); } @@ -840,11 +165,11 @@ } bool - AnyMatches(ConstString type_name, - FormatCategoryItems items = ALL_ITEM_TYPES, - bool only_enabled = true, - const char** matching_category = NULL, - FormatCategoryItems* matching_type = NULL); + AnyMatches (ConstString type_name, + FormatCategoryItems items = ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = NULL, + FormatCategoryItems* matching_type = NULL); typedef lldb::SharedPtr::Type SharedPointer; @@ -907,17 +232,17 @@ typedef MapType::iterator MapIterator; typedef bool(*CallbackType)(void*, const ValueSP&); - CategoryMap(IFormatChangeListener* lst) : - m_map_mutex(Mutex::eMutexTypeRecursive), - listener(lst), - m_map(), - m_active_categories() + CategoryMap (IFormatChangeListener* lst) : + m_map_mutex(Mutex::eMutexTypeRecursive), + listener(lst), + m_map(), + m_active_categories() { } void - Add(KeyType name, - const ValueSP& entry) + Add (KeyType name, + const ValueSP& entry) { Mutex::Locker(m_map_mutex); m_map[name] = entry; @@ -985,8 +310,8 @@ } bool - Get(KeyType name, - ValueSP& entry) + Get (KeyType name, + ValueSP& entry) { Mutex::Locker(m_map_mutex); MapIterator iter = m_map.find(name); @@ -1000,11 +325,11 @@ LoopThrough (CallbackType callback, void* param); bool - AnyMatches(ConstString type_name, - FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, - bool only_enabled = true, - const char** matching_category = NULL, - FormatCategory::FormatCategoryItems* matching_type = NULL) + AnyMatches (ConstString type_name, + FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = NULL, + FormatCategory::FormatCategoryItems* matching_type = NULL) { Mutex::Locker(m_map_mutex); @@ -1028,9 +353,9 @@ } bool - Get(ValueObject& valobj, - lldb::SummaryFormatSP& entry, - lldb::DynamicValueType use_dynamic) + Get (ValueObject& valobj, + lldb::SummaryFormatSP& entry, + lldb::DynamicValueType use_dynamic) { Mutex::Locker(m_map_mutex); @@ -1050,9 +375,9 @@ } bool - Get(ValueObject& valobj, - lldb::SyntheticChildrenSP& entry, - lldb::DynamicValueType use_dynamic) + Get (ValueObject& valobj, + lldb::SyntheticChildrenSP& entry, + lldb::DynamicValueType use_dynamic) { Mutex::Locker(m_map_mutex); @@ -1084,7 +409,7 @@ return m_map; } - ActiveCategoriesList& active_list() + ActiveCategoriesList& active_list () { return m_active_categories; } @@ -1138,16 +463,22 @@ m_categories_map.Disable(category_name); } - void - EnableCategory (const char* category_name) + bool + DeleteCategory (const ConstString& category_name) { - EnableCategory(ConstString(category_name)); + return m_categories_map.Delete(category_name); } void - DisableCategory (const char* category_name) + ClearCategories () { - DisableCategory(ConstString(category_name)); + return m_categories_map.Clear(); + } + + uint32_t + GetCategoriesCount () + { + return m_categories_map.GetCount(); } void @@ -1183,26 +514,26 @@ } bool - Get(ValueObject& valobj, - lldb::SummaryFormatSP& entry, - lldb::DynamicValueType use_dynamic) + Get (ValueObject& valobj, + lldb::SummaryFormatSP& entry, + lldb::DynamicValueType use_dynamic) { return m_categories_map.Get(valobj, entry, use_dynamic); } bool - Get(ValueObject& valobj, - lldb::SyntheticChildrenSP& entry, - lldb::DynamicValueType use_dynamic) + Get (ValueObject& valobj, + lldb::SyntheticChildrenSP& entry, + lldb::DynamicValueType use_dynamic) { return m_categories_map.Get(valobj, entry, use_dynamic); } bool - AnyMatches(ConstString type_name, - FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, - bool only_enabled = true, - const char** matching_category = NULL, - FormatCategory::FormatCategoryItems* matching_type = NULL) + AnyMatches (ConstString type_name, + FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = NULL, + FormatCategory::FormatCategoryItems* matching_type = NULL) { return m_categories_map.AnyMatches(type_name, items, @@ -1232,7 +563,7 @@ // when DataExtractor dumps a vectorOfT, it uses a predefined format for each item // this method returns it, or eFormatInvalid if vector_format is not a vectorOf static lldb::Format - GetSingleItemFormat(lldb::Format vector_format); + GetSingleItemFormat (lldb::Format vector_format); void Changed () @@ -1250,12 +581,6 @@ { } - CategoryMap& - GetCategories () - { - return m_categories_map; - } - private: ValueNavigator m_value_nav; NamedSummariesMap m_named_summaries_map; @@ -1266,6 +591,12 @@ ConstString m_system_category_name; ConstString m_gnu_cpp_category_name; + CategoryMap& + GetCategories () + { + return m_categories_map; + } + }; } // namespace lldb_private Added: lldb/trunk/include/lldb/Core/FormatNavigator.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatNavigator.h?rev=138307&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/FormatNavigator.h (added) +++ lldb/trunk/include/lldb/Core/FormatNavigator.h Mon Aug 22 18:45:15 2011 @@ -0,0 +1,686 @@ +//===-- FormatNavigator.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_FormatNavigator_h_ +#define lldb_FormatNavigator_h_ + +// C Includes + +#include +#include + +// C++ Includes + +#ifdef __GNUC__ +#include + +namespace std +{ + using namespace __gnu_cxx; +} + +#else +#include +#endif + +#include + +// Other libraries and framework includes +#include "clang/AST/DeclCXX.h" +#include "clang/AST/Type.h" +#include "clang/AST/DeclObjC.h" + +// Project includes +#include "lldb/lldb-public.h" +#include "lldb/lldb-enumerations.h" + +#include "lldb/Core/FormatClasses.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/RegularExpression.h" +#include "lldb/Core/ValueObject.h" +#include "lldb/Target/ObjCLanguageRuntime.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/StackFrame.h" +#include "lldb/Target/TargetList.h" + +using lldb::LogSP; + +namespace lldb_private { + +// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization +// class DataVisualization is the high-level front-end of this feature +// clients should refer to that class as the entry-point into the data formatters +// unless they have a good reason to bypass it and prefer to use this file's objects directly +class IFormatChangeListener +{ +public: + virtual void + Changed () = 0; + + virtual + ~IFormatChangeListener () {} + + virtual uint32_t + GetCurrentRevision () = 0; + +}; + +static inline bool +IsWhitespace (char c) +{ + return ( (c == ' ') || (c == '\t') || (c == '\v') || (c == '\f') ); +} + +static inline bool +HasPrefix (const char* str1, const char* str2) +{ + return ( ::strstr(str1, str2) == str1 ); +} + +// if the user tries to add formatters for, say, "struct Foo" +// those will not match any type because of the way we strip qualifiers from typenames +// this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo +// and strips the unnecessary qualifier +static ConstString +GetValidTypeName_Impl (const ConstString& type) +{ + int strip_len = 0; + + if (type == false) + return type; + + const char* type_cstr = type.AsCString(); + + if ( HasPrefix(type_cstr, "class ") ) + strip_len = 6; + else if ( HasPrefix(type_cstr, "enum ") ) + strip_len = 5; + else if ( HasPrefix(type_cstr, "struct ") ) + strip_len = 7; + else if ( HasPrefix(type_cstr, "union ") ) + strip_len = 6; + + if (strip_len == 0) + return type; + + type_cstr += strip_len; + while (IsWhitespace(*type_cstr) && ++type_cstr) + ; + + return ConstString(type_cstr); +} + +template +class FormatNavigator; + +template +class FormatMap +{ +public: + + typedef typename ValueType::SharedPointer ValueSP; + typedef std::map MapType; + typedef typename MapType::iterator MapIterator; + typedef bool(*CallbackType)(void*, KeyType, const ValueSP&); + + FormatMap(IFormatChangeListener* lst) : + m_map(), + m_map_mutex(Mutex::eMutexTypeRecursive), + listener(lst) + { + } + + void + Add(KeyType name, + const ValueSP& entry) + { + if (listener) + entry->m_my_revision = listener->GetCurrentRevision(); + else + entry->m_my_revision = 0; + + Mutex::Locker(m_map_mutex); + m_map[name] = entry; + if (listener) + listener->Changed(); + } + + bool + Delete (KeyType name) + { + Mutex::Locker(m_map_mutex); + MapIterator iter = m_map.find(name); + if (iter == m_map.end()) + return false; + m_map.erase(name); + if (listener) + listener->Changed(); + return true; + } + + void + Clear () + { + Mutex::Locker(m_map_mutex); + m_map.clear(); + if (listener) + listener->Changed(); + } + + bool + Get(KeyType name, + ValueSP& entry) + { + Mutex::Locker(m_map_mutex); + MapIterator iter = m_map.find(name); + if (iter == m_map.end()) + return false; + entry = iter->second; + return true; + } + + void + LoopThrough (CallbackType callback, void* param) + { + if (callback) + { + Mutex::Locker(m_map_mutex); + MapIterator pos, end = m_map.end(); + for (pos = m_map.begin(); pos != end; pos++) + { + KeyType type = pos->first; + if (!callback(param, type, pos->second)) + break; + } + } + } + + uint32_t + GetCount () + { + return m_map.size(); + } + +protected: + MapType m_map; + Mutex m_map_mutex; + IFormatChangeListener* listener; + + MapType& + map () + { + return m_map; + } + + Mutex& + mutex () + { + return m_map_mutex; + } + + friend class FormatNavigator; + friend class FormatManager; + +}; + +template +class FormatNavigator +{ +protected: + typedef FormatMap BackEndType; + + template + struct Types { }; + +public: + typedef typename BackEndType::MapType MapType; + typedef typename MapType::iterator MapIterator; + typedef typename MapType::key_type MapKeyType; + typedef typename MapType::mapped_type MapValueType; + typedef typename BackEndType::CallbackType CallbackType; + + typedef typename lldb::SharedPtr >::Type SharedPointer; + + friend class FormatCategory; + + FormatNavigator(std::string name, + IFormatChangeListener* lst) : + m_format_map(lst), + m_name(name), + m_id_cs(ConstString("id")) + { + } + + void + Add (const MapKeyType &type, const MapValueType& entry) + { + Add_Impl(type, entry, Types()); + } + + bool + Delete (ConstString type) + { + return Delete_Impl(type, Types()); + } + + bool + Get(ValueObject& valobj, + MapValueType& entry, + lldb::DynamicValueType use_dynamic, + uint32_t* why = NULL) + { + uint32_t value = lldb::eFormatterChoiceCriterionDirectChoice; + clang::QualType type = clang::QualType::getFromOpaquePtr(valobj.GetClangType()); + bool ret = Get(valobj, type, entry, use_dynamic, value); + if (ret) + entry = MapValueType(entry); + else + entry = MapValueType(); + if (why) + *why = value; + return ret; + } + + void + Clear () + { + m_format_map.Clear(); + } + + void + LoopThrough (CallbackType callback, void* param) + { + m_format_map.LoopThrough(callback,param); + } + + uint32_t + GetCount () + { + return m_format_map.GetCount(); + } + +protected: + + BackEndType m_format_map; + + std::string m_name; + + DISALLOW_COPY_AND_ASSIGN(FormatNavigator); + + ConstString m_id_cs; + + template + void + Add_Impl (const MapKeyType &type, const MapValueType& entry, Types) + { + m_format_map.Add(type,entry); + } + + template + void Add_Impl (const ConstString &type, const MapValueType& entry, Types) + { + m_format_map.Add(GetValidTypeName_Impl(type), entry); + } + + template + bool + Delete_Impl (ConstString type, Types) + { + return m_format_map.Delete(type); + } + + template + bool + Delete_Impl (ConstString type, Types) + { + Mutex& x_mutex = m_format_map.mutex(); + lldb_private::Mutex::Locker locker(x_mutex); + MapIterator pos, end = m_format_map.map().end(); + for (pos = m_format_map.map().begin(); pos != end; pos++) + { + lldb::RegularExpressionSP regex = pos->first; + if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) + { + m_format_map.map().erase(pos); + if (m_format_map.listener) + m_format_map.listener->Changed(); + return true; + } + } + return false; + } + + template + bool + Get_Impl (ConstString type, MapValueType& entry, Types) + { + return m_format_map.Get(type, entry); + } + + template + bool + Get_Impl (ConstString key, MapValueType& value, Types) + { + Mutex& x_mutex = m_format_map.mutex(); + lldb_private::Mutex::Locker locker(x_mutex); + MapIterator pos, end = m_format_map.map().end(); + for (pos = m_format_map.map().begin(); pos != end; pos++) + { + lldb::RegularExpressionSP regex = pos->first; + if (regex->Execute(key.AsCString())) + { + value = pos->second; + return true; + } + } + return false; + } + + bool + Get (ConstString type, MapValueType& entry) + { + return Get_Impl(type, entry, Types()); + } + + bool Get_ObjC(ValueObject& valobj, + ObjCLanguageRuntime::ObjCISA isa, + MapValueType& entry, + uint32_t& reason) + { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); + if (log) + log->Printf("going to an Objective-C dynamic scanning"); + Process* process = valobj.GetUpdatePoint().GetProcessSP().get(); + ObjCLanguageRuntime* runtime = process->GetObjCLanguageRuntime(); + if (runtime == NULL) + { + if (log) + log->Printf("no valid ObjC runtime, bailing out"); + return false; + } + if (runtime->IsValidISA(isa) == false) + { + if (log) + log->Printf("invalid ISA, bailing out"); + return false; + } + ConstString name = runtime->GetActualTypeName(isa); + if (log) + log->Printf("looking for formatter for %s", name.GetCString()); + if (Get(name, entry)) + { + if (log) + log->Printf("direct match found, returning"); + return true; + } + if (log) + log->Printf("no direct match"); + ObjCLanguageRuntime::ObjCISA parent = runtime->GetParentClass(isa); + if (runtime->IsValidISA(parent) == false) + { + if (log) + log->Printf("invalid parent ISA, bailing out"); + return false; + } + if (parent == isa) + { + if (log) + log->Printf("parent-child loop, bailing out"); + return false; + } + if (Get_ObjC(valobj, parent, entry, reason)) + { + reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; + return true; + } + return false; + } + + bool Get(ValueObject& valobj, + clang::QualType type, + MapValueType& entry, + lldb::DynamicValueType use_dynamic, + uint32_t& reason) + { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); + if (type.isNull()) + { + if (log) + log->Printf("type is NULL, returning"); + return false; + } + // clang::QualType type = q_type.getUnqualifiedType(); + type.removeLocalConst(); type.removeLocalVolatile(); type.removeLocalRestrict(); + const clang::Type* typePtr = type.getTypePtrOrNull(); + if (!typePtr) + { + if (log) + log->Printf("type is NULL, returning"); + return false; + } + ConstString typeName(ClangASTType::GetTypeNameForQualType(type).c_str()); + if (valobj.GetBitfieldBitSize() > 0) + { + // for bitfields, append size to the typename so one can custom format them + StreamString sstring; + sstring.Printf("%s:%d",typeName.AsCString(),valobj.GetBitfieldBitSize()); + ConstString bitfieldname = ConstString(sstring.GetData()); + if (log) + log->Printf("appended bitfield info, final result is %s", bitfieldname.GetCString()); + if (Get(bitfieldname, entry)) + { + if (log) + log->Printf("bitfield direct match found, returning"); + return true; + } + else + { + reason |= lldb::eFormatterChoiceCriterionStrippedBitField; + if (log) + log->Printf("no bitfield direct match"); + } + } + if (log) + log->Printf("trying to get %s for VO name %s of type %s", + m_name.c_str(), + valobj.GetName().AsCString(), + typeName.AsCString()); + if (Get(typeName, entry)) + { + if (log) + log->Printf("direct match found, returning"); + return true; + } + if (log) + log->Printf("no direct match"); + // look for a "base type", whatever that means + if (typePtr->isReferenceType()) + { + if (log) + log->Printf("stripping reference"); + if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->m_skip_references) + { + reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; + return true; + } + } + if (use_dynamic != lldb::eNoDynamicValues && + (/*strstr(typeName, "id") == typeName ||*/ + ClangASTType::GetMinimumLanguage(valobj.GetClangAST(), valobj.GetClangType()) == lldb::eLanguageTypeObjC)) + { + if (log) + log->Printf("this is an ObjC 'id', let's do dynamic search"); + Process* process = valobj.GetUpdatePoint().GetProcessSP().get(); + ObjCLanguageRuntime* runtime = process->GetObjCLanguageRuntime(); + if (runtime == NULL) + { + if (log) + log->Printf("no valid ObjC runtime, skipping dynamic"); + } + else + { + if (Get_ObjC(valobj, runtime->GetISA(valobj), entry, reason)) + { + reason |= lldb::eFormatterChoiceCriterionDynamicObjCHierarchy; + return true; + } + } + } + else if (use_dynamic != lldb::eNoDynamicValues && log) + { + log->Printf("typename: %s, typePtr = %p, id = %p", + typeName.AsCString(), typePtr, valobj.GetClangAST()->ObjCBuiltinIdTy.getTypePtr()); + } + else if (log) + { + log->Printf("no dynamic"); + } + if (typePtr->isPointerType()) + { + if (log) + log->Printf("stripping pointer"); + clang::QualType pointee = typePtr->getPointeeType(); + if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->m_skip_pointers) + { + reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; + return true; + } + } + if (typePtr->isObjCObjectPointerType()) + { + if (use_dynamic != lldb::eNoDynamicValues && + typeName == m_id_cs) + { + if (log) + log->Printf("this is an ObjC 'id', let's do dynamic search"); + Process* process = valobj.GetUpdatePoint().GetProcessSP().get(); + ObjCLanguageRuntime* runtime = process->GetObjCLanguageRuntime(); + if (runtime == NULL) + { + if (log) + log->Printf("no valid ObjC runtime, skipping dynamic"); + } + else + { + if (Get_ObjC(valobj, runtime->GetISA(valobj), entry, reason)) + { + reason |= lldb::eFormatterChoiceCriterionDynamicObjCHierarchy; + return true; + } + } + } + if (log) + log->Printf("stripping ObjC pointer"); + + // For some reason, C++ can quite easily obtain the type hierarchy for a ValueObject + // even if the VO represent a pointer-to-class, as long as the typePtr is right + // Objective-C on the other hand cannot really complete an @interface when + // the VO refers to a pointer-to- at interface + + Error error; + ValueObject* target = valobj.Dereference(error).get(); + if (error.Fail() || !target) + return false; + if (Get(*target, typePtr->getPointeeType(), entry, use_dynamic, reason) && !entry->m_skip_pointers) + { + reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference; + return true; + } + } + const clang::ObjCObjectType *objc_class_type = typePtr->getAs(); + if (objc_class_type) + { + if (log) + log->Printf("working with ObjC"); + clang::ASTContext *ast = valobj.GetClangAST(); + if (ClangASTContext::GetCompleteType(ast, valobj.GetClangType()) && !objc_class_type->isObjCId()) + { + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + if (class_interface_decl) + { + if (log) + log->Printf("got an ObjCInterfaceDecl"); + clang::ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); + if (superclass_interface_decl) + { + if (log) + log->Printf("got a parent class for this ObjC class"); + clang::QualType ivar_qual_type(ast->getObjCInterfaceType(superclass_interface_decl)); + if (Get(valobj, ivar_qual_type, entry, use_dynamic, reason) && entry->m_cascades) + { + reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; + return true; + } + } + } + } + } + // for C++ classes, navigate up the hierarchy + if (typePtr->isRecordType()) + { + if (log) + log->Printf("working with C++"); + clang::CXXRecordDecl* record = typePtr->getAsCXXRecordDecl(); + if (record) + { + if (!record->hasDefinition()) + ClangASTContext::GetCompleteType(valobj.GetClangAST(), valobj.GetClangType()); + if (record->hasDefinition()) + { + clang::CXXRecordDecl::base_class_iterator pos,end; + if (record->getNumBases() > 0) + { + if (log) + log->Printf("look into bases"); + end = record->bases_end(); + for (pos = record->bases_begin(); pos != end; pos++) + { + if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades) + { + reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; + return true; + } + } + } + if (record->getNumVBases() > 0) + { + if (log) + log->Printf("look into VBases"); + end = record->vbases_end(); + for (pos = record->vbases_begin(); pos != end; pos++) + { + if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades) + { + reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses; + return true; + } + } + } + } + } + } + // try to strip typedef chains + const clang::TypedefType* type_tdef = type->getAs(); + if (type_tdef) + { + if (log) + log->Printf("stripping typedef"); + if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->m_cascades) + { + reason |= lldb::eFormatterChoiceCriterionNavigatedTypedefs; + return true; + } + } + return false; + } +}; + +} // namespace lldb_private + +#endif // lldb_FormatNavigator_h_ Modified: lldb/trunk/include/lldb/lldb-private-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-enumerations.h?rev=138307&r1=138306&r2=138307&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-private-enumerations.h Mon Aug 22 18:45:15 2011 @@ -200,6 +200,19 @@ } InstructionType; + +//------------------------------------------------------------------ +/// Format category entry types +//------------------------------------------------------------------ +typedef enum FormatCategoryItem +{ + eFormatCategoryItemSummary = 0x0001, + eFormatCategoryItemRegexSummary = 0x1001, + eFormatCategoryItemFilter = 0x0002, + eFormatCategoryItemRegexFilter = 0x1002, + eFormatCategoryItemSynth = 0x0004, + eFormatCategoryItemRegexSynth = 0x1004, +} FormatCategoryItem; } // namespace lldb Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=138307&r1=138306&r2=138307&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Aug 22 18:45:15 2011 @@ -1190,6 +1190,7 @@ 9467E65413C3D98900B3B6F3 /* TypeHierarchyNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeHierarchyNavigator.h; path = include/lldb/Symbol/TypeHierarchyNavigator.h; sourceTree = ""; }; 9470A8EE1402DF940056FF61 /* DataVisualization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DataVisualization.h; path = include/lldb/Core/DataVisualization.h; sourceTree = ""; }; 9470A8EF1402DFFB0056FF61 /* DataVisualization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataVisualization.cpp; path = source/Core/DataVisualization.cpp; sourceTree = ""; }; + 94A8287514031D05006C37A8 /* FormatNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatNavigator.h; path = include/lldb/Core/FormatNavigator.h; sourceTree = ""; }; 94A9112B13D5DEF80046D8A6 /* FormatClasses.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatClasses.h; path = include/lldb/Core/FormatClasses.h; sourceTree = ""; }; 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatClasses.cpp; path = source/Core/FormatClasses.cpp; sourceTree = ""; }; 94B6E76013D8833C005F417F /* ValueObjectSyntheticFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectSyntheticFilter.h; path = include/lldb/Core/ValueObjectSyntheticFilter.h; sourceTree = ""; }; @@ -1950,6 +1951,7 @@ 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */, 9415F61613B2C0DC00A52B36 /* FormatManager.h */, 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */, + 94A8287514031D05006C37A8 /* FormatNavigator.h */, 26F7305F139D8FC900FD51C7 /* History.h */, 26F73061139D8FDB00FD51C7 /* History.cpp */, 9AA69DBB118A029E00D753A0 /* InputReader.h */, Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=138307&r1=138306&r2=138307&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Mon Aug 22 18:45:15 2011 @@ -1169,7 +1169,7 @@ const lldb::FormatCategorySP& cate) { ConstString *name = (ConstString*)param; - cate->Delete(*name, FormatCategory::eSummary | FormatCategory::eRegexSummary); + cate->Delete(*name, eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); return true; } @@ -1540,7 +1540,7 @@ const char* cate_name = cate->GetName().c_str(); // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->GetCount(FormatCategory::eSummary | FormatCategory::eRegexSummary) == 0) && param->cate_regex == NULL) + if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary) == 0) && param->cate_regex == NULL) return true; // if we have a regex and this category does not match it, just skip it @@ -2046,7 +2046,7 @@ CommandReturnObject* result = param->result; // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->GetCount(FormatCategory::eFilter | FormatCategory::eRegexFilter) == 0) && param->cate_regex == NULL) + if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter) == 0) && param->cate_regex == NULL) return true; // if we have a regex and this category does not match it, just skip it @@ -2256,7 +2256,7 @@ const char* cate_name = cate->GetName().c_str(); // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->GetCount(FormatCategory::eSynth | FormatCategory::eRegexSynth) == 0) && param->cate_regex == NULL) + if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth) == 0) && param->cate_regex == NULL) return true; // if we have a regex and this category does not match it, just skip it @@ -2397,7 +2397,7 @@ const lldb::FormatCategorySP& cate) { ConstString *name = (ConstString*)param; - return cate->Delete(*name, FormatCategory::eFilter | FormatCategory::eRegexFilter); + return cate->Delete(*name, eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter); } public: @@ -2559,7 +2559,7 @@ const lldb::FormatCategorySP& cate) { ConstString* name = (ConstString*)param; - return cate->Delete(*name, FormatCategory::eSynth | FormatCategory::eRegexSynth); + return cate->Delete(*name, eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth); } public: @@ -2716,7 +2716,7 @@ PerCategoryCallback(void* param, const lldb::FormatCategorySP& cate) { - cate->Clear(FormatCategory::eFilter | FormatCategory::eRegexFilter); + cate->Clear(eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter); return true; } @@ -2842,7 +2842,7 @@ PerCategoryCallback(void* param, const lldb::FormatCategorySP& cate) { - cate->Clear(FormatCategory::eSynth | FormatCategory::eRegexSynth); + cate->Clear(eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth); return true; } @@ -3209,7 +3209,7 @@ DataVisualization::Categories::Get(ConstString(category_name.c_str()), category); if (category->AnyMatches(type_name, - FormatCategory::eFilter | FormatCategory::eRegexFilter, + eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter, false)) { if (error) @@ -3386,7 +3386,7 @@ DataVisualization::Categories::Get(ConstString(category_name.c_str()), category); if (category->AnyMatches(type_name, - FormatCategory::eSynth | FormatCategory::eRegexSynth, + eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth, false)) { if (error) Modified: lldb/trunk/source/Core/DataVisualization.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataVisualization.cpp?rev=138307&r1=138306&r2=138307&view=diff ============================================================================== --- lldb/trunk/source/Core/DataVisualization.cpp (original) +++ lldb/trunk/source/Core/DataVisualization.cpp Mon Aug 22 18:45:15 2011 @@ -27,7 +27,7 @@ } void -DataVisualization::ForceUpdate() +DataVisualization::ForceUpdate () { GetFormatManager().Changed(); } @@ -39,62 +39,62 @@ } bool -DataVisualization::ValueFormats::Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry) +DataVisualization::ValueFormats::Get (ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry) { return GetFormatManager().GetValueNavigator().Get(valobj,entry, use_dynamic); } void -DataVisualization::ValueFormats::Add(const ConstString &type, const lldb::ValueFormatSP &entry) +DataVisualization::ValueFormats::Add (const ConstString &type, const lldb::ValueFormatSP &entry) { GetFormatManager().GetValueNavigator().Add(FormatManager::GetValidTypeName(type),entry); } bool -DataVisualization::ValueFormats::Delete(const ConstString &type) +DataVisualization::ValueFormats::Delete (const ConstString &type) { return GetFormatManager().GetValueNavigator().Delete(type); } void -DataVisualization::ValueFormats::Clear() +DataVisualization::ValueFormats::Clear () { GetFormatManager().GetValueNavigator().Clear(); } void -DataVisualization::ValueFormats::LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton) +DataVisualization::ValueFormats::LoopThrough (ValueFormat::ValueCallback callback, void* callback_baton) { GetFormatManager().GetValueNavigator().LoopThrough(callback, callback_baton); } uint32_t -DataVisualization::ValueFormats::GetCount() +DataVisualization::ValueFormats::GetCount () { return GetFormatManager().GetValueNavigator().GetCount(); } bool -DataVisualization::GetSummaryFormat(ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - lldb::SummaryFormatSP& entry) +DataVisualization::GetSummaryFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic, + lldb::SummaryFormatSP& entry) { return GetFormatManager().Get(valobj, entry, use_dynamic); } bool -DataVisualization::GetSyntheticChildren(ValueObject& valobj, - lldb::DynamicValueType use_dynamic, - lldb::SyntheticChildrenSP& entry) +DataVisualization::GetSyntheticChildren (ValueObject& valobj, + lldb::DynamicValueType use_dynamic, + lldb::SyntheticChildrenSP& entry) { return GetFormatManager().Get(valobj, entry, use_dynamic); } bool -DataVisualization::AnyMatches(ConstString type_name, - FormatCategory::FormatCategoryItems items, - bool only_enabled, - const char** matching_category, - FormatCategory::FormatCategoryItems* matching_type) +DataVisualization::AnyMatches (ConstString type_name, + FormatCategory::FormatCategoryItems items, + bool only_enabled, + const char** matching_category, + FormatCategory::FormatCategoryItems* matching_type) { return GetFormatManager().AnyMatches(type_name, items, @@ -104,39 +104,39 @@ } bool -DataVisualization::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry) +DataVisualization::Categories::Get (const ConstString &category, lldb::FormatCategorySP &entry) { entry = GetFormatManager().Category(category); return true; } void -DataVisualization::Categories::Add(const ConstString &category) +DataVisualization::Categories::Add (const ConstString &category) { GetFormatManager().Category(category); } bool -DataVisualization::Categories::Delete(const ConstString &category) +DataVisualization::Categories::Delete (const ConstString &category) { GetFormatManager().DisableCategory(category); - return GetFormatManager().GetCategories().Delete(category); + return GetFormatManager().DeleteCategory(category); } void -DataVisualization::Categories::Clear() +DataVisualization::Categories::Clear () { - GetFormatManager().GetCategories().Clear(); + GetFormatManager().ClearCategories(); } void -DataVisualization::Categories::Clear(ConstString &category) +DataVisualization::Categories::Clear (ConstString &category) { GetFormatManager().Category(category)->ClearSummaries(); } void -DataVisualization::Categories::Enable(ConstString& category) +DataVisualization::Categories::Enable (ConstString& category) { if (GetFormatManager().Category(category)->IsEnabled() == false) GetFormatManager().EnableCategory(category); @@ -148,56 +148,56 @@ } void -DataVisualization::Categories::Disable(ConstString& category) +DataVisualization::Categories::Disable (ConstString& category) { if (GetFormatManager().Category(category)->IsEnabled() == true) GetFormatManager().DisableCategory(category); } void -DataVisualization::Categories::LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton) +DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton) { GetFormatManager().LoopThroughCategories(callback, callback_baton); } uint32_t -DataVisualization::Categories::GetCount() +DataVisualization::Categories::GetCount () { - return GetFormatManager().GetCategories().GetCount(); + return GetFormatManager().GetCategoriesCount(); } bool -DataVisualization::NamedSummaryFormats::Get(const ConstString &type, lldb::SummaryFormatSP &entry) +DataVisualization::NamedSummaryFormats::Get (const ConstString &type, lldb::SummaryFormatSP &entry) { return GetFormatManager().GetNamedSummaryNavigator().Get(type,entry); } void -DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const lldb::SummaryFormatSP &entry) +DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::SummaryFormatSP &entry) { GetFormatManager().GetNamedSummaryNavigator().Add(FormatManager::GetValidTypeName(type),entry); } bool -DataVisualization::NamedSummaryFormats::Delete(const ConstString &type) +DataVisualization::NamedSummaryFormats::Delete (const ConstString &type) { return GetFormatManager().GetNamedSummaryNavigator().Delete(type); } void -DataVisualization::NamedSummaryFormats::Clear() +DataVisualization::NamedSummaryFormats::Clear () { GetFormatManager().GetNamedSummaryNavigator().Clear(); } void -DataVisualization::NamedSummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton) +DataVisualization::NamedSummaryFormats::LoopThrough (SummaryFormat::SummaryCallback callback, void* callback_baton) { GetFormatManager().GetNamedSummaryNavigator().LoopThrough(callback, callback_baton); } uint32_t -DataVisualization::NamedSummaryFormats::GetCount() +DataVisualization::NamedSummaryFormats::GetCount () { return GetFormatManager().GetNamedSummaryNavigator().GetCount(); -} \ No newline at end of file +} Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=138307&r1=138306&r2=138307&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Mon Aug 22 18:45:15 2011 @@ -228,17 +228,17 @@ void FormatCategory::Clear (FormatCategoryItems items) { - if ( (items & eSummary) == eSummary ) + if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary ) m_summary_nav->Clear(); - if ( (items & eRegexSummary) == eRegexSummary ) + if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary ) m_regex_summary_nav->Clear(); - if ( (items & eFilter) == eFilter ) + if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter ) m_filter_nav->Clear(); - if ( (items & eRegexFilter) == eRegexFilter ) + if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter ) m_regex_filter_nav->Clear(); - if ( (items & eSynth) == eSynth ) + if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth ) m_synth_nav->Clear(); - if ( (items & eRegexSynth) == eRegexSynth ) + if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth ) m_regex_synth_nav->Clear(); } @@ -247,17 +247,17 @@ FormatCategoryItems items) { bool success = false; - if ( (items & eSummary) == eSummary ) + if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary ) success = m_summary_nav->Delete(name) || success; - if ( (items & eRegexSummary) == eRegexSummary ) + if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary ) success = m_regex_summary_nav->Delete(name) || success; - if ( (items & eFilter) == eFilter ) + if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter ) success = m_filter_nav->Delete(name) || success; - if ( (items & eRegexFilter) == eRegexFilter ) + if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter ) success = m_regex_filter_nav->Delete(name) || success; - if ( (items & eSynth) == eSynth ) + if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth ) success = m_synth_nav->Delete(name) || success; - if ( (items & eRegexSynth) == eRegexSynth ) + if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth ) success = m_regex_synth_nav->Delete(name) || success; return success; } @@ -266,17 +266,17 @@ FormatCategory::GetCount (FormatCategoryItems items) { uint32_t count = 0; - if ( (items & eSummary) == eSummary ) + if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary ) count += m_summary_nav->GetCount(); - if ( (items & eRegexSummary) == eRegexSummary ) + if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary ) count += m_regex_summary_nav->GetCount(); - if ( (items & eFilter) == eFilter ) + if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter ) count += m_filter_nav->GetCount(); - if ( (items & eRegexFilter) == eRegexFilter ) + if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter ) count += m_regex_filter_nav->GetCount(); - if ( (items & eSynth) == eSynth ) + if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth ) count += m_synth_nav->GetCount(); - if ( (items & eRegexSynth) == eRegexSynth ) + if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth ) count += m_regex_synth_nav->GetCount(); return count; } @@ -295,69 +295,69 @@ SyntheticFilter::SharedPointer filter; SyntheticScriptProvider::SharedPointer synth; - if ( (items & eSummary) == eSummary ) + if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary ) { if (m_summary_nav->Get(type_name, summary)) { if (matching_category) *matching_category = m_name.c_str(); if (matching_type) - *matching_type = eSummary; + *matching_type = eFormatCategoryItemSummary; return true; } } - if ( (items & eRegexSummary) == eRegexSummary ) + if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary ) { if (m_regex_summary_nav->Get(type_name, summary)) { if (matching_category) *matching_category = m_name.c_str(); if (matching_type) - *matching_type = eRegexSummary; + *matching_type = eFormatCategoryItemRegexSummary; return true; } } - if ( (items & eFilter) == eFilter ) + if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter ) { if (m_filter_nav->Get(type_name, filter)) { if (matching_category) *matching_category = m_name.c_str(); if (matching_type) - *matching_type = eFilter; + *matching_type = eFormatCategoryItemFilter; return true; } } - if ( (items & eRegexFilter) == eRegexFilter ) + if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter ) { if (m_regex_filter_nav->Get(type_name, filter)) { if (matching_category) *matching_category = m_name.c_str(); if (matching_type) - *matching_type = eRegexFilter; + *matching_type = eFormatCategoryItemRegexFilter; return true; } } - if ( (items & eSynth) == eSynth ) + if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth ) { if (m_synth_nav->Get(type_name, synth)) { if (matching_category) *matching_category = m_name.c_str(); if (matching_type) - *matching_type = eSynth; + *matching_type = eFormatCategoryItemSynth; return true; } } - if ( (items & eRegexSynth) == eRegexSynth ) + if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth ) { if (m_regex_synth_nav->Get(type_name, synth)) { if (matching_category) *matching_category = m_name.c_str(); if (matching_type) - *matching_type = eRegexSynth; + *matching_type = eFormatCategoryItemRegexSynth; return true; } } From granata.enrico at gmail.com Mon Aug 22 19:32:52 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Tue, 23 Aug 2011 00:32:52 -0000 Subject: [Lldb-commits] [lldb] r138315 - in /lldb/trunk: include/lldb/ include/lldb/Core/ scripts/Python/ source/Commands/ source/Core/ test/functionalities/data-formatter/data-formatter-categories/ test/functionalities/data-formatter/data-formatter-globals/ test/functionalities/data-formatter/data-formatter-script/ test/functionalities/data-formatter/data-formatter-synth/ Message-ID: <20110823003252.AD25C2A6C12C@llvm.org> Author: enrico Date: Mon Aug 22 19:32:52 2011 New Revision: 138315 URL: http://llvm.org/viewvc/llvm-project?rev=138315&view=rev Log: Additional code cleanups ; Short option name for --python-script in type summary add moved from -s to -o (this is a preliminary step in moving the short option for --summary-string from -f to -s) ; Accordingly updated the test suite Modified: lldb/trunk/include/lldb/Core/FormatClasses.h lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/include/lldb/lldb-private-enumerations.h lldb/trunk/scripts/Python/python-wrapper.swig lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Core/DataVisualization.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/FormatClasses.cpp lldb/trunk/source/Core/FormatManager.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Modified: lldb/trunk/include/lldb/Core/FormatClasses.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatClasses.h (original) +++ lldb/trunk/include/lldb/Core/FormatClasses.h Mon Aug 22 19:32:52 2011 @@ -31,10 +31,8 @@ #include "lldb/lldb-public.h" #include "lldb/lldb-enumerations.h" -#include "lldb/API/SBValue.h" #include "lldb/Core/ValueObject.h" #include "lldb/Interpreter/ScriptInterpreterPython.h" -#include "lldb/Symbol/SymbolContext.h" namespace lldb_private { @@ -48,13 +46,7 @@ ValueFormat (lldb::Format f = lldb::eFormatInvalid, bool casc = false, bool skipptr = false, - bool skipref = false) : - m_cascades(casc), - m_skip_pointers(skipptr), - m_skip_references(skipref), - m_format (f) - { - } + bool skipref = false); typedef lldb::SharedPtr::Type SharedPointer; typedef bool(*ValueCallback)(void*, ConstString, const lldb::ValueFormatSP&); @@ -335,25 +327,7 @@ } virtual lldb::ValueObjectSP - GetChildAtIndex (uint32_t idx, bool can_create) - { - if (m_wrapper == NULL || m_interpreter == NULL) - return lldb::ValueObjectSP(); - - PyObject* py_return = (PyObject*)m_interpreter->GetChildAtIndex(m_wrapper, idx); - if (py_return == NULL || py_return == Py_None) - { - Py_XDECREF(py_return); - return lldb::ValueObjectSP(); - } - - lldb::SBValue *sb_ptr = m_interpreter->CastPyObjectToSBValue(py_return); - - if (py_return == NULL || sb_ptr == NULL) - return lldb::ValueObjectSP(); - - return sb_ptr->m_opaque_sp; - } + GetChildAtIndex (uint32_t idx, bool can_create); virtual void Update() @@ -383,122 +357,121 @@ } }; - -struct SyntheticArrayRange -{ -private: - int m_low; - int m_high; - SyntheticArrayRange* m_next; +class SyntheticArrayView : public SyntheticChildren +{ public: - SyntheticArrayRange () : + struct SyntheticArrayRange + { + private: + int m_low; + int m_high; + SyntheticArrayRange* m_next; + + public: + + SyntheticArrayRange () : m_low(-1), m_high(-2), m_next(NULL) - {} - - SyntheticArrayRange (int L) : + {} + + SyntheticArrayRange (int L) : m_low(L), m_high(L), m_next(NULL) - {} - - SyntheticArrayRange (int L, int H) : + {} + + SyntheticArrayRange (int L, int H) : m_low(L), m_high(H), m_next(NULL) - {} - - SyntheticArrayRange (int L, int H, SyntheticArrayRange* N) : + {} + + SyntheticArrayRange (int L, int H, SyntheticArrayRange* N) : m_low(L), m_high(H), m_next(N) - {} - - inline int - GetLow () - { - return m_low; - } - - inline int - GetHigh () - { - return m_high; - } - - inline void - SetLow (int L) - { - m_low = L; - } - - inline void - SetHigh (int H) - { - m_high = H; - } - - inline int - GetSelfCount() - { - return GetHigh() - GetLow() + 1; - } - - int - GetCount() - { - int count = GetSelfCount(); - if (m_next) - count += m_next->GetCount(); - return count; - } - - inline SyntheticArrayRange* - GetNext() - { - return m_next; - } - - void - SetNext(SyntheticArrayRange* N) - { - if (m_next) - delete m_next; - m_next = N; - } - - void - SetNext(int L, int H) - { - if (m_next) - delete m_next; - m_next = new SyntheticArrayRange(L, H); - } - - void - SetNext(int L) - { - if (m_next) + {} + + inline int + GetLow () + { + return m_low; + } + + inline int + GetHigh () + { + return m_high; + } + + inline void + SetLow (int L) + { + m_low = L; + } + + inline void + SetHigh (int H) + { + m_high = H; + } + + inline int + GetSelfCount() + { + return GetHigh() - GetLow() + 1; + } + + int + GetCount() + { + int count = GetSelfCount(); + if (m_next) + count += m_next->GetCount(); + return count; + } + + inline SyntheticArrayRange* + GetNext() + { + return m_next; + } + + void + SetNext(SyntheticArrayRange* N) + { + if (m_next) + delete m_next; + m_next = N; + } + + void + SetNext(int L, int H) + { + if (m_next) + delete m_next; + m_next = new SyntheticArrayRange(L, H); + } + + void + SetNext(int L) + { + if (m_next) + delete m_next; + m_next = new SyntheticArrayRange(L); + } + + ~SyntheticArrayRange() + { delete m_next; - m_next = new SyntheticArrayRange(L); - } - - ~SyntheticArrayRange() - { - delete m_next; - m_next = NULL; - } - -}; + m_next = NULL; + } + + }; -class SyntheticArrayView : public SyntheticChildren -{ - SyntheticArrayRange m_head; - SyntheticArrayRange *m_tail; -public: SyntheticArrayView(bool casc = false, bool skipptr = false, bool skipref = false) : @@ -524,29 +497,7 @@ } const int - GetRealIndexForIndex(int i) - { - if (i >= GetCount()) - return -1; - - SyntheticArrayRange* ptr = &m_head; - - int residual = i; - - while(ptr && ptr != m_tail) - { - if (residual >= ptr->GetSelfCount()) - { - residual -= ptr->GetSelfCount(); - ptr = ptr->GetNext(); - } - - return ptr->GetLow() + residual; - } - - return -1; - - } + GetRealIndexForIndex(int i); bool IsScripted() @@ -592,20 +543,7 @@ Update() {} virtual uint32_t - GetIndexOfChildWithName (const ConstString &name_cs) - { - const char* name_cstr = name_cs.GetCString(); - if (*name_cstr != '[') - return UINT32_MAX; - std::string name(name_cstr+1); - if (name[name.size()-1] != ']') - return UINT32_MAX; - name = name.erase(name.size()-1,1); - int index = Args::StringToSInt32 (name.c_str(), -1); - if (index < 0) - return UINT32_MAX; - return index; - } + GetIndexOfChildWithName (const ConstString &name_cs); typedef lldb::SharedPtr::Type SharedPointer; @@ -616,6 +554,9 @@ { return SyntheticChildrenFrontEnd::SharedPointer(new FrontEnd(this, backend)); } +private: + SyntheticArrayRange m_head; + SyntheticArrayRange *m_tail; }; @@ -635,15 +576,7 @@ bool skipref = false, bool nochildren = true, bool novalue = true, - bool oneliner = false) : - m_cascades(casc), - m_skip_pointers(skipptr), - m_skip_references(skipref), - m_dont_show_children(nochildren), - m_dont_show_value(novalue), - m_show_members_oneliner(oneliner) - { - } + bool oneliner = false); bool Cascades() const @@ -707,11 +640,7 @@ bool nochildren = true, bool novalue = true, bool oneliner = false, - std::string f = "") : - SummaryFormat(casc,skipptr,skipref,nochildren,novalue,oneliner), - m_format(f) - { - } + std::string f = ""); std::string GetFormat() const @@ -745,12 +674,7 @@ bool novalue = true, bool oneliner = false, std::string fname = "", - std::string pscri = "") : - SummaryFormat(casc,skipptr,skipref,nochildren,novalue,oneliner), - m_function_name(fname), - m_python_script(pscri) - { - } + std::string pscri = ""); std::string GetFunctionName() const Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Mon Aug 22 19:32:52 2011 @@ -115,39 +115,14 @@ Get (ValueObject& valobj, lldb::SummaryFormatSP& entry, lldb::DynamicValueType use_dynamic, - uint32_t* reason = NULL) - { - if (!IsEnabled()) - return false; - if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason)) - return true; - bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason); - if (regex && reason) - *reason |= lldb::eFormatterChoiceCriterionRegularExpressionSummary; - return regex; - } + uint32_t* reason = NULL); bool Get (ValueObject& valobj, lldb::SyntheticChildrenSP& entry, lldb::DynamicValueType use_dynamic, uint32_t* reason = NULL); - - // just a shortcut for GetSummaryNavigator()->Clear; GetRegexSummaryNavigator()->Clear() - void - ClearSummaries () - { - Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); - } - - // just a shortcut for (GetSummaryNavigator()->Delete(name) || GetRegexSummaryNavigator()->Delete(name)) - bool - DeleteSummaries (ConstString name) - { - return Delete(name, (eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary)); - } - - + void Clear (FormatCategoryItems items = ALL_ITEM_TYPES); @@ -275,19 +250,6 @@ m_active_categories.push_front(category); } - class delete_matching_categories - { - lldb::FormatCategorySP ptr; - public: - delete_matching_categories(lldb::FormatCategorySP p) : ptr(p) - {} - - bool operator()(const lldb::FormatCategorySP& other) - { - return ptr.get() == other.get(); - } - }; - void Disable (KeyType category_name) { @@ -329,22 +291,7 @@ FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, bool only_enabled = true, const char** matching_category = NULL, - FormatCategory::FormatCategoryItems* matching_type = NULL) - { - Mutex::Locker(m_map_mutex); - - MapIterator pos, end = m_map.end(); - for (pos = m_map.begin(); pos != end; pos++) - { - if (pos->second->AnyMatches(type_name, - items, - only_enabled, - matching_category, - matching_type)) - return true; - } - return false; - } + FormatCategory::FormatCategoryItems* matching_type = NULL); uint32_t GetCount () @@ -355,49 +302,28 @@ bool Get (ValueObject& valobj, lldb::SummaryFormatSP& entry, - lldb::DynamicValueType use_dynamic) - { - Mutex::Locker(m_map_mutex); - - uint32_t reason_why; - ActiveCategoriesIterator begin, end = m_active_categories.end(); - - for (begin = m_active_categories.begin(); begin != end; begin++) - { - lldb::FormatCategorySP category = *begin; - lldb::SummaryFormatSP current_format; - if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) - continue; - entry = current_format; - return true; - } - return false; - } + lldb::DynamicValueType use_dynamic); bool Get (ValueObject& valobj, lldb::SyntheticChildrenSP& entry, - lldb::DynamicValueType use_dynamic) + lldb::DynamicValueType use_dynamic); + +private: + + class delete_matching_categories { - Mutex::Locker(m_map_mutex); - - uint32_t reason_why; - - ActiveCategoriesIterator begin, end = m_active_categories.end(); + lldb::FormatCategorySP ptr; + public: + delete_matching_categories(lldb::FormatCategorySP p) : ptr(p) + {} - for (begin = m_active_categories.begin(); begin != end; begin++) + bool operator()(const lldb::FormatCategorySP& other) { - lldb::FormatCategorySP category = *begin; - lldb::SyntheticChildrenSP current_format; - if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) - continue; - entry = current_format; - return true; + return ptr.get() == other.get(); } - return false; - } + }; -private: Mutex m_map_mutex; IFormatChangeListener* listener; @@ -425,14 +351,10 @@ class FormatManager : public IFormatChangeListener { -private: - typedef FormatNavigator ValueNavigator; - typedef ValueNavigator::MapType ValueMap; typedef FormatMap NamedSummariesMap; typedef CategoryMap::MapType::iterator CategoryMapIterator; - public: typedef CategoryMap::CallbackType CategoryCallback; @@ -498,20 +420,7 @@ lldb::FormatCategorySP Category (const ConstString& category_name, - bool can_create = true) - { - if (!category_name) - return Category(m_default_category_name); - lldb::FormatCategorySP category; - if (m_categories_map.Get(category_name, category)) - return category; - - if (!can_create) - return lldb::FormatCategorySP(); - - m_categories_map.Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name.AsCString()))); - return Category(category_name); - } + bool can_create = true); bool Get (ValueObject& valobj, @@ -520,6 +429,7 @@ { return m_categories_map.Get(valobj, entry, use_dynamic); } + bool Get (ValueObject& valobj, lldb::SyntheticChildrenSP& entry, Modified: lldb/trunk/include/lldb/lldb-private-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-enumerations.h?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-private-enumerations.h Mon Aug 22 19:32:52 2011 @@ -207,11 +207,11 @@ typedef enum FormatCategoryItem { eFormatCategoryItemSummary = 0x0001, - eFormatCategoryItemRegexSummary = 0x1001, - eFormatCategoryItemFilter = 0x0002, - eFormatCategoryItemRegexFilter = 0x1002, - eFormatCategoryItemSynth = 0x0004, - eFormatCategoryItemRegexSynth = 0x1004, + eFormatCategoryItemRegexSummary = 0x0002, + eFormatCategoryItemFilter = 0x0004, + eFormatCategoryItemRegexFilter = 0x0008, + eFormatCategoryItemSynth = 0x0010, + eFormatCategoryItemRegexSynth = 0x0020, } FormatCategoryItem; } // namespace lldb Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Mon Aug 22 19:32:52 2011 @@ -679,6 +679,4 @@ return retval; } -#undef RETURN_RETVAL - %} Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Mon Aug 22 19:32:52 2011 @@ -627,7 +627,7 @@ case 'n': m_name = new ConstString(option_arg); break; - case 's': + case 'o': m_python_script = std::string(option_arg); m_is_add_script = true; break; @@ -1082,7 +1082,7 @@ { LLDB_OPT_SET_ALL, false, "regex", 'x', no_argument, NULL, 0, eArgTypeNone, "Type names are actually regular expressions."}, { LLDB_OPT_SET_1 , true, "inline-children", 'c', no_argument, NULL, 0, eArgTypeNone, "If true, inline all child values into summary string."}, { LLDB_OPT_SET_2 , true, "summary-string", 'f', required_argument, NULL, 0, eArgTypeSummaryString, "Summary string used to display text and object contents."}, - { LLDB_OPT_SET_3, false, "python-script", 's', required_argument, NULL, 0, eArgTypeName, "Give a one-liner Python script as part of the command."}, + { LLDB_OPT_SET_3, false, "python-script", 'o', required_argument, NULL, 0, eArgTypeName, "Give a one-liner Python script as part of the command."}, { LLDB_OPT_SET_3, false, "python-function", 'F', required_argument, NULL, 0, eArgTypeName, "Give the name of a Python function to use for this type."}, { LLDB_OPT_SET_3, false, "input-python", 'P', no_argument, NULL, 0, eArgTypeNone, "Input Python code to use for this type manually."}, { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "expand", 'e', no_argument, NULL, 0, eArgTypeNone, "Expand aggregate data types to show children on separate lines."}, @@ -1228,7 +1228,8 @@ lldb::FormatCategorySP category; DataVisualization::Categories::Get(ConstString(m_options.m_category.c_str()), category); - bool delete_category = category->DeleteSummaries(typeCS); + bool delete_category = category->Delete(typeCS, + eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); bool delete_named = DataVisualization::NamedSummaryFormats::Delete(typeCS); if (delete_category || delete_named) @@ -1360,7 +1361,7 @@ } else DataVisualization::Categories::Get(ConstString(NULL), category); - category->ClearSummaries(); + category->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); } DataVisualization::NamedSummaryFormats::Clear(); @@ -3436,6 +3437,32 @@ m_arguments.push_back (type_arg); + SetHelpLong( + "Some examples of using this command.\n" + "We use as reference the following snippet of code:\n" + "\n" + "class Foo {;\n" + " int a;\n" + " int b;\n" + " int c;\n" + " int d;\n" + " int e;\n" + " int f;\n" + " int g;\n" + " int h;\n" + " int i;\n" + "} \n" + "Typing:\n" + "type filter add --child a -- child g Foo\n" + "frame variable a_foo\n" + "will produce an output where only a and b are displayed\n" + "Other children of a_foo (b,c,d,e,f,h and i) are available by asking for them, as in:\n" + "frame variable a_foo.b a_foo.c ... a_foo.i\n" + "\n" + "Use option --raw to frame variable prevails on the filter\n" + "frame variable a_foo --raw\n" + "shows all the children of a_foo (a thru i) as if no filter was defined\n" + ); } ~CommandObjectTypeFilterAdd () Modified: lldb/trunk/source/Core/DataVisualization.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataVisualization.cpp?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/source/Core/DataVisualization.cpp (original) +++ lldb/trunk/source/Core/DataVisualization.cpp Mon Aug 22 19:32:52 2011 @@ -132,7 +132,7 @@ void DataVisualization::Categories::Clear (ConstString &category) { - GetFormatManager().Category(category)->ClearSummaries(); + GetFormatManager().Category(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); } void Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Aug 22 19:32:52 2011 @@ -694,20 +694,13 @@ } } -#define IFERROR_PRINT_IT if (error.Fail()) \ -{ \ - if (log) \ - log->Printf("ERROR: %s\n", error.AsCString("unknown")); \ - break; \ -} - static bool -ScanFormatDescriptor(const char* var_name_begin, - const char* var_name_end, - const char** var_name_final, - const char** percent_position, - lldb::Format* custom_format, - ValueObject::ValueObjectRepresentationStyle* val_obj_display) +ScanFormatDescriptor (const char* var_name_begin, + const char* var_name_end, + const char** var_name_final, + const char** percent_position, + lldb::Format* custom_format, + ValueObject::ValueObjectRepresentationStyle* val_obj_display) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); *percent_position = ::strchr(var_name_begin,'%'); @@ -766,15 +759,15 @@ } static bool -ScanBracketedRange(const char* var_name_begin, - const char* var_name_end, - const char* var_name_final, - const char** open_bracket_position, - const char** separator_position, - const char** close_bracket_position, - const char** var_name_final_if_array_range, - int64_t* index_lower, - int64_t* index_higher) +ScanBracketedRange (const char* var_name_begin, + const char* var_name_end, + const char* var_name_final, + const char** open_bracket_position, + const char** separator_position, + const char** close_bracket_position, + const char** var_name_final_if_array_range, + int64_t* index_lower, + int64_t* index_higher) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); *open_bracket_position = ::strchr(var_name_begin,'['); @@ -829,12 +822,12 @@ static ValueObjectSP -ExpandExpressionPath(ValueObject* valobj, - StackFrame* frame, - bool* do_deref_pointer, - const char* var_name_begin, - const char* var_name_final, - Error& error) +ExpandExpressionPath (ValueObject* valobj, + StackFrame* frame, + bool* do_deref_pointer, + const char* var_name_begin, + const char* var_name_final, + Error& error) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); StreamString sstring; @@ -870,10 +863,10 @@ } static ValueObjectSP -ExpandIndexedExpression(ValueObject* valobj, - uint32_t index, - StackFrame* frame, - bool deref_pointer) +ExpandIndexedExpression (ValueObject* valobj, + uint32_t index, + StackFrame* frame, + bool deref_pointer) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); const char* ptr_deref_format = "[%d]"; @@ -1153,7 +1146,12 @@ // to get to the target ValueObject Error error; target = target->Dereference(error).get(); - IFERROR_PRINT_IT + if (error.Fail()) + { + if (log) + log->Printf("ERROR: %s\n", error.AsCString("unknown")); \ + break; + } do_deref_pointer = false; } Modified: lldb/trunk/source/Core/FormatClasses.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatClasses.cpp (original) +++ lldb/trunk/source/Core/FormatClasses.cpp Mon Aug 22 19:32:52 2011 @@ -30,6 +30,17 @@ using namespace lldb; using namespace lldb_private; +ValueFormat::ValueFormat (lldb::Format f, + bool casc, + bool skipptr, + bool skipref) : + m_cascades(casc), + m_skip_pointers(skipptr), + m_skip_references(skipref), + m_format (f) +{ +} + std::string ValueFormat::FormatObject(lldb::ValueObjectSP object) { @@ -54,6 +65,39 @@ } } +SummaryFormat::SummaryFormat(bool casc, + bool skipptr, + bool skipref, + bool nochildren, + bool novalue, + bool oneliner) : + m_cascades(casc), + m_skip_pointers(skipptr), + m_skip_references(skipref), + m_dont_show_children(nochildren), + m_dont_show_value(novalue), + m_show_members_oneliner(oneliner) +{ +} + +StringSummaryFormat::StringSummaryFormat(bool casc, + bool skipptr, + bool skipref, + bool nochildren, + bool novalue, + bool oneliner, + std::string f) : + SummaryFormat(casc, + skipptr, + skipref, + nochildren, + novalue, + oneliner), + m_format(f) +{ +} + + std::string StringSummaryFormat::FormatObject(lldb::ValueObjectSP object) { @@ -119,6 +163,26 @@ return sstr.GetString(); } +ScriptSummaryFormat::ScriptSummaryFormat(bool casc, + bool skipptr, + bool skipref, + bool nochildren, + bool novalue, + bool oneliner, + std::string fname, + std::string pscri) : + SummaryFormat(casc, + skipptr, + skipref, + nochildren, + novalue, + oneliner), + m_function_name(fname), + m_python_script(pscri) +{ +} + + std::string ScriptSummaryFormat::FormatObject(lldb::ValueObjectSP object) { @@ -245,6 +309,27 @@ m_wrapper = (PyObject*)m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend); } +lldb::ValueObjectSP +SyntheticScriptProvider::FrontEnd::GetChildAtIndex (uint32_t idx, bool can_create) +{ + if (m_wrapper == NULL || m_interpreter == NULL) + return lldb::ValueObjectSP(); + + PyObject* py_return = (PyObject*)m_interpreter->GetChildAtIndex(m_wrapper, idx); + if (py_return == NULL || py_return == Py_None) + { + Py_XDECREF(py_return); + return lldb::ValueObjectSP(); + } + + lldb::SBValue *sb_ptr = m_interpreter->CastPyObjectToSBValue(py_return); + + if (py_return == NULL || sb_ptr == NULL) + return lldb::ValueObjectSP(); + + return sb_ptr->m_opaque_sp; +} + std::string SyntheticScriptProvider::GetDescription() { @@ -257,3 +342,43 @@ return sstr.GetString(); } + +const int +SyntheticArrayView::GetRealIndexForIndex(int i) +{ + if (i >= GetCount()) + return -1; + + SyntheticArrayRange* ptr = &m_head; + + int residual = i; + + while(ptr && ptr != m_tail) + { + if (residual >= ptr->GetSelfCount()) + { + residual -= ptr->GetSelfCount(); + ptr = ptr->GetNext(); + } + + return ptr->GetLow() + residual; + } + + return -1; +} + +uint32_t +SyntheticArrayView::FrontEnd::GetIndexOfChildWithName (const ConstString &name_cs) +{ + const char* name_cstr = name_cs.GetCString(); + if (*name_cstr != '[') + return UINT32_MAX; + std::string name(name_cstr+1); + if (name[name.size()-1] != ']') + return UINT32_MAX; + name = name.erase(name.size()-1,1); + int index = Args::StringToSInt32 (name.c_str(), -1); + if (index < 0) + return UINT32_MAX; + return index; +} \ No newline at end of file Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Mon Aug 22 19:32:52 2011 @@ -169,6 +169,22 @@ {} bool +FormatCategory::Get (ValueObject& valobj, + lldb::SummaryFormatSP& entry, + lldb::DynamicValueType use_dynamic, + uint32_t* reason) +{ + if (!IsEnabled()) + return false; + if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason)) + return true; + bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason); + if (regex && reason) + *reason |= lldb::eFormatterChoiceCriterionRegularExpressionSummary; + return regex; +} + +bool FormatCategory::Get(ValueObject& valobj, lldb::SyntheticChildrenSP& entry, lldb::DynamicValueType use_dynamic, @@ -364,6 +380,73 @@ return false; } +bool +CategoryMap::AnyMatches (ConstString type_name, + FormatCategory::FormatCategoryItems items, + bool only_enabled, + const char** matching_category, + FormatCategory::FormatCategoryItems* matching_type) +{ + Mutex::Locker(m_map_mutex); + + MapIterator pos, end = m_map.end(); + for (pos = m_map.begin(); pos != end; pos++) + { + if (pos->second->AnyMatches(type_name, + items, + only_enabled, + matching_category, + matching_type)) + return true; + } + return false; +} + +bool +CategoryMap::Get (ValueObject& valobj, + lldb::SummaryFormatSP& entry, + lldb::DynamicValueType use_dynamic) +{ + Mutex::Locker(m_map_mutex); + + uint32_t reason_why; + ActiveCategoriesIterator begin, end = m_active_categories.end(); + + for (begin = m_active_categories.begin(); begin != end; begin++) + { + lldb::FormatCategorySP category = *begin; + lldb::SummaryFormatSP current_format; + if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) + continue; + entry = current_format; + return true; + } + return false; +} + +bool +CategoryMap::Get (ValueObject& valobj, + lldb::SyntheticChildrenSP& entry, + lldb::DynamicValueType use_dynamic) +{ + Mutex::Locker(m_map_mutex); + + uint32_t reason_why; + + ActiveCategoriesIterator begin, end = m_active_categories.end(); + + for (begin = m_active_categories.begin(); begin != end; begin++) + { + lldb::FormatCategorySP category = *begin; + lldb::SyntheticChildrenSP current_format; + if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) + continue; + entry = current_format; + return true; + } + return false; +} + void CategoryMap::LoopThrough(CallbackType callback, void* param) { @@ -398,6 +481,23 @@ } } +lldb::FormatCategorySP +FormatManager::Category (const ConstString& category_name, + bool can_create) +{ + if (!category_name) + return Category(m_default_category_name); + lldb::FormatCategorySP category; + if (m_categories_map.Get(category_name, category)) + return category; + + if (!can_create) + return lldb::FormatCategorySP(); + + m_categories_map.Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name.AsCString()))); + return Category(category_name); +} + lldb::Format FormatManager::GetSingleItemFormat(lldb::Format vector_format) { Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py Mon Aug 22 19:32:52 2011 @@ -102,7 +102,7 @@ # Add summaries to two different categories and check that we can switch self.runCmd("type summary add -f \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1") - self.runCmd("type summary add -s \"return 'Area = ' + str( int(valobj.GetChildMemberWithName('w').GetValue()) * int(valobj.GetChildMemberWithName('h').GetValue()) );\" Rectangle -w Category2") + self.runCmd("type summary add --python-script \"return 'Area = ' + str( int(valobj.GetChildMemberWithName('w').GetValue()) * int(valobj.GetChildMemberWithName('h').GetValue()) );\" Rectangle -w Category2") # check that enable A B is the same as enable B enable A self.runCmd("type category enable Category1 Category2") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py Mon Aug 22 19:32:52 2011 @@ -67,7 +67,7 @@ substrs = ['(Point *) g_point_pointer =']) # Test Python code on resulting SBValue - self.runCmd("type summary add -s \"return 'x=' + str(valobj.GetChildMemberWithName('x').GetValue());\" Point") + self.runCmd("type summary add --python-script \"return 'x=' + str(valobj.GetChildMemberWithName('x').GetValue());\" Point") self.expect("target variable g_point", substrs = ['x=']) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py Mon Aug 22 19:32:52 2011 @@ -56,7 +56,7 @@ # Set the script here to ease the formatting script = 'a = valobj.GetChildMemberWithName(\'integer\'); a_val = a.GetValue(); str = \'Hello from Python, \' + a_val + \' time\'; return str + (\'!\' if a_val == \'1\' else \'s!\');' - self.runCmd("type summary add i_am_cool -s \"%s\"" % script) + self.runCmd("type summary add i_am_cool --python-script \"%s\"" % script) self.expect("frame variable one", substrs = ['Hello from Python', @@ -81,7 +81,7 @@ script = 'a = valobj.GetChildMemberWithName(\'integer\'); a_val = a.GetValue(); str = \'int says \' + a_val; return str;' # Check that changes in the script are immediately reflected - self.runCmd("type summary add i_am_cool -s \"%s\"" % script) + self.runCmd("type summary add i_am_cool --python-script \"%s\"" % script) self.expect("frame variable two", substrs = ['int says 1']) @@ -101,14 +101,14 @@ 'and float says 2.71']) # Force a failure for pointers - self.runCmd("type summary add i_am_cool -p -s \"%s\"" % script) + self.runCmd("type summary add i_am_cool -p --python-script \"%s\"" % script) self.expect("frame variable twoptr", matching=False, substrs = ['and float says 2.71']) script = 'return \'Python summary\''; - self.runCmd("type summary add --name test_summary -s \"%s\"" % script) + self.runCmd("type summary add --name test_summary --python-script \"%s\"" % script) # attach the Python named summary to someone self.runCmd("frame variable one --summary test_summary") @@ -140,7 +140,7 @@ # disable type summary for pointers, and make a Python regex summary self.runCmd("type summary add i_am_cool -p -f \"Text summary\"") - self.runCmd("type summary add -x cool -s \"%s\"" % script) + self.runCmd("type summary add -x cool --python-script \"%s\"" % script) # variables should stick to the type summary self.expect("frame variable one", Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py?rev=138315&r1=138314&r2=138315&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Mon Aug 22 19:32:52 2011 @@ -90,7 +90,7 @@ 'z = 8']) # Same output, but using Python - self.runCmd("type summary add BagOfInts -s \"return 'y='+valobj.GetChildMemberWithName('y').GetValue()\" -e") + self.runCmd("type summary add BagOfInts --python-script \"return 'y='+valobj.GetChildMemberWithName('y').GetValue()\" -e") self.expect('frame variable int_bag', substrs = ['y=7', 'x = 6', From johnny.chen at apple.com Mon Aug 22 20:00:14 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 23 Aug 2011 01:00:14 -0000 Subject: [Lldb-commits] [lldb] r138316 - in /lldb/trunk/test/lang/cpp: class_static/TestStaticVariables.py this/TestCPPThis.py Message-ID: <20110823010014.93F762A6C12C@llvm.org> Author: johnny Date: Mon Aug 22 20:00:14 2011 New Revision: 138316 URL: http://llvm.org/viewvc/llvm-project?rev=138316&view=rev Log: Add some expected failure decorators with radar numbers. Modified: lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py lldb/trunk/test/lang/cpp/this/TestCPPThis.py Modified: lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py?rev=138316&r1=138315&r2=138316&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py (original) +++ lldb/trunk/test/lang/cpp/class_static/TestStaticVariables.py Mon Aug 22 20:00:14 2011 @@ -23,12 +23,16 @@ self.static_variable_commands() @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + #rdar://problem/9980907 + @expectedFailureClang @python_api_test def test_with_dsym_and_python_api(self): """Test Python APIs on file and class static variables.""" self.buildDsym() self.static_variable_python() + #rdar://problem/9980907 + @expectedFailureClang @python_api_test def test_with_dwarf_and_python_api(self): """Test Python APIs on file and class static variables.""" Modified: lldb/trunk/test/lang/cpp/this/TestCPPThis.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/this/TestCPPThis.py?rev=138316&r1=138315&r2=138316&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/this/TestCPPThis.py (original) +++ lldb/trunk/test/lang/cpp/this/TestCPPThis.py Mon Aug 22 20:00:14 2011 @@ -9,11 +9,15 @@ mydir = os.path.join("lang", "cpp", "this") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + #rdar://problem/9962849 + @expectedFailureClang def test_with_dsym_and_run_command(self): """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" self.buildDsym() self.static_method_commands() + #rdar://problem/9962849 + @expectedFailureClang def test_with_dwarf_and_run_command(self): """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" self.buildDwarf() From granata.enrico at gmail.com Tue Aug 23 11:13:35 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Tue, 23 Aug 2011 16:13:35 -0000 Subject: [Lldb-commits] [lldb] r138331 - in /lldb/trunk: examples/summaries/ source/Commands/ test/functionalities/data-formatter/data-formatter-advanced/ test/functionalities/data-formatter/data-formatter-categories/ test/functionalities/data-formatter/data-formatter-cpp/ test/functionalities/data-formatter/data-formatter-globals/ test/functionalities/data-formatter/data-formatter-named-summaries/ test/functionalities/data-formatter/data-formatter-objc/ test/functionalities/data-formatter/data-formatter-python-synth/ test/func... Message-ID: <20110823161335.C76CC2A6C12C@llvm.org> Author: enrico Date: Tue Aug 23 11:13:35 2011 New Revision: 138331 URL: http://llvm.org/viewvc/llvm-project?rev=138331&view=rev Log: Short option for --summary-string in 'type summary add' is now -s. This might be a breaking change for those who have summaries defined. Modified: lldb/trunk/examples/summaries/essentials lldb/trunk/examples/summaries/lldb lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py lldb/trunk/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py Modified: lldb/trunk/examples/summaries/essentials URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/essentials?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/examples/summaries/essentials (original) +++ lldb/trunk/examples/summaries/essentials Tue Aug 23 11:13:35 2011 @@ -1,2 +1,5 @@ -type summary add -f "${var._M_dataplus._M_p}" std::string std::basic_string "std::basic_string,std::allocator >" -type summary add -f "\"${var%@}\"" "NSString *" +type summary add -s "${var._M_dataplus._M_p}" std::string std::basic_string "std::basic_string,std::allocator >" +type summary add -s "\"${var%@}\"" "NSString *" +type summary add -s "${svar%#} items" -e -x std::map< +type summary add -s "${svar%#} items" -e -x std::vector< +type summary add -s "${svar%#} items" -e -x std::list< Modified: lldb/trunk/examples/summaries/lldb URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/summaries/lldb?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/examples/summaries/lldb (original) +++ lldb/trunk/examples/summaries/lldb Tue Aug 23 11:13:35 2011 @@ -1,15 +1,15 @@ -type summary add -w lldb lldb_private::Error -f "Type: ${var.m_type%E}, Code: ${var.m_code}, Message: ${var.m_string}" -type summary add -w lldb lldb_private::ConstString -f "${var.m_string}" -type summary add -w lldb lldb_private::Language -f "${var.m_language%E}" -type summary add -w lldb lldb_private::RegularExpression -f "${var.m_re}" -type summary add -w lldb lldb_private::UserID -f "UserID(${var.m_uid})" -type summary add -w lldb lldb_private::ValueObject -f "${var.m_name}" -type summary add -w lldb lldb_private::ValueObjectSP -f "${var.ptr_.m_name}" -type summary add -w lldb lldb_private::ValueObjectRegister -f "${var.m_reg_info.name}" -type summary add -w lldb lldb_private::ClangExpression -f "{${var.m_expr_text}}" -type summary add -w lldb lldb_private::CommandObject -f "Command name: ${var.m_cmd_name}" -type summary add -w lldb lldb_private::Variable -f "${var.m_type.m_name} ${var.m_name}" -type summary add -w lldb lldb_private::StopInfo -f "ID: ${var.m_stop_id}, ${var.m_description}" -type summary add -w lldb lldb_private::FileSpec -f "file: ${var.m_filename} dir: ${var.m_directory}" -type summary add -w lldb -v lldb::ConnectionStatus -f "[enum=${var%E} val=${var%i}]" +type summary add -w lldb lldb_private::Error -s "Type: ${var.m_type%E}, Code: ${var.m_code}, Message: ${var.m_string}" +type summary add -w lldb lldb_private::ConstString -s "${var.m_string}" +type summary add -w lldb lldb_private::Language -s "${var.m_language%E}" +type summary add -w lldb lldb_private::RegularExpression -s "${var.m_re}" +type summary add -w lldb lldb_private::UserID -s "UserID(${var.m_uid})" +type summary add -w lldb lldb_private::ValueObject -s "${var.m_name}" +type summary add -w lldb lldb_private::ValueObjectSP -s "${var.ptr_.m_name}" +type summary add -w lldb lldb_private::ValueObjectRegister -s "${var.m_reg_info.name}" +type summary add -w lldb lldb_private::ClangExpression -s "{${var.m_expr_text}}" +type summary add -w lldb lldb_private::CommandObject -s "Command name: ${var.m_cmd_name}" +type summary add -w lldb lldb_private::Variable -s "${var.m_type.m_name} ${var.m_name}" +type summary add -w lldb lldb_private::StopInfo -s "ID: ${var.m_stop_id}, ${var.m_description}" +type summary add -w lldb lldb_private::FileSpec -s "file: ${var.m_filename} dir: ${var.m_directory}" +type summary add -w lldb -v lldb::ConnectionStatus -s "[enum=${var%E} val=${var%i}]" # Where '-v' tells type summary not to show the value itself, but just use the summary format. Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue Aug 23 11:13:35 2011 @@ -612,7 +612,7 @@ case 'c': m_one_liner = true; break; - case 'f': + case 's': m_format_string = std::string(option_arg); break; case 'p': @@ -1013,7 +1013,7 @@ "You can also add Python summaries, in which case you will use lldb public API to gather information from your variables" "and elaborate them to a meaningful summary inside a script written in Python. The variable object will be passed to your" "script as an SBValue object. The following example might help you when starting to use the Python summaries feature:\n" - "type summary add JustADemo -s \"value = valobj.GetChildMemberWithName('value'); return 'My value is ' + value.GetValue();\"\n" + "type summary add JustADemo -o \"value = valobj.GetChildMemberWithName('value'); return 'My value is ' + value.GetValue();\"\n" "If you prefer to type your scripts on multiple lines, you will use the -P option and then type your script, ending it with " "the word DONE on a line by itself to mark you're finished editing your code:\n" "(lldb)type summary add JustADemo -P\n" @@ -1081,7 +1081,7 @@ { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeNone, "Don't use this format for references-to-type objects."}, { LLDB_OPT_SET_ALL, false, "regex", 'x', no_argument, NULL, 0, eArgTypeNone, "Type names are actually regular expressions."}, { LLDB_OPT_SET_1 , true, "inline-children", 'c', no_argument, NULL, 0, eArgTypeNone, "If true, inline all child values into summary string."}, - { LLDB_OPT_SET_2 , true, "summary-string", 'f', required_argument, NULL, 0, eArgTypeSummaryString, "Summary string used to display text and object contents."}, + { LLDB_OPT_SET_2 , true, "summary-string", 's', required_argument, NULL, 0, eArgTypeSummaryString, "Summary string used to display text and object contents."}, { LLDB_OPT_SET_3, false, "python-script", 'o', required_argument, NULL, 0, eArgTypeName, "Give a one-liner Python script as part of the command."}, { LLDB_OPT_SET_3, false, "python-function", 'F', required_argument, NULL, 0, eArgTypeName, "Give the name of a Python function to use for this type."}, { LLDB_OPT_SET_3, false, "input-python", 'P', no_argument, NULL, 0, eArgTypeNone, "Input Python code to use for this type manually."}, Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py Tue Aug 23 11:13:35 2011 @@ -55,9 +55,9 @@ # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add -f \"pippo\" \"i_am_cool\"") + self.runCmd("type summary add --summary-string \"pippo\" \"i_am_cool\"") - self.runCmd("type summary add -f \"pluto\" -x \"i_am_cool[a-z]*\"") + self.runCmd("type summary add --summary-string \"pluto\" -x \"i_am_cool[a-z]*\"") self.expect("frame variable cool_boy", substrs = ['pippo']) @@ -72,32 +72,32 @@ self.runCmd("type summary clear") - self.runCmd("type summary add -f \"${var[]}\" -x \"int \\[[0-9]\\]") + self.runCmd("type summary add --summary-string \"${var[]}\" -x \"int \\[[0-9]\\]") self.expect("frame variable int_array", substrs = ['1,2,3,4,5']) - self.runCmd("type summary add -f \"${var[].integer}\" -x \"i_am_cool \\[[0-9]\\]") + self.runCmd("type summary add --summary-string \"${var[].integer}\" -x \"i_am_cool \\[[0-9]\\]") self.expect("frame variable cool_array", substrs = ['1,1,1,1,6']) self.runCmd("type summary clear") - self.runCmd("type summary add -f \"${var[1-0]%x}\" \"int\"") + self.runCmd("type summary add --summary-string \"${var[1-0]%x}\" \"int\"") self.expect("frame variable iAmInt", substrs = ['01']) - self.runCmd("type summary add -f \"${var[0-1]%x}\" \"int\"") + self.runCmd("type summary add --summary-string \"${var[0-1]%x}\" \"int\"") self.expect("frame variable iAmInt", substrs = ['01']) self.runCmd("type summary clear") - self.runCmd("type summary add -f \"${var[0-1]%x}\" int") - self.runCmd("type summary add -f \"${var[0-31]%x}\" float") + self.runCmd("type summary add --summary-string \"${var[0-1]%x}\" int") + self.runCmd("type summary add --summary-string \"${var[0-31]%x}\" float") self.expect("frame variable *pointer", substrs = ['0x', @@ -106,20 +106,20 @@ self.expect("frame variable cool_array[3].floating", substrs = ['0x']) - self.runCmd("type summary add -f \"low bits are ${*var[0-1]} tgt is ${*var}\" \"int *\"") + self.runCmd("type summary add --summary-string \"low bits are ${*var[0-1]} tgt is ${*var}\" \"int *\"") self.expect("frame variable pointer", substrs = ['low bits are', 'tgt is 6']) - self.runCmd("type summary add -f \"${*var[0-1]}\" -x \"int \[[0-9]\]\"") + self.runCmd("type summary add --summary-string \"${*var[0-1]}\" -x \"int \[[0-9]\]\"") self.expect("frame variable int_array", substrs = ['3']) self.runCmd("type summary clear") - self.runCmd("type summary add -f \"${var[0-1]}\" -x \"int \[[0-9]\]\"") + self.runCmd("type summary add --summary-string \"${var[0-1]}\" -x \"int \[[0-9]\]\"") self.expect("frame variable int_array", substrs = ['1,2']) @@ -139,13 +139,13 @@ 'character', 'floating']) - self.runCmd("type summary add -f \"int = ${*var.int_pointer}, float = ${*var.float_pointer}\" IWrapPointers") + self.runCmd("type summary add --summary-string \"int = ${*var.int_pointer}, float = ${*var.float_pointer}\" IWrapPointers") self.expect("frame variable wrapper", substrs = ['int = 4', 'float = 1.1']) - self.runCmd("type summary add -f \"low bits = ${*var.int_pointer[2]}\" IWrapPointers -p") + self.runCmd("type summary add --summary-string \"low bits = ${*var.int_pointer[2]}\" IWrapPointers -p") self.expect("frame variable wrapper", substrs = ['low bits = 1']) @@ -155,7 +155,7 @@ self.runCmd("type summary clear") - self.runCmd("type summary add -f \"${var[0][0-2]%hex}\" -x \"int \[[0-9]\]\"") + self.runCmd("type summary add --summary-string \"${var[0][0-2]%hex}\" -x \"int \[[0-9]\]\"") self.expect("frame variable int_array", substrs = ['0x', @@ -163,8 +163,8 @@ self.runCmd("type summary clear") - self.runCmd("type summary add -f \"${*var[].x[0-3]%hex} is a bitfield on a set of integers\" -x \"SimpleWithPointers \[[0-9]\]\"") - self.runCmd("type summary add -f \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\" Couple") + self.runCmd("type summary add --summary-string \"${*var[].x[0-3]%hex} is a bitfield on a set of integers\" -x \"SimpleWithPointers \[[0-9]\]\"") + self.runCmd("type summary add --summary-string \"${*var.sp.x[0-2]} are low bits of integer ${*var.sp.x}. If I pretend it is an array I get ${var.sp.x[0-5]}\" Couple") self.expect("frame variable couple", substrs = ['1 are low bits of integer 9.', @@ -175,7 +175,7 @@ # check that we can format a variable in a summary even if a format is defined for its datatype self.runCmd("type format add -f hex int") - self.runCmd("type summary add -f \"x=${var.x%i}\" Simple") + self.runCmd("type summary add --summary-string \"x=${var.x%i}\" Simple") self.expect("frame variable a_simple_object", substrs = ['x=3']) @@ -184,7 +184,7 @@ substrs = ['0x0']) # now check that the default is applied if we do not hand out a format - self.runCmd("type summary add -f \"x=${var.x}\" Simple") + self.runCmd("type summary add --summary-string \"x=${var.x}\" Simple") self.expect("frame variable a_simple_object", matching=False, substrs = ['x=3']) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py Tue Aug 23 11:13:35 2011 @@ -62,7 +62,7 @@ self.addTearDownHook(cleanup) # Add a summary to a new category and check that it works - self.runCmd("type summary add Rectangle -f \"ARectangle\" -w NewCategory") + self.runCmd("type summary add Rectangle --summary-string \"ARectangle\" -w NewCategory") self.expect("frame variable r1 r2 r3", matching=False, substrs = ['r1 = ARectangle', @@ -101,7 +101,7 @@ 'r3 = {']) # Add summaries to two different categories and check that we can switch - self.runCmd("type summary add -f \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1") + self.runCmd("type summary add --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1") self.runCmd("type summary add --python-script \"return 'Area = ' + str( int(valobj.GetChildMemberWithName('w').GetValue()) * int(valobj.GetChildMemberWithName('h').GetValue()) );\" Rectangle -w Category2") # check that enable A B is the same as enable B enable A @@ -156,8 +156,8 @@ # Now add another summary to another category and switch back and forth self.runCmd("type category delete Category1 Category2") - self.runCmd("type summary add Rectangle -f \"Category1\" -w Category1") - self.runCmd("type summary add Rectangle -f \"Category2\" -w Category2") + self.runCmd("type summary add Rectangle --summary-string \"Category1\" -w Category1") + self.runCmd("type summary add Rectangle --summary-string \"Category2\" -w Category2") self.runCmd("type category enable Category2") self.runCmd("type category enable Category1") @@ -191,8 +191,8 @@ 'r3 = {']) # Check that multiple summaries can go into one category - self.runCmd("type summary add -f \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1") - self.runCmd("type summary add -f \"Radius = ${var.r}\" Circle -w Category1") + self.runCmd("type summary add --summary-string \"Width = ${var.w}, Height = ${var.h}\" Rectangle -w Category1") + self.runCmd("type summary add --summary-string \"Radius = ${var.r}\" Circle -w Category1") self.runCmd("type category enable Category1") @@ -214,7 +214,7 @@ 'c3 = {']) # Add a regex based summary to a category - self.runCmd("type summary add -f \"Radius = ${var.r}\" -x Circle -w Category1") + self.runCmd("type summary add --summary-string \"Radius = ${var.r}\" -x Circle -w Category1") self.expect("frame variable r1 r2 r3", substrs = ['r1 = Width = ', @@ -235,14 +235,14 @@ 'c3 = {']) # Change a summary inside a category and check that the change is reflected - self.runCmd("type summary add Circle -w Category1 -f \"summary1\"") + self.runCmd("type summary add Circle -w Category1 --summary-string \"summary1\"") self.expect("frame variable c1 c2 c3", substrs = ['c1 = summary1', 'c2 = summary1', 'c3 = summary1']) - self.runCmd("type summary add Circle -w Category1 -f \"summary2\"") + self.runCmd("type summary add Circle -w Category1 --summary-string \"summary2\"") self.expect("frame variable c1 c2 c3", substrs = ['c1 = summary2', @@ -252,7 +252,7 @@ # Check that our order of priority works. Start by clearing categories self.runCmd("type category delete Category1") - self.runCmd("type summary add Shape -w BaseCategory -f \"AShape\"") + self.runCmd("type summary add Shape -w BaseCategory --summary-string \"AShape\"") self.runCmd("type category enable BaseCategory") self.expect("frame variable c1 r1 c_ptr r_ptr", @@ -261,8 +261,8 @@ 'AShape', 'AShape']) - self.runCmd("type summary add Circle -w CircleCategory -f \"ACircle\"") - self.runCmd("type summary add Rectangle -w RectangleCategory -f \"ARectangle\"") + self.runCmd("type summary add Circle -w CircleCategory --summary-string \"ACircle\"") + self.runCmd("type summary add Rectangle -w RectangleCategory --summary-string \"ARectangle\"") self.runCmd("type category enable CircleCategory") self.expect("frame variable c1 r1 c_ptr r_ptr", @@ -271,7 +271,7 @@ 'ACircle', 'AShape']) - self.runCmd("type summary add \"Rectangle *\" -w RectangleStarCategory -f \"ARectangleStar\"") + self.runCmd("type summary add \"Rectangle *\" -w RectangleStarCategory --summary-string \"ARectangleStar\"") self.runCmd("type category enable RectangleStarCategory") self.expect("frame variable c1 r1 c_ptr r_ptr", @@ -322,10 +322,10 @@ # check that filters work into categories self.runCmd("type filter add Rectangle --child w --category RectangleCategory") self.runCmd("type category enable RectangleCategory") - self.runCmd("type summary add Rectangle -f \" \" -e --category RectangleCategory") + self.runCmd("type summary add Rectangle --summary-string \" \" -e --category RectangleCategory") self.expect('frame variable r2', substrs = ['w = 9']) - self.runCmd("type summary add Rectangle -f \" \" -e") + self.runCmd("type summary add Rectangle --summary-string \" \" -e") self.expect('frame variable r2', matching=False, substrs = ['h = 16']) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Tue Aug 23 11:13:35 2011 @@ -94,19 +94,19 @@ self.expect("type format delete Speed", error=True, substrs = ['no custom format for Speed']) - self.runCmd("type summary add -f \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") + self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") self.expect("frame variable strarr", substrs = ['arr = "Hello world!"']) self.runCmd("type summary clear") - self.runCmd("type summary add -f \"ptr = ${var%s}\" \"char *\" -v") + self.runCmd("type summary add --summary-string \"ptr = ${var%s}\" \"char *\" -v") self.expect("frame variable strptr", substrs = ['ptr = "Hello world!"']) - self.runCmd("type summary add -f \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") + self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\" -v") self.expect("frame variable strarr", substrs = ['arr = "Hello world!']) @@ -124,18 +124,18 @@ substrs = ['Point', 'one-line']) - self.runCmd("type summary add -f \"y=${var.y%x}\" Point") + self.runCmd("type summary add --summary-string \"y=${var.y%x}\" Point") self.expect("frame variable iAmSomewhere", substrs = ['y=0x']) - self.runCmd("type summary add -f \"y=${var.y},x=${var.x}\" Point") + self.runCmd("type summary add --summary-string \"y=${var.y},x=${var.x}\" Point") self.expect("frame variable iAmSomewhere", substrs = ['y=6', 'x=4']) - self.runCmd("type summary add -f \"hello\" Point -e") + self.runCmd("type summary add --summary-string \"hello\" Point -e") self.expect("type summary list", substrs = ['Point', @@ -146,25 +146,25 @@ 'x = 4', '}']) - self.runCmd("type summary add -f \"Sign: ${var[31]%B} Exponent: ${var[23-30]%x} Mantissa: ${var[0-22]%u}\" ShowMyGuts") + self.runCmd("type summary add --summary-string \"Sign: ${var[31]%B} Exponent: ${var[23-30]%x} Mantissa: ${var[0-22]%u}\" ShowMyGuts") self.expect("frame variable cool_pointer->floating", substrs = ['Sign: true', 'Exponent: 0x', '80']) - self.runCmd("type summary add -f \"a test\" i_am_cool") + self.runCmd("type summary add --summary-string \"a test\" i_am_cool") self.expect("frame variable cool_pointer", substrs = ['a test']) - self.runCmd("type summary add -f \"a test\" i_am_cool --skip-pointers") + self.runCmd("type summary add --summary-string \"a test\" i_am_cool --skip-pointers") self.expect("frame variable cool_pointer", substrs = ['a test'], matching = False) - self.runCmd("type summary add -f \"${var[1-3]}\" \"int [5]\"") + self.runCmd("type summary add --summary-string \"${var[1-3]}\" \"int [5]\"") self.expect("frame variable int_array", substrs = ['2', @@ -173,8 +173,8 @@ self.runCmd("type summary clear") - self.runCmd("type summary add -f \"${var[0-2].integer}\" \"i_am_cool *\"") - self.runCmd("type summary add -f \"${var[2-4].integer}\" \"i_am_cool [5]\"") + self.runCmd("type summary add --summary-string \"${var[0-2].integer}\" \"i_am_cool *\"") + self.runCmd("type summary add --summary-string \"${var[2-4].integer}\" \"i_am_cool [5]\"") self.expect("frame variable cool_array", substrs = ['1,1,6']) @@ -183,7 +183,7 @@ substrs = ['3,0,0']) # test special symbols for formatting variables into summaries - self.runCmd("type summary add -f \"cool object @ ${var%L}\" i_am_cool") + self.runCmd("type summary add --summary-string \"cool object @ ${var%L}\" i_am_cool") self.runCmd("type summary delete \"i_am_cool [5]\"") # this test might fail if the compiler tries to store @@ -197,7 +197,7 @@ '[4] = cool object @ 0x']) # test getting similar output by exploiting ${var} = 'type @ location' for aggregates - self.runCmd("type summary add -f \"${var}\" i_am_cool") + self.runCmd("type summary add --summary-string \"${var}\" i_am_cool") # this test might fail if the compiler tries to store # these values into registers.. hopefully this is not @@ -211,7 +211,7 @@ # test getting same output by exploiting %T and %L together for aggregates - self.runCmd("type summary add -f \"${var%T} @ ${var%L}\" i_am_cool") + self.runCmd("type summary add --summary-string \"${var%T} @ ${var%L}\" i_am_cool") # this test might fail if the compiler tries to store # these values into registers.. hopefully this is not @@ -223,37 +223,37 @@ '[3] = i_am_cool @ 0x', '[4] = i_am_cool @ 0x']) - self.runCmd("type summary add -f \"goofy\" i_am_cool") - self.runCmd("type summary add -f \"${var.second_cool%S}\" i_am_cooler") + self.runCmd("type summary add --summary-string \"goofy\" i_am_cool") + self.runCmd("type summary add --summary-string \"${var.second_cool%S}\" i_am_cooler") self.expect("frame variable the_coolest_guy", substrs = ['(i_am_cooler) the_coolest_guy = goofy']) # check that unwanted type specifiers are removed self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add -f \"goofy\" \"class i_am_cool\"") + self.runCmd("type summary add --summary-string \"goofy\" \"class i_am_cool\"") self.expect("frame variable the_coolest_guy", substrs = ['(i_am_cooler) the_coolest_guy = goofy']) self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add -f \"goofy\" \"enum i_am_cool\"") + self.runCmd("type summary add --summary-string \"goofy\" \"enum i_am_cool\"") self.expect("frame variable the_coolest_guy", substrs = ['(i_am_cooler) the_coolest_guy = goofy']) self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add -f \"goofy\" \"struct i_am_cool\"") + self.runCmd("type summary add --summary-string \"goofy\" \"struct i_am_cool\"") self.expect("frame variable the_coolest_guy", substrs = ['(i_am_cooler) the_coolest_guy = goofy']) # many spaces, but we still do the right thing self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add -f \"goofy\" \"union i_am_cool\"") + self.runCmd("type summary add --summary-string \"goofy\" \"union i_am_cool\"") self.expect("frame variable the_coolest_guy", substrs = ['(i_am_cooler) the_coolest_guy = goofy']) # but that not *every* specifier is removed self.runCmd("type summary delete i_am_cool") - self.runCmd("type summary add -f \"goofy\" \"wrong i_am_cool\"") + self.runCmd("type summary add --summary-string \"goofy\" \"wrong i_am_cool\"") self.expect("frame variable the_coolest_guy", matching=False, substrs = ['(i_am_cooler) the_coolest_guy = goofy']) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py Tue Aug 23 11:13:35 2011 @@ -46,7 +46,7 @@ # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add -f \"JustATest\" Point") + self.runCmd("type summary add --summary-string \"JustATest\" Point") # Simply check we can get at global variables self.expect("target variable g_point", @@ -57,7 +57,7 @@ # Print some information about the variables # (we ignore the actual values) - self.runCmd("type summary add -f \"(x=${var.x},y=${var.y})\" Point") + self.runCmd("type summary add --summary-string \"(x=${var.x},y=${var.y})\" Point") self.expect("target variable g_point", substrs = ['x=', Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py Tue Aug 23 11:13:35 2011 @@ -53,10 +53,10 @@ # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add -f \"AllUseIt: x=${var.x} {y=${var.y}} {z=${var.z}}\" --name AllUseIt") - self.runCmd("type summary add -f \"First: x=${var.x} y=${var.y} dummy=${var.dummy}\" First") - self.runCmd("type summary add -f \"Second: x=${var.x} y=${var.y%hex}\" Second") - self.runCmd("type summary add -f \"Third: x=${var.x} z=${var.z}\" Third") + self.runCmd("type summary add --summary-string \"AllUseIt: x=${var.x} {y=${var.y}} {z=${var.z}}\" --name AllUseIt") + self.runCmd("type summary add --summary-string \"First: x=${var.x} y=${var.y} dummy=${var.dummy}\" First") + self.runCmd("type summary add --summary-string \"Second: x=${var.x} y=${var.y%hex}\" Second") + self.runCmd("type summary add --summary-string \"Third: x=${var.x} z=${var.z}\" Third") self.expect("frame variable first", substrs = ['First: x=12']) @@ -99,7 +99,7 @@ self.runCmd("thread step-over") - self.runCmd("type summary add -f \"FirstAndFriends: x=${var.x} {y=${var.y}} {z=${var.z}}\" First --name FirstAndFriends") + self.runCmd("type summary add --summary-string \"FirstAndFriends: x=${var.x} {y=${var.y}} {z=${var.z}}\" First --name FirstAndFriends") self.expect("frame variable first", substrs = ['FirstAndFriends: x=12', Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Tue Aug 23 11:13:35 2011 @@ -54,7 +54,7 @@ # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add -f \"${var%@}\" MyClass") + self.runCmd("type summary add --summary-string \"${var%@}\" MyClass") self.expect("frame variable object2", substrs = ['MyOtherClass']); @@ -69,7 +69,7 @@ self.expect("type summary list", matching=False, substrs = ['MyClass']) - self.runCmd("type summary add -f \"a test\" MyClass") + self.runCmd("type summary add --summary-string \"a test\" MyClass") self.expect("frame variable object2", substrs = ['a test']); @@ -83,7 +83,7 @@ self.expect("frame variable *object", substrs = ['a test']); - self.runCmd("type summary add -f \"a test\" MyClass -C no") + self.runCmd("type summary add --summary-string \"a test\" MyClass -C no") self.expect("frame variable *object2", substrs = ['*object2 = {', Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Tue Aug 23 11:13:35 2011 @@ -85,16 +85,16 @@ substrs = ['16777216']) # put synthetic children in summary in several combinations - self.runCmd("type summary add -f \"fake_a=${svar.fake_a}\" foo") + self.runCmd("type summary add --summary-string \"fake_a=${svar.fake_a}\" foo") self.expect('frame variable f00_1', substrs = ['fake_a=16777216']) - self.runCmd("type summary add -f \"fake_a=${var.fake_a}\" foo") + self.runCmd("type summary add --summary-string \"fake_a=${var.fake_a}\" foo") self.expect('frame variable f00_1', substrs = ['fake_a=16777216']) - self.runCmd("type summary add -f \"fake_a=${var[1]}\" foo") + self.runCmd("type summary add --summary-string \"fake_a=${var[1]}\" foo") self.expect('frame variable f00_1', substrs = ['fake_a=16777216']) - self.runCmd("type summary add -f \"fake_a=${svar[1]}\" foo") + self.runCmd("type summary add --summary-string \"fake_a=${svar[1]}\" foo") self.expect('frame variable f00_1', substrs = ['fake_a=16777216']) @@ -252,11 +252,11 @@ '}']) # check access to synthetic children - self.runCmd("type summary add -f \"item 0 is ${var[0]}\" std::int_vect int_vect") + self.runCmd("type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") self.expect('frame variable numbers', substrs = ['item 0 is 1']); - self.runCmd("type summary add -f \"item 0 is ${svar[0]}\" std::int_vect int_vect") + self.runCmd("type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") #import time #time.sleep(19) self.expect('frame variable numbers', @@ -321,7 +321,7 @@ 'smart']) # test summaries based on synthetic children - self.runCmd("type summary add std::string_vect string_vect -f \"vector has ${svar%#} items\" -e") + self.runCmd("type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") self.expect("frame variable strings", substrs = ['vector has 3 items', 'goofy', @@ -357,7 +357,7 @@ self.runCmd("frame variable numbers_list -T") #self.runCmd("type synth add std::int_list std::string_list int_list string_list -l StdListSynthProvider") - self.runCmd("type summary add std::int_list std::string_list int_list string_list -f \"list has ${svar%#} items\" -e") + self.runCmd("type summary add std::int_list std::string_list int_list string_list --summary-string \"list has ${svar%#} items\" -e") self.runCmd("type format add -f hex int") self.expect("frame variable numbers_list", @@ -442,7 +442,7 @@ '[3]', '!!!']) # let's prettify string display - self.runCmd("type summary add -f \"${var._M_dataplus._M_p}\" std::string std::basic_string \"std::basic_string,std::allocator >\"") + self.runCmd("type summary add --summary-string \"${var._M_dataplus._M_p}\" std::string std::basic_string \"std::basic_string,std::allocator >\"") self.expect("frame variable text_list", substrs = ['list has 4 items', @@ -468,7 +468,7 @@ self.runCmd("frame variable ii -T") #self.runCmd("script from StdMapSynthProvider import *") - self.runCmd("type summary add -x \"std::map<\" -f \"map has ${svar%#} items\" -e") + self.runCmd("type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e") #import time #time.sleep(30) @@ -535,7 +535,7 @@ self.runCmd("n") self.runCmd("frame variable si -T") - #self.runCmd("type summary add std::strint_map strint_map -f \"map has ${svar%#} items\" -e") + #self.runCmd("type summary add std::strint_map strint_map --summary-string \"map has ${svar%#} items\" -e") #self.runCmd("type synth add std::strint_map strint_map -l StdMapSynthProvider") self.expect('frame variable si', @@ -588,7 +588,7 @@ self.runCmd("n") self.runCmd("frame variable is -T") - #self.runCmd("type summary add std::intstr_map intstr_map -f \"map has ${svar%#} items\" -e") + #self.runCmd("type summary add std::intstr_map intstr_map --summary-string \"map has ${svar%#} items\" -e") #self.runCmd("type synth add std::intstr_map intstr_map -l StdMapSynthProvider") self.expect('frame variable is', @@ -630,7 +630,7 @@ self.runCmd("n") self.runCmd("frame variable ss -T") - #self.runCmd("type summary add std::strstr_map strstr_map -f \"map has ${svar%#} items\" -e") + #self.runCmd("type summary add std::strstr_map strstr_map --summary-string \"map has ${svar%#} items\" -e") #self.runCmd("type synth add std::strstr_map strstr_map -l StdMapSynthProvider") self.expect('frame variable ss', Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py Tue Aug 23 11:13:35 2011 @@ -90,7 +90,7 @@ substrs = ['int says 1']) # Change the summary - self.runCmd("type summary add -f \"int says ${var.integer}, and float says ${var.floating}\" i_am_cool") + self.runCmd("type summary add --summary-string \"int says ${var.integer}, and float says ${var.floating}\" i_am_cool") self.expect("frame variable two", substrs = ['int says 1', @@ -120,7 +120,7 @@ self.expect("frame variable two", matching=False, substrs = ['Python summary']) - self.runCmd("type summary add i_am_cool -f \"Text summary\"") + self.runCmd("type summary add i_am_cool --summary-string \"Text summary\"") self.expect("frame variable one", substrs = ['Python summary']) @@ -139,7 +139,7 @@ substrs = ['Text summary']) # disable type summary for pointers, and make a Python regex summary - self.runCmd("type summary add i_am_cool -p -f \"Text summary\"") + self.runCmd("type summary add i_am_cool -p --summary-string \"Text summary\"") self.runCmd("type summary add -x cool --python-script \"%s\"" % script) # variables should stick to the type summary @@ -157,7 +157,7 @@ substrs = ['Python summary']) # return pointers to the type summary - self.runCmd("type summary add i_am_cool -f \"Text summary\"") + self.runCmd("type summary add i_am_cool --summary-string \"Text summary\"") self.expect("frame variable one", substrs = ['Text summary']) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py Tue Aug 23 11:13:35 2011 @@ -54,12 +54,12 @@ self.addTearDownHook(cleanup) # Setup the summaries for this scenario - #self.runCmd("type summary add -f \"${var._M_dataplus._M_p}\" std::string") - self.runCmd("type summary add -f \"Level 1\" \"DeepData_1\"") - self.runCmd("type summary add -f \"Level 2\" \"DeepData_2\" -e") - self.runCmd("type summary add -f \"Level 3\" \"DeepData_3\"") - self.runCmd("type summary add -f \"Level 4\" \"DeepData_4\"") - self.runCmd("type summary add -f \"Level 5\" \"DeepData_5\"") + #self.runCmd("type summary add --summary-string \"${var._M_dataplus._M_p}\" std::string") + self.runCmd("type summary add --summary-string \"Level 1\" \"DeepData_1\"") + self.runCmd("type summary add --summary-string \"Level 2\" \"DeepData_2\" -e") + self.runCmd("type summary add --summary-string \"Level 3\" \"DeepData_3\"") + self.runCmd("type summary add --summary-string \"Level 4\" \"DeepData_4\"") + self.runCmd("type summary add --summary-string \"Level 5\" \"DeepData_5\"") # Default case, just print out summaries self.expect('frame variable', @@ -167,7 +167,7 @@ '}']) # Change summary and expand, first without -Y then with -Y - self.runCmd("type summary add -f \"${var.m_some_text}\" DeepData_5") + self.runCmd("type summary add --summary-string \"${var.m_some_text}\" DeepData_5") self.expect('fr var data2.m_child4.m_child2.m_child2', substrs = ['(DeepData_5) data2.m_child4.m_child2.m_child2 = "Just a test"']) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py Tue Aug 23 11:13:35 2011 @@ -54,12 +54,12 @@ self.addTearDownHook(cleanup) # check that we are not looping here - self.runCmd("type summary add -f \"${var%V}\" SomeData") + self.runCmd("type summary add --summary-string \"${var%V}\" SomeData") self.expect("frame variable data", substrs = ['invalid use of aggregate type']) # ${var%s} - self.runCmd("type summary add -f \"ptr = ${var%s}\" \"char *\"") + self.runCmd("type summary add --summary-string \"ptr = ${var%s}\" \"char *\"") self.expect("frame variable strptr", substrs = ['ptr = \"', @@ -69,7 +69,7 @@ substrs = ['ptr = \"', 'Nested Hello world!']) - self.runCmd("type summary add -f \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%s}\" -x \"char \\[[0-9]+\\]\"") self.expect("frame variable strarr", substrs = ['arr = \"', @@ -80,7 +80,7 @@ 'Nested Hello world!']) # ${var%c} - self.runCmd("type summary add -f \"ptr = ${var%c}\" \"char *\"") + self.runCmd("type summary add --summary-string \"ptr = ${var%c}\" \"char *\"") self.expect("frame variable strptr", substrs = ['ptr = \"', @@ -90,7 +90,7 @@ substrs = ['ptr = \"', 'Nested Hello world!']) - self.runCmd("type summary add -f \"arr = ${var%c}\" -x \"char \\[[0-9]+\\]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%c}\" -x \"char \\[[0-9]+\\]\"") self.expect("frame variable strarr", substrs = ['arr = \"', @@ -101,7 +101,7 @@ 'Nested Hello world!']) # ${var%char[]} - self.runCmd("type summary add -f \"arr = ${var%char[]}\" -x \"char \\[[0-9]+\\]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%char[]}\" -x \"char \\[[0-9]+\\]\"") self.expect("frame variable strarr", substrs = ['arr = \"', @@ -111,7 +111,7 @@ substrs = ['arr = ', 'Nested Hello world!']) - self.runCmd("type summary add -f \"ptr = ${var%char[]}\" \"char *\"") + self.runCmd("type summary add --summary-string \"ptr = ${var%char[]}\" \"char *\"") self.expect("frame variable strptr", substrs = ['ptr = \"', @@ -122,7 +122,7 @@ 'Nested Hello world!']) # ${var%a} - self.runCmd("type summary add -f \"arr = ${var%a}\" -x \"char \\[[0-9]+\\]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%a}\" -x \"char \\[[0-9]+\\]\"") self.expect("frame variable strarr", substrs = ['arr = \"', @@ -132,7 +132,7 @@ substrs = ['arr = ', 'Nested Hello world!']) - self.runCmd("type summary add -f \"ptr = ${var%a}\" \"char *\"") + self.runCmd("type summary add --summary-string \"ptr = ${var%a}\" \"char *\"") self.expect("frame variable strptr", substrs = ['ptr = \"', @@ -142,7 +142,7 @@ substrs = ['ptr = \"', 'Nested Hello world!']) - self.runCmd("type summary add -f \"ptr = ${var[]%char[]}\" \"char *\"") + self.runCmd("type summary add --summary-string \"ptr = ${var[]%char[]}\" \"char *\"") # I do not know the size of the data, but you are asking for a full array slice.. # use the ${var%char[]} to obtain a string as result @@ -155,7 +155,7 @@ 'Nested Hello world!']) # You asked an array-style printout... - self.runCmd("type summary add -f \"ptr = ${var[0-1]%char[]}\" \"char *\"") + self.runCmd("type summary add --summary-string \"ptr = ${var[0-1]%char[]}\" \"char *\"") self.expect("frame variable strptr", substrs = ['ptr = ', @@ -166,7 +166,7 @@ '[{N},{e}]']) # using [] is required here - self.runCmd("type summary add -f \"arr = ${var%x}\" \"int [5]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%x}\" \"int [5]\"") self.expect("frame variable intarr", substrs = ['']) @@ -174,7 +174,7 @@ self.expect("frame variable other.intarr", substrs = ['']) - self.runCmd("type summary add -f \"arr = ${var[]%x}\" \"int [5]\"") + self.runCmd("type summary add --summary-string \"arr = ${var[]%x}\" \"int [5]\"") self.expect("frame variable intarr", substrs = ['intarr = arr =', @@ -185,7 +185,7 @@ '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) # printing each array item as an array - self.runCmd("type summary add -f \"arr = ${var[]%uint32_t[]}\" \"int [5]\"") + self.runCmd("type summary add --summary-string \"arr = ${var[]%uint32_t[]}\" \"int [5]\"") self.expect("frame variable intarr", substrs = ['intarr = arr =', @@ -196,19 +196,18 @@ '{0x00000009},{0x00000008},{0x00000007},{0x00000006},{0x00000005}']) # printing full array as an array - self.runCmd("log enable lldb types -f dummy.log") - self.runCmd("type summary add -f \"arr = ${var%uint32_t[]}\" \"int [5]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%uint32_t[]}\" \"int [5]\"") self.expect("frame variable intarr", substrs = ['intarr = arr =', '0x00000001,0x00000001,0x00000002,0x00000003,0x00000005']) - self.runCmd("log disable lldb types") + self.expect("frame variable other.intarr", substrs = ['intarr = arr =', '0x00000009,0x00000008,0x00000007,0x00000006,0x00000005']) # printing each array item as an array - self.runCmd("type summary add -f \"arr = ${var[]%float32[]}\" \"float [7]\"") + self.runCmd("type summary add --summary-string \"arr = ${var[]%float32[]}\" \"float [7]\"") self.expect("frame variable flarr", substrs = ['flarr = arr =', @@ -219,7 +218,7 @@ '{25.5},{25.7},{25.9},{26.4},{27.1},{27.3},{26.9}']) # printing full array as an array - self.runCmd("type summary add -f \"arr = ${var%float32[]}\" \"float [7]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%float32[]}\" \"float [7]\"") self.expect("frame variable flarr", substrs = ['flarr = arr =', @@ -230,8 +229,8 @@ '25.5,25.7,25.9,26.4,27.1,27.3,26.9']) # using array smart summary strings for pointers should make no sense - self.runCmd("type summary add -f \"arr = ${var%float32[]}\" \"float *\"") - self.runCmd("type summary add -f \"arr = ${var%int32_t[]}\" \"int *\"") + self.runCmd("type summary add --summary-string \"arr = ${var%float32[]}\" \"float *\"") + self.runCmd("type summary add --summary-string \"arr = ${var%int32_t[]}\" \"int *\"") self.expect("frame variable flptr", matching=False, substrs = ['78.5,77.4,78,76.1,76.7,76.8,77']) @@ -240,8 +239,8 @@ substrs = ['1,1,2,3,5']) # use y and Y - self.runCmd("type summary add -f \"arr = ${var%y}\" \"float [7]\"") - self.runCmd("type summary add -f \"arr = ${var%y}\" \"int [5]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%y}\" \"float [7]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%y}\" \"int [5]\"") self.expect("frame variable flarr", substrs = ['flarr = arr =', @@ -259,8 +258,8 @@ substrs = ['intarr = arr = ', '09 00 00 00,08 00 00 00,07 00 00 00,06 00 00 00,05 00 00 00']) - self.runCmd("type summary add -f \"arr = ${var%Y}\" \"float [7]\"") - self.runCmd("type summary add -f \"arr = ${var%Y}\" \"int [5]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%Y}\" \"float [7]\"") + self.runCmd("type summary add --summary-string \"arr = ${var%Y}\" \"int [5]\"") self.expect("frame variable flarr", substrs = ['flarr = arr =', Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Tue Aug 23 11:13:35 2011 @@ -61,7 +61,7 @@ 'z = 8']) # Check we can still access the missing child by summary - self.runCmd("type summary add BagOfInts -f \"y=${var.y}\"") + self.runCmd("type summary add BagOfInts --summary-string \"y=${var.y}\"") self.expect('frame variable int_bag', substrs = ['y=7']) @@ -83,7 +83,7 @@ 'z = 8']) # Summary+Synth must work together - self.runCmd("type summary add BagOfInts -f \"y=${var.y}\" -e") + self.runCmd("type summary add BagOfInts --summary-string \"y=${var.y}\" -e") self.expect('frame variable int_bag', substrs = ['y=7', 'x = 6', Modified: lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py (original) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py Tue Aug 23 11:13:35 2011 @@ -53,7 +53,7 @@ # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var}\" Summarize") + self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var}\" Summarize") self.expect('frame variable mine_ptr', substrs = ['SUMMARY SUCCESS summarize_ptr_t @ ']) @@ -61,7 +61,7 @@ self.expect('frame variable *mine_ptr', substrs = ['SUMMARY SUCCESS summarize_t @']) - self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var.first}\" Summarize") + self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") self.expect('frame variable mine_ptr', substrs = ['SUMMARY SUCCESS 10']) Modified: lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py?rev=138331&r1=138330&r2=138331&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py (original) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py Tue Aug 23 11:13:35 2011 @@ -53,7 +53,7 @@ # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var}\" Summarize") + self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var}\" Summarize") self.expect('frame variable mine_ptr', substrs = ['SUMMARY SUCCESS summarize_ptr_t @ ']) @@ -61,7 +61,7 @@ self.expect('frame variable *mine_ptr', substrs = ['SUMMARY SUCCESS summarize_t @']) - self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var.first}\" Summarize") + self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") self.expect('frame variable mine_ptr', substrs = ['SUMMARY SUCCESS 10']) @@ -69,15 +69,15 @@ self.expect('frame variable *mine_ptr', substrs = ['SUMMARY SUCCESS 10']) - self.runCmd("type summary add -f \"${var}\" Summarize") - self.runCmd("type summary add -f \"${var}\" -e TwoSummarizes") + self.runCmd("type summary add --summary-string \"${var}\" Summarize") + self.runCmd("type summary add --summary-string \"${var}\" -e TwoSummarizes") self.expect('frame variable', substrs = ['(TwoSummarizes) twos = TwoSummarizes @ ', 'first = summarize_t @ ', 'second = summarize_t @ ']) - self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var.first}\" Summarize") + self.runCmd("type summary add --summary-string \"SUMMARY SUCCESS ${var.first}\" Summarize") self.expect('frame variable', substrs = ['(TwoSummarizes) twos = TwoSummarizes @ ', 'first = SUMMARY SUCCESS 1', From scallanan at apple.com Tue Aug 23 16:20:51 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 23 Aug 2011 21:20:51 -0000 Subject: [Lldb-commits] [lldb] r138383 - in /lldb/trunk: include/lldb/Core/ include/lldb/Expression/ source/Commands/ source/Expression/ test/expression_command/persistent_types/ Message-ID: <20110823212051.EE4992A6C12C@llvm.org> Author: spyffe Date: Tue Aug 23 16:20:51 2011 New Revision: 138383 URL: http://llvm.org/viewvc/llvm-project?rev=138383&view=rev Log: Added support for persistent types to the expression parser. You can use a persistent type like this: (lldb) expr struct $foo { int a; int b; }; (lldb) struct $foo i; i.a = 2; i.b = 3; i ($foo) $0 = { (int) a = 2 (int) b = 3 } typedefs work similarly. This patch affects the following files: test/expression_command/persistent_types/* A test case for persistent types, in particular structs and typedefs. ClangForward.h Added TypeDecl, needed to declare some functions in ASTResultSynthesizer.h ClangPersistentVariables.[h,cpp] Added a list of persistent types to the persistent variable store. ASTResultSynthesizer.[h,cpp] Made the AST result synthesizer iterate across TypeDecls in the expression, and record any persistent types found. Also made a minor documentation fix. ClangUserExpression.[h,cpp] Extended the user expression class to keep the state needed to report the persistent variable store for the target to the AST result synthesizers. Also introduced a new error code for expressions that executed normally but did not return a result. CommandObjectExpression.cpp Improved output for expressions (like declarations of new persistent types) that don't return a result. This is no longer treated as an error. Added: lldb/trunk/test/expression_command/persistent_types/ lldb/trunk/test/expression_command/persistent_types/Makefile lldb/trunk/test/expression_command/persistent_types/TestPersistentTypes.py lldb/trunk/test/expression_command/persistent_types/main.c Modified: lldb/trunk/include/lldb/Core/ClangForward.h lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h lldb/trunk/include/lldb/Expression/ClangPersistentVariables.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Expression/ASTResultSynthesizer.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/ClangPersistentVariables.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/include/lldb/Core/ClangForward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ClangForward.h?rev=138383&r1=138382&r2=138383&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ClangForward.h (original) +++ lldb/trunk/include/lldb/Core/ClangForward.h Tue Aug 23 16:20:51 2011 @@ -110,6 +110,7 @@ class TextDiagnosticBuffer; class TranslationUnitDecl; class Type; + class TypeDecl; class TypedefDecl; class TypesCompatibleExpr; class UnaryOperator; Modified: lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h?rev=138383&r1=138382&r2=138383&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h (original) +++ lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h Tue Aug 23 16:20:51 2011 @@ -44,9 +44,15 @@ /// @param[in] desired_type /// The type that the result should have. May be initialized with a /// NULL type, in which case the type is inferred. + /// + /// @param[in] scratch_ast_context + /// If non-NULL, an AST context to populate with the persistent types + /// found in the expression. //---------------------------------------------------------------------- ASTResultSynthesizer(clang::ASTConsumer *passthrough, - TypeFromUser desired_type); + TypeFromUser desired_type, + clang::ASTContext &scratch_ast_context, + ClangPersistentVariables &persistent_vars); //---------------------------------------------------------------------- /// Destructor @@ -140,18 +146,43 @@ bool SynthesizeFunctionResult(clang::FunctionDecl *FunDecl); //---------------------------------------------------------------------- - /// Process a functionbody and produce the result variable and + /// Process a function body and produce the result variable and /// initialization /// /// @param[in] Body /// The body of the function. + /// + /// @param[in] DC + /// The DeclContext of the function, into which the result variable + /// is inserted. //---------------------------------------------------------------------- bool SynthesizeBodyResult(clang::CompoundStmt *Body, clang::DeclContext *DC); + //---------------------------------------------------------------------- + /// Given a DeclContext for a function or method, find all types + /// declared in the context and record any persistent types found. + /// + /// @param[in] FunDeclCtx + /// The context for the function to process. + //---------------------------------------------------------------------- + void RecordPersistentTypes(clang::DeclContext *FunDeclCtx); + + //---------------------------------------------------------------------- + /// Given a TypeDecl, if it declares a type whose name starts with a + /// dollar sign, register it as a pointer type in the target's scratch + /// AST context. + /// + /// @param[in] Body + /// The body of the function. + //---------------------------------------------------------------------- + void MaybeRecordPersistentType(clang::TypeDecl *D); + clang::ASTContext *m_ast_context; ///< The AST context to use for identifiers and types. clang::ASTConsumer *m_passthrough; ///< The ASTConsumer down the chain, for passthrough. NULL if it's a SemaConsumer. clang::SemaConsumer *m_passthrough_sema; ///< The SemaConsumer down the chain, for passthrough. NULL if it's an ASTConsumer. + clang::ASTContext &m_scratch_ast_context; ///< The AST context to install persistent types into. + ClangPersistentVariables &m_persistent_vars;///< The persistent variable manager to register persistent types with. clang::Sema *m_sema; ///< The Sema to use. TypeFromUser m_desired_type; ///< If non-NULL, the type to coerce the result to. }; Modified: lldb/trunk/include/lldb/Expression/ClangPersistentVariables.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangPersistentVariables.h?rev=138383&r1=138382&r2=138383&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangPersistentVariables.h (original) +++ lldb/trunk/include/lldb/Expression/ClangPersistentVariables.h Tue Aug 23 16:20:51 2011 @@ -11,10 +11,11 @@ #define liblldb_ClangPersistentVariables_h_ #include "lldb/Expression/ClangExpressionVariable.h" +#include "llvm/ADT/DenseMap.h" namespace lldb_private { - + //---------------------------------------------------------------------- /// @class ClangPersistentVariables ClangPersistentVariables.h "lldb/Expression/ClangPersistentVariables.h" /// @brief Manages persistent values that need to be preserved between expression invocations. @@ -52,8 +53,18 @@ ConstString GetNextPersistentVariableName (); + void + RegisterPersistentType (const ConstString &name, + clang::TypeDecl *tag_decl); + + clang::TypeDecl * + GetPersistentType (const ConstString &name); + private: - uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName(). + uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName(). + + typedef llvm::DenseMap PersistentTypeMap; + PersistentTypeMap m_persistent_types; ///< The persistent types declared by the user. }; } Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=138383&r1=138382&r2=138383&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Tue Aug 23 16:20:51 2011 @@ -290,7 +290,8 @@ const char *expr_prefix, lldb::ValueObjectSP &result_valobj_sp, Error &error); - + + static const Error::ValueType kNoResult = 0x1001; ///< ValueObject::GetError() returns this if there is no result from the expression. private: //------------------------------------------------------------------ /// Populate m_cplusplus and m_objetivec based on the environment. @@ -320,6 +321,7 @@ bool m_objectivec; ///< True if the expression is compiled as an Objective-C method (true if it was parsed when exe_ctx was in an Objective-C method). bool m_needs_object_ptr; ///< True if "this" or "self" must be looked up and passed in. False if the expression doesn't really use them and they can be NULL. bool m_const_object; ///< True if "this" is const. + Target *m_target; ///< The target for storing persistent data like types and variables. lldb::ClangExpressionVariableSP m_const_result; ///< The statically-computed result of the expression. NULL if it could not be computed statically or the expression has side effects. }; Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=138383&r1=138382&r2=138383&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Aug 23 16:20:51 2011 @@ -347,24 +347,34 @@ } else { - const char *error_cstr = result_valobj_sp->GetError().AsCString(); - if (error_cstr && error_cstr[0]) + if (result_valobj_sp->GetError().GetError() == ClangUserExpression::kNoResult) { - int error_cstr_len = strlen (error_cstr); - const bool ends_with_newline = error_cstr[error_cstr_len - 1] == '\n'; - if (strstr(error_cstr, "error:") != error_cstr) - error_stream->PutCString ("error: "); - error_stream->Write(error_cstr, error_cstr_len); - if (!ends_with_newline) - error_stream->EOL(); + error_stream->PutCString("\n"); + + if (result) + result->SetStatus (eReturnStatusSuccessFinishResult); } else { - error_stream->PutCString ("error: unknown error\n"); + const char *error_cstr = result_valobj_sp->GetError().AsCString(); + if (error_cstr && error_cstr[0]) + { + int error_cstr_len = strlen (error_cstr); + const bool ends_with_newline = error_cstr[error_cstr_len - 1] == '\n'; + if (strstr(error_cstr, "error:") != error_cstr) + error_stream->PutCString ("error: "); + error_stream->Write(error_cstr, error_cstr_len); + if (!ends_with_newline) + error_stream->EOL(); + } + else + { + error_stream->PutCString ("error: unknown error\n"); + } + + if (result) + result->SetStatus (eReturnStatusFailed); } - - if (result) - result->SetStatus (eReturnStatusFailed); } } } Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=138383&r1=138382&r2=138383&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original) +++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Tue Aug 23 16:20:51 2011 @@ -19,19 +19,25 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/raw_ostream.h" #include "lldb/Core/Log.h" +#include "lldb/Expression/ClangPersistentVariables.h" #include "lldb/Expression/ASTResultSynthesizer.h" +#include "lldb/Symbol/ClangASTContext.h" using namespace llvm; using namespace clang; using namespace lldb_private; ASTResultSynthesizer::ASTResultSynthesizer(ASTConsumer *passthrough, - TypeFromUser desired_type) : + TypeFromUser desired_type, + ASTContext &scratch_ast_context, + ClangPersistentVariables &persistent_vars) : m_ast_context (NULL), m_passthrough (passthrough), m_passthrough_sema (NULL), m_sema (NULL), - m_desired_type (desired_type) + m_desired_type (desired_type), + m_scratch_ast_context (scratch_ast_context), + m_persistent_vars (persistent_vars) { if (!m_passthrough) return; @@ -87,6 +93,7 @@ if (m_ast_context && !method_decl->getSelector().getAsString().compare("$__lldb_expr:")) { + RecordPersistentTypes(method_decl); SynthesizeObjCMethodResult(method_decl); } } @@ -95,6 +102,7 @@ if (m_ast_context && !function_decl->getNameInfo().getAsString().compare("$__lldb_expr")) { + RecordPersistentTypes(function_decl); SynthesizeFunctionResult(function_decl); } } @@ -397,9 +405,51 @@ m_passthrough->HandleTranslationUnit(Ctx); } +void +ASTResultSynthesizer::RecordPersistentTypes(DeclContext *FunDeclCtx) +{ + typedef DeclContext::specific_decl_iterator TypeDeclIterator; + + for (TypeDeclIterator i = TypeDeclIterator(FunDeclCtx->decls_begin()), + e = TypeDeclIterator(FunDeclCtx->decls_end()); + i != e; + ++i) + { + MaybeRecordPersistentType(*i); + } +} + void -ASTResultSynthesizer::HandleTagDeclDefinition(TagDecl *D) +ASTResultSynthesizer::MaybeRecordPersistentType(TypeDecl *D) { + if (!D->getIdentifier()) + return; + + StringRef name = D->getName(); + + if (name.size() == 0 || name[0] != '$') + return; + + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + ConstString name_cs(name.str().c_str()); + + if (log) + log->Printf ("Recording persistent type %s\n", name_cs.GetCString()); + + Decl *D_scratch = ClangASTContext::CopyDecl(&m_scratch_ast_context, + m_ast_context, + D); + + TypeDecl *TD_scratch = dyn_cast(D_scratch); + + if (TD_scratch) + m_persistent_vars.RegisterPersistentType(name_cs, TD_scratch); +} + +void +ASTResultSynthesizer::HandleTagDeclDefinition(TagDecl *D) +{ if (m_passthrough) m_passthrough->HandleTagDeclDefinition(D); } Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=138383&r1=138382&r2=138383&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Aug 23 16:20:51 2011 @@ -1945,6 +1945,42 @@ return; } + do + { + if (!m_parser_vars->m_exe_ctx->target) + break; + + ClangASTContext *scratch_clang_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext(); + + if (!scratch_clang_ast_context) + break; + + ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext(); + + if (!scratch_ast_context) + break; + + TypeDecl *ptype_type_decl = m_parser_vars->m_persistent_vars->GetPersistentType(name); + + if (!ptype_type_decl) + break; + + Decl *parser_ptype_decl = ClangASTContext::CopyDecl(context.GetASTContext(), scratch_ast_context, ptype_type_decl); + + if (!parser_ptype_decl) + break; + + TypeDecl *parser_ptype_type_decl = dyn_cast(parser_ptype_decl); + + if (!parser_ptype_type_decl) + break; + + if (log) + log->Printf("Found persistent type %s", name.GetCString()); + + context.AddNamedDecl(parser_ptype_type_decl); + } while (0); + ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariable(name)); if (pvar_sp) Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=138383&r1=138382&r2=138383&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Tue Aug 23 16:20:51 2011 @@ -234,6 +234,7 @@ m_compiler->getLangOpts().ThreadsafeStatics = false; m_compiler->getLangOpts().AccessControl = false; // Debuggers get universal access m_compiler->getLangOpts().DollarIdents = true; // $ indicates a persistent variable name + //m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients // Set CodeGen options m_compiler->getCodeGenOpts().EmitDeclMetadata = true; Modified: lldb/trunk/source/Expression/ClangPersistentVariables.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangPersistentVariables.cpp?rev=138383&r1=138382&r2=138383&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangPersistentVariables.cpp (original) +++ lldb/trunk/source/Expression/ClangPersistentVariables.cpp Tue Aug 23 16:20:51 2011 @@ -13,6 +13,8 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/Value.h" +#include "llvm/ADT/StringMap.h" + using namespace lldb; using namespace lldb_private; @@ -53,3 +55,21 @@ ConstString name(name_cstr); return name; } + +void +ClangPersistentVariables::RegisterPersistentType (const ConstString &name, + clang::TypeDecl *type_decl) +{ + m_persistent_types.insert(std::pair(name.GetCString(), type_decl)); +} + +clang::TypeDecl * +ClangPersistentVariables::GetPersistentType (const ConstString &name) +{ + PersistentTypeMap::const_iterator i = m_persistent_types.find(name.GetCString()); + + if (i == m_persistent_types.end()) + return NULL; + else + return i->second; +} Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=138383&r1=138382&r2=138383&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Aug 23 16:20:51 2011 @@ -53,7 +53,8 @@ m_objectivec (false), m_needs_object_ptr (false), m_const_object (false), - m_const_result () + m_const_result (), + m_target (NULL) { } @@ -64,8 +65,15 @@ clang::ASTConsumer * ClangUserExpression::ASTTransformer (clang::ASTConsumer *passthrough) { + ClangASTContext *clang_ast_context = m_target->GetScratchClangASTContext(); + + if (!clang_ast_context) + return NULL; + return new ASTResultSynthesizer(passthrough, - m_desired_type); + m_desired_type, + *m_target->GetScratchClangASTContext()->getASTContext(), + m_target->GetPersistentVariables()); } void @@ -88,6 +96,8 @@ if (!decl_context) return; + + m_target = exe_ctx.target; if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast(decl_context)) { @@ -718,7 +728,7 @@ if (log) log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with no result =="); - error.SetErrorString ("Expression did not return a result"); + error.SetError(ClangUserExpression::kNoResult, lldb::eErrorTypeGeneric); } } } Added: lldb/trunk/test/expression_command/persistent_types/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/persistent_types/Makefile?rev=138383&view=auto ============================================================================== --- lldb/trunk/test/expression_command/persistent_types/Makefile (added) +++ lldb/trunk/test/expression_command/persistent_types/Makefile Tue Aug 23 16:20:51 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/expression_command/persistent_types/TestPersistentTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/persistent_types/TestPersistentTypes.py?rev=138383&view=auto ============================================================================== --- lldb/trunk/test/expression_command/persistent_types/TestPersistentTypes.py (added) +++ lldb/trunk/test/expression_command/persistent_types/TestPersistentTypes.py Tue Aug 23 16:20:51 2011 @@ -0,0 +1,41 @@ +""" +Test that lldb persistent types works correctly. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class PersistenttypesTestCase(TestBase): + + mydir = os.path.join("expression_command", "persistent_types") + + def test_persistent_types(self): + """Test that lldb persistent types works correctly.""" + self.buildDefault() + + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.runCmd("breakpoint set --name main") + + self.runCmd("run", RUN_SUCCEEDED) + + self.runCmd("expression struct $foo { int a; int b; };") + + self.expect("expression struct $foo $my_foo; $my_foo.a = 2; $my_foo.b = 3;", + startstr = "(int) $0 = 3") + + self.expect("expression $my_foo", + substrs = ['a = 2', 'b = 3']) + + self.runCmd("expression typedef int $bar") + + self.expect("expression $bar i = 5; i", + startstr = "($bar) $1 = 5") + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/expression_command/persistent_types/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/persistent_types/main.c?rev=138383&view=auto ============================================================================== --- lldb/trunk/test/expression_command/persistent_types/main.c (added) +++ lldb/trunk/test/expression_command/persistent_types/main.c Tue Aug 23 16:20:51 2011 @@ -0,0 +1,13 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main (int argc, char const *argv[]) +{ + return 0; +} From granata.enrico at gmail.com Tue Aug 23 16:26:09 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Tue, 23 Aug 2011 21:26:09 -0000 Subject: [Lldb-commits] [lldb] r138384 - in /lldb/trunk: source/Core/Debugger.cpp source/Core/FormatManager.cpp source/Core/ValueObject.cpp test/functionalities/data-formatter/rdar-9974002/ test/functionalities/data-formatter/rdar-9974002/Makefile test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py test/functionalities/data-formatter/rdar-9974002/main.cpp www/varformats.html Message-ID: <20110823212609.D296C2A6C12C@llvm.org> Author: enrico Date: Tue Aug 23 16:26:09 2011 New Revision: 138384 URL: http://llvm.org/viewvc/llvm-project?rev=138384&view=rev Log: Improved the user-friendliness of errors shown by the summary feature in certain areas Renamed format "signed decimal" to be "decimal". "unsigned decimal" remains unchanged: - the name "signed decimal" was interfering with symbol %S (use summary) in summary strings. because of the way summary strings are implemented, this did not really lead to a bug, but simply to performing more steps than necessary to display a summary. this is fixed. Documentation improvements (more on synthetic children, some information on filters). This is still a WIP. Added: lldb/trunk/test/functionalities/data-formatter/rdar-9974002/ lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Makefile lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py lldb/trunk/test/functionalities/data-formatter/rdar-9974002/main.cpp Modified: lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/FormatManager.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/www/varformats.html Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=138384&r1=138383&r2=138384&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Tue Aug 23 16:26:09 2011 @@ -1186,11 +1186,16 @@ } else { - // if ${var} - if (was_plain_var) + if (was_plain_var) // if ${var} { s << target->GetTypeName() << " @ " << target->GetLocationAsCString(); } + else if (is_pointer) // if pointer, value is the address stored + { + var_success = target->GetPrintableRepresentation(s, + val_obj_display, + custom_format); + } else { s << ""; Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=138384&r1=138383&r2=138384&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Tue Aug 23 16:26:09 2011 @@ -39,7 +39,7 @@ { eFormatCharPrintable , 'C' , "printable character" }, { eFormatComplexFloat , 'F' , "complex float" }, { eFormatCString , 's' , "c-string" }, - { eFormatDecimal , 'i' , "signed decimal" }, + { eFormatDecimal , 'i' , "decimal" }, { eFormatEnum , 'E' , "enumeration" }, { eFormatHex , 'x' , "hex" }, { eFormatFloat , 'f' , "float" }, Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=138384&r1=138383&r2=138384&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Tue Aug 23 16:26:09 2011 @@ -1021,7 +1021,18 @@ if (return_value) s.PutCString(return_value); else - s.PutCString(""); + { + if (m_error.Fail()) + s.Printf("<%s>", m_error.AsCString()); + else if (val_obj_display == eDisplaySummary) + s.PutCString(""); + else if (val_obj_display == eDisplayValue) + s.PutCString(""); + else if (val_obj_display == eDisplayLanguageSpecific) + s.PutCString(""); // edit this if we have other runtimes that support a description + else + s.PutCString(""); + } // we should only return false here if we could not do *anything* // even if we have an error message as output, that's a success Added: lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Makefile?rev=138384&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Makefile (added) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Makefile Tue Aug 23 16:26:09 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py?rev=138384&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py (added) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py Tue Aug 23 16:26:09 2011 @@ -0,0 +1,146 @@ +""" +Test lldb data formatter subsystem. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class DataFormatterTestCase(TestBase): + + # test for rdar://problem/9974002 () + mydir = os.path.join("functionalities", "data-formatter", "rdar-9974002") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_run_command(self): + """Test data formatter commands.""" + self.buildDsym() + self.data_formatter_commands() + + def test_with_dwarf_and_run_command(self): + """Test data formatter commands.""" + self.buildDwarf() + self.data_formatter_commands() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break at. + self.line = line_number('main.cpp', '// Set break point at this line.') + + def data_formatter_commands(self): + """Test that that file and class static variables display correctly.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.expect("breakpoint set -f main.cpp -l %d" % self.line, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" % + self.line) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type summary clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', '']) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', '0x000000']) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', '0x000000']) + + self.runCmd("type summary add -s foo contained") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', 'foo']) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', 'foo']) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', '0x000000']) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', '']) + + self.runCmd("type summary delete contained") + self.runCmd("n") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', '']) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', '0x000000']) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%S}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', '0x000000']) + + self.runCmd("type summary add -s foo contained") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', 'foo']) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', 'foo']) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer%V}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', '0x000000']) + + self.runCmd("type summary add -s \"${var.scalar} and ${var.pointer.first}\" container") + + self.expect('frame variable mine', + substrs = ['mine = ', + '1', '']) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/data-formatter/rdar-9974002/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9974002/main.cpp?rev=138384&view=auto ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9974002/main.cpp (added) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9974002/main.cpp Tue Aug 23 16:26:09 2011 @@ -0,0 +1,30 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +struct contained +{ + int first; + int second; +}; + +struct container +{ + int scalar; + struct contained *pointer; +}; + +int main () +{ + struct container mine = {1, 0}; + printf ("Mine's scalar is the only thing that is good: %d.\n", mine.scalar); // Set break point at this line. + return 0; +} + Modified: lldb/trunk/www/varformats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/varformats.html?rev=138384&r1=138383&r2=138384&view=diff ============================================================================== --- lldb/trunk/www/varformats.html (original) +++ lldb/trunk/www/varformats.html Tue Aug 23 16:26:09 2011 @@ -159,11 +159,11 @@

    (lldb) type format add -f float32[] int
    - (lldb) fr var pointer *pointer -T
    + (lldb) frame variable pointer *pointer -T
    (int *) pointer = {1.46991e-39 1.4013e-45}
    (int) *pointer = {1.53302e-42}
    (lldb) type format add -f float32[] int -p
    - (lldb) fr var pointer *pointer -T
    + (lldb) frame variable pointer *pointer -T
    (int *) pointer = 0x0000000100100180
    (int) *pointer = {1.53302e-42}

    @@ -390,7 +390,7 @@ information from classes, structures, ... (aggregate types) and arranging it in a user-defined format, as in the following example:

    before adding a summary...
    - (lldb) fr var -T one
    + (lldb) frame variable -T one
    (i_am_cool) one = {
        (int) integer = 3
        (float) floating = 3.14159
    @@ -398,7 +398,7 @@ }

    after adding a summary...
    - (lldb) fr var one
    + (lldb) frame variable one
    (i_am_cool) one = int = 3, float = 3.14159, char = 69

    @@ -409,7 +409,7 @@

    In the example, the command we type was:

    - (lldb) type summary add -f "int = ${var.integer}, float = ${var.floating}, char = ${var.character%u}" i_am_cool + (lldb) type summary add --summary-string "int = ${var.integer}, float = ${var.floating}, char = ${var.character%u}" i_am_cool
    @@ -546,7 +546,7 @@ dereferencing symbol only applies to the result of the whole expression path traversing.
    e.g.
    - (lldb) fr var -T c
    + (lldb) frame variable -T c
    (Couple) c = {
        (SimpleWithPointers) sp = {
            (int *) x = 0x00000001001000b0
    @@ -561,7 +561,7 @@
    - (lldb) type summary add -f "int = ${*var.sp.x}, + (lldb) type summary add --summary-string "int = ${*var.sp.x}, float = ${*var.sp.y}, char = ${*var.sp.z%u}, Simple = ${*var.s}" Couple
    (lldb) type summary add -c -p Simple
    @@ -570,7 +570,7 @@ the output becomes:
    - (lldb) fr var c
    + (lldb) frame variable c
    (Couple) c = int = 9, float = 9.99, char = 88, Simple = (x=9, y=9.99, z='X')

    @@ -584,7 +584,7 @@ produce the same output:
    - (lldb) type summary add -f "int = ${*var.sp.x}, + (lldb) type summary add --summary-string "int = ${*var.sp.x}, float = ${*var.sp.y}, char = ${*var.sp.z%u}, Simple = ${var.s}" Couple
    (lldb) type summary add -c Simple
    @@ -612,18 +612,18 @@ similar to that used for arrays, just you can also give a pair of indices separated by a -.
    e.g.
    - (lldb) fr var float_point
    + (lldb) frame variable float_point
    (float) float_point = -3.14159
    - (lldb) type summary add -f "Sign: ${var[31]%B} + (lldb) type summary add --summary-string "Sign: ${var[31]%B} Exponent: ${var[30-23]%x} Mantissa: ${var[0-22]%u}" float

    - (lldb) fr var float_point
    + (lldb) frame variable float_point
    (float) float_point = -3.14159 Sign: true Exponent: 0x00000080 Mantissa: 4788184
    In this example, LLDB shows the internal @@ -645,7 +645,7 @@ LLDB to format arrays in special ways, possibly independent of the way the array members' datatype is formatted.
    e.g.
    - (lldb) fr var sarray
    + (lldb) frame variable sarray
    (Simple [3]) sarray = {
        [0] = {
            x = 1
    @@ -666,13 +666,13 @@
    - (lldb) type summary add -f "${var[].x}" "Simple + (lldb) type summary add --summary-string "${var[].x}" "Simple [3]"

    - (lldb) fr var sarray
    + (lldb) frame variable sarray
    (Simple [3]) sarray = [1,4,7]

    The [] symbol amounts to: if var @@ -683,7 +683,7 @@ If you find some of those integers anomalous, you can then inspect that one item in greater detail, without the array format getting in the way:
    - (lldb) fr var sarray[1]
    + (lldb) frame variable sarray[1]
    (Simple) sarray[1] = {
        x = 4
        y = 5
    @@ -695,12 +695,12 @@ for bitfields:

    - (lldb) type summary add -f "${var[1-2].x}" "Simple + (lldb) type summary add --summary-string "${var[1-2].x}" "Simple [3]"

    - (lldb) fr var sarray
    + (lldb) frame variable sarray
    (Simple [3]) sarray = [4,7]

    The same logic works if you are printing a pointer @@ -716,7 +716,7 @@ omitting square brackets, as in:

    - (lldb) type summary add -f "${var%s}" "char *" + (lldb) type summary add --summary-string "${var%s}" "char *"
    @@ -734,7 +734,7 @@ type, even if square brackets are omitted.
    - (lldb) type summary add -f "${var%int32_t[]}" "int [10]" + (lldb) type summary add --summary-string "${var%int32_t[]}" "int [10]"
    @@ -836,7 +836,7 @@

    If you need to delve into several levels of hierarchy, as you can do with summary - strings, you must use the method GetValueForExpressionPath(), passing it + strings, you can use the method GetValueForExpressionPath(), passing it an expression path just like those you could use for summary strings. However, if you need to access array slices, you cannot do that (yet) via this method call, and you must use GetChildMemberWithName() querying it for the array items one by one. @@ -845,12 +845,12 @@ to input a Python script as a summary:

      -
    • using the -s option to type summary add and typing the script +
    • using the --python-script option to type summary add and typing the script code as an option argument; as in:
    - - - @@ -264,11 +264,11 @@ - + + an integer with sign) @@ -301,20 +301,20 @@ + e.g. (float) x = '\n\x1f\xd7\n' + e.g. (float) x = 0xd70a 0x411f + e.g. (float) x = 0x411fd70a @@ -348,8 +348,8 @@ + (int) x = {1 0 0 0} (with uint8_t[])
    + (int) y = {0x00000001} (with uint32_t[])
    @@ -406,7 +406,7 @@ summary string to the datatype; the second is to bind a Python script to the datatype. Both options are enabled by the type summary add command.

    -

    In the example, the command we type was:

    +

    The command to obtain the output shown in the example is:

    - (lldb) type summary add -s "height = + (lldb) type summary add --python-script "height = int(valobj.GetChildMemberWithName('height').GetValue());width = int(valobj.GetChildMemberWithName('width').GetValue()); return 'Area: ' + str(height*width)" Rectangle
    @@ -885,13 +885,13 @@
    - (lldb) type summary add -f "${var[].x}" + (lldb) type summary add --summary-string "${var[].x}" -x "Simple \[[0-9]+\]"
    - (lldb) fr var sarray
    + (lldb) frame variable sarray
    (Simple [3]) sarray = [1,4,7]
    The above scenario works for Simple [3] as well as for any other array of Simple @@ -905,6 +905,9 @@ matching. Thus, if your type has a base class with a cascading summary, this will be preferred over any regular expression match for your type itself.

    + +

    The regular expression language used by LLDB is the POSIX extended regular expression language, as defined by the SUS. + @@ -924,12 +927,12 @@

    - (lldb) type summary add -f "x=${var.integer}" --name NamedSummary + (lldb) type summary add --summary-string "x=${var.integer}" --name NamedSummary
    - (lldb) fr var one
    + (lldb) frame variable one
    (i_am_cool) one = int = 3, float = 3.14159, char = 69
    - (lldb) fr var one --summary NamedSummary
    + (lldb) frame variable one --summary NamedSummary
    (i_am_cool) one = x=3

    @@ -959,9 +962,9 @@

    For instance, consider an STL vector:

    (lldb) frame variable numbers -T
    - (std::vector) numbers = {
    -    (std::_Vector_base >) std::_Vector_base > = {
    -        (std::_Vector_base >::_Vector_impl) _M_impl = {
    + (std::vector<int>) numbers = {
    +    (std::_Vector_base<int, std::allocator<int> >) std::_Vector_base<int, std::allocator<int> > = {
    +        (std::_Vector_base<int, std::allocator&tl;int> >::_Vector_impl) _M_impl = {
                (int *) _M_start = 0x00000001001008a0
                (int *) _M_finish = 0x00000001001008a8
                (int *) _M_end_of_storage = 0x00000001001008a8
    @@ -974,7 +977,7 @@

    What you would like to see is probably something like:

    (lldb) frame variable numbers -T
    - (std::vector) numbers = {
    + (std::vector<int>) numbers = {
        (int) [0] = 1
        (int) [1] = 12
        (int) [2] = 123
    @@ -1004,8 +1007,83 @@ of LLDB.

    For examples of how synthetic children are created, you are encouraged to look at examples/synthetic in the LLDB trunk.

    + +

    Once a synthetic children provider is written, one must load it into LLDB before it can be used. + Currently, one can use the LLDB script command to type Python code interactively, + or use the script import module command to load Python code from a Python module + (ordinary rules apply to importing modules this way). A third option is to type the code for + the provider class interactively while adding it.

    + +

    For example, let's pretend we have a class Foo for which a synthetic children provider class Foo_Provider + is available, in a Python module named Foo_Tools. The following interaction sets Foo_Provider as a synthetic + children provider in LLDB:

    + +
    + +
    + (lldb) script import Foo_Tools
    + (lldb) type synthetic add Foo --python-class Foo_Tools.Foo_Provider +
    + (lldb) frame variable a_foo
    + (Foo) a_foo = {
    +     x = 1
    +     y = "Hello world"
    + }
    +

    + +

    Currently, in LLDB top of tree, synthetic children providers are enabled for + std::vector<T>, std::list<T> and std::map<K,V>.

    + +

    Synthetic children enable a new symbol for summary strings, ${svar. This symbol tells LLDB to refer expression paths to the + synthetic children instead of the real ones. While in certain cases, you can use ${var.synthetic-child-path} and LLDB will + access the synthetic child correctly, it is best to always use ${svar to refer to synthetic children. For instance,

    + +
    + +
    + (lldb) type summary add --expand -x "std::vector<" --summary-string "${svar%#} items" +
    + (lldb) frame variable numbers
    + (std::vector<int>) numbers = 4 items {
    +     (int) [0] = 1
    +     (int) [1] = 12
    +     (int) [2] = 123
    +     (int) [3] = 1234
    + }
    +

    + + +
    +

    Filters

    +
    + +

    Filters are a solution to the display of complex classes. + At times, classes have many member variables but not all of these are actually + necessary for the user to see.

    +

    A filter will solve this issue by only letting the user see those member + variables he cares about. Of course, the equivalent of a filter can be implemented easily + using synthetic children, but a filter lets you get the job done without having to write + Python code.

    +

    For instance, if your class Foobar has member variables named A thru Z, but you only need to see + the ones named B, H and Q, you can define a filter: +

    + +
    + (lldb) type filter add Foo --child B --child H --child Q +
    + (lldb) frame variable a_foobar
    + (Foobar) a_foobar = {
    +     (int) B = 1
    +     (char) H = 'H'
    +     (std::string) Q = "Hello world"
    + }
    +

    + + + +

    Finding formatters 101

    From granata.enrico at gmail.com Tue Aug 23 16:29:50 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Tue, 23 Aug 2011 21:29:50 -0000 Subject: [Lldb-commits] [lldb] r138385 - in /lldb/trunk/include/lldb: Target/StackFrame.h lldb-private-enumerations.h Message-ID: <20110823212950.67D302A6C12C@llvm.org> Author: enrico Date: Tue Aug 23 16:29:50 2011 New Revision: 138385 URL: http://llvm.org/viewvc/llvm-project?rev=138385&view=rev Log: Fixing commas in enums (build breaker on GCC) as reported by Filipe Cabecinhas Modified: lldb/trunk/include/lldb/Target/StackFrame.h lldb/trunk/include/lldb/lldb-private-enumerations.h Modified: lldb/trunk/include/lldb/Target/StackFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=138385&r1=138384&r2=138385&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StackFrame.h (original) +++ lldb/trunk/include/lldb/Target/StackFrame.h Tue Aug 23 16:29:50 2011 @@ -35,7 +35,7 @@ eExpressionPathOptionCheckPtrVsMember = (1u << 0), eExpressionPathOptionsNoFragileObjcIvar = (1u << 1), eExpressionPathOptionsNoSyntheticChildren = (1u << 2), - eExpressionPathOptionsNoSyntheticArrayRange = (1u << 3), + eExpressionPathOptionsNoSyntheticArrayRange = (1u << 3) }; //------------------------------------------------------------------ // Constructors and Destructors Modified: lldb/trunk/include/lldb/lldb-private-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-enumerations.h?rev=138385&r1=138384&r2=138385&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-private-enumerations.h Tue Aug 23 16:29:50 2011 @@ -211,7 +211,7 @@ eFormatCategoryItemFilter = 0x0004, eFormatCategoryItemRegexFilter = 0x0008, eFormatCategoryItemSynth = 0x0010, - eFormatCategoryItemRegexSynth = 0x0020, + eFormatCategoryItemRegexSynth = 0x0020 } FormatCategoryItem; } // namespace lldb From johnny.chen at apple.com Tue Aug 23 16:54:11 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 23 Aug 2011 21:54:11 -0000 Subject: [Lldb-commits] [lldb] r138391 - /lldb/trunk/test/make/Makefile.rules Message-ID: <20110823215411.129762A6C12C@llvm.org> Author: johnny Date: Tue Aug 23 16:54:10 2011 New Revision: 138391 URL: http://llvm.org/viewvc/llvm-project?rev=138391&view=rev Log: Make clang the default compiler for building the test programs. 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=138391&r1=138390&r2=138391&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Tue Aug 23 16:54:10 2011 @@ -23,14 +23,14 @@ endif #---------------------------------------------------------------------- -# CC defaults to gcc. +# CC defaults to clang. # See also these functions: # o cxx_compiler # o cxx_linker #---------------------------------------------------------------------- -CC ?= gcc +CC ?= clang ifeq "$(CC)" "cc" - CC = gcc + CC = clang endif #---------------------------------------------------------------------- From johnny.chen at apple.com Tue Aug 23 17:10:17 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 23 Aug 2011 22:10:17 -0000 Subject: [Lldb-commits] [lldb] r138393 - /lldb/trunk/test/lang/cpp/this/TestCPPThis.py Message-ID: <20110823221017.901A42A6C12C@llvm.org> Author: johnny Date: Tue Aug 23 17:10:17 2011 New Revision: 138393 URL: http://llvm.org/viewvc/llvm-project?rev=138393&view=rev Log: Skip these two cases temporarily while investigating the crash on OSX Lion with clang as the compiler. Modified: lldb/trunk/test/lang/cpp/this/TestCPPThis.py Modified: lldb/trunk/test/lang/cpp/this/TestCPPThis.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/this/TestCPPThis.py?rev=138393&r1=138392&r2=138393&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/this/TestCPPThis.py (original) +++ lldb/trunk/test/lang/cpp/this/TestCPPThis.py Tue Aug 23 17:10:17 2011 @@ -8,6 +8,7 @@ mydir = os.path.join("lang", "cpp", "this") + @unittest2.skip("segmentation fault -- skipping") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") #rdar://problem/9962849 @expectedFailureClang @@ -16,6 +17,7 @@ self.buildDsym() self.static_method_commands() + @unittest2.skip("segmentation fault -- skipping") #rdar://problem/9962849 @expectedFailureClang def test_with_dwarf_and_run_command(self): From johnny.chen at apple.com Tue Aug 23 17:32:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 23 Aug 2011 22:32:45 -0000 Subject: [Lldb-commits] [lldb] r138399 - in /lldb/trunk/test/functionalities/data-formatter: data-formatter-advanced/ data-formatter-categories/ data-formatter-cpp/ data-formatter-globals/ data-formatter-named-summaries/ data-formatter-objc/ data-formatter-python-synth/ data-formatter-script/ data-formatter-skip-summary/ data-formatter-smart-array/ data-formatter-synth/ rdar-9973865/ rdar-9973992/ rdar-9974002/ Message-ID: <20110823223245.6F6FC2A6C12C@llvm.org> Author: johnny Date: Tue Aug 23 17:32:45 2011 New Revision: 138399 URL: http://llvm.org/viewvc/llvm-project?rev=138399&view=rev Log: Uniquefy the various data-formatter test class names so that: ./dotest.py -v -f DataFormatterTestCase.test_with_dsym_and_run_command will not end up running 14 tests. Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py lldb/trunk/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class AdvDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-advanced") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class CategoriesDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-categories") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class CppDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-cpp") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class GlobalsDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-globals") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class NamedSummariesDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-named-summaries") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class ObjCDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-objc") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class PythonSynthDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-python-synth") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class ScriptDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-script") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class SkipSummaryDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-skip-summary") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class SmartArrayDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-smart-array") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class SynthDataFormatterTestCase(TestBase): mydir = os.path.join("functionalities", "data-formatter", "data-formatter-synth") Modified: lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py (original) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class Radar9973865DataFormatterTestCase(TestBase): # test for rdar://problem/9973865 (If you use "${var}" in the summary string for an aggregate type, the summary doesn't print for a pointer to that type) mydir = os.path.join("functionalities", "data-formatter", "rdar-9973865") Modified: lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py (original) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9973992/Test-rdar-9973992.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class Radar9973992DataFormatterTestCase(TestBase): # test for rdar://problem/9973992 (What should we do for "${var}" in summaries of aggregate types?) mydir = os.path.join("functionalities", "data-formatter", "rdar-9973992") Modified: lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py?rev=138399&r1=138398&r2=138399&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py (original) +++ lldb/trunk/test/functionalities/data-formatter/rdar-9974002/Test-rdar-9974002.py Tue Aug 23 17:32:45 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class DataFormatterTestCase(TestBase): +class Radar9974002DataFormatterTestCase(TestBase): # test for rdar://problem/9974002 () mydir = os.path.join("functionalities", "data-formatter", "rdar-9974002") From johnny.chen at apple.com Tue Aug 23 17:36:23 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 23 Aug 2011 22:36:23 -0000 Subject: [Lldb-commits] [lldb] r138403 - /lldb/trunk/lib/Makefile Message-ID: <20110823223623.EE2A62A6C12C@llvm.org> Author: johnny Date: Tue Aug 23 17:36:23 2011 New Revision: 138403 URL: http://llvm.org/viewvc/llvm-project?rev=138403&view=rev Log: Patch by Filipe to build lldb usng 'make'! Modified: lldb/trunk/lib/Makefile Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=138403&r1=138402&r2=138403&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Tue Aug 23 17:36:23 2011 @@ -60,7 +60,8 @@ clangParse.a \ clangSema.a \ clangSerialization.a \ - EnhancedDisassembly.a + EnhancedDisassembly.a \ + LLVMMCDisassembler.a include $(LLDB_LEVEL)/../../Makefile.config From granata.enrico at gmail.com Tue Aug 23 20:32:46 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 24 Aug 2011 01:32:46 -0000 Subject: [Lldb-commits] [lldb] r138421 - in /lldb/trunk: examples/synthetic/StdVectorSynthProvider.py www/varformats.html Message-ID: <20110824013246.335EB2A6C12C@llvm.org> Author: enrico Date: Tue Aug 23 20:32:46 2011 New Revision: 138421 URL: http://llvm.org/viewvc/llvm-project?rev=138421&view=rev Log: More documentation changes (WIP) Modified: lldb/trunk/examples/synthetic/StdVectorSynthProvider.py lldb/trunk/www/varformats.html Modified: lldb/trunk/examples/synthetic/StdVectorSynthProvider.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/StdVectorSynthProvider.py?rev=138421&r1=138420&r2=138421&view=diff ============================================================================== --- lldb/trunk/examples/synthetic/StdVectorSynthProvider.py (original) +++ lldb/trunk/examples/synthetic/StdVectorSynthProvider.py Tue Aug 23 20:32:46 2011 @@ -2,19 +2,20 @@ def __init__(self, valobj, dict): self.valobj = valobj; - self.update() + self.update() # initialize this provider def num_children(self): - start_val = self.start.GetValueAsUnsigned(0) - finish_val = self.finish.GetValueAsUnsigned(0) - end_val = self.end.GetValueAsUnsigned(0) + start_val = self.start.GetValueAsUnsigned(0) # read _M_start + finish_val = self.finish.GetValueAsUnsigned(0) # read _M_finish + end_val = self.end.GetValueAsUnsigned(0) # read _M_end_of_storage + # Before a vector has been constructed, it will contain bad values # so we really need to be careful about the length we return since # unitialized data can cause us to return a huge number. We need # to also check for any of the start, finish or end of storage values # being zero (NULL). If any are, then this vector has not been # initialized yet and we should return zero - + # Make sure nothing is NULL if start_val == 0 or finish_val == 0 or end_val == 0: return 0 @@ -25,23 +26,46 @@ if finish_val > end_val: return 0 + # pointer arithmetic: (_M_finish - _M_start) would return the number of + # items of type T contained in the vector. because Python has no way to know + # that we want to subtract two pointers instead of two integers, we have to divide + # by sizeof(T) to be equivalent to the C++ pointer expression num_children = (finish_val-start_val)/self.data_size return num_children + # we assume we are getting children named [0] thru [N-1] + # if for some reason our child name is not in this format, + # do not bother to show it, and return an invalid value def get_child_index(self,name): - return int(name.lstrip('[').rstrip(']')) + try: + return int(name.lstrip('[').rstrip(']')) + except: + return -1; def get_child_at_index(self,index): + # LLDB itself should never query for children < 0, but this might come + # from someone asking for a nonexisting child and getting -1 as index + if index < 0: + return None if index >= self.num_children(): return None; - offset = index * self.data_size - return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) - + # *(_M_start + index), or equivalently _M_start[index] is C++ code to + # read the index-th item of the vector. in Python we must make an offset + # that is index * sizeof(T), and then grab the value at that offset from + # _M_start + offset = index * self.data_size # index * sizeof(T) + return self.start.CreateChildAtOffset('['+str(index)+']',offset,self.data_type) # *(_M_start + index) + + # an std::vector contains an object named _M_impl, which in turn contains + # three pointers, _M_start, _M_end and _M_end_of_storage. _M_start points to the + # beginning of the data area, _M_finish points to where the current vector elements + # finish, and _M_end_of_storage is the end of the currently alloc'ed memory portion + # (to allow resizing, a vector may allocate more memory than required) def update(self): impl = self.valobj.GetChildMemberWithName('_M_impl') self.start = impl.GetChildMemberWithName('_M_start') self.finish = impl.GetChildMemberWithName('_M_finish') self.end = impl.GetChildMemberWithName('_M_end_of_storage') - self.data_type = self.start.GetType().GetPointeeType() - self.data_size = self.data_type.GetByteSize() + self.data_type = self.start.GetType().GetPointeeType() # _M_start is defined as a T* + self.data_size = self.data_type.GetByteSize() # sizeof(T) Modified: lldb/trunk/www/varformats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/varformats.html?rev=138421&r1=138420&r2=138421&view=diff ============================================================================== --- lldb/trunk/www/varformats.html (original) +++ lldb/trunk/www/varformats.html Tue Aug 23 20:32:46 2011 @@ -1006,7 +1006,9 @@ Currently this method is optional, because the internal state of synthetic children providers will not be preserved. However, this is meant to change in future versions of LLDB.
    -

    For examples of how synthetic children are created, you are encouraged to look at examples/synthetic in the LLDB trunk.

    +

    For examples of how synthetic children are created, you are encouraged to look at examples/synthetic in the LLDB trunk. + You may especially want to begin looking at StdVector to get + a feel for this feature.

    Once a synthetic children provider is written, one must load it into LLDB before it can be used. Currently, one can use the LLDB script command to type Python code interactively, @@ -1084,14 +1086,41 @@

    - +
    +

    Categories

    +
    +

    Categories are a way to group related formatters. For instance, LLDB itself groups + the formatters for the C++ STL objects in a category named gnu-libstdc++. + Basically, categories act like containers in which to store formatters for a same library + or OS release.

    +

    By default, three categories are created in LLDB: system, gnu-libstdc++ and default. + Every formatter that is not created inside a category, is by default a part of the default category. + If you want to use a custom category for your formatters, all the type ... add (except for type format add), + provide a --category (-w) option, that names the category to add the formatter to. + To delete the formatter, you then have to specify the correct category.

    +

    Categories can be in one of two states: enabled and disabled. A category is initially disabled, + and can be enabled using the type category enable command. To disable an enabled category, + the command to use is type category disable. The order in which categories are enabled or disabled + is significant, in that LLDB uses that order when looking for formatters. Therefore, when you enable a category, it becomes + the first one to be searched. The default categories are enabled in the order: default as first, then + gnu-libstdc++, and finally system. As said, gnu-libstdc++ contains formatters for C++ STL + data types. system contains formatters for char* and char[], which are expected to be + consistent throughout libraries and systems, and replace

    +

    Categories are a way to group related formatters. For instance, LLDB itself groups + the formatters for the C++ STL objects in a category named gnu-libstdc++

    +
    +
    +

    Finding formatters 101

    While the rules for finding an appropriate format for a type are relatively simple (just go through typedef hierarchies), searching formatters for a type goes through - a rather intricate set of rules. Namely, what happens is:

    + a rather intricate set of rules. Namely, what happens is that LLDB + starts looking in each enabled category, according to the order in which + they were enabled (latest enabled first). In each category, LLDB does + the following:

    • If there is a formatter for the type of the variable, use it
    • @@ -1125,6 +1154,11 @@ looking for regular expressions instead of exact matches
    +

    If any of those attempts returned a valid formatter to be used, + that one is used, and the search is terminated (without going to look + in other categories). If nothing was found in the current category, the next + enabled category is scanned according to the same algorithm. If there are no + more enabled categories, the search has failed.

    From granata.enrico at gmail.com Tue Aug 23 20:49:09 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 24 Aug 2011 01:49:09 -0000 Subject: [Lldb-commits] [lldb] r138423 - /lldb/trunk/www/varformats.html Message-ID: <20110824014909.7386E2A6C12C@llvm.org> Author: enrico Date: Tue Aug 23 20:49:09 2011 New Revision: 138423 URL: http://llvm.org/viewvc/llvm-project?rev=138423&view=rev Log: Minor documentation changes (WIP) Modified: lldb/trunk/www/varformats.html Modified: lldb/trunk/www/varformats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/varformats.html?rev=138423&r1=138422&r2=138423&view=diff ============================================================================== --- lldb/trunk/www/varformats.html (original) +++ lldb/trunk/www/varformats.html Tue Aug 23 20:49:09 2011 @@ -719,15 +719,23 @@ (lldb) type summary add --summary-string "${var%s}" "char *"
    - - This works for char* and char[] objects, and uses the - \0 terminator - when possible to terminate the string, instead of relying on array length. - - +

    + This syntax works for char* as well as for char[] + because LLDB can rely on the final \0 terminator to know when the string + has ended.

    + LLDB has default summary strings for char* and char[] that use + this special case. On debugger startup, the following are defined automatically: +
    + +
    + (lldb) type summary add --summary-string "${var%s}" "char *"
    + (lldb) type summary add --summary-string "${var%s}" -x "char \[[0-9]+]"
    +
    + +
      -
    • anyone of the array formats (int8_t[], +
    • any of the array formats (int8_t[], float32{}, ...), and the y, Y and a formats work to print an array of a non-aggregate From granata.enrico at gmail.com Tue Aug 23 23:53:32 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 24 Aug 2011 04:53:32 -0000 Subject: [Lldb-commits] [lldb] r138425 - /lldb/trunk/www/varformats.html Message-ID: <20110824045332.220FA2A6C12C@llvm.org> Author: enrico Date: Tue Aug 23 23:53:31 2011 New Revision: 138425 URL: http://llvm.org/viewvc/llvm-project?rev=138425&view=rev Log: Documentation on dynamic types (WIP) Modified: lldb/trunk/www/varformats.html Modified: lldb/trunk/www/varformats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/varformats.html?rev=138425&r1=138424&r2=138425&view=diff ============================================================================== --- lldb/trunk/www/varformats.html (original) +++ lldb/trunk/www/varformats.html Tue Aug 23 23:53:31 2011 @@ -1068,7 +1068,6 @@

      Filters

      -

      Filters are a solution to the display of complex classes. At times, classes have many member variables but not all of these are actually necessary for the user to see.

      @@ -1082,7 +1081,7 @@
    -
    (lldb) type filter add Foo --child B --child H --child Q
    +
    (lldb) frame variable a_foobar
    (Foobar) a_foobar = {
        (int) B = 1
    @@ -1090,7 +1089,52 @@     (std::string) Q = "Hello world"
    }

    - + + + +
    +

    Objective-C dynamic type discovery

    +
    +

    When doing Objective-C development, you may notice that some of your variables + come out as of type id. While this does not influence the ability + of the runtime to send messages to them, it can make it impossible for LLDB + to determine the actual formatters for that object.

    +

    The debugger, however, can dynamically discover the type of an Objective-C + variable, much like the runtime itself does when invoking a selector. In order + to let LLDB do that, however, a special option to frame variable is + required: --dynamic-type.

    +

    --dynamic-type can have one of three values: +

      +
    • no-dynamic-values: the default, prevents dynamic type discovery
    • +
    • no-run-target: enables dynamic type discovery as long as running + code on the target is not required
    • +
    • run-target: enables code execution on the target in order to perform + dynamic type discovery
    • +
    +

    +

    + If you specify a value of either no-run-target or run-target, + LLDB will detect the dynamic type of your variables and show the appropriate formatters + for them. As an example: +

    +

    + +
    + (lldb) frame variable ns_string --dynamic-type no-run-target --show-types +
    + (id, dynamic type: __NSCFString) ns_string = 0x00000001001183d0 @"An NSString saying hello world"
    +
    +

    + Because LLDB uses a detection algorithm that does not need to invoke any functions + on the target process, no-run-target is enough for this to work. + As a final sidenote on this, LLDB is currently able to provide a summary string for NSString + that shows the content of the string, without requiring you to run code on the target + process. + CFString.py contains the code for such a Python summary provider (the code is well commented, + but you may find it hard to follow if it is your first time dealing with LLDB formatting features) + and + this test case contains an usage example. +

    From granata.enrico at gmail.com Wed Aug 24 12:12:47 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 24 Aug 2011 17:12:47 -0000 Subject: [Lldb-commits] [lldb] r138442 - /lldb/trunk/www/varformats.html Message-ID: <20110824171247.DD1EE2A6C12C@llvm.org> Author: enrico Date: Wed Aug 24 12:12:47 2011 New Revision: 138442 URL: http://llvm.org/viewvc/llvm-project?rev=138442&view=rev Log: Documentation edits: correcting typos, adding information and general tweaks for readability Modified: lldb/trunk/www/varformats.html Modified: lldb/trunk/www/varformats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/varformats.html?rev=138442&r1=138441&r2=138442&view=diff ============================================================================== --- lldb/trunk/www/varformats.html (original) +++ lldb/trunk/www/varformats.html Wed Aug 24 12:12:47 2011 @@ -4,7 +4,7 @@ - LLDB Homepage + LLDB Data Formatters
    The LLDB Debugger
    @@ -30,7 +30,7 @@     (float *) y = 0x0000000100100130
        (char *) z = - 0x0000000100100140 "6"
    + 0x0000000100100140 "3"
    }

    @@ -231,22 +231,22 @@
    bytes with ASCII Yshow the bytes, but try to print them as ASCII - characters
    +
    show the bytes, but try to display them as ASCII + characters as well
    e.g. (int *) c.sp.x = 50 f8 bf 5f ff 7f 00 00 P.._....
    character cshow the bytes printed as ASCII characters
    +
    show the bytes as ASCII characters
    e.g. (int *) c.sp.x = P\xf8\xbf_\xff\x7f\0\0
    printable character Cshow the bytes printed as printable ASCII + show the bytes as printable ASCII characters
    e.g. (int *) c.sp.x = P.._....
    show this as a 0-terminated C string
    signed decimaldecimal i show this as a signed integer number (this does not perform a cast, it simply shows the bytes as - signed integer)
    enumerationOSType O show this as a MacOS OSType
    - e.g. (float) *c.sp.y = '\n\x1f\xd7\n'
    unicode16 U show this as UTF-16 characters
    - e.g. (float) *c.sp.y = 0xd70a 0x411f
    unicode32
    show this as UTF-32 characters
    - e.g. (float) *c.sp.y = 0x411fd70a
    unsigned decimalshow this as an array of the corresponding integer type
    e.g.
    - (int) sarray[0].x = {1 0 0 0}
    - (int) sarray[0].x = {0x00000001}
    float32[], float64[]
    (lldb) type summary add --summary-string "int = ${var.integer}, float = ${var.floating}, char = ${var.character%u}" i_am_cool @@ -432,22 +432,25 @@ '}', '$', or '\' character.

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

    + prefix, and end with a "}" suffix. Variables can be a simple name + or they can refer to complex objects that have subitems themselves. + In other words, a variable looks like "${object}" or + "${object.child.otherchild}". A variable can also be prefixed or + suffixed with other symbols meant to change the way its value is handled. An example is + "${*var.int_pointer[0-3]}".

    Basically, all the variables described in Frame and Thread Formatting are accepted. Also acceptable are the control characters and scoping features described in that page. Additionally, ${var and ${*var - become acceptable symbols in this scenario.

    + become acceptable symbols in this scenario. These special symbols + are used to refer to the variable that a summary is being created for.

    The simplest thing you can do is grab a member variable of a class or structure by typing its expression path. In the previous example, the expression path for the floating member is simply .floating. Thus, to ask the summary string to display floating - you would type ${var.floating} (${var - is a placeholder token replaced with whatever variable - is being displayed).

    + you would type ${var.floating}.

    If you have code like the following:
    struct A {
        int x;
    @@ -456,17 +459,16 @@ struct B {
        A x;
        A y;
    -     int z;
    +     int *z;
    };
    the expression path for the y member of the x member of an object of type B would be .x.y and you would type ${var.x.y} to display it in a summary string for type B.

    -

    As you could be using a summary string for both - displaying objects of type T or T* - (unless -p is used to prevent this), the - expression paths do not differentiate between . +

    By default, summary strings work for both type T and + type T* (there is an option to prevent this if you need to). + For this reason, expression paths do not differentiate between . and ->, and the above expression path .x.y would be just as good if you were displaying a B*, or even if the actual definition of B @@ -474,28 +476,40 @@ struct B {
        A *x;
        A y;
    -     int z;
    +     int *z;
    };

    -

    This is unlike the behaviour of frame variable +

    This is unlike the behavior of frame variable which, on the contrary, will enforce the distinction. As hinted above, the rationale for this choice is that - waiving this distinction enables one to write a summary + waiving this distinction enables you to write a summary string once for type T and use it for both T and T* instances. As a summary string is mostly about extracting nested members' information, a pointer to an object is just as good as the object itself for the purpose.

    -

    Of course, you can have multiple entries in one summary - string, as shown in the previous example.

    -

    As you can see, the last expression path also contains - a %u symbol which is nowhere to be found - in the actual member variable name. The symbol is - reminding of a printf() format symbol, and - in fact it has a similar effect. If you add a % sign - followed by any one format name or abbreviation from the - above table after an expression path, the resulting - object will be displyed using the chosen format.

    +

    If you need to access the value of the integer pointed to by B::z, you + cannot simply say ${var.z} because that symbol refers to the pointer z. + In order to dereference it and get the pointed value, you should say ${*var.z}. The ${*var + tells LLDB to get the object that the expression paths leads to, and then dereference it. In this example is it + equivalent to *(bObject.z) in C/C++ syntax. Because . and -> operators can both be + used, there is no need to have dereferences in the middle of an expression path (e.g. you do not need to type + ${*(var.x).x}) to read A::x as contained in *(B::x). To achieve that effect + you can simply write ${var.x->x}, or even ${var.x.x}. The * operator only binds + to the result of the whole expression path, rather than piecewise, and there is no way to use parentheses to change + that behavior.

    +

    Of course, a summary string can contain more than one ${var specifier, + and can use ${var and ${*var specifiers together.

    + + +
    +

    Formatting summary elements

    +
    +

    An expression path can include formatting codes. + Much like the type formats discussed previously, you can also customize + the way variables are displayed in summary strings, regardless of the format they have + applied to their types. To do that, you can use %format inside an expression path, + as in ${var.x->x%u}, which would display the value of x as an unsigned integer.

    You can also use some other special format markers, not available for type formatters, but which carry a special meaning when used in this @@ -535,53 +549,23 @@

    -

    As previously said, pointers and values are treated the - same way when getting to their members in an expression - path. However, if your expression path leads to a - pointer, LLDB will not automatically dereference it. In - order to obtain The deferenced value for a pointer, your - expression path must start with ${*var - instead of ${var. Because there is no need - to dereference pointers along your way, the - dereferencing symbol only applies to the result of the - whole expression path traversing.
    - e.g.
    - (lldb) frame variable -T c
    - (Couple) c = {
    -     (SimpleWithPointers) sp = {
    -         (int *) x = 0x00000001001000b0
    -         (float *) y = 0x00000001001000c0
    -         (char *) z = 0x00000001001000d0 "X"
    -     }
    -     (Simple *) s = 0x00000001001000e0
    - }
    -

    - - If one types the following commands: - - - -
    - (lldb) type summary add --summary-string "int = ${*var.sp.x}, - float = ${*var.sp.y}, char = ${*var.sp.z%u}, Simple = - ${*var.s}" Couple
    - (lldb) type summary add -c -p Simple
    -

    - - the output becomes:
    - - (lldb) frame variable c
    - (Couple) c = int = 9, float = 9.99, char = 88, Simple - = (x=9, y=9.99, z='X')
    -

    -

    Option -c to type summary add +

    Option --inline-children (-c) to type summary add tells LLDB not to look for a summary string, but instead to just print a listing of all the object's children on - one line, as shown in the summary for object Simple.

    -

    We are using the -p flag here to show that - aggregate types can be dereferenced as well as basic types. - The following command sequence would work just as well and - produce the same output: + one line.

    +

    As an example, given a type Couple: +
    + (lldb) frame variable --show-types a_couple
    + (Couple) a_couple = {
    +     (SimpleWithPointers) sp = {
    +         (int *) x = 0x00000001001000b0
    +         (float *) y = 0x00000001001000c0
    +         (char *) z = 0x00000001001000d0 "X"
    +     }
    +     (Simple *) s = 0x00000001001000e0
    + }
    +

    + If one types the following commands:

    -
    (lldb) type summary add --summary-string "int = ${*var.sp.x}, @@ -589,7 +573,25 @@ ${var.s}" Couple
    (lldb) type summary add -c Simple

    +
    + the output becomes:
    + + (lldb) frame variable a_couple
    + (Couple) a_couple = int = 9, float = 9.99, char = 88, Simple + = (x=9, y=9.99, z='X')
    +

    +

    Using the above summary for type Couple, without providing a summary for type Simple + would lead LLDB to display the address of the Simple object, as in: +
    + + (lldb) frame variable a_couple
    + (Couple) a_couple = int = 9, float = 9.99, char = 88, Simple + = Simple @ 0x00007fff5fbff940
    +

    + This happens because Simple is an aggregate type, so it has no value of its own to display, + but it has no summary defined. Thus, LLDB picks a reasonable default summary and displays it. If you want to reproduce + that summary, the summary string to use is ${var%T} @ ${var%L}. +

    @@ -845,9 +847,12 @@

    If you need to delve into several levels of hierarchy, as you can do with summary strings, you can use the method GetValueForExpressionPath(), passing it - an expression path just like those you could use for summary strings. However, if you need - to access array slices, you cannot do that (yet) via this method call, and you must + an expression path just like those you could use for summary strings (one of the differences + is that dereferencing a pointer does not occur by prefixing the path with a *, + but by calling the Dereference() method on the returned SBValue). + If you need to access array slices, you cannot do that (yet) via this method call, and you must use GetChildMemberWithName() querying it for the array items one by one. + Also, handling custom formats is something you have to deal with on your own.

    Other than interactively typing a Python script there are two other ways for you to input a Python script as a summary: @@ -865,7 +870,7 @@

      -
    • using the -F option to type summary add and giving the name of a +
    • using the --python-function (-F) option to type summary add and giving the name of a Python function with the correct prototype. Most probably, you will define (or have already defined) the function in the interactive interpreter, or somehow loaded it from a file. @@ -913,8 +918,13 @@ matching. Thus, if your type has a base class with a cascading summary, this will be preferred over any regular expression match for your type itself.

      +

      One of the ways LLDB uses this feature internally, is to match + the names of STL container classes, regardless of the template + arguments provided (e.g. std::vector<T> for any + type argument T).

      -

      The regular expression language used by LLDB is the POSIX extended regular expression language, as defined by the SUS. +

      The regular expression language used by LLDB is the POSIX extended language, as defined by the Single UNIX Specification, of which Mac OS X is a + compliant implementation. @@ -1017,6 +1027,10 @@

      For examples of how synthetic children are created, you are encouraged to look at examples/synthetic in the LLDB trunk. You may especially want to begin looking at StdVector to get a feel for this feature.

      +

      While the update method is optional, the design pattern consistently used in synthetic providers shipping with LLDB + is to use the __init__ to store the SBValue instance as a part of self, and then call update + to perform the actual initialization. This pattern should make transition to a future version of LLDB that persists synthetic children + providers transparent.

      Once a synthetic children provider is written, one must load it into LLDB before it can be used. Currently, one can use the LLDB script command to type Python code interactively, @@ -1024,9 +1038,9 @@ (ordinary rules apply to importing modules this way). A third option is to type the code for the provider class interactively while adding it.

      -

      For example, let's pretend we have a class Foo for which a synthetic children provider class Foo_Provider - is available, in a Python module named Foo_Tools. The following interaction sets Foo_Provider as a synthetic - children provider in LLDB:

      +

      For example, let's pretend we have a class Foo for which a synthetic children provider class + Foo_Provider is available, in a Python module named Foo_Tools. The following interaction + sets Foo_Provider as a synthetic children provider in LLDB:

      @@ -1079,7 +1093,7 @@ the ones named B, H and Q, you can define a filter:
      - (lldb) type filter add Foo --child B --child H --child Q + (lldb) type filter add Foobar --child B --child H --child Q
      (lldb) frame variable a_foobar
      @@ -1158,8 +1172,24 @@ gnu-libstdc++, and finally system. As said, gnu-libstdc++ contains formatters for C++ STL data types. system contains formatters for char* and char[], which are expected to be consistent throughout libraries and systems, and replace

      -

      Categories are a way to group related formatters. For instance, LLDB itself groups - the formatters for the C++ STL objects in a category named gnu-libstdc++

      +

      There is no special command to create a category. When you place a formatter in a category, if that category does not + exist, it is automatically created. For instance,

      +

      + +
      + (lldb) type summary add Foobar --summary-string "a foobar" --category newcategory +
      + automatically creates a (disabled) category named newcategory.

      +

      Another way to create a new (empty) category, is to enable it, as in:

      +

      + +
      + (lldb) type category enable newcategory +
      +

      However, in this case LLDB warns you that enabling an empty category has no effect. If you add formatters to the + category after enabling it, they will be honored. But an empty category per se does not change the way any + type is displayed. The reason the debugger warns you is that enabling an empty category might be a typo, and you + effectively wanted to enable a similarly-named but not-empty category.

      @@ -1168,7 +1198,7 @@

      While the rules for finding an appropriate format for a type are relatively simple (just go through typedef - hierarchies), searching formatters for a type goes through + hierarchies), searching other formatters goes through a rather intricate set of rules. Namely, what happens is that LLDB starts looking in each enabled category, according to the order in which they were enabled (latest enabled first). In each category, LLDB does @@ -1180,7 +1210,7 @@ for the pointee type that does not skip pointers, use it

    • If this object is a reference, and there is a - summary for the pointee type that does not skip + summary for the referred type that does not skip references, use it
    • If this object is an Objective-C class with a parent class, look at the parent class (and parent of parent, @@ -1221,10 +1251,9 @@ need to be careful what the dereferencing operation is binding to in complicated scenarios
    • Synthetic children providers cannot have a permanent state
    • +
    • Smarter algorithm to detect possible typos in category names
    • type format add does not support the -x option
    • -
    • Object location cannot be printed in the summary - string
    • From granata.enrico at gmail.com Wed Aug 24 12:45:40 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 24 Aug 2011 17:45:40 -0000 Subject: [Lldb-commits] [lldb] r138444 - in /lldb/trunk/test/functionalities: alias/TestAliases.py alias/welcome.py command_python/ command_python/Makefile command_python/TestCommandPython.py command_python/main.cpp command_python/py_import command_python/welcome.py Message-ID: <20110824174540.D10142A6C12C@llvm.org> Author: enrico Date: Wed Aug 24 12:45:40 2011 New Revision: 138444 URL: http://llvm.org/viewvc/llvm-project?rev=138444&view=rev Log: Moved the test code for Python commands out of the test case for aliases, into its own dedicated test case Added: lldb/trunk/test/functionalities/command_python/ lldb/trunk/test/functionalities/command_python/Makefile lldb/trunk/test/functionalities/command_python/TestCommandPython.py lldb/trunk/test/functionalities/command_python/main.cpp lldb/trunk/test/functionalities/command_python/py_import lldb/trunk/test/functionalities/command_python/welcome.py Removed: lldb/trunk/test/functionalities/alias/welcome.py Modified: lldb/trunk/test/functionalities/alias/TestAliases.py Modified: lldb/trunk/test/functionalities/alias/TestAliases.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/TestAliases.py?rev=138444&r1=138443&r2=138444&view=diff ============================================================================== --- lldb/trunk/test/functionalities/alias/TestAliases.py (original) +++ lldb/trunk/test/functionalities/alias/TestAliases.py Wed Aug 24 12:45:40 2011 @@ -130,44 +130,6 @@ substrs = [ "use of undeclared identifier 'f'", "1 errors parsing expression" ]) - self.runCmd("command source py_import") - - self.expect('welcome Enrico', - substrs = ['Hello Enrico, welcome to LLDB']); - - self.expect("help welcome", - substrs = ['Just a docstring for welcome_impl', - 'A command that says hello to LLDB users']) - - self.runCmd("command script delete welcome"); - - self.expect('welcome Enrico', matching=False, error=True, - substrs = ['Hello Enrico, welcome to LLDB']); - - self.expect('targetname', - substrs = ['a.out']) - - self.expect('targetname fail', error=True, - substrs = ['a test for error in command']) - - self.expect('command script list', - substrs = ['targetname', - 'Run Python function welcome.target_name_impl']) - - self.expect("help targetname", - substrs = ['Run Python function welcome.target_name_imp', - 'This command takes \'raw\' input', - 'quote stuff']) - - self.expect("longwait", - substrs = ['Done; if you saw the delays I am doing OK']) - - self.runCmd("command script clear") - - self.expect('command script list', matching=False, - substrs = ['targetname', - 'longwait']) - if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() Removed: lldb/trunk/test/functionalities/alias/welcome.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/welcome.py?rev=138443&view=auto ============================================================================== --- lldb/trunk/test/functionalities/alias/welcome.py (original) +++ lldb/trunk/test/functionalities/alias/welcome.py (removed) @@ -1,27 +0,0 @@ -import sys - -def welcome_impl(debugger, args, result, dict): - """ - Just a docstring for welcome_impl - A command that says hello to LLDB users - """ - result.Printf('Hello ' + args + ', welcome to LLDB'); - return None; - -def target_name_impl(debugger, args, result, dict): - target = debugger.GetSelectedTarget() - file = target.GetExecutable() - result.PutCString('Current target ' + file.GetFilename()) - if args == 'fail': - return 'a test for error in command' - else: - return None - -def print_wait_impl(debugger, args, result, dict): - print 'Trying to do long task..'; - import time - time.sleep(1) - print 'Still doing long task..'; - time.sleep(1) - result.PutCString('Done; if you saw the delays I am doing OK') - return None \ No newline at end of file Added: lldb/trunk/test/functionalities/command_python/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_python/Makefile?rev=138444&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_python/Makefile (added) +++ lldb/trunk/test/functionalities/command_python/Makefile Wed Aug 24 12:45:40 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/command_python/TestCommandPython.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_python/TestCommandPython.py?rev=138444&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_python/TestCommandPython.py (added) +++ lldb/trunk/test/functionalities/command_python/TestCommandPython.py Wed Aug 24 12:45:40 2011 @@ -0,0 +1,71 @@ +""" +Test lldb Python commands. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class CmdPythonTestCase(TestBase): + + mydir = os.path.join("functionalities", "command_python") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym (self): + self.buildDsym () + self.pycmd_tests () + + def test_with_dwarf (self): + self.buildDwarf () + self.pycmd_tests () + + def pycmd_tests (self): + exe = os.path.join (os.getcwd(), "a.out") + self.expect("file " + exe, + patterns = [ "Current executable set to .*a.out" ]) + + self.runCmd("command source py_import") + + self.expect('welcome Enrico', + substrs = ['Hello Enrico, welcome to LLDB']); + + self.expect("help welcome", + substrs = ['Just a docstring for welcome_impl', + 'A command that says hello to LLDB users']) + + self.runCmd("command script delete welcome"); + + self.expect('welcome Enrico', matching=False, error=True, + substrs = ['Hello Enrico, welcome to LLDB']); + + self.expect('targetname', + substrs = ['a.out']) + + self.expect('targetname fail', error=True, + substrs = ['a test for error in command']) + + self.expect('command script list', + substrs = ['targetname', + 'Run Python function welcome.target_name_impl']) + + self.expect("help targetname", + substrs = ['Run Python function welcome.target_name_imp', + 'This command takes \'raw\' input', + 'quote stuff']) + + self.expect("longwait", + substrs = ['Done; if you saw the delays I am doing OK']) + + self.runCmd("command script clear") + + self.expect('command script list', matching=False, + substrs = ['targetname', + 'longwait']) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() + Added: lldb/trunk/test/functionalities/command_python/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_python/main.cpp?rev=138444&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_python/main.cpp (added) +++ lldb/trunk/test/functionalities/command_python/main.cpp Wed Aug 24 12:45:40 2011 @@ -0,0 +1,62 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +int +product (int x, int y) +{ + int result = x * y; + return result; +} + +int +sum (int a, int b) +{ + int result = a + b; + return result; +} + +int +strange_max (int m, int n) +{ + if (m > n) + return m; + else if (n > m) + return n; + else + return 0; +} + +int +foo (int i, int j) +{ + if (strange_max (i, j) == i) + return product (i, j); + else if (strange_max (i, j) == j) + return sum (i, j); + else + return product (sum (i, i), sum (j, j)); +} + +int +main(int argc, char const *argv[]) +{ + + int array[3]; + + array[0] = foo (1238, 78392); + array[1] = foo (379265, 23674); + array[2] = foo (872934, 234); + + return 0; +} Added: lldb/trunk/test/functionalities/command_python/py_import URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_python/py_import?rev=138444&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_python/py_import (added) +++ lldb/trunk/test/functionalities/command_python/py_import Wed Aug 24 12:45:40 2011 @@ -0,0 +1,6 @@ +script import sys, os +script sys.path.append(os.path.join(os.getcwd(), os.pardir)) +script import welcome +command script add welcome --function welcome.welcome_impl +command script add targetname --function welcome.target_name_impl +command script add longwait --function welcome.print_wait_impl Added: lldb/trunk/test/functionalities/command_python/welcome.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_python/welcome.py?rev=138444&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_python/welcome.py (added) +++ lldb/trunk/test/functionalities/command_python/welcome.py Wed Aug 24 12:45:40 2011 @@ -0,0 +1,27 @@ +import sys + +def welcome_impl(debugger, args, result, dict): + """ + Just a docstring for welcome_impl + A command that says hello to LLDB users + """ + result.Printf('Hello ' + args + ', welcome to LLDB'); + return None; + +def target_name_impl(debugger, args, result, dict): + target = debugger.GetSelectedTarget() + file = target.GetExecutable() + result.PutCString('Current target ' + file.GetFilename()) + if args == 'fail': + return 'a test for error in command' + else: + return None + +def print_wait_impl(debugger, args, result, dict): + print 'Trying to do long task..'; + import time + time.sleep(1) + print 'Still doing long task..'; + time.sleep(1) + result.PutCString('Done; if you saw the delays I am doing OK') + return None \ No newline at end of file From granata.enrico at gmail.com Wed Aug 24 12:46:38 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 24 Aug 2011 17:46:38 -0000 Subject: [Lldb-commits] [lldb] r138446 - /lldb/trunk/test/functionalities/alias/py_import Message-ID: <20110824174638.823092A6C12C@llvm.org> Author: enrico Date: Wed Aug 24 12:46:38 2011 New Revision: 138446 URL: http://llvm.org/viewvc/llvm-project?rev=138446&view=rev Log: Moved the test code for Python commands out of the test case for aliases, into its own dedicated test case (one fill was still lurking in the old folder) Removed: lldb/trunk/test/functionalities/alias/py_import Removed: lldb/trunk/test/functionalities/alias/py_import URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/alias/py_import?rev=138445&view=auto ============================================================================== --- lldb/trunk/test/functionalities/alias/py_import (original) +++ lldb/trunk/test/functionalities/alias/py_import (removed) @@ -1,6 +0,0 @@ -script import sys, os -script sys.path.append(os.path.join(os.getcwd(), os.pardir)) -script import welcome -command script add welcome --function welcome.welcome_impl -command script add targetname --function welcome.target_name_impl -command script add longwait --function welcome.print_wait_impl From johnny.chen at apple.com Wed Aug 24 13:10:09 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 24 Aug 2011 18:10:09 -0000 Subject: [Lldb-commits] [lldb] r138452 - /lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py Message-ID: <20110824181009.4FC292A6C12C@llvm.org> Author: johnny Date: Wed Aug 24 13:10:09 2011 New Revision: 138452 URL: http://llvm.org/viewvc/llvm-project?rev=138452&view=rev Log: Remove the expectedFailure decorator. The test has been passing for some time now. Modified: lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py Modified: lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py?rev=138452&r1=138451&r2=138452&view=diff ============================================================================== --- lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py (original) +++ lldb/trunk/test/expression_command/radar_9531204/TestPrintfAfterUp.py Wed Aug 24 13:10:09 2011 @@ -12,7 +12,6 @@ mydir = os.path.join("expression_command", "radar_9531204") # rdar://problem/9531204 - @unittest2.expectedFailure def test_expr_commands(self): """The evaluating printf(...) after break stop and then up a stack frame.""" self.buildDefault() From johnny.chen at apple.com Wed Aug 24 13:12:53 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 24 Aug 2011 18:12:53 -0000 Subject: [Lldb-commits] [lldb] r138454 - in /lldb/trunk/test: make/Makefile.rules plugins/builder_base.py Message-ID: <20110824181253.89B602A6C12C@llvm.org> Author: johnny Date: Wed Aug 24 13:12:53 2011 New Revision: 138454 URL: http://llvm.org/viewvc/llvm-project?rev=138454&view=rev Log: The plugin impl of getCompiler() should be in unison with the Makefile.rules change. Modified: lldb/trunk/test/make/Makefile.rules lldb/trunk/test/plugins/builder_base.py Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=138454&r1=138453&r2=138454&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Wed Aug 24 13:12:53 2011 @@ -24,6 +24,11 @@ #---------------------------------------------------------------------- # CC defaults to clang. +# +# If you change the defaults of CC, be sure to also change it in the file +# test/plugins/builder_base.py, which provides a Python way to return the +# value of the make variable CC -- getCompiler(). +# # See also these functions: # o cxx_compiler # o cxx_linker Modified: lldb/trunk/test/plugins/builder_base.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/builder_base.py?rev=138454&r1=138453&r2=138454&view=diff ============================================================================== --- lldb/trunk/test/plugins/builder_base.py (original) +++ lldb/trunk/test/plugins/builder_base.py Wed Aug 24 13:12:53 2011 @@ -21,7 +21,7 @@ def getCompiler(): """Returns the compiler in effect the test suite is running with.""" - return os.environ["CC"] if "CC" in os.environ else "" + return os.environ["CC"] if "CC" in os.environ else "clang" def getArchSpec(architecture): """ From johnny.chen at apple.com Wed Aug 24 13:19:50 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 24 Aug 2011 18:19:50 -0000 Subject: [Lldb-commits] [lldb] r138458 - /lldb/trunk/test/functionalities/command_python/TestCommandPython.py Message-ID: <20110824181950.BFCE72A6C12C@llvm.org> Author: johnny Date: Wed Aug 24 13:19:50 2011 New Revision: 138458 URL: http://llvm.org/viewvc/llvm-project?rev=138458&view=rev Log: Don't display the stdout if not in TraceOn(), i.e, '-t option, mode. Modified: lldb/trunk/test/functionalities/command_python/TestCommandPython.py Modified: lldb/trunk/test/functionalities/command_python/TestCommandPython.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_python/TestCommandPython.py?rev=138458&r1=138457&r2=138458&view=diff ============================================================================== --- lldb/trunk/test/functionalities/command_python/TestCommandPython.py (original) +++ lldb/trunk/test/functionalities/command_python/TestCommandPython.py Wed Aug 24 13:19:50 2011 @@ -27,6 +27,10 @@ self.runCmd("command source py_import") + # We don't want to display the stdout if not in TraceOn() mode. + if not self.TraceOn(): + self.HideStdout() + self.expect('welcome Enrico', substrs = ['Hello Enrico, welcome to LLDB']); From johnny.chen at apple.com Wed Aug 24 14:35:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 24 Aug 2011 19:35:24 -0000 Subject: [Lldb-commits] [lldb] r138465 - /lldb/trunk/test/expression_command/radar_9531204/main.c Message-ID: <20110824193524.CED0C2A6C12C@llvm.org> Author: johnny Date: Wed Aug 24 14:35:24 2011 New Revision: 138465 URL: http://llvm.org/viewvc/llvm-project?rev=138465&view=rev Log: Fix compile warning. Modified: lldb/trunk/test/expression_command/radar_9531204/main.c Modified: lldb/trunk/test/expression_command/radar_9531204/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_9531204/main.c?rev=138465&r1=138464&r2=138465&view=diff ============================================================================== --- lldb/trunk/test/expression_command/radar_9531204/main.c (original) +++ lldb/trunk/test/expression_command/radar_9531204/main.c Wed Aug 24 14:35:24 2011 @@ -14,6 +14,7 @@ int foo (int value) { printf ("I got the value: %d.\n", value); + return 0; } int main (int argc, char **argv) From johnny.chen at apple.com Wed Aug 24 14:48:51 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 24 Aug 2011 19:48:51 -0000 Subject: [Lldb-commits] [lldb] r138466 - /lldb/trunk/test/lldbtest.py Message-ID: <20110824194851.40F762A6C12C@llvm.org> Author: johnny Date: Wed Aug 24 14:48:51 2011 New Revision: 138466 URL: http://llvm.org/viewvc/llvm-project?rev=138466&view=rev Log: Pretty print the run options for dumpSessionInfo(self) client. 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=138466&r1=138465&r2=138466&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Aug 24 14:48:51 2011 @@ -777,11 +777,13 @@ self.dumpSessionInfo().""" arch = self.getArchitecture() comp = self.getCompiler() - if not arch and not comp: - return "" + if arch: + option_str = "-A " + arch else: - return "%s %s" % ("-A "+arch if arch else "", - "-C "+comp if comp else "") + option_str = "" + if comp: + option_str += "-C " + comp + return option_str # ================================================== # Build methods supported through a plugin interface From scallanan at apple.com Wed Aug 24 17:18:13 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 24 Aug 2011 22:18:13 -0000 Subject: [Lldb-commits] [lldb] r138499 - /lldb/trunk/source/Expression/ClangUserExpression.cpp Message-ID: <20110824221813.108502A6C12C@llvm.org> Author: spyffe Date: Wed Aug 24 17:18:12 2011 New Revision: 138499 URL: http://llvm.org/viewvc/llvm-project?rev=138499&view=rev Log: Fixed a bug where the target for an expression was not set if the containing function could not be found. This caused LLDB to crash later in expression parsing. Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=138499&r1=138498&r2=138499&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Wed Aug 24 17:18:12 2011 @@ -64,7 +64,7 @@ clang::ASTConsumer * ClangUserExpression::ASTTransformer (clang::ASTConsumer *passthrough) -{ +{ ClangASTContext *clang_ast_context = m_target->GetScratchClangASTContext(); if (!clang_ast_context) @@ -87,6 +87,8 @@ if (!sym_ctx.function) return; + m_target = &exe_ctx.GetProcess()->GetTarget(); + clang::DeclContext *decl_context; if (sym_ctx.block && sym_ctx.block->GetInlinedFunctionInfo()) @@ -96,9 +98,7 @@ if (!decl_context) return; - - m_target = exe_ctx.target; - + if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast(decl_context)) { if (method_decl->isInstance()) From johnny.chen at apple.com Wed Aug 24 17:30:47 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 24 Aug 2011 22:30:47 -0000 Subject: [Lldb-commits] [lldb] r138503 - in /lldb/trunk/test/lang/cpp/this: TestCPPThis.py main.cpp Message-ID: <20110824223048.009F12A6C12C@llvm.org> Author: johnny Date: Wed Aug 24 17:30:47 2011 New Revision: 138503 URL: http://llvm.org/viewvc/llvm-project?rev=138503&view=rev Log: Remove skip decorator now that crash has been fixed. Fix a compie warning for main.cpp. Modified: lldb/trunk/test/lang/cpp/this/TestCPPThis.py lldb/trunk/test/lang/cpp/this/main.cpp Modified: lldb/trunk/test/lang/cpp/this/TestCPPThis.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/this/TestCPPThis.py?rev=138503&r1=138502&r2=138503&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/this/TestCPPThis.py (original) +++ lldb/trunk/test/lang/cpp/this/TestCPPThis.py Wed Aug 24 17:30:47 2011 @@ -8,7 +8,6 @@ mydir = os.path.join("lang", "cpp", "this") - @unittest2.skip("segmentation fault -- skipping") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") #rdar://problem/9962849 @expectedFailureClang @@ -17,7 +16,6 @@ self.buildDsym() self.static_method_commands() - @unittest2.skip("segmentation fault -- skipping") #rdar://problem/9962849 @expectedFailureClang def test_with_dwarf_and_run_command(self): Modified: lldb/trunk/test/lang/cpp/this/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/this/main.cpp?rev=138503&r1=138502&r2=138503&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/this/main.cpp (original) +++ lldb/trunk/test/lang/cpp/this/main.cpp Wed Aug 24 17:30:47 2011 @@ -16,7 +16,7 @@ int accessMemberConst() const; static int accessStaticMember(); - int accessMemberInline(int a) __attribute__ ((always_inline)) + void accessMemberInline(int a) __attribute__ ((always_inline)) { m_a = a; // breakpoint 4 } From gclayton at apple.com Wed Aug 24 18:02:49 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 24 Aug 2011 23:02:49 -0000 Subject: [Lldb-commits] [lldb] r138512 - /lldb/tags/lldb-75/ Message-ID: <20110824230249.A04FA2A6C12C@llvm.org> Author: gclayton Date: Wed Aug 24 18:02:49 2011 New Revision: 138512 URL: http://llvm.org/viewvc/llvm-project?rev=138512&view=rev Log: Basing lldb-75 off of lldb-74. Added: lldb/tags/lldb-75/ - copied from r138510, lldb/tags/lldb-74/ From gclayton at apple.com Wed Aug 24 18:04:07 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 24 Aug 2011 23:04:07 -0000 Subject: [Lldb-commits] [lldb] r138513 - in /lldb/tags/lldb-75: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20110824230407.CE7142A6C12C@llvm.org> Author: gclayton Date: Wed Aug 24 18:04:07 2011 New Revision: 138513 URL: http://llvm.org/viewvc/llvm-project?rev=138513&view=rev Log: Bumping Xcode project version to 75 for lldb-75 build. Modified: lldb/tags/lldb-75/lldb.xcodeproj/project.pbxproj lldb/tags/lldb-75/resources/LLDB-Info.plist Modified: lldb/tags/lldb-75/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-75/lldb.xcodeproj/project.pbxproj?rev=138513&r1=138512&r2=138513&view=diff ============================================================================== --- lldb/tags/lldb-75/lldb.xcodeproj/project.pbxproj (original) +++ lldb/tags/lldb-75/lldb.xcodeproj/project.pbxproj Wed Aug 24 18:04:07 2011 @@ -3431,10 +3431,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 74; + DYLIB_CURRENT_VERSION = 75; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3483,11 +3483,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 74; + DYLIB_CURRENT_VERSION = 75; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3534,8 +3534,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 74; - DYLIB_CURRENT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; + DYLIB_CURRENT_VERSION = 75; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3573,9 +3573,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 74; + DYLIB_CURRENT_VERSION = 75; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3613,9 +3613,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 74; + DYLIB_CURRENT_VERSION = 75; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3683,7 +3683,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3714,11 +3714,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 74; + DYLIB_CURRENT_VERSION = 75; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3843,7 +3843,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3875,7 +3875,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 74; + CURRENT_PROJECT_VERSION = 75; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/tags/lldb-75/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-75/resources/LLDB-Info.plist?rev=138513&r1=138512&r2=138513&view=diff ============================================================================== --- lldb/tags/lldb-75/resources/LLDB-Info.plist (original) +++ lldb/tags/lldb-75/resources/LLDB-Info.plist Wed Aug 24 18:04:07 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 74 + 75 CFBundleName ${EXECUTABLE_NAME} From gclayton at apple.com Wed Aug 24 18:24:31 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 24 Aug 2011 23:24:31 -0000 Subject: [Lldb-commits] [lldb] r138522 - /lldb/tags/lldb-75/source/Symbol/ClangASTContext.cpp Message-ID: <20110824232431.AE8BE2A6C12C@llvm.org> Author: gclayton Date: Wed Aug 24 18:24:31 2011 New Revision: 138522 URL: http://llvm.org/viewvc/llvm-project?rev=138522&view=rev Log: Fixed an issue where we might create a CXXRecordDecl instead of a ObjCInterfaceDecl. Modified: lldb/tags/lldb-75/source/Symbol/ClangASTContext.cpp Modified: lldb/tags/lldb-75/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-75/source/Symbol/ClangASTContext.cpp?rev=138522&r1=138521&r2=138522&view=diff ============================================================================== --- lldb/tags/lldb-75/source/Symbol/ClangASTContext.cpp (original) +++ lldb/tags/lldb-75/source/Symbol/ClangASTContext.cpp Wed Aug 24 18:24:31 2011 @@ -1068,7 +1068,7 @@ decl_ctx = ast->getTranslationUnitDecl(); - if (language == eLanguageTypeObjC) + if (language == eLanguageTypeObjC || language == eLanguageTypeObjC_plus_plus) { bool isForwardDecl = true; bool isInternal = false; From jingham at apple.com Wed Aug 24 18:34:21 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 24 Aug 2011 23:34:21 -0000 Subject: [Lldb-commits] [lldb] r138523 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20110824233421.1C7AD2A6C12C@llvm.org> Author: jingham Date: Wed Aug 24 18:34:20 2011 New Revision: 138523 URL: http://llvm.org/viewvc/llvm-project?rev=138523&view=rev Log: The Compilation Unit language was being stored in a variable called "class_language"... Changed that to "cu_language". 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=138523&r1=138522&r2=138523&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Aug 24 18:34:20 2011 @@ -565,7 +565,7 @@ { const char * cu_die_name = cu_die->GetName(this, curr_cu); const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, curr_cu, DW_AT_comp_dir, NULL); - LanguageType class_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_language, 0); + LanguageType cu_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_language, 0); if (cu_die_name) { FileSpec cu_file_spec; @@ -585,7 +585,7 @@ cu_file_spec.SetFile (fullpath.c_str(), false); } - compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), curr_cu, cu_file_spec, curr_cu->GetOffset(), class_language)); + compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), curr_cu, cu_file_spec, curr_cu->GetOffset(), cu_language)); if (compile_unit_sp.get()) { curr_cu->SetUserData(compile_unit_sp.get()); From gclayton at apple.com Wed Aug 24 18:50:00 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 24 Aug 2011 23:50:00 -0000 Subject: [Lldb-commits] [lldb] r138527 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20110824235001.01A692A6C12C@llvm.org> Author: gclayton Date: Wed Aug 24 18:50:00 2011 New Revision: 138527 URL: http://llvm.org/viewvc/llvm-project?rev=138527&view=rev Log: Fix so we don't create C++ classes for all objective C classes when we have a objective C++ source file. 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=138527&r1=138526&r2=138527&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Aug 24 18:50:00 2011 @@ -1068,7 +1068,7 @@ decl_ctx = ast->getTranslationUnitDecl(); - if (language == eLanguageTypeObjC) + if (language == eLanguageTypeObjC || language == eLanguageTypeObjC_plus_plus) { bool isForwardDecl = true; bool isInternal = false; From jmolenda at apple.com Wed Aug 24 19:20:04 2011 From: jmolenda at apple.com (Jason Molenda) Date: Thu, 25 Aug 2011 00:20:04 -0000 Subject: [Lldb-commits] [lldb] r138530 - in /lldb/trunk/source: Interpreter/CommandInterpreter.cpp lldb-log.cpp Message-ID: <20110825002004.F18232A6C12C@llvm.org> Author: jmolenda Date: Wed Aug 24 19:20:04 2011 New Revision: 138530 URL: http://llvm.org/viewvc/llvm-project?rev=138530&view=rev Log: Include lldb/commands as a valid logging type in the 'log list' output. Remove an extraneous \n from one of the lldb/commands log line. Add an lldb/commands log indicating whether the command was successful or not. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/lldb-log.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=138530&r1=138529&r2=138530&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Wed Aug 24 19:20:04 2011 @@ -1187,7 +1187,7 @@ remainder.erase(0, pos); if (log) - log->Printf ("HandleCommand, command line after removing command name(s): '%s'\n", remainder.c_str()); + log->Printf ("HandleCommand, command line after removing command name(s): '%s'", remainder.c_str()); if (wants_raw_input) @@ -1237,6 +1237,9 @@ result.SetStatus (eReturnStatusFailed); } + if (log) + log->Printf ("HandleCommand, command %s", (result.Succeeded() ? "succeeded" : "did not succeed")); + return result.Succeeded(); } Modified: lldb/trunk/source/lldb-log.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb-log.cpp?rev=138530&r1=138529&r2=138530&view=diff ============================================================================== --- lldb/trunk/source/lldb-log.cpp (original) +++ lldb/trunk/source/lldb-log.cpp Wed Aug 24 19:20:04 2011 @@ -227,6 +227,7 @@ strm->Printf("Logging categories for 'lldb':\n" "\tall - turn on all available logging categories\n" "\tapi - enable logging of API calls and return values\n" + "\tcommand - log command argument parsing\n" "\tdefault - enable the default set of logging categories for liblldb\n" "\tbreak - log breakpoints\n" "\tevents - log broadcaster, listener and event queue activities\n" From jmolenda at apple.com Wed Aug 24 20:59:13 2011 From: jmolenda at apple.com (Jason Molenda) Date: Thu, 25 Aug 2011 01:59:13 -0000 Subject: [Lldb-commits] [lldb] r138543 - /lldb/trunk/source/Commands/CommandObjectRegister.cpp Message-ID: <20110825015913.953D92A6C12C@llvm.org> Author: jmolenda Date: Wed Aug 24 20:59:13 2011 New Revision: 138543 URL: http://llvm.org/viewvc/llvm-project?rev=138543&view=rev Log: Emit an error message if we're unable to write a value to a register. (in addition to the previous error message if the value could not be parsed as a numbe). These both generate reasonable errors now - reg write rip 0x500000000000000000000a reg write rip 0x5jjjj Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=138543&r1=138542&r2=138543&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Wed Aug 24 20:59:13 2011 @@ -420,14 +420,20 @@ return true; } } - else + if (error.AsCString()) { result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s': %s\n", reg_name, value_str, error.AsCString()); - result.SetStatus (eReturnStatusFailed); } + else + { + result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s'", + reg_name, + value_str); + } + result.SetStatus (eReturnStatusFailed); } else { From jmolenda at apple.com Wed Aug 24 21:46:44 2011 From: jmolenda at apple.com (Jason Molenda) Date: Thu, 25 Aug 2011 02:46:44 -0000 Subject: [Lldb-commits] [lldb] r138544 - /lldb/trunk/www/formats.html Message-ID: <20110825024644.B19F02A6C12C@llvm.org> Author: jmolenda Date: Wed Aug 24 21:46:44 2011 New Revision: 138544 URL: http://llvm.org/viewvc/llvm-project?rev=138544&view=rev Log: Change old "settings set frame-prompt" and thread-prompt to frame-format and thread-format. 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=138544&r1=138543&r2=138544&view=diff ============================================================================== --- lldb/trunk/www/formats.html (original) +++ lldb/trunk/www/formats.html Wed Aug 24 21:46:44 2011 @@ -36,8 +36,8 @@

      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 +

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

      @@ -253,4 +253,4 @@ - \ No newline at end of file + From gclayton at apple.com Wed Aug 24 22:48:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 25 Aug 2011 03:48:57 -0000 Subject: [Lldb-commits] [lldb] r138547 - /lldb/tags/lldb-75/resources/LLDB-Info.plist Message-ID: <20110825034857.988022A6C12C@llvm.org> Author: gclayton Date: Wed Aug 24 22:48:57 2011 New Revision: 138547 URL: http://llvm.org/viewvc/llvm-project?rev=138547&view=rev Log: Changed the CFBundleShortVersionString to contain the build number. Modified: lldb/tags/lldb-75/resources/LLDB-Info.plist Modified: lldb/tags/lldb-75/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-75/resources/LLDB-Info.plist?rev=138547&r1=138546&r2=138547&view=diff ============================================================================== --- lldb/tags/lldb-75/resources/LLDB-Info.plist (original) +++ lldb/tags/lldb-75/resources/LLDB-Info.plist Wed Aug 24 22:48:57 2011 @@ -13,7 +13,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 1.75 CFBundleSignature ???? CFBundleVersion From gclayton at apple.com Wed Aug 24 23:13:59 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 25 Aug 2011 04:13:59 -0000 Subject: [Lldb-commits] [lldb] r138549 - /lldb/trunk/resources/LLDB-Info.plist Message-ID: <20110825041359.BB6DB2A6C12C@llvm.org> Author: gclayton Date: Wed Aug 24 23:13:59 2011 New Revision: 138549 URL: http://llvm.org/viewvc/llvm-project?rev=138549&view=rev Log: Make the CFBundleShortVersionString and CFBundleVersion automatically track the Apple Generic Version number from the Xcode project. Modified: lldb/trunk/resources/LLDB-Info.plist Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=138549&r1=138548&r2=138549&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Wed Aug 24 23:13:59 2011 @@ -13,11 +13,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 1.${CURRENT_PROJECT_VERSION} CFBundleSignature ???? CFBundleVersion - 73 + ${CURRENT_PROJECT_VERSION} CFBundleName ${EXECUTABLE_NAME} From johnny.chen at apple.com Thu Aug 25 12:27:02 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 25 Aug 2011 17:27:02 -0000 Subject: [Lldb-commits] [lldb] r138563 - /lldb/trunk/source/Target/StackFrameList.cpp Message-ID: <20110825172702.AA1272A6C12C@llvm.org> Author: johnny Date: Thu Aug 25 12:27:02 2011 New Revision: 138563 URL: http://llvm.org/viewvc/llvm-project?rev=138563&view=rev Log: Fix compilation error with DEBUG_STACK_FRAMES defined, patch by Filipe Cabecinhas! With some slight modification. Modified: lldb/trunk/source/Target/StackFrameList.cpp Modified: lldb/trunk/source/Target/StackFrameList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=138563&r1=138562&r2=138563&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrameList.cpp (original) +++ lldb/trunk/source/Target/StackFrameList.cpp Thu Aug 25 12:27:02 2011 @@ -63,7 +63,7 @@ if (m_show_inlined_frames) { #if defined (DEBUG_STACK_FRAMES) - StreamFile s(stdout); + StreamFile s(stdout, false); #endif Unwind *unwinder = m_thread.GetUnwinder (); addr_t pc = LLDB_INVALID_ADDRESS; @@ -456,7 +456,7 @@ Mutex::Locker prev_locker (prev_sp.get() ? prev_sp->m_mutex.GetMutex() : NULL); #if defined (DEBUG_STACK_FRAMES) - StreamFile s(stdout); + StreamFile s(stdout, false); s.PutCString("\n\nStackFrameList::Merge():\nPrev:\n"); if (prev_sp.get()) prev_sp->Dump (&s); @@ -514,9 +514,8 @@ StackID curr_stack_id (curr_frame_zero_sp->GetStackID()); StackID prev_stack_id (prev_frame_zero_sp->GetStackID()); - //const uint32_t num_prev_frames = prev_sp->GetNumFrames (false); - #if defined (DEBUG_STACK_FRAMES) + const uint32_t num_prev_frames = prev_sp->GetNumFrames (false); s.Printf("\n%u previous frames with one current frame\n", num_prev_frames); #endif From johnny.chen at apple.com Thu Aug 25 12:40:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 25 Aug 2011 17:40:39 -0000 Subject: [Lldb-commits] [lldb] r138565 - /lldb/trunk/source/Core/Address.cpp Message-ID: <20110825174039.D8C612A6C12C@llvm.org> Author: johnny Date: Thu Aug 25 12:40:39 2011 New Revision: 138565 URL: http://llvm.org/viewvc/llvm-project?rev=138565&view=rev Log: Initializes (uint64_t)buf variable, patch by Filipe Cabecinhas! Modified: lldb/trunk/source/Core/Address.cpp Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=138565&r1=138564&r2=138565&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Thu Aug 25 12:40:39 2011 @@ -74,7 +74,7 @@ success = false; return 0; } - uint64_t buf; + uint64_t buf = 0; success = ReadBytes (exe_scope, address, &buf, byte_size) == byte_size; if (success) From johnny.chen at apple.com Thu Aug 25 14:38:34 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 25 Aug 2011 19:38:34 -0000 Subject: [Lldb-commits] [lldb] r138577 - in /lldb/trunk: include/lldb/Target/ThreadList.h source/Core/Debugger.cpp source/Interpreter/CommandInterpreter.cpp source/Plugins/Process/Utility/InferiorCallPOSIX.cpp source/Target/Process.cpp source/Target/ThreadList.cpp Message-ID: <20110825193834.93C742A6C12C@llvm.org> Author: johnny Date: Thu Aug 25 14:38:34 2011 New Revision: 138577 URL: http://llvm.org/viewvc/llvm-project?rev=138577&view=rev Log: Make ThreadList::GetSelectedThread() select and return the 0th thread if there's no currently selected thread. And update the call sites accordingly. Modified: lldb/trunk/include/lldb/Target/ThreadList.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/ThreadList.cpp Modified: lldb/trunk/include/lldb/Target/ThreadList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadList.h?rev=138577&r1=138576&r2=138577&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadList.h (original) +++ lldb/trunk/include/lldb/Target/ThreadList.h Thu Aug 25 14:38:34 2011 @@ -45,6 +45,8 @@ void AddThread (lldb::ThreadSP &thread_sp); + // Return the selected thread if there is one. Otherwise, return the thread + // selected at index 0. lldb::ThreadSP GetSelectedThread (); Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=138577&r1=138576&r2=138577&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Aug 25 14:38:34 2011 @@ -346,8 +346,6 @@ if (exe_ctx.process && exe_ctx.process->IsRunning() == false) { exe_ctx.thread = exe_ctx.process->GetThreadList().GetSelectedThread().get(); - if (exe_ctx.thread == NULL) - exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); if (exe_ctx.thread) { exe_ctx.frame = exe_ctx.thread->GetSelectedFrame().get(); Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=138577&r1=138576&r2=138577&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Aug 25 14:38:34 2011 @@ -2230,13 +2230,6 @@ if (m_exe_ctx.process && m_exe_ctx.process->IsAlive() && !m_exe_ctx.process->IsRunning()) { m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetSelectedThread().get(); - if (m_exe_ctx.thread == NULL) - { - m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); - // If we didn't have a selected thread, select one here. - if (m_exe_ctx.thread != NULL) - m_exe_ctx.process->GetThreadList().SetSelectedThreadByID(m_exe_ctx.thread->GetID()); - } if (m_exe_ctx.thread) { m_exe_ctx.frame = m_exe_ctx.thread->GetSelectedFrame().get(); Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp?rev=138577&r1=138576&r2=138577&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Thu Aug 25 14:38:34 2011 @@ -26,8 +26,6 @@ unsigned flags, addr_t fd, addr_t offset) { Thread *thread = process->GetThreadList().GetSelectedThread().get(); if (thread == NULL) - thread = process->GetThreadList().GetThreadAtIndex(0).get(); - if (thread == NULL) return false; const bool append = true; @@ -129,7 +127,7 @@ addr_t length) { Thread *thread = process->GetThreadList().GetSelectedThread().get(); if (thread == NULL) - thread = process->GetThreadList().GetThreadAtIndex(0).get(); + return false; const bool append = true; const bool include_symbols = true; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=138577&r1=138576&r2=138577&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Aug 25 14:38:34 2011 @@ -1138,8 +1138,6 @@ if (error.Success()) { ThreadSP thread_sp(GetThreadList ().GetSelectedThread()); - if (thread_sp == NULL) - thread_sp = GetThreadList ().GetThreadAtIndex(0, true); if (thread_sp) { @@ -1205,8 +1203,6 @@ if (error.Success()) { ThreadSP thread_sp(GetThreadList ().GetSelectedThread()); - if (thread_sp == NULL) - thread_sp = GetThreadList ().GetThreadAtIndex(0, true); if (thread_sp) { Modified: lldb/trunk/source/Target/ThreadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=138577&r1=138576&r2=138577&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadList.cpp (original) +++ lldb/trunk/source/Target/ThreadList.cpp Thu Aug 25 14:38:34 2011 @@ -545,6 +545,8 @@ ThreadList::GetSelectedThread () { Mutex::Locker locker(m_threads_mutex); + if (m_selected_tid == LLDB_INVALID_THREAD_ID) + SetSelectedThreadByID(m_threads[0]->GetID()); return FindThreadByID(m_selected_tid); } From johnny.chen at apple.com Thu Aug 25 16:51:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 25 Aug 2011 21:51:45 -0000 Subject: [Lldb-commits] [lldb] r138590 - /lldb/trunk/test/logging/TestLogging.py Message-ID: <20110825215145.7026C2A6C12C@llvm.org> Author: johnny Date: Thu Aug 25 16:51:45 2011 New Revision: 138590 URL: http://llvm.org/viewvc/llvm-project?rev=138590&view=rev Log: Modify the loggings output oracle to fix test suite failure, after the recent change to CommandInterpreter.cpp. Modified: lldb/trunk/test/logging/TestLogging.py Modified: lldb/trunk/test/logging/TestLogging.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/logging/TestLogging.py?rev=138590&r1=138589&r2=138590&view=diff ============================================================================== --- lldb/trunk/test/logging/TestLogging.py (original) +++ lldb/trunk/test/logging/TestLogging.py Thu Aug 25 16:51:45 2011 @@ -46,19 +46,19 @@ "com.apple.main-thread HandleCommand, revised_command_line: 'command alias bp breakpoint'\n", "com.apple.main-thread HandleCommand, wants_raw_input:'True'\n", "com.apple.main-thread HandleCommand, command line after removing command name(s): 'bp breakpoint'\n", - "\n", + "com.apple.main-thread HandleCommand, command succeeded\n", "com.apple.main-thread Processing command: bp set -n main\n", "com.apple.main-thread HandleCommand, cmd_obj : 'breakpoint set'\n", "com.apple.main-thread HandleCommand, revised_command_line: 'breakpoint set -n main'\n", "com.apple.main-thread HandleCommand, wants_raw_input:'False'\n", "com.apple.main-thread HandleCommand, command line after removing command name(s): '-n main'\n", - "\n", + "com.apple.main-thread HandleCommand, command succeeded\n", "com.apple.main-thread Processing command: bp l\n", "com.apple.main-thread HandleCommand, cmd_obj : 'breakpoint list'\n", "com.apple.main-thread HandleCommand, revised_command_line: 'breakpoint l'\n", "com.apple.main-thread HandleCommand, wants_raw_input:'False'\n", "com.apple.main-thread HandleCommand, command line after removing command name(s): ''\n", - "\n" + "com.apple.main-thread HandleCommand, command succeeded\n", ] self.assertTrue (os.path.isfile (log_file)) From johnny.chen at apple.com Thu Aug 25 17:00:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 25 Aug 2011 22:00:00 -0000 Subject: [Lldb-commits] [lldb] r138591 - /lldb/trunk/source/Target/ThreadList.cpp Message-ID: <20110825220000.1ED722A6C12C@llvm.org> Author: johnny Date: Thu Aug 25 16:59:59 2011 New Revision: 138591 URL: http://llvm.org/viewvc/llvm-project?rev=138591&view=rev Log: Modify the impl of ThreadList::GetSelectedThread() so that it tries to fetch the m_selected_tid thread first, check to see if it is valid (might be null if the thread just exited), and if not select/return the 0th thread instead. Modified: lldb/trunk/source/Target/ThreadList.cpp Modified: lldb/trunk/source/Target/ThreadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=138591&r1=138590&r2=138591&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadList.cpp (original) +++ lldb/trunk/source/Target/ThreadList.cpp Thu Aug 25 16:59:59 2011 @@ -545,9 +545,13 @@ ThreadList::GetSelectedThread () { Mutex::Locker locker(m_threads_mutex); - if (m_selected_tid == LLDB_INVALID_THREAD_ID) - SetSelectedThreadByID(m_threads[0]->GetID()); - return FindThreadByID(m_selected_tid); + ThreadSP thread_sp = FindThreadByID(m_selected_tid); + if (!thread_sp.get()) + { + m_selected_tid = m_threads[0]->GetID(); + thread_sp = m_threads[0]; + } + return thread_sp; } bool From jingham at apple.com Thu Aug 25 18:21:43 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 25 Aug 2011 23:21:43 -0000 Subject: [Lldb-commits] [lldb] r138600 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20110825232143.B42AF2A6C12C@llvm.org> Author: jingham Date: Thu Aug 25 18:21:43 2011 New Revision: 138600 URL: http://llvm.org/viewvc/llvm-project?rev=138600&view=rev Log: Add logging to SymbolFileDWARF::ParseType so that we can tell the type/comp_unit/obj_file were being processed when something goes wrong... 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=138600&r1=138599&r2=138600&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Aug 25 18:21:43 2011 @@ -3072,6 +3072,25 @@ AccessType accessibility = eAccessNone; if (die != NULL) { + Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); + if (log && dwarf_cu) + { + const DWARFDebugInfoEntry *cu_die = dwarf_cu->GetCompileUnitDIEOnly(); + const char *cu_name = NULL; + if (cu_die != NULL) + cu_name = cu_die->GetName (this, dwarf_cu); + const char *obj_file_name = NULL; + if (m_obj_file) + obj_file_name = m_obj_file->GetFileSpec().GetFilename().AsCString(); + const char *die_name = die->GetName (this, dwarf_cu); + log->Printf ("SymbolFileDWARF::%s: CU: %s OBJFILE: %s DIE: %s (0x%llx).", + __FUNCTION__, + cu_name ? cu_name : "", + obj_file_name ? obj_file_name : "", + die_name ? die_name : "", + die->GetOffset()); + } + Type *type_ptr = m_die_to_type.lookup (die); TypeList* type_list = GetTypeList(); if (type_ptr == NULL) From johnny.chen at apple.com Thu Aug 25 19:00:01 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 26 Aug 2011 00:00:01 -0000 Subject: [Lldb-commits] [lldb] r138608 - in /lldb/trunk/test: benchmarks/disassembly/TestDisassembly.py benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py dotest.py functionalities/command_regex/TestCommandRegex.py functionalities/embedded_interpreter/TestConvenienceVariables.py functionalities/stop-hook/TestStopHookMechanism.py lldbtest.py Message-ID: <20110826000001.862CE2A6C12C@llvm.org> Author: johnny Date: Thu Aug 25 19:00:01 2011 New Revision: 138608 URL: http://llvm.org/viewvc/llvm-project?rev=138608&view=rev Log: Add a new attribute self.lldbHere, representing the fullpath to the 'lldb' executable built locally from the source tree. This is distinguished from self.lldbExec, which can be used by test/benchmarks to measure the performances against other debuggers. You can use environment variable LLDB_EXEC to specify self.lldbExec to the dotest.py test driver, otherwise it is going to be populated with self.lldbHere. Modify the regular tests under test dir, i.e., not test/benchmarks, to use self.lldbHere. Also modify the benchmarks tests to use self.lldbHere when it needs an 'lldb' executable with debug info to do the performance measurements. Modified: lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py lldb/trunk/test/dotest.py lldb/trunk/test/functionalities/command_regex/TestCommandRegex.py lldb/trunk/test/functionalities/embedded_interpreter/TestConvenienceVariables.py lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py?rev=138608&r1=138607&r2=138608&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py (original) +++ lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py Thu Aug 25 19:00:01 2011 @@ -12,7 +12,7 @@ def setUp(self): BenchBase.setUp(self) - self.exe = self.lldbExec + self.exe = self.lldbHere self.function = 'Driver::MainLoop()' self.lldb_avg = None self.gdb_avg = None Modified: lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py?rev=138608&r1=138607&r2=138608&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py (original) +++ lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py Thu Aug 25 19:00:01 2011 @@ -14,7 +14,7 @@ BenchBase.setUp(self) self.gdb_41_exe = '/Flint/usr/bin/gdb' self.gdb_42_exe = '/Developer/usr/bin/gdb' - self.exe = self.lldbExec + self.exe = self.lldbHere self.function = 'Driver::MainLoop()' self.gdb_41_avg = None self.gdb_42_avg = None Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=138608&r1=138607&r2=138608&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Aug 25 19:00:01 2011 @@ -567,6 +567,13 @@ # Some of the tests can invoke the 'lldb' command directly. # We'll try to locate the appropriate executable right here. + # First, you can define an environment variable LLDB_EXEC specifying the + # full pathname of the lldb executable. + if "LLDB_EXEC" in os.environ and is_exe(os.environ["LLDB_EXEC"]): + lldbExec = os.environ["LLDB_EXEC"] + else: + lldbExec = None + executable = ['lldb'] dbgExec = os.path.join(base, *(xcode3_build_dir + dbg + executable)) dbgExec2 = os.path.join(base, *(xcode4_build_dir + dbg + executable)) @@ -575,26 +582,34 @@ baiExec = os.path.join(base, *(xcode3_build_dir + bai + executable)) baiExec2 = os.path.join(base, *(xcode4_build_dir + bai + executable)) - lldbExec = None + # The 'lldb' executable built here in the source tree. + lldbHere = None if is_exe(dbgExec): - lldbExec = dbgExec + lldbHere = dbgExec elif is_exe(dbgExec2): - lldbExec = dbgExec2 + lldbHere = dbgExec2 elif is_exe(relExec): - lldbExec = relExec + lldbHere = relExec elif is_exe(relExec2): - lldbExec = relExec2 + lldbHere = relExec2 elif is_exe(baiExec): - lldbExec = baiExec + lldbHere = baiExec elif is_exe(baiExec2): - lldbExec = baiExec2 + lldbHere = baiExec2 - if lldbExec: + if lldbHere: + os.environ["LLDB_HERE"] = lldbHere + if not lldbExec: + lldbExec = lldbHere os.environ["LLDB_BUILD_DIR"] = os.path.split(lldbExec)[0] print os.environ["LLDB_BUILD_DIR"] + # One last chance to locate the 'lldb' executable. if not lldbExec: - lldbExec = which('lldb') + if lldbHere: + lldbExec = lldbHere + else: + lldbExec = which('lldb') if not lldbExec: print "The 'lldb' executable cannot be located. Some of the tests may not be run as a result." Modified: lldb/trunk/test/functionalities/command_regex/TestCommandRegex.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_regex/TestCommandRegex.py?rev=138608&r1=138607&r2=138608&view=diff ============================================================================== --- lldb/trunk/test/functionalities/command_regex/TestCommandRegex.py (original) +++ lldb/trunk/test/functionalities/command_regex/TestCommandRegex.py Thu Aug 25 19:00:01 2011 @@ -18,7 +18,7 @@ regex_prompt = "Enter regular expressions in the form 's///' and terminate with an empty line:\r\n" regex_prompt1 = "\r\n" - child = pexpect.spawn('%s' % self.lldbExec) + child = pexpect.spawn('%s' % self.lldbHere) # Turn on logging for what the child sends back. if self.TraceOn(): child.logfile_read = sys.stdout Modified: lldb/trunk/test/functionalities/embedded_interpreter/TestConvenienceVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/embedded_interpreter/TestConvenienceVariables.py?rev=138608&r1=138607&r2=138608&view=diff ============================================================================== --- lldb/trunk/test/functionalities/embedded_interpreter/TestConvenienceVariables.py (original) +++ lldb/trunk/test/functionalities/embedded_interpreter/TestConvenienceVariables.py Thu Aug 25 19:00:01 2011 @@ -34,7 +34,7 @@ python_prompt = ">>> " # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s' % (self.lldbExec, exe)) + self.child = pexpect.spawn('%s %s' % (self.lldbHere, exe)) child = self.child # Turn on logging for what the child sends back. if self.TraceOn(): Modified: lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py?rev=138608&r1=138607&r2=138608&view=diff ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py (original) +++ lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py Thu Aug 25 19:00:01 2011 @@ -39,7 +39,7 @@ add_prompt1 = "\r\n> " # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s' % (self.lldbExec, exe)) + self.child = pexpect.spawn('%s %s' % (self.lldbHere, exe)) child = self.child # Turn on logging for what the child sends back. if self.TraceOn(): Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=138608&r1=138607&r2=138608&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Aug 25 19:00:01 2011 @@ -475,6 +475,12 @@ if "LLDB_EXEC" in os.environ: self.lldbExec = os.environ["LLDB_EXEC"] + else: + self.lldbExec = None + if "LLDB_HERE" in os.environ: + self.lldbHere = os.environ["LLDB_HERE"] + else: + self.lldbHere = None # Assign the test method name to self.testMethodName. # From gclayton at apple.com Thu Aug 25 21:44:58 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 26 Aug 2011 02:44:58 -0000 Subject: [Lldb-commits] [lldb] r138620 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: NameToDIE.cpp NameToDIE.h Message-ID: <20110826024458.CE95C2A6C12C@llvm.org> Author: gclayton Date: Thu Aug 25 21:44:58 2011 New Revision: 138620 URL: http://llvm.org/viewvc/llvm-project?rev=138620&view=rev Log: Added code to test hash bucket sizes for an DWARF index that we can write to a file. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp?rev=138620&r1=138619&r2=138620&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp Thu Aug 25 21:44:58 2011 @@ -66,3 +66,77 @@ s->Printf("%p: 0x%8.8x 0x%8.8x \"%s\"\n", pos->first, pos->second.cu_idx, pos->second.die_idx, pos->first); } } + + +static uint32_t +dl_new_hash (const char *s) +{ + uint32_t h = 5381; + + for (unsigned char c = *s; c; c = *++s) + h = ((h << 5) + h) + c; + + return h; +} + +struct HashEntry +{ + uint32_t hash; + uint32_t cu_idx; + uint32_t die_idx; + const char *name; +}; + +typedef struct HashEntry HashEntryType; + +void +NameToDIE::Hash (lldb_private::Stream *s) +{ + typedef std::vector hash_collection; + hash_collection hash_entries; + collection::const_iterator pos, end = m_collection.end(); + for (pos = m_collection.begin(); pos != end; ++pos) + { + HashEntry entry = { dl_new_hash (pos->first), pos->second.cu_idx, pos->second.die_idx, pos->first }; + hash_entries.push_back (entry); + } + + + const uint32_t hash_entries_size = hash_entries.size(); + + uint32_t i; + + for (uint32_t power_2 = 0x10; power_2 <= hash_entries_size; power_2 <<= 1) + { + const uint32_t size = power_2 - 1; + if (size > 0x10 && size > hash_entries_size) + break; + + s->Printf ("\nTrying size of %u for %u items:\n", size, hash_entries_size); + std::vector indexes(size, 0); + for (i=0; iPrintf ("good = %u\n", good); + s->Printf ("empties = %u\n", empties); + s->Printf ("collisions = %u\n", collisions); + s->Printf ("avg count = %llu\n", total / indexes_size); + } +} Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h?rev=138620&r1=138619&r2=138620&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h Thu Aug 25 21:44:58 2011 @@ -51,6 +51,9 @@ FindAllEntriesForCompileUnitWithIndex (const uint32_t cu_idx, std::vector &info_array) const; + void + Hash (lldb_private::Stream *s); + protected: typedef std::multimap collection; From jingham at apple.com Fri Aug 26 14:44:13 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 26 Aug 2011 19:44:13 -0000 Subject: [Lldb-commits] [lldb] r138644 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: DWARFDebugInfoEntry.cpp DWARFDebugInfoEntry.h SymbolFileDWARF.cpp Message-ID: <20110826194413.B43DC2A6C12D@llvm.org> Author: jingham Date: Fri Aug 26 14:44:13 2011 New Revision: 138644 URL: http://llvm.org/viewvc/llvm-project?rev=138644&view=rev Log: Move DIE location reporting into the DWARFDebugInfo class, use it from there in SymbolFileDWARF::ParseType (and eventually in other interesting places as well.) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=138644&r1=138643&r2=138644&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Fri Aug 26 14:44:13 2011 @@ -1129,6 +1129,30 @@ } } +void +DWARFDebugInfoEntry::DumpLocation +( + SymbolFileDWARF* dwarf2Data, + DWARFCompileUnit* cu, + Stream *s +) const +{ + const DWARFDebugInfoEntry *cu_die = cu->GetCompileUnitDIEOnly(); + const char *cu_name = NULL; + if (cu_die != NULL) + cu_name = cu_die->GetName (dwarf2Data, cu); + const char *obj_file_name = NULL; + ObjectFile *obj_file = dwarf2Data->GetObjectFile(); + if (obj_file) + obj_file_name = obj_file->GetFileSpec().GetFilename().AsCString(); + const char *die_name = GetName (dwarf2Data, cu); + s->Printf ("CU: %s OBJFILE: %s DIE: %s (0x%llx).", + cu_name ? cu_name : "", + obj_file_name ? obj_file_name : "", + die_name ? die_name : "", + GetOffset()); +} + //---------------------------------------------------------------------- // DumpAttribute // 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=138644&r1=138643&r2=138644&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Fri Aug 26 14:44:13 2011 @@ -256,7 +256,12 @@ lldb_private::Stream *s, dw_attr_t attr, dw_form_t form); - + // This one dumps the comp unit name, objfile name and die offset for this die so the stream S. + void DumpLocation( + SymbolFileDWARF* dwarf2Data, + DWARFCompileUnit* cu, + lldb_private::Stream *s) const; + bool GetDIENamesAndRanges( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, 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=138644&r1=138643&r2=138644&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Aug 26 14:44:13 2011 @@ -30,6 +30,7 @@ #include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" #include "lldb/Core/Value.h" @@ -2288,6 +2289,7 @@ // Return the number of variable that were appended to the list return sc_list.GetSize() - original_size; } + void SymbolFileDWARF::ReportError (const char *format, ...) { @@ -3075,20 +3077,10 @@ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); if (log && dwarf_cu) { - const DWARFDebugInfoEntry *cu_die = dwarf_cu->GetCompileUnitDIEOnly(); - const char *cu_name = NULL; - if (cu_die != NULL) - cu_name = cu_die->GetName (this, dwarf_cu); - const char *obj_file_name = NULL; - if (m_obj_file) - obj_file_name = m_obj_file->GetFileSpec().GetFilename().AsCString(); - const char *die_name = die->GetName (this, dwarf_cu); - log->Printf ("SymbolFileDWARF::%s: CU: %s OBJFILE: %s DIE: %s (0x%llx).", - __FUNCTION__, - cu_name ? cu_name : "", - obj_file_name ? obj_file_name : "", - die_name ? die_name : "", - die->GetOffset()); + StreamString s; + die->DumpLocation (this, dwarf_cu, &s); + log->Printf ("SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData()); + } Type *type_ptr = m_die_to_type.lookup (die); From gclayton at apple.com Fri Aug 26 15:01:35 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 26 Aug 2011 20:01:35 -0000 Subject: [Lldb-commits] [lldb] r138646 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20110826200135.BDE592A6C12D@llvm.org> Author: gclayton Date: Fri Aug 26 15:01:35 2011 New Revision: 138646 URL: http://llvm.org/viewvc/llvm-project?rev=138646&view=rev Log: Fixed an assertion that could happen if we happened to parse a mach-o object file that had a symbol that had a section specified where the section had zero size. We now honor this section definition for the symbol and don't assert anymore. Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=138646&r1=138645&r2=138646&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Aug 26 15:01:35 2011 @@ -686,7 +686,18 @@ } } if (m_section_infos[n_sect].vm_range.Contains(file_addr)) + { + // Symbol is in section. return m_section_infos[n_sect].section; + } + else if (m_section_infos[n_sect].vm_range.GetByteSize () == 0 && + m_section_infos[n_sect].vm_range.GetBaseAddress() == file_addr) + { + // Symbol is in section with zero size, but has the same start + // address as the section. This can happen with linker symbols + // (symbols that start with the letter 'l' or 'L'. + return m_section_infos[n_sect].section; + } } return m_section_list->FindSectionContainingFileAddress(file_addr).get(); } @@ -1162,7 +1173,13 @@ case NListTypeSection: // N_SECT symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); - assert(symbol_section != NULL); + if (symbol_section == NULL) + { + // TODO: warn about this? + add_nlist = false; + break; + } + if (TEXT_eh_frame_sectID == nlist.n_sect) { type = eSymbolTypeException; From johnny.chen at apple.com Fri Aug 26 18:50:10 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 26 Aug 2011 23:50:10 -0000 Subject: [Lldb-commits] [lldb] r138677 - /lldb/trunk/test/help/TestHelp.py Message-ID: <20110826235010.77AE82A6C12D@llvm.org> Author: johnny Date: Fri Aug 26 18:50:10 2011 New Revision: 138677 URL: http://llvm.org/viewvc/llvm-project?rev=138677&view=rev Log: Update the test case in light of recent change of LLDB-Info.plist to track Apple Generic Version number from the Xcode project file. Modified: lldb/trunk/test/help/TestHelp.py Modified: lldb/trunk/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=138677&r1=138676&r2=138677&view=diff ============================================================================== --- lldb/trunk/test/help/TestHelp.py (original) +++ lldb/trunk/test/help/TestHelp.py Fri Aug 26 18:50:10 2011 @@ -58,8 +58,10 @@ self.expect("help version", substrs = ['Show version of LLDB debugger.']) version_str = self.version_number_string() + import re + match = re.match('[0-9]+', version_str) self.expect("version", - patterns = ['LLDB-' + (version_str if version_str else '[0-9]+')]) + patterns = ['LLDB-' + (version_str if match else '[0-9]+')]) def test_help_should_not_crash_lldb(self): """Command 'help disasm' should not crash lldb.""" From johnny.chen at apple.com Fri Aug 26 18:51:22 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 26 Aug 2011 23:51:22 -0000 Subject: [Lldb-commits] [lldb] r138678 - /lldb/trunk/source/Core/DataExtractor.cpp Message-ID: <20110826235123.063C82A6C12D@llvm.org> Author: johnny Date: Fri Aug 26 18:51:22 2011 New Revision: 138678 URL: http://llvm.org/viewvc/llvm-project?rev=138678&view=rev Log: Micro-optimization: Update the shift amount only when needed. Modified: lldb/trunk/source/Core/DataExtractor.cpp Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=138678&r1=138677&r2=138678&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Fri Aug 26 18:51:22 2011 @@ -1232,9 +1232,9 @@ bytecount++; byte = *src++; result |= (byte & 0x7f) << shift; - shift += 7; if ((byte & 0x80) == 0) break; + shift += 7; } *offset_ptr += bytecount; From jingham at apple.com Fri Aug 26 19:07:43 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 27 Aug 2011 00:07:43 -0000 Subject: [Lldb-commits] [lldb] r138682 - /lldb/tags/lldb-76/ Message-ID: <20110827000743.A3C432A6C12D@llvm.org> Author: jingham Date: Fri Aug 26 19:07:43 2011 New Revision: 138682 URL: http://llvm.org/viewvc/llvm-project?rev=138682&view=rev Log: Cloning for lldb-76 submission. Added: lldb/tags/lldb-76/ - copied from r138681, lldb/tags/lldb-75/ From jingham at apple.com Fri Aug 26 19:13:38 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 27 Aug 2011 00:13:38 -0000 Subject: [Lldb-commits] [lldb] r138685 - in /lldb/tags/lldb-76: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20110827001338.7D20A2A6C12D@llvm.org> Author: jingham Date: Fri Aug 26 19:13:38 2011 New Revision: 138685 URL: http://llvm.org/viewvc/llvm-project?rev=138685&view=rev Log: Bumping version numbers for lldb-76. Modified: lldb/tags/lldb-76/lldb.xcodeproj/project.pbxproj lldb/tags/lldb-76/resources/LLDB-Info.plist Modified: lldb/tags/lldb-76/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-76/lldb.xcodeproj/project.pbxproj?rev=138685&r1=138684&r2=138685&view=diff ============================================================================== --- lldb/tags/lldb-76/lldb.xcodeproj/project.pbxproj (original) +++ lldb/tags/lldb-76/lldb.xcodeproj/project.pbxproj Fri Aug 26 19:13:38 2011 @@ -3431,10 +3431,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 75; + DYLIB_CURRENT_VERSION = 76; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3483,11 +3483,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 75; + DYLIB_CURRENT_VERSION = 76; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3534,8 +3534,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 75; - DYLIB_CURRENT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; + DYLIB_CURRENT_VERSION = 76; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3573,9 +3573,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 75; + DYLIB_CURRENT_VERSION = 76; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3613,9 +3613,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 75; + DYLIB_CURRENT_VERSION = 76; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3683,7 +3683,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3714,11 +3714,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 75; + DYLIB_CURRENT_VERSION = 76; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3843,7 +3843,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3875,7 +3875,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 75; + CURRENT_PROJECT_VERSION = 76; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/tags/lldb-76/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-76/resources/LLDB-Info.plist?rev=138685&r1=138684&r2=138685&view=diff ============================================================================== --- lldb/tags/lldb-76/resources/LLDB-Info.plist (original) +++ lldb/tags/lldb-76/resources/LLDB-Info.plist Fri Aug 26 19:13:38 2011 @@ -13,11 +13,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.75 + 1.76 CFBundleSignature ???? CFBundleVersion - 75 + 76 CFBundleName ${EXECUTABLE_NAME} From jingham at apple.com Fri Aug 26 19:46:25 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 27 Aug 2011 00:46:25 -0000 Subject: [Lldb-commits] [lldb] r138690 - /lldb/tags/lldb-76/source/Commands/CommandObjectFrame.cpp Message-ID: <20110827004625.4EA1E2A6C12D@llvm.org> Author: jingham Date: Fri Aug 26 19:46:25 2011 New Revision: 138690 URL: http://llvm.org/viewvc/llvm-project?rev=138690&view=rev Log: Fix CommandObjectFrameVariable::Execute so that it holds onto a shared pointer to the frame it is inspecting, in case running code causes someone else to clear the stack list. Modified: lldb/tags/lldb-76/source/Commands/CommandObjectFrame.cpp Modified: lldb/tags/lldb-76/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-76/source/Commands/CommandObjectFrame.cpp?rev=138690&r1=138689&r2=138690&view=diff ============================================================================== --- lldb/tags/lldb-76/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/tags/lldb-76/source/Commands/CommandObjectFrame.cpp Fri Aug 26 19:46:25 2011 @@ -431,7 +431,13 @@ Stream &s = result.GetOutputStream(); bool get_file_globals = true; - VariableList *variable_list = exe_ctx.frame->GetVariableList (get_file_globals); + + // Be careful about the stack frame, if any summary formatter runs code, it might clear the StackFrameList + // for the thread. So hold onto a shared pointer to the frame so it stays alive. + + StackFrameSP frame_sp = exe_ctx.frame->GetSP(); + + VariableList *variable_list = frame_sp->GetVariableList (get_file_globals); VariableSP var_sp; ValueObjectSP valobj_sp; @@ -488,7 +494,7 @@ var_sp = regex_var_list.GetVariableAtIndex (regex_idx); if (var_sp) { - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); + valobj_sp = frame_sp->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); if (valobj_sp) { if (m_option_variable.format != eFormatDefault) @@ -529,7 +535,7 @@ Error error; uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember; lldb::VariableSP var_sp; - valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, + valobj_sp = frame_sp->GetValueForVariableExpressionPath (name_cstr, m_varobj_options.use_dynamic, expr_path_options, var_sp, @@ -609,7 +615,7 @@ // Use the variable object code to make sure we are // using the same APIs as the the public API will be // using... - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, + valobj_sp = frame_sp->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); if (valobj_sp) { From jingham at apple.com Fri Aug 26 20:22:52 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 27 Aug 2011 01:22:52 -0000 Subject: [Lldb-commits] [lldb] r138692 - /lldb/trunk/source/Commands/CommandObjectFrame.cpp Message-ID: <20110827012252.5B95D2A6C12D@llvm.org> Author: jingham Date: Fri Aug 26 20:22:52 2011 New Revision: 138692 URL: http://llvm.org/viewvc/llvm-project?rev=138692&view=rev Log: Hold onto a shared pointer to the frame CommandObjectFrameVariable::Execute is analyzing so it won't get deleted on us if a formatter runs code. Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=138692&r1=138691&r2=138692&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Aug 26 20:22:52 2011 @@ -432,7 +432,13 @@ Stream &s = result.GetOutputStream(); bool get_file_globals = true; - VariableList *variable_list = exe_ctx.frame->GetVariableList (get_file_globals); + + // Be careful about the stack frame, if any summary formatter runs code, it might clear the StackFrameList + // for the thread. So hold onto a shared pointer to the frame so it stays alive. + + StackFrameSP frame_sp = exe_ctx.frame->GetSP(); + + VariableList *variable_list = frame_sp->GetVariableList (get_file_globals); VariableSP var_sp; ValueObjectSP valobj_sp; @@ -489,7 +495,7 @@ var_sp = regex_var_list.GetVariableAtIndex (regex_idx); if (var_sp) { - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); + valobj_sp = frame_sp->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); if (valobj_sp) { if (m_option_variable.format != eFormatDefault) @@ -530,7 +536,7 @@ Error error; uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember; lldb::VariableSP var_sp; - valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, + valobj_sp = frame_sp->GetValueForVariableExpressionPath (name_cstr, m_varobj_options.use_dynamic, expr_path_options, var_sp, @@ -610,7 +616,7 @@ // Use the variable object code to make sure we are // using the same APIs as the the public API will be // using... - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, + valobj_sp = frame_sp->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); if (valobj_sp) { From jingham at apple.com Fri Aug 26 20:24:09 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 27 Aug 2011 01:24:09 -0000 Subject: [Lldb-commits] [lldb] r138693 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110827012409.0D1402A6C12D@llvm.org> Author: jingham Date: Fri Aug 26 20:24:08 2011 New Revision: 138693 URL: http://llvm.org/viewvc/llvm-project?rev=138693&view=rev Log: Don't change the host's environment, just append our Python Directory directly to the one in sys. 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=138693&r1=138692&r2=138693&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Aug 26 20:24:08 2011 @@ -2033,59 +2033,53 @@ TerminalState stdin_tty_state; stdin_tty_state.Save(STDIN_FILENO, false); + PyEval_InitThreads (); + Py_InitializeEx (0); + + // Initialize SWIG after setting up python + assert (g_swig_init_callback != NULL); + g_swig_init_callback (); + + // Update the path python uses to search for modules to include the current directory. + + PyRun_SimpleString ("import sys"); + PyRun_SimpleString ("sys.path.append ('.')"); + // Find the module that owns this code and use that path we get to - // set the PYTHONPATH appropriately. + // set the sys.path appropriately. FileSpec file_spec; char python_dir_path[PATH_MAX]; if (Host::GetLLDBPath (ePathTypePythonDir, file_spec)) { - std::string python_path; - const char *curr_python_path = ::getenv ("PYTHONPATH"); - if (curr_python_path) - { - // We have a current value for PYTHONPATH, so lets append to it - python_path.append (curr_python_path); - } - + std::string python_path("sys.path.insert(0,\""); + size_t orig_len = python_path.length(); if (file_spec.GetPath(python_dir_path, sizeof (python_dir_path))) { - if (!python_path.empty()) - python_path.append (1, ':'); python_path.append (python_dir_path); + python_path.append ("\")"); + PyRun_SimpleString (python_path.c_str()); + python_path.resize (orig_len); } if (Host::GetLLDBPath (ePathTypeLLDBShlibDir, file_spec)) { if (file_spec.GetPath(python_dir_path, sizeof (python_dir_path))) { - if (!python_path.empty()) - python_path.append (1, ':'); python_path.append (python_dir_path); + python_path.append ("\")"); + PyRun_SimpleString (python_path.c_str()); + python_path.resize (orig_len); } } - const char *pathon_path_env_cstr = python_path.c_str(); - ::setenv ("PYTHONPATH", pathon_path_env_cstr, 1); } - PyEval_InitThreads (); - Py_InitializeEx (0); - - // Initialize SWIG after setting up python - assert (g_swig_init_callback != NULL); - g_swig_init_callback (); - - // Update the path python uses to search for modules to include the current directory. - - PyRun_SimpleString ("import sys"); - PyRun_SimpleString ("sys.path.append ('.')"); PyRun_SimpleString ("sys.dont_write_bytecode = 1"); PyRun_SimpleString ("import embedded_interpreter"); PyRun_SimpleString ("from embedded_interpreter import run_python_interpreter"); PyRun_SimpleString ("from embedded_interpreter import run_one_line"); - PyRun_SimpleString ("import sys"); PyRun_SimpleString ("from termios import *"); stdin_tty_state.Restore(); From jingham at apple.com Fri Aug 26 20:24:54 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 27 Aug 2011 01:24:54 -0000 Subject: [Lldb-commits] [lldb] r138694 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: DWARFDebugInfo.cpp DWARFDebugInfoEntry.cpp DWARFDebugInfoEntry.h DWARFDebugRanges.cpp DWARFDebugRanges.h DWARFFormValue.cpp DWARFFormValue.h DWARFLocationDescription.cpp DWARFLocationDescription.h DWARFLocationList.cpp DWARFLocationList.h SymbolFileDWARF.cpp Message-ID: <20110827012454.892DC2A6C12D@llvm.org> Author: jingham Date: Fri Aug 26 20:24:54 2011 New Revision: 138694 URL: http://llvm.org/viewvc/llvm-project?rev=138694&view=rev Log: Fix a bunch of places where we were passing Stream *'s but were never checking them for NULL. Pass a reference instead. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Fri Aug 26 20:24:54 2011 @@ -940,7 +940,7 @@ { // Yes we are dumping everything. Obey our recurse level though if (curr_depth < dumpInfo->recurse_depth) - die->Dump(dwarf2Data, cu, s, 0); + die->Dump(dwarf2Data, cu, *s, 0); } else { @@ -956,7 +956,7 @@ { for (uint32_t i=0; iancestors[i].Dump(dwarf2Data, cu, s, 0); + dumpInfo->ancestors[i].Dump(dwarf2Data, cu, *s, 0); s->IndentMore(); } } @@ -964,7 +964,7 @@ dumpInfo->found_depth = curr_depth; - die->Dump(dwarf2Data, cu, s, 0); + die->Dump(dwarf2Data, cu, *s, 0); // Note that we found the DIE we were looking for dumpInfo->found_die = true; @@ -983,7 +983,7 @@ // our recurse depth and return an invalid offset if we get done // dumping all the the children if (dumpInfo->recurse_depth == UINT32_MAX || curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth) - die->Dump(dwarf2Data, cu, s, 0); + die->Dump(dwarf2Data, cu, *s, 0); } else if (dumpInfo->die_offset > die->GetOffset()) { @@ -1133,7 +1133,7 @@ { const DWARFCompileUnitSP& cu_sp = *pos; DumpCallback(m_dwarf2Data, (DWARFCompileUnitSP&)cu_sp, NULL, 0, curr_depth, &dumpInfo); - cu_sp->DIE()->Dump(m_dwarf2Data, cu_sp.get(), s, recurse_depth); + cu_sp->DIE()->Dump(m_dwarf2Data, cu_sp.get(), *s, recurse_depth); } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Fri Aug 26 20:24:54 2011 @@ -583,7 +583,7 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const DWARFDebugInfoEntry* oldest, - Stream *s, + Stream &s, uint32_t recurse_depth ) const { @@ -1074,7 +1074,7 @@ ( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, - Stream *s, + Stream &s, uint32_t recurse_depth ) const { @@ -1085,14 +1085,14 @@ { dw_uleb128_t abbrCode = debug_info_data.GetULEB128(&offset); - s->Printf("\n0x%8.8x: ", m_offset); - s->Indent(); + s.Printf("\n0x%8.8x: ", m_offset); + s.Indent(); if (abbrCode) { if (m_abbrevDecl) { - s->PutCString(DW_TAG_value_to_name(m_abbrevDecl->Tag())); - s->Printf( " [%u] %c\n", abbrCode, m_abbrevDecl->HasChildren() ? '*':' '); + s.PutCString(DW_TAG_value_to_name(m_abbrevDecl->Tag())); + s.Printf( " [%u] %c\n", abbrCode, m_abbrevDecl->HasChildren() ? '*':' '); // Dump all data in the .debug_info for the attributes const uint32_t numAttributes = m_abbrevDecl->NumAttributes(); @@ -1109,22 +1109,22 @@ const DWARFDebugInfoEntry* child = GetFirstChild(); if (recurse_depth > 0 && child) { - s->IndentMore(); + s.IndentMore(); while (child) { child->Dump(dwarf2Data, cu, s, recurse_depth-1); child = child->GetSibling(); } - s->IndentLess(); + s.IndentLess(); } } else - s->Printf( "Abbreviation code note found in 'debug_abbrev' class for code: %u\n", abbrCode); + s.Printf( "Abbreviation code note found in 'debug_abbrev' class for code: %u\n", abbrCode); } else { - s->Printf( "NULL\n"); + s.Printf( "NULL\n"); } } } @@ -1134,7 +1134,7 @@ ( SymbolFileDWARF* dwarf2Data, DWARFCompileUnit* cu, - Stream *s + Stream &s ) const { const DWARFDebugInfoEntry *cu_die = cu->GetCompileUnitDIEOnly(); @@ -1146,7 +1146,7 @@ if (obj_file) obj_file_name = obj_file->GetFileSpec().GetFilename().AsCString(); const char *die_name = GetName (dwarf2Data, cu); - s->Printf ("CU: %s OBJFILE: %s DIE: %s (0x%llx).", + s.Printf ("CU: %s OBJFILE: %s DIE: %s (0x%llx).", cu_name ? cu_name : "", obj_file_name ? obj_file_name : "", die_name ? die_name : "", @@ -1167,23 +1167,23 @@ const DWARFCompileUnit* cu, const DataExtractor& debug_info_data, uint32_t* offset_ptr, - Stream *s, + Stream &s, dw_attr_t attr, dw_form_t form ) { - bool verbose = s->GetVerbose(); - bool show_form = s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm); + bool verbose = s.GetVerbose(); + bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm); const DataExtractor* debug_str_data = dwarf2Data ? &dwarf2Data->get_debug_str_data() : NULL; if (verbose) - s->Offset (*offset_ptr); + s.Offset (*offset_ptr); else - s->Printf (" "); - s->Indent(DW_AT_value_to_name(attr)); + s.Printf (" "); + s.Indent(DW_AT_value_to_name(attr)); if (show_form) { - s->Printf( "[%s", DW_FORM_value_to_name(form)); + s.Printf( "[%s", DW_FORM_value_to_name(form)); } DWARFFormValue form_value(form); @@ -1195,13 +1195,13 @@ { if (form == DW_FORM_indirect) { - s->Printf( " [%s]", DW_FORM_value_to_name(form_value.Form())); + s.Printf( " [%s]", DW_FORM_value_to_name(form_value.Form())); } - s->PutCString("] "); + s.PutCString("] "); } - s->PutCString("( "); + s.PutCString("( "); // Always dump form value if verbose is enabled if (verbose) @@ -1214,21 +1214,21 @@ switch (attr) { case DW_AT_stmt_list: - if ( verbose ) s->PutCString(" ( "); - s->Printf( "0x%8.8x", form_value.Unsigned()); - if ( verbose ) s->PutCString(" )"); + if ( verbose ) s.PutCString(" ( "); + s.Printf( "0x%8.8x", form_value.Unsigned()); + if ( verbose ) s.PutCString(" )"); break; case DW_AT_language: - if ( verbose ) s->PutCString(" ( "); - s->PutCString(DW_LANG_value_to_name(form_value.Unsigned())); - if ( verbose ) s->PutCString(" )"); + if ( verbose ) s.PutCString(" ( "); + s.PutCString(DW_LANG_value_to_name(form_value.Unsigned())); + if ( verbose ) s.PutCString(" )"); break; case DW_AT_encoding: - if ( verbose ) s->PutCString(" ( "); - s->PutCString(DW_ATE_value_to_name(form_value.Unsigned())); - if ( verbose ) s->PutCString(" )"); + if ( verbose ) s.PutCString(" ( "); + s.PutCString(DW_ATE_value_to_name(form_value.Unsigned())); + if ( verbose ) s.PutCString(" )"); break; case DW_AT_frame_base: @@ -1243,9 +1243,9 @@ // Location description is inlined in data in the form value DataExtractor locationData(debug_info_data, (*offset_ptr) - form_value.Unsigned(), form_value.Unsigned()); - if ( verbose ) s->PutCString(" ( "); + if ( verbose ) s.PutCString(" ( "); print_dwarf_expression (s, locationData, DWARFCompileUnit::GetAddressByteSize(cu), 4, false); - if ( verbose ) s->PutCString(" )"); + if ( verbose ) s.PutCString(" )"); } else { @@ -1274,9 +1274,9 @@ uint64_t abstract_die_offset = form_value.Reference(cu); form_value.Dump(s, debug_str_data, cu); // *ostrm_ptr << HEX32 << abstract_die_offset << " ( "; - if ( verbose ) s->PutCString(" ( "); + if ( verbose ) s.PutCString(" ( "); GetName(dwarf2Data, cu, abstract_die_offset, s); - if ( verbose ) s->PutCString(" )"); + if ( verbose ) s.PutCString(" )"); } break; @@ -1285,9 +1285,9 @@ uint64_t type_die_offset = form_value.Reference(cu); if (!verbose) form_value.Dump(s, debug_str_data, cu); - s->PutCString(" ( "); + s.PutCString(" ( "); AppendTypeName(dwarf2Data, cu, type_die_offset, s); - s->PutCString(" )"); + s.PutCString(" )"); } break; @@ -1307,7 +1307,7 @@ break; } - s->PutCString(" )\n"); + s.PutCString(" )\n"); } //---------------------------------------------------------------------- @@ -1684,7 +1684,7 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const uint32_t die_offset, - Stream *s + Stream &s ) { DWARFDebugInfoEntry die; @@ -1693,7 +1693,7 @@ { if (die.IsNULL()) { - s->PutCString("NULL"); + s.PutCString("NULL"); return true; } else @@ -1704,7 +1704,7 @@ const char* name = form_value.AsCString(&dwarf2Data->get_debug_str_data()); if (name) { - s->PutCString(name); + s.PutCString(name); return true; } } @@ -1727,7 +1727,7 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const uint32_t die_offset, - Stream *s + Stream &s ) { DWARFDebugInfoEntry die; @@ -1736,7 +1736,7 @@ { if (die.IsNULL()) { - s->PutCString("NULL"); + s.PutCString("NULL"); return true; } else @@ -1745,7 +1745,7 @@ // if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value)) // name = form_value.AsCString(&dwarf2Data->get_debug_str_data()); if (name) - s->PutCString(name); + s.PutCString(name); else { bool result = true; @@ -1754,27 +1754,27 @@ switch (abbrevDecl->Tag()) { case DW_TAG_array_type: break; // print out a "[]" after printing the full type of the element below - case DW_TAG_base_type: s->PutCString("base "); break; - case DW_TAG_class_type: s->PutCString("class "); break; - case DW_TAG_const_type: s->PutCString("const "); break; - case DW_TAG_enumeration_type: s->PutCString("enum "); break; - case DW_TAG_file_type: s->PutCString("file "); break; - case DW_TAG_interface_type: s->PutCString("interface "); break; - case DW_TAG_packed_type: s->PutCString("packed "); break; + case DW_TAG_base_type: s.PutCString("base "); break; + case DW_TAG_class_type: s.PutCString("class "); break; + case DW_TAG_const_type: s.PutCString("const "); break; + case DW_TAG_enumeration_type: s.PutCString("enum "); break; + case DW_TAG_file_type: s.PutCString("file "); break; + case DW_TAG_interface_type: s.PutCString("interface "); break; + case DW_TAG_packed_type: s.PutCString("packed "); break; case DW_TAG_pointer_type: break; // print out a '*' after printing the full type below case DW_TAG_ptr_to_member_type: break; // print out a '*' after printing the full type below case DW_TAG_reference_type: break; // print out a '&' after printing the full type below - case DW_TAG_restrict_type: s->PutCString("restrict "); break; - case DW_TAG_set_type: s->PutCString("set "); break; - case DW_TAG_shared_type: s->PutCString("shared "); break; - case DW_TAG_string_type: s->PutCString("string "); break; - case DW_TAG_structure_type: s->PutCString("struct "); break; - case DW_TAG_subrange_type: s->PutCString("subrange "); break; - case DW_TAG_subroutine_type: s->PutCString("function "); break; - case DW_TAG_thrown_type: s->PutCString("thrown "); break; - case DW_TAG_union_type: s->PutCString("union "); break; - case DW_TAG_unspecified_type: s->PutCString("unspecified "); break; - case DW_TAG_volatile_type: s->PutCString("volatile "); break; + case DW_TAG_restrict_type: s.PutCString("restrict "); break; + case DW_TAG_set_type: s.PutCString("set "); break; + case DW_TAG_shared_type: s.PutCString("shared "); break; + case DW_TAG_string_type: s.PutCString("string "); break; + case DW_TAG_structure_type: s.PutCString("struct "); break; + case DW_TAG_subrange_type: s.PutCString("subrange "); break; + case DW_TAG_subroutine_type: s.PutCString("function "); break; + case DW_TAG_thrown_type: s.PutCString("thrown "); break; + case DW_TAG_union_type: s.PutCString("union "); break; + case DW_TAG_unspecified_type: s.PutCString("unspecified "); break; + case DW_TAG_volatile_type: s.PutCString("volatile "); break; default: return false; } @@ -1789,10 +1789,10 @@ switch (abbrevDecl->Tag()) { - case DW_TAG_array_type: s->PutCString("[]"); break; - case DW_TAG_pointer_type: s->PutChar('*'); break; - case DW_TAG_ptr_to_member_type: s->PutChar('*'); break; - case DW_TAG_reference_type: s->PutChar('&'); break; + case DW_TAG_array_type: s.PutCString("[]"); break; + case DW_TAG_pointer_type: s.PutChar('*'); break; + case DW_TAG_ptr_to_member_type: s.PutChar('*'); break; + case DW_TAG_reference_type: s.PutChar('&'); break; default: break; } 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=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Fri Aug 26 20:24:54 2011 @@ -201,13 +201,13 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const dw_offset_t die_offset, - lldb_private::Stream *s); + lldb_private::Stream &s); static bool AppendTypeName( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const dw_offset_t die_offset, - lldb_private::Stream *s); + lldb_private::Stream &s); // static int Compare( // SymbolFileDWARF* dwarf2Data, @@ -238,14 +238,14 @@ void Dump( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, - lldb_private::Stream *s, + lldb_private::Stream &s, uint32_t recurse_depth) const; void DumpAncestry( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const DWARFDebugInfoEntry* oldest, - lldb_private::Stream *s, + lldb_private::Stream &s, uint32_t recurse_depth) const; static void DumpAttribute( @@ -253,14 +253,14 @@ const DWARFCompileUnit* cu, const lldb_private::DataExtractor& debug_info_data, uint32_t* offset_ptr, - lldb_private::Stream *s, + lldb_private::Stream &s, dw_attr_t attr, dw_form_t form); // This one dumps the comp unit name, objfile name and die offset for this die so the stream S. void DumpLocation( SymbolFileDWARF* dwarf2Data, DWARFCompileUnit* cu, - lldb_private::Stream *s) const; + lldb_private::Stream &s) const; bool GetDIENamesAndRanges( SymbolFileDWARF* dwarf2Data, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp?rev=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp Fri Aug 26 20:24:54 2011 @@ -215,10 +215,10 @@ void -DWARFDebugRanges::Dump(Stream *s, const DataExtractor& debug_ranges_data, uint32_t* offset_ptr, dw_addr_t cu_base_addr) +DWARFDebugRanges::Dump(Stream &s, const DataExtractor& debug_ranges_data, uint32_t* offset_ptr, dw_addr_t cu_base_addr) { - uint32_t addr_size = s->GetAddressByteSize(); - bool verbose = s->GetVerbose(); + uint32_t addr_size = s.GetAddressByteSize(); + bool verbose = s.GetVerbose(); dw_addr_t base_addr = cu_base_addr; while (debug_ranges_data.ValidOffsetForDataOfSize(*offset_ptr, 2 * addr_size)) @@ -230,23 +230,23 @@ if (begin == 0xFFFFFFFFull && addr_size == 4) begin = DW_INVALID_ADDRESS; - s->Indent(); + s.Indent(); if (verbose) { - s->AddressRange(begin, end, sizeof (dw_addr_t), " offsets = "); + s.AddressRange(begin, end, sizeof (dw_addr_t), " offsets = "); } if (begin == 0 && end == 0) { - s->PutCString(" End"); + s.PutCString(" End"); break; } else if (begin == DW_INVALID_ADDRESS) { // A base address selection entry base_addr = end; - s->Address(base_addr, sizeof (dw_addr_t), " Base address = "); + s.Address(base_addr, sizeof (dw_addr_t), " Base address = "); } else { @@ -254,7 +254,7 @@ dw_addr_t begin_addr = begin + base_addr; dw_addr_t end_addr = end + base_addr; - s->AddressRange(begin_addr, end_addr, sizeof (dw_addr_t), verbose ? " ==> addrs = " : NULL); + s.AddressRange(begin_addr, end_addr, sizeof (dw_addr_t), verbose ? " ==> addrs = " : NULL); } } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h?rev=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h Fri Aug 26 20:24:54 2011 @@ -75,7 +75,7 @@ DWARFDebugRanges(); ~DWARFDebugRanges(); void Extract(SymbolFileDWARF* dwarf2Data); - static void Dump(lldb_private::Stream *s, const lldb_private::DataExtractor& debug_ranges_data, uint32_t* offset_ptr, dw_addr_t cu_base_addr); + static void Dump(lldb_private::Stream &s, const lldb_private::DataExtractor& debug_ranges_data, uint32_t* offset_ptr, dw_addr_t cu_base_addr); bool FindRanges(dw_offset_t debug_ranges_offset, DWARFDebugRanges::RangeList& range_list) const; protected: Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp?rev=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp Fri Aug 26 20:24:54 2011 @@ -350,22 +350,22 @@ //} void -DWARFFormValue::Dump(Stream *s, const DataExtractor* debug_str_data, const DWARFCompileUnit* cu) const +DWARFFormValue::Dump(Stream &s, const DataExtractor* debug_str_data, const DWARFCompileUnit* cu) const { uint64_t uvalue = Unsigned(); bool cu_relative_offset = false; - bool verbose = s->GetVerbose(); + bool verbose = s.GetVerbose(); switch (m_form) { - case DW_FORM_addr: s->Address(uvalue, sizeof (uint64_t)); break; + case DW_FORM_addr: s.Address(uvalue, sizeof (uint64_t)); break; case DW_FORM_flag: - case DW_FORM_data1: s->PutHex8(uvalue); break; - case DW_FORM_data2: s->PutHex16(uvalue); break; - case DW_FORM_data4: s->PutHex32(uvalue); break; - case DW_FORM_data8: s->PutHex64(uvalue); break; - case DW_FORM_string: s->QuotedCString(AsCString(NULL)); break; + case DW_FORM_data1: s.PutHex8(uvalue); break; + case DW_FORM_data2: s.PutHex16(uvalue); break; + case DW_FORM_data4: s.PutHex32(uvalue); break; + case DW_FORM_data8: s.PutHex64(uvalue); break; + case DW_FORM_string: s.QuotedCString(AsCString(NULL)); break; case DW_FORM_block: case DW_FORM_block1: case DW_FORM_block2: @@ -374,10 +374,10 @@ { switch (m_form) { - case DW_FORM_block: s->Printf("<0x%llx> ", uvalue); break; - case DW_FORM_block1: s->Printf("<0x%2.2x> ", (uint8_t)uvalue); break; - case DW_FORM_block2: s->Printf("<0x%4.4x> ", (uint16_t)uvalue); break; - case DW_FORM_block4: s->Printf("<0x%8.8x> ", (uint32_t)uvalue); break; + case DW_FORM_block: s.Printf("<0x%llx> ", uvalue); break; + case DW_FORM_block1: s.Printf("<0x%2.2x> ", (uint8_t)uvalue); break; + case DW_FORM_block2: s.Printf("<0x%4.4x> ", (uint16_t)uvalue); break; + case DW_FORM_block4: s.Printf("<0x%8.8x> ", (uint32_t)uvalue); break; default: break; } @@ -387,57 +387,57 @@ const uint8_t* end_data_ptr = data_ptr + uvalue; // uvalue contains size of block while (data_ptr < end_data_ptr) { - s->Printf("%2.2x ", *data_ptr); + s.Printf("%2.2x ", *data_ptr); ++data_ptr; } } else - s->PutCString("NULL"); + s.PutCString("NULL"); } break; - case DW_FORM_sdata: s->PutSLEB128(uvalue); break; - case DW_FORM_udata: s->PutULEB128(uvalue); break; + case DW_FORM_sdata: s.PutSLEB128(uvalue); break; + case DW_FORM_udata: s.PutULEB128(uvalue); break; case DW_FORM_strp: if (debug_str_data) { if (verbose) - s->Printf(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue); + s.Printf(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue); const char* dbg_str = AsCString(debug_str_data); if (dbg_str) - s->QuotedCString(dbg_str); + s.QuotedCString(dbg_str); } else { - s->PutHex32(uvalue); + s.PutHex32(uvalue); } break; case DW_FORM_ref_addr: { - s->Address(uvalue, sizeof (uint64_t) * 2); + s.Address(uvalue, sizeof (uint64_t) * 2); break; } - case DW_FORM_ref1: cu_relative_offset = true; if (verbose) s->Printf("cu + 0x%2.2x", (uint8_t)uvalue); break; - case DW_FORM_ref2: cu_relative_offset = true; if (verbose) s->Printf("cu + 0x%4.4x", (uint16_t)uvalue); break; - case DW_FORM_ref4: cu_relative_offset = true; if (verbose) s->Printf("cu + 0x%4.4x", (uint32_t)uvalue); break; - case DW_FORM_ref8: cu_relative_offset = true; if (verbose) s->Printf("cu + 0x%8.8llx", uvalue); break; - case DW_FORM_ref_udata: cu_relative_offset = true; if (verbose) s->Printf("cu + 0x%llx", uvalue); break; + case DW_FORM_ref1: cu_relative_offset = true; if (verbose) s.Printf("cu + 0x%2.2x", (uint8_t)uvalue); break; + case DW_FORM_ref2: cu_relative_offset = true; if (verbose) s.Printf("cu + 0x%4.4x", (uint16_t)uvalue); break; + case DW_FORM_ref4: cu_relative_offset = true; if (verbose) s.Printf("cu + 0x%4.4x", (uint32_t)uvalue); break; + case DW_FORM_ref8: cu_relative_offset = true; if (verbose) s.Printf("cu + 0x%8.8llx", uvalue); break; + case DW_FORM_ref_udata: cu_relative_offset = true; if (verbose) s.Printf("cu + 0x%llx", uvalue); break; // All DW_FORM_indirect attributes should be resolved prior to calling this function - case DW_FORM_indirect: s->PutCString("DW_FORM_indirect"); break; + case DW_FORM_indirect: s.PutCString("DW_FORM_indirect"); break; default: - s->Printf("DW_FORM(0x%4.4x)", m_form); + s.Printf("DW_FORM(0x%4.4x)", m_form); break; } if (cu_relative_offset) { if (verbose) - s->PutCString(" => "); + s.PutCString(" => "); - s->Printf("{0x%8.8x}", (uvalue + (cu ? cu->GetOffset() : 0))); + s.Printf("{0x%8.8x}", (uvalue + (cu ? cu->GetOffset() : 0))); } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h?rev=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h Fri Aug 26 20:24:54 2011 @@ -52,7 +52,7 @@ dw_form_t Form() const { return m_form; } void SetForm(dw_form_t form) { m_form = form; } const ValueType& Value() const { return m_value; } - void Dump(lldb_private::Stream *s, const lldb_private::DataExtractor* debug_str_data, const DWARFCompileUnit* cu) const; + void Dump(lldb_private::Stream &s, const lldb_private::DataExtractor* debug_str_data, const DWARFCompileUnit* cu) const; bool ExtractValue(const lldb_private::DataExtractor& data, uint32_t* offset_ptr, const DWARFCompileUnit* cu); bool IsInlinedCStr() const { return (m_value.data != NULL) && m_value.data == (uint8_t*)m_value.value.cstr; } const uint8_t* BlockData() const; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp?rev=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp Fri Aug 26 20:24:54 2011 @@ -15,10 +15,10 @@ using namespace lldb_private; -static int print_dwarf_exp_op (Stream *s, const DataExtractor& data, uint32_t* offset_ptr, int address_size, int dwarf_ref_size); +static int print_dwarf_exp_op (Stream &s, const DataExtractor& data, uint32_t* offset_ptr, int address_size, int dwarf_ref_size); int -print_dwarf_expression (Stream *s, +print_dwarf_expression (Stream &s, const DataExtractor& data, int address_size, int dwarf_ref_size, @@ -35,7 +35,7 @@ } if (op_count > 0) { - s->PutCString(", "); + s.PutCString(", "); } if (print_dwarf_exp_op (s, data, &offset, address_size, dwarf_ref_size) == 1) return 1; @@ -46,7 +46,7 @@ } static int -print_dwarf_exp_op (Stream *s, +print_dwarf_exp_op (Stream &s, const DataExtractor& data, uint32_t* offset_ptr, int address_size, @@ -61,7 +61,7 @@ opcode_class = DW_OP_value_to_class (opcode) & (~DRC_DWARFv3); - s->Printf("%s ", DW_OP_value_to_name (opcode)); + s.Printf("%s ", DW_OP_value_to_name (opcode)); /* Does this take zero parameters? If so we can shortcut this function. */ if (opcode_class == DRC_ZEROOPERANDS) @@ -71,12 +71,12 @@ { uint = data.GetULEB128(offset_ptr); sint = data.GetSLEB128(offset_ptr); - s->Printf("%llu %lli", uint, sint); + s.Printf("%llu %lli", uint, sint); return 0; } if (opcode_class != DRC_ONEOPERAND) { - s->Printf("UNKNOWN OP %u", opcode); + s.Printf("UNKNOWN OP %u", opcode); return 1; } @@ -150,22 +150,22 @@ case DW_OP_regx: size = 128; break; default: - s->Printf("UNKNOWN ONE-OPERAND OPCODE, #%u", opcode); + s.Printf("UNKNOWN ONE-OPERAND OPCODE, #%u", opcode); return 1; } switch (size) { - case -1: sint = (int8_t) data.GetU8(offset_ptr); s->Printf("%+lli", sint); break; - case -2: sint = (int16_t) data.GetU16(offset_ptr); s->Printf("%+lli", sint); break; - case -4: sint = (int32_t) data.GetU32(offset_ptr); s->Printf("%+lli", sint); break; - case -8: sint = (int64_t) data.GetU64(offset_ptr); s->Printf("%+lli", sint); break; - case -128: sint = data.GetSLEB128(offset_ptr); s->Printf("%+lli", sint); break; - case 1: uint = data.GetU8(offset_ptr); s->Printf("0x%2.2llx", uint); break; - case 2: uint = data.GetU16(offset_ptr); s->Printf("0x%4.4llx", uint); break; - case 4: uint = data.GetU32(offset_ptr); s->Printf("0x%8.8llx", uint); break; - case 8: uint = data.GetU64(offset_ptr); s->Printf("0x%16.16llx", uint); break; - case 128: uint = data.GetULEB128(offset_ptr); s->Printf("0x%llx", uint); break; + case -1: sint = (int8_t) data.GetU8(offset_ptr); s.Printf("%+lli", sint); break; + case -2: sint = (int16_t) data.GetU16(offset_ptr); s.Printf("%+lli", sint); break; + case -4: sint = (int32_t) data.GetU32(offset_ptr); s.Printf("%+lli", sint); break; + case -8: sint = (int64_t) data.GetU64(offset_ptr); s.Printf("%+lli", sint); break; + case -128: sint = data.GetSLEB128(offset_ptr); s.Printf("%+lli", sint); break; + case 1: uint = data.GetU8(offset_ptr); s.Printf("0x%2.2llx", uint); break; + case 2: uint = data.GetU16(offset_ptr); s.Printf("0x%4.4llx", uint); break; + case 4: uint = data.GetU32(offset_ptr); s.Printf("0x%8.8llx", uint); break; + case 8: uint = data.GetU64(offset_ptr); s.Printf("0x%16.16llx", uint); break; + case 128: uint = data.GetULEB128(offset_ptr); s.Printf("0x%llx", uint); break; } return 0; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h?rev=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h Fri Aug 26 20:24:54 2011 @@ -13,7 +13,7 @@ #include "SymbolFileDWARF.h" int -print_dwarf_expression (lldb_private::Stream *s, +print_dwarf_expression (lldb_private::Stream &s, const lldb_private::DataExtractor& data, int address_size, int dwarf_ref_size, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp?rev=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp Fri Aug 26 20:24:54 2011 @@ -18,11 +18,11 @@ using namespace lldb_private; dw_offset_t -DWARFLocationList::Dump(Stream *s, const DWARFCompileUnit* cu, const DataExtractor& debug_loc_data, dw_offset_t offset) +DWARFLocationList::Dump(Stream &s, const DWARFCompileUnit* cu, const DataExtractor& debug_loc_data, dw_offset_t offset) { uint64_t start_addr, end_addr; uint32_t addr_size = DWARFCompileUnit::GetAddressByteSize(cu); - s->SetAddressByteSize(DWARFCompileUnit::GetAddressByteSize(cu)); + s.SetAddressByteSize(DWARFCompileUnit::GetAddressByteSize(cu)); dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0; while (debug_loc_data.ValidOffset(offset)) { @@ -32,9 +32,9 @@ if (start_addr == 0 && end_addr == 0) break; - s->PutCString("\n "); - s->Indent(); - s->AddressRange(start_addr + base_addr, end_addr + base_addr, NULL, ": "); + s.PutCString("\n "); + s.Indent(); + s.AddressRange(start_addr + base_addr, end_addr + base_addr, NULL, ": "); uint32_t loc_length = debug_loc_data.GetU16(&offset); DataExtractor locationData(debug_loc_data, offset, loc_length); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h?rev=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h Fri Aug 26 20:24:54 2011 @@ -16,7 +16,7 @@ { public: static dw_offset_t - Dump (lldb_private::Stream *s, + Dump (lldb_private::Stream &s, const DWARFCompileUnit* cu, const lldb_private::DataExtractor& debug_loc_data, dw_offset_t offset); 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=138694&r1=138693&r2=138694&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Aug 26 20:24:54 2011 @@ -3078,7 +3078,7 @@ if (log && dwarf_cu) { StreamString s; - die->DumpLocation (this, dwarf_cu, &s); + die->DumpLocation (this, dwarf_cu, s); log->Printf ("SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData()); }