Commit Graph

25914 Commits

Author SHA1 Message Date
Pavel Labath a007a6d844 [lldb] Convert "LLDB" log channel to the new API 2022-02-02 14:13:08 +01:00
Pavel Labath b1127753b9 [lldb] Convert ProcessGDBRemoteLog to the new API 2022-02-01 14:36:29 +01:00
Jonas Devlieghere d329dfd0c8 [lldb] Use the build's python interpreter in the shell tests
Make sure that the shell tests use the same python interpreter as the
rest of the build instead of picking up `python` from the PATH.

It would be nice if we could use the _disallow helper, but that triggers
on invocations that specify python as the scripting language.
2022-01-31 16:53:42 -08:00
Jonas Devlieghere e1cad1303b [lldb] Support Rosetta registers in crashlog.py
Rosetta crashlogs can have their own thread register state. Unlike the
other registers which ware directly listed under "threadState", the
Rosetta registers are nested under their own key in the JSON, as
illustrated below:

  {
      "threadState":
      {
          "rosetta":
          {
              "tmp2":
              {
                  "value": 4935057216
              },
              "tmp1":
              {
                  "value": 4365863188
              },
              "tmp0":
              {
                  "value": 18446744073709551615
              }
          }
      }
  }
2022-01-31 10:50:16 -08:00
Pavel Labath c8fbf8037d [lldb] Convert Process KDP Log to the new API 2022-01-31 08:59:41 +01:00
Kazu Hirata 5423839929 [lldb] Forward-declare ClangExpressionParser (NFC)
ClangUserExpression.h is relying on the forward declaration of
ClangExpressionParser in ClangFunctionCaller.h.  This patch moves the
forward declaration to ClangUserExpression.h.
2022-01-30 12:32:53 -08:00
Simon Pilgrim b81b3ac668 [lldb] TypeSystemClang - use castAs/cast<> instead of getAs/dyn_cast<> to avoid dereference of nullptr
The pointers are dereferenced immediately, so assert the cast is correct instead of returning nullptr
2022-01-29 15:34:26 +00:00
Simon Pilgrim 058c5dfc78 Raise the minimum Visual Studio version to VS2019
As raised here: https://lists.llvm.org/pipermail/llvm-dev/2021-November/153881.html

Now that VS2022 is on general release, LLVM is expected to build on VS2017, VS2019 and VS2022, which is proving hazardous to maintain due to changes in behaviour including preprocessor and constexpr changes. Plus of the few developers that work with VS, many have already moved to VS2019/22.

This patch proposes to raise the minimum supported version to VS2019 (16.x) - I've made the hard limit 16.0 or later, with the soft limit VS2019 16.7 - older versions of VS2019 are "allowed" (at your own risk) via the LLVM_FORCE_USE_OLD_TOOLCHAIN cmake flag.

Differential Revision: https://reviews.llvm.org/D114639
2022-01-29 10:56:41 +00:00
Stella Stamenova 738d73fbf4 [lldb] Update the lldb build instructions on Windows
The existing instructions for lldb on Windows can be more explicit. This adds a few details on how to install various components and the easiest way to get to a working build.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D118425
2022-01-28 10:18:19 -08:00
Michał Górny ac666d1799 [lldb] [gdb-remote] Support getting siginfo via API
Add Thread::GetSiginfo() and SBThread::GetSiginfo() methods to retrieve
the siginfo value from server.

Differential Revision: https://reviews.llvm.org/D118055
2022-01-28 17:47:47 +01:00
Augusto Noronha b414954a5f [lldb] Make ReadCStringFromMemory default to read from the file-cache.
Differential Revision: https://reviews.llvm.org/D118265
2022-01-28 13:08:30 -03:00
Pavel Labath 2d75f62722 [lldb] Convert DWARF log to the new API
This also deletes some dead log statements (log initialization commented
out).
2022-01-28 10:41:10 +01:00
Michał Górny 59a3f65f5e Revert "[lldb] [gdb-remote] Support getting siginfo via API"
This reverts commit 1a8f60f5f5.
The API requires further work.
2022-01-28 10:15:52 +01:00
David Spickett d1c124e6e7 [lldb][ARM/AArch64] Update dissembler to v9.3-a
This means sve2 is enabled by default and the v8.8 mops (memcpy
and memset acceleration instructions) and HBC (hinted conditional
branch) extensions can be disassembled.

v9.3-a is equivalent to v8.8-a except that in v9.0-a sve2 was
enabled by default so v9.3-a includes that too.

MTE remains an optional extension, only enabled for specific CPUs.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D118358
2022-01-28 09:10:04 +00:00
Jonas Devlieghere 4a64955c37 [lldb] Remove reproducers documentation 2022-01-27 19:35:28 -08:00
Shubham Sandeep Rastogi cf93a08575 Fixed typos in TestLldbGdbServer.py
Fixed more typos
2022-01-27 14:12:24 -08:00
Shubham Sandeep Rastogi 867fdec194 Disable TestLldbGdbServer on Dwarf2 and clang versions below 14
We have been noticing issues with the lldb bots on builds using versions below clang 14 and dwarf 2, so to make sure we can get clean builds for a while, we are disabling the tests for those versions

Differential Revision: https://reviews.llvm.org/D118395
2022-01-27 14:02:35 -08:00
Shubham Sandeep Rastogi ee54868a76 Revert "Disable TestLldbGdbServer on Dwarf2 and clang versions below 14"
This reverts commit cd31763770.
2022-01-27 13:36:21 -08:00
Shubham Sandeep Rastogi cd31763770 Disable TestLldbGdbServer on Dwarf2 and clang versions below 14
We have been noticing issues with the lldb bots on builds using versions below clang 14 and dwarf 2, so to make sure we can get clean builds for a while, we are disabling the tests for those versions

Differential Revision: https://reviews.llvm.org/D118395
2022-01-27 13:29:34 -08:00
Med Ismail Bennani 48c36a15a3 [lldb/test] Disable test_launch_scripted_process_stack_frames on x86_64
There seems to be an issue on x86_64 when launching a ScriptdProcess.
This disables temporarely the test that causes the bot to timeout until
I finish investigating the issue.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-01-27 18:42:08 +01:00
Pavel Labath 33eb3f14eb [lldb] Delete TestBacktraceAll.py
This test is completely nondeterministic, environment-dependent and does
not test what it was supposed to test (reverting the associated patch
does not make it fail).

I tried to figure out what the patch was meant to fix to see if I can
create a better test with the current tools, but I was not able to
understand the problem (it sounds like it has something to do with local
classes, but I don't understand the details).
2022-01-27 15:01:08 +01:00
Michał Górny 1a8f60f5f5 [lldb] [gdb-remote] Support getting siginfo via API
Add Thread::GetSiginfo() and SBThread::GetSiginfo() methods to retrieve
the siginfo value from server.

Differential Revision: https://reviews.llvm.org/D118055
2022-01-27 13:33:47 +01:00
Michał Górny 3053e143be [lldb] [Platform] Support synthesizing siginfo_t
Support synthesizing the siginfo_t type from the Platform plugin.
This type is going to be used by LLDB client to process the raw siginfo
data received from lldb-server without the necessity of relying
on target's debug info being present.

Differential Revision: https://reviews.llvm.org/D117707
2022-01-27 13:33:47 +01:00
Pavel Labath 4cd8877a34 [lldb/test] Fix gnu-style-compression.yaml
In the rush to get the bot green, I did not realize I was building the
file with -gsplit-dwarf, and therefore the yaml ended up referring to a
file I did not check it.

This rebuilds the file without split dwarf.
2022-01-27 10:23:21 +01:00
Pavel Labath 6730df4779 [lldb] Convert ProcessWindowsLog to the new API 2022-01-27 10:05:05 +01:00
Pavel Labath 7afd052112 [lldb/DWARF] Make manual dwarf index deterministic
Currently, running the test suite with LLVM_ENABLE_EXPENSIVE_CHECKS=On
causes a couple of tests to fail. This happens because they expect a
certain order of variables (all of them happen to use the "target
variable" command, but other lookup functions should suffer from the
same issues), all of which have the same name. Sort algorithms often
preserve the order of equivalent elements (in this case the entries in
the NameToDIE map), but that not guaranteed, and
LLVM_ENABLE_EXPENSIVE_CHECKS stresses that by pre-shuffling all inputs
before sorting.

While this could easily be fixed by relaxing the test expectations,
having a deterministic output seems like a worthwhile goal,
particularly, as this could have bigger consequences than just a
different print order -- in some cases we just pick the first entry that
we find, whatever that is. Therefore this patch makes the sort
deterministic by introducing another sort key -- UniqueCString::Sort
gets a value comparator functor, which can be used to sort elements with
the same name -- in the DWARF case we use DIERef::operator<, which
roughly equals the order in which the entries appear in the debug info,
and matches the current "accidental" order.

Using a extra functor seemed preferable to using stable_sort, as the
latter allocates extra O(n) of temporary memory.

I observed no difference in debug info parsing speed with this patch
applied.

Differential Revision: https://reviews.llvm.org/D118251
2022-01-27 10:05:05 +01:00
Pavel Labath aaa9f40e3f [lldb/test] Replace gnu-style-compression.cpp with a yaml file
In D117744, llvm removed writing support for this format, breaking the
test. We may eventually want to remove reading support as well, but for
now I have converted the test to a yaml file to maintain coverage.
2022-01-27 10:05:05 +01:00
Med Ismail Bennani aae3c4f2b4
[lldb/test] Skip TestSBModule unless darwin
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-01-27 01:05:12 +01:00
Med Ismail Bennani a6b5624372 Revert "[lldb/test] Try to fix TestSBModule failure"
This reverts commit 326516448c.
2022-01-27 01:04:38 +01:00
Med Ismail Bennani 326516448c [lldb/test] Try to fix TestSBModule failure
This should fix https://lab.llvm.org/buildbot/#/builders/68/builds/25571

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-01-27 01:00:29 +01:00
Med Ismail Bennani ff52ef334b
[lldb/API] Add ability to check if module is backed by a file on disk
This patch introduces a new SBAPI method: `SBModule::IsFileBacked`

As the name suggests, it tells the user if the module's object file is
on disk or in memory.

rdar://68538278

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-01-26 20:40:24 +01:00
Jonas Devlieghere cbd0822f27 [lldb] Remove ConstString::StaticMemorySize
Remove ConstString::StaticMemorySize as it is unused and superseded by
GetMemoryStats. It is referenced in a bunch of doc comments but I don't
really understand why. My best guess it that the comments were
copy-pasted from ConstString::MemorySize() even though it didn't make
sense there either. The implementation of StaticMemorySize was being
called on the MemoryPool, not on the ConstString itself.

Differential revision: https://reviews.llvm.org/D118091
2022-01-26 09:13:46 -08:00
Pavel Labath dcd0926ad0 [lldb] Fix a couple of use-of-uninit-var errors in Materializer.cpp
These were probably not picked up before because they only run when
logging is enabled.
2022-01-26 17:01:53 +01:00
Benjamin Kramer f15014ff54 Revert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17"
This reverts commit ef82063207.

- It conflicts with the existing llvm::size in STLExtras, which will now
  never be called.
- Calling it without llvm:: breaks C++17 compat
2022-01-26 16:55:53 +01:00
serge-sans-paille ef82063207 Rename llvm::array_lengthof into llvm::size to match std::size from C++17
As a conquence move llvm::array_lengthof from STLExtras.h to
STLForwardCompat.h (which is included by STLExtras.h so no build
breakage expected).
2022-01-26 16:17:45 +01:00
David Spickett 070090d08e [lldb] Add option to show memory tags in memory read output
This adds an option --show-tags to "memory read".

(lldb) memory read mte_buf mte_buf+32 -f "x" -s8 --show-tags
0x900fffff7ff8000: 0x0000000000000000 0x0000000000000000 (tag: 0x0)
0x900fffff7ff8010: 0x0000000000000000 0x0000000000000000 (tag: 0x1)

Tags are printed on the end of each line, if that
line has any tags associated with it. Meaning that
untagged memory output is unchanged.

Tags are printed based on the granule(s) of memory that
a line covers. So you may have lines with 1 tag, with many
tags, no tags or partially tagged lines.

In the case of partially tagged lines, untagged granules
will show "<no tag>" so that the ordering is obvious.
For example, a line that covers 2 granules where the first
is not tagged:

(lldb) memory read mte_buf-16 mte_buf+16 -l32 -f"x" --show-tags
0x900fffff7ff7ff0: 0x00000000 <...> (tags: <no tag> 0x0)

Untagged lines will just not have the "(tags: ..." at all.
Though they may be part of a larger output that does have
some tagged lines.

To do this I've extended DumpDataExtractor to also print
memory tags where it has a valid execution context and
is asked to print them.

There are no special alignment requirements, simply
use "memory read" as usual. All alignment is handled
in DumpDataExtractor.

We use MakeTaggedRanges to find all the tagged memory
in the current dump, then read all that into a MemoryTagMap.

The tag map is populated once in DumpDataExtractor and re-used
for each subsequently printed line (or recursive call of
DumpDataExtractor, which some formats do).

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D107140
2022-01-26 14:40:39 +00:00
David Spickett 8d714e4ad5 [lldb] Correct \params to \param in StackFrame Doxygen comments 2022-01-26 14:05:58 +00:00
David Spickett 5d2f90cbcd [lldb] Correct some uses of \b in Doxygen documentation 2022-01-26 14:05:58 +00:00
David Spickett 37c4bd0fdb [lldb] Add MemoryTagMap class
The tag map holds a sparse set of memory tags and allows
you to query ranges for tags.

Granules that do not have tags will be set to llvm::None.
to keep the ordering intact. If there are no tags for the
requested range we'll just return an empty result so that
callers don't need to check that all values are llvm::None.

This will be combined with MemoryTagManager's MakeTaggedRanges:
* MakeTaggedRanges
* Read from all those ranges
* Insert the results into the tag map
* Give the tag map to whatever needs to print tags

Which in this case will be "memory read"/DumpDataExtractor.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D112825
2022-01-26 13:55:48 +00:00
Pavel Labath 4fa1ad0521 [lldb] Convert POSIXLog to use the new API 2022-01-26 13:10:10 +01:00
David Spickett ee0c3820f8 [lldb][AArch64] Add MakeTaggedRanges to MemoryTagManager
This is to be used when you want to know what subranges
of a larger range have memory tagging. Like MakeTaggedRange
but memory without tags is skipped and you get a list of ranges back.

Will be used later by DumpDataExtractor to show memory tags.

MakeTaggedRanges assumes that the memory regions it is
given are sorted in ascending order and do not overlap.
For the current use case where you get regions from
GetMemoryRegions and are on some Linux like OS, this is
reasonable to assume.

I've used asserts to check those conditions. In future
any API binding will check them up front to prevent a crash.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D112824
2022-01-26 11:30:10 +00:00
Pavel Labath 2a1b7aa016 [lldb] Fix ProcessKDPLog for the logging refactor 2022-01-25 20:51:19 +01:00
Jonas Devlieghere c2cd7cc63c [lldb] Only include mach headers on Darwin 2022-01-25 09:58:47 -08:00
Jonas Devlieghere d7e183b225 [lldb] Use new dyld SPIs to query the shared cache local symbols
rdar://85492172
2022-01-25 09:36:48 -08:00
Pavel Labath 6b67e89b45 [lldb] Fix windows build for D117490
I forgot to update ProcessWindowsLog to the new API.
2022-01-25 13:51:53 +01:00
Pavel Labath 345d85e124 [lldb] Fix mac build for D117490
This is exactly that kind of a API misuse that the patch was meant to
detect.
2022-01-25 13:42:24 +01:00
Pavel Labath ce6903595b [lldb/test] Use abspath when searching for lldb.exe
realpath is too aggressive and does not produce the desired effect if
ones build folder is a symlink farm.
2022-01-25 12:13:49 +01:00
Pavel Labath 0f08db66db [lldb] Make logging machinery type-safe
This patch makes use of c++ type checking and scoped enums to make
logging statements shorter and harder to misuse.

Defines like LIBLLDB_LOG_PROCESS are replaces with LLDBLog::Process.
Because it now carries type information we do not need to worry about
matching a specific enum value with the right getter function -- the
compiler will now do that for us.

The main entry point for the logging machinery becomes the GetLog
(template) function, which will obtain the correct Log object based on
the enum type. It achieves this through another template function
(LogChannelFor<T>), which must be specialized for each type, and should
return the appropriate channel object.

This patch also removes the ability to log a message if multiple
categories are enabled simultaneously as it was unused and confusing.

This patch does not actually remove any of the existing interfaces. The
defines and log retrieval functions are left around as wrappers around
the new interfaces. They will be removed in follow-up patch.

Differential Revision: https://reviews.llvm.org/D117490
2022-01-25 12:13:49 +01:00
Jonas Devlieghere 16bff06790 [lldb] Make PythonDataObjects work with Python 2
I considered keeping this change strictly downstream. Since we still
have a bunch of places that check for Python 2, I figured it doesn't
harm to land it upstream and avoid the conflict when I eventually do
remove them (hopefully soon!).
2022-01-24 17:23:09 -08:00
Jonas Devlieghere cd8122b27f [lldb] Add ConstString memory usage statistics
Add statistics about the memory usage of the string pool. I'm
particularly interested in the memory used by the allocator, i.e. the
number of bytes actually used by the allocator it self as well as the
number of bytes allocated through the allocator.

Differential revision: https://reviews.llvm.org/D117914
2022-01-24 15:13:17 -08:00