Commit Graph

1725 Commits

Author SHA1 Message Date
Greg Clayton 1b7746e383 After recent OperatingsSystem plug-in changes, the lldb_private::Process and lldb_private::Thread subclasses were changed and the API was not respected properly.
This checkin aims to fix this. The process now has two thread lists: a real thread list for threads that are created by the lldb_private::Process subclass, and the user visible threads. The user visible threads are the same as the real threas when no OS plug-in in used. But when an OS plug-in is used, the user thread can be a combination of real and "memory" threads. Real threads can be placed inside of memory threads so that a thread appears to be different, but is still controlled by the actual real thread. When the thread list needs updating, the lldb_private::Process class will call the: lldb_private::Process::UpdateThreadList() function with the old real thread list, and the function is expected to fill in the new real thread list with the current state of the process. After this function, the process will check if there is an OS plug-in being used, and if so, it will give the old user thread list, the new real thread list and the OS plug-in will create the new user thread list from both of these lists. If there is no OS plug-in, the real thread list is the user thread list.

These changes keep the lldb_private::Process subclasses clean and no changes are required.

llvm-svn: 181091
2013-05-04 01:38:48 +00:00
Jason Molenda fe806906d4 fix a couple of clang static analyzer warnings.
Most important was a new[] + delete mismatch in ScanFormatDescriptor()
and a couple of possible memory leaks in FileSpec::EnumerateDirectory().

llvm-svn: 181080
2013-05-04 00:39:52 +00:00
Jason Molenda c16b4af0d7 Remove the UUID::GetAsCString() method which required a buffer to save the
UUID string in; added UUID::GetAsString() which returns the uuid string in
a std::string.  Updated callers to use the new method.

llvm-svn: 181078
2013-05-03 23:56:12 +00:00
Andrew Kaylor 3a8625dda9 Fix logic error in ProcessInfo::SetArg0
llvm-svn: 181049
2013-05-03 19:38:09 +00:00
Enrico Granata c3387333ce <rdar://problem/11742979>
SWIG is smart enough to recognize that C++ operators == and != mean __eq__ and __ne__ in Python and do the appropriate translation
But it is not smart enough to recognize that mySBObject == None should return False instead of erroring out
The %pythoncode blocks are meant to provide those extra smarts (and they play some SWIG&Python magic to find the right function to call behind the scenes with no risk of typos :-)
Lastly, SBBreakpoint provides an == but never provided a != operator - common courtesy is to provide both

llvm-svn: 180987
2013-05-03 01:29:27 +00:00
Daniel Malea c7da5d0122 Add missing include to LLDB.h -- SBStream
llvm-svn: 180954
2013-05-02 21:42:13 +00:00
Greg Clayton 05e2c79f87 We aren't ready for the assertions to be enabled on the ReadWriteLock classes yet.
llvm-svn: 180928
2013-05-02 17:17:05 +00:00
Jim Ingham acff895015 Recommitting r180831 with trivial fix - remember to return errors if you compute.
llvm-svn: 180898
2013-05-02 00:27:30 +00:00
Greg Clayton 160c9d81e0 <rdar://problem/13700260>
<rdar://problem/13723772>

Modified the lldb_private::Thread to work much better with the OperatingSystem plug-ins. Operating system plug-ins can now return have a "core" key/value pair in each thread dictionary for the OperatingSystemPython plug-ins which allows the core threads to be contained with memory threads. It also allows these memory threads to be stepped, resumed, and controlled just as if they were the actual backing threads themselves.

A few things are introduced:
- lldb_private::Thread now has a GetProtocolID() method which returns the thread protocol ID for a given thread. The protocol ID (Thread::GetProtocolID()) is usually the same as the thread id (Thread::GetID()), but it can differ when a memory thread has its own id, but is backed by an actual API thread.
- Cleaned up the Thread::WillResume() code to do the mandatory parts in Thread::ShouldResume(), and let the thread subclasses override the Thread::WillResume() which is now just a notification.
- Cleaned up ClearStackFrames() implementations so that fewer thread subclasses needed to override them
- Changed the POSIXThread class a bit since it overrode Thread::WillResume(). It is doing the wrong thing by calling "Thread::SetResumeState()" on its own, this shouldn't be done by thread subclasses, but the current code might rely on it so I left it in with a TODO comment with an explanation.

llvm-svn: 180886
2013-05-01 21:54:04 +00:00
Daniel Malea 7f3859538f Revert 180829 as it causes hangs in TestTypeCompletion.py on 2 Linux buildbots:
http://lab.llvm.org:8011/builders/lldb-x86_64-linux/builds/3810
http://lab.llvm.org:8011/builders/lldb-x86_64-debian-clang/builds/2754

llvm-svn: 180870
2013-05-01 19:14:30 +00:00
Daniel Malea 54e39db805 Reverting 180831 as it crashes TestDefaultConstructorForAPIObjects.py
llvm-svn: 180868
2013-05-01 19:11:56 +00:00
Jim Ingham a23f73dbbc Added an option to "process detach" to keep the process stopped, if the process plugin (or in the
case of ProcessGDBRemote the stub we are talking to) know how to do that.

rdar://problem/13680832

llvm-svn: 180831
2013-04-30 23:46:08 +00:00
Jim Ingham 2d386b35eb Make "process handle -n true -s false" actually notifies of the signal.
rdar://problem/12020085

llvm-svn: 180829
2013-04-30 23:42:24 +00:00
Enrico Granata 82fabf89b4 <rdar://problem/13695846>
Enabling LLDB to write to variables that are stored in registers
Previously, this would not work since the Value's Context loses the notion of the data being in a register
We now store an "original" context that comes out of DWARF parsing, and use that context's data when attempting a write

llvm-svn: 180803
2013-04-30 20:45:04 +00:00
Greg Clayton 46c2b6e605 lldb_private::StopInfo now holds onto a ThreadWP (a std::weak_ptr<lldb_private::Thread>) in case the thread goes away while the stop info still exists.
llvm-svn: 180749
2013-04-29 23:30:46 +00:00
Greg Clayton b5ad4ec7a3 Cleanup logging to use the new "std::string FileSpec::GetPath()" function. Also added a similar function for modules:
std::string
Module::GetSpecificationDescription () const;

This returns the module as "/usr/lib/libfoo.dylib" for normal files (calls "std::string FileSpec::GetPath()" on m_file) but it also might include the object name in case the module is for a .o file in a BSD archive ("/usr/lib/libfoo.a(bar.o)"). Cleaned up necessary logging code to use it.

llvm-svn: 180717
2013-04-29 17:25:54 +00:00
Greg Clayton a44c1e6b63 Don't return a reference to a local variable, and removed a redundant API.
llvm-svn: 180713
2013-04-29 16:36:27 +00:00
Jason Molenda a7ae4673c7 Add a few new methods to FileSpec to make it a little easier to work
with directories, without increasing the size of the FileSpec object.
GetPath() returns a std::string of the full pathname of the file.
IsDirectory(), IsPipe(), IsRegularFile(), IsSocket(), and IsSymbolicLink()
can be used instead of getting the FileType() and comparing it to an enum.

Update PlatformDarwinKernel to use these new methods.

llvm-svn: 180704
2013-04-29 09:46:43 +00:00
Sean Callanan df56540a58 Performance optimizations to ClangUserExpression,
mostly related to management of the stack frame
for the interpreter.

  - First, if the expression can be interpreted,
    allocate the stack frame in the target process
    (to make sure pointers are valid) but only
    read/write to the copy in the host's memory.

  - Second, keep the memory allocations for the
    stack frame and the materialized struct as
    member variables of ClangUserExpression.  This
    avoids memory allocations and deallocations
    each time the expression runs.

<rdar://problem/13043685>

llvm-svn: 180664
2013-04-27 02:19:33 +00:00
Enrico Granata cd67f97cb7 <rdar://problem/12529989>
Synthetic children provider for NSOrderedSet

llvm-svn: 180655
2013-04-27 00:27:20 +00:00
Andrew Kaylor d693c19a73 Fixing a typo in the SBThread::Suspend documentation
llvm-svn: 180621
2013-04-26 18:34:17 +00:00
Enrico Granata c76b97bcce Make a synthetic children provider for the ObjC Class type
llvm-svn: 180588
2013-04-26 00:59:02 +00:00
Greg Clayton f4d6de6a53 Added the ability to extract a ModuleSpecList (a new class) from an ObjectFile. This is designed to be used when you have an object file that contains one or more architectures (MacOSX universal (fat) files) and/or one or more objects (BSD archive (.a files)).
There is a new static ObjectFile function you can call:

size_t
ObjectFile::GetModuleSpecifications (const FileSpec &file,
                                     lldb::offset_t file_offset,
                                     ModuleSpecList &specs)

This will fill in "specs" which the details of all the module specs (file + arch + UUID (if there is one) + object name (for BSD archive objects eventually) + file offset to the object in question).

This helps us when a user specifies a file that contains a single architecture, and also helps us when we are given a debug symbol file (like a dSYM file on MacOSX) that contains one or more architectures and we need to be able to match it up to an existing Module that has no debug info.

llvm-svn: 180224
2013-04-24 22:29:28 +00:00
Enrico Granata e743c78299 <rdar://problem/13209140>
“plugin load” tries to be more helpful when it fails to load a plugin

llvm-svn: 180218
2013-04-24 21:29:08 +00:00
Enrico Granata b636be79c0 Changes to the ObjC runtime
llvm-svn: 180199
2013-04-24 17:49:08 +00:00
Sean Callanan 485f732b84 Fixed a problem where the expression parser would
not find multiple functions with the same name but
different types.  Now we keep track of what types
we've already reported for a function and only elide
functions if we've already reported a conflicting
one.

Also added a test case.

<rdar://problem/11367837>

llvm-svn: 180167
2013-04-24 00:34:41 +00:00
Sylvestre Ledru 333b9974cd Remove duplicate define
llvm-svn: 180095
2013-04-23 12:18:53 +00:00
Enrico Granata 19f0e8c163 Daniel Malea reported seeing warnings for the use of anonymous namespaces in our public API.
Removing these namespace { ... } declarations (but still keeping the helper *Impl objects outside of namespace lldb proper)

llvm-svn: 180067
2013-04-22 22:57:56 +00:00
Daniel Malea 7f3aa1081c Fix lock hierarchy violation in Listener/Broadcaster
- avoid deadlocks if Broadcaster::SignUpListenersForBroadcaster and
  Listener::StartListeningForEventSpec are both called concurrently

llvm-svn: 180050
2013-04-22 21:22:41 +00:00
Daniel Malea 4818460269 Fix data race in Address class by wrapping m_offset in std::atomic
llvm-svn: 180047
2013-04-22 20:59:13 +00:00
Greg Clayton d1d06e4744 <rdar://problem/13697881>
Fixed the GDB remote with the python OS plug-in to not show core threads when they aren't desired and also to have the threads "to the right thing" when continuing.

llvm-svn: 179912
2013-04-20 00:27:58 +00:00
Greg Clayton 71dba2ce89 Be sure to include initializer_list when needed.
llvm-svn: 179911
2013-04-20 00:25:20 +00:00
Greg Clayton 03da4cc294 Fixed some linux buildbot warnings.
llvm-svn: 179892
2013-04-19 21:31:16 +00:00
Sean Callanan d2562509a5 Simplified the management of the data buffer for
an Allocation to reduce heap fragmentation and
make the code less brittle (and to make some
buildbots happier).

llvm-svn: 179868
2013-04-19 17:44:40 +00:00
Ashok Thirumurthi 6ac9d13e61 Provided a variant of ReadCStringFromMemory that supports null terminators of any character width.
This prevents unbounded reads (i.e. reads of GetMaximumSizeOfStringSummary() bytes)
from causing test failures (i.e. due to ptrace EIO or EFAULT on Linux).

Note that ReadCStringFromMemory is marked as deprecated because the loop that calls
ReadMemory does not continue until the string has been completely read.
The expected behavior is to read until until max_bytes or a null terminator.

Note: As discussed on lldb-dev, further testing will be performed with ReadStringFromMemory
before further changes are made for users of ReadCStringFromMemory.

Thanks to Enrico, Matt and Andy for their review feedback.

llvm-svn: 179857
2013-04-19 15:58:38 +00:00
Sean Callanan 443427357f Removed 2800+ lines of code that no longer do anything
now that the IR interpreter and the JIT share the same
materialization codepaths.

llvm-svn: 179842
2013-04-19 08:14:32 +00:00
Sean Callanan 3dbf346ef3 Optimized the way breakpoint conditions are evaluated.
Previously, the options for a breakopint or its
locations stored only the text of the breakpoint
condition (ironically, they used ClangUserExpression
as a glorified std::string) and, each time the condition
had to be evaluated in the StopInfo code, the expression
parser would be invoked via a static method to parse and
then execute the expression.

I made several changes here:

  - Each breakpoint location now has its own
    ClangUserExpressionSP containing a version of
    the breakpoint expression compiled for that exact
    location.

  - Whenever the breakpoint is hit, the breakpoint
    condition expression is simply re-run to determine
    whether to stop.

  - If the process changes (e.g., it's re-run) or
    the source code of the expression changes (we use
    a hash so as to avoid doing string comparisons)
    the ClangUserExpressionSP is re-generated.

This should improve performance of breakpoint
conditions significantly, and takes advantage of
the recent expression re-use work.

llvm-svn: 179838
2013-04-19 07:09:15 +00:00
Sean Callanan bb9945f447 Made IRMemoryMap::FindSpace a little cleverer,
and made attempts to allocate memory in the process
fall back to FindSpace and just allocate memory on
the host (but with real-looking pointers, hence
FindSpace) if the process doesn't allow allocation.
This allows expressions to run on processes that don't
support allocation, like core files.

This introduces an extremely rare potential problem:
If all of the following are true:

- The Process doesn't support allocation;

- the user writes an expression that refers to an
  address that does not yet map to anything, or is
  dynamically generated (e.g., the result of calling
  a function); and

- the randomly-selected address for the static data
  for that specific expression runs into the
  address the user was expecting to work with;

then dereferencing the pointer later results
in the user seeing something unexpected.  This is
unlikely but possible; as a future piece of work,
we should have processes be able to hint to the
expression parser where it can allocate temporary data
of this kind.

llvm-svn: 179827
2013-04-19 01:51:24 +00:00
Greg Clayton 7b0992d9cd After discussing with Chris Lattner, we require C++11, so lets get rid of the macros and just use C++11.
llvm-svn: 179805
2013-04-18 22:45:39 +00:00
Sean Callanan 1582ee6840 This commit changes the way LLDB executes user
expressions.  

Previously, ClangUserExpression assumed that if
there was a constant result for an expression 
then it could be determined during parsing.  In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap) 
was present.  This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run.  Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.

I have rewritten the IRInterpreter to be 
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see.  This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be 
present.

Materialization, interpretation, and dematerialization
are now all independent of parsing.  This means that
in theory we can parse expressions once and run them
many times.  I have three outstanding tasks before
shutting this down:

    - First, I will ensure that all of this works with
      core files.  Core files have a Process but do not
      allow allocating memory, which currently confuses
      materialization.

    - Second, I will make expression breakpoint 
      conditions remember their ClangUserExpression and
      re-use it.

    - Third, I will tear out all the redundant code
      (for example, materialization logic in
      ClangExpressionDeclMap) that is no longer used.

While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.  
This should be fixed.

llvm-svn: 179801
2013-04-18 22:06:33 +00:00
Greg Clayton e0c64e15a4 Try to unbreak the lldb-x86_64-linux buildbot after recent std::auto_ptr/std::unique_ptr changes.
llvm-svn: 179799
2013-04-18 22:01:06 +00:00
Greg Clayton beb02fd1ea Missed some cases when switching over to using our STD_UNIQUE_PTR macros.
llvm-svn: 179796
2013-04-18 21:01:59 +00:00
Greg Clayton e01e07b6e7 Since we use C++11, we should switch over to using std::unique_ptr when C++11 is being used. To do this, we follow what we have done for shared pointers and we define a STD_UNIQUE_PTR macro that can be used and it will "do the right thing". Due to some API differences in std::unique_ptr and due to the fact that we need to be able to compile without C++11, we can't use move semantics so some code needed to change so that it can compile with either C++.
Anyone wanting to use a unique_ptr or auto_ptr should now use the "STD_UNIQUE_PTR(TYPE)" macro.

llvm-svn: 179779
2013-04-18 18:10:51 +00:00
Greg Clayton 9624985b1a Re-enable m_private_run_lock changes from 179329, but only for Apple hosted builds so it doesn't break the buildbots. We will try and work the issues out in the Apple build before enabling this feature for everyone.
llvm-svn: 179772
2013-04-18 16:57:27 +00:00
Ashok Thirumurthi cf7c55ebcc Revert of r179378 and r179329, which introduce a private thread lock around thread enumeration,
in order to prevent consistent hangs on all 3 LLDB buildbots.

llvm-svn: 179759
2013-04-18 14:38:20 +00:00
Andy Gibbs a9b1125355 Remove duplicate "friend" declaration.
llvm-svn: 179749
2013-04-18 07:42:20 +00:00
Daniel Malea 9ff5633f85 Add missing include
llvm-svn: 179711
2013-04-17 19:26:52 +00:00
Sean Callanan 14cb2aaa69 Added a new API to the IRInterpreter (the old API
will be gone soon!) that lets it interpret a function
using just an llvm::Module, an llvm::Function, and a
MemoryMap.

Also added an API to IRExecutionUnit to get at its
llvm::Function, so that the IRInterpreter can work
with it.

llvm-svn: 179704
2013-04-17 18:35:47 +00:00
Sean Callanan 182bd6c0fe Made the IRInterpreter's methods static, since
it doesn't actually hold any important state.

llvm-svn: 179702
2013-04-17 18:07:40 +00:00
Sean Callanan 175187b36b Made the IRInterpreter be able to operate without
a ClangExpressionDeclMap.  Any functions that
require value resolution etc. fail if the
ClangExpressionDeclMap isn't present - which is
exactly what is desired.

llvm-svn: 179695
2013-04-17 17:51:08 +00:00