[lldb] Fix trailing whitespace in Breakpoint (NFC)

Working in the Breakpoint library is a minefield if you have your editor
configured to trim trailing whitespace. Remove it and format the
affected lines.
This commit is contained in:
Jonas Devlieghere
2025-07-08 15:35:41 -07:00
parent 5cf4537fe1
commit d9060794c2
7 changed files with 52 additions and 55 deletions

View File

@@ -32,18 +32,20 @@ public:
class Permissions
{
public:
enum PermissionKinds { listPerm = 0, disablePerm = 1,
deletePerm = 2, allPerms = 3 };
enum PermissionKinds {
listPerm = 0,
disablePerm = 1,
deletePerm = 2,
allPerms = 3
};
Permissions(bool in_list, bool in_disable, bool in_delete)
{
Permissions(bool in_list, bool in_disable, bool in_delete) {
m_permissions[listPerm] = in_list;
m_permissions[disablePerm] = in_disable;
m_permissions[deletePerm] = in_delete;
m_set_mask.Set(permissions_mask[allPerms]);
}
Permissions(const Permissions &rhs)
{
m_permissions[listPerm] = rhs.m_permissions[listPerm];
@@ -51,15 +53,14 @@ public:
m_permissions[deletePerm] = rhs.m_permissions[deletePerm];
m_set_mask = rhs.m_set_mask;
}
Permissions()
{
Permissions() {
m_permissions[listPerm] = true;
m_permissions[disablePerm] = true;
m_permissions[deletePerm] = true;
m_set_mask.Clear();
}
const Permissions &operator= (const Permissions &rhs)
{
if (this != &rhs) {
@@ -70,11 +71,11 @@ public:
}
return *this;
}
void Clear() {
*this = Permissions();
}
// Merge the permissions from incoming into this set of permissions. Only
// merge set permissions, and most restrictive permission wins.
void MergeInto(const Permissions &incoming)
@@ -86,13 +87,14 @@ public:
bool GetAllowList() const { return GetPermission(listPerm); }
bool SetAllowList(bool value) { return SetPermission(listPerm, value); }
bool GetAllowDelete() const { return GetPermission(deletePerm); }
bool SetAllowDelete(bool value) { return SetPermission(deletePerm, value); }
bool GetAllowDisable() const { return GetPermission(disablePerm); }
bool SetAllowDisable(bool value) { return SetPermission(disablePerm,
value); }
bool SetAllowDisable(bool value) {
return SetPermission(disablePerm, value);
}
bool GetPermission(enum PermissionKinds permission) const
{
@@ -105,17 +107,17 @@ public:
{
return m_set_mask.Test(permissions_mask[permission]);
}
bool AnySet() {
return m_set_mask.AnySet(permissions_mask[allPerms]);
}
private:
static const Flags::ValueType permissions_mask[allPerms + 1];
bool m_permissions[allPerms];
Flags m_set_mask;
bool SetPermission(enum PermissionKinds permission, bool value)
{
bool old_value = m_permissions[permission];
@@ -123,11 +125,10 @@ public:
m_set_mask.Set(permissions_mask[permission]);
return old_value;
}
// If either side disallows the permission, the resultant disallows it.
void MergePermission(const Permissions &incoming,
enum PermissionKinds permission)
{
void MergePermission(const Permissions &incoming,
enum PermissionKinds permission) {
if (incoming.IsSet(permission))
{
SetPermission(permission, !(m_permissions[permission] |
@@ -135,37 +136,37 @@ public:
}
}
};
BreakpointName(ConstString name, const char *help = nullptr) :
m_name(name), m_options(false)
{
SetHelp(help);
}
BreakpointName(const BreakpointName &rhs) :
m_name(rhs.m_name), m_options(rhs.m_options),
m_permissions(rhs.m_permissions), m_help(rhs.m_help)
{}
ConstString GetName() const { return m_name; }
BreakpointOptions &GetOptions() { return m_options; }
const BreakpointOptions &GetOptions() const { return m_options; }
void SetOptions(const BreakpointOptions &options) {
m_options = options;
}
Permissions &GetPermissions() { return m_permissions; }
const Permissions &GetPermissions() const { return m_permissions; }
void SetPermissions(const Permissions &permissions) {
m_permissions = permissions;
}
bool GetPermission(Permissions::PermissionKinds permission) const
{
return m_permissions.GetPermission(permission);
}
void SetHelp(const char *description)
{
if (description)
@@ -173,17 +174,17 @@ public:
else
m_help.clear();
}
const char *GetHelp()
{
return m_help.c_str();
}
// Returns true if any options were set in the name
bool GetDescription(Stream *s, lldb::DescriptionLevel level);
void ConfigureBreakpoint(lldb::BreakpointSP bp_sp);
private:
ConstString m_name;
BreakpointOptions m_options;

View File

@@ -60,7 +60,7 @@ protected:
private:
void CreateImplementationIfNeeded(lldb::BreakpointSP bkpt);
ScriptInterpreter *GetScriptInterpreter();
std::string m_class_name;
lldb::SearchDepth m_depth;
StructuredDataImpl m_args;

View File

@@ -73,7 +73,7 @@ public:
bool IsHardware() const override;
bool ShouldStop(StoppointCallbackContext *context) override;
bool WatchpointRead() const;
bool WatchpointWrite() const;
bool WatchpointModify() const;

View File

@@ -256,7 +256,7 @@ llvm::Error BreakpointIDList::FindAndReplaceIDRanges(
else
iter++;
}
if (!names_found.empty()) {
for (BreakpointSP bkpt_sp : target->GetBreakpointList().Breakpoints()) {
for (const std::string &name : names_found) {

View File

@@ -121,7 +121,7 @@ bool BreakpointLocationCollection::ShouldStop(
size_t prev_size = GetSize();
while (i < prev_size) {
// ShouldStop can remove the breakpoint from the list, or even delete
// it, so we should
// it, so we should
BreakpointLocationSP cur_loc_sp = GetByIndex(i);
BreakpointSP keep_bkpt_alive_sp = cur_loc_sp->GetBreakpoint().shared_from_this();
if (cur_loc_sp->ShouldStop(context))

View File

@@ -21,12 +21,8 @@ using namespace lldb;
using namespace lldb_private;
const Flags::ValueType BreakpointName::Permissions::permissions_mask
[BreakpointName::Permissions::PermissionKinds::allPerms + 1] = {
(1u << 0),
(1u << 1),
(1u << 2),
(0x5u)
};
[BreakpointName::Permissions::PermissionKinds::allPerms + 1] = {
(1u << 0), (1u << 1), (1u << 2), (0x5u)};
bool BreakpointName::Permissions::GetDescription(Stream *s,
lldb::DescriptionLevel level) {
@@ -36,10 +32,10 @@ bool BreakpointName::Permissions::GetDescription(Stream *s,
s->Indent();
if (IsSet(listPerm))
s->Printf("list: %s", GetAllowList() ? "allowed" : "disallowed");
if (IsSet(disablePerm))
s->Printf("disable: %s", GetAllowDisable() ? "allowed" : "disallowed");
if (IsSet(deletePerm))
s->Printf("delete: %s", GetAllowDelete() ? "allowed" : "disallowed");
s->IndentLess();

View File

@@ -99,8 +99,8 @@ BreakpointOptions::CommandData::CreateFromStructuredData(
const char *BreakpointOptions::g_option_names[(
size_t)BreakpointOptions::OptionNames::LastOptionName]{
"ConditionText", "IgnoreCount",
"EnabledState", "OneShotState", "AutoContinue"};
"ConditionText", "IgnoreCount", "EnabledState", "OneShotState",
"AutoContinue"};
// BreakpointOptions constructor
BreakpointOptions::BreakpointOptions(bool all_flags_set)
@@ -113,7 +113,7 @@ BreakpointOptions::BreakpointOptions(bool all_flags_set)
}
BreakpointOptions::BreakpointOptions(const char *condition, bool enabled,
int32_t ignore, bool one_shot,
int32_t ignore, bool one_shot,
bool auto_continue)
: m_callback(nullptr), m_baton_is_command_baton(false),
m_callback_is_synchronous(false), m_enabled(enabled),
@@ -247,7 +247,7 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
}
set_options.Set(eOneShot);
}
key = GetKey(OptionNames::AutoContinue);
if (key && options_dict.HasKey(key)) {
success = options_dict.GetValueForKeyAsBoolean(key, auto_continue);
@@ -258,7 +258,7 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
}
set_options.Set(eAutoContinue);
}
key = GetKey(OptionNames::IgnoreCount);
if (key && options_dict.HasKey(key)) {
success = options_dict.GetValueForKeyAsInteger(key, ignore_count);
@@ -297,8 +297,8 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
}
auto bp_options = std::make_unique<BreakpointOptions>(
condition_ref.str().c_str(), enabled,
ignore_count, one_shot, auto_continue);
condition_ref.str().c_str(), enabled, ignore_count, one_shot,
auto_continue);
if (cmd_data_up) {
if (cmd_data_up->interpreter == eScriptLanguageNone)
bp_options->SetCommandDataCallback(cmd_data_up);
@@ -364,7 +364,7 @@ StructuredData::ObjectSP BreakpointOptions::SerializeToStructuredData() {
if (m_set_flags.Test(eCondition))
options_dict_sp->AddStringItem(GetKey(OptionNames::ConditionText),
m_condition_text);
if (m_set_flags.Test(eCallback) && m_baton_is_command_baton) {
auto cmd_baton =
std::static_pointer_cast<CommandBaton>(m_callback_baton_sp);