Commit Graph

14999 Commits

Author SHA1 Message Date
Jim Ingham e655769c4a Fix a bug in Launch when using an async debugger & remote platform.
We weren't setting the listener back to the unhijacked one in this
case, so that a continue after the stop fails.  It thinks the process
is still running.  Also add tests for this behavior.

Differential Revision: https://reviews.llvm.org/D112747
2021-10-28 17:02:43 -07:00
Jim Ingham 1227fa7e90 Remove unused ValueObjectDynamicValue::SetOwningSP & backing ivar
This has no uses and the ValueObjectDynamicValue already tracks
its ownership through the parent it is passed when made.  I can't
find any vestiges of the use of this API, maybe it was from some
earlier design?

Resetting the backing ivar was the only job the destructor did, so I
set that to default as well.

Differential Revision: https://reviews.llvm.org/D112677
2021-10-28 16:06:01 -07:00
Michał Górny e50f02ba7e [lldb] [Host/ConnectionFileDescriptor] Refactor to improve code reuse
Refactor ConnectionFileDescriptor to improve code reuse for different
types of sockets.  Unify method naming.

While at it, remove some (now-)dead code from Socket.

Differential Revision: https://reviews.llvm.org/D112495
2021-10-28 19:24:10 +02:00
Raphael Isemann f5c65be510 [lldb][NFC] Improve CppModuleConfiguration documentation a bit 2021-10-28 16:39:06 +02:00
Pavel Labath 5f4980f004 [lldb] Remove ConstString from Process, ScriptInterpreter and StructuredData plugin names 2021-10-28 10:15:03 +02:00
Michał Górny 073c5d0e47 [lldb] [Host/Socket] Make DecodeHostAndPort() return a dedicated struct
Differential Revision: https://reviews.llvm.org/D112629
2021-10-28 09:57:50 +02:00
Greg Clayton 1300556479 Add unix signal hit counts to the target statistics.
Android and other platforms make wide use of signals when running applications and this can slow down debug sessions. Tracking this statistic can help us to determine why a debug session is slow.

The new data appears inside each target object and reports the signal hit counts:

      "signals": [
        {
          "SIGSTOP": 1
        },
        {
          "SIGUSR1": 1
        }
      ],

Differential Revision: https://reviews.llvm.org/D112683
2021-10-27 22:31:14 -07:00
Greg Clayton fb25496832 Add breakpoint resolving stats to each target.
This patch adds breakpoints to each target's statistics so we can track how long it takes to resolve each breakpoint. It also includes the structured data for each breakpoint so the exact breakpoint details are logged to allow for reproduction of slow resolving breakpoints. Each target gets a new "breakpoints" array that contains breakpoint details. Each breakpoint has "details" which is the JSON representation of a serialized breakpoint resolver and filter, "id" which is the breakpoint ID, and "resolveTime" which is the time in seconds it took to resolve the breakpoint. A snippet of the new data is shown here:

  "targets": [
    {
      "breakpoints": [
        {
          "details": {...},
          "id": 1,
          "resolveTime": 0.00039291599999999999
        },
        {
          "details": {...},
          "id": 2,
          "resolveTime": 0.00022679199999999999
        }
      ],
      "totalBreakpointResolveTime": 0.00061970799999999996
    }
  ]

This provides full details on exactly how breakpoints were set and how long it took to resolve them.

Differential Revision: https://reviews.llvm.org/D112587
2021-10-27 16:50:11 -07:00
Med Ismail Bennani 8dbbe3356b Revert "[lldb] [Host/ConnectionFileDescriptor] Refactor to improve code reuse"
This reverts commit e1acadb61d.
2021-10-27 23:57:33 +02:00
Jonas Devlieghere 8bac9e3686 [lldb] Fixup code addresses in the Objective-C language runtime
Upstream the calls to ABI::FixCodeAddress in the Objective-C language
runtime.

Differential revision: https://reviews.llvm.org/D112662
2021-10-27 14:48:03 -07:00
Danil Stefaniuc 3eb9e6536a [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs
This diff adds a data formatter for libstdcpp's set. Besides, it unifies the tests for set for libcxx and libstdcpp for maintainability.

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D112537
2021-10-27 11:55:11 -07:00
Raphael Isemann 9d7006c4ae [lldb][NFC] Move a declaration in DWARFASTParserClang to its first use. 2021-10-27 17:46:50 +02:00
Nico Weber 99f5f0a2b7 fix comment typos to cycle bots 2021-10-27 09:43:42 -04:00
Michał Górny e1acadb61d [lldb] [Host/ConnectionFileDescriptor] Refactor to improve code reuse
Refactor ConnectionFileDescriptor to improve code reuse for different
types of sockets.  Unify method naming.

While at it, remove some (now-)dead code from Socket.

Differential Revision: https://reviews.llvm.org/D112495
2021-10-27 12:45:52 +02:00
Pavel Labath f5158ca48c Modernize Platform::GetOSKernelDescription 2021-10-27 10:46:47 +02:00
Pavel Labath 49481b5380 Remove ConstString from Language, LanguageRuntime, SystemRuntime and SymbolFile plugin names 2021-10-27 08:25:44 +02:00
Greg Clayton 2887d9fd86 Add new key/value pairs to the module statistics for "statistics dump".
The new key/value pairs that are added to each module's stats are:
"debugInfoByteSize": The size in bytes of debug info for each module.
"debugInfoIndexTime": The time in seconds that it took to index the debug info.
"debugInfoParseTime": The time in seconds that debug info had to be parsed.

At the top level we add up all of the debug info size, parse time and index time with the following keys:
"totalDebugInfoByteSize": The size in bytes of all debug info in all modules.
"totalDebugInfoIndexTime": The time in seconds that it took to index all debug info if it was indexed for all modules.
"totalDebugInfoParseTime": The time in seconds that debug info was parsed for all modules.

Differential Revision: https://reviews.llvm.org/D112501
2021-10-26 15:09:31 -07:00
Danil Stefaniuc 566bfbb740 [formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs
This diff adds a data formatter for libstdcpp's bitset. Besides, it unifies the tests for bitset for libcxx and libstdcpp for maintainability.

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D112180
2021-10-26 14:49:50 -07:00
Michał Górny 4373f3595f [lldb] [Host] Move port predicate-related logic to gdb-remote
Remove the port predicate from Socket and ConnectionFileDescriptor,
and move it to gdb-remote.  It is specifically relevant to the threading
used inside gdb-remote and with the new port callback API, we can
reliably move it there.  While at it, switch from the custom Predicate
to std::promise/std::future.

Differential Revision: https://reviews.llvm.org/D112357
2021-10-26 13:53:08 +02:00
Michał Górny 58d28b931f [lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor
Unify the listen and connect code inside lldb-server to use
ConnectionFileDescriptor uniformly rather than a mix of it and Acceptor.
This involves:

- adding a function to map legacy values of host:port parameter
  (including legacy server URLs) into CFD-style URLs

- adding a callback to return "local socket id" (i.e. UNIX socket path
  or TCP port number) between listen() and accept() calls in CFD

- adding a "unix-abstract-accept" scheme to CFD

As an additional advantage, this permits lldb-server to accept any URL
known to CFD including the new serial:// scheme.  Effectively,
lldb-server can now listen on the serial port.  Tests for connecting
over a pty are added to test that.

Differential Revision: https://reviews.llvm.org/D111964
2021-10-26 13:06:19 +02:00
Pavel Labath 93c7ed8c3f [lldb] Fix PlatformAppleSimulator for a458ef4f 2021-10-26 13:03:47 +02:00
Michał Górny f279e50fd0 [lldb] [Communication] Add a WriteAll() method that resumes writing
Add a Communication::WriteAll() that resumes Write() if the initial call
did not write all data.  Use it in GDBRemoteCommunication when sending
packets in order to fix handling partial writes (i.e. just resume/retry
them rather than erring out).  This fixes LLDB failures when writing
large packets to a pty.

Differential Revision: https://reviews.llvm.org/D112169
2021-10-26 12:45:45 +02:00
Pavel Labath 0a39a9c2cb Modernize and simplify HostInfo::GetOSKernelDescription
Replace bool+by-ref argument with llvm::Optional, and move the common
implementation into HostInfoPOSIX. Based on my (simple) experiment,
the uname and the sysctl approach return the same value on MacOS, so
there's no need for a mac-specific implementation of this functionality.

Differential Revision: https://reviews.llvm.org/D112457
2021-10-26 11:17:02 +02:00
Pavel Labath a458ef4f73 [lldb] Remove ConstString from Platform plugin names 2021-10-26 10:04:35 +02:00
Pavel Labath b69564d94d [lldb/DWARF] Move a declaration closer to its use
Adresses post-commit feedback on D112310.
2021-10-26 09:58:10 +02:00
Greg Clayton c571988e9d Add modules stats into the "statistics dump" command.
The new module stats adds the ability to measure the time it takes to parse and index the symbol tables for each module, and reports modules statistics in the output of "statistics dump" along with the path, UUID and triple of the module. The time it takes to parse and index the symbol tables are also aggregated into new top level key/value pairs at the target level.

Differential Revision: https://reviews.llvm.org/D112279
2021-10-25 11:50:02 -07:00
Michał Górny 1bd258fd4e [lldb] [DynamicRegisterInfo] Remove AddRegister() and make Finalize() protected
Now that AddRegister() is no longer used, remove it.  While at it,
we can also make Finalize() protected as all supported API methods
call it internally.

Differential Revision: https://reviews.llvm.org/D111498
2021-10-25 20:05:30 +02:00
Michał Górny 26c584f4f1 [lldb] [gdb-remote] Remove HardcodeARMRegisters() hack
HardcodeARMRegisters() is a hack that was supposed to be used "until
we can get an updated debugserver down on the devices".  Since it was
introduced back in 2012, there is a good chance that the debugserver
has been updated at least once since then.  Removing this code makes
transition to the new DynamicRegisterInfo API easier.

Differential Revision: https://reviews.llvm.org/D111491
2021-10-25 20:05:29 +02:00
Pavel Labath a53978c95c [lldb] Remove a trailing \0 from the result of HostInfoMacOSX::GetOSBuildString
This has been in there since forever, but only started to matter once
40e4ac3e changed how we print the string.
2021-10-25 17:33:06 +02:00
Michał Górny 9d63b90b59 [lldb] [Host/ConnectionFileDescriptor] Do not use non-blocking mode
Disable non-blocking mode that's enabled only for file:// and serial://
protocols.  All read operations should be going through the select(2)
in ConnectionFileDescriptor::BytesAvaliable, which effectively erases
(non-)blocking mode differences in reading.  We do want to perform
writes in the blocking mode.

Differential Revision: https://reviews.llvm.org/D112442
2021-10-25 16:24:00 +02:00
Pavel Labath 40e4ac3e5b [lldb] Modernize Platform::GetOSBuildString 2021-10-25 15:58:58 +02:00
Raphael Isemann 309fccdac9 [lldb][NFC] Use llvm::Optional to refer to Optional
clang::Optional is just an alias used within Clang.
2021-10-25 11:37:15 +02:00
Pavel Labath 1397c56d7a Fix windows build for 6fa1b4ff4 2021-10-25 11:12:39 +02:00
Michał Górny 0e5a4147e5 [lldb] [Utility/UriParser] Return results as 'struct URI'
Return results of URI parsing as 'struct URI' instead of assigning them
via output parameters.

Differential Revision: https://reviews.llvm.org/D112314
2021-10-25 10:58:21 +02:00
Michał Górny 21bb808eb4 [lldb] Support serial port parity checking
Differential Revision: https://reviews.llvm.org/D112365
2021-10-25 10:51:46 +02:00
Pavel Labath 6fa1b4ff4b Remove ConstString from DynamicLoader, JITLoader and Instruction plugin names 2021-10-25 10:32:35 +02:00
Pavel Labath c1055f0919 [lldb/DWARF] Don't create lldb_private::Functions for gc'ed DW_TAG_subprograms
Front-load the first_valid_code_address check, so that we avoid creating
the function object (instead of simply refusing to use it in queries).

Differential Revision: https://reviews.llvm.org/D112310
2021-10-25 10:32:35 +02:00
Kazu Hirata 4bd46501c3 Use llvm::any_of and llvm::none_of (NFC) 2021-10-24 17:35:33 -07:00
Kazu Hirata 7cc8fa2dd2 Use llvm::is_contained (NFC) 2021-10-24 09:32:57 -07:00
Kazu Hirata 4ba9d9c84f Use StringRef::contains (NFC) 2021-10-23 20:41:46 -07:00
Kazu Hirata d8e4170b0a Ensure newlines at the end of files (NFC) 2021-10-23 08:45:29 -07:00
Martin Storsjö ea9e9d61b5 [lldb] [Host/SerialPort] Fix build with GCC 7 2021-10-23 12:52:55 +03:00
Michał Górny ff56d80eaa [lldb] [Host/FreeBSD] Remove unused variable (NFC) 2021-10-23 11:38:35 +02:00
Med Ismail Bennani 42e4959253 [lldb/Formatters] Remove space from vector type string summaries (NFCI)
This patch changes the string summaries for vector types by removing the
space between the type and the bracket, conforming to 277623f4d5.

This should also fix TestCompactVectors failure.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-10-22 21:18:54 +02:00
Pavel Labath f37463b2ee [lldb] Another build fix for 8b8070e23
This particular usage was guarded by !__linux__, so it broke everywhere
else. It should probably be replaced by something else.
2021-10-22 15:29:38 +02:00
Michał Górny ff569ed030 [lldb] [Utility/UriParser] Replace port==-1 with llvm::None
Use llvm::Optional<uint16_t> instead of int for port number
in UriParser::Parse(), and use llvm::None to indicate missing port
instead of a magic value of -1.

Differential Revision: https://reviews.llvm.org/D112309
2021-10-22 14:39:18 +02:00
Pavel Labath 43f8845dd3 [lldb] Fix build errors from 8b8070e23
I missed windows and openbsd.
2021-10-22 14:28:52 +02:00
Pavel Labath 8b8070e234 Host::GetOSBuildString 2021-10-22 12:59:58 +02:00
Michał Górny 66e06cc8cb [llvm] [ADT] Update llvm::Split() per Pavel Labath's suggestions
Optimize the iterator comparison logic to compare Current.data()
pointers.  Use std::tie for assignments from std::pair.  Replace
the custom class with a function returning iterator_range.

Differential Revision: https://reviews.llvm.org/D110535
2021-10-22 12:27:46 +02:00
Pavel Labath b5e9f83ea4 [lldb] Remove ConstString from ABI, Architecture and Disassembler plugin names 2021-10-22 10:29:19 +02:00
Greg Clayton d7b338537c Modify "statistics dump" to dump JSON.
This patch is a smaller version of a previous patch https://reviews.llvm.org/D110804.

This patch modifies the output of "statistics dump" to be able to get stats from the current target. It adds 3 new stats as well. The output of "statistics dump" is now emitted as JSON so that it can be used to track performance and statistics and the output could be used to populate a database that tracks performance. Sample output looks like:

(lldb) statistics dump
{
  "expressionEvaluation": {
    "failures": 0,
    "successes": 0
  },
  "firstStopTime": 0.34164492800000001,
  "frameVariable": {
    "failures": 0,
    "successes": 0
  },
  "launchOrAttachTime": 0.31969605400000001,
  "targetCreateTime": 0.0040863039999999998
}

The top level keys are:

"expressionEvaluation" which replaces the previous stats that were emitted as plain text. This dictionary contains the success and fail counts.
"frameVariable" which replaces the previous stats for "frame variable" that were emitted as plain text. This dictionary contains the success and fail counts.
"targetCreateTime" contains the number of seconds it took to create the target and load dependent libraries (if they were enabled) and also will contain symbol preloading times if that setting is enabled.
"launchOrAttachTime" is the time it takes from when the launch/attach is initiated to when the first private stop occurs.
"firstStopTime" is the time in seconds that it takes to stop at the first stop that is presented to the user via the LLDB interface. This value will only have meaning if you set a known breakpoint or stop location in your code that you want to measure as a performance test.

This diff is also meant as a place to discuess what we want out of the "statistics dump" command before adding more funcionality. It is also meant to clean up the previous code that was storting statistics in a vector of numbers within the lldb_private::Target class.

Differential Revision: https://reviews.llvm.org/D111686
2021-10-21 12:14:21 -07:00
David Blaikie aee4925507 Recommit: Compress formatting of array type names (int [4] -> int[4])
Based on post-commit review discussion on
2bd8493847 with Richard Smith.

Other uses of forcing HasEmptyPlaceHolder to false seem OK to me -
they're all around pointer/reference types where the pointer/reference
token will appear at the rightmost side of the left side of the type
name, so they make nested types (eg: the "int" in "int *") behave as
though there is a non-empty placeholder (because the "*" is essentially
the placeholder as far as the "int" is concerned).

This was originally committed in 277623f4d5

Reverted in f9ad1d1c77 due to breakages
outside of clang - lldb seems to have some strange/strong dependence on
"char [N]" versus "char[N]" when printing strings (not due to that name
appearing in DWARF, but probably due to using clang to stringify type
names) that'll need to be addressed, plus a few other odds and ends in
other subprojects (clang-tools-extra, compiler-rt, etc).
2021-10-21 11:34:43 -07:00
Pavel Labath 6c88086ba8 [lldb] Fix a thinko in 2ace1e57
An empty plugin name means we should try everything.

Picked up by the windows bot.
2021-10-21 14:05:49 +02:00
Benjamin Kramer 39724158d3 [lldb] Silence -Wpessimizing-move warning
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3635:10: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
  return std::move(merged);
         ^
2021-10-21 12:59:00 +02:00
Pavel Labath 2ace1e5753 [lldb] Remove ConstString from GetPluginNameStatic of some plugins
This patch deals with ObjectFile, ObjectContainer and OperatingSystem
plugins. I'll convert the other types in separate patches.

In order to enable piecemeal conversion, I am leaving some ConstStrings
in the lowest PluginManager layers. I'll convert those as the last step.

Differential Revision: https://reviews.llvm.org/D112061
2021-10-21 12:58:45 +02:00
Jaroslav Sevcik 5a3556aa55 [lldb] Add omitted abstract formal parameters in DWARF symbol files
This patch fixes a problem introduced by clang change
https://reviews.llvm.org/D95617 and described by
https://bugs.llvm.org/show_bug.cgi?id=50076#c6, where inlined functions
omit unused parameters both in the stack trace and in `frame var`
command. With this patch, the parameters are listed correctly in the
stack trace and in `frame var` command.

Specifically, we parse formal parameters from the abstract version of
inlined functions and use those formal parameters if they are missing
from the concrete version.

Differential Revision: https://reviews.llvm.org/D110571
2021-10-21 12:33:42 +02:00
Michał Górny b8c3683d46 [lldb] [Host/SerialPort] Add std::moves for better compatibility 2021-10-21 11:08:05 +02:00
Michał Górny cbe7898447 [lldb] [Host/Terminal] Add missing #ifdef for baudRateToConst() 2021-10-21 11:00:17 +02:00
Michał Górny 4a7b4beac7 [lldb] Add serial:// protocol for connecting to serial port
Add a new serial:// protocol along with SerialPort that provides a new
API to open serial ports.  The URL consists of serial device path
followed by URL-style options, e.g.:

    serial:///dev/ttyS0?baud=115200&parity=even

If no options are provided, the serial port is only set to raw mode
and the other attributes remain unchanged.  Attributes provided via
options are modified to the specified values.  Upon closing the serial
port, its original attributes are restored.

Differential Revision: https://reviews.llvm.org/D111355
2021-10-21 10:46:45 +02:00
Michał Górny 92fb574c9f [lldb] [Host] Add setters for common teletype properties to Terminal
Add setters for common teletype properties to the Terminal class:

- SetRaw() to enable common raw mode options

- SetBaudRate() to set the baud rate

- SetStopBits() to select the number of stop bits

- SetParity() to control parity bit in the output

- SetHardwareControlFlow() to enable or disable hardware control flow
  (if supported)

Differential Revision: https://reviews.llvm.org/D111030
2021-10-21 10:33:38 +02:00
Raphael Isemann 46fb5d5ddf [lldb][NFC] clang-format CPlusPlusLanguage.cpp 2021-10-21 10:01:18 +02:00
Daniel Jalkut d531e5cf58 [LLDB] [NFC] Typo fix in usage text for "type filter" command
When you invoke "help type filter" the resulting help shows:

Syntax: type synthetic [<sub-command-options>]

This patch fixes the help so it says "type filter" instead of "type synthetic".

patch by: "Daniel Jalkut <jalkut@red-sweater.com>"

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D112199
2021-10-21 12:22:52 +05:30
Jonas Devlieghere 207998c242 [lldb] Remove variable "any" which is set but not used 2021-10-20 12:08:35 -07:00
Michał Górny f290efc326 [lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*
gdbserver does not expose combined ymm* registers but rather XSAVE-style
split xmm* and ymm*h portions.  Extend value_regs to support combining
multiple registers and use it to create user-friendly ymm* registers
that are combined from split xmm* and ymm*h portions.

Differential Revision: https://reviews.llvm.org/D108937
2021-10-20 15:06:45 +02:00
Michał Górny 99277a81f8 [lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM
Fix incorrect values for value_regs, and incomplete values for
invalidate_regs in RegisterInfos_arm.  The value_regs entry needs
to list only one base (i.e. larger) register that needs to be read
to get the value for this register, while invalidate_regs needs to list
all other registers (including pseudo-register) whose values would
change when this register is written to.

7a8ba4ffbe fixed a similar problem
for ARM64.

Differential Revision: https://reviews.llvm.org/D112066
2021-10-20 15:06:45 +02:00
Michał Górny 192331b890 [lldb] [Process/Linux] Support arbitrarily-sized FPR writes on ARM
Support arbitrarily-sized FPR writes on ARM in order to fix writing qN
registers directly.  Currently, writing them works only by accident
due to value_regs splitting them into smaller writes via dN and sN
registers.

Differential Revision: https://reviews.llvm.org/D112131
2021-10-20 15:06:44 +02:00
Michał Górny 6561c074c0 [lldb] [Process/Utility] Define qN regs on ARM via helper macro
Add a FPU_QREG macro to define qN registers.  This is a piece-wise
attempt of reconstructing D112066 with the goal of figuring out which
part of the larger change breaks the buildbot.

Differential Revision: https://reviews.llvm.org/D112066
2021-10-20 13:08:17 +02:00
Pavel Labath ffbff6c511 [lldb/DWARF] Ignore debug info pointing to the low addresses
specifically, ignore addresses that point before the first code section.

This resurrects D87172 with several notable changes:
- it fixes a bug where the early exits in InitializeObject left
  m_first_code_address "initialized" to LLDB_INVALID_ADDRESS (0xfff..f),
  which caused _everything_ to be ignored.
- it extends the line table fix to function parsing as well, where it
  replaces a similar check which was checking the executable permissions
  of the section. This was insufficient because some
  position-independent elf executables can have an executable segment
  mapped at file address zero. (What makes this fix different is that it
  checks for the executable-ness of the sections contained within that
  segment, and those will not be at address zero.)
- It uses a different test case, with an elf file with near-zero
  addresses, and checks for both line table and function parsing.

Differential Revision: https://reviews.llvm.org/D112058
2021-10-20 11:19:30 +02:00
Lawrence D'Anna 8ac5a6641f [lldb] improve the help strings for gdb-remote and kdp-remote
The help string can be more helpful by explaining these are
aliases for 'process connect'

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D111965
2021-10-19 13:08:21 -07:00
Jim Ingham a66798cd67 Remove unneeded variable num_found. 2021-10-19 09:57:07 -07:00
Michał Górny b492b0be95 [lldb] [Process/Utility] Define dN regs on ARM via helper macro
Use FPU_REG macro to define dN registers, removing the wrong value_regs
while at it.  This is a piece-wise attempt of reconstructing D112066
with the goal of figuring out which part of the larger change breaks
the buildbot.

Differential Revision: https://reviews.llvm.org/D112066
2021-10-19 17:06:03 +02:00
Michał Górny 28e0c34216 [lldb] [Process/Utility] Define sN regs on ARM via helper macro
This is a piece-wise attempt of reconstructing D112066 with the goal
of figuring out which part of the larger change breaks the buildbot.

Differential Revision: https://reviews.llvm.org/D112066
2021-10-19 15:51:47 +02:00
Michał Górny 5cd28f71b1 [lldb] [Process/Utility] clang-format RegisterInfos_arm.h 2021-10-19 15:51:47 +02:00
Michał Górny 7df912c65d Revert "[lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM"
This reverts commit 1c2c67b46b.
Something's still wrong.
2021-10-19 15:33:39 +02:00
Michał Górny 1c2c67b46b [lldb] [Process/Utility] Fix value_regs/invalidate_regs for ARM
Fix incorrect values for value_regs, and incomplete values for
invalidate_regs in RegisterInfos_arm.  The value_regs entry needs
to list only one base (i.e. larger) register that needs to be read
to get the value for this register, while invalidate_regs needs to list
all other registers (including pseudo-register) whose values would
change when this register is written to.

While at it, introduce helper macros for the definitions.

7a8ba4ffbe fixed a similar problem
for ARM64.

Differential Revision: https://reviews.llvm.org/D112066
2021-10-19 14:47:46 +02:00
Michał Górny c6d7f248bd [lldb] [ABI/X86] Refactor ABIX86::AugmentRegisterInfo()
Refactor ABIX86::AugmentRegisterInfo() and helper functions for better
readability.  This also fixes listing eax & co. as potential subregs
on 32-bit systems.

Differential Revision: https://reviews.llvm.org/D108937
2021-10-19 13:36:38 +02:00
Michał Górny 39f2b05963 [lldb] [Host] Make Terminal methods return llvm::Error
Differential Revision: https://reviews.llvm.org/D111890
2021-10-19 13:31:03 +02:00
Michał Górny ee11612ee1 Revert "[lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*"
This reverts commit 5352ea4a72.  It seems
to have broken the arm buildbot.
2021-10-19 12:31:25 +02:00
Raphael Isemann 9a57d1e526 [lldb] Allow dumping the state of all scratch TypeSystems
This adds the `target dump typesystem'`command which dumps the TypeSystem of the
target itself (aka the 'scratch TypeSystem'). This is similar to `target modules
dump ast` which dumps the AST of lldb::Modules associated with a selected
target.

Unlike `target modules dump ast`, the new command is not a subcommand of `target
modules dump` as it's not touching the modules of a target at all. Also unlike
`target modules dump ast` I tried to keep the implementation language-neutral,
so this patch moves our Clang `Dump` to the `TypeSystem` interface so it will
also dump the state of any future/downstream scratch TypeSystems (e.g., Swift).
That's also why the command just refers to a 'typesystem' instead of an 'ast'
(which is only how Clang is necessarily modelling the internal TypeSystem
state).

The main motivation for this patch is that I need to write some tests that check
for duplicates in the ScratchTypeSystemClang of a target. There is currently no
way to check for this at the moment (beside measuring memory consumption of
course). It's probably also useful for debugging LLDB itself.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D111936
2021-10-19 12:05:14 +02:00
Lasse Folger 134e1817f6 [lldb] change name demangling to be consistent between windows and linx
When printing names in lldb on windows these names contain the full type information while on linux only the name is contained.

This change introduces a flag in the Microsoft demangler to control if the type information should be included.
With the flag enabled demangled name contains only the qualified name, e.g:
without flag -> with flag
int (*array2d)[10] -> array2d
int (*abc::array2d)[10] -> abc::array2d
const int *x -> x

For globals there is a second inconsistency which is not yet addressed by this change. On linux globals (in global namespace) are prefixed with :: while on windows they are not.

Reviewed By: teemperor, rnk

Differential Revision: https://reviews.llvm.org/D111715
2021-10-19 12:04:37 +02:00
Raphael Isemann cfaa5c344d [lldb] Filter duplicates in Target::GetScratchTypeSystems
`Target::GetScratchTypeSystems` returns the list of scratch TypeSystems. The
current implementation is iterating over all LanguageType values and retrieves
the respective TypeSystem for each LanguageType.

All C/C++/Obj-C LanguageTypes are however mapped to the same
ScratchTypeSystemClang instance, so the current implementation adds this single
TypeSystem instance several times to the list of TypeSystems (once for every
LanguageType that we support).

The only observable effect of this is that `SBTarget.FindTypes` for builtin
types currently queries the ScratchTypeSystemClang several times (and also adds
the same result several times).

Reviewed By: bulbazord, labath

Differential Revision: https://reviews.llvm.org/D111931
2021-10-19 11:49:47 +02:00
Michał Górny 5352ea4a72 [lldb] [ABI/X86] Support combining xmm* and ymm*h regs into ymm*
gdbserver does not expose combined ymm* registers but rather XSAVE-style
split xmm* and ymm*h portions.  Extend value_regs to support combining
multiple registers and use it to create user-friendly ymm* registers
that are combined from split xmm* and ymm*h portions.

Differential Revision: https://reviews.llvm.org/D108937
2021-10-19 10:31:07 +02:00
Jonas Devlieghere 957a5e9874 [lldb] Fix nullptr dereference in AppleObjCRuntimeV2
Fix a potential nullptr dereference in AppleObjCRuntimeV2 by checking
the result of GetClassInfoUtilityFunction and returning a failure if
it's null.

The DynamicClassInfoExtractor was already doign the right thing, but the
SharedCacheClassInfoExtractor was missing this check.
2021-10-18 23:30:31 -07:00
Jim Ingham c5011aed9c Add a "command container" hierarchy to allow users to add container nodes.
The point is to allow users with a related set of script based commands
to organize their commands in a hierarchy in the command set, rather than
having to have only top-level commands.

Differential Revision: https://reviews.llvm.org/D110298
2021-10-18 15:29:24 -07:00
Kazu Hirata 8568ca789e Use llvm::erase_if (NFC) 2021-10-18 09:33:42 -07:00
Lasse Folger ee691fbc3d [lldb][NFC] clang format change
clang format on some demangling files

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D111934
2021-10-18 12:00:32 +02:00
Michał Górny 239b4d62b6 [lldb] [Utility] Remove Status::WasInterrupted() along with its only use
Remove Status::WasInterrupted() that checks whether the underlying error
code matches EINTR.  ProcessGDBRemote::ConnectToDebugserver() is its
only call site, and it does not seem correct there.  After all, EINTR
is precisely when we want to retry, not stop retrying.  Furthermore,
it should not really matter since we should be catching EINTR
immediately via llvm::sys::RetryAfterSignal() but that's another story.

Differential Revision: https://reviews.llvm.org/D111908
2021-10-18 10:50:25 +02:00
Pavel Labath a3939e159f [lldb] Return StringRef from PluginInterface::GetPluginName
There is no reason why this function should be returning a ConstString.

While modifying these files, I also fixed several instances where
GetPluginName and GetPluginNameStatic were returning different strings.

I am not changing the return type of GetPluginNameStatic in this patch, as that
would necessitate additional changes, and this patch is big enough as it is.

Differential Revision: https://reviews.llvm.org/D111877
2021-10-18 10:14:42 +02:00
Raphael Isemann 60b96aa65e [lldb] Split ParseSingleMember into Obj-C property and normal member/ivar parsing code.
Right now DWARFASTParserClang::ParseSingleMember has two parts: One part parses
Objective-C properties and the other part parses C/C++ members/Objective-C
ivars. These parts are pretty much independent of each other (with one
historical exception, see below) and in practice they parse DIEs with different
tags/attributes: `DW_TAG_APPLE_property` and `DW_TAG_member`.

I don't see a good reason for keeping the different parsing code intertwined in
a single function, so instead split out the Objective-C property parser into its
own function.

Note that 90% of this commit is just unindenting nearly all of
`ParseSingleMember` which was inside a `if (tag == DW_TAG_member)` block. I.e.,
think of the old `ParseSingleMember` function as: The rest is just moving the
property parsing code into its own function and I added the ReportError
implementation in case we fail to resolve the property type (which before was
just a silent failure).

```
lang=c++
void DWARFASTParserClang::ParseSingleMember(...) {
  [...]
  if (tag == DW_TAG_member) {
    [...] // This huge block got unindented in this patch as the `if` above is gone.
  }
  if (property) {
    [...] // This is the property parsing code that is now its own function.
  }
}
```

There is one exception to the rule that the parsers are independent. Before 2012
Objective-C properties were encoded as `DW_TAG_member` with
`DW_AT_APPLE_property*` attributes describing the property. In 2012 this has
changed in a series of commits (see for example
c0449635b3 which updates the docs) so that
`DW_TAG_APPLE_property` is now used for properties. With the old format we first
created an ivar and afterwards used the `DW_AT_APPLE_property*` attributes to
create the respective property, but there doesn't seem to be any way to create
such debug info with any clang from the last 9 years. So this is technically not
NFC in case some finds debug info from that time and tries to use properties.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D111632
2021-10-16 14:20:04 +02:00
Michał Górny f70f9620d9 [lldb] [ABI/AArch64] Do not add subregs if some of them are present
Fix a bug introduced while refactoring ABIAArch64::AugmentRegisterInfo()
that caused subregisters to be added even if they were already present.
Instead, abort immediately if at least one subregister is found
(following ABIX86).  While at it, add a test for that.

Differential Revision: https://reviews.llvm.org/D111881
2021-10-15 14:08:37 +02:00
Michał Górny 2712d18148 [lldb] [ABI/X86] Add pseudo-registers if missing
Differential Revision: https://reviews.llvm.org/D108831
2021-10-15 12:55:03 +02:00
Michał Górny 0d1705a9d6 [lldb] [DynamicRegisterInfo] Support value_regs with offset
Support specifying an offset for value_regs[0], and add the offset
to the computed derived register offset.  This makes it possible to
e.g. create the "ah" register on x86.

Differential Revision: https://reviews.llvm.org/D111489
2021-10-15 12:55:02 +02:00
Jason Molenda 35d710148b Use Module's FileSpec for limiting binaries to set dyld breakpoint in
When DynamicLoaderMacOS::SetNotificationBreakpoint sets the breakpoint
for new binaries being loaded/unloaded, it limits the scope of that
breakpoint to just dyld, so we don't re-evaluate the breakpoint for
every new binary loaded.  I wrote this to get the module's ObjectFile
FileSpec in an earlier change, but this is not correct.  If lldb
is debugging a remote system, and it had to read dyld out of memory
from the remote system, it will have no FileSpec on the lldb debugger
host.  We need to grab the Module's FileSpec, which in this case is
actually falling back to the PlatformFileSpec, the binary path on the
target system.

rdar://84199646
2021-10-14 23:58:23 -07:00
Raphael Isemann 482c53fa0d [lldb] Move ~Platform to source file
The called destructors of the members require the includes that are only
in the source file.
2021-10-14 21:36:46 +02:00
Raphael Isemann e632e900ac [lldb] Remove logging from Platform::~Platform
Platform instances are stored in a function-local static list. However, the
logging code involves locking a function-local static mutex. This only works on
some implementations where the Log mutex is by accident destroyed *after* the
Platform list is destroyed.

This fixes randomly failing tests due to `recursive_mutex lock failed: Invalid
argument`.

Reviewed By: kastiglione

Differential Revision: https://reviews.llvm.org/D111816
2021-10-14 20:42:45 +02:00
Dave Lee 722a2fb7f9 [lldb] Fix 'frame diagnose' docstring typo 2021-10-14 08:32:20 -07:00
Martin Storsjö 7106f58856 [lldb] Make the thread_local g_global_boundary accessed from a single file
This makes the compiler generated code for accessing the thread local
variable much simpler (no need for wrapper functions and weak pointers
to potential init functions), and can avoid toolchain bugs regarding how
to access TLS variables.

In particular, this fixes LLDB when built with current GCC/binutils for
MinGW, see https://github.com/msys2/MINGW-packages/issues/8868.

Differential Revision: https://reviews.llvm.org/D111779
2021-10-14 11:17:20 +03:00
Pavel Labath ca0ce99fc8 [lldb] Print embedded nuls in char arrays (PR44649)
When we know the bounds of the array, print any embedded nuls instead of
treating them as terminators. An exception to this rule is made for the
nul character at the very end of the string. We don't print that, as
otherwise 99% of the strings would end in \0. This way the strings
usually come out the same as how the user typed it into the compiler
(char foo[] = "with\0nuls"). It also matches how they come out in gdb.

This resolves a FIXME left from D111399, and leaves another FIXME for dealing
with nul characters in "escape-non-printables=false" mode. In this mode the
characters cause the entire summary string to be terminated prematurely.

Differential Revision: https://reviews.llvm.org/D111634
2021-10-14 09:50:40 +02:00
Raphael Isemann 0648b3c026 [lldb][NFC] for-range loop when iterating over delayed_properties 2021-10-13 15:27:23 +02:00
Raphael Isemann 7103753733 [lldb][NFC] Split out DW_TAG_inheritance parsing into own function
Just moving that block inside DWARFASTParserClang::ParseChildMembers into
its own function. Also early-exiting instead of a large if when
num_attributes is 0.
2021-10-13 13:14:57 +02:00