Commit Graph

507 Commits

Author SHA1 Message Date
Jaroslav Sevcik f968bd77bb Reland "[lldb/DWARF] Only match mangled name in full-name function lookup (with accelerators)"
Summary:

In the spirit of https://reviews.llvm.org/D70846, we only return functions with
matching mangled name from Apple/DebugNamesDWARFIndex::GetFunction if
eFunctionNameTypeFull is requested.

This speeds up lookup in the presence of large amount of class methods of the
same name (a typical examples would be constructors of templates with many
instantiations or overloaded operators).

Reviewers: labath, teemperor

Reviewed By: labath, teemperor

Subscribers: aprantl, arphaman, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73191
2021-08-04 12:50:13 +02:00
Kim-Anh Tran 0092dbcd80 [lldb] Fix lookup of .debug_loclists with split-dwarf
This patch fixes the lookup of locations in
.debug_loclists, if they are split in a .dwp file.

Mainly, we need to consider the cu index offsets.

Reviewed By: jankratochvil

Differential Revision: https://reviews.llvm.org/D107161
2021-08-04 11:36:44 +02:00
Alex Langford d2b2ab4e1c [lldb] Further constrain a test that fails without python enabled
The test relies on the python embedded interpreter being available and
fails otherwise.
2021-08-03 11:50:36 -07:00
Eric Leese ea9706626c [test] [lldb] Use filename instead of index in test
In some environments this test could fail if start.S has its own DWARF
CompileUnit or similar are included before the DWARF CompileUnit for the
file.

This change makes the test independent of the index of the compile unit,
instead checking the filename.

Reviewed By: herhut, jankratochvil

Differential Revision: https://reviews.llvm.org/D107300
2021-08-02 21:12:57 +02:00
Eric Leese fb09f365ae [lldb] [DWARF-5] Be lazier about loading .dwo files
This change makes sure that DwarfUnit does not load a .dwo file until
necessary. I also take advantage of DWARF 5's guarantee that the first
support file is also the primary file to make it possible to create
a compile unit without loading the .dwo file.

Testcases now require Linux as it is needed for -gsplit-dwarf.

Review By: jankratochvil, dblaikie

Differential Revision: https://reviews.llvm.org/D100299
2021-07-31 10:45:31 +02:00
Stella Stamenova dfb6f7b015 Revert "[lldb] [DWARF-5] Be lazier about loading .dwo files"
This reverts commit 8dfd6cae9b.

This change broke the windows lldb bot:
https://lab.llvm.org/buildbot/#/builders/83/builds/8842
2021-07-30 18:33:13 -07:00
Eric Leese 8dfd6cae9b [lldb] [DWARF-5] Be lazier about loading .dwo files
This change makes sure that DwarfUnit does not load a .dwo file until
necessary. I also take advantage of DWARF 5's guarantee that the first
support file is also the primary file to make it possible to create
a compile unit without loading the .dwo file.

Review By: jankratochvil, dblaikie

Differential Revision: https://reviews.llvm.org/D100299
2021-07-30 23:17:06 +02:00
Jan Kratochvil d0e6d946b6 Revert "[lldb] [DWARF-5] Be lazier about loading .dwo files"
This reverts commit e7b8ba103a.

It broke 32-bit ARM - lldb-arm-ubuntu, reported by omjavaid:
  https://lab.llvm.org/buildbot/#/builders/17/builds/9595
2021-07-30 14:54:27 +02:00
Eric Leese e7b8ba103a [lldb] [DWARF-5] Be lazier about loading .dwo files
This change makes sure that DwarfUnit does not load a .dwo file until
necessary. I also take advantage of DWARF 5's guarantee that the first
support file is also the primary file to make it possible to create
a compile unit without loading the .dwo file.

Review By: jankratochvil, dblaikie

Differential Revision: https://reviews.llvm.org/D100299
2021-07-30 13:34:51 +02:00
Stella Stamenova 66ba4e3dc6 Revert "[lldb] Assert filecache and live memory match on debug under a setting"
This reverts commit 77e9d10f0f.

This change broke the Windows LLDB bot:
https://lab.llvm.org/buildbot/#/builders/83/builds/8784/steps/7/logs/stdio
2021-07-29 10:48:57 -07:00
Augusto Noronha 77e9d10f0f [lldb] Assert filecache and live memory match on debug under a setting 2021-07-29 10:29:34 -03:00
Greg Clayton ec1a491701 Create synthetic symbol names on demand to improve memory consumption and startup times.
This is a resubmission of https://reviews.llvm.org/D105160 after fixing testing issues.

This fix was created after profiling the target creation of a large C/C++/ObjC application that contained almost 4,000,000 redacted symbol names. The symbol table parsing code was creating names for each of these synthetic symbols and adding them to the name indexes. The code was also adding the object file basename to the end of the symbol name which doesn't allow symbols from different shared libraries to share the names in the constant string pool.

Prior to this fix this was creating 180MB of "___lldb_unnamed_symbol" symbol names and was taking a long time to generate each name, add them to the string pool and then add each of these names to the name index.

This patch fixes the issue by:

not adding a name to synthetic symbols at creation time, and allows name to be dynamically generated when accessed
doesn't add synthetic symbol names to the name indexes, but catches this special case as name lookup time. Users won't typically set breakpoints or lookup these synthetic names, but support was added to do the lookup in case it does happen
removes the object file baseanme from the generated names to allow the names to be shared in the constant string pool
Prior to this fix the startup times for a large application was:
12.5 seconds (cold file caches)
8.5 seconds (warm file caches)

After this fix:
9.7 seconds (cold file caches)
5.7 seconds (warm file caches)

The names of the symbols are auto generated by appending the symbol's UserID to the end of the "___lldb_unnamed_symbol" string and is only done when the name is requested from a synthetic symbol if it has no name.

Differential Revision: https://reviews.llvm.org/D106837
2021-07-27 16:51:12 -07:00
Amy Huang 1a3bf2953a [DebugInfo] Switch to using constructor homing (-debug-info-kind=constructor) by default when debug info is enabled
Constructor homing reduces the amount of class type info that is emitted
by emitting conmplete type info for a class only when a constructor for
that class is emitted.

This will mainly reduce the amount of duplicate debug info in object
files. In Chrome enabling ctor homing decreased total build directory sizes
by about 30%.

It's also expected that some class types (such as unused classes)
will no longer be emitted in the debug info. This is fine, since we wouldn't
expect to need these types when debugging.

In some cases (e.g. libc++, https://reviews.llvm.org/D98750), classes
are used without calling the constructor. Since this is technically
undefined behavior, enabling constructor homing should be fine.
However Clang now has an attribute
`__attribute__((standalone_debug))` that can be used on classes to
ignore ctor homing.

Bug: https://bugs.llvm.org/show_bug.cgi?id=46537

Differential Revision: https://reviews.llvm.org/D106084
2021-07-26 17:24:42 -07:00
Fangrui Song b71b25008f [test] Fix PayloadString: in lldb tests 2021-07-26 10:00:05 -07:00
Jonas Devlieghere 3338819b08 [lldb] Drop REQUIRES where redundant because of lit.local.cfg 2021-07-09 13:25:10 -07:00
Jonas Devlieghere 488fcea3b5 [lldb] Use custom script instead of lldb.macosx.crashlog in test
I'm not entirely sure this is the problem, but the Windows bot doesn't
seem to like this test. Let's do something similar to
command_import.test which doesn't have that issue.
2021-07-09 12:42:11 -07:00
Jonas Devlieghere f951735395 [lldb] Add the ability to silently import scripted commands
Add the ability to silence command script import. The motivation for
this change is being able to add command script import -s
lldb.macosx.crashlog to your ~/.lldbinit without it printing the
following message at the beginning of every debug session.

  "malloc_info", "ptr_refs", "cstr_refs", "find_variable", and
  "objc_refs" commands have been installed, use the "--help" options on
  these commands for detailed help.

In addition to forwarding the silent option to LoadScriptingModule, this
also changes ScriptInterpreterPythonImpl::ExecuteOneLineWithReturn and
ScriptInterpreterPythonImpl::ExecuteMultipleLines to honor the enable IO
option in ExecuteScriptOptions, which until now was ignored.

Note that IO is only enabled (or disabled) at the start of a session,
and for this particular use case, that's done when taking the Python
lock in LoadScriptingModule, which means that the changes to these two
functions are not strictly necessary, but (IMO) desirable nonetheless.

Differential revision: https://reviews.llvm.org/D105327
2021-07-09 10:05:39 -07:00
Siger Yang e81ba28313 [lldb/lua] Add scripted watchpoints for Lua
Add support for Lua scripted watchpoints, with basic tests.

Differential Revision: https://reviews.llvm.org/D105034
2021-07-07 14:51:02 -03:00
Jonas Devlieghere 6b0d266036 Revert "Create synthetic symbol names on demand to improve memory consumption and startup times."
This reverts commit c8164d0276 and
43f6dad234 because it breaks
TestDyldTrieSymbols.py on GreenDragon.
2021-07-02 16:21:47 -07:00
Greg Clayton c8164d0276 Create synthetic symbol names on demand to improve memory consumption and startup times.
This fix was created after profiling the target creation of a large C/C++/ObjC application that contained almost 4,000,000 redacted symbol names. The symbol table parsing code was creating names for each of these synthetic symbols and adding them to the name indexes. The code was also adding the object file basename to the end of the symbol name which doesn't allow symbols from different shared libraries to share the names in the constant string pool.

Prior to this fix this was creating 180MB of "___lldb_unnamed_symbol" symbol names and was taking a long time to generate each name, add them to the string pool and then add each of these names to the name index.

This patch fixes the issue by:
- not adding a name to synthetic symbols at creation time, and allows name to be dynamically generated when accessed
- doesn't add synthetic symbol names to the name indexes, but catches this special case as name lookup time. Users won't typically set breakpoints or lookup these synthetic names, but support was added to do the lookup in case it does happen
- removes the object file baseanme from the generated names to allow the names to be shared in the constant string pool

Prior to this fix the startup times for a large application was:
12.5 seconds (cold file caches)
8.5 seconds (warm file caches)

After this fix:
9.7 seconds (cold file caches)
5.7 seconds (warm file caches)

The names of the symbols are auto generated by appending the symbol's UserID to the end of the "___lldb_unnamed_symbol" string and is only done when the name is requested from a synthetic symbol if it has no name.

Differential Revision: https://reviews.llvm.org/D105160
2021-06-29 17:44:33 -07:00
Stella Stamenova c8a9c78e17 [lldb] Fix debug_loc.s which was broken after https://reviews.llvm.org/D103502
An empty location is now printed as <empty>
2021-06-29 13:54:48 -07:00
Stella Stamenova 9952d591cc [lldb] Fix globals-bss.cpp which was broken in https://reviews.llvm.org/D105055
-S replaced -s, so the test needs to be updated to use the new option
2021-06-29 13:39:18 -07:00
Stella Stamenova bb2cfca2f3 Revert D104488 and friends since it broke the windows bot
Reverts commits:
"Fix failing tests after https://reviews.llvm.org/D104488."
"Fix buildbot failure after https://reviews.llvm.org/D104488."
"Create synthetic symbol names on demand to improve memory consumption and startup times."

This series of commits broke the windows lldb bot and then failed to fix all of the failing tests.
2021-06-29 12:58:55 -07:00
Greg Clayton 42c05ed8be Fix failing tests after https://reviews.llvm.org/D104488.
Synthetic names no longer have the shared library name appended to the end.
2021-06-28 19:59:24 -07:00
Michał Górny d4c437c428 [lldb] [Process/elf-core] Fix reading NetBSD/i386 core dumps
Add support for extracting basic data from NetBSD/i386 core dumps.
FPU registers are not supported at the moment.

Differential Revision: https://reviews.llvm.org/D101091
2021-06-20 18:59:21 +02:00
Jim Ingham 80b2da42d2 Don't depend on the "run" alias doing shell expanding.
Instead dial it up explicitly.

This test started failing recently and I'm not sure why.  It also
doesn't make sense to me the replacing "run" with "process launch -X 1 --"
should make any difference - run is an alias for the latter.  But
it does pass with the change, and unless we are testing for the exact
run alias, it's better to ask for what we want explicitly.
2021-06-15 16:37:46 -07:00
David Spickett 31b9acaec5 Reland "[lldb] Set return status to failed when adding a command error"
This reverts commit ac031c8db2.

SB API usage has been corrected.
2021-06-14 14:26:47 +01:00
David Spickett ac031c8db2 Revert "[lldb] Set return status to failed when adding a command error" (and fixups)
This reverts commit f583029da3,
0f94d68a2e and
a2363c0cf9.

Due to test failures from incorrect SB API usage.
2021-06-14 12:09:42 +00:00
David Spickett a2363c0cf9 Reland "[lldb] Set return status to failed when adding a command error"
This reverts commit db93e4e70a.

This modifies TestRegsters.py to account for Darwin showing
AVX registers as part of "Floating Point Registers" instead
of in a separate "Advanced Vector Extensions" category.
2021-06-14 09:19:25 +00:00
David Spickett db93e4e70a Revert "[lldb] Set return status to failed when adding a command error"
This reverts commit e05b03cf4f.

While I investigate a register test failure:
http://green.lab.llvm.org/green/blue/organizations/jenkins/lldb-cmake/detail/lldb-cmake/32693/pipeline/
2021-06-09 09:41:59 +01:00
Jonas Devlieghere 1a216fb15a [lldb] Don't print script output twice in HandleCommand
When executing a script command in HandleCommand(s) we currently print
its output twice
You can see this issue in action when adding a breakpoint command:

(lldb) b main
Breakpoint 1: where = main.out`main + 13 at main.cpp:2:3, address = 0x0000000100003fad
(lldb) break command add 1 -o "script print(\"Hey!\")"
(lldb) r
Process 76041 launched: '/tmp/main.out' (x86_64)
Hey!
(lldb)  script print("Hey!")
Hey!
Process 76041 stopped

The issue is caused by HandleCommands using a temporary
CommandReturnObject and one of the commands (`script` in this case)
setting an immediate output stream. This causes the result to be printed
twice: once directly to the immediate output stream and once when
printing the result of HandleCommands.

This patch fixes the issue by introducing a new option to suppress
immediate output for temporary CommandReturnObjects.

Differential revision: https://reviews.llvm.org/D103349
2021-06-08 13:57:39 -07:00
David Spickett e05b03cf4f [lldb] Set return status to failed when adding a command error
There is a common pattern:
result.AppendError(...);
result.SetStatus(eReturnStatusFailed);

I found that some commands don't actually "fail" but only
print "error: ..." because the second line got missed.

This can cause you to miss a failed command when you're
using the Python interface during testing.
(and produce some confusing script results)

I did not find any place where you would want to add
an error without setting the return status, so just
set eReturnStatusFailed whenever you add an error to
a command result.

This change does not remove any of the now redundant
SetStatus. This should allow us to see if there are any
tests that have commands unexpectedly fail with this change.
(the test suite passes for me but I don't have access to all
the systems we cover so there could be some corner cases)

Some tests that failed on x86 and AArch64 have been modified
to work with the new behaviour.

Differential Revision: https://reviews.llvm.org/D103701
2021-06-08 09:41:07 +01:00
Daniel Rodríguez Troitiño 5e327785da [lldb] Match test dependencies name to other LLVM projects.
Other LLVM projects use the suffix `-depends` for the test dependencies,
however LLDB uses `-deps` and seems to be the only project under the
LLVM to do so.

In order to make the projects more homogeneous, switch all the
references to `lldb-test-deps` to `lldb-test-depends`.

Additionally, provide a compatibility target with the old name and
depending on the new name, in order to not break anyone workflow.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D102889
2021-05-21 00:10:27 -07:00
Jan Kratochvil 6d19c84cd9 [lldb] Improve invalid DWARF DW_AT_ranges error reporting
In D98289#inline-939112 @dblaikie said:
  Perhaps this could be more informative about what makes the range list
  index of 0 invalid? "index 0 out of range of range list table (with
  range list base 0xXXX) with offset entry count of XX (valid indexes
  0-(XX-1))" Maybe that's too verbose/not worth worrying about since
  this'll only be relevant to DWARF producers trying to debug their
  DWARFv5, maybe no one will ever see this message in practice. Just
  a thought.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D102851
2021-05-20 21:37:01 +02:00
Jan Kratochvil d131081719 [lldb] 2/2: Fix DW_AT_ranges DW_FORM_sec_offset not using DW_AT_rnglists_base (used by GCC)
DW_AT_ranges can use DW_FORM_sec_offset (instead of DW_FORM_rnglistx).
In such case DW_AT_rnglists_base does not need to be present.
DWARF-5 spec:
        "If the offset_entry_count is zero, then DW_FORM_rnglistx cannot
        be used to access a range list; DW_FORM_sec_offset must be used
        instead. If the offset_entry_count is non-zero, then
        DW_FORM_rnglistx may be used to access a range list;"

This fix is for TestTypeCompletion.py category `dwarf` using GCC with DWARF-5.

The fix just provides GetRnglist() lazy getter for `m_rnglist_table`.
The testcase is easier to review by:
        diff -u lldb/test/Shell/SymbolFile/DWARF/DW_AT_low_pc-addrx.s \
          lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s

Differential Revision: https://reviews.llvm.org/D98289
2021-05-19 15:57:40 +02:00
James Henderson a1e6565855 [lit] Stop using PATH to lookup clang/lld/lldb unless requested
This patch stops lit from looking on the PATH for clang, lld and other
users of use_llvm_tool (currently only the debuginfo-tests) unless the
call explicitly requests to opt into using the PATH. When not opting in,
tests will only look in the build directory.

See the mailing list thread starting from
https://lists.llvm.org/pipermail/llvm-dev/2021-May/150421.html.

See the review for details of why decisions were made about when still
to use the PATH.

Reviewed by: thopre

Differential Revision: https://reviews.llvm.org/D102630
2021-05-18 10:43:33 +01:00
Adrian Prantl 017d7a9e14 Rename human-readable name for DW_LANG_Mips_Assembler
The Mips in DW_LANG_Mips_Assembler is a vendor name not an
architecture name and in lack of a proper generic DW_LANG_assembler,
some assemblers emit DWARF using this tag. Due to a warning I recently
introduced users will now be greeted with

  This version of LLDB has no plugin for the mipsassem language. Inspection of frame variables will be limited.

By renaming this to just "Assembler" this error message will make more sense.

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

rdar://77214764
2021-05-12 19:13:58 -07:00
Michał Górny b6c0edb979 [lldb] [Process/elf-core] Fix reading FPRs from FreeBSD/i386 cores
The FreeBSD coredumps from i386 systems contain only FSAVE-style
NT_FPREGSET.  Since we do not really support reading that kind of data
anymore, just use NT_X86_XSTATE to get FXSAVE-style data when available.

Differential Revision: https://reviews.llvm.org/D101086
2021-05-12 11:51:37 +02:00
Jonas Devlieghere 91d3f73937 [lldb] Update register state parsing for JSON crashlogs
- The register encoding state in the JSON crashlog format changes.
   Update the parser accordingly.
 - Print the register state when printing the symbolicated thread.
2021-04-22 16:40:59 -07:00
Jonas Devlieghere a62cbd9a02 [lldb] Include thread name in crashlog.py output
Update the JSON parser to include the thread name in the Thread object.

rdar://76677320
2021-04-22 11:38:53 -07:00
Michał Górny e414ede2cd [lldb] [test/Register] Initial tests for regsets in core dumps
Add initial tests for reading register sets from core dumps.  This
includes a C++ program to write registers and dump core, resulting core
dumps for Linux, FreeBSD and NetBSD, and the tests to verify them.

The tests are split into generic part, verifying user-specified register
values, and coredump-specific tests that verify memory addresses that
differ for every dump.

At this moment, all platforms support GPRs and FPRs up to XMM for amd64
target.  The i386 target does not work on NetBSD at all, and is missing
FPRs entirely on FreeBSD.

Differential Revision: https://reviews.llvm.org/D91963
2021-04-21 19:41:09 +02:00
Pavel Labath cd64273f5e [lldb/ELF] Fix IDs of synthetic eh_frame symbols
The code used the total number of symbols to create a symbol ID for the
synthetic symbols. This is not correct because the IDs of real symbols
can be higher than their total number, as we do not add all symbols (and
in particular, we never add symbol zero, which is not a real symbol).

This meant we could have symbols with duplicate IDs, which caused
problems if some relocations were referring to the duplicated IDs. This
was the cause of the failure of the test D97786.

This patch fixes the code to use the ID of the highest (last) symbol
instead.
2021-04-21 11:24:43 +02:00
Jonas Devlieghere eff4f65afb [lldb] Simplify check for nill value in breakpoint_function_callback.test 2021-04-20 21:53:30 -07:00
Jonas Devlieghere a7712091ea [lldb] Update breakpoint_function_callback.test for different error message
Adjust for the Lua error message printed by Lua 5.4.3.
2021-04-19 12:23:23 -07:00
Caroline Tice 3dc24bc31e [LLDB] Re-land: Use path relative to binary for finding .dwo files.
DWARF allows .dwo file paths to be relative rather than absolute. When
they are relative, DWARF uses DW_AT_comp_dir to find the .dwo
file. DW_AT_comp_dir can also be relative, making the entire search
patch for the .dwo file relative. In this case, LLDB currently
searches relative to its current working directory, i.e. the directory
from which the debugger was launched. This is not right, as the
compiler, which generated the relative paths, can have no idea where
the debugger will be launched. The correct thing is to search relative
to the location of the executable binary. That is what this patch
does.

Differential Revision: https://reviews.llvm.org/D97786
2021-04-16 11:12:39 -07:00
Caroline Tice 042668d092 Revert "[LLDB] Use path relative to binary for finding .dwo files."
This reverts commit b241f3cb29.

Test case is breaking windows builder.
2021-04-15 17:17:44 -07:00
Caroline Tice b241f3cb29 [LLDB] Use path relative to binary for finding .dwo files.
DWARF allows .dwo file paths to be relative rather than absolute. When
they are relative, DWARF uses DW_AT_comp_dir to find the .dwo
file. DW_AT_comp_dir can also be relative, making the entire search
patch for the .dwo file relative. In this case, LLDB currently
searches relative to its current working directory, i.e. the directory
from which the debugger was launched. This is not right, as the
compiler, which generated the relative paths, can have no idea where
the debugger will be launched. The correct thing is to search relative
to the location of the executable binary. That is what this patch
does.

Differential Revision: https://reviews.llvm.org/D97786
2021-04-15 14:43:47 -07:00
David Spickett f152472af5 [lldb] Require x86 for various NativePDB, Breakpad and Minidump tests
These tests fail if you build without the x86 llvm backend.
Either because they use an x86 triple or try to backtrace which
requires some x86 knowledge to see all frames.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D100194
2021-04-13 12:51:48 +00:00
Michał Górny c8d18cba4e Reland "[lldb] [Process] Watch for fork/vfork notifications" for Linux
Big thanks to Pavel Labath for figuring out my mistake.

Differential Revision: https://reviews.llvm.org/D98822
2021-04-13 14:38:31 +02:00
Michał Górny 7da3b44d67 Reland "[lldb] [Process] Watch for fork/vfork notifications" for NetBSD
Differential Revision: https://reviews.llvm.org/D98822
2021-04-13 14:35:44 +02:00