[commit: ghc] wip/nonmoving-gc: rts/Printer: Introduce a few more printing utilities (c668d95)

git at git.haskell.org git at git.haskell.org
Wed Feb 6 14:09:24 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nonmoving-gc
Link       : http://ghc.haskell.org/trac/ghc/changeset/c668d9537f6a03903cbecd556e3b48c8c06b063c/ghc

>---------------------------------------------------------------

commit c668d9537f6a03903cbecd556e3b48c8c06b063c
Author: Ömer Sinan Ağacan <omer at well-typed.com>
Date:   Tue Feb 5 00:37:57 2019 -0500

    rts/Printer: Introduce a few more printing utilities
    
    These include printLargeAndPinnedObjects, printWeakLists, and
    printStaticObjects. These are generally useful things to have.


>---------------------------------------------------------------

c668d9537f6a03903cbecd556e3b48c8c06b063c
 rts/Printer.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 rts/Printer.h |  3 +++
 2 files changed, 78 insertions(+)

diff --git a/rts/Printer.c b/rts/Printer.c
index 291f529..2f93ba8 100644
--- a/rts/Printer.c
+++ b/rts/Printer.c
@@ -646,6 +646,81 @@ void printTSO( StgTSO *tso )
     printStack( tso->stackobj );
 }
 
+void printStaticObjects( StgClosure *p )
+{
+    while (p != END_OF_STATIC_OBJECT_LIST) {
+        p = UNTAG_STATIC_LIST_PTR(p);
+        printClosure(p);
+
+        const StgInfoTable *info = get_itbl(p);
+        p = *STATIC_LINK(info, p);
+    }
+}
+
+void printWeakLists()
+{
+    debugBelch("======= WEAK LISTS =======\n");
+
+    for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) {
+        debugBelch("Capability %d:\n", cap_idx);
+        Capability *cap = capabilities[cap_idx];
+        for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) {
+            printClosure((StgClosure*)weak);
+        }
+    }
+
+    for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) {
+        generation *gen = &generations[gen_idx];
+        debugBelch("Generation %d current weaks:\n", gen_idx);
+        for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) {
+            printClosure((StgClosure*)weak);
+        }
+        debugBelch("Generation %d old weaks:\n", gen_idx);
+        for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) {
+            printClosure((StgClosure*)weak);
+        }
+    }
+
+    debugBelch("=========================\n");
+}
+
+void printLargeAndPinnedObjects()
+{
+    debugBelch("====== PINNED OBJECTS ======\n");
+
+    for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) {
+        debugBelch("Capability %d:\n", cap_idx);
+        Capability *cap = capabilities[cap_idx];
+
+        debugBelch("Current pinned object block: %p\n", (void*)cap->pinned_object_block);
+        // just to check if my understanding is correct
+        // 4/6/2018: assertion fails
+        // ASSERT(cap->pinned_object_block == NULL || cap->pinned_object_block->link == NULL);
+
+        for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) {
+            debugBelch("%p\n", (void*)bd);
+        }
+    }
+
+    debugBelch("====== LARGE OBJECTS =======\n");
+    for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) {
+        generation *gen = &generations[gen_idx];
+        debugBelch("Generation %d current large objects:\n", gen_idx);
+        for (bdescr *bd = gen->large_objects; bd; bd = bd->link) {
+            debugBelch("%p: ", (void*)bd);
+            printClosure((StgClosure*)bd->start);
+        }
+
+        debugBelch("Generation %d scavenged large objects:\n", gen_idx);
+        for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) {
+            debugBelch("%p: ", (void*)bd);
+            printClosure((StgClosure*)bd->start);
+        }
+    }
+
+    debugBelch("============================\n");
+}
+
 /* --------------------------------------------------------------------------
  * Address printing code
  *
diff --git a/rts/Printer.h b/rts/Printer.h
index d2eaf01..44c55de 100644
--- a/rts/Printer.h
+++ b/rts/Printer.h
@@ -25,6 +25,9 @@ extern void        printClosure    ( const StgClosure *obj );
 extern void        printStackChunk ( StgPtr sp, StgPtr spLim );
 extern void        printTSO        ( StgTSO *tso );
 extern void        printMutableList( bdescr *bd );
+extern void        printStaticObjects ( StgClosure *obj );
+extern void        printWeakLists ( void );
+extern void        printLargeAndPinnedObjects ( void );
 
 extern void DEBUG_LoadSymbols( const char *name );
 



More information about the ghc-commits mailing list