[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 15:23:27 +08:00
|
|
|
//===-- CommandObjectFrame.cpp --------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08: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-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2016-02-20 03:33:46 +08:00
|
|
|
#include "CommandObjectFrame.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2010-09-02 08:18:39 +08:00
|
|
|
#include "lldb/Core/ValueObject.h"
|
2013-01-29 07:47:25 +08: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-10-01 03:11:51 +08:00
|
|
|
#include "lldb/DataFormatters/ValueObjectPrinter.h"
|
2019-12-11 00:54:30 +08:00
|
|
|
#include "lldb/Host/Config.h"
|
2017-03-23 07:33:16 +08:00
|
|
|
#include "lldb/Host/OptionParser.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
2011-10-25 14:44:01 +08:00
|
|
|
#include "lldb/Interpreter/OptionGroupFormat.h"
|
2011-05-04 11:43:18 +08:00
|
|
|
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
|
2011-07-07 12:38:25 +08:00
|
|
|
#include "lldb/Interpreter/OptionGroupVariable.h"
|
2015-08-12 06:53:00 +08:00
|
|
|
#include "lldb/Interpreter/Options.h"
|
2015-10-01 07:12:22 +08:00
|
|
|
#include "lldb/Symbol/Function.h"
|
2010-09-02 08:18:39 +08:00
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
|
|
|
#include "lldb/Symbol/Variable.h"
|
|
|
|
#include "lldb/Symbol/VariableList.h"
|
2013-11-04 17:33:30 +08:00
|
|
|
#include "lldb/Target/StackFrame.h"
|
2018-10-31 12:00:22 +08: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 12:48:36 +08:00
|
|
|
#include "lldb/Target/StopInfo.h"
|
2010-09-02 08:18:39 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
2018-04-18 02:53:35 +08:00
|
|
|
#include "lldb/Utility/Args.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-02-12 07:13:08 +08:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
2010-06-09 00:52:24 +08: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 12:48:36 +08:00
|
|
|
#pragma mark CommandObjectFrameDiagnose
|
|
|
|
|
|
|
|
// CommandObjectFrameInfo
|
|
|
|
|
|
|
|
// CommandObjectFrameDiagnose
|
|
|
|
|
2019-07-25 19:22:46 +08: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-23 04:22:55 +08: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 12:48:36 +08:00
|
|
|
class CommandObjectFrameDiagnose : public CommandObjectParsed {
|
|
|
|
public:
|
|
|
|
class CommandOptions : public Options {
|
|
|
|
public:
|
|
|
|
CommandOptions() : Options() { OptionParsingStarting(nullptr); }
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
~CommandOptions() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-05-12 12:51:55 +08: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 12:48:36 +08:00
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
|
|
|
switch (short_option) {
|
|
|
|
case 'r':
|
|
|
|
reg = ConstString(option_arg);
|
|
|
|
break;
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
case 'a': {
|
2016-11-13 00:56:47 +08: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 12:48:36 +08:00
|
|
|
address.reset();
|
|
|
|
error.SetErrorStringWithFormat("invalid address argument '%s'",
|
2016-11-13 00:56:47 +08: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 12:48:36 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
case 'o': {
|
2016-11-13 00:56:47 +08: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 12:48:36 +08:00
|
|
|
offset.reset();
|
|
|
|
error.SetErrorStringWithFormat("invalid offset argument '%s'",
|
2016-11-13 00:56:47 +08: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 12:48:36 +08:00
|
|
|
}
|
|
|
|
} break;
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
default:
|
2019-08-22 16:08:05 +08:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
return error;
|
|
|
|
}
|
2016-09-07 04:57:50 +08: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 12:48:36 +08: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-23 04:22:55 +08:00
|
|
|
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
|
2016-09-23 05:06:13 +08:00
|
|
|
return llvm::makeArrayRef(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-23 04:22:55 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
// Options.
|
|
|
|
llvm::Optional<lldb::addr_t> address;
|
|
|
|
llvm::Optional<ConstString> reg;
|
|
|
|
llvm::Optional<int64_t> offset;
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
CommandObjectFrameDiagnose(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(interpreter, "frame diagnose",
|
|
|
|
"Try to determine what path path the current stop "
|
|
|
|
"location used to get to a register or address",
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
eCommandRequiresThread | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched |
|
|
|
|
eCommandProcessMustBePaused),
|
2016-08-12 07:51:28 +08:00
|
|
|
m_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 12:48:36 +08:00
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData index_arg;
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
// Define the first (and only) variant of this arg.
|
2010-10-05 06:28:36 +08:00
|
|
|
index_arg.arg_type = eArgTypeFrameIndex;
|
2010-10-11 06:28:11 +08:00
|
|
|
index_arg.arg_repetition = eArgRepeatOptional;
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
// There is only one variant this argument could be; put it into the
|
|
|
|
// argument entry.
|
|
|
|
arg.push_back(index_arg);
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
// Push the data for the first argument into the m_arguments vector.
|
|
|
|
m_arguments.push_back(arg);
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
~CommandObjectFrameDiagnose() override = default;
|
2016-09-07 04:57:50 +08: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-10-01 03:11:51 +08:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
protected:
|
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
|
|
|
Thread *thread = m_exe_ctx.GetThreadPtr();
|
|
|
|
StackFrameSP frame_sp = thread->GetSelectedFrame();
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
ValueObjectSP valobj_sp;
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
if (m_options.address.hasValue()) {
|
|
|
|
if (m_options.reg.hasValue() || m_options.offset.hasValue()) {
|
|
|
|
result.AppendError(
|
|
|
|
"`frame diagnose --address` is incompatible with other arguments.");
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
valobj_sp = frame_sp->GuessValueForAddress(m_options.address.getValue());
|
|
|
|
} else if (m_options.reg.hasValue()) {
|
|
|
|
valobj_sp = frame_sp->GuessValueForRegisterAndOffset(
|
|
|
|
m_options.reg.getValue(), m_options.offset.getValueOr(0));
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
StopInfoSP stop_info_sp = thread->GetStopInfo();
|
|
|
|
if (!stop_info_sp) {
|
|
|
|
result.AppendError("No arguments provided, and no stop info.");
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
valobj_sp = StopInfo::GetCrashingDereference(stop_info_sp);
|
|
|
|
}
|
|
|
|
|
2016-09-06 20:48:10 +08: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 12:48:36 +08:00
|
|
|
result.AppendError("No diagnosis available.");
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-10-31 06:26:19 +08: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 12:48:36 +08:00
|
|
|
const ValueObject::GetExpressionPathFormat format = ValueObject::
|
|
|
|
GetExpressionPathFormat::eGetExpressionPathFormatHonorPointers;
|
2020-02-03 06: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 12:48:36 +08:00
|
|
|
stream.PutCString(" =");
|
|
|
|
return true;
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
DumpValueObjectOptions options;
|
|
|
|
options.SetDeclPrintingHelper(helper);
|
|
|
|
ValueObjectPrinter printer(valobj_sp.get(), &result.GetOutputStream(),
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
printer.PrintValueObject();
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08: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 12:48:36 +08:00
|
|
|
CommandOptions m_options;
|
|
|
|
};
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark CommandObjectFrameInfo
|
|
|
|
|
|
|
|
// CommandObjectFrameInfo
|
|
|
|
|
2012-06-09 05:56:10 +08:00
|
|
|
class CommandObjectFrameInfo : public CommandObjectParsed {
|
2010-06-09 00:52:24 +08:00
|
|
|
public:
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectFrameInfo(CommandInterpreter &interpreter)
|
2019-10-31 06:26:19 +08:00
|
|
|
: CommandObjectParsed(interpreter, "frame info",
|
|
|
|
"List information about the current "
|
|
|
|
"stack frame in the current thread.",
|
|
|
|
"frame info",
|
|
|
|
eCommandRequiresFrame | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched |
|
|
|
|
eCommandProcessMustBePaused) {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
~CommandObjectFrameInfo() override = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-06-09 05:56:10 +08:00
|
|
|
protected:
|
2015-10-08 00:56:17 +08:00
|
|
|
bool 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-10 03:44:40 +08:00
|
|
|
m_exe_ctx.GetFrameRef().DumpUsingSettingsFormat(&result.GetOutputStream());
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
2010-06-09 00:52:24 +08:00
|
|
|
return result.Succeeded();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma mark CommandObjectFrameSelect
|
|
|
|
|
|
|
|
// CommandObjectFrameSelect
|
|
|
|
|
2019-07-25 19:22:46 +08: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-23 04:22:55 +08:00
|
|
|
|
2012-06-09 05:56:10 +08:00
|
|
|
class CommandObjectFrameSelect : public CommandObjectParsed {
|
2010-06-09 00:52:24 +08:00
|
|
|
public:
|
2016-02-20 03:33:46 +08:00
|
|
|
class CommandOptions : public Options {
|
2010-10-11 06:28:11 +08:00
|
|
|
public:
|
2016-08-12 07:51:28 +08:00
|
|
|
CommandOptions() : Options() { OptionParsingStarting(nullptr); }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
~CommandOptions() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
|
|
|
|
ExecutionContext *execution_context) override {
|
|
|
|
Status error;
|
2012-12-04 08:32:51 +08:00
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
2010-10-11 06:28:11 +08:00
|
|
|
switch (short_option) {
|
2019-09-30 20:49:32 +08:00
|
|
|
case 'r': {
|
|
|
|
int32_t offset = 0;
|
|
|
|
if (option_arg.getAsInteger(0, offset) || offset == INT32_MIN) {
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat("invalid frame offset argument '%s'",
|
2016-11-13 00:56:47 +08:00
|
|
|
option_arg.str().c_str());
|
2019-09-30 20:49:32 +08:00
|
|
|
} else
|
|
|
|
relative_frame_offset = offset;
|
2010-10-11 06:28:11 +08:00
|
|
|
break;
|
2019-09-30 20:49:32 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-10-11 06:28:11 +08:00
|
|
|
default:
|
2019-08-22 16:08:05 +08:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2010-10-11 06:28:11 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-10-11 06:28:11 +08:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2019-09-30 17:00:23 +08:00
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
2019-09-30 20:49:32 +08:00
|
|
|
relative_frame_offset.reset();
|
2019-09-30 17:00:23 +08: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-23 04:22:55 +08:00
|
|
|
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
|
2016-09-23 05:06:13 +08:00
|
|
|
return llvm::makeArrayRef(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-23 04:22:55 +08:00
|
|
|
}
|
2010-10-11 06:28:11 +08:00
|
|
|
|
2019-09-30 20:49:32 +08:00
|
|
|
llvm::Optional<int32_t> relative_frame_offset;
|
2010-10-11 06:28:11 +08:00
|
|
|
};
|
2016-07-15 06:03:10 +08:00
|
|
|
|
|
|
|
CommandObjectFrameSelect(CommandInterpreter &interpreter)
|
2019-10-31 06:26:19 +08:00
|
|
|
: CommandObjectParsed(interpreter, "frame select",
|
|
|
|
"Select the current stack frame by "
|
|
|
|
"index from within the current thread "
|
|
|
|
"(see 'thread backtrace'.)",
|
|
|
|
nullptr,
|
|
|
|
eCommandRequiresThread | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched |
|
|
|
|
eCommandProcessMustBePaused),
|
2016-08-12 07:51:28 +08:00
|
|
|
m_options() {
|
2010-10-05 06:28:36 +08:00
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData index_arg;
|
|
|
|
|
|
|
|
// Define the first (and only) variant of this arg.
|
|
|
|
index_arg.arg_type = eArgTypeFrameIndex;
|
2010-10-11 06:28:11 +08:00
|
|
|
index_arg.arg_repetition = eArgRepeatOptional;
|
2010-10-05 06:28:36 +08:00
|
|
|
|
|
|
|
// There is only one variant this argument could be; put it into the
|
|
|
|
// argument entry.
|
|
|
|
arg.push_back(index_arg);
|
|
|
|
|
|
|
|
// Push the data for the first argument into the m_arguments vector.
|
|
|
|
m_arguments.push_back(arg);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
~CommandObjectFrameSelect() override = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2020-06-30 19:02:18 +08:00
|
|
|
void
|
|
|
|
HandleArgumentCompletion(CompletionRequest &request,
|
|
|
|
OptionElementVector &opt_element_vector) override {
|
2020-08-11 18:20:43 +08:00
|
|
|
if (request.GetCursorIndex() != 0)
|
2020-06-30 19:02:18 +08:00
|
|
|
return;
|
|
|
|
|
2020-08-11 18:20:43 +08:00
|
|
|
CommandCompletions::InvokeCommonCompletionCallbacks(
|
|
|
|
GetCommandInterpreter(), CommandCompletions::eFrameIndexCompletion,
|
|
|
|
request, nullptr);
|
2020-06-30 19:02:18 +08:00
|
|
|
}
|
|
|
|
|
2015-10-08 00:56:17 +08:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
2010-10-11 06:28:11 +08:00
|
|
|
|
2012-06-09 05:56:10 +08:00
|
|
|
protected:
|
2015-10-08 00:56:17 +08:00
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
2015-05-27 13:04:35 +08: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-10 03:44:40 +08:00
|
|
|
Thread *thread = m_exe_ctx.GetThreadPtr();
|
2016-09-07 04:57:50 +08: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-10 03:44:40 +08:00
|
|
|
uint32_t frame_idx = UINT32_MAX;
|
2019-09-30 20:49:32 +08:00
|
|
|
if (m_options.relative_frame_offset.hasValue()) {
|
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-10 03:44:40 +08:00
|
|
|
// The one and only argument is a signed relative frame index
|
|
|
|
frame_idx = thread->GetSelectedFrameIndex();
|
|
|
|
if (frame_idx == UINT32_MAX)
|
|
|
|
frame_idx = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-09-30 20:49:32 +08: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-10 03:44:40 +08:00
|
|
|
else {
|
|
|
|
if (frame_idx == 0) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// If you are already at the bottom of the stack, then just warn
|
|
|
|
// and don't reset the frame.
|
2016-07-15 06:03:10 +08:00
|
|
|
result.AppendError("Already at the bottom of the stack.");
|
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-10 03:44:40 +08:00
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
} else
|
|
|
|
frame_idx = 0;
|
|
|
|
}
|
2019-09-30 20:49:32 +08:00
|
|
|
} else if (*m_options.relative_frame_offset > 0) {
|
2015-01-16 04:08:35 +08:00
|
|
|
// I don't want "up 20" where "20" takes you past the top of the stack
|
|
|
|
// to produce
|
2016-07-15 06:03:10 +08:00
|
|
|
// an error, but rather to just go to the top. So I have to count the
|
2013-11-06 02:25:23 +08:00
|
|
|
// stack here...
|
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-10 03:44:40 +08:00
|
|
|
const uint32_t num_frames = thread->GetStackFrameCount();
|
|
|
|
if (static_cast<int32_t>(num_frames - frame_idx) >
|
2019-09-30 20:49:32 +08:00
|
|
|
*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-10 03:44:40 +08:00
|
|
|
else {
|
2015-12-23 00:50:28 +08:00
|
|
|
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.");
|
2016-08-12 07:51:28 +08:00
|
|
|
result.SetStatus(eReturnStatusFailed);
|
2015-12-23 00:50:28 +08:00
|
|
|
return false;
|
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-10 03:44:40 +08:00
|
|
|
} else
|
|
|
|
frame_idx = num_frames - 1;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-02-01 05:46:01 +08:00
|
|
|
} else {
|
2016-12-08 10:02:09 +08:00
|
|
|
if (command.GetArgumentCount() > 1) {
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"too many arguments; expected frame-index, saw '%s'.\n",
|
2016-12-09 09:20:58 +08:00
|
|
|
command[0].c_str());
|
2016-12-08 10:02:09 +08:00
|
|
|
m_options.GenerateOptionUsage(
|
|
|
|
result.GetErrorStream(), this,
|
|
|
|
GetCommandInterpreter().GetDebugger().GetTerminalWidth());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
if (command.GetArgumentCount() == 1) {
|
2019-09-13 19:26:48 +08: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-10 03:44:40 +08:00
|
|
|
result.AppendErrorWithFormat("invalid frame index argument '%s'.",
|
2016-12-08 10:02:09 +08:00
|
|
|
command[0].c_str());
|
2013-02-01 05:46:01 +08:00
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2013-02-01 05:46:01 +08:00
|
|
|
} else if (command.GetArgumentCount() == 0) {
|
|
|
|
frame_idx = thread->GetSelectedFrameIndex();
|
|
|
|
if (frame_idx == UINT32_MAX) {
|
|
|
|
frame_idx = 0;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
bool success = thread->SetSelectedFrameByIndexNoisily(
|
2011-09-13 07:58:53 +08:00
|
|
|
frame_idx, result.GetOutputStream());
|
2013-11-06 02:25:23 +08:00
|
|
|
if (success) {
|
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 12:48:36 +08:00
|
|
|
m_exe_ctx.SetFrameSP(thread->GetSelectedFrame());
|
2013-02-01 05:46:01 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2013-02-01 05:46:01 +08:00
|
|
|
result.AppendErrorWithFormat("Frame index (%u) out of range.\n",
|
2015-01-16 04:08:35 +08:00
|
|
|
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-10 03:44:40 +08:00
|
|
|
result.SetStatus(eReturnStatusFailed);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-10-11 06:28:11 +08:00
|
|
|
|
2010-09-02 08:18:39 +08:00
|
|
|
return result.Succeeded();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-10-11 06:28:11 +08:00
|
|
|
CommandOptions m_options;
|
|
|
|
};
|
|
|
|
|
2010-09-02 08:18:39 +08:00
|
|
|
#pragma mark CommandObjectFrameVariable
|
|
|
|
// List images with associated information
|
2012-06-09 05:56:10 +08:00
|
|
|
class CommandObjectFrameVariable : public CommandObjectParsed {
|
2010-09-02 08:18:39 +08:00
|
|
|
public:
|
2016-07-15 06:03:10 +08: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, "
|
|
|
|
"local, file static and file global variables can be specified. "
|
|
|
|
"Children of aggregate variables can be specified such as "
|
2018-10-10 08:51:30 +08:00
|
|
|
"'var->child.x'. The -> and [] operators in 'frame variable' 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."
|
|
|
|
"\nIt 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.",
|
2019-10-31 06:26:19 +08:00
|
|
|
nullptr,
|
|
|
|
eCommandRequiresFrame | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused |
|
|
|
|
eCommandRequiresProcess),
|
2016-08-12 07:51:28 +08:00
|
|
|
m_option_group(),
|
2016-07-15 06:03:10 +08:00
|
|
|
m_option_variable(
|
|
|
|
true), // Include the frame specific options by passing "true"
|
2019-10-31 06:26:19 +08:00
|
|
|
m_option_format(eFormatDefault), m_varobj_options() {
|
2010-10-05 06:28:36 +08:00
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData var_name_arg;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-10-05 06:28:36 +08:00
|
|
|
// Define the first (and only) variant of this arg.
|
|
|
|
var_name_arg.arg_type = eArgTypeVarName;
|
|
|
|
var_name_arg.arg_repetition = eArgRepeatStar;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-10-05 06:28:36 +08:00
|
|
|
// There is only one variant this argument could be; put it into the
|
|
|
|
// argument entry.
|
|
|
|
arg.push_back(var_name_arg);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-10-05 06:28:36 +08:00
|
|
|
// Push the data for the first argument into the m_arguments vector.
|
|
|
|
m_arguments.push_back(arg);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-07-07 12:38:25 +08: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-28 01:55:14 +08:00
|
|
|
m_option_group.Append(&m_option_format,
|
|
|
|
OptionGroupFormat::OPTION_GROUP_FORMAT |
|
|
|
|
OptionGroupFormat::OPTION_GROUP_GDB_FMT,
|
|
|
|
LLDB_OPT_SET_1);
|
2011-05-04 11:43:18 +08:00
|
|
|
m_option_group.Append(&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
|
|
|
|
m_option_group.Finalize();
|
2010-09-02 08:18:39 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
~CommandObjectFrameVariable() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-05-04 11:43:18 +08:00
|
|
|
Options *GetOptions() override { return &m_option_group; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void
|
|
|
|
HandleArgumentCompletion(CompletionRequest &request,
|
|
|
|
OptionElementVector &opt_element_vector) override {
|
2013-05-15 07:43:18 +08:00
|
|
|
// Arguments are the standard source file completer.
|
2016-08-12 07:51:28 +08:00
|
|
|
CommandCompletions::InvokeCommonCompletionCallbacks(
|
2016-02-20 03:33:46 +08:00
|
|
|
GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion,
|
2018-07-14 02:28:14 +08:00
|
|
|
request, nullptr);
|
2013-05-15 07:43:18 +08:00
|
|
|
}
|
2010-09-02 08:18:39 +08:00
|
|
|
|
2012-06-09 05:56:10 +08:00
|
|
|
protected:
|
2016-10-27 03:17:49 +08:00
|
|
|
llvm::StringRef GetScopeString(VariableSP var_sp) {
|
|
|
|
if (!var_sp)
|
|
|
|
return llvm::StringRef::withNullAsEmpty(nullptr);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return llvm::StringRef::withNullAsEmpty(nullptr);
|
|
|
|
}
|
|
|
|
|
2015-10-08 00:56:17 +08:00
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
2018-05-01 00:49:04 +08:00
|
|
|
// No need to check "frame" for validity as eCommandRequiresFrame ensures
|
|
|
|
// it is valid
|
2013-11-04 17:33:30 +08:00
|
|
|
StackFrame *frame = m_exe_ctx.GetFramePtr();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-09-13 07:58:53 +08:00
|
|
|
Stream &s = result.GetOutputStream();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-09-13 07:58:53 +08:00
|
|
|
// Be careful about the stack frame, if any summary formatter runs code, it
|
2018-05-01 00:49:04 +08:00
|
|
|
// might clear the StackFrameList for the thread. So hold onto a shared
|
|
|
|
// pointer to the frame so it stays alive.
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-06-10 07:56:12 +08:00
|
|
|
VariableList *variable_list =
|
|
|
|
frame->GetVariableList(m_option_variable.show_globals);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-08-10 06:02:51 +08:00
|
|
|
VariableSP var_sp;
|
<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-10-01 03:11:51 +08:00
|
|
|
ValueObjectSP valobj_sp;
|
2016-09-07 04:57:50 +08: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-10-01 03:11:51 +08:00
|
|
|
TypeSummaryImplSP summary_format_sp;
|
2015-10-01 07:12:22 +08:00
|
|
|
if (!m_option_variable.summary.IsCurrentValueEmpty())
|
2011-10-25 14:44:01 +08:00
|
|
|
DataVisualization::NamedSummaryFormats::GetSummaryFormat(
|
2016-02-20 03:33:46 +08:00
|
|
|
ConstString(m_option_variable.summary.GetCurrentValue()),
|
|
|
|
summary_format_sp);
|
2011-09-13 07:58:53 +08:00
|
|
|
else if (!m_option_variable.summary_string.IsCurrentValueEmpty())
|
2019-02-12 07:13:08 +08:00
|
|
|
summary_format_sp = std::make_shared<StringSummaryFormat>(
|
2011-09-13 07:58:53 +08:00
|
|
|
TypeSummaryImpl::Flags(),
|
2019-02-12 07:13:08 +08:00
|
|
|
m_option_variable.summary_string.GetCurrentValue());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-09-13 07:58:53 +08:00
|
|
|
DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(
|
|
|
|
eLanguageRuntimeDescriptionDisplayVerbosityFull, eFormatDefault,
|
2012-08-10 06:02:51 +08:00
|
|
|
summary_format_sp));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-09-13 07:58:53 +08:00
|
|
|
const SymbolContext &sym_ctx =
|
2011-09-22 12:58:26 +08:00
|
|
|
frame->GetSymbolContext(eSymbolContextFunction);
|
2011-09-13 07:58:53 +08:00
|
|
|
if (sym_ctx.function && sym_ctx.function->IsTopLevelFunction())
|
|
|
|
m_option_variable.show_globals = true;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-09-13 07:58:53 +08: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-10-01 03:11:51 +08:00
|
|
|
const Format format = m_option_format.GetFormat();
|
2012-03-01 12:24:26 +08:00
|
|
|
options.SetFormat(format);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-10-06 04:03:37 +08:00
|
|
|
if (!command.empty()) {
|
2011-09-13 07:58:53 +08:00
|
|
|
VariableList regex_var_list;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// If we have any args to the variable command, we will make variable
|
|
|
|
// objects from them...
|
2016-12-08 10:02:09 +08:00
|
|
|
for (auto &entry : command) {
|
2012-08-10 06:02:51 +08:00
|
|
|
if (m_option_variable.use_regex) {
|
2011-09-13 07:58:53 +08:00
|
|
|
const size_t regex_start_index = regex_var_list.GetSize();
|
2019-09-13 19:26:48 +08:00
|
|
|
llvm::StringRef name_str = entry.ref();
|
2016-09-22 00:01:28 +08:00
|
|
|
RegularExpression regex(name_str);
|
2019-08-20 17:24:20 +08:00
|
|
|
if (regex.IsValid()) {
|
2014-08-12 02:06:28 +08:00
|
|
|
size_t num_matches = 0;
|
|
|
|
const size_t num_new_regex_vars =
|
2011-09-13 07:58:53 +08:00
|
|
|
variable_list->AppendVariablesIfUnique(regex, regex_var_list,
|
2013-11-04 17:33:30 +08:00
|
|
|
num_matches);
|
|
|
|
if (num_new_regex_vars > 0) {
|
|
|
|
for (size_t regex_idx = regex_start_index,
|
2015-11-20 06:28:58 +08:00
|
|
|
end_index = regex_var_list.GetSize();
|
|
|
|
regex_idx < end_index; ++regex_idx) {
|
2011-09-13 07:58:53 +08:00
|
|
|
var_sp = regex_var_list.GetVariableAtIndex(regex_idx);
|
2011-09-22 12:58:26 +08:00
|
|
|
if (var_sp) {
|
|
|
|
valobj_sp = frame->GetValueObjectForFrameVariable(
|
|
|
|
var_sp, m_varobj_options.use_dynamic);
|
2011-09-13 07:58:53 +08:00
|
|
|
if (valobj_sp) {
|
2016-10-27 03:17:49 +08:00
|
|
|
std::string scope_string;
|
|
|
|
if (m_option_variable.show_scope)
|
|
|
|
scope_string = GetScopeString(var_sp).str();
|
|
|
|
|
|
|
|
if (!scope_string.empty())
|
2016-11-03 04:34:10 +08:00
|
|
|
s.PutCString(scope_string);
|
2016-10-27 03:17:49 +08:00
|
|
|
|
2011-09-13 07:58:53 +08:00
|
|
|
if (m_option_variable.show_decl &&
|
|
|
|
var_sp->GetDeclaration().GetFile()) {
|
|
|
|
bool show_fullpaths = false;
|
|
|
|
bool show_module = true;
|
2016-02-20 03:33:46 +08:00
|
|
|
if (var_sp->DumpDeclaration(&s, show_fullpaths,
|
|
|
|
show_module))
|
|
|
|
s.PutCString(": ");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-09-13 07:58:53 +08:00
|
|
|
valobj_sp->Dump(result.GetOutputStream(), options);
|
2010-09-02 08:18:39 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-09-02 08:18:39 +08: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-10 03:44:40 +08:00
|
|
|
} else if (num_matches == 0) {
|
2011-09-13 07:58:53 +08:00
|
|
|
result.GetErrorStream().Printf("error: no variables matched "
|
2016-07-15 06:03:10 +08:00
|
|
|
"the regular expression '%s'.\n",
|
2016-12-08 10:02:09 +08:00
|
|
|
entry.c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} else {
|
2019-08-17 05:25:36 +08:00
|
|
|
if (llvm::Error err = regex.GetError())
|
|
|
|
result.GetErrorStream().Printf(
|
|
|
|
"error: %s\n", llvm::toString(std::move(err)).c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2016-07-15 06:03:10 +08:00
|
|
|
result.GetErrorStream().Printf(
|
2014-08-12 02:06:28 +08:00
|
|
|
"error: unknown regex error when compiling '%s'\n",
|
2016-12-08 10:02:09 +08:00
|
|
|
entry.c_str());
|
2011-09-13 07:58:53 +08:00
|
|
|
}
|
|
|
|
} else // No regex, either exact variable names or variable
|
|
|
|
// expressions.
|
|
|
|
{
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2013-01-26 02:06:21 +08:00
|
|
|
uint32_t expr_path_options =
|
|
|
|
StackFrame::eExpressionPathOptionCheckPtrVsMember |
|
2011-09-13 07:58:53 +08:00
|
|
|
StackFrame::eExpressionPathOptionsAllowDirectIVarAccess |
|
2015-02-11 10:35:39 +08:00
|
|
|
StackFrame::eExpressionPathOptionsInspectAnonymousUnions;
|
2011-09-13 07:58:53 +08:00
|
|
|
lldb::VariableSP var_sp;
|
2010-09-13 11:44:33 +08:00
|
|
|
valobj_sp = frame->GetValueForVariableExpressionPath(
|
2019-09-13 19:26:48 +08:00
|
|
|
entry.ref(), m_varobj_options.use_dynamic, expr_path_options,
|
2016-06-10 07:56:12 +08:00
|
|
|
var_sp, error);
|
2011-09-13 07:58:53 +08:00
|
|
|
if (valobj_sp) {
|
2016-10-27 03:17:49 +08:00
|
|
|
std::string scope_string;
|
|
|
|
if (m_option_variable.show_scope)
|
|
|
|
scope_string = GetScopeString(var_sp).str();
|
|
|
|
|
|
|
|
if (!scope_string.empty())
|
2016-11-03 04:34:10 +08:00
|
|
|
s.PutCString(scope_string);
|
2011-07-07 12:38:25 +08:00
|
|
|
if (m_option_variable.show_decl && var_sp &&
|
2016-07-02 01:17:23 +08:00
|
|
|
var_sp->GetDeclaration().GetFile()) {
|
|
|
|
var_sp->GetDeclaration().DumpStopContext(&s, false);
|
|
|
|
s.PutCString(": ");
|
2011-09-13 07:58:53 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-03-01 12:24:26 +08:00
|
|
|
options.SetFormat(format);
|
2011-09-13 07:58:53 +08:00
|
|
|
options.SetVariableFormatDisplayLanguage(
|
|
|
|
valobj_sp->GetPreferredDisplayLanguage());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-09-13 07:58:53 +08:00
|
|
|
Stream &output_stream = result.GetOutputStream();
|
2016-12-08 10:02:09 +08:00
|
|
|
options.SetRootValueObjectName(
|
|
|
|
valobj_sp->GetParent() ? entry.c_str() : nullptr);
|
2011-09-13 07:58:53 +08:00
|
|
|
valobj_sp->Dump(output_stream, options);
|
|
|
|
} else {
|
2012-03-01 12:24:26 +08:00
|
|
|
const char *error_cstr = error.AsCString(nullptr);
|
2011-09-13 07:58:53 +08:00
|
|
|
if (error_cstr)
|
<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-10-01 03:11:51 +08:00
|
|
|
result.GetErrorStream().Printf("error: %s\n", error_cstr);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
<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-10-01 03:11:51 +08:00
|
|
|
result.GetErrorStream().Printf("error: unable to find any "
|
|
|
|
"variable expression path that "
|
2016-07-15 06:03:10 +08:00
|
|
|
"matches '%s'.\n",
|
2016-12-08 10:02:09 +08:00
|
|
|
entry.c_str());
|
2010-09-02 08:18:39 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-09-02 08:18:39 +08:00
|
|
|
}
|
2011-08-13 00:42:31 +08:00
|
|
|
} else // No command arg specified. Use variable_list, instead.
|
2016-09-07 04:57:50 +08:00
|
|
|
{
|
2011-08-13 00:42:31 +08:00
|
|
|
const size_t num_variables = variable_list->GetSize();
|
2011-09-13 07:58:53 +08:00
|
|
|
if (num_variables > 0) {
|
2013-01-26 02:06:21 +08:00
|
|
|
for (size_t i = 0; i < num_variables; i++) {
|
2011-08-13 00:42:31 +08:00
|
|
|
var_sp = variable_list->GetVariableAtIndex(i);
|
2017-06-19 14:57:54 +08:00
|
|
|
switch (var_sp->GetScope()) {
|
|
|
|
case eValueTypeVariableGlobal:
|
|
|
|
if (!m_option_variable.show_globals)
|
2017-04-19 00:52:16 +08:00
|
|
|
continue;
|
2017-06-19 14:57:54 +08:00
|
|
|
break;
|
|
|
|
case eValueTypeVariableStatic:
|
|
|
|
if (!m_option_variable.show_globals)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
case eValueTypeVariableArgument:
|
|
|
|
if (!m_option_variable.show_args)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
case eValueTypeVariableLocal:
|
|
|
|
if (!m_option_variable.show_locals)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
break;
|
2017-04-19 00:52:16 +08:00
|
|
|
}
|
2017-06-19 14:57:54 +08:00
|
|
|
std::string scope_string;
|
|
|
|
if (m_option_variable.show_scope)
|
|
|
|
scope_string = GetScopeString(var_sp).str();
|
2017-04-19 00:52:16 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// Use the variable object code to make sure we are using the same
|
|
|
|
// APIs as the public API will be using...
|
2017-04-19 00:52:16 +08:00
|
|
|
valobj_sp = frame->GetValueObjectForFrameVariable(
|
|
|
|
var_sp, m_varobj_options.use_dynamic);
|
|
|
|
if (valobj_sp) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// When dumping all variables, don't print any variables that are
|
|
|
|
// not in scope to avoid extra unneeded output
|
2017-04-19 00:52:16 +08: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-07 04:57:50 +08:00
|
|
|
}
|
2017-04-19 00:52:16 +08: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-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-13 00:42:31 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-09-02 08:18:39 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
}
|
|
|
|
|
2018-10-31 12:00:22 +08: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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:42:31 +08:00
|
|
|
if (m_interpreter.TruncationWarningNecessary()) {
|
|
|
|
result.GetOutputStream().Printf(m_interpreter.TruncationWarningText(),
|
|
|
|
m_cmd_name.c_str());
|
|
|
|
m_interpreter.TruncationWarningGiven();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2018-04-14 02:02:39 +08:00
|
|
|
// Increment statistics.
|
|
|
|
bool res = result.Succeeded();
|
2019-08-27 02:12:44 +08:00
|
|
|
Target &target = GetSelectedOrDummyTarget();
|
2018-04-14 02:02:39 +08:00
|
|
|
if (res)
|
2019-08-27 02:12:44 +08:00
|
|
|
target.IncrementStats(StatisticKind::FrameVarSuccess);
|
2018-04-14 02:02:39 +08:00
|
|
|
else
|
2019-08-27 02:12:44 +08:00
|
|
|
target.IncrementStats(StatisticKind::FrameVarFailure);
|
2018-04-14 02:02:39 +08:00
|
|
|
return res;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-05-04 11:43:18 +08:00
|
|
|
OptionGroupOptions m_option_group;
|
2011-07-07 12:38:25 +08:00
|
|
|
OptionGroupVariable m_option_variable;
|
2011-10-25 14:44:01 +08:00
|
|
|
OptionGroupFormat m_option_format;
|
2011-05-04 11:43:18 +08:00
|
|
|
OptionGroupValueObjectDisplay m_varobj_options;
|
2010-09-02 08:18:39 +08:00
|
|
|
};
|
|
|
|
|
2018-10-31 12:00:22 +08:00
|
|
|
#pragma mark CommandObjectFrameRecognizer
|
|
|
|
|
2019-07-25 19:22:46 +08:00
|
|
|
#define LLDB_OPTIONS_frame_recognizer_add
|
|
|
|
#include "CommandOptions.inc"
|
2018-10-31 12:00:22 +08:00
|
|
|
|
|
|
|
class CommandObjectFrameRecognizerAdd : public CommandObjectParsed {
|
|
|
|
private:
|
|
|
|
class CommandOptions : public Options {
|
|
|
|
public:
|
|
|
|
CommandOptions() : Options() {}
|
|
|
|
~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) {
|
|
|
|
case 'l':
|
|
|
|
m_class_name = std::string(option_arg);
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
m_module = std::string(option_arg);
|
|
|
|
break;
|
|
|
|
case 'n':
|
2020-03-14 06:56:35 +08:00
|
|
|
m_symbols.push_back(std::string(option_arg));
|
2018-10-31 12:00:22 +08:00
|
|
|
break;
|
|
|
|
case 'x':
|
|
|
|
m_regex = true;
|
|
|
|
break;
|
|
|
|
default:
|
2019-08-22 16:08:05 +08:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2018-10-31 12:00:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
|
|
|
m_module = "";
|
2020-03-14 06:56:35 +08:00
|
|
|
m_symbols.clear();
|
2018-10-31 12:00:22 +08:00
|
|
|
m_class_name = "";
|
|
|
|
m_regex = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
|
|
|
|
return llvm::makeArrayRef(g_frame_recognizer_add_options);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Instance variables to hold the values for command options.
|
|
|
|
std::string m_class_name;
|
|
|
|
std::string m_module;
|
2020-03-14 06:56:35 +08:00
|
|
|
std::vector<std::string> m_symbols;
|
2018-10-31 12:00:22 +08:00
|
|
|
bool m_regex;
|
|
|
|
};
|
|
|
|
|
|
|
|
CommandOptions m_options;
|
|
|
|
|
|
|
|
Options *GetOptions() override { return &m_options; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CommandObjectFrameRecognizerAdd(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(interpreter, "frame recognizer add",
|
|
|
|
"Add a new frame recognizer.", nullptr),
|
|
|
|
m_options() {
|
|
|
|
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
|
|
|
|
value = lldb.target.CreateValueFromExpression("fd", "(int)%d" % fd)
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool CommandObjectFrameRecognizerAdd::DoExecute(Args &command,
|
|
|
|
CommandReturnObject &result) {
|
2019-12-14 02:37:33 +08:00
|
|
|
#if LLDB_ENABLE_PYTHON
|
2018-10-31 12:00:22 +08:00
|
|
|
if (m_options.m_class_name.empty()) {
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"%s needs a Python class name (-l argument).\n", m_cmd_name.c_str());
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_options.m_module.empty()) {
|
|
|
|
result.AppendErrorWithFormat("%s needs a module name (-s argument).\n",
|
|
|
|
m_cmd_name.c_str());
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-03-14 06:56:35 +08:00
|
|
|
if (m_options.m_symbols.empty()) {
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"%s needs at least one symbol name (-n argument).\n",
|
|
|
|
m_cmd_name.c_str());
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
2018-10-31 12:00:22 +08:00
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-27 06:43:16 +08:00
|
|
|
ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
|
2018-10-31 12:00:22 +08:00
|
|
|
|
|
|
|
if (interpreter &&
|
|
|
|
!interpreter->CheckObjectExists(m_options.m_class_name.c_str())) {
|
2019-10-31 06:26:19 +08:00
|
|
|
result.AppendWarning("The provided class does not exist - please define it "
|
|
|
|
"before attempting to use this frame recognizer");
|
2018-10-31 12:00:22 +08: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-14 06:56:35 +08:00
|
|
|
RegularExpressionSP(new RegularExpression(m_options.m_symbols.front()));
|
2020-07-17 14:36:38 +08:00
|
|
|
GetSelectedOrDummyTarget().GetFrameRecognizerManager().AddRecognizer(
|
|
|
|
recognizer_sp, module, func);
|
2018-10-31 12:00:22 +08:00
|
|
|
} else {
|
|
|
|
auto module = ConstString(m_options.m_module);
|
2020-03-14 06:56:35 +08:00
|
|
|
std::vector<ConstString> symbols(m_options.m_symbols.begin(),
|
|
|
|
m_options.m_symbols.end());
|
2020-07-17 14:36:38 +08:00
|
|
|
GetSelectedOrDummyTarget().GetFrameRecognizerManager().AddRecognizer(
|
|
|
|
recognizer_sp, module, symbols);
|
2018-10-31 12:00:22 +08:00
|
|
|
}
|
2018-10-31 12:43:09 +08:00
|
|
|
#endif
|
2018-10-31 12:00:22 +08:00
|
|
|
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
|
|
|
return result.Succeeded();
|
|
|
|
}
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizerClear : public CommandObjectParsed {
|
|
|
|
public:
|
|
|
|
CommandObjectFrameRecognizerClear(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(interpreter, "frame recognizer clear",
|
2019-10-31 06:26:19 +08:00
|
|
|
"Delete all frame recognizers.", nullptr) {}
|
2018-10-31 12:00:22 +08:00
|
|
|
|
|
|
|
~CommandObjectFrameRecognizerClear() override = default;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
2020-07-17 14:36:38 +08:00
|
|
|
GetSelectedOrDummyTarget()
|
|
|
|
.GetFrameRecognizerManager()
|
|
|
|
.RemoveAllRecognizers();
|
2018-10-31 12:00:22 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
return result.Succeeded();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizerDelete : public CommandObjectParsed {
|
2019-10-31 06:26:19 +08:00
|
|
|
public:
|
2018-10-31 12:00:22 +08:00
|
|
|
CommandObjectFrameRecognizerDelete(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(interpreter, "frame recognizer delete",
|
|
|
|
"Delete an existing frame recognizer.", nullptr) {}
|
|
|
|
|
|
|
|
~CommandObjectFrameRecognizerDelete() override = default;
|
|
|
|
|
2020-06-30 19:14:46 +08:00
|
|
|
void
|
|
|
|
HandleArgumentCompletion(CompletionRequest &request,
|
|
|
|
OptionElementVector &opt_element_vector) override {
|
|
|
|
if (request.GetCursorIndex() != 0)
|
|
|
|
return;
|
|
|
|
|
2020-07-17 14:36:38 +08:00
|
|
|
GetSelectedOrDummyTarget().GetFrameRecognizerManager().ForEach(
|
2020-06-30 19:14:46 +08: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-31 06:26:19 +08:00
|
|
|
protected:
|
2018-10-31 12:00:22 +08:00
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
|
|
|
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...");
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-17 14:36:38 +08:00
|
|
|
GetSelectedOrDummyTarget()
|
|
|
|
.GetFrameRecognizerManager()
|
|
|
|
.RemoveAllRecognizers();
|
2018-10-31 12:00:22 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
return result.Succeeded();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command.GetArgumentCount() != 1) {
|
|
|
|
result.AppendErrorWithFormat("'%s' takes zero or one arguments.\n",
|
|
|
|
m_cmd_name.c_str());
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-01 23:00:12 +08: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));
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
2018-10-31 12:00:22 +08:00
|
|
|
|
2020-07-23 23:25:17 +08:00
|
|
|
if (!GetSelectedOrDummyTarget()
|
|
|
|
.GetFrameRecognizerManager()
|
|
|
|
.RemoveRecognizerWithID(recognizer_id)) {
|
|
|
|
result.AppendErrorWithFormat("'%s' is not a valid recognizer id.\n",
|
|
|
|
command.GetArgumentAtIndex(0));
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
2018-10-31 12:00:22 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
return result.Succeeded();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizerList : public CommandObjectParsed {
|
2019-10-31 06:26:19 +08:00
|
|
|
public:
|
2018-10-31 12:00:22 +08:00
|
|
|
CommandObjectFrameRecognizerList(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(interpreter, "frame recognizer list",
|
|
|
|
"Show a list of active frame recognizers.",
|
|
|
|
nullptr) {}
|
|
|
|
|
|
|
|
~CommandObjectFrameRecognizerList() override = default;
|
|
|
|
|
2019-10-31 06:26:19 +08:00
|
|
|
protected:
|
2018-10-31 12:00:22 +08:00
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
|
|
|
bool any_printed = false;
|
2020-07-17 14:36:38 +08:00
|
|
|
GetSelectedOrDummyTarget().GetFrameRecognizerManager().ForEach(
|
2020-03-14 06:56:35 +08:00
|
|
|
[&result, &any_printed](
|
|
|
|
uint32_t recognizer_id, std::string name, std::string module,
|
|
|
|
llvm::ArrayRef<ConstString> symbols, bool regexp) {
|
2020-02-11 06:29:12 +08:00
|
|
|
Stream &stream = result.GetOutputStream();
|
|
|
|
|
|
|
|
if (name.empty())
|
2019-10-31 06:26:19 +08:00
|
|
|
name = "(internal)";
|
2020-02-11 06:29:12 +08:00
|
|
|
|
|
|
|
stream << std::to_string(recognizer_id) << ": " << name;
|
|
|
|
if (!module.empty())
|
|
|
|
stream << ", module " << module;
|
2020-03-14 06:56:35 +08:00
|
|
|
if (!symbols.empty())
|
|
|
|
for (auto &symbol : symbols)
|
|
|
|
stream << ", symbol " << symbol;
|
2020-02-11 06:29:12 +08:00
|
|
|
if (regexp)
|
|
|
|
stream << " (regexp)";
|
|
|
|
|
|
|
|
stream.EOL();
|
|
|
|
stream.Flush();
|
|
|
|
|
2018-10-31 12:00:22 +08:00
|
|
|
any_printed = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (any_printed)
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
else {
|
|
|
|
result.GetOutputStream().PutCString("no matching results found.\n");
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
|
|
|
}
|
|
|
|
return result.Succeeded();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizerInfo : public CommandObjectParsed {
|
2019-10-31 06:26:19 +08:00
|
|
|
public:
|
2018-10-31 12:00:22 +08:00
|
|
|
CommandObjectFrameRecognizerInfo(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(
|
|
|
|
interpreter, "frame recognizer info",
|
|
|
|
"Show which frame recognizer is applied a stack frame (if any).",
|
|
|
|
nullptr) {
|
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData index_arg;
|
|
|
|
|
|
|
|
// Define the first (and only) variant of this arg.
|
|
|
|
index_arg.arg_type = eArgTypeFrameIndex;
|
|
|
|
index_arg.arg_repetition = eArgRepeatPlain;
|
|
|
|
|
|
|
|
// There is only one variant this argument could be; put it into the
|
|
|
|
// argument entry.
|
|
|
|
arg.push_back(index_arg);
|
|
|
|
|
|
|
|
// Push the data for the first argument into the m_arguments vector.
|
|
|
|
m_arguments.push_back(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
~CommandObjectFrameRecognizerInfo() override = default;
|
|
|
|
|
2019-10-31 06:26:19 +08:00
|
|
|
protected:
|
2018-10-31 12:00:22 +08:00
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
2020-07-01 23:00:12 +08: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);
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-31 12:00:22 +08:00
|
|
|
Process *process = m_exe_ctx.GetProcessPtr();
|
|
|
|
if (process == nullptr) {
|
|
|
|
result.AppendError("no process");
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Thread *thread = m_exe_ctx.GetThreadPtr();
|
|
|
|
if (thread == nullptr) {
|
|
|
|
result.AppendError("no thread");
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (command.GetArgumentCount() != 1) {
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"'%s' takes exactly one frame index argument.\n", m_cmd_name.c_str());
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
StackFrameSP frame_sp = thread->GetStackFrameAtIndex(frame_index);
|
|
|
|
if (!frame_sp) {
|
|
|
|
result.AppendErrorWithFormat("no frame with index %u", frame_index);
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-17 14:36:38 +08:00
|
|
|
auto recognizer = GetSelectedOrDummyTarget()
|
|
|
|
.GetFrameRecognizerManager()
|
|
|
|
.GetRecognizerForFrame(frame_sp);
|
2018-10-31 12:00:22 +08: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);
|
|
|
|
return result.Succeeded();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandObjectFrameRecognizer : public CommandObjectMultiword {
|
2019-10-31 06:26:19 +08:00
|
|
|
public:
|
2018-10-31 12:00:22 +08:00
|
|
|
CommandObjectFrameRecognizer(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectMultiword(
|
|
|
|
interpreter, "frame recognizer",
|
|
|
|
"Commands for editing and viewing frame recognizers.",
|
|
|
|
"frame recognizer [<sub-command-options>] ") {
|
2019-10-31 06:26:19 +08:00
|
|
|
LoadSubCommand("add", CommandObjectSP(new CommandObjectFrameRecognizerAdd(
|
|
|
|
interpreter)));
|
2018-10-31 12:00:22 +08:00
|
|
|
LoadSubCommand(
|
|
|
|
"clear",
|
|
|
|
CommandObjectSP(new CommandObjectFrameRecognizerClear(interpreter)));
|
|
|
|
LoadSubCommand(
|
|
|
|
"delete",
|
|
|
|
CommandObjectSP(new CommandObjectFrameRecognizerDelete(interpreter)));
|
2019-10-31 06:26:19 +08:00
|
|
|
LoadSubCommand("list", CommandObjectSP(new CommandObjectFrameRecognizerList(
|
|
|
|
interpreter)));
|
|
|
|
LoadSubCommand("info", CommandObjectSP(new CommandObjectFrameRecognizerInfo(
|
|
|
|
interpreter)));
|
2018-10-31 12:00:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
~CommandObjectFrameRecognizer() override = default;
|
|
|
|
};
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark CommandObjectMultiwordFrame
|
|
|
|
|
|
|
|
// CommandObjectMultiwordFrame
|
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectMultiwordFrame::CommandObjectMultiwordFrame(
|
|
|
|
CommandInterpreter &interpreter)
|
2019-10-31 06:26:19 +08:00
|
|
|
: CommandObjectMultiword(interpreter, "frame",
|
|
|
|
"Commands for selecting and "
|
|
|
|
"examing the current "
|
|
|
|
"thread's stack frames.",
|
2016-07-15 06:03:10 +08: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 12:48:36 +08:00
|
|
|
LoadSubCommand("diagnose",
|
|
|
|
CommandObjectSP(new CommandObjectFrameDiagnose(interpreter)));
|
2010-09-18 09:14:36 +08:00
|
|
|
LoadSubCommand("info",
|
|
|
|
CommandObjectSP(new CommandObjectFrameInfo(interpreter)));
|
|
|
|
LoadSubCommand("select",
|
|
|
|
CommandObjectSP(new CommandObjectFrameSelect(interpreter)));
|
|
|
|
LoadSubCommand("variable",
|
|
|
|
CommandObjectSP(new CommandObjectFrameVariable(interpreter)));
|
2019-12-14 02:37:33 +08:00
|
|
|
#if LLDB_ENABLE_PYTHON
|
2019-10-31 06:26:19 +08:00
|
|
|
LoadSubCommand("recognizer", CommandObjectSP(new CommandObjectFrameRecognizer(
|
|
|
|
interpreter)));
|
2018-10-31 12:00:22 +08:00
|
|
|
#endif
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-02-20 03:33:46 +08:00
|
|
|
CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame() = default;
|