//
//===----------------------------------------------------------------------===//
-#include "CommandObjectDisassemble.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectDisassemble.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
OptionParsingStarting();
}
-CommandObjectDisassemble::CommandOptions::~CommandOptions ()
-{
-}
+CommandObjectDisassemble::CommandOptions::~CommandOptions() = default;
Error
CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
some_location_specified = true;
}
break;
+
case 'n':
func_name.assign (option_arg);
some_location_specified = true;
error.SetErrorStringWithFormat("Disassembler flavors are currently only supported for x86 and x86_64 targets.");
break;
}
+
case 'r':
raw = true;
break;
if (!some_location_specified)
current_function = true;
return Error();
-
}
const OptionDefinition*
OptionDefinition
CommandObjectDisassemble::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, false, "bytes" , 'b', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Show opcode bytes when disassembling."},
-{ LLDB_OPT_SET_ALL, false, "context" , 'C', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeNumLines, "Number of context lines of source to show."},
-{ LLDB_OPT_SET_ALL, false, "mixed" , 'm', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Enable mixed source and assembly display."},
-{ LLDB_OPT_SET_ALL, false, "raw" , 'r', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Print raw disassembly with no symbol information."},
-{ LLDB_OPT_SET_ALL, false, "plugin" , 'P', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypePlugin, "Name of the disassembler plugin you want to use."},
-{ LLDB_OPT_SET_ALL, false, "flavor" , 'F', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeDisassemblyFlavor, "Name of the disassembly flavor you want to use. "
+{ LLDB_OPT_SET_ALL, false, "bytes" , 'b', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Show opcode bytes when disassembling."},
+{ LLDB_OPT_SET_ALL, false, "context" , 'C', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeNumLines, "Number of context lines of source to show."},
+{ LLDB_OPT_SET_ALL, false, "mixed" , 'm', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Enable mixed source and assembly display."},
+{ LLDB_OPT_SET_ALL, false, "raw" , 'r', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Print raw disassembly with no symbol information."},
+{ LLDB_OPT_SET_ALL, false, "plugin" , 'P', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypePlugin, "Name of the disassembler plugin you want to use."},
+{ LLDB_OPT_SET_ALL, false, "flavor" , 'F', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeDisassemblyFlavor, "Name of the disassembly flavor you want to use. "
"Currently the only valid options are default, and for Intel"
" architectures, att and intel."},
-{ LLDB_OPT_SET_ALL, false, "arch" , 'A', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeArchitecture,"Specify the architecture to use from cross disassembly."},
+{ LLDB_OPT_SET_ALL, false, "arch" , 'A', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeArchitecture,"Specify the architecture to use from cross disassembly."},
{ LLDB_OPT_SET_1 |
- LLDB_OPT_SET_2 , true , "start-address", 's', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeAddressOrExpression,"Address at which to start disassembling."},
-{ LLDB_OPT_SET_1 , false, "end-address" , 'e', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeAddressOrExpression, "Address at which to end disassembling."},
+ LLDB_OPT_SET_2 , true , "start-address", 's', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeAddressOrExpression,"Address at which to start disassembling."},
+{ LLDB_OPT_SET_1 , false, "end-address" , 'e', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Address at which to end disassembling."},
{ LLDB_OPT_SET_2 |
LLDB_OPT_SET_3 |
LLDB_OPT_SET_4 |
- LLDB_OPT_SET_5 , false, "count" , 'c', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeNumLines, "Number of instructions to display."},
-{ LLDB_OPT_SET_3 , false, "name" , 'n', OptionParser::eRequiredArgument , NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
+ LLDB_OPT_SET_5 , false, "count" , 'c', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeNumLines, "Number of instructions to display."},
+{ LLDB_OPT_SET_3 , false, "name" , 'n', OptionParser::eRequiredArgument , nullptr, nullptr, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
"Disassemble entire contents of the given function name."},
-{ LLDB_OPT_SET_4 , false, "frame" , 'f', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Disassemble from the start of the current frame's function."},
-{ LLDB_OPT_SET_5 , false, "pc" , 'p', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Disassemble around the current pc."},
-{ LLDB_OPT_SET_6 , false, "line" , 'l', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "Disassemble the current frame's current source line instructions if there is debug line table information, else disassemble around the pc."},
-{ LLDB_OPT_SET_7 , false, "address" , 'a', OptionParser::eRequiredArgument , NULL, NULL, 0, eArgTypeAddressOrExpression, "Disassemble function containing this address."},
-{ 0 , false, NULL , 0, 0 , NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_4 , false, "frame" , 'f', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Disassemble from the start of the current frame's function."},
+{ LLDB_OPT_SET_5 , false, "pc" , 'p', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Disassemble around the current pc."},
+{ LLDB_OPT_SET_6 , false, "line" , 'l', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone, "Disassemble the current frame's current source line instructions if there is debug line table information, else disassemble around the pc."},
+{ LLDB_OPT_SET_7 , false, "address" , 'a', OptionParser::eRequiredArgument , nullptr, nullptr, 0, eArgTypeAddressOrExpression, "Disassemble function containing this address."},
+{ 0 , false, nullptr , 0, 0 , nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
-
-
//-------------------------------------------------------------------------
// CommandObjectDisassemble
//-------------------------------------------------------------------------
{
}
-CommandObjectDisassemble::~CommandObjectDisassemble()
-{
-}
+CommandObjectDisassemble::~CommandObjectDisassemble() = default;
bool
CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result)
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
- if (target == NULL)
+ if (target == nullptr)
{
result.AppendError ("invalid target, create a debug target using the 'target create' command");
result.SetStatus (eReturnStatusFailed);
result.SetStatus (eReturnStatusFailed);
return false;
}
- else if (flavor_string != NULL && !disassembler->FlavorValidForArchSpec(m_options.arch, flavor_string))
+ else if (flavor_string != nullptr && !disassembler->FlavorValidForArchSpec(m_options.arch, flavor_string))
result.AppendWarningWithFormat("invalid disassembler flavor \"%s\", using default.\n", flavor_string);
result.SetStatus (eReturnStatusSuccessFinishResult);
{
ConstString name(m_options.func_name.c_str());
- if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
- m_options.arch,
- plugin_name,
- flavor_string,
- m_exe_ctx,
- name,
- NULL, // Module *
- m_options.num_instructions,
- m_options.show_mixed ? m_options.num_lines_context : 0,
- options,
- result.GetOutputStream()))
+ if (Disassembler::Disassemble(m_interpreter.GetDebugger(),
+ m_options.arch,
+ plugin_name,
+ flavor_string,
+ m_exe_ctx,
+ name,
+ nullptr, // Module *
+ m_options.num_instructions,
+ m_options.show_mixed ? m_options.num_lines_context : 0,
+ options,
+ result.GetOutputStream()))
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
StackFrame *frame = m_exe_ctx.GetFramePtr();
if (m_options.frame_line)
{
- if (frame == NULL)
+ if (frame == nullptr)
{
result.AppendError ("Cannot disassemble around the current line without a selected frame.\n");
result.SetStatus (eReturnStatusFailed);
}
else if (m_options.current_function)
{
- if (frame == NULL)
+ if (frame == nullptr)
{
result.AppendError ("Cannot disassemble around the current function without a selected frame.\n");
result.SetStatus (eReturnStatusFailed);
{
if (m_options.at_pc)
{
- if (frame == NULL)
+ if (frame == nullptr)
{
result.AppendError ("Cannot disassemble around the current PC without a selected frame.\n");
result.SetStatus (eReturnStatusFailed);
}
}
}
-
}
}
}
if (m_options.num_instructions != 0)
{
- if (ranges.size() == 0)
+ if (ranges.empty())
{
// The default action is to disassemble the current frame function.
if (frame)
}
else
{
- if (ranges.size() == 0)
+ if (ranges.empty())
{
// The default action is to disassemble the current frame function.
if (frame)
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter);
~CommandOptions() override;
const char *
GetPluginName ()
{
- if (plugin_name.empty())
- return NULL;
- return plugin_name.c_str();
+ return (plugin_name.empty() ? nullptr : plugin_name.c_str());
}
const char *
GetFlavorString ()
{
if (flavor_string.empty() || flavor_string == "default")
- return NULL;
+ return nullptr;
return flavor_string.c_str();
}
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectHelp.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectHelp.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/Options.h"
m_arguments.push_back (arg);
}
-CommandObjectHelp::~CommandObjectHelp()
-{
-}
+CommandObjectHelp::~CommandObjectHelp() = default;
OptionDefinition
CommandObjectHelp::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Hide aliases in the command list."},
- { LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Hide user-defined commands from the list."},
- { LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Include commands prefixed with an underscore."},
- { 0, false, NULL, 0, 0, 0, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Hide aliases in the command list."},
+ { LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Hide user-defined commands from the list."},
+ { LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Include commands prefixed with an underscore."},
+ { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
bool
bool is_alias_command = m_interpreter.AliasExists (command.GetArgumentAtIndex (0));
std::string alias_name = command.GetArgumentAtIndex(0);
- if (cmd_obj != NULL)
+ if (cmd_obj != nullptr)
{
StringList matches;
bool all_okay = true;
{
CommandObject *found_cmd;
found_cmd = sub_cmd_obj->GetSubcommandObject(sub_command.c_str(), &matches);
- if (found_cmd == NULL)
+ if (found_cmd == nullptr)
all_okay = false;
else if (matches.GetSize() > 1)
all_okay = false;
}
}
- if (!all_okay || (sub_cmd_obj == NULL))
+ if (!all_okay || (sub_cmd_obj == nullptr))
{
std::string cmd_string;
command.GetCommandString (cmd_string);
}
int
-CommandObjectHelp::HandleCompletion
-(
- Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches
-)
+CommandObjectHelp::HandleCompletion(Args &input,
+ int &cursor_index,
+ int &cursor_char_position,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches)
{
// Return the completions of the commands in the help system:
if (cursor_index == 0)
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectLog.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectLog.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Timer.h"
-
#include "lldb/Core/Debugger.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
-
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
-
class CommandObjectLogEnable : public CommandObjectParsed
{
public:
// Constructors and Destructors
//------------------------------------------------------------------
CommandObjectLogEnable(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "log enable",
- "Enable logging for a single log channel.",
- NULL),
+ CommandObjectParsed(interpreter,
+ "log enable",
+ "Enable logging for a single log channel.",
+ nullptr),
m_options (interpreter)
{
-
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
CommandArgumentData channel_arg;
m_arguments.push_back (arg2);
}
- ~CommandObjectLogEnable() override
- {
- }
+ ~CommandObjectLogEnable() override = default;
Options *
GetOptions () override
class CommandOptions : public Options
{
public:
-
CommandOptions (CommandInterpreter &interpreter) :
Options (interpreter),
log_file (),
{
}
-
- ~CommandOptions () override
- {
- }
+ ~CommandOptions () override = default;
Error
SetOptionValue (uint32_t option_idx, const char *option_arg) override
OptionDefinition
CommandObjectLogEnable::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFilename, "Set the destination file to log to."},
-{ LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." },
-{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable verbose logging." },
-{ LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable debug logging." },
-{ LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." },
-{ LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with a timestamp." },
-{ LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." },
-{ LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." },
-{ LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Append a stack backtrace to each log line." },
-{ LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Append to the log file instead of overwriting." },
-{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Set the destination file to log to."},
+{ LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." },
+{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable verbose logging." },
+{ LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable debug logging." },
+{ LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." },
+{ LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with a timestamp." },
+{ LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." },
+{ LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." },
+{ LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append a stack backtrace to each log line." },
+{ LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append to the log file instead of overwriting." },
+{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
};
class CommandObjectLogDisable : public CommandObjectParsed
// Constructors and Destructors
//------------------------------------------------------------------
CommandObjectLogDisable(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "log disable",
- "Disable one or more log channel categories.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "log disable",
+ "Disable one or more log channel categories.",
+ nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
m_arguments.push_back (arg2);
}
- ~CommandObjectLogDisable() override
- {
- }
+ ~CommandObjectLogDisable() override = default;
protected:
bool
// Constructors and Destructors
//------------------------------------------------------------------
CommandObjectLogList(CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "log list",
- "List the log categories for one or more log channels. If none specified, lists them all.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "log list",
+ "List the log categories for one or more log channels. If none specified, lists them all.",
+ nullptr)
{
CommandArgumentEntry arg;
CommandArgumentData channel_arg;
m_arguments.push_back (arg);
}
- ~CommandObjectLogList() override
- {
- }
+ ~CommandObjectLogList() override = default;
protected:
bool
{
}
- ~CommandObjectLogTimer() override
- {
- }
+ ~CommandObjectLogTimer() override = default;
protected:
bool
Timer::ResetCategoryTimes ();
result.SetStatus(eReturnStatusSuccessFinishResult);
}
-
}
else if (argc == 2)
{
}
};
-//----------------------------------------------------------------------
-// CommandObjectLog constructor
-//----------------------------------------------------------------------
CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) :
CommandObjectMultiword (interpreter,
"log",
LoadSubCommand ("timers", CommandObjectSP (new CommandObjectLogTimer (interpreter)));
}
-//----------------------------------------------------------------------
-// Destructor
-//----------------------------------------------------------------------
-CommandObjectLog::~CommandObjectLog()
-{
-}
-
-
-
-
+CommandObjectLog::~CommandObjectLog() = default;
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectMemory.h"
-
// C Includes
#include <inttypes.h>
#include "clang/AST/Decl.h"
// Project includes
+#include "CommandObjectMemory.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Debugger.h"
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "num-per-line" ,'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."},
- { LLDB_OPT_SET_2, false, "binary" ,'b', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."},
- { LLDB_OPT_SET_3, true , "type" ,'t', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."},
- { LLDB_OPT_SET_3, false , "offset" ,'E', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount ,"How many elements of the specified type to skip before starting to display data."},
+ { LLDB_OPT_SET_1, false, "num-per-line" ,'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNumberPerLine ,"The number of items per line to display."},
+ { LLDB_OPT_SET_2, false, "binary" ,'b', OptionParser::eNoArgument , nullptr, nullptr, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."},
+ { LLDB_OPT_SET_3, true , "type" ,'t', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeNone ,"The name of a type to view memory as."},
+ { LLDB_OPT_SET_3, false , "offset" ,'E', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount ,"How many elements of the specified type to skip before starting to display data."},
{ LLDB_OPT_SET_1|
LLDB_OPT_SET_2|
- LLDB_OPT_SET_3, false, "force" ,'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone ,"Necessary if reading over target.max-memory-read-size bytes."},
+ LLDB_OPT_SET_3, false, "force" ,'r', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone ,"Necessary if reading over target.max-memory-read-size bytes."},
};
-
-
class OptionGroupReadMemory : public OptionGroup
{
public:
-
OptionGroupReadMemory () :
m_num_per_line (1,1),
m_output_as_binary (false),
{
}
- ~OptionGroupReadMemory () override
- {
- }
-
-
+ ~OptionGroupReadMemory() override = default;
+
uint32_t
GetNumDefinitions () override
{
if (!count_option_set)
format_options.GetCountValue() = 32;
break;
+
case eFormatCharArray:
case eFormatChar:
case eFormatCharPrintable:
if (!count_option_set)
format_options.GetCountValue() = 64;
break;
+
case eFormatComplex:
if (!byte_size_option_set)
byte_size_value = 8;
if (!count_option_set)
format_options.GetCountValue() = 8;
break;
+
case eFormatComplexInteger:
if (!byte_size_option_set)
byte_size_value = 8;
if (!count_option_set)
format_options.GetCountValue() = 8;
break;
+
case eFormatHex:
if (!byte_size_option_set)
byte_size_value = 4;
OptionValueUInt64 m_offset;
};
-
-
//----------------------------------------------------------------------
// Read memory from the inferior process
//----------------------------------------------------------------------
class CommandObjectMemoryRead : public CommandObjectParsed
{
public:
-
CommandObjectMemoryRead (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "memory read",
- "Read from the memory of the process being debugged.",
- NULL,
- eCommandRequiresTarget | eCommandProcessMustBePaused),
+ CommandObjectParsed(interpreter,
+ "memory read",
+ "Read from the memory of the process being debugged.",
+ nullptr,
+ eCommandRequiresTarget | eCommandProcessMustBePaused),
m_option_group (interpreter),
m_format_options (eFormatBytesWithASCII, 1, 8),
m_memory_options (),
m_option_group.Finalize();
}
- ~CommandObjectMemoryRead () override
- {
- }
+ ~CommandObjectMemoryRead() override = default;
Options *
GetOptions () override
}
}
- if (clang_ast_type.IsValid() == false)
+ if (!clang_ast_type.IsValid())
{
if (type_list.GetSize() == 0)
{
if (argc == 2)
{
- lldb::addr_t end_addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(1), LLDB_INVALID_ADDRESS, 0);
+ lldb::addr_t end_addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(1),
+ LLDB_INVALID_ADDRESS, nullptr);
if (end_addr == LLDB_INVALID_ADDRESS)
{
result.AppendError("invalid end address expression.");
if (clang_ast_type.GetOpaqueQualType())
{
// Make sure we don't display our type as ASCII bytes like the default memory read
- if (m_format_options.GetFormatValue().OptionWasSet() == false)
+ if (!m_format_options.GetFormatValue().OptionWasSet())
m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
bytes_read = clang_ast_type.GetByteSize(nullptr) * m_format_options.GetCountValue().GetCurrentValue();
else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString)
{
data_sp.reset (new DataBufferHeap (total_byte_size, '\0'));
- if (data_sp->GetBytes() == NULL)
+ if (data_sp->GetBytes() == nullptr)
{
result.AppendErrorWithFormat ("can't allocate 0x%" PRIx32 " bytes for the memory read buffer, specify a smaller size to read", (uint32_t)total_byte_size);
result.SetStatus(eReturnStatusFailed);
return false;
}
- Address address(addr, NULL);
+ Address address(addr, nullptr);
bytes_read = target->ReadMemory(address, false, data_sp->GetBytes (), data_sp->GetByteSize(), error);
if (bytes_read == 0)
{
if (!m_format_options.GetCountValue().OptionWasSet())
item_count = 1;
data_sp.reset (new DataBufferHeap ((item_byte_size+1) * item_count, '\0')); // account for NULLs as necessary
- if (data_sp->GetBytes() == NULL)
+ if (data_sp->GetBytes() == nullptr)
{
result.AppendErrorWithFormat ("can't allocate 0x%" PRIx64 " bytes for the memory read buffer, specify a smaller size to read", (uint64_t)((item_byte_size+1) * item_count));
result.SetStatus(eReturnStatusFailed);
m_prev_clang_ast_type = clang_ast_type;
StreamFile outfile_stream;
- Stream *output_stream = NULL;
+ Stream *output_stream = nullptr;
const FileSpec &outfile_spec = m_outfile_options.GetFile().GetCurrentValue();
if (outfile_spec)
{
output_stream = &result.GetOutputStream();
}
-
ExecutionContextScope *exe_scope = m_exe_ctx.GetBestExecutionContextScope();
if (clang_ast_type.GetOpaqueQualType())
{
&& (item_byte_size != 1))
{
// if a count was not passed, or it is 1
- if (m_format_options.GetCountValue().OptionWasSet() == false || item_count == 1)
+ if (!m_format_options.GetCountValue().OptionWasSet() || item_count == 1)
{
// this turns requests such as
// memory read -fc -s10 -c1 *charPtrPtr
OptionDefinition
g_memory_find_option_table[] =
{
- { LLDB_OPT_SET_1, false, "expression", 'e', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeExpression, "Evaluate an expression to obtain a byte pattern."},
- { LLDB_OPT_SET_2, false, "string", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeName, "Use text to find a byte pattern."},
- { LLDB_OPT_SET_1|LLDB_OPT_SET_2, false, "count", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount, "How many times to perform the search."},
- { LLDB_OPT_SET_1|LLDB_OPT_SET_2, false, "dump-offset", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, "When dumping memory for a match, an offset from the match location to start dumping from."},
+ { LLDB_OPT_SET_1, false, "expression", 'e', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeExpression, "Evaluate an expression to obtain a byte pattern."},
+ { LLDB_OPT_SET_2, false, "string", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName, "Use text to find a byte pattern."},
+ { LLDB_OPT_SET_1|LLDB_OPT_SET_2, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount, "How many times to perform the search."},
+ { LLDB_OPT_SET_1|LLDB_OPT_SET_2, false, "dump-offset", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset, "When dumping memory for a match, an offset from the match location to start dumping from."},
};
//----------------------------------------------------------------------
class CommandObjectMemoryFind : public CommandObjectParsed
{
public:
-
class OptionGroupFindMemory : public OptionGroup
{
public:
m_offset(0)
{
}
-
- ~OptionGroupFindMemory () override
- {
- }
-
+
+ ~OptionGroupFindMemory() override = default;
+
uint32_t
GetNumDefinitions () override
{
};
CommandObjectMemoryFind (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "memory find",
- "Find a value in the memory of the process being debugged.",
- NULL,
- eCommandRequiresProcess | eCommandProcessMustBeLaunched),
+ CommandObjectParsed(interpreter,
+ "memory find",
+ "Find a value in the memory of the process being debugged.",
+ nullptr,
+ eCommandRequiresProcess | eCommandProcessMustBeLaunched),
m_option_group (interpreter),
m_memory_options ()
{
m_option_group.Append (&m_memory_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_2);
m_option_group.Finalize();
}
-
- ~CommandObjectMemoryFind () override
- {
- }
-
+
+ ~CommandObjectMemoryFind() override = default;
+
Options *
GetOptions () override
{
StackFrame* frame = m_exe_ctx.GetFramePtr();
ValueObjectSP result_sp;
if ((eExpressionCompleted == process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp)) &&
- result_sp.get())
+ result_sp)
{
uint64_t value = result_sp->GetValueAsUnsigned(0);
switch (result_sp->GetCompilerType().GetByteSize(nullptr))
OptionGroupFindMemory m_memory_options;
};
-
OptionDefinition
g_memory_write_option_table[] =
{
-{ LLDB_OPT_SET_1, true, "infile", 'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFilename, "Write memory using the contents of a file."},
-{ LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, "Start writing bytes from an offset within the input file."},
+{ LLDB_OPT_SET_1, true, "infile", 'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Write memory using the contents of a file."},
+{ LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeOffset, "Start writing bytes from an offset within the input file."},
};
//----------------------------------------------------------------------
class CommandObjectMemoryWrite : public CommandObjectParsed
{
public:
-
class OptionGroupWriteMemory : public OptionGroup
{
public:
{
}
- ~OptionGroupWriteMemory () override
- {
- }
+ ~OptionGroupWriteMemory() override = default;
uint32_t
GetNumDefinitions () override
};
CommandObjectMemoryWrite (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "memory write",
- "Write to the memory of the process being debugged.",
- NULL,
- eCommandRequiresProcess | eCommandProcessMustBeLaunched),
+ CommandObjectParsed(interpreter,
+ "memory write",
+ "Write to the memory of the process being debugged.",
+ nullptr,
+ eCommandRequiresProcess | eCommandProcessMustBeLaunched),
m_option_group (interpreter),
m_format_options (eFormatBytes, 1, UINT64_MAX),
m_memory_options ()
m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_SIZE , LLDB_OPT_SET_1|LLDB_OPT_SET_2);
m_option_group.Append (&m_memory_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_2);
m_option_group.Finalize();
-
}
- ~CommandObjectMemoryWrite () override
- {
- }
+ ~CommandObjectMemoryWrite() override = default;
Options *
GetOptions () override
case eFormatHex:
case eFormatHexUppercase:
case eFormatPointer:
-
// Decode hex bytes
uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 16, &success);
if (!success)
class CommandObjectMemoryHistory : public CommandObjectParsed
{
public:
-
CommandObjectMemoryHistory (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "memory history",
- "Prints out the recorded stack traces for allocation/deallocation of a memory address.",
- NULL,
- eCommandRequiresTarget | eCommandRequiresProcess | eCommandProcessMustBePaused | eCommandProcessMustBeLaunched)
+ CommandObjectParsed(interpreter,
+ "memory history",
+ "Prints out the recorded stack traces for allocation/deallocation of a memory address.",
+ nullptr,
+ eCommandRequiresTarget | eCommandRequiresProcess | eCommandProcessMustBePaused |
+ eCommandProcessMustBeLaunched)
{
CommandArgumentEntry arg1;
CommandArgumentData addr_arg;
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg1);
}
-
- ~CommandObjectMemoryHistory () override
- {
- }
-
+
+ ~CommandObjectMemoryHistory() override = default;
+
const char *
GetRepeatCommand (Args ¤t_command_args, uint32_t index) override
{
const ProcessSP &process_sp = m_exe_ctx.GetProcessSP();
const MemoryHistorySP &memory_history = MemoryHistory::FindPlugin(process_sp);
- if (! memory_history.get())
+ if (!memory_history)
{
result.AppendError("no available memory history provider");
result.SetStatus(eReturnStatusFailed);
return true;
}
-
};
-
//-------------------------------------------------------------------------
// CommandObjectMemory
//-------------------------------------------------------------------------
LoadSubCommand ("history", CommandObjectSP (new CommandObjectMemoryHistory (interpreter)));
}
-CommandObjectMemory::~CommandObjectMemory ()
-{
-}
+CommandObjectMemory::~CommandObjectMemory() = default;
//
//===----------------------------------------------------------------------===//
-#include "lldb/Interpreter/CommandObjectMultiword.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/Options.h"
// CommandObjectMultiword
//-------------------------------------------------------------------------
-CommandObjectMultiword::CommandObjectMultiword
-(
- CommandInterpreter &interpreter,
- const char *name,
- const char *help,
- const char *syntax,
- uint32_t flags
-) :
+CommandObjectMultiword::CommandObjectMultiword(CommandInterpreter &interpreter,
+ const char *name,
+ const char *help,
+ const char *syntax,
+ uint32_t flags) :
CommandObject (interpreter, name, help, syntax, flags),
m_can_be_removed(false)
{
}
-CommandObjectMultiword::~CommandObjectMultiword ()
-{
-}
+CommandObjectMultiword::~CommandObjectMultiword() = default;
CommandObjectSP
CommandObjectMultiword::GetSubcommandSP (const char *sub_cmd, StringList *matches)
}
else
{
-
StringList local_matches;
- if (matches == NULL)
+ if (matches == nullptr)
matches = &local_matches;
int num_matches = CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, sub_cmd, *matches);
}
bool
-CommandObjectMultiword::LoadSubCommand
-(
- const char *name,
- const CommandObjectSP& cmd_obj
-)
+CommandObjectMultiword::LoadSubCommand(const char *name,
+ const CommandObjectSP& cmd_obj)
{
- if (cmd_obj.get())
+ if (cmd_obj)
assert((&GetCommandInterpreter() == &cmd_obj->GetCommandInterpreter()) && "tried to add a CommandObject from a different interpreter");
CommandMap::iterator pos;
{
StringList matches;
CommandObject *sub_cmd_obj = GetSubcommandObject(sub_command, &matches);
- if (sub_cmd_obj != NULL)
+ if (sub_cmd_obj != nullptr)
{
// Now call CommandObject::Execute to process and options in 'rest_of_line'. From there
// the command-specific version of Execute will be called, with the processed arguments.
}
int
-CommandObjectMultiword::HandleCompletion
-(
- Args &input,
- int &cursor_index,
- int &cursor_char_position,
- int match_start_point,
- int max_return_elements,
- bool &word_complete,
- StringList &matches
-)
+CommandObjectMultiword::HandleCompletion(Args &input,
+ int &cursor_index,
+ int &cursor_char_position,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches)
{
// Any of the command matches will provide a complete word, otherwise the individual
// completers will override this.
matches);
if (matches.GetSize() == 1
- && matches.GetStringAtIndex(0) != NULL
+ && matches.GetStringAtIndex(0) != nullptr
&& strcmp (arg0, matches.GetStringAtIndex(0)) == 0)
{
StringList temp_matches;
CommandObject *cmd_obj = GetSubcommandObject (arg0,
&temp_matches);
- if (cmd_obj != NULL)
+ if (cmd_obj != nullptr)
{
if (input.GetArgumentCount() == 1)
{
{
CommandObject *sub_command_object = GetSubcommandObject (arg0,
&matches);
- if (sub_command_object == NULL)
+ if (sub_command_object == nullptr)
{
return matches.GetSize();
}
word_complete,
matches);
}
-
}
}
{
index++;
if (current_command_args.GetArgumentCount() <= index)
- return NULL;
+ return nullptr;
CommandObject *sub_command_object = GetSubcommandObject (current_command_args.GetArgumentAtIndex(index));
- if (sub_command_object == NULL)
- return NULL;
+ if (sub_command_object == nullptr)
+ return nullptr;
return sub_command_object->GetRepeatCommand(current_command_args, index);
}
-
void
CommandObjectMultiword::AproposAllSubCommands (const char *prefix,
const char *search_word,
}
}
-
-
CommandObjectProxy::CommandObjectProxy (CommandInterpreter &interpreter,
const char *name,
const char *help,
{
}
-CommandObjectProxy::~CommandObjectProxy ()
-{
-}
+CommandObjectProxy::~CommandObjectProxy() = default;
const char *
CommandObjectProxy::GetHelpLong ()
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->GetHelpLong();
- return NULL;
+ return nullptr;
}
bool
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->GetSubcommandObject(sub_cmd, matches);
- return NULL;
+ return nullptr;
}
void
return false;
}
-
Options *
CommandObjectProxy::GetOptions ()
{
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->GetOptions ();
- return NULL;
+ return nullptr;
}
-
int
CommandObjectProxy::HandleCompletion (Args &input,
int &cursor_index,
matches.Clear();
return 0;
}
+
int
CommandObjectProxy::HandleArgumentCompletion (Args &input,
int &cursor_index,
CommandObject *proxy_command = GetProxyCommandObject();
if (proxy_command)
return proxy_command->GetRepeatCommand (current_command_args, index);
- return NULL;
+ return nullptr;
}
bool
result.SetStatus (eReturnStatusFailed);
return false;
}
-
-
-//===-- CommandObjectPlugin.cpp ----------------------------------*- C++ -*-===//
+//===-- CommandObjectPlugin.cpp ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
#include "CommandObjectPlugin.h"
-
#include "lldb/Host/Host.h"
-
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
class CommandObjectPluginLoad : public CommandObjectParsed
{
-private:
public:
CommandObjectPluginLoad (CommandInterpreter &interpreter) :
- CommandObjectParsed (interpreter,
- "plugin load",
- "Import a dylib that implements an LLDB plugin.",
- NULL)
+ CommandObjectParsed(interpreter,
+ "plugin load",
+ "Import a dylib that implements an LLDB plugin.",
+ nullptr)
{
CommandArgumentEntry arg1;
CommandArgumentData cmd_arg;
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg1);
}
-
- ~CommandObjectPluginLoad () override
- {
- }
-
+
+ ~CommandObjectPluginLoad() override = default;
+
int
HandleArgumentCompletion (Args &input,
int &cursor_index,
std::string completion_str (input.GetArgumentAtIndex(cursor_index));
completion_str.erase (cursor_char_position);
- CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
- CommandCompletions::eDiskFileCompletion,
- completion_str.c_str(),
- match_start_point,
- max_return_elements,
- NULL,
- word_complete,
- matches);
+ CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter,
+ CommandCompletions::eDiskFileCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ nullptr,
+ word_complete,
+ matches);
return matches.GetSize();
}
LoadSubCommand ("load", CommandObjectSP (new CommandObjectPluginLoad (interpreter)));
}
-CommandObjectPlugin::~CommandObjectPlugin ()
-{
-}
+CommandObjectPlugin::~CommandObjectPlugin() = default;
//
//===----------------------------------------------------------------------===//
-#include "CommandObjectSyntax.h"
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "CommandObjectSyntax.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/Options.h"
-
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
m_arguments.push_back (arg);
}
-CommandObjectSyntax::~CommandObjectSyntax()
-{
-}
-
+CommandObjectSyntax::~CommandObjectSyntax() = default;
bool
CommandObjectSyntax::DoExecute (Args& command, CommandReturnObject &result)
}
}
- if (all_okay && (cmd_obj != NULL))
+ if (all_okay && (cmd_obj != nullptr))
{
Stream &output_strm = result.GetOutputStream();
- if (cmd_obj->GetOptions() != NULL)
+ if (cmd_obj->GetOptions() != nullptr)
{
output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax());
output_strm.Printf ("(Try 'help %s' for more information on command options syntax.)\n",