[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 08:23:27 +01:00
|
|
|
//===-- CommandObjectFrame.cpp --------------------------------------------===//
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2016-02-19 19:33:46 +00:00
|
|
|
#include "CommandObjectFrame.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2010-09-02 00:18:39 +00:00
|
|
|
#include "lldb/Core/ValueObject.h"
|
2013-01-28 23:47:25 +00:00
|
|
|
#include "lldb/DataFormatters/DataVisualization.h"
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
#include "lldb/DataFormatters/ValueObjectPrinter.h"
|
2019-12-10 08:54:30 -08:00
|
|
|
#include "lldb/Host/Config.h"
|
2017-03-22 23:33:16 +00:00
|
|
|
#include "lldb/Host/OptionParser.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
2022-07-13 20:11:37 -07:00
|
|
|
#include "lldb/Interpreter/CommandOptionArgumentTable.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
2021-08-29 17:26:15 +02:00
|
|
|
#include "lldb/Interpreter/OptionArgParser.h"
|
2011-10-25 06:44:01 +00:00
|
|
|
#include "lldb/Interpreter/OptionGroupFormat.h"
|
2011-05-04 03:43:18 +00:00
|
|
|
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
|
2011-07-07 04:38:25 +00:00
|
|
|
#include "lldb/Interpreter/OptionGroupVariable.h"
|
2015-08-11 22:53:00 +00:00
|
|
|
#include "lldb/Interpreter/Options.h"
|
2015-09-30 23:12:22 +00:00
|
|
|
#include "lldb/Symbol/Function.h"
|
2010-09-02 00:18:39 +00:00
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
|
|
|
|
#include "lldb/Symbol/Variable.h"
|
|
|
|
|
#include "lldb/Symbol/VariableList.h"
|
2013-11-04 09:33:30 +00:00
|
|
|
#include "lldb/Target/StackFrame.h"
|
2018-10-31 04:00:22 +00:00
|
|
|
#include "lldb/Target/StackFrameRecognizer.h"
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
#include "lldb/Target/StopInfo.h"
|
2010-09-02 00:18:39 +00:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Target/Thread.h"
|
2018-04-17 18:53:35 +00:00
|
|
|
#include "lldb/Utility/Args.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-02-11 23:13:08 +00:00
|
|
|
#include <memory>
|
2023-01-07 13:43:00 -08:00
|
|
|
#include <optional>
|
2019-02-11 23:13:08 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
#pragma mark CommandObjectFrameDiagnose
|
|
|
|
|
|
|
|
|
|
// CommandObjectFrameInfo
|
|
|
|
|
|
|
|
|
|
// CommandObjectFrameDiagnose
|
|
|
|
|
|
2019-07-25 11:22:46 +00:00
|
|
|
#define LLDB_OPTIONS_frame_diag
|
|
|
|
|
#include "CommandOptions.inc"
|
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-22 20:22:55 +00:00
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
class CommandObjectFrameDiagnose : public CommandObjectParsed {
|
|
|
|
|
public:
|
|
|
|
|
class CommandOptions : public Options {
|
|
|
|
|
public:
|
2022-01-23 11:07:14 -08:00
|
|
|
CommandOptions() { OptionParsingStarting(nullptr); }
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
~CommandOptions() override = default;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
|
|
|
|
|
ExecutionContext *execution_context) override {
|
|
|
|
|
Status error;
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
|
|
|
|
switch (short_option) {
|
|
|
|
|
case 'r':
|
|
|
|
|
reg = ConstString(option_arg);
|
|
|
|
|
break;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
case 'a': {
|
2016-11-12 16:56:47 +00:00
|
|
|
address.emplace();
|
|
|
|
|
if (option_arg.getAsInteger(0, *address)) {
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
address.reset();
|
|
|
|
|
error.SetErrorStringWithFormat("invalid address argument '%s'",
|
2016-11-12 16:56:47 +00:00
|
|
|
option_arg.str().c_str());
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
} break;
|
|
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
case 'o': {
|
2016-11-12 16:56:47 +00:00
|
|
|
offset.emplace();
|
|
|
|
|
if (option_arg.getAsInteger(0, *offset)) {
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
offset.reset();
|
|
|
|
|
error.SetErrorStringWithFormat("invalid offset argument '%s'",
|
2016-11-12 16:56:47 +00:00
|
|
|
option_arg.str().c_str());
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
} break;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
default:
|
2019-08-22 08:08:05 +00:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
return error;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
|
|
|
|
address.reset();
|
|
|
|
|
reg.reset();
|
|
|
|
|
offset.reset();
|
|
|
|
|
}
|
|
|
|
|
|
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-22 20:22:55 +00:00
|
|
|
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
|
2023-01-09 18:11:07 +01:00
|
|
|
return llvm::ArrayRef(g_frame_diag_options);
|
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-22 20:22:55 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
// Options.
|
2023-01-07 14:18:35 -08:00
|
|
|
std::optional<lldb::addr_t> address;
|
|
|
|
|
std::optional<ConstString> reg;
|
|
|
|
|
std::optional<int64_t> offset;
|
2016-09-06 20:57:50 +00:00
|
|
|
};
|
|
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
CommandObjectFrameDiagnose(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectParsed(interpreter, "frame diagnose",
|
2021-10-05 11:10:45 -07:00
|
|
|
"Try to determine what path the current stop "
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
"location used to get to a register or address",
|
2016-09-06 20:57:50 +00:00
|
|
|
nullptr,
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
eCommandRequiresThread | eCommandTryTargetAPILock |
|
|
|
|
|
eCommandProcessMustBeLaunched |
|
2022-01-23 11:07:14 -08:00
|
|
|
eCommandProcessMustBePaused) {
|
2024-02-27 10:34:01 -08:00
|
|
|
AddSimpleArgumentList(eArgTypeFrameIndex, eArgRepeatOptional);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
~CommandObjectFrameDiagnose() override = default;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
Thread *thread = m_exe_ctx.GetThreadPtr();
|
2023-04-21 13:49:01 -07:00
|
|
|
StackFrameSP frame_sp = thread->GetSelectedFrame(SelectMostRelevantFrame);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
ValueObjectSP valobj_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2022-06-26 19:29:40 -07:00
|
|
|
if (m_options.address) {
|
|
|
|
|
if (m_options.reg || m_options.offset) {
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
result.AppendError(
|
|
|
|
|
"`frame diagnose --address` is incompatible with other arguments.");
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2022-12-17 20:37:13 +00:00
|
|
|
valobj_sp = frame_sp->GuessValueForAddress(*m_options.address);
|
2022-06-26 19:29:40 -07:00
|
|
|
} else if (m_options.reg) {
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
valobj_sp = frame_sp->GuessValueForRegisterAndOffset(
|
2022-12-17 20:37:13 +00:00
|
|
|
*m_options.reg, m_options.offset.value_or(0));
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
StopInfoSP stop_info_sp = thread->GetStopInfo();
|
|
|
|
|
if (!stop_info_sp) {
|
|
|
|
|
result.AppendError("No arguments provided, and no stop info.");
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
valobj_sp = StopInfo::GetCrashingDereference(stop_info_sp);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-06 12:48:10 +00:00
|
|
|
if (!valobj_sp) {
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
result.AppendError("No diagnosis available.");
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-10-30 15:26:19 -07:00
|
|
|
DumpValueObjectOptions::DeclPrintingHelper helper =
|
|
|
|
|
[&valobj_sp](ConstString type, ConstString var,
|
|
|
|
|
const DumpValueObjectOptions &opts,
|
|
|
|
|
Stream &stream) -> bool {
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
const ValueObject::GetExpressionPathFormat format = ValueObject::
|
|
|
|
|
GetExpressionPathFormat::eGetExpressionPathFormatHonorPointers;
|
2020-02-02 14:17:02 -08:00
|
|
|
valobj_sp->GetExpressionPath(stream, format);
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
stream.PutCString(" =");
|
|
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
};
|
|
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
DumpValueObjectOptions options;
|
|
|
|
|
options.SetDeclPrintingHelper(helper);
|
Make ValueObjectPrinter's handling of its ValueObject pointers more principled (NFC) (#81314)
I get a small but fairly steady stream of crash reports which I can only
explain by ValueObjectPrinter trying to access its m_valobj field, and
finding it NULL. I have never been able to reproduce any of these, and
the reports show a state too long after the fact to know what went
wrong.
I've read through this section of lldb a bunch of times trying to figure
out how this could happen, but haven't ever found anything actually
wrong that could cause this. OTOH, ValueObjectPrinter is somewhat sloppy
about how it handles the ValueObject it is printing.
a) lldb allows you to make a ValueObjectPrinter with a Null incoming
ValueObject. However, there's no affordance to set the ValueObject in
the Printer after the fact, and it doesn't really make sense to do that.
So I change the ValueObjectPrinter API's to take a ValueObject
reference, rather than a pointer. All the places that make
ValueObjectPrinters already check the non-null status of their
ValueObject's before making the ValueObjectPrinter, so sadly, I didn't
find the bug, but this will enforce the intent.
b) The next step in printing the ValueObject is deciding which of the
associated DynamicValue/SyntheticValue we are actually printing (based
on the use_dynamic and use_synthetic settings in the original
ValueObject. This was put in a pointer by GetMostSpecializedValue, but
most of the printer code just accessed the pointer, and it was hard to
reason out whether we were guaranteed to always call this before using
m_valobj. So far as I could see we always do (sigh, didn't find the bug
there either) but this was way too hard to reason about.
In fact, we figure out once which ValueObject we're going to print and
don't change that through the life of the printer. So I changed this to
both set the "most specialized value" in the constructor, and then to
always access it through GetMostSpecializedValue(). That makes it easier
to reason about the use of this ValueObject as well.
This is an NFC change, all it does is make the code easier to reason
about.
2024-02-12 15:24:11 -08:00
|
|
|
// We've already handled the case where the value object sp is null, so
|
|
|
|
|
// this is just to make sure future changes don't skip that:
|
|
|
|
|
assert(valobj_sp.get() && "Must have a valid ValueObject to print");
|
|
|
|
|
ValueObjectPrinter printer(*valobj_sp, &result.GetOutputStream(),
|
2016-09-06 20:57:50 +00:00
|
|
|
options);
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
printer.PrintValueObject();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
CommandOptions m_options;
|
|
|
|
|
};
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
#pragma mark CommandObjectFrameInfo
|
|
|
|
|
|
|
|
|
|
// CommandObjectFrameInfo
|
|
|
|
|
|
2012-06-08 21:56:10 +00:00
|
|
|
class CommandObjectFrameInfo : public CommandObjectParsed {
|
2010-06-08 16:52:24 +00:00
|
|
|
public:
|
2016-07-14 22:03:10 +00:00
|
|
|
CommandObjectFrameInfo(CommandInterpreter &interpreter)
|
2019-10-30 15:26:19 -07:00
|
|
|
: CommandObjectParsed(interpreter, "frame info",
|
|
|
|
|
"List information about the current "
|
|
|
|
|
"stack frame in the current thread.",
|
|
|
|
|
"frame info",
|
|
|
|
|
eCommandRequiresFrame | eCommandTryTargetAPILock |
|
|
|
|
|
eCommandProcessMustBeLaunched |
|
|
|
|
|
eCommandProcessMustBePaused) {}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2016-02-19 19:33:46 +00:00
|
|
|
~CommandObjectFrameInfo() override = default;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2012-06-08 21:56:10 +00:00
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-09 19:44:40 +00:00
|
|
|
m_exe_ctx.GetFrameRef().DumpUsingSettingsFormat(&result.GetOutputStream());
|
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#pragma mark CommandObjectFrameSelect
|
|
|
|
|
|
|
|
|
|
// CommandObjectFrameSelect
|
|
|
|
|
|
2019-07-25 11:22:46 +00:00
|
|
|
#define LLDB_OPTIONS_frame_select
|
|
|
|
|
#include "CommandOptions.inc"
|
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-22 20:22:55 +00:00
|
|
|
|
2012-06-08 21:56:10 +00:00
|
|
|
class CommandObjectFrameSelect : public CommandObjectParsed {
|
2010-06-08 16:52:24 +00:00
|
|
|
public:
|
2016-02-19 19:33:46 +00:00
|
|
|
class CommandOptions : public Options {
|
2010-10-10 22:28:11 +00:00
|
|
|
public:
|
2022-01-23 11:07:14 -08:00
|
|
|
CommandOptions() { OptionParsingStarting(nullptr); }
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-02-19 19:33:46 +00:00
|
|
|
~CommandOptions() override = default;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
|
|
|
|
|
ExecutionContext *execution_context) override {
|
|
|
|
|
Status error;
|
2012-12-04 00:32:51 +00:00
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
2010-10-10 22:28:11 +00:00
|
|
|
switch (short_option) {
|
2019-09-30 12:49:32 +00:00
|
|
|
case 'r': {
|
|
|
|
|
int32_t offset = 0;
|
|
|
|
|
if (option_arg.getAsInteger(0, offset) || offset == INT32_MIN) {
|
2011-10-26 00:56:27 +00:00
|
|
|
error.SetErrorStringWithFormat("invalid frame offset argument '%s'",
|
2016-11-12 16:56:47 +00:00
|
|
|
option_arg.str().c_str());
|
2019-09-30 12:49:32 +00:00
|
|
|
} else
|
|
|
|
|
relative_frame_offset = offset;
|
2010-10-10 22:28:11 +00:00
|
|
|
break;
|
2019-09-30 12:49:32 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-10-10 22:28:11 +00:00
|
|
|
default:
|
2019-08-22 08:08:05 +00:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2010-10-10 22:28:11 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-10-10 22:28:11 +00:00
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-30 09:00:23 +00:00
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
2019-09-30 12:49:32 +00:00
|
|
|
relative_frame_offset.reset();
|
2019-09-30 09:00:23 +00:00
|
|
|
}
|
|
|
|
|
|
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-22 20:22:55 +00:00
|
|
|
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
|
2023-01-09 18:11:07 +01:00
|
|
|
return llvm::ArrayRef(g_frame_select_options);
|
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
2016-09-22 20:22:55 +00:00
|
|
|
}
|
2010-10-10 22:28:11 +00:00
|
|
|
|
2023-01-07 14:18:35 -08:00
|
|
|
std::optional<int32_t> relative_frame_offset;
|
2010-10-10 22:28:11 +00:00
|
|
|
};
|
2016-07-14 22:03:10 +00:00
|
|
|
|
|
|
|
|
CommandObjectFrameSelect(CommandInterpreter &interpreter)
|
2019-10-30 15:26:19 -07:00
|
|
|
: CommandObjectParsed(interpreter, "frame select",
|
|
|
|
|
"Select the current stack frame by "
|
|
|
|
|
"index from within the current thread "
|
|
|
|
|
"(see 'thread backtrace'.)",
|
|
|
|
|
nullptr,
|
|
|
|
|
eCommandRequiresThread | eCommandTryTargetAPILock |
|
|
|
|
|
eCommandProcessMustBeLaunched |
|
2022-01-23 11:07:14 -08:00
|
|
|
eCommandProcessMustBePaused) {
|
2024-02-27 10:34:01 -08:00
|
|
|
AddSimpleArgumentList(eArgTypeFrameIndex, eArgRepeatOptional);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-19 19:33:46 +00:00
|
|
|
~CommandObjectFrameSelect() override = default;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2015-10-07 16:56:17 +00:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
2010-10-10 22:28:11 +00:00
|
|
|
|
2012-06-08 21:56:10 +00:00
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
2015-05-27 05:04:35 +00:00
|
|
|
// No need to check "thread" for validity as eCommandRequiresThread ensures
|
|
|
|
|
// it is valid
|
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-09 19:44:40 +00:00
|
|
|
Thread *thread = m_exe_ctx.GetThreadPtr();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-09 19:44:40 +00:00
|
|
|
uint32_t frame_idx = UINT32_MAX;
|
2022-06-20 11:33:56 -07:00
|
|
|
if (m_options.relative_frame_offset) {
|
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-09 19:44:40 +00:00
|
|
|
// The one and only argument is a signed relative frame index
|
2023-04-21 13:49:01 -07:00
|
|
|
frame_idx = thread->GetSelectedFrameIndex(SelectMostRelevantFrame);
|
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-09 19:44:40 +00:00
|
|
|
if (frame_idx == UINT32_MAX)
|
|
|
|
|
frame_idx = 0;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2019-09-30 12:49:32 +00:00
|
|
|
if (*m_options.relative_frame_offset < 0) {
|
|
|
|
|
if (static_cast<int32_t>(frame_idx) >=
|
|
|
|
|
-*m_options.relative_frame_offset)
|
|
|
|
|
frame_idx += *m_options.relative_frame_offset;
|
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-09 19:44:40 +00:00
|
|
|
else {
|
|
|
|
|
if (frame_idx == 0) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// If you are already at the bottom of the stack, then just warn
|
|
|
|
|
// and don't reset the frame.
|
2016-07-14 22:03:10 +00:00
|
|
|
result.AppendError("Already at the bottom of the stack.");
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-09 19:44:40 +00:00
|
|
|
} else
|
|
|
|
|
frame_idx = 0;
|
|
|
|
|
}
|
2019-09-30 12:49:32 +00:00
|
|
|
} else if (*m_options.relative_frame_offset > 0) {
|
2015-01-15 20:08:35 +00:00
|
|
|
// I don't want "up 20" where "20" takes you past the top of the stack
|
2023-05-23 11:13:36 -07:00
|
|
|
// to produce an error, but rather to just go to the top. OTOH, start
|
|
|
|
|
// by seeing if the requested frame exists, in which case we can avoid
|
|
|
|
|
// counting the stack here...
|
|
|
|
|
const uint32_t frame_requested = frame_idx
|
|
|
|
|
+ *m_options.relative_frame_offset;
|
|
|
|
|
StackFrameSP frame_sp = thread->GetStackFrameAtIndex(frame_requested);
|
|
|
|
|
if (frame_sp)
|
|
|
|
|
frame_idx = frame_requested;
|
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-09 19:44:40 +00:00
|
|
|
else {
|
2023-05-23 11:13:36 -07:00
|
|
|
// The request went past the stack, so handle that case:
|
|
|
|
|
const uint32_t num_frames = thread->GetStackFrameCount();
|
|
|
|
|
if (static_cast<int32_t>(num_frames - frame_idx) >
|
|
|
|
|
*m_options.relative_frame_offset)
|
|
|
|
|
frame_idx += *m_options.relative_frame_offset;
|
|
|
|
|
else {
|
|
|
|
|
if (frame_idx == num_frames - 1) {
|
|
|
|
|
// If we are already at the top of the stack, just warn and don't
|
|
|
|
|
// reset the frame.
|
|
|
|
|
result.AppendError("Already at the top of the stack.");
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2023-05-23 11:13:36 -07:00
|
|
|
} else
|
|
|
|
|
frame_idx = num_frames - 1;
|
|
|
|
|
}
|
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-09 19:44:40 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-01-31 21:46:01 +00:00
|
|
|
} else {
|
2016-12-08 02:02:09 +00:00
|
|
|
if (command.GetArgumentCount() > 1) {
|
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
|
"too many arguments; expected frame-index, saw '%s'.\n",
|
2016-12-09 01:20:58 +00:00
|
|
|
command[0].c_str());
|
2016-12-08 02:02:09 +00:00
|
|
|
m_options.GenerateOptionUsage(
|
2022-05-09 10:50:03 +00:00
|
|
|
result.GetErrorStream(), *this,
|
2016-12-08 02:02:09 +00:00
|
|
|
GetCommandInterpreter().GetDebugger().GetTerminalWidth());
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2016-12-08 02:02:09 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-31 21:46:01 +00:00
|
|
|
if (command.GetArgumentCount() == 1) {
|
2019-09-13 11:26:48 +00:00
|
|
|
if (command[0].ref().getAsInteger(0, frame_idx)) {
|
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-09 19:44:40 +00:00
|
|
|
result.AppendErrorWithFormat("invalid frame index argument '%s'.",
|
2016-12-08 02:02:09 +00:00
|
|
|
command[0].c_str());
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2013-01-31 21:46:01 +00:00
|
|
|
} else if (command.GetArgumentCount() == 0) {
|
2023-04-21 13:49:01 -07:00
|
|
|
frame_idx = thread->GetSelectedFrameIndex(SelectMostRelevantFrame);
|
2013-01-31 21:46:01 +00:00
|
|
|
if (frame_idx == UINT32_MAX) {
|
|
|
|
|
frame_idx = 0;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-31 21:46:01 +00:00
|
|
|
bool success = thread->SetSelectedFrameByIndexNoisily(
|
2011-09-12 23:58:53 +00:00
|
|
|
frame_idx, result.GetOutputStream());
|
2013-11-05 18:25:23 +00:00
|
|
|
if (success) {
|
2023-04-21 13:49:01 -07:00
|
|
|
m_exe_ctx.SetFrameSP(thread->GetSelectedFrame(SelectMostRelevantFrame));
|
2013-01-31 21:46:01 +00:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2013-01-31 21:46:01 +00:00
|
|
|
result.AppendErrorWithFormat("Frame index (%u) out of range.\n",
|
2015-01-15 20:08:35 +00:00
|
|
|
frame_idx);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-10 22:28:11 +00:00
|
|
|
CommandOptions m_options;
|
|
|
|
|
};
|
|
|
|
|
|
2010-09-02 00:18:39 +00:00
|
|
|
#pragma mark CommandObjectFrameVariable
|
|
|
|
|
// List images with associated information
|
2012-06-08 21:56:10 +00:00
|
|
|
class CommandObjectFrameVariable : public CommandObjectParsed {
|
2010-09-02 00:18:39 +00:00
|
|
|
public:
|
2016-07-14 22:03:10 +00:00
|
|
|
CommandObjectFrameVariable(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectParsed(
|
|
|
|
|
interpreter, "frame variable",
|
|
|
|
|
"Show variables for the current stack frame. Defaults to all "
|
|
|
|
|
"arguments and local variables in scope. Names of argument, "
|
2022-01-05 14:22:33 -08:00
|
|
|
"local, file static and file global variables can be specified.",
|
2019-10-30 15:26:19 -07:00
|
|
|
nullptr,
|
|
|
|
|
eCommandRequiresFrame | eCommandTryTargetAPILock |
|
|
|
|
|
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused |
|
|
|
|
|
eCommandRequiresProcess),
|
2016-07-14 22:03:10 +00:00
|
|
|
m_option_variable(
|
|
|
|
|
true), // Include the frame specific options by passing "true"
|
2022-01-23 11:07:14 -08:00
|
|
|
m_option_format(eFormatDefault) {
|
2022-01-05 14:22:33 -08:00
|
|
|
SetHelpLong(R"(
|
|
|
|
|
Children of aggregate variables can be specified such as 'var->child.x'. In
|
|
|
|
|
'frame variable', the operators -> and [] do not invoke operator overloads if
|
|
|
|
|
they exist, but directly access the specified element. If you want to trigger
|
|
|
|
|
operator overloads use the expression command to print the variable instead.
|
|
|
|
|
|
|
|
|
|
It is worth noting that except for overloaded operators, when printing local
|
|
|
|
|
variables 'expr local_var' and 'frame var local_var' produce the same results.
|
|
|
|
|
However, 'frame variable' is more efficient, since it uses debug information and
|
|
|
|
|
memory reads directly, rather than parsing and evaluating an expression, which
|
|
|
|
|
may even involve JITing and running code in the target program.)");
|
|
|
|
|
|
2024-02-27 10:34:01 -08:00
|
|
|
AddSimpleArgumentList(eArgTypeVarName, eArgRepeatStar);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-07-07 04:38:25 +00:00
|
|
|
m_option_group.Append(&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
|
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C
class names to all of the methods and class functions. We need to do this
because in the DWARF the methods for Objective C are never contained in the
class definition, they are scattered about at the translation unit level and
they don't even have attributes that say the are contained within the class
itself.
Added 3 new formats which can be used to display data:
eFormatAddressInfo
eFormatHexFloat
eFormatInstruction
eFormatAddressInfo describes an address such as function+offset and file+line,
or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants).
The format character for this is "A", the long format is "address".
eFormatHexFloat will print out the hex float format that compilers tend to use.
The format character for this is "X", the long format is "hex float".
eFormatInstruction will print out disassembly with bytes and it will use the
current target's architecture. The format character for this is "i" (which
used to be being used for the integer format, but the integer format also has
"d", so we gave the "i" format to disassembly), the long format is
"instruction".
Mate the lldb::FormatterChoiceCriterion enumeration private as it should have
been from the start. It is very specialized and doesn't belong in the public
API.
llvm-svn: 143114
2011-10-27 17:55:14 +00:00
|
|
|
m_option_group.Append(&m_option_format,
|
|
|
|
|
OptionGroupFormat::OPTION_GROUP_FORMAT |
|
|
|
|
|
OptionGroupFormat::OPTION_GROUP_GDB_FMT,
|
|
|
|
|
LLDB_OPT_SET_1);
|
2011-05-04 03:43:18 +00:00
|
|
|
m_option_group.Append(&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
|
|
|
|
|
m_option_group.Finalize();
|
2010-09-02 00:18:39 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-02-19 19:33:46 +00:00
|
|
|
~CommandObjectFrameVariable() override = default;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-05-04 03:43:18 +00:00
|
|
|
Options *GetOptions() override { return &m_option_group; }
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-06-08 21:56:10 +00:00
|
|
|
protected:
|
2016-10-26 19:17:49 +00:00
|
|
|
llvm::StringRef GetScopeString(VariableSP var_sp) {
|
|
|
|
|
if (!var_sp)
|
2021-05-18 09:03:28 +02:00
|
|
|
return llvm::StringRef();
|
2016-10-26 19:17:49 +00:00
|
|
|
|
|
|
|
|
switch (var_sp->GetScope()) {
|
|
|
|
|
case eValueTypeVariableGlobal:
|
|
|
|
|
return "GLOBAL: ";
|
|
|
|
|
case eValueTypeVariableStatic:
|
|
|
|
|
return "STATIC: ";
|
|
|
|
|
case eValueTypeVariableArgument:
|
|
|
|
|
return "ARG: ";
|
|
|
|
|
case eValueTypeVariableLocal:
|
|
|
|
|
return "LOCAL: ";
|
|
|
|
|
case eValueTypeVariableThreadLocal:
|
|
|
|
|
return "THREAD: ";
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-18 09:03:28 +02:00
|
|
|
return llvm::StringRef();
|
2016-10-26 19:17:49 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-14 13:34:27 -04:00
|
|
|
/// Returns true if `scope` matches any of the options in `m_option_variable`.
|
|
|
|
|
bool ScopeRequested(lldb::ValueType scope) {
|
|
|
|
|
switch (scope) {
|
|
|
|
|
case eValueTypeVariableGlobal:
|
|
|
|
|
case eValueTypeVariableStatic:
|
|
|
|
|
return m_option_variable.show_globals;
|
|
|
|
|
case eValueTypeVariableArgument:
|
|
|
|
|
return m_option_variable.show_args;
|
|
|
|
|
case eValueTypeVariableLocal:
|
|
|
|
|
return m_option_variable.show_locals;
|
|
|
|
|
case eValueTypeInvalid:
|
|
|
|
|
case eValueTypeRegister:
|
|
|
|
|
case eValueTypeRegisterSet:
|
|
|
|
|
case eValueTypeConstResult:
|
|
|
|
|
case eValueTypeVariableThreadLocal:
|
2023-10-30 17:46:18 -07:00
|
|
|
case eValueTypeVTable:
|
|
|
|
|
case eValueTypeVTableEntry:
|
2023-07-14 13:34:27 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
2024-01-16 12:32:06 -05:00
|
|
|
llvm_unreachable("Unexpected scope value");
|
2023-07-14 13:34:27 -04:00
|
|
|
}
|
|
|
|
|
|
2023-07-14 15:59:24 -04:00
|
|
|
/// Finds all the variables in `all_variables` whose name matches `regex`,
|
|
|
|
|
/// inserting them into `matches`. Variables already contained in `matches`
|
|
|
|
|
/// are not inserted again.
|
|
|
|
|
/// Nullopt is returned in case of no matches.
|
|
|
|
|
/// A sub-range of `matches` with all newly inserted variables is returned.
|
|
|
|
|
/// This may be empty if all matches were already contained in `matches`.
|
|
|
|
|
std::optional<llvm::ArrayRef<VariableSP>>
|
|
|
|
|
findUniqueRegexMatches(RegularExpression ®ex,
|
|
|
|
|
VariableList &matches,
|
|
|
|
|
const VariableList &all_variables) {
|
|
|
|
|
bool any_matches = false;
|
|
|
|
|
const size_t previous_num_vars = matches.GetSize();
|
|
|
|
|
|
|
|
|
|
for (const VariableSP &var : all_variables) {
|
|
|
|
|
if (!var->NameMatches(regex) || !ScopeRequested(var->GetScope()))
|
|
|
|
|
continue;
|
|
|
|
|
any_matches = true;
|
|
|
|
|
matches.AddVariableIfUnique(var);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (any_matches)
|
|
|
|
|
return matches.toArrayRef().drop_front(previous_num_vars);
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
2018-04-30 16:49:04 +00:00
|
|
|
// No need to check "frame" for validity as eCommandRequiresFrame ensures
|
|
|
|
|
// it is valid
|
2013-11-04 09:33:30 +00:00
|
|
|
StackFrame *frame = m_exe_ctx.GetFramePtr();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-12 23:58:53 +00:00
|
|
|
Stream &s = result.GetOutputStream();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2023-07-14 15:59:24 -04:00
|
|
|
// Using a regex should behave like looking for an exact name match: it
|
|
|
|
|
// also finds globals.
|
|
|
|
|
m_option_variable.show_globals |= m_option_variable.use_regex;
|
|
|
|
|
|
2011-09-12 23:58:53 +00:00
|
|
|
// Be careful about the stack frame, if any summary formatter runs code, it
|
2018-04-30 16:49:04 +00:00
|
|
|
// might clear the StackFrameList for the thread. So hold onto a shared
|
|
|
|
|
// pointer to the frame so it stays alive.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2022-08-30 15:46:57 -07:00
|
|
|
Status error;
|
2016-06-09 23:56:12 +00:00
|
|
|
VariableList *variable_list =
|
2022-08-30 15:46:57 -07:00
|
|
|
frame->GetVariableList(m_option_variable.show_globals, &error);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2022-08-30 15:46:57 -07:00
|
|
|
if (error.Fail() && (!variable_list || variable_list->GetSize() == 0)) {
|
|
|
|
|
result.AppendError(error.AsCString());
|
|
|
|
|
|
|
|
|
|
}
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
ValueObjectSP valobj_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
TypeSummaryImplSP summary_format_sp;
|
2015-09-30 23:12:22 +00:00
|
|
|
if (!m_option_variable.summary.IsCurrentValueEmpty())
|
2011-10-25 06:44:01 +00:00
|
|
|
DataVisualization::NamedSummaryFormats::GetSummaryFormat(
|
2016-02-19 19:33:46 +00:00
|
|
|
ConstString(m_option_variable.summary.GetCurrentValue()),
|
|
|
|
|
summary_format_sp);
|
2011-09-12 23:58:53 +00:00
|
|
|
else if (!m_option_variable.summary_string.IsCurrentValueEmpty())
|
2019-02-11 23:13:08 +00:00
|
|
|
summary_format_sp = std::make_shared<StringSummaryFormat>(
|
2011-09-12 23:58:53 +00:00
|
|
|
TypeSummaryImpl::Flags(),
|
2019-02-11 23:13:08 +00:00
|
|
|
m_option_variable.summary_string.GetCurrentValue());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-12 23:58:53 +00:00
|
|
|
DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(
|
|
|
|
|
eLanguageRuntimeDescriptionDisplayVerbosityFull, eFormatDefault,
|
2012-08-09 22:02:51 +00:00
|
|
|
summary_format_sp));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-12 23:58:53 +00:00
|
|
|
const SymbolContext &sym_ctx =
|
2011-09-22 04:58:26 +00:00
|
|
|
frame->GetSymbolContext(eSymbolContextFunction);
|
2011-09-12 23:58:53 +00:00
|
|
|
if (sym_ctx.function && sym_ctx.function->IsTopLevelFunction())
|
|
|
|
|
m_option_variable.show_globals = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-12 23:58:53 +00:00
|
|
|
if (variable_list) {
|
<rdar://problem/14393032>
DumpValueObject() 2.0
This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
1 = 2;
2 = 3;
}
When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
1 = 2;
2 = 3;
}
- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5
On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed
Test case to follow
llvm-svn: 191694
2013-09-30 19:11:51 +00:00
|
|
|
const Format format = m_option_format.GetFormat();
|
2012-03-01 04:24:26 +00:00
|
|
|
options.SetFormat(format);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-10-05 20:03:37 +00:00
|
|
|
if (!command.empty()) {
|
2011-09-12 23:58:53 +00:00
|
|
|
VariableList regex_var_list;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// If we have any args to the variable command, we will make variable
|
|
|
|
|
// objects from them...
|
2016-12-08 02:02:09 +00:00
|
|
|
for (auto &entry : command) {
|
2012-08-09 22:02:51 +00:00
|
|
|
if (m_option_variable.use_regex) {
|
2019-09-13 11:26:48 +00:00
|
|
|
llvm::StringRef name_str = entry.ref();
|
2016-09-21 16:01:28 +00:00
|
|
|
RegularExpression regex(name_str);
|
2019-08-20 09:24:20 +00:00
|
|
|
if (regex.IsValid()) {
|
2023-07-14 15:59:24 -04:00
|
|
|
std::optional<llvm::ArrayRef<VariableSP>> results =
|
|
|
|
|
findUniqueRegexMatches(regex, regex_var_list, *variable_list);
|
|
|
|
|
if (!results) {
|
2022-01-06 19:38:31 -08:00
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
|
"no variables matched the regular expression '%s'.",
|
|
|
|
|
entry.c_str());
|
2023-07-14 15:59:24 -04:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (const VariableSP &var_sp : *results) {
|
|
|
|
|
valobj_sp = frame->GetValueObjectForFrameVariable(
|
|
|
|
|
var_sp, m_varobj_options.use_dynamic);
|
|
|
|
|
if (valobj_sp) {
|
|
|
|
|
std::string scope_string;
|
|
|
|
|
if (m_option_variable.show_scope)
|
|
|
|
|
scope_string = GetScopeString(var_sp).str();
|
|
|
|
|
|
|
|
|
|
if (!scope_string.empty())
|
|
|
|
|
s.PutCString(scope_string);
|
|
|
|
|
|
|
|
|
|
if (m_option_variable.show_decl &&
|
|
|
|
|
var_sp->GetDeclaration().GetFile()) {
|
|
|
|
|
bool show_fullpaths = false;
|
|
|
|
|
bool show_module = true;
|
|
|
|
|
if (var_sp->DumpDeclaration(&s, show_fullpaths,
|
|
|
|
|
show_module))
|
|
|
|
|
s.PutCString(": ");
|
|
|
|
|
}
|
|
|
|
|
valobj_sp->Dump(result.GetOutputStream(), options);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2019-08-16 21:25:36 +00:00
|
|
|
if (llvm::Error err = regex.GetError())
|
2022-01-06 19:38:31 -08:00
|
|
|
result.AppendError(llvm::toString(std::move(err)));
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2022-01-06 19:38:31 -08:00
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
|
"unknown regex error when compiling '%s'", entry.c_str());
|
2011-09-12 23:58:53 +00:00
|
|
|
}
|
|
|
|
|
} else // No regex, either exact variable names or variable
|
|
|
|
|
// expressions.
|
|
|
|
|
{
|
2017-05-12 04:51:55 +00:00
|
|
|
Status error;
|
2013-01-25 18:06:21 +00:00
|
|
|
uint32_t expr_path_options =
|
|
|
|
|
StackFrame::eExpressionPathOptionCheckPtrVsMember |
|
2011-09-12 23:58:53 +00:00
|
|
|
StackFrame::eExpressionPathOptionsAllowDirectIVarAccess |
|
2015-02-11 02:35:39 +00:00
|
|
|
StackFrame::eExpressionPathOptionsInspectAnonymousUnions;
|
2011-09-12 23:58:53 +00:00
|
|
|
lldb::VariableSP var_sp;
|
2010-09-13 03:44:33 +00:00
|
|
|
valobj_sp = frame->GetValueForVariableExpressionPath(
|
2019-09-13 11:26:48 +00:00
|
|
|
entry.ref(), m_varobj_options.use_dynamic, expr_path_options,
|
2016-06-09 23:56:12 +00:00
|
|
|
var_sp, error);
|
2011-09-12 23:58:53 +00:00
|
|
|
if (valobj_sp) {
|
2016-10-26 19:17:49 +00:00
|
|
|
std::string scope_string;
|
|
|
|
|
if (m_option_variable.show_scope)
|
|
|
|
|
scope_string = GetScopeString(var_sp).str();
|
|
|
|
|
|
|
|
|
|
if (!scope_string.empty())
|
2016-11-02 20:34:10 +00:00
|
|
|
s.PutCString(scope_string);
|
2011-07-07 04:38:25 +00:00
|
|
|
if (m_option_variable.show_decl && var_sp &&
|
2016-07-01 17:17:23 +00:00
|
|
|
var_sp->GetDeclaration().GetFile()) {
|
|
|
|
|
var_sp->GetDeclaration().DumpStopContext(&s, false);
|
|
|
|
|
s.PutCString(": ");
|
2011-09-12 23:58:53 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-03-01 04:24:26 +00:00
|
|
|
options.SetFormat(format);
|
2011-09-12 23:58:53 +00:00
|
|
|
options.SetVariableFormatDisplayLanguage(
|
|
|
|
|
valobj_sp->GetPreferredDisplayLanguage());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-12 23:58:53 +00:00
|
|
|
Stream &output_stream = result.GetOutputStream();
|
2016-12-08 02:02:09 +00:00
|
|
|
options.SetRootValueObjectName(
|
|
|
|
|
valobj_sp->GetParent() ? entry.c_str() : nullptr);
|
2011-09-12 23:58:53 +00:00
|
|
|
valobj_sp->Dump(output_stream, options);
|
|
|
|
|
} else {
|
2022-01-06 19:38:31 -08:00
|
|
|
if (auto error_cstr = error.AsCString(nullptr))
|
|
|
|
|
result.AppendError(error_cstr);
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
2022-01-06 19:38:31 -08:00
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
|
"unable to find any variable expression path that matches "
|
|
|
|
|
"'%s'.",
|
|
|
|
|
entry.c_str());
|
2010-09-02 00:18:39 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-09-02 00:18:39 +00:00
|
|
|
}
|
2011-08-12 16:42:31 +00:00
|
|
|
} else // No command arg specified. Use variable_list, instead.
|
2016-09-06 20:57:50 +00:00
|
|
|
{
|
2011-08-12 16:42:31 +00:00
|
|
|
const size_t num_variables = variable_list->GetSize();
|
2011-09-12 23:58:53 +00:00
|
|
|
if (num_variables > 0) {
|
2013-01-25 18:06:21 +00:00
|
|
|
for (size_t i = 0; i < num_variables; i++) {
|
2023-07-14 15:59:24 -04:00
|
|
|
VariableSP var_sp = variable_list->GetVariableAtIndex(i);
|
2023-07-14 13:34:27 -04:00
|
|
|
if (!ScopeRequested(var_sp->GetScope()))
|
2017-06-19 06:57:54 +00:00
|
|
|
continue;
|
|
|
|
|
std::string scope_string;
|
|
|
|
|
if (m_option_variable.show_scope)
|
|
|
|
|
scope_string = GetScopeString(var_sp).str();
|
2017-04-18 16:52:16 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Use the variable object code to make sure we are using the same
|
|
|
|
|
// APIs as the public API will be using...
|
2017-04-18 16:52:16 +00:00
|
|
|
valobj_sp = frame->GetValueObjectForFrameVariable(
|
|
|
|
|
var_sp, m_varobj_options.use_dynamic);
|
|
|
|
|
if (valobj_sp) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// When dumping all variables, don't print any variables that are
|
|
|
|
|
// not in scope to avoid extra unneeded output
|
2017-04-18 16:52:16 +00:00
|
|
|
if (valobj_sp->IsInScope()) {
|
|
|
|
|
if (!valobj_sp->GetTargetSP()
|
|
|
|
|
->GetDisplayRuntimeSupportValues() &&
|
|
|
|
|
valobj_sp->IsRuntimeSupportValue())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!scope_string.empty())
|
|
|
|
|
s.PutCString(scope_string);
|
|
|
|
|
|
|
|
|
|
if (m_option_variable.show_decl &&
|
|
|
|
|
var_sp->GetDeclaration().GetFile()) {
|
|
|
|
|
var_sp->GetDeclaration().DumpStopContext(&s, false);
|
|
|
|
|
s.PutCString(": ");
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2017-04-18 16:52:16 +00:00
|
|
|
|
|
|
|
|
options.SetFormat(format);
|
|
|
|
|
options.SetVariableFormatDisplayLanguage(
|
|
|
|
|
valobj_sp->GetPreferredDisplayLanguage());
|
|
|
|
|
options.SetRootValueObjectName(
|
|
|
|
|
var_sp ? var_sp->GetName().AsCString() : nullptr);
|
|
|
|
|
valobj_sp->Dump(result.GetOutputStream(), options);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-08-12 16:42:31 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2022-01-06 19:38:31 -08:00
|
|
|
if (result.GetStatus() != eReturnStatusFailed)
|
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
2010-09-02 00:18:39 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-31 04:00:22 +00:00
|
|
|
if (m_option_variable.show_recognized_args) {
|
|
|
|
|
auto recognized_frame = frame->GetRecognizedFrame();
|
|
|
|
|
if (recognized_frame) {
|
|
|
|
|
ValueObjectListSP recognized_arg_list =
|
|
|
|
|
recognized_frame->GetRecognizedArguments();
|
|
|
|
|
if (recognized_arg_list) {
|
|
|
|
|
for (auto &rec_value_sp : recognized_arg_list->GetObjects()) {
|
|
|
|
|
options.SetFormat(m_option_format.GetFormat());
|
|
|
|
|
options.SetVariableFormatDisplayLanguage(
|
|
|
|
|
rec_value_sp->GetPreferredDisplayLanguage());
|
|
|
|
|
options.SetRootValueObjectName(rec_value_sp->GetName().AsCString());
|
|
|
|
|
rec_value_sp->Dump(result.GetOutputStream(), options);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-26 16:34:10 -07:00
|
|
|
m_interpreter.PrintWarningsIfNecessary(result.GetOutputStream(),
|
|
|
|
|
m_cmd_name);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-04-13 18:02:39 +00:00
|
|
|
// Increment statistics.
|
2021-10-20 14:49:09 -07:00
|
|
|
TargetStats &target_stats = GetSelectedOrDummyTarget().GetStatistics();
|
2023-10-30 10:21:00 -10:00
|
|
|
if (result.Succeeded())
|
2021-10-20 14:49:09 -07:00
|
|
|
target_stats.GetFrameVariableStats().NotifySuccess();
|
2018-04-13 18:02:39 +00:00
|
|
|
else
|
2021-10-20 14:49:09 -07:00
|
|
|
target_stats.GetFrameVariableStats().NotifyFailure();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-04 03:43:18 +00:00
|
|
|
OptionGroupOptions m_option_group;
|
2011-07-07 04:38:25 +00:00
|
|
|
OptionGroupVariable m_option_variable;
|
2011-10-25 06:44:01 +00:00
|
|
|
OptionGroupFormat m_option_format;
|
2011-05-04 03:43:18 +00:00
|
|
|
OptionGroupValueObjectDisplay m_varobj_options;
|
2010-09-02 00:18:39 +00:00
|
|
|
};
|
|
|
|
|
|
2018-10-31 04:00:22 +00:00
|
|
|
#pragma mark CommandObjectFrameRecognizer
|
|
|
|
|
|
2019-07-25 11:22:46 +00:00
|
|
|
#define LLDB_OPTIONS_frame_recognizer_add
|
|
|
|
|
#include "CommandOptions.inc"
|
2018-10-31 04:00:22 +00:00
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizerAdd : public CommandObjectParsed {
|
|
|
|
|
private:
|
|
|
|
|
class CommandOptions : public Options {
|
|
|
|
|
public:
|
2022-03-31 13:20:46 -07:00
|
|
|
CommandOptions() = default;
|
2018-10-31 04:00:22 +00:00
|
|
|
~CommandOptions() override = default;
|
|
|
|
|
|
|
|
|
|
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
|
|
|
|
|
ExecutionContext *execution_context) override {
|
|
|
|
|
Status error;
|
|
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
|
|
|
|
|
|
|
|
|
switch (short_option) {
|
2021-08-29 17:26:15 +02:00
|
|
|
case 'f': {
|
|
|
|
|
bool value, success;
|
|
|
|
|
value = OptionArgParser::ToBoolean(option_arg, true, &success);
|
|
|
|
|
if (success) {
|
|
|
|
|
m_first_instruction_only = value;
|
|
|
|
|
} else {
|
|
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
|
"invalid boolean value '%s' passed for -f option",
|
|
|
|
|
option_arg.str().c_str());
|
|
|
|
|
}
|
|
|
|
|
} break;
|
2018-10-31 04:00:22 +00:00
|
|
|
case 'l':
|
|
|
|
|
m_class_name = std::string(option_arg);
|
|
|
|
|
break;
|
|
|
|
|
case 's':
|
|
|
|
|
m_module = std::string(option_arg);
|
|
|
|
|
break;
|
|
|
|
|
case 'n':
|
2020-03-13 23:56:35 +01:00
|
|
|
m_symbols.push_back(std::string(option_arg));
|
2018-10-31 04:00:22 +00:00
|
|
|
break;
|
|
|
|
|
case 'x':
|
|
|
|
|
m_regex = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-08-22 08:08:05 +00:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
|
|
|
|
m_module = "";
|
2020-03-13 23:56:35 +01:00
|
|
|
m_symbols.clear();
|
2018-10-31 04:00:22 +00:00
|
|
|
m_class_name = "";
|
|
|
|
|
m_regex = false;
|
2021-08-29 17:26:15 +02:00
|
|
|
m_first_instruction_only = true;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
|
2023-01-09 18:11:07 +01:00
|
|
|
return llvm::ArrayRef(g_frame_recognizer_add_options);
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Instance variables to hold the values for command options.
|
|
|
|
|
std::string m_class_name;
|
|
|
|
|
std::string m_module;
|
2020-03-13 23:56:35 +01:00
|
|
|
std::vector<std::string> m_symbols;
|
2018-10-31 04:00:22 +00:00
|
|
|
bool m_regex;
|
2021-08-29 17:26:15 +02:00
|
|
|
bool m_first_instruction_only;
|
2018-10-31 04:00:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CommandOptions m_options;
|
|
|
|
|
|
|
|
|
|
Options *GetOptions() override { return &m_options; }
|
|
|
|
|
|
|
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override;
|
2018-10-31 04:00:22 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CommandObjectFrameRecognizerAdd(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectParsed(interpreter, "frame recognizer add",
|
2022-01-23 11:07:14 -08:00
|
|
|
"Add a new frame recognizer.", nullptr) {
|
2018-10-31 04:00:22 +00:00
|
|
|
SetHelpLong(R"(
|
|
|
|
|
Frame recognizers allow for retrieving information about special frames based on
|
|
|
|
|
ABI, arguments or other special properties of that frame, even without source
|
|
|
|
|
code or debug info. Currently, one use case is to extract function arguments
|
|
|
|
|
that would otherwise be unaccesible, or augment existing arguments.
|
|
|
|
|
|
|
|
|
|
Adding a custom frame recognizer is possible by implementing a Python class
|
|
|
|
|
and using the 'frame recognizer add' command. The Python class should have a
|
|
|
|
|
'get_recognized_arguments' method and it will receive an argument of type
|
|
|
|
|
lldb.SBFrame representing the current frame that we are trying to recognize.
|
|
|
|
|
The method should return a (possibly empty) list of lldb.SBValue objects that
|
|
|
|
|
represent the recognized arguments.
|
|
|
|
|
|
|
|
|
|
An example of a recognizer that retrieves the file descriptor values from libc
|
|
|
|
|
functions 'read', 'write' and 'close' follows:
|
|
|
|
|
|
|
|
|
|
class LibcFdRecognizer(object):
|
|
|
|
|
def get_recognized_arguments(self, frame):
|
|
|
|
|
if frame.name in ["read", "write", "close"]:
|
|
|
|
|
fd = frame.EvaluateExpression("$arg1").unsigned
|
2022-09-06 13:24:21 -07:00
|
|
|
target = frame.thread.process.target
|
|
|
|
|
value = target.CreateValueFromExpression("fd", "(int)%d" % fd)
|
2018-10-31 04:00:22 +00:00
|
|
|
return [value]
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
The file containing this implementation can be imported via 'command script
|
|
|
|
|
import' and then we can register this recognizer with 'frame recognizer add'.
|
|
|
|
|
It's important to restrict the recognizer to the libc library (which is
|
|
|
|
|
libsystem_kernel.dylib on macOS) to avoid matching functions with the same name
|
|
|
|
|
in other modules:
|
|
|
|
|
|
|
|
|
|
(lldb) command script import .../fd_recognizer.py
|
|
|
|
|
(lldb) frame recognizer add -l fd_recognizer.LibcFdRecognizer -n read -s libsystem_kernel.dylib
|
|
|
|
|
|
|
|
|
|
When the program is stopped at the beginning of the 'read' function in libc, we
|
|
|
|
|
can view the recognizer arguments in 'frame variable':
|
|
|
|
|
|
|
|
|
|
(lldb) b read
|
|
|
|
|
(lldb) r
|
|
|
|
|
Process 1234 stopped
|
|
|
|
|
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.3
|
|
|
|
|
frame #0: 0x00007fff06013ca0 libsystem_kernel.dylib`read
|
|
|
|
|
(lldb) frame variable
|
|
|
|
|
(int) fd = 3
|
|
|
|
|
|
|
|
|
|
)");
|
|
|
|
|
}
|
|
|
|
|
~CommandObjectFrameRecognizerAdd() override = default;
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-30 10:21:00 -10:00
|
|
|
void CommandObjectFrameRecognizerAdd::DoExecute(Args &command,
|
2018-10-31 04:00:22 +00:00
|
|
|
CommandReturnObject &result) {
|
2019-12-13 10:37:33 -08:00
|
|
|
#if LLDB_ENABLE_PYTHON
|
2018-10-31 04:00:22 +00:00
|
|
|
if (m_options.m_class_name.empty()) {
|
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
|
"%s needs a Python class name (-l argument).\n", m_cmd_name.c_str());
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_options.m_module.empty()) {
|
|
|
|
|
result.AppendErrorWithFormat("%s needs a module name (-s argument).\n",
|
|
|
|
|
m_cmd_name.c_str());
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-13 23:56:35 +01:00
|
|
|
if (m_options.m_symbols.empty()) {
|
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
|
"%s needs at least one symbol name (-n argument).\n",
|
|
|
|
|
m_cmd_name.c_str());
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2020-03-13 23:56:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_options.m_regex && m_options.m_symbols.size() > 1) {
|
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
|
"%s needs only one symbol regular expression (-n argument).\n",
|
|
|
|
|
m_cmd_name.c_str());
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-26 22:43:16 +00:00
|
|
|
ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
|
2018-10-31 04:00:22 +00:00
|
|
|
|
|
|
|
|
if (interpreter &&
|
|
|
|
|
!interpreter->CheckObjectExists(m_options.m_class_name.c_str())) {
|
2019-10-30 15:26:19 -07:00
|
|
|
result.AppendWarning("The provided class does not exist - please define it "
|
|
|
|
|
"before attempting to use this frame recognizer");
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StackFrameRecognizerSP recognizer_sp =
|
|
|
|
|
StackFrameRecognizerSP(new ScriptedStackFrameRecognizer(
|
|
|
|
|
interpreter, m_options.m_class_name.c_str()));
|
|
|
|
|
if (m_options.m_regex) {
|
|
|
|
|
auto module =
|
|
|
|
|
RegularExpressionSP(new RegularExpression(m_options.m_module));
|
|
|
|
|
auto func =
|
2020-03-13 23:56:35 +01:00
|
|
|
RegularExpressionSP(new RegularExpression(m_options.m_symbols.front()));
|
2020-07-17 08:36:38 +02:00
|
|
|
GetSelectedOrDummyTarget().GetFrameRecognizerManager().AddRecognizer(
|
2021-08-29 17:26:15 +02:00
|
|
|
recognizer_sp, module, func, m_options.m_first_instruction_only);
|
2018-10-31 04:00:22 +00:00
|
|
|
} else {
|
|
|
|
|
auto module = ConstString(m_options.m_module);
|
2020-03-13 23:56:35 +01:00
|
|
|
std::vector<ConstString> symbols(m_options.m_symbols.begin(),
|
|
|
|
|
m_options.m_symbols.end());
|
2020-07-17 08:36:38 +02:00
|
|
|
GetSelectedOrDummyTarget().GetFrameRecognizerManager().AddRecognizer(
|
2021-08-29 17:26:15 +02:00
|
|
|
recognizer_sp, module, symbols, m_options.m_first_instruction_only);
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
2018-10-31 04:43:09 +00:00
|
|
|
#endif
|
2018-10-31 04:00:22 +00:00
|
|
|
|
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizerClear : public CommandObjectParsed {
|
|
|
|
|
public:
|
|
|
|
|
CommandObjectFrameRecognizerClear(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectParsed(interpreter, "frame recognizer clear",
|
2019-10-30 15:26:19 -07:00
|
|
|
"Delete all frame recognizers.", nullptr) {}
|
2018-10-31 04:00:22 +00:00
|
|
|
|
|
|
|
|
~CommandObjectFrameRecognizerClear() override = default;
|
|
|
|
|
|
|
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
2020-07-17 08:36:38 +02:00
|
|
|
GetSelectedOrDummyTarget()
|
|
|
|
|
.GetFrameRecognizerManager()
|
|
|
|
|
.RemoveAllRecognizers();
|
2018-10-31 04:00:22 +00:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizerDelete : public CommandObjectParsed {
|
2019-10-30 15:26:19 -07:00
|
|
|
public:
|
2018-10-31 04:00:22 +00:00
|
|
|
CommandObjectFrameRecognizerDelete(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectParsed(interpreter, "frame recognizer delete",
|
2022-06-23 09:33:40 -07:00
|
|
|
"Delete an existing frame recognizer by id.",
|
|
|
|
|
nullptr) {
|
2024-02-27 10:34:01 -08:00
|
|
|
AddSimpleArgumentList(eArgTypeRecognizerID);
|
2022-06-23 09:33:40 -07:00
|
|
|
}
|
2018-10-31 04:00:22 +00:00
|
|
|
|
|
|
|
|
~CommandObjectFrameRecognizerDelete() override = default;
|
|
|
|
|
|
2020-06-30 13:14:46 +02:00
|
|
|
void
|
|
|
|
|
HandleArgumentCompletion(CompletionRequest &request,
|
|
|
|
|
OptionElementVector &opt_element_vector) override {
|
|
|
|
|
if (request.GetCursorIndex() != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-07-17 08:36:38 +02:00
|
|
|
GetSelectedOrDummyTarget().GetFrameRecognizerManager().ForEach(
|
2020-06-30 13:14:46 +02:00
|
|
|
[&request](uint32_t rid, std::string rname, std::string module,
|
|
|
|
|
llvm::ArrayRef<lldb_private::ConstString> symbols,
|
|
|
|
|
bool regexp) {
|
|
|
|
|
StreamString strm;
|
|
|
|
|
if (rname.empty())
|
|
|
|
|
rname = "(internal)";
|
|
|
|
|
|
|
|
|
|
strm << rname;
|
|
|
|
|
if (!module.empty())
|
|
|
|
|
strm << ", module " << module;
|
|
|
|
|
if (!symbols.empty())
|
|
|
|
|
for (auto &symbol : symbols)
|
|
|
|
|
strm << ", symbol " << symbol;
|
|
|
|
|
if (regexp)
|
|
|
|
|
strm << " (regexp)";
|
|
|
|
|
|
|
|
|
|
request.TryCompleteCurrentArg(std::to_string(rid), strm.GetString());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-30 15:26:19 -07:00
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
2018-10-31 04:00:22 +00:00
|
|
|
if (command.GetArgumentCount() == 0) {
|
|
|
|
|
if (!m_interpreter.Confirm(
|
|
|
|
|
"About to delete all frame recognizers, do you want to do that?",
|
|
|
|
|
true)) {
|
|
|
|
|
result.AppendMessage("Operation cancelled...");
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
2020-07-17 08:36:38 +02:00
|
|
|
GetSelectedOrDummyTarget()
|
|
|
|
|
.GetFrameRecognizerManager()
|
|
|
|
|
.RemoveAllRecognizers();
|
2018-10-31 04:00:22 +00:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (command.GetArgumentCount() != 1) {
|
|
|
|
|
result.AppendErrorWithFormat("'%s' takes zero or one arguments.\n",
|
|
|
|
|
m_cmd_name.c_str());
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
2020-07-01 17:00:12 +02:00
|
|
|
uint32_t recognizer_id;
|
|
|
|
|
if (!llvm::to_integer(command.GetArgumentAtIndex(0), recognizer_id)) {
|
|
|
|
|
result.AppendErrorWithFormat("'%s' is not a valid recognizer id.\n",
|
|
|
|
|
command.GetArgumentAtIndex(0));
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2020-07-01 17:00:12 +02:00
|
|
|
}
|
2018-10-31 04:00:22 +00:00
|
|
|
|
2020-07-23 17:25:17 +02:00
|
|
|
if (!GetSelectedOrDummyTarget()
|
|
|
|
|
.GetFrameRecognizerManager()
|
|
|
|
|
.RemoveRecognizerWithID(recognizer_id)) {
|
|
|
|
|
result.AppendErrorWithFormat("'%s' is not a valid recognizer id.\n",
|
|
|
|
|
command.GetArgumentAtIndex(0));
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2020-07-23 17:25:17 +02:00
|
|
|
}
|
2018-10-31 04:00:22 +00:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizerList : public CommandObjectParsed {
|
2019-10-30 15:26:19 -07:00
|
|
|
public:
|
2018-10-31 04:00:22 +00:00
|
|
|
CommandObjectFrameRecognizerList(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectParsed(interpreter, "frame recognizer list",
|
|
|
|
|
"Show a list of active frame recognizers.",
|
|
|
|
|
nullptr) {}
|
|
|
|
|
|
|
|
|
|
~CommandObjectFrameRecognizerList() override = default;
|
|
|
|
|
|
2019-10-30 15:26:19 -07:00
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
2018-10-31 04:00:22 +00:00
|
|
|
bool any_printed = false;
|
2020-07-17 08:36:38 +02:00
|
|
|
GetSelectedOrDummyTarget().GetFrameRecognizerManager().ForEach(
|
2020-03-13 23:56:35 +01:00
|
|
|
[&result, &any_printed](
|
|
|
|
|
uint32_t recognizer_id, std::string name, std::string module,
|
|
|
|
|
llvm::ArrayRef<ConstString> symbols, bool regexp) {
|
2020-02-10 23:29:12 +01:00
|
|
|
Stream &stream = result.GetOutputStream();
|
|
|
|
|
|
|
|
|
|
if (name.empty())
|
2019-10-30 15:26:19 -07:00
|
|
|
name = "(internal)";
|
2020-02-10 23:29:12 +01:00
|
|
|
|
|
|
|
|
stream << std::to_string(recognizer_id) << ": " << name;
|
|
|
|
|
if (!module.empty())
|
|
|
|
|
stream << ", module " << module;
|
2020-03-13 23:56:35 +01:00
|
|
|
if (!symbols.empty())
|
|
|
|
|
for (auto &symbol : symbols)
|
|
|
|
|
stream << ", symbol " << symbol;
|
2020-02-10 23:29:12 +01:00
|
|
|
if (regexp)
|
|
|
|
|
stream << " (regexp)";
|
|
|
|
|
|
|
|
|
|
stream.EOL();
|
|
|
|
|
stream.Flush();
|
|
|
|
|
|
2018-10-31 04:00:22 +00:00
|
|
|
any_printed = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (any_printed)
|
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
|
else {
|
|
|
|
|
result.GetOutputStream().PutCString("no matching results found.\n");
|
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizerInfo : public CommandObjectParsed {
|
2019-10-30 15:26:19 -07:00
|
|
|
public:
|
2018-10-31 04:00:22 +00:00
|
|
|
CommandObjectFrameRecognizerInfo(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectParsed(
|
|
|
|
|
interpreter, "frame recognizer info",
|
|
|
|
|
"Show which frame recognizer is applied a stack frame (if any).",
|
|
|
|
|
nullptr) {
|
2024-02-27 10:34:01 -08:00
|
|
|
AddSimpleArgumentList(eArgTypeFrameIndex);
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~CommandObjectFrameRecognizerInfo() override = default;
|
|
|
|
|
|
2019-10-30 15:26:19 -07:00
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
2020-07-01 17:00:12 +02:00
|
|
|
const char *frame_index_str = command.GetArgumentAtIndex(0);
|
|
|
|
|
uint32_t frame_index;
|
|
|
|
|
if (!llvm::to_integer(frame_index_str, frame_index)) {
|
|
|
|
|
result.AppendErrorWithFormat("'%s' is not a valid frame index.",
|
|
|
|
|
frame_index_str);
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2020-07-01 17:00:12 +02:00
|
|
|
}
|
|
|
|
|
|
2018-10-31 04:00:22 +00:00
|
|
|
Process *process = m_exe_ctx.GetProcessPtr();
|
|
|
|
|
if (process == nullptr) {
|
|
|
|
|
result.AppendError("no process");
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
Thread *thread = m_exe_ctx.GetThreadPtr();
|
|
|
|
|
if (thread == nullptr) {
|
|
|
|
|
result.AppendError("no thread");
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
if (command.GetArgumentCount() != 1) {
|
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
|
"'%s' takes exactly one frame index argument.\n", m_cmd_name.c_str());
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StackFrameSP frame_sp = thread->GetStackFrameAtIndex(frame_index);
|
|
|
|
|
if (!frame_sp) {
|
|
|
|
|
result.AppendErrorWithFormat("no frame with index %u", frame_index);
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
2020-07-17 08:36:38 +02:00
|
|
|
auto recognizer = GetSelectedOrDummyTarget()
|
|
|
|
|
.GetFrameRecognizerManager()
|
|
|
|
|
.GetRecognizerForFrame(frame_sp);
|
2018-10-31 04:00:22 +00:00
|
|
|
|
|
|
|
|
Stream &output_stream = result.GetOutputStream();
|
|
|
|
|
output_stream.Printf("frame %d ", frame_index);
|
|
|
|
|
if (recognizer) {
|
|
|
|
|
output_stream << "is recognized by ";
|
|
|
|
|
output_stream << recognizer->GetName();
|
|
|
|
|
} else {
|
|
|
|
|
output_stream << "not recognized by any recognizer";
|
|
|
|
|
}
|
|
|
|
|
output_stream.EOL();
|
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizer : public CommandObjectMultiword {
|
2019-10-30 15:26:19 -07:00
|
|
|
public:
|
2018-10-31 04:00:22 +00:00
|
|
|
CommandObjectFrameRecognizer(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectMultiword(
|
|
|
|
|
interpreter, "frame recognizer",
|
|
|
|
|
"Commands for editing and viewing frame recognizers.",
|
|
|
|
|
"frame recognizer [<sub-command-options>] ") {
|
2019-10-30 15:26:19 -07:00
|
|
|
LoadSubCommand("add", CommandObjectSP(new CommandObjectFrameRecognizerAdd(
|
|
|
|
|
interpreter)));
|
2018-10-31 04:00:22 +00:00
|
|
|
LoadSubCommand(
|
|
|
|
|
"clear",
|
|
|
|
|
CommandObjectSP(new CommandObjectFrameRecognizerClear(interpreter)));
|
|
|
|
|
LoadSubCommand(
|
|
|
|
|
"delete",
|
|
|
|
|
CommandObjectSP(new CommandObjectFrameRecognizerDelete(interpreter)));
|
2019-10-30 15:26:19 -07:00
|
|
|
LoadSubCommand("list", CommandObjectSP(new CommandObjectFrameRecognizerList(
|
|
|
|
|
interpreter)));
|
|
|
|
|
LoadSubCommand("info", CommandObjectSP(new CommandObjectFrameRecognizerInfo(
|
|
|
|
|
interpreter)));
|
2018-10-31 04:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~CommandObjectFrameRecognizer() override = default;
|
|
|
|
|
};
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
#pragma mark CommandObjectMultiwordFrame
|
|
|
|
|
|
|
|
|
|
// CommandObjectMultiwordFrame
|
|
|
|
|
|
2016-07-14 22:03:10 +00:00
|
|
|
CommandObjectMultiwordFrame::CommandObjectMultiwordFrame(
|
|
|
|
|
CommandInterpreter &interpreter)
|
2019-10-30 15:26:19 -07:00
|
|
|
: CommandObjectMultiword(interpreter, "frame",
|
|
|
|
|
"Commands for selecting and "
|
|
|
|
|
"examing the current "
|
|
|
|
|
"thread's stack frames.",
|
2016-07-14 22:03:10 +00:00
|
|
|
"frame <subcommand> [<subcommand-options>]") {
|
Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one). From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.
To address this, I have added new fuctionality to StackFrame to parse the
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.
This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command. It is also used to provide symbolic information, when
available, in the event of a crash.
The algorithm is very rudimentary, and it needs a bunch of work, including
- better parsing for assembly, preferably with help from LLVM
- support for non-Apple platforms
- cleanup of the algorithm core, preferably to make it all work in terms of
Operands instead of register/offset pairs
- improvement of the GetExpressioPath() logic to make prettier expression
paths, and
- better handling of vtables.
I welcome all suggestios, improvements, and testcases.
llvm-svn: 280692
2016-09-06 04:48:36 +00:00
|
|
|
LoadSubCommand("diagnose",
|
|
|
|
|
CommandObjectSP(new CommandObjectFrameDiagnose(interpreter)));
|
2010-09-18 01:14:36 +00:00
|
|
|
LoadSubCommand("info",
|
|
|
|
|
CommandObjectSP(new CommandObjectFrameInfo(interpreter)));
|
|
|
|
|
LoadSubCommand("select",
|
|
|
|
|
CommandObjectSP(new CommandObjectFrameSelect(interpreter)));
|
|
|
|
|
LoadSubCommand("variable",
|
|
|
|
|
CommandObjectSP(new CommandObjectFrameVariable(interpreter)));
|
2019-12-13 10:37:33 -08:00
|
|
|
#if LLDB_ENABLE_PYTHON
|
2019-10-30 15:26:19 -07:00
|
|
|
LoadSubCommand("recognizer", CommandObjectSP(new CommandObjectFrameRecognizer(
|
|
|
|
|
interpreter)));
|
2018-10-31 04:00:22 +00:00
|
|
|
#endif
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-19 19:33:46 +00:00
|
|
|
CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame() = default;
|