Commit Graph

246 Commits

Author SHA1 Message Date
Jason Molenda 0a72520f22 Patch from Dan Malea to fix a build break I introduced yesterday.
Thanks again Dan!

llvm-svn: 165519
2012-10-09 18:40:44 +00:00
Jason Molenda bb860bd264 Add a parameter to Symbols::DownloadObjectAndSymbolFile() to control
whether we try to call an external program to load symbols unconditionally,
or if we check the user's preferences before calling it.

ProcessMachCore now sets CanJIT to false - we can't execute code in a core file.

DynamicLoaderDarwinKernel::OSKextLoadedKextSummary::LoadImageUsingMemoryModule changed
to load the kernel from an on-disk file if at all possible.
Don't load the kext binaries out of memory from the remote systems - their linkedit doesn't
seem to be in a good state and we'll error out down in SymbolVendorMacOSX if we try to use
the in-memory images.
Call Symbols::DownloadObjectAndSymbolFile to get the kext/kernel binary -- the external
program may be able to give us a file path on the local filesystem instead of reading
the binary / dSYM over a network drive every time.  Fall back to calling 
Target::GetSharedModule() like before if DownloadObjectAndSymbolFile fails.

llvm-svn: 165471
2012-10-09 01:17:11 +00:00
Jason Molenda a8805d3809 Symbols::LocateMacOSXFilesUsingDebugSymbols() - perform tilde
expansion on the dSYM path we find if it starts with a tilde.

llvm-svn: 165299
2012-10-05 04:57:34 +00:00
Jason Molenda 743e439608 Change DynamicLoaderDarwinKernel::OSKextLoadedKextSummary to use
the Symbols::LocateExecutableObjectFile method to locate kexts and
kernels instead of copying them out of the memory of the remote
system.  This is the fix for <rdar://problem/12416384>.

Fix a variable shadowing problem in
Symbols::LocateMacOSXFilesUsingDebugSymbols which caused the symbol
rich executable binaries to not be found even if they were listed
in the dSYM Info.plist.

Change Symbols::DownloadObjectAndSymbolFile to ignore dsymForUUID's
negative cache - this is typically being called by the user and we
should try even if there's a incorrect entry in the negative cache.

llvm-svn: 165061
2012-10-02 22:23:42 +00:00
Enrico Granata 21dfcd9d41 Implementing plugins that provide commands.
This checkin adds the capability for LLDB to load plugins from external dylibs that can provide new commands
It exports an SBCommand class from the public API layer, and a new SBCommandPluginInterface

There is a minimal load-only plugin manager built into the debugger, which can be accessed via Debugger::LoadPlugin.

Plugins are loaded from two locations at debugger startup (LLDB.framework/Resources/PlugIns and ~/Library/Application Support/LLDB/PlugIns) and more can be (re)loaded via the "plugin load" command

For an example of how to make a plugin, refer to the fooplugin.cpp file in examples/plugins/commands

Caveats:
	Currently, the new API objects and features are not exposed via Python.
	The new commands can only be "parsed" (i.e. not raw) and get their command line via a char** parameter (we do not expose our internal Args object)
	There is no unloading feature, which can potentially lead to leaks if you overwrite the commands by reloading the same or different plugins
	There is no API exposed for option parsing, which means you may need to use getopt or roll-your-own

llvm-svn: 164865
2012-09-28 23:57:51 +00:00
Greg Clayton b5f0feabae Wrapped up the work I am going to do for now for the "add-dsym" or "target symfile add" command.
We can now do:

Specify a path to a debug symbols file:
(lldb) add-dsym <path-to-dsym>

Go and download the dSYM file for the "libunc.dylib" module in your target:
(lldb) add-dsym --shlib libunc.dylib

Go and download the dSYM given a UUID:
(lldb) add-dsym --uuid <UUID>

Go and download the dSYM file for the current frame:
(lldb) add-dsym --frame

llvm-svn: 164806
2012-09-27 22:26:11 +00:00
Greg Clayton c8f814d1df Added the ability to download a symboled executable and symbol file given a UUID.
llvm-svn: 164753
2012-09-27 03:13:55 +00:00
Jason Molenda 944cc67eba Bump to lldb-168, debugserver-193.
llvm-svn: 164291
2012-09-20 06:42:30 +00:00
Greg Clayton 813ddfcdd0 <rdar://problem/12219840>
Don't leak mach ports when calling "mach_thread_self()".

llvm-svn: 164152
2012-09-18 18:19:49 +00:00
Greg Clayton 43e0af06b4 Stop using the "%z" size_t modifier and cast all size_t values to uint64_t. Some platforms don't support this modification.
llvm-svn: 164148
2012-09-18 18:04:04 +00:00
Greg Clayton c1b1f1ea26 <rdar://problem/11374963>
When attaching on ARM hosted debuggers we were incorrectly setting the triple to "arm-apple-ios". This was happening because in the post attach code, we would lookup the process info through the platform, and if successful, we would get the architecture of the process. This code uses sysctl() calls, but we can only get the CPU type, not the subtype, so we would get ARM for CPU type and nothing for the cpu subtype, so this would map to "arm-apple-ios". I fixed the code to get the cpu subtype from "hw.cpusubtype" which is what we really want for ARM, and not the architecture is already correct. "add-dsym" then works like a charm. I also improved the command output when the architecture changes to show the entire triple instead of just the arch name.

llvm-svn: 163868
2012-09-14 02:41:36 +00:00
Greg Clayton 103f02820d <rdar://problem/11374963>
Partial fix for the above radar where we now resolve dsym mach-o files within the dSYM bundle when using "add-dsym" through the platform.

llvm-svn: 163676
2012-09-12 02:03:59 +00:00
Filipe Cabecinhas d0b87d81a1 Some more typing-related fixes.
llvm-svn: 163641
2012-09-11 18:11:16 +00:00
Greg Clayton 542e407581 Patch from Andrew Kaylor for linux:
The attached patch adds support for debugging 32-bit processes when running a 64-bit lldb on an x86_64 Linux system.
 
Making this work required two basic changes:
 
1)      Getting lldb to report that it could debug 32-bit processes
2)      Changing an assumption about how ptrace works when debugging cross-platform
 
For the first change, I took a conservative approach and only enabled this for x86_64 Linux platforms.  It may be that the change I made in Host.cpp could be extended to other 64-bit Linux platforms, but I'm not familiar enough with the other platforms to know for sure.
 
For the second change, the Linux ProcessMonitor class was assuming that ptrace(PTRACE_[PEEK|POKE]DATA...) would read/write a "word" based on the child process word size.  However, the ptrace documentation says that the "word" size read or written is "determined by the OS variant."  I verified experimentally that when ptracing a 32-bit child from a 64-bit parent a 64-bit word is read or written.

llvm-svn: 163398
2012-09-07 17:49:29 +00:00
Greg Clayton 0b0b512fd6 OptionValueFileSpec had an accessor to read the contents of the file and return the data. This can end up being used to get the string contents of a text file and could end up not being NULL terminated. I added accessors to get the file contents raw, or with a null terminator. Added the needed calls to make this happen in the FileSpec and File classes.
llvm-svn: 162921
2012-08-30 18:15:10 +00:00
Greg Clayton 1f7460716b <rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file". 
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()

Cleaned up header includes a bit as well.

llvm-svn: 162860
2012-08-29 21:13:06 +00:00
Greg Clayton 67cc06366c Reimplemented the code that backed the "settings" in lldb. There were many issues with the previous implementation:
- no setting auto completion
- very manual and error prone way of getting/setting variables
- tons of code duplication
- useless instance names for processes, threads

Now settings can easily be defined like option values. The new settings makes use of the "OptionValue" classes so we can re-use the option value code that we use to set settings in command options. No more instances, just "does the right thing".

llvm-svn: 162366
2012-08-22 17:17:09 +00:00
Johnny Chen 82e5a26240 rdar://problem/11324515
'add-dsym' (aka 'target symbols add') should display error messages when dsym file is not found
or the dsym uuid does not match any existing modules. Add TestAddDsymCommand.py test file.

llvm-svn: 162332
2012-08-22 00:18:43 +00:00
Sean Callanan d5e37e4d2b Updating Xcode project version numbers for lldb-165 and debugserver-192
llvm-svn: 161374
2012-08-07 00:32:29 +00:00
Sean Callanan c40b0f38b3 Updating Xcode project version numbers for lldb-164 and debugserver-191
llvm-svn: 161209
2012-08-02 20:40:53 +00:00
Filipe Cabecinhas cffbd09a56 Make glibc and its developers happy. Circumvent the lack of strlcat in glibc.
llvm-svn: 160979
2012-07-30 18:56:10 +00:00
Filipe Cabecinhas 0b75116ae9 Fixed ePathTypePythonDir for Linux and FreeBSD (at least). This works for non-installed compilations. I will test further.
llvm-svn: 160963
2012-07-30 16:46:32 +00:00
Sean Callanan 6981f1d856 Updating Xcode project version numbers for lldb-163 and debugserver-190
llvm-svn: 160770
2012-07-26 01:42:37 +00:00
Greg Clayton 9c3f4101bc Call "drain" on the auto release pool as it will do the right thing for both GC and non-GC apps. It will also quiet the static analyzer.
llvm-svn: 160390
2012-07-17 19:46:12 +00:00
Greg Clayton 23f59509a8 Ran the static analyzer on the codebase and found a few things.
llvm-svn: 160338
2012-07-17 03:23:13 +00:00
Jason Molenda 64e1d4abc7 Bump to lldb-162 / debugserver-189.
llvm-svn: 160212
2012-07-14 01:12:03 +00:00
Greg Clayton 96816e4848 Resolve source paths that start with ~ when doing substitutions.
llvm-svn: 160158
2012-07-13 01:20:25 +00:00
Jim Ingham 9aa15a4562 Unify how we get host version on Mac OS X & iOS.
Also remove our dependency on UIKit & AppKit.
Cleaned up the project files a bit.

<rdar://problem/11814498>

llvm-svn: 160147
2012-07-12 23:16:43 +00:00
Filipe Cabecinhas 0c251adf75 Provide more information when process launch can't change directory to the
path passed with -w

Test this functionality.

llvm-svn: 160130
2012-07-12 14:09:25 +00:00
Filipe Cabecinhas 2ada3104ec Fixed errors and warnings on debug code.
llvm-svn: 159929
2012-07-09 13:34:19 +00:00
Jason Molenda 84d32ddfc8 Bump versions to lldb-161, debugserver-188.
llvm-svn: 159798
2012-07-06 01:32:10 +00:00
Jason Molenda 06bca9ed0e Bump version number to lldb-160.
llvm-svn: 158890
2012-06-21 01:41:15 +00:00
Jim Ingham 4ceb928f02 Change the Mutex::Locker class so that it takes the Mutex object and locks it, rather
than being given the pthread_mutex_t from the Mutex and locks that.  That allows us to
track ownership of the Mutex better.  

Used this to switch the LLDB_CONFIGURATION_DEBUG enabled assert when we can't get the
gdb-remote sequence mutex to assert when the thread that had the mutex releases it.  This
is generally more useful information than saying just who failed to get it (since the
code that had it locked often had released it by the time the assert fired.)

llvm-svn: 158240
2012-06-08 22:50:40 +00:00
Jim Ingham b4451b1730 When the Platform launches a process for debugging, make sure it goes into a separate process group, otherwise ^C will both cause us to try to Stop it manually, AND send it a SIGINT, which can confuse us.
rdar://problem/11369230

llvm-svn: 157791
2012-06-01 01:22:13 +00:00
Jason Molenda 6bfd821ad0 Bump to lldb 152.
llvm-svn: 157456
2012-05-25 02:05:58 +00:00
Filipe Cabecinhas 721ba3ff77 Fixes the case where we created a dummy target, deleted it, and then tried to evaluate an expression with no target.
llvm-svn: 157110
2012-05-19 09:59:08 +00:00
Jason Molenda 8d27075c3d bump to lldb-150.
llvm-svn: 157090
2012-05-19 00:32:19 +00:00
Jason Molenda f34358e90b bump to lldb 149.
llvm-svn: 157040
2012-05-18 02:03:26 +00:00
Han Ming Ong 69b7412f34 <rdar://11477301>
Restore Xcode as a valid white list client using the XPC root launcher

llvm-svn: 157012
2012-05-17 20:41:48 +00:00
Filipe Cabecinhas b018345ddc We shouldn't save g_dummy_target_sp. Other code will simply call Destroy() on it.
TestBackticksWithoutATarget.BackticksWithNoTargetTestCase was calling
GetDummyTarget() when executing for x86_64. When performing session
tearDown, it would get destroyed (and everything would be invalid (arch,
etc).

Then the test would run for i386. The dummy target wasn't being
reinitialized and was invalid. lldb complained that 'current process state
is unsuitable for expression parsing'.

llvm-svn: 156994
2012-05-17 15:48:02 +00:00
Jason Molenda 5a725efeb0 Bump to version 148.
llvm-svn: 156971
2012-05-17 01:49:53 +00:00
Jason Molenda 43e70807da Bump version # to lldb-147.
llvm-svn: 156887
2012-05-16 00:40:14 +00:00
Greg Clayton 8910c90cdc <rdar://problem/11451919>
Fixed the test suite not working on i386 due to recent default arch detection changes.

llvm-svn: 156796
2012-05-15 02:44:13 +00:00
Greg Clayton 1a362fbb86 <rdar://problem/11439169>
"lldb -a i386" doesn't set the calculator mode correctly if run on a 64 bit system. 

The previous logic always used the current host architecture, not the default architecture. The default arch gets set into a static varaible in lldb_private::Target when an arch is set from the command line:

lldb -a i386

We now use the default arch correctly.

llvm-svn: 156680
2012-05-12 00:26:42 +00:00
Greg Clayton 950971f77c <rdar://problem/11439022>
Restore expressions with no target.

llvm-svn: 156669
2012-05-12 00:01:21 +00:00
Han Ming Ong b9c53daa55 <rdar://problem/11400476>
On Lion, because the rights initially doesn't exist in /etc/authorization, if an admin user logs in and uses lldb within the first 5 minutes, it is possible to do AuthorizationCopyRights on LaunchUsingXPCRightName and get the rights back. As another security measure, we make sure that the LaunchUsingXPCRightName rights actually exists.

Removed Xcode as the user of the XPC service to shrink the security surface area.

llvm-svn: 156424
2012-05-08 21:35:52 +00:00
Han Ming Ong 222bb03518 <rdar://problem/11408853>
We make sure that if the user cancels out of the authentication dialog to add 'com.apple.lldb.LaunchUsingXPC' rights to /etc/authorization, we don't try to do AuthorizationCopyRights.

As well, refactored a bit so that control flow is easier to read for other folks. Added more comments.

llvm-svn: 156423
2012-05-08 21:32:32 +00:00
Jason Molenda b2c7b92ae8 bump TOT version number to lldb-146 to match the checkin on the branch.
llvm-svn: 156359
2012-05-08 02:54:06 +00:00
Filipe Cabecinhas 75bc95ec28 Fixed some strncat/strlcat uses.
llvm-svn: 156264
2012-05-06 17:56:42 +00:00
Jim Ingham 10ebffa48a Don't expose the pthread_mutex_t underlying the Mutex & Mutex::Locker classes.
No one was using it and Locker(pthread_mutex_t *) immediately asserts for 
pthread_mutex_t's that don't come from a Mutex anyway.  Rather than try to make
that work, we should maintain the Mutex abstraction and not pass around the
platform implementation...

Make Mutex::Locker::Lock take a Mutex & or a Mutex *, and remove the constructor
taking a pthread_mutex_t *.  You no longer need to call Mutex::GetMutex to pass
your mutex to a Locker (you can't in fact, since I made it private.)

llvm-svn: 156221
2012-05-04 23:02:50 +00:00