[Git][ghc/ghc][wip/ghc-debug] Define a public API for Printer.c (#18405)

Sven Tennie gitlab at gitlab.haskell.org
Wed Sep 9 07:11:39 UTC 2020



Sven Tennie pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC


Commits:
25c2a49b by Sven Tennie at 2020-09-09T09:11:19+02:00
Define a public API for Printer.c (#18405)

The RtsAPI contains functions to inspect the heap. The published
Printer.c functions help to print the found closures.

- - - - -


3 changed files:

- + includes/rts/PrinterAPI.h
- rts/Printer.c
- rts/Printer.h


Changes:

=====================================
includes/rts/PrinterAPI.h
=====================================
@@ -0,0 +1,23 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team, 2020
+ *
+ * Public API of closure printing functions.
+ *
+ * ---------------------------------------------------------------------------*/
+
+#pragma once
+
+// findPtrCb takes a callback of type FindPtrCb, so external tools (such as
+// ghc-debug) can invoke it and intercept the intermediate results.
+// When findPtrCb successfully finds a closure containing an address then the
+// callback is called on the address of that closure.
+// The `StgClosure` argument is an untagged closure pointer.
+// `user` points to any data provided by the caller. It's not used internally.
+typedef void (*FindPtrCb)(void *user, StgClosure *);
+
+void findPtrCb(FindPtrCb cb, void *, P_ p);
+
+// Special case of findPtrCb: Uses a default callback, that prints the closure
+// pointed to by p.
+void findPtr(P_ p, int follow);


=====================================
rts/Printer.c
=====================================
@@ -852,17 +852,6 @@ extern void DEBUG_LoadSymbols( const char *name STG_UNUSED )
 
 #endif /* USING_LIBBFD */
 
-// findPtrCb takes a callback of type FindPtrCb, so external tools (such as
-// ghc-debug) can invoke it and intercept the intermediate results.
-// When findPtrCb successfully finds a closure containing an address then the
-// callback is called on the address of that closure.
-// The `StgClosure` argument is an untagged closure pointer.
-// `user` points to any data provided by the caller. It's not used internally.
-typedef void (*FindPtrCb)(void *user, StgClosure *);
-
-void findPtr(P_ p, int);                /* keep gcc -Wall happy */
-void findPtrCb(FindPtrCb cb, void *, P_ p);  /* keep gcc -Wall happy */
-
 static void
 findPtr_default_callback(void *user STG_UNUSED, StgClosure * closure){
   debugBelch("%p = ", closure);


=====================================
rts/Printer.h
=====================================
@@ -10,6 +10,8 @@
 
 #include "BeginPrivate.h"
 
+#include "rts/PrinterAPI.h"
+
 extern void        printPtr        ( StgPtr p );
 extern void        printObj        ( StgClosure *obj );
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/25c2a49b894b33e94b24423b485ef6a0bbfede9e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/25c2a49b894b33e94b24423b485ef6a0bbfede9e
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200909/2b3be53f/attachment-0001.html>


More information about the ghc-commits mailing list