Commit Graph

2530 Commits

Author SHA1 Message Date
Sean Callanan 6f298a6464 Updated LLVM to take some fixes that make the
Intel disassembler usable.

Also flipped the switch: we are now exclusively
using Disassembler.h instead of
EnhancedDisassembly.h for all disassembly in
LLDB.

llvm-svn: 151306
2012-02-23 23:43:28 +00:00
Enrico Granata d3d444f811 This patch provides a set of formatters for most of the commonly used Cocoa classes.
The formatter for NSString is an improved version of the one previously shipped as an example, the others are new in design and implementation.
A more robust and OO-compliant Objective-C runtime wrapper is provided for runtime versions 1 and 2 on 32 and 64 bit.
The formatters are contained in a category named "AppKit", which is not enabled at startup.

llvm-svn: 151299
2012-02-23 23:10:03 +00:00
Jason Molenda 7e1f45f9c5 Make a nested if .. if .. else block nesting more explicit with some curly braces.
llvm-svn: 151292
2012-02-23 22:32:13 +00:00
Sean Callanan 7277284f87 Added support for looking up the complete type for
Objective-C classes.  This allows LLDB to find
ivars declared in class extensions in modules other
than where the debugger is currently stopped (we
already supported this when the debugger was
stopped in the same module as the definition).

This involved the following main changes:

- The ObjCLanguageRuntime now knows how to hunt
  for the authoritative version of an Objective-C
  type.  It looks for the symbol indicating a
  definition, and then gets the type from the
  module containing that symbol.

- ValueObjects now report their type with a
  potential override, and the override is set if
  the type of the ValueObject is an Objective-C
  class or pointer type that is defined somewhere
  other than the original reported type.  This
  means that "frame variable" will always use the
  complete type if one is available.

- The ClangASTSource now looks for the complete
  type when looking for ivars.  This means that
  "expr" will always use the complete type if one
  is available.

- I added a testcase that verifies that both
  "frame variable" and "expr" work.

llvm-svn: 151214
2012-02-22 23:57:45 +00:00
Jim Ingham 4f02b22db5 Make Debugger::SetLoggingCallback public, and expose it through the SB API. Sometimes it is not
convenient to provide a log callback right when the debugger is created.

llvm-svn: 151209
2012-02-22 22:49:20 +00:00
Greg Clayton f56ddeaa6f Added support for the DWARF 4 DW_FORM values.
llvm-svn: 151202
2012-02-22 21:17:27 +00:00
Greg Clayton c2ff9318a2 Added the ability to get a ObjectFile versions from the ObjectFile
subclasses if the object files support version numbering. Exposed
this through SBModule for upcoming data formatter version checking stuff.

llvm-svn: 151190
2012-02-22 19:41:02 +00:00
Greg Clayton a9f40ad80a For stepping performance I added the ability to outlaw all memory accesseses
to the __PAGEZERO segment on darwin. The dynamic loader now correctly doesn't
slide __PAGEZERO and it also registers it as an invalid region of memory. This
allows us to not make any memory requests from the local or remote debug session
for any addresses in this region. Stepping performance can improve when uninitialized
local variables that point to locations in __PAGEZERO are attempted to be read 
from memory as we won't even make the memory read or write request.

llvm-svn: 151128
2012-02-22 04:37:26 +00:00
Greg Clayton 0c90ef479a Linux fix patch from Dmitry Vyukov.
llvm-svn: 151072
2012-02-21 18:40:07 +00:00
Benjamin Kramer ff461fcf07 Remove a ton of implicit narrowing conversions for C++11 compatibility.
llvm-svn: 151071
2012-02-21 18:37:14 +00:00
Jim Ingham 8fdeff25e8 Forgot to add two files from the last checkin.
llvm-svn: 151069
2012-02-21 18:22:37 +00:00
Greg Clayton ee212e2cc1 Fixed an issue where empty sections or zero filled sections could return
incorrect values and also fire an assertion.

llvm-svn: 151066
2012-02-21 17:34:25 +00:00
Jason Molenda cf7e2dc09a Patch Enrico's changes from r150558 on 2012-02-14 to build even if Python
is not available (LLDB_DISABLE_PYTHON is defined).

Change build-swig-Python.sh to emit an empty LLDBPythonWrap.cpp file if 
this build is LLDB_DISABLE_PYTHON.

Change the "Copy to Xcode.app" shell script phase in the lldb.xcodeproj
to only do this copying for Mac native builds.

llvm-svn: 151035
2012-02-21 05:33:55 +00:00
Greg Clayton 021f73684b Fixed a crasher that would happen when supplying lldb with an application
bundle that didn't contain an executable.

llvm-svn: 151034
2012-02-21 05:25:28 +00:00
Jim Ingham 228063cd21 Add a logging mode that takes a callback and flush'es to that callback.
Also add SB API's to set this callback, and to enable the log channels.

llvm-svn: 151018
2012-02-21 02:23:08 +00:00
Greg Clayton 1ac04c3088 Thread hardening part 3. Now lldb_private::Thread objects have std::weak_ptr
objects for the backlink to the lldb_private::Process. The issues we were
running into before was someone was holding onto a shared pointer to a 
lldb_private::Thread for too long, and the lldb_private::Process parent object
would get destroyed and the lldb_private::Thread had a "Process &m_process"
member which would just treat whatever memory that used to be a Process as a
valid Process. This was mostly happening for lldb_private::StackFrame objects
that had a member like "Thread &m_thread". So this completes the internal
strong/weak changes.

Documented the ExecutionContext and ExecutionContextRef classes so that our
LLDB developers can understand when and where to use ExecutionContext and 
ExecutionContextRef objects.

llvm-svn: 151009
2012-02-21 00:09:25 +00:00
Johnny Chen 9b44acd86b Fix compile error for DisassemblerLLVMC.cpp.
Patch by Dmitry Vyukov <dvyukov@google.com>.

Also add the relevant files to the Xcode project.

llvm-svn: 150991
2012-02-20 22:05:34 +00:00
Greg Clayton d9e416c0ea The second part in thread hardening the internals of LLDB where we make
the lldb_private::StackFrame objects hold onto a weak pointer to the thread
object. The lldb_private::StackFrame objects the the most volatile objects
we have as when we are doing single stepping, frames can often get lost or
thrown away, only to be re-created as another object that still refers to the
same frame. We have another bug tracking that. But we need to be able to 
have frames no longer be able to get the thread when they are not part of
a thread anymore, and this is the first step (this fix makes that possible
but doesn't implement it yet).

Also changed lldb_private::ExecutionContextScope to return shared pointers to
all objects in the execution context to further thread harden the internals.

llvm-svn: 150871
2012-02-18 05:35:26 +00:00
Sean Callanan 5056ab04ad Ignore the constness of the object pointer when
fetching it.

llvm-svn: 150861
2012-02-18 02:01:03 +00:00
Jim Ingham ec1da844f8 Remove unneeded includes.
llvm-svn: 150843
2012-02-17 21:59:03 +00:00
Greg Clayton cc4d0146b4 This checking is part one of trying to add some threading safety to our
internals. The first part of this is to use a new class:

lldb_private::ExecutionContextRef

This class holds onto weak pointers to the target, process, thread and frame
and it also contains the thread ID and frame Stack ID in case the thread and
frame objects go away and come back as new objects that represent the same
logical thread/frame. 

ExecutionContextRef objcets have accessors to access shared pointers for
the target, process, thread and frame which might return NULL if the backing
object is no longer available. This allows for references to persistent program
state without needing to hold a shared pointer to each object and potentially
keeping that object around for longer than it needs to be. 

You can also "Lock" and ExecutionContextRef (which contains weak pointers)
object into an ExecutionContext (which contains strong, or shared pointers)
with code like

ExecutionContext exe_ctx (my_obj->GetExectionContextRef().Lock());

llvm-svn: 150801
2012-02-17 07:49:44 +00:00
Enrico Granata 864e3e8413 Adding formatters for several useful Objective-C/Cocoa data types. The new categories are not enabled at startup, but can be manually activated if desired.
Adding new API calls to SBValue to be able to retrieve the associated formatters
Some refactoring to FormatNavigator::Get() in order to shrink its size down to more manageable terms (a future, massive, refactoring effort will still be needed)
Test cases added for the above

llvm-svn: 150784
2012-02-17 03:18:30 +00:00
Sean Callanan 95e5c63012 Added a new disassembler plugin, DisassemblerLLVMC,
which uses the Disassembler.h interface to the LLVM
disassemblers rather than the EnhancedDisassembly.h
interface.  Disassembler.h is a better-maintained
API and will be stabler in the long term.

Currently the output from Disassembler.h does not
provide for symbolic disassembly in all the places
that the old disassembler did, so I have gated (and
disabled) the disassembler.  It'll be easy to flip
the switch later.

In the meantime, to enable the new disassembler,
uncomment "#define USE_NEW_DISASSEMBLER" in
lldb.cpp.

llvm-svn: 150772
2012-02-17 00:53:45 +00:00
Johnny Chen 3517d12826 memory read -f X doesn't print anything (lldb should warn when encountering an unsupported byte size)
Also add a test sequence for it.

rdar://problem/10876841

llvm-svn: 150766
2012-02-16 23:09:08 +00:00
Johnny Chen 325fa8a77c memory read prints out duplicate entries when using vector formats
DataExtractor::Dump() needs to supply the correct cursor when delegating to the child DataExtractor::Dump() calls.
Add a regression test file.
 
rdar://problem/10872908

llvm-svn: 150729
2012-02-16 22:06:47 +00:00
Jim Ingham 4bddaeb5ab Add a general mechanism to wait on the debugger for Broadcasters of a given class/event bit set.
Use this to allow the lldb Driver to emit notifications for breakpoint modifications.
<rdar://problem/10619974>

llvm-svn: 150665
2012-02-16 06:50:00 +00:00
Sean Callanan 3ae617943b Stop finding bare symbols when we're explicitly
told to look in a namespace.

llvm-svn: 150590
2012-02-15 17:14:49 +00:00
Enrico Granata 061858ce61 <rdar://problem/10062621>
New public API for handling formatters: creating, deleting, modifying categories, and formatters, and managing type/formatter association.
This provides SB classes for each of the main object types involved in providing formatter support:
 SBTypeCategory
 SBTypeFilter
 SBTypeFormat
 SBTypeSummary
 SBTypeSynthetic
plus, an SBTypeNameSpecifier class that is used on the public API layer to abstract the notion that formatters can be applied to plain type-names as well as to regular expressions
For naming consistency, this patch also renames a lot of formatters-related classes.
Plus, the changes in how flags are handled that started with summaries is now extended to other classes as well. A new enum (lldb::eTypeOption) is meant to support this on the public side.
The patch also adds several new calls to the formatter infrastructure that are used to implement by-index accessing and several other design changes required to accommodate the new API layer.
An architectural change is introduced in that backing objects for formatters now become writable. On the public API layer, CoW is implemented to prevent unwanted propagation of changes.
Lastly, there are some modifications in how the "default" category is constructed and managed in relation to other categories.

llvm-svn: 150558
2012-02-15 02:34:21 +00:00
Sean Callanan f673e769a6 Previoously the expression parser had to rely on the
JIT when printing the values of registers (e.g.,
"expr $pc").  Now the expression parser can do this
in the IR interpreter without running code in the
inferior process.

llvm-svn: 150554
2012-02-15 01:40:39 +00:00
Sean Callanan a7b443a6bf Only allow expressions to use the JIT if memory
can be allocated in the process.

llvm-svn: 150523
2012-02-14 22:50:38 +00:00
Johnny Chen 973cf9e8ae Remove the functionality of using 'frame variable -w' to set a watchpoint now that 'watchpoint set variable/expression'
is working.  Also update the relevant test cases.

llvm-svn: 150514
2012-02-14 22:00:40 +00:00
Enrico Granata 6baf70aaab (no commit message)
llvm-svn: 150492
2012-02-14 18:01:27 +00:00
Sean Callanan a97aa92ab2 Fixed a bug that caused the description strings
for assembly instructions to occasionally come
out empty.

llvm-svn: 150445
2012-02-14 00:22:51 +00:00
Greg Clayton bae2f2f812 Made loading sections in the DynamicLoaderDarwinKernel more robust as it
seems that sections in the memory module might be quite different from the
sections in the file module. Now we find all segments in the on disk file and
find that segment by name in the memory module and it is ok if any sections
from the file are missing in the memory image.

llvm-svn: 150443
2012-02-14 00:14:24 +00:00
Greg Clayton c859e2d524 Full core file support has been added for mach-o core files.
Tracking modules down when you have a UUID and a path has been improved.

DynamicLoaderDarwinKernel no longer parses mach-o load commands and it
now uses the memory based modules now that we can load modules from memory.

Added a target setting named "target.exec-search-paths" which can be used
to supply a list of directories to use when trying to look for executables.
This allows one or more directories to be used when searching for modules
that may not exist in the SDK/PDK. The target automatically adds the directory
for the main executable to this list so this should help us in tracking down
shared libraries and other binaries. 

llvm-svn: 150426
2012-02-13 23:10:39 +00:00
Sean Callanan 59700591f1 Tightened up type uniq'ing so we don't uniq two
anonymous types to each other unless they have
the same byte_size.

llvm-svn: 150422
2012-02-13 22:30:16 +00:00
Sean Callanan d4a7c123f3 Made the "--no-inlines" option on
"target modules lookup" also work with the
"--function" option, so you can search for
functions that aren't inlined.  This is the
same query that the expression parser makes, so
it's good for diagnosing situations where the
expression parser doesn't find a function you
think should be there.

llvm-svn: 150289
2012-02-11 01:22:21 +00:00
Sean Callanan f6172c2cbc Make the output from "target modules lookup -n"
prettier.

llvm-svn: 150285
2012-02-11 00:24:04 +00:00
Sean Callanan 9df05fbb7f Extended function lookup to allow the user to
indicate whether inline functions are desired.
This allows the expression parser, for instance,
to filter out inlined functions when looking for
functions it can call.

llvm-svn: 150279
2012-02-10 22:52:19 +00:00
Sean Callanan 49bce8ecdb Improved detection of object file types, moving
detection of kernels into the object file and
adding a new category for raw binary images.
Fixed all clients who previously searched for
sections manually, making them use the object
file's facilities instead.

llvm-svn: 150272
2012-02-10 20:22:35 +00:00
Greg Clayton 1ada7bc09d Fixed incorrect #include directives.
llvm-svn: 150271
2012-02-10 20:13:26 +00:00
Sean Callanan 933693b621 Fixed a bunch of ownership problems with the expression
parser.  Specifically:

- ClangUserExpression now keeps weak pointers to the
  structures it needs and then locks them when needed.
  This ensures that they continue to be valid without
  leaking memory if the ClangUserExpression is long
  lived.

- ClangExpressionDeclMap, instead of keeping a pointer
  to an ExecutionContext, now contains an
  ExecutionContext.  This prevents bugs if the pointer
  or its contents somehow become stale.  It also no
  longer requires that ExecutionContexts be passed
  into any function except its initialization function,
  since it can count on the ExecutionContext still
  being around.

There's a lot of room for improvement (specifically,
ClangExpressionDeclMap should also use weak pointers
insetad of shared pointers) but this is an important
first step that codifies assumptions that already
existed in the code.

llvm-svn: 150217
2012-02-10 01:22:05 +00:00
Sean Callanan 4d04c6ad07 Caching the DIE for the DeclContext as reported
by GetClangDeclContextContainingDIE, for better
debuggability.

llvm-svn: 150211
2012-02-09 22:54:11 +00:00
Greg Clayton 1fba8711b0 Added a logging helper class for SymbolFileDWARF::ParseType() that will
enable us to track the depth of parsing and what is being parsed. This
helps when trying to track down difficult type parsing issues and is only
enabled in non-production builds.

llvm-svn: 150203
2012-02-09 20:03:49 +00:00
Johnny Chen acdde195fb Add error handling for missing option terminator "--" and a test scenario for it.
Also fix a logic error for a missing return stmt. Oops.

llvm-svn: 150195
2012-02-09 18:44:27 +00:00
Greg Clayton c3776bf288 First pass at mach-o core file support is in. It currently works for x86_64
user space programs. The core file support is implemented by making a process
plug-in that will dress up the threads and stack frames by using the core file
memory. 

Added many default implementations for the lldb_private::Process functions so
that plug-ins like the ProcessMachCore don't need to override many many 
functions only to have to return an error.

Added new virtual functions to the ObjectFile class for extracting the frozen
thread states that might be stored in object files. The default implementations
return no thread information, but any platforms that support core files that
contain frozen thread states (like mach-o) can make a module using the core
file and then extract the information. The object files can enumerate the 
threads and also provide the register state for each thread. Since each object
file knows how the thread registers are stored, they are responsible for 
creating a suitable register context that can be used by the core file threads.

Changed the process CreateInstace callbacks to return a shared pointer and
to also take an "const FileSpec *core_file" parameter to allow for core file
support. This will also allow for lldb_private::Process subclasses to be made
that could load crash logs. This should be possible on darwin where the crash
logs contain all of the stack frames for all of the threads, yet the crash
logs only contain the registers for the crashed thrad. It should also allow
some variables to be viewed for the thread that crashed.

llvm-svn: 150154
2012-02-09 06:16:32 +00:00
Sean Callanan d2b465f17a Brought LLVM/Clang up to top of tree. The only
change (besides logging) is that now string
literals in the IR are ConstantDataArrays instead
of ConstantArrays.

llvm-svn: 150142
2012-02-09 03:22:41 +00:00
Sean Callanan 12b0dabd31 Removed another debug message. Sigh...
llvm-svn: 150134
2012-02-09 02:04:23 +00:00
Jim Ingham 6a4617bb01 Some Breakpoint:: methods crept down be log the Breakpoint::BreakpointEventData methods.
llvm-svn: 150131
2012-02-09 01:49:26 +00:00
Johnny Chen 2ffa754a6f After discussions with Jim and Greg, modify the 'watchpoint set' command to become a mutiword command
with subcommand 'expression' and 'variable'.  The first subcommand is for supplying an expression to
be evaluated into an address to watch for, while the second is for watching a variable.

'watchpoint set expression' is a raw command, which means that you need to use the "--" option terminator
to end the '-w' or '-x' option processing and to start typing your expression.

Also update several test cases to comply and add a couple of test cases into TestCompletion.py,
in particular, test that 'watchpoint set ex' completes to 'watchpoint set expression ' and that
'watchpoint set var' completes to 'watchpoint set variable '.

llvm-svn: 150109
2012-02-08 22:37:48 +00:00