aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Host
AgeCommit message (Collapse)AuthorFilesLines
2016-08-12Merging r277997, r277999 and r278001:Hans Wennborg1-1/+1
------------------------------------------------------------------------ r277997 | labath | 2016-08-08 05:26:57 -0700 (Mon, 08 Aug 2016) | 3 lines Remove _isatty from Android.h it is just #defined to isatty anyway, which lldb already knows how to use. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r277999 | labath | 2016-08-08 05:40:11 -0700 (Mon, 08 Aug 2016) | 3 lines Remove SYS_tgkill from Android.h instead, use __NR_tgkill directly, which seems to be the preferred form in the codebase anyway. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r278001 | labath | 2016-08-08 06:13:03 -0700 (Mon, 08 Aug 2016) | 5 lines Clean up linux/Ptrace.h This removes references to PT_XXX macros from the file, as they were not used anyway. It also changes the macro used to check for the definition of __ptrace_request, as there are other C libraries which do not define this type. ------------------------------------------------------------------------ llvm-svn: 278540
2016-07-14Editing multi-line content in a terminal environment involves a lot ofKate Stone1-37/+81
trade-offs. When LLDB's multi-line editing support was first introduced for expressions / REPL contexts the behavior was as follows: * The Return key is treated as a line-break except at the end of the input buffer, where a completeness test is applied This worked well enough when writing code, and makes it trivial to insert new lines above code you've already typed. Just use cursor navigation to move up and type freely. Where it was awkward is that the gesture to insert a line break and end editing is conflated for most people. Sometimes you want Return to end the editing session and other times you want to insert a line break. This commit changes the behavior as follows: * The Return key is treated as the end of editing except at the end of the input buffer, where a completeness test is applied * The Meta+Return sequence is always treated as a line break. This is consistent with conventions in Facebook and elsewhere since Alt/Option+Return is often mapped to Meta+Return. The unfortunate exception is on macOS where this *can* be the case, but isn't by default. Sigh. Note that by design both before and after the patch pasting a Return character always introduces a line break. <rdar://problem/26886287> llvm-svn: 275482
2016-07-12Add logging to Linux Host::GetProcessAndStatInfo.Oleksiy Vyalov1-4/+16
llvm-svn: 275198
2016-06-23Revert r273524, it may have been the cause of a linux testbot failureJason Molenda2-2/+2
for TestNamespaceLookup.py; didn't see anything obviously wrong so I'll need to look at this more closely before re-committing. (passed OK on macOS ;) llvm-svn: 273531
2016-06-23Do some minor renames of "Mac OS X" to "macOS".Jason Molenda2-2/+2
There's uses of "macosx" that will be more tricky to change, like in triples (e.g. "x86_64-apple-macosx10.11") - for now I'm just updating source comments and strings printed for humans. llvm-svn: 273524
2016-06-21Fix typo in eOpenOptionDontFollowSymlinksFrancis Ricci1-1/+1
Summary: Fix capitalization Reviewers: labath, sas, clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D21422 llvm-svn: 273225
2016-06-07Don't use SO_REUSEADDR for *client* socketsPavel Labath1-3/+0
Summary: In the case of client sockets, we are not binding to a specific port, so we should be able to just request a new one. Disregarding refactors, this code has been here since the initial LLDB checkin, so I was unable to figure out whether it was added as a fix for a specific problem, or just for symmetry with server sockets, but I see no side-effect from removing it now. I was still able to create 10000 connections within a couple of seconds, so I think it's unlikely we will exhaust the port space (previously, I would get an error after a couple thousand connections). This fixes an occasional issue with connecting to the android debug bridge deamon on OSX when running the test suite, which would occasionaly fail with EADDRINUSE. My best guess is that this was happening because two processes were assigned the same client port number, and then things blew up because they were both trying to connect to the same ADB server port. I have not observed this issue happening on Linux or Windows. Reviewers: clayborg Subscribers: tberghammer, danalbert, lldb-commits Differential Revision: http://reviews.llvm.org/D21088 llvm-svn: 272041
2016-06-07LLDB is leaking memory in Editline.cpp on MacOSX. Greg Clayton1-43/+62
When USE_SETUPTERM_WORKAROUND is enabled, we were calling setupterm() multiple times and leaking memory on each subsequent call. This is now fixed by calling setupterm() once in the constructor and tracking if we have already setup a terminal for a file descriptor. Calls to "el_set (m_editline, EL_ADDFN, ..." were leaking memory. If we switch over to call el_wset with wide strings when LLDB_EDITLINE_USE_WCHAR is set, then we no longer leak memory each time we construct a new Editline object. The calls to "el_set (m_editline, EL_ADDFN, ..." were changed over to call "el_wset (m_editline, EL_ADDFN, ...". Note that when LLDB_EDITLINE_USE_WCHAR is not defined, then el_wset is #define'ed to el_set. All strings are wrapped in EditLineConstString which will use wide strings when needed, and normal C strings when LLDB_EDITLINE_USE_WCHAR is not defined. <rdar://problem/26677627> llvm-svn: 272036
2016-05-19second pass over removal of Mutex and ConditionSaleem Abdulrasool1-3/+3
llvm-svn: 270024
2016-05-18remove use of Mutex in favour of std::{,recursive_}mutexSaleem Abdulrasool6-84/+78
This is a pretty straightforward first pass over removing a number of uses of Mutex in favor of std::mutex or std::recursive_mutex. The problem is that there are interfaces which take Mutex::Locker & to lock internal locks. This patch cleans up most of the easy cases. The only non-trivial change is in CommandObjectTarget.cpp where a Mutex::Locker was split into two. llvm-svn: 269877
2016-05-13Disable HostThread::Cancel assertion on FreeBSDEd Maste1-0/+2
It is still used by ProcessMonitor::StopMonitoringChildProcess and ProcessMonitor::StopOpThread. llvm-svn: 269434
2016-05-12Fix some long standing issues that caused tests to be flaky. Greg Clayton1-6/+12
The main issues were: - Listeners recently were converted over to used by getting a shared pointer to a listener. And when they listened to broadcasters they would get a strong reference added to them meaning the listeners would never go away. This caused memory usage to increase and would cause performance issue if many steps were done. - The lldb_private::Process private state thread had an issue where if a "stop" contol signal was attempted to be sent to that thread, it could end up not responding in 2 seconds and end up getting cancelled which might cause us to cancel a thread that had a mutex locked and it would deadlock the test. This change makes broadcasters hold onto weak references to listeners. It also fixes some bad threading code that had races inside of it by making the m_events_mutex be non-recursive and getting rid of fragile use of a Predicate<bool> to say that new events are available, and replacing it with using the m_events_mutex with a new m_events_condition to control access to the events in a safer way. The private state thread now uses a safer way to communicate that the control event has been received by the private state thread: it makes a EventDataReceipt instance that it attaches to the event that sends the control to the private state thread and used this to synchronize the fact that the private state thread has received the event instead of using a Predicate<bool> to convey the info. When the signal event is received, it will pull the event off of the queue in the private state thread and cause the EventData::DoOnRemoval() to be called, which will signal that the event has been received. This cleans up the signal delivery notification so it doesn't rely on a member variable of the process class to convey the info. std::shared_ptr<EventDataReceipt> event_receipt_sp(new EventDataReceipt()); m_private_state_control_broadcaster.BroadcastEvent(signal, event_receipt_sp); <rdar://problem/26256353> Listeners are being kept around longer than they should be due to recent changs <rdar://problem/26256258> Private process state thread can be cancelled and cause deadlocks in test suite llvm-svn: 269377
2016-05-11Generalize child process monitoring functionsPavel Labath7-64/+39
Summary: This replaces the C-style "void *" baton of the child process monitoring functions with a more C++-like API taking a std::function. The motivation for this was that it was very difficult to handle the ownership of the object passed into the callback function -- each caller ended up implementing his own way of doing it, some doing it better than others. With the new API, one can just pass a smart pointer into the callback and all of the lifetime management will be handled automatically. This has enabled me to simplify the rather complicated handshake in Host::RunShellCommand. I have left handling of MonitorDebugServerProcess (my original motivation for this change) to a separate commit to reduce the scope of this change. Reviewers: clayborg, zturner, emaste, krytarowski Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D20106 llvm-svn: 269205
2016-05-03Revert "Add a read_full_buffer argument to ConnectionFileDescriptor::Read"Pavel Labath2-33/+21
This reverts commit r268380 as it breaks windows build (I forgot to make neccesary adjustments to ConnectionGenericFileWindows). llvm-svn: 268384
2016-05-03Add a read_full_buffer argument to ConnectionFileDescriptor::ReadPavel Labath2-21/+33
Summary: AdbClient was attempting to handle the case where the socket input arrived in pieces, but it was failing to handle the case where the connection was closed before that happened. In this case, it would just spin in an infinite loop calling Connection::Read. (This was also the cause of the spurious timeouts on the darwin->android buildbot. The exact cause of the premature EOF remains to be investigated, but is likely a server bug.) Since this wait-for-a-certain-number-of-bytes seems like a useful functionality to have, I am moving it (with the infinite loop fixed) to the Connection class, and adding an appropriate test for it. Reviewers: clayborg, zturner, ovyalov Subscribers: tberghammer, danalbert, lldb-commits Differential Revision: http://reviews.llvm.org/D19533 llvm-svn: 268380
2016-04-27Renamed system plugin directory to address https://bugs.swift.org/browse/SR-1093Kate Stone1-1/+1
llvm-svn: 267749
2016-04-21Host: fix some -Wformat-pedantic warningsSaleem Abdulrasool1-6/+6
Add explicit casts for function pointer to void * for %p conversion. NFC. llvm-svn: 267000
2016-04-19llvm::sys::path::home_directory() relies on having "HOME" set in the ↵Greg Clayton1-1/+15
environment and that might not always be set. Our FileSpec class uses this function to resolve any paths that start with "~/" on systems that support home directories as '~'. I have modified FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path) to deal with the cases where llvm::sys::path::home_directory() returns false by digging a little further on unix systems and setting "HOME" in the environment so that subsequent calls to llvm::sys::path::home_directory() will succeed. I also added a test to ensure we don't regress. <rdar://problem/25342377> llvm-svn: 266832
2016-04-19Fix Windows build.Chaoren Lin1-0/+1
llvm-svn: 266702
2016-04-14Support Linux on SystemZ as platformUlrich Weigand1-0/+1
This patch adds support for Linux on SystemZ: - A new ArchSpec value of eCore_s390x_generic - A new directory Plugins/ABI/SysV-s390x providing an ABI implementation - Register context support - Native Linux support including watchpoint support - ELF core file support - Misc. support throughout the code base (e.g. breakpoint opcodes) - Test case updates to support the platform This should provide complete support for debugging the SystemZ platform. Not yet supported are optional features like transaction support (zEC12) or SIMD vector support (z13). There is no instruction emulation, since our ABI requires that all code provide correct DWARF CFI at all PC locations in .eh_frame to support unwinding (i.e. -fasynchronous-unwind-tables is on by default). The implementation follows existing platforms in a mostly straightforward manner. A couple of things that are different: - We do not use PTRACE_PEEKUSER / PTRACE_POKEUSER to access single registers, since some registers (access register) reside at offsets in the user area that are multiples of 4, but the PTRACE_PEEKUSER interface only allows accessing aligned 8-byte blocks in the user area. Instead, we use a s390 specific ptrace interface PTRACE_PEEKUSR_AREA / PTRACE_POKEUSR_AREA that allows accessing a whole block of the user area in one go, so in effect allowing to treat parts of the user area as register sets. - SystemZ hardware does not provide any means to implement read watchpoints, only write watchpoints. In fact, we can only support a *single* write watchpoint (but this can span a range of arbitrary size). In LLDB this means we support only a single watchpoint. I've set all test cases that require read watchpoints (or multiple watchpoints) to expected failure on the platform. [ Note that there were two test cases that install a read/write watchpoint even though they nowhere rely on the "read" property. I've changed those to simply use plain write watchpoints. ] Differential Revision: http://reviews.llvm.org/D18978 llvm-svn: 266308
2016-04-14FileSpec: make matching separator-agnostic againPavel Labath1-0/+2
Summary: In D18689, I removed the call to Normalize() in FileSpec::SetFile, because it no longer seemed needed, and it resolved a quirk in the FileSpec API (spec.GetCString() returnes a path with backslashes, but spec.GetDirectory().GetCString() has forward slashes). This turned out to be a problem because we would consider paths with different separators as different (which led to unresolved breakpoints for instance). Here, I am putting back in the call to Normalize() and adding a unittest for FileSpec::Equal. I am commenting out the GetDirectory unittests until we figure out the what is the expected behaviour here. Reviewers: zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D19060 llvm-svn: 266286
2016-04-12Revert to using libdispatch to reap threads on MacOSX. Code was accidentally ↵Greg Clayton1-21/+33
checked in that is now reverted. <rdar://problem/25643874> llvm-svn: 266118
2016-04-04Make FileSpec handling platform-independentPavel Labath1-26/+100
Summary: Even though FileSpec attempted to handle both kinds of path syntaxes (posix and windows) on both platforms, it relied on the llvm path library to do its work, whose behavior differed on different platforms. This led to subtle differences in FileSpec behavior between platforms. This replaces the pieces of the llvm library with our own implementations. The functions are simply copied from llvm, with #ifdefs replaced by runtime checks for ePathSyntaxWindows. Reviewers: zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D18689 llvm-svn: 265299
2016-03-22Unicode support on Win32.Zachary Turner12-149/+378
Win32 API calls that are Unicode aware require wide character strings, but LLDB uses UTF8 everywhere. This patch does conversions wherever necessary when passing strings into and out of Win32 API calls. Patch by Cameron Differential Revision: http://reviews.llvm.org/D17107 Reviewed By: zturner, amccarth llvm-svn: 264074
2016-03-19Add a DiagnosticManager replace error streams in the expression parser.Sean Callanan1-29/+17
We want to do a better job presenting errors that occur when evaluating expressions. Key to this effort is getting away from a model where all errors are spat out onto a stream where the client has to take or leave all of them. To this end, this patch adds a new class, DiagnosticManager, which contains errors produced by the compiler or by LLDB as an expression is created. The DiagnosticManager can dump itself to a log as well as to a string. Clients will (in the future) be able to filter out the errors they're interested in by ID or present subsets of these errors to the user. This patch is not intended to change the *users* of errors - only to thread DiagnosticManagers to all the places where streams are used. I also attempt to standardize our use of errors a bit, removing trailing newlines and making clients omit 'error:', 'warning:' etc. and instead pass the Severity flag. The patch is testsuite-neutral, with modifications to one part of the MI tests because it relied on "error: error:" being erroneously printed. This patch fixes the MI variable handling and the testcase. <rdar://problem/22864976> llvm-svn: 263859
2016-03-16Fix null pointer "dereference" in DomainSocketPavel Labath1-1/+1
offsetof is the official way to get the offset of a field in a structure. llvm-svn: 263637
2016-03-15Remove unnecessary <limits> includes.Jim Ingham1-2/+4
llvm-svn: 263588
2016-03-11Fix a couple of cornercases in FileSpec + testsPavel Labath1-24/+22
Summary: This fixes a couple of corner cases in FileSpec, related to AppendPathComponent and handling of root directory (/) file spec. I add a bunch of unit tests for the new behavior. Summary of changes: FileSpec("/bar").GetCString(): before "//bar", after "/bar". FileSpec("/").CopyByAppendingPathComponent("bar").GetCString(): before "//bar", after "/bar". FileSpec("C:", ePathSyntaxWindows).CopyByAppendingPathComponent("bar").GetCString(): before "C:/bar", after "C:\bar". Reviewers: clayborg, zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D18044 llvm-svn: 263207
2016-03-10Fixed the python interpreter so that it correctly inherits the top ↵Greg Clayton1-51/+0
IOHandler's files instead of always using stdin/out/err. Removed lldb_private::File::Duplicate() and the copy constructor and the assignment operator that used to duplicate the file handles and made them private so no one uses them. Previously the lldb_private::File::Duplicate() function duplicated files that used file descriptors, (int) but not file streams (FILE *), so the lldb_private::File::Duplicate() function only worked some of the time. No one else excep thee ScriptInterpreterPython was using these functions, so that aren't needed nor desired. Previously every time you would drop into the python interpreter we would duplicate files, and now we avoid this file churn. <rdar://problem/24877720> llvm-svn: 263161
2016-03-02Add support for reading line tables from PDB files.Zachary Turner2-7/+33
PDB is Microsoft's debug information format, and although we cannot yet generate it, we still must be able to consume it. Reason for this is that debug information for system libraries (e.g. kernel32, C Runtime Library, etc) only have debug info in PDB format, so in order to be able to support debugging of system code, we must support it. Currently this code should compile on every platform, but on non-Windows platforms the PDB plugin will return 0 capabilities, meaning that for now PDB is only supported on Windows. This may change in the future, but the API is designed in such a way that this will require few (if any) changes on the LLDB side. In the future we can just flip a switch and everything will work. This patch only adds support for line tables. It does not return information about functions, types, global variables, or anything else. This functionality will be added in a followup patch. Differential Revision: http://reviews.llvm.org/D17363 Reviewed by: Greg Clayton llvm-svn: 262528
2016-02-26Fix all of the unannotated switch cases to annotate the fall through or do ↵Greg Clayton2-20/+20
the right thing and break. llvm-svn: 261950
2016-02-24Some fixes for case insensitive paths on Windows.Zachary Turner1-53/+61
Paths on Windows are not case-sensitive. Because of this, if a file is called main.cpp, you should be able to set a breakpoint on it by using the name Main.cpp. In an ideal world, you could just tell people to match the case, but in practice this can be a real problem as it requires you to know whether the person who compiled the program ran "clang++ main.cpp" or "clang++ Main.cpp", both of which would work, regardless of what the file was actually called. This fixes http://llvm.org/pr22667 Patch by Petr Hons Differential Revision: http://reviews.llvm.org/D17492 Reviewed by: zturner llvm-svn: 261771
2016-02-23[linux] Remove all traces of signalfd(2)Pavel Labath1-5/+0
Summary: Signalfd is not used in the code anymore, and given that the same functionality can be achieved with the new MainLoop class, it's unlikely we will need it in the future. Remove all traces of it. Reviewers: tberghammer, ovyalov Subscribers: tberghammer, danalbert, srhines, lldb-commits Differential Revision: http://reviews.llvm.org/D17510 llvm-svn: 261631
2016-02-19Don't use an atexit handler for cleaning up the temp directory.Zachary Turner1-16/+17
Differential Revision: http://reviews.llvm.org/D17420 llvm-svn: 261353
2016-02-04Make HostThread SetName work on OS X. GetName doesn't currently work, the ↵Jim Ingham2-14/+10
code that was in GetName actually got the queue name not the thread name and anyway didn't actually work to do that. So I just deleted it with a fixme. <rdar://problem/24487554> llvm-svn: 259818
2016-02-03Fix an off-by-one in SocketTest::DecodeHostAndPortPavel Labath1-1/+1
65535 is still a valid port. This should fix the android failures we were getting when we chose to connect over 65535 to the remote lldb-server. llvm-svn: 259638
2016-02-02We try to avoid static objects. These are on the error path for unsupported ↵Jim Ingham1-4/+4
features in the socket, so just returning freshly constructed objects is fine. llvm-svn: 259443
2016-01-28Remove autoconf support from source directories.Eugene Zelenko2-79/+0
Differential revision: http://reviews.llvm.org/D16662 llvm-svn: 259098
2016-01-20Fix a problem where we were not calling fcntl() with the correct arguments ↵Enrico Granata1-2/+2
for F_DUPFD On Mac OS X, this was working just fine in debug builds (presumably, because the right value ended up being at the right location for the variadic ABI), but not in Release builds As a result, we were seeing failures with commands that set their own immediate output stream - only in Release builds, which always makes for a fun little investigation I have removed those fcntl() calls and replaced them with dup() calls. This fixes the issue in both Debug and Release builds llvm-svn: 258367
2016-01-13Fix TestProcessLaunch for Python 3.Zachary Turner1-2/+33
There were a number of problems preventing this from working: 1. The SWIG typemaps for converting Python lists to and from C++ arrays were not updated for Python 3. So they were doing things like PyString_Check instead of using the PythonString from PythonDataObjects. 2. ProcessLauncherWindows was ignoring the environment completely. So any test that involved launching an inferior with any kind of environment variable would have failed. 3. The test itself was using process.GetSTDOUT(), which isn't implemented on Windows. So this was changed to save the value of the environment variable in a local variable and have the debugger look at the value of the variable. llvm-svn: 257669
2016-01-13Fix an issue where scripted commands would not actually print any of their ↵Enrico Granata1-0/+9
output if an immediate output file was set in the result object via a Python file object Fixes rdar://24130303 llvm-svn: 257644
2016-01-11Make the aarch64 lldb-server capable of debugging arm32 applicationsTamas Berghammer1-1/+1
Differential revision: http://reviews.llvm.org/D15533 llvm-svn: 257322
2015-12-14[Editline] Redesign automatic indentation fix command for robustnessKate Stone1-20/+33
The FixIndentationCommand implementation has proven to be fragile across various libedit iterations. This patch reworks the command to use the same basic strategy as when moving between lines in a multi-line edit session: when indentation changes are required, exit line editing completely and restart with amended content. This approach won't be susceptible to subtle behavior differences libedit has introduced over time. llvm-svn: 255548
2015-11-21Add code to PlatformDarwin and HostInfoMacOSX so they return theJason Molenda1-0/+13
correct OS type when running on an apple tv or apple watch. Also, in TargetList::CreateTargetInternal, check that a platform is returned by GetPlatformForArchitecture fallback instead of adding it to the vector of platforms unconditionally; we can end up crashing when we call a member function on it later. <rdar://problem/23601982>, <rdar://problem/21292886> llvm-svn: 253763
2015-11-19Fix an issue where LLDB would not launch argdumper correctly if there were ↵Enrico Granata2-2/+5
spaces in the path to it llvm-svn: 253599
2015-11-07Fix pessimizing moves. Found by clang.Davide Italiano1-1/+1
llvm-svn: 252409
2015-11-07Make lldb::endian::InlHostByteOrder() private.Bruce Mitchener3-3/+3
Summary: Since this is within the lldb namespace, the compiler tries to export a symbol for it. Unfortunately, since it is inlined, the symbol is hidden and this results in a mess of warnings when building on OS X with cmake. Moving it to the lldb_private namespace eliminates that problem. Reviewers: clayborg Subscribers: emaste, lldb-commits Differential Revision: http://reviews.llvm.org/D14417 llvm-svn: 252396
2015-11-06Jim thinks we shouldn't bother to pollute the svn repo with theseJason Molenda1-2/+2
internal details, so I'll pull it back to just our own branch of the sources. llvm-svn: 252254
2015-11-05Update the invocation to dsymForUUID (a script plugin usedJason Molenda1-2/+2
at Apple, called by the DebugSymbols private framework to find a dSYM for a UUID on mac) to include the latest args we need to use when looking for kernel binaries etc. llvm-svn: 252235
2015-11-05LLDB needs a mutex around getopt_long_only() function calls to avoid ↵Jim Ingham1-1/+3
multi-threading option parsing issues. <rdar://problem/17052381> llvm-svn: 252111