1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:47:35 +00:00

Everywhere: Rename ASSERT => VERIFY

(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
This commit is contained in:
Andreas Kling 2021-02-23 20:42:32 +01:00
parent b33a6a443e
commit 5d180d1f99
725 changed files with 3448 additions and 3448 deletions

View file

@ -207,7 +207,7 @@ static Optional<Dwarf::DIE> parse_variable_type_die(const Dwarf::DIE& variable_d
if (!type_die_offset.has_value())
return {};
ASSERT(type_die_offset.value().type == Dwarf::DIE::AttributeValue::Type::DieReference);
VERIFY(type_die_offset.value().type == Dwarf::DIE::AttributeValue::Type::DieReference);
auto type_die = variable_die.get_die_at_offset(type_die_offset.value().data.as_u32);
auto type_name = type_die.get_attribute(Dwarf::Attribute::Name);
@ -241,7 +241,7 @@ static void parse_variable_location(const Dwarf::DIE& variable_die, DebugInfo::V
auto value = Dwarf::Expression::evaluate(expression_bytes, regs);
if (value.type != Dwarf::Expression::Type::None) {
ASSERT(value.type == Dwarf::Expression::Type::UnsignedIntetger);
VERIFY(value.type == Dwarf::Expression::Type::UnsignedIntetger);
variable_info.location_type = DebugInfo::VariableInfo::LocationType::Address;
variable_info.location_data.address = value.data.as_u32;
}
@ -254,7 +254,7 @@ static void parse_variable_location(const Dwarf::DIE& variable_die, DebugInfo::V
OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters& regs) const
{
ASSERT(variable_die.tag() == Dwarf::EntryTag::Variable
VERIFY(variable_die.tag() == Dwarf::EntryTag::Variable
|| variable_die.tag() == Dwarf::EntryTag::Member
|| variable_die.tag() == Dwarf::EntryTag::FormalParameter
|| variable_die.tag() == Dwarf::EntryTag::EnumerationType
@ -274,7 +274,7 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
if (variable_die.tag() == Dwarf::EntryTag::Enumerator) {
auto constant = variable_die.get_attribute(Dwarf::Attribute::ConstValue);
ASSERT(constant.has_value());
VERIFY(constant.has_value());
switch (constant.value().type) {
case Dwarf::DIE::AttributeValue::Type::UnsignedNumber:
variable_info->constant_data.as_u32 = constant.value().data.as_u32;
@ -286,7 +286,7 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
variable_info->constant_data.as_string = constant.value().data.as_string;
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
} else {
parse_variable_location(variable_die, *variable_info, regs);
@ -302,7 +302,7 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
if (member.is_null())
return;
auto member_variable = create_variable_info(member, regs);
ASSERT(member_variable);
VERIFY(member_variable);
if (type_die.value().tag() == Dwarf::EntryTag::EnumerationType) {
member_variable->parent = type_info.ptr();
@ -311,7 +311,7 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
if (variable_info->location_type == DebugInfo::VariableInfo::LocationType::None) {
return;
}
ASSERT(variable_info->location_type == DebugInfo::VariableInfo::LocationType::Address);
VERIFY(variable_info->location_type == DebugInfo::VariableInfo::LocationType::Address);
if (member_variable->location_type == DebugInfo::VariableInfo::LocationType::Address)
member_variable->location_data.address += variable_info->location_data.address;

View file

@ -73,7 +73,7 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(const String& command, String
}
auto parts = command.split(' ');
ASSERT(!parts.is_empty());
VERIFY(!parts.is_empty());
const char** args = (const char**)calloc(parts.size() + 1, sizeof(const char*));
for (size_t i = 0; i < parts.size(); i++) {
args[i] = parts[i].characters();
@ -155,7 +155,7 @@ bool DebugSession::insert_breakpoint(void* address)
if (!original_bytes.has_value())
return false;
ASSERT((original_bytes.value() & 0xff) != BREAKPOINT_INSTRUCTION);
VERIFY((original_bytes.value() & 0xff) != BREAKPOINT_INSTRUCTION);
BreakPoint breakpoint { address, original_bytes.value(), BreakPointState::Disabled };
@ -169,7 +169,7 @@ bool DebugSession::insert_breakpoint(void* address)
bool DebugSession::disable_breakpoint(void* address)
{
auto breakpoint = m_breakpoints.get(address);
ASSERT(breakpoint.has_value());
VERIFY(breakpoint.has_value());
if (!poke(reinterpret_cast<u32*>(reinterpret_cast<char*>(breakpoint.value().address)), breakpoint.value().original_first_word))
return false;
@ -182,9 +182,9 @@ bool DebugSession::disable_breakpoint(void* address)
bool DebugSession::enable_breakpoint(void* address)
{
auto breakpoint = m_breakpoints.get(address);
ASSERT(breakpoint.has_value());
VERIFY(breakpoint.has_value());
ASSERT(breakpoint.value().state == BreakPointState::Disabled);
VERIFY(breakpoint.value().state == BreakPointState::Disabled);
if (!poke(reinterpret_cast<u32*>(breakpoint.value().address), (breakpoint.value().original_first_word & ~(uint32_t)0xff) | BREAKPOINT_INSTRUCTION))
return false;
@ -214,7 +214,7 @@ PtraceRegisters DebugSession::get_registers() const
PtraceRegisters regs;
if (ptrace(PT_GETREGS, m_debuggee_pid, &regs, 0) < 0) {
perror("PT_GETREGS");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return regs;
}
@ -223,7 +223,7 @@ void DebugSession::set_registers(const PtraceRegisters& regs)
{
if (ptrace(PT_SETREGS, m_debuggee_pid, reinterpret_cast<void*>(&const_cast<PtraceRegisters&>(regs)), 0) < 0) {
perror("PT_SETREGS");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -232,7 +232,7 @@ void DebugSession::continue_debuggee(ContinueType type)
int command = (type == ContinueType::FreeRun) ? PT_CONTINUE : PT_SYSCALL;
if (ptrace(command, m_debuggee_pid, 0, 0) < 0) {
perror("continue");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -242,7 +242,7 @@ int DebugSession::continue_debuggee_and_wait(ContinueType type)
int wstatus = 0;
if (waitpid(m_debuggee_pid, &wstatus, WSTOPPED | WEXITED) != m_debuggee_pid) {
perror("waitpid");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return wstatus;
}
@ -264,7 +264,7 @@ void* DebugSession::single_step()
if (waitpid(m_debuggee_pid, 0, WSTOPPED) != m_debuggee_pid) {
perror("waitpid");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
regs = get_registers();
@ -316,7 +316,7 @@ Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::ins
return {};
auto lib = library_at(address);
ASSERT(lib);
VERIFY(lib);
return InsertBreakpointAtSourcePositionResult { lib->name, address_and_source_position.value().file, address_and_source_position.value().line, address };
}
@ -325,11 +325,11 @@ void DebugSession::update_loaded_libs()
{
auto file = Core::File::construct(String::format("/proc/%u/vm", m_debuggee_pid));
bool rc = file->open(Core::IODevice::ReadOnly);
ASSERT(rc);
VERIFY(rc);
auto file_contents = file->read_all();
auto json = JsonValue::from_string(file_contents);
ASSERT(json.has_value());
VERIFY(json.has_value());
auto vm_entries = json.value().as_array();
Regex<PosixExtended> re("(.+): \\.text");

View file

@ -298,7 +298,7 @@ void DebugSession::run(DesiredInitialDebugeeState initial_debugee_state, Callbac
break;
}
if (decision == DebugDecision::Kill) {
ASSERT_NOT_REACHED(); // TODO: implement
VERIFY_NOT_REACHED(); // TODO: implement
}
if (state == State::SingleStep && !did_single_step) {

View file

@ -46,7 +46,7 @@ DIE::DIE(const CompilationUnit& unit, u32 offset)
m_tag = EntryTag::None;
} else {
auto abbreviation_info = m_compilation_unit.abbreviations_map().get(m_abbreviation_code);
ASSERT(abbreviation_info.has_value());
VERIFY(abbreviation_info.has_value());
m_tag = abbreviation_info.value().tag;
m_has_children = abbreviation_info.value().has_children;
@ -76,7 +76,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::StringPointer: {
u32 offset;
debug_info_stream >> offset;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::String;
auto strings_data = m_compilation_unit.dwarf_info().debug_strings_data();
@ -86,7 +86,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::Data1: {
u8 data;
debug_info_stream >> data;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::UnsignedNumber;
value.data.as_u32 = data;
break;
@ -94,7 +94,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::Data2: {
u16 data;
debug_info_stream >> data;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::UnsignedNumber;
value.data.as_u32 = data;
break;
@ -102,7 +102,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::Addr: {
u32 address;
debug_info_stream >> address;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::UnsignedNumber;
value.data.as_u32 = address;
break;
@ -110,7 +110,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::SData: {
ssize_t data;
debug_info_stream.read_LEB128_signed(data);
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::SignedNumber;
value.data.as_i32 = data;
break;
@ -118,7 +118,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::SecOffset: {
u32 data;
debug_info_stream >> data;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::SecOffset;
value.data.as_u32 = data;
break;
@ -126,7 +126,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::Data4: {
u32 data;
debug_info_stream >> data;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::UnsignedNumber;
value.data.as_u32 = data;
break;
@ -134,7 +134,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::Ref4: {
u32 data;
debug_info_stream >> data;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::DieReference;
value.data.as_u32 = data + m_compilation_unit.offset();
break;
@ -147,7 +147,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::ExprLoc: {
size_t length;
debug_info_stream.read_LEB128_unsigned(length);
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::DwarfExpression;
assign_raw_bytes_value(length);
break;
@ -156,7 +156,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
String str;
u32 str_offset = debug_info_stream.offset();
debug_info_stream >> str;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::String;
value.data.as_string = reinterpret_cast<const char*>(str_offset + m_compilation_unit.dwarf_info().debug_info_data().data());
break;
@ -165,7 +165,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
value.type = AttributeValue::Type::RawBytes;
u8 length;
debug_info_stream >> length;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
assign_raw_bytes_value(length);
break;
}
@ -173,7 +173,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
value.type = AttributeValue::Type::RawBytes;
u16 length;
debug_info_stream >> length;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
assign_raw_bytes_value(length);
break;
}
@ -181,7 +181,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
value.type = AttributeValue::Type::RawBytes;
u32 length;
debug_info_stream >> length;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
assign_raw_bytes_value(length);
break;
}
@ -189,13 +189,13 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
value.type = AttributeValue::Type::RawBytes;
size_t length;
debug_info_stream.read_LEB128_unsigned(length);
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
assign_raw_bytes_value(length);
break;
}
default:
dbgln("Unimplemented AttributeDataForm: {}", (u32)form);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return value;
}
@ -206,7 +206,7 @@ Optional<DIE::AttributeValue> DIE::get_attribute(const Attribute& attribute) con
stream.discard_or_error(m_data_offset);
auto abbreviation_info = m_compilation_unit.abbreviations_map().get(m_abbreviation_code);
ASSERT(abbreviation_info.has_value());
VERIFY(abbreviation_info.has_value());
for (const auto& attribute_spec : abbreviation_info.value().attribute_specifications) {
auto value = get_attribute_value(attribute_spec.form, stream);
@ -251,7 +251,7 @@ void DIE::for_each_child(Function<void(const DIE& child)> callback) const
DIE DIE::get_die_at_offset(u32 offset) const
{
ASSERT(offset >= m_compilation_unit.offset() && offset < m_compilation_unit.offset() + m_compilation_unit.size());
VERIFY(offset >= m_compilation_unit.offset() && offset < m_compilation_unit.offset() + m_compilation_unit.size());
return DIE(m_compilation_unit, offset);
}

View file

@ -59,8 +59,8 @@ void DwarfInfo::populate_compilation_units()
CompilationUnitHeader compilation_unit_header {};
stream >> Bytes { &compilation_unit_header, sizeof(compilation_unit_header) };
ASSERT(compilation_unit_header.address_size == sizeof(u32));
ASSERT(compilation_unit_header.version <= 4);
VERIFY(compilation_unit_header.address_size == sizeof(u32));
VERIFY(compilation_unit_header.version <= 4);
u32 length_after_header = compilation_unit_header.length - (sizeof(CompilationUnitHeader) - offsetof(CompilationUnitHeader, version));
m_compilation_units.empend(*this, unit_offset, compilation_unit_header);

View file

@ -55,10 +55,10 @@ Value evaluate(ReadonlyBytes bytes, const PtraceRegisters& regs)
default:
dbgln("DWARF expr addr: {}", (const void*)bytes.data());
dbgln("unsupported opcode: {}", (u8)opcode);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -45,8 +45,8 @@ void LineProgram::parse_unit_header()
{
m_stream >> Bytes { &m_unit_header, sizeof(m_unit_header) };
ASSERT(m_unit_header.version == DWARF_VERSION);
ASSERT(m_unit_header.opcode_base == SPECIAL_OPCODES_BASE);
VERIFY(m_unit_header.version == DWARF_VERSION);
VERIFY(m_unit_header.opcode_base == SPECIAL_OPCODES_BASE);
#if DWARF_DEBUG
dbgln("unit length: {}", m_unit_header.length);
@ -67,7 +67,7 @@ void LineProgram::parse_source_directories()
}
m_stream.handle_recoverable_error();
m_stream.discard_or_error(1);
ASSERT(!m_stream.has_any_error());
VERIFY(!m_stream.has_any_error());
}
void LineProgram::parse_source_files()
@ -87,7 +87,7 @@ void LineProgram::parse_source_files()
m_source_files.append({ file_name, directory_index });
}
m_stream.discard_or_error(1);
ASSERT(!m_stream.has_any_error());
VERIFY(!m_stream.has_any_error());
}
void LineProgram::append_to_line_info()
@ -131,7 +131,7 @@ void LineProgram::handle_extended_opcode()
break;
}
case ExtendedOpcodes::SetAddress: {
ASSERT(length == sizeof(size_t) + 1);
VERIFY(length == sizeof(size_t) + 1);
m_stream >> m_address;
#if DWARF_DEBUG
dbgln("SetAddress: {:p}", m_address);
@ -149,7 +149,7 @@ void LineProgram::handle_extended_opcode()
#if DWARF_DEBUG
dbgln("offset: {:p}", m_stream.offset());
#endif
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
void LineProgram::handle_standard_opcode(u8 opcode)
@ -191,7 +191,7 @@ void LineProgram::handle_standard_opcode(u8 opcode)
case StandardOpcodes::AdvanceLine: {
ssize_t line_delta;
m_stream.read_LEB128_signed(line_delta);
ASSERT(line_delta >= 0 || m_line >= (size_t)(-line_delta));
VERIFY(line_delta >= 0 || m_line >= (size_t)(-line_delta));
m_line += line_delta;
#if DWARF_DEBUG
dbgln("AdvanceLine: {}", m_line);
@ -223,7 +223,7 @@ void LineProgram::handle_standard_opcode(u8 opcode)
}
default:
dbgln("Unhandled LineProgram opcode {}", opcode);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
void LineProgram::handle_sepcial_opcode(u8 opcode)