-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb] Change implementation of memory read --show-tags option
This does 2 things: * Moves it after the short options. Which makes sense given it's a niche, default off option. (if 2 files for one option seems a bit much, I am going to reuse them for "memory find" later) * Fixes the use of repeated commands. For example: memory read buf --show-tags <shows tags> memory read <shows tags> Added tests for the repetition and updated existing help tests. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D125089
- Loading branch information
1 parent
ca302f0
commit 29e556f
Showing
7 changed files
with
143 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//===-- OptionGroupMemoryTag.h ---------------------------------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLDB_INTERPRETER_OPTIONGROUPMEMORYTAG_H | ||
#define LLDB_INTERPRETER_OPTIONGROUPMEMORYTAG_H | ||
|
||
#include "lldb/Interpreter/OptionValueBoolean.h" | ||
#include "lldb/Interpreter/Options.h" | ||
|
||
namespace lldb_private { | ||
|
||
class OptionGroupMemoryTag : public OptionGroup { | ||
public: | ||
OptionGroupMemoryTag(); | ||
|
||
~OptionGroupMemoryTag() override = default; | ||
|
||
llvm::ArrayRef<OptionDefinition> GetDefinitions() override; | ||
|
||
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, | ||
ExecutionContext *execution_context) override; | ||
|
||
void OptionParsingStarting(ExecutionContext *execution_context) override; | ||
|
||
bool AnyOptionWasSet() const { return m_show_tags.OptionWasSet(); } | ||
|
||
OptionValueBoolean GetShowTags() { return m_show_tags; }; | ||
|
||
protected: | ||
OptionValueBoolean m_show_tags; | ||
}; | ||
|
||
} // namespace lldb_private | ||
|
||
#endif // LLDB_INTERPRETER_OPTIONGROUPMEMORYTAG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//===-- OptionGroupMemoryTag.cpp -----------------------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "lldb/Interpreter/OptionGroupMemoryTag.h" | ||
|
||
#include "lldb/Host/OptionParser.h" | ||
|
||
using namespace lldb; | ||
using namespace lldb_private; | ||
|
||
OptionGroupMemoryTag::OptionGroupMemoryTag() : m_show_tags(false, false) {} | ||
|
||
static const uint32_t SHORT_OPTION_SHOW_TAGS = 0x54414753; // 'tags' | ||
|
||
static constexpr OptionDefinition g_option_table[] = { | ||
{LLDB_OPT_SET_1, | ||
false, | ||
"show-tags", | ||
SHORT_OPTION_SHOW_TAGS, | ||
OptionParser::eNoArgument, | ||
nullptr, | ||
{}, | ||
0, | ||
eArgTypeNone, | ||
"Include memory tags in output (does not apply to binary output)."}, | ||
}; | ||
|
||
llvm::ArrayRef<OptionDefinition> OptionGroupMemoryTag::GetDefinitions() { | ||
return llvm::makeArrayRef(g_option_table); | ||
} | ||
|
||
Status | ||
OptionGroupMemoryTag::SetOptionValue(uint32_t option_idx, | ||
llvm::StringRef option_arg, | ||
ExecutionContext *execution_context) { | ||
assert(option_idx == 0 && "Only one option in memory tag group!"); | ||
|
||
switch (g_option_table[0].short_option) { | ||
case SHORT_OPTION_SHOW_TAGS: | ||
m_show_tags.SetCurrentValue(true); | ||
m_show_tags.SetOptionWasSet(); | ||
break; | ||
|
||
default: | ||
llvm_unreachable("Unimplemented option"); | ||
} | ||
|
||
return {}; | ||
} | ||
|
||
void OptionGroupMemoryTag::OptionParsingStarting( | ||
ExecutionContext *execution_context) { | ||
m_show_tags.Clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters