Commit Graph

16514 Commits

Author SHA1 Message Date
Jim Ingham f539174f9a Work around a bug in the C++ expression parser.
When the expression parser does name resolution for local
variables in C++ closures it doesn't give the local name
priority over other global symbols of the same name.  heap.py
uses "info" which is a fairly common name, and so the commands
in it fail.  This is a workaround, just use lldb_info not info.

<rdar://problem/34026140>

llvm-svn: 314959
2017-10-05 01:00:29 +00:00
Jim Ingham a6976269bd Another silly little thing you can do with Python commands.
Sometimes you want to step along and print a local each time as you go.
You can do that with stop hooks, but that's a little heavy-weight.  This
is a sketch of a command that steps and then does "frame variable" on all
its arguments.

llvm-svn: 314958
2017-10-05 00:49:49 +00:00
Leonard Mosescu 63ed8c6c2e LLDB cmake fix: define LLDB_CONFIGURATION_xxx based on the build type
Neither LLDB_CONFIGURATION_DEBUG nor LLDB_CONFIGURATION_RELEASE were ever set in the CMake LLDB project.

Also cleaned up a questionable #ifdef in SharingPtr.h, removing all the references to LLDB_CONFIGURATION_BUILD_AND_INTEGRATION in the process.

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

llvm-svn: 314929
2017-10-04 20:23:56 +00:00
Tim Hammerquist a6db41675c cmake + xcode: prevent gtests from using includes from project root
Summary:
At present, several gtests in the lldb open source codebase are using
#include statements rooted at $(SOURCE_ROOT)/${LLDB_PROJECT_ROOT}.

This patch cleans up this directory/include structure for both CMake and
Xcode build systems.

rdar://problem/33835795

Reviewers: zturner, jingham, beanz

Reviewed By: beanz

Subscribers: emaste, lldb-commits, mgorny

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

llvm-svn: 314849
2017-10-03 21:20:18 +00:00
Alexander Shaposhnikov 56138de385 [lldb] Fix initialization of m_debug_cu_index_map
SymbolFileDWARFDwp contains m_debug_cu_index_map which was previously 
initialized incorrectly: before m_debug_cu_index.parse 
is called m_debug_cu_index is empty, thus 
the map was not actually getting populated properly. 
This diff moves this step into a private helper method
and calls it after m_debug_cu_index.parse inside SymbolFileDWARFDwp::Create.

Test plan:

Build a toy test example 
main.cpp
clang -gsplit-dwarf -g -O0 main.cpp -o main.exe
llvm-dwp -e main.exe -o main.exe.dwp
Build LLDB with ENABLE_DEBUG_PRINTF set.
Run: lldb -- ./main.exe
Check that the indexes are now correct 
(before this change they were empty)
Check that debugging works 
(setting breakpoints, printing local variables (this was not working before))

Differential revision: http://reviews.llvm.org/D38492

llvm-svn: 314832
2017-10-03 19:56:21 +00:00
Jason Molenda a7e7d90d9f Move install_name_tool to a separate make target.
llvm-svn: 314731
2017-10-02 22:11:22 +00:00
Ed Maste d13f691f41 Improve FreeBSD kernel debugging
FreeBSD kernel modules are actually relocatable (.o) ELF files and this
previously caused some issues for LLDB. This change addresses these when
using lldb to symbolicate FreeBSD kernel backtraces. 

The major problems:

- Relocations were not being applied to the DWARF debug info despite
  there being code to do this. Several issues prevented it from working:

  - Relocations are computed at the same time as the symbol table, but
    in the case of split debug files, symbol table parsing always
    redirects to the primary object file, meaning that relocations would
    never be applied in the debug file.

  - There's actually no guarantee that the symbol table has been parsed
    yet when trying to parse debug information.

  - When actually applying relocations, it will segfault because the
    object files are not mapped with MAP_PRIVATE and PROT_WRITE.

- LLDB returned invalid results when performing ordinary address-to-
  symbol resolution. It turned out that the addresses specified in the
  section headers were all 0, so LLDB believed all the sections had
  overlapping "file addresses" and would sometimes return a symbol from
  the wrong section.

Patch by Brian Koropoff

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

llvm-svn: 314672
2017-10-02 14:35:07 +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
Davide Italiano fe34df5951 [ExpressionParser] Prefer isa<> to dyn_cast<>. NFCI.
The result type is unused anyway.

llvm-svn: 314602
2017-09-30 21:16:56 +00:00
Eugene Zemtsov 74e94836e7 Fix Android remote debugging tests running on Windows
Use make based OS check, instad of relying on shell.

llvm-svn: 314488
2017-09-29 03:25:25 +00:00
Eugene Zemtsov a9d928c396 Fix compilation error
llvm-svn: 314487
2017-09-29 03:15:08 +00:00
Sean Callanan 68e4423917 [Expression parser] Setting to enable use of ExternalASTMerger
This setting can be enabled like this at the target level:

(lldb) settings set target.experimental.use-modern-type-lookup true

This causes several new behaviors in the Clang expression parser:

- It completely disables use of ClangASTImporter.  None are created
  at all, and all users of it are now conditionalized on its
  presence.

- It instead constructs a per-expression ExternalASTMerger, which
  exists inside Clang and contains much of the type completion
  logic that hitherto lived in ExternalASTSource,
  ClangExpressionDeclMap, and ClangASTImporter.

- The expression parser uses this Merger as a backend for copying
  and completing types.

- It also constructs a persistent ExternalASTMerger which is
  connected to the Target's persistent AST context.

This is a major chunk of LLDB functionality moved into Clang.  It
can be tested in two ways:

1. For an individual debug session, enable the setting before
   running a target.

2. For the testsuite, change the option to be default-true.  This
   is done in Target.cpp's g_experimental_properties.  The
   testsuite is not yet clean with this, so I have not committed
   that switch.

I have filed a Bugzilla for extending the testsuite to allow
custom settings for all tests:
  https://bugs.llvm.org/show_bug.cgi?id=34771

I have also filed a Bugzilla for fixing the remaining testsuite
failures with this setting enabled:
  https://bugs.llvm.org/show_bug.cgi?id=34772

llvm-svn: 314458
2017-09-28 20:20:25 +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
Jim Ingham 8c9ecc5010 Revert patch r313904, as it breaks "command source" and in
particular causes lldb to die on startup if you have a ~/.lldbinit file.

I filed:

https://bugs.llvm.org/show_bug.cgi?id=34758

to cover fixing the bug.

llvm-svn: 314371
2017-09-28 01:39:07 +00:00
Jason Molenda bfee0a506f Change build-llvm.py and build-lldb-llvm-clang's patching mechanisms to
assume git-style diffs.  Committing for Francis Ricci.

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

llvm-svn: 314366
2017-09-27 23:44:54 +00:00
Jason Molenda 11ff56c958 Add support for running the lldb testsuite against an apple watch
running watchos.  These tests cannot run on normal customer devices,
but I hope to some day have a public facing bot running against a
device.

llvm-svn: 314355
2017-09-27 22:12:54 +00:00
Jason Molenda 300fd45326 Update the Objective-C runtime interface code to handle objc objects
whose isa is an index instead of a pointer.  Currently, this type
of isa encoding is only used on watchos.
<rdar://problem/34675497> 

llvm-svn: 314343
2017-09-27 20:56:32 +00:00
Jason Molenda 1d23cb4e7e Update ABIMacOSX_arm::PrepareTrivialCall to correctly align the
stack pointer for apple's armv7 ABI.  When in a frameless function
or in a prologue/epilogue where sp wasn't properly aligned, we could
try to make function calls with an unaligned sp; the expression
would crash.

llvm-svn: 314265
2017-09-27 02:49:18 +00:00
Sean Callanan 1b3c43b6dd [Expression Parser] Inhibit global lookups for symbols in the IR dynamic checks
The IR dynamic checks are self-contained functions whose job is to

- verify that pointers referenced in an expression are valid at runtime; and
- verify that selectors sent to Objective-C objects by an expression are
  actually supported by that object.

These dynamic checks forward-declare all the functions they use and should not
require any external debug information. The way they ensure this is by marking
all the names they use with a dollar sign ($). The expression parser recognizes
such symbols and perform no lookups for them.

This patch fixes three issues surrounding the use of the dollar sign:

- to fix a MIPS issue, the name of the pointer checker was changed from
  starting with $ to starting with _$, but this was not properly ignored; and
- the Objective-C object checker used a temporary variable that did not start
  with $.
- the Objective-C object checker used an externally-defined struct (struct
  objc_selector) but didn't need to.

The patch also implements some cleanup in the area:

- it reformats the string containing the Objective-C object checker,
  which was mangled horribly when the code was transformed to a uniform width
  of 80 columns, and
- it factors out the logic for ignoring global $-symbols into common code
  shared between ClangASTSource and ClangExpressionDeclMap.

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

llvm-svn: 314225
2017-09-26 17:25:34 +00:00
Jason Molenda ce9606dd4f Remove the details of the libstdc++ implementation that were
in TestDataFormatterSkipSummary.py - I'm building this test
with the default c++ library.

Skip TestMTCSimple.py when running for i386.

llvm-svn: 314155
2017-09-25 21:23:37 +00:00
Jason Molenda 8652b249e6 Initial patchset to get the testsuite running against armv7 and arm64 iOS devices.
Normal customer devices won't be able to run these tests, we're hoping to get
a public facing bot set up at some point.  Both devices pass the testsuite without
any errors or failures.

I have seen some instability with the armv7 test runs, I may submit additional patches
to address this.  arm64 looks good.

I'll be watching the bots for the rest of today; if any problems are introduced by
this patch I'll revert it - if anyone sees a problem with their bot that I don't
see, please do the same.  I know it's a rather large patch.

One change I had to make specifically for iOS devices was that debugserver can't 
create files.  There were several tests that launch the inferior process redirecting
its output to a file, then they retrieve the file.  They were not trying to test
file redirection in these tests, so I rewrote those to write their output to a file
directly.

llvm-svn: 314132
2017-09-25 18:19:39 +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
Chris Bieneman 9568a5102e Revert "Initial patchset to get the testsuite running against armv7 and arm64 iOS devices. Normal customer devices won't be able to run these devices, we're hoping to get a public facing bot set up at some point. Both devices pass the testsuite without any errors or failures."
This patch has been causing LLDB test failures on ObjC tests. A test log
may still be available here:

http://lab.llvm.org:8080/green/view/LLDB/job/lldb/1650/

This reverts commit r314038.

llvm-svn: 314122
2017-09-25 17:31:40 +00:00
Stephane Sezer 85317f23df Implement trampoline step-through for Windows-x86.
Summary:
This is required to be able to step through calls to external functions
that are not properly marked with __declspec(dllimport). When a call
like this is emitted, the linker will inject a trampoline to produce an
indirect call through the IAT.

Reviewers: zturner, jingham

Reviewed By: jingham

Subscribers: sas, jingham, lldb-commits

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

llvm-svn: 314045
2017-09-22 23:41:41 +00:00
Jason Molenda 0187a8f6f9 Initial patchset to get the testsuite running against armv7 and arm64 iOS devices.
Normal customer devices won't be able to run these devices, we're hoping to get
a public facing bot set up at some point.  Both devices pass the testsuite without
any errors or failures.

I have seen some instability with the armv7 test runs, I may submit additional patches
to address this.  arm64 looks good.

I'll be watching the bots for the rest of today; if any problems are introduced by
this patch I'll revert it - if anyone sees a problem with their bot that I don't
see, please do the same.  I know it's a rather large patch.

One change I had to make specifically for iOS devices was that debugserver can't 
create files.  There were several tests that launch the inferior process redirecting
its output to a file, then they retrieve the file.  They were not trying to test
file redirection in these tests, so I rewrote those to write their output to a file
directly.

llvm-svn: 314038
2017-09-22 22:34:53 +00:00
Jason Molenda 2d5d71c061 Revert this patch; I was emailing with Eugene and they have some other changes going
in today and don't want the two changes to confuse the situation with the build bots.
I'll commit tomorrow once they're known good.

llvm-svn: 313934
2017-09-21 23:02:56 +00:00
Jason Molenda 182a8083c1 Initial patchset to get the testsuite running against armv7 and arm64 iOS devices.
Normal customer devices won't be able to run these devices, we're hoping to get
a public facing bot set up at some point.

There will be some smaller follow-on patches.  The changes to tools/lldb-server are
verbose and I'm not thrilled with having to skip all of these tests manually.
There are a few places where I'm making the assumption that "armv7", "armv7k", "arm64"
means it's an ios device, and I need to review & clean these up with an OS check
as well.  (Android will show up as "arm" and "aarch64" so by pure luck they shouldn't
cause problems, but it's not an assumption I want to rely on).

I'll be watching the bots for the rest of today; if any problems are introduced by
this patch I'll revert it - if anyone sees a problem with their bot that I don't
see, please do the same.  I know it's a rather large patch.

One change I had to make specifically for iOS devices was that debugserver can't 
create files.  There were several tests that launch the inferior process redirecting
its output to a file, then they retrieve the file.  They were not trying to test
file redirection in these tests, so I rewrote those to write their output to a file
directly.

llvm-svn: 313932
2017-09-21 23:00:19 +00:00
Adrian McCarthy 977996d25b [LLDB] Implement interactive command interruption
The core of this change is the new CommandInterpreter::m_command_state, which
models the state transitions for interactive commands, including an
"interrupted" state transition.

In general, command interruption requires cooperation from the code executing
the command, which needs to poll for interruption requests through
CommandInterpreter::WasInterrupted().

CommandInterpreter::PrintCommandOutput() implements an optionally
interruptible printing of the command output, which for large outputs was
likely the longest blocking part.  (ex. target modules dump symtab on a
complex binary could take 10+ minutes)

patch by lemo

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

llvm-svn: 313904
2017-09-21 19:36:52 +00:00
Ted Woodward 4355c7c562 Fix warning caused by new clang::BuiltinType::Float16 added in r312794
llvm-svn: 313799
2017-09-20 19:16:53 +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
Eugene Zemtsov e768daad6e Signal polling is supported with pselect (re-land r313704 without a Windows breakage)
Older Android API levels don't have ppoll, but LLDB works just fine,
since on Android it always uses pselect anyway.

llvm-svn: 313726
2017-09-20 06:56:46 +00:00
Eugene Zemtsov b207d12456 Rollback r313704 because of the Windows build break
llvm-svn: 313707
2017-09-20 01:57:59 +00:00
Eugene Zemtsov 4ce010e775 Signal polling is supported with pselect
Older Android API levels don't have ppoll, but LLDB works just fine,
since on Android it always uses pselect anyway.

llvm-svn: 313704
2017-09-20 00:39:04 +00:00
Adrian McCarthy 3887ba8d38 Re-land r313210 - Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)
The main change is to avoid setting the process state as running when
debugging core/minidumps (details in the bug).  Also included a few small,
related fixes around how the errors propagate in this case.

Fixed the FreeBSD/Windows break: the intention was to keep
Process::WillResume() and Process::DoResume() "in-sync", but this had the
unfortunate consequence of breaking Process sub-classes which don't override
WillResume().

The safer approach is to keep Process::WillResume() untouched and only
override it in the minidump and core implementations.

patch by lemo

Bug: https://bugs.llvm.org/show_bug.cgi?id=34532

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

llvm-svn: 313655
2017-09-19 18:07:33 +00:00
Francis Ricci 7bda2c6baf Fix build of TaskPoolTest with xcodebuild
llvm-svn: 313642
2017-09-19 17:13:39 +00:00
Francis Ricci 7ddfe8ef75 Use ThreadLauncher to launch TaskPool threads
Summary:
This allows for the stack size to be configured, which isn't
possible with std::thread. Prevents overflowing the stack when
performing complex operations in the task pool on darwin,
where the default pthread stack size is only 512kb.

This also moves TaskPool from Utility to Host.

Reviewers: labath, tberghammer, clayborg

Subscribers: lldb-commits

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

llvm-svn: 313637
2017-09-19 15:38:30 +00:00
Adrian McCarthy 8f31dc9754 Revert "Fix for bug 34532 - A few rough corners related to post-mortem debugging (core/minidump)"
Broke Windows and FreeBSD (at least).

This reverts commit 628ca7052b4a5dbace0f6205409113e12c8a78fa.

llvm-svn: 313540
2017-09-18 15:59:44 +00:00
Francis Ricci 25c6d26131 Revert "Use ThreadLauncher to launch TaskPool threads"
This reverts commit r313537 because it fails to link on linux buildbots

llvm-svn: 313539
2017-09-18 15:43:59 +00:00
Francis Ricci 52ca3286fb Use ThreadLauncher to launch TaskPool threads
Summary:
This allows for the stack size to be configured, which isn't
possible with std::thread. Prevents overflowing the stack when
performing complex operations in the task pool on darwin,
where the default pthread stack size is only 512kb.

Reviewers: labath, tberghammer, clayborg

Subscribers: lldb-commits

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

llvm-svn: 313537
2017-09-18 15:18:48 +00:00
Tamas Berghammer 1492cb89ca Fix Linux remote debugging after r313442
On Linux lldb-server sends an OK response to qfThreadInfo if no process
is started yet. I don't know why would LLDB issue a qfThreadInfo packet
before starting a process but creating a fake thread ID in case of an
OK or Error respoinse sounds bad anyway so lets not do it.

llvm-svn: 313525
2017-09-18 10:24:48 +00:00
Vadim Chugunov 3293b9d42c Fix compatibility with OpenOCD debug stub.
OpenOCD sends register classes as two separate <feature> nodes, fixed parser to process both of them.

OpenOCD returns "l" in response to "qfThreadInfo", so IsUnsupportedResponse() was false and we were ending up without any threads in the process. I think it's reasonable to assume that there's always at least one thread.

llvm-svn: 313442
2017-09-16 03:53:13 +00:00
Eugene Zemtsov 0edfea5340 Check availability of accept4 in C++ instad of C code.
llvm-svn: 313437
2017-09-16 02:58:49 +00:00
Eugene Zemtsov d4abad9a0a More precise c library feature detection for Android.
llvm-svn: 313436
2017-09-16 02:19:21 +00:00
Zachary Turner ce92db13ea Resubmit "[lit] Force site configs to run before source-tree configs"
This is a resubmission of r313270.  It broke standalone builds of
compiler-rt because we were not correctly generating the llvm-lit
script in the standalone build directory.

The fixes incorporated here attempt to find llvm/utils/llvm-lit
from the source tree returned by llvm-config.  If present, it
will generate llvm-lit into the output directory.  Regardless,
the user can specify -DLLVM_EXTERNAL_LIT to point to a specific
lit.py on their file system.  This supports the use case of
someone installing lit via a package manager.  If it cannot find
a source tree, and -DLLVM_EXTERNAL_LIT is either unspecified or
invalid, then we print a warning that tests will not be able
to run.

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

llvm-svn: 313407
2017-09-15 22:10:46 +00:00
Jim Ingham 576628bdd7 Remove a couple of warnings pointed out by Ted Woodward.
llvm-svn: 313371
2017-09-15 17:54:37 +00:00
Zachary Turner 83dcb68468 Revert "[lit] Force site configs to run before source-tree configs"
This patch is still breaking several multi-stage compiler-rt bots.
I already know what the fix is, but I want to get the bots green
for now and then try re-applying in the morning.

llvm-svn: 313335
2017-09-15 02:56:40 +00:00
Reid Kleckner 325b6c1efe Fix syntax in lldb lit.cfg
llvm-svn: 313332
2017-09-15 01:30:52 +00:00
Jim Ingham e9632ebab3 Wire up the breakpoint name help string.
llvm-svn: 313327
2017-09-15 00:52:35 +00:00
Jim Ingham 5cd216650f Mention breakpoint names in the tutorial.
llvm-svn: 313305
2017-09-14 22:20:31 +00:00