Commit Graph

27178 Commits

Author SHA1 Message Date
Zequan Wu d4514b1553 [LLDB][NativePDB] Pass register_kind as reference (an oversight in 71d778f).
Fix #57799
2022-09-20 13:41:13 -07:00
George Hu 3ae633766b [LLDB]Initialize accept_socket with nullptr
Fix high impact issue of illegal access of memory.
Initialize accept_socket with nullptr.

Differential Revision: https://reviews.llvm.org/D134293
2022-09-20 12:17:32 -07:00
Jorge Gorbe Moya dce6887336 [NFCI] Clean up enum FormatCategoryItem.
- Merge pairs like `eFormatCategoryItemSummary` and
  `eFormatCategoryItemRegexSummary` into a single value. See explanation
  below.

- Rename `eFormatCategoryItemValue` to `eFormatCategoryItemFormat`. This
  makes the enum match the names used elsewhere for formatter kinds
  (format, summary, filter, synth).

- Delete unused values `eFormatCategoryItemValidator` and
  `eFormatCategoryItemRegexValidator`.

This enum is only used to reuse some code in CommandObjectType.cpp.  For
example, instead of having separate implementations for `type summary
delete`, `type format delete`, and so on, there's a single generic
implementation that takes an enum value, and then the specific commands
derive from it and set the right flags for the specific kind of
formatter.

Even though the enum distinguishes between regular and regex matches for
every kind of formatter, this distinction is never used: enum values are
always specified in pairs like
`eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary`.

This causes some ugly code duplication in TypeCategory.cpp. In order to
handle every flag combination some code appears 8 times:

{format, summary, synth, filter} x {exact, regex}

Differential Revision: https://reviews.llvm.org/D134244
2022-09-20 10:41:06 -07:00
David Spickett ec3e290502 [lldb] Log when we cannot find an equivalent for a gdb register type
This happens if the type is described elsewhere in target xml as a
<flags> or <struct>.

Also hardcode the function names into the log messages because
if you use __FUNCTION__ in a lambda you just get "operator()".

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D134043
2022-09-20 09:26:55 +00:00
David Spickett 01d8270a15 [LLDB] Make instruction emulation context type private
This is the first step to being able to handle non
trivial types in the union.

info_type effects the lifetime of the objects in the union,
so making it private means we know you have to call one of the
Set<...> functions to change it.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D134039
2022-09-20 09:10:14 +00:00
David Spickett ba822e248d [LLDB] Format lldb-server's target XML
So that the XML isn't one giant line. Which wasn't
a problem for lldb but was for me trying to troubleshoot
it using the logs.

It now looks like:
```
<?xml version="1.0"?>
<target version="1.0">
  <architecture>aarch64</architecture>
  <feature>
    <...>
    <reg name="fpcr" .../>
  </feature>
</target>
```

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D134035
2022-09-20 09:02:17 +00:00
Jonas Devlieghere 3b4db10f34
[lldb] Actually support more than 32 logging categories
In January, Greg put up a patch (D117382) to support, among other
things, more than 32 log categories. That led to a bunch of nice
cleanups, but categories remained constrained because different parts of
the code were still using uint32_t. This patch fixes the remaining
issues and makes it possible to add a 32nd log category.

Differential revision: https://reviews.llvm.org/D134245
2022-09-19 22:31:20 -07:00
Jonas Devlieghere d3a536fa93
[lldb] Appease the MSCV compiler
Fix error C2027: use of undefined type 'llvm::MemoryBuffer'.
2022-09-19 17:37:27 -07:00
Jonas Devlieghere 70599d7027
[lldb] Remove LLDB reproducers
This patch removes the remaining reproducer code. The SBReproducer class
remains for ABI stability but is just an empty shell. This completes the
removal process outlined on the mailing list [1].

[1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html
2022-09-19 14:43:31 -07:00
Jeffrey Tan dc9e6c52f3 Add auto deduce source map setting
This patch adds a new "target.auto-source-map-relative" setting.

    If enabled, this setting may auto deduce a source map entry based on requested
    breakpoint path and the original path stored in debug info for resolved
    breakpoint.

    As an example, if debug info contains "./a/b/c/main.cpp", user sets a source
    breakpoint at "/root/repo/x/y/z/a/b/c/main.cpp". The breakpoint will resolve
    correctly now with Greg's patch https://reviews.llvm.org/D130401. However, the
    resolved breakpoint will use "./a/b/c/main.cpp" to locate source file during
    stop event which would fail most of the time.

    With the new "target.auto-source-map-relative" setting enabled, a auto deduced
    source map entry "." => "/root/repo/x/y/z" will be added. This new mapping will
    help lldb to map resolved breakpoint path "./a/b/c/main.cpp" back to
    "/root/repo/x/y/z/a/b/c/main.cpp" and locate it on disk.

    If an existing source map entry is used the patch also concatenates the auto
    deduced entry with any stripped reverse mapping prefix (see example below).

    As a second example, debug info contains "./a/b/c/main.cpp" and user sets
    breakpoint at "/root/repo/x/y/z/a/b/c/main.cpp". Let's say there is an existing
    source map entry "." => "/root/repo"; this mapping would strip the prefix out of
    "/root/repo/x/y/z/a/b/c/main.cpp" and use "x/y/z/a/b/c/main.cpp" to resolve
    breakpoint. "target.auto-source-map-relative" setting would auto deduce a new
    potential mapping of "." => "x/y/z", then it detects that there is a stripped
    prefix from reverse mapping and concatenates it as the new mapping:
     "." => "/root/repo/x/y/z" which would correct map "./a/b/c/main.cpp" path to
    new path in disk.

    This patches depends on https://reviews.llvm.org/D130401 to use new added
    SBDebugger::GetSetting() API for testing.

Differential Revision: https://reviews.llvm.org/D133042
2022-09-19 13:40:22 -07:00
Felipe de Azevedo Piovezan 9749587498 [lldb] Reset breakpoint hit count before new runs
A common debugging pattern is to set a breakpoint that only stops after
a number of hits is recorded. The current implementation never resets
the hit count of breakpoints; as such, if a user re-`run`s their
program, the debugger will never stop on such a breakpoint again.

This behavior is arguably undesirable, as it renders such breakpoints
ineffective on all but the first run. This commit changes the
implementation of the `Will{Launch, Attach}` methods so that they reset
the _target's_ breakpoint hitcounts.

Differential Revision: https://reviews.llvm.org/D133858
2022-09-19 12:56:12 -04:00
Kazu Hirata 2078350645 Use std::make_unsigned_t (NFC) 2022-09-18 18:41:02 -07:00
Emmmer edc1c9f610 [LLDB][RISCV] Add RVM and RVA instruction support for EmulateInstructionRISCV
Add:
- RVM and RVA instructions sets.
- corresponding unittests.

Further work:
- implement RVC, RVF, RVD, and RVV extension.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D133670
2022-09-17 12:19:09 +08: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
Michael Buch e456d2ba8b [clang][ASTImporter] DeclContext::localUncachedLookup: Continue lookup into decl chain when regular lookup fails
The uncached lookup is mainly used in the ASTImporter/LLDB code-path
where we're not allowed to load from external storage. When importing
a FieldDecl with a DeclContext that had no external visible storage
(but came from a Clang module or PCH) the above call to `lookup(Name)`
the regular `DeclContext::lookup` fails because:
1. `DeclContext::buildLookup` doesn't set `LookupPtr` for decls
   that came from a module
2. LLDB doesn't use the `SharedImporterState`

In such a case we would never continue with the "slow" path of iterating
through the decl chain on the DeclContext. In some cases this means that
ASTNodeImporter::VisitFieldDecl ends up importing a decl into the
DeclContext a second time.

The patch removes the short-circuit in the case where we don't find
any decls via the regular lookup.

**Tests**

* Un-skip the failing LLDB API tests

Differential Revision: https://reviews.llvm.org/D133945
2022-09-16 12:38:50 -04:00
Michael Buch 3004a759bc [lldb][tests][gmodules] Test for expression evaluator crash for types referencing the same template
The problem here is that the ASTImporter adds
the template class member FieldDecl to
the DeclContext twice. This happens because
we don't construct a `LookupPtr` for decls
that originate from modules and thus the
ASTImporter never realizes that the FieldDecl
has already been imported. These duplicate
decls then break the assumption of the LayoutBuilder
which expects only a single member decl to
exist.

The test will be fixed by a follow-up revision
and is thus skipped for now.

Differential Revision: https://reviews.llvm.org/D133944
2022-09-16 12:38:49 -04:00
Dave Lee 6e450d1347 [lldb] Use SWIG_fail in python-typemaps.swig (NFC)
When attempting to use SWIG's `-builtin` flag, there were a few compile
failures caused by a mismatch between return type and return value. In those
cases, the return type was `int` but many of the type maps assume returning
`NULL`/`nullptr` (only the latter caused compile failures).

This fix abstracts failure paths to use the `SWIG_fail` macro, which performs
`goto fail;`. Each of the generated functions contain a `fail` label, which
performs any resource cleanup and returns the appropriate failure value.

This change isn't strictly necessary at this point, but seems like the right
thing to do, and for anyone who tries `-builtin` later, it resolves those
issues.

Differential Revision: https://reviews.llvm.org/D133961
2022-09-16 08:25:01 -07:00
Matheus Izvekov 67e2298311
[clang] use getCommonSugar in an assortment of places
For this patch, a simple search was performed for patterns where there are
two types (usually an LHS and an RHS) which are structurally the same, and there
is some result type which is resolved as either one of them (typically LHS for
consistency).

We change those cases to resolve as the common sugared type between those two,
utilizing the new infrastructure created for this purpose.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D111509
2022-09-16 16:36:00 +02:00
Matheus Izvekov 1d1a98e9a0
Revert "[clang] use getCommonSugar in an assortment of places"
This reverts commit aff1f6310e.
2022-09-16 12:03:34 +02:00
Matheus Izvekov aff1f6310e
[clang] use getCommonSugar in an assortment of places
For this patch, a simple search was performed for patterns where there are
two types (usually an LHS and an RHS) which are structurally the same, and there
is some result type which is resolved as either one of them (typically LHS for
consistency).

We change those cases to resolve as the common sugared type between those two,
utilizing the new infrastructure created for this purpose.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D111509
2022-09-16 11:55:40 +02:00
Zequan Wu 8704281c56 [LLDB][NativePDB] Global ctor and dtor should be global decls.
This fixes a crash that mistaken global ctor/dtor as funciton methods.

Differential Revision: https://reviews.llvm.org/D133446
2022-09-15 22:35:58 -07:00
Dave Lee ab755e6562 [lldb] Improve formatting of skipped categories message (NFC) 2022-09-15 20:39:25 -07:00
Jim Ingham f3d0bda534 Revert "Revert "Be more careful to maintain quoting information when parsing commands.""
This reverts commit ac05bc0524.

I had incorrectly removed one set of checks in the option handling in
Options::ParseAlias because I couldn't see what it is for.  It was a
bit obscure, but it handled the case where you pass "-something=other --"
as the input_line, which caused the built-in "run" alias not to return
the right value for IsDashDashCommand, causing TestHelp.py to fail.
2022-09-14 14:49:51 -07:00
John Ericson 3a1c81e327 [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 2
A simple sed doing these substitutions:

- `${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}\>` -> `${LLVM_LIBRARY_DIR}`
- `${LLVM_BINARY_DIR}/bin\>` -> `${LLVM_TOOLS_BINARY_DIR}`

where `\>` means "word boundary".

The only manual modifications were reverting changes in

- `runtimes/CMakeLists.txt`

because these were "entry points" where we wanted to tread carefully not not introduce a "loop" which would end with an undefined variable being expanded to nothing.

There are some `${LLVM_BINARY_DIR}/lib` without the `${LLVM_LIBDIR_SUFFIX}`, but these refer to the lib subdirectory of the source (`llvm/lib`). That `lib` is automatically appended to make the local `CMAKE_CURRENT_BINARY_DIR` value by `add_subdirectory`; since the directory name in the source tree is fixed without any suffix, the corresponding `CMAKE_CURRENT_BINARY_DIR` will also be. We therefore do not replace it but leave it as-is.

This picks up where D133828 left off, getting the occurrences with*out* `CMAKE_CFG_INTDIR`. But this is difficult to do correctly and so not done in the (retroactively) previous diff.

This hopefully increases readability overall, and also decreases the usages of `LLVM_LIBDIR_SUFFIX`, preparing us for D130586.

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D132316
2022-09-14 15:48:58 -04:00
Michael Buch 3b44c9af8e [lldb][tests] Move C++ gmodules tests into new gmodules/ subdirectory
This is in preparation for adding more gmodules
tests.

Differential Revision: https://reviews.llvm.org/D133876
2022-09-14 14:45:35 -04:00
Stella Stamenova da459043f8 Revert "[lldb][DWARF5] Enable macro evaluation"
This reverts commit a0fb69d17b.

This broke the windows lldb bot: https://lab.llvm.org/buildbot/#/builders/83/builds/23666
2022-09-14 09:30:49 -07:00
John Ericson 154db06ce0 [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 1
A simple sed doing these substitutions:

- `${LLVM_BINARY_DIR}/\$\{CMAKE_CFG_INTDIR}/lib(${LLVM_LIBDIR_SUFFIX})?\>` -> `${LLVM_LIBRARY_DIR}`
- `${LLVM_BINARY_DIR}/\$\{CMAKE_CFG_INTDIR}/bin\>` -> `${LLVM_TOOLS_BINARY_DIR}`

where `\>` means "word boundary".

The only manual modifications were reverting changes in

- `compiler-rt/cmake/Modules/CompilerRTUtils.cmake`

because these were "entry points" where we wanted to tread carefully not not introduce a "loop" which would end with an undefined variable being expanded to nothing.

There are many more occurrences without `CMAKE_CFG_INTDIR`, but those are left for D132316 as they have proved somewhat tricky to fix.

This hopefully increases readability overall, and also decreases the usages of `LLVM_LIBDIR_SUFFIX`, preparing us for D130586.

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D133828
2022-09-14 10:58:47 -04:00
Jordan Rupprecht 1f3def30ca Fix heap-use-after-free when clearing DIEs in fission compile units.
D131437 caused heap-use-after-free failures when testing TestCreateAfterAttach.py in asan mode, and "regular" crashes outside of asan.

This appears to be due to a mismatch in a couple places where we choose to clear the DIEs. When we clear the DIE of a skeleton unit, we unconditionally clear the DIE of the DWO unit if it exists. However, `~ScopedExtractDIEs()` only looks at the skeleton unit when deciding to clear. If we decide to clear the skeleton unit because it is now unused, we end up clearing the DWO unit that _is_ used. This change adds a guard by checking `m_cancel_scopes` to prevent clearing the DWO unit.

This is 100% reproducible by running TestCreateAfterAttach.py in asan mode, although it only seems to reproduce in our internal build, so no test case is added here. If someone has suggestions on how to write one, I can add it.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D133790
2022-09-14 06:52:47 -07:00
Pavel Labath d079bf33de [lldb] Enable (un-xfail) some dwarf tests for arm
These are passing now that the relocation assertion has been removed in
D132954.

Relocations still remain unimplemented though, so it's possible this may
start to fail due to unrelated changes. If that happens very often, we
may just need to disable (skip) the test instead.
2022-09-14 11:35:16 +02:00
Pavel Kosov a0fb69d17b [lldb][DWARF5] Enable macro evaluation
Patch enables handing of DWARFv5 DW_MACRO_define_strx and DW_MACRO_undef_strx

~~~

OS Laboratory. Huawei RRI. Saint-Petersburg

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D130062
2022-09-14 11:32:07 +03:00
Jason Molenda 92bd2e443e Add mach-o corefile support for platform binaries
Add support for recognizing a platform binary in the ObjectFileMachO
method that parses the "load binary" LC_NOTEs in a corefile.

A bit of reorganization to ProcessMachCore::DoLoadCore to separate
all of the unrelated things being done in that method into their own
separate methods, as well as small fixes to improve the handling of
a corefile with multiple kernel images in the corefile.

Differential Revision: https://reviews.llvm.org/D133680
rdar://98754861
2022-09-13 15:46:18 -07:00
Jordan Rupprecht 4fdda4f82d [lldb][fuzz] Allow expression fuzzer to be passed as a flag.
The expression fuzzer checks an environment variable, `LLDB_FUZZER_TARGET`, to get the fuzzer target binary. This is fine, but internally our tooling for running fuzz tests only has proper handling for flag values. It's surprisingly complicated to add support for that, and allowing it to be passed via flag seems reasonable anyway.

Reviewed By: cassanova

Differential Revision: https://reviews.llvm.org/D133546
2022-09-13 15:39:15 -07:00
Jim Ingham ac05bc0524 Revert "Be more careful to maintain quoting information when parsing commands."
This reverts commit 6c089b2af5.

This was causing the test test_help_run_hides_options from TestHelp.py to
fail on Linux and Windows (but the test succeeds on macOS).  The decision
to print option information is determined by CommandObjectAlias::IsDashDashCommand
which was changed, but only by replacing an inline string constant with a const char *
CommandInterpreter::g_argument which has the same string value.  I can't see why this
would fail, I'll have to spin up a vm to see if I can repo there.
2022-09-13 14:59:21 -07:00
Jim Ingham a2d0a01e3f Revert "constexpr isn't right here."
This didn't help either.

This reverts commit 8433b21083.
2022-09-13 14:58:53 -07:00
Jim Ingham 3f23eb6591 Revert "Trying to understand the TestHelp.py failure from 6c089b2."
It didn't help.

This reverts commit 81f8788528.
2022-09-13 14:58:27 -07:00
Jim Ingham 81f8788528 Trying to understand the TestHelp.py failure from 6c089b2.
Sadly, the test passes on macOS, but fails on Ubuntu & Win.  The
extra option printing is supposed to be suppressed by the return
from CommandObjectAlias::IsDashDashCommand.  That was changed, but just
by replacing an inline string compare with a const string from
CommandInterpreter.  Putting the old version back temporarily to
see if that is really the problem.
2022-09-13 14:09:44 -07:00
Jim Ingham 8433b21083 constexpr isn't right here. 2022-09-13 13:01:56 -07:00
Jorge Gorbe Moya ef3fa232b3 [Formatters][NFCI] Replace 'is_regex' arguments with an enum.
Modify `SBTypeNameSpecifier` and `lldb_private::TypeMatcher` so they
have an enum value for the type of matching to perform instead of an
`m_is_regex` boolean value.

This change paves the way for introducing formatter matching based on
the result of a python callback in addition to the existing name-based
matching. See the RFC thread at
https://discourse.llvm.org/t/rfc-python-callback-for-data-formatters-type-matching/64204
for more details.

Differential Revision: https://reviews.llvm.org/D133240
2022-09-13 12:50:55 -07:00
Jim Ingham 6c089b2af5 Be more careful to maintain quoting information when parsing commands.
This is particularly a problem for alias construction, where you might
want to have a backtick surrounded option in the alias.  Before this
patch:

command alias expression -Z \`argc\` -- argv

for instance would be rendered as:

expression -Z argc -- argv

and would fail to work.

Differential Revision: https://reviews.llvm.org/D133045
2022-09-13 11:02:47 -07:00
Gabriel Ravier 7240436c94
[lldb] Fixed a number of typos
I went over the output of the following mess of a command:

  (ulimit -m 2000000; ulimit -v 2000000; git ls-files -z | parallel
  --xargs -0 cat | aspell list --mode=none --ignore-case | grep -E
  '^[A-Za-z][a-z]*$' | sort | uniq -c | sort -n | grep -vE '.{25}' |
  aspell pipe -W3 | grep : | cut -d' ' -f2 | less)

and proceeded to spend a few days looking at it to find probable typos
and fixed a few hundred of them in all of the llvm project (note, the
ones I found are not anywhere near all of them, but it seems like a
good start).

Differential revision: https://reviews.llvm.org/D131122
2022-09-13 10:38:38 -07:00
David M. Lary f4fc405631 lldb: Add support for R_386_32 relocations to ObjectFileELF
I encountered an issue where `p &variable` was finding an incorrect address for
32-bit PIC ELF files loaded into a running process.  The problem was that the
R_386_32 ELF relocations were not being applied to the DWARF section, so all
variables in that file were reporting as being at the start of their respective
section.  There is an assert that catches this on debug builds, but silently
ignores the issue on non-debug builds.

In this changeset, I added handling for the R_386_32 relocation type to
ObjectFileELF, and a supporting function to ELFRelocation to differentiate
between DT_REL & DT_RELA in ObjectFileELF::ApplyRelocations().

Demonstration of issue:
```
[dmlary@host work]$ cat rel.c
volatile char padding[32] = "make sure var isnt at .data+0";
volatile char var[] = "test";
[dmlary@host work]$ gcc -c rel.c -FPIC -fpic -g -m32

[dmlary@host work]$ lldb ./exec
(lldb) target create "./exec"
Current executable set to '/home/dmlary/src/work/exec' (i386).
(lldb) process launch --stop-at-entry
Process 21278 stopped
* thread #1, name = 'exec', stop reason = signal SIGSTOP
    frame #0: 0xf7fdb150 ld-2.17.so`_start
ld-2.17.so`_start:
->  0xf7fdb150 <+0>: movl   %esp, %eax
    0xf7fdb152 <+2>: calll  0xf7fdb990                ; _dl_start

ld-2.17.so`_dl_start_user:
    0xf7fdb157 <+0>: movl   %eax, %edi
    0xf7fdb159 <+2>: calll  0xf7fdb140
Process 21278 launched: '/home/dmlary/src/work/exec' (i386)

(lldb) image add ./rel.o
(lldb) image load --file rel.o .text 0x40000000 .data 0x50000000
section '.text' loaded at 0x40000000
section '.data' loaded at 0x50000000

(lldb) image dump symtab rel.o
Symtab, file = rel.o, num_symbols = 13:
               Debug symbol
               |Synthetic symbol
               ||Externally Visible
               |||
Index   UserID DSX Type            File Address/Value Load Address       Size               Flags      Name
------- ------ --- --------------- ------------------ ------------------ ------------------ ---------- ----------------------------------
[    0]      1     SourceFile      0x0000000000000000                    0x0000000000000000 0x00000004 rel.c
[    1]      2     Invalid         0x0000000000000000                    0x0000000000000020 0x00000003
[    2]      3     Invalid         0x0000000000000000 0x50000000 0x0000000000000020 0x00000003
[    3]      4     Invalid         0x0000000000000025                    0x0000000000000000 0x00000003
[    4]      5     Invalid         0x0000000000000000                    0x0000000000000020 0x00000003
[    5]      6     Invalid         0x0000000000000000                    0x0000000000000020 0x00000003
[    6]      7     Invalid         0x0000000000000000                    0x0000000000000020 0x00000003
[    7]      8     Invalid         0x0000000000000000                    0x0000000000000020 0x00000003
[    8]      9     Invalid         0x0000000000000000                    0x0000000000000020 0x00000003
[    9]     10     Invalid         0x0000000000000000                    0x0000000000000020 0x00000003
[   10]     11     Invalid         0x0000000000000000                    0x0000000000000020 0x00000003
[   11]     12   X Data            0x0000000000000000 0x50000000 0x0000000000000020 0x00000011 padding
[   12]     13   X Data            0x0000000000000020 0x50000020 0x0000000000000005 0x00000011 var

(lldb) p &var
(volatile char (*)[5]) $1 = 0x50000000
```

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D132954
2022-09-13 18:38:48 +02:00
Jordan Rupprecht e07e1d4425 [test] Increase test assertion for reasonable auxv values.
While auxv keys are usually small, e.g. less than 50, they can sometimes be larger, especially on a downstream kernel where a custom auxv entry is intentionally high to avoid conflicting with the standard lower numbers. This test fails on a system with an auxv value bigger than 1000, but instead of putting this test at that value plus one, it looks like 2023 (i.e. `AT_SUN_CAP_HW2`) is another large one out there. Use 2500 as a limit to still have this be a reasonable "small" check but still allow all known auxv keys.

Semi-related change: this test case prints the auxv dict at the trace level, but only _after_ the assertion fails, making it not print what the offending value is as the test case aborts. Move it earlier so we can see what the "unreasonable" auxv value is.
2022-09-12 19:41:06 -07:00
Greg Clayton 376c7bd92a Fix DW_OP_convert to resolve the CU relative offset correctly.
Debugging some DWARF5 binaries was causing errors to appear when DWARFExpression::Evaluate was called:

    error: GetDIE for DIE 0x31 is outside of its CU 0x123450

The issue is in the DWARF expression evaluator. Fixed with this.

Differential Revision: https://reviews.llvm.org/D133623
2022-09-12 16:53:19 -07:00
Adrian Prantl c9ccaf176d Fix make invocation to pass in the correct source file 2022-09-12 16:51:17 -07:00
Adrian Prantl 455aff72ce Force system C++ stdlib in test that forces system clang.
Unfortunately these options are still not upstream.
2022-09-12 16:47:46 -07:00
Adrian Prantl 1910eeb59f Fix make invocation to pass in the correct source file 2022-09-12 16:36:56 -07:00
Greg Clayton 4763200ec9 Add the ability to show when variables fails to be available when debug info is valid.
Summary:
Many times when debugging variables might not be available even though a user can successfully set breakpoints and stops somewhere. Letting the user know will help users fix these kinds of issues and have a better debugging experience.

Examples of this include:
- enabling -gline-tables-only and being able to set file and line breakpoints and yet see no variables
- unable to open object file for DWARF in .o file debugging for darwin targets due to modification time mismatch or not being able to locate the N_OSO file.

This patch adds an new API to SBValueList:

  lldb::SBError lldb::SBValueList::GetError();

object so that if you request a stack frame's variables using SBValueList SBFrame::GetVariables(...), you can get an error the describes why the variables were not available.

This patch adds the ability to get an error back when requesting variables from a lldb_private::StackFrame when calling GetVariableList.

It also now shows an error in response to "frame variable" if we have debug info and are unable to get varialbes due to an error as mentioned above:

(lldb) frame variable
error: "a.o" object from the "/tmp/libfoo.a" archive: either the .o file doesn't exist in the archive or the modification time (0x63111541) of the .o file doesn't match

Reviewers: labath JDevlieghere aadsm yinghuitan jdoerfert sscalpone

Subscribers:

Differential Revision: https://reviews.llvm.org/D133164
2022-09-12 13:59:05 -07:00
Felipe de Azevedo Piovezan 67c73d88de Reland "[lldb] Use just-built libcxx for tests when available"
This commit improves upon cc0b5ebf7f, which added support for
specifying which libcxx to use when testing LLDB. That patch honored
requests by tests that had `USE_LIBCPP=1` defined in their makefiles.
Now, we also use a non-default libcxx if all conditions below are true:

1. The test is not explicitly requesting the use of libstdcpp
(USE_LIBSTDCPP=1).
2. The test is not explicitly requesting the use of the system's
library (USE_SYSTEM_STDLIB=1).
3. A path to libcxx was either provided by the user through CMake flags
or libcxx was built together with LLDB.

Condition (2) is new and introduced in this patch in order to support
tests that are either:

* Cross-platform (such as API/macosx/macCatalyst and
API/tools/lldb-server). The just-built libcxx is usually not built for
platforms other than the host's.
* Cross-language (such as API/lang/objc/exceptions). In this case, the
Objective C runtime throws an exceptions that always goes through the
system's libcxx, instead of the just built libcxx. Fixing this would
require either changing the install-name of the just built libcxx in Mac
systems, or tuning the DYLD_LIBRARY_PATH variable at runtime.

Some other tests exposes limitations of LLDB when running with a debug
standard library. TestDbgInfoContentForwardLists had an assertion
removed, as it was checking for buggy LLDB behavior (which now
crashes). TestFixIts had a variable renamed, as the old name clashes
with a standard library name when debug info is present. This is a known
issue: https://github.com/llvm/llvm-project/issues/34391.

For `TestSBModule`, the way the "main" module is found was changed to
look for the "a.out" module, instead of relying on the index being 0. In
some systems, the index 0 is dyld when a custom standard library is
used.

Differential Revision: https://reviews.llvm.org/D132940
2022-09-12 15:32:25 -04:00
Zequan Wu aedad60231 [LLDB][NativePDB] Add local variables with no location info.
If we don't add local variables with no location info, when trying to print it,
lldb won't find it in the its parent DeclContext, which makes lldb to spend more
time to search all the way up in DeclContext hierarchy until found same name
variable or failed. Dwarf plugin also add local vars even if they don't have
location info.

Differential Revision: https://reviews.llvm.org/D133626
2022-09-12 12:01:24 -07:00
Stella Stamenova 327146639c Revert "Add the ability to show when variables fails to be available when debug info is valid."
This reverts commit 9af089f517.

This broke the windows lldb bot: https://lab.llvm.org/buildbot/#/builders/83/builds/23528
2022-09-12 11:31:17 -07:00