Commit Graph

2323 Commits

Author SHA1 Message Date
Omar Emara 28a76049c6 [LLDB][GUI] Handle return key for compound fields
This patch handles the return key for compound fields like lists and
mapping fields. The return key, if not handled by the field will select
the next primary element, skipping secondary elements like remove
buttons and the like.

Differential Revision: https://reviews.llvm.org/D108331
2021-08-19 11:46:30 -07:00
Omar Emara 82507f1798 [LLDB][GUI] Add Process Launch form
This patch adds a process launch form. Additionally, a LazyBoolean field
was implemented and numerous utility methods were added to various
fields to get the launch form working.

Differential Revision: https://reviews.llvm.org/D107869
2021-08-18 15:43:30 -07:00
Omar Emara 698e210636 [LLDB][GUI] Fix text field incorrect key handling
The isprint libc function was used to determine if the key code
represents a printable character. The problem is that the specification
leaves the behavior undefined if the key is not representable as an
unsigned char, which is the case for many ncurses keys. This patch adds
and explicit check for this undefined behavior and make it consistent.

The llvm::isPrint function didn't work correctly for some reason, most
likely because it takes a char instead of an int, which I guess makes it
unsuitable for checking ncurses key codes.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D108327
2021-08-18 15:06:27 -07:00
Omar Emara b26e1efc42 [LLDB][GUI] Add Breakpoints window
This patch adds a breakpoints window that lists all breakpoints and
breakpoints locations. The window is implemented as a tree, where the
first level is the breakpoints and the second level is breakpoints
locations.

The tree delegate was hardcoded to only draw when there is a process,
which is not necessary for breakpoints, so the relevant logic was
abstracted in the TreeDelegateShouldDraw method.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D107386
2021-08-17 17:38:16 -07:00
Omar Emara 79e950a29e [LLDB][GUI] Refactor form drawing using subsurfaces
This patch adds a new method SubSurface to the Surface class. The method
returns another surface that is a subset of this surface. This is
important to further abstract away drawing from the ncurses objects. For
instance, fields could previously be drawn on subpads only but can now
be drawn on any surface. This is needed to create the file search
dialogs and similar functionalities.

There is an opportunity to refactor window drawing in general using
surfaces, but we shall consider this separately later.

Differential Revision: https://reviews.llvm.org/D107761
2021-08-17 16:54:41 -07:00
Raphael Isemann 3240000546 [lldb][NFC] Remove never read member variable IOHandler::m_editing
The last read access to this variable was removed in 2015 in
4446487d71 .
2021-08-09 18:05:53 +02:00
Michał Górny 14735cab65 [lldb] [gdb-remote] Add eOpenOptionReadWrite for future gdb compat
Modify OpenOptions enum to open the future path into synchronizing
vFile:open bits with GDB.  Currently, LLDB and GDB use different flag
models effectively making it impossible to match bits.  Notably, LLDB
uses two bits to indicate read and write status, and uses union of both
for read/write.  GDB uses a value of 0 for read-only, 1 for write-only
and 2 for read/write.

In order to future-proof the code for the GDB variant:

1. Add a distinct eOpenOptionReadWrite constant to be used instead
   of (eOpenOptionRead | eOpenOptionWrite) when R/W access is required.

2. Rename eOpenOptionRead and eOpenOptionWrite to eOpenOptionReadOnly
   and eOpenOptionWriteOnly respectively, to make it clear that they
   do not mean to be combined and require update to all call sites.

3. Use the intersection of all three flags when matching against
   the three possible values.

This commit does not change the actual bits used by LLDB.

Differential Revision: https://reviews.llvm.org/D106984
2021-08-09 12:06:59 +02:00
Jason Molenda 4d3d182c1d Revert "[LLDB][GUI] Refactor form drawing using subsurfaces"
Temporarily revert this patch to unbreak the bots/builds
until we can understand what was intended; is_pad() call
isn't defined.

This reverts commit 2b89f40a41.
2021-08-05 19:27:55 -07:00
Omar Emara 2b89f40a41 [LLDB][GUI] Refactor form drawing using subsurfaces
This patch adds a new method SubSurface to the Surface class. The method
returns another surface that is a subset of this surface. This is
important to further abstract away drawing from the ncurses objects. For
instance, fields could previously be drawn on subpads only but can now
be drawn on any surface. This is needed to create the file search
dialogs and similar functionalities.

There is an opportunity to refactor window drawing in general using
surfaces, but we shall consider this separately later.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D107182
2021-08-05 16:51:14 -07:00
Jonas Devlieghere c020be17ce [lldb] Use a struct to pass function search options to Module::FindFunction
Rather than passing two booleans around, which is especially error prone
with them being next to each other, use a struct with named fields
instead.

Differential revision: https://reviews.llvm.org/D107295
2021-08-05 10:18:14 -07:00
Muhammad Omair Javaid a94fbb25de Revert "Revert "[LLDB][GUI] Expand selected thread tree item by default""
This reverts commit fd18f0e84c.

I reverted this change to see its effect on failing GUI tests on LLDB
Arm/AArch64 Linux buildbots. I could not find any evidence against this
particular change so reverting it back.

Differential Revision: https://reviews.llvm.org/D100243
2021-08-02 05:29:32 +05:00
Muhammad Omair Javaid fd18f0e84c Revert "[LLDB][GUI] Expand selected thread tree item by default"
This reverts commit fed25ddc1c.

There has been sporadic failures in LLDB AArch64/Arm 32 buildbots since
this commit. I am temporarily reverting it see if it fixes the issue.

Differential Revision: https://reviews.llvm.org/D100243
2021-07-30 13:40:05 +05:00
Alex Langford 993220a99c [lldb] Remove CPlusPlusLanguage from Mangled
The only remaining plugin dependency in Mangled is CPlusPlusLanguage which it
uses to extract information from C++ mangled names. The static function
GetDemangledNameWithoutArguments is written specifically for C++, so it
would make sense for this specific functionality to live in a
C++-related plugin. In order to keep this functionality in Mangled
without maintaining this dependency, I added
`Language::GetDemangledFunctionNameWithoutArguments`.

Differential Revision: https://reviews.llvm.org/D105215
2021-07-29 13:58:35 -07:00
Omar Emara 62bd33158d [LLDB][GUI] Add Environment Variable Field
This patch adds an environment variable field. This is usually used as
the basic type of a List field. This is needed to create the process
launch form.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D106999
2021-07-29 13:28:49 -07:00
Omar Emara 18c25cd376 [LLDB][GUI] Add Create Target form
This patch adds a Create Target form for the LLDB GUI. Additionally, an
Arch Field was introduced to input an arch and the file and directory
fields now have a required property.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D106192
2021-07-29 13:27:53 -07: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
Walter Erquinigo c1b4632528 [trace] Add the definition of a TraceExporter plugin
Copying from the inline documentation:

```
Trace exporter plug-ins operate on traces, converting the trace data provided by an \a lldb_private::TraceCursor into a different format that can be digested by other tools, e.g. Chrome Trace Event Profiler.
Trace exporters are supposed to operate on an architecture-agnostic fashion, as a TraceCursor, which feeds the data, hides the actual trace technology being used.
```

I want to use this to make the code in https://reviews.llvm.org/D105741 a plug-in. I also imagine that there will be more and more exporters being implemented, as an exporter creates something useful out of trace data. And tbh I don't want to keep adding more stuff to the lldb/Target folder.

This is the minimal definition for a TraceExporter plugin. I plan to use this with the following commands:

- thread trace export <plug-in name> [plug-in specific args]
  - This command would support autocompletion of plug-in names
- thread trace export list
  - This command would list the available trace exporter plug-ins

I don't plan to create yet a "process trace export" because it's easier to start analyzing the trace of a given thread than of the entire process. When we need a process-level command, we can implement it.

I also don't plan to force each "export" command implementation to support multiple threads (for example, "thread trace start 1 2 3" or "thread trace start all" operate on many threads simultaneously). The reason is that the format used by the exporter might or might not support multiple threads, so I'm leaving this decision to each trace exporter plug-in.

Differential Revision: https://reviews.llvm.org/D106501
2021-07-26 18:01:50 -07:00
Omar Emara ed5b4dbd39 [LLDB][GUI] Add Arch Field
This patch adds an Arch field that inputs and validates an arch spec.

Differential Revision: https://reviews.llvm.org/D106564
2021-07-26 14:22:25 -07:00
Omar Emara fed25ddc1c [LLDB][GUI] Expand selected thread tree item by default
This patch expands the tree item that corresponds to the selected thread
by default in the Threads window. Additionally, the tree root item is
always expanded, which is the process in the Threads window.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D100243
2021-07-26 14:20:50 -07:00
Omar Emara a98f394e81 [LLDB][GUI] Resolve paths in file/directory fields
This patch resolves the paths in the file/directory fields before
performing checks. Those checks are applied on the file system if
m_need_to_exist is true, so remote files can set this to false to avoid
performing host-side file system checks. Additionally, methods to get
a resolved and a direct file specs were added to be used by client code.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D106553
2021-07-26 11:05:10 -07:00
Omar Emara 80ac12b70b [LLDB][GUI] Check fields validity in actions
This patch adds a virtual method HasError to fields, it can be
overridden by fields that have errors. Additionally, a form method
CheckFieldsValidity was added to be called by actions that expects all
the field to be valid.

Differential Revision: https://reviews.llvm.org/D106459
2021-07-23 18:02:48 -07:00
Omar Emara e160b3987e [LLDB][GUI] Add Platform Plugin Field
This patch adds a new Platform Plugin Field. It is a choices field that
lists all the available platform plugins and can retrieve the name of the
selected plugin. The default selected plugin is the currently selected
one. This patch also allows for arbitrary scrolling to make scrolling
easier when setting choices.

Differential Revision: https://reviews.llvm.org/D106483
2021-07-23 18:00:10 -07:00
Omar Emara 9ef7de7c81 [LLDB][GUI] Add required property to text fields
This patch adds a required property to text fields and their
derivatives. Additionally, the Process Name and PID fields in the attach
form were marked as required.

Differential Revision: https://reviews.llvm.org/D106458
2021-07-21 14:40:43 -07:00
Omar Emara c93dc2597a [LLDB][GUI] Add Process Plugin Field
This patch adds a new Process Plugin Field. It is a choices field that
lists all the available process plugins and can retrieve the name of the
selected plugin or an empty string if the default is selected.

The Attach form now uses that field instead of manually creating a
choices field.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D106467
2021-07-21 14:38:29 -07:00
Omar Emara 0321dbc87e [LLDB][GUI] Add Process Attach form
This patch adds a form window to attach a process, either by PID or by
name. This patch also adds support for dynamic field visibility such
that the form delegate can hide or show certain fields based on some
conditions.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D105655
2021-07-15 15:12:27 -07:00
Jonas Devlieghere de448c0a9e [lldb] Make TargetList iterable (NFC)
Make it possible to iterate over the TargetList.

Differential revision: https://reviews.llvm.org/D105914
2021-07-14 13:35:54 -07:00
Jan Kratochvil 72748488ad [lldb] Fix editline unicode on Linux
Based on:
  [lldb-dev] proposed change to remove conditional WCHAR support in libedit wrapper
  https://lists.llvm.org/pipermail/lldb-dev/2021-July/016961.html

There is already setlocale in lldb/source/Core/IOHandlerCursesGUI.cpp
but that does not apply for Editline GUI editing.

Unaware how to make automated test for this, it requires pty.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D105779
2021-07-13 12:37:53 +02: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
Omar Emara 29cc50e17a [LLDB][GUI] Add initial forms support
This patch adds initial support for forms for the LLDB GUI. The currently
supported form elements are Text fields, Integer fields, Boolean fields, Choices
fields, File fields, Directory fields, and List fields.

A form can be created by subclassing FormDelegate. In the constructor, field
factory methods can be used to add new fields, storing the returned pointer in a
member variable. One or more actions can be added using the AddAction method.
The method takes a function with an interface void(Window &). This function will
be executed whenever the user executes the action.

Example form definition:

```lang=cpp
class TestFormDelegate : public FormDelegate {
public:
  TestFormDelegate() {
    m_text_field = AddTextField("Text", "The big brown fox.");
    m_file_field = AddFileField("File", "/tmp/a");
    m_directory_field = AddDirectoryField("Directory", "/tmp/");
    m_integer_field = AddIntegerField("Number", 5);
    std::vector<std::string> choices;
    choices.push_back(std::string("Choice 1"));
    choices.push_back(std::string("Choice 2"));
    choices.push_back(std::string("Choice 3"));
    choices.push_back(std::string("Choice 4"));
    choices.push_back(std::string("Choice 5"));
    m_choices_field = AddChoicesField("Choices", 3, choices);
    m_bool_field = AddBooleanField("Boolean", true);
    TextFieldDelegate default_field =
        TextFieldDelegate("Text", "The big brown fox.");
    m_text_list_field = AddListField("Text List", default_field);

    AddAction("Submit", [this](Window &window) { Submit(window); });
  }

  void Submit(Window &window) { SetError("An example error."); }

protected:
  TextFieldDelegate *m_text_field;
  FileFieldDelegate *m_file_field;
  DirectoryFieldDelegate *m_directory_field;
  IntegerFieldDelegate *m_integer_field;
  BooleanFieldDelegate *m_bool_field;
  ChoicesFieldDelegate *m_choices_field;
  ListFieldDelegate<TextFieldDelegate> *m_text_list_field;
};
```

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D104395
2021-07-07 17:17:46 +02:00
Jonas Devlieghere fd2433e139 [lldb] Replace default bodies of special member functions with = default;
Replace default bodies of special member functions with = default;

$ run-clang-tidy.py -header-filter='lldb' -checks='-*,modernize-use-equals-default' -fix ,

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html

Differential revision: https://reviews.llvm.org/D104041
2021-07-02 11:31:16 -07:00
Adrian Prantl a0e1b11fac Modernize Module::RemapFile to return an Optional (NFC)
This addresses feedback raised in https://reviews.llvm.org/D104404.

Differential Revision: https://reviews.llvm.org/D104724
2021-06-29 15:19:31 -07:00
Adrian Prantl a346372200 Change PathMappingList::FindFile to return an optional result (NFC)
This is an NFC modernization refactoring that replaces the combination
of a bool return + reference argument, with an Optional return value.

Differential Revision: https://reviews.llvm.org/D104405
2021-06-29 15:10:46 -07:00
Med Ismail Bennani d6b64612bd [lldb/Interpreter] Fix session-save-on-quit when using ^D
Previously, when `interpreter.save-session-on-quit` was enabled, lldb
would save the session transcript only when running the `quit` command.

This patch changes that so the transcripts are saved when the debugger
object is destroyed if the setting is enabled.

rdar://72902650

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-06-29 10:54:29 +02:00
Adrian Prantl 4cf7c6c6a4 Change PathMappingList::RemapPath to return an optional result (NFC)
This is an NFC modernization refactoring that replaces the combination
of a bool return + reference argument, with an Optional return value.

Differential Revision: https://reviews.llvm.org/D104404
2021-06-25 14:15:29 -07:00
Alexander Mols 0a2d4f3f24 [lldb] Enable Rust v0 symbol demangling
Rust's v0 name mangling scheme [1] is easy to disambiguate from other
name mangling schemes because symbols always start with `_R`. The llvm
Demangle library supports demangling the Rust v0 scheme. Use it to
demangle Rust symbols.

Added unit tests that check simple symbols. Ran LLDB built with this
patch to debug some Rust programs compiled with the v0 name mangling
scheme. Confirmed symbol names were demangled as expected.

Note: enabling the new name mangling scheme requires a nightly
toolchain:

```
$ cat main.rs
fn main() {
    println!("Hello world!");
}
$ $(rustup which --toolchain nightly rustc) -Z symbol-mangling-version=v0 main.rs -g
$ /home/asm/hacking/llvm/build/bin/lldb ./main --one-line 'b main.rs:2'
(lldb) target create "./main"
Current executable set to '/home/asm/hacking/llvm/rust/main' (x86_64).
(lldb) b main.rs:2
Breakpoint 1: where = main`main::main + 4 at main.rs:2:5, address = 0x00000000000076a4
(lldb) r
Process 948449 launched: '/home/asm/hacking/llvm/rust/main' (x86_64)
warning: (x86_64) /lib64/libgcc_s.so.1 No LZMA support found for reading .gnu_debugdata section
Process 948449 stopped
* thread #1, name = 'main', stop reason = breakpoint 1.1
    frame #0: 0x000055555555b6a4 main`main::main at main.rs:2:5
   1    fn main() {
-> 2        println!("Hello world!");
   3    }
(lldb) bt
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x7, bit_size = 0
* thread #1, name = 'main', stop reason = breakpoint 1.1
  * frame #0: 0x000055555555b6a4 main`main::main at main.rs:2:5
    frame #1: 0x000055555555b78b main`<fn() as core::ops::function::FnOnce<()>>::call_once((null)=(main`main::main at main.rs:1), (null)=<unavailable>) at function.rs:227:5
    frame #2: 0x000055555555b66e main`std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>(f=(main`main::main at main.rs:1)) at backtrace.rs:125:18
    frame #3: 0x000055555555b851 main`std::rt::lang_start::<()>::{closure#0} at rt.rs:49:18
    frame #4: 0x000055555556c9f9 main`std::rt::lang_start_internal::hc51399759a90501a [inlined] core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h04259e4a34d07c2f at function.rs:259:13
    frame #5: 0x000055555556c9f2 main`std::rt::lang_start_internal::hc51399759a90501a [inlined] std::panicking::try::do_call::hb8da45704d5cfbbf at panicking.rs:401:40
    frame #6: 0x000055555556c9f2 main`std::rt::lang_start_internal::hc51399759a90501a [inlined] std::panicking::try::h4beadc19a78fec52 at panicking.rs:365:19
    frame #7: 0x000055555556c9f2 main`std::rt::lang_start_internal::hc51399759a90501a [inlined] std::panic::catch_unwind::hc58016cd36ba81a4 at panic.rs:433:14
    frame #8: 0x000055555556c9f2 main`std::rt::lang_start_internal::hc51399759a90501a at rt.rs:34:21
    frame #9: 0x000055555555b830 main`std::rt::lang_start::<()>(main=(main`main::main at main.rs:1), argc=1, argv=0x00007fffffffcb18) at rt.rs:48:5
    frame #10: 0x000055555555b6fc main`main + 28
    frame #11: 0x00007ffff73f2493 libc.so.6`__libc_start_main + 243
    frame #12: 0x000055555555b59e main`_start + 46
(lldb)
```

[1]: https://github.com/rust-lang/rust/issues/60705

Reviewed By: clayborg, teemperor

Differential Revision: https://reviews.llvm.org/D104054
2021-06-21 18:20:15 +02:00
Jason Molenda 9ea6dd5cfa Add a corefile style option to process save-core; skinny corefiles
Add a new feature to process save-core on Darwin systems -- for
lldb to create a user process corefile with only the dirty (modified
memory) pages included.  All of the binaries that were used in the
corefile are assumed to still exist on the system for the duration
of the use of the corefile.  A new --style option to process save-core
is added, so a full corefile can be requested if portability across
systems, or across time, is needed for this corefile.

debugserver can now identify the dirty pages in a memory region
when queried with qMemoryRegionInfo, and the size of vm pages is
given in qHostInfo.

Create a new "all image infos" LC_NOTE for Mach-O which allows us
to describe all of the binaries that were loaded in the process --
load address, UUID, file path, segment load addresses, and optionally
whether code from the binary was executing on any thread.  The old
"read dyld_all_image_infos and then the in-memory Mach-O load
commands to get segment load addresses" no longer works when we
only have dirty memory.

rdar://69670807
Differential Revision: https://reviews.llvm.org/D88387
2021-06-20 12:26:54 -07:00
Raphael Isemann 3b7795aece [lldb] vwprintw -> vw_printw in IOHandlerCursesGUI
`vwprintw` is (in theory) using the `arargs.h` va_list while `vw_printw` is
using the `stdarg.h` va_list. It seems these days they can be used
interchangeably but `vwprintw` is marked as deprecated.
2021-06-16 13:14:08 +02:00
Jim Ingham cfb96d845a Convert functions that were returning BreakpointOption * to BreakpointOption &.
This is an NFC cleanup.

Many of the API's that returned BreakpointOptions always returned valid ones.
Internally the BreakpointLocations usually have null BreakpointOptions, since they
use their owner's options until an option is set specifically on the location.
So the original code used pointers & unique_ptr everywhere for consistency.
But that made the code hard to reason about from the outside.

This patch changes the code so that everywhere an API is guaranteed to
return a non-null BreakpointOption, it returns it as a reference to make
that clear.

It also changes the Breakpoint to hold a BreakpointOption
member where it previously had a UP.  Since we were always filling the UP
in the Breakpoint constructor, having the UP wasn't helping anything.

Differential Revision: https://reviews.llvm.org/D104162
2021-06-15 14:34:02 -07:00
Simon Pilgrim 307cfad0d6 Fix extraneous ')' error. 2021-06-11 14:50:22 +01:00
Simon Pilgrim cd2e500e55 [lldb] DumpDataExtractor.cpp - replace APInt::toString() with llvm::toString(APInt)
APInt::toString() was removed rG61cdaf66fe22be2b5942ddee4f46a998b4f3ee29
2021-06-11 13:39:14 +01:00
Jonas Devlieghere 9494c510af [lldb] Use C++11 default member initializers
This converts a default constructor's member initializers into C++11
default member initializers. This patch was automatically generated with
clang-tidy and the modernize-use-default-member-init check.

$ run-clang-tidy.py -header-filter='lldb' -checks='-*,modernize-use-default-member-init' -fix

This is a mass-refactoring patch and this commit will be added to
.git-blame-ignore-revs.

Differential revision: https://reviews.llvm.org/D103483
2021-06-09 09:43:13 -07:00
Greg Clayton b0572abf72 Improve performance when parsing symbol tables in mach-o files.
Some larger projects were loading quite slowly with the current LLDB on macOS and macOS simulator builds. I did some instrument traces and found 3 main culprits:
- a LLDB timer that was put into a function that was called too often
- a std::set that was keeping track of the address of symbols that were already added
- a unnamed function generator in ObjectFile that was going slow due to allocations

In order to see this in action I ran the latest LLDB on a large application with many frameworks using the following method:

(lldb) script import time; start_time = time.perf_counter()
(lldb) file Large.app
(lldb) script print(time.perf_counter() - start_time)

I first range "sudo purge" to clear the system file caches to simulate a cold startup of the debugger, followed by two iterations with warm file caches.

Prior to this fix I was seeing the following timings:

17.68 (cold)
14.56 (warm 1)
14.52 (warm 2)

After this fix I was seeing:

11.32 (cold)
8.43 (warm 1)
8.49 (warm 2)

Differential Revision: https://reviews.llvm.org/D103504
2021-06-02 10:31:37 -07:00
Raphael Isemann ecfca427f9 [lldb][NFC] Use Language plugins in Mangled::GuessLanguage
This removes the direct dependency to the ObjC and C++ plugins.

Reviewed By: bulbazord

Differential Revision: https://reviews.llvm.org/D103158
2021-06-01 18:02:07 +02:00
Bruce Mitchener 36597e4719 [lldb] Fix typos. NFC.
Differential Revision: https://reviews.llvm.org/D103381
2021-05-31 06:48:57 +07:00
Raphael Isemann d28bc54ff4 [lldb] Remove cache in get_demangled_name_without_arguments
This function has a single-value caching based on function local static variables.

This causes two problems:

* There is no synchronization, so this function randomly returns the demangled
  name of other functions that are demangled at the same time.
* The 1-element cache is not very effective (the cache rate is around 0% when
  running the LLDB test suite that calls this function around 30k times).

I would propose just removing it.

To prevent anyone else the git archeology: the static result variables were
originally added as this returned a ConstString reference, but that has since
been changed so that this returns by value.

Reviewed By: #lldb, JDevlieghere, shafik

Differential Revision: https://reviews.llvm.org/D103107
2021-05-26 18:27:40 +02:00
Raphael Isemann 76e47d4887 [lldb][NFC] Use C++ versions of the deprecated C standard library headers
The C headers are deprecated so as requested in D102845, this is replacing them
all with their (not deprecated) C++ equivalent.

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D103084
2021-05-26 12:46:12 +02:00
Raphael Isemann ae58cf5f45 [lldb] Fix that LLDB doesn't print NaN's sign on Darwin
It seems std::ostringstream ignores NaN signs on Darwin while it prints them on
Linux. This causes that LLDB behaves differently on those platforms which is
both confusing for users and it also means we have to deal with that in our
tests.

This patch manually implements the NaN/Inf printing (which are apparently
implementation defined) to make LLDB print the same thing on all platforms. The
only output difference in practice seems to be that we now print negative NaNs
as `-nan`, but this potentially also changes the output on other systems I
haven't tested this on.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D102845
2021-05-25 13:33:28 +02:00
Raphael Isemann 42a9c0c80c [lldb] Reland "Fix UB in half2float" to fix the ubsan bot.
This relands part of the UB fix in 4b074b49be.
The original commit also added some additional tests that uncovered some
other issues (see D102845). I landed all the passing tests in
48780527dd and this patch is now just fixing
the UB in half2float. See D102846 for a proposed rewrite of the function.

Original commit message:

  The added DumpDataExtractorTest uncovered that this is lshifting a negative
  integer which upsets ubsan and breaks the sanitizer bot. This patch just
  changes the variable we shift to be unsigned.
2021-05-24 15:23:32 +02:00
Raphael Isemann 30a5ddaef3 Revert "[lldb] Fix UB in half2float and add some more tests."
This reverts commit 4b074b49be.

Some of the new tests are failing on Debian.
2021-05-19 22:06:53 +02:00