Commit Graph

4801 Commits

Author SHA1 Message Date
Greg Clayton d1cf11a74d Added a new host function that allows us to run shell command and get the output from them along with the status and signal:
Error
Host::RunShellCommand (const char *command,
                       const char *working_dir,
                       int *status_ptr,
                       int *signo_ptr,
                       std::string *command_output_ptr,
                       uint32_t timeout_sec);

This will allow us to use this functionality in the host lldb_private::Platform, and also use it in our lldb-platform binary. It leverages the existing code in Host::LaunchProcess and ProcessLaunchInfo.

llvm-svn: 154730
2012-04-14 01:42:46 +00:00
Sean Callanan f5c87882a0 Added a --lldb option to override the location
of LLDB.framework.

llvm-svn: 154728
2012-04-14 01:06:06 +00:00
Sean Callanan 2a7d20405d Made sure that the collections of mutexes used in
checking for LLDB mutex validity are static so
that entries put in there actually persist between
calls to error_check_mutex.

llvm-svn: 154727
2012-04-14 01:05:29 +00:00
Johnny Chen 7b9f93a186 Patch from Viktor Kutuzov <vkutuzov@accesssoftek.com>:
Hello everyone,
 
please find the attached patch for TOT and lldb-platform-work branch, which provides the following changes:
 - fixed a crash in the ProcessPOSIX constructor when an executable module object is not yet created.
 - added support for the multi instanciated FreeBSD platform objects (the local host and remote as example).
 - enabled the remote gdb plugin on FreeBSD.

llvm-svn: 154724
2012-04-14 00:54:42 +00:00
Sean Callanan 0fcd749a51 Updated LLVM to take a variety of fixes to
disassembler problems:

- r153766, fixing a crash disassembling vmov
- r154628, fixing relative branches
- r154459, fixing a crash disassembling vld
- r154544, fixing a crash disassembling vst

llvm-svn: 154722
2012-04-14 00:08:14 +00:00
Jim Ingham d846f1f2b1 The API lock was getting dropped too soon in GetVariables. GetValueObjectForFrameVariable could run the target (to get dynamic values) and that requires the target lock.
llvm-svn: 154711
2012-04-13 23:29:44 +00:00
Jim Ingham 99ff2c42f6 In debug mode, assert if we haven't initialized a mutex we thought we'd initialized.
llvm-svn: 154710
2012-04-13 23:28:33 +00:00
Jim Ingham 87d0e61839 Don't do the work in DoTakedown if the thread plan isn't valid.
Also fixed up some logging.

llvm-svn: 154709
2012-04-13 23:11:52 +00:00
Jim Ingham e39f85c774 The run all threads timeout in RunThreadPlan should respect the user timeout, not be arbitrarily 10 seconds (which was too long anyway...)
Also added some logging to RunThreadPlan and made others more regular.

llvm-svn: 154708
2012-04-13 23:09:49 +00:00
Greg Clayton d451c1a843 Added the thread ID (tid) to each packet history item and the packet history now always dumps to a lldb_private::Stream.
Enable logging the packet history when registers fail to read due to not getting the sequence mutex if "--verbose" is enabled on the log channel for the "gdb-remote" log category.

This will help us track down some issues.

llvm-svn: 154704
2012-04-13 21:24:18 +00:00
Johnny Chen 9a27713a74 First step to make the test suite runnable for remote platforms.
For the types directory, we were running lldbtest.system() to execute the compiled program
on the test host to collect golden output in order to compare with the output of various
lldb debugger commands as performed later.  This won't work for the remote platform
scenario where the architecture of the target and host platforms are different.

Modify the AbstractBase class to use lldb to launch the inferior while specifying the
output file, from which the golden output is collected and grokked.  How to bootstrap and
to connect to the remote platform is still being worked at.

llvm-svn: 154699
2012-04-13 20:40:52 +00:00
Jim Ingham 0092c8eb2f Factor out a bunch of common code in the two ThreadPlanCallFunction constructors. Also add a sanity check - try reading the frame, and if we fail bag out.
llvm-svn: 154698
2012-04-13 20:38:13 +00:00
Greg Clayton de0e9d04ad <rdar://problem/11193466>
Fixed an error where lldb would hang when writing memory near the end of the addres space due to an unsigned overflow.

llvm-svn: 154697
2012-04-13 20:37:20 +00:00
Jim Ingham cbbdaa9378 Couple more places in SBValue where you need to take the run-lock.
llvm-svn: 154683
2012-04-13 18:30:20 +00:00
Jim Ingham 718583ff23 ThreadPlanCallFunction's destructor wasn't calling DoTakedown, so if the that plan got discarded we weren't doing the takedown.
llvm-svn: 154681
2012-04-13 18:27:58 +00:00
Greg Clayton d84bb48582 Added a --memory option to allow dumping the matching malloc block memory with a default format that makes sense, or that format can be overridden with the --format option.
llvm-svn: 154671
2012-04-13 16:24:09 +00:00
Greg Clayton f958f348c8 <rdar://problem/11241798>
The less locks there are, the better. I removed the thread ID mutex and now just shared the m_thread_list's mutex to make sure we don't deadlock due to lock inversion.

llvm-svn: 154652
2012-04-13 02:11:32 +00:00
Jason Molenda 5a9f9d3241 version bump to lldb-139.
llvm-svn: 154650
2012-04-13 02:00:58 +00:00
Sean Callanan 84790aedb1 Updated llvm.zip to include a fix for a leak in
the MC disassembler.

llvm-svn: 154649
2012-04-13 01:46:44 +00:00
Johnny Chen 18104239b4 Ditto 'requires modern objc runtime' for TestRealDefinition.py -- fix test suite errors for i386.
llvm-svn: 154638
2012-04-13 00:23:26 +00:00
Greg Clayton ce7d345a57 Added more complete error checking for mutexes only for "Debug" builds where we always check if a mutex is valid prior to doing stuff with it. We also track when mutexes are initialized and destroyed and keep these in sets that can very subsequent pthread_mutex_XXX API calls.
llvm-svn: 154637
2012-04-13 00:21:53 +00:00
Johnny Chen 97ccf9f3b2 Ditto 'requires modern objc runtime' for TestObjCProperty.py -- fix test suite errors for i386.
llvm-svn: 154636
2012-04-13 00:18:17 +00:00
Johnny Chen 45872c01ff Fix some test suite errors. TestForwardDecl.py errors were due to bad Makefile.rules, while TestHiddenIvars.py errors due to features only available in modern objc runtime.
llvm-svn: 154635
2012-04-13 00:13:35 +00:00
Sean Callanan 60217120b5 Added a mechanism for keeping track of where in
the debug information individual Decls came from.

We've had a metadata infrastructure for a while,
which was intended to solve a problem we've since
dealt with in a different way.  (It was meant to
keep track of which definition of an Objective-C
class was the "true" definition, but we now find
it by searching the symbols for the class symbol.)
The metadata is attached to the ExternalASTSource,
which means it has a one-to-one correspondence with
AST contexts.

I've repurposed the metadata infrastructure to
hold the object file and DIE offset for the DWARF
information corresponding to a Decl.  There are
methods in ClangASTContext that get and set this
metadata, and the ClangASTImporter is capable of
tracking down the metadata for Decls that have been
copied out of the debug information into the
parser's AST context without using any additional
memory.

To see the metadata, you just have to enable the
expression log:
-
(lldb) log enable lldb expr
-
and watch the import messages.  The high 32 bits
of the metadata indicate the index of the object
file in its containing DWARFDebugMap; I have also
added a log which you can use to track that mapping:
-
(lldb) log enable dwarf map
-

This adds 64 bits per Decl, which in my testing
hasn't turned out to be very much (debugging Clang
produces around 6500 Decls in my tests).  To track
how much data is being consumed, I've also added a
global variable g_TotalSizeOfMetadata which tracks
the total number of Decls that have metadata in all
active AST contexts.

Right now this metadata is enormously useful for
tracking down bugs in the debug info parser.  In the
future I also want to use this information to provide
more intelligent error messages instead of printing
empty source lines wherever Clang refers to the
location where something is defined.

llvm-svn: 154634
2012-04-13 00:10:03 +00:00
Greg Clayton c8e0c244e4 Expose GetAddressClass() from both the SBAddress and SBInstruction so clients can tell the difference between ARM/Thumb opcodes when disassembling ARM.
llvm-svn: 154633
2012-04-13 00:07:34 +00:00
Sean Callanan 02eee4d4f7 Fixed a problem where LLDB inserted regular C
FunctionDecls into classes if it looked up a
method in a different DWARF context than the
one where it found the parent class's definition.

The symptom of this was, for a method A::B(),

1) LLDB finds A in context 1, creating a
   CXXRecordDecl for A and marking it as needing
   completion

2) LLDB looks up B in context 2, finds that its
   parent A already has a CXXRecordDecl, but can't
   find a CXXMethodDecl for B

3) Not finding a CXXMethodDecl for B, LLDB doesn't
   set the flag indicating that B was resolved

4) Because the flag wasn't set, LLDB's fallthrough
   code creates a FunctionDecl for B and sticks it
   in the DeclContext -- in this case, A.

5) Clang crashes on finding a FunctionDecl inside a
   CXXRecordDecl.

llvm-svn: 154627
2012-04-12 23:10:00 +00:00
Greg Clayton 1bcb26c672 Fixed some expression issues after switching to void * args.
llvm-svn: 154615
2012-04-12 21:06:22 +00:00
Greg Clayton af2589ea09 Fixed an issue that happens in LLDB versions after SBFrame switched to using a lldb::ExecutionContextRefSP where we might segfault due to using a shared pointer with NULL in it. The SBFrame object should always have a valid lldb::ExecutionContextRefSP in it. The SBFrame::Clear() method was doing the wrong thing and is now fixed.
llvm-svn: 154614
2012-04-12 20:58:26 +00:00
Greg Clayton c3c0b0e59a Remove the GetSequenceMutex timeout that isn't being used in the GDB remote plug-in.
Also fixed the ProcessLinux, ProcessPOSIX and ProcessFreeBSD to have the correct UpdateThreadList() prototype.

llvm-svn: 154603
2012-04-12 19:04:34 +00:00
Greg Clayton 7767716d0f A few tweaks done to the heap.py in me free time where we now have:
(lldb) command script import heap.py

Find all malloc blocks that contains a pointer value of 0x1234000:
(lldb) ptr_refs 0x1234000

Find all malloc blocks that contain a C string:
(lldb) cstr_refs "hello"

Get info on a malloc block that starts at or contains 0x12340000
(lldb) malloc_info 0x12340000

llvm-svn: 154602
2012-04-12 18:57:36 +00:00
Jim Ingham b1e2e848f3 Make sure that DoResume doesn't stall if we shut down the async thread while DoResume is waiting
for packet confirmation.  
Also added a bit more logging.
Also, unlock the writer end of the run lock in Process.cpp on our way out of the private state
thread so that the Process can shut down cleanly.

<rdar://problem/11228538>

llvm-svn: 154601
2012-04-12 18:49:31 +00:00
Jim Ingham 5b7a845a0a Cleanup, keep private types separate from private member variables.
llvm-svn: 154600
2012-04-12 18:25:11 +00:00
Sean Callanan 6f3e5ad704 Make sure frozen_sp for a ClangExpressionVariable
is non-NULL before asking for its name.

llvm-svn: 154593
2012-04-12 16:58:26 +00:00
Johnny Chen b127f00b51 Make the default architectures to run as both 64 and 32-bit.
rdar://problem/11031264

llvm-svn: 154573
2012-04-12 00:55:57 +00:00
Sean Callanan 18a11e33ea Fixed a crash in Clang when a superclass of an
Objective-C class doesn't have a definition but
Clang tries to read through its protocols anyway.

llvm-svn: 154538
2012-04-11 21:48:13 +00:00
Greg Clayton d1411e1aa2 Cleaned up code that was getting SBData for an SBInstruction.
llvm-svn: 154535
2012-04-11 21:13:31 +00:00
Greg Clayton 7fb671bac0 Cleaned up the code and we now also dump the dynamic object for the malloc block. Using this on the lldb/test/lang/objc/foundation test we can see this in action:
First we can load the module:

(lldb) command script import /Volumes/work/gclayton/Documents/src/lldb/examples/darwin/heap_find/heap.py
Loading "/Volumes/work/gclayton/Documents/src/lldb/examples/darwin/heap_find/libheap.dylib"...ok
Image 0 loaded.
"heap_ptr_refs" and "heap_cstr_refs" commands have been installed, use the "--help" options on these commands for detailed help.


Lets take a look at the variable "my":

(lldb) fr var *my
(MyString) *my = {
  MyBase = {
    NSObject = {
      isa = MyString
    }
    propertyMovesThings = 0
  }
  str = 0x0000000100301a60
  date = 0x0000000100301e60
  _desc_pauses = NO
}


We can see that this contains an ivar "str" which has a pointer value of "0x0000000100301a60". Lets search the heap for this pointer and see what we find:

(lldb) heap_ptr_refs 0x0000000100301a60
found pointer 0x0000000100301a60: block = 0x103800270, size = 384, offset = 168, type = 'void *'
found pointer 0x0000000100301a60: block = 0x100301cf0, size = 48, offset = 16, type = 'MyString *', ivar = 'str' 
(MyString) *addr = {
  MyBase = {
    NSObject = {
      isa = MyString
    }
    propertyMovesThings = 0
  }
  str = 0x0000000100301a60
  date = 0x0000000100301e60
  _desc_pauses = NO
}
found pointer 0x0000000100301a60: block = 0x100820000, size = 4096, offset = 96, type = (autorelease object pool)
found pointer 0x0000000100301a60: block = 0x100820000, size = 4096, offset = 104, type = (autorelease object pool)


Note that it used dynamic type info to find that it was in "MyString" at offset 16 and it also found the ivar "str"!

We can also look for C string values on the heap. Lets look for "a.out":

(lldb) heap_cstr_refs "a.out"
found cstr a.out: block = 0x10010ce00, size = 96, offset = 85, type = '__NSCFString *'
found cstr a.out: block = 0x100112d90, size = 80, offset = 68, type = 'void *'
found cstr a.out: block = 0x100114490, size = 96, offset = 85, type = '__NSCFString *'
found cstr a.out: block = 0x100114530, size = 112, offset = 97, type = '__NSCFString *'
found cstr a.out: block = 0x100114e40, size = 32, offset = 17, type = '__NSCFString *'
found cstr a.out: block = 0x100114fa0, size = 32, offset = 17, type = '__NSCFString *'
found cstr a.out: block = 0x100300780, size = 160, offset = 128, type = '__NSCFData *'
found cstr a.out: block = 0x100301a60, size = 112, offset = 97, type = '__NSCFString *'
found cstr a.out: block = 0x100821000, size = 4096, offset = 100, type = 'void *'

We see we have some objective C classes that contain this, so lets "po" all of the results by adding the --po option:

(lldb)  heap_cstr_refs a.out --po
found cstr a.out: block = 0x10010ce00, size = 96, offset = 85, type = '__NSCFString *'
  (__NSCFString *) 0x10010ce00 /Volumes/work/gclayton/Documents/src/lldb/test/lang/objc/foundation/a.out

found cstr a.out: block = 0x100112d90, size = 80, offset = 68, type = 'void *'
found cstr a.out: block = 0x100114490, size = 96, offset = 85, type = '__NSCFString *'
  (__NSCFString *) 0x100114490 /Volumes/work/gclayton/Documents/src/lldb/test/lang/objc/foundation/a.out

found cstr a.out: block = 0x100114530, size = 112, offset = 97, type = '__NSCFString *'
  (__NSCFString *) 0x100114530 Hello from '/Volumes/work/gclayton/Documents/src/lldb/test/lang/objc/foundation/a.out'

found cstr a.out: block = 0x100114e40, size = 32, offset = 17, type = '__NSCFString *'
  (__NSCFString *) 0x100114e40 a.out.dSYM

found cstr a.out: block = 0x100114fa0, size = 32, offset = 17, type = '__NSCFString *'
  (__NSCFString *) 0x100114fa0 a.out

found cstr a.out: block = 0x100300780, size = 160, offset = 128, type = '__NSCFData *'
  (__NSCFData *) 0x100300780 <48656c6c 6f206672 6f6d2027 2f566f6c 756d6573 2f776f72 6b2f6763 6c617974 6f6e2f44 6f63756d 656e7473 2f737263 2f6c6c64 622f7465 73742f6c 616e672f 6f626a63 2f666f75 6e646174 696f6e2f 612e6f75 742700>

found cstr a.out: block = 0x100301a60, size = 112, offset = 97, type = '__NSCFString *'
  (__NSCFString *) 0x100301a60 Hello from '/Volumes/work/gclayton/Documents/src/lldb/test/lang/objc/foundation/a.out'

found cstr a.out: block = 0x100821000, size = 4096, offset = 100, type = 'void *'

llvm-svn: 154519
2012-04-11 18:30:53 +00:00
Greg Clayton 885294808a Get rid of absolute path in "process load" command.
llvm-svn: 154506
2012-04-11 17:04:00 +00:00
Greg Clayton 804de01c33 Added a new "heap.py" module that adds a new command line command that can find values on the heap and print out the dynamic type of the malloc block that contains the data. I will be modifying this a bit more to tweak the output and make the output more useful.
llvm-svn: 154504
2012-04-11 16:27:06 +00:00
Greg Clayton 6a0afeb9c8 Fixed an issue that would cause a crash when dumping fully qualified types.
llvm-svn: 154503
2012-04-11 16:21:20 +00:00
Greg Clayton 851eacb507 Added a property to get the dynamic type which uses the most permissive way to get a dynamic type.
llvm-svn: 154502
2012-04-11 16:20:15 +00:00
Greg Clayton 37a0a24a5f No functionality changes, mostly cleanup.
Cleaned up the Mutex::Locker and the ReadWriteLock classes a bit.

Also cleaned up the GDBRemoteCommunication class to not have so many packet functions. Used the "NoLock" versions of send/receive packet functions when possible for a bit of performance.

llvm-svn: 154458
2012-04-11 00:24:49 +00:00
Jason Molenda 9704e82978 Tweak arm variants list for valid arches settings.
llvm-svn: 154450
2012-04-10 23:08:02 +00:00
Sean Callanan 62ecb9b97b Improved detection of ARM branch instructions to
cover all possible condition codes.

llvm-svn: 154440
2012-04-10 21:51:12 +00:00
Greg Clayton 470dfcbc42 Added more documentation in the header file to explain how to use the results that are found by the function calls to find_pointer_in_heap().
llvm-svn: 154435
2012-04-10 20:59:36 +00:00
Greg Clayton b10973af64 Fixed head_find to compile again.
llvm-svn: 154419
2012-04-10 18:19:20 +00:00
Sean Callanan 6153c518b9 Set variables returned by utility functions to
not consume slots in the persistent variable
store.

llvm-svn: 154416
2012-04-10 18:16:59 +00:00
Greg Clayton 4463399b0d Added a new packet to our GDB remote protocol:
QListThreadsInStopReply
	
This GDB remote query command can enable added a "threads" key/value pair to all stop reply packets so that we always get a list of all threads in each stop reply packet. It increases performance if enabled (the reply to the "QListThreadsInStopReply" is "OK") by saving us from sending to command/reply pairs (the "qfThreadInfo" and "qsThreadInfo" packets), and also helps us keep the current process state up to date. 

llvm-svn: 154380
2012-04-10 03:22:03 +00:00
Greg Clayton 9e92090b3c A general stability fix where we _always_ get the thread list immediately after we get the stop packets. We had some racy conditions where thread 1 might be sending a packet and thread 2 tries to send a packet to get the thread list and it fails and ends up with an empty list. Packets use a sequence mutex to be able to ensure when you send a packet, you get the resonse. This sequence mutex is take when the process is running, and as we exit the running state and notify our process with the stop packet, we now always get the thread ID list before we do anything and before we can run into race conditions.
The next step is to have our stop reply packets send the thread list in the actual stop reply packet to avoid a 2 packet overhead of sending the qfThreadInfo + response and qfThreadInfo + response.

llvm-svn: 154376
2012-04-10 02:25:43 +00:00
Jim Ingham 076b3041c0 Two changes,
1) Start the PrivateStateThread stopped, and then in
StartPrivateStateThread, make the private state thread and then
resume it before we say the thread is created.  That way we know it is
listening for events by the time we get out of
StartPrivateStateThread.

2) Backstop running a thread plan when calling Process::RunThreadPlan
on the private state thread with a ThreadPlanBase so that running the
plan doesn't pass its stop events to whatever plans happen to be above
us on the thread plan stack.

llvm-svn: 154368
2012-04-10 01:21:57 +00:00