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

Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)

Good-bye LogStream. Long live AK::Format!
This commit is contained in:
Andreas Kling 2021-03-12 17:29:37 +01:00
parent 423ed53396
commit ef1e5db1d0
209 changed files with 164 additions and 837 deletions

View file

@ -25,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Format.h>
#include <AK/StringView.h>
#include <Kernel/ACPI/Parser.h>
#include <Kernel/Arch/PC/BIOS.h>
@ -32,7 +33,6 @@
#include <Kernel/IO.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/StdLib.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/TypedMapping.h>
namespace Kernel {

View file

@ -243,7 +243,6 @@ set(AK_SOURCES
../AK/JsonParser.cpp
../AK/JsonValue.cpp
../AK/LexicalPath.cpp
../AK/LogStream.cpp
../AK/String.cpp
../AK/StringBuilder.cpp
../AK/StringImpl.cpp

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Format.h>
#include <AK/Singleton.h>
#include <AK/StringView.h>
#include <AK/Types.h>
@ -31,7 +32,6 @@
#include <Kernel/DMI.h>
#include <Kernel/StdLib.h>
#include <Kernel/VM/MappedROM.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/TypedMapping.h>
namespace Kernel {

View file

@ -25,6 +25,7 @@
*/
#include <AK/Checked.h>
#include <AK/Format.h>
#include <AK/Singleton.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/BXVGADevice.h>

View file

@ -72,12 +72,6 @@ private:
InodeIndex m_index { 0 };
};
inline const LogStream& operator<<(const LogStream& stream, const InodeIdentifier& value)
{
stream << value.fsid() << ':' << value.index().value();
return stream;
}
}
template<>

View file

@ -27,7 +27,6 @@
#pragma once
#include <AK/Assertions.h>
#include <AK/LogStream.h>
#include <AK/String.h>
#include <AK/Types.h>
#include <Kernel/Arch/i386/CPU.h>
@ -157,11 +156,6 @@ private:
u16 m_address { 0 };
};
inline const LogStream& operator<<(const LogStream& stream, IOAddress value)
{
return stream << "IO " << String::formatted("{:x}", value.get());
}
template<>
struct AK::Formatter<IOAddress> : AK::Formatter<FormatString> {
void format(FormatBuilder& builder, IOAddress value)

View file

@ -38,7 +38,6 @@
#include <AK/Assertions.h>
#include <AK/ByteBuffer.h>
#include <AK/LogStream.h>
#include <AK/Memory.h>
#include <AK/StringView.h>
#include <Kernel/VM/MemoryManager.h>
@ -175,9 +174,4 @@ private:
RefPtr<KBufferImpl> m_impl;
};
inline const LogStream& operator<<(const LogStream& stream, const KBuffer& value)
{
return stream << StringView(value.data(), value.size());
}
}

View file

@ -24,7 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/LogStream.h>
#include <AK/Format.h>
#include <Kernel/Modules/module_syms.h>
extern "C" const char module_name[] = "TestModule";

View file

@ -123,7 +123,6 @@ private:
};
static_assert(sizeof(IPv4Packet) == 20);
const LogStream& operator<<(const LogStream& stream, const IPv4Packet& packet);
inline NetworkOrdered<u16> internet_checksum(const void* ptr, size_t count)
{

View file

@ -27,7 +27,6 @@
#pragma once
#include <AK/Function.h>
#include <AK/LogStream.h>
#include <AK/String.h>
#include <AK/Types.h>
#include <AK/Vector.h>
@ -84,10 +83,7 @@ struct ID {
return vendor_id != other.vendor_id || device_id != other.device_id;
}
};
inline const LogStream& operator<<(const LogStream& stream, const ID value)
{
return stream << String::formatted("({:04x}:{:04x})", value.vendor_id, value.device_id);
}
struct Address {
public:
Address() = default;
@ -141,11 +137,6 @@ protected:
u8 m_function { 0 };
};
inline const LogStream& operator<<(const LogStream& stream, const Address value)
{
return stream << "PCI [" << String::formatted("{:04x}:{:02x}:{:02x}:{:02x}", value.seg(), value.bus(), value.device(), value.function()) << "]";
}
struct ChangeableAddress : public Address {
ChangeableAddress()
: Address(0)

View file

@ -26,7 +26,7 @@
#pragma once
#include <AK/LogStream.h>
#include <AK/Format.h>
#include <AK/Types.h>
class PhysicalAddress {
@ -61,11 +61,6 @@ private:
FlatPtr m_address { 0 };
};
inline const LogStream& operator<<(const LogStream& stream, PhysicalAddress value)
{
return stream << 'P' << value.as_ptr();
}
template<>
struct AK::Formatter<PhysicalAddress> : AK::Formatter<FormatString> {
void format(FormatBuilder& builder, PhysicalAddress value)

View file

@ -719,11 +719,6 @@ inline ProcessID Thread::pid() const
return m_process->pid();
}
inline const LogStream& operator<<(const LogStream& stream, const Process& process)
{
return stream << process.name() << '(' << process.pid().value() << ')';
}
#define REQUIRE_NO_PROMISES \
do { \
if (Process::current()->has_promises()) { \

View file

@ -25,7 +25,6 @@
*/
#include <AK/Assertions.h>
#include <AK/LogStream.h>
#include <AK/Time.h>
#include <Kernel/CMOS.h>
#include <Kernel/RTC.h>

View file

@ -1027,11 +1027,6 @@ KResult Thread::make_thread_specific_region(Badge<Process>)
return KSuccess;
}
const LogStream& operator<<(const LogStream& stream, const Thread& value)
{
return stream << value.process().name() << "(" << value.pid().value() << ":" << value.tid().value() << ")";
}
RefPtr<Thread> Thread::from_tid(ThreadID tid)
{
RefPtr<Thread> found_thread;

View file

@ -1298,8 +1298,6 @@ inline IterationDecision Thread::for_each_in_state(State state, Callback callbac
return IterationDecision::Continue;
}
const LogStream& operator<<(const LogStream&, const Thread&);
}
template<>

View file

@ -475,7 +475,7 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
dbgln_if(PAGE_FAULT_DEBUG, "MM: CPU[{}] handle_page_fault({:#04x}) at {}", Processor::id(), fault.code(), fault.vaddr());
auto* region = find_region_from_vaddr(fault.vaddr());
if (!region) {
dmesgln("CPU[{}] NP(error) fault at invalid address {}", Processor::id(), fault.vaddr());
Process::current()->space().dump_regions();
return PageFaultResponse::ShouldCrash;
}

View file

@ -26,7 +26,7 @@
#pragma once
#include <AK/LogStream.h>
#include <AK/Format.h>
#include <AK/Types.h>
class VirtualAddress {
@ -71,11 +71,6 @@ inline VirtualAddress operator-(const VirtualAddress& a, const VirtualAddress& b
return VirtualAddress(a.get() - b.get());
}
inline const LogStream& operator<<(const LogStream& stream, VirtualAddress value)
{
return stream << 'V' << value.as_ptr();
}
template<>
struct AK::Formatter<VirtualAddress> : AK::Formatter<FormatString> {
void format(FormatBuilder& builder, const VirtualAddress& value)

View file

@ -72,6 +72,7 @@
#include <Kernel/Tasks/SyncTask.h>
#include <Kernel/Time/TimeManagement.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/kstdio.h>
// Defined in the linker script
typedef void (*ctor_func_t)();
@ -337,7 +338,7 @@ void init_stage2(void*)
UNMAP_AFTER_INIT void setup_serial_debug()
{
// serial_debug will output all the klog() and dbgln() data to COM1 at
// serial_debug will output all the dbgln() data to COM1 at
// 8-N-1 57600 baud. this is particularly useful for debugging the boot
// process on live hardware.
if (StringView(kernel_cmdline).contains("serial_debug")) {

View file

@ -36,7 +36,7 @@
static bool serial_debug;
// A recursive spinlock allows us to keep writing in the case where a
// page fault happens in the middle of a dbgln(), klog(), etc
// page fault happens in the middle of a dbgln(), etc
static RecursiveSpinLock s_log_lock;
void set_serial_debug(bool on_or_off)
@ -148,22 +148,20 @@ static void debugger_out(char ch)
IO::out8(0xe9, ch);
}
extern "C" int dbgputstr(const char* characters, int length)
extern "C" void dbgputstr(const char* characters, size_t length)
{
if (!characters)
return 0;
return;
ScopedSpinLock lock(s_log_lock);
for (int i = 0; i < length; ++i)
for (size_t i = 0; i < length; ++i)
debugger_out(characters[i]);
return 0;
}
extern "C" int kernelputstr(const char* characters, int length)
extern "C" void kernelputstr(const char* characters, size_t length)
{
if (!characters)
return 0;
return;
ScopedSpinLock lock(s_log_lock);
for (int i = 0; i < length; ++i)
for (size_t i = 0; i < length; ++i)
console_out(characters[i]);
return 0;
}

View file

@ -29,8 +29,8 @@
#include <AK/Types.h>
extern "C" {
int dbgputstr(const char*, int);
int kernelputstr(const char*, int);
void dbgputstr(const char*, size_t);
void kernelputstr(const char*, size_t);
int snprintf(char* buf, size_t, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
void set_serial_debug(bool on_or_off);
int get_serial_debug();