Commit Graph

4246 Commits

Author SHA1 Message Date
Enrico Granata 56a27bb5fa Splitting test case for Python synthetic children: part 1 test is only testing the synthetic children feature itself. More test cases will be commited for individual STL containers
llvm-svn: 149393
2012-01-31 17:50:00 +00:00
Enrico Granata 7b59f755f4 Comments edited to better reflect what the function really does
llvm-svn: 149390
2012-01-31 17:18:40 +00:00
Enrico Granata bac45f610d This commit provides a new default summary for Objective-C boolean variables, which shows YES or NO instead of the character value. A new category named objc is added to contain this summary provider. Any future Objective-C related formatters would probably fit here
llvm-svn: 149388
2012-01-31 17:01:51 +00:00
Greg Clayton 74d4193e2f Cleaned up the Communication class when it tears down ConnectionFileDescriptor
instances to not pthread_cancel the read threads and wreak havoc on the mutex
in our ConnectionFileDescriptor class.

Also cleaned up some shutdown delays.

llvm-svn: 149355
2012-01-31 04:56:17 +00:00
Greg Clayton ef496d5c4d <rdar://problem/10776614>
Fixed an issue where we can crash if you call cast when the SBValue
doesn't contain a valid value.

llvm-svn: 149345
2012-01-31 04:25:15 +00:00
Enrico Granata cff58989d7 quick fixes for two issues that were causing LLDB to crash
llvm-svn: 149338
2012-01-31 02:21:45 +00:00
Johnny Chen 6b68c98f7d Add some more test cases for the "watchpoint set" command.
llvm-svn: 149324
2012-01-31 01:26:28 +00:00
Johnny Chen 5d0d607b6b Add a period.
llvm-svn: 149305
2012-01-31 00:48:02 +00:00
Johnny Chen 8f8a2a7774 Add a '-u ENV_VAR_NAME' option to the test driver, whose purpose is to unset the said
environment variable before starting the test runner which executes the test cases and
may spawn child processes.  An example:

    ./dotest.py -u MY_ENV1 -u MY_ENV2 -v -p TestWatchLocationWithWatchSet.py

llvm-svn: 149304
2012-01-31 00:38:03 +00:00
Johnny Chen 3926837056 Trivial indentation change.
llvm-svn: 149297
2012-01-30 23:26:57 +00:00
Johnny Chen 5b3b5f07fe Fixed a typo in the test case. Updated comment.
llvm-svn: 149295
2012-01-30 23:17:07 +00:00
Johnny Chen 50df1f96dc Reverted 149277 changeset. It was coded that way for a reason.
llvm-svn: 149292
2012-01-30 22:48:10 +00:00
Johnny Chen dedb67ab9b Add "watch set" command as a more general interface in conjunction with "frame var -w".
Also add test cases for watching a variable as well as a location expressed as an expression.

o TestMyFirstWatchpoint.py:

  Modified to test "watchpoint set -w write global".

o TestWatchLocationWithWatchSet.py:

  Added to test "watchpoint set -w write -x 1 g_char_ptr + 7" where a contrived example program
  with several threads is supposed to only access the array index within the range [0..6], but
  there's some misbehaving thread writing past the range.

rdar://problem/10701761

llvm-svn: 149280
2012-01-30 21:46:17 +00:00
Johnny Chen a5822c0501 Make BreakpointLocation::IsEnabled() consistent with the BreakpointLocation::SetEnabled() implementation.
llvm-svn: 149277
2012-01-30 21:16:22 +00:00
Greg Clayton 0a94b6614a Added a new lldb.SBValue helper module that has two classes:
sbvalue.value (<SBValue>)
sbvalue.variable (<SBValue>)

Initialize both with a lldb.SBValue

sbvalue.value() make all sorts of convenience properties. Type "help(sbvalue.value)" 
in the embedded python interpreter to see what is available.

sbvalue.variable() wraps a lldb.SBValue and allows you to play with your variable just
as you would expect:

pt = sbvalue.variable (lldb.frame.FindVariable("pt"))

print pt.x
print py.y

argv = sbvalue.variable (lldb.frame.FindVariable("argv"))
print argv[0]

Member access and array acccess is all taken care of!

llvm-svn: 149260
2012-01-30 19:32:25 +00:00
Greg Clayton acdbe81637 lldb::SBTarget and lldb::SBProcess are now thread hardened. They both still
contain shared pointers to the lldb_private::Target and lldb_private::Process
objects respectively as we won't want the target or process just going away.

Also cleaned up the lldb::SBModule to remove dangerous pointer accessors.

For any code the public API files, we should always be grabbing shared 
pointers to any objects for the current class, and any other classes prior
to running code with them.

llvm-svn: 149238
2012-01-30 09:04:36 +00:00
Greg Clayton b9556acc9e SBFrame is now threadsafe using some extra tricks. One issue is that stack
frames might go away (the object itself, not the actual logical frame) when
we are single stepping due to the way we currently sometimes end up flushing
frames when stepping in/out/over. They later will come back to life 
represented by another object yet they have the same StackID. Now when you get
a lldb::SBFrame object, it will track the frame it is initialized with until 
the thread goes away or the StackID no longer exists in the stack for the 
thread it was created on. It uses a weak_ptr to both the frame and thread and
also stores the StackID. These three items allow us to determine when the
stack frame object has gone away (the weak_ptr will be NULL) and allows us to
find the correct frame again. In our test suite we had such cases where we
were just getting lucky when something like this happened:

1 - stop at breakpoint
2 - get first frame in thread where we stopped
3 - run an expression that causes the program to JIT and run code
4 - run more expressions on the frame from step 2 which was very very luckily
    still around inside a shared pointer, yet, not part of the current 
    thread (a new stack frame object had appeared with the same stack ID and
    depth). 
    
We now avoid all such issues and properly keep up to date, or we start 
returning errors when the frame doesn't exist and always responds with
invalid answers.

Also fixed the UserSettingsController  (not going to rewrite this just yet)
so that it doesn't crash on shutdown. Using weak_ptr's came in real handy to
track when the master controller has already gone away and this allowed me to
pull out the previous NotifyOwnerIsShuttingDown() patch as it is no longer 
needed.

llvm-svn: 149231
2012-01-30 07:41:31 +00:00
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
Greg Clayton e1cd1be6d6 Switching back to using std::tr1::shared_ptr. We originally switched away
due to RTTI worries since llvm and clang don't use RTTI, but I was able to 
switch back with no issues as far as I can tell. Once the RTTI issue wasn't
an issue, we were looking for a way to properly track weak pointers to objects
to solve some of the threading issues we have been running into which naturally
led us back to std::tr1::weak_ptr. We also wanted the ability to make a shared 
pointer from just a pointer, which is also easily solved using the 
std::tr1::enable_shared_from_this class. 

The main reason for this move back is so we can start properly having weak
references to objects. Currently a lldb_private::Thread class has a refrence
to its parent lldb_private::Process. This doesn't work well when we now hand
out a SBThread object that contains a shared pointer to a lldb_private::Thread
as this SBThread can be held onto by external clients and if they end up
using one of these objects we can easily crash.

So the next task is to start adopting std::tr1::weak_ptr where ever it makes
sense which we can do with lldb_private::Debugger, lldb_private::Target,
lldb_private::Process, lldb_private::Thread, lldb_private::StackFrame, and
many more objects now that they are no longer using intrusive ref counted
pointer objects (you can't do std::tr1::weak_ptr functionality with intrusive
pointers).

llvm-svn: 149207
2012-01-29 20:56:30 +00:00
Greg Clayton bbb032e219 Removed an incorrectly added property from SBTarget.i
llvm-svn: 149192
2012-01-29 07:09:30 +00:00
Greg Clayton 13d1950ae6 Added the ability to get the target triple, byte order and address byte size
from the SBTarget and SBModule interfaces. Also added many python properties
for easier access to many things from many SB objects.

llvm-svn: 149191
2012-01-29 06:07:39 +00:00
Jason Molenda b10ebda354 Fix shell commands that do code signing.
llvm-svn: 149171
2012-01-28 04:19:15 +00:00
Greg Clayton 3120dc6261 Bumping Xcode project versions for lldb-109 and debugserver-167.
llvm-svn: 149168
2012-01-28 02:48:10 +00:00
Greg Clayton 821ac6ddbd Added logging so we can see the field names and offsets of any structures
for when we enable the assisted layout.

llvm-svn: 149167
2012-01-28 02:22:27 +00:00
Greg Clayton 037f9fda5a Stop running so many individual commands when going into the script interpreter.
All of the commands now get globbed into a single line.

lldb.target, lldb.process, lldb.thread and lldb.frame now get initialized with
empty SBTarget, SBProcess, SBThread and SBFrame objects when they don't contain
anything. 

llvm-svn: 149166
2012-01-28 02:11:02 +00:00
Greg Clayton 9f94975ca6 Xcode codesigning is broken. Work around this by doing code signing in a shell script build phase.
llvm-svn: 149165
2012-01-28 01:40:47 +00:00
Greg Clayton caab74e02d Adding the DWARF parser side for assited layout where the AST context
will ask ExternalASTSource objects to help laying out a type. This is needed
because the DWARF typically doesn't contain alignement or packing attribute
values, and we need to be able to match up types that the compiler uses
in expressions.

llvm-svn: 149160
2012-01-28 00:48:57 +00:00
Johnny Chen aefcf999d2 Add an InstanceSettings::NotifyOwnerIsShuttingDown() method so that the owner can notify InstanceSettings instances
that their owner reference is no longer valid.

llvm-svn: 149145
2012-01-27 21:27:39 +00:00
Greg Clayton 9620f466af Disable the ConnectionFileDescriptor mutex for now as it is deadlocking our
test suite and I need to investigate this.

llvm-svn: 149141
2012-01-27 18:57:04 +00:00
Johnny Chen f8f0fd765e Fix typo.
llvm-svn: 149140
2012-01-27 18:53:22 +00:00
Johnny Chen 921ca5d4b8 Emit the message about putting ' -- ' between the end of command options and the raw input conditionally,
that is, only if the command object does not want completion.  An example is the "settings set" command.

llvm-svn: 149139
2012-01-27 18:49:33 +00:00
Greg Clayton 29ad7b914f Added a ModuleList::Destroy() method which will reclaim the std::vector
memory by doing a swap.

Also added a few utilty functions that can be enabled for debugging issues
with modules staying around too long when external clients still have references
to them.

llvm-svn: 149138
2012-01-27 18:45:39 +00:00
Greg Clayton a896f574e0 NULL out the "ptr_" member of shared pointers for debug and release
builds (not build and integration builds) to help catch when a shared pointer
that might be in a collection class is used after the collection
has been freed.

llvm-svn: 149136
2012-01-27 18:33:53 +00:00
Greg Clayton ecc6116950 Enable extra error checking for debug builds in our mutexes by
watching for errors from pthread_mutex_destroy () (usually "Resource
busy" errors for when you have a mutex locked and try to destroy
it), and pthread_mutex_lock, and pthread_mutex_unlock (usually for
trying to lock an invalid mutex that might have possible already
been freed).

llvm-svn: 149135
2012-01-27 18:29:47 +00:00
Greg Clayton a73d269294 There is no need to hold onto an ExecutionContext as a member variable.
ExecutionContext objects have shared pointers to Target, Process, Thread
and Frame objects and they can end up being held onto for too long.

llvm-svn: 149133
2012-01-27 18:18:23 +00:00
Greg Clayton e3f6b5ce48 Fixed a location where we would never end up unlocking our mutex in
the ClusterManager. Also switched to using Mutex::Locker where we can.

llvm-svn: 149132
2012-01-27 18:14:51 +00:00
Greg Clayton b26e6bebac Fixed an issue that could happen during global object destruction in our
map that tracks all live Module classes. We must leak our mutex for our
collection class as it might be destroyed in an order we can't control.

llvm-svn: 149131
2012-01-27 18:08:35 +00:00
Greg Clayton 23f7793b13 <rdar://problem/10760649>
Fixed another double file descriptor close issue that could occur when destroying a ProcessGDBRemote() object. There was a race which was detected by our fd_interposing library:

error: /Applications/Xcode.app/Contents/MacOS/Xcode (pid=55222): close (fd=60) resulted in EBADF:
0   libFDInterposing.dylib              0x00000001082be8ca close$__interposed__ + 666
1   LLDB                                0x00000001194fde91 lldb_private::ConnectionFileDescriptor::Close(int&, lldb_private::Error*) + 97
2   LLDB                                0x00000001194fddcd lldb_private::ConnectionFileDescriptor::Disconnect(lldb_private::Error*) + 143
3   LLDB                                0x00000001194fe249 lldb_private::ConnectionFileDescriptor::Read(void*, unsigned long, unsigned int, lldb::ConnectionStatus&, lldb_private::Error*) + 835
4   LLDB                                0x00000001194fc320 lldb_private::Communication::Read(void*, unsigned long, unsigned int, lldb::ConnectionStatus&, lldb_private::Error*) + 634
5   LLDB                                0x000000011959c7f4 GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock(StringExtractorGDBRemote&, unsigned int) + 228
6   LLDB                                0x000000011959c6b5 GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSeconds(StringExtractorGDBRemote&, unsigned int) + 49
7   LLDB                                0x0000000119629a71 GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse(ProcessGDBRemote*, char const*, unsigned long, StringExtractorGDBRemote&) + 509
8   LLDB                                0x00000001195a4076 ProcessGDBRemote::AsyncThread(void*) + 514
9   LLDB                                0x0000000119568094 ThreadCreateTrampoline(void*) + 91
10  libsystem_c.dylib                   0x00007fff8ca028bf _pthread_start + 335
11  libsystem_c.dylib                   0x00007fff8ca05b75 thread_start + 13

fd=60 was previously closed with this event:
pid=55222: close (fd=60) => 0
0   libFDInterposing.dylib              0x00000001082be870 close$__interposed__ + 576
1   LLDB                                0x00000001194fde91 lldb_private::ConnectionFileDescriptor::Close(int&, lldb_private::Error*) + 97
2   LLDB                                0x00000001194fddcd lldb_private::ConnectionFileDescriptor::Disconnect(lldb_private::Error*) + 143
3   LLDB                                0x00000001194fbf00 lldb_private::Communication::Disconnect(lldb_private::Error*) + 92
4   LLDB                                0x00000001195a2a77 ProcessGDBRemote::StopAsyncThread() + 89
5   LLDB                                0x00000001195a2bf6 ProcessGDBRemote::DoDestroy() + 310
6   LLDB                                0x00000001195f938d lldb_private::Process::Destroy() + 85
7   LLDB                                0x0000000118819b48 lldb::SBProcess::Kill() + 72
8   DebuggerLLDB                        0x0000000117264358 DBGLLDBSessionThread(void*) + 4450
9   LLDB                                0x0000000119568094 ThreadCreateTrampoline(void*) + 91
10  libsystem_c.dylib                   0x00007fff8ca028bf _pthread_start + 335
11  libsystem_c.dylib                   0x00007fff8ca05b75 thread_start + 13

fd=60 was created with this event:
pid=55222: socket (domain = 2, type = 1, protocol = 6) => fd=60
0   libFDInterposing.dylib              0x00000001082bc968 socket$__interposed__ + 600
1   LLDB                                0x00000001194fd75f lldb_private::ConnectionFileDescriptor::ConnectTCP(char const*, lldb_private::Error*) + 179
.....

llvm-svn: 149103
2012-01-27 00:46:15 +00:00
Greg Clayton 9ea3fcd845 <rdar://problem/10750012>
Remove a pseudo terminal master open and slave file descriptor that was being
used for pythong stdin. It was not hooked up correctly and was causing file
descriptor leaks.

llvm-svn: 149098
2012-01-27 00:13:27 +00:00
Greg Clayton 6efba4fc97 Fixed formats being able to be applied recursively when using:
target variable -f <format> [args]
frame variable -f <format> [args]
expression -f <format> -- expr

llvm-svn: 149080
2012-01-26 21:08:30 +00:00
Greg Clayton ba728e6d7d Added some clarifications about when the __lldb_init_module would be called
and showed a work around for when this won't.

llvm-svn: 149046
2012-01-26 05:36:07 +00:00
Greg Clayton e284163990 Added a 'gdbremote' python module that adds two commands: start_gdb_log and end_gdb_log.
When this is imported into your lldb using the "command script import /path/to/gdbremote.py"
these new commands are available within LLDB. 'start_gdb_log' will enable logging with 
timestamps for GDB remote packets, and 'stop_gdb_log' will then dump the details and
also a lot of packet timing data. This allows us to accurately track what packets are
taking up the most time when debugging (when using the ProcessGDBRemote debugging plug-in).

Also udpated the comments at the top of the cmdtemplate.py to show how to correctly import
the module from within LLDB.

llvm-svn: 149030
2012-01-26 02:56:24 +00:00
Greg Clayton 690b034161 Fix page title.
llvm-svn: 149004
2012-01-26 00:32:22 +00:00
Johnny Chen 9ec3c4f5a7 For Dump(Stream *s), use GetOptionsNoCreate()->GetIgnoreCount() and fix the indentation.
llvm-svn: 149002
2012-01-26 00:08:14 +00:00
Johnny Chen 29f7dff581 Typo.
llvm-svn: 148994
2012-01-25 23:08:23 +00:00
Greg Clayton 5c3de1560a If timestamps are enabled when logging GDB remote packets ("log enable -T -f /tmp/packets.log gdb-remote logs") then get the amount of time spent executing each packet and summarize at the end of a dump. Sample timing output looks like:
----------------------------------------------------------------------
Packet timing summary:
----------------------------------------------------------------------
Packet                 Time       %
---------------------- -------- ------
       qThreadStopInfo 0.363844  35.35
                     m 0.281967  27.39
                     s 0.147160  14.30
          qfThreadInfo 0.070865   6.88
          qsThreadInfo 0.061608   5.99
                     z 0.036796   3.57
                     Z 0.036271   3.52
                     c 0.018410   1.79
                     H 0.012418   1.21
---------------------- -------- ------
                 Total 1.029339 100.00

llvm-svn: 148983
2012-01-25 21:52:15 +00:00
Johnny Chen 11c00fc7b2 Move argument checking/manipulation into the front of the function.
llvm-svn: 148974
2012-01-25 20:50:21 +00:00
Johnny Chen 8d24390cad Clearify some comment.
llvm-svn: 148972
2012-01-25 20:29:26 +00:00
Johnny Chen 78e49e7fee Cleanup docstring and remove dead code.
llvm-svn: 148971
2012-01-25 20:25:38 +00:00
Greg Clayton 9431f01f65 Handle 's' packets correctly when disassembling GDB packet output.
llvm-svn: 148911
2012-01-25 03:20:34 +00:00