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

Kernel: Unbreak building with extra debug macros, part 2

This commit is contained in:
Ben Wiederhake 2020-08-27 00:58:09 +02:00 committed by Andreas Kling
parent eac3bbdcee
commit 081bb29626
9 changed files with 28 additions and 18 deletions

View file

@ -27,7 +27,9 @@
#include <AK/ByteBuffer.h> #include <AK/ByteBuffer.h>
#include <Kernel/Devices/MBRPartitionTable.h> #include <Kernel/Devices/MBRPartitionTable.h>
#define MBR_DEBUG #ifndef MBR_DEBUG
# define MBR_DEBUG
#endif
namespace Kernel { namespace Kernel {

View file

@ -60,6 +60,8 @@
#include <Kernel/VM/PurgeableVMObject.h> #include <Kernel/VM/PurgeableVMObject.h>
#include <LibC/errno_numbers.h> #include <LibC/errno_numbers.h>
//#define PROCFS_DEBUG
namespace Kernel { namespace Kernel {
enum ProcParentDirectory { enum ProcParentDirectory {
@ -1104,7 +1106,7 @@ InodeMetadata ProcFSInode::metadata() const
auto proc_file_type = to_proc_file_type(identifier()); auto proc_file_type = to_proc_file_type(identifier());
#ifdef PROCFS_DEBUG #ifdef PROCFS_DEBUG
dbg() << " -> pid: " << pid << ", fi: " << proc_file_type << ", pdi: " << proc_parent_directory; dbg() << " -> pid: " << to_pid(identifier()).value() << ", fi: " << proc_file_type << ", pdi: " << proc_parent_directory;
#endif #endif
if (is_process_related_file(identifier())) { if (is_process_related_file(identifier())) {

View file

@ -24,8 +24,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <Kernel/Net/RTL8139NetworkAdapter.h>
#include <Kernel/IO.h> #include <Kernel/IO.h>
#include <Kernel/Net/RTL8139NetworkAdapter.h>
//#define RTL8139_DEBUG //#define RTL8139_DEBUG
@ -293,7 +293,7 @@ void RTL8139NetworkAdapter::read_mac_address()
void RTL8139NetworkAdapter::send_raw(ReadonlyBytes payload) void RTL8139NetworkAdapter::send_raw(ReadonlyBytes payload)
{ {
#ifdef RTL8139_DEBUG #ifdef RTL8139_DEBUG
klog() << "RTL8139NetworkAdapter::send_raw length=" << length; klog() << "RTL8139NetworkAdapter::send_raw length=" << payload.size();
#endif #endif
if (payload.size() > PACKET_SIZE_MAX) { if (payload.size() > PACKET_SIZE_MAX) {
@ -317,7 +317,7 @@ void RTL8139NetworkAdapter::send_raw(ReadonlyBytes payload)
return; return;
} else { } else {
#ifdef RTL8139_DEBUG #ifdef RTL8139_DEBUG
klog() << "RTL8139NetworkAdapter: chose buffer " << hw_buffer << " @ " << PhysicalAddress(m_tx_buffer_addr[hw_buffer]); klog() << "RTL8139NetworkAdapter: chose buffer " << hw_buffer << " @ " << PhysicalAddress(m_tx_buffers[hw_buffer]);
#endif #endif
m_tx_next_buffer = (hw_buffer + 1) % 4; m_tx_next_buffer = (hw_buffer + 1) % 4;
} }

View file

@ -79,9 +79,10 @@
#include <LibELF/Validation.h> #include <LibELF/Validation.h>
#include <LibKeyboard/CharacterMapData.h> #include <LibKeyboard/CharacterMapData.h>
//#define PROCESS_DEBUG
//#define DEBUG_POLL_SELECT
//#define DEBUG_IO //#define DEBUG_IO
//#define DEBUG_POLL_SELECT
//#define MM_DEBUG
//#define PROCESS_DEBUG
//#define SIGNAL_DEBUG //#define SIGNAL_DEBUG
namespace Kernel { namespace Kernel {
@ -367,12 +368,12 @@ Process::Process(Thread*& first_thread, const String& name, uid_t uid, gid_t gid
, m_ppid(ppid) , m_ppid(ppid)
{ {
#ifdef PROCESS_DEBUG #ifdef PROCESS_DEBUG
dbg() << "Created new process " << m_name << "(" << m_pid << ")"; dbg() << "Created new process " << m_name << "(" << m_pid.value() << ")";
#endif #endif
m_page_directory = PageDirectory::create_for_userspace(*this, fork_parent ? &fork_parent->page_directory().range_allocator() : nullptr); m_page_directory = PageDirectory::create_for_userspace(*this, fork_parent ? &fork_parent->page_directory().range_allocator() : nullptr);
#ifdef MM_DEBUG #ifdef MM_DEBUG
dbg() << "Process " << pid() << " ctor: PD=" << m_page_directory.ptr() << " created"; dbg() << "Process " << pid().value() << " ctor: PD=" << m_page_directory.ptr() << " created";
#endif #endif
if (fork_parent) { if (fork_parent) {

View file

@ -28,6 +28,8 @@
#include <Kernel/Process.h> #include <Kernel/Process.h>
#include <Kernel/SharedBuffer.h> #include <Kernel/SharedBuffer.h>
//#define SHARED_BUFFER_DEBUG
namespace Kernel { namespace Kernel {
static AK::Singleton<Lockable<HashMap<int, NonnullOwnPtr<SharedBuffer>>>> s_map; static AK::Singleton<Lockable<HashMap<int, NonnullOwnPtr<SharedBuffer>>>> s_map;
@ -129,11 +131,11 @@ void SharedBuffer::deref_for_process(Process& process)
m_total_refs--; m_total_refs--;
if (ref.count == 0) { if (ref.count == 0) {
#ifdef SHARED_BUFFER_DEBUG #ifdef SHARED_BUFFER_DEBUG
dbg() << "Releasing shared buffer reference on " << m_shbuf_id << " of size " << size() << " by PID " << process.pid(); dbg() << "Releasing shared buffer reference on " << m_shbuf_id << " of size " << size() << " by PID " << process.pid().value();
#endif #endif
process.deallocate_region(*ref.region); process.deallocate_region(*ref.region);
#ifdef SHARED_BUFFER_DEBUG #ifdef SHARED_BUFFER_DEBUG
dbg() << "Released shared buffer reference on " << m_shbuf_id << " of size " << size() << " by PID " << process.pid(); dbg() << "Released shared buffer reference on " << m_shbuf_id << " of size " << size() << " by PID " << process.pid().value();
#endif #endif
sanity_check("deref_for_process"); sanity_check("deref_for_process");
destroy_if_unused(); destroy_if_unused();
@ -153,12 +155,12 @@ void SharedBuffer::disown(ProcessID pid)
auto& ref = m_refs[i]; auto& ref = m_refs[i];
if (ref.pid == pid) { if (ref.pid == pid) {
#ifdef SHARED_BUFFER_DEBUG #ifdef SHARED_BUFFER_DEBUG
dbg() << "Disowning shared buffer " << m_shbuf_id << " of size " << size() << " by PID " << pid; dbg() << "Disowning shared buffer " << m_shbuf_id << " of size " << size() << " by PID " << pid.value();
#endif #endif
m_total_refs -= ref.count; m_total_refs -= ref.count;
m_refs.unstable_take(i); m_refs.unstable_take(i);
#ifdef SHARED_BUFFER_DEBUG #ifdef SHARED_BUFFER_DEBUG
dbg() << "Disowned shared buffer " << m_shbuf_id << " of size " << size() << " by PID " << pid; dbg() << "Disowned shared buffer " << m_shbuf_id << " of size " << size() << " by PID " << pid.value();
#endif #endif
destroy_if_unused(); destroy_if_unused();
return; return;

View file

@ -40,6 +40,7 @@
#include <LibELF/Validation.h> #include <LibELF/Validation.h>
//#define EXEC_DEBUG //#define EXEC_DEBUG
//#define MM_DEBUG
namespace Kernel { namespace Kernel {
@ -97,7 +98,7 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
} }
#ifdef MM_DEBUG #ifdef MM_DEBUG
dbg() << "Process " << pid() << " exec: PD=" << m_page_directory.ptr() << " created"; dbg() << "Process " << pid().value() << " exec: PD=" << m_page_directory.ptr() << " created";
#endif #endif
InodeMetadata loader_metadata; InodeMetadata loader_metadata;

View file

@ -26,6 +26,8 @@
#include <Kernel/Process.h> #include <Kernel/Process.h>
//#define PROCESS_DEBUG
namespace Kernel { namespace Kernel {
KResultOr<siginfo_t> Process::do_waitid(idtype_t idtype, int id, int options) KResultOr<siginfo_t> Process::do_waitid(idtype_t idtype, int id, int options)
@ -109,7 +111,7 @@ pid_t Process::sys$waitid(Userspace<const Syscall::SC_waitid_params*> user_param
return -EFAULT; return -EFAULT;
#ifdef PROCESS_DEBUG #ifdef PROCESS_DEBUG
dbg() << "sys$waitid(" << params.idtype << ", " << params.id << ", " << params.infop << ", " << params.options << ")"; dbg() << "sys$waitid(" << params.idtype << ", " << params.id << ", " << params.infop.ptr() << ", " << params.options << ")";
#endif #endif
auto siginfo_or_error = do_waitid(static_cast<idtype_t>(params.idtype), params.id, params.options); auto siginfo_or_error = do_waitid(static_cast<idtype_t>(params.idtype), params.id, params.options);

View file

@ -77,7 +77,7 @@ Vector<Range, 2> Range::carve(const Range& taken)
parts.append({ taken.end(), end().get() - taken.end().get() }); parts.append({ taken.end(), end().get() - taken.end().get() });
#ifdef VRA_DEBUG #ifdef VRA_DEBUG
dbg() << "VRA: carve: take " << String::format("%x", taken.base().get()) << "-" << String::format("%x", taken.end().get() - 1) << " from " << String::format("%x", base().get()) << "-" << String::format("%x", end().get() - 1); dbg() << "VRA: carve: take " << String::format("%x", taken.base().get()) << "-" << String::format("%x", taken.end().get() - 1) << " from " << String::format("%x", base().get()) << "-" << String::format("%x", end().get() - 1);
for (int i = 0; i < parts.size(); ++i) for (size_t i = 0; i < parts.size(); ++i)
dbg() << " " << String::format("%x", parts[i].base().get()) << "-" << String::format("%x", parts[i].end().get() - 1); dbg() << " " << String::format("%x", parts[i].base().get()) << "-" << String::format("%x", parts[i].end().get() - 1);
#endif #endif
return parts; return parts;

View file

@ -387,7 +387,7 @@ PageFaultResponse Region::handle_zero_fault(size_t page_index_in_region)
} }
#ifdef PAGE_FAULT_DEBUG #ifdef PAGE_FAULT_DEBUG
dbg() << " >> ZERO " << physical_page->paddr(); dbg() << " >> ZERO " << page->paddr();
#endif #endif
page_slot = move(page); page_slot = move(page);
remap_page(page_index_in_region); remap_page(page_index_in_region);
@ -423,7 +423,7 @@ PageFaultResponse Region::handle_cow_fault(size_t page_index_in_region)
u8* dest_ptr = MM.quickmap_page(*page); u8* dest_ptr = MM.quickmap_page(*page);
const u8* src_ptr = vaddr().offset(page_index_in_region * PAGE_SIZE).as_ptr(); const u8* src_ptr = vaddr().offset(page_index_in_region * PAGE_SIZE).as_ptr();
#ifdef PAGE_FAULT_DEBUG #ifdef PAGE_FAULT_DEBUG
dbg() << " >> COW " << physical_page->paddr() << " <- " << physical_page_to_copy->paddr(); dbg() << " >> COW " << page->paddr() << " <- " << physical_page_to_copy->paddr();
#endif #endif
copy_from_user(dest_ptr, src_ptr, PAGE_SIZE); copy_from_user(dest_ptr, src_ptr, PAGE_SIZE);
page_slot = move(page); page_slot = move(page);