Commit Graph

1561 Commits

Author SHA1 Message Date
Felipe de Azevedo Piovezan
4684507455
[lldb][DWARFUnit] Implement PeekDIEName query (#78486)
This allows us to query the AT_Name of a DIE without parsing the entire
CU.

Part of the ongoing effort to support IDX_Parent in accelerator tables
[1].

[1]:
https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/44
2024-01-19 16:11:08 -08:00
Alexandre Ganea
cfc9f3695f Revert "[lldb] Silence narrowing conversion warning with MSVC"
This reverts commit cb67dc1925.
2024-01-18 14:13:07 -05:00
Alexandre Ganea
cb67dc1925 [lldb] Silence narrowing conversion warning with MSVC
Fixes:
```
[13/270] Building CXX object tools\lldb\unittests\Core\CMakeFiles\LLDBCoreTests.dir\DumpDataExtractorTest.cpp.obj
C:\git\llvm-project\lldb\unittests\Core\DumpDataExtractorTest.cpp(140): warning C4305: 'argument': truncation from 'double' to 'const std::complex<float>::_Ty'
```
2024-01-18 13:06:12 -05:00
Alexandre Ganea
d950157f7b [lldb] Silence warning when building with latest MSVC
Fixes:
```
C:\git\llvm-project\lldb\unittests\Core\DumpDataExtractorTest.cpp(140): warning C4305: 'argument': truncation from 'double' to 'const std::complex<float>::_Ty'
```
2024-01-18 13:06:12 -05:00
Jonas Devlieghere
3b6a8f823b
[lldb] Upstream xros support in lldb (#78389)
Upstream support for debugging xros applications through LLDB.
2024-01-17 09:47:08 -08:00
Jonas Devlieghere
e27561fc7d
[lldb] Move MD5 Checksum from FileSpec to SupportFile
When I added the MD5 checksum I was on the fence between storing it in
FileSpec or creating a new SupportFile abstraction. The latter was
deemed overkill for just the MD5 hashes, but support for inline sources
in the DWARF 5 line table tipped the scales. This patch moves the MD5
checksum into the new SupportFile class.
2024-01-12 13:08:24 -08:00
Adrian Prantl
917b404e2c
Add support for inline DWARF source files. (#75880)
LLVM supports DWARF 5 linetable extension to store source files inline
in DWARF. This is particularly useful for compiler-generated source
code. This implementation tries to materialize them as temporary files
lazily, so SBAPI clients don't need to be aware of them.

rdar://110926168
2024-01-04 09:04:05 -08:00
gmh
f3f4387e02
[lldb][NFC] Fix compilation issue on windows (#76453) 2024-01-04 08:39:50 +00:00
David Spickett
f54249e79a [lldb][test] Link to PlatformWindows in thread tests
Clearly I need my eyes checked, it wasn't linking to a non-existent
library at all, I had the name wrong.
2023-12-21 14:07:27 +00:00
David Spickett
55985db5fe [lldb][test] Remove non-existent Windows lib from thread tests
I assumed since it was in the PR and seemed like a logical
library to have, it would exist, but only `...Common` exists.
2023-12-21 14:05:08 +00:00
David Spickett
dddb9d1ee3 [lldb][test] Fix missing-braces warnings in unit tests
```
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/unittests/Utility/ChecksumTest.cpp:15:38: warning: suggest braces around initialization of subobject [-Wmissing-braces]
static llvm::MD5::MD5Result hash1 = {0, 1, 2,  3,  4,  5,  6,  7,
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                     {
```
And others.
2023-12-21 13:36:04 +00:00
David Spickett
513c2151cd [lldb][test] Only link Windows libraries on Windows
ld.lld: error: unable to find library -llldbPluginProcessWindowsCommon

https://lab.llvm.org/buildbot/#/builders/96/builds/50407

Fixes 95e5839e06.
2023-12-21 13:11:34 +00:00
oltolm
95e5839e06
[lldb] add support for thread names on Windows (#74731)
This PR adds support for thread names in lldb on Windows.

```
(lldb) thr list
Process 2960 stopped
  thread #53: tid = 0x03a0, 0x00007ff84582db34 ntdll.dll`NtWaitForMultipleObjects + 20
  thread #29: tid = 0x04ec, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPUW.6'
  thread #89: tid = 0x057c, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x1000019] physics[main]'
  thread #3: tid = 0x0648, 0x00007ff843c2cafe combase.dll`InternalDoATClassCreate + 39518
  thread #93: tid = 0x0688, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x100501d] uMovie::StreamingThread'
  thread #1: tid = 0x087c, 0x00007ff842e7a104 win32u.dll`NtUserMsgWaitForMultipleObjectsEx + 20
  thread #96: tid = 0x0890, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x1002020] HLE Video Decoder'
<...>
```
2023-12-21 12:42:22 +00:00
David Spickett
87bf1afbbf
[lldb][PDB] Update max matches test for type queries (#75813)
NestedClass will be found via Class::NestedClass and
ClassTypedef::NestedClass. So the first part of the test gets 2 results
as the default is to find all matching types.

In the next part, we ask for only the first match and expect to get only
1 of those two possible results.
2023-12-19 08:54:03 +00:00
Kazu Hirata
ee667db4b8 [lldb] Use StringRef::{starts,ends}_with (NFC)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-16 15:02:15 -08:00
Kazu Hirata
744f38913f [lldb] Use StringRef::{starts,ends}_with (NFC)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-16 14:39:37 -08:00
Greg Clayton
8959cef135
[lldb] Trying to fix windows buildbots after #74786 (#75566)
This patch fixes the SymbolFilePDBTests::TestMaxMatches(...) by making
it test what it was testing before, see comments in the test case for
details.

It also disables TestUniqueTypes4.py for now until we can debug or fix
why it isn't working.
2023-12-15 11:55:40 +00:00
David Spickett
f59fed261e [lldb][PDB] TypeQuery parameter should be ConstString 2023-12-13 12:46:16 +00:00
David Spickett
e34c35a21c [lldb][PDB] Fix more issues with PDB tests 2023-12-13 11:49:24 +00:00
David Spickett
887f211028 [lldb][PDB] Attempt to fix tests on Windows 2023-12-13 11:15:46 +00:00
Greg Clayton
dcbf1e4e49
[lldb] Fix buildbots after PR 74786 (#75272)
Fix unexpected pass after
https://github.com/llvm/llvm-project/pull/74786.
2023-12-13 09:12:30 +00:00
Michael Buch
bcb621f0a1
[lldb][DWARFASTParserClang][NFC] Remove redundant parameter to AddMethodToObjCObjectType (#73832) 2023-11-30 05:15:57 +00:00
Alex Langford
133bcacecf
[lldb] Change interface of StructuredData::Array::GetItemAtIndexAsDictionary (#71961)
Similar to my previous patch (#71613) where I changed
`GetItemAtIndexAsString`, this patch makes the same change to
`GetItemAtIndexAsDictionary`.

`GetItemAtIndexAsDictionary` now returns a std::optional that is either
`std::nullopt` or is a valid pointer. Therefore, if the optional is
populated, we consider the pointer to always be valid (i.e. no need to
check pointer validity).
2023-11-10 12:47:43 -08:00
Alex Langford
1486264d5f
[lldb] Change interface of StructuredData::Array::GetItemAtIndexAsString (#71613)
This patch changes the interface of
StructuredData::Array::GetItemAtIndexAsString to return a
`std::optional<llvm::StringRef>` instead of taking an out parameter.
More generally, this commit serves as proposal that we change all of the
sibling APIs (`GetItemAtIndexAs`) to do the same thing. The reason this
isn't one giant patch is because it is rather unwieldy changing just one
of these, so if this is approved, I will do all of the other ones as
individual follow-ups.
2023-11-09 13:35:35 -08:00
Jonas Devlieghere
919f5ef462
[lldb] Add Checksum to FileSpec (#71457)
Store a Checksum in FileSpec. Its purpose is to store the MD5 hash that
was added to the DWARF 5 line table.

This increases the size of a FileSpec from 24 to 40 bytes. The
alternative is to introduce a new SupportFile abstraction for a FileSpec
+ Checksum but that would require a corresponding SupportFileList class.
During review we decided that wasn't worth it, but that's something we
can revisit in the future.
2023-11-08 20:11:48 -08:00
Jonas Devlieghere
7ef7a92ead
[lldb] Add Checksum class to lldbUtility (#71456)
This commit adds an MD5 checksum (`Checksum`) class to LLDB. Its purpose
is to store the MD5 hash added to the DWARF 5 line table.
2023-11-08 10:11:58 -08:00
Med Ismail Bennani
0a21144614 [lldb] Check for abstract methods implementation in Scripted Plugin Objects (#71260)
This patch enforces that every scripted object implements all the
necessary abstract methods.

Every scripted affordance language interface can implement a list of
abstract methods name that checked when the object is instanciated.

Since some scripting affordances implementations can be derived from
template base classes, we can't check the object dictionary since it
will contain the definition of the base class, so instead, this checks
the scripting class dictionary.

Previously, for the various python interfaces, we used
`ABC.abstractmethod` decorators but this is too language specific and
doesn't work for scripting affordances that are not derived from
template base classes (i.e OperatingSystem, ScriptedThreadPlan, ...), so
this patch provides generic/language-agnostic checks for every scripted
affordance.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-11-07 22:01:41 -08:00
Med Ismail Bennani
c2ad9f8b60 Revert "[lldb] Check for abstract methods implementation in Scripted Plugin Objects (#71260)"
This reverts commit cc9ad72713 since it
breaks some tests upstream:

https://lab.llvm.org/buildbot/#/builders/68/builds/63112

********************
Failed Tests (4):
  lldb-api :: functionalities/gdb_remote_client/TestThreadSelectionBug.py
  lldb-api :: functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
  lldb-api :: functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py
  lldb-api :: functionalities/postmortem/mach-core/TestMachCore.py
2023-11-07 13:04:01 -08:00
Med Ismail Bennani
cc9ad72713
[lldb] Check for abstract methods implementation in Scripted Plugin Objects (#71260)
This patch enforces that every scripted object implements all the
necessary abstract methods.

Every scripted affordance language interface can implement a list of
abstract methods name that checked when the object is instanciated.

Since some scripting affordances implementations can be derived from
template base classes, we can't check the object dictionary since it
will contain the definition of the base class, so instead, this checks
the scripting class dictionary.

Previously, for the various python interfaces, we used
`ABC.abstractmethod` decorators but this is too language specific and
doesn't work for scripting affordances that are not derived from
template base classes (i.e OperatingSystem, ScriptedThreadPlan, ...), so
this patch provides generic/language-agnostic checks for every scripted
affordance.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-11-07 12:07:16 -08:00
Jonas Devlieghere
745e8bfd1a
[lldb] Remove LocateSymbolFile (#71301)
This completes the conversion of LocateSymbolFile into a SymbolLocator
plugin. The only remaining function is DownloadSymbolFileAsync which
doesn't really fit into the plugin model, and therefore moves into the
SymbolLocator class, while still relying on the plugins to do the
underlying work.
2023-11-05 08:26:42 -08:00
Jonas Devlieghere
19df9aa3f4
[lldb] Move LocateExecutableSymbolFile to SymbolLocator plugin (#71266)
This builds on top of the work started in c3a302d to convert
LocateSymbolFile to a SymbolLocator plugin. This commit moves
LocateExecutableSymbolFile.
2023-11-03 19:48:36 -07:00
Vlad Serebrennikov
edd690b02e
[clang][NFC] Refactor TagTypeKind (#71160)
This patch converts TagTypeKind into scoped enum. Among other benefits,
this allows us to forward-declare it where necessary.
2023-11-03 21:45:39 +04:00
Med Ismail Bennani
6eafe2cb7a Revert "[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392)"
This reverts commit 4b3cd379cc since it
introduces some test failures:

https://lab.llvm.org/buildbot/#/builders/68/builds/62556
2023-10-30 17:40:11 -07:00
Med Ismail Bennani
4b3cd379cc
[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392)
This patch makes ScriptedThreadPlan conforming to the ScriptedInterface
& ScriptedPythonInterface facilities by introducing 2
ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes.

This allows us to get rid of every ScriptedThreadPlan-specific SWIG
method and re-use the same affordances as other scripting offordances,
like Scripted{Process,Thread,Platform} & OperatingSystem.

To do so, this adds new transformer methods for `ThreadPlan`, `Stream` &
`Event`, to allow the bijection between C++ objects and their python
counterparts.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-10-30 16:52:17 -07:00
Pete Lawrence
92d8a28cc6
[lldb] Part 2 of 2 - Refactor CommandObject::DoExecute(...) return void (not bool) (#69991)
[lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` to return
`void` instead of ~~`bool`~~

Justifications:
- The code doesn't ultimately apply the `true`/`false` return values.
- The methods already pass around a `CommandReturnObject`, typically
with a `result` parameter.
- Each command return object already contains:
	- A more precise status
	- The error code(s) that apply to that status

Part 1 refactors the `CommandObject::Execute(...)` method.
- See
[https://github.com/llvm/llvm-project/pull/69989](https://github.com/llvm/llvm-project/pull/69989)

rdar://117378957
2023-10-30 13:21:00 -07:00
Med Ismail Bennani
7a1e878358 [lldb] Introduce OperatingSystem{,Python}Interface and make use it
This patch aims to consolidate the OperatingSystem scripting affordance
by introducing a stable interface that conforms to the
Scripted{,Python}Interface.

This unify the way we call into python methods from lldb while
also improving its capabilities by allowing us to pass lldb_private
objects are arguments.

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-10-26 15:12:22 -07:00
David Spickett
d1556e5efb
[lldb][lldb-server] Enable sending RegisterFlags as XML (#69951)
This adds ToXML methods to encode RegisterFlags and its fields into XML
according to GDB's target XML format:

https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format

lldb-server does not use libXML to build XML, so this follows the
existing code that uses strings. Indentation is used so the result is
still human readable.

```
<flags id=\"Foo\" size=\"4\">
  <field name=\"abc\" start=\"0\" end=\"0\"/>
</flags>
```

This is used by lldb-server when building target XML, though no one sets
any fields yet. That'll come in a later commit.
2023-10-26 08:33:30 +01:00
Med Ismail Bennani
f22d82cef2
[lldb/Interpreter] Make ScriptedInterface Object creation more generic (#68052)
This patch changes the way plugin objects used with Scripted Interfaces
are created.

Instead of implementing a different SWIG method to create the object for
every scripted interface, this patch makes the creation more generic by
re-using some of the ScriptedPythonInterface templated Dispatch code.

This patch also improves error handling of the object creation by
returning an `llvm::Expected`.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-10-25 10:05:54 -07:00
David Spickett
fe929770f4
[lldb] Add a single bit constructor for RegisterFlags::Field (#69315)
This means you don't have to do RegisterField("", 0, 0), you can do
RegisterField("", 0).

Which is useful for testing and even more useful when we are writing
definitions of real registers which have 10s of single bit fields.
2023-10-23 18:16:03 +01:00
Kazu Hirata
aaa5f34b61 [lldb] Remove an unused using decl (NFC) 2023-10-22 11:57:23 -07:00
Alex Langford
170b552136
[lldb] Scalar::GetValue() should take a Stream by reference (#69231)
This function always expects the pointer to be valid, a reference seems
more appropriate.
2023-10-17 15:40:51 -07:00
David Spickett
3b23704f16 [lldb][PDB] Fix test build after plugin namespace change
This was failing to build on Windows after 1673a1ba5d.
2023-10-16 10:23:45 +00:00
walter erquinigo
a669a237c4 [LLDB] Fix buildbots
https://lab.llvm.org/buildbot/#/builders/96/builds/46935 https://lab.llvm.org/buildbot/#/builders/68/builds/61651 are failing because of some namespace changes introduced by https://reviews.llvm.org/rG1673a1ba5dec
2023-10-13 17:22:49 -04:00
Kazu Hirata
4a0ccfa865 Use llvm::endianness::{big,little,native} (NFC)
Note that llvm::support::endianness has been renamed to
llvm::endianness while becoming an enum class as opposed to an
enum. This patch replaces support::{big,little,native} with
llvm::endianness::{big,little,native}.
2023-10-12 21:21:45 -07:00
Kazu Hirata
a9d5056862 Use llvm::endianness (NFC)
Now that llvm::support::endianness has been renamed to
llvm::endianness, we can use the shorter form.  This patch replaces
support::endianness with llvm::endianness.
2023-10-10 21:54:15 -07:00
Kazu Hirata
d7b18d5083 Use llvm::endianness{,::little,::native} (NFC)
Now that llvm::support::endianness has been renamed to
llvm::endianness, we can use the shorter form.  This patch replaces
llvm::support::endianness with llvm::endianness.
2023-10-09 00:54:47 -07:00
Walter Erquinigo
266630cffc [LLDB] Attempt to fix DumpDataExtractorTest
In 014c41d688 I tried to fix these tests,
but it seems that I needed to change TEST for TEST_F to make that work.
It's a pain that these failures don't repro on any of my machines, but I
verified thta the initialization code for the tests is invoked.
2023-09-18 22:02:05 +00:00
Walter Erquinigo
014c41d688 [LLDB] Attempt to fix DumpDataExtractorTest
This test was broken by 710276a250 because
DumpDataExtractor now accesses the Target properties, which someone ends
up relying on the file system.

This is an instance of this error https://lab.llvm.org/buildbot/#/builders/96/builds/45607/steps/6/logs/stdio

I cannot reproduce this locally, but it seems that the error happens
because we are not initializing the FileSystem and the Host as part of
the test setup.
2023-09-18 21:30:42 +00:00
Jonas Devlieghere
6ebbb1f536
[lldb] Simplify color logic in (IOHandler)Editline (NFC)
This patch simplifies the color handling logic in Editline and
IOHandlerEditline:

 - Remove the m_color_prompts property from Editline and use the prompt
   ANSI prefix and suffix as the single source of truth. This avoids
   having to redraw the prompt unnecessarily, for example when colors
   are enabled but the prompt prefix and suffix are empty.

 - Rename m_color_prompts to just m_color in IOHandlerEditline and use
   it to ensure consistency between colored prompts and colored
   auto-suggestions. Some IOHandler explicitly turn off colors (such as
   IOHandlerConfirm) and it doesn't really make sense to have one or the
   other.
2023-09-13 22:27:05 -07:00
Fangrui Song
678e3ee123 [lldb] Fix duplicate word typos; NFC
Those fixes were taken from https://reviews.llvm.org/D137338
2023-09-01 21:32:24 -07:00