Commit Graph

1349 Commits

Author SHA1 Message Date
Jason Molenda f50299fb87 Add another entitlement that we need for debugserver.
<rdar://problem/29855293> 

llvm-svn: 326399
2018-03-01 01:04:07 +00:00
Han Ming Ong 4142369204 Add ability to collect memory limit.
Reviewer: Jason Molenda

<rdar://problem/37686560>

llvm-svn: 326374
2018-02-28 22:18:45 +00:00
Pavel Labath a535a7a2a0 [LLDB] Initial version of PPC64 InstEmulation
Summary: Supports common prologue/epilogue instructions.

Reviewers: clayborg, labath

Reviewed By: clayborg, labath

Subscribers: davide, anajuliapc, alexandreyy, lbianc, nemanjai, mgorny, kbarton

Differential Revision: https://reviews.llvm.org/D43345
Author: Leandro Lupori <leandro.lupori@gmail.com>

llvm-svn: 326224
2018-02-27 18:42:46 +00:00
Han Ming Ong 28efd27fe2 Removed accidentally committed code from previous commit.
llvm-svn: 326214
2018-02-27 18:02:15 +00:00
Han Ming Ong 83d178de9f Got rid of weak imports of libpenergy and libpsample because we are already requiring a modern macOS (at least 10.11)
Reviewer: Jason Molenda
llvm-svn: 326213
2018-02-27 17:53:38 +00:00
Pavel Labath 7c94582f90 Add "lldb-test breakpoint" command and convert the case-sensitivity test to use it
Summary:
The command takes two input arguments: a module to use as a debug target
and a file containing a list of commands. The command will execute each
of the breakpoint commands in the file and dump the breakpoint state
after each one.

The commands are expected to be breakpoint set/remove/etc. commands, but
I explicitly allow any lldb command here, so you can do things like
change setting which impact breakpoint resolution, etc. There is also a
"-persistent" flag, which causes lldb-test to *not* automatically clear
the breakpoint list after each command. Right now I don't use it, but
the idea behind it was that it could be used to test more complex
combinations of breakpoint commands (set+modify, set+disable, etc.).

Right now the command prints out only the basic breakpoint state, but
more information can be easily added there.  To enable easy matching of
the "at least one breakpoint location found" state, the command
explicitly prints out the string "At least one breakpoint location.".

To enable testing of breakpoints set with an absolute paths, I add the
ability to perform rudimentary substitutions on the commands: right now
the string %p is replaced by the directory which contains the command
file (so, under normal circumstances, this will perform the same
substitution as lit would do for %p).

I use this command to rewrite the TestBreakpointCaseSensitivity test --
the test was checking about a dozen breakpoint commands, but it was
launching a new process for each one, so it took about 90 seconds to
run. The new test takes about 0.3 seconds for me, which is approximately
a 300x speedup.

Reviewers: davide, zturner, jingham

Subscribers: luporl, lldb-commits

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

llvm-svn: 326112
2018-02-26 18:50:16 +00:00
Vedant Kumar d4e2dabbbb Delete dead code in MachVMMemory.cpp, NFC
This addresses a compiler warning.

llvm-svn: 326002
2018-02-24 00:17:05 +00:00
Vedant Kumar f6769ae176 [unittests] Disable lldb-server tests if an external debug server is in use
The lldb-server unit tests don't test the right thing when the debug
server in use is copied from somewhere else. This can lead to spurious
test failures.

Disable these unit tests when an external debug server is in use.

Fixes llvm.org/PR36494.

llvm-svn: 326001
2018-02-24 00:17:04 +00:00
Don Hinton b308571916 Add DEBUGSERVER_PATH to the cache so it'll be available for tests.
This fixed a problem caused by r325442.

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

llvm-svn: 325452
2018-02-17 23:06:15 +00:00
Don Hinton d8a6b90e83 [cmake] Fix LLDB_CODESIGN_IDENTITY logic.
Summary:
Consolidate LLDB_CODESIGN_IDENTITY logic in one place and use
SKIP_DEBUGSERVER, which can be set independently, to control
codesigning targets.

Currently, running cmake the first time in a clean directory, without
passing -DLLDB_CODESIGN_IDENTITY='', fails.  However, subsequent runs
succeed.  That's because LLDB_CODESIGN_IDENTITY gets added to the
CACHE after the initial test.  To fix that, the default value must be
set before it's tested.

Here's the error produced on the first run:

CMake Error at tools/lldb/tools/debugserver/source/CMakeLists.txt:215 (add_custom_command):
  No TARGET 'debugserver' has been created in this directory.

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

llvm-svn: 325442
2018-02-17 19:17:21 +00:00
Vedant Kumar 361b5e1169 [cmake] Darwin: Copy in the system debugserver if needed
This makes the built debugger functional on Darwin when compiling
without code signing (as documented in docs/code-signing.txt).

llvm-svn: 325068
2018-02-13 23:05:46 +00:00
Jason Molenda 35eb6c856a Turn off the deprecated ALWAYS_SEARCH_USER_PATHS feature
in debugserver.  This is already set this way in the lldb
project files but not in debugserver.  Updating for
consistency.

llvm-svn: 324158
2018-02-03 00:37:46 +00:00
Han Ming Ong 017edbddeb Make use of physical footprint as memory measurement.
Remove obsolete measurements.

This check in requires at least 10.11

Reviewed: Jason Molenda, Jim Ingham

<rdar://problem/37047106> Xcode Memory gauge should show the jetsam ledger footprint rather than anonymous

llvm-svn: 324013
2018-02-01 21:46:40 +00:00
Jason Molenda 0af609d17c Remove the hardcoded macos deployment targets altogether
from the xcode project files.  We'll build for the current
OS only, by default.  

llvm-svn: 322603
2018-01-17 00:22:27 +00:00
Jason Molenda c4dd04c5c3 When parsing the target.xml register file, if no architecture has
been specified yet (either by the user, or by one of the lldb
extensions like qHostInfo or qProcessInfo), and the target.xml
includes a <architecture> tag specifying x86_64, set the architecture
appropriately.

I'm not sure what we can expect to see in the <architecture> tag, so
I'm only doing this for x86_64 right now where I've seen "i386:x86_64"
used.  I've seen a target.xml from a jtag board that sends just "arm"
because it doesn't know more specifically what type of board it is
connected to...  

<rdar://problem/29908970> 

llvm-svn: 322339
2018-01-12 01:16:13 +00:00
Pavel Labath 62930e57eb Add Utility/Environment class for handling... environments
Summary:
There was some confusion in the code about how to represent process
environment. Most of the code (ab)used the Args class for this purpose,
but some of it used a more basic StringList class instead. In either
case, the fact that the underlying abstraction did not provide primitive
operations for the typical environment operations meant that even a
simple operation like checking for an environment variable value was
several lines of code.

This patch adds a separate Environment class, which is essentialy a
llvm::StringMap<std::string> in disguise. To standard StringMap
functionality, it adds a couple of new functions, which are specific to
the environment use case:
- (most important) envp conversion for passing into execve() and likes.
  Instead of trying to maintain a constantly up-to-date envp view, it
  provides a function which creates a envp view on demand, with the
  expectation that this will be called as the very last thing before
  handing the value to the system function.
- insert(StringRef KeyEqValue) - splits KeyEqValue into (key, value)
  pair and inserts it into the environment map.
- compose(value_type KeyValue) - takes a map entry and converts in back
  into "KEY=VALUE" representation.

With this interface most of the environment-manipulating code becomes
one-liners. The only tricky part was maintaining compatibility in
SBLaunchInfo, which expects that the environment entries are accessible
by index and that the returned const char* is backed by the launch info
object (random access into maps is hard and the map stores the entry in
a deconstructed form, so we cannot just return a .c_str() value). To
solve this, I have the SBLaunchInfo convert the environment into the
"envp" form, and use it to answer the environment queries. Extra code is
added to make sure the envp version is always in sync.

(This also improves the layering situation as Args was in the Interpreter module
whereas Environment is in Utility.)

Reviewers: zturner, davide, jingham, clayborg

Subscribers: emaste, lldb-commits, mgorny

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

llvm-svn: 322174
2018-01-10 11:57:31 +00:00
Jason Molenda 6b7daba64a This change updates the deployment target for lldb and debugserver
(built with Xcode) from 10.9 to 10.11.  It also enables the use of
libcompression in debugserver by default (these API are only present
in macOS 10.11 and newer -- 10.11 was released c. Sep 2015).

I don't know if we have people / bots building lldb on older mac
releases; if this turns out to be a problem I will revert the change.
There are some parts of lldb (e.g. debugserer's ability to report
the OS version #) that only work with 10.10 and this changes the
behavior of lldb (whether the older or newer dyld interfaces are
used) so there is some importance to updating the min required
version.

llvm-svn: 322128
2018-01-09 22:17:10 +00:00
Pavel Labath deb45f2043 debugserver: Propagate environment in launch-mode (pr35671)
Summary:
Make sure we propagate environment when starting debugserver with a pre-loaded
inferior. AFAIK, RNBRunLoopLaunchInferior is only called in pre-loaded inferior
scenario, so we can just pick up the debugserver environment instead of trying
to construct an envp from the (empty) context.

This makes debugserver pass an test added for an equivalent lldb-server fix.

Reviewers: jasonmolenda, clayborg

Subscribers: JDevlieghere, lldb-commits

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

llvm-svn: 321355
2017-12-22 11:09:21 +00:00
Adrian Prantl 7e13aef428 Replace an accidentally added "break" with an LLVM_FALLTHROUGH.
Thanks to Greg Clayton for catchting this!

llvm-svn: 321123
2017-12-19 23:16:38 +00:00
Adrian Prantl a01e024ad7 Fix a couple of warnings (NFC)
llvm-svn: 321120
2017-12-19 22:54:37 +00:00
Jason Molenda b1e350f71f Tweak to the debugserver entitlements setup in the xcode project
file.  For macos builds specifically, use the macosx entitlements
files; for all other builds, use the ios etc entitlements.

llvm-svn: 321051
2017-12-19 01:41:47 +00:00
Pavel Labath 11e5917d2a llgs: Propagate the environment when launching the inferior from command line
Summary:
We were failing to propagate the environment when lldb-server was
started with a pre-loaded process
(e.g.: lldb-server gdbserver -- inferior --inferior_args)

This patch makes sure the environment is propagated. Instead of adding a
new GDBRemoteCommunicationServerLLGS::SetLaunchEnvironment function to
complement SetLaunchArgs and SetLaunchFlags, I replace these with a
more generic SetLaunchInfo, which can be used to set any launch-related
property.

The accompanying test also verifies that the server correctly terminates
the connection after sending the exit packet (specifically, that it does
not send the exit packet twice).

Reviewers: clayborg, eugene

Subscribers: lldb-commits, mgorny

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

llvm-svn: 320984
2017-12-18 14:31:39 +00:00
Pavel Labath e2867bc4a0 ObjectFileELF: Add support for compressed sections
Summary:
We use the llvm decompressor to decompress SHF_COMPRESSED sections. This enables
us to read data from debug info sections, which are sometimes compressed,
particuarly in the split-dwarf case.  This functionality is only available if
llvm is compiled with zlib support.

Reviewers: clayborg, zturner

Subscribers: emaste, mgorny, aprantl, lldb-commits

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

llvm-svn: 320813
2017-12-15 14:23:58 +00:00
Jason Molenda aae5b69079 Change uses of strncpy in debugserver to strlcpy
for better safety.

<rdar://problem/32906923> 

llvm-svn: 320242
2017-12-09 03:37:09 +00:00
Vedant Kumar 9c36859b33 [MachException] Avoid alignment UB, NFC
Fix alignment UB in some Mach exception-handling logic.

This lets us build lldb and debugserver with UBSan in trapping mode, and
get further along in the testing process before a trap is encountered.

rdar://35923991

llvm-svn: 320127
2017-12-08 01:09:40 +00:00
Vedant Kumar b773e488c9 Remove extant references to g_message_mutex, NFC
Thanks to Jim Ingham for providing the explanation!

llvm-svn: 320126
2017-12-08 01:09:39 +00:00
Shoaib Meenai 5e8d5ccfe7 [lldb] Use PRIVATE in target_link_libraries
This is a follow-up to r319840. I guess none of the systems I'd tested
on before had LLDB_SYSTEM_LIBS set, which is why I didn't see any local
errors, but I'm surprised none of the bots caught it either.

llvm-svn: 319953
2017-12-06 20:53:03 +00:00
Vedant Kumar 50048ac65e Fix the -Wunused-function warning properly (MachProcess.mm)
r319938 was not NFC, because it got the preprocessor guard wrong. Check
WITH_FBS and WITH_BKS before defining SplitEventData.

llvm-svn: 319943
2017-12-06 19:27:20 +00:00
Vedant Kumar eacb0929e8 Fix an -Wunused-function warning, NFC
llvm-svn: 319938
2017-12-06 19:21:11 +00:00
Vedant Kumar 07d956149b Fix misc -Wcast-qual warnings, NFC
llvm-svn: 319937
2017-12-06 19:21:11 +00:00
Vedant Kumar 606908aab5 Remove no-op function pointer null checks, NFC
Null-checking functions which aren't marked weak_import is a no-op
(the compiler rewrites the check to 'true'), regardless of whether a
library providing its definition is weak-linked. If the deployment
target is greater than the minimum requirement, the availability markup
on APIs does not lower to weak_import.

Remove no-op null checks to clean up the code and silence warnings.

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

llvm-svn: 319936
2017-12-06 19:21:10 +00:00
Zachary Turner a6d5464cfe Add a symbols subcommand to lldb-test.
Differential Revision: https://reviews.llvm.org/D40745

llvm-svn: 319599
2017-12-02 00:15:29 +00:00
Vedant Kumar 02de50fdc4 Fix warnings in JSON.cpp, NFC
These asserts are no-ops, and are supplanted by -Wcovered-switch.

llvm-svn: 319596
2017-12-01 23:29:04 +00:00
Vedant Kumar 01e86df684 Fix warnings in DNBDataRef.cpp, NFC
llvm-svn: 319595
2017-12-01 23:24:12 +00:00
Zachary Turner 888a428292 Add lldb-test.
This is basically a proof-of-concept and starting point for having a
testing-centric tool in LLDB.  I'm sure this leaves a lot of room to be
desired, but this at least allows us to have something to build on.

Right now there is only one command, the `module-sections` command, and I
created this command not because it was particularly special, but
because it addressed an immediate use case and was extremely simple.

Run the tool as `lldb-test module-sections <path-to-object>`.

Feel free to add testing related stuff to your heart's content after
this goes in.  Implementing the commands themselves takes some work, but
once they're there they can be reused without writing any code and
result in very easy to use and maintain tests.

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

llvm-svn: 319504
2017-12-01 00:52:51 +00:00
Jim Ingham e28a93deff Recognize another magic token sent in the LaunchInfo's EventData.
<rdar://problem/32505028>

llvm-svn: 318496
2017-11-17 01:22:34 +00:00
Pavel Labath f753bfeeec Fix LLVM_LINK_LLVM_DYLIB build (pr35053)
Summary:
r316368 broke this build when it introduced a reference to a pthread
function to the Utility module. This caused cmake to generate an
incorrect link line (wrong order of libs) because it did not see the
dependency from Utility to the system libraries. Instead these libraries
were being manually added to each final target.

This changes moves the dependency management from the individual targets
to the lldbUtility module, which is consistent with how llvm does it.
The final targets will pick up these libraries as they will be a part of
the link interface of the module.

Technically, some of these dependencies could go into the host module,
as that's where most of the os-specific code is, but I did not try to
investigate which ones.

Reviewers: zturner, sylvestre.ledru

Subscribers: lldb-commits, mgorny

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

llvm-svn: 316997
2017-10-31 13:23:19 +00:00
Ted Woodward 2ecfd62938 Remove default case from switch.
Add case to handle new event lldb::eBreakpointEventTypeAutoContinueChanged.

llvm-svn: 315496
2017-10-11 19:38:35 +00:00
Davide Italiano 54fcf82454 [lldb-mi] Fix a thinko in my previous commit.
Hopefully this should unbreak the Android buildbot.

llvm-svn: 314606
2017-09-30 21:52:31 +00:00
Davide Italiano d4e450aca2 [lldb-mi] Add a default case to placate GCC with -Werror.
llvm-svn: 314604
2017-09-30 21:30:41 +00:00
Stephane Sezer 2ca6c3da63 Add a few missing newlines in lldb-server messages
Reviewers: fjricci, clayborg

Subscribers: lldb-commits

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

llvm-svn: 314455
2017-09-28 19:49:00 +00:00
Eugene Zemtsov 3015341d45 Use socketpair on all Unix platforms
Using TCP sockets is insecure against local attackers, and possibly
against remote attackers too (some vulnerabilities may allow tricking a
browser to make a request to localhost). Use socketpair (which is immune
to such attacks) on all Unix platforms.

Patch by Demi Marie Obenour < demiobenour@gmail.com >

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

llvm-svn: 314127
2017-09-25 17:41:16 +00:00
Adrian McCarthy 6c84ffbf5f Fix the SIGINT handlers
1. Fix a data race (g_interrupt_sent flag usage was not thread safe, signals
can be handled on arbitrary threads)

2. exit() is not signal-safe, replaced it with the signal-safe equivalent
_exit()

(This differs from the patch on Phabrictor because I had to add
`#include <atomic>` to get the definition of `std::atomic_flag`.)

patch by lemo

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

llvm-svn: 313785
2017-09-20 18:09:39 +00:00
Chris Bieneman 5226a2a6de [CMake] Need to set WITH_LOCKDOWN on debugserver target
Turns out WITH_LOCKDOWN define changes the struct layout and constructor implementation for RNBSocket which is used in debugserver.cpp, so we need to make sure this is consistent.

In the future we should change WITH_LOCKDOWN to be configured in a generated header, but for now we can just set it correctly.

<rdar://problem/33900552>

llvm-svn: 312666
2017-09-06 20:15:43 +00:00
Ted Woodward 91635e0cef lldb-mi: -var-update can hang when traversing complex types with pointers
Summary:
-var-update calls CMICmdCmdVarUpdate::ExamineSBValueForChange to check if a varObj has been updated. It checks that the varObj is updated, then recurses on all of its children. If a child is a pointer pointing back to a parent node, this will result in an infinite loop, and lldb-mi hanging.

The problem is exposed by packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py, but this test is skipped everywhere.

This patch changes ExamineSBValueForChange to not traverse children of varObjs that are pointers.

Reviewers: ki.stfu, zturner, clayborg, abidh

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 312270
2017-08-31 19:22:33 +00:00
Jason Molenda 9ff294f039 Change the ftag x87 register from being 8-bits wide to 16-bits wide
to match the changes Saleem Abdulrasool committed in r311579.  Fixes
a testsuite failure now that the testsuite expects a 16 bit return
value for thsi reg.

llvm-svn: 311627
2017-08-24 03:22:08 +00:00
Bruce Mitchener 416bc3d70a lldb-argdumper doesn't need lldbCore.
Summary: lldb-argdumper only needs lldbUtility to successfully build and link.

Reviewers: beanz, zturner, labath

Subscribers: mgorny, lldb-commits

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

llvm-svn: 311399
2017-08-21 22:54:49 +00:00
Lang Hames ccfc80ccc7 Fix typo in variable name.
llvm-svn: 310984
2017-08-16 01:50:32 +00:00
Chris Bieneman a944dd109b [CMake] Fixing an error in STREQUAL usage.
llvm-svn: 310955
2017-08-15 20:56:04 +00:00
Chris Bieneman 30f044b72c [CMake] Disable code sign entitlements when using lldb_codesign
Turns out self-signed certificates and entitlements don't always play well together...

llvm-svn: 310936
2017-08-15 17:42:20 +00:00