Commit Graph

800 Commits

Author SHA1 Message Date
Enrico Granata 58ad33440a Taking care of an issue with using lldb_private types in SBCommandInterpreter.cpp ; Making NSString test case work on Snow Leopard ; Removing an unused variable warning
llvm-svn: 138105
2011-08-19 21:56:10 +00:00
Enrico Granata d64d0bc0ea - Now using ${var} as the summary for an aggregate type will produce "name-of-type @ object-location" instead of giving an error
e.g. you may get "foo_class @ 0x123456" when typing "type summary add -f ${var} foo_class"
- Added a new special formatting token %T for summaries. This shows the type of the object.
  Using it, the new "type @ location" summary could be manually generated by writing ${var%T} @ ${var%L}
- Bits and pieces required to support "frame variable array[n-m]"
  The feature is not enabled yet because some additional design and support code is required, but the basics
  are getting there
- Fixed a potential issue where a ValueObjectSyntheticFilter was not holding on to its SyntheticChildrenSP
  Because of the way VOSF are being built now, this has never been an actual issue, but it is still sensible for
  a VOSF to hold on to the SyntheticChildrenSP as well as to its FrontEnd

llvm-svn: 138080
2011-08-19 21:13:46 +00:00
Enrico Granata da616d06e9 More thorough fix for the spaces-in-typename issue
llvm-svn: 138026
2011-08-19 01:47:11 +00:00
Enrico Granata 02b6676d2b Third round of code cleanups:
- reorganizing the PTS (Partial Template Specializations) in FormatManager.h
 - applied a patch by Filipe Cabecinhas to make LLDB compile with GCC
Functional changes:
 - fixed an issue where command type summary add for type "struct Foo" would not match any types.
   currently, "struct" will be stripped off and type "Foo" will be matched.
   similar behavior occurs for class, enum and union specifiers.

llvm-svn: 138020
2011-08-19 01:14:49 +00:00
Enrico Granata 85933ed40c Second round of code cleanups:
- reorganizing classes layout to have public part first
   Typedefs that we want to keep private, but must be defined for some public code to work correctly are an exception
 - avoiding methods in the form T foo() { code; } all on one-line
 - moving method implementations from .h to .cpp whenever feasible
   Templatized code is an exception and so are very small methods
 - generally, adhering to coding conventions followed project-wide
Functional changes:
 - fixed an issue where using ${var} in a summary for an aggregate, and then displaying a pointer-to-aggregate would lead to no summary being displayed
   The issue was not a major one because all ${var} was meant to do in that context was display an error for invalid use of pointer
   Accordingly fixed test cases and added a new test case

llvm-svn: 137944
2011-08-18 16:38:26 +00:00
Enrico Granata c482a19294 First round of code cleanups:
- all instances of "vobj" have been renamed to "valobj"
 - class Debugger::Formatting has been renamed to DataVisualization (defined in FormatManager.h/cpp)
   The interface to this class has not changed
 - FormatCategory now uses ConstString's as keys to the navigators instead of repeatedly casting
   from ConstString to const char* and back all the time
   Next step is making the same happen for categories themselves
 - category gnu-libstdc++ is defined in the constructor for a FormatManager
   The source code for it is defined in gnu_libstdcpp.py, drawn from examples/synthetic at compile time
   All references to previous 'osxcpp' name have been removed from both code and file names
Functional changes:
 - the name of the option to use a summary string for 'type summary add' has changed from the previous --format-string
   to the new --summary-string. It is expected that the short option will change from -f to -s, and -s for --python-script
   will become -o

llvm-svn: 137886
2011-08-17 22:13:59 +00:00
Enrico Granata 217f91fc57 New category "gnu-libstdc++" provides summary for std::string and synthetic children for types std::map, std::list and std::vector
The category is enabled by default. If you run into issues with it, disable it and the previous behavior of LLDB is restored
 ** This is a temporary solution. The general solution to having formatters pulled in at startup should involve going through the Platform.
Fixed an issue in type synthetic list where a category with synthetic providers in it was not shown if all the providers were regex-based

llvm-svn: 137850
2011-08-17 19:07:52 +00:00
Enrico Granata 99f0b8f935 When defining a scripted command, it is possible to provide a docstring and that will be used as the help text for the command
If no docstring is provided, a default help text is created
LLDB will refuse to create scripted commands if the scripting language is anything but Python
Some additional comments in AppleObjCRuntimeV2.cpp to describe the memory layout expected by the dynamic type lookup code

llvm-svn: 137801
2011-08-17 01:30:04 +00:00
Enrico Granata 223383ed6c Changes to Python commands:
- They now have an SBCommandReturnObject instead of an SBStream as third argument
 - The class CommandObjectPythonFunction has been merged into CommandObjectCommands.cpp
 - The command to manage them is now:
  command script with subcommands add, list, delete, clear
   command alias is returned to its previous functionality
 - Python commands are now part of an user dictionary, instead of being seen as aliases
 

llvm-svn: 137785
2011-08-16 23:24:13 +00:00
Enrico Granata be93a35a8a Python commands:
It is now possible to use 'command alias --python' to define a command name that actually triggers execution of a Python function
 (e.g. command alias --python foo foo_impl makes a command named 'foo' that runs Python function 'foo_impl')
 The Python function foo_impl should have as signature: def foo_impl(debugger, args, stream, dict): where
  debugger is an object wrapping an LLDB SBDebugger
  args is the command line arguments, as an unparsed Python string
  stream is an SBStream that represents the standard output
  dict is an internal utility parameter and should be left untouched
 The function should return None on no error, or an error string to describe any problems

llvm-svn: 137722
2011-08-16 16:49:25 +00:00
Greg Clayton 2d928c4d07 Fixed register value objects to be able to return their values as unsigned
and signed integers.

llvm-svn: 137710
2011-08-16 03:49:01 +00:00
Enrico Granata 379447a7f2 Refactoring of ValueObject::DumpValueObject and 'frame variable', 'target variable' commands to use an Options object instead of passing an ever-increasing number of arguments to the DumpValueObject() method, with the ultimate aim of making that call private implementation
llvm-svn: 137622
2011-08-15 18:01:31 +00:00
Jim Ingham ff5f5ff963 Factor out the code that parses ObjC Method names into a static method
in ObjCLanguageRuntime.
Add the category-free name of symbols to the Symtab name-to-index list.

llvm-svn: 137600
2011-08-15 01:32:22 +00:00
Jim Ingham 06942690b1 Add a version of SBDebugger::Create which allows us to specify whether to source
in the init files or not.

llvm-svn: 137541
2011-08-13 00:22:20 +00:00
Jim Ingham 16e0c68627 Make ValueObject::SetValueFromCString work correctly.
Also change the SourceInitFile to look for .lldb-<APPNAME> and source that
preferentially if it exists.
Also made the breakpoint site report its address as well as its breakpoint number
when it gets hit and can't find any the associated locations (usually because the
breakpoint got disabled or deleted programmatically between the time it was hit
and reported.)
Changed ThreadPlanCallFunction to initialize the ivar m_func in the initializers of the
constructor, rather than waiting to initialize till later on in the function.
Fixed a bug where if you make an SBError and the ask it Success, it returns false.
Fixed ValueObject::ResolveValue so that it resolves a temporary value, rather than
overwriting the one in the value object.

llvm-svn: 137536
2011-08-12 23:34:31 +00:00
Greg Clayton b8171ddf3e Removed an initialization that wasn't needed.
llvm-svn: 137533
2011-08-12 23:32:17 +00:00
Greg Clayton 7e9b1fd045 We were leaking a stack frame in StackFrameList in Thread.cpp which could
cause extra shared pointer references to one or more modules to be leaked.
This would cause many object files to stay around the life of LLDB, so after
a recompile and rexecution, we would keep adding more and more memory. After
fixing the leak, we found many cases where leaked stack frames were still
being used and causing crashes in the test suite. These are now all resolved.

llvm-svn: 137516
2011-08-12 21:40:01 +00:00
Enrico Granata 68eb4bb421 Added an error message when the user tries to add a filter when a synthetic provider for the same type is already defined in the same category
The converse is also true: an error is shown when the user tries to add a synthetic provider to a category that already has a filter for the same type

llvm-svn: 137493
2011-08-12 19:14:27 +00:00
Enrico Granata 61a80ba6c3 Giving a warning to the user the first time children are truncated by the new cap setting
llvm-svn: 137462
2011-08-12 16:42:31 +00:00
Enrico Granata 22c55d180d *Some more optimizations in usage of ConstString
*New setting target.max-children-count gives an upper-bound to the number of child objects that will be displayed at each depth-level
  This might be a breaking change in some scenarios. To override the new limit you can use the --show-all-children (-A) option
  to frame variable or increase the limit in your lldbinit file
*Command "type synthetic" has been split in two:
  - "type synthetic" now only handles Python synthetic children providers
  - the new command "type filter" handles filters
  Because filters and synthetic providers are both ways to replace the children of a ValueObject, only one can be effective at any given time.

llvm-svn: 137416
2011-08-12 02:00:06 +00:00
Enrico Granata 8c9d35603e Fixed an issue where a pointer's address was being logged instead of its value
Access to synthetic children by name:
 if your object has a synthetic child named foo you can now type
  frame variable object.foo (or ->foo if you have a pointer)
  and that will print the value of the synthetic child
  (if your object has an actual child named foo, the actual child prevails!)
 this behavior should also work in summaries, and you should be able to use
 ${var.foo} and ${svar.foo} interchangeably
  (but using svar.foo will mask an actual child named foo)

llvm-svn: 137314
2011-08-11 17:08:01 +00:00
Greg Clayton aa51684318 Patch for "process load" by Filipe Cabecinhas.
Filipe was attempting to do a:

(lldb) process load ~/path/foo.dylib

But the process load command wasn't resolving the path. We have to be careful
about resolving the path here because we want to do it in terms of the platform
we are using. the "~/" can mean a completely different path if you are remotely
debugging on another machine as another user. So to support this, platforms now
can resolve remote paths:

bool
Platform::ResolveRemotePath (const FileSpec &platform_path,
                             FileSpec &resolved_platform_path);

The host/local platform will just resolve the path.
                             

llvm-svn: 137307
2011-08-11 16:25:18 +00:00
Greg Clayton aa149cbd86 Added the ability to remove orphaned module shared pointers from a ModuleList.
This is helping us track down some extra references to ModuleSP objects that
are causing things to get kept around for too long. 

Added a module pointer accessor to target and change a lot of code to use 
it where it would be more efficient.

"taret delete" can now specify "--clean=1" which will cleanup the global module
list for any orphaned module in the shared module cache which can save memory
and also help track down module reference leaks like we have now.

llvm-svn: 137294
2011-08-11 02:48:45 +00:00
Greg Clayton 3418c85771 While tracking down memory consumption issue a few things were needed: the
ability to dump more information about modules in "target modules list". We
can now dump the shared pointer reference count for modules, the pointer to
the module itself (in case performance tools can help track down who has
references to said pointer), and the modification time.

Added "target delete [target-idx ...]" to be able to delete targets when they
are no longer needed. This will help track down memory usage issues and help 
to resolve when module ref counts keep getting incremented. If the command gets
no arguments, the currently selected target will be deleted. If any arguments 
are given, they must all be valid target indexes (use the "target list" 
command to get the current target indexes).

Took care of a bunch of "no newline at end of file" warnings.

TimeValue objects can now dump their time to a lldb_private::Stream object.

Modified the "target modules list --global" command to not error out if there
are no targets since it doesn't require a target.

Fixed an issue in the MacOSX DYLD dynamic loader plug-in where if a shared 
library was updated on disk, we would keep using the older one, even if it was
updated.

Don't allow the ModuleList::GetSharedModule(...) to return an empty module.
Previously we could specify a valid path on disc to a module, and specify an
architecture that wasn't contained in that module and get a shared pointer to
a module that wouldn't be able to return an object file or a symbol file. We
now make sure an object file can be extracted prior to adding the shared pointer
to the module to get added to the shared list.

llvm-svn: 137196
2011-08-10 02:10:13 +00:00
Enrico Granata ce68b02c99 CFString.py now shows contents in a more NSString-like way (e.g. you get @"Hello" instead of "Hello")
new --raw-output (-R) option to frame variable prevents using summaries and synthetic children
 other future formatting enhancements will be excluded by using the -R option
 test case enhanced to check that -R works correctly

llvm-svn: 137185
2011-08-09 23:50:01 +00:00
Jim Ingham 4b53618247 Move the handling of breakpoint conditions from the Private event loop to the StopInfoBreakpoint::DoActions, which happens as the
event is removed.  Also use the return value of asynchronous breakpoint callbacks, they get checked before, and override the 
breakpoint conditions.

Added ProcessModInfo class, to unify "stop_id generation" and "memory modification generation", and use where needed.

llvm-svn: 137102
2011-08-09 02:12:22 +00:00
Enrico Granata 27b625e12f Basic support for reading synthetic children by index:
if your datatype provides synthetic children, "frame variable object[index]" should now do the right thing
 in cases where the above syntax would have been rejected before, i.e.
  object is not a pointer nor an array (frame variable ignores potential overload of [])
  object is a pointer to an Objective-C class (which cannot be dereferenced)
 expression will still run operator[] if available and complain if it cannot do so
 synthetic children by name do not work yet

llvm-svn: 137097
2011-08-09 01:04:56 +00:00
Greg Clayton 65a0399197 Added a "--global" option to the "target modules list"
command that allows us to see all modules that exist and
their corresponding global shared pointer count. This will
help us track down memory issues when modules aren't being
removed and cleaned up from the module list.

llvm-svn: 137078
2011-08-09 00:01:09 +00:00
Jim Ingham 41c7591a1a Add EvaluateWithError static method. Fix a bug in handling constant expressions - we weren't setting the result even though the expression evaluation succeeded...
llvm-svn: 137077
2011-08-09 00:00:49 +00:00
Sean Callanan 72e4940bd1 This is an overhaul of the expression parser code
that detects what context the current expression is
meant to execute in.  LLDB now properly consults
the method declaration in the debug information
rather than trying to hunt down the "this" or "self"
pointer by name, which can be misleading.

Other fixes include:

- LLDB now properly detects that it is inside
  an inlined C++ member function.

- LLDB now allows access to non-const members when
  in const code.

- The functions in SymbolFile that locate the
  DeclContext containing a DIE have been renamed
  to reflect what they actually do.  I have added
  new functions that find the DeclContext for the
  DIE itself.

I have also introduced testcases for C++ and 
Objective-C.

llvm-svn: 136999
2011-08-05 23:43:37 +00:00
Johnny Chen 76ea84eaf4 On second thought, add the IsValid() method to SBTypeList, making it similar to SBSymbolContextList and SBValueList.
Modify the test suite accordingly.

llvm-svn: 136990
2011-08-05 22:23:26 +00:00
Greg Clayton a17ec9d84d Fixed issues for iOS debugging where if a device has
a native architecture that doesn't match the universal
slice that is being used for all executables, we weren't
correctly descending through the platform architectures
and resolving the binaries.

llvm-svn: 136980
2011-08-05 20:48:30 +00:00
Enrico Granata f1af1ed6d2 Option --regex (-x) now also works for synthetic children:
- Added a test case in python-synth
Minor code improvements in categories, making them ready for adding new element types

llvm-svn: 136957
2011-08-05 01:32:50 +00:00
Enrico Granata cd1c0236fe fixed a potential memory leak ; small improvement in the formatters lookup algorithm
llvm-svn: 136945
2011-08-04 23:37:18 +00:00
Sean Callanan 0c4d8d25a7 Fixed a problem that caused LLDB to fail to execute
expressions that used function pointers.  The problem
was that IRForTarget previously only scanned the IR
for the expression for call instructions; if a function
was used in another context, it was ignored.

Now LLDB scans the Module for functions that are only
declared (not also defined -- so these are externals);
it then constructs function pointers for these
functions and substitutes them wherever the function
is used.

Also made some changes so that "expr main" works just
as well as "expr &main"; they end up being the same
code, but LLDB was generating the result variable in
different ways.

llvm-svn: 136928
2011-08-04 21:37:47 +00:00
Greg Clayton 2c5f0e96c4 Make sure we track CXX and objc method decls.
llvm-svn: 136920
2011-08-04 21:02:57 +00:00
Enrico Granata 5dfd49ccba New formatting symbol %# can be used in summary strings to get the "count of children" of a variable
- accordingly, the test cases for the synthetic providers for the std:: containers have been edited to use
   ${svar%#} instead of ${svar.len} to print out the count of elements ; the .len synthetic child has been
   removed from the synthetic providers
The synthetic children providers for the std:: containers now return None when asked for children indexes >= num_children()
Basic code to support filter names based on regular expressions (WIP)

llvm-svn: 136862
2011-08-04 02:34:29 +00:00
Enrico Granata 6fd87d5d33 APIs to GetValueAsSigned/Unsigned() in SBValue now also accept an SBError parameter to give more info about any problem
The synthetic children providers now use the new (safer) APIs to get the values of objects
As a side effect, fixed an issue in ValueObject where ResolveValue() was not always updating the value before reading it

llvm-svn: 136861
2011-08-04 01:41:02 +00:00
Greg Clayton fe42ac4d0a Cleaned up the SBType.h file to not include internal headers and reorganized
the SBType implementation classes.

Fixed LLDB core and the test suite to not use deprecated SBValue APIs.

Added a few new APIs to SBValue:

    int64_t
    SBValue::GetValueAsSigned(int64_t fail_value=0);

    uint64_t
    SBValue::GetValueAsUnsigned(uint64_t fail_value=0)

 

llvm-svn: 136829
2011-08-03 22:57:10 +00:00
Enrico Granata 9910bc855d Fixed an issue where the KVO swizzled type would be returned as the dynamic type instead of the actual user-level type
- see the test case in lang/objc/objc-dynamic-value for an example
Objective-C dynamic type lookup now works for every Objective-C type
 - previously, true dynamic lookup was only performed for type id

llvm-svn: 136763
2011-08-03 02:18:51 +00:00
Jim Ingham b53cb271ca Add method Module::IsLoadedInTarget, and then in the MacOS X dynamic loader, after we
have initialized our shared library state, discard all the modules that didn't make
it into the running process.

llvm-svn: 136755
2011-08-03 01:03:17 +00:00
Greg Clayton d41f032a45 Fixed an issue where StackFrame::GetValueForVariableExpressionPath(...)
was previously using the entire frame variable list instead of using the
in scope variable list. I added a new function to a stack frame:

	lldb::VariableListSP
	StackFrame::GetInScopeVariableList (bool get_file_globals);

This gets only variables that are in scope and they will be ordered such
that the variables from the current scope are first.

llvm-svn: 136745
2011-08-02 23:35:43 +00:00
Johnny Chen 8f3d8384be Patch by David Forsythe to build lldb on FreeBSD!
I did not take the patch for ClangExpressionParser.cpp since there was a
recent change by Peter for the same line.  Feel free to disagree. :-)

Reference:
----------------------------------------------------------------------
r136580 | pcc | 2011-07-30 15:42:24 -0700 (Sat, 30 Jul 2011) | 3 lines

Add reloc arg to standard JIT createJIT()

Fixes non-__APPLE__ build.  Patch by Matt Johnson!
----------------------------------------------------------------------

Also, I ignore the part of the patch to remove the RegisterContextDarwin*.h/.cpp.

llvm-svn: 136720
2011-08-02 20:52:42 +00:00
Enrico Granata c3e320a7a0 Fixed a bug where a variable could not be formatted in a summary if its datatype already had a custom format
Fixed a bug where Objective-C variables coming out of the expression parser could crash the Python synthetic providers:
 - expression parser output has a "frozen data" component, which is a byte-exact copy of the value (in host memory),
   if trying to read into memory based on the host address, LLDB would crash. we are now passing the correct (target)
   pointer to the Python code
Objective-C "id" variables are now formatted according to their dynamic type, if the -d option to frame variable is used:
 - Code based on the Objective-C 2.0 runtime is used to obtain this information without running code on the target

llvm-svn: 136695
2011-08-02 17:27:39 +00:00
Sean Callanan b995119900 Added checking to make sure that the target has a
scratch AST context before attempting to parse.

llvm-svn: 136631
2011-08-01 18:18:33 +00:00
Sean Callanan cc427fadec This change brings in the latest LLVM/Clang, and
completes the support in the LLDB expression parser
for incomplete types.  Clang now imports types
lazily, and we complete those types as necessary.

Changes include:

- ClangASTSource now supports three APIs which it
  passes to ClangExpressionDeclMap.  CompleteType
  completes a TagDecl or an ObjCInterfaceDecl when
  needed; FindExternalVisibleDecls finds named
  entities that are visible in the expression's
  scope; and FindExternalLexicalDecls performs a
  (potentially restricted) search for entities
  inside a lexical scope like a namespace.  These
  changes mean that entities in namespaces should
  work normally.

- The SymbolFileDWARF code for searching a context
  for a specific name is now more general, and can
  search arbitrary contexts.

- We are continuing to adapt our calls into LLVM
  from interfaces that take start and end iterators
  when accepting multiple items to interfaces that
  use ArrayRef.

- I have cleaned up some code, especially our use
  of namespaces.

This change is neutral for our testsuite and greatly
improves correctness for large programs (like Clang)
with complicated type systems.  It should also lay
the groundwork for improving the expression parser's
performance as we are lazier and lazier about
providing type information.

llvm-svn: 136555
2011-07-30 02:42:06 +00:00
Greg Clayton 92eac7f501 Moved some functionality from ValueObject to ClangASTType.
llvm-svn: 136536
2011-07-29 23:21:00 +00:00
Enrico Granata 6f3533fb1d Public API changes:
- Completely new implementation of SBType
 - Various enhancements in several other classes
Python synthetic children providers for std::vector<T>, std::list<T> and std::map<K,V>:
 - these return the actual elements into the container as the children of the container
 - basic template name parsing that works (hopefully) on both Clang and GCC
 - find them in examples/synthetic and in the test suite in functionalities/data-formatter/data-formatter-python-synth
New summary string token ${svar :
 - the syntax is just the same as in ${var but this new token lets you read the values
   coming from the synthetic children provider instead of the actual children
 - Python providers above provide a synthetic child len that returns the number of elements
   into the container
Full bug fix for the issue in which getting byte size for a non-complete type would crash LLDB
Several other fixes, including:
 - inverted the order of arguments in the ClangASTType constructor
 - EvaluationPoint now only returns SharedPointer's to Target and Process
 - the help text for several type subcommands now correctly indicates argument-less options as such

llvm-svn: 136504
2011-07-29 19:53:35 +00:00
Enrico Granata c53114e30a new flag -P to type synth add lets you type a Python class interactively
added a final newline to fooSynthProvider.py
new option to automatically save user input in InputReaderEZ
checking for NULL pointers in several new places

llvm-svn: 135916
2011-07-25 16:59:05 +00:00
Enrico Granata a37a065c33 Python synthetic children:
- you can now define a Python class as a synthetic children producer for a type
   the class must adhere to this "interface":
        def __init__(self, valobj, dict):
     	def get_child_at_index(self, index):
     	def get_child_index(self, name):
   then using type synth add -l className typeName
   (e.g. type synth add -l fooSynthProvider foo)
   (This is still WIP with lots to be added)
   A small test case is available also as reference

llvm-svn: 135865
2011-07-24 00:14:56 +00:00