Commit Graph

14657 Commits

Author SHA1 Message Date
Rumeet Dhindsa d9c5613e85 Update logic to close inherited file descriptors.
This patch adds the support to close all inherited fds into the child
process by iterating over /proc/self/fd entries.

Differential Revision: https://reviews.llvm.org/D105732
2021-08-19 14:40:43 -07:00
Omar Emara 28a76049c6 [LLDB][GUI] Handle return key for compound fields
This patch handles the return key for compound fields like lists and
mapping fields. The return key, if not handled by the field will select
the next primary element, skipping secondary elements like remove
buttons and the like.

Differential Revision: https://reviews.llvm.org/D108331
2021-08-19 11:46:30 -07:00
Alex Langford 4947f6d8bc [lldb][NFC] Remove unused header include 2021-08-19 11:06:56 -07:00
Omar Emara 82507f1798 [LLDB][GUI] Add Process Launch form
This patch adds a process launch form. Additionally, a LazyBoolean field
was implemented and numerous utility methods were added to various
fields to get the launch form working.

Differential Revision: https://reviews.llvm.org/D107869
2021-08-18 15:43:30 -07:00
Omar Emara 698e210636 [LLDB][GUI] Fix text field incorrect key handling
The isprint libc function was used to determine if the key code
represents a printable character. The problem is that the specification
leaves the behavior undefined if the key is not representable as an
unsigned char, which is the case for many ncurses keys. This patch adds
and explicit check for this undefined behavior and make it consistent.

The llvm::isPrint function didn't work correctly for some reason, most
likely because it takes a char instead of an int, which I guess makes it
unsuitable for checking ncurses key codes.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D108327
2021-08-18 15:06:27 -07:00
Omar Emara b26e1efc42 [LLDB][GUI] Add Breakpoints window
This patch adds a breakpoints window that lists all breakpoints and
breakpoints locations. The window is implemented as a tree, where the
first level is the breakpoints and the second level is breakpoints
locations.

The tree delegate was hardcoded to only draw when there is a process,
which is not necessary for breakpoints, so the relevant logic was
abstracted in the TreeDelegateShouldDraw method.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D107386
2021-08-17 17:38:16 -07:00
Omar Emara 79e950a29e [LLDB][GUI] Refactor form drawing using subsurfaces
This patch adds a new method SubSurface to the Surface class. The method
returns another surface that is a subset of this surface. This is
important to further abstract away drawing from the ncurses objects. For
instance, fields could previously be drawn on subpads only but can now
be drawn on any surface. This is needed to create the file search
dialogs and similar functionalities.

There is an opportunity to refactor window drawing in general using
surfaces, but we shall consider this separately later.

Differential Revision: https://reviews.llvm.org/D107761
2021-08-17 16:54:41 -07:00
Shafik Yaghmour 0479afb3d6 [LLDB] Fix off by one logging placeholders in ClangASTSource::layoutRecordType()
D72391 Added some additional information to the logging but in this case instead of using
placeholder 2 and 3 they used 3 and 4.
2021-08-17 16:47:46 -07:00
Jan Kratochvil e21a21a977 [lldb] Fix#2 of DW_AT_ranges DW_FORM_sec_offset not using DW_AT_rnglists_base (used by GCC)
Fix D98289 so that it works even for 2nd..nth compilation unit
(.debug_rnglists).

Reviewed By: dblaikie, ikudrin

Differential Revision: https://reviews.llvm.org/D106466
2021-08-17 22:19:16 +02:00
Fangrui Song 5a95ff2bfc [lldb] Fix -Wunused-but-set-variable 2021-08-16 16:41:17 -07:00
Jason Molenda aa575ed918 Ah, fix formatting, I didn't notice lldb-instr's code
additions were unusually formatted.
2021-08-16 13:46:54 -07:00
Jason Molenda 65bc8ba1a2 Correctly update reproducer hooks for SB API I added
In 9ea6dd5cfa /
https://reviews.llvm.org/D88387 where I added skinny corefile
creation, I added new SB API and tried to manually update the hooks
for the reproducers. I missed a spot, and I should have used
lldb-instr to update the instrumentation automatically.
2021-08-16 13:41:18 -07:00
Dimitry Andric 5033f0793f [lldb] Avoid unhandled Error in TypeSystemMap::GetTypeSystemForLanguage
When assertions are turned off, the `llvm::Error` value created at the
start of this function is overwritten using the move-assignment
operator, but the success value is never checked. Whenever a TypeSystem
cannot be found or created, this can lead to lldb core dumping with:

    Program aborted due to an unhandled Error:
    Error value was Success. (Note: Success values must still be checked prior to being destroyed).

Fix this by not creating a `llvm::Error` value in advance, and directly
returning the result of `llvm::make_error` instead, whenever an error is
encountered.

See also: <https://bugs.freebsd.org/253881> and
<https://bugs.freebsd.org/257829>.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D108088
2021-08-16 17:34:42 +02:00
Jason Molenda 7150b56208 Symbolicate aarch64 adrp+add pc-relative addr in disass
On aarch64 a two instruction sequence is used to calculate a
pc-relative address, add some state to the DisassemblerLLVMC
symbolicator so it can track the necessary data across the
two instructions and compute the address being calculated.

Differential Revision: https://reviews.llvm.org/D107213
rdar://49119253
2021-08-12 14:44:17 -07:00
Walter Erquinigo ef28c78350 [tests] [trace] Add a more comprehensive test for `thread trace export ctf` command
Follow up on https://reviews.llvm.org/D105741

- Add new test that exhaustively checks the output file's content
- Fix typos in documentation and other minor fixes

Reviewed By: wallace

Original Author: jj10306

Differential Revision: https://reviews.llvm.org/D107674
2021-08-11 20:50:10 -07:00
Jason Molenda 2b30fc2ff3 Fix two bugs with stack corefiles patch, restrict test built debugserver
These two tests, TestSkinnyCorefile.py and TestStackCorefile.py,
require a new debugserver on darwin systems to run correctly; for now,
skip them if the system debugserver is in use.  There's no easy way to
test if the debugserver being used supports either of these memory
region info features. For end users, the fallback will be a full
corefile and that's not the worst thing, but for the tests it is a
problem.
2021-08-11 17:19:31 -07:00
Jason Molenda 8c31efeed6 Add the ability to process save-core stack-memory-only corefiles
Add a field to the qMemoryRegionInfo packet where the remote stub
can describe the type of memory -- heap, stack.  Keep track of
memory regions that are stack memory in lldb.  Add a new "--style
stack" to process save-core to request that only stack memory be
included in the corefile.

Differential Revision: https://reviews.llvm.org/D107625
2021-08-11 13:37:31 -07:00
Raphael Isemann b2c262cfb1 [lldb][NFC] Define DWARFDIE::children out-of-line instead of using template magic
As pointed out by David in D103172 (thanks!)

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D106743
2021-08-11 19:19:41 +02:00
Med Ismail Bennani be556d5131 [lldb/Commands] Fix heap-use-after-free error in CommandObjectProcess
This patch should fix the use-after-free error that was brought up by
the LLDB ASAN Green Dragon bot.

This is caused because the `StringRef` object was acquired too early
before being use and by the underlying memory was modified which caused
it to point to null memory.

Fetching back the string reference close to its usage location should
fix the issue.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-08-11 17:03:20 +01:00
Jan Kratochvil f3932b9a0b [nfc] [lldb] Assertions for D106270 - [DWARF5] Fix offset check when using .debug_names
Skeleton vs. DWO units mismatch has been fixed in D106270. As they both
have type DWARFUnit it is a bit difficult to debug. So it is better to
make it safe against future changes.

Reviewed By: kimanh, clayborg

Differential Revision: https://reviews.llvm.org/D107659
2021-08-10 20:43:24 +02:00
Raphael Isemann 9900af52f6 [lldb][NFC] Add a FIXME for NameSearchContext::AddFunDecl's missing addDecl 2021-08-10 16:14:27 +02:00
Raphael Isemann 3240000546 [lldb][NFC] Remove never read member variable IOHandler::m_editing
The last read access to this variable was removed in 2015 in
4446487d71 .
2021-08-09 18:05:53 +02:00
Robin Giese 875a16bcfc [lldb] Fix break introduced in 14735ca
The `File::OpenOptions` were renamed; this fixes up a callsite that breaks for
macOS builds. (See
14735cab65)

Differential Revision: https://reviews.llvm.org/D107767
2021-08-09 17:34:57 +02:00
Kim-Anh Tran 0dda542531 [DWARF5] Fix offset check when using .debug_names
When going through the CU entries in the name index,
make sure to compare the name entry's CU
offset against the skeleton CU's offset.

Previously there would be a mismatch, since the
wrong offset was compared, and thus no suitable
entry was found.

Reviewed By: jankratochvil

Differential Revision: https://reviews.llvm.org/D106270
2021-08-09 13:15:14 +02:00
Michał Górny 9929cfbcd5 [lldb] [gdb-remote] Use hexadecimal numbers in vFile packats for GDB compliance
Use hexadecimal numbers rather than decimal in various vFile packets
in order to fix compatibility with gdbserver.  This also changes the few
custom LLDB packets -- while technically they do not have to be changed,
it is easier to use the same syntax consistently across LLDB.

Differential Revision: https://reviews.llvm.org/D107475
2021-08-09 12:07:33 +02:00
Michał Górny 8bbef4f9af [lldb] [gdb-remote] Sync vFile:open mode constants with GDB
Sync the mode constants used to drive vFile:open requests with these
used by GDB and defined for the gdb remote protocol.  This makes it
possible to use 'platform file open' after connecting to gdbremote
server (and to some degree to operate on the open file modulo other
incompatibilities).

Differential Revision: https://reviews.llvm.org/D106985
2021-08-09 12:07:18 +02:00
Michał Górny 14735cab65 [lldb] [gdb-remote] Add eOpenOptionReadWrite for future gdb compat
Modify OpenOptions enum to open the future path into synchronizing
vFile:open bits with GDB.  Currently, LLDB and GDB use different flag
models effectively making it impossible to match bits.  Notably, LLDB
uses two bits to indicate read and write status, and uses union of both
for read/write.  GDB uses a value of 0 for read-only, 1 for write-only
and 2 for read/write.

In order to future-proof the code for the GDB variant:

1. Add a distinct eOpenOptionReadWrite constant to be used instead
   of (eOpenOptionRead | eOpenOptionWrite) when R/W access is required.

2. Rename eOpenOptionRead and eOpenOptionWrite to eOpenOptionReadOnly
   and eOpenOptionWriteOnly respectively, to make it clear that they
   do not mean to be combined and require update to all call sites.

3. Use the intersection of all three flags when matching against
   the three possible values.

This commit does not change the actual bits used by LLDB.

Differential Revision: https://reviews.llvm.org/D106984
2021-08-09 12:06:59 +02:00
Jonas Devlieghere 47a889c668 [lldb] Move Objective-C constants into ObjCConstants.h
Move Objective-C constants into ObjCConstants.h and share them between
Cocoa and AppleObjCTypeEncodingParser.

Differential revision: https://reviews.llvm.org/D107679
2021-08-07 16:04:52 -07:00
Jonas Devlieghere 9d5e95d094 Re-land "[lldb] Upstream support for Foundation constant classes"
Upstream support for NSConstantArray, NSConstantIntegerNumber,
NSConstant{Float,Double}Number and NSConstantDictionary.

We would've upstreamed this earlier but testing it requires
-fno-constant-nsnumber-literals, -fno-constant-nsarray-literals and
-fno-constant-nsdictionary-literals which haven't been upstreamed yet.
As a temporary workaround use the system compiler (xcrun clang) for the
constant variant of the tests.

I'm just upstreaming this. The patch and the tests were all authored by
Fred Riss.

Differential revision: https://reviews.llvm.org/D107660
2021-08-06 17:24:47 -07:00
Sterling Augustine 4e5af6ef48 Revert "[lldb] Upstream support for Foundation constant classes"
This reverts commit 34d78b6a67.

This breaks build bots witha  missing file:
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source/Plugins/Language/ObjC/Cocoa.cpp:10:10: fatal error: 'objc/runtime.h' file not found
2021-08-06 16:56:59 -07:00
Jim Ingham bfeb281fbd Use LC_DYLD_EXPORTS_TRIE to locate the dyld trie structure if present
The pointer to the dyld trie data structure which lldb needs to parse to get
"trampoline kinds" on Darwin used to be a field in the LC_DYLD_INFO load command. A
new load command was added recently dedicated to this purpose: LC_DYLD_EXPORTS_TRIE.
The format of the trie did not change, however. So all we have to do is use the new
command if present. The commands are supposed to be mutually exclusive, so I added
an lldb_assert to warn if they are not.

Differential Revision: https://reviews.llvm.org/D107673
2021-08-06 16:38:34 -07:00
Jonas Devlieghere 34d78b6a67 [lldb] Upstream support for Foundation constant classes
Upstream support for NSConstantArray, NSConstantIntegerNumber,
NSConstant{Float,Double}Number and NSConstantDictionary.

We would've upstreamed this earlier but testing it requires
-fno-constant-nsnumber-literals, -fno-constant-nsarray-literals and
-fno-constant-nsdictionary-literals which haven't been upstreamed yet.
As a temporary workaround use the system compiler (xcrun clang) for the
constant variant of the tests.

I'm just upstreaming this. The patch and the tests were all authored by
Fred Riss.

Differential revision: https://reviews.llvm.org/D107660
2021-08-06 16:08:48 -07:00
Jim Ingham f362b05d0d Add a "current" token to the ThreadID option to break set/modify.
This provides a convenient way to limit a breakpoint
to the current thread when setting it from the command line w/o
having to figure out what the current thread is.

Differential Revision: https://reviews.llvm.org/D107015
2021-08-06 15:29:55 -07:00
Fred Riss 9ed7416aaf [lldb] Try harder to find the __NSCFBoolean addresses
It looks like recent CoreFoundation builds strip the non-public symbol
that we were looking for to find the 2 boolean "classes". The public
symbol is of course there, and it contains the address of the private
one. If we don't find the private symbol directly, go through a memory
read at the public symbol's location instead.
2021-08-06 13:04:29 -07:00
Jason Molenda 4d3d182c1d Revert "[LLDB][GUI] Refactor form drawing using subsurfaces"
Temporarily revert this patch to unbreak the bots/builds
until we can understand what was intended; is_pad() call
isn't defined.

This reverts commit 2b89f40a41.
2021-08-05 19:27:55 -07:00
Omar Emara 2b89f40a41 [LLDB][GUI] Refactor form drawing using subsurfaces
This patch adds a new method SubSurface to the Surface class. The method
returns another surface that is a subset of this surface. This is
important to further abstract away drawing from the ncurses objects. For
instance, fields could previously be drawn on subpads only but can now
be drawn on any surface. This is needed to create the file search
dialogs and similar functionalities.

There is an opportunity to refactor window drawing in general using
surfaces, but we shall consider this separately later.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D107182
2021-08-05 16:51:14 -07:00
Nico Weber 11565320fd [lldb] Remove a few unused .exports files
They used to be referenced from the .xcodeproj files, but those are long gone.

No behavior change.

Differential Revision: https://reviews.llvm.org/D107444
2021-08-05 22:17:00 +02:00
Jonas Devlieghere a46bcc60e5 [lldb] Refactor IRExecutionUnit::FindInSymbols (NFC)
This patch refactors IRExecutionUnit::FindInSymbols. It eliminates a few
potential pitfalls and tries to be more explicit about the state carried
between symbol resolution attempts.

Differential revision: https://reviews.llvm.org/D107206
2021-08-05 10:18:14 -07:00
Jonas Devlieghere c020be17ce [lldb] Use a struct to pass function search options to Module::FindFunction
Rather than passing two booleans around, which is especially error prone
with them being next to each other, use a struct with named fields
instead.

Differential revision: https://reviews.llvm.org/D107295
2021-08-05 10:18:14 -07:00
Neal Sidhwaney 55fd6f292f Revert "D106035: Remove conditional compilation for WCHAR support in libedit"
This reverts commit 7529f0e3e1.
2021-08-05 02:55:10 -07:00
Neal Sidhwaney 7529f0e3e1 D106035: Remove conditional compilation for WCHAR support in libedit
This change moves to using narrow character types and libedit APIs in
Editline, because those are the same types that the rest of LLVM/LLDB
uses, and it's generally considered better practice to use UTF-8
encoded in char than it is to use wider characters. However, for
character input, the change leaves in using a wchar to enable input of
multi-byte characters.

Differential Revision: https://reviews.llvm.org/D106035
2021-08-05 00:29:54 -07:00
Jan Kratochvil 14f443030c [nfc] [lldb] Prevent needless copies of DataExtractor
lldb_private::DataExtractor contains DataBufferSP m_data_sp which is
relatively expensive to copy (due to multi-threading locking).

llvm::DataExtractor does not have this problem as it uses StringRef
instead.

The copy constructor is explicit as otherwise it is easy to make
unintended modification of a local copy instead of a caller's instance
(D107470 but that is llvm::DataExtractor).

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D107485
2021-08-04 20:35:53 +02:00
Jaroslav Sevcik f968bd77bb Reland "[lldb/DWARF] Only match mangled name in full-name function lookup (with accelerators)"
Summary:

In the spirit of https://reviews.llvm.org/D70846, we only return functions with
matching mangled name from Apple/DebugNamesDWARFIndex::GetFunction if
eFunctionNameTypeFull is requested.

This speeds up lookup in the presence of large amount of class methods of the
same name (a typical examples would be constructors of templates with many
instantiations or overloaded operators).

Reviewers: labath, teemperor

Reviewed By: labath, teemperor

Subscribers: aprantl, arphaman, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73191
2021-08-04 12:50:13 +02:00
Kim-Anh Tran 0092dbcd80 [lldb] Fix lookup of .debug_loclists with split-dwarf
This patch fixes the lookup of locations in
.debug_loclists, if they are split in a .dwp file.

Mainly, we need to consider the cu index offsets.

Reviewed By: jankratochvil

Differential Revision: https://reviews.llvm.org/D107161
2021-08-04 11:36:44 +02:00
Raphael Isemann e4977f9cb5 [lldb] Partly revert "Allow range-based for loops over DWARFDIE's children"
As pointed out in D107434 by Walter, D103172 also changed two for loops that
were actually not just iterating over some DIEs but also using the iteration
variable later on for some other things. This patch reverts the respective
faulty parts of D103172.
2021-08-04 11:05:08 +02:00
Nico Weber bf3383501f [lldb] Get rid of HAVE_SYS_TYPES_H
LLVM includes this header unconditionally on all platforms
(including Windows), so this define should no longer be necessary.

No behavior change.

Differential Revision: https://reviews.llvm.org/D107338
2021-08-03 22:14:56 +02:00
Eric Leese 437e37dd55 [nfc] [lldb] Support moving support files instead of copy
Split from D100299.

Reviewed By: jankratochvil

Differential Revision: https://reviews.llvm.org/D107165
2021-08-02 21:43:34 +02:00
Muhammad Omair Javaid a94fbb25de Revert "Revert "[LLDB][GUI] Expand selected thread tree item by default""
This reverts commit fd18f0e84c.

I reverted this change to see its effect on failing GUI tests on LLDB
Arm/AArch64 Linux buildbots. I could not find any evidence against this
particular change so reverting it back.

Differential Revision: https://reviews.llvm.org/D100243
2021-08-02 05:29:32 +05:00
Dave Lee 41d0b20cc9 [lldb] Avoid moving ThreadPlanSP from plans vector
Change `ThreadPlanStack::PopPlan` and `::DiscardPlan` to not do the following:

1. Move the last plan, leaving a moved `ThreadPlanSP` in the plans vector
2. Operate on the last plan
3. Pop the last plan off the plans vector

This leaves a period of time where the last element in the plans vector has been moved. I am not sure what, if any, guarantees there are when doing this, but it seems like it would/could leave a null `ThreadPlanSP` in the container. There are asserts in place to prevent empty/null `ThreadPlanSP` instances from being pushed on to the stack, and so this could break that invariant during multithreaded access to the thread plan stack.

An open question is whether this use of `std::move` was the result of a measure performance problem.

Differential Revision: https://reviews.llvm.org/D106171
2021-08-01 10:40:04 -07:00
Jan Kratochvil 6ef6616e07 [nfc] [lldb] Removed unused DWARFDebugInfo::GetDIEForDIEOffset
Its last use was removed by D63428.
2021-08-01 00:38:01 +02:00