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

Everywhere: Hook up remaining debug macros to Debug.h.

This commit is contained in:
asynts 2021-01-24 15:28:26 +01:00 committed by Andreas Kling
parent da69de1f1b
commit eea72b9b5c
63 changed files with 458 additions and 287 deletions

View file

@ -25,6 +25,7 @@
*/
#include <AK/Badge.h>
#include <AK/Debug.h>
#include <AK/HashTable.h>
#include <AK/StackInfo.h>
#include <AK/TemporaryChange.h>
@ -115,7 +116,7 @@ void Heap::gather_roots(HashTable<Cell*>& roots)
}
}
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln("gather_roots:");
for (auto* root : roots)
dbgln(" + {}", root);
@ -126,7 +127,7 @@ __attribute__((no_sanitize("address"))) void Heap::gather_conservative_roots(Has
{
FlatPtr dummy;
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln("gather_conservative_roots:");
#endif
@ -157,19 +158,19 @@ __attribute__((no_sanitize("address"))) void Heap::gather_conservative_roots(Has
for (auto possible_pointer : possible_pointers) {
if (!possible_pointer)
continue;
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln(" ? {}", (const void*)possible_pointer);
#endif
auto* possible_heap_block = HeapBlock::from_cell(reinterpret_cast<const Cell*>(possible_pointer));
if (all_live_heap_blocks.contains(possible_heap_block)) {
if (auto* cell = possible_heap_block->cell_from_possible_pointer(possible_pointer)) {
if (cell->is_live()) {
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln(" ?-> {}", (const void*)cell);
#endif
roots.set(cell);
} else {
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln(" #-> {}", (const void*)cell);
#endif
}
@ -186,7 +187,7 @@ public:
{
if (cell->is_marked())
return;
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln(" ! {}", cell);
#endif
cell->set_marked(true);
@ -196,7 +197,7 @@ public:
void Heap::mark_live_cells(const HashTable<Cell*>& roots)
{
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln("mark_live_cells:");
#endif
MarkingVisitor visitor;
@ -206,7 +207,7 @@ void Heap::mark_live_cells(const HashTable<Cell*>& roots)
void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measurement_timer)
{
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln("sweep_dead_cells:");
#endif
Vector<HeapBlock*, 32> empty_blocks;
@ -223,7 +224,7 @@ void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measure
block.for_each_cell([&](Cell* cell) {
if (cell->is_live()) {
if (!cell->is_marked()) {
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln(" ~ {}", cell);
#endif
block.deallocate(cell);
@ -245,20 +246,20 @@ void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measure
});
for (auto* block : empty_blocks) {
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln(" - HeapBlock empty @ {}: cell_size={}", block, block->cell_size());
#endif
allocator_for_size(block->cell_size()).block_did_become_empty({}, *block);
}
for (auto* block : full_blocks_that_became_usable) {
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
dbgln(" - HeapBlock usable again @ {}: cell_size={}", block, block->cell_size());
#endif
allocator_for_size(block->cell_size()).block_did_become_usable({}, *block);
}
#ifdef HEAP_DEBUG
#if HEAP_DEBUG
for_each_block([&](auto& block) {
dbgln(" > Live HeapBlock @ {}: cell_size={}", &block, block.cell_size());
return IterationDecision::Continue;

View file

@ -26,6 +26,7 @@
*/
#include "Lexer.h"
#include <AK/Debug.h>
#include <AK/HashMap.h>
#include <AK/StringBuilder.h>
#include <ctype.h>
@ -169,7 +170,7 @@ void Lexer::consume()
return;
if (is_line_terminator()) {
#ifdef LEXER_DEBUG
#if LEXER_DEBUG
String type;
if (m_current_char == '\n')
type = "LINE FEED";
@ -198,7 +199,7 @@ void Lexer::consume()
if (!second_char_of_crlf) {
m_line_number++;
m_line_column = 1;
#ifdef LEXER_DEBUG
#if LEXER_DEBUG
dbgln("Incremented line number, now at: line {}, column 1", m_line_number);
} else {
dbgln("Previous was CR, this is LF - not incrementing line number again.");
@ -638,7 +639,7 @@ Token Lexer::next()
value_start_line_number,
value_start_column_number);
#ifdef LEXER_DEBUG
#if LEXER_DEBUG
dbgln("------------------------------");
dbgln("Token: {}", m_current_token.name());
dbgln("Trivia: _{}_", m_current_token.trivia());

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Debug.h>
#include <AK/String.h>
#include <AK/TemporaryChange.h>
#include <LibJS/Heap/Heap.h>
@ -397,7 +398,7 @@ bool Object::define_property(const StringOrSymbol& property_name, const Object&
return false;
}
#ifdef OBJECT_DEBUG
#if OBJECT_DEBUG
dbgln("Defining new property {} with accessor descriptor {{ attributes={}, getter={}, setter={} }}", property_name.to_display_string(), attributes, getter, setter);
#endif
@ -417,7 +418,7 @@ bool Object::define_property(const StringOrSymbol& property_name, const Object&
if (vm.exception())
return {};
#ifdef OBJECT_DEBUG
#if OBJECT_DEBUG
dbgln("Defining new property {} with data descriptor {{ attributes={}, value={} }}", property_name.to_display_string(), attributes, value);
#endif
@ -497,7 +498,7 @@ bool Object::put_own_property(Object& this_object, const StringOrSymbol& propert
bool new_property = !metadata.has_value();
if (!is_extensible() && new_property) {
#ifdef OBJECT_DEBUG
#if OBJECT_DEBUG
dbgln("Disallow define_property of non-extensible object");
#endif
if (throw_exceptions && vm().in_strict_mode())
@ -526,7 +527,7 @@ bool Object::put_own_property(Object& this_object, const StringOrSymbol& propert
}
if (!new_property && mode == PutOwnPropertyMode::DefineProperty && !metadata.value().attributes.is_configurable() && attributes != metadata.value().attributes) {
#ifdef OBJECT_DEBUG
#if OBJECT_DEBUG
dbgln("Disallow reconfig of non-configurable property");
#endif
if (throw_exceptions)
@ -542,14 +543,14 @@ bool Object::put_own_property(Object& this_object, const StringOrSymbol& propert
}
metadata = shape().lookup(property_name);
#ifdef OBJECT_DEBUG
#if OBJECT_DEBUG
dbgln("Reconfigured property {}, new shape says offset is {} and my storage capacity is {}", property_name.to_display_string(), metadata.value().offset, m_storage.size());
#endif
}
auto value_here = m_storage[metadata.value().offset];
if (!new_property && mode == PutOwnPropertyMode::Put && !value_here.is_accessor() && !metadata.value().attributes.is_writable()) {
#ifdef OBJECT_DEBUG
#if OBJECT_DEBUG
dbgln("Disallow write to non-writable property");
#endif
return false;
@ -574,7 +575,7 @@ bool Object::put_own_property_by_index(Object& this_object, u32 property_index,
auto new_property = !existing_property.has_value();
if (!is_extensible() && new_property) {
#ifdef OBJECT_DEBUG
#if OBJECT_DEBUG
dbgln("Disallow define_property of non-extensible object");
#endif
if (throw_exceptions && vm().in_strict_mode())
@ -593,7 +594,7 @@ bool Object::put_own_property_by_index(Object& this_object, u32 property_index,
PropertyAttributes existing_attributes = new_property ? 0 : existing_property.value().attributes;
if (!new_property && mode == PutOwnPropertyMode::DefineProperty && !existing_attributes.is_configurable() && attributes != existing_attributes) {
#ifdef OBJECT_DEBUG
#if OBJECT_DEBUG
dbgln("Disallow reconfig of non-configurable property");
#endif
if (throw_exceptions)
@ -603,7 +604,7 @@ bool Object::put_own_property_by_index(Object& this_object, u32 property_index,
auto value_here = new_property ? Value() : existing_property.value().value;
if (!new_property && mode == PutOwnPropertyMode::Put && !value_here.is_accessor() && !existing_attributes.is_writable()) {
#ifdef OBJECT_DEBUG
#if OBJECT_DEBUG
dbgln("Disallow write to non-writable property");
#endif
return false;