with the attachement this time.

Le sam. 9 févr. 2019 à 18:10, Amirouche Boubekki <
amirouche.boube...@gmail.com> a écrit :

>
>
> Le sam. 9 févr. 2019 à 14:48, Nala Ginrut <nalagin...@gmail.com> a écrit :
>
>> I wonder if it's a bug that the FN was skipped.
>>
>
> Yes it is expected, see
> http://git.savannah.gnu.org/cgit/guile.git/tree/module/system/vm/coverage.scm#n309
>
> Here is a patch that take into account function coverage, it is rather
> slow.
>
> demo: https://screenshots.firefox.com/FmuctotjXTFRSiFW/null
>
> HTH
>
>
>> On Sat, Feb 9, 2019 at 10:51 AM Nala Ginrut <nalagin...@gmail.com> wrote:
>> >
>> > Never mind, it's better than mine, at least there're lines records,
>> > although functions calling are still missing.
>> > Thanks ;-)
>> >
>> > On Sat, Feb 9, 2019 at 8:27 AM Amirouche Boubekki
>> > <amirouche.boube...@gmail.com> wrote:
>> > >
>> > > Sorry! My test is not good. Ignore what I posted previously.
>>
>
From d32da0570d3f6aa1857331c821ca071b0eca96f2 Mon Sep 17 00:00:00 2001
From: Amirouche <amirouche.boube...@gmail.com>
Date: Sat, 9 Feb 2019 18:08:45 +0100
Subject: [PATCH] add function coverage


diff --git a/module/system/vm/coverage.scm b/module/system/vm/coverage.scm
index 0d51e261a..f151912f7 100644
--- a/module/system/vm/coverage.scm
+++ b/module/system/vm/coverage.scm
@@ -21,6 +21,7 @@
   #:use-module (system vm frame)
   #:use-module (system vm program)
   #:use-module (system vm debug)
+  #:use-module (system xref)
   #:use-module (ice-9 format)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-9)
@@ -309,11 +310,11 @@ gathered, even if their code was not executed."
   ;; FIXME: Re-enable this code, but using for-each-elf-symbol on each source
   ;; chunk.  Use that to build a map of file -> proc-addr + line + name.  Then
   ;; use something like procedure-execution-count to get the execution count.
-  #;
+
   (define (dump-function proc)
     ;; Dump source location and basic coverage data for PROC.
     (and (or (program? proc))
-         (let ((sources (program-sources* data proc)))
+         (let ((sources (program-sources proc)))
            (and (pair? sources)
                 (let* ((line (source:line-for-user (car sources)))
                        (name (or (procedure-name proc)
@@ -330,8 +331,9 @@ gathered, even if their code was not executed."
                 (if (string? path)
                     (begin
                       (format port "SF:~A~%" path)
-                      #;
-                      (for-each dump-function procs)
+                      (let ((procs (file-procedures file)))
+                        (when procs
+                          (for-each dump-function procs)))
                       (for-each (lambda (line+count)
                                   (let ((line  (car line+count))
                                         (count (cdr line+count)))
diff --git a/module/system/xref.scm b/module/system/xref.scm
index e335f9481..d0ac49615 100644
--- a/module/system/xref.scm
+++ b/module/system/xref.scm
@@ -26,7 +26,8 @@
             procedure-callees
             procedure-callers
             source-closures
-            source-procedures))
+            source-procedures
+            file-procedures))
 
 ;;;
 ;;; The cross-reference database: who calls whom.
@@ -371,3 +372,11 @@ pair of the form (module-name . variable-name), "
                  (false-if-exception (open-input-file file))))
          (file (if port (port-filename port) file)))
     (lookup-source-procedures file line *sources-db*)))
+
+(define (lookup-procedures file-table)
+  (apply append (hash-fold (lambda (key value acc) (cons value acc)) '() file-table)))
+
+(define (file-procedures file)
+  "Retrieve all procedures defined in FILE. Can return multiple times the same procedure"
+  (ensure-sources-db #f)
+  (and=> (hash-ref *sources-db* file) lookup-procedures))
-- 
2.19.1

Reply via email to