[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
|
|
|
//===-- CommandObjectThread.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
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "CommandObjectThread.h"
|
|
|
|
|
2020-10-03 05:32:22 +08:00
|
|
|
#include <sstream>
|
|
|
|
|
2020-10-27 12:22:06 +08:00
|
|
|
#include "CommandObjectThreadUtil.h"
|
2020-11-10 05:36:26 +08:00
|
|
|
#include "CommandObjectTrace.h"
|
2020-10-27 12:22:06 +08:00
|
|
|
#include "lldb/Core/PluginManager.h"
|
2015-03-04 07:11:11 +08:00
|
|
|
#include "lldb/Core/ValueObject.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"
|
2018-04-10 17:03:59 +08:00
|
|
|
#include "lldb/Interpreter/OptionArgParser.h"
|
2019-10-04 06:50:18 +08:00
|
|
|
#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Interpreter/Options.h"
|
|
|
|
#include "lldb/Symbol/CompileUnit.h"
|
|
|
|
#include "lldb/Symbol/Function.h"
|
|
|
|
#include "lldb/Symbol/LineEntry.h"
|
|
|
|
#include "lldb/Symbol/LineTable.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2013-11-12 15:02:07 +08:00
|
|
|
#include "lldb/Target/SystemRuntime.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
#include "lldb/Target/ThreadPlan.h"
|
|
|
|
#include "lldb/Target/ThreadPlanStepInRange.h"
|
2020-10-03 05:32:22 +08:00
|
|
|
#include "lldb/Target/Trace.h"
|
2018-08-07 19:07:21 +08:00
|
|
|
#include "lldb/Utility/State.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
// CommandObjectThreadBacktrace
|
2019-07-18 19:12:00 +08:00
|
|
|
#define LLDB_OPTIONS_thread_backtrace
|
|
|
|
#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
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads {
|
2010-06-09 00:52:24 +08:00
|
|
|
public:
|
2010-08-27 07:36:03 +08:00
|
|
|
class CommandOptions : public Options {
|
|
|
|
public:
|
2016-08-12 07:51:28 +08:00
|
|
|
CommandOptions() : Options() {
|
2011-04-13 08:18:08 +08:00
|
|
|
// Keep default values of all options in one place: OptionParsingStarting
|
|
|
|
// ()
|
2016-08-12 07:51:28 +08:00
|
|
|
OptionParsingStarting(nullptr);
|
2010-08-27 07:36:03 +08:00
|
|
|
}
|
|
|
|
|
2011-10-26 08:56:27 +08:00
|
|
|
~CommandOptions() override = default;
|
2010-08-27 07:36:03 +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;
|
2010-08-27 07:36:03 +08:00
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
switch (short_option) {
|
|
|
|
case 'c': {
|
2016-11-13 00:56:47 +08:00
|
|
|
int32_t input_count = 0;
|
|
|
|
if (option_arg.getAsInteger(0, m_count)) {
|
|
|
|
m_count = UINT32_MAX;
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat(
|
2011-03-25 05:19:54 +08:00
|
|
|
"invalid integer value for option '%c'", short_option);
|
2016-11-13 00:56:47 +08:00
|
|
|
} else if (input_count < 0)
|
2010-08-27 07:36:03 +08:00
|
|
|
m_count = UINT32_MAX;
|
2016-09-07 04:57:50 +08:00
|
|
|
} break;
|
2016-11-13 00:56:47 +08:00
|
|
|
case 's':
|
|
|
|
if (option_arg.getAsInteger(0, m_start))
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat(
|
2015-10-08 00:56:17 +08:00
|
|
|
"invalid integer value for option '%c'", short_option);
|
2016-11-13 00:56:47 +08:00
|
|
|
break;
|
2013-11-12 15:02:07 +08:00
|
|
|
case 'e': {
|
2010-08-27 07:36:03 +08:00
|
|
|
bool success;
|
2015-10-08 00:56:17 +08:00
|
|
|
m_extended_backtrace =
|
2018-04-10 17:03:59 +08:00
|
|
|
OptionArgParser::ToBoolean(option_arg, false, &success);
|
2010-08-27 07:36:03 +08:00
|
|
|
if (!success)
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat(
|
2013-11-12 15:02:07 +08:00
|
|
|
"invalid boolean value for option '%c'", short_option);
|
2016-09-07 04:57:50 +08:00
|
|
|
} break;
|
2015-10-08 00:56:17 +08:00
|
|
|
default:
|
2019-08-22 16:08:05 +08:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-08-27 07:36:03 +08:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
|
|
|
m_count = UINT32_MAX;
|
2015-01-16 04:08:35 +08:00
|
|
|
m_start = 0;
|
2010-08-27 07:36:03 +08:00
|
|
|
m_extended_backtrace = false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-08-27 07:36:03 +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_thread_backtrace_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-06-09 00:52:24 +08:00
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
// Instance variables to hold the values for command options.
|
|
|
|
uint32_t m_count;
|
2010-08-27 07:36:03 +08:00
|
|
|
uint32_t m_start;
|
2016-02-26 07:46:36 +08:00
|
|
|
bool m_extended_backtrace;
|
2016-09-07 04:57:50 +08:00
|
|
|
};
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2015-10-08 00:56:17 +08:00
|
|
|
CommandObjectThreadBacktrace(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectIterateOverThreads(
|
2016-07-15 06:03:10 +08:00
|
|
|
interpreter, "thread backtrace",
|
2015-10-08 00:56:17 +08:00
|
|
|
"Show thread call stacks. Defaults to the current thread, thread "
|
2017-06-13 00:25:24 +08:00
|
|
|
"indexes can be specified as arguments.\n"
|
|
|
|
"Use the thread-index \"all\" to see all threads.\n"
|
|
|
|
"Use the thread-index \"unique\" to see threads grouped by unique "
|
2019-05-02 10:14:08 +08:00
|
|
|
"call stacks.\n"
|
|
|
|
"Use 'settings set frame-format' to customize the printing of "
|
|
|
|
"frames in the backtrace and 'settings set thread-format' to "
|
|
|
|
"customize the thread header.",
|
2016-09-07 04:57:50 +08:00
|
|
|
nullptr,
|
2016-07-15 06:03:10 +08:00
|
|
|
eCommandRequiresProcess | eCommandRequiresThread |
|
2010-08-27 07:36:03 +08:00
|
|
|
eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
|
2016-07-15 06:03:10 +08:00
|
|
|
eCommandProcessMustBePaused),
|
2010-08-27 07:36:03 +08:00
|
|
|
m_options() {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-11-12 15:02:07 +08:00
|
|
|
~CommandObjectThreadBacktrace() override = default;
|
|
|
|
|
2016-03-18 02:52:41 +08:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
|
|
|
|
2012-06-09 05:56:10 +08:00
|
|
|
protected:
|
2016-03-18 02:52:41 +08:00
|
|
|
void DoExtendedBacktrace(Thread *thread, CommandReturnObject &result) {
|
|
|
|
SystemRuntime *runtime = thread->GetProcess()->GetSystemRuntime();
|
2013-11-12 15:02:07 +08:00
|
|
|
if (runtime) {
|
2016-03-18 02:52:41 +08:00
|
|
|
Stream &strm = result.GetOutputStream();
|
2013-11-12 15:02:07 +08:00
|
|
|
const std::vector<ConstString> &types =
|
|
|
|
runtime->GetExtendedBacktraceTypes();
|
|
|
|
for (auto type : types) {
|
2016-03-18 02:52:41 +08:00
|
|
|
ThreadSP ext_thread_sp = runtime->GetExtendedBacktraceThread(
|
2013-11-13 07:33:32 +08:00
|
|
|
thread->shared_from_this(), type);
|
2013-11-12 15:02:07 +08:00
|
|
|
if (ext_thread_sp && ext_thread_sp->IsValid()) {
|
|
|
|
const uint32_t num_frames_with_source = 0;
|
2016-11-09 04:36:40 +08:00
|
|
|
const bool stop_format = false;
|
2016-03-18 02:52:41 +08:00
|
|
|
if (ext_thread_sp->GetStatus(strm, m_options.m_start,
|
2013-11-12 15:02:07 +08:00
|
|
|
m_options.m_count,
|
2019-10-31 06:26:19 +08:00
|
|
|
num_frames_with_source, stop_format)) {
|
2016-03-18 02:52:41 +08:00
|
|
|
DoExtendedBacktrace(ext_thread_sp.get(), result);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-18 02:52:41 +08:00
|
|
|
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
|
2013-11-13 07:33:32 +08:00
|
|
|
ThreadSP thread_sp =
|
2016-03-18 02:52:41 +08:00
|
|
|
m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
|
|
|
|
if (!thread_sp) {
|
2016-02-10 11:25:24 +08:00
|
|
|
result.AppendErrorWithFormat(
|
2016-03-18 02:52:41 +08:00
|
|
|
"thread disappeared while computing backtraces: 0x%" PRIx64 "\n",
|
2016-09-07 04:57:50 +08:00
|
|
|
tid);
|
2016-03-18 02:52:41 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2016-03-18 02:52:41 +08:00
|
|
|
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
Thread *thread = thread_sp.get();
|
|
|
|
|
|
|
|
Stream &strm = result.GetOutputStream();
|
2014-09-30 07:17:18 +08:00
|
|
|
|
2017-06-13 00:25:24 +08:00
|
|
|
// Only dump stack info if we processing unique stacks.
|
|
|
|
const bool only_stacks = m_unique_stacks;
|
|
|
|
|
2016-03-18 02:52:41 +08:00
|
|
|
// Don't show source context when doing backtraces.
|
|
|
|
const uint32_t num_frames_with_source = 0;
|
2016-11-09 07:43:36 +08:00
|
|
|
const bool stop_format = true;
|
2016-03-18 02:52:41 +08:00
|
|
|
if (!thread->GetStatus(strm, m_options.m_start, m_options.m_count,
|
2017-06-13 00:25:24 +08:00
|
|
|
num_frames_with_source, stop_format, only_stacks)) {
|
2016-02-10 11:25:24 +08:00
|
|
|
result.AppendErrorWithFormat(
|
2014-09-30 07:17:18 +08:00
|
|
|
"error displaying backtrace for thread: \"0x%4.4x\"\n",
|
2016-03-18 02:52:41 +08:00
|
|
|
thread->GetIndexID());
|
2014-09-30 07:17:18 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-09-30 07:17:18 +08:00
|
|
|
if (m_options.m_extended_backtrace) {
|
2016-03-18 02:52:41 +08:00
|
|
|
DoExtendedBacktrace(thread, result);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2012-06-09 05:56:10 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-08-27 07:36:03 +08:00
|
|
|
CommandOptions m_options;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum StepScope { eStepScopeSource, eStepScopeInstruction };
|
|
|
|
|
2018-09-27 02:50:19 +08:00
|
|
|
static constexpr OptionEnumValueElement g_tri_running_mode[] = {
|
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
|
|
|
{eOnlyThisThread, "this-thread", "Run only this thread"},
|
|
|
|
{eAllThreads, "all-threads", "Run all threads"},
|
|
|
|
{eOnlyDuringStepping, "while-stepping",
|
2019-10-31 06:26:19 +08:00
|
|
|
"Run only this thread while stepping"}};
|
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
|
|
|
|
2018-09-27 02:50:19 +08:00
|
|
|
static constexpr OptionEnumValues TriRunningModes() {
|
|
|
|
return OptionEnumValues(g_tri_running_mode);
|
|
|
|
}
|
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
|
|
|
|
2019-07-18 19:12:00 +08:00
|
|
|
#define LLDB_OPTIONS_thread_step_scope
|
|
|
|
#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
|
|
|
|
2019-10-04 06:50:18 +08:00
|
|
|
class ThreadStepScopeOptionGroup : public OptionGroup {
|
2010-06-09 00:52:24 +08:00
|
|
|
public:
|
2019-10-04 06:50:18 +08:00
|
|
|
ThreadStepScopeOptionGroup() : OptionGroup() {
|
|
|
|
// Keep default values of all options in one place: OptionParsingStarting
|
|
|
|
// ()
|
|
|
|
OptionParsingStarting(nullptr);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-10-04 06:50:18 +08:00
|
|
|
~ThreadStepScopeOptionGroup() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-10-04 06:50:18 +08:00
|
|
|
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
|
|
|
|
return llvm::makeArrayRef(g_thread_step_scope_options);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-10-04 06:50:18 +08:00
|
|
|
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
|
|
|
|
ExecutionContext *execution_context) override {
|
|
|
|
Status error;
|
2019-10-31 06:26:19 +08:00
|
|
|
const int short_option =
|
|
|
|
g_thread_step_scope_options[option_idx].short_option;
|
2019-10-04 06:50:18 +08:00
|
|
|
|
|
|
|
switch (short_option) {
|
|
|
|
case 'a': {
|
|
|
|
bool success;
|
|
|
|
bool avoid_no_debug =
|
|
|
|
OptionArgParser::ToBoolean(option_arg, true, &success);
|
|
|
|
if (!success)
|
2019-10-31 06:26:19 +08:00
|
|
|
error.SetErrorStringWithFormat("invalid boolean value for option '%c'",
|
|
|
|
short_option);
|
2019-10-04 06:50:18 +08:00
|
|
|
else {
|
2019-10-31 06:26:19 +08:00
|
|
|
m_step_in_avoid_no_debug = avoid_no_debug ? eLazyBoolYes : eLazyBoolNo;
|
2019-10-04 06:50:18 +08:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case 'A': {
|
|
|
|
bool success;
|
|
|
|
bool avoid_no_debug =
|
|
|
|
OptionArgParser::ToBoolean(option_arg, true, &success);
|
|
|
|
if (!success)
|
2019-10-31 06:26:19 +08:00
|
|
|
error.SetErrorStringWithFormat("invalid boolean value for option '%c'",
|
|
|
|
short_option);
|
2019-10-04 06:50:18 +08:00
|
|
|
else {
|
2019-10-31 06:26:19 +08:00
|
|
|
m_step_out_avoid_no_debug = avoid_no_debug ? eLazyBoolYes : eLazyBoolNo;
|
2019-10-04 06:50:18 +08:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case 'c':
|
|
|
|
if (option_arg.getAsInteger(0, m_step_count))
|
|
|
|
error.SetErrorStringWithFormat("invalid step count '%s'",
|
|
|
|
option_arg.str().c_str());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'm': {
|
|
|
|
auto enum_values = GetDefinitions()[option_idx].enum_values;
|
|
|
|
m_run_mode = (lldb::RunMode)OptionArgParser::ToOptionEnum(
|
|
|
|
option_arg, enum_values, eOnlyDuringStepping, error);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case 'e':
|
|
|
|
if (option_arg == "block") {
|
|
|
|
m_end_line_is_block_end = true;
|
2010-10-05 06:28:36 +08:00
|
|
|
break;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2019-10-04 06:50:18 +08:00
|
|
|
if (option_arg.getAsInteger(0, m_end_line))
|
|
|
|
error.SetErrorStringWithFormat("invalid end line number '%s'",
|
|
|
|
option_arg.str().c_str());
|
|
|
|
break;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-10-04 06:50:18 +08:00
|
|
|
case 'r':
|
2015-10-08 00:56:17 +08:00
|
|
|
m_avoid_regexp.clear();
|
2020-01-29 03:23:46 +08:00
|
|
|
m_avoid_regexp.assign(std::string(option_arg));
|
2019-10-04 06:50:18 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 't':
|
2015-10-08 00:56:17 +08:00
|
|
|
m_step_in_target.clear();
|
2020-01-29 03:23:46 +08:00
|
|
|
m_step_in_target.assign(std::string(option_arg));
|
2019-10-04 06:50:18 +08:00
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-10-04 06:50:18 +08:00
|
|
|
default:
|
|
|
|
llvm_unreachable("Unimplemented option");
|
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
|
|
|
}
|
2019-10-04 06:50:18 +08:00
|
|
|
return error;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-10-04 06:50:18 +08:00
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
|
|
|
m_step_in_avoid_no_debug = eLazyBoolCalculate;
|
|
|
|
m_step_out_avoid_no_debug = eLazyBoolCalculate;
|
|
|
|
m_run_mode = eOnlyDuringStepping;
|
|
|
|
|
|
|
|
// Check if we are in Non-Stop mode
|
|
|
|
TargetSP target_sp =
|
|
|
|
execution_context ? execution_context->GetTargetSP() : TargetSP();
|
2020-08-08 05:44:01 +08:00
|
|
|
if (target_sp && target_sp->GetNonStopModeEnabled()) {
|
|
|
|
// NonStopMode runs all threads by definition, so when it is on we don't
|
|
|
|
// need to check the process setting for runs all threads.
|
2019-10-04 06:50:18 +08:00
|
|
|
m_run_mode = eOnlyThisThread;
|
2020-08-08 05:44:01 +08:00
|
|
|
} else {
|
|
|
|
ProcessSP process_sp =
|
|
|
|
execution_context ? execution_context->GetProcessSP() : ProcessSP();
|
|
|
|
if (process_sp && process_sp->GetSteppingRunsAllThreads())
|
|
|
|
m_run_mode = eAllThreads;
|
|
|
|
}
|
2019-10-04 06:50:18 +08:00
|
|
|
|
|
|
|
m_avoid_regexp.clear();
|
|
|
|
m_step_in_target.clear();
|
|
|
|
m_step_count = 1;
|
|
|
|
m_end_line = LLDB_INVALID_LINE_NUMBER;
|
|
|
|
m_end_line_is_block_end = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Instance variables to hold the values for command options.
|
|
|
|
LazyBool m_step_in_avoid_no_debug;
|
|
|
|
LazyBool m_step_out_avoid_no_debug;
|
|
|
|
RunMode m_run_mode;
|
|
|
|
std::string m_avoid_regexp;
|
|
|
|
std::string m_step_in_target;
|
|
|
|
uint32_t m_step_count;
|
|
|
|
uint32_t m_end_line;
|
|
|
|
bool m_end_line_is_block_end;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed {
|
|
|
|
public:
|
2015-10-08 00:56:17 +08:00
|
|
|
CommandObjectThreadStepWithTypeAndScope(CommandInterpreter &interpreter,
|
2016-08-27 07:28:47 +08:00
|
|
|
const char *name, const char *help,
|
2010-09-18 09:14:36 +08:00
|
|
|
const char *syntax,
|
|
|
|
StepType step_type,
|
|
|
|
StepScope step_scope)
|
2016-07-15 06:03:10 +08:00
|
|
|
: CommandObjectParsed(interpreter, name, help, syntax,
|
2015-10-08 00:56:17 +08:00
|
|
|
eCommandRequiresProcess | eCommandRequiresThread |
|
2015-05-27 13:04:35 +08:00
|
|
|
eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched |
|
2016-07-15 06:03:10 +08:00
|
|
|
eCommandProcessMustBePaused),
|
2019-10-04 06:50:18 +08:00
|
|
|
m_step_type(step_type), m_step_scope(step_scope), m_options(),
|
2019-11-29 00:16:55 +08:00
|
|
|
m_class_options("scripted step") {
|
2010-10-05 06:28:36 +08:00
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData thread_id_arg;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-08 00:56:17 +08:00
|
|
|
// Define the first (and only) variant of this arg.
|
2010-10-05 06:28:36 +08:00
|
|
|
thread_id_arg.arg_type = eArgTypeThreadID;
|
2013-02-01 05:46:01 +08:00
|
|
|
thread_id_arg.arg_repetition = eArgRepeatOptional;
|
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(thread_id_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);
|
2019-10-31 06:26:19 +08:00
|
|
|
|
2019-10-04 06:50:18 +08:00
|
|
|
if (step_type == eStepTypeScripted) {
|
2019-10-31 06:26:19 +08:00
|
|
|
m_all_options.Append(&m_class_options, LLDB_OPT_SET_1 | LLDB_OPT_SET_2,
|
2019-10-26 05:05:07 +08:00
|
|
|
LLDB_OPT_SET_1);
|
2019-10-04 06:50:18 +08:00
|
|
|
}
|
|
|
|
m_all_options.Append(&m_options);
|
|
|
|
m_all_options.Finalize();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-10-08 00:56:17 +08:00
|
|
|
~CommandObjectThreadStepWithTypeAndScope() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-08-11 19:19:27 +08:00
|
|
|
void
|
|
|
|
HandleArgumentCompletion(CompletionRequest &request,
|
|
|
|
OptionElementVector &opt_element_vector) override {
|
|
|
|
if (request.GetCursorIndex())
|
|
|
|
return;
|
|
|
|
|
|
|
|
CommandCompletions::InvokeCommonCompletionCallbacks(
|
|
|
|
GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
|
|
|
|
request, nullptr);
|
|
|
|
}
|
|
|
|
|
2019-10-31 06:26:19 +08:00
|
|
|
Options *GetOptions() override { return &m_all_options; }
|
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
|
|
|
Process *process = m_exe_ctx.GetProcessPtr();
|
2010-09-18 09:14:36 +08:00
|
|
|
bool synchronous_execution = m_interpreter.GetSynchronous();
|
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
|
|
|
const uint32_t num_threads = process->GetThreadList().GetSize();
|
2016-02-26 07:46:36 +08:00
|
|
|
Thread *thread = nullptr;
|
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
|
|
|
if (command.GetArgumentCount() == 0) {
|
2016-03-12 10:45:34 +08:00
|
|
|
thread = GetDefaultThread();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
if (thread == nullptr) {
|
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.AppendError("no selected thread in process");
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} else {
|
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 char *thread_idx_cstr = command.GetArgumentAtIndex(0);
|
2020-07-01 23:00:12 +08:00
|
|
|
uint32_t step_thread_idx;
|
|
|
|
|
|
|
|
if (!llvm::to_integer(thread_idx_cstr, step_thread_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 thread index '%s'.\n",
|
|
|
|
thread_idx_cstr);
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
thread =
|
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
|
|
|
process->GetThreadList().FindThreadByIndexID(step_thread_idx).get();
|
2016-02-26 07:46:36 +08:00
|
|
|
if (thread == nullptr) {
|
2016-02-10 11:25:24 +08:00
|
|
|
result.AppendErrorWithFormat(
|
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 index %u is out of range (valid values are 0 - %u).\n",
|
|
|
|
step_thread_idx, num_threads);
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
2016-03-12 10:45:34 +08:00
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
if (m_step_type == eStepTypeScripted) {
|
2019-10-26 05:05:07 +08:00
|
|
|
if (m_class_options.GetName().empty()) {
|
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("empty class name for scripted step.");
|
|
|
|
return false;
|
2019-04-27 06:43:16 +08:00
|
|
|
} else if (!GetDebugger().GetScriptInterpreter()->CheckObjectExists(
|
2019-10-26 05:05:07 +08:00
|
|
|
m_class_options.GetName().c_str())) {
|
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(
|
|
|
|
"class for scripted step: \"%s\" does not exist.",
|
2019-10-26 05:05:07 +08:00
|
|
|
m_class_options.GetName().c_str());
|
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
|
|
|
return false;
|
2010-06-09 00:52:24 +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
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
if (m_options.m_end_line != LLDB_INVALID_LINE_NUMBER &&
|
|
|
|
m_step_type != eStepTypeInto) {
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"end line option is only valid for step into");
|
|
|
|
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
|
|
|
const bool abort_other_plans = false;
|
|
|
|
const lldb::RunMode stop_other_threads = m_options.m_run_mode;
|
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
|
|
|
// This is a bit unfortunate, but not all the commands in this command
|
2018-05-01 00:49:04 +08:00
|
|
|
// object support only while stepping, so I use the bool for them.
|
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
|
|
|
bool bool_stop_other_threads;
|
|
|
|
if (m_options.m_run_mode == eAllThreads)
|
|
|
|
bool_stop_other_threads = false;
|
|
|
|
else if (m_options.m_run_mode == eOnlyDuringStepping)
|
2020-08-08 05:44:01 +08:00
|
|
|
bool_stop_other_threads = (m_step_type != eStepTypeOut);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
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
|
|
|
bool_stop_other_threads = true;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP new_plan_sp;
|
2018-11-15 09:18:15 +08:00
|
|
|
Status new_plan_status;
|
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
|
|
|
if (m_step_type == eStepTypeInto) {
|
2013-11-04 17:33:30 +08:00
|
|
|
StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
|
2015-03-27 01:47:34 +08:00
|
|
|
assert(frame != nullptr);
|
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
|
|
|
if (frame->HasDebugInformation()) {
|
2016-02-13 08:31:47 +08:00
|
|
|
AddressRange range;
|
|
|
|
SymbolContext sc = frame->GetSymbolContext(eSymbolContextEverything);
|
2016-02-10 11:25:24 +08:00
|
|
|
if (m_options.m_end_line != LLDB_INVALID_LINE_NUMBER) {
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2016-02-10 11:25:24 +08:00
|
|
|
if (!sc.GetAddressRangeFromHereToEndLine(m_options.m_end_line, range,
|
|
|
|
error)) {
|
|
|
|
result.AppendErrorWithFormat("invalid end-line option: %s.",
|
|
|
|
error.AsCString());
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-26 09:37:30 +08:00
|
|
|
} else if (m_options.m_end_line_is_block_end) {
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2016-02-13 08:31:47 +08:00
|
|
|
Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
|
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
|
|
|
if (!block) {
|
2013-07-19 05:48:26 +08:00
|
|
|
result.AppendErrorWithFormat("Could not find the current block.");
|
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
|
|
|
return false;
|
|
|
|
}
|
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
|
|
|
AddressRange block_range;
|
|
|
|
Address pc_address = frame->GetFrameCodeAddress();
|
|
|
|
block->GetRangeContainingAddress(pc_address, block_range);
|
|
|
|
if (!block_range.GetBaseAddress().IsValid()) {
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"Could not find the current block address.");
|
2013-07-19 05:48:26 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2016-02-26 09:37:30 +08:00
|
|
|
lldb::addr_t pc_offset_in_block =
|
|
|
|
pc_address.GetFileAddress() -
|
2013-07-19 05:48:26 +08:00
|
|
|
block_range.GetBaseAddress().GetFileAddress();
|
2016-02-26 09:37:30 +08:00
|
|
|
lldb::addr_t range_length =
|
|
|
|
block_range.GetByteSize() - pc_offset_in_block;
|
|
|
|
range = AddressRange(pc_address, range_length);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2013-07-19 05:48:26 +08:00
|
|
|
range = sc.line_entry.range;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
new_plan_sp = thread->QueueThreadPlanForStepInRange(
|
|
|
|
abort_other_plans, range,
|
|
|
|
frame->GetSymbolContext(eSymbolContextEverything),
|
|
|
|
m_options.m_step_in_target.c_str(), stop_other_threads,
|
2018-11-15 09:18:15 +08:00
|
|
|
new_plan_status, m_options.m_step_in_avoid_no_debug,
|
2014-07-09 03:28:57 +08:00
|
|
|
m_options.m_step_out_avoid_no_debug);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-07-17 04:28:24 +08:00
|
|
|
if (new_plan_sp && !m_options.m_avoid_regexp.empty()) {
|
2014-07-09 03:28:57 +08:00
|
|
|
ThreadPlanStepInRange *step_in_range_plan =
|
|
|
|
static_cast<ThreadPlanStepInRange *>(new_plan_sp.get());
|
|
|
|
step_in_range_plan->SetAvoidRegexp(m_options.m_avoid_regexp.c_str());
|
|
|
|
}
|
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
|
|
|
|
new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
|
2018-11-15 09:18:15 +08:00
|
|
|
false, abort_other_plans, bool_stop_other_threads, new_plan_status);
|
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 (m_step_type == eStepTypeOver) {
|
|
|
|
StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-05-27 20:40:32 +08:00
|
|
|
if (frame->HasDebugInformation())
|
2013-07-19 05:48:26 +08:00
|
|
|
new_plan_sp = thread->QueueThreadPlanForStepOverRange(
|
|
|
|
abort_other_plans,
|
2015-12-15 08:40:30 +08:00
|
|
|
frame->GetSymbolContext(eSymbolContextEverything).line_entry,
|
2015-05-27 20:40:32 +08:00
|
|
|
frame->GetSymbolContext(eSymbolContextEverything),
|
2018-11-15 09:18:15 +08:00
|
|
|
stop_other_threads, new_plan_status,
|
|
|
|
m_options.m_step_out_avoid_no_debug);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2015-05-27 20:40:32 +08:00
|
|
|
new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
|
2018-11-15 09:18:15 +08:00
|
|
|
true, abort_other_plans, bool_stop_other_threads, new_plan_status);
|
2014-10-21 09:00:42 +08:00
|
|
|
} else if (m_step_type == eStepTypeTrace) {
|
2014-08-12 22:33:19 +08:00
|
|
|
new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
|
2018-11-15 09:18:15 +08:00
|
|
|
false, abort_other_plans, bool_stop_other_threads, new_plan_status);
|
2014-08-12 22:33:19 +08:00
|
|
|
} else if (m_step_type == eStepTypeTraceOver) {
|
|
|
|
new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
|
2018-11-15 09:18:15 +08:00
|
|
|
true, abort_other_plans, bool_stop_other_threads, new_plan_status);
|
2014-08-12 22:33:19 +08:00
|
|
|
} else if (m_step_type == eStepTypeOut) {
|
2016-02-26 07:46:36 +08:00
|
|
|
new_plan_sp = thread->QueueThreadPlanForStepOut(
|
2014-08-12 22:33:19 +08:00
|
|
|
abort_other_plans, nullptr, false, bool_stop_other_threads, eVoteYes,
|
2018-11-15 09:18:15 +08:00
|
|
|
eVoteNoOpinion, thread->GetSelectedFrameIndex(), new_plan_status,
|
2016-02-13 08:31:47 +08:00
|
|
|
m_options.m_step_out_avoid_no_debug);
|
2014-08-12 22:33:19 +08:00
|
|
|
} else if (m_step_type == eStepTypeScripted) {
|
|
|
|
new_plan_sp = thread->QueueThreadPlanForStepScripted(
|
2019-10-31 06:26:19 +08:00
|
|
|
abort_other_plans, m_class_options.GetName().c_str(),
|
|
|
|
m_class_options.GetStructuredData(), bool_stop_other_threads,
|
|
|
|
new_plan_status);
|
2014-10-21 09:00:42 +08:00
|
|
|
} else {
|
|
|
|
result.AppendError("step type is not supported");
|
2016-02-26 09:37:30 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-10-21 09:00:42 +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
|
|
|
// If we got a new plan, then set it to be a master plan (User level Plans
|
2018-05-01 00:49:04 +08:00
|
|
|
// should be master plans so that they can be interruptible). Then resume
|
|
|
|
// the process.
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
if (new_plan_sp) {
|
|
|
|
new_plan_sp->SetIsMasterPlan(true);
|
|
|
|
new_plan_sp->SetOkayToDiscard(false);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
if (m_options.m_step_count > 1) {
|
2017-05-25 10:24:18 +08:00
|
|
|
if (!new_plan_sp->SetIterationCount(m_options.m_step_count)) {
|
2013-02-01 05:46:01 +08:00
|
|
|
result.AppendWarning(
|
2016-08-27 07:28:47 +08:00
|
|
|
"step operation does not support iteration count.");
|
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
|
|
|
process->GetThreadList().SetSelectedThreadByID(thread->GetID());
|
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
|
|
|
const uint32_t iohandler_id = process->GetIOHandlerID();
|
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
|
|
|
StreamString stream;
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2014-10-21 09:00:42 +08:00
|
|
|
if (synchronous_execution)
|
|
|
|
error = process->ResumeSynchronous(&stream);
|
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
|
2014-10-21 09:00:42 +08:00
|
|
|
error = process->Resume();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-09-20 02:07:33 +08:00
|
|
|
if (!error.Success()) {
|
|
|
|
result.AppendMessage(error.AsCString());
|
|
|
|
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
|
|
|
// There is a race condition where this thread will return up the call
|
2018-05-01 00:49:04 +08:00
|
|
|
// stack to the main command handler and show an (lldb) prompt before
|
|
|
|
// HandlePrivateEvent (from PrivateStateThread) has a chance to call
|
|
|
|
// PushProcessIOHandler().
|
2018-05-09 22:29:30 +08:00
|
|
|
process->SyncIOHandler(iohandler_id, std::chrono::seconds(2));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-10-21 09:00:42 +08:00
|
|
|
if (synchronous_execution) {
|
|
|
|
// If any state changed events had anything to say, add that to the
|
|
|
|
// result
|
2016-11-17 05:15:24 +08:00
|
|
|
if (stream.GetSize() > 0)
|
|
|
|
result.AppendMessage(stream.GetString());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-12-11 10:31:48 +08:00
|
|
|
process->GetThreadList().SetSelectedThreadByID(thread->GetID());
|
2010-06-09 00:52:24 +08:00
|
|
|
result.SetDidChangeProcessState(true);
|
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(eReturnStatusSuccessFinishNoResult);
|
2012-05-04 05:19:36 +08:00
|
|
|
} else {
|
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(eReturnStatusSuccessContinuingNoResult);
|
2010-06-09 00:52:24 +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 {
|
2018-11-15 09:18:15 +08:00
|
|
|
result.SetError(new_plan_status);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return result.Succeeded();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
StepType m_step_type;
|
|
|
|
StepScope m_step_scope;
|
2019-10-04 06:50:18 +08:00
|
|
|
ThreadStepScopeOptionGroup m_options;
|
|
|
|
OptionGroupPythonClassWithDict m_class_options;
|
|
|
|
OptionGroupOptions m_all_options;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// CommandObjectThreadContinue
|
|
|
|
|
2012-06-09 05:56:10 +08:00
|
|
|
class CommandObjectThreadContinue : public CommandObjectParsed {
|
2010-06-09 00:52:24 +08:00
|
|
|
public:
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectThreadContinue(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(
|
|
|
|
interpreter, "thread continue",
|
|
|
|
"Continue execution of the current target process. One "
|
|
|
|
"or more threads may be specified, by default all "
|
|
|
|
"threads continue.",
|
|
|
|
nullptr,
|
|
|
|
eCommandRequiresThread | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {
|
2010-10-05 06:28:36 +08:00
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData thread_idx_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.
|
|
|
|
thread_idx_arg.arg_type = eArgTypeThreadIndex;
|
|
|
|
thread_idx_arg.arg_repetition = eArgRepeatPlus;
|
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(thread_idx_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
|
|
|
}
|
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
~CommandObjectThreadContinue() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-08-11 19:19:27 +08:00
|
|
|
void
|
|
|
|
HandleArgumentCompletion(CompletionRequest &request,
|
|
|
|
OptionElementVector &opt_element_vector) override {
|
|
|
|
CommandCompletions::InvokeCommonCompletionCallbacks(
|
|
|
|
GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
|
|
|
|
request, nullptr);
|
|
|
|
}
|
|
|
|
|
2015-10-08 00:56:17 +08:00
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
2010-09-18 09:14:36 +08:00
|
|
|
bool synchronous_execution = m_interpreter.GetSynchronous();
|
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
|
|
|
Process *process = m_exe_ctx.GetProcessPtr();
|
2013-09-13 03:15:05 +08:00
|
|
|
if (process == nullptr) {
|
2012-07-04 04:54:16 +08:00
|
|
|
result.AppendError("no process exists. Cannot continue");
|
2012-11-30 05:49:15 +08:00
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2013-09-13 03:15:05 +08:00
|
|
|
|
2014-10-21 09:00:42 +08:00
|
|
|
StateType state = process->GetState();
|
2010-06-09 00:52:24 +08:00
|
|
|
if ((state == eStateCrashed) || (state == eStateStopped) ||
|
2014-10-21 09:00:42 +08:00
|
|
|
(state == eStateSuspended)) {
|
2013-09-13 03:15:05 +08:00
|
|
|
const size_t argc = command.GetArgumentCount();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (argc > 0) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// These two lines appear at the beginning of both blocks in this
|
|
|
|
// if..else, but that is because we need to release the lock before
|
|
|
|
// calling process->Resume below.
|
2014-10-21 09:00:42 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
2016-05-19 13:13:57 +08:00
|
|
|
process->GetThreadList().GetMutex());
|
2014-10-21 09:00:42 +08:00
|
|
|
const uint32_t num_threads = process->GetThreadList().GetSize();
|
|
|
|
std::vector<Thread *> resume_threads;
|
2016-10-06 07:40:23 +08:00
|
|
|
for (auto &entry : command.entries()) {
|
|
|
|
uint32_t thread_idx;
|
2019-09-13 19:26:48 +08:00
|
|
|
if (entry.ref().getAsInteger(0, thread_idx)) {
|
2010-06-09 00:52:24 +08:00
|
|
|
result.AppendErrorWithFormat(
|
2016-10-06 07:40:23 +08:00
|
|
|
"invalid thread index argument: \"%s\".\n", entry.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Thread *thread =
|
|
|
|
process->GetThreadList().FindThreadByIndexID(thread_idx).get();
|
|
|
|
|
|
|
|
if (thread) {
|
|
|
|
resume_threads.push_back(thread);
|
|
|
|
} else {
|
|
|
|
result.AppendErrorWithFormat("invalid thread index %u.\n",
|
|
|
|
thread_idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (resume_threads.empty()) {
|
|
|
|
result.AppendError("no valid thread indexes were specified");
|
|
|
|
return false;
|
|
|
|
} else {
|
2012-07-04 04:54:16 +08:00
|
|
|
if (resume_threads.size() == 1)
|
2012-06-01 04:48:41 +08:00
|
|
|
result.AppendMessageWithFormat("Resuming thread: ");
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
result.AppendMessageWithFormat("Resuming threads: ");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
for (uint32_t idx = 0; idx < num_threads; ++idx) {
|
2012-07-04 04:54:16 +08:00
|
|
|
Thread *thread =
|
2010-06-09 00:52:24 +08:00
|
|
|
process->GetThreadList().GetThreadAtIndex(idx).get();
|
|
|
|
std::vector<Thread *>::iterator this_thread_pos =
|
2012-07-04 04:54:16 +08:00
|
|
|
find(resume_threads.begin(), resume_threads.end(), thread);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (this_thread_pos != resume_threads.end()) {
|
|
|
|
resume_threads.erase(this_thread_pos);
|
2016-02-26 07:46:36 +08:00
|
|
|
if (!resume_threads.empty())
|
2010-06-09 00:52:24 +08:00
|
|
|
result.AppendMessageWithFormat("%u, ", thread->GetIndexID());
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2012-06-01 04:48:41 +08:00
|
|
|
result.AppendMessageWithFormat("%u ", thread->GetIndexID());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
const bool override_suspend = true;
|
2014-04-03 09:26:14 +08:00
|
|
|
thread->SetResumeState(eStateRunning, override_suspend);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2010-06-09 00:52:24 +08:00
|
|
|
thread->SetResumeState(eStateSuspended);
|
|
|
|
}
|
|
|
|
}
|
2012-11-30 05:49:15 +08:00
|
|
|
result.AppendMessageWithFormat("in process %" PRIu64 "\n",
|
|
|
|
process->GetID());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} else {
|
2018-05-01 00:49:04 +08:00
|
|
|
// These two lines appear at the beginning of both blocks in this
|
|
|
|
// if..else, but that is because we need to release the lock before
|
|
|
|
// calling process->Resume below.
|
2016-05-19 13:13:57 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
process->GetThreadList().GetMutex());
|
2013-09-13 03:15:05 +08:00
|
|
|
const uint32_t num_threads = process->GetThreadList().GetSize();
|
2016-03-12 10:45:34 +08:00
|
|
|
Thread *current_thread = GetDefaultThread();
|
2016-02-26 07:46:36 +08:00
|
|
|
if (current_thread == nullptr) {
|
2010-06-09 00:52:24 +08:00
|
|
|
result.AppendError("the process doesn't have a current thread");
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
// Set the actions that the threads should each take when resuming
|
2016-02-26 07:46:36 +08:00
|
|
|
for (uint32_t idx = 0; idx < num_threads; ++idx) {
|
2012-07-04 04:54:16 +08:00
|
|
|
Thread *thread = process->GetThreadList().GetThreadAtIndex(idx).get();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (thread == current_thread) {
|
2012-11-30 05:49:15 +08:00
|
|
|
result.AppendMessageWithFormat("Resuming thread 0x%4.4" PRIx64
|
|
|
|
" in process %" PRIu64 "\n",
|
|
|
|
thread->GetID(), process->GetID());
|
2014-04-03 09:26:14 +08:00
|
|
|
const bool override_suspend = true;
|
|
|
|
thread->SetResumeState(eStateRunning, override_suspend);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2010-06-09 00:52:24 +08:00
|
|
|
thread->SetResumeState(eStateSuspended);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-21 09:00:42 +08:00
|
|
|
StreamString stream;
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2014-10-21 09:00:42 +08:00
|
|
|
if (synchronous_execution)
|
|
|
|
error = process->ResumeSynchronous(&stream);
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
2014-10-21 09:00:42 +08:00
|
|
|
error = process->Resume();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-08-27 07:28:47 +08:00
|
|
|
// We should not be holding the thread list lock when we do this.
|
2010-06-09 00:52:24 +08:00
|
|
|
if (error.Success()) {
|
2012-11-30 05:49:15 +08:00
|
|
|
result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n",
|
|
|
|
process->GetID());
|
2014-10-21 09:00:42 +08:00
|
|
|
if (synchronous_execution) {
|
|
|
|
// If any state changed events had anything to say, add that to the
|
|
|
|
// result
|
2016-11-17 05:15:24 +08:00
|
|
|
if (stream.GetSize() > 0)
|
|
|
|
result.AppendMessage(stream.GetString());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
result.SetDidChangeProcessState(true);
|
2014-09-30 07:17:18 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
2010-06-09 00:52:24 +08:00
|
|
|
} else {
|
|
|
|
result.SetStatus(eReturnStatusSuccessContinuingNoResult);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} else {
|
2010-06-09 00:52:24 +08:00
|
|
|
result.AppendErrorWithFormat("Failed to resume process: %s\n",
|
2016-02-13 08:31:47 +08:00
|
|
|
error.AsCString());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} else {
|
2012-07-04 04:54:16 +08:00
|
|
|
result.AppendErrorWithFormat(
|
2010-06-09 00:52:24 +08:00
|
|
|
"Process cannot be continued from its current state (%s).\n",
|
|
|
|
StateAsCString(state));
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return result.Succeeded();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// CommandObjectThreadUntil
|
|
|
|
|
2018-09-27 02:50:19 +08:00
|
|
|
static constexpr OptionEnumValueElement g_duo_running_mode[] = {
|
|
|
|
{eOnlyThisThread, "this-thread", "Run only this thread"},
|
2019-10-31 06:26:19 +08:00
|
|
|
{eAllThreads, "all-threads", "Run all threads"}};
|
2018-09-27 02:50:19 +08:00
|
|
|
|
|
|
|
static constexpr OptionEnumValues DuoRunningModes() {
|
|
|
|
return OptionEnumValues(g_duo_running_mode);
|
|
|
|
}
|
|
|
|
|
2019-07-18 19:12:00 +08:00
|
|
|
#define LLDB_OPTIONS_thread_until
|
|
|
|
#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 CommandObjectThreadUntil : public CommandObjectParsed {
|
2010-06-09 00:52:24 +08:00
|
|
|
public:
|
|
|
|
class CommandOptions : public Options {
|
|
|
|
public:
|
|
|
|
uint32_t m_thread_idx = LLDB_INVALID_THREAD_ID;
|
2016-08-12 07:51:28 +08:00
|
|
|
uint32_t m_frame_idx = LLDB_INVALID_FRAME_ID;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-12-04 08:32:51 +08:00
|
|
|
CommandOptions() : Options() {
|
2011-10-08 02:58:12 +08:00
|
|
|
// Keep default values of all options in one place: OptionParsingStarting
|
|
|
|
// ()
|
2011-10-26 08:56:27 +08:00
|
|
|
OptionParsingStarting(nullptr);
|
2010-06-09 00:52:24 +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;
|
2016-08-12 07:51:28 +08:00
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
switch (short_option) {
|
2015-02-06 10:10:56 +08:00
|
|
|
case 'a': {
|
2018-04-10 17:03:59 +08:00
|
|
|
lldb::addr_t tmp_addr = OptionArgParser::ToAddress(
|
2016-08-27 07:28:47 +08:00
|
|
|
execution_context, option_arg, LLDB_INVALID_ADDRESS, &error);
|
2016-08-12 07:51:28 +08:00
|
|
|
if (error.Success())
|
|
|
|
m_until_addrs.push_back(tmp_addr);
|
2010-06-09 00:52:24 +08:00
|
|
|
} break;
|
|
|
|
case 't':
|
2016-11-13 00:56:47 +08:00
|
|
|
if (option_arg.getAsInteger(0, m_thread_idx)) {
|
|
|
|
m_thread_idx = LLDB_INVALID_INDEX32;
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat("invalid thread index '%s'",
|
2016-11-13 00:56:47 +08:00
|
|
|
option_arg.str().c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
case 'f':
|
2016-11-13 00:56:47 +08:00
|
|
|
if (option_arg.getAsInteger(0, m_frame_idx)) {
|
|
|
|
m_frame_idx = LLDB_INVALID_FRAME_ID;
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat("invalid frame index '%s'",
|
2016-11-13 00:56:47 +08:00
|
|
|
option_arg.str().c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
case 'm': {
|
2018-09-27 02:50:19 +08:00
|
|
|
auto enum_values = GetDefinitions()[option_idx].enum_values;
|
2018-04-10 17:03:59 +08:00
|
|
|
lldb::RunMode run_mode = (lldb::RunMode)OptionArgParser::ToOptionEnum(
|
2016-11-13 00:56:47 +08:00
|
|
|
option_arg, enum_values, eOnlyDuringStepping, error);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (error.Success()) {
|
2011-10-08 02:58:12 +08:00
|
|
|
if (run_mode == eAllThreads)
|
2010-06-09 00:52:24 +08:00
|
|
|
m_stop_others = false;
|
2015-10-08 00:56:17 +08:00
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
m_stop_others = true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
} break;
|
|
|
|
default:
|
2019-08-22 16:08:05 +08:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return error;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
|
|
|
m_thread_idx = LLDB_INVALID_THREAD_ID;
|
2010-06-09 00:52:24 +08:00
|
|
|
m_frame_idx = 0;
|
2011-03-25 05:19:54 +08:00
|
|
|
m_stop_others = false;
|
|
|
|
m_until_addrs.clear();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +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_thread_until_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-06-09 00:52:24 +08:00
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
uint32_t m_step_thread_idx;
|
2010-10-05 06:28:36 +08:00
|
|
|
bool m_stop_others;
|
|
|
|
std::vector<lldb::addr_t> m_until_addrs;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2015-10-08 00:56:17 +08:00
|
|
|
// Instance variables to hold the values for command options.
|
2010-09-18 09:14:36 +08:00
|
|
|
};
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-09-18 09:14:36 +08:00
|
|
|
CommandObjectThreadUntil(CommandInterpreter &interpreter)
|
2011-05-04 06:09:39 +08:00
|
|
|
: CommandObjectParsed(
|
|
|
|
interpreter, "thread until",
|
|
|
|
"Continue until a line number or address is reached by the "
|
|
|
|
"current or specified thread. Stops when returning from "
|
2016-11-19 06:06:10 +08:00
|
|
|
"the current function as a safety measure. "
|
2019-10-31 06:26:19 +08:00
|
|
|
"The target line number(s) are given as arguments, and if more "
|
|
|
|
"than one"
|
2016-11-24 18:01:34 +08:00
|
|
|
" is provided, stepping will stop when the first one is hit.",
|
2011-05-04 06:09:39 +08:00
|
|
|
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;
|
2011-05-04 06:09:39 +08:00
|
|
|
CommandArgumentData line_num_arg;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// Define the first (and only) variant of this arg.
|
2015-02-06 10:10:56 +08:00
|
|
|
line_num_arg.arg_type = eArgTypeLineNum;
|
|
|
|
line_num_arg.arg_repetition = eArgRepeatPlain;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-05-31 08:29:20 +08:00
|
|
|
// There is only one variant this argument could be; put it into the
|
2010-10-05 06:28:36 +08:00
|
|
|
// argument entry.
|
2012-05-31 08:29:20 +08:00
|
|
|
arg.push_back(line_num_arg);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-05-08 08:56:32 +08:00
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2012-05-12 07:47:32 +08:00
|
|
|
~CommandObjectThreadUntil() override = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-11-04 17:33:30 +08:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
2011-05-08 08:56:32 +08:00
|
|
|
bool synchronous_execution = m_interpreter.GetSynchronous();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-08-31 17:41:25 +08:00
|
|
|
Target *target = &GetSelectedTarget();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-08-27 05:32:51 +08:00
|
|
|
Process *process = m_exe_ctx.GetProcessPtr();
|
|
|
|
if (process == nullptr) {
|
|
|
|
result.AppendError("need a valid process to step");
|
|
|
|
} else {
|
2016-02-26 07:46:36 +08:00
|
|
|
Thread *thread = nullptr;
|
2010-08-27 05:32:51 +08:00
|
|
|
std::vector<uint32_t> line_numbers;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-02-06 10:10:56 +08:00
|
|
|
if (command.GetArgumentCount() >= 1) {
|
|
|
|
size_t num_args = command.GetArgumentCount();
|
|
|
|
for (size_t i = 0; i < num_args; i++) {
|
|
|
|
uint32_t line_number;
|
2020-07-01 23:00:12 +08:00
|
|
|
if (!llvm::to_integer(command.GetArgumentAtIndex(i), line_number)) {
|
2015-02-06 10:10:56 +08:00
|
|
|
result.AppendErrorWithFormat("invalid line number: '%s'.\n",
|
2016-11-19 06:06:10 +08:00
|
|
|
command.GetArgumentAtIndex(i));
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
} else
|
2015-02-06 10:10:56 +08:00
|
|
|
line_numbers.push_back(line_number);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2015-02-06 10:10:56 +08:00
|
|
|
} else if (m_options.m_until_addrs.empty()) {
|
|
|
|
result.AppendErrorWithFormat("No line number or address provided:\n%s",
|
2016-11-15 08:45:18 +08:00
|
|
|
GetSyntax().str().c_str());
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (m_options.m_thread_idx == LLDB_INVALID_THREAD_ID) {
|
2016-03-12 10:45:34 +08:00
|
|
|
thread = GetDefaultThread();
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2010-08-27 05:32:51 +08:00
|
|
|
thread = process->GetThreadList()
|
|
|
|
.FindThreadByIndexID(m_options.m_thread_idx)
|
2014-10-21 09:00:42 +08:00
|
|
|
.get();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2014-10-21 09:00:42 +08:00
|
|
|
if (thread == nullptr) {
|
2012-11-30 05:49:15 +08:00
|
|
|
const uint32_t num_threads = process->GetThreadList().GetSize();
|
|
|
|
result.AppendErrorWithFormat(
|
2014-10-21 09:00:42 +08:00
|
|
|
"Thread index %u is out of range (valid values are 0 - %u).\n",
|
|
|
|
m_options.m_thread_idx, num_threads);
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
const bool abort_other_plans = false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-04 17:33:30 +08:00
|
|
|
StackFrame *frame =
|
2010-06-09 00:52:24 +08:00
|
|
|
thread->GetStackFrameAtIndex(m_options.m_frame_idx).get();
|
|
|
|
if (frame == nullptr) {
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"Frame index %u is out of range for thread %u.\n",
|
|
|
|
m_options.m_frame_idx, m_options.m_thread_idx);
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP new_plan_sp;
|
2018-11-15 09:18:15 +08:00
|
|
|
Status new_plan_status;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (frame->HasDebugInformation()) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// Finally we got here... Translate the given line number to a bunch
|
|
|
|
// of addresses:
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolContext sc(frame->GetSymbolContext(eSymbolContextCompUnit));
|
|
|
|
LineTable *line_table = nullptr;
|
|
|
|
if (sc.comp_unit)
|
|
|
|
line_table = sc.comp_unit->GetLineTable();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (line_table == nullptr) {
|
|
|
|
result.AppendErrorWithFormat("Failed to resolve the line table for "
|
|
|
|
"frame %u of thread index %u.\n",
|
2011-05-08 08:56:32 +08:00
|
|
|
m_options.m_frame_idx,
|
2010-06-09 00:52:24 +08:00
|
|
|
m_options.m_thread_idx);
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
LineEntry function_start;
|
|
|
|
uint32_t index_ptr = 0, end_ptr;
|
|
|
|
std::vector<addr_t> address_list;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// Find the beginning & end index of the
|
|
|
|
AddressRange fun_addr_range = sc.function->GetAddressRange();
|
|
|
|
Address fun_start_addr = fun_addr_range.GetBaseAddress();
|
|
|
|
line_table->FindLineEntryByAddress(fun_start_addr, function_start,
|
|
|
|
&index_ptr);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-05-08 08:56:32 +08:00
|
|
|
Address fun_end_addr(fun_start_addr.GetSection(),
|
|
|
|
fun_start_addr.GetOffset() +
|
|
|
|
fun_addr_range.GetByteSize());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-08-27 07:28:47 +08:00
|
|
|
bool all_in_function = true;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-02-06 10:10:56 +08:00
|
|
|
line_table->FindLineEntryByAddress(fun_end_addr, function_start,
|
|
|
|
&end_ptr);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-02-06 10:10:56 +08:00
|
|
|
for (uint32_t line_number : line_numbers) {
|
|
|
|
uint32_t start_idx_ptr = index_ptr;
|
|
|
|
while (start_idx_ptr <= end_ptr) {
|
|
|
|
LineEntry line_entry;
|
|
|
|
const bool exact = false;
|
|
|
|
start_idx_ptr = sc.comp_unit->FindLineEntry(
|
2019-11-28 23:22:44 +08:00
|
|
|
start_idx_ptr, line_number, nullptr, exact, &line_entry);
|
2015-02-06 10:10:56 +08:00
|
|
|
if (start_idx_ptr == UINT32_MAX)
|
2016-09-07 04:57:50 +08:00
|
|
|
break;
|
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
addr_t address =
|
2016-02-26 09:37:30 +08:00
|
|
|
line_entry.range.GetBaseAddress().GetLoadAddress(target);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (address != LLDB_INVALID_ADDRESS) {
|
2015-02-06 10:10:56 +08:00
|
|
|
if (fun_addr_range.ContainsLoadAddress(address, target))
|
|
|
|
address_list.push_back(address);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2015-02-06 10:10:56 +08:00
|
|
|
all_in_function = false;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2015-02-06 10:10:56 +08:00
|
|
|
start_idx_ptr++;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-06 10:10:56 +08:00
|
|
|
for (lldb::addr_t address : m_options.m_until_addrs) {
|
|
|
|
if (fun_addr_range.ContainsLoadAddress(address, target))
|
|
|
|
address_list.push_back(address);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2015-02-06 10:10:56 +08:00
|
|
|
all_in_function = false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
if (address_list.empty()) {
|
2011-05-08 08:56:32 +08:00
|
|
|
if (all_in_function)
|
2011-09-21 05:44:10 +08:00
|
|
|
result.AppendErrorWithFormat(
|
2011-05-08 08:56:32 +08:00
|
|
|
"No line entries matching until target.\n");
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2011-09-21 05:44:10 +08:00
|
|
|
result.AppendErrorWithFormat(
|
2011-05-08 08:56:32 +08:00
|
|
|
"Until target outside of the current function.\n");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-02-06 10:10:56 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
new_plan_sp = thread->QueueThreadPlanForStepUntil(
|
2016-08-27 07:28:47 +08:00
|
|
|
abort_other_plans, &address_list.front(), address_list.size(),
|
2018-11-15 09:18:15 +08:00
|
|
|
m_options.m_stop_others, m_options.m_frame_idx, new_plan_status);
|
|
|
|
if (new_plan_sp) {
|
|
|
|
// User level plans should be master plans so they can be interrupted
|
|
|
|
// (e.g. by hitting a breakpoint) and other plans executed by the
|
|
|
|
// user (stepping around the breakpoint) and then a "continue" will
|
|
|
|
// resume the original plan.
|
|
|
|
new_plan_sp->SetIsMasterPlan(true);
|
|
|
|
new_plan_sp->SetOkayToDiscard(false);
|
|
|
|
} else {
|
|
|
|
result.SetError(new_plan_status);
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
} else {
|
|
|
|
result.AppendErrorWithFormat(
|
2011-05-08 08:56:32 +08:00
|
|
|
"Frame index %u of thread %u has no debug information.\n",
|
2010-06-09 00:52:24 +08:00
|
|
|
m_options.m_frame_idx, m_options.m_thread_idx);
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
process->GetThreadList().SetSelectedThreadByID(m_options.m_thread_idx);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-10-21 09:00:42 +08:00
|
|
|
StreamString stream;
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2014-10-21 09:00:42 +08:00
|
|
|
if (synchronous_execution)
|
|
|
|
error = process->ResumeSynchronous(&stream);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2014-10-21 09:00:42 +08:00
|
|
|
error = process->Resume();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (error.Success()) {
|
2012-11-30 05:49:15 +08:00
|
|
|
result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n",
|
|
|
|
process->GetID());
|
2014-10-21 09:00:42 +08:00
|
|
|
if (synchronous_execution) {
|
|
|
|
// If any state changed events had anything to say, add that to the
|
2016-09-07 04:57:50 +08:00
|
|
|
// result
|
2016-11-17 05:15:24 +08:00
|
|
|
if (stream.GetSize() > 0)
|
|
|
|
result.AppendMessage(stream.GetString());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
result.SetDidChangeProcessState(true);
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2010-06-09 00:52:24 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessContinuingNoResult);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} else {
|
2016-03-18 02:52:41 +08:00
|
|
|
result.AppendErrorWithFormat("Failed to resume process: %s.\n",
|
2013-02-01 05:46:01 +08:00
|
|
|
error.AsCString());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return result.Succeeded();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-06-09 05:56:10 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
CommandOptions m_options;
|
|
|
|
};
|
|
|
|
|
|
|
|
// CommandObjectThreadSelect
|
|
|
|
|
2012-06-09 05:56:10 +08:00
|
|
|
class CommandObjectThreadSelect : public CommandObjectParsed {
|
2010-06-09 00:52:24 +08:00
|
|
|
public:
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectThreadSelect(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(interpreter, "thread select",
|
|
|
|
"Change the currently selected thread.", nullptr,
|
|
|
|
eCommandRequiresProcess | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched |
|
|
|
|
eCommandProcessMustBePaused) {
|
2010-10-05 06:28:36 +08:00
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData thread_idx_arg;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
// Define the first (and only) variant of this arg.
|
|
|
|
thread_idx_arg.arg_type = eArgTypeThreadIndex;
|
2010-10-05 06:28:36 +08:00
|
|
|
thread_idx_arg.arg_repetition = eArgRepeatPlain;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2015-10-08 00:56:17 +08:00
|
|
|
// There is only one variant this argument could be; put it into the
|
2010-06-09 00:52:24 +08:00
|
|
|
// argument entry.
|
2011-09-21 05:44:10 +08:00
|
|
|
arg.push_back(thread_idx_arg);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2015-01-16 04:08:35 +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
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-10-26 08:56:27 +08:00
|
|
|
~CommandObjectThreadSelect() override = default;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2020-08-11 19:19:27 +08:00
|
|
|
void
|
|
|
|
HandleArgumentCompletion(CompletionRequest &request,
|
|
|
|
OptionElementVector &opt_element_vector) override {
|
|
|
|
if (request.GetCursorIndex())
|
|
|
|
return;
|
|
|
|
|
|
|
|
CommandCompletions::InvokeCommonCompletionCallbacks(
|
|
|
|
GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
|
|
|
|
request, nullptr);
|
|
|
|
}
|
|
|
|
|
2012-12-11 10:31:48 +08:00
|
|
|
protected:
|
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
|
|
|
Process *process = m_exe_ctx.GetProcessPtr();
|
2010-09-14 08:53:53 +08:00
|
|
|
if (process == nullptr) {
|
|
|
|
result.AppendError("no process");
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
} else if (command.GetArgumentCount() != 1) {
|
|
|
|
result.AppendErrorWithFormat(
|
2011-09-21 05:44:10 +08:00
|
|
|
"'%s' takes exactly one thread index argument:\nUsage: %s\n",
|
|
|
|
m_cmd_name.c_str(), m_cmd_syntax.c_str());
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-07-01 23:00:12 +08:00
|
|
|
uint32_t index_id;
|
|
|
|
if (!llvm::to_integer(command.GetArgumentAtIndex(0), index_id)) {
|
|
|
|
result.AppendErrorWithFormat("Invalid thread index '%s'",
|
|
|
|
command.GetArgumentAtIndex(0));
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
Thread *new_thread =
|
|
|
|
process->GetThreadList().FindThreadByIndexID(index_id).get();
|
2016-02-26 07:46:36 +08:00
|
|
|
if (new_thread == nullptr) {
|
2012-07-04 04:54:16 +08:00
|
|
|
result.AppendErrorWithFormat("invalid thread #%s.\n",
|
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
|
|
|
command.GetArgumentAtIndex(0));
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-12-11 10:31:48 +08:00
|
|
|
process->GetThreadList().SetSelectedThreadByID(new_thread->GetID(), true);
|
2014-09-30 07:17:18 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
return result.Succeeded();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// CommandObjectThreadList
|
|
|
|
|
2012-06-09 05:56:10 +08:00
|
|
|
class CommandObjectThreadList : public CommandObjectParsed {
|
2010-06-23 09:19:29 +08:00
|
|
|
public:
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectThreadList(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(
|
|
|
|
interpreter, "thread list",
|
2019-05-02 10:14:08 +08:00
|
|
|
"Show a summary of each thread in the current target process. "
|
|
|
|
"Use 'settings set thread-format' to customize the individual "
|
|
|
|
"thread listings.",
|
2016-07-15 06:03:10 +08:00
|
|
|
"thread list",
|
|
|
|
eCommandRequiresProcess | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {}
|
2010-06-23 09:19:29 +08:00
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
~CommandObjectThreadList() 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 {
|
2011-02-19 10:53:09 +08:00
|
|
|
Stream &strm = result.GetOutputStream();
|
2010-06-23 09:19:29 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
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
|
|
|
Process *process = m_exe_ctx.GetProcessPtr();
|
|
|
|
const bool only_threads_with_stop_reason = false;
|
|
|
|
const uint32_t start_frame = 0;
|
|
|
|
const uint32_t num_frames = 0;
|
|
|
|
const uint32_t num_frames_with_source = 0;
|
|
|
|
process->GetStatus(strm);
|
|
|
|
process->GetThreadStatus(strm, only_threads_with_stop_reason, start_frame,
|
2016-11-09 04:36:40 +08:00
|
|
|
num_frames, num_frames_with_source, false);
|
2010-06-23 09:19:29 +08:00
|
|
|
return result.Succeeded();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
};
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2014-06-13 10:37:02 +08:00
|
|
|
// CommandObjectThreadInfo
|
2019-07-18 19:12:00 +08:00
|
|
|
#define LLDB_OPTIONS_thread_info
|
|
|
|
#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
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
class CommandObjectThreadInfo : public CommandObjectIterateOverThreads {
|
2014-06-13 10:37:02 +08:00
|
|
|
public:
|
|
|
|
class CommandOptions : public Options {
|
|
|
|
public:
|
2016-08-12 07:51:28 +08:00
|
|
|
CommandOptions() : Options() { OptionParsingStarting(nullptr); }
|
2016-02-26 07:46:36 +08:00
|
|
|
|
2016-08-12 07:51:28 +08:00
|
|
|
~CommandOptions() override = default;
|
2014-06-13 10:37:02 +08:00
|
|
|
|
2016-08-12 07:51:28 +08:00
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
m_json_thread = false;
|
|
|
|
m_json_stopinfo = false;
|
2014-06-13 10:37:02 +08:00
|
|
|
}
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
|
|
|
|
ExecutionContext *execution_context) override {
|
2014-06-13 10:37:02 +08:00
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2014-06-13 10:37:02 +08:00
|
|
|
|
|
|
|
switch (short_option) {
|
|
|
|
case 'j':
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
m_json_thread = true;
|
|
|
|
break;
|
2014-06-13 10:37:02 +08:00
|
|
|
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
case 's':
|
2014-06-13 10:37:02 +08:00
|
|
|
m_json_stopinfo = true;
|
|
|
|
break;
|
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
default:
|
2019-08-22 16:08:05 +08:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2016-02-26 07:46:36 +08:00
|
|
|
return error;
|
2014-06-13 10:37:02 +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_thread_info_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
|
|
|
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
bool m_json_thread;
|
|
|
|
bool m_json_stopinfo;
|
2016-09-07 04:57:50 +08:00
|
|
|
};
|
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectThreadInfo(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectIterateOverThreads(
|
2019-10-31 06:26:19 +08:00
|
|
|
interpreter, "thread info",
|
|
|
|
"Show an extended summary of one or "
|
|
|
|
"more threads. Defaults to the "
|
|
|
|
"current thread.",
|
2016-07-15 06:03:10 +08:00
|
|
|
"thread info",
|
|
|
|
eCommandRequiresProcess | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
|
2016-08-12 07:51:28 +08:00
|
|
|
m_options() {
|
2016-02-26 07:46:36 +08:00
|
|
|
m_add_return = false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
~CommandObjectThreadInfo() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-08-11 19:19:27 +08:00
|
|
|
void
|
|
|
|
HandleArgumentCompletion(CompletionRequest &request,
|
|
|
|
OptionElementVector &opt_element_vector) override {
|
|
|
|
CommandCompletions::InvokeCommonCompletionCallbacks(
|
|
|
|
GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
|
|
|
|
request, nullptr);
|
|
|
|
}
|
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-06-13 10:37:02 +08:00
|
|
|
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
|
2016-03-18 02:52:41 +08:00
|
|
|
ThreadSP thread_sp =
|
2016-02-26 07:46:36 +08:00
|
|
|
m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
|
2016-03-18 02:52:41 +08:00
|
|
|
if (!thread_sp) {
|
2016-02-26 07:46:36 +08:00
|
|
|
result.AppendErrorWithFormat("thread no longer exists: 0x%" PRIx64 "\n",
|
2016-09-07 04:57:50 +08:00
|
|
|
tid);
|
2016-02-26 07:46:36 +08:00
|
|
|
return false;
|
2014-06-13 10:37:02 +08:00
|
|
|
}
|
|
|
|
|
2016-03-18 02:52:41 +08:00
|
|
|
Thread *thread = thread_sp.get();
|
|
|
|
|
2014-06-13 10:37:02 +08:00
|
|
|
Stream &strm = result.GetOutputStream();
|
2016-03-18 02:52:41 +08:00
|
|
|
if (!thread->GetDescription(strm, eDescriptionLevelFull,
|
|
|
|
m_options.m_json_thread,
|
|
|
|
m_options.m_json_stopinfo)) {
|
|
|
|
result.AppendErrorWithFormat("error displaying info for thread: \"%d\"\n",
|
|
|
|
thread->GetIndexID());
|
2014-09-30 07:17:18 +08:00
|
|
|
return false;
|
2014-06-13 10:37:02 +08:00
|
|
|
}
|
2014-09-30 07:17:18 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-06-13 10:37:02 +08:00
|
|
|
|
|
|
|
CommandOptions m_options;
|
|
|
|
};
|
|
|
|
|
2018-11-29 06:01:52 +08:00
|
|
|
// CommandObjectThreadException
|
|
|
|
|
|
|
|
class CommandObjectThreadException : public CommandObjectIterateOverThreads {
|
2019-10-31 06:26:19 +08:00
|
|
|
public:
|
2018-11-29 06:01:52 +08:00
|
|
|
CommandObjectThreadException(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectIterateOverThreads(
|
|
|
|
interpreter, "thread exception",
|
|
|
|
"Display the current exception object for a thread. Defaults to "
|
|
|
|
"the current thread.",
|
|
|
|
"thread exception",
|
|
|
|
eCommandRequiresProcess | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {}
|
|
|
|
|
|
|
|
~CommandObjectThreadException() override = default;
|
|
|
|
|
2020-08-11 19:19:27 +08:00
|
|
|
void
|
|
|
|
HandleArgumentCompletion(CompletionRequest &request,
|
|
|
|
OptionElementVector &opt_element_vector) override {
|
|
|
|
CommandCompletions::InvokeCommonCompletionCallbacks(
|
|
|
|
GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
|
|
|
|
request, nullptr);
|
|
|
|
}
|
|
|
|
|
2018-11-29 06:01:52 +08:00
|
|
|
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
|
|
|
|
ThreadSP thread_sp =
|
|
|
|
m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
|
|
|
|
if (!thread_sp) {
|
|
|
|
result.AppendErrorWithFormat("thread no longer exists: 0x%" PRIx64 "\n",
|
|
|
|
tid);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Stream &strm = result.GetOutputStream();
|
|
|
|
ValueObjectSP exception_object_sp = thread_sp->GetCurrentException();
|
|
|
|
if (exception_object_sp) {
|
|
|
|
exception_object_sp->Dump(strm);
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadSP exception_thread_sp = thread_sp->GetCurrentExceptionBacktrace();
|
|
|
|
if (exception_thread_sp && exception_thread_sp->IsValid()) {
|
|
|
|
const uint32_t num_frames_with_source = 0;
|
|
|
|
const bool stop_format = false;
|
2018-12-20 10:01:59 +08:00
|
|
|
exception_thread_sp->GetStatus(strm, 0, UINT32_MAX,
|
2018-11-29 06:01:52 +08:00
|
|
|
num_frames_with_source, stop_format);
|
2018-12-20 10:01:59 +08:00
|
|
|
}
|
2018-11-29 06:01:52 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
// CommandObjectThreadReturn
|
2019-07-18 19:12:00 +08:00
|
|
|
#define LLDB_OPTIONS_thread_return
|
|
|
|
#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-09-14 10:14:15 +08:00
|
|
|
class CommandObjectThreadReturn : public CommandObjectRaw {
|
|
|
|
public:
|
2013-02-01 05:46:01 +08:00
|
|
|
class CommandOptions : public Options {
|
|
|
|
public:
|
2016-08-12 07:51:28 +08:00
|
|
|
CommandOptions() : Options() {
|
2013-02-01 05:46:01 +08:00
|
|
|
// Keep default values of all options in one place: OptionParsingStarting
|
|
|
|
// ()
|
2016-08-12 07:51:28 +08:00
|
|
|
OptionParsingStarting(nullptr);
|
2013-02-01 05:46:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
~CommandOptions() override = default;
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
|
|
|
|
ExecutionContext *execution_context) override {
|
|
|
|
Status error;
|
2013-02-01 05:46:01 +08:00
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
|
|
|
|
|
|
|
switch (short_option) {
|
|
|
|
case 'x': {
|
|
|
|
bool success;
|
2018-04-10 17:03:59 +08:00
|
|
|
bool tmp_value =
|
|
|
|
OptionArgParser::ToBoolean(option_arg, false, &success);
|
2013-02-01 05:46:01 +08:00
|
|
|
if (success)
|
|
|
|
m_from_expression = tmp_value;
|
2016-09-07 04:57:50 +08:00
|
|
|
else {
|
2013-02-01 05:46:01 +08:00
|
|
|
error.SetErrorStringWithFormat(
|
2016-11-13 00:56:47 +08:00
|
|
|
"invalid boolean value '%s' for 'x' option",
|
|
|
|
option_arg.str().c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} break;
|
2015-10-08 00:56:17 +08:00
|
|
|
default:
|
2019-08-22 16:08:05 +08:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-02-01 05:46:01 +08:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2016-08-12 07:51:28 +08:00
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
2013-02-01 05:46:01 +08:00
|
|
|
m_from_expression = false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-02-01 05:46:01 +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_thread_return_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
|
|
|
}
|
2013-02-01 05:46:01 +08:00
|
|
|
|
|
|
|
bool m_from_expression = false;
|
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
// Instance variables to hold the values for command options.
|
2016-09-07 04:57:50 +08:00
|
|
|
};
|
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectThreadReturn(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectRaw(interpreter, "thread return",
|
|
|
|
"Prematurely return from a stack frame, "
|
|
|
|
"short-circuiting execution of newer frames "
|
|
|
|
"and optionally yielding a specified value. Defaults "
|
|
|
|
"to the exiting the current stack "
|
|
|
|
"frame.",
|
|
|
|
"thread return",
|
|
|
|
eCommandRequiresFrame | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched |
|
|
|
|
eCommandProcessMustBePaused),
|
2016-08-12 07:51:28 +08:00
|
|
|
m_options() {
|
2012-09-14 10:14:15 +08:00
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData expression_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.
|
2012-09-14 10:14:15 +08:00
|
|
|
expression_arg.arg_type = eArgTypeExpression;
|
2013-02-01 05:46:01 +08:00
|
|
|
expression_arg.arg_repetition = eArgRepeatOptional;
|
2012-09-14 10:14:15 +08:00
|
|
|
|
|
|
|
// There is only one variant this argument could be; put it into the
|
|
|
|
// argument entry.
|
2013-02-01 05:46:01 +08:00
|
|
|
arg.push_back(expression_arg);
|
2012-09-14 10:14:15 +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
|
|
|
}
|
2012-09-14 10:14:15 +08:00
|
|
|
|
|
|
|
~CommandObjectThreadReturn() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-14 10:14:15 +08:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-14 10:14:15 +08:00
|
|
|
protected:
|
2018-07-13 06:28:52 +08:00
|
|
|
bool DoExecute(llvm::StringRef command,
|
|
|
|
CommandReturnObject &result) override {
|
2012-09-14 10:14:15 +08:00
|
|
|
// I am going to handle this by hand, because I don't want you to have to
|
2016-09-07 04:57:50 +08:00
|
|
|
// say:
|
2012-09-14 10:14:15 +08:00
|
|
|
// "thread return -- -5".
|
2018-07-13 06:28:52 +08:00
|
|
|
if (command.startswith("-x")) {
|
|
|
|
if (command.size() != 2U)
|
2012-09-14 10:14:15 +08:00
|
|
|
result.AppendWarning("Return values ignored when returning from user "
|
2013-02-01 05:46:01 +08:00
|
|
|
"called expressions");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-14 10:14:15 +08:00
|
|
|
Thread *thread = m_exe_ctx.GetThreadPtr();
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2013-02-01 05:46:01 +08:00
|
|
|
error = thread->UnwindInnermostExpression();
|
2012-09-14 10:14:15 +08:00
|
|
|
if (!error.Success()) {
|
|
|
|
result.AppendErrorWithFormat("Unwinding expression failed - %s.",
|
2013-02-01 05:46:01 +08:00
|
|
|
error.AsCString());
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2013-02-01 05:46:01 +08:00
|
|
|
bool success =
|
2012-09-14 10:14:15 +08:00
|
|
|
thread->SetSelectedFrameByIndexNoisily(0, result.GetOutputStream());
|
|
|
|
if (success) {
|
|
|
|
m_exe_ctx.SetFrameSP(thread->GetSelectedFrame());
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2012-09-14 10:14:15 +08:00
|
|
|
result.AppendErrorWithFormat(
|
2013-02-01 05:46:01 +08:00
|
|
|
"Could not select 0th frame after unwinding expression.");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
2013-02-01 05:46:01 +08:00
|
|
|
return result.Succeeded();
|
2012-09-14 10:14:15 +08:00
|
|
|
}
|
2016-02-26 07:46:36 +08:00
|
|
|
|
|
|
|
ValueObjectSP return_valobj_sp;
|
|
|
|
|
2013-11-04 17:33:30 +08:00
|
|
|
StackFrameSP frame_sp = m_exe_ctx.GetFrameSP();
|
2016-02-26 07:46:36 +08:00
|
|
|
uint32_t frame_idx = frame_sp->GetFrameIndex();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
if (frame_sp->IsInlined()) {
|
|
|
|
result.AppendError("Don't know how to return from inlined frames.");
|
|
|
|
return false;
|
2012-09-14 10:14:15 +08:00
|
|
|
}
|
|
|
|
|
2018-07-13 06:28:52 +08:00
|
|
|
if (!command.empty()) {
|
2013-02-01 05:46:01 +08:00
|
|
|
Target *target = m_exe_ctx.GetTargetPtr();
|
|
|
|
EvaluateExpressionOptions options;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
options.SetUnwindOnError(true);
|
|
|
|
options.SetUseDynamic(eNoDynamicValues);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
ExpressionResults exe_results = eExpressionSetupError;
|
|
|
|
exe_results = target->EvaluateExpression(command, frame_sp.get(),
|
2012-09-14 10:14:15 +08:00
|
|
|
return_valobj_sp, options);
|
|
|
|
if (exe_results != eExpressionCompleted) {
|
|
|
|
if (return_valobj_sp)
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"Error evaluating result expression: %s",
|
|
|
|
return_valobj_sp->GetError().AsCString());
|
|
|
|
else
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"Unknown error evaluating result expression.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
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
|
|
|
ThreadSP thread_sp = m_exe_ctx.GetThreadSP();
|
2012-10-11 02:32:14 +08:00
|
|
|
const bool broadcast = true;
|
2012-09-14 10:14:15 +08:00
|
|
|
error = thread_sp->ReturnFromFrame(frame_sp, return_valobj_sp, broadcast);
|
|
|
|
if (!error.Success()) {
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"Error returning from frame %d of thread %d: %s.", frame_idx,
|
|
|
|
thread_sp->GetIndexID(), error.AsCString());
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
2014-09-30 07:17:18 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
CommandOptions m_options;
|
2012-09-14 10:14:15 +08:00
|
|
|
};
|
2016-02-26 07:46:36 +08:00
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
// CommandObjectThreadJump
|
2019-07-18 19:12:00 +08:00
|
|
|
#define LLDB_OPTIONS_thread_jump
|
|
|
|
#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
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
class CommandObjectThreadJump : public CommandObjectParsed {
|
|
|
|
public:
|
|
|
|
class CommandOptions : public Options {
|
|
|
|
public:
|
2016-08-12 07:51:28 +08:00
|
|
|
CommandOptions() : Options() { OptionParsingStarting(nullptr); }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-08-12 07:51:28 +08:00
|
|
|
~CommandOptions() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-08-12 07:51:28 +08:00
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
2013-09-12 10:20:34 +08:00
|
|
|
m_filenames.Clear();
|
|
|
|
m_line_num = 0;
|
|
|
|
m_line_offset = 0;
|
|
|
|
m_load_addr = LLDB_INVALID_ADDRESS;
|
2015-05-27 13:04:35 +08:00
|
|
|
m_force = false;
|
2013-09-12 10:20:34 +08:00
|
|
|
}
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
|
|
|
|
ExecutionContext *execution_context) override {
|
2013-02-01 05:46:01 +08:00
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
switch (short_option) {
|
2013-09-12 10:20:34 +08:00
|
|
|
case 'f':
|
2018-11-02 05:05:36 +08:00
|
|
|
m_filenames.AppendIfUnique(FileSpec(option_arg));
|
2016-02-26 07:46:36 +08:00
|
|
|
if (m_filenames.GetSize() > 1)
|
2017-05-12 12:51:55 +08:00
|
|
|
return Status("only one source file expected.");
|
2016-09-07 04:57:50 +08:00
|
|
|
break;
|
2013-09-12 10:20:34 +08:00
|
|
|
case 'l':
|
2016-11-13 00:56:47 +08:00
|
|
|
if (option_arg.getAsInteger(0, m_line_num))
|
2017-05-12 12:51:55 +08:00
|
|
|
return Status("invalid line number: '%s'.", option_arg.str().c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
break;
|
2013-09-12 10:20:34 +08:00
|
|
|
case 'b':
|
2016-11-13 00:56:47 +08:00
|
|
|
if (option_arg.getAsInteger(0, m_line_offset))
|
2017-05-12 12:51:55 +08:00
|
|
|
return Status("invalid line offset: '%s'.", option_arg.str().c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
break;
|
2013-09-12 10:20:34 +08:00
|
|
|
case 'a':
|
2018-04-10 17:03:59 +08:00
|
|
|
m_load_addr = OptionArgParser::ToAddress(execution_context, option_arg,
|
|
|
|
LLDB_INVALID_ADDRESS, &error);
|
2016-09-07 04:57:50 +08:00
|
|
|
break;
|
2013-09-12 10:20:34 +08:00
|
|
|
case 'r':
|
|
|
|
m_force = true;
|
2016-09-07 04:57:50 +08:00
|
|
|
break;
|
|
|
|
default:
|
2019-08-22 16:08:05 +08:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-02-01 05:46:01 +08:00
|
|
|
return error;
|
2013-09-12 10:20:34 +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_thread_jump_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
|
|
|
}
|
2013-09-12 10:20:34 +08:00
|
|
|
|
|
|
|
FileSpecList m_filenames;
|
|
|
|
uint32_t m_line_num;
|
|
|
|
int32_t m_line_offset;
|
|
|
|
lldb::addr_t m_load_addr;
|
|
|
|
bool m_force;
|
2016-09-07 04:57:50 +08:00
|
|
|
};
|
2013-09-12 10:20:34 +08:00
|
|
|
|
|
|
|
CommandObjectThreadJump(CommandInterpreter &interpreter)
|
2016-07-15 06:03:10 +08:00
|
|
|
: CommandObjectParsed(
|
2013-09-12 10:20:34 +08:00
|
|
|
interpreter, "thread jump",
|
|
|
|
"Sets the program counter to a new address.", "thread jump",
|
|
|
|
eCommandRequiresFrame | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
|
|
|
|
m_options() {}
|
|
|
|
|
|
|
|
~CommandObjectThreadJump() override = default;
|
|
|
|
|
2016-08-27 07:28:47 +08:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
protected:
|
2013-09-12 10:20:34 +08:00
|
|
|
bool DoExecute(Args &args, CommandReturnObject &result) override {
|
|
|
|
RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext();
|
2013-11-04 17:33:30 +08:00
|
|
|
StackFrame *frame = m_exe_ctx.GetFramePtr();
|
2013-09-12 10:20:34 +08:00
|
|
|
Thread *thread = m_exe_ctx.GetThreadPtr();
|
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
|
|
|
Target *target = m_exe_ctx.GetTargetPtr();
|
2013-09-12 10:20:34 +08:00
|
|
|
const SymbolContext &sym_ctx =
|
|
|
|
frame->GetSymbolContext(eSymbolContextLineEntry);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
if (m_options.m_load_addr != LLDB_INVALID_ADDRESS) {
|
|
|
|
// Use this address directly.
|
|
|
|
Address dest = Address(m_options.m_load_addr);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
lldb::addr_t callAddr = dest.GetCallableLoadAddress(target);
|
|
|
|
if (callAddr == LLDB_INVALID_ADDRESS) {
|
|
|
|
result.AppendErrorWithFormat("Invalid destination address.");
|
2012-09-14 10:14:15 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
if (!reg_ctx->SetPC(callAddr)) {
|
|
|
|
result.AppendErrorWithFormat("Error changing PC value for thread %d.",
|
2012-06-01 04:48:41 +08:00
|
|
|
thread->GetIndexID());
|
2012-09-14 10:14:15 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
} else {
|
2013-09-12 10:20:34 +08:00
|
|
|
// Pick either the absolute line, or work out a relative one.
|
|
|
|
int32_t line = (int32_t)m_options.m_line_num;
|
|
|
|
if (line == 0)
|
|
|
|
line = sym_ctx.line_entry.line + m_options.m_line_offset;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
// Try the current file, but override if asked.
|
|
|
|
FileSpec file = sym_ctx.line_entry.file;
|
|
|
|
if (m_options.m_filenames.GetSize() == 1)
|
|
|
|
file = m_options.m_filenames.GetFileSpecAtIndex(0);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
if (!file) {
|
2012-09-14 10:14:15 +08:00
|
|
|
result.AppendErrorWithFormat(
|
2013-09-12 10:20:34 +08:00
|
|
|
"No source file available for the current location.");
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
std::string warnings;
|
2017-05-12 12:51:55 +08:00
|
|
|
Status err = thread->JumpToLine(file, line, m_options.m_force, &warnings);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
if (err.Fail()) {
|
2013-02-01 05:46:01 +08:00
|
|
|
result.SetError(err);
|
2012-09-14 10:14:15 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
if (!warnings.empty())
|
|
|
|
result.AppendWarning(warnings.c_str());
|
|
|
|
}
|
|
|
|
|
2013-02-01 05:46:01 +08:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
2014-09-30 07:17:18 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-09-12 10:20:34 +08:00
|
|
|
CommandOptions m_options;
|
|
|
|
};
|
2016-02-26 07:46:36 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
// Next are the subcommands of CommandObjectMultiwordThreadPlan
|
|
|
|
|
|
|
|
// CommandObjectThreadPlanList
|
2019-07-18 19:12:00 +08:00
|
|
|
#define LLDB_OPTIONS_thread_plan_list
|
|
|
|
#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
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
class CommandObjectThreadPlanList : public CommandObjectIterateOverThreads {
|
|
|
|
public:
|
|
|
|
class CommandOptions : public Options {
|
|
|
|
public:
|
2016-08-12 07:51:28 +08:00
|
|
|
CommandOptions() : Options() {
|
2014-09-30 07:17:18 +08:00
|
|
|
// Keep default values of all options in one place: OptionParsingStarting
|
|
|
|
// ()
|
2016-08-12 07:51:28 +08:00
|
|
|
OptionParsingStarting(nullptr);
|
2014-09-30 07:17:18 +08:00
|
|
|
}
|
|
|
|
|
2016-02-26 07:46: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 {
|
2014-09-30 07:17:18 +08:00
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
switch (short_option) {
|
|
|
|
case 'i':
|
|
|
|
m_internal = true;
|
2016-02-26 07:46:36 +08:00
|
|
|
break;
|
2020-03-19 03:05:08 +08:00
|
|
|
case 't':
|
|
|
|
lldb::tid_t tid;
|
|
|
|
if (option_arg.getAsInteger(0, tid))
|
|
|
|
return Status("invalid tid: '%s'.", option_arg.str().c_str());
|
|
|
|
m_tids.push_back(tid);
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
m_unreported = false;
|
|
|
|
break;
|
2014-09-30 07:17:18 +08:00
|
|
|
case 'v':
|
|
|
|
m_verbose = true;
|
2016-02-26 07:46:36 +08:00
|
|
|
break;
|
2014-09-30 07:17:18 +08:00
|
|
|
default:
|
2019-08-22 16:08:05 +08:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2014-09-30 07:17:18 +08:00
|
|
|
}
|
2020-03-19 03:05:08 +08:00
|
|
|
return {};
|
2014-09-30 07:17:18 +08:00
|
|
|
}
|
|
|
|
|
2016-08-12 07:51:28 +08:00
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
2014-09-30 07:17:18 +08:00
|
|
|
m_verbose = false;
|
|
|
|
m_internal = false;
|
2020-03-19 03:05:08 +08:00
|
|
|
m_unreported = true; // The variable is "skip unreported" and we want to
|
|
|
|
// skip unreported by default.
|
|
|
|
m_tids.clear();
|
2014-09-30 07:17:18 +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_thread_plan_list_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
|
|
|
}
|
2014-09-30 07:17:18 +08:00
|
|
|
|
|
|
|
// Instance variables to hold the values for command options.
|
|
|
|
bool m_verbose;
|
|
|
|
bool m_internal;
|
2020-03-19 03:05:08 +08:00
|
|
|
bool m_unreported;
|
|
|
|
std::vector<lldb::tid_t> m_tids;
|
2014-09-30 07:17:18 +08:00
|
|
|
};
|
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectThreadPlanList(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectIterateOverThreads(
|
|
|
|
interpreter, "thread plan list",
|
|
|
|
"Show thread plans for one or more threads. If no threads are "
|
|
|
|
"specified, show the "
|
|
|
|
"current thread. Use the thread-index \"all\" to see all threads.",
|
|
|
|
nullptr,
|
|
|
|
eCommandRequiresProcess | eCommandRequiresThread |
|
|
|
|
eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
|
|
|
|
eCommandProcessMustBePaused),
|
2016-08-12 07:51:28 +08:00
|
|
|
m_options() {}
|
2014-09-30 07:17:18 +08:00
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
~CommandObjectThreadPlanList() override = default;
|
2014-09-30 07:17:18 +08:00
|
|
|
|
2015-10-08 00:56:17 +08:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
2014-09-30 07:17:18 +08:00
|
|
|
|
2020-03-19 03:05:08 +08:00
|
|
|
bool DoExecute(Args &command, CommandReturnObject &result) override {
|
|
|
|
// If we are reporting all threads, dispatch to the Process to do that:
|
|
|
|
if (command.GetArgumentCount() == 0 && m_options.m_tids.empty()) {
|
|
|
|
Stream &strm = result.GetOutputStream();
|
|
|
|
DescriptionLevel desc_level = m_options.m_verbose
|
|
|
|
? eDescriptionLevelVerbose
|
|
|
|
: eDescriptionLevelFull;
|
|
|
|
m_exe_ctx.GetProcessPtr()->DumpThreadPlans(
|
|
|
|
strm, desc_level, m_options.m_internal, true, m_options.m_unreported);
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
// Do any TID's that the user may have specified as TID, then do any
|
|
|
|
// Thread Indexes...
|
|
|
|
if (!m_options.m_tids.empty()) {
|
|
|
|
Process *process = m_exe_ctx.GetProcessPtr();
|
|
|
|
StreamString tmp_strm;
|
|
|
|
for (lldb::tid_t tid : m_options.m_tids) {
|
|
|
|
bool success = process->DumpThreadPlansForTID(
|
|
|
|
tmp_strm, tid, eDescriptionLevelFull, m_options.m_internal,
|
|
|
|
true /* condense_trivial */, m_options.m_unreported);
|
|
|
|
// If we didn't find a TID, stop here and return an error.
|
|
|
|
if (!success) {
|
|
|
|
result.SetError("Error dumping plans:");
|
|
|
|
result.AppendError(tmp_strm.GetString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Otherwise, add our data to the output:
|
|
|
|
result.GetOutputStream() << tmp_strm.GetString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CommandObjectIterateOverThreads::DoExecute(command, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
protected:
|
2016-03-18 02:52:41 +08:00
|
|
|
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
|
2020-03-19 03:05:08 +08:00
|
|
|
// If we have already handled this from a -t option, skip it here.
|
2020-08-13 19:44:25 +08:00
|
|
|
if (llvm::is_contained(m_options.m_tids, tid))
|
2020-03-19 03:05:08 +08:00
|
|
|
return true;
|
2016-03-18 02:52:41 +08:00
|
|
|
|
2020-03-19 03:05:08 +08:00
|
|
|
Process *process = m_exe_ctx.GetProcessPtr();
|
2016-03-18 02:52:41 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
Stream &strm = result.GetOutputStream();
|
|
|
|
DescriptionLevel desc_level = eDescriptionLevelFull;
|
|
|
|
if (m_options.m_verbose)
|
|
|
|
desc_level = eDescriptionLevelVerbose;
|
|
|
|
|
2020-03-19 03:05:08 +08:00
|
|
|
process->DumpThreadPlansForTID(strm, tid, desc_level, m_options.m_internal,
|
|
|
|
true /* condense_trivial */,
|
|
|
|
m_options.m_unreported);
|
2014-09-30 07:17:18 +08:00
|
|
|
return true;
|
|
|
|
}
|
2016-02-26 07:46:36 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
CommandOptions m_options;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandObjectThreadPlanDiscard : public CommandObjectParsed {
|
|
|
|
public:
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectThreadPlanDiscard(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(interpreter, "thread plan discard",
|
|
|
|
"Discards thread plans up to and including the "
|
|
|
|
"specified index (see 'thread plan list'.) "
|
|
|
|
"Only user visible plans can be discarded.",
|
|
|
|
nullptr,
|
|
|
|
eCommandRequiresProcess | eCommandRequiresThread |
|
|
|
|
eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched |
|
|
|
|
eCommandProcessMustBePaused) {
|
2014-09-30 07:17:18 +08:00
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData plan_index_arg;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
// Define the first (and only) variant of this arg.
|
|
|
|
plan_index_arg.arg_type = eArgTypeUnsignedInteger;
|
|
|
|
plan_index_arg.arg_repetition = eArgRepeatPlain;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
// There is only one variant this argument could be; put it into the
|
|
|
|
// argument entry.
|
|
|
|
arg.push_back(plan_index_arg);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-09-30 07:17:18 +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
|
|
|
}
|
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
~CommandObjectThreadPlanDiscard() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-08-11 16:02:51 +08:00
|
|
|
void
|
|
|
|
HandleArgumentCompletion(CompletionRequest &request,
|
|
|
|
OptionElementVector &opt_element_vector) override {
|
|
|
|
if (!m_exe_ctx.HasThreadScope() || request.GetCursorIndex())
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_exe_ctx.GetThreadPtr()->AutoCompleteThreadPlans(request);
|
|
|
|
}
|
|
|
|
|
2015-10-08 00:56:17 +08:00
|
|
|
bool DoExecute(Args &args, CommandReturnObject &result) override {
|
2013-09-12 10:20:34 +08:00
|
|
|
Thread *thread = m_exe_ctx.GetThreadPtr();
|
2014-09-30 07:17:18 +08:00
|
|
|
if (args.GetArgumentCount() != 1) {
|
|
|
|
result.AppendErrorWithFormat("Too many arguments, expected one - the "
|
|
|
|
"thread plan index - but got %zu.",
|
|
|
|
args.GetArgumentCount());
|
2013-09-12 10:20:34 +08:00
|
|
|
return false;
|
2014-09-30 07:17:18 +08:00
|
|
|
}
|
|
|
|
|
2020-07-01 23:00:12 +08:00
|
|
|
uint32_t thread_plan_idx;
|
|
|
|
if (!llvm::to_integer(args.GetArgumentAtIndex(0), thread_plan_idx)) {
|
2014-09-30 07:17:18 +08:00
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"Invalid thread index: \"%s\" - should be unsigned int.",
|
|
|
|
args.GetArgumentAtIndex(0));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thread_plan_idx == 0) {
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"You wouldn't really want me to discard the base thread plan.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thread->DiscardUserThreadPlansUpToIndex(thread_plan_idx)) {
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
result.AppendErrorWithFormat(
|
|
|
|
"Could not find User thread plan with index %s.",
|
|
|
|
args.GetArgumentAtIndex(0));
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-09-30 07:17:18 +08:00
|
|
|
};
|
|
|
|
|
2020-03-19 03:05:08 +08:00
|
|
|
class CommandObjectThreadPlanPrune : public CommandObjectParsed {
|
|
|
|
public:
|
|
|
|
CommandObjectThreadPlanPrune(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(interpreter, "thread plan prune",
|
|
|
|
"Removes any thread plans associated with "
|
|
|
|
"currently unreported threads. "
|
|
|
|
"Specify one or more TID's to remove, or if no "
|
|
|
|
"TID's are provides, remove threads for all "
|
|
|
|
"unreported threads",
|
|
|
|
nullptr,
|
|
|
|
eCommandRequiresProcess |
|
|
|
|
eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched |
|
|
|
|
eCommandProcessMustBePaused) {
|
|
|
|
CommandArgumentEntry arg;
|
|
|
|
CommandArgumentData tid_arg;
|
|
|
|
|
|
|
|
// Define the first (and only) variant of this arg.
|
|
|
|
tid_arg.arg_type = eArgTypeThreadID;
|
|
|
|
tid_arg.arg_repetition = eArgRepeatStar;
|
|
|
|
|
|
|
|
// There is only one variant this argument could be; put it into the
|
|
|
|
// argument entry.
|
|
|
|
arg.push_back(tid_arg);
|
|
|
|
|
|
|
|
// Push the data for the first argument into the m_arguments vector.
|
|
|
|
m_arguments.push_back(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
~CommandObjectThreadPlanPrune() override = default;
|
|
|
|
|
|
|
|
bool DoExecute(Args &args, CommandReturnObject &result) override {
|
|
|
|
Process *process = m_exe_ctx.GetProcessPtr();
|
|
|
|
|
|
|
|
if (args.GetArgumentCount() == 0) {
|
|
|
|
process->PruneThreadPlans();
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const size_t num_args = args.GetArgumentCount();
|
|
|
|
|
|
|
|
std::lock_guard<std::recursive_mutex> guard(
|
|
|
|
process->GetThreadList().GetMutex());
|
|
|
|
|
|
|
|
for (size_t i = 0; i < num_args; i++) {
|
2020-07-01 23:00:12 +08:00
|
|
|
lldb::tid_t tid;
|
|
|
|
if (!llvm::to_integer(args.GetArgumentAtIndex(i), tid)) {
|
2020-03-19 03:05:08 +08:00
|
|
|
result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n",
|
|
|
|
args.GetArgumentAtIndex(i));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!process->PruneThreadPlansForTID(tid)) {
|
|
|
|
result.AppendErrorWithFormat("Could not find unreported tid: \"%s\"\n",
|
|
|
|
args.GetArgumentAtIndex(i));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishNoResult);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
// CommandObjectMultiwordThreadPlan
|
|
|
|
|
|
|
|
class CommandObjectMultiwordThreadPlan : public CommandObjectMultiword {
|
|
|
|
public:
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectMultiwordThreadPlan(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectMultiword(
|
|
|
|
interpreter, "plan",
|
|
|
|
"Commands for managing thread plans that control execution.",
|
|
|
|
"thread plan <subcommand> [<subcommand objects]") {
|
2014-09-30 07:17:18 +08:00
|
|
|
LoadSubCommand(
|
|
|
|
"list", CommandObjectSP(new CommandObjectThreadPlanList(interpreter)));
|
|
|
|
LoadSubCommand(
|
|
|
|
"discard",
|
|
|
|
CommandObjectSP(new CommandObjectThreadPlanDiscard(interpreter)));
|
2020-03-19 03:05:08 +08:00
|
|
|
LoadSubCommand(
|
|
|
|
"prune",
|
|
|
|
CommandObjectSP(new CommandObjectThreadPlanPrune(interpreter)));
|
2014-09-30 07:17:18 +08:00
|
|
|
}
|
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
~CommandObjectMultiwordThreadPlan() override = default;
|
2014-09-30 07:17:18 +08:00
|
|
|
};
|
|
|
|
|
2020-10-03 05:32:22 +08:00
|
|
|
// Next are the subcommands of CommandObjectMultiwordTrace
|
|
|
|
|
2020-10-27 12:22:06 +08:00
|
|
|
// CommandObjectTraceStart
|
|
|
|
|
2020-11-10 05:36:26 +08:00
|
|
|
class CommandObjectTraceStart : public CommandObjectTraceProxy {
|
2020-10-27 12:22:06 +08:00
|
|
|
public:
|
|
|
|
CommandObjectTraceStart(CommandInterpreter &interpreter)
|
2020-11-10 05:36:26 +08:00
|
|
|
: CommandObjectTraceProxy(
|
|
|
|
/*live_debug_session_only*/ true, interpreter, "thread trace start",
|
|
|
|
"Start tracing threads with the corresponding trace "
|
|
|
|
"plug-in for the current process.",
|
|
|
|
"thread trace start [<trace-options>]") {}
|
2020-10-27 12:22:06 +08:00
|
|
|
|
|
|
|
protected:
|
2020-11-10 05:36:26 +08:00
|
|
|
lldb::CommandObjectSP GetDelegateCommand(Trace &trace) override {
|
|
|
|
return trace.GetThreadTraceStartCommand(m_interpreter);
|
2020-10-27 12:22:06 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// CommandObjectTraceStop
|
|
|
|
|
2020-11-10 05:36:26 +08:00
|
|
|
class CommandObjectTraceStop : public CommandObjectMultipleThreads {
|
2020-10-27 12:22:06 +08:00
|
|
|
public:
|
|
|
|
CommandObjectTraceStop(CommandInterpreter &interpreter)
|
2020-11-10 05:36:26 +08:00
|
|
|
: CommandObjectMultipleThreads(
|
2020-10-27 12:22:06 +08:00
|
|
|
interpreter, "thread trace stop",
|
2020-11-10 05:36:26 +08:00
|
|
|
"Stop tracing threads, including the ones traced with the "
|
|
|
|
"\"process trace start\" command."
|
2020-10-27 12:22:06 +08:00
|
|
|
"Defaults to the current thread. Thread indices can be "
|
2020-11-10 05:36:26 +08:00
|
|
|
"specified as arguments.\n Use the thread-index \"all\" to stop "
|
|
|
|
"tracing "
|
|
|
|
"for all existing threads.",
|
2020-10-27 12:22:06 +08:00
|
|
|
"thread trace stop [<thread-index> <thread-index> ...]",
|
|
|
|
eCommandRequiresProcess | eCommandTryTargetAPILock |
|
|
|
|
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused |
|
|
|
|
eCommandProcessMustBeTraced) {}
|
|
|
|
|
|
|
|
~CommandObjectTraceStop() override = default;
|
|
|
|
|
2020-11-10 05:36:26 +08:00
|
|
|
bool DoExecuteOnThreads(Args &command, CommandReturnObject &result,
|
|
|
|
const std::vector<lldb::tid_t> &tids) override {
|
|
|
|
ProcessSP process_sp = m_exe_ctx.GetProcessSP();
|
2020-10-27 12:22:06 +08:00
|
|
|
|
2020-11-10 05:36:26 +08:00
|
|
|
TraceSP trace_sp = process_sp->GetTarget().GetTrace();
|
2020-10-27 12:22:06 +08:00
|
|
|
|
2020-11-10 05:36:26 +08:00
|
|
|
if (llvm::Error err = trace_sp->StopThreads(tids))
|
|
|
|
result.SetError(toString(std::move(err)));
|
|
|
|
else
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
|
|
|
|
return result.Succeeded();
|
2020-10-27 12:22:06 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-10-03 05:32:22 +08:00
|
|
|
// CommandObjectTraceDumpInstructions
|
|
|
|
#define LLDB_OPTIONS_thread_trace_dump_instructions
|
|
|
|
#include "CommandOptions.inc"
|
|
|
|
|
|
|
|
class CommandObjectTraceDumpInstructions
|
|
|
|
: public CommandObjectIterateOverThreads {
|
|
|
|
public:
|
|
|
|
class CommandOptions : public Options {
|
|
|
|
public:
|
|
|
|
CommandOptions() : Options() { OptionParsingStarting(nullptr); }
|
|
|
|
|
|
|
|
~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 'c': {
|
|
|
|
int32_t count;
|
|
|
|
if (option_arg.empty() || option_arg.getAsInteger(0, count) ||
|
|
|
|
count < 0)
|
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
"invalid integer value for option '%s'",
|
|
|
|
option_arg.str().c_str());
|
|
|
|
else
|
|
|
|
m_count = count;
|
|
|
|
break;
|
|
|
|
}
|
[trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.
This diff finally implements trace decoding!
The current interface is
$ trace load /path/to/trace/session/file.json
$ thread trace dump instructions
thread #1: tid = 3842849, total instructions = 22
[ 0] 0x40052d
[ 1] 0x40052d
...
[19] 0x400521
$ # simply enter, which is a repeat command
[20] 0x40052d
[21] 0x400529
...
This doesn't do any disassembly, which will be done in the next diff.
Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
- GetInstructionCount, which counts the number of instructions traced for a given thread
- IsTraceFailed, which returns an Error if decoding a thread failed
- ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included
Differential Revision: https://reviews.llvm.org/D89283
2020-10-15 01:26:10 +08:00
|
|
|
case 'p': {
|
|
|
|
int32_t position;
|
|
|
|
if (option_arg.empty() || option_arg.getAsInteger(0, position) ||
|
|
|
|
position < 0)
|
2020-10-03 05:32:22 +08:00
|
|
|
error.SetErrorStringWithFormat(
|
|
|
|
"invalid integer value for option '%s'",
|
|
|
|
option_arg.str().c_str());
|
|
|
|
else
|
[trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.
This diff finally implements trace decoding!
The current interface is
$ trace load /path/to/trace/session/file.json
$ thread trace dump instructions
thread #1: tid = 3842849, total instructions = 22
[ 0] 0x40052d
[ 1] 0x40052d
...
[19] 0x400521
$ # simply enter, which is a repeat command
[20] 0x40052d
[21] 0x400529
...
This doesn't do any disassembly, which will be done in the next diff.
Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
- GetInstructionCount, which counts the number of instructions traced for a given thread
- IsTraceFailed, which returns an Error if decoding a thread failed
- ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included
Differential Revision: https://reviews.llvm.org/D89283
2020-10-15 01:26:10 +08:00
|
|
|
m_position = position;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'r': {
|
|
|
|
m_raw = true;
|
2020-10-03 05:32:22 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
llvm_unreachable("Unimplemented option");
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
|
|
|
m_count = kDefaultCount;
|
[trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.
This diff finally implements trace decoding!
The current interface is
$ trace load /path/to/trace/session/file.json
$ thread trace dump instructions
thread #1: tid = 3842849, total instructions = 22
[ 0] 0x40052d
[ 1] 0x40052d
...
[19] 0x400521
$ # simply enter, which is a repeat command
[20] 0x40052d
[21] 0x400529
...
This doesn't do any disassembly, which will be done in the next diff.
Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
- GetInstructionCount, which counts the number of instructions traced for a given thread
- IsTraceFailed, which returns an Error if decoding a thread failed
- ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included
Differential Revision: https://reviews.llvm.org/D89283
2020-10-15 01:26:10 +08:00
|
|
|
m_position = llvm::None;
|
|
|
|
m_raw = false;
|
2020-10-03 05:32:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
|
|
|
|
return llvm::makeArrayRef(g_thread_trace_dump_instructions_options);
|
|
|
|
}
|
|
|
|
|
[trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.
This diff finally implements trace decoding!
The current interface is
$ trace load /path/to/trace/session/file.json
$ thread trace dump instructions
thread #1: tid = 3842849, total instructions = 22
[ 0] 0x40052d
[ 1] 0x40052d
...
[19] 0x400521
$ # simply enter, which is a repeat command
[20] 0x40052d
[21] 0x400529
...
This doesn't do any disassembly, which will be done in the next diff.
Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
- GetInstructionCount, which counts the number of instructions traced for a given thread
- IsTraceFailed, which returns an Error if decoding a thread failed
- ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included
Differential Revision: https://reviews.llvm.org/D89283
2020-10-15 01:26:10 +08:00
|
|
|
static const size_t kDefaultCount = 20;
|
2020-10-03 05:32:22 +08:00
|
|
|
|
|
|
|
// Instance variables to hold the values for command options.
|
[trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.
This diff finally implements trace decoding!
The current interface is
$ trace load /path/to/trace/session/file.json
$ thread trace dump instructions
thread #1: tid = 3842849, total instructions = 22
[ 0] 0x40052d
[ 1] 0x40052d
...
[19] 0x400521
$ # simply enter, which is a repeat command
[20] 0x40052d
[21] 0x400529
...
This doesn't do any disassembly, which will be done in the next diff.
Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
- GetInstructionCount, which counts the number of instructions traced for a given thread
- IsTraceFailed, which returns an Error if decoding a thread failed
- ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included
Differential Revision: https://reviews.llvm.org/D89283
2020-10-15 01:26:10 +08:00
|
|
|
size_t m_count;
|
|
|
|
llvm::Optional<ssize_t> m_position;
|
|
|
|
bool m_raw;
|
2020-10-03 05:32:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
CommandObjectTraceDumpInstructions(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectIterateOverThreads(
|
|
|
|
interpreter, "thread trace dump instructions",
|
|
|
|
"Dump the traced instructions for one or more threads. If no "
|
|
|
|
"threads are specified, show the current thread. Use the "
|
|
|
|
"thread-index \"all\" to see all threads.",
|
|
|
|
nullptr,
|
|
|
|
eCommandRequiresProcess | eCommandTryTargetAPILock |
|
2020-10-27 12:22:06 +08:00
|
|
|
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused |
|
|
|
|
eCommandProcessMustBeTraced),
|
2020-10-03 05:32:22 +08:00
|
|
|
m_options(), m_create_repeat_command_just_invoked(false) {}
|
|
|
|
|
|
|
|
~CommandObjectTraceDumpInstructions() override = default;
|
|
|
|
|
|
|
|
Options *GetOptions() override { return &m_options; }
|
|
|
|
|
|
|
|
const char *GetRepeatCommand(Args ¤t_command_args,
|
|
|
|
uint32_t index) override {
|
|
|
|
current_command_args.GetCommandString(m_repeat_command);
|
|
|
|
m_create_repeat_command_just_invoked = true;
|
[trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.
This diff finally implements trace decoding!
The current interface is
$ trace load /path/to/trace/session/file.json
$ thread trace dump instructions
thread #1: tid = 3842849, total instructions = 22
[ 0] 0x40052d
[ 1] 0x40052d
...
[19] 0x400521
$ # simply enter, which is a repeat command
[20] 0x40052d
[21] 0x400529
...
This doesn't do any disassembly, which will be done in the next diff.
Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
- GetInstructionCount, which counts the number of instructions traced for a given thread
- IsTraceFailed, which returns an Error if decoding a thread failed
- ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included
Differential Revision: https://reviews.llvm.org/D89283
2020-10-15 01:26:10 +08:00
|
|
|
m_consecutive_repetitions = 0;
|
2020-10-03 05:32:22 +08:00
|
|
|
return m_repeat_command.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool DoExecute(Args &args, CommandReturnObject &result) override {
|
[trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.
This diff finally implements trace decoding!
The current interface is
$ trace load /path/to/trace/session/file.json
$ thread trace dump instructions
thread #1: tid = 3842849, total instructions = 22
[ 0] 0x40052d
[ 1] 0x40052d
...
[19] 0x400521
$ # simply enter, which is a repeat command
[20] 0x40052d
[21] 0x400529
...
This doesn't do any disassembly, which will be done in the next diff.
Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
- GetInstructionCount, which counts the number of instructions traced for a given thread
- IsTraceFailed, which returns an Error if decoding a thread failed
- ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included
Differential Revision: https://reviews.llvm.org/D89283
2020-10-15 01:26:10 +08:00
|
|
|
if (IsRepeatCommand())
|
|
|
|
m_consecutive_repetitions++;
|
2020-10-03 05:32:22 +08:00
|
|
|
bool status = CommandObjectIterateOverThreads::DoExecute(args, result);
|
|
|
|
|
|
|
|
m_create_repeat_command_just_invoked = false;
|
[trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.
This diff finally implements trace decoding!
The current interface is
$ trace load /path/to/trace/session/file.json
$ thread trace dump instructions
thread #1: tid = 3842849, total instructions = 22
[ 0] 0x40052d
[ 1] 0x40052d
...
[19] 0x400521
$ # simply enter, which is a repeat command
[20] 0x40052d
[21] 0x400529
...
This doesn't do any disassembly, which will be done in the next diff.
Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
- GetInstructionCount, which counts the number of instructions traced for a given thread
- IsTraceFailed, which returns an Error if decoding a thread failed
- ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included
Differential Revision: https://reviews.llvm.org/D89283
2020-10-15 01:26:10 +08:00
|
|
|
return status;
|
2020-10-03 05:32:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsRepeatCommand() {
|
|
|
|
return !m_repeat_command.empty() && !m_create_repeat_command_just_invoked;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
|
|
|
|
const TraceSP &trace_sp = m_exe_ctx.GetTargetSP()->GetTrace();
|
|
|
|
ThreadSP thread_sp =
|
|
|
|
m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
|
|
|
|
|
[trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.
This diff finally implements trace decoding!
The current interface is
$ trace load /path/to/trace/session/file.json
$ thread trace dump instructions
thread #1: tid = 3842849, total instructions = 22
[ 0] 0x40052d
[ 1] 0x40052d
...
[19] 0x400521
$ # simply enter, which is a repeat command
[20] 0x40052d
[21] 0x400529
...
This doesn't do any disassembly, which will be done in the next diff.
Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
- GetInstructionCount, which counts the number of instructions traced for a given thread
- IsTraceFailed, which returns an Error if decoding a thread failed
- ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included
Differential Revision: https://reviews.llvm.org/D89283
2020-10-15 01:26:10 +08:00
|
|
|
size_t count = m_options.m_count;
|
|
|
|
ssize_t position = m_options.m_position.getValueOr(
|
|
|
|
trace_sp->GetCursorPosition(*thread_sp)) -
|
|
|
|
m_consecutive_repetitions * count;
|
|
|
|
if (position < 0)
|
|
|
|
result.SetError("error: no more data");
|
|
|
|
else
|
|
|
|
trace_sp->DumpTraceInstructions(*thread_sp, result.GetOutputStream(),
|
|
|
|
count, position, m_options.m_raw);
|
2020-10-03 05:32:22 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CommandOptions m_options;
|
|
|
|
|
|
|
|
// Repeat command helpers
|
|
|
|
std::string m_repeat_command;
|
|
|
|
bool m_create_repeat_command_just_invoked;
|
[trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.
This diff finally implements trace decoding!
The current interface is
$ trace load /path/to/trace/session/file.json
$ thread trace dump instructions
thread #1: tid = 3842849, total instructions = 22
[ 0] 0x40052d
[ 1] 0x40052d
...
[19] 0x400521
$ # simply enter, which is a repeat command
[20] 0x40052d
[21] 0x400529
...
This doesn't do any disassembly, which will be done in the next diff.
Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
- GetInstructionCount, which counts the number of instructions traced for a given thread
- IsTraceFailed, which returns an Error if decoding a thread failed
- ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included
Differential Revision: https://reviews.llvm.org/D89283
2020-10-15 01:26:10 +08:00
|
|
|
size_t m_consecutive_repetitions = 0;
|
2020-10-03 05:32:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// CommandObjectMultiwordTraceDump
|
|
|
|
class CommandObjectMultiwordTraceDump : public CommandObjectMultiword {
|
|
|
|
public:
|
|
|
|
CommandObjectMultiwordTraceDump(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectMultiword(
|
|
|
|
interpreter, "dump",
|
|
|
|
"Commands for displaying trace information of the threads "
|
|
|
|
"in the current process.",
|
|
|
|
"thread trace dump <subcommand> [<subcommand objects>]") {
|
|
|
|
LoadSubCommand(
|
|
|
|
"instructions",
|
|
|
|
CommandObjectSP(new CommandObjectTraceDumpInstructions(interpreter)));
|
|
|
|
}
|
|
|
|
~CommandObjectMultiwordTraceDump() override = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
// CommandObjectMultiwordTrace
|
|
|
|
class CommandObjectMultiwordTrace : public CommandObjectMultiword {
|
|
|
|
public:
|
|
|
|
CommandObjectMultiwordTrace(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectMultiword(
|
|
|
|
interpreter, "trace",
|
|
|
|
"Commands for operating on traces of the threads in the current "
|
|
|
|
"process.",
|
|
|
|
"thread trace <subcommand> [<subcommand objects>]") {
|
|
|
|
LoadSubCommand("dump", CommandObjectSP(new CommandObjectMultiwordTraceDump(
|
|
|
|
interpreter)));
|
2020-10-27 12:22:06 +08:00
|
|
|
LoadSubCommand("start",
|
|
|
|
CommandObjectSP(new CommandObjectTraceStart(interpreter)));
|
|
|
|
LoadSubCommand("stop",
|
|
|
|
CommandObjectSP(new CommandObjectTraceStop(interpreter)));
|
2020-10-03 05:32:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
~CommandObjectMultiwordTrace() override = default;
|
|
|
|
};
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// CommandObjectMultiwordThread
|
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
CommandObjectMultiwordThread::CommandObjectMultiwordThread(
|
|
|
|
CommandInterpreter &interpreter)
|
2019-10-31 06:26:19 +08:00
|
|
|
: CommandObjectMultiword(interpreter, "thread",
|
|
|
|
"Commands for operating on "
|
|
|
|
"one or more threads in "
|
|
|
|
"the current process.",
|
2016-07-15 06:03:10 +08:00
|
|
|
"thread <subcommand> [<subcommand-options>]") {
|
2010-09-18 09:14:36 +08:00
|
|
|
LoadSubCommand("backtrace", CommandObjectSP(new CommandObjectThreadBacktrace(
|
|
|
|
interpreter)));
|
|
|
|
LoadSubCommand("continue",
|
|
|
|
CommandObjectSP(new CommandObjectThreadContinue(interpreter)));
|
|
|
|
LoadSubCommand("list",
|
|
|
|
CommandObjectSP(new CommandObjectThreadList(interpreter)));
|
2012-09-14 10:14:15 +08:00
|
|
|
LoadSubCommand("return",
|
|
|
|
CommandObjectSP(new CommandObjectThreadReturn(interpreter)));
|
2013-09-12 10:20:34 +08:00
|
|
|
LoadSubCommand("jump",
|
|
|
|
CommandObjectSP(new CommandObjectThreadJump(interpreter)));
|
2010-09-18 09:14:36 +08:00
|
|
|
LoadSubCommand("select",
|
|
|
|
CommandObjectSP(new CommandObjectThreadSelect(interpreter)));
|
|
|
|
LoadSubCommand("until",
|
|
|
|
CommandObjectSP(new CommandObjectThreadUntil(interpreter)));
|
2014-06-13 10:37:02 +08:00
|
|
|
LoadSubCommand("info",
|
|
|
|
CommandObjectSP(new CommandObjectThreadInfo(interpreter)));
|
2019-10-31 06:26:19 +08:00
|
|
|
LoadSubCommand("exception", CommandObjectSP(new CommandObjectThreadException(
|
|
|
|
interpreter)));
|
2016-07-15 06:03:10 +08:00
|
|
|
LoadSubCommand("step-in",
|
|
|
|
CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
|
|
|
|
interpreter, "thread step-in",
|
|
|
|
"Source level single step, stepping into calls. Defaults "
|
|
|
|
"to current thread unless specified.",
|
|
|
|
nullptr, eStepTypeInto, eStepScopeSource)));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
LoadSubCommand("step-out",
|
|
|
|
CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
|
|
|
|
interpreter, "thread step-out",
|
|
|
|
"Finish executing the current stack frame and stop after "
|
|
|
|
"returning. Defaults to current thread unless specified.",
|
|
|
|
nullptr, eStepTypeOut, eStepScopeSource)));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
LoadSubCommand("step-over",
|
|
|
|
CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
|
|
|
|
interpreter, "thread step-over",
|
|
|
|
"Source level single step, stepping over calls. Defaults "
|
|
|
|
"to current thread unless specified.",
|
|
|
|
nullptr, eStepTypeOver, eStepScopeSource)));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
LoadSubCommand("step-inst",
|
|
|
|
CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
|
|
|
|
interpreter, "thread step-inst",
|
|
|
|
"Instruction level single step, stepping into calls. "
|
|
|
|
"Defaults to current thread unless specified.",
|
|
|
|
nullptr, eStepTypeTrace, eStepScopeInstruction)));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-07-15 06:03:10 +08:00
|
|
|
LoadSubCommand("step-inst-over",
|
|
|
|
CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
|
|
|
|
interpreter, "thread step-inst-over",
|
|
|
|
"Instruction level single step, stepping over calls. "
|
|
|
|
"Defaults to current thread unless specified.",
|
|
|
|
nullptr, eStepTypeTraceOver, eStepScopeInstruction)));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
LoadSubCommand(
|
2016-07-15 06:03:10 +08:00
|
|
|
"step-scripted",
|
|
|
|
CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
|
|
|
|
interpreter, "thread step-scripted",
|
2019-10-04 06:50:18 +08:00
|
|
|
"Step as instructed by the script class passed in the -C option. "
|
|
|
|
"You can also specify a dictionary of key (-k) and value (-v) pairs "
|
|
|
|
"that will be used to populate an SBStructuredData Dictionary, which "
|
|
|
|
"will be passed to the constructor of the class implementing the "
|
|
|
|
"scripted step. See the Python Reference for more details.",
|
2014-09-30 07:17:18 +08:00
|
|
|
nullptr, eStepTypeScripted, eStepScopeSource)));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
LoadSubCommand("plan", CommandObjectSP(new CommandObjectMultiwordThreadPlan(
|
|
|
|
interpreter)));
|
2020-10-03 05:32:22 +08:00
|
|
|
LoadSubCommand("trace",
|
|
|
|
CommandObjectSP(new CommandObjectMultiwordTrace(interpreter)));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-02-26 07:46:36 +08:00
|
|
|
CommandObjectMultiwordThread::~CommandObjectMultiwordThread() = default;
|