From d5ffb51a8328f5274a6a338163e1d4fb7f6ac210 Mon Sep 17 00:00:00 2001 From: asynts Date: Sun, 4 Oct 2020 15:35:43 +0200 Subject: [PATCH] AK: Don't add newline for outf/dbgf/warnf. In the future all (normal) output should be written by any of the following functions: out (currently called new_out) outln dbg (currently called new_dbg) dbgln warn (currently called new_warn) warnln However, there are still a ton of uses of the old out/warn/dbg in the code base so the new functions are called new_out/new_warn/new_dbg. I am going to rename them as soon as all the other usages are gone (this might take a while.) I also added raw_out/raw_dbg/raw_warn which don't do any escaping, this should be useful if no formatting is required and if the input contains tons of curly braces. (I am not entirely sure if this function will stay, but I am adding it for now.) --- AK/Format.cpp | 83 +++++++++++++++++++++ AK/Format.h | 43 +++++++++++ AK/LogStream.cpp | 2 + AK/LogStream.h | 22 ------ AK/TestSuite.h | 4 +- Applications/IRCClient/IRCClient.cpp | 14 ++-- DevTools/UserspaceEmulator/Emulator.cpp | 16 ++-- DevTools/UserspaceEmulator/MallocTracer.cpp | 38 +++++----- DevTools/UserspaceEmulator/MmapRegion.cpp | 16 ++-- DevTools/UserspaceEmulator/SoftCPU.cpp | 24 +++--- DevTools/UserspaceEmulator/SoftMMU.cpp | 16 ++-- Services/TelnetServer/main.cpp | 2 +- Services/WebServer/main.cpp | 4 +- Shell/Shell.cpp | 4 +- Shell/main.cpp | 6 +- Userland/tar.cpp | 4 +- 16 files changed, 202 insertions(+), 96 deletions(-) diff --git a/AK/Format.cpp b/AK/Format.cpp index 5331b7621b..09de6e4292 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -30,6 +30,14 @@ #include #include +#ifdef KERNEL +# include +# include +#else +# include +# include +#endif + namespace AK { namespace { @@ -540,6 +548,81 @@ void Formatter::format(TypeErasedFormatParams& params, FormatBuilder& buil } } +#ifndef KERNEL +void raw_out(StringView string) +{ + const auto retval = ::fwrite(string.characters_without_null_termination(), 1, string.length(), stdout); + ASSERT(retval == string.length()); +} +void vout(StringView fmtstr, TypeErasedFormatParams params, bool newline) +{ + StringBuilder builder; + vformat(builder, fmtstr, params); + + if (newline && !builder.is_empty()) + builder.append('\n'); + + raw_out(builder.to_string()); +} + +void raw_warn(StringView string) +{ + const auto retval = ::write(STDERR_FILENO, string.characters_without_null_termination(), string.length()); + ASSERT(static_cast(retval) == string.length()); +} +void vwarn(StringView fmtstr, TypeErasedFormatParams params, bool newline) +{ + StringBuilder builder; + vformat(builder, fmtstr, params); + + if (newline && !builder.is_empty()) + builder.append('\n'); + + raw_warn(builder.to_string()); +} +#endif + +void raw_dbg(StringView string) +{ + const auto retval = dbgputstr(string.characters_without_null_termination(), string.length()); + ASSERT(static_cast(retval) == string.length()); +} +void vdbg(StringView fmtstr, TypeErasedFormatParams params, bool newline) +{ + StringBuilder builder; + +// FIXME: This logic is redundant with the stuff in LogStream.cpp. +#if defined(__serenity__) +# ifdef KERNEL + if (Kernel::Processor::is_initialized() && Kernel::Thread::current()) { + auto& thread = *Kernel::Thread::current(); + builder.appendff("\033[34;1m[{}({}:{})]\033[0m: ", thread.process().name(), thread.pid().value(), thread.tid().value()); + } else { + builder.appendff("\033[34;1m[Kernel]\033[0m: "); + } +# else + static TriState got_process_name = TriState::Unknown; + static char process_name_buffer[256]; + + if (got_process_name == TriState::Unknown) { + if (get_process_name(process_name_buffer, sizeof(process_name_buffer)) == 0) + got_process_name = TriState::True; + else + got_process_name = TriState::False; + } + if (got_process_name == TriState::True) + builder.appendff("\033[33;1m{}({})\033[0m: ", process_name_buffer, getpid()); +# endif +#endif + + vformat(builder, fmtstr, params); + + if (newline && !builder.is_empty()) + builder.append('\n'); + + raw_dbg(builder.to_string()); +} + template struct Formatter; template struct Formatter; template struct Formatter; diff --git a/AK/Format.h b/AK/Format.h index e4a8ff6509..c813d27e38 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -299,4 +299,47 @@ struct Formatter : StandardFormatter { void vformat(StringBuilder& builder, StringView fmtstr, TypeErasedFormatParams); void vformat(const LogStream& stream, StringView fmtstr, TypeErasedFormatParams); +#ifndef KERNEL +void vout(StringView fmtstr, TypeErasedFormatParams, bool newline = false); +void raw_out(StringView string); + +// FIXME: Rename this function to 'out' when that name becomes avaliable. +template +void new_out(StringView fmtstr, const Parameters&... parameters) { vout(fmtstr, VariadicFormatParams { parameters... }); } +template +void outln(StringView fmtstr, const Parameters&... parameters) { vout(fmtstr, VariadicFormatParams { parameters... }, true); } + +void vwarn(StringView fmtstr, TypeErasedFormatParams, bool newline = false); +void raw_warn(StringView string); + +// FIXME: Rename this function to 'warn' when that name becomes avaliable. +template +void new_warn(StringView fmtstr, const Parameters&... parameters) { vwarn(fmtstr, VariadicFormatParams { parameters... }); } +template +void warnln(StringView fmtstr, const Parameters&... parameters) { vwarn(fmtstr, VariadicFormatParams { parameters... }, true); } +#endif + +void vdbg(StringView fmtstr, TypeErasedFormatParams, bool newline = false); +void raw_dbg(StringView string); + +// FIXME: Rename this function to 'dbg' when that name becomes avaliable. +template +void new_dbg(StringView fmtstr, const Parameters&... parameters) { vdbg(fmtstr, VariadicFormatParams { parameters... }); } +template +void dbgln(StringView fmtstr, const Parameters&... parameters) { vdbg(fmtstr, VariadicFormatParams { parameters... }, true); } + } // namespace AK + +#ifndef KERNEL +using AK::new_out; +using AK::outln; +using AK::raw_out; + +using AK::new_warn; +using AK::raw_warn; +using AK::warnln; +#endif + +using AK::dbgln; +using AK::new_dbg; +using AK::raw_dbg; diff --git a/AK/LogStream.cpp b/AK/LogStream.cpp index 37a7a58e08..3e910f24d3 100644 --- a/AK/LogStream.cpp +++ b/AK/LogStream.cpp @@ -115,6 +115,8 @@ static char process_name_buffer[256]; DebugLogStream dbg() { DebugLogStream stream; + + // FIXME: This logic is redundant with the stuff in Format.cpp. #if defined(__serenity__) && !defined(KERNEL) if (got_process_name == TriState::Unknown) { if (get_process_name(process_name_buffer, sizeof(process_name_buffer)) == 0) diff --git a/AK/LogStream.h b/AK/LogStream.h index b68925465e..a27473818a 100644 --- a/AK/LogStream.h +++ b/AK/LogStream.h @@ -207,35 +207,13 @@ DebugLogStream klog(); void dump_bytes(ReadonlyBytes); -#ifndef KERNEL -template -void outf(StringView fmtstr, const Parameters&... parameters) -{ - vformat(out(), fmtstr, VariadicFormatParams { parameters... }); -} -template -void warnf(StringView fmtstr, const Parameters&... parameters) -{ - vformat(warn(), fmtstr, VariadicFormatParams { parameters... }); -} -#endif - -template -void dbgf(StringView fmtstr, const Parameters&... parameters) -{ - vformat(dbg(), fmtstr, VariadicFormatParams { parameters... }); -} - } using AK::dbg; -using AK::dbgf; using AK::klog; using AK::LogStream; #if !defined(KERNEL) using AK::out; -using AK::outf; using AK::warn; -using AK::warnf; #endif diff --git a/AK/TestSuite.h b/AK/TestSuite.h index ed0e36a486..1b2baa5852 100644 --- a/AK/TestSuite.h +++ b/AK/TestSuite.h @@ -199,13 +199,13 @@ void TestSuite::run(const NonnullRefPtrVector& tests) for (const auto& t : tests) { const auto test_type = t.is_benchmark() ? "benchmark" : "test"; - warnf("Running {} '{}'.", test_type, t.name()); + warnln("Running {} '{}'.", test_type, t.name()); TestElapsedTimer timer; t.func()(); const auto time = timer.elapsed_milliseconds(); - dbgf("Completed {} '{}' in {}ms", test_type, t.name(), time); + dbgln("Completed {} '{}' in {}ms", test_type, t.name(), time); if (t.is_benchmark()) { m_benchtime += time; diff --git a/Applications/IRCClient/IRCClient.cpp b/Applications/IRCClient/IRCClient.cpp index f4c7435764..56f0be4c71 100644 --- a/Applications/IRCClient/IRCClient.cpp +++ b/Applications/IRCClient/IRCClient.cpp @@ -258,14 +258,14 @@ void IRCClient::send_whois(const String& nick) void IRCClient::handle(const Message& msg) { #ifdef IRC_DEBUG - outf("IRCClient::execute: prefix='{}', command='{}', arguments={}", + outln("IRCClient::execute: prefix='{}', command='{}', arguments={}", msg.prefix, msg.command, msg.arguments.size()); size_t index = 0; for (auto& arg : msg.arguments) - outf(" [{}]: {}", index++, arg); + outln(" [{}]: {}", index++, arg); #endif auto numeric = msg.command.to_uint(); @@ -489,7 +489,7 @@ void IRCClient::handle_privmsg_or_notice(const Message& msg, PrivmsgOrNotice typ bool is_ctcp = has_ctcp_payload(msg.arguments[1]); #ifdef IRC_DEBUG - outf("handle_privmsg_or_notice: type='{}'{}, sender_nick='{}', target='{}'", + outln("handle_privmsg_or_notice: type='{}'{}, sender_nick='{}', target='{}'", type == PrivmsgOrNotice::Privmsg ? "privmsg" : "notice", is_ctcp ? " (ctcp)" : "", sender_nick, @@ -671,11 +671,11 @@ void IRCClient::handle_rpl_welcome(const Message& msg) auto channel_str = m_config->read_entry("Connection", "AutoJoinChannels", ""); if (channel_str.is_empty()) return; - dbgf("IRCClient: Channels to autojoin: {}", channel_str); + dbgln("IRCClient: Channels to autojoin: {}", channel_str); auto channels = channel_str.split(','); for (auto& channel : channels) { join_channel(channel); - dbgf("IRCClient: Auto joining channel: {}", channel); + dbgln("IRCClient: Auto joining channel: {}", channel); } } @@ -1153,7 +1153,7 @@ void IRCClient::send_ctcp_request(const StringView& peer, const StringView& payl void IRCClient::handle_ctcp_request(const StringView& peer, const StringView& payload) { - dbgf("handle_ctcp_request: {}", payload); + dbgln("handle_ctcp_request: {}", payload); if (payload == "VERSION") { auto version = ctcp_version_reply(); @@ -1187,5 +1187,5 @@ void IRCClient::handle_ctcp_request(const StringView& peer, const StringView& pa void IRCClient::handle_ctcp_response(const StringView& peer, const StringView& payload) { - dbgf("handle_ctcp_response({}): {}", peer, payload); + dbgln("handle_ctcp_response({}): {}", peer, payload); } diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp index 8199450f14..59a7c300ec 100644 --- a/DevTools/UserspaceEmulator/Emulator.cpp +++ b/DevTools/UserspaceEmulator/Emulator.cpp @@ -234,7 +234,7 @@ void Emulator::dump_backtrace() u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3) { #ifdef DEBUG_SPAM - dbgf("Syscall: {} ({:x})", Syscall::to_string((Syscall::Function)function), function); + dbgln("Syscall: {} ({:x})", Syscall::to_string((Syscall::Function)function), function); #endif switch (function) { case SC_chdir: @@ -379,7 +379,7 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3) case SC_fork: return virt$fork(); default: - warnf("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}", getpid(), Syscall::to_string((Syscall::Function)function), function); + warnln("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}", getpid(), Syscall::to_string((Syscall::Function)function), function); dump_backtrace(); TODO(); } @@ -950,7 +950,7 @@ int Emulator::virt$ioctl(int fd, unsigned request, FlatPtr arg) mmu().copy_from_vm(&termios, arg, sizeof(termios)); return syscall(SC_ioctl, fd, request, &termios); } - dbgf("Unsupported ioctl: {}", request); + dbgln("Unsupported ioctl: {}", request); dump_backtrace(); TODO(); } @@ -983,10 +983,10 @@ int Emulator::virt$execve(FlatPtr params_addr) copy_string_list(arguments, params.arguments); copy_string_list(environment, params.environment); - warnf("\n=={}== \033[33;1mSyscall:\033[0m execve", getpid()); - warnf("=={}== @ {}", getpid(), path); + warnln("\n=={}== \033[33;1mSyscall:\033[0m execve", getpid()); + warnln("=={}== @ {}", getpid(), path); for (auto& argument : arguments) - warnf("=={}== - {}", getpid(), argument); + warnln("=={}== - {}", getpid(), argument); Vector argv; Vector envp; @@ -1199,7 +1199,7 @@ void Emulator::dispatch_one_pending_signal() auto action = default_signal_action(signum); if (action == DefaultSignalAction::Ignore) return; - warnf("\n=={}== Got signal {} ({}), no handler registered", getpid(), signum, strsignal(signum)); + warnln("\n=={}== Got signal {} ({}), no handler registered", getpid(), signum, strsignal(signum)); m_shutdown = true; return; } @@ -1209,7 +1209,7 @@ void Emulator::dispatch_one_pending_signal() return; } - warnf("\n=={}== Got signal {} ({}), handler at {:p}", getpid(), signum, strsignal(signum), handler.handler); + warnln("\n=={}== Got signal {} ({}), handler at {:p}", getpid(), signum, strsignal(signum), handler.handler); auto old_esp = m_cpu.esp(); diff --git a/DevTools/UserspaceEmulator/MallocTracer.cpp b/DevTools/UserspaceEmulator/MallocTracer.cpp index e9a7218924..2e145b27ed 100644 --- a/DevTools/UserspaceEmulator/MallocTracer.cpp +++ b/DevTools/UserspaceEmulator/MallocTracer.cpp @@ -70,8 +70,8 @@ void MallocTracer::target_did_free(Badge, FlatPtr address) for (auto& mallocation : m_mallocations) { if (mallocation.address == address) { if (mallocation.freed) { - warnf("\n=={}== \033[31;1mDouble free()\033[0m, {:p}", getpid(), address); - warnf("=={}== Address {} has already been passed to free()", getpid(), address); + warnln("\n=={}== \033[31;1mDouble free()\033[0m, {:p}", getpid(), address); + warnln("=={}== Address {} has already been passed to free()", getpid(), address); Emulator::the().dump_backtrace(); } else { mallocation.freed = true; @@ -81,8 +81,8 @@ void MallocTracer::target_did_free(Badge, FlatPtr address) } } - warnf("\n=={}== \033[31;1mInvalid free()\033[0m, {:p}", getpid(), address); - warnf("=={}== Address {} has never been returned by malloc()", getpid(), address); + warnln("\n=={}== \033[31;1mInvalid free()\033[0m, {:p}", getpid(), address); + warnln("=={}== Address {} has never been returned by malloc()", getpid(), address); Emulator::the().dump_backtrace(); } @@ -118,11 +118,11 @@ void MallocTracer::audit_read(FlatPtr address, size_t size) auto* mallocation = find_mallocation(address); if (!mallocation) { - warnf("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address); + warnln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address); Emulator::the().dump_backtrace(); if ((mallocation = find_mallocation_before(address))) { size_t offset_into_mallocation = address - mallocation->address; - warnf("=={}== Address is {} byte(s) after block of size {}, allocated at:", getpid(), offset_into_mallocation - mallocation->size, mallocation->size); + warnln("=={}== Address is {} byte(s) after block of size {}, allocated at:", getpid(), offset_into_mallocation - mallocation->size, mallocation->size); Emulator::the().dump_backtrace(mallocation->malloc_backtrace); } return; @@ -131,11 +131,11 @@ void MallocTracer::audit_read(FlatPtr address, size_t size) size_t offset_into_mallocation = address - mallocation->address; if (mallocation->freed) { - warnf("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address); + warnln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address); Emulator::the().dump_backtrace(); - warnf("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size); + warnln("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size); Emulator::the().dump_backtrace(mallocation->malloc_backtrace); - warnf("=={}== Later freed at:", getpid()); + warnln("=={}== Later freed at:", getpid()); Emulator::the().dump_backtrace(mallocation->free_backtrace); return; } @@ -151,11 +151,11 @@ void MallocTracer::audit_write(FlatPtr address, size_t size) auto* mallocation = find_mallocation(address); if (!mallocation) { - warnf("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address); + warnln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address); Emulator::the().dump_backtrace(); if ((mallocation = find_mallocation_before(address))) { size_t offset_into_mallocation = address - mallocation->address; - warnf("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size); + warnln("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size); Emulator::the().dump_backtrace(mallocation->malloc_backtrace); } return; @@ -164,11 +164,11 @@ void MallocTracer::audit_write(FlatPtr address, size_t size) size_t offset_into_mallocation = address - mallocation->address; if (mallocation->freed) { - warnf("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address); + warnln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address); Emulator::the().dump_backtrace(); - warnf("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size); + warnln("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size); Emulator::the().dump_backtrace(mallocation->malloc_backtrace); - warnf("=={}== Later freed at:", getpid()); + warnln("=={}== Later freed at:", getpid()); Emulator::the().dump_backtrace(mallocation->free_backtrace); return; } @@ -189,7 +189,7 @@ bool MallocTracer::is_reachable(const Mallocation& mallocation) const auto value = Emulator::the().mmu().read32({ 0x20, other_mallocation.address + i * sizeof(u32) }); if (value.value() == mallocation.address && !value.is_uninitialized()) { #ifdef REACHABLE_DEBUG - warnf("mallocation {:p} is reachable from other mallocation {:p}", mallocation.address, other_mallocation.address); + warnln("mallocation {:p} is reachable from other mallocation {:p}", mallocation.address, other_mallocation.address); #endif return true; } @@ -214,7 +214,7 @@ bool MallocTracer::is_reachable(const Mallocation& mallocation) const auto value = region.read32(i * sizeof(u32)); if (value.value() == mallocation.address && !value.is_uninitialized()) { #ifdef REACHABLE_DEBUG - warnf("mallocation {:p} is reachable from region {:p}-{:p}", mallocation.address, region.base(), region.end() - 1); + warnln("mallocation {:p} is reachable from region {:p}-{:p}", mallocation.address, region.base(), region.end() - 1); #endif reachable = true; return IterationDecision::Break; @@ -238,14 +238,14 @@ void MallocTracer::dump_leak_report() continue; ++leaks_found; bytes_leaked += mallocation.size; - warnf("\n=={}== \033[31;1mLeak\033[0m, {}-byte allocation at address {:p}", getpid(), mallocation.size, mallocation.address); + warnln("\n=={}== \033[31;1mLeak\033[0m, {}-byte allocation at address {:p}", getpid(), mallocation.size, mallocation.address); Emulator::the().dump_backtrace(mallocation.malloc_backtrace); } if (!leaks_found) - warnf("\n=={}== \033[32;1mNo leaks found!\033[0m", getpid()); + warnln("\n=={}== \033[32;1mNo leaks found!\033[0m", getpid()); else - warnf("\n=={}== \033[31;1m{} leak(s) found: {} byte(s) leaked\033[0m", getpid(), leaks_found, bytes_leaked); + warnln("\n=={}== \033[31;1m{} leak(s) found: {} byte(s) leaked\033[0m", getpid(), leaks_found, bytes_leaked); } } diff --git a/DevTools/UserspaceEmulator/MmapRegion.cpp b/DevTools/UserspaceEmulator/MmapRegion.cpp index 92b1950c1d..b3123183d8 100644 --- a/DevTools/UserspaceEmulator/MmapRegion.cpp +++ b/DevTools/UserspaceEmulator/MmapRegion.cpp @@ -68,7 +68,7 @@ MmapRegion::~MmapRegion() ValueWithShadow MmapRegion::read8(FlatPtr offset) { if (!is_readable()) { - warnf("8-bit read from unreadable MmapRegion @ {:p}", base() + offset); + warnln("8-bit read from unreadable MmapRegion @ {:p}", base() + offset); Emulator::the().dump_backtrace(); TODO(); } @@ -85,7 +85,7 @@ ValueWithShadow MmapRegion::read8(FlatPtr offset) ValueWithShadow MmapRegion::read16(u32 offset) { if (!is_readable()) { - warnf("16-bit read from unreadable MmapRegion @ {:p}", base() + offset); + warnln("16-bit read from unreadable MmapRegion @ {:p}", base() + offset); Emulator::the().dump_backtrace(); TODO(); } @@ -102,7 +102,7 @@ ValueWithShadow MmapRegion::read16(u32 offset) ValueWithShadow MmapRegion::read32(u32 offset) { if (!is_readable()) { - warnf("32-bit read from unreadable MmapRegion @ {:p}", base() + offset); + warnln("32-bit read from unreadable MmapRegion @ {:p}", base() + offset); Emulator::the().dump_backtrace(); TODO(); } @@ -119,7 +119,7 @@ ValueWithShadow MmapRegion::read32(u32 offset) ValueWithShadow MmapRegion::read64(u32 offset) { if (!is_readable()) { - warnf("64-bit read from unreadable MmapRegion @ {:p}", base() + offset); + warnln("64-bit read from unreadable MmapRegion @ {:p}", base() + offset); Emulator::the().dump_backtrace(); TODO(); } @@ -136,7 +136,7 @@ ValueWithShadow MmapRegion::read64(u32 offset) void MmapRegion::write8(u32 offset, ValueWithShadow value) { if (!is_writable()) { - warnf("8-bit write from unwritable MmapRegion @ {:p}", base() + offset); + warnln("8-bit write from unwritable MmapRegion @ {:p}", base() + offset); Emulator::the().dump_backtrace(); TODO(); } @@ -154,7 +154,7 @@ void MmapRegion::write8(u32 offset, ValueWithShadow value) void MmapRegion::write16(u32 offset, ValueWithShadow value) { if (!is_writable()) { - warnf("16-bit write from unwritable MmapRegion @ {:p}", base() + offset); + warnln("16-bit write from unwritable MmapRegion @ {:p}", base() + offset); Emulator::the().dump_backtrace(); TODO(); } @@ -172,7 +172,7 @@ void MmapRegion::write16(u32 offset, ValueWithShadow value) void MmapRegion::write32(u32 offset, ValueWithShadow value) { if (!is_writable()) { - warnf("32-bit write from unwritable MmapRegion @ {:p}", base() + offset); + warnln("32-bit write from unwritable MmapRegion @ {:p}", base() + offset); Emulator::the().dump_backtrace(); TODO(); } @@ -191,7 +191,7 @@ void MmapRegion::write32(u32 offset, ValueWithShadow value) void MmapRegion::write64(u32 offset, ValueWithShadow value) { if (!is_writable()) { - warnf("64-bit write from unwritable MmapRegion @ {:p}", base() + offset); + warnln("64-bit write from unwritable MmapRegion @ {:p}", base() + offset); Emulator::the().dump_backtrace(); TODO(); } diff --git a/DevTools/UserspaceEmulator/SoftCPU.cpp b/DevTools/UserspaceEmulator/SoftCPU.cpp index cb73d98f66..bc7352729c 100644 --- a/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -60,7 +60,7 @@ template void warn_if_uninitialized(T value_with_shadow, const char* message) { if (value_with_shadow.is_uninitialized()) { - dbgf("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message); + dbgln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message); Emulator::the().dump_backtrace(); } } @@ -68,7 +68,7 @@ void warn_if_uninitialized(T value_with_shadow, const char* message) void SoftCPU::warn_if_flags_tainted(const char* message) const { if (m_flags_tainted) { - warnf("\n=={}== \033[31;1mConditional depends on uninitialized data\033[0m ({})\n", getpid(), message); + warnln("\n=={}== \033[31;1mConditional depends on uninitialized data\033[0m ({})\n", getpid(), message); Emulator::the().dump_backtrace(); } } @@ -96,9 +96,9 @@ SoftCPU::SoftCPU(Emulator& emulator) void SoftCPU::dump() const { - outf(" eax={:08x} ebx={:08x} ecx={:08x} edx={:08x} ebp={:08x} esp={:08x} esi={:08x} edi={:08x} o={:d} s={:d} z={:d} a={:d} p={:d} c={:d}", + outln(" eax={:08x} ebx={:08x} ecx={:08x} edx={:08x} ebp={:08x} esp={:08x} esi={:08x} edi={:08x} o={:d} s={:d} z={:d} a={:d} p={:d} c={:d}", eax(), ebx(), ecx(), edx(), ebp(), esp(), esi(), edi(), of(), sf(), zf(), af(), pf(), cf()); - outf("#eax={:08x} #ebx={:08x} #ecx={:08x} #edx={:08x} #ebp={:08x} #esp={:08x} #esi={:08x} #edi={:08x} #f={}", + outln("#eax={:08x} #ebx={:08x} #ecx={:08x} #edx={:08x} #ebp={:08x} #esp={:08x} #esi={:08x} #edi={:08x} #f={}", eax().shadow(), ebx().shadow(), ecx().shadow(), edx().shadow(), m_flags_tainted); fflush(stdout); } @@ -130,7 +130,7 @@ ValueWithShadow SoftCPU::read_memory8(X86::LogicalAddress address) ASSERT(address.selector() == 0x18 || address.selector() == 0x20 || address.selector() == 0x28); auto value = m_emulator.mmu().read8(address); #ifdef MEMORY_DEBUG - outf("\033[36;1mread_memory8: @{:04x}:{:08x} -> {:02x} ({:02x})\033[0m", address.selector(), address.offset(), value, value.shadow()); + outln("\033[36;1mread_memory8: @{:04x}:{:08x} -> {:02x} ({:02x})\033[0m", address.selector(), address.offset(), value, value.shadow()); #endif return value; } @@ -140,7 +140,7 @@ ValueWithShadow SoftCPU::read_memory16(X86::LogicalAddress address) ASSERT(address.selector() == 0x18 || address.selector() == 0x20 || address.selector() == 0x28); auto value = m_emulator.mmu().read16(address); #ifdef MEMORY_DEBUG - outf("\033[36;1mread_memory16: @{:04x}:{:08x} -> {:04x} ({:04x})\033[0m", address.selector(), address.offset(), value, value.shadow()); + outln("\033[36;1mread_memory16: @{:04x}:{:08x} -> {:04x} ({:04x})\033[0m", address.selector(), address.offset(), value, value.shadow()); #endif return value; } @@ -150,7 +150,7 @@ ValueWithShadow SoftCPU::read_memory32(X86::LogicalAddress address) ASSERT(address.selector() == 0x18 || address.selector() == 0x20 || address.selector() == 0x28); auto value = m_emulator.mmu().read32(address); #ifdef MEMORY_DEBUG - outf("\033[36;1mread_memory32: @{:04x}:{:08x} -> {:08x} ({:08x})\033[0m", address.selector(), address.offset(), value, value.shadow()); + outln("\033[36;1mread_memory32: @{:04x}:{:08x} -> {:08x} ({:08x})\033[0m", address.selector(), address.offset(), value, value.shadow()); #endif return value; } @@ -160,7 +160,7 @@ ValueWithShadow SoftCPU::read_memory64(X86::LogicalAddress address) ASSERT(address.selector() == 0x18 || address.selector() == 0x20 || address.selector() == 0x28); auto value = m_emulator.mmu().read64(address); #ifdef MEMORY_DEBUG - outf("\033[36;1mread_memory64: @{:04x}:{:08x} -> {:016x} ({:016x})\033[0m", address.selector(), address.offset(), value, value.shadow()); + outln("\033[36;1mread_memory64: @{:04x}:{:08x} -> {:016x} ({:016x})\033[0m", address.selector(), address.offset(), value, value.shadow()); #endif return value; } @@ -169,7 +169,7 @@ void SoftCPU::write_memory8(X86::LogicalAddress address, ValueWithShadow val { ASSERT(address.selector() == 0x20 || address.selector() == 0x28); #ifdef MEMORY_DEBUG - outf("\033[36;1mwrite_memory8: @{:04x}:{:08x} <- {:02x} ({:02x})\033[0m", address.selector(), address.offset(), value, value.shadow()); + outln("\033[36;1mwrite_memory8: @{:04x}:{:08x} <- {:02x} ({:02x})\033[0m", address.selector(), address.offset(), value, value.shadow()); #endif m_emulator.mmu().write8(address, value); } @@ -178,7 +178,7 @@ void SoftCPU::write_memory16(X86::LogicalAddress address, ValueWithShadow v { ASSERT(address.selector() == 0x20 || address.selector() == 0x28); #ifdef MEMORY_DEBUG - outf("\033[36;1mwrite_memory16: @{:04x}:{:08x} <- {:04x} ({:04x})\033[0m", address.selector(), address.offset(), value, value.shadow()); + outln("\033[36;1mwrite_memory16: @{:04x}:{:08x} <- {:04x} ({:04x})\033[0m", address.selector(), address.offset(), value, value.shadow()); #endif m_emulator.mmu().write16(address, value); } @@ -187,7 +187,7 @@ void SoftCPU::write_memory32(X86::LogicalAddress address, ValueWithShadow v { ASSERT(address.selector() == 0x20 || address.selector() == 0x28); #ifdef MEMORY_DEBUG - outf("\033[36;1mwrite_memory32: @{:04x}:{:08x} <- {:08x} ({:08x})\033[0m", address.selector(), address.offset(), value, value.shadow()); + outln("\033[36;1mwrite_memory32: @{:04x}:{:08x} <- {:08x} ({:08x})\033[0m", address.selector(), address.offset(), value, value.shadow()); #endif m_emulator.mmu().write32(address, value); } @@ -196,7 +196,7 @@ void SoftCPU::write_memory64(X86::LogicalAddress address, ValueWithShadow v { ASSERT(address.selector() == 0x20 || address.selector() == 0x28); #ifdef MEMORY_DEBUG - outf("\033[36;1mwrite_memory64: @{:04x}:{:08x} <- {:016x} ({:016x})\033[0m", address.selector(), address.offset(), value, value.shadow()); + outln("\033[36;1mwrite_memory64: @{:04x}:{:08x} <- {:016x} ({:016x})\033[0m", address.selector(), address.offset(), value, value.shadow()); #endif m_emulator.mmu().write64(address, value); } diff --git a/DevTools/UserspaceEmulator/SoftMMU.cpp b/DevTools/UserspaceEmulator/SoftMMU.cpp index 13fb2b7d75..86ea4e8fa1 100644 --- a/DevTools/UserspaceEmulator/SoftMMU.cpp +++ b/DevTools/UserspaceEmulator/SoftMMU.cpp @@ -68,7 +68,7 @@ ValueWithShadow SoftMMU::read8(X86::LogicalAddress address) { auto* region = find_region(address); if (!region) { - warnf("SoftMMU::read8: No region for @ {:p}", address.offset()); + warnln("SoftMMU::read8: No region for @ {:p}", address.offset()); TODO(); } @@ -79,7 +79,7 @@ ValueWithShadow SoftMMU::read16(X86::LogicalAddress address) { auto* region = find_region(address); if (!region) { - warnf("SoftMMU::read16: No region for @ {:p}", address.offset()); + warnln("SoftMMU::read16: No region for @ {:p}", address.offset()); TODO(); } @@ -90,7 +90,7 @@ ValueWithShadow SoftMMU::read32(X86::LogicalAddress address) { auto* region = find_region(address); if (!region) { - warnf("SoftMMU::read32: No region for @ {:p}", address.offset()); + warnln("SoftMMU::read32: No region for @ {:p}", address.offset()); TODO(); } @@ -101,7 +101,7 @@ ValueWithShadow SoftMMU::read64(X86::LogicalAddress address) { auto* region = find_region(address); if (!region) { - warnf("SoftMMU::read64: No region for @ {:p}", address.offset()); + warnln("SoftMMU::read64: No region for @ {:p}", address.offset()); TODO(); } @@ -112,7 +112,7 @@ void SoftMMU::write8(X86::LogicalAddress address, ValueWithShadow value) { auto* region = find_region(address); if (!region) { - warnf("SoftMMU::write8: No region for @ {:p}", address.offset()); + warnln("SoftMMU::write8: No region for @ {:p}", address.offset()); TODO(); } @@ -123,7 +123,7 @@ void SoftMMU::write16(X86::LogicalAddress address, ValueWithShadow value) { auto* region = find_region(address); if (!region) { - warnf("SoftMMU::write16: No region for @ {:p}", address.offset()); + warnln("SoftMMU::write16: No region for @ {:p}", address.offset()); TODO(); } @@ -134,7 +134,7 @@ void SoftMMU::write32(X86::LogicalAddress address, ValueWithShadow value) { auto* region = find_region(address); if (!region) { - warnf("SoftMMU::write32: No region for @ {:p}", address.offset()); + warnln("SoftMMU::write32: No region for @ {:p}", address.offset()); TODO(); } @@ -145,7 +145,7 @@ void SoftMMU::write64(X86::LogicalAddress address, ValueWithShadow value) { auto* region = find_region(address); if (!region) { - warnf("SoftMMU::write64: No region for @ {:p}", address.offset()); + warnln("SoftMMU::write64: No region for @ {:p}", address.offset()); TODO(); } diff --git a/Services/TelnetServer/main.cpp b/Services/TelnetServer/main.cpp index 3e77a8e345..d0bbbaa666 100644 --- a/Services/TelnetServer/main.cpp +++ b/Services/TelnetServer/main.cpp @@ -126,7 +126,7 @@ int main(int argc, char** argv) } if (!server->listen({}, port)) { - warnf("Listening on 0.0.0.0:{} failed", port); + warnln("Listening on 0.0.0.0:{} failed", port); exit(1); } diff --git a/Services/WebServer/main.cpp b/Services/WebServer/main.cpp index 22e28f9840..8c326c84a8 100644 --- a/Services/WebServer/main.cpp +++ b/Services/WebServer/main.cpp @@ -74,11 +74,11 @@ int main(int argc, char** argv) }; if (!server->listen({}, port)) { - warnf("Failed to listen on 0.0.0.0:{}", port); + warnln("Failed to listen on 0.0.0.0:{}", port); return 1; } - outf("Listening on 0.0.0.0:{}", port); + outln("Listening on 0.0.0.0:{}", port); if (unveil("/res/icons", "r") < 0) { perror("unveil"); diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index d07ddbecc9..8f9cf8f330 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -1414,11 +1414,11 @@ void Shell::notify_child_event() int wstatus = 0; #ifdef SH_DEBUG - dbgf("waitpid({}) = ...", job.pid()); + dbgln("waitpid({}) = ...", job.pid()); #endif auto child_pid = waitpid(job.pid(), &wstatus, WNOHANG | WUNTRACED); #ifdef SH_DEBUG - dbgf("... = {} - {}", child_pid, wstatus); + dbgln("... = {} - {}", child_pid, wstatus); #endif if (child_pid < 0) { diff --git a/Shell/main.cpp b/Shell/main.cpp index 65c12da552..eb36de5c54 100644 --- a/Shell/main.cpp +++ b/Shell/main.cpp @@ -140,14 +140,14 @@ int main(int argc, char** argv) } } else if (sid != pid) { if (getpgid(pid) != pid) { - dbgf("We were already in a session with sid={} (we are {}), let's do some gymnastics", sid, pid); + dbgln("We were already in a session with sid={} (we are {}), let's do some gymnastics", sid, pid); if (setpgid(pid, sid) < 0) { auto strerr = strerror(errno); - dbgf("couldn't setpgid: {}", strerr); + dbgln("couldn't setpgid: {}", strerr); } if (setsid() < 0) { auto strerr = strerror(errno); - dbgf("couldn't setsid: {}", strerr); + dbgln("couldn't setsid: {}", strerr); } } } diff --git a/Userland/tar.cpp b/Userland/tar.cpp index 7a9bc3dd59..c9c5618a77 100644 --- a/Userland/tar.cpp +++ b/Userland/tar.cpp @@ -57,7 +57,7 @@ int main(int argc, char** argv) args_parser.parse(argc, argv); if (create + extract + list != 1) { - warnf("exactly one of -c, -x, and -t can be used"); + warnln("exactly one of -c, -x, and -t can be used"); return 1; } @@ -67,7 +67,7 @@ int main(int argc, char** argv) if (archive_file) { auto maybe_file = Core::File::open(archive_file, Core::IODevice::OpenMode::ReadOnly); if (maybe_file.is_error()) { - warnf("Core::File::open: {}", maybe_file.error()); + warnln("Core::File::open: {}", maybe_file.error()); return 1; } file = maybe_file.value();