Commit Graph

5534 Commits

Author SHA1 Message Date
Bruce Mitchener 4d1a26dcc2 Minumum -> Minimum.
llvm-svn: 212129
2014-07-01 21:18:35 +00:00
Deepak Panickal 9b35cf52d2 This creates a valid Python API for Windows, pending some issues. The changes included are -
- Ported the SWIG wrapper shell scripts to Python so that they would work on Windows too along with other platforms
 - Updated CMake handling to fix SWIG errors and manage sym-linking on Windows to liblldb.dll
 - More build fixes for Windows

The pending issues are that two Python modules, termios and pexpect are not available on Windows.
These are currently required for the Python command interpreter to be used from within LLDB.

llvm-svn: 212111
2014-07-01 17:57:19 +00:00
Todd Fiala 9be5049a01 Use native ::pid_t in Linux ProcessMonitor (local debugging).
There were a few places where we were not catching the possibility of negative
error codes in waitpid() calls.  This change fixes those remaining after
the llgs branch fixes to ProcessMonitor.

Change by Shawn Best.

llvm-svn: 212107
2014-07-01 16:30:53 +00:00
Zachary Turner 0ec7baa9f4 Fix Windows build after llgs upstream.
With _HAS_EXCEPTIONS=0, Windows' version of <thread> will fail to
compile because it calls __uncaught_exception(), which is compiled
out due to _HAS_EXCEPTIONS=0.  This just creates a stub version
of __uncaught_exception() which always fails.

llvm-svn: 212076
2014-07-01 00:18:46 +00:00
Todd Fiala 2850b1be2e Fixup Windows build breaks for the llgs upstream.
Also moves NativeRegisterContextLinux* files into the Linux directory.
These, like NativeProcessLinux, should only be built on Linux or a cross
compiler with proper headers.

llvm-svn: 212074
2014-06-30 23:51:35 +00:00
Todd Fiala af245d115b Add lldb-gdbserver support for Linux x86_64.
This change brings in lldb-gdbserver (llgs) specifically for Linux x86_64.
(More architectures coming soon).

Not every debugserver option is covered yet.  Currently
the lldb-gdbserver command line can start unattached,
start attached to a pid (process-name attach not supported yet),
or accept lldb attaching and launching a process or connecting
by process id.

The history of this large change can be found here:
https://github.com/tfiala/lldb/tree/dev-tfiala-native-protocol-linux-x86_64

Until mid/late April, I was not sharing the work and continued
to rebase it off of head (developed via id tfiala@google.com).  I switched over to
user todd.fiala@gmail.com in the middle, and once I went to github, I did
merges rather than rebasing so I could share with others.

llvm-svn: 212069
2014-06-30 21:05:18 +00:00
Todd Fiala 3dc2fb2fc0 Factored out Linux proc file reading into separate class.
Both NativeProcessLinux (in llgs branch) and Linux Host.cpp had similar code to handle /proc 
file reading.  I factored that out into a new Linux-specific ProcFileReader class and added a method
that the llgs branch will use for line-by-line parsing.

This change also adds numerous Linux-specific files to Xcode that were missing from the Xcode
project files.

Related to https://github.com/tfiala/lldb/issues/27

llvm-svn: 212015
2014-06-30 04:14:13 +00:00
Todd Fiala 6d6b55d153 Pull ProcessInfo and ProcessLaunchInfo out of Target/Process.
Elevate ProcessInfo and ProcessLaunchInfo into their own headers.
llgs will be using ProcessLaunchInfo but doesn't need to pull in
the rest of Process.h.

This also moves a bunch of implementation details from the header
declarations into ProcessInfo.cpp and ProcessLaunchInfo.cpp.

Tested on Ubuntu 14.04 Cmake and MacOSX Xcode.

Related to https://github.com/tfiala/lldb/issues/26.

llvm-svn: 212005
2014-06-30 00:30:53 +00:00
Zachary Turner a57596658a Don't truncate the target triple when initializing clang.
Reviewed by: Sean Callanan

Differential Revision: http://reviews.llvm.org/D4282

llvm-svn: 211968
2014-06-27 23:19:42 +00:00
Todd Fiala b91de7861c Fix ObjectFileELF to determine architectures independent of host.
Previously ObjectFileELF was simplifying and assuming the object file it was
looking at was the same as the host architecture/triple.  This would break
attempts to run, say, lldb on MacOSX against lldb-gdbserver on Linux since
the MacOSX lldb would say that the linux elf file was really an Apple MacOSX
architecture.  Chaos would ensue.

This change allows the elf file to parse ELF notes for Linux, FreeBSD and
NetBSD, and determine the OS appropriately from them.  It also initializes
the OS type from the ELF header OSABI if it is set (which it is for FreeBSD
but not for Linux).

Added a test with freebsd and linux images that verify that 
'(lldb) image list -t -A' prints out the expected architecture for each.

llvm-svn: 211907
2014-06-27 16:52:49 +00:00
Saleem Abdulrasool 28606954bf lldb: remove adhoc implementation of array_sizeof
Replace adhoc inline implementation of llvm::array_lengthof in favour of the
implementation in LLVM.  This is simply a cleanup change, no functional change
intended.

llvm-svn: 211868
2014-06-27 05:17:41 +00:00
Bruce Mitchener 6a7f33387d Fix a few typos.
llvm-svn: 211851
2014-06-27 02:42:12 +00:00
Zachary Turner cfcd7914da Fix silly compilation error.
llvm-svn: 211728
2014-06-25 18:40:58 +00:00
Zachary Turner 1536244594 Fix a bug in the IRMemoryMap which generated bogus allocations.
Previously, only the starting locations of the candidate interval
and the existing interval were compared.  To correctly detect
range intersections, it is necessary to compare the entire range
of both intervals against each other.

Reviewed by: scallanan

Differential Revision: http://reviews.llvm.org/D4286

llvm-svn: 211726
2014-06-25 18:37:19 +00:00
Zachary Turner 736d4d85db Replace GCC-specific intrinsic with portable alternative.
Not all supported compilers have GCC intrinsics, so this patch
uses the correct portable alternative.

Additionally, this patch fixes an off-by-one error.  __builtin_ffs
returns the 1-based index of the least-significant 1-bit, but the
function expects the base 2 logarithm of the number, which is
equivalent to the 0-based index of the least-significant 1-bit.

Reviewed by: Keno Fischer

Differential Revision: http://reviews.llvm.org/D4284

llvm-svn: 211669
2014-06-25 05:42:32 +00:00
Jim Ingham 106d02866d Added an option to turn OFF the "detach on error" behavior that was added
to debugserver when launching processes.

<rdar://problem/16216199>

llvm-svn: 211658
2014-06-25 02:32:56 +00:00
Ed Maste 2bc7643d10 Remove extra newline from log Printf
Clean up this one specifically, as it has the effect of double-spacing
the list of thread stop reasons, and substantially bloats the log file
when opening a core with hundreds of threads.

There are other cases of extra newlines.  Some of them do increase
readability, so avoid a general sweep for now.

llvm-svn: 211655
2014-06-25 00:38:35 +00:00
Greg Clayton 48672afb66 Patch from Keno Fischer to enable JITLoaderGDB with mach-o file support.
The patch is as is with the functionality left disabled for apple vendors because of performance regressions. If this is enabled it ends up searching for symbols in all shared libraries that are loadeded.

llvm-svn: 211638
2014-06-24 22:22:43 +00:00
Jim Ingham 6008924508 Rework fix in r201744. You really DO need to waitpid twice to get the
process fully reaped.  The race & bad behavior was because we were letting
the reaping thread in LLDB to also set the Process exit status, so debugserver
would sometimes be shut down before it got a chance to report the exit status, 
and then we got confused.

<rdar://problem/16555850>

llvm-svn: 211636
2014-06-24 21:51:42 +00:00
Todd Fiala 5d1b9c7386 Fix up Windows build for the SBUnixSignals addition.
Change by Zachary Turner.

llvm-svn: 211635
2014-06-24 21:38:31 +00:00
Jason Molenda fa4286eab7 Fix error handling for the AppleGetQueues and AppleGetPendingItems
ClangFunctions if the clang function compilation fails for any reason.
<rdar://problem/16793965> 

llvm-svn: 211549
2014-06-23 22:45:54 +00:00
Jason Molenda d81c483928 Temporarily roll back the parts of r211241 where I fixed a
mistake in the lock acquistion in HistoryUnwind and HistoryThread.
We've got a deadlock with one use case of HistoryUnwind; I
need to figure out what lock ordering is causing this and fix
it for real.  
<rdar://problem/17411904> 

llvm-svn: 211541
2014-06-23 21:30:15 +00:00
Sean Callanan 60400ecbce Don't set the ABI to apcs-gnu for non-ARM iOS targets (i.e., the
simulator).
    
<rdar://problem/17399406>

llvm-svn: 211536
2014-06-23 21:00:25 +00:00
Todd Fiala 802dc40228 Add API control of the signal disposition.
See http://reviews.llvm.org/D4221 for details.

This commit allows you to control the signals that lldb will suppress, stop or forward using the Python and C++ APIs.

Change by Russell Harmon.

Xcode build system changes (and any mistakes) by Todd Fiala.  Tested on MacOSX 10.9.3 and Xcode 6 beta.  (Xcode 5 is hitting the dependency checker crasher on all my systems).

llvm-svn: 211526
2014-06-23 19:30:49 +00:00
Todd Fiala d35f2b902b lldb: deal with non-portable PTRACE-related constants
See http://reviews.llvm.org/D4091 for details.

Change by Paul Osmialowski.

llvm-svn: 211503
2014-06-23 15:59:04 +00:00
Sylvestre Ledru 579cf37189 Remove useless call
llvm-svn: 211454
2014-06-21 23:51:07 +00:00
Todd Fiala f105f588b3 Fix a gdbremote bug in _M/_m stub support detection.
When a stub reported $#00 (unsupported) for _M and _m
packets, the unsupported response was not handled and
the client then marked the _M/_m commands as definitely
supported.  However, they would always fail, preventing
lldb's fallback InferiorCallMmap-based allocation strategy
from being used to attempt to allocate memory in the inferior
process space.

llvm-svn: 211425
2014-06-21 00:48:09 +00:00
Greg Clayton 06f09b58f7 Fixed the "log enable gdb-remote packets" to support dumping the binary memory read packet ('x') by printing out the binary data correctly using only printable characters and removing the 0x7d escapes so the memory is readable in the packet output.
llvm-svn: 211400
2014-06-20 20:41:07 +00:00
Greg Clayton 577508df83 Command files that switch input handlers didn't work, now they do.
The issue was when we called Debugger::RunIOHandler(), it would run the current IOHandler by activating it, and running it and then try to pop it and exit regardless of wether it was on top or not.

The new code will push the IOHandler that was passed in, and run the IOHandlers until the one passed in is successfully popped. This allows files for the "command source" to switch input handlers:

% cat /tmp/commands
br s -S alignLeftEdges:
br command add
bt
frame var
po self
DONE
b s -n main
br command add
bt
frame var
DONE

Note above we set a breakpoint, then add commands do it. The "br command add" will push the breakpoint comment gatherer until it sees "DONE" and then pop itself off the stack. The a new breakpoint will be set and it does the same thing again.

Now this file can be sourced from the command line:

% lldb -s /tmp/commands /path/to/a.out

And your breakpoints will be correctly setup!

<rdar://problem/17081650>

llvm-svn: 211329
2014-06-20 00:23:57 +00:00
John Wolfe 6f5cb5f14b Test commit: Correct type in two comments.
llvm-svn: 211296
2014-06-19 19:21:53 +00:00
Jim Ingham e4ce44197c Switch over to using object_getClass to get the class of an object. Previously we were
directly accessing the isa pointer of a class object to get its meta-class, but the isa
pointers are not simple pointers on arm64, so this would cause the stepping to fail.
object_getClass does whatever magic needs doing in this case.

<rdar://problem/17239690>

llvm-svn: 211289
2014-06-19 18:25:51 +00:00
Jim Ingham 2dfa00f6f2 Actually make a real scoped locker rather than constructing one that gets immediately thrown away...
llvm-svn: 211242
2014-06-18 23:40:13 +00:00
Jason Molenda 5cba569c4b Add a lock in the UnwindTable class so two Targets won't try
to modify the same UnwindTable object simultaneously.  Fix
HistoryThread and HistoryUnwind's mutex lock acqusition to
retain the lock for the duration of the operation instead of
releasing the temporary immediately.
<rdar://problem/17055023>

llvm-svn: 211241
2014-06-18 23:32:53 +00:00
Greg Clayton 9e42e92e43 Don't allow multiple line entries with the same address to exist sequentially.
The compiler, when JIT'ing code, can emit illegal DWARF line tables (address is line table sequences must increase). This changes fixes that issue by replacing previous line entries whose start address is the same with the new line entry to avoid having multiple line entries with the same address. Since the address range of lines entries is determined by the delta between the current and next line entry, this shouldn't cause any issues.

llvm-svn: 211212
2014-06-18 19:55:34 +00:00
Jim Ingham 5799e291e1 Add locking around the m_owners collection in the breakpoint site. If we are in the middle of "BreakpointLocation::ShouldStop" we don't
want other commands (like "break disable") to mutate the owners of this breakpoint out from under us.

<rdar://problem/17255589>

llvm-svn: 211136
2014-06-18 01:04:40 +00:00
Ed Maste 2e940a11e7 Avoid crashing on invalid or unreadable ELF core
Issue discovered during the GSoC 2014 project implementing FreeBSD
kernel support.  The existing elf-core Process plugin crashed trying
to read from /dev/mem (the kernel memory device).

Patch by Mike Ma.

llvm-svn: 211102
2014-06-17 14:14:33 +00:00
Greg Clayton 38f9cc425a Correctly classify code sections as code sections by using the S_ATTR_PURE_INSTRUCTIONS and S_ATTR_SOME_INSTRUCTIONS section flags.
Also correctly set the symbol type of symbols for S_REGULAR and other section types.

<rdar://problem/16896734>

llvm-svn: 211073
2014-06-16 22:53:16 +00:00
Greg Clayton c72f713068 Don't allow two threads to create/use the section list before it has been fully populated.
<rdar://problem/16937203>

llvm-svn: 211043
2014-06-16 19:44:24 +00:00
Todd Fiala 720cd3f689 Move x86-specific struct user code for Linux ProcessMonitor behind #define guards.
See http://reviews.llvm.org/D4092 for details.

Change by Paul Osmialowski.  (Minor tweaks to the comment by Todd.)

llvm-svn: 211026
2014-06-16 14:49:28 +00:00
Todd Fiala be03c36ef3 Properly terminated POSIX register sets with LLDB_INVALID_REGNUM.
RegisterSets are assumed to be terminated by this value.  Loops over
register set values would fail without LLDB_INVALID_REGNUM terminating
the list.  This change adjusts the static check to account for the
size of the register set regnum list being one larger than the expected
valid register set count.

llvm-svn: 210964
2014-06-14 03:13:01 +00:00
Jason Molenda b51d5cd84f Add a check that we found an ABI plugin before calling a method on it.
llvm-svn: 210942
2014-06-13 22:04:15 +00:00
Greg Clayton fc56a0123b Don't dereference target if it is NULL.
Caught by the clang static analyzer by Jason Molenda.

llvm-svn: 210941
2014-06-13 21:57:58 +00:00
Saleem Abdulrasool 6ae82a66ac Interpreter: kill some dead code
Remove commented out code and an unnecessary associated scope.  No functional
change.

llvm-svn: 210882
2014-06-13 03:30:47 +00:00
Saleem Abdulrasool e014729d34 Interpreter: explicitly initialize base class
Initialise base class std::enable_shared_from_this explicitly.  Identified by
GCC.

llvm-svn: 210881
2014-06-13 03:30:45 +00:00
Saleem Abdulrasool e8e4ae9f78 Core: address comparison of signed and unsigned types
Add a cast to ensure that the comparison is done with the same sign type.
Identified by GCC.

llvm-svn: 210880
2014-06-13 03:30:42 +00:00
Saleem Abdulrasool 3924d754e5 Remove unused variables
Address the 'variable set but not used' warning from GCC.  In some cases a few
additional calls were removed where there should be no visible side effects of
the calls (i.e. should not effect any cached state).

llvm-svn: 210879
2014-06-13 03:30:39 +00:00
Jason Molenda 705b180964 Initial merge of some of the iOS 8 / Mac OS X Yosemite specific
lldb support.  I'll be doing more testing & cleanup but I wanted to
get the initial checkin done.

This adds a new SBExpressionOptions::SetLanguage API for selecting a
language of an expression.

I added adds a new SBThread::GetInfoItemByPathString for retriving
information about a thread from that thread's StructuredData.

I added a new StructuredData class for representing
key-value/array/dictionary information (e.g. JSON formatted data).
Helper functions to read JSON and create a StructuredData object,
and to print a StructuredData object in JSON format are included.

A few Cocoa / Cocoa Touch data formatters were updated by Enrico
to track changes in iOS 8 / Yosemite.

Before we query a thread's extended information, the system runtime may 
provide hints to the remote debug stub that it will use to retrieve values
out of runtime structures.  I added a new SystemRuntime method 
AddThreadExtendedInfoPacketHints which allows the SystemRuntime to add 
key-value type data to the initial request that we send to the remote stub.

The thread-format formatter string can now retrieve values out of a thread's
extended info structured data.  The default thread-format string picks up
two of these - thread.info.activity.name and thread.info.trace_messages.

I added a new "jThreadExtendedInfo" packet in debugserver; I will
add documentation to the lldb-gdb-remote.txt doc soon.  It accepts
JSON formatted arguments (most importantly, "thread":threadnum) and
it returns a variety of information regarding the thread to lldb
in JSON format.  This JSON return is scanned into a StructuredData
object that is associated with the thread; UI layers can query the
thread's StructuredData to see if key-values are present, and if
so, show them to the user.  These key-values are likely to be
specific to different targets with some commonality among many
targets.  For instance, many targets will be able to advertise the
pthread_t value for a thread.

I added an initial rough cut of "thread info" command which will print
the information about a thread from the jThreadExtendedInfo result.
I need to do more work to make this format reasonably.

Han Ming added calls into the pmenergy and pmsample libraries if
debugserver is run on Mac OS X Yosemite to get information about the
inferior's power use.

I added support to debugserver for gathering the Genealogy information
about threads, if it exists, and returning it in the jThreadExtendedInfo
JSON result.

llvm-svn: 210874
2014-06-13 02:37:02 +00:00
Greg Clayton a2715cf108 Added the ability to save core files:
(lldb) file /bin/ls
(lldb) b malloc
(lldb) run
(lldb) process save-core /tmp/ls.core

Each ObjectFile plug-in now has the option to save core files by registering a new static callback.

llvm-svn: 210864
2014-06-13 00:54:12 +00:00
Alp Toker 10933d1489 Track clang changes from r210764
llvm-svn: 210765
2014-06-12 11:14:32 +00:00
Greg Clayton bc88d938f7 Multi-line expressions in Xcode now have a space between the line number and the expression text.
<rdar://problem/17238093>

llvm-svn: 210718
2014-06-11 23:10:41 +00:00