1 ;;;; dwarf.test -*- scheme -*-
3 ;;;; Copyright 2013 Free Software Foundation, Inc.
5 ;;;; This library is free software; you can redistribute it and/or
6 ;;;; modify it under the terms of the GNU Lesser General Public
7 ;;;; License as published by the Free Software Foundation; either
8 ;;;; version 3 of the License, or (at your option) any later version.
10 ;;;; This library is distributed in the hope that it will be useful,
11 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ;;;; Lesser General Public License for more details.
15 ;;;; You should have received a copy of the GNU Lesser General Public
16 ;;;; License along with this library; if not, write to the Free Software
17 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 (define-module (test-suite test-dwarf)
20 #:use-module (test-suite lib)
21 #:use-module (ice-9 match)
22 #:use-module (system base compile)
23 #:use-module (system vm debug)
24 #:use-module (system vm program)
25 #:use-module (system vm loader))
29 ;; Every open parenthesis is a possible source location.
43 (let* ((port (open-input-string prog))
45 (set-port-filename! port "foo.scm")
46 (read-and-compile port #:to 'bytecode))))
47 (pass-if-equal 'success
48 ((load-thunk-from-memory bv)))
50 (pass-if-equal 13 (bar 10))
52 (let ((source (find-source-for-addr (program-code qux))))
53 (pass-if-equal "foo.scm" (source-file source))
54 (pass-if-equal 0 (source-line source))
55 (pass-if-equal 1 (source-line-for-user source))
56 (pass-if-equal 0 (source-column source)))
58 (let ((source (find-source-for-addr (program-code bar))))
59 (pass-if-equal "foo.scm" (source-file source))
60 (pass-if-equal 4 (source-line source))
61 (pass-if-equal 5 (source-line-for-user source))
62 (pass-if-equal 2 (source-column source)))
64 (match (find-program-sources (program-code qux))
66 (pass-if-equal "foo.scm" (source-file s1))
67 (pass-if-equal 0 (source-line s1))
68 (pass-if-equal 1 (source-line-for-user s1))
69 (pass-if-equal 0 (source-column s1))
71 (pass-if-equal "foo.scm" (source-file s2))
72 (pass-if-equal 1 (source-line s2))
73 (pass-if-equal 2 (source-line-for-user s2))
74 (pass-if-equal 8 (source-column s2))
76 (pass-if-equal "foo.scm" (source-file s3))
77 (pass-if-equal 1 (source-line s3))
78 (pass-if-equal 2 (source-line-for-user s3))
79 (pass-if-equal 2 (source-column s3)))
81 (error "unexpected sources" sources)))
83 (match (find-program-sources (program-code bar))
85 (pass-if-equal "foo.scm" (source-file source))
86 (pass-if-equal 4 (source-line source))
87 (pass-if-equal 5 (source-line-for-user source))
88 (pass-if-equal 2 (source-column source)))
90 (error "unexpected sources" sources))))