Commit Graph

24907 Commits

Author SHA1 Message Date
Walter Erquinigo d52ba48821 [trace] Introduce Hierarchical Trace Representation (HTR) and add command for Intel PT trace visualization
This diff introduces Hierarchical Trace Representation (HTR) and creates the `thread trace export ctf  -f <filename> -t <thread_id>` command to export an Intel PT trace's HTR to Chrome Trace Format (CTF) for visualization.

See `lldb/docs/htr.rst` for context/documentation on HTR.

**Overview of Changes**
    - Add HTR documentation (see `lldb/docs/htr.rst`)
    - Add HTR structures (layer, block, block metadata)
    - Implement "Basic Super Block" HTR pass
    - Add 'thread trace export ctf' command to export the HTR of an Intel PT
      trace to Chrome Trace Format (CTF)

As this diff is the first iteration of HTR and trace visualization, future diffs will build on this work by generalizing the internal design of HTR and implementing new HTR passes that provide better trace summarization/visualization.

See attached video for an example of Intel PT trace visualization:
{F17851042}

Original Author: jj10306

Submitted by: wallace

Reviewed By: wallace, clayborg

Differential Revision: https://reviews.llvm.org/D105741
2021-07-28 13:56:45 -07:00
Muhammad Omair Javaid 4b88a94ebe Revert "[trace] Introduce Hierarchical Trace Representation (HTR) and add command for Intel PT trace visualization"
This reverts commit aad17c55a8.

Breaks LLDB build on 32 bit Arm/Linux bot:
https://lab.llvm.org/buildbot/#/builders/17/builds/9497

Differential Revision: https://reviews.llvm.org/D105741
2021-07-29 01:34:24 +05:00
Walter Erquinigo aad17c55a8 [trace] Introduce Hierarchical Trace Representation (HTR) and add command for Intel PT trace visualization
This diff introduces Hierarchical Trace Representation (HTR) and creates the `thread trace export ctf  -f <filename> -t <thread_id>` command to export an Intel PT trace's HTR to Chrome Trace Format (CTF) for visualization.

See `lldb/docs/htr.rst` for context/documentation on HTR.

**Overview of Changes**
    - Add HTR documentation (see `lldb/docs/htr.rst`)
    - Add HTR structures (layer, block, block metadata)
    - Implement "Basic Super Block" HTR pass
    - Add 'thread trace export ctf' command to export the HTR of an Intel PT
      trace to Chrome Trace Format (CTF)

As this diff is the first iteration of HTR and trace visualization, future diffs will build on this work by generalizing the internal design of HTR and implementing new HTR passes that provide better trace summarization/visualization.

See attached video for an example of Intel PT trace visualization:
{F17851042}

Original Author: jj10306

Submitted by: wallace

Reviewed By: wallace, clayborg

Differential Revision: https://reviews.llvm.org/D105741
2021-07-28 11:04:13 -07:00
Raphael Isemann 83c752bfa6 Revert "[lldb] Temporarily bump the max length of the pexpect error message to diagnose an lldb-aarch64 test failure"
This reverts commit 5db8e23212. The test has
been disabled since then on the bot and we got the logs we wanted.
2021-07-28 18:11:52 +02:00
David Spickett 6eded00e0c [lldb] Add "memory tag write" --end-addr option
The default mode of "memory tag write" is to calculate the
range from the start address and the number of tags given.
(just like "memory write" does)

(lldb) memory tag write mte_buf 1 2
(lldb) memory tag read mte_buf mte_buf+48
Logical tag: 0x0
Allocation tags:
[0xfffff7ff9000, 0xfffff7ff9010): 0x1
[0xfffff7ff9010, 0xfffff7ff9020): 0x2
[0xfffff7ff9020, 0xfffff7ff9030): 0x0

This new option allows you to set an end address and have
the tags repeat until that point.

(lldb) memory tag write mte_buf 1 2 --end-addr mte_buf+64
(lldb) memory tag read mte_buf mte_buf+80
Logical tag: 0x0
Allocation tags:
[0xfffff7ff9000, 0xfffff7ff9010): 0x1
[0xfffff7ff9010, 0xfffff7ff9020): 0x2
[0xfffff7ff9020, 0xfffff7ff9030): 0x1
[0xfffff7ff9030, 0xfffff7ff9040): 0x2
[0xfffff7ff9040, 0xfffff7ff9050): 0x0

This is implemented using the QMemTags packet previously
added. We skip validating the number of tags in lldb and send
them on to lldb-server, which repeats them as needed.

Apart from the number of tags, all the other client side checks
remain. Tag values, memory range must be tagged, etc.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D105183
2021-07-28 14:05:40 +01:00
Muhammad Omair Javaid 0dc9c88aa3 [LLDB] Skip TestGuiBasicDebug.py on Arm/AArch64 Linux
TestGuiBasicDebug.py randomly fails due to timeouts sending out false
negatives on LLDB Arm and AArch64 Linux buildbots. I havnt found a
reliable wayy to set pexpect timeout for this test to pass regularly.

Skipping it on Arm and AArch64 Linux to silence buildbot failures.
2021-07-28 15:30:48 +05:00
Muhammad Omair Javaid 30308d1eb9 [LLDB] Skip HW breakpoints test_step_until on Arm/Linux
test_step_until xpasses on some machines while fails on others.
Marking it as skipped for now.
2021-07-28 15:30:47 +05:00
Raphael Isemann 5db8e23212 [lldb] Temporarily bump the max length of the pexpect error message to diagnose an lldb-aarch64 test failure
This is only temporarily to gather some logs before this gets reverted. See
D106873 for a discussion about how/if we can make this change permanent.
2021-07-28 11:47:54 +02:00
David Spickett 6a7a2ee816 [lldb] Add "memory tag write" command
This adds a new command for writing memory tags.
It is based on the existing "memory write" command.

Syntax: memory tag write <address-expression> <value> [<value> [...]]
(where "value" is a tag value)

(lldb) memory tag write mte_buf 1 2
(lldb) memory tag read mte_buf mte_buf+32
Logical tag: 0x0
Allocation tags:
[0xfffff7ff9000, 0xfffff7ff9010): 0x1
[0xfffff7ff9010, 0xfffff7ff9020): 0x2

The range you are writing to will be calculated by
aligning the address down to a granule boundary then
adding as many granules as there are tags.

(a repeating mode with an end address will be in a follow
up patch)

This is why "memory tag write" uses MakeTaggedRange but has
some extra steps to get this specific behaviour.

The command does all the usual argument validation:
* Address must evaluate
* You must supply at least one tag value
  (though lldb-server would just treat that as a nop anyway)
* Those tag values must be valid for your tagging scheme
  (e.g. for MTE the value must be > 0 and < 0xf)
* The calculated range must be memory tagged

That last error will show you the final range, not just
the start address you gave the command.

(lldb) memory tag write mte_buf_2+page_size-16 6
(lldb) memory tag write mte_buf_2+page_size-16 6 7
error: Address range 0xfffff7ffaff0:0xfffff7ffb010 is not in a memory tagged region

(note that we do not check if the region is writeable
since lldb can write to it anyway)

The read and write tag tests have been merged into
a single set of "tag access" tests as their test programs would
have been almost identical.
(also I have renamed some of the buffers to better
show what each one is used for)

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D105182
2021-07-28 10:12:50 +01:00
Muhammad Omair Javaid 6cd0e35f43 Revert "[LLDB] Skip HW breakpoints test_step_until on Arm/Linux"
This reverts commit ab5b8ee1a7.

This caused some failure on buildbots so reverting it for now.
2021-07-28 13:26:06 +05:00
Muhammad Omair Javaid ab5b8ee1a7 [LLDB] Skip HW breakpoints test_step_until on Arm/Linux
test_step_until xpasses on some machines while fails on others. I am
marking it as skipped for now.
2021-07-28 13:18:14 +05:00
Jim Ingham 3c45476923 Fix a thinko in the parsing of substitutions in CommandObjectRegexCommand.
The old code incorrectly calculated the start position for the search
for the third (and subsequent) instance of a particular substitution
pattern (e.g. %1).

I also added a few test cases for this parsing covering this failure.
2021-07-27 18:58:56 -07: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
Alex Langford 0a74fbb7b1 [lldb][NFC] Fix incorrect log and comment
Likely copy & paste issue that was overlooked years ago
2021-07-27 14:43:42 -07:00
Jim Ingham 69529286ce Add a test for top-level expressions using "expr --top-level".
This was broken for a while even though the Python version
continued to work.  This adds a test so it doesn't regress.
2021-07-27 13:38:09 -07:00
Jim Ingham 910353c104 When calculating the "currently selected thread" in
Process::HandleStateChangedEvent, we check whether a thread stopped
for eStopReasonSignal is stopped for a signal that's currently set to
"no-stop". If it is, then we don't set that thread as the currently
selected thread.

But that only happens in the part of the algorithm that's handling the
case where the previously selected thread has no stop reason. Since we
want to keep on a thread as long as it is doing something interesting,
we always prefer the current thread. That's almost right, but we
forgot to check whether the previously selected thread stopped with an
eStopReasonSignal for a "no-stop" signal. If it did, then we shouldn't
select it.

This patch adds that check. I can't figure out a good way to test
this. This is the sort of thing that Ismail's scripted process plugin
will make easy once it is a real boy. But figuring out how to do this
in a real process is not trivial.

Differential Revision: https://reviews.llvm.org/D106712
2021-07-27 13:38:09 -07:00
Jim Ingham 0018c7123b Fix "break delete --disabled" with no arguments.
The code that figured out which breakpoints to delete was supposed
to set the result status if it found breakpoints, and then the code
that actually deleted them checked that the result's status was set.

The code for "break delete --disabled" failed to set the status if
no "protected" breakpoints were provided.  This was a confusing way
to implement this, so I reworked it with early returns so it was less
error prone, and added a test case for the no arguments case.

Differential Revision: https://reviews.llvm.org/D106623
2021-07-27 13:38:09 -07:00
David Spickett 5ea091a817 [lldb][AArch64] Add memory tag writing to lldb
This adds memory tag writing to Process and the
GDB remote code. Supporting work for the
"memory tag write" command. (to follow)

Process WriteMemoryTags is similair to ReadMemoryTags.
It will pack the tags then call DoWriteMemoryTags.
That function will send the QMemTags packet to the gdb-remote.

The QMemTags packet follows the GDB specification in:
https://sourceware.org/gdb/current/onlinedocs/gdb/General-Query-Packets.html#General-Query-Packets

Note that lldb-server will be treating partial writes as
complete failures. So lldb doesn't need to handle the partial
write case in any special way.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D105181
2021-07-27 15:18:42 +01:00
Raphael Isemann 43e45f0ec9 [lldb] Wait in TestGuiBasicDebug for the interface to open before quitting the welcome screen
Speculative fix for the failing lldb-aarch64-ubuntu bot.
2021-07-27 13:58:49 +02:00
David Spickett 7d27230de3 [lldb][AArch64] Add memory tag writing to lldb-server
This is implemented using the QMemTags packet, as specified
by GDB in:
https://sourceware.org/gdb/current/onlinedocs/gdb/General-Query-Packets.html#General-Query-Packets

(recall that qMemTags was previously added to read tags)

On receipt of a valid packet lldb-server will:
* align the given address and length to granules
  (most of the time lldb will have already done this
  but the specification doesn't guarantee it)
* Repeat the supplied tags as many times as needed to cover
  the range. (if tags > range we just use as many as needed)
* Call ptrace POKEMTETAGS to write the tags.

The ptrace step will loop just like the tag read does,
until all tags are written or we get an error.
Meaning that if ptrace succeeds it could be a partial write.
So we call it again and if we then get an error, return an error to
lldb.

We are not going to attempt to restore tags after a partial
write followed by an error. This matches the behaviour of the
existing memory writes.

The lldb-server tests have been extended to include read and
write in the same test file. With some updated function names
since "qMemTags" vs "QMemTags" isn't very clear when they're
next to each other.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D105180
2021-07-27 12:02:17 +01: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
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
Michał Górny 3c3269559b [lldb] [gdb-remote client] Avoid zero padding PID/TID in H packet
Change SetCurrentThread*() logic not to include the zero padding
in PID/TID that was a side effect of 02ef0f5ab4.  This should fix
problems caused by sending 64-bit integers to 32-bit servers.  Reported
by Ted Woodward.

Differential Revision: https://reviews.llvm.org/D106832
2021-07-27 00:44:43 +02: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
Alex Langford e42edce4a3 [lldb][NFC] Delete unused and commented out DWARF constants
I cannot find any users of these anywhere and they have been commented out
for years.
2021-07-26 12:26:35 -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
Fangrui Song b71b25008f [test] Fix PayloadString: in lldb tests 2021-07-26 10:00:05 -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
Walter Erquinigo ef8c6849a2 [source maps] fix source mapping when there are multiple matching rules
D104406 introduced an error in which, if there are multiple matchings rules for a given path, lldb was only checking for the validity in the filesystem of the first match instead of looking exhaustively one by one until a valid file is found.

Besides that, a call to consume_front was being done incorrectly, as it was modifying the input, which renders subsequent matches incorrect.

I added a test that checks for both cases.

Differential Revision: https://reviews.llvm.org/D106723
2021-07-23 17:53:12 -07:00
Jim Ingham bcce8e0fcc Fix the logic so stop-hooks get run after a breakpoint that ran an expression
Code was added to Target::RunStopHook to make sure that we don't run stop hooks when
you stop after an expression evaluation. But the way it was done was to check that we
hadn't run an expression since the last natural stop. That failed in the case where you
stopped for a breakpoint which had run an expression, because the stop-hooks get run
after the breakpoint actions, and so by the time we got to running the stop-hooks,
we had already run a user expression.

I fixed this by adding a target ivar tracking the last natural stop ID at which we had
run a stop-hook. Then we keep track of this and make sure we run the stop-hooks only
once per natural stop.

Differential Revision: https://reviews.llvm.org/D106514
2021-07-22 15:06:41 -07:00
Med Ismail Bennani 254c4d174e
[lldb] Fix build failure introduced by 3d4cadfb26
This patch updates the `ScriptedProcess::GetGenericInteger` return type
to `llvm::Optional<unsigned long long>` to match implementation.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-07-22 20:54:27 +00:00
Med Ismail Bennani 3d4cadfb26 [lldb/Interpreter] Conform ScriptedProcessPythonInterface to SWIG python types
This patch should address the compiler warnings due to mismatch type
comparaison.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-07-22 22:48:15 +02:00
Raphael Isemann 3d9a9fa691 [lldb] Remove a wrong assert in TestStructTypes that checks that empty structs in C always have size 0
D105471 fixes the way we assign sizes to empty structs in C mode. Instead of
just giving them a size 0, we instead use the size we get from DWARF if possible.

After landing D105471 the TestStructTypes test started failing on Windows. The
tests checked that the size of an empty C struct is 0 while the size LLDB now
reports is 4 bytes. It turns out that 4 bytes are the actual size Clang is using
for C structs with the MicrosoftRecordLayoutBuilder. The commit that introduced
that behaviour is 00a061dccc.

This patch removes that specific check from TestStructTypes. Note that D105471
added a series of tests that already cover this case (and the added checks
automatically adjust to whatever size the target compiler chooses for empty
structs).
2021-07-22 16:56:50 +02:00
Raphael Isemann eb61ffbcb2 [lldb] Fix TestCompletion by using SIGPIPE instead of SIGINT as test signal
The test I added in commit 078003482e was using
SIGINT for testing the tab completion. The idea is to have a signal that only
has one possible completion and I ended up picking SIGIN -> SIGINT for the test.
However on non-Linux systems there is SIGINFO which is a valid completion for
`SIGIN' and so the test fails there.

This replaces SIGIN -> SIGINT with SIGPIP -> SIGPIPE completion which according
to LLDB's signal list in Host.cpp is the only valid completion.
2021-07-22 15:35:28 +02:00
Raphael Isemann 77440d644b [lldb][NFC] Allow range-based for loops over DWARFDIE's children
This patch adds the ability to get a DWARFDIE's children as an LLVM range.

This way we can use for range loops to iterate over them and we can use LLVM's
algorithms like `llvm::all_of` to query all children.

The implementation has to do some small shenanigans as the iterator needs to
store a DWARFDIE, but a DWARFDIE container is also a DWARFDIE so it can't return
the iterator by value. I just made the `children` getter a templated function to
avoid the cyclic dependency.

Reviewed By: #lldb, werat, JDevlieghere

Differential Revision: https://reviews.llvm.org/D103172
2021-07-22 15:03:30 +02:00
Med Ismail Bennani 312b43da05 [lldb/Plugins] Add ScriptedProcess Process Plugin
This patch introduces Scripted Processes to lldb.

The goal, here, is to be able to attach in the debugger to fake processes
that are backed by script files (in Python, Lua, Swift, etc ...) and
inspect them statically.

Scripted Processes can be used in cooperative multithreading environments
like the XNU Kernel or other real-time operating systems, but it can
also help us improve the debugger testing infrastructure by writting
synthetic tests that simulates hard-to-reproduce process/thread states.

Although ScriptedProcess is not feature-complete at the moment, it has
basic execution capabilities and will improve in the following patches.

rdar://65508855

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-07-22 14:47:33 +02:00
Raphael Isemann 078003482e [lldb] Fix that `process signal` completion always returns all signals
`CompletionRequest::AddCompletion` adds the given string as completion of the
current command token. `CompletionRequest::TryCompleteCurrentArg` only adds it
if the current token is a prefix of the given string. We're using
`AddCompletion` for the `process signal` handler which means that `process
signal SIGIN` doesn't get uniquely completed to `process signal SIGINT` as we
unconditionally add all other signals (such as `SIGABRT`) as possible
completions.

By using `TryCompleteCurrentArg` we actually do the proper filtering which will
only add `SIGINT` (as that's the only signal with the prefix 'SIGIN' in the
example above).

Reviewed By: mib

Differential Revision: https://reviews.llvm.org/D105028
2021-07-22 13:51:21 +02:00
Raphael Isemann 12a89e14b8 [lldb][NFCI] Remove redundant accessibility heuristic in the DWARF parser
LLDB's DWARF parser has some heuristics for guessing and fixing up the
accessibility of C++ class/struct members after they were already created in the
internal Clang AST. The heuristic is that if a struct/class has a base class,
then it's actually a class and it's members are private unless otherwise
specified.

From what I can see this heuristic isn't sound and also unnecessary. The idea
that inheritance implies that the `class` keyword was used and the default
visibility is `private` is incorrect. Also both GCC and Clang use
`DW_TAG_structure_type` and `DW_TAG_class_type` for `struct` and `class` types
respectively, so the default visibility we infer from that information is always
correct and there is no need to fix it up.

And finally, the access specifiers we set in the Clang AST are anyway unused
within LLDB. The expression parser explicitly ignores them to give users access
to private members and there is not SBAPI functionality that exposes this
information.

This patch removes all the heuristic code for the reasons above and instead
just relies on the access values we infer from the tag kind and explicit
annotations in DWARF.

This patch is NFCI.

Reviewed By: werat

Differential Revision: https://reviews.llvm.org/D105463
2021-07-22 13:36:23 +02:00
Raphael Isemann 67c588c481 [lldb] Generalize empty record size computation to avoid giving empty C++ structs a size of 0
C doesn't allow empty structs but Clang/GCC support them and give them a size of 0.

LLDB implements this by checking the tag kind and if it's `DW_TAG_structure_type` then
we give it a size of 0 via an empty external RecordLayout. This is done because our
internal TypeSystem is always in C++ mode (which means we would give them a size
of 1).

The current check for when we have this special case is currently too lax as types with
`DW_TAG_structure_type` can also occur in C++ with types defined using the `struct`
keyword. This means that in a C++ program with `struct Empty{};`, LLDB would return
`0` for `sizeof(Empty)` even though the correct size is 1.

This patch removes this special case and replaces it with a generic approach that just
assigns empty structs the byte_size as specified in DWARF. The GCC/Clang special
case is handles as they both emit an explicit `DW_AT_byte_size` of 0. And if another
compiler decides to use a different byte size for this case then this should also be
handled by the same code as long as that information is provided via `DW_AT_byte_size`.

Reviewed By: werat, shafik

Differential Revision: https://reviews.llvm.org/D105471
2021-07-22 13:30:48 +02:00
Jason Molenda cdc6f8d728 Read and write a LC_NOTE "addrable bits" for addressing mask
This patch adds code to process save-core for Mach-O files which
embeds an "addrable bits" LC_NOTE when the process is using a
code address mask (e.g. AArch64 v8.3 with ptrauth aka arm64e).
Add code to ObjectFileMachO to read that LC_NOTE from corefiles,
and ProcessMachCore to set the process masks based on it when reading
a corefile back in.

Also have "process status --verbose" print the current address masks
that lldb is using internally to strip ptrauth bits off of addresses.

Differential Revision: https://reviews.llvm.org/D106348
rdar://68630113
2021-07-22 01:06:44 -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
Walter Erquinigo 29af527c86 [intel pt] fix builds
https://reviews.llvm.org/D105649 broke intel pt builds. Fortunately the
fix is super easy.
2021-07-21 14:10:09 -07:00
Alex Langford 8e6b31c395 [LLDB] Move Trace-specific classes into separate library
These two classes, TraceSessionFileParser and ThreadPostMortemTrace,
seem to be useful primarily for tracing. Currently it looks like
intel-pt is the sole user of these, but that other tracing plugins could
be written in the future that take advantage of these. Unfortunately
with them in Target, there is a dependency on PluginProcessUtility. I'd
like to sever that dependency, so I moved them into a `TraceCommon`
plugin.

Differential Revision: https://reviews.llvm.org/D105649
2021-07-21 13:28:34 -07:00
Walter Erquinigo 345ace026b [trace] [intel pt] Create a "thread trace dump stats" command
When the user types that command 'thread trace dump info' and there's a running Trace session in LLDB, a raw trace in bytes should be printed; the command 'thread trace dump info all' should print the info for all the threads.

Original Author: hanbingwang

Reviewed By: clayborg, wallace

Differential Revision: https://reviews.llvm.org/D105717
2021-07-21 09:50:15 -07:00
Jan Kratochvil 278df28557 [nfc] [lldb] Rename GetRnglist() to GetRnglistTable()
My D99653 implemented a getter GetRnglist() for m_rnglist_table.

That was confusing as the getter returns DWARFDebugRnglistTable which
contains DWARFDebugRnglist as its elements.
2021-07-21 10:45:37 +02:00
Walter Erquinigo 04195843ef [intel pt] Add TSC timestamps
Differential Revision: https://reviews.llvm.org/D106328
2021-07-20 16:29:17 -07:00
Benjamin Kramer aa09d1f9c9 [lldb] Remove unused variable. NFCI 2021-07-20 10:34:05 +02:00