]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/guile/lib/gdb/printing.scm
PR guile/17177
[thirdparty/binutils-gdb.git] / gdb / guile / lib / gdb / printing.scm
CommitLineData
ed3ef339
DE
1;; Additional pretty-printer support.
2;;
3;; Copyright (C) 2014 Free Software Foundation, Inc.
4;;
5;; This file is part of GDB.
6;;
7;; This program is free software; you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation; either version 3 of the License, or
10;; (at your option) any later version.
11;;
12;; This program is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16;;
17;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (gdb printing)
21 #:use-module ((gdb) #:select
ee7333ae
DE
22 (pretty-printer? objfile? progspace?
23 pretty-printers set-pretty-printers!
ded03782
DE
24 objfile-pretty-printers set-objfile-pretty-printers!
25 progspace-pretty-printers set-progspace-pretty-printers!))
ed3ef339
DE
26 #:use-module (gdb init))
27
28(define-public (prepend-pretty-printer! obj matcher)
29 "Add MATCHER to the beginning of the pretty-printer list for OBJ.
30If OBJ is #f, add MATCHER to the global list."
31 (%assert-type (pretty-printer? matcher) matcher SCM_ARG1
32 'prepend-pretty-printer!)
33 (cond ((eq? obj #f)
ee7333ae 34 (set-pretty-printers! (cons matcher (pretty-printers))))
ed3ef339 35 ((objfile? obj)
ded03782
DE
36 (set-objfile-pretty-printers!
37 obj (cons matcher (objfile-pretty-printers obj))))
38 ((progspace? obj)
39 (set-progspace-pretty-printers!
40 obj (cons matcher (progspace-pretty-printers obj))))
ed3ef339
DE
41 (else
42 (%assert-type #f obj SCM_ARG1 'prepend-pretty-printer!))))
43
44(define-public (append-pretty-printer! obj matcher)
45 "Add MATCHER to the end of the pretty-printer list for OBJ.
46If OBJ is #f, add MATCHER to the global list."
47 (%assert-type (pretty-printer? matcher) matcher SCM_ARG1
48 'append-pretty-printer!)
49 (cond ((eq? obj #f)
ee7333ae 50 (set-pretty-printers! (append! (pretty-printers) (list matcher))))
ed3ef339 51 ((objfile? obj)
ded03782
DE
52 (set-objfile-pretty-printers!
53 obj (append! (objfile-pretty-printers obj) (list matcher))))
54 ((progspace? obj)
55 (set-progspace-pretty-printers!
56 obj (append! (progspace-pretty-printers obj) (list matcher))))
ed3ef339
DE
57 (else
58 (%assert-type #f obj SCM_ARG1 'append-pretty-printer!))))