Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lldb/include/lldb/Interpreter/OptionValueSInt64.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> {
}

bool SetDefaultValue(int64_t value) {
if (value >= m_min_value && value <= m_max_value) {
m_default_value = value;
return true;
}
return false;
assert(value >= m_min_value && value <= m_max_value &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things I'd like to make sure of:

  • What happens in release configurations where assertions are compiled out? Might this allow you to set an invalid value?
  • Can you call SetDefaultValue by typing a command in lldb? If so, an assertion seems like the wrong way of catching this. I ask because this is in OptionValue, which are involved in parsing commands in LLDB.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the default value is set by LLDB itself. The situation this assert catches is someone defining a default value in the tablegen file that's larger or smaller than the mix/max value. AFAIK there is no way for a user to set a default value.

Currently, SetMinValue is only called for the terminal width and height. There are no other users.

"disallowed default value");
m_default_value = value;
return true;
}

void SetMinimumValue(int64_t v) { m_min_value = v; }
Expand Down
13 changes: 6 additions & 7 deletions lldb/include/lldb/Interpreter/OptionValueUInt64.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,17 @@ class OptionValueUInt64 : public Cloneable<OptionValueUInt64, OptionValue> {
}

bool SetDefaultValue(uint64_t value) {
if (value >= m_min_value && value <= m_max_value) {
m_default_value = value;
return true;
}
return false;
assert(value >= m_min_value && value <= m_max_value &&
"disallowed default value");
m_default_value = value;
return true;
}

void SetMinimumValue(int64_t v) { m_min_value = v; }
void SetMinimumValue(uint64_t v) { m_min_value = v; }

uint64_t GetMinimumValue() const { return m_min_value; }

void SetMaximumValue(int64_t v) { m_max_value = v; }
void SetMaximumValue(uint64_t v) { m_max_value = v; }

uint64_t GetMaximumValue() const { return m_max_value; }

Expand Down