llvm-project/lldb
Greg Clayton 17a6ad05c1 Removed the "lldb-forward-rtti.h" header file as it was designed to contain
all RTTI types, and since we don't use RTTI anymore since clang and llvm don't
we don't really need this header file. All shared pointer definitions have
been moved into "lldb-forward.h".

Defined std::tr1::weak_ptr definitions for all of the types that inherit from
enable_shared_from_this() in "lldb-forward.h" in preparation for thread
hardening our public API.

The first in the thread hardening check-ins. First we start with SBThread.
We have issues in our lldb::SB API right now where if you have one object
that is being used by two threads we have a race condition. Consider the
following code:

 1    int
 2    SBThread::SomeFunction()
 3    {
 4        int result = -1;
 5        if (m_opaque_sp)
 6        {
 7            result = m_opaque_sp->DoSomething();
 8        }
 9        return result;
10    }

And now this happens:

Thread 1 enters any SBThread function and checks its m_opaque_sp and is about
to execute the code on line 7 but hasn't yet
Thread 2 gets to run and class sb_thread.Clear() which calls m_opaque_sp.clear()
and clears the contents of the shared pointer member
Thread 1 now crashes when it resumes.

The solution is to use std::tr1::weak_ptr. Now the SBThread class contains a
lldb::ThreadWP (weak pointer to our lldb_private::Thread class) and this 
function would look like:

 1    int
 2    SBThread::SomeFunction()
 3    {
 4        int result = -1;
 5        ThreadSP thread_sp(m_opaque_wp.lock());
 6        if (thread_sp)
 7        {
 8            result = m_opaque_sp->DoSomething();
 9        }
10        return result;
11    }

Now we have a solid thread safe API where we get a local copy of our thread
shared pointer from our weak_ptr and then we are guaranteed it can't go away
during our function.

So lldb::SBThread has been thread hardened, more checkins to follow shortly.

llvm-svn: 149218
2012-01-30 02:53:15 +00:00
..
docs When unwinding from the first frame, try to ask the remote debugserver 2011-12-13 05:39:38 +00:00
examples Added a 'gdbremote' python module that adds two commands: start_gdb_log and end_gdb_log. 2012-01-26 02:56:24 +00:00
include Removed the "lldb-forward-rtti.h" header file as it was designed to contain 2012-01-30 02:53:15 +00:00
lib This patch combines common code from Linux and FreeBSD into 2012-01-05 19:17:38 +00:00
lldb.xcodeproj Removed the "lldb-forward-rtti.h" header file as it was designed to contain 2012-01-30 02:53:15 +00:00
lldb.xcworkspace I accidentally committed some changes to the 2011-12-21 21:30:33 +00:00
resources Bumping Xcode project versions for lldb-109 and debugserver-167. 2012-01-28 02:48:10 +00:00
scripts Removed the "lldb-forward-rtti.h" header file as it was designed to contain 2012-01-30 02:53:15 +00:00
source Removed the "lldb-forward-rtti.h" header file as it was designed to contain 2012-01-30 02:53:15 +00:00
test Move argument checking/manipulation into the front of the function. 2012-01-25 20:50:21 +00:00
tools Fix shell commands that do code signing. 2012-01-28 04:19:15 +00:00
utils Add a utility script: 2011-11-04 01:05:29 +00:00
www Added some clarifications about when the __lldb_init_module would be called 2012-01-26 05:36:07 +00:00
INSTALL.txt You'll need to be running Mac OS X to get lldb to build right now. 2010-06-09 07:29:26 +00:00
LICENSE.TXT test commit 2010-06-09 03:55:24 +00:00
Makefile This patch combines common code from Linux and FreeBSD into 2012-01-05 19:17:38 +00:00