Commit Graph

1280 Commits

Author SHA1 Message Date
Pavel Labath 10c41f37b5 replace uses of strerror with llvm::sys::StrError
strerror is not thread-safe. llvm's StrError tries hard to retrieve the
string in a thread-safe way and falls back to strerror only if it does
not have another way.

llvm-svn: 304795
2017-06-06 14:06:17 +00:00
Hafiz Abid Qadeer f64177ea83 Fix a small issue with -var-update.
If the variable was a pointer, code was ignoring the change in the
pointee.

Discussed in
http://lists.llvm.org/pipermail/lldb-dev/2017-May/012435.html

llvm-svn: 304400
2017-06-01 10:33:13 +00:00
Zachary Turner 97206d5727 Rename Error -> Status.
This renames the LLDB error class to Status, as discussed
on the lldb-dev mailing list.

A change of this magnitude cannot easily be done without
find and replace, but that has potential to catch unwanted
occurrences of common strings such as "Error".  Every effort
was made to find all the obvious things such as the word "Error"
appearing in a string, etc, but it's possible there are still
some lingering occurences left around.  Hopefully nothing too
serious.

llvm-svn: 302872
2017-05-12 04:51:55 +00:00
Chris Bieneman 1182779917 Re-landing IPv6 support for LLDB Host
This support was landed in r300579, and reverted in r300669 due to failures on the bots.

The failures were caused by sockets not being properly closed, and this updated version of the patches should resolve that.

Summary from the original change:

This patch adds IPv6 support to LLDB/Host's TCP socket implementation. Supporting IPv6 involved a few significant changes to the implementation of the socket layers, and I have performed some significant code cleanup along the way.

This patch changes the Socket constructors for all types of sockets to not create sockets until first use. This is required for IPv6 support because the socket type will vary based on the address you are connecting to. This also has the benefit of removing code that could have errors from the Socket subclass constructors (which seems like a win to me).

The patch also slightly changes the API and behaviors of the Listen/Accept pattern. Previously both Listen and Accept calls took an address specified as a string. Now only listen does. This change was made because the Listen call can result in opening more than one socket. In order to support listening for both IPv4 and IPv6 connections we need to open one AF_INET socket and one AF_INET6 socket. During the listen call we construct a map of file descriptors to addrin structures which represent the allowable incoming connection address. This map removes the need for taking an address into the Accept call.

This does have a change in functionality. Previously you could Listen for connections based on one address, and Accept connections from a different address. This is no longer supported. I could not find anywhere in LLDB where we actually used the APIs in that way. The new API does still support AnyAddr for allowing incoming connections from any address.

The Listen implementation is implemented using kqueue on FreeBSD and Darwin, WSAPoll on Windows and poll(2) everywhere else.

https://reviews.llvm.org/D31823

llvm-svn: 301492
2017-04-26 23:17:20 +00:00
Jason Molenda 11506a9d1c Correct the names of some target conditional defines in debugserver.
llvm-svn: 301034
2017-04-21 20:19:28 +00:00
Pavel Labath 107e694271 Revert yesterdays IPv6 patches
The break the linux bots (and probably any other machine which would
run the test suite in a massively parallel way). The problem is that it
can happen that we only successfully create an IPv6 listening socket
(because the relevant IPv4 port is used by another process) and then the
connecting side attempts to connect to the IPv4 port and fails.

It's not very obvious how to fix this problem, so I am reverting this
until we come up with a solution.

llvm-svn: 300669
2017-04-19 10:13:22 +00:00
Chris Bieneman d01a2fa38d Update DebugServer to support IPv6 over TCP
Summary: This patch adds IPv6 support to debugserver. It follows a similar pattern to the changes proposed for LLDB/Host except that the listen implementation is only with kqueue(2) because debugserver is only supported on Darwin.

Reviewers: jingham, jasonmolenda, clayborg

Reviewed By: clayborg

Subscribers: mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D31824

llvm-svn: 300580
2017-04-18 20:01:59 +00:00
Chris Bieneman 31e7c5e89f Update LLDB Host to support IPv6 over TCP
Summary:
This patch adds IPv6 support to LLDB/Host's TCP socket implementation. Supporting IPv6 involved a few significant changes to the implementation of the socket layers, and I have performed some significant code cleanup along the way.

This patch changes the Socket constructors for all types of sockets to not create sockets until first use. This is required for IPv6 support because the socket type will vary based on the address you are connecting to. This also has the benefit of removing code that could have errors from the Socket subclass constructors (which seems like a win to me).

The patch also slightly changes the API and behaviors of the Listen/Accept pattern. Previously both Listen and Accept calls took an address specified as a string. Now only listen does. This change was made because the Listen call can result in opening more than one socket. In order to support listening for both IPv4 and IPv6 connections we need to open one AF_INET socket and one AF_INET6 socket. During the listen call we construct a map of file descriptors to addrin structures which represent the allowable incoming connection address. This map removes the need for taking an address into the Accept call.

This does have a change in functionality. Previously you could Listen for connections based on one address, and Accept connections from a different address. This is no longer supported. I could not find anywhere in LLDB where we actually used the APIs in that way. The new API does still support AnyAddr for allowing incoming connections from any address.

The Listen implementation is implemented using kqueue on FreeBSD and Darwin, WSAPoll on Windows and poll(2) everywhere else.

Reviewers: zturner, clayborg

Subscribers: jasonmolenda, labath, lldb-commits, emaste

Differential Revision: https://reviews.llvm.org/D31823

llvm-svn: 300579
2017-04-18 20:01:52 +00:00
Chris Bieneman efd065e6a0 Support Unit Testing debugserver
Summary:
This patch refactors the CMake build system's support for building debugserver to allow us to build the majority of debugserver's sources into the debugserverCommon library which can then be reused by unit tests.

The first unit test I've written tests debug server's ability to accept incoming connections from LLDB. The test forks the process, and one side creates a listening socket using debugserver's socket API, the other side creates a transmitting socket using LLDB's TCPSocket class.

I have no clue where to even start getting this connected into the LLDB Xcode project, so for now these tests are CMake-only.

Reviewers: zturner, labath, jasonmolenda

Subscribers: lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D31357

llvm-svn: 300111
2017-04-12 21:56:29 +00:00
Zachary Turner 4479ac15c9 iwyu fixes on lldbUtility.
This patch makes adjustments to header file includes in
lldbUtility based on recommendations by the iwyu tool
(include-what-you-use).  The goal here is to make sure that
all files include the exact set of headers which are needed
for that file only, to eliminate cases of dead includes (e.g.
someone deleted some code but forgot to delete the header
includes that that code necessitated), and to eliminate the
case where header includes are picked up transitively.

llvm-svn: 299676
2017-04-06 18:12:24 +00:00
Ilia K a97973ab4e Enable lldm-mi commands -stack-list-locals -stack-list-variables and -var-create to work only with variables in scope
Patch by ayuckhulk

Reviewers: abidh, lldb-commits, ki.stfu

Reviewed By: ki.stfu

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D31073

llvm-svn: 299417
2017-04-04 08:00:28 +00:00
Jason Molenda e20648595b Back out temporary masking of EXC_SYSCALL mach exceptions.
<rdar://problem/31359720> 

llvm-svn: 299345
2017-04-03 00:59:47 +00:00
Jason Molenda 2ccbac3fee Mask out EXC_SYSCALL exceptions as well.
<rdar://problem/31335814> 

llvm-svn: 299040
2017-03-30 00:23:46 +00:00
Zachary Turner 5713a05b5b Move FileSpec from Host -> Utility.
llvm-svn: 298536
2017-03-22 18:40:07 +00:00
Kamil Rytarowski 1a3d19dd25 Add stub for PluginProcessNetBSD
Summary:
This is the base for introduction of further features to support Process Tracing on NetBSD, in local and remote setup.

This code is also a starting point to synchronize the development with other BSDs. Currently NetBSD is ahead and other systems can catch up.

Sponsored by <The NetBSD Foundation>

Reviewers: emaste, joerg, kettenis, labath

Reviewed By: labath

Subscribers: mgorny, #lldb

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D31138

llvm-svn: 298408
2017-03-21 17:30:47 +00:00
Pavel Labath e3ad2e2e73 Replace std::ofstream with llvm::raw_fd_ostream
Summary:
ofstream does not handle paths with non-ascii characters correctly on
windows, so I am switching these to llvm streams to fix that.

Reviewers: zturner, eugene

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D31079

llvm-svn: 298375
2017-03-21 13:49:50 +00:00
Zachary Turner d3d95fd66a Remove FileSystem::MakeDirectory.
Have callers use llvm::sys::fs::create_directory() instead.

Differential Revision: https://reviews.llvm.org/D31086

llvm-svn: 298203
2017-03-19 05:48:47 +00:00
Chris Bieneman 1936585789 [debugserver] NFC. One more small cleanup to DNBArchImplX86_64::SetFPUState
This is another similar cleanup to other changes I've been making to simplify the AVX code in debugserver.

llvm-svn: 297880
2017-03-15 19:52:57 +00:00
Pavel Labath 775588c0c3 Remove lldb streams from the Log class completely
Summary:
previously we switched to llvm streams for log output, this completes
the switch for the error streams.

I also clean up the includes and remove the unused argument from
DisableAllLogChannels().

This required adding a bit of boiler plate to convert the output in the
command interpreter, but that should go away when we switch command
results to use llvm streams as well.

Reviewers: zturner, eugene

Subscribers: lldb-commits, emaste

Differential Revision: https://reviews.llvm.org/D30894

llvm-svn: 297812
2017-03-15 09:06:58 +00:00
Chris Bieneman 8baba08b64 [debugserver] NFC. Cleanup Get/Set Register Value/Context
This patch modifies the Get/Set Register Value/Context functions for Intel to not duplicate code for reading non-AVX registers. This is similar to other transformations I've been making to the AVX register handling code.

llvm-svn: 297787
2017-03-14 22:24:36 +00:00
Chris Bieneman 5bd77e02f7 [debugserver] Fixing a small logic error from r297685
I had mixed up the logic during patch review. This resolves the test failure reading YMM registers on Darwin.

llvm-svn: 297774
2017-03-14 20:01:24 +00:00
Chris Bieneman c934e928cd [debugserver] NFC. Missed one bit of cleanup in r297688
I did this cleanup in the x86_64, but missed it in the i386 code. This just simplifies the calls to thread_get_state.

llvm-svn: 297691
2017-03-13 23:46:50 +00:00
Chris Bieneman b3c780875d [debugserver] NFC. Cleanup DNBArchImpl*::GetFPUState()
This patch consolidates the DEBUG_FPU_REGS code for i386 and x86_64 to take advantage of the fact that the non-AVX members of the avx register state structure overlap with the standard fpu register state structure.

This reduces the amount of code required to set debug values into the register state structures because the register state structures are stored in a union.

llvm-svn: 297688
2017-03-13 23:27:58 +00:00
Chris Bieneman 1899e8d9e8 [debugserver] This is a small cleanup patch to AVX support detection
Summary:
The first Sandybridge iMacs with AVX support shipped in Spring 2011 with Snow Leopard as their OS. Unfortunately due to a kernel bug debugging AVX code was not really possible until 10.7.4.

The old code here checked the kernel build number to determine when to support AVX, but that code was incorrect. It verified that the kernel build number was greater than xnu-2020, which is the build of the kernel that had the fix for 10.8. The fix was also back ported to 10.7.4. Which means all publicly available OS builds 10.7.4 and later have working AVX support.

This new patch verifies that the host OS is greater than or equal to 10.7.4 by checking that the build number is greater than or equal to 11Exx.

The patch also removes the HasAVX assembly blob in favor of querying the kernel via sysctl for the hardware features.

Using sysctl is slower, however since the code is executed once and the result cached it is a better approach because it is possible for the kernel to disable AVX support on hardware that supports it, so listening to the kernel is a better approach for the debugger to take.

Reviewers: jasonmolenda, spyffe

Subscribers: lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D30918

llvm-svn: 297685
2017-03-13 23:19:04 +00:00
Tim Hammerquist a64fafc7b6 fix format specifier warnings
llvm-svn: 297228
2017-03-07 21:26:04 +00:00
Zachary Turner 6f9e690199 Move Log from Core -> Utility.
All references to Host and Core have been removed, so this
class can now safely be lowered into Utility.

Differential Revision: https://reviews.llvm.org/D30559

llvm-svn: 296909
2017-03-03 20:56:28 +00:00
Zachary Turner 1e021a162e [Windows] Remove the #include <eh.h> hack.
Prior to MSVC 2015 we had to manually include this header any
time we were going to include <thread> or <future> due to a
bug in MSVC's STL implementation.  This has been fixed in MSVC
for some time now, and we require VS 2015 minimum, so we can
remove this across all subprojects.

llvm-svn: 296906
2017-03-03 20:21:59 +00:00
Pavel Labath 5e336903be Modernize Enable/DisableLogChannel interface a bit
Summary:
Use StringRef and ArrayRef where possible. This adds an accessor to the
Args class to get a view of the arguments as ArrayRef<const char *>.

Reviewers: zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D30402

llvm-svn: 296592
2017-03-01 10:08:40 +00:00
Zachary Turner 24ae6294a4 Finish breaking the dependency from Utility.
Differential Revision: https://reviews.llvm.org/D29964

llvm-svn: 295368
2017-02-16 19:38:21 +00:00
Pavel Labath 5f7e583b33 UriParser cleanup
- move the header file to the include folder
- enclose the class in the proper namespace

llvm-svn: 294741
2017-02-10 12:21:22 +00:00
Pavel Labath 5fae71c51c Convert Log class to llvm streams
Summary:
This converts LLDB's logging to use llvm streams instead of
lldb_private::Stream and friends. The changes are mostly
straight-forward and amount to s/lldb_private::Stream/llvm::raw_ostream.

The part worth calling out is the rewrite of the StreamCallback class.
Previously this class contained a per-thread buffer of data written. I
assume this had something to do with it trying to make sure each log
line is delivered as a single event, instead of multiple (possibly
interleaved) events. However, this is no longer relevant as the Log
class already writes things to a temporary buffer and then delivers the
message as a single "write", so I have just removed the code in
question.

Reviewers: zturner, clayborg

Subscribers: emaste, lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D29615

llvm-svn: 294736
2017-02-10 11:49:21 +00:00
Chris Bieneman fd2f0cb170 [CMake] Final dependency cleanup patch!
Summary:
This patch removes the over-specified dependencies from LLDBDependencies and instead relies on the dependencies as expressed in each library and tool.

This also removes the library looping in favor of allowing CMake to do its thing. I've tested this patch on Darwin, and found no issues, but since linker semantics vary by system I'll also work on testing it on other platforms too.

Help testing would be greatly appreciated.

Reviewers: labath, zturner

Subscribers: danalbert, srhines, mgorny, jgosnell, lldb-commits

Differential Revision: https://reviews.llvm.org/D29352

llvm-svn: 294515
2017-02-08 21:00:46 +00:00
Pavel Labath e8a7b9841c Remove the verbose category in the gdb-remote channel
replace by LLDB_LOGV

llvm-svn: 294224
2017-02-06 19:31:09 +00:00
Pavel Labath 60199c1a4d Fix darwin build (llvm::once_flag fallout)
llvm-svn: 294221
2017-02-06 19:30:59 +00:00
Kamil Rytarowski c5f28e2a05 Switch std::call_once to llvm::call_once
Summary:
The std::call_once implementation in libstdc++ has problems on few systems: NetBSD, OpenBSD and Linux PPC. LLVM ships with a homegrown implementation llvm::call_once to help on these platforms.

This change is required in the NetBSD LLDB port. std::call_once with libstdc++ results with crashing the debugger.

Sponsored by <The NetBSD Foundation>

Reviewers: labath, joerg, emaste, mehdi_amini, clayborg

Reviewed By: labath, clayborg

Subscribers: #lldb

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D29288

llvm-svn: 294202
2017-02-06 17:55:02 +00:00
Zachary Turner bf9a77305f Move classes from Core -> Utility.
This moves the following classes from Core -> Utility.

ConstString
Error
RegularExpression
Stream
StreamString

The goal here is to get lldbUtility into a state where it has
no dependendencies except on itself and LLVM, so it can be the
starting point at which to start untangling LLDB's dependencies.
These are all low level and very widely used classes, and
previously lldbUtility had dependencies up to lldbCore in order
to use these classes.  So moving then down to lldbUtility makes
sense from both the short term and long term perspective in
solving this problem.

Differential Revision: https://reviews.llvm.org/D29427

llvm-svn: 293941
2017-02-02 21:39:50 +00:00
Pavel Labath 5569c0b953 [cmake] Remove VERSION property from executable targets
Summary:
Currently, in the default configuration, the "install" target will
install all llvm executables unversioned, except for three lldb tools
which will be installed versioned (with a non-versioned symlink). This
rectifies that situation.

Reviewers: beanz, sylvestre.ledru, mgorny

Subscribers: ki.stfu, lldb-commits

Differential Revision: https://reviews.llvm.org/D29126

llvm-svn: 293803
2017-02-01 19:12:22 +00:00
Kamil Rytarowski b5bc933c29 Do not pass non-POD type variables through variadic function
Summary:
Cannot pass object of non-POD type 'const CMIUtilString' through variadic function.

This behavior is undefined according to C++11 5.2.2/7:

> Passing a potentially-evaluated argument of class type having a non-trivial copy constructor, a non-trivial move contructor, or a non-trivial destructor, with no corresponding parameter, is conditionally-supported with implementation-defined semantics.

Replace SetErrorDescriptionn(errMsg); with SetErrorDescription(errMsg);

Original patch by Tobias Nygren (NetBSD).

Sponsored by <The NetBSD Foundation>


Reviewers: clayborg, labath, emaste, joerg, ki.stfu

Reviewed By: labath, ki.stfu

Subscribers: tnn, ki.stfu, #lldb

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D29256

llvm-svn: 293774
2017-02-01 16:02:55 +00:00
Ismail Donmez 79d58a39d1 Fix missing include after r293660
llvm-svn: 293767
2017-02-01 13:33:50 +00:00
Chris Bieneman c4f9920bd4 [CMake] Partial revert of r293686
This change reverts the lldb-server part of r293686, which is having trouble on Linux bots. I'm not sure if I can make lldb-server work correctly until the full dependency graph is fixed.

llvm-svn: 293690
2017-01-31 21:12:52 +00:00
Chris Bieneman 494f277af5 [CMake] Add accurate dependency specifications
Summary:
This patch adds accurate dependency specifications to the mail LLDB libraries and tools.

In all cases except lldb-server, these dependencies are added in addition to existing dependencies (making this low risk), and I performed some code cleanup along the way.

For lldb-server I've cleaned up the LLVM dependencies down to just the minimum actually required. This is more than lldb-server actually directly references, and I've left a todo in the code to clean that up.

Reviewers: labath, zturner

Subscribers: lldb-commits, danalbert, srhines, ki.stfu, mgorny, jgosnell

Differential Revision: https://reviews.llvm.org/D29333

llvm-svn: 293686
2017-01-31 20:43:05 +00:00
Valentina Giusti c0eeee7a78 Add a command to access and manipulate the Intel(R) MPX Boundary Tables.
Summary:
The Boundary Table Entries are stored in the application memory and allow
to store boundary info for all the pointers of the program, also those that
otherwise wouldn't fit in the 4 bound registers provided by the HW.

Here is an example of how it works:
 * mpx-table show <pointer>
        lbound = 0x..., ubound = 0x..., (pointer value = 0x..., metadata = 0x...)
 * mpx-table set <pointer>

Signed-off-by: Valentina Giusti <valentina.giusti@intel.com>

Reviewers: labath, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D29078

llvm-svn: 293660
2017-01-31 18:02:54 +00:00
Sean Callanan 1912d9633f Removed an unneccesary #if now that debugserver-mini links Foundation.
llvm-svn: 293161
2017-01-26 08:51:32 +00:00
Jason Molenda 728c290daf Add Foundation to the debugserver-mini dependencies;
debugserver-mini can use Foundation.

llvm-svn: 293140
2017-01-26 02:27:35 +00:00
Jason Molenda 891c777f90 Instead of weak-linking against LoggingSupport framework (which
requires that this private framework be available - and it is not
available earlier than macOS 10.12 - to build lldb), dlopen the
framework binary on demand in debugserver.  We're already using
dlsym() to look up all the symbols so there is no need to use weak
linking here.

<rdar://problem/30158797> 

llvm-svn: 293135
2017-01-26 02:13:43 +00:00
Sean Callanan 9ea2835704 Link debugserver against Foundation to get access to NSProcessInfo.
debugserver-mini can't use Foundation so disable that code there. 

llvm-svn: 293098
2017-01-25 21:32:00 +00:00
Sean Callanan 60370e375a Reverted 292880 to fix a linker error.
<rdar://problem/30180883>

llvm-svn: 293022
2017-01-25 05:39:14 +00:00
Sean Callanan 95a6e6f6a6 Conditionalized OsLogger.cpp on a modern SDK.
llvm-svn: 293020
2017-01-25 05:18:32 +00:00
Jason Molenda 3ca38564cb Fix the last commit; compression was being enabled on mac native
which led to

ERROR: test_auxv_chunked_reads_work_debugserver (tools/lldb-server/TestGdbRemoteAuxvSupport.py)
ERROR: test_auxv_data_is_correct_size_debugserver (tools/lldb-server/TestGdbRemoteAuxvSupport.py)
ERROR: test_auxv_keys_look_valid_debugserver (tools/lldb-server/TestGdbRemoteAuxvSupport.py)
ERROR: test_qSupported_returns_known_stub_features_debugserver (tools/lldb-server/TestLldbGdbServer.py)

failures because debugserver was advertising compression being available, e.g.

send packet: $qSupported:xmlRegisters=i386,arm,mips#12
read packet: $qXfer:features:read+;PacketSize=20000;qEcho+;SupportedCompressions=zlib-deflate;DefaultCompressionMinSize=384#00

maybe these tests should be a little more accepting of additional
features.  but I didn't mean for this to be enabled on mac native.

llvm-svn: 292890
2017-01-24 06:09:06 +00:00
Jason Molenda 5a6826ebc4 Enable compression capability in debugserver for all of ios/watchos/tvos
environments.

<rdar://problem/30159019> 

llvm-svn: 292882
2017-01-24 04:43:40 +00:00