Commit Graph

24623 Commits

Author SHA1 Message Date
Benjamin Kramer d4d80a2903 Bump googletest to 1.10.0 2021-05-14 19:16:31 +02:00
Jonas Devlieghere f93e9c12bf [lldb] Fixup indirect symbols as they are signed.
This fixes a bunch of test failures in Apple Silicon (arm64e).
2021-05-13 10:27:22 -07:00
Jonas Devlieghere ce12b52de2 [lldb] Fixup more code addresses
The Swift async task pointers are signed on arm64e and we need to fixup
the addresses in the CFA and DWARF expressions.
2021-05-13 10:27:22 -07:00
Jason Molenda afee09751d [NFC] Add GetInferiorAddrSize method, unify code to compute
MachProcess.mm has a sequence to get the address size in
the inferior in three places; and I'm about to add a fourth
in a future patch.  Not a fan.
2021-05-13 00:47:58 -07:00
Jason Molenda 0c443e92d3 Add some warnings when debugserver is running in translation
A debugserver launched x86_64 cannot control an arm64/arm64e
process on an Apple Silicon system.  Warn when this situation
has happened and return an error for the most common case of
attach.  I think there will be refinements to this in the
future, but start out by making it easy to spot the problem
when it happens.

rdar://76630595
2021-05-12 22:18:24 -07:00
Adrian Prantl 017d7a9e14 Rename human-readable name for DW_LANG_Mips_Assembler
The Mips in DW_LANG_Mips_Assembler is a vendor name not an
architecture name and in lack of a proper generic DW_LANG_assembler,
some assemblers emit DWARF using this tag. Due to a warning I recently
introduced users will now be greeted with

  This version of LLDB has no plugin for the mipsassem language. Inspection of frame variables will be limited.

By renaming this to just "Assembler" this error message will make more sense.

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

rdar://77214764
2021-05-12 19:13:58 -07:00
Michał Górny 71e66da04c [Process/elf-core] Read PID from FreeBSD prpsinfo
Add a function to read NT_PRPSINFO note from FreeBSD core dumps.  This
is necessary to get the process ID (NT_PRSTATUS has only thread ID).
Move the lp64 check from NT_PRSTATUS parsing to the parseFreeBSDNotes()
to avoid repeating it.

Differential Revision: https://reviews.llvm.org/D101893
2021-05-12 11:51:37 +02:00
Michał Górny b6c0edb979 [lldb] [Process/elf-core] Fix reading FPRs from FreeBSD/i386 cores
The FreeBSD coredumps from i386 systems contain only FSAVE-style
NT_FPREGSET.  Since we do not really support reading that kind of data
anymore, just use NT_X86_XSTATE to get FXSAVE-style data when available.

Differential Revision: https://reviews.llvm.org/D101086
2021-05-12 11:51:37 +02:00
Neal (nealsid) 5af3a6645f Remove Windows editline from LLDB
I don't mean to undo others' work but it looks like the hand-rolled EditLine for LLDB on Windows isn't used.  It'd be easier to make changes to bring the other platforms' Editline wrapper up to date (e.g. simplifying char vs wchar_t) without modifying/testing this one too.

Reviewed By: amccarth

Differential Revision: https://reviews.llvm.org/D102208
2021-05-12 10:05:44 +01:00
Jim Ingham 10c309ad81 Removing test...
Actually, I don't think this test is going to be stable enough
to be worthwhile.  Let me see if I can think of a better way to
test this.
2021-05-11 18:27:37 -07:00
Jim Ingham 0f2eb7e6e5 This test is failing on Linux, skip while I investigate.
The gdb-remote tests are a bit artificial, depending on
Python threading, and sleeps.  So I'm not 100% surprised it doesn't
work straight up on another XSsystem.
2021-05-11 18:13:56 -07:00
Jim Ingham 9558b602b2 Add an "interrupt timeout" to Process, and pipe that through the
ProcessGDBRemote plugin layers.

Also fix a bug where if we tried to interrupt, but the ReadPacket
wakeup timer woke us up just after the timeout, we would break out
the switch, but then since we immediately check if the response is
empty & fail if it is, we could end up actually only giving a
small interval to the interrupt.

Differential Revision: https://reviews.llvm.org/D102085
2021-05-11 11:57:08 -07:00
Augusto Noronha ec28e43e01 Add null-pointer checks when accessing a TypeSystem's SymbolFile
A type system is not guaranteed to have a symbol file. This patch adds null-pointer checks so we don't crash when trying to access a type system's symbol file.

Reviewed By: aprantl, teemperor

Differential Revision: https://reviews.llvm.org/D101539
2021-05-11 13:15:20 -03:00
Augusto Noronha 6c82b8a378 Change Target::ReadMemory to ensure the amount of memory read from the file-cache is the amount requested.
This change ensures that if for whatever reason we read less bytes than expected (for example, when trying to read memory that spans multiple sections), we try reading from the live process as well.

Reviewed By: jasonmolenda

Differential Revision: https://reviews.llvm.org/D101390
2021-05-11 13:07:11 -03:00
Martin Storsjö 3f03877f5a [LLDB] Don't use the local python to set a default for LLDB_PYTHON_RELATIVE_PATH when cross compiling.
Differential Revision: https://reviews.llvm.org/D101903
2021-05-11 14:04:41 +03:00
David Blaikie 6dc2a6a8c9 Remove some unnecessary explicit defaulted copy ctors to cleanup -Wdeprecated-copy
These types also wanted to be/were copy assignable, and using the
implicit copy ctor is deprecated in the presence of an explicit copy
ctor.

Removing the explicit copy ctor provides the desired behavior - both
ctor and assignment operator are available implicitly.

Also while I was nearby there were some missing std::moves on shared
pointer parameters.
2021-05-10 14:31:11 -07:00
Jim Ingham 72ba78c29e When SendContinuePacketAndWaitForResponse returns eStateInvalid, don't fetch more packets.
This looks like just an oversight in the AsyncThread function.  It gets a result of
eStateInvalid, and then marks the process as exited, but doesn't set "done" to true,
so we go to fetch another event.  That is not safe, since you don't know when that
extra packet is going to arrive.  If it arrives while you are tearing down the
process, the internal-state-thread might try to handle it when the process in not
in a good state.

Rather than put more effort into checking all the shutdown paths to make sure this
extra packet doesn't cause problems, just don't fetch it.  We weren't going to do
anything useful with it anyway.

The main part of the patch is setting "done = true" when we get the eStateInvalid.
I also added a check at the beginning of the while(done) loop to prevent another error
from getting us to fetch packets for an exited process.

I added a test case to ensure that if an Interrupt fails, we call the process
exited.  I can't test exactly the error I'm fixing, there's no good way to know
that the stop reply for the failed interrupt wasn't fetched.  But at least this
asserts that the overall behavior is correct.

Differential Revision: https://reviews.llvm.org/D101933
2021-05-06 14:11:42 -07:00
Raphael Isemann 3026f75ed0 [lldb][NFC] Make assert in TestStaticVariables more expressive 2021-05-06 16:00:24 +02:00
Dave Lee c5cf4b8f11 [lldb] Handle missing SBStructuredData copy assignment cases
Fix cases that can crash `SBStructuredData::operator=`.

This happened in a case where `rhs` had a null `SBStructuredDataImpl`.

Differential Revision: https://reviews.llvm.org/D101585
2021-05-05 15:12:03 -07:00
Philipp Krones 632ebc4ab4 [MC] Untangle MCContext and MCObjectFileInfo
This untangles the MCContext and the MCObjectFileInfo. There is a circular
dependency between MCContext and MCObjectFileInfo. Currently this dependency
also exists during construction: You can't contruct a MOFI without a MCContext
without constructing the MCContext with a dummy version of that MOFI first.
This removes this dependency during construction. In a perfect world,
MCObjectFileInfo wouldn't depend on MCContext at all, but only be stored in the
MCContext, like other MC information. This is future work.

This also shifts/adds more information to the MCContext making it more
available to the different targets. Namely:

- TargetTriple
- ObjectFileType
- SubtargetInfo

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D101462
2021-05-05 10:03:02 -07:00
Med Ismail Bennani 9775582e34 [lldb/Test] Disable testBreakpointByLineAndColumnNearestCode on Windows
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-05-05 06:04:08 +00:00
Med Ismail Bennani 35ecfda01c [lldb/Symbol] Fix column breakpoint `move_to_nearest_code` match
This patch fixes the column symbol resolution when creating a breakpoint
with the `move_to_nearest_code` flag set.

In order to achieve this, the patch adds column information handling in
the `LineTable`'s `LineEntry` finder. After experimenting a little, it
turns out the most natural approach in case of an inaccurate column match,
is to move backward and match the previous `LineEntry` rather than going
forward like we do with simple line breakpoints.

The patch also reflows the function to reduce code duplication.

Finally, it updates the `BreakpointResolver` heuristic to align it with
the `LineTable` method.

rdar://73218201

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-05-05 05:07:50 +00:00
Brad Smith 3a62d4fde8 Fix typo, arvm7 -> armv7 2021-05-05 00:56:44 -04:00
Walter Erquinigo ade59d5309 [trace] Dedup different source lines when dumping instructions + refactor
When dumping the traced instructions in a for loop, like this one

  4:  for (int a = 0; a < n; a++)
  5:    do something;

there might be multiple LineEntry objects for line 4, but with different address ranges. This was causing the dump command to dump something like this:

```
  a.out`main + 11 at main.cpp:4
    [1] 0x0000000000400518    movl   $0x0, -0x8(%rbp)
    [2] 0x000000000040051f    jmp    0x400529                  ; <+28> at main.cpp:4
  a.out`main + 28 at main.cpp:4
    [3] 0x0000000000400529    cmpl   $0x3, -0x8(%rbp)
    [4] 0x000000000040052d    jle    0x400521                  ; <+20> at main.cpp:5
```

which is confusing, as main.cpp:4 appears twice consecutively.

This diff fixes that issue by making the line entry comparison strictly about the line, column and file name. Before it was also comparing the address ranges, which we don't need because our output is strictly about what the user sees in the source.

Besides, I've noticed that the logic that traverses instructions and calculates symbols and disassemblies had too much coupling, and made my changes harder to implement, so I decided to decouple it. Now there are two methods for iterating over the instruction of a trace. The existing one does it on raw load addresses, but the one provides a SymbolContext and an InstructionSP, and does the calculations efficiently (not as efficient as possible for now though), so the caller doesn't need to care about these details. I think I'll be using that iterator to reconstruct the call stacks.

I was able to fix a test with this change.

Differential Revision: https://reviews.llvm.org/D100740
2021-05-04 19:40:52 -07:00
Med Ismail Bennani d5069dace7
[lldb/Symbol] Fix typo in SymbolFilePDBTests (NFC)
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-05-05 00:38:41 +00:00
Med Ismail Bennani 30fcdf0b19 [lldb/Symbol] Update SymbolFilePDB unitest with SourceLocationSpec
This patch should fix the windows test failure following `3e2ed7440569`.

It makes use of a `SourceLocationSpec` object  when resolving a symbol
context from `SymbolFilePDB` file.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-05-05 00:34:44 +00:00
Med Ismail Bennani 3e2ed74405 [lldb] Refactor argument group by SourceLocationSpec (NFCI)
This patch refactors a good part of the code base turning the usual
FileSpec, Line, Column, CheckInlines, ExactMatch arguments into a
SourceLocationSpec object.

This change is required for a following patch that will add handling of the
column line information when doing symbol resolution.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-05-04 23:04:31 +00:00
Med Ismail Bennani adfffebec6 [lldb/Core] Add SourceLocationSpec class (NFC)
A source location specifier class that holds a Declaration object containing
a FileSpec with line and column information. The column line is optional.
It also holds search flags that can be fetched by resolvers to look inlined
declarations and/or exact matches.

It describes a specific location in a source file and allows the user
to perform checks and comparaisons between multiple instances of that class.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-05-04 16:34:45 +00:00
Med Ismail Bennani 1435f6b00b [lldb] Move and clean-up the Declaration class (NFC)
This patch moves the Declaration class from the Symbol library to the
Core library. This will allow to use it in a more generic fashion and
aims to lower the dependency cycles when it comes to the linking.

The patch also does some cleaning up by making column information
permanent and removing the LLDB_ENABLE_DECLARATION_COLUMNS directives.

Differential revision: https://reviews.llvm.org/D101556

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-05-04 16:34:44 +00:00
Med Ismail Bennani 0c3f762c8f [lldb/Utility] Update path in FileSpec documentation (NFC)
Update FileSpec doxygen path to reflect its actual location in the
source-tree.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-05-04 16:34:44 +00:00
Jim Ingham 60ad0fd3c8 Clarify the help for "breakpoint command add" and "watchpoint command add".
These two commands add a list of commands to the breakpoint/watchpoint. The current
implementation only supports replacing the current command list.  I started with
that as overwrite seems to be the most common operation.  But using "add" will
allow us to later offer other add-modes: "prepend", "append" and "insert".
That and "overwrite" then make up a useful set of options for this operation.
2021-05-03 17:22:43 -07:00
Jonas Devlieghere 2d5d720df0 [debugserver] Include LLDB_VERSION_SUFFIX in debugserver version
The lack of a dot before the suffix is intentional, as the suffix itself
includes a dot or dash.

Differential revision: https://reviews.llvm.org/D101655
2021-05-03 15:05:32 -07:00
Muhammad Omair Javaid 69a3269250 Support AArch64 PAC elf-core register read
This adds support for reading AArch64 Pointer Authentication regset
from elf-core file. Also includes a test-case for the same. Furthermore
there is also a slight refactoring of RegisterContextPOSIXCore_arm64
members and constructor. linux-aarch64-pac.core file is generated using
lldb/test/API/functionalities/postmortem/elf-core/main.c with following
clang arguments:
-march=armv8.5-a -mbranch-protection=pac-ret+leaf -nostdlib -static -g

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D99941
2021-05-03 16:04:47 +05:00
Michał Górny db457e6479 [lldb] [Process/FreeBSD] Fix arm64 build after RegisterInfoPOSIX_arm64 changes
Commit 88a5b35d63 changed the API
of RegisterInfoPOSIX_arm64 and effectively broke the FreeBSD plugin.
Update it to work with the new API.

Differential Revision: https://reviews.llvm.org/D101521
2021-05-01 22:50:49 +02:00
David Spickett 44d0ad53af [lldb] Change DumpDataExtractorTest function names to lldb style (NFC) 2021-04-30 16:55:34 +01:00
David Spickett 8da5d111a5 [lldb] DumpDataExtractor tests for item byte size errors
Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D101631
2021-04-30 16:49:04 +01:00
David Spickett a86cbd4755 [lldb] More tests for DumpDataExtractor
* Using a base address or skipping it with LLDB_INVALID_ADDRESS
* Using a data offset, which does not effect the printed addresses
* Not providing an output stream
* Formatting a double sized HexFloat
* Formatting over multiple lines

Since address printing now has its own test,
I've removed the base address from all the format
type tests.

The multi line tests still use a base address to check that
it's incremented correctly for each new line.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D101627
2021-04-30 16:16:38 +01:00
Neal (nealsid) fd89af6880 Wrap edit line configuration calls into helper functions
Currently we call el_set directly to configure the editor in the libedit
wrapper.  There are some cases in which this causes extra casting, but we pass
captureless lambdas as function pointers, which should work out of the box.
Since el_set takes varargs, if the cast is incorrect or if the cast is not
present, it causes a run time failure rather than compile error.  This change
makes it so a few different types of configuration is done inside a helper
function to provide type safety and eliminate that casting.  I didn't do all
edit line configuration because I'm not sure how important it was in other cases
and it might require something more general keep up with libedit's signature.
I'm open to suggestions, though.

Reviewed By: teemperor, JDevlieghere

Differential Revision: https://reviews.llvm.org/D101250
2021-04-30 12:32:29 +02:00
David Spickett 8fdfc1d64c [lldb] Add tests for DumpDataExtractor formats
Covering basic cases where you have 1 item on 1 line.

Apart from eFormatCharArray, where using multiple lines
highlights the difference between it and eFormatVectorOfChar.

Reviewed By: #lldb, teemperor

Differential Revision: https://reviews.llvm.org/D101453
2021-04-30 10:29:05 +01:00
Jonas Devlieghere b535459d0a [debugserver] Use add_lldb_library instead of add_library
Use add_lldb_library to ensure debugserver inherits the defines set by
llvm and lldb.

Differential revision: https://reviews.llvm.org/D101596
2021-04-29 22:09:10 -07:00
Walter Erquinigo 1141ba677e [lldb-vscode] Follow up of D99989 - store some strings more safely
As a follow up of https://reviews.llvm.org/D99989#inline-953343, I'm now
storing std::string instead of char *. I know it might never break as char *,
but if it does, chasing that bug might be dauting.
Besides, I'm also checking of the strings gotten through the SB API are
null or not.
2021-04-29 18:37:44 -07:00
Raphael Isemann a76df78470 [lldb] Make the NSSet formatter faster and less prone to infinite recursion
Right now to get the 'NSSet *` pointer value we first derefence it and then take
the address of the result.

Beside being inefficient this potentially can cause an infinite recursion if the
`pointer` value we get is a pointer of a type that the TypeSystem can't
derefence. If the pointer is for example some form of `void *` that the dynamic
type resolution can't resolve to an actual type, then the `Derefence` call goes
back to asking the formatters how to reference it. If the NSSet formatter then
checks if it's an NSSet variation under the hood then we just end infinitely
often recursion.

In practice this seems to happen with some form of Builtin.RawPointer we get
from a NSDictionary in Swift.

FWIW, no other formatter is doing the same deref->addressOf as here and there
doesn't seem to be any specific reason to do so in the git history (it's just
part of the initial formatter commit)

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D101537
2021-04-29 19:13:43 +02:00
David Spickett f31e390453 [lldb][AArch64] Don't check for VmFlags in smaps files
AArch64 kernel builds default to having /smaps and
the "VmFlags" line was added in 3.8. Long before MTE
was supported.

So we can assume that if you're AArch64 with MTE,
you can run this test.

The previous method of checking had a race condition
where the process we read smaps for, could finish before
we get to read the file.

I explored some alternatives but in the end I think
it's fine to just assume we have what we need.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D100493
2021-04-29 09:30:14 +01:00
David Spickett d0c521da3f [lldb] Correct format enum comment (NFC)
'.' is used for unprintable chars (see NON_PRINTABLE_CHAR).
2021-04-28 12:17:03 +01:00
Jordan Rupprecht 44e2247dcd [lldb] Fix DataLayout reference after 0f1137ba79 2021-04-27 20:07:09 -07:00
Adrian Prantl 711a473cd9 Update testcase for D101333. 2021-04-27 13:24:24 -07:00
Adrian Prantl 25bf137b1e Also display the underlying error message when displaying a fixit
When the user running LLDB with default settings sees the fixit
notification it means that the auto-applied fixit didn't work. This
patch shows the underlying error message instead of just the fixit to
make it easier to understand what the error in the expression was.

Differential Revision: https://reviews.llvm.org/D101333
2021-04-27 10:40:42 -07:00
Michał Górny ca7824c2a8 [lldb] [gdb-remote] Report QPassSignals and qXfer via extensions API
Remove hardcoded platform list for QPassSignals, qXfer:auxv:read
and qXfer:libraries-svr4:read and instead query the process plugin
via the GetSupportedExtensions() API.

Differential Revision: https://reviews.llvm.org/D101241
2021-04-27 19:34:00 +02:00
Raphael Isemann a0c735e29a [lldb] Skip TestPointerToMemberTypeDependingOnParentSize on Windows and GCC
The test added in D100977 is failing to compile on these platforms. This seems
to be caused by GCC, MSVC and Clang@Windows rejecting the code because
`ToLayout` isn't complete when pointer_to_member_member is declared (even though
that seems to be valid code).

This also reverts the test changes in the lazy-loading test from D100977 as
that failed for the same reason.
2021-04-26 18:55:54 +02:00
Jonas Devlieghere 7d850db6b6 [lldb] Don't use ::fork or ::vfork on watchOS or tvOS
Update lldb-server to not use fork or vfork on watchOS and tvOS as these
functions are explicitly marked unavailable there.

llvm-project/lldb/test/API/tools/lldb-server/main.cpp:304:11:
error: 'fork' is unavailable: not available on watchOS
      if (fork() == 0)
          ^
WatchSimulator6.2.sdk/usr/include/unistd.h:447:8: note: 'fork' has been
explicitly marked unavailable here
pid_t    fork(void) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
         ^
llvm-project/lldb/test/API/tools/lldb-server/main.cpp:307:11:
error: 'vfork' is unavailable: not available on watchOS
      if (vfork() == 0)
          ^
WatchSimulator6.2.sdk/usr/include/unistd.h:602:8: note: 'vfork' has been
explicitly marked unavailable here
pid_t    vfork(void) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
         ^
2021-04-26 09:31:35 -07:00