Commit Graph

329 Commits

Author SHA1 Message Date
Greg Clayton
3661eb150e Add support for parsing type unit entries in .debug_names. (#72952)
This is a follow up patch after .debug_names can now emit local type
unit entries when we compile with type units + DWARF5 + .debug_names.
The pull request that added this functionality was:

https://github.com/llvm/llvm-project/pull/70515

This patch makes sure that the DebugNamesDWARFIndex in LLDB will not
manually need to parse type units if they have a valid index. It also
fixes the index to be able to correctly extract name entries that
reference type unit DIEs. Added a test to verify things work as
expected.
2023-11-28 13:56:45 -08:00
David Spickett
1459c627f0 [lldb][PDB] Fix message order in test case
Launch/stopped ordering was fixed by bd8f1068ca
but the Windows on Arm bot wasn't running at the time it landed.
2023-11-28 09:15:51 +00:00
Haojian Wu
81a76902ae [lldb] Only run ignored_artificial_fields.test when gcc is available. 2023-11-10 20:56:27 +01:00
David Spickett
d96ea27973 Revert "[lldb] Remove the newly-added test in 66acd1e4dc1080015fe6b234226f1d30d6577f04"
This reverts commit 343eb4b425.

This test should work now that the build script doesn't add -m(32|64) on Arm/AArch64
builders.
2023-11-10 13:47:41 +00:00
Haojian Wu
343eb4b425 [lldb] Remove the newly-added test in 66acd1e4dc
The test added causes some buildbot failures:
- https://lab.llvm.org/buildbot/#/builders/17/builds/45077
https://lab.llvm.org/buildbot/#/builders/96/builds/48277

Remove the test for now to make the builtbots happy, and will re-add it after
investigation.
2023-11-10 13:46:36 +01:00
Haojian Wu
66acd1e4dc [LLDB] Ignore actual-needed artificial members in DWARFASTParserClang::ParseSingleMember (#70779)
Address the FIXME, this will allow lldb to print all fields of the
generated coroutine frame structure.

Fixes #69309.
2023-11-10 10:53:03 +01:00
Adrian Prantl
49504674db Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (#69981)
I need this API in the Swift plugin, but it seems generally useful
enough to expose it in the main branch.
2023-10-24 10:55:23 -07:00
Tom Yang
74ca07295f [lldb] improve dwo path in missing dwo error when relative (#69783)
When the debug info refers to a dwo with relative `DW_AT_comp_dir` and
`DW_AT_dwo_name`, we only print the `DW_AT_comp_dir` in our error
message if we can't find it. This often isn't very helpful, especially
when the `DW_AT_comp_dir` is ".":
```
(lldb) fr v
error: unable to locate .dwo debug file "." for skeleton DIE 0x000000000000003c
```

I'm updating the error message to include both `DW_AT_comp_dir` (if it
exists) and `DW_AT_dwo_name` when the `DW_AT_dwo_name` is relative. The
behavior when `DW_AT_dwo_name` is absolute should be the same.
2023-10-21 16:59:44 -07:00
David Spickett
b1f14d6473 Reland "[lldb] Add more ways to find split DWARF files"
This reverts commit dc3f758ddc.

Lit decided to show me the least interesting part of the
test output, but from what I gather on Mac OS the DWARF
stays in the object files (https://stackoverflow.com/a/12827463).

So either split DWARF options do nothing or they produce
files I don't know the name of that aren't .dwo, so I'm
skipping these tests on Darwin.
2023-09-08 08:15:08 +00:00
David Spickett
dc3f758ddc Revert "[lldb] Add more ways to find split DWARF files"
This reverts commit a723694321.

Tests are failing on x86_64 MacOS.
2023-09-08 08:00:38 +00:00
David Spickett
a723694321 [lldb] Add more ways to find split DWARF files
Fixes #28667

There's a bunch of ways to end up building split DWARF where the
DWO file is not next to the program file. On top of that you may
distribute the program in various ways, move files about, switch
machines, flatten the directories, etc.

This change adds a few more strategies to find DWO files:
* Appending the DW_AT_COMP_DIR and DWO name to all the debug
  search paths.
* Appending the same to the binary's dir.
* Appending the DWO name (e.g. a/b/foo.dwo) to all the debug
  search paths.
* Appending the DWO name to the binary's location.
* Appending the DWO filename (e.g. foo.dwo) to the debug
  search paths.
* Appending the DWO filename to the binary's location.

They are applied in that order and some will be skipped
if the DW_AT_COMP_DIR is relative or absolute, same for
the DWO name (though that seems to always be relative).

This uses the setting target.debug-file-search-paths, which
is used for DWP files already.

The added tests likely do not cover every part of the
strategies listed, it's a best effort.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D157609
2023-09-07 08:19:11 +00:00
Daniel Paoliello
a8138c3d2f [lldb] Fix inline_sites.test
Fixes `lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test` to use the correct line number now that f2f36c9b29 is causing the inline call site info to be taken into account.
2023-09-06 11:20:39 -07:00
David Spickett
4139461d4e [lldb] Fix REQUIRES for DWO relative path test
This was "x86-registered-target" which seems to be false in this test
suite despite me having the x86 backend enabled. The other tests use just "x86"
and with that the test passes on my AArch64 machine fine.
2023-08-17 14:19:27 +00:00
Adrian Prantl
27fac4a72a Add support for __debug_line_str in Mach-O
This patch resolves an issue that currently accounts for the vast
majority of failures on the matrix bot.

Differential Revision: https://reviews.llvm.org/D152872
2023-06-14 08:37:08 -07:00
Adrian Prantl
59b5581833 Speculative fix for windows test 2023-06-12 14:51:24 -07:00
Michael Buch
73927d574f [lldb][test] incomplete-tag-type.cpp: fix expected error message
Follow up to 133c3eaac0

Differential Revision: https://reviews.llvm.org/D152590
2023-06-12 19:33:10 +01:00
David Blaikie
ed7be0d4d1 lldb: Fix cross-cu-reference test to explicitly request that feature 2023-06-01 00:35:39 +00:00
Daniel Paoliello
f8499d5709 Emit the correct flags for the PROC CodeView Debug Symbol
The S_LPROC32_ID and S_GPROC32_ID CodeView Debug Symbols have a flags
field which LLVM has had the values for (in the ProcSymFlags enum) but
has never actually set.

These flags are used by Microsoft-internal tooling that leverages debug
information to do binary analysis.

Modified LLVM to set the correct flags:

- ProcSymFlags::HasOptimizedDebugInfo - always set, as this indicates that
debug info is present for optimized builds (if debug info is not emitted
for optimized builds, then LLVM won't emit a debug symbol at all).
- ProcSymFlags::IsNoReturn and ProcSymFlags::IsNoInline - set if the
function has the NoReturn or NoInline attributes respectively.
- ProcSymFlags::HasFP - set if the function requires a frame pointer (per
TargetFrameLowering::hasFP).

Per discussion in review, XFAIL'ing lldb test until someone working on
lldb has a chance to look at it.

Differential Revision: https://reviews.llvm.org/D148761
2023-05-16 10:58:10 -07:00
LU Hongyi
16c2872d7b Reland "[lldb][DWARFExpression] Fix DW_OP_div to use signed division"
This patch resolves an issue where a value
is incorrectly displayed if it is represented
by DW_OP_div.

This issue is caused by lldb evaluating
operands of DW_OP_div as unsigned
and performed unintended unsigned
division.

This issue is resolved by creating two
temporary signed scalar and performing
signed division.

(Addresses GH#61727)

Differential Revision: https://reviews.llvm.org/D147370
2023-05-05 06:45:07 -04:00
Michael Buch
ad74df12b8 Revert "[lldb][DWARFExpression] Fix DW_OP_div to use signed division"
This reverts commit e15d6b520e.

Newly added test fails on Darwin platforms and arm.

Differential Revision: https://reviews.llvm.org/D147370
2023-05-02 15:36:56 -04:00
Adrian Prantl
419bc85675 Revert "Add amissing REQUIRES: to test"
This reverts commit 1f74964b40.

The googles. They do nothing!
2023-05-02 11:41:58 -07:00
Adrian Prantl
1f74964b40 Add amissing REQUIRES: to test 2023-05-02 11:16:04 -07:00
LU Hongyi
e15d6b520e [lldb][DWARFExpression] Fix DW_OP_div to use signed division
This patch resolves an issue where a value
is incorrectly displayed if it is represented
by DW_OP_div.

This issue is caused by lldb evaluating
operands of DW_OP_div as unsigned
and performed unintended unsigned
division.

This issue is resolved by creating two
temporary signed scalar and performing
signed division.

(Addresses GH#61727)

Differential Revision: https://reviews.llvm.org/D147370
2023-05-02 07:38:52 -04:00
Caroline Tice
be58b42a75 [lldb] Add 'CHECK' to class-type-nullptr-deref.s test.
This test previously relied on just segfaulting or not. This commit adds
a CHECK statement to the test.

Differential Revision: https://reviews.llvm.org/D148151
2023-04-13 08:17:53 -07:00
Caroline Tice
1fa26e64fd [PATCH][lldb] Fix dereference of null pointer.
The function DWARFASTParserClang::ParsePointerToMemberType attempts to make
two pointers and then immediately tries to dereference them, without
verifying that the pointesr were successfully created. Sometimes the pointer
creation fails, and the dereference then causes a segfault. This add a check
that the pointers are non-null before attempting to dereference them.
2023-04-11 13:33:03 -07:00
Alexander Yermolovich
d557384b43 [LLDB] Fix for D139955 Summary:
Fixing a small typo.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D146659
2023-03-23 14:03:42 -07:00
Dave Lee
8c040d0f49 [lldb] Fix d875838e8b 2023-03-17 10:45:46 -07:00
Dave Lee
d875838e8b [lldb][test] Replace use of p with expression in Shell tests (NFC)
In Shell tests, replace use of the `p` alias with the `expression` command.

To avoid conflating tests of the alias with tests of the expression command,
this patch canonicalizes to the use `expression`.

See also D141539 which made the same change to API tests.

Differential Revision: https://reviews.llvm.org/D146230
2023-03-17 10:29:24 -07:00
Michael Buch
ef7adbe2b7 Reland "[lldb][TypeSystemClang] Format pointers to member functions as eFormatHex"
Before this patch, LLDB used to format pointers to members, such as,
```
void (Foo::*pointer_to_member_func)() = &Foo::member_func;
```
as `eFormatBytes`. E.g.,
```
(lldb) v pointer_to_member_func
(void (Foo::*)()) $1 = 94 3f 00 00 01 00 00 00 00 00 00 00 00 00 00 00
```

This patch makes sure we format pointers to member functions the same
way we do regular function pointers.

After this patch we format member pointers as:
```
(lldb) v pointer_to_member_func
(void (Foo::*)()) ::pointer_to_member_func = 0x00000000000000000000000100003f94
```

Differential Revision: https://reviews.llvm.org/D145241
2023-03-07 19:45:49 +00:00
Michael Buch
bc112b1447 Revert "[lldb][test] NativePDB/ast-types: fix expected pointer format"
Reverted because dependecies had to be reverted.

This reverts commit 96e39fdbb9.
2023-03-07 11:18:37 +00:00
David Stenberg
98c3dc3fa7 [lldb] Make GetDIENamesAndRanges() allow 0-valued decl and call lines
In an upcoming patch, D142556, Clang is proposed to be changed to emit
line locations that are inlined at line 0. This clashed with the behavior of
GetDIENamesAndRanges() which used 0 as a default value to determine if
file, line or column numbers had been set. Users of that function then
checked for any non-0 values when setting up the call site:

  if (call_file != 0 || call_line != 0 || call_column != 0)
    [...]

which did not work with the Clang change since all three values then
could be 0.

This changes the function to use std::optional to catch non-set values
instead.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D142552
2023-03-06 14:23:29 +01:00
Michael Buch
96e39fdbb9 [lldb][test] NativePDB/ast-types: fix expected pointer format
Format changed in `b642fd5ee250247ccefb38099169b4ee8ac4112b`

Differential Revision: https://reviews.llvm.org/D145241
2023-03-03 21:41:18 +00:00
Pavel Labath
fad60105ac [lldb/test] Update error message in debug-types-signature-loop.s
The error message changed in D144664.
2023-03-01 13:51:58 +01:00
Alexander Yermolovich
34a8e6eee6 [LLDB] Enable 64 bit debug/type offset
This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902
With big binaries we can have .dwp files where .debug_info.dwo section can grow
beyond 4GB. We would like to support this in LLVM and in LLDB.

The plan is to enable manual parsing of cu/tu index in DWARF library
(https://reviews.llvm.org/D137882), and then
switch internal index data structure to 64 bit.
For the second part is to enable 64bit offset support in LLDB with
this patch.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D138618
2023-02-22 11:34:00 -08:00
Alexander Yermolovich
8116fc592c Revert "[LLDB] Enable 64 bit debug/type offset"
This reverts commit 2062e90aa5.
2023-02-16 17:20:27 -08:00
Alexander Yermolovich
2062e90aa5 [LLDB] Enable 64 bit debug/type offset
This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902
With big binaries we can have .dwp files where .debug_info.dwo section can grow
beyond 4GB. We would like to support this in LLVM and in LLDB.

The plan is to enable manual parsing of cu/tu index in DWARF library
(https://reviews.llvm.org/D137882), and then
switch internal index data structure to 64 bit.
For the second part is to enable 64bit offset support in LLDB with
this patch.

Depends on D139955

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D138618
2023-02-16 14:46:13 -08:00
Alexander Yermolovich
620b3d9ba3 Revert "[LLDB] Enable 64 bit debug/type offset"
This reverts commit f36fe009c0.
2023-02-13 14:08:40 -08:00
Alexander Yermolovich
f36fe009c0 [LLDB] Enable 64 bit debug/type offset
This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902
With big binaries we can have .dwp files where .debug_info.dwo section can grow
beyond 4GB. We would like to support this in LLVM and in LLDB.

The plan is to enable manual parsing of cu/tu index in DWARF library
(https://reviews.llvm.org/D137882), and then
switch internal index data structure to 64 bit.
For the second part is to enable 64bit offset support in LLDB with
this patch.

Depends on D139955

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D138618
2023-02-13 13:08:01 -08:00
Alex Langford
f841c4af5f [lldb] Fix image lookup crash
lldb may crash when performing `image lookup --verbose --address $ADDR`.
The ExecutionContext that gets passed into DWARFExpression::Evaluate may
be valid but unpopulated. However, in one specific case, we were
assuming that it has a valid Target and using it without checking first.

We reach this codepath when we attempt to get information about an
address that doesn't map to a CompileUnit in the module containing the
requested address. lldb then checks to see if it maps to a global
variable, so lldb has to evaluate the location of each global variable
in the module. If a location expression contains DW_OP_deref_size that
uses a FileAddress, we hit this code path. The simplest test case is to
take a module that has a global variable with DW_OP_deref_size in its
location expression, attempt to read an address that doesn't map to a
CompileUnit (e.g. 0x0) and ensure we don't crash.

Differential Revision: https://reviews.llvm.org/D143792
2023-02-13 10:55:10 -08:00
Adrian Prantl
9000a36f5c Manual DWARF index: don't skip over -gmodules debug info
This fixes a regression introduced by
https://reviews.llvm.org/D131437. The intention of the patch was to
avoid indexing DWO skeleton units, but it also skipped over full DWARF
compile units linked via a -gmodules DW_AT_dwo_name attribute. This
patch restores the functionality and adds a test for it.

Differential Revision: https://reviews.llvm.org/D142683
2023-01-27 15:59:46 -08:00
Alexander Yermolovich
e262b8f48a [LLDB] Change formatting to use llvm::formatv
In preparation for eanbling 64bit support in LLDB switching to use llvm::formatv
instead of format MACROs.

Reviewed By: labath, JDevlieghere

Differential Revision: https://reviews.llvm.org/D139955
2023-01-09 11:29:43 -08:00
Mitch Phillips
fc5bda52f0 Fix dwarf5-lazy-dwo.c for the default c target not being c99.
My host compiler is clang version 15.0.0, which uses -std=c11 by
default. The test asserts that the language is 'c99', and so the test
fails locally.

Update the test to be explicit about compiling with 'c99'.

Reviewed By: Eric

Differential Revision: https://reviews.llvm.org/D139461
2022-12-07 09:07:56 -08:00
Pavel Labath
c699a81bc9 [lldb/test] Remove the module cache directory in module-ownership.mm
The stale cache directory can cause compilation to fail when ast
serialization changes.
2022-11-25 11:55:42 +01:00
Zequan Wu
24993e749c [LLDB][Minidump] Merge executable module's architecture into target's architecture.
This allows minidump process ABI to match the PE/COFF file ABI.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D137873
2022-11-22 10:23:11 -08:00
Zequan Wu
6435fe699c [LLDB][NativePDB] Forcefully complete a record type if it has empty debug info and is required to have complete type.
It's required in following situations:
1. As a base class.
2. As a data member.
3. As an array element type.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D134066
2022-11-16 11:17:07 -08:00
Zequan Wu
a7fa5febaa [Test] Fix CHECK typo.
Differential Revision: https://reviews.llvm.org/D137287
2022-11-04 10:18:04 -07:00
Zequan Wu
d3492ed016 [LLDB][NativePDB] Fix struct layout when it has anonymous unions.
Previously, lldb mistook fields in anonymous union in a struct as the direct
field of the struct, which causes lldb crashes due to multiple fields sharing
the same offset in a struct. This patch fixes it.

MSVC generated pdb doesn't have the debug info entity representing a anonymous
union in a struct. It looks like the following:
```
struct S {
union {
  char c;
  int i;
};
};

0x1004 | LF_FIELDLIST [size = 40]
         - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public]
         - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
0x1005 | LF_STRUCTURE [size = 32] `S`
         unique name: `.?AUS@@`
         vtable: <no type>, base list: <no type>, field list: 0x1004
```
Clang generated pdb is similar, though due to the [[ https://github.com/llvm/llvm-project/issues/57999 | bug ]],
it's not more useful than the debug info above. But that's not very relavent,
lldb should still be able to understand MSVC geneerated pdb.
```
0x1003 | LF_UNION [size = 60] `S::<unnamed-tag>`
         unique name: `.?AT<unnamed-type-$S1>@S@@`
         field list: <no type>
         options: forward ref (= 0x1003) | has unique name | is nested, sizeof 0
0x1004 | LF_FIELDLIST [size = 40]
         - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public]
         - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
         - LF_NESTTYPE [name = ``, parent = 0x1003]
0x1005 | LF_STRUCTURE [size = 32] `S`
         unique name: `.?AUS@@`
         vtable: <no type>, base list: <no type>, field list: 0x1004
         options: contains nested class | has unique name, sizeof 4
0x1006 | LF_FIELDLIST [size = 28]
         - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public]
         - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
0x1007 | LF_UNION [size = 60] `S::<unnamed-tag>`
         unique name: `.?AT<unnamed-type-$S1>@S@@`
         field list: 0x1006
         options: has unique name | is nested | sealed, sizeof
```
This patch delays the FieldDecl creation when travesing LF_FIELDLIST so we know
if there are multiple fields are in the same offsets and are able to group them
into different anonymous unions based on offsets. Nested anonymous union will
be flatten into one anonymous union, because we simply don't have that info, but
they are equivalent in terms of union layout.

Differential Revision: https://reviews.llvm.org/D134849
2022-10-13 12:43:45 -07:00
Zequan Wu
d434f43720 [LLDB][NativePDB] Add class/union layout bit size.
Missing it causes lldb to crash or give incorrect result.

Differential Revision: https://reviews.llvm.org/D134656
2022-09-27 11:41:55 -07:00
Alvin Wong
f4991bfa89 [lldb] Improve display of absolute symbol lookup
When running `target module lookup` command, show the name of absolute
symbols. Also fix indentation issue after printing an absolute symbol.

Reviewed By: clayborg, DavidSpickett

Differential Revision: https://reviews.llvm.org/D134516
2022-09-27 13:09:59 +03:00
Zequan Wu
d21b417025 [LLDB][NativePDB] ResolveSymbolContext should return the innermost block
Before, it returns the outermost blocks if nested blocks have the same
address range. That casuses lldb unable to find variables that are inside
inner blocks.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D133601
2022-09-16 10:19:09 -07:00