Commit Graph

5578 Commits

Author SHA1 Message Date
Saleem Abdulrasool 12390847fb build: fix bleeding whitespace
llvm-svn: 203531
2014-03-11 03:08:47 +00:00
Jason Molenda 2528631f12 Minor fix for a logging message.
llvm-svn: 203512
2014-03-10 23:18:34 +00:00
Hafiz Abid Qadeer a667875fb9 Fix Mingw build error by using lower case name for windows header files.
llvm-svn: 203505
2014-03-10 22:31:39 +00:00
Ed Maste bde27d2451 Fix #if 0'd code after range-based for loop change
llvm-svn: 203487
2014-03-10 20:49:37 +00:00
Ed Maste a855309bcd Update LLDB for LLVM iterator change in r203364
What was use_iterator is now user_iterator.  Also switch to range-based
APIs, as in Clang r203365.

(This part of the change was missed in r203463)

Differential Revision: http://llvm-reviews.chandlerc.com/D3030

llvm-svn: 203475
2014-03-10 17:24:16 +00:00
Ed Maste 80e8cc6dee Update LLDB for LLVM iterator change in r203364
What was use_iterator is now user_iterator.  Also switch to range-based
APIs, as in Clang r203365.

llvm-svn: 203463
2014-03-10 14:23:10 +00:00
Jason Molenda e32cd191f0 Correctly add the QueueID to a pending block's extended thread backtrace thread.
Seed the QueueItem objects with the item_refs and addresses when they are fetched
in one batch.  If additional information is needed from the QueueItem, fetch it
lazily one pending item per function call.
<rdar://problem/16270007>, <rdar://problem/16032150> 

llvm-svn: 203449
2014-03-10 08:42:03 +00:00
Jason Molenda 37e9b5ab38 libBacktraceRecording __introspection_dispatch_queue_get_pending_items is
changing the data it returns; this change accepts either the old format or
the new format.  It doesn't yet benefit from the new format's additions -
but I need to get this checked in so we aren't rev-locked.
Also add a missing .i entry for SBQueue::GetNumRunningItems() missing from
the last checkin.
<rdar://problem/16272115> 

llvm-svn: 203421
2014-03-09 21:17:08 +00:00
Jason Molenda fe95dc95b5 SBQueue::GetNumPendingItems() should not force a fetch of the pending
items; the backing Queue object has the number of pending items
already cached.  Also, add SBQueue::GetNumRunningItems() to provide
that information.
<rdar://problem/16272016> 

llvm-svn: 203420
2014-03-09 19:41:30 +00:00
Virgile Bello 2641e383a2 Fix unwind_plan test conditions (could result in NULL memory access).
llvm-svn: 203385
2014-03-09 10:01:25 +00:00
Virgile Bello be6ddab060 PlatformWindows: Fix ObjectFile presence test conditions (could result in NULL memory access)
llvm-svn: 203384
2014-03-09 10:00:40 +00:00
Virgile Bello 89eb1baea3 Implement ObjectFilePECOFF::GetModuleSpecifications().
llvm-svn: 203383
2014-03-09 09:59:36 +00:00
Saleem Abdulrasool 9174593d09 POSIX: fix possible API misuse
memcpy cannot be passed NULL.  Ensuring that the destination pointer is non-NULL
requires checking success.  Rather than performing the success check at that
point, increasing indentation an additional level, fold it into the previous
statement.

llvm-svn: 203359
2014-03-08 20:47:12 +00:00
Saleem Abdulrasool d41fca11af POSIX: fix possible invalid API usage
strcmp cannot be passed a NULL.  Add a short-circuiting check to avoid the
possible API misuse.

llvm-svn: 203358
2014-03-08 20:47:07 +00:00
Saleem Abdulrasool 03700ded1b POSIX: add missing curly braces
It seems that the original commit missed the curly braces for the scope, always
doing the string comparision.

llvm-svn: 203357
2014-03-08 20:47:03 +00:00
Virgile Bello 2756adf377 Implement ObjectFilePECOFF::SetLoadAddress().
llvm-svn: 203350
2014-03-08 17:17:20 +00:00
Virgile Bello ffeba25652 Remove %zx in printf (only GCC supports it, not MSVC).
llvm-svn: 203349
2014-03-08 17:15:35 +00:00
Virgile Bello da0fc76e7f Add inttypes.h to SBQueue.cpp (MSVC compilation error with PRIx32).
llvm-svn: 203348
2014-03-08 16:22:55 +00:00
Jason Molenda ac605f4a3a Add API logging to the SBQueue/SBQueueItem/SBThread calls.
llvm-svn: 203330
2014-03-08 01:34:55 +00:00
Jason Molenda 0d6a1ff23d Fix a small inferior process memory leak in SystemRuntimeMacOSX::PopulatePendingItemsForQueue().
llvm-svn: 203312
2014-03-07 23:28:54 +00:00
Jason Molenda 790b4e527b Re-enable ProcessElfCore for non-FreeBSD/Linux builds; with Greg's fix in r203274
this is not installing itself for Mach-O binaries.

llvm-svn: 203310
2014-03-07 23:23:10 +00:00
Greg Clayton 289dde27a2 Remove unused code.
llvm-svn: 203292
2014-03-07 21:51:19 +00:00
Greg Clayton 9cbd3c628c Verify we have a correct ELF or Mach core file before we return a valid instace of ProcessElfCore or ProcessMachCore respectively.
llvm-svn: 203274
2014-03-07 19:24:39 +00:00
Jim Ingham 4a65fb1f25 Don't hold the ThreadList lock over calls to the GetStatus (Process or Thread) calls
or the lower levels of the Process won't be able to restart.

<rdar://problem/16244835>

llvm-svn: 203233
2014-03-07 11:20:03 +00:00
Jim Ingham a04ef756d4 If you are disabling a hardware breakpoint, use z1 not z0.
<rdar://problem/16256532>

llvm-svn: 203232
2014-03-07 11:18:02 +00:00
Jim Ingham 0ff099f10c The ThreadPlanCallFunction needs to pass its "StopOthers" to its run to address subplan.
llvm-svn: 203231
2014-03-07 11:16:37 +00:00
Ben Langmuir 9f0bac5cd1 Update for clang r203213
llvm-svn: 203217
2014-03-07 08:31:36 +00:00
Jason Molenda e4ea6f5901 Todd points out that my change to ProcessElfCore is probably
not going to key off of the ELF object file like I'd intended.
Revert my change in r203205; also revert Greg's change in
r203107 which builds ProcessElfCore on non-Linux/FreeBSD systems
for the moment until we can straighten this out.

llvm-svn: 203207
2014-03-07 06:28:29 +00:00
Jason Molenda 75fb3d70e2 Only enable ProcessElfCore if this is an ELF file. Right now this plugin is winning over
ProcessMachCore because it doesn't check the format of the file up front.  (this is only now
happening because of Greg's change in r203178 to build ProcessElfCore for non-Linux/FreeBSD
hosts).
<rdar://problem/16257533> 

llvm-svn: 203205
2014-03-07 06:15:24 +00:00
Ahmed Charles 8f926ad0d9 Replace uses of OwningPtr<T> with std::unique_ptr<T>.
llvm-svn: 203200
2014-03-07 04:45:22 +00:00
Greg Clayton f6913cd7af Allow line numbers to be shown in multi-line expressions.
llvm-svn: 203185
2014-03-07 00:53:24 +00:00
Greg Clayton 0e4b605e47 Re-enable the JITLoaderGDB and ProcessElfCore that were disabled by:
Author: ace2001ac
Date: Thu Mar  6 05:30:34 2014
New Revision: 203107

URL: http://llvm.org/viewvc/llvm-project?rev=203107&view=rev
Log:
Fix Windows build break introduced in r203035.

Add '#if defined(__linux__) || defined(__FreeBSD__)' around JITLoaderGDB
and ProcessElfCore, which are only built on Linux and FreeBSD.

Modified:
   lldb/trunk/source/lldb.cpp

Windows will need to start building all files necessary so that JITLoaderGDB and ProcessElfCore can build since they should work on all platforms.

llvm-svn: 203178
2014-03-06 23:29:58 +00:00
Ahmed Charles 943d4a6896 Fix Windows build break introduced in r203035.
Add '#if defined(__linux__) || defined(__FreeBSD__)' around JITLoaderGDB
and ProcessElfCore, which are only built on Linux and FreeBSD.

llvm-svn: 203107
2014-03-06 11:30:34 +00:00
Jason Molenda a8ff543c28 When a client asks for a queue pending item's extended backtrace,
hold a strong pointer to that extended backtrace thread in the Process
just like we do for asking a thread's extended backtrace.
Also, give extended backtrace threads an invalid ThreadIndexID number.
We'll still give them valid thread_id's.  Clients who want to know the
original thread's IndexID can call GetExtendedBacktraceOriginatingIndexID().
<rdar://problem/16126034> 

llvm-svn: 203088
2014-03-06 06:31:18 +00:00
Jim Ingham 82536bdbbf Temporarily disable the JIT loading detector till we figure out why it crashes when lldb follows through exec's...
llvm-svn: 203068
2014-03-06 03:47:34 +00:00
Greg Clayton 4b047f2378 Moved JITLoader.cpp and JITLoaderList.cpp over into "source/Target" since the header files were in "include/lldb/Target".
Also enabled the ELF Core file support in all builds since the header files have been properly separated from ProcessMonitor.

llvm-svn: 203035
2014-03-06 00:14:12 +00:00
Jason Molenda b509a414f0 Add the new JITLoader plugin files to the lldb xcode project file.
Add a cast for a size_t / PRIu64 printf formatter.

llvm-svn: 203030
2014-03-05 23:48:15 +00:00
Ed Maste 32aa12b86c Build JITLoader on FreeBSD also
llvm-svn: 202980
2014-03-05 13:57:24 +00:00
Ed Maste 29150c1731 Put "jit" in alpha order in log category list
llvm-svn: 202976
2014-03-05 13:43:23 +00:00
Andrew MacPherson 17220c1886 Add support for JIT debugging on Linux using the GDB JIT interface. Patch written with Keno Fischer.
llvm-svn: 202956
2014-03-05 10:12:43 +00:00
Jason Molenda 0ddfe7f8dc Small fix to DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule needed
with Greg's change to how we load modules in r202890.

llvm-svn: 202933
2014-03-05 03:33:01 +00:00
Steve Pucci 03904accc0 Add ProcessGDBRemote::GetAuxvData() and fix multiple-packet concatenation for binary data.
ProcessGDBRemote::GetAuxvData obtains the auxv from a remote gdbserver (via a binary-data packet), and returns the data as a DataBufferSP.

The patch includes a small fix to GDBRemoteCommunicationClient::SendPacketsAndConcatenateResponses() to support binary file format packet returns (by not assuming each binary packet is a null-terminated string when concatenating them).

llvm-svn: 202907
2014-03-04 23:18:46 +00:00
Sean Callanan 9bbf3cd3d7 Hardened against reads in the IRMemoryMap that
exceed the bounds of the backing memory.

<rdar://problem/16088322>

llvm-svn: 202899
2014-03-04 21:56:11 +00:00
Greg Clayton 34f1159bbd Fixed SBDebugger.CreateTarget("filename") and also make sure remote targets don't pickup bogus locally cached files.
<rdar://problem/16217254>
<rdar://problem/16078651>

llvm-svn: 202890
2014-03-04 21:20:23 +00:00
Todd Fiala 1251053e04 Get Linux i386 running.
This change uses a fixed known offset for the Linux i386 DR0 register.
This change also undoes the 32-bit wordsize change from r169645 that
revolved around being 32-bit/64-bit friendly in
WriteRegOperation::Execute within the Linux ProcessMonitor.cpp. I ran
all the tests on x86_64 Linux with no failures. I also ran some simple
tests with 32-bit Linux exe on x86_64 host and 32-bit linux exe on
i686 32-bit host and these worked fine.

Note (from Todd): the UserData struct in the Linux i386 register
context (only used by Linux i386 host running Linux 32-bit inferior)
is out of sync with what shows up in the sys/user.h for an 32-bit
Linux build (per an earlier change of mine to make it look more like
x86_64 host running x86 exe). I think we should (1) make i386 Linux
targets run using the same register context (and correct ones) on i386
and x86_64 linux hosts if that is possible, and (2) we could use some
tests around the register handling, particularly to verify things like
DR0 registers are in the right spots on host/target combos that we can
verify vs. known correct values.

Change by Matthew Gardiner.

llvm-svn: 202887
2014-03-04 20:46:32 +00:00
Jim Ingham 8f63266569 Fix a couple of typo's in breakpoint descriptions.
llvm-svn: 202782
2014-03-04 03:09:00 +00:00
Jason Molenda 8d08a78c30 Temporarily revert part of Greg's changes in r202738 which are causing problems with the testsuite and SBDebugger::CreateTarget().
llvm-svn: 202776
2014-03-04 02:07:24 +00:00
Greg Clayton e556a4230c Stop messages from being emitted out of order when detaching.
llvm-svn: 202756
2014-03-03 20:29:02 +00:00
Jim Ingham 8225d59b3f Only require thread scope when we're about to run the function on a thread.
llvm-svn: 202740
2014-03-03 19:16:45 +00:00
Greg Clayton 6fea17e874 "size_t" isn't always 64 bit, it is 32 bit on 32 bit systems. All printf style statements that were assuming size_t were 64 bit were changed, and they were also changed to display them as unsigned values as "size_t" isn't signed.
If you print anything with 'size_t', please cast it to "uint64_t" in the printf and use PRIu64 or PRIx64.

llvm-svn: 202738
2014-03-03 19:15:20 +00:00
Deepak Panickal 6419e98ee1 Check if the terminal is interactive and set the flags accordingly
llvm-svn: 202726
2014-03-03 15:53:37 +00:00
Deepak Panickal d582f69469 Move Windows getopt for building the DLL
llvm-svn: 202725
2014-03-03 15:52:27 +00:00
Deepak Panickal 627f4ae811 Build liblldb.dll in Windows
llvm-svn: 202724
2014-03-03 15:50:36 +00:00
Deepak Panickal 99fbc07600 Fix Windows build using portable types for formatting the log outputs
llvm-svn: 202723
2014-03-03 15:39:47 +00:00
Ed Maste 6fa32b6f54 Don't require a valid thread if expr can be evaluated statically
This seems reasonable and the BackticksWithNoTargetTestCase suggests it
should be this way.

llvm-svn: 202722
2014-03-03 15:37:30 +00:00
Jim Ingham 36a02e0655 Make sure the exe_ctx passed to ClangUserExpression::Execute has a valid thread.
<rdar://problem/15949113>

llvm-svn: 202561
2014-03-01 00:17:06 +00:00
Sean Callanan 866e91c9d4 Better error reporting when a variable can't be
read during materialization.  First of all, report
if we can't read the data for some reason.  Second,
consult the ValueObject's error and report that if
there's some problem.

<rdar://problem/16074201>

llvm-svn: 202552
2014-02-28 22:27:53 +00:00
Ed Maste 111387c47b Simplify POSIXThread register context handling
This seems a little more straightforward and is equivalent to r201457
for ELF core files.  A case for FreeBSD i386 is also added (it was
incorrectly using the 64-bit register context and corrupting mememory).

Better (user-facing) error handling is still needed.

Review: http://llvm-reviews.chandlerc.com/D2765
llvm-svn: 202549
2014-02-28 22:15:58 +00:00
Todd Fiala 620ea83926 Fixed configure-based build on OS X.
This change adds a missing include path to the
ObjC LanguageRuntime path to the MacOSX SystemRuntime
plugin's Makefile.

It also adds the panel and curses library to the liblldb
shared library linkage step.

Changes by Jevin Sweval with a minor tweak.

llvm-svn: 202547
2014-02-28 21:55:46 +00:00
Greg Clayton 3121fde41a Be sure to propagate the error back out SBTarget::Attach() when we fail to launch debugserver as root.
<rdar://problem/15669788>

llvm-svn: 202536
2014-02-28 20:47:08 +00:00
Greg Clayton ec67ab1e0c Fixed "process launch --tty" on MacOSX.
llvm-svn: 202535
2014-02-28 20:25:41 +00:00
Greg Clayton b4874f1a70 Fixed all overlapping prompt issues.
I carefully reviewed exactly how the IOHandlers interact and found places where we weren't properly controlling things. There should be no overlapping prompts and all output should now come out in a controlled fashion.

<rdar://problem/16111293>

llvm-svn: 202525
2014-02-28 18:22:24 +00:00
Ed Maste c71f60f4a1 Restore signal delivery to the inferior on FreeBSD
This was broken in the threaded inferior implementation for FreeBSD
(r196787) and caused FreeBSD to resume always with no signal.

llvm-svn: 202513
2014-02-28 17:13:39 +00:00
Ed Maste 2c2f83ef07 Fix types to eliminate compiler warnings in FreeBSD host class
llvm-svn: 202498
2014-02-28 13:46:51 +00:00
Jim Ingham 286fb1ef32 Plumb the EvaluateExpressionOptions::{Set,Get}StopOthers through the SB API, and make it work in RunThreadPlan.
Also remove SetStopOthers from the ThreadPlanCallFunction, because if the value you have doesn't match what is
in the EvaluateExpressionOptions the plan was passed when created it won't work correctly.

llvm-svn: 202464
2014-02-28 02:52:06 +00:00
Sylvestre Ledru 451ca2924c remove useless declarations found thanks to scan-build
llvm-svn: 202440
2014-02-27 22:46:23 +00:00
Todd Fiala 4507f06aaa Fix linux x86 debugging on a linux x86 host (32-bit on 32-bit).
This change fixes up issues with specifying the size of the i386
register infos for FPU registers.  The bug was that for the i386
register context, the size of the FPU registers were still being
computed based on the x86_64 FXSAVE structure.

This change permits the FPR_SIZE macro to optionally be defined
outside of RegisterInfos_i386.h, which RegisterContextLinux_i386.cpp
does properly. It redefines the FPR_i386 structure with all the
accessible parts that RegisterInfos_i386.h wants to see, which we had
not done before when we made the overall size of the structure
properly sized a recently.

This change also modifies POSIXThread to create a
RegisterContextLinux_i386 only when the host is 32-bit; otherwise, it
uses the RegisterContextLinux_x86_64, which works properly for 32-bit
and 64-bit inferiors on a 64-bit host.

I tested this debugging a Linux x86 exe on an x86 host (Ubuntu 13.10
x86), and debugging a Linux x86 exe and a Linux x86-64 exe on an
x86-64 host (Ubuntu 12.04 LTS).  Those cases all worked.

Thanks to Matthew Gardiner who discoverd may key insights into
tracking down the issue. The motivation for this change and some of
the code originates from him via this thread:

http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140224/010554.html

llvm-svn: 202428
2014-02-27 20:46:12 +00:00
Jim Ingham d6efa2a977 Check call to fgetc for EINTR.
<rdar://problem/16140277>

llvm-svn: 202426
2014-02-27 19:48:13 +00:00
Greg Clayton 1681092f96 Remove an assertion that was being hit due to slow DNS name lookups on MacOSX for "localhost".
Changed all "localhost" to "127.0.0.1" to prevent potentially long name lookups.

<rdar://problem/16154630>

llvm-svn: 202424
2014-02-27 19:38:18 +00:00
Greg Clayton fdbad6d5d8 Improve logging a bit by printing the exception or signal type description.
llvm-svn: 202423
2014-02-27 19:35:12 +00:00
Todd Fiala 955fe6f6ed Fix build break due to signature change on ASTContext' setExternalSource parameter.
This change converts points to clang::ExternalASTSource from llvm::OwningPtr<> to
llvm::IntrusiveRefCntPtr<>.

llvm-svn: 202411
2014-02-27 17:18:23 +00:00
Sylvestre Ledru 7ba631f651 update the declaration from llvm::OwningPtr to llvm::IntrusiveRefCntPtr to match the clang update (r202346) on ASTContext
llvm-svn: 202376
2014-02-27 10:46:57 +00:00
Greg Clayton 19e1135108 A better long term fix for stopping the process when it is running by writing to the pipe that was used for cancel.
We now write a 'q' to indicate to exit the IOHandlerProcessSTDIO::Run(), and a 'i' to interrupt the process. This should make this code safer to use in a signal handler function.

llvm-svn: 202311
2014-02-26 22:47:33 +00:00
Jason Molenda d84f606deb Small fix for i386 extended backtraces; wasn't skipping a
4-byte reserved area when reading the libBacktraceRecording API results.
Also, add a little logging about queues being created.
<rdar://problem/16127752> 

llvm-svn: 202306
2014-02-26 22:27:09 +00:00
Todd Fiala 994f63dc00 Fix x86 32-bit register context definition to build properly on 32 and 64-bit hosts.
This fix changes thee x86 32-bit floating point register area to be
the proper size independent of the host platform.

Note as of this change list, this register context is not yet used
since selecting it exposes issues with watchpoint assertions.

Change by Matthew Gardiner.

llvm-svn: 202285
2014-02-26 18:51:03 +00:00
Ed Maste 0121e43b5b Add libexecinfo for backtrace() on FreeBSD
llvm-svn: 202284
2014-02-26 18:21:42 +00:00
Todd Fiala 86dccb39c2 Fixed lldb cmake build to include missing libpanel/libncurses.
These libraries became necessary recently to link properly.
I think they are needed everywhere non-Windows, but if they
end up breaking on a given platform, we can conditionalize this
further.

llvm-svn: 202282
2014-02-26 17:44:00 +00:00
Sylvestre Ledru 91d2101722 remove useless declaration
llvm-svn: 202281
2014-02-26 17:28:21 +00:00
Todd Fiala 9bb71b73d9 Suppress python readline module under Linux to fix a seg fault.
Bug fix for pr18841:
http://llvm.org/bugs/show_bug.cgi?id=18841

This change creates a stub Python readline.so module that does almost
nothing. Its whole purpose is to prevent Python from loading the real
module, something it does during the embedded Python interpreter's
initialization sequence (and way before lldb ever requests it within
embedded_interpreter.py).

On Ubuntu 12.04 and 13.10 x86_64, and in the Python 2.7.6 tree, the
stock Python readline module links against the GNU readline library.
This appears to be the case on all Pythons except where __APPLE__ is
defined. LLDB now requires linking against the libedit library.
Something about having both libedit.so and libreadline.so linked into
the same process space is causing the Python readline.so to trigger a
NULL memory access. I have put in a separate patch to python.org.

This suppression of embedded interpreter readline support can be
removed if at least any one of the following happens:

1. The stock python distribution accepts a patch similar to what I
submitted to Python 2.7.6's Modules/readline.c file.

2. The stock python distribution implements Modules/readline.c in
terms of libedit's readline compatibility mode (i.e. essentially
compiles it the way __APPLE__ compiles that module) under Linux.

3. a clean-room implementation of the python readline module is
implemented against libedit (either readline compatibility mode or
native libedit). This could be implemented within the readline.cpp
file that this change introduces. It cannot be a fork of python's
readline.c module due to llvm licensing.

The net effect of this change on Linux is that the embedded python's
readline support will not exist.

llvm-svn: 202243
2014-02-26 07:39:20 +00:00
Enrico Granata c6f0a6ac27 <rdar://problem/15593026>
Fix the algorithm used to detect a loop in a std::list

llvm-svn: 202205
2014-02-25 23:34:40 +00:00
Ed Maste 96e51b890b Reapply r184270 by Jim Ingham to avoid abort on FreeBSD
Don't actually Halt in the Interrupt handler for the Process, just
  send an AsyncInterrupt.  That's actually not async-signal-clean, but
  it is a lot safer than Halt...

The underlying problem is actually a nested pthread_cond_wait from the
signal handler.  Note frames 4, 13, 18 in the backtrace of the aborting
path below.

    frame #1: 0x000000080715fff9 libc.so.7`abort + 73 at abort.c:65
    frame #2: 0x0000000805d20fda libthr.so.3`_thread_exit(fname=<unavailable>, lineno=<unavailable>, msg=<unavailable>) + 58 at thr_exit.c:182
    frame #3: 0x0000000805d1fdc8 libthr.so.3`cond_wait_common [inlined] cond_wait_user(mp=<unavailable>, abstime=<unavailable>, cancel=<unavailable>) + 936 at thr_cond.c:223
    frame #4: 0x0000000805d1fd5b libthr.so.3`cond_wait_common(cond=<unavailable>, mutex=<unavailable>, abstime=<unavailable>, cancel=<unavailable>) + 827 at thr_cond.c:311
    frame #5: 0x00000008013450b5 liblldb.so.3.5`lldb_private::Condition::Wait(lldb_private::Mutex&, lldb_private::TimeValue const*, bool*) + 117
    frame #6: 0x00000008013411e8 liblldb.so.3.5`lldb_private::Predicate<bool>::WaitForValueEqualTo(bool, lldb_private::TimeValue const*, bool*) + 200
    frame #7: 0x00000008013eb34c liblldb.so.3.5`lldb_private::Listener::WaitForEventsInternal(lldb_private::TimeValue const*, lldb_private::Broadcaster*, lldb_private::ConstString const*, unsigned int, unsigned int, std::__1::shared_ptr<lldb_private::Event>&) + 876
    frame #8: 0x00000008013eb751 liblldb.so.3.5`lldb_private::Listener::WaitForEvent(lldb_private::TimeValue const*, std::__1::shared_ptr<lldb_private::Event>&) + 81
    frame #9: 0x00000008017c5bcf liblldb.so.3.5`lldb_private::Process::Halt(bool) + 783
    frame #10: 0x00000008017def3a liblldb.so.3.5`IOHandlerProcessSTDIO::Interrupt() + 74
    frame #11: 0x00000008013823d3 liblldb.so.3.5`lldb_private::Debugger::DispatchInputInterrupt() + 115
    frame #12: 0x00000008011d69c5 liblldb.so.3.5`lldb::SBDebugger::DispatchInputInterrupt() + 69
    frame #13: 0x000000000040b254 lldb`sigint_handler(int) + 68
    frame #14: 0x0000000805d1b3da libthr.so.3`handle_signal(actp=<unavailable>, sig=<unavailable>, info=<unavailable>, ucp=<unavailable>) + 234 at thr_sig.c:240
    frame #15: 0x0000000805d1afc2 libthr.so.3`thr_sighandler(sig=<unavailable>, info=<unavailable>, _ucp=<unavailable>) + 306 at thr_sig.c:183
    frame #16: 0x00007ffffffff003
    frame #17: 0x0000000805d1fc7e libthr.so.3`cond_wait_common [inlined] cond_wait_user(mp=<unavailable>, abstime=<unavailable>, cancel=1) + 239 at thr_cond.c:255
    frame #18: 0x0000000805d1fb8f libthr.so.3`cond_wait_common(cond=<unavailable>, mutex=<unavailable>, abstime=0x0000000000000000, cancel=1) + 367 at thr_cond.c:311
    frame #19: 0x00000008013450d2 liblldb.so.3.5`lldb_private::Condition::Wait(lldb_private::Mutex&, lldb_private::TimeValue const*, bool*) + 146

llvm-svn: 202154
2014-02-25 14:20:14 +00:00
Greg Clayton e68f5d6b69 Fixed the command line LLDB so that "CTRL+C" will interrupt a running process again.
llvm-svn: 202086
2014-02-24 22:50:57 +00:00
Jim Ingham 40083a4326 Don’t process the stop reply packet as a generic signal if we already figured out what it was from other data in the packet.
llvm-svn: 202066
2014-02-24 19:49:46 +00:00
Steve Pucci 3c5d3339be Fix handling of gdbserver binary packets with escape characters.
We were not properly handling the escape character 0x7d ('}') in responses
from gdbserver which used the binary protocol.

llvm-svn: 202062
2014-02-24 19:07:29 +00:00
Greg Clayton 039697513e LLDB now handles DW_TAG_unspecified_parameters nested inside function prototypes and we now mark the function prototypes as being variadic.
<rdar://problem/16149526> 

llvm-svn: 202061
2014-02-24 18:53:11 +00:00
Ed Maste c099c958bc Fix ptrace log on i386 and include return value
Patch by Matthew Gardiner

llvm-svn: 202036
2014-02-24 14:07:45 +00:00
Deepak Panickal b98a2bb7a8 Patch for fixing the handling of hardware breakpoints.
Differential Revision: http://llvm-reviews.chandlerc.com/D2826

llvm-svn: 202028
2014-02-24 11:50:46 +00:00
Jim Ingham eac0aa47b4 Oops, probably ought to turn on that fix...
llvm-svn: 201897
2014-02-21 22:36:11 +00:00
Jim Ingham 9d67cc59c4 We have to call waitpid on the lldb side for Mac OS X (even though we've successfully called it
on the debugserver side) when we kill a process or it leaves a zombie around.

llvm-svn: 201896
2014-02-21 22:35:29 +00:00
Greg Clayton 700e5085eb Improved the GDBRemoteCommunicationClient::TestPacketSpeed() function so it tests how long it takes to send a 4MB buffer from the REMOTE GDB server to LLDB.
llvm-svn: 201875
2014-02-21 19:11:28 +00:00
Greg Clayton b922aa9efc Remove the packet speed lines that were "#if 0"'ed out.
llvm-svn: 201873
2014-02-21 19:07:27 +00:00
Greg Clayton 8fe3d4779d Don't crash when we build with python enabled, yet we don't link in the lldb::SB* API layer.
Previously the lldb-platform and lldb-gdbserver would crash.

llvm-svn: 201872
2014-02-21 19:06:44 +00:00
Sylvestre Ledru f561a01a12 remove dead code + simplify a little
llvm-svn: 201865
2014-02-21 18:08:09 +00:00
Jason Molenda 31d7ad4ecf Add a new idea of a "fallback" UnwindPlan to the RegisterContextLLDB
class.  If we try to unwind a stack frame to find a caller stack
frame, and we fail to get a valid-looking frame, AND if the UnwindPlan
we used is an assembly-inspection based UnwindPlan, then we should 
throw away the assembly-inspection UnwindPlan and try unwinding with 
the architectural default UnwindPlan.  

This code path won't be taken if eh_frame unwind instructions are available -
lldb will always prefer those once it's off the zeroth frame.

The problem I'm trying to fix here is the class of unwind failures that
happen when we have hand-written assembly on the stack, with no eh_frame,
and lldb's assembly parser fails to understand the assembly.  People usually
write their hand-written assembly to follow the frame-pointer-preserving
conventions of the platform so the architectural default UnwindPlan will 
often work.  We won't have the spill location for most of the non-volatile
registers if we fall back to this, but it's better than stopping the unwind
prematurely.

This is a bit of a tricky change that I believe is correct, but if we get
unwinds that go of into the weeds / unwind bogus frames at the end of the
stack, I'll need to revisit it.

<rdar://problem/16099440> 

llvm-svn: 201839
2014-02-21 05:20:25 +00:00
Jim Ingham 90331d5cf4 There’s no need to call posix_spawnp_setbinpref_np when we are launching in the shell. That only sets the architecture of the shell, we use “arch —arch” to actually pick the binary we actually want to launch’s architecture.
<rdar://problem/16103187>

llvm-svn: 201831
2014-02-21 01:25:21 +00:00
Hafiz Abid Qadeer 673b4a3fd1 Improve the handling of stop-reply packet when it does not contain
thread information.

llvm-svn: 201773
2014-02-20 10:23:20 +00:00
Juergen Ributzka a864ce741e Revert "Track Clang virtualFileSystem change (r201618)"
This reverts commit r201671, because the clang changes have been reverted.

llvm-svn: 201759
2014-02-20 06:49:12 +00:00
Jim Ingham ff26163768 Don't have both lldb and debugserver call waitpid on the target process. This sets up a race condition,
and if lldb wins, then debugserver won't get the correct error status to lldb.

<rdar://problem/16030008>

llvm-svn: 201744
2014-02-20 00:52:37 +00:00
Sean Callanan 92cdbc8f2d Emit a warning diagnostic if a symbol was promoted
to a variable.  This helps people figure out what
happened if they tried to do something to the variable
and it didn't work because we gave it the default type
of void*.

llvm-svn: 201737
2014-02-19 23:37:25 +00:00
Ed Maste dc97e23b02 Disable breakpoint sites upon detach on FreeBSD
llvm.org/pr18894

llvm-svn: 201724
2014-02-19 22:12:57 +00:00
Enrico Granata 8a2a0dfba5 Restore the ability of SBFrame::FindValue() to look for file global variables
This should clean up the new test failures caused by r201614

llvm-svn: 201710
2014-02-19 19:35:13 +00:00
Ed Maste a4be2c5dcd FreeBSD hardware watchpoint implementation
Implement x86_64 debug register read/write in support of hardware
watchpoints. Hoist LinuxThread::TraceNotify code back into
POSIXThread::TraceNotify()

Patch by John Wolfe.

We still need to rework this later to avoid the #ifdef FreeBSD.

llvm-reviews.chandlerc.com/D2572
llvm.org/pr16706

llvm-svn: 201706
2014-02-19 18:34:06 +00:00
Ed Maste 954e4b9259 Track Clang virtualFileSystem change (r201618)
Clang now requires calling CompilerInstance::createVirtualFileSystem
before CompilerInstance::createFileManager.

llvm-svn: 201671
2014-02-19 13:00:08 +00:00
Deepak Panickal 6d3df420d2 Initial patch for supporting Hexagon DSP
llvm-svn: 201665
2014-02-19 11:16:46 +00:00
Jason Molenda 9c37cbdb86 Re-apply r201292. We're not going to enforce proper stack frame alignment on i386/x86_64
because there are too many trap handlers that will have an improperly aligned caller sp 
and this will cause the unwinder to stop too early.  

llvm-svn: 201637
2014-02-19 03:42:19 +00:00
Enrico Granata bdab3dee8f <rdar://problem/15906684>
The way in which we were determining whether a python module had already been imported in the current session stopped working due to the IOHandler changes
As a result, importing in a new debug session a module which had been imported in a previous session did not work
This commit restores that functionality by checking for the module's presence in the session dictionary (which should be more correct anyway)

llvm-svn: 201623
2014-02-19 01:45:22 +00:00
Enrico Granata 08a04327a9 <rdar://problem/15960553>
Fix a bug where calling SBFrame::FindValue() would cause a copy of all variables in the block to be inserted in the frame's variable list, regardless of whether those same variables were there or not - which means one could end up with a frame with lots of duplicate copies of the same variables

llvm-svn: 201614
2014-02-18 23:48:11 +00:00
Jason Molenda 7b535d5453 Also recognize interrupt as a possible trap handler name.
llvm-svn: 201611
2014-02-18 22:48:27 +00:00
Jason Molenda 33489c1678 Add two additional trap handler names for PlatformDarwinKernel.
<rdar://problem/15246793> 

llvm-svn: 201609
2014-02-18 22:35:38 +00:00
Ed Maste 330fd535f8 elf-core: support 32- and 64-bit x86 registers
This way the same RegisterContext class can support i386 and
amd64/x86_64 core files.

With some further refinement we should be able to merge all of the
processor-specific RegisterContextPOSIX_* classes into a single shared
one.

llvm-svn: 201577
2014-02-18 15:12:35 +00:00
Sean Callanan 11e32d3db4 Properly report when a struct is anonymous.
<rdar://problem/16071066>

llvm-svn: 201539
2014-02-18 00:31:38 +00:00
Deepak Panickal ff4ac8a6e7 Replaced custom variable arguments to standard library for correcting 64 bit Windows build
llvm-svn: 201523
2014-02-17 17:52:22 +00:00
Deepak Panickal 94667bcf70 Fix Windows build, broken by the inclusion of sys/ioctl.h and isatty()
llvm-svn: 201522
2014-02-17 17:43:39 +00:00
Deepak Panickal 0db9d32ff7 Fix the LLDB prompt for older Editline versions, specifically running on Ubuntu 12.04
llvm-svn: 201521
2014-02-17 17:42:25 +00:00
Deepak Panickal f275d09a34 Remove nativecodegen as it forces the native target libraries to be linked in regardless of whether the target was specified in LLVM_TARGETS_TO_BUILD
llvm-svn: 201519
2014-02-17 17:39:27 +00:00
Ed Maste ff8e5f2587 elf-core: Plug latent memory leak
ProcessElfCore::ParseThreadContextsFromNoteSegment was leaking
ThreadData for each ELF note found in core file.  We now allocate it
only once and use std::unique_ptr to ensure it is always being freed.

While at it make ParseFreeBSDThrMisc and ParseFreeBSDPrStatus take
ThreadData by reference, rather than pointer, since those arguments are
not optional.

Patch by Piotr Rak.

http://llvm-reviews.chandlerc.com/D2813

llvm-svn: 201473
2014-02-16 04:01:54 +00:00
Ed Maste 8b5e46a159 Simplify core file register context handling
This seems like a more straightforward approach for instantiating the
appropriate RegisterContext* class, made possible by Michael Sartain's
cleanup of the POSIX RegisterContext class hierarchy in r190647.

Better (user-facing) error handling is still needed.

llvm-svn: 201457
2014-02-15 02:31:22 +00:00
Enrico Granata 465f4bc287 <rdar://problem/16006373>
Revert the spirit of r199857 - a convincing case can be made that overriding a summary's format markers behind its back is not the right thing to do
This commit reverts the behavior of the code to the previous model, and changes the test case to validate the opposite of what it was validating before

llvm-svn: 201455
2014-02-15 01:24:44 +00:00
Jason Molenda 2a6c252df2 Add some additional logging to the Mac OS X SystemRuntime. Fix a bug where lldb could free an inferior's vm_page.
llvm-svn: 201447
2014-02-15 00:20:40 +00:00
Ed Maste 92b1f7e4f9 Allow FreeBSD/i386 core files to be loaded
llvm-svn: 201435
2014-02-14 21:57:27 +00:00
Ed Maste 8b4a283234 Correct offset calculation for FreeBSD i386 core NT_PRSTATUS
llvm-svn: 201434
2014-02-14 21:29:05 +00:00
Jason Molenda 026f389117 Fix minor build warning on Mac OS X x86_64.
llvm-svn: 201387
2014-02-14 05:16:17 +00:00
Jason Molenda a4bea72ee7 Add a new target setting, trap-handler-names, where a user can
specify a list of functions which should be treated as trap handlers.
This will be primarily useful to people working in non-user-level
process debugging - kernels and other standalone environments.
For most people, the trap handler functions provided by the Platform
plugin will be sufficient.

<rdar://problem/15835846>, <rdar://problem/15982682> 

llvm-svn: 201386
2014-02-14 05:06:49 +00:00
Greg Clayton e98008cc58 Fixed deadlocks that could occur when using python for breakpoints, operating system plugins, and other async python usage.
<rdar://problem/16054348>
<rdar://problem/16040833>

llvm-svn: 201372
2014-02-13 23:34:38 +00:00
Jason Molenda abba74b4ee Revert r201292 which relaxed the stack frame alignment requirements.
This was primarily working around problems where we weren't able
to identify trap handlers for different environments -- but instead,
I'm working to make it easier to specify those trap handler function
names.

llvm-svn: 201366
2014-02-13 23:29:36 +00:00
Jason Molenda 2094dbf4e7 Change the way the m_trap_handlers Platform base class ivar is initialized;
add a new pure virtual CalculateTrapHandlerSymbolNames() that Platform 
subclasses must implement which fills in the function name list with any
trap handlers that are expected on that platform.

llvm-svn: 201364
2014-02-13 23:11:45 +00:00
Ed Maste 800e12ac81 Avoid undesired variable shadowing
Michael Sartain refactored RegisterContextPOSIX_* in r192332, and I must
have missed the now-shadowed variable when I rebased the FreeBSD MIPS64
register context after that.

llvm-svn: 201334
2014-02-13 15:12:57 +00:00
Jason Molenda 6223db2778 The Platform base class now maintains a list of trap handlers
aka asynchronous signal handlers, which subclasses should fill
in as appropriate.  For most Unix user process environments,
the one entry in this list is _sigtramp.  For bare-board and
kernel environments, there will be different sets of trap 
handlers.

The unwinder needs to know when a frame is a trap handler 
because the rules it enforces for the frame "above" the
trap handler is different from most middle-of-the-stack frames.

<rdar://problem/15835846> 

llvm-svn: 201300
2014-02-13 07:11:08 +00:00
Jason Molenda 9098f1d3d9 Change the ABI CallFrameAddressIsValid methods for i386 and x86_64.
They were enforcing 16-byte alignment on stack frames for Darwin x86 programs.
But we've found that trap handlers typically don't have the stack pointer
aligned correctly when a trap happens and lldb wasn't backtracing all
the way through.  This method is only used as a safety guard to prevent
lldb's unwinder from using a bogus address as a stack frame - we'll still
enforce word-size alignment on stack frames so that should be fine.

Also rolled back akaylor's changes from August 2013 in r188952 which changed
the i386 ABI plugin to relax the CallFrameAddressIsValid offsets for non-Darwin
targets where only 4-byte alignment is enforced.  Now Darwin is the same as
those environments.

<rdar://problem/15982682> 

llvm-svn: 201292
2014-02-13 04:19:32 +00:00
Greg Clayton 7a1bd0baa1 Add support for DW_OP_piece and DW_OP_bit_piece.
llvm-svn: 201268
2014-02-12 23:16:19 +00:00
Todd Fiala 729c001ec3 Fix elf core file VMA-contiguous region collapsing.
Elf core files were collapsing core segments when the virtual memory
addresses were contiguous without checking if the core-file-backed
memory region was the same size as the segment's VMA region. Without
this extra check, any time regions were collapsed but the core-backed
region was smaller (and thus had a zero-filled hole at the end), the
collapse operation would break VMA to core file lookups for subsequent
collapsed regions.

This change fixes the following bug:
http://llvm.org/bugs/show_bug.cgi?id=18769

llvm-svn: 201214
2014-02-12 07:29:44 +00:00
Enrico Granata 67530b694c Avoid leaking namebuf in case of an early exit
llvm-svn: 201206
2014-02-12 03:37:33 +00:00
Filipe Cabecinhas 89372e99ba Fix cmake compilation on Mac OS X.
llvm-svn: 201200
2014-02-12 00:57:20 +00:00
Greg Clayton b6892508a6 When a multiline expression produces output, the multi-line help message is printed twice.
<rdar://problem/16031890> 

llvm-svn: 201171
2014-02-11 19:11:11 +00:00
Jason Molenda da276f9013 Adjust the calls to __introspection_dispatch_thread_get_item_info to
use a system-wide unique thread ID instead of a pthread_t to identify
the thread we want debug info for.  Also, free some more memory regions
that needed to be freed.

llvm-svn: 201117
2014-02-11 00:36:18 +00:00
Han Ming Ong a6cad47207 <rdar://problem/15996848>
Made sure we pass along the file action paths for stdin/stdout/stderr to the XPC service.
[Reviewed by Greg Clayton]

llvm-svn: 201103
2014-02-10 19:23:28 +00:00
Saleem Abdulrasool 78c135942d Host: unconstify editline paramters
Although the interface to el_push should be a constant parameter (as it is on
Darwin), certain Linux distributions currently ship a header which does not
provide proper const correctness.  This causes compilation failures on Linux.
Strip the constness on the parameter, which whilst incorrect, is mostly
harmless.  The parameter will not be changed by the interface and so it is
acceptable to do this.  When distributions have updated to a more correct
declaration, it would be nice to revert this change.

Addresses PR18784.

llvm-svn: 201092
2014-02-10 16:10:42 +00:00
Jean-Daniel Dupas 3c6774a172 hostname is guarantee to never be null in this branch.
llvm-svn: 201027
2014-02-08 20:29:40 +00:00
Jean-Daniel Dupas ef37711f85 Fix null dereference if address is NULL.
llvm-svn: 201026
2014-02-08 20:22:05 +00:00
Sylvestre Ledru bfc57f8370 Only set EL_PROMPT_ESC when existing - fix typo
llvm-svn: 201024
2014-02-08 13:26:24 +00:00
Sylvestre Ledru 54e7a77690 Only set EL_PROMPT_ESC when existing
llvm-svn: 201023
2014-02-08 13:25:47 +00:00
Greg Clayton 751caf65c2 Modified ObjectFile::SetLoadAddress() to now be:
ObjectFile::SetLoadAddress (Target &target,
                            lldb::addr_t value,
                            bool value_is_offset);

Now "value" is a slide if "value_is_offset" is true, and "value" is an image base address otherwise. All previous usage of this API was using slides.

Updated the ObjectFileELF and ObjectFileMachO SetLoadAddress methods to do the right thing.

Also updated the ObjectFileMachO::SetLoadAddress() function to not load __LINKEDIT when it isn't needed and to only load sections that belong to the executable object file.

llvm-svn: 201003
2014-02-07 22:54:47 +00:00
Greg Clayton 9b5442aed9 Now that the command interpreter runs in a separate thread in Xcode, we need to lock the target API lock instead of trying to lock it.
What was happening was:
1 - Xcode ran and stopped and was doing work on thread 2
2 - Users would type something in Xcode console on thread 1
3 - thread 3 would be running command interpreter thread and try to execute command but get "failed to get API lock" error for any command that wanted the target API lock (like "expression")

<rdar://problem/15775016>

llvm-svn: 200997
2014-02-07 22:31:20 +00:00
Enrico Granata 41c440fbfe <rdar://problem/12857181>
When a user says

type formatter add ... unsigned int

he most probably means to deal with the "unsigned int" type. However, given how the LLDB command parser works, that command will try to add the formatter to the TWO types 'unsigned' AND 'int'

Since this is unlikely to be what the user wants, warn about it, and suggest they can use quotes to override the debugger's understanding

llvm-svn: 200996
2014-02-07 22:12:55 +00:00
Sean Callanan 3d6ae767a0 When writing data back into a register, accept
values whose size differs from the register's
size.

llvm-svn: 200991
2014-02-07 20:42:44 +00:00
Greg Clayton 4c484ecb31 Fix a bug where we will crash if we have a class "B" that is contained inside a class "A" in the DWARF where "A" is a forward declaration.
<rdar://problem/14673945>
<rdar://problem/15682781>

llvm-svn: 200985
2014-02-07 19:21:56 +00:00
Enrico Granata 1d736c31d6 rdar://15648942
Provide a filter for libc++ std::atomic<T>
This just hides some implementation clutter and promotes the actual content to only child status

llvm-svn: 200984
2014-02-07 19:21:09 +00:00
Sean Callanan 7c435a5ede Lock the JIT before using it.
<rdar://problem/15958296>

llvm-svn: 200951
2014-02-06 22:25:20 +00:00
Sean Callanan d6be7085c2 Removed spurious lookup of the $__lldb_expr
selector when compiling an expression in an
Objective-C context.

<rdar://problem/15797390>

llvm-svn: 200950
2014-02-06 22:24:11 +00:00
Greg Clayton 7524e090e9 Implement ObjectFileMachO::SetLoadAddress().
llvm-svn: 200943
2014-02-06 20:10:16 +00:00
Steve Pucci 9e02dacddf Factor some methods that were in DynamicLoaderPOSIXDYLD.
Move some code that was in DynamicLoaderPOSIXDLYD into the
base class DynamicLoader.  In the case of UpdateLoadedSections(),
the test to see whether a file is loadable (its address is zero)
is not generally applicable so that test is changed to a more
universally applicable check for the SHF_ALLOC flag on the section.

Also make it explicit that the reading of the module_id in
DynamicLoaderPOSIXDYLD::GetThreadLocalData() is using a hardcoded
size (of module_id) of 4, which might not be appropriate on
big-endian 64-bit systems, leaving a FIXME comment in place.

llvm-svn: 200939
2014-02-06 19:02:19 +00:00
Greg Clayton 8ee673141b Don't print out "script" results twice.
We now properly detect when a result object has an immediate output stream and don't echo the results a second time.

<rdar://problem/15954906>

llvm-svn: 200882
2014-02-05 21:46:20 +00:00
Greg Clayton e4e462c42c Fixed output to display correctly for "command source" by fixing the correct flags being set.
Also emit the "Executing commands" message so it properly only comes out when desired and so it comes out in the right place.

<rdar://problem/15992208>

llvm-svn: 200875
2014-02-05 21:03:22 +00:00
Greg Clayton 340b0309b5 Fixed an issue where "command source" would not do the right thing:
- empty lines in init files would repeat previous command and cause errors to be displayed
- all options to control showing the command, its output, if it should stop on error or continue, weren't being obeyed.

llvm-svn: 200860
2014-02-05 17:57:57 +00:00
Jason Molenda 2fd83355a8 Change the Mac OS X SystemRuntime plugin from using the placeholder
libldi library to collect extended backtrace information; switch
to the libBacktraceRecording library and its APIs.  Complete the
work of adding QueueItems to Queues and allow for the QueueItems
to be interrogated about their extended backtraces in turn.

There's still cleanup and documentation to do on this code but the
code is functional and I it's a good time to get the work-in-progress 
checked in.  
<rdar://problem/15314027> 

llvm-svn: 200822
2014-02-05 05:44:54 +00:00
Enrico Granata 95a9df2c82 <rdar://problem/15936507>
ScriptInterpreterPython caches the lldb.embedded_interpreter module, and since it caches it in a refcounting-safe PythonObject, the refcount will appropriately go down 1 every time a ScriptInterpreterPython is deallocated
However, we were only importing the module once - in InitializePrivate(). In a handful of interpreter creations, the refcount on the run_one_line function would end up at 0, causing LLDB to crash
This fixes it by also importing the module for every interpreter, which ensures correct refcounting

llvm-svn: 200816
2014-02-05 03:19:01 +00:00
Ed Maste 441a1beaba If setgid fails for any reason, exit lldb.
This is SVN r191618 by Sylvestre Ledru applied to the FreeBSD
ProcessMonitor.

llvm-svn: 200791
2014-02-04 19:37:15 +00:00
Greg Clayton 0f86e6e711 LLDB exits the command interpreter and thus LLDB when using a pty or file as the input handle and a blank line is entered (like when running under emacs). This is now fixed.
<rdar://problem/15976187>

llvm-svn: 200790
2014-02-04 19:25:11 +00:00
Ed Maste aacfe09867 Avoid accessing an element of an empty vector in a log message
llvm-svn: 200784
2014-02-04 18:51:11 +00:00
Jean-Daniel Dupas 36b5eea258 Fix UnwindAssembly memory leak by defining and using a shared UnwindAssemblySP type.
llvm-svn: 200725
2014-02-03 23:49:47 +00:00
Enrico Granata d8e4584cbd <rdar://problem/15154623>
Move a couple formatters from category AppKit to CoreFoundation

llvm-svn: 200713
2014-02-03 19:46:31 +00:00
Ed Maste 10c82017b6 Update header comment to match filename
llvm-svn: 200647
2014-02-02 19:25:11 +00:00
Jean-Daniel Dupas 59999a32b3 Remove commented includes
llvm-svn: 200637
2014-02-02 14:06:07 +00:00
Todd Fiala 31cb474e2d Fix for failure to unwind Linux stack frames with call in final position.
Fixes http://llvm.org/bugs/show_bug.cgi?id=18656.

Note this exposes a failure on Linux of
TestInferiorAssert.test_inferior_asserting_disassemble, similar to how
it fails on FreeBSD. I'll file a bug for this next. We're now getting
another frame beyond where we used to prior to this fix, so the fix is
exposing failures in previosly not-reachable frames.

Much thanks to Jason Molenda, who had much to do with helping figure
out where unwinding was breaking.

llvm-svn: 200600
2014-02-01 00:48:34 +00:00
Deepak Panickal 914b8d989b Fixing the Windows build for the changes brought in from the iohandler merge.
llvm-svn: 200565
2014-01-31 18:48:46 +00:00
Jim Ingham 4046a30c73 Check curr_thread is not empty before accessing it.
<rdar://problem/15953271>

llvm-svn: 200504
2014-01-31 01:01:23 +00:00
Greg Clayton 10c0ef7b8a Pressing ^D in a non-empty input terminates LLDB. This was due to the fact that we stack more than one editline instance on top of each other and we still expect CTRL+D to exit the editline instance, but it should only do so when the line is empty. Otherwise it should (and does) delete the character at the cursor.
<rdar://problem/15944703>

llvm-svn: 200489
2014-01-30 20:59:18 +00:00
Todd Fiala 3452df6723 Fixed b18655: cleaned up script interpreter file reference handling.
This change addresses shutdown crashes in the python lldb module when
the script interpreter was hanging on to saved file references after
leaving a session.  It also gets rid of extra references to the
stdin/stdout/stderr python file objects that are created when entering
the session.

This change also moves the bundled pyexpect 2.4 library to the front
of the python library path so that a python distribution default
pyexpect (2.3 in Ubuntu 12.04) is not picked up first.

llvm-svn: 200486
2014-01-30 20:19:22 +00:00
Greg Clayton 590426029b Missing files for previous checkin that fixed: "script help (lldb.SBThread)" output stops after 2048 bytes are printed.
<rdar://problem/15942977>

llvm-svn: 200478
2014-01-30 18:52:57 +00:00
Greg Clayton 31480e64ee "script help (lldb.SBThread)" output stops before all output is displayed. Fixed now.
<rdar://problem/15942977>

llvm-svn: 200476
2014-01-30 18:17:31 +00:00
Greg Clayton 99dcbe1e50 Don't crash when trying to auto complete 'breakpoint set -n "_'
<rdar://problem/15921898>

llvm-svn: 200402
2014-01-29 18:25:07 +00:00
Greg Clayton 5fdb09bb76 Show help dialog the first time the "gui" is run to help users find their way.
llvm-svn: 200326
2014-01-28 18:41:35 +00:00
Greg Clayton c809cbcf4d Fixed a crasher when handling process events that is due to a translation from the public API to the private API.
llvm-svn: 200267
2014-01-28 00:36:31 +00:00
Todd Fiala b8b49ec92b Modified GDBProcessCommunicationServer to launch via the platform.
GDBProcessCommunicationServer now optionally takes a PlatformSP that
defaults to the default platform for the host.
GDBProcessCommunicationServer::LaunchProcess () now uses the platform
to launch the process.

lldb-gdbserver now takes an optional --platform={platform_plugin_name}
or -p {platform_plugin_name} command line option. If no platform is
specified, the default platform for the host is used; otherwise, if
the platform_plugin_name matches a registered platform plugin or
matches the default platform's name (which is not necessarily
registered by name in the case of 'host'), that platform is used. If
the platform name cannot be resolved, lldb-gdbserver exits after
printing all the available platform plugin names and the default
platform plugin name.

llvm-svn: 200266
2014-01-28 00:34:23 +00:00
Greg Clayton 44d937820b Merging the iohandler branch back into main.
The many many benefits include:
1 - Input/Output/Error streams are now handled as real streams not a push style input
2 - auto completion in python embedded interpreter
3 - multi-line input for "script" and "expression" commands now allow you to edit previous/next lines using up and down arrow keys and this makes multi-line input actually a viable thing to use
4 - it is now possible to use curses to drive LLDB (please try the "gui" command)

We will need to deal with and fix any buildbot failures and tests and arise now that input/output and error are correctly hooked up in all cases.

llvm-svn: 200263
2014-01-27 23:43:24 +00:00
Jason Molenda 89c37499dd Change DecodeProcessInfoResponse to set the ProcessInfo's architecture
if the remote stub provided enough information to identify it in the
qProcessInfo packet response.  (e.g. for an Apple device where we know 
it is Mach-O, the cpu type & cpu sub type).
<rdar://problem/15847901> 

llvm-svn: 200253
2014-01-27 22:23:20 +00:00
Enrico Granata 5000ee16f6 <rdar://problem/15776874>
ValueObjectPrinter could enter an infinite loop while trying to display an aptly formed ValueObject: a reference, with a child of some pointer type, such that the pointees chain ended up pointing back to some part of itself - a pointer to itself being the simplest such case

Fixed here by only setting a pointer depth when needed, and ensuring that we won't overflow and wrap the pointer depth when it's zero.

llvm-svn: 200247
2014-01-27 21:31:26 +00:00
Todd Fiala 9f37737311 convert gdb-remote 'A' launch to use LaunchProcess ()
This change modifies the 'A' command handler's launch code to launch
with LaunchProcess (). The net effect is that the default process
monitoring that LaunchProcess () adds will kick in, allowing the
GDBRemoteCommunicationServer to be able to reap processes started with
this facility correctly. Later, in the case of lldb-gdbserver, we'll
also have the proper process monitoring going on to really debug the
inferior process.

llvm-svn: 200246
2014-01-27 20:44:50 +00:00
Todd Fiala 1b0539c7f6 Fix group stop signal handling issue on Linux.
This patch addresses a bug where in a multi-threaded program a new
signal from the inferior may be received before all group-stop
messages from an earlier signal have been handled.

Patch by Andrew MacPherson

llvm-svn: 200226
2014-01-27 17:03:57 +00:00
Ed Maste 1e8f163709 Remove FIXME comments about tids on FreeBSD that no longer apply
Spotted by John Wolfe.

llvm-svn: 200092
2014-01-25 18:45:40 +00:00
Alp Toker 6a6ff05b57 Track clang changes from r200082
llvm-svn: 200085
2014-01-25 16:57:13 +00:00
Steve Pucci 5ae54ae6cd Support for debugging against a remote stock gdbserver.
There are a couple of pieces:
 * some lazy-evaluation members that store info listed in a qSupported response
 * new method SendPacketsAndConcatenateResponses which is used for
   fetching fixed-size objects from the remote gdbserver by using multiple
   packets if necessary (first use will be to fetch shared-library XML files).

llvm-svn: 200072
2014-01-25 05:46:51 +00:00
Jason Molenda bbef401896 Change DataExtractor's ReadInt* and ReadSwapInt* routines, as well as
GetU32 and GetU64, to use memcpy to copy bytes into a local buffer instead
of having a (uint64_t *) etc local variable, pointing to the address, and
dereferencing it.  If compiled on a CPU where data alignment is required 
(e.g. the LDM instruction on armv7) and we try to GetU64 out of a mmap'ed 
DWARF file, that 8 byte quantity may not be world aligned and the program
can get an unaligned memory access fault.

<rdar://problem/15849231> 

llvm-svn: 200069
2014-01-25 05:12:35 +00:00
Jason Molenda 6e20554ea8 Initialize the named_pipe_path in GDBRemoteCommunication::StartDebugserverProcess
right after the space for it is allocated on the stack, instead of trying
to initialize it in all the different places in this method.  It's too easy
for another uninitialized code path to sneak in as it is written right now.

llvm-svn: 200066
2014-01-25 03:57:13 +00:00
Todd Fiala 8ce3dee45f Fix crash on Linux if sem_wait() is interrupted.
Patch by Andrew MacPherson.

llvm-svn: 200049
2014-01-24 22:59:22 +00:00
Jason Molenda ffa674e6d7 Terminate an unused char* buffer correctly so we don't try to open
it later in GDBRemoteCommunication::StartDebugserverProcess and report
an error.
<rdar://problem/15820813> 

llvm-svn: 200047
2014-01-24 22:49:32 +00:00
Todd Fiala 3e92a2b013 Added reaper for commandline-launched processes.
GDBRemoteCommunicationServer::LaunchProcess () now uses the built-up
ProcessLaunchArgs rather than clearing and setting items from the
function arguments. I added setters for the arguments and launch
flags, which lldb-gdbserver uses for its specification of the
commandline-specified startup app (if one is specified).

LaunchProcess () also adds a new reaper monitor that it applies to
the launched process if no process monitor has already been applied.

This addresses an issue where the 'k' command would generate (possibly
false) warnings about not being able to positively state whether a
killed process actually terminated. GDBRemoteCommunicationServer now
definitely knows the disposition of its children.

llvm-svn: 199959
2014-01-24 00:52:53 +00:00
Greg Clayton 1e3be5ba2c Don't copy entire value into m_data unless we need to. If we did this and the entire variable failed to be read, we wouldn't be able to display any actual values that were in good memory. This will also make things more efficient by not have every struct/union/class/array copy its entire value into a ValueObject.m_data even though no one was using it.
llvm-svn: 199953
2014-01-23 22:55:05 +00:00
Greg Clayton 146b7b1230 Updated to latest and greatest demangler sources.
<rdar://problem/15736085>

llvm-svn: 199946
2014-01-23 22:12:54 +00:00
Todd Fiala 403edc5c57 Move process launching into GDBRemoteCommunicationServer.
lldb-gdbserver was launching the commandline-specified launch process
directly, without GDBRemoteCommunicationServer knowing anything about
it.  As GDBRemoteCommunicationServer is the piece that manages and
knows about processes that the gdb remote protocol discusses with
the client end, it is important that it know about launched processes.

This change also implements the k gdb remote protocol message, having it
kill all known spawned processes when it is received.

(Note: in lldb-gdbserver, the spawned processes are not properly
monitored yet. The response to the k packet will complain that
spawned processes do not really appear to be getting killed even if
they are. This will get addressed soon.)

llvm-svn: 199945
2014-01-23 22:05:44 +00:00
Jim Ingham a786e53903 Don't need to figure out the frame's module if we don't have any libraries
in the step-avoid-libraries list.

llvm-svn: 199944
2014-01-23 21:57:53 +00:00
Jim Ingham 4da6206d75 Add a "step-avoid-libraries" setting to complement the "step-avoid-regexp" setting.
llvm-svn: 199943
2014-01-23 21:52:47 +00:00
Greg Clayton 1f4db7da8f Added the ability to get the type that a typedef points to via:
SBType SBType::GetTypedefedType();

Also added the ability to get a type by type ID from a SBModule:

SBType SBModule::GetTypeByID (lldb::user_id_t uid);

llvm-svn: 199939
2014-01-23 21:38:34 +00:00
Todd Fiala 571768caa6 Candidate fix for bug 18592.
This reverts Host.cpp LaunchProcess spawn behavior on FreeBSD to be
like Linux (and unlike OS X) with regards to how default signal
handlers and setup on the spawned process. FreeBSD does not reset
default signal handlers on the spawned process after this change.

llvm-svn: 199908
2014-01-23 17:07:54 +00:00
Enrico Granata 90890bba04 If a user specifies a format option to frame variable or expression, that format should prevail over whatever format(s) a summary specifies
(see test case for an example)

llvm-svn: 199857
2014-01-23 01:21:18 +00:00
Todd Fiala 76747120ca Unify OS X/POSIX/Linux Host spawn support.
This fixes a bug under Linux where spawning a process via
Host::LaunchProcess was disabling all blockable signals on the
launched process.  This caused strange behavior when attempting
to kill the lldb-gdbserver process, as the child generally would
not die unless killed with a non-blockable signal (e.g. 'kill -9').

This change moves several functions out of macosx/Host.mm into
common/Host.cpp.  In addition, two functions that needed to work
across common/Host.cpp and macosx/Host.mm were moved into the Host.h
header file.

llvm-svn: 199856
2014-01-23 00:52:28 +00:00
Greg Clayton a86dc43371 Add support for Haswell on x86_64.
<rdar://problem/15312873>

llvm-svn: 199854
2014-01-22 23:42:03 +00:00
Sean Callanan 4f2c198617 Better logging for the IRExecutionUnit so that
we can see exactly what data was put where.

llvm-svn: 199701
2014-01-21 00:54:48 +00:00
Alp Toker f747ff1f54 Build fix following clang r199686
llvm-svn: 199689
2014-01-20 21:14:57 +00:00
Todd Fiala 5000e28a5e Make lldb build with Makefiles on OS X.
This change does the following:

* Adds Makefile build scripts to debug server.

* Fixes a few small mistakes in the other makefiles.

* Modifies generate-vers.pl slightly to also work for debugserver.

* Changes the OS X, non-framework python search path from libdir to
  libdir/python2.X/site-packages where it is installed by the build
  system (also where it is installed on other operating systems).

Patch by Keno Fischer.

llvm-svn: 199543
2014-01-18 08:05:32 +00:00
Todd Fiala a9ddb0e14f Added distribution info to ArchSpec and qHostInfo message.
ArchSpec now contains an optional distribution_id, with getters and
setters. Host::GetArchitecture () sets it on non-Apple platforms using
Host::GetDistributionId (). The distribution_id is ignored during
ArchSpec comparisons.

The gdb remote qHostInfo message transmits it, if set, via the
distribution_id={id-value} key/value pair. Updated gdb remote docs to
reflect this change.

As before, GetDistributionId () returns nothing on non-Linux platforms
at this time. On Linux, it is returned only if the lsb_platform
command is installed (in /bin or /usr/bin), and only if the
distributor id key is returned by 'lsb_platform -i'. This id is
lowercased, and whitespace is replaced with underscores.

llvm-svn: 199539
2014-01-18 03:02:39 +00:00
Sean Callanan 6826d22784 Made sure that ValueObjectVariable actually
updates itself before it tries to set its own
data.  Otherwise it has no idea where to put the
data value.

<rdar://problem/15846476>

llvm-svn: 199533
2014-01-18 01:13:50 +00:00
Todd Fiala e28f1d7f07 Undo change to triple behavior from r199510.
The Linux distribution will be added to the ArchSpec class in an
upcoming change. This change only undoes the change to the triple. The
distribution retrieval logic and enabling of lldb-gdbserver for linux
x86_64 builds is still in place.

llvm-svn: 199520
2014-01-17 22:21:22 +00:00
Todd Fiala f3d61de532 Enable Linux distribution in vendor portion of host triple.
This change does the following:

* enables building lldb-gdbserver on linux_x86-64 platforms.

  Note - it builds but it has several run-time issues where many gdb
  remote protocol features are not properly implemented yet. I'm
  working on these one at a time.

* lldb-gdbserver: does not enable the eLaunchFlagDebug launch flag on
  Linux. Currently the POSIX launch routine will assert if that flag
  is passed in, presumably because that launch mode is not yet
  available.  This prevents lldb-gdbserver from asserting the moment
  it launches the debuggee process.

* Adds ConstString& Host::GetDistributionId ()

  This method is defined to return an empty result on all platforms
  except for Linux.  On Linux, it makes one attempt to execute
  'lsb_release -i' (both /usr/bin/lsb_release, where it appears
  on ubuntu, and /bin/lsb_release, where it appears on fedora
  if the redhat-lsb package is installed).  If lsb_release is not
  found in either of those locations, or if 'lsb_release -i' does
  not return the first line starting with "Distributor ID:\t",
  then the distribution id is empty.  The method will lower-case
  the id and replace whitespace with underscores.

* Modify Host::GetArchitecture () so that linux replaces an unknown
  vendor portion with the results of GetDistributionId () if that
  is non-empty.  This shows up now in qHostInfo remote packet
  responses and on the lldb host side.  Tested with ubuntu and
  fedora (the latter both with the default of not having lsb_release
  installed, and with having lsb_release installed via the redhat-lsb
  package).

  Examples of triples on Linux after this change:

    # x86_64 Unbuntu 12.04 LTS:
    x86_64-ubuntu-linux-gnu

    # x86_64 Fedora 20 Desktop with redhat-lsb package installed
    x86_64-fedora-linux-gnu

    # x86_64 Fedora 20 Desktop without redhat-lsb-core installed
    # (i.e. no /bin/lsb_release available)
    # same as before the change
    x86_64--linux-gnu

  Note I intend to have Android respond with:

    {arch}-android-linux

  when I get to implementing Android lldb-gdbserver support.

llvm-svn: 199510
2014-01-17 20:18:59 +00:00
Jim Ingham 6f78f3869d The default timeout for EvaluateExpressionOptions is not 0, so if no timeout is provided, we have to set the option timeout to 0 by hand.
<rdar://problem/15846781>

llvm-svn: 199509
2014-01-17 20:09:23 +00:00
Steve Pucci 7489cc98f7 Fix gcc warnings about casting away constness
llvm-svn: 199506
2014-01-17 18:29:08 +00:00
Steve Pucci fc99572540 Rename Platform::GetFile (3-arg version) to GetFileWithUUID
This rename was suggested by gclayton as a way to silence gcc
warnings; the warning is emitted when there is an overloaded function
in a base class (Platform) for which a derived class redefines one of
the overloads but not the other (because doing so hides the other
overload from users of the derived class).  By giving the two methods
different names, the situation is avoided.

llvm-svn: 199504
2014-01-17 18:18:31 +00:00
Ed Maste 21afbe034e Correct logic checking for the first stop ID
llvm-svn: 199503
2014-01-17 17:31:06 +00:00
Steve Pucci 5ec012d4de Test new committer permission with one-line trailing whitespace removal.
llvm-svn: 199432
2014-01-16 22:18:14 +00:00
Todd Fiala a475693947 Fix bug in Linux remote dynamic loader setup and fix test.
Part 1 changes PlatformLinux::CreateInstance to always create with
is_host=false; that method is only used as the plug-in creator method
associated with the remote-linux platform plugin, and should therefore
always be remote.

Part 1 patch by Steve Pucci.

Part 2: fix a test break on linux.

In test/functionalities/thread/thread_specific_break, when using gcc,
either C99 mode would need to be enabled, or the code would need to
change.  I changed a couple loop variable definitions to conform
to pre-C99 to simplify testing the fix.  The second issue was
the necessity to include -lpthread as a linker option in the Makefile.

Any issues with that part are due to me (Todd Fiala).

llvm-svn: 199426
2014-01-16 21:22:11 +00:00
Sean Callanan 79fde96b6a Fixed some API drift by making "used" attributes
in a better way.

llvm-svn: 199408
2014-01-16 18:47:07 +00:00
Greg Clayton baf2c2211d If a library has no N_FUN symbols we don't succeed in finding resolver symbols, now we do.
<rdar://problem/15831334>

llvm-svn: 199345
2014-01-16 01:48:44 +00:00
Greg Clayton d81088c540 Make sure we correctly merge all N_FUN symbols with non-stab entries even if there are multiple symbols with the same name.
<rdar://problem/15831292>

llvm-svn: 199344
2014-01-16 01:38:29 +00:00
Jim Ingham 39fdae7f6a Fix a bug where if we stop but nobody says there was a reason for the stop, we would return
control to the user anyway.  This was put in to handle monitors that would say there was no
stop reason when you first attached to them.  But it broke the case where you hit a thread specific
breakpoint on many threads, but NOT the one specified in the breakpoint.  I work around this
by only doing the junky override when the StopID is 0 - i.e. on first attach.

This commit also adds a test for thread specific breakpoints.

llvm-svn: 199290
2014-01-15 03:32:42 +00:00
Jim Ingham a8b99ca4bb Add a little more logging to the StopInfoBreakpoint::PerformAction.
llvm-svn: 199289
2014-01-15 03:30:04 +00:00
Deepak Panickal 263fde068f Fix return type for Windows
llvm-svn: 199202
2014-01-14 11:34:44 +00:00
Sean Callanan 22ac610c4f Harden the Materializer logic against types that
don't know their bit alignment.

llvm-svn: 199173
2014-01-14 01:14:40 +00:00
Deepak Panickal b36da43dc3 Fixed the Visual Studio Windows build
llvm-svn: 199111
2014-01-13 14:55:15 +00:00
Ed Maste 9344787636 Avoid LLDB crash upon DW_OP_deref* with empty stack
As done in other DW_OP_* cases, return an error if the stack is empty
rather than eventually crashing elsewhere.  Encountered on big-endian
MIPS, where LLVM bugs currently result in invalid .debug_loc data.

llvm-svn: 199110
2014-01-13 14:53:09 +00:00
Jim Ingham 55d3a0c3d4 Sometimes the trampoline refers directly to the indirect symbol. Handle that too.
llvm-svn: 198990
2014-01-11 01:21:50 +00:00
Jason Molenda 7f6d84b9c1 Add the offset for cfa+offset log messages in the unwind channel, to aid in debugging.
llvm-svn: 198977
2014-01-10 23:53:32 +00:00
Jim Ingham 1460e4bf0e Get the breakpoint setting, and the Mac OS X DYLD trampolines and expression evaluator to handle Indirect
symbols correctly.  There were a couple of pieces to this.

1) When a breakpoint location finds itself pointing to an Indirect symbol, when the site for it is created
   it needs to resolve the symbol and actually set the site at its target.
2) Not all breakpoints want to do this (i.e. a straight address breakpoint should always set itself on the
   specified address, so somem machinery was needed to specify that.
3) I added some info to the break list output for indirect symbols so you could see what was happening. 
   Also I made it clear when we re-route through re-exported symbols.
4) I moved ResolveIndirectFunction from ProcessPosix to Process since it works the exact same way on Mac OS X
   and the other posix systems.  If we find a platform that doesn't do it this way, they can override the
   call in Process.
5) Fixed one bug in RunThreadPlan, if you were trying to run a thread plan after a "running" event had
   been broadcast, the event coalescing would cause you to miss the ThreadPlan running event.  So I added
   a way to override the coalescing.
6) Made DynamicLoaderMacOSXDYLD::GetStepThroughTrampolinePlan handle Indirect & Re-exported symbols.

<rdar://problem/15280639>

llvm-svn: 198976
2014-01-10 23:46:59 +00:00
Jim Ingham ea3ac27029 The actual indirect symbol is not the one at the address of the Trie entry marked with the EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER, it is given in the address in the “other” field in that entry.
llvm-svn: 198967
2014-01-10 22:55:37 +00:00
Greg Clayton fda4fab505 Revert to getting a random port and sending that down to debugserver for iOS. The sandboxing is not letting debugserver reverse connect back to lldb.
<rdar://problem/15789865>

llvm-svn: 198963
2014-01-10 22:24:11 +00:00
Jason Molenda 5f36c4beec Update the lldb version number in the xcode project files from 310.99.0 to 320.99.0.
llvm-svn: 198917
2014-01-10 06:12:10 +00:00
Greg Clayton 99e384c85f Fixed an issue with the byte order of ports in KDP packets.
I previously fixed a bug in the SocketAddress class where SocketAddress::GetPort() wasn't using ntohs() on the port number in the structures.

After fixing this, it broke places where we weren't using ntohs() and htons() correctly.

<rdar://problem/15767514>

llvm-svn: 198902
2014-01-10 00:31:10 +00:00
Jason Molenda 25f3961caf Roll back r198729; it seems to be causing two testsuite failures if llvm is built with asserts -
210: test_with_dsym_and_run_command (Test-rdar-10642615.Radar10642615DataFormatterTestCase)
     Test data formatter commands. ... Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file llvm/include/llvm/Support/Casting.h, line 239.

     226: test_with_dsym_and_run_command (Test-rdar-13338477.Radar13338477DataFormatterTestCase)
         Test that LLDB handles the clang typeclass Paren correctly. ... Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file llvm/include/llvm/Support/Casting.h, line 239.

llvm-svn: 198811
2014-01-09 00:02:17 +00:00
Jason Molenda 491caa14d5 Roll back my change to r198729; I'm going to revert it entirely.
llvm-svn: 198810
2014-01-09 00:00:53 +00:00
Jason Molenda 5005de4bac Revert the vector part of Enrico's change in r198729;
it is causing an llvm assert when run against
test/functionalities/data-formatter/rdar-10642615,

Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file llvm/include/llvm/Support/Casting.h, line 239.

llvm-svn: 198809
2014-01-08 23:35:54 +00:00
Greg Clayton 76af996df8 Only check os version for POSIX_SPAWN_CLOEXEC_DEFAULT on desktop builds of LLDB.
llvm-svn: 198800
2014-01-08 22:12:52 +00:00
Greg Clayton 2210624d86 Fixed a kernel panic that would occur if you debug anything on MacOSX 10.7 or earlier due to the use of the POSIX_SPAWN_CLOEXEC_DEFAULT attribute flag that closes all file descriptors on exec. We now dyamically detect the OS version and do the right thing.
llvm-svn: 198776
2014-01-08 18:02:51 +00:00
Todd Fiala 1a63440953 Fixes a bug preventing reading of the python register file.
This change fixes a bug recently introduced in ProcessGDBRemote that
prevented the Python register definition file from getting loaded when
the qRegisterInfo0 response returned $00#.

Patch by Steve Pucci.

llvm-svn: 198742
2014-01-08 07:52:40 +00:00
Enrico Granata af76481caf <rdar://problem/15453076>
When determining the type of array members, do not see-through typedefs
For instance, in BOOL arr[4], we want the elements to be typed as BOOL, not signed char

llvm-svn: 198729
2014-01-08 03:02:33 +00:00
Enrico Granata 6b6ea7ac17 __CFString should also format as an NSString
llvm-svn: 198727
2014-01-08 02:34:42 +00:00
Enrico Granata 0dba9b33f0 New and improved data formatter for std::shared_ptr<> and std::weak_ptr<>
llvm-svn: 198724
2014-01-08 01:36:59 +00:00
Sean Callanan 65b320f783 Fixed a bug where the expression parser doesn't
materialize a variable in a register correctly
if the variable is a pointer.  This fixes a
regression introduced by my commit of Oct. 22nd
(r193191).

llvm-svn: 198718
2014-01-07 23:15:26 +00:00
Greg Clayton 3d5bb3266f Fixed an issue when attaching to a process without specifying a file where we wouldn't set the dyld gdb image notifier breakpoint correctly.
<rdar://problem/15720040>

llvm-svn: 198717
2014-01-07 23:15:02 +00:00
Jason Molenda 5a87c0fb37 Update the checks in EmulateInstructionARM::GetFramePointerRegisterNumber
and EmulateInstructionARM::GetFramePointerDWARFRegisterNumber to recognize
the Apple arm convention (of using r7 for the frame pointer, regardless of
thumb or arm) even if the OS does not match Darwin/MacOSX/iOS.  Also 
corrects the behavior for thumb code on non-Apple platforms.
<rdar://problem/14661537> 

llvm-svn: 198648
2014-01-06 23:39:35 +00:00
Todd Fiala fb10118bfa Fix lldb build break due to TypedefNameDecl member signature change.
Patch by Steve Pucci.

llvm-svn: 198635
2014-01-06 20:25:42 +00:00
Jason Molenda 83f1149b30 Use Address::SetLoadAddress() instead of SectionLoadList::ResolveLoadAddress().
The former will set the Address object's offset to the load address value if
it is not present in any section; the latter will only set the Address object
if the load addr is contained in one of its sections.
<rdar://problem/15135987> 

llvm-svn: 198469
2014-01-04 01:37:52 +00:00
Jason Molenda 4b79247750 Don't enforce ABI stack alignment rules on the sigtramp frame --
its stack frame is a constructed, fake thing that may not conform
correctly to these rules.  This fixes a problem where lldb couldn't
backtrace past an asynchronous signal handler (_sigtramp) frame on
a stack on Mac OS X.
<rdar://problem/15035673> 

llvm-svn: 198450
2014-01-03 22:06:25 +00:00
Jason Molenda 1b101ef364 Fix a mistake in the last change I made to ProcessMachCore.cpp.
<rdar://problem/15745397> 

llvm-svn: 198447
2014-01-03 20:46:16 +00:00
Jean-Daniel Dupas de5094ba00 Fix a couple of memory leaks.
llvm-svn: 198178
2013-12-29 20:18:15 +00:00
Jean-Daniel Dupas c6f26f8542 Stop leaking MCRegisterInfo.
llvm-svn: 198177
2013-12-29 20:17:26 +00:00
Enrico Granata 30f287fde5 Add a new way to bind a format to a type: by enum type
The "type format add" command gets a new flag --type (-t). If you pass -t <sometype>, upon fetching the value for an object of your type,
LLDB will display it as-if it was of enumeration type <sometype>
This is useful in cases of non-contiguous enums where there are empty gaps of unspecified values, and as such one cannot type their variables as the enum type,
but users would still like to see them as-if they were of the enum type (e.g. DWARF field types with their user-reserved ranges)

The SB API has also been improved to handle both types of formats, and a test case is added

llvm-svn: 198105
2013-12-28 08:44:02 +00:00
Jason Molenda 703a45616c Add a new setting (currently fixed) for how to
interpret core files that contain both a user
process dyld and a kernel executable in them.
Fix an additional method that needs to be 
adjusted depending on this preference as well.
<rdar://problem/15721409> 

llvm-svn: 197931
2013-12-24 02:57:50 +00:00
Jean-Daniel Dupas 9c517c0dd9 Remove wait_for_launch parameter from DoAttachToProcessWithName(). This parameter is redundant as this information is already provided by the ProcessAttachInfo parameter.
CC: lldb-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2463

llvm-svn: 197923
2013-12-23 22:32:54 +00:00
Enrico Granata 4939b98a2c Centralize the code for GetValueAsCString() in TypeFormatImpl (the implementing class of "type format ...")
TypeFormatImpl used to just wrap a Format (and Flags for matching), and then ValueObject itself would do the printing deed
With this checkin, the responsibility of generating a value string is centralized in the data formatter (as it should, and already is for summaries) 

This change is good practice per se, and should also enable us to extend the type format mechanism in a cleaner way

llvm-svn: 197874
2013-12-22 09:24:22 +00:00
Enrico Granata 16f35ea9bb <rdar://problem/14822563> - Do not attempt to use a null VariableList or crashes will ensue
llvm-svn: 197862
2013-12-21 08:44:28 +00:00
Enrico Granata 0c0f9dcd91 Add a new-line
llvm-svn: 197860
2013-12-21 08:24:28 +00:00
Enrico Granata 473316f4ea There is no need to use the expression parser to generate true and false - writing in a buffer is good enough
llvm-svn: 197858
2013-12-21 08:09:49 +00:00
Jason Molenda c62bd7bd24 Any time ProcessGDBRemote tries to get the remote's ProcessArchitecture,
it needs to fall back to using the HostArchitecture if a valid one is not
returned.  When doing low-level system debugging we may not have a process
(or the remote stub may not support the qProcessInfo packet) in which case
we should fall back to the architecture we determined via qHostInfo.
<rdar://problem/15713180> 

llvm-svn: 197857
2013-12-21 05:20:36 +00:00
Sean Callanan fd1ca95331 Harden the Objective-C runtime against weird method
signatures.

<rdar://problem/15631996>

llvm-svn: 197843
2013-12-20 23:07:12 +00:00
Sean Callanan 439dcae4a2 Updated our IR processing to reflect best practices
for making pointer-valued constants.

llvm-svn: 197829
2013-12-20 19:55:02 +00:00
Enrico Granata cbbaf7585f All data formatters come in "match exact" and "match regex" styles
This refactoring makes it less error-prone to define formatter types with the correct match schemes

llvm-svn: 197800
2013-12-20 11:32:26 +00:00
Enrico Granata b72a501d86 FormatNavigator has long stopped navigating anything - the generation of possible formatters matches is now done elsewhere
So, rename the class for what it truly is: a FormattersContainer
Also do a bunch of related text substitutions in the interest of overall naming clarity

llvm-svn: 197795
2013-12-20 09:38:13 +00:00
Sean Callanan f4c0a221bc Fixed the AST importer to ensure that base classes
of Objective-C classes are completed, and that
variables of Objective-C types have their types
completed when the variables are reported.

This fixes a long-standing issue where ivars did
not show up correctly on 32-bit OS X.

<rdar://problem/12184093> 

llvm-svn: 197775
2013-12-20 04:09:05 +00:00
Sean Callanan 090e11975d Adjust to the new way LLVM emits modules: it doesn't
specify a pointer size until code gen.  So we just
make all our pointer-sized integer literals 64-bit.
That doesn't seem to hurt anything.

llvm-svn: 197774
2013-12-20 04:07:43 +00:00
Jason Molenda 3d21975a44 Partially revert a patch from Ashok Thirumurthi in r191430.
The original code was not completely correct, but a form of
this check is necessary to avoid an infinite recursion on
some unwind cases where a function unwinds to itself with the
same CFA.  Ashok thought the recursion would be caught in
RegisterContextLLDB but this one isn't - we still need it here.
<rdar://problem/15664282> 

llvm-svn: 197761
2013-12-20 01:05:11 +00:00
Jason Molenda 91e428bc90 Revert one part of Ashok Thirumurthi's patch from September 16, r190812.
In those set of patches, Ashok changed Module::ResolveSymbolContextForAddress 
so that if it failed to find a symbol for a pc, it could back up
the pc value by 1 and re-search for a symbol.

His change to RegisterContextLLDB.cpp partially duplicates that
behavior but it also removes the separate case where we find a
Symbol for the pc address but it's the wrong symbol -- we need to
handle this as well as the lookup-by-pc-finds-no-symbol case.

The most obvious fallout from this regression was that lldb on
Mac OS X couldn't backtrace past __assert_rtn() which tail-calls 
abort().  e.g.

(lldb) bt
* thread #1: tid = 0x5d6ea1, 0x00007fff8ee80866 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff8ee80866 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff8eb5835c libsystem_pthread.dylib`pthread_kill + 92
    frame #2: 0x00007fff8852ab1a libsystem_c.dylib`abort + 125
    frame #3: 0x00007fff884f49bf libsystem_c.dylib`__assert_rtn + 321
    frame #4: 0x0000000100000f2c a.out`main + 124

(lldb) dis -c 3 -s 0x7fff884f49b3
libsystem_c.dylib`__assert_rtn + 309:
   0x7fff884f49b3:  movq   %rax, -0x11b96242(%rip)   ; gCRAnnotations + 8
   0x7fff884f49ba:  callq  0x7fff8854fd2c            ; symbol stub for: abort

libsystem_c.dylib`basename:
   0x7fff884f49bf:  pushq  %rbp
(lldb) 

in this case, __assert_rtn() is immediately followed by basename() and 
the changes in r190812 didn't back up the pc value to get the correct
function name / unwind info.

<rdar://problem/15367233> 

llvm-svn: 197655
2013-12-19 04:32:42 +00:00
Han Ming Ong 4b5a63cd54 <rdar://problem/15639995>
Allow the root XPC launcher to launch any target as root.

llvm-svn: 197634
2013-12-19 00:35:40 +00:00
Jason Molenda 23f2fcaed8 Fix return type of ReadLibdispatchOffsetsAddress.
llvm-svn: 197632
2013-12-19 00:10:23 +00:00
Jason Molenda 4a5ec88f0d Fix std::string initialization in Queue ctor.
<rdar://problem/15694319> 

llvm-svn: 197631
2013-12-19 00:09:13 +00:00
Jason Molenda 64de91522f Code reorganization in PlatformDarwin for how the libdispatch
offsets structure is read & saved in the platform object -- soon
we'll be getting more than the queue name offset out of this
structure so we'll need to reuse the information in other methods.

llvm-svn: 197620
2013-12-18 22:52:34 +00:00
Ed Maste 48f986faee Workaround QEMU GDB server issue.
During testing I observed QEMU send "$T02thread:01;#04" upon connection,
before any command from LLDB.  This change from gclayton accepts (and
discards) a packet immediately after sending the initial ack, to flush
the GDB remote pipeline.

llvm-svn: 197579
2013-12-18 15:31:45 +00:00
Greg Clayton 6b32f1ec18 <rdar://problem/15668743>
Fixed a crasher that would only occur if Xcode attaches to a remote process first, then launches. 

llvm-svn: 197546
2013-12-18 02:06:45 +00:00
Jason Molenda eadd2cb459 When ProcessMachCore::DoLoadCore() finds *BOTH* a user process dyld and a mach kernel
binary, change to prefer the mach kernel binary by default.

llvm-svn: 197545
2013-12-18 01:56:30 +00:00
Jim Ingham a6195b732d Fix a bug introduced in asynchronous packet sends. We were not setting the packet result, and so
it looked like the async packet send always failed.

<rdar://problem/15657157>

llvm-svn: 197543
2013-12-18 01:24:33 +00:00
Jason Molenda b97f44d9ef Fix how Queue/QueueItem weak pointers are initialized in the ctors.
llvm-svn: 197541
2013-12-18 00:58:23 +00:00
Jason Molenda c8064ac626 Move the ivars / logic of SBQueue into a QueueImpl class and
change SBQueue to have a shared pointer to its corresponding
QueueImpl object for binary compatibility.
<rdar://problem/15657926> 

llvm-svn: 197300
2013-12-14 01:14:45 +00:00
Greg Clayton b09c5384b0 Centralized the launching of a process into Target::Launch()
While investigating test suite failures when running the test suite remotely, I noticed we had 3 copies of code that launched a process:
1 - in "process launch" command 
2 - SBTarget::Launch() with args
3 - SBTarget::Launch() with SBLaunchInfo

"process launch" was launching through the platform if it was supported (this is needed for remote debugging) and the 2 and 3 were not.

Now all code is in one place.

llvm-svn: 197247
2013-12-13 17:20:18 +00:00
Sylvestre Ledru a4cc7dec70 Fixes an issue where a signum => name mapping function has multiple case statements that define to the same integral value on my Linux (Ubuntu 12.04, x86_64). It's for SIGIO and SIGPOLL.
In the case that they are both defined the same.
Patch by Todd Fiala (but typos are mine)

llvm-svn: 197221
2013-12-13 09:51:39 +00:00
Jason Molenda 5e8dce4dbf Add new Queue, QueueItem, Queuelist, SBQueue, SBQueueItem classes to represent
libdispatch aka Grand Central Dispatch (GCD) queues.  Still fleshing out the
documentation and testing of these but the overall API is settling down so it's
a good time to check it in.
<rdar://problem/15600370> 

llvm-svn: 197190
2013-12-13 00:29:16 +00:00
Han Ming Ong 3a7c3d1bf8 <rdar://problem/15639995>
debugserver's launch info was cleared unnecessarily. It has important user ID set. Reviewed by Greg Clayton.

llvm-svn: 197182
2013-12-12 22:14:52 +00:00
Jean-Daniel Dupas 13698b2714 Don't try to guess sys header conditions, and simply check if each signal is defined.
CC: lldb-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2394

llvm-svn: 197173
2013-12-12 18:12:16 +00:00
Greg Clayton b73a31efe6 Pickup fixes for demangling crashers.
<rdar://problem/15600471>

llvm-svn: 197171
2013-12-12 17:39:39 +00:00
Sylvestre Ledru 6215685ab9 sin_len is not available in the structure sockaddr_in under GNU/Linux. Fix the build failure. Patch by Todd Fiala (and many other who proposed similar patches)
llvm-svn: 197155
2013-12-12 13:45:47 +00:00
Jean-Daniel Dupas b2065ecdd6 Remove useless includes
llvm-svn: 197147
2013-12-12 11:52:05 +00:00
Greg Clayton 4705f8d842 LLDB can crash if given DWARF debug info for a class that has a base class which isn't a complete definition.
<rdar://problem/15594781>

We need to not crash at any cost. We currently detect if any base classes are forward declarations, emit an error string that directs the use to file a compiler bug, and continues by completing the class with no contents. This avoids a clang crash that would usually follow when we call setBase().

llvm-svn: 197108
2013-12-12 01:54:04 +00:00
Greg Clayton 78f4d95d09 Fixed parsing the DW_TAG_member children for structs, unions and classes to not alway treat every member as a bitfield.
The previous fix for bitfields made us always search for anonymous bitfields regardless of the member (bitfield or normal field).

llvm-svn: 197088
2013-12-11 23:10:39 +00:00
Ed Maste 30df85e67f Fix Linux by partially reverting 196787
llvm-svn: 197065
2013-12-11 20:43:27 +00:00
Greg Clayton eeb15653c6 Fix the test suite after the changes made in revision 196616 exposed issues in the test suite.
We must make sure that all ValueObject objects always contain a valid target.

llvm-svn: 196983
2013-12-10 23:16:40 +00:00
Greg Clayton d30ed41c13 Revert change I didn't mean to check in.
llvm-svn: 196956
2013-12-10 19:44:41 +00:00
Greg Clayton 765d2e234c Fix autocompletion for multi-word commands.
<rdar://problem/14183288>

llvm-svn: 196949
2013-12-10 19:14:04 +00:00
Jean-Daniel Dupas 7782de923e Remove 'const' constraint on ProcessLaunchInfo parameter in Process::DoLaunch().
This 'const' is not required and prevent us to defer the launch to the Host layer.

llvm-svn: 196837
2013-12-09 22:52:50 +00:00
Ed Maste 8958af36c1 Fix Linux build after r196787
Patch from Xavier de Gaye

llvm-svn: 196830
2013-12-09 22:34:49 +00:00
Ed Maste 90359963ab Handle endianness in the Opcode class
Previously, an opcode set via SetOpcode32 (for example) was later
extracted via GetData() as a byte sequence in host order rather than
target order.

Review: http://llvm-reviews.chandlerc.com/D1838
llvm-svn: 196808
2013-12-09 19:45:33 +00:00
Jean-Daniel Dupas e5f4780d9b Replace 'mkdir' shell invocation by native function call.
Summary: Now that Host provide a MakeDirectory function, we can use it instead of relying on command line tool to create a directory.

CC: lldb-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2356

llvm-svn: 196801
2013-12-09 19:16:14 +00:00
Ed Maste 10565b61d5 FreeBSD and NetBSD have sa_len in struct sockaddr
llvm-svn: 196790
2013-12-09 16:07:11 +00:00
Ed Maste 7fd845cc9d Threaded inferior support for FreeBSD
Modelled in part on GDBRemoteCommunicationClient.

Review: http://llvm-reviews.chandlerc.com/D2267
llvm-svn: 196787
2013-12-09 15:51:17 +00:00
Ed Maste 991fe6c701 Fix Debian GNU/kFreeBSD build
Use the same LaunchProcessPosixSpawn as on FreeBSD and Linux.

llvm-svn: 196742
2013-12-09 01:35:42 +00:00
Jim Ingham b44af8ff25 If the StepThrough plan makes it back to the frame in which it started, it should say
it succeeded, since the plan that was using it can figure out what to do from there.
It should only say it failed if it truely went off into the weeds.

<rdar://problem/15597807>

llvm-svn: 196631
2013-12-07 01:17:30 +00:00
Jean-Daniel Dupas 870c011de5 Replace the last auto_ptr by unique_ptr
llvm-svn: 196625
2013-12-06 23:38:05 +00:00
Sylvestre Ledru c061cceed2 Fixed Makefile-based install to place python packages in the LLDB install tree.
Failure to install python packages now fails the make install.
This patch properly handles the optional DESTDIR variable.

Patch by Todd Fiala

llvm-svn: 196624
2013-12-06 23:16:23 +00:00
Jim Ingham 793d8d9c00 Do a little more prevention against SBValues getting used after the world has been torn down around them.
llvm-svn: 196616
2013-12-06 22:21:04 +00:00
Greg Clayton fb6621ef4b Add a setting to allow users to enable expressions that crash LLDB to show up in crash logs.
<rdar://problem/11549320> 

llvm-svn: 196613
2013-12-06 21:59:52 +00:00
Greg Clayton 3dedae12b5 Fixed the GDBRemoteCommuncation to return a new GDBRemoteCommuncation::PacketResult enum for all packet sends/receives.
<rdar://problem/15600045>

Due to other recent changes, all connections to GDB servers that didn't support the "QStartNoAckMode" packet would cause us to fail to attach to the remote GDB server.

The problem was that SendPacket* and WaitForResponse* packets would return a size_t indicating the number of bytes sent/received. The other issue was WaitForResponse* packets would strip the leading '$' and the trailing "#CC" (checksum) bytes, so the unimplemented response packet of "$#00" would get stripped and the WaitForResponse* packets would return 0.

These new error codes give us flexibility to to more intelligent things in response to what is returned. 

llvm-svn: 196610
2013-12-06 21:45:27 +00:00
Greg Clayton d629980ab3 Replace all in_port_t with uint16_t to avoid compilation issues on different systems.
llvm-svn: 196586
2013-12-06 17:46:35 +00:00
Jean-Daniel Dupas 3cfa8e217e Typo in comments
llvm-svn: 196577
2013-12-06 09:35:53 +00:00
Jean-Daniel Dupas 89d910c397 Tell CMake about the SystemRuntime plugin.
This fixes CMake build on Darwin.

llvm-svn: 196575
2013-12-06 09:32:46 +00:00
Arnaud A. de Grandmaison 223bda22f4 Tell CMake about recently added SectionLoadHistory.cpp
llvm-svn: 196566
2013-12-06 08:49:14 +00:00
Greg Clayton d5944cd118 For logical backtrace work, lldb needs to track Module unloads etc & symoblicate an address based on a point in time
<rdar://problem/15314403> 

This patch adds a new lldb_private::SectionLoadHistory class that tracks what shared libraries were loaded given a process stop ID. This allows us to keep a history of the sections that were loaded for a time T. Many items in history objects will rely upon the process stop ID in the future.

llvm-svn: 196557
2013-12-06 01:12:00 +00:00
Greg Clayton 00fe87b488 Modified local spawning in debugserver processes to use a new --reverse-connect option so that debugserver actually connects back to LLDB instead of LLDB connecting to debugserver.
This gets rid of our hacky "get_random_port()" which would grab a random port and tell debugserver to open that port. Now LLDB creates, binds, listens and accepts a connection by binding to port zero and sending the correctly bound port down as the host:port to connect back to.

Fixed the "ConnectionFileDescriptor" to be able to correctly listen for connections from a specified host, localhost, or any host. Prior to this fix "listen://" only accepted the following format:

listen://<port>

But now it can accept:

listen://<port>         // Listen for connection from localhost on port <port>
listen://<host>:<port>  // Listen for connection from <host> and <port>    
listen://*:<port>       // Listen for connection from any host on port <port>

llvm-svn: 196547
2013-12-05 22:58:22 +00:00
Jean-Daniel Dupas 0fefa67606 Extends StringExtractorGDBRemote to support debugger packets.
CC: lldb-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2337

llvm-svn: 196525
2013-12-05 19:25:45 +00:00
Sylvestre Ledru 13b0fba48b Revert: "Patch from Todd Fiala that install the lldb.py module in the prefix directory and also makes install fail if the prefix directory can't be accessed"
Does not respect the prefix

llvm-svn: 196499
2013-12-05 12:51:47 +00:00
Sylvestre Ledru 34efb6aee1 Fix the build failure of lldb wrt clang recent change. Patch by Todd Fiala
llvm-svn: 196483
2013-12-05 07:55:40 +00:00
Greg Clayton 8fbbb5b421 Patch from Todd Fiala that install the lldb.py module in the prefix directory and also makes install fail if the prefix directory can't be accessed
llvm-svn: 196413
2013-12-04 21:27:40 +00:00
Greg Clayton dbf0457a7b Allow the hostname to be specified when asking a platform to launch another debugserver in case you want to change it.
The GDB server remote platform how has the debugserver that are launched on iOS devices to use localhost due to the use of a USB mux.

llvm-svn: 196405
2013-12-04 19:40:33 +00:00
Greg Clayton c8b38d3389 Enable POSIX_SPAWN_CLOEXEC_DEFAULT (a darwin specific flag) when available when using posix_spawn to spawn processes to close all file handles.
llvm-svn: 196404
2013-12-04 19:38:57 +00:00
Greg Clayton 91a9b247d4 Switch local launching of debugserver over to always use a FIFO in order to handshake with the launched debugserver.
This helps ensure that the launched debugserver is ready and listening for a connection. Prior to this we had a race condition.

Consolidate the launching of debugserver into a single place: a static function in GDBRemoteCommunication.

llvm-svn: 196401
2013-12-04 19:19:12 +00:00
Greg Clayton c6931fcf49 Added a new directory type for the "bool Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)" function: ePathTypeLLDBTempSystemDir
This will get the temporary directory on the current system.

Removed a call to tmpnam() and replaced it with a call to mktemp() using a template that will be in the temp directory.

llvm-svn: 196397
2013-12-04 18:53:50 +00:00
Ed Maste ea66007938 Correct header guard #endif comments
llvm-svn: 196381
2013-12-04 13:41:18 +00:00
Jason Molenda 135e55f8f3 Fix log message for new invalidation checks in PlanValidAtAddress().
Thanks to Ed and Greg for catching the incorrect logging statements.

llvm-svn: 196322
2013-12-03 21:59:39 +00:00
Greg Clayton c6b26f0545 <rdar://problem/15566148>
Fix use of std::lower_bound to check for equality if a match is found to ensure we don't return the next breakpoint with an ID greater than the break_id that was asked for.

llvm-svn: 196298
2013-12-03 17:50:20 +00:00
Jason Molenda 61cd0729bb Build up UnwindPlan::PlanValidAtAddress to recognize some general
indications that the UnwindPlan is invalid -- for instance, a
complete lack of rows, or a row that fails to define a register to
base the CFA off of.
<rdar://problem/15246247> 

llvm-svn: 196201
2013-12-03 04:46:27 +00:00
Jim Ingham 177553e4c0 Remove the bad assumption that breakpoint locations won't get deleted in BreakpointLocationList::FindByID.
<rdar://problem/15566148>

llvm-svn: 196197
2013-12-03 02:31:17 +00:00
Ed Maste f44e3cd7f1 Ensure parsed debug arange data is sorted
llvm.org/pr18114

llvm-svn: 196146
2013-12-02 20:16:30 +00:00
Greg Clayton 5fb8f79738 Fixed internal code to not link against and code from "lldb/API/*".
lldb_private::Debugger was #including some "lldb/API" header files which causes tools (lldb-platform and lldb-gdbserver) that link against the internals only (no API layer) to fail to link depending on which calls were being used.

Also fixed the current working directory so that it gets set correctly for remote test suite runs. Now the remote working directory is set to: "ARCH/TESTNUM/..." where ARCH is the current architecture name and "TESTNUM" is the current test number. 

Fixed the "lldb-platform" and "lldb-gdbserver" to not warn about mismatched visibility settings by having each have their own exports file which contains nothing. This forces all symbols to not be exported, and also quiets the linker warnings.

llvm-svn: 196141
2013-12-02 19:35:49 +00:00
Ed Maste c113ff8cba elf: Move elf note parsing to ObjectFileELF.cpp
Separate ELF note implementations were introduced for core files and
GNU build-id.  Move the more general one from elf-core to ObjectFileELF
and use it for build-id as well.

Review: http://llvm-reviews.chandlerc.com/D1902
llvm-svn: 196125
2013-12-02 17:49:13 +00:00
Sylvestre Ledru 3b5b16cdff Also silent -Wno-cast-qual in the SWIG Python wrapper. Remove a huge number of warnings
llvm-svn: 195930
2013-11-28 18:11:34 +00:00
Colin Riley 909bb7a3f4 Fix MSVC build
Added _WIN32 guards to new platform features. Using correct SetErrorStringWithFormat within Host when LLDB_DISABLE_POSIX is defined. Also fixed an if defined block.

llvm-svn: 195766
2013-11-26 15:10:46 +00:00
Ed Maste 82a0005b21 Fix compile warnings
llvm-svn: 195685
2013-11-25 21:15:53 +00:00
Ed Maste 426285bfad Remove unused variable
llvm-svn: 195683
2013-11-25 20:48:07 +00:00
Ed Maste ac7270b56b Correct a standalone debug file path
For a file /bin/ls with a .gnu_debuglink entry of "ls.debug" the path
should be /usr/lib/debug/bin/ls.debug, not /usr/lib/debug/bin/ls.

ref: https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html

llvm.org/pr17903
http://llvm-reviews.chandlerc.com/D2169

llvm-svn: 195681
2013-11-25 20:33:56 +00:00
Ed Maste 3fe7186a1b Remove redundant assignment
llvm-svn: 195664
2013-11-25 17:16:34 +00:00
Ed Maste 6cf5b8f18c Fix issue from r166732 found by Andrew Kaylor
From Jim Ingham's email:
  It does look like ThreadPlanStepInRange test is some kind of thinko.
  In practice, in this case it is probably safe to run only one thread
  when doing the "step through" since that generally involved running
  from a shared library stub to its target.  That could deadlock if the
  dynamic loader has to fix up the symbol, and another thread is in the
  middle of doing that.  But that doesn't seem to be very common, or at
  least the code is clearly wrong but I haven't had any reports of this
  causing deadlocks...

llvm-svn: 195657
2013-11-25 16:36:47 +00:00
Ed Maste 502f9020a7 PT_CONTINUE and PT_STEP are process-scope on FreeBSD
Although ptrace() can be passed a PID or TID for PT_CONTINUE and PT_STEP,
the kernel operates on all threads in the process in both cases.  (See
the FOREACH_THREAD_IN_PROC in FreeBSD's sys_process.c:kern_ptrace.)

Make this clear by using the PID from the ProcessMonitor instance.

llvm-svn: 195656
2013-11-25 16:31:23 +00:00
Jason Molenda 906f329724 Change lldb from building against a Python framework out of
the installed SDK to using the current OS installed headers/libraries.
This change is to address the removal of the Python framework
from the Mac OS X 10.9 (Mavericks) SDK, and is the recommended
workaround via https://developer.apple.com/library/mac/technotes/tn2328/_index.html

llvm-svn: 195557
2013-11-23 20:07:29 +00:00
Greg Clayton 5c6eab21eb Removed printf and puts calls that were left in accidentally.
llvm-svn: 195542
2013-11-23 02:01:06 +00:00
Greg Clayton fb90931b60 Improved platform support.
Improved the detection of a valid GDB server where we actually can connect to a socket, but then it doesn't read or write anything (which happens with some USB mux software).

Host::MakeDirectory() now can make as many intermediate directories as needed.

The testsuite now has very initial support for remote test suite running. When running on a remote platform, the setUp function for the test will make a new directory and select it as the working directory on the remote host. 

Added a common function that can be used to create the short option string for getopt_long calls.

llvm-svn: 195541
2013-11-23 01:58:15 +00:00
Greg Clayton ec6829eac0 Patch from Todd Fiala: lldb will seg fault if for some reason there is no unwinder when StackFrameList::GetFramesUpTo() is called.
Mainly patched to stop LLDB from crashing. This can easily happen if you debug to a remote gdbserver that doesn't have any dynamic register info and you don't have a target definition file specified.

llvm-svn: 195499
2013-11-22 21:03:42 +00:00
Greg Clayton 2b98c56996 Fixed functions to always reply to packets and added a port offset.
Fixed a bunch of issues with many functions that were added for the platform host IO calls where they might not reply to the packet if the packet was malformed.

Cleaned up error codes.

Added a port offset to allow for connections across a USB mux.

llvm-svn: 195485
2013-11-22 18:53:12 +00:00
Greg Clayton 3bd19fb07d Fix ePathTypeSupportExecutableDir for shallow bundle Darwin targets and add "host" logging for the different paths.
llvm-svn: 195484
2013-11-22 18:48:24 +00:00
Greg Clayton 8c8018d36f Only use a PTY master/slave when launching for local processes.
llvm-svn: 195483
2013-11-22 18:47:24 +00:00
Greg Clayton c029382690 Fix File::GetPermissions() to only return the permission bits.
llvm-svn: 195482
2013-11-22 18:46:55 +00:00
Greg Clayton 6d4130e7d9 Fix indentation.
llvm-svn: 195481
2013-11-22 18:46:16 +00:00
Colin Riley 6c97042044 Fix for PECOFF GetArchitecture
0 as CPU subtype never matches anything (at least, it doesn't match x86_64 windows binaries, of which there are correct arch definitions for). It should be created with LLDB_INVALID_CPUTYPE. 

llvm-svn: 195435
2013-11-22 09:35:12 +00:00
Jim Ingham 1a7ee7044a #include <AvailabilityMacros.h> if you want to use them. This was causing us to skip
the code that should have set thread names on Mac OS X.

<rdar://problem/15517264>

llvm-svn: 195403
2013-11-22 00:51:36 +00:00
Enrico Granata de61cecd1c <rdar://problem/15530080>
Rework data formatters matching algorithm
What happens now is that, for each category, the FormatNavigator generates all possible matches, and checks them one by one
Since the possible matches do not actually depend on the category (whether a match is accepted or not does, but that check can be shifted at a more convenient time),
it is actually feasible to generate every possible match upfront and then let individual categories just scan through those

This commit changes things by introducing a notion of formatters match candidate, and shifting responsibility for generating all of them given a (ValueObject,DynamicValueType) pair
from the FormatNavigator back to the FormatManager
A list of these candidates is then passed down to each category for matching
Candidates also need to remember whether they were generated by stripping pointers, references, typedefs, since this is something that individual formatters can choose to reject
This check, however, is conveniently only done once a "textual" match has been found, so that the list of candidates is truly category-independent

While the performance benefit is small (mostly, due to caching), this is much cleaner from a design perspective

llvm-svn: 195395
2013-11-22 00:02:13 +00:00
Ed Maste 5341404258 Update cmake for SBPlatform.cpp added in r195273
llvm-svn: 195362
2013-11-21 14:38:22 +00:00
Jason Molenda 4a4b5dcb7d sys/stat.h needed for mkdir, chmod, stat.
llvm-svn: 195305
2013-11-21 02:45:55 +00:00
Greg Clayton 29b8fc4da9 Added new options to lldb-platform:
--gdbserver-port PORT
    --min-gdbserver-port PORT
    --max-gdbserver-port PORT
    
The --gdbserver-port option can be specified multiple times to tell lldb-platform which ports it can use when launching child GDB server processes.
The --min-gdbserver-port and --max-gdbserver-port options allow a range of ports to be specified for use when launching child GDB server processes.

Fixed the code to manage these ports correctly in GDBRemoteCommunicationServer.

Also changed GDBRemoteCommunicationClient to not set a port when sending the "qLaunchGDBServer" packet so that the remote lldb-platform can decide which ports to use. If the lldb-platform was launched with no --gdbserver-port or --min-gdbserver-port/--max-gdbserver-port options, then port 0 is always used and a unix socket is used between the lldb-platform and child GDB server process to coordinate the use of valid port.

llvm-svn: 195300
2013-11-21 01:44:58 +00:00
Enrico Granata 5383e81a7f <rdar://problem/15449837>
Change the NSSet data formatter to not use the expression parser to produce synthetic children
In small-scale experimentation with lldb-perf, this improves our performance by around 25%

llvm-svn: 195294
2013-11-21 01:08:05 +00:00
Greg Clayton fbb7634934 Expose SBPlatform through the public API.
Example code:

remote_platform = lldb.SBPlatform("remote-macosx"); 
remote_platform.SetWorkingDirectory("/private/tmp")
debugger.SetSelectedPlatform(remote_platform)

connect_options = lldb.SBPlatformConnectOptions("connect://localhost:1111"); 
err = remote_platform.ConnectRemote(connect_options)
if err.Success():
    print >> result, 'Connected to remote platform:'
    print >> result, 'hostname: %s' % (remote_platform.GetHostname())
    src = lldb.SBFileSpec("/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework", False)
    dst = lldb.SBFileSpec()
    # copy src to platform working directory since "dst" is empty
    err = remote_platform.Install(src, dst);
    if err.Success():
        print >> result, '%s installed successfully' % (src)
    else:
        print >> result, 'error: failed to install "%s": %s' % (src, err)


Implemented many calls needed in lldb-platform to be able to install a directory that contains symlinks, file and directories.

The remote lldb-platform can now launch GDB servers on the remote system so that remote debugging can be spawned through the remote platform when connected to a remote platform.

The API in SBPlatform is subject to change and will be getting many new functions.

llvm-svn: 195273
2013-11-20 21:07:01 +00:00
Colin Riley 61979ccad6 Fix MSVC build
The demangler added in r193708 from cxa_demangle.cpp uses language features which are not supported by the latest visual studio. In order to preserve the msvc build, this patch restores the previous (non)functionality in windows under msvc by disabling the demangler. 

llvm-svn: 195254
2013-11-20 15:19:08 +00:00
Jason Molenda 4ff132610a Flush the Process' cache of extended threads every time the
natural stop id is updated.
<rdar://problem/15496603> 

llvm-svn: 195177
2013-11-20 00:31:38 +00:00
Jason Molenda a6e9130d52 Add logging for the SB API which creates extended
threads.

Take a stab at fixing the too-soon freeing of the extended
backtrace thread list in Process.
<rdar://problem/15496603> 

llvm-svn: 195104
2013-11-19 05:44:41 +00:00
Jason Molenda 8ee9cb5891 Add a new SBThread::GetExtendedBacktraceOriginatingIndexID() method
(and same thing to Thread base class) which can be used when looking
at an ExtendedBacktrace thread; it will try to find the IndexID() of
the original thread that was executing this backtrace when it was
recorded.  If lldb can't find a record of that thread, it will return
the same value as IndexID() for the ExtendedBacktrace thread.

llvm-svn: 194912
2013-11-16 01:24:22 +00:00
Sylvestre Ledru f0f2d58086 Improve the set of the Python libraries during the cmake build.
Thanks to Kal Conley for the patch

llvm-svn: 194815
2013-11-15 14:15:10 +00:00
Jason Molenda a7b5afa91b Commit a work-in-progress system runtime for Mac OS X which won't
do anything right now.  Add a few new methods to the Thread base
class which HistoryThread needs.  I think I updated all the 
CMakeLists files correctly for the new plugin.

llvm-svn: 194756
2013-11-15 00:17:32 +00:00