Allow using the heap profiler in the inferior

This commit is contained in:
Christopher Baines 2024-11-08 19:02:29 +00:00
parent ebeb4212ff
commit e7ada1bada

View file

@ -1714,6 +1714,31 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
(inferior-eval '(when (defined? '%graft?) (%graft? #f)) inf)
;; Load the heap-profiler
(for-each
(lambda (exp)
(inferior-eval exp inf))
(call-with-input-file
(%search-load-path "guix-data-service/heap-profiler.scm")
(lambda (port)
(let loop ((result '()))
(let ((exp (read port)))
(if (eof-object? exp)
(reverse! result)
(loop (cons (if (eq? (car exp) 'define-module)
`(use-modules
,@(let loop ((lst (cddr exp))
(result '()))
(match lst
('() result)
(('#:use-module mod rest ...)
(loop rest
(cons mod result)))
(rest
(loop (cdr lst) result)))))
exp)
result))))))))
;; TODO Have Guix make this easier
((@@ (guix inferior) ensure-store-bridge!) inf)
(non-blocking-port ((@@ (guix inferior) inferior-bridge-socket) inf))