22#define LLDB_OPTIONS_memory_tag_read
23#include "CommandOptions.inc"
29 "Read memory tags for the given range of memory."
30 " Mismatched tags will be marked.",
32 eCommandRequiresTarget | eCommandRequiresProcess |
33 eCommandProcessMustBePaused) {
48 "wrong number of arguments; expected at least <address-expression>, "
49 "at most <address-expression> <end-address-expression>");
63 addr_t end_addr = start_addr + 1;
76 llvm::Expected<const MemoryTagManager *> tag_manager_or_err =
79 if (!tag_manager_or_err) {
97 start_addr = abi->FixDataAddress(start_addr);
98 end_addr = abi->FixDataAddress(end_addr);
101 llvm::Expected<MemoryTagManager::TagRange> tagged_range =
109 llvm::Expected<std::vector<lldb::addr_t>> tags = process->
ReadMemoryTags(
110 tagged_range->GetRangeBase(), tagged_range->GetByteSize());
120 addr_t addr = tagged_range->GetRangeBase();
121 for (
auto tag : *tags) {
126 logical_tag == tag ?
"" :
" (mismatch)");
134#define LLDB_OPTIONS_memory_tag_write
135#include "CommandOptions.inc"
146 return llvm::ArrayRef(g_memory_tag_write_options);
152 const int short_option =
153 g_memory_tag_write_options[option_idx].short_option;
155 switch (short_option) {
161 llvm_unreachable(
"Unimplemented option");
176 "Write memory tags starting from the granule that "
177 "contains the given address.",
179 eCommandRequiresTarget | eCommandRequiresProcess |
180 eCommandProcessMustBePaused) {
199 result.
AppendError(
"wrong number of arguments; expected "
200 "<address-expression> <tag> [<tag> [...]]");
215 std::vector<lldb::addr_t> tags;
216 for (
auto &entry : command) {
219 if (entry.ref().getAsInteger(0, tag_value)) {
221 "'%s' is not a valid unsigned decimal string value.\n",
225 tags.push_back(tag_value);
229 llvm::Expected<const MemoryTagManager *> tag_manager_or_err =
232 if (!tag_manager_or_err) {
248 start_addr = abi->FixDataAddress(start_addr);
271 aligned_start_addr + (tags.size() * tag_manager->
GetGranuleSize());
275 end_addr = abi->FixDataAddress(end_addr);
280 llvm::Expected<MemoryTagManager::TagRange> tagged_range =
290 tagged_range->GetByteSize(), tags);
306 interpreter,
"tag",
"Commands for manipulating memory tags",
307 "memory tag <sub-command> [<sub-command-options>]") {
310 read_command_object->SetCommandName(
"memory tag read");
315 write_command_object->SetCommandName(
"memory tag write");
static llvm::raw_ostream & error(Stream &strm)
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectMemoryTagRead() override=default
CommandObjectMemoryTagRead(CommandInterpreter &interpreter)
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
OptionGroupTagWrite()=default
void OptionParsingStarting(ExecutionContext *execution_context) override
~OptionGroupTagWrite() override=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
OptionGroupOptions m_option_group
~CommandObjectMemoryTagWrite() override=default
Options * GetOptions() override
CommandObjectMemoryTagWrite(CommandInterpreter &interpreter)
OptionGroupTagWrite m_tag_write_options
void DoExecute(Args &command, CommandReturnObject &result) override
A command line argument class.
void Shift()
Shifts the first argument C string value of the array off the argument array.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
CommandObjectMemoryTag(CommandInterpreter &interpreter)
~CommandObjectMemoryTag() override
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
std::vector< CommandArgumentData > CommandArgumentEntry
ExecutionContext m_exe_ctx
std::vector< CommandArgumentEntry > m_arguments
void AppendErrorWithFormatv(const char *format, Args &&... args)
void AppendMessage(llvm::StringRef in_string)
void void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
void void AppendMessageWithFormatv(const char *format, Args &&... args)
void SetError(Status error)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Process * GetProcessPtr() const
Returns a pointer to the process object.
virtual TagRange ExpandToGranule(TagRange range) const =0
virtual llvm::Expected< TagRange > MakeTaggedRange(lldb::addr_t addr, lldb::addr_t end_addr, const lldb_private::MemoryRegionInfos &memory_regions) const =0
virtual lldb::addr_t GetGranuleSize() const =0
virtual lldb::addr_t GetLogicalTag(lldb::addr_t addr) const =0
void Append(OptionGroup *group)
Append options from a OptionGroup class.
A command line option parsing protocol class.
A plug-in interface definition class for debugging a process.
llvm::Expected< const MemoryTagManager * > GetMemoryTagManager()
If this architecture and process supports memory tagging, return a tag manager that can be used to ma...
virtual llvm::Expected< std::vector< lldb::addr_t > > ReadMemoryTags(lldb::addr_t addr, size_t len)
Read memory tags for the range addr to addr+len.
virtual Status GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list)
Obtain all the mapped memory regions within this process.
Status WriteMemoryTags(lldb::addr_t addr, size_t len, const std::vector< lldb::addr_t > &tags)
Write memory tags for a range of memory.
const lldb::ABISP & GetABI()
bool Fail() const
Test for error condition.
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
@ eReturnStatusSuccessFinishResult
@ eArgTypeAddressOrExpression
Used to build individual command argument lists.
static lldb::addr_t ToRawAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, lldb::addr_t fail_value, Status *error_ptr)
As for ToAddress but do not remove non-address bits from the result.
BaseType GetRangeBase() const