forked from OSchip/llvm-project
[Commands] Remove dead code for unused `args` command.
It wasn't even registered. (lldb) apropos args No commands found pertaining to 'args'. Try 'help' to see a complete list of debugger commands. llvm-svn: 328370
This commit is contained in:
parent
e4d34c0d56
commit
88ad88667c
|
@ -379,7 +379,6 @@
|
|||
2689000F13353DB600698AC0 /* StoppointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */; };
|
||||
2689001113353DB600698AC0 /* Watchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1810F1B83100F91463 /* Watchpoint.cpp */; };
|
||||
2689001213353DDE00698AC0 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; };
|
||||
2689001313353DDE00698AC0 /* CommandObjectArgs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 499F381F11A5B3F300F5CE02 /* CommandObjectArgs.cpp */; };
|
||||
2689001413353DDE00698AC0 /* CommandObjectBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */; };
|
||||
2689001513353DDE00698AC0 /* CommandObjectBreakpointCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A42976211861AA600FE05CD /* CommandObjectBreakpointCommand.cpp */; };
|
||||
2689001613353DDE00698AC0 /* CommandObjectCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */; };
|
||||
|
@ -2510,8 +2509,6 @@
|
|||
4987FB1C1F30EC6000E5C17D /* SBProcessInfo.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBProcessInfo.i; sourceTree = "<group>"; };
|
||||
4987FB1E1F30EC7E00E5C17D /* SBProcessInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBProcessInfo.cpp; path = source/API/SBProcessInfo.cpp; sourceTree = "<group>"; };
|
||||
4987FB201F30EC9900E5C17D /* SBProcessInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBProcessInfo.h; path = include/lldb/API/SBProcessInfo.h; sourceTree = "<group>"; };
|
||||
499F381E11A5B3F300F5CE02 /* CommandObjectArgs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectArgs.h; path = source/Commands/CommandObjectArgs.h; sourceTree = "<group>"; };
|
||||
499F381F11A5B3F300F5CE02 /* CommandObjectArgs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectArgs.cpp; path = source/Commands/CommandObjectArgs.cpp; sourceTree = "<group>"; };
|
||||
49A1CAC11430E21D00306AC9 /* ExpressionSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExpressionSourceCode.h; path = include/lldb/Expression/ExpressionSourceCode.h; sourceTree = "<group>"; };
|
||||
49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExpressionSourceCode.cpp; path = source/Expression/ExpressionSourceCode.cpp; sourceTree = "<group>"; };
|
||||
49A8A39F11D568A300AD3B68 /* ASTResultSynthesizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTResultSynthesizer.cpp; path = ExpressionParser/Clang/ASTResultSynthesizer.cpp; sourceTree = "<group>"; };
|
||||
|
@ -5170,8 +5167,6 @@
|
|||
children = (
|
||||
4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */,
|
||||
4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */,
|
||||
499F381E11A5B3F300F5CE02 /* CommandObjectArgs.h */,
|
||||
499F381F11A5B3F300F5CE02 /* CommandObjectArgs.cpp */,
|
||||
26BC7D1410F1B76300F91463 /* CommandObjectBreakpoint.h */,
|
||||
26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */,
|
||||
9A42976111861A9F00FE05CD /* CommandObjectBreakpointCommand.h */,
|
||||
|
@ -7529,7 +7524,6 @@
|
|||
AE44FB4C1BB4BB540033EB62 /* GoFormatterFunctions.cpp in Sources */,
|
||||
8C3BD9961EF45DA50016C343 /* MainThreadCheckerRuntime.cpp in Sources */,
|
||||
23042D121976CA1D00621B2C /* PlatformKalimba.cpp in Sources */,
|
||||
2689001313353DDE00698AC0 /* CommandObjectArgs.cpp in Sources */,
|
||||
2689001413353DDE00698AC0 /* CommandObjectBreakpoint.cpp in Sources */,
|
||||
2689001513353DDE00698AC0 /* CommandObjectBreakpointCommand.cpp in Sources */,
|
||||
2689001613353DDE00698AC0 /* CommandObjectCommands.cpp in Sources */,
|
||||
|
|
|
@ -1,234 +0,0 @@
|
|||
//===-- CommandObjectArgs.cpp -----------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "CommandObjectArgs.h"
|
||||
#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h"
|
||||
#include "lldb/Core/Debugger.h"
|
||||
#include "lldb/Core/Module.h"
|
||||
#include "lldb/Core/Value.h"
|
||||
#include "lldb/Host/Host.h"
|
||||
#include "lldb/Host/OptionParser.h"
|
||||
#include "lldb/Interpreter/Args.h"
|
||||
#include "lldb/Interpreter/CommandInterpreter.h"
|
||||
#include "lldb/Interpreter/CommandReturnObject.h"
|
||||
#include "lldb/Symbol/ClangASTContext.h"
|
||||
#include "lldb/Symbol/ObjectFile.h"
|
||||
#include "lldb/Symbol/Variable.h"
|
||||
#include "lldb/Target/ABI.h"
|
||||
#include "lldb/Target/Process.h"
|
||||
#include "lldb/Target/StackFrame.h"
|
||||
#include "lldb/Target/Target.h"
|
||||
#include "lldb/Target/Thread.h"
|
||||
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
|
||||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
||||
// This command is a toy. I'm just using it to have a way to construct the
|
||||
// arguments to
|
||||
// calling functions.
|
||||
//
|
||||
|
||||
static OptionDefinition g_arg_options[] = {
|
||||
// clang-format off
|
||||
{ LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation." },
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
CommandObjectArgs::CommandOptions::CommandOptions(
|
||||
CommandInterpreter &interpreter)
|
||||
: Options() {
|
||||
// Keep only one place to reset the values to their defaults
|
||||
OptionParsingStarting(nullptr);
|
||||
}
|
||||
|
||||
CommandObjectArgs::CommandOptions::~CommandOptions() = default;
|
||||
|
||||
Status CommandObjectArgs::CommandOptions::SetOptionValue(
|
||||
uint32_t option_idx, llvm::StringRef option_arg,
|
||||
ExecutionContext *execution_context) {
|
||||
Status error;
|
||||
|
||||
const int short_option = m_getopt_table[option_idx].val;
|
||||
error.SetErrorStringWithFormat("invalid short option character '%c'",
|
||||
short_option);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void CommandObjectArgs::CommandOptions::OptionParsingStarting(
|
||||
ExecutionContext *execution_context) {}
|
||||
|
||||
llvm::ArrayRef<OptionDefinition>
|
||||
CommandObjectArgs::CommandOptions::GetDefinitions() {
|
||||
return llvm::makeArrayRef(g_arg_options);
|
||||
}
|
||||
|
||||
CommandObjectArgs::CommandObjectArgs(CommandInterpreter &interpreter)
|
||||
: CommandObjectParsed(interpreter, "args",
|
||||
"When stopped at the start of a function, reads "
|
||||
"function arguments of type (u?)int(8|16|32|64)_t, "
|
||||
"(void|char)*",
|
||||
"args"),
|
||||
m_options(interpreter) {}
|
||||
|
||||
CommandObjectArgs::~CommandObjectArgs() = default;
|
||||
|
||||
Options *CommandObjectArgs::GetOptions() { return &m_options; }
|
||||
|
||||
bool CommandObjectArgs::DoExecute(Args &args, CommandReturnObject &result) {
|
||||
ConstString target_triple;
|
||||
|
||||
Process *process = m_exe_ctx.GetProcessPtr();
|
||||
if (!process) {
|
||||
result.AppendError("Args found no process.");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
const ABI *abi = process->GetABI().get();
|
||||
if (!abi) {
|
||||
result.AppendError("The current process has no ABI.");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.empty()) {
|
||||
result.AppendError("args requires at least one argument");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
Thread *thread = m_exe_ctx.GetThreadPtr();
|
||||
|
||||
if (!thread) {
|
||||
result.AppendError("args found no thread.");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
lldb::StackFrameSP thread_cur_frame = thread->GetSelectedFrame();
|
||||
if (!thread_cur_frame) {
|
||||
result.AppendError("The current thread has no current frame.");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
ModuleSP thread_module_sp(
|
||||
thread_cur_frame->GetFrameCodeAddress().GetModule());
|
||||
if (!thread_module_sp) {
|
||||
result.AppendError("The PC has no associated module.");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
TypeSystem *type_system =
|
||||
thread_module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
|
||||
if (type_system == nullptr) {
|
||||
result.AppendError("Unable to create C type system.");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
ValueList value_list;
|
||||
|
||||
for (auto &arg_entry : args.entries()) {
|
||||
llvm::StringRef arg_type = arg_entry.ref;
|
||||
Value value;
|
||||
value.SetValueType(Value::eValueTypeScalar);
|
||||
CompilerType compiler_type;
|
||||
|
||||
std::size_t int_pos = arg_type.find("int");
|
||||
if (int_pos != llvm::StringRef::npos) {
|
||||
Encoding encoding = eEncodingSint;
|
||||
|
||||
int width = 0;
|
||||
|
||||
if (int_pos > 1) {
|
||||
result.AppendErrorWithFormat("Invalid format: %s.\n",
|
||||
arg_entry.c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
if (int_pos == 1 && arg_type[0] != 'u') {
|
||||
result.AppendErrorWithFormat("Invalid format: %s.\n",
|
||||
arg_entry.c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
if (arg_type[0] == 'u') {
|
||||
encoding = eEncodingUint;
|
||||
}
|
||||
|
||||
llvm::StringRef width_spec = arg_type.drop_front(int_pos + 3);
|
||||
|
||||
auto exp_result = llvm::StringSwitch<llvm::Optional<int>>(width_spec)
|
||||
.Case("8_t", 8)
|
||||
.Case("16_t", 16)
|
||||
.Case("32_t", 32)
|
||||
.Case("64_t", 64)
|
||||
.Default(llvm::None);
|
||||
if (!exp_result.hasValue()) {
|
||||
result.AppendErrorWithFormat("Invalid format: %s.\n",
|
||||
arg_entry.c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
width = *exp_result;
|
||||
|
||||
compiler_type =
|
||||
type_system->GetBuiltinTypeForEncodingAndBitSize(encoding, width);
|
||||
|
||||
if (!compiler_type.IsValid()) {
|
||||
result.AppendErrorWithFormat(
|
||||
"Couldn't get Clang type for format %s (%s integer, width %d).\n",
|
||||
arg_entry.c_str(),
|
||||
(encoding == eEncodingSint ? "signed" : "unsigned"), width);
|
||||
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
} else if (arg_type == "void*") {
|
||||
compiler_type =
|
||||
type_system->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType();
|
||||
} else if (arg_type == "char*") {
|
||||
compiler_type =
|
||||
type_system->GetBasicTypeFromAST(eBasicTypeChar).GetPointerType();
|
||||
} else {
|
||||
result.AppendErrorWithFormat("Invalid format: %s.\n", arg_entry.c_str());
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
value.SetCompilerType(compiler_type);
|
||||
value_list.PushValue(value);
|
||||
}
|
||||
|
||||
if (!abi->GetArgumentValues(*thread, value_list)) {
|
||||
result.AppendError("Couldn't get argument values");
|
||||
result.SetStatus(eReturnStatusFailed);
|
||||
return false;
|
||||
}
|
||||
|
||||
result.GetOutputStream().Printf("Arguments : \n");
|
||||
|
||||
for (auto entry : llvm::enumerate(args.entries())) {
|
||||
result.GetOutputStream().Printf(
|
||||
"%" PRIu64 " (%s): ", (uint64_t)entry.index(), entry.value().c_str());
|
||||
value_list.GetValueAtIndex(entry.index())->Dump(&result.GetOutputStream());
|
||||
result.GetOutputStream().Printf("\n");
|
||||
}
|
||||
|
||||
return result.Succeeded();
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
//===-- CommandObjectArgs.h -------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef liblldb_CommandObjectArgs_h_
|
||||
#define liblldb_CommandObjectArgs_h_
|
||||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/Interpreter/CommandObject.h"
|
||||
#include "lldb/Interpreter/Options.h"
|
||||
|
||||
namespace lldb_private {
|
||||
|
||||
class CommandObjectArgs : public CommandObjectParsed {
|
||||
public:
|
||||
class CommandOptions : public Options {
|
||||
public:
|
||||
CommandOptions(CommandInterpreter &interpreter);
|
||||
|
||||
~CommandOptions() override;
|
||||
|
||||
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
|
||||
ExecutionContext *execution_context) override;
|
||||
|
||||
void OptionParsingStarting(ExecutionContext *execution_context) override;
|
||||
|
||||
llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
|
||||
};
|
||||
|
||||
CommandObjectArgs(CommandInterpreter &interpreter);
|
||||
|
||||
~CommandObjectArgs() override;
|
||||
|
||||
Options *GetOptions() override;
|
||||
|
||||
protected:
|
||||
CommandOptions m_options;
|
||||
|
||||
bool DoExecute(Args &command, CommandReturnObject &result) override;
|
||||
};
|
||||
|
||||
} // namespace lldb_private
|
||||
|
||||
#endif // liblldb_CommandObjectArgs_h_
|
|
@ -15,7 +15,6 @@
|
|||
#include "lldb/Interpreter/CommandObjectRegexCommand.h"
|
||||
|
||||
#include "../Commands/CommandObjectApropos.h"
|
||||
#include "../Commands/CommandObjectArgs.h"
|
||||
#include "../Commands/CommandObjectBreakpoint.h"
|
||||
#include "../Commands/CommandObjectBugreport.h"
|
||||
#include "../Commands/CommandObjectCommands.h"
|
||||
|
|
Loading…
Reference in New Issue