1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:27:45 +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

@ -68,7 +68,7 @@ Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(const Debug::
frames.append({ name, current_instruction, current_ebp });
auto frame_info = Debug::StackFrameUtils::get_info(*Debugger::the().session(), current_ebp);
ASSERT(frame_info.has_value());
VERIFY(frame_info.has_value());
current_instruction = frame_info.value().return_address;
current_ebp = frame_info.value().next_ebp;
} while (current_ebp && current_instruction);

View file

@ -33,7 +33,7 @@ static Debugger* s_the;
Debugger& Debugger::the()
{
ASSERT(s_the);
VERIFY(s_the);
return *s_the;
}
@ -90,10 +90,10 @@ void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointC
if (change_type == BreakpointChange::Added) {
bool success = session->insert_breakpoint(reinterpret_cast<void*>(address.value().address));
ASSERT(success);
VERIFY(success);
} else {
bool success = session->remove_breakpoint(reinterpret_cast<void*>(address.value().address));
ASSERT(success);
VERIFY(success);
}
}
@ -113,14 +113,14 @@ int Debugger::start_static()
void Debugger::start()
{
m_debug_session = Debug::DebugSession::exec_and_attach(m_executable_path, m_source_root);
ASSERT(!!m_debug_session);
VERIFY(!!m_debug_session);
for (const auto& breakpoint : m_breakpoints) {
dbgln("inserting breakpoint at: {}:{}", breakpoint.file_path, breakpoint.line_number);
auto address = m_debug_session->get_address_from_source_position(breakpoint.file_path, breakpoint.line_number);
if (address.has_value()) {
bool success = m_debug_session->insert_breakpoint(reinterpret_cast<void*>(address.value().address));
ASSERT(success);
VERIFY(success);
} else {
dbgln("couldn't insert breakpoint");
}
@ -131,7 +131,7 @@ void Debugger::start()
int Debugger::debugger_loop()
{
ASSERT(m_debug_session);
VERIFY(m_debug_session);
m_debug_session->run(Debug::DebugSession::DesiredInitialDebugeeState::Running, [this](Debug::DebugSession::DebugBreakReason reason, Optional<PtraceRegisters> optional_regs) {
if (reason == Debug::DebugSession::DebugBreakReason::Exited) {
@ -140,7 +140,7 @@ int Debugger::debugger_loop()
return Debug::DebugSession::DebugDecision::Detach;
}
remove_temporary_breakpoints();
ASSERT(optional_regs.has_value());
VERIFY(optional_regs.has_value());
const PtraceRegisters& regs = optional_regs.value();
auto source_position = m_debug_session->get_source_position(regs.eip);
@ -151,7 +151,7 @@ int Debugger::debugger_loop()
if (source_position.value().file_path.ends_with(".S"))
return Debug::DebugSession::DebugDecision::SingleStep;
ASSERT(source_position.has_value());
VERIFY(source_position.has_value());
if (m_state.get() == Debugger::DebuggingState::SingleStepping) {
if (m_state.should_stop_single_stepping(source_position.value())) {
m_state.set_normal();
@ -196,7 +196,7 @@ int Debugger::debugger_loop()
dbgln("Debugger exiting");
return Debug::DebugSession::DebugDecision::Detach;
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
});
m_debug_session.clear();
return 0;
@ -216,16 +216,16 @@ void Debugger::DebuggingState::set_single_stepping(Debug::DebugInfo::SourcePosit
bool Debugger::DebuggingState::should_stop_single_stepping(const Debug::DebugInfo::SourcePosition& current_source_position) const
{
ASSERT(m_state == State::SingleStepping);
VERIFY(m_state == State::SingleStepping);
return m_original_source_position.value() != current_source_position;
}
void Debugger::remove_temporary_breakpoints()
{
for (auto breakpoint_address : m_state.temporary_breakpoints()) {
ASSERT(m_debug_session->breakpoint_exists((void*)breakpoint_address));
VERIFY(m_debug_session->breakpoint_exists((void*)breakpoint_address));
bool rc = m_debug_session->remove_breakpoint((void*)breakpoint_address);
ASSERT(rc);
VERIFY(rc);
}
m_state.clear_temporary_breakpoints();
}
@ -259,7 +259,7 @@ void Debugger::do_step_over(const PtraceRegisters& regs)
dbgln("cannot perform step_over, failed to find containing function of: {:p}", regs.eip);
return;
}
ASSERT(current_function.has_value());
VERIFY(current_function.has_value());
auto lines_in_current_function = lib->debug_info->source_lines_in_scope(current_function.value());
for (const auto& line : lines_in_current_function) {
insert_temporary_breakpoint(line.address_of_first_statement.value() + lib->base_address);
@ -270,7 +270,7 @@ void Debugger::do_step_over(const PtraceRegisters& regs)
void Debugger::insert_temporary_breakpoint_at_return_address(const PtraceRegisters& regs)
{
auto frame_info = Debug::StackFrameUtils::get_info(*m_debug_session, regs.ebp);
ASSERT(frame_info.has_value());
VERIFY(frame_info.has_value());
u32 return_address = frame_info.value().return_address;
insert_temporary_breakpoint(return_address);
}
@ -280,7 +280,7 @@ void Debugger::insert_temporary_breakpoint(FlatPtr address)
if (m_debug_session->breakpoint_exists((void*)address))
return;
bool success = m_debug_session->insert_breakpoint(reinterpret_cast<void*>(address));
ASSERT(success);
VERIFY(success);
m_state.add_temporary_breakpoint(address);
}

View file

@ -63,7 +63,7 @@ DisassemblyModel::DisassemblyModel(const Debug::DebugSession& debug_session, con
auto symbol = elf->find_symbol(containing_function.value().address_low);
if (!symbol.has_value())
return;
ASSERT(symbol.has_value());
VERIFY(symbol.has_value());
auto view = symbol.value().raw_data();
@ -104,7 +104,7 @@ String DisassemblyModel::column_name(int column) const
case Column::Disassembly:
return "Disassembly";
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return {};
}
}

View file

@ -87,7 +87,7 @@ String RegistersModel::column_name(int column) const
case Column::Value:
return "Value";
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return {};
}
}

View file

@ -52,14 +52,14 @@ GUI::ModelIndex VariablesModel::parent_index(const GUI::ModelIndex& index) const
for (size_t row = 0; row < m_variables.size(); row++)
if (m_variables.ptr_at(row).ptr() == parent)
return create_index(row, 0, parent);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
for (size_t row = 0; row < parent->parent->members.size(); row++) {
Debug::DebugInfo::VariableInfo* child_at_row = parent->parent->members.ptr_at(row).ptr();
if (child_at_row == parent)
return create_index(row, 0, parent);
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
int VariablesModel::row_count(const GUI::ModelIndex& index) const
@ -79,29 +79,29 @@ static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& var
if (variable.is_enum_type()) {
auto value = Debugger::the().session()->peek((u32*)variable_address);
ASSERT(value.has_value());
VERIFY(value.has_value());
auto it = variable.type->members.find_if([&enumerator_value = value.value()](const auto& enumerator) {
return enumerator->constant_data.as_u32 == enumerator_value;
});
ASSERT(!it.is_end());
VERIFY(!it.is_end());
return String::formatted("{}::{}", variable.type_name, (*it)->name);
}
if (variable.type_name == "int") {
auto value = Debugger::the().session()->peek((u32*)variable_address);
ASSERT(value.has_value());
VERIFY(value.has_value());
return String::formatted("{}", static_cast<int>(value.value()));
}
if (variable.type_name == "char") {
auto value = Debugger::the().session()->peek((u32*)variable_address);
ASSERT(value.has_value());
VERIFY(value.has_value());
return String::formatted("'{0:c}' ({0:d})", value.value());
}
if (variable.type_name == "bool") {
auto value = Debugger::the().session()->peek((u32*)variable_address);
ASSERT(value.has_value());
VERIFY(value.has_value());
return (value.value() & 1) ? "true" : "false";
}
@ -151,7 +151,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, const Stri
if (value.has_value()) {
auto success = Debugger::the().session()->poke((u32*)variable->location_data.address, value.value());
ASSERT(success);
VERIFY(success);
return;
}

View file

@ -135,7 +135,7 @@ RefPtr<ProjectTemplate> NewProjectDialog::selected_template()
}
auto project_template = m_model->template_for_index(m_icon_view->selection().first());
ASSERT(!project_template.is_null());
VERIFY(!project_template.is_null());
return project_template;
}

View file

@ -78,7 +78,7 @@ String ProjectTemplatesModel::column_name(int column) const
case Column::Name:
return "Name";
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
GUI::Variant ProjectTemplatesModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const

View file

@ -385,7 +385,7 @@ const Gfx::Bitmap& Editor::current_position_icon_bitmap()
const CodeDocument& Editor::code_document() const
{
const auto& doc = document();
ASSERT(doc.is_code_document());
VERIFY(doc.is_code_document());
return static_cast<const CodeDocument&>(doc);
}
@ -396,7 +396,7 @@ CodeDocument& Editor::code_document()
void Editor::set_document(GUI::TextDocument& doc)
{
ASSERT(doc.is_code_document());
VERIFY(doc.is_code_document());
GUI::TextEditor::set_document(doc);
set_override_cursor(Gfx::StandardCursor::IBeam);
@ -487,7 +487,7 @@ void Editor::on_edit_action(const GUI::Command& command)
return;
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void Editor::undo()

View file

@ -69,7 +69,7 @@ public:
case Column::MatchedText:
return "Text";
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -85,7 +85,7 @@ public:
void remove(GUI::Widget& widget)
{
ASSERT(m_widgets.contains(&widget));
VERIFY(m_widgets.contains(&widget));
m_widgets.remove(&widget);
if (m_hooks_enabled && on_remove)
on_remove(widget);

View file

@ -86,7 +86,7 @@ void DiffViewer::paint_event(GUI::PaintEvent& event)
right_y_offset += line_height();
}
ASSERT(left_y_offset == right_y_offset);
VERIFY(left_y_offset == right_y_offset);
y_offset = left_y_offset;
}
for (size_t i = current_original_line_index; i < m_original_lines.size(); ++i) {

View file

@ -75,7 +75,7 @@ void GitFilesView::mousedown_event(GUI::MouseEvent& event)
auto data = model()->index(item_index, model_column()).data();
ASSERT(data.is_string());
VERIFY(data.is_string());
m_action_callback(LexicalPath(data.to_string()));
}

View file

@ -49,7 +49,7 @@ RefPtr<GitRepo> GitRepo::initialize_repository(const LexicalPath& repository_roo
if (res.is_null())
return {};
ASSERT(git_repo_exists(repository_root));
VERIFY(git_repo_exists(repository_root));
return adopt(*new GitRepo(repository_root));
}

View file

@ -109,7 +109,7 @@ bool GitWidget::initialize()
return true;
}
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -128,7 +128,7 @@ void GitWidget::refresh()
return;
}
ASSERT(!m_git_repo.is_null());
VERIFY(!m_git_repo.is_null());
m_unstaged_files->set_model(GitFilesModel::create(m_git_repo->unstaged_files()));
m_staged_files->set_model(GitFilesModel::create(m_git_repo->staged_files()));
@ -138,7 +138,7 @@ void GitWidget::stage_file(const LexicalPath& file)
{
dbgln("staging: {}", file);
bool rc = m_git_repo->stage(file);
ASSERT(rc);
VERIFY(rc);
refresh();
}
@ -146,7 +146,7 @@ void GitWidget::unstage_file(const LexicalPath& file)
{
dbgln("unstaging: {}", file);
bool rc = m_git_repo->unstage(file);
ASSERT(rc);
VERIFY(rc);
refresh();
}
@ -172,7 +172,7 @@ void GitWidget::show_diff(const LexicalPath& file_path)
auto file = Core::File::construct(file_path.string());
if (!file->open(Core::IODevice::ReadOnly)) {
perror("open");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
auto content = file->read_all();
@ -182,7 +182,7 @@ void GitWidget::show_diff(const LexicalPath& file_path)
}
const auto& original_content = m_git_repo->original_file_content(file_path);
const auto& diff = m_git_repo->unstaged_diff(file_path);
ASSERT(original_content.has_value() && diff.has_value());
VERIFY(original_content.has_value() && diff.has_value());
m_view_diff_callback(original_content.value(), diff.value());
}
}

View file

@ -191,7 +191,7 @@ void HackStudioWidget::open_project(const String& root_path)
exit(1);
}
m_project = Project::open_with_root_path(root_path);
ASSERT(m_project);
VERIFY(m_project);
if (m_project_tree_view) {
m_project_tree_view->set_model(m_project->model());
m_project_tree_view->update();
@ -222,7 +222,7 @@ void HackStudioWidget::open_file(const String& full_filename)
if (!currently_open_file().is_empty()) {
// Since the file is previously open, it should always be in m_open_files.
ASSERT(m_open_files.find(currently_open_file()) != m_open_files.end());
VERIFY(m_open_files.find(currently_open_file()) != m_open_files.end());
auto previous_open_project_file = m_open_files.get(currently_open_file()).value();
// Update the scrollbar values of the previous_open_project_file and save them to m_open_files.
@ -272,7 +272,7 @@ void HackStudioWidget::open_file(const String& full_filename)
EditorWrapper& HackStudioWidget::current_editor_wrapper()
{
ASSERT(m_current_editor_wrapper);
VERIFY(m_current_editor_wrapper);
return *m_current_editor_wrapper;
}
@ -290,7 +290,7 @@ void HackStudioWidget::set_edit_mode(EditMode mode)
} else if (mode == EditMode::Diff) {
m_right_hand_stack->set_active_widget(m_diff_viewer);
} else {
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
m_right_hand_stack->active_widget()->update();
}
@ -563,7 +563,7 @@ void HackStudioWidget::initialize_debugger()
Debugger::initialize(
m_project->root_path(),
[this](const PtraceRegisters& regs) {
ASSERT(Debugger::the().session());
VERIFY(Debugger::the().session());
const auto& debug_session = *Debugger::the().session();
auto source_position = debug_session.get_source_position(regs.eip);
if (!source_position.has_value()) {
@ -610,7 +610,7 @@ void HackStudioWidget::initialize_debugger()
String HackStudioWidget::get_full_path_of_serenity_source(const String& file)
{
auto path_parts = LexicalPath(file).parts();
ASSERT(path_parts[0] == "..");
VERIFY(path_parts[0] == "..");
path_parts.remove(0);
StringBuilder relative_path_builder;
relative_path_builder.join("/", path_parts);

View file

@ -117,7 +117,7 @@ void LanguageClient::set_active_client()
void LanguageClient::on_server_crash()
{
ASSERT(m_server_connection);
VERIFY(m_server_connection);
auto project_path = m_server_connection->projcet_path();
ServerConnection::remove_instance_for_project(project_path);
m_server_connection = nullptr;

View file

@ -105,14 +105,14 @@ public:
: m_server_connection(move(connection))
{
m_previous_client = m_server_connection->language_client();
ASSERT(m_previous_client.ptr() != this);
VERIFY(m_previous_client.ptr() != this);
m_server_connection->attach(*this);
}
virtual ~LanguageClient()
{
m_server_connection->detach();
ASSERT(m_previous_client.ptr() != this);
VERIFY(m_previous_client.ptr() != this);
if (m_previous_client)
m_server_connection->attach(*m_previous_client);
}

View file

@ -65,7 +65,7 @@ String FileDB::to_absolute_path(const String& file_name) const
if (LexicalPath { file_name }.is_absolute()) {
return file_name;
}
ASSERT(!m_project_root.is_null());
VERIFY(!m_project_root.is_null());
return LexicalPath { String::formatted("{}/{}", m_project_root, file_name) }.string();
}

View file

@ -65,8 +65,8 @@ Vector<GUI::AutocompleteProvider::Entry> LexerAutoComplete::get_suggestions(cons
StringView LexerAutoComplete::text_of_token(const Vector<String>& lines, const Cpp::Token& token)
{
ASSERT(token.m_start.line == token.m_end.line);
ASSERT(token.m_start.column <= token.m_end.column);
VERIFY(token.m_start.line == token.m_end.line);
VERIFY(token.m_start.column <= token.m_end.column);
return lines[token.m_start.line].substring_view(token.m_start.column, token.m_end.column - token.m_start.column + 1);
}

View file

@ -53,14 +53,14 @@ const ParserAutoComplete::DocumentData& ParserAutoComplete::get_document_data(co
{
auto absolute_path = filedb().to_absolute_path(file);
auto document_data = m_documents.get(absolute_path);
ASSERT(document_data.has_value());
VERIFY(document_data.has_value());
return *document_data.value();
}
OwnPtr<ParserAutoComplete::DocumentData> ParserAutoComplete::create_document_data_for(const String& file)
{
auto document = filedb().get(file);
ASSERT(document);
VERIFY(document);
auto content = document->text();
auto document_data = make<DocumentData>(document->text(), file);
auto root = document_data->parser.parse();
@ -107,7 +107,7 @@ Vector<GUI::AutocompleteProvider::Entry> ParserAutoComplete::get_suggestions(con
}
if (is_empty_property(document, *node, position)) {
ASSERT(node->is_member_expression());
VERIFY(node->is_member_expression());
return autocomplete_property(document, (MemberExpression&)(*node), "");
}
@ -235,7 +235,7 @@ String ParserAutoComplete::type_of(const DocumentData& document, const Expressio
return type_of_property(document, *member_expression.m_property);
}
if (!expression.is_identifier()) {
ASSERT_NOT_REACHED(); // TODO
VERIFY_NOT_REACHED(); // TODO
}
auto& identifier = (const Identifier&)expression;
@ -350,7 +350,7 @@ RefPtr<Declaration> ParserAutoComplete::find_declaration_of(const DocumentData&
}
if (is_property(node) && decl.is_struct_or_class()) {
for (auto& member : ((Cpp::StructOrClassDeclaration&)decl).m_members) {
ASSERT(node.is_identifier());
VERIFY(node.is_identifier());
if (member.m_name == ((const Identifier&)node).m_name)
return member;
}

View file

@ -55,15 +55,15 @@ void TerminalWrapper::run_command(const String& command)
int ptm_fd = posix_openpt(O_RDWR | O_CLOEXEC);
if (ptm_fd < 0) {
perror("posix_openpt");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (grantpt(ptm_fd) < 0) {
perror("grantpt");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (unlockpt(ptm_fd) < 0) {
perror("unlockpt");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
m_terminal_widget->set_pty_master_fd(ptm_fd);
@ -72,7 +72,7 @@ void TerminalWrapper::run_command(const String& command)
int rc = waitpid(m_pid, &wstatus, 0);
if (rc < 0) {
perror("waitpid");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (WIFEXITED(wstatus)) {
m_terminal_widget->inject_string(String::formatted("\033[{};1m(Command exited with code {})\033[0m\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus)));
@ -147,7 +147,7 @@ void TerminalWrapper::run_command(const String& command)
setenv("TERM", "xterm", true);
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();
@ -157,7 +157,7 @@ void TerminalWrapper::run_command(const String& command)
perror("execve");
exit(1);
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
// (In parent process)
@ -166,7 +166,7 @@ void TerminalWrapper::run_command(const String& command)
void TerminalWrapper::kill_running_command()
{
ASSERT(m_pid != -1);
VERIFY(m_pid != -1);
// Kill our child process and its whole process group.
[[maybe_unused]] auto rc = killpg(m_pid, SIGTERM);

View file

@ -69,7 +69,7 @@ GUI::ModelIndex WidgetTreeModel::parent_index(const GUI::ModelIndex& index) cons
++grandparent_child_index;
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return {};
}