10Sstevel@tonic-gate# Copyright (C) 2011-2023 Free Software Foundation, Inc. 20Sstevel@tonic-gate 30Sstevel@tonic-gate# This program is free software; you can redistribute it and/or modify 40Sstevel@tonic-gate# it under the terms of the GNU General Public License as published by 50Sstevel@tonic-gate# the Free Software Foundation; either version 3 of the License, or 60Sstevel@tonic-gate# (at your option) any later version. 70Sstevel@tonic-gate# 80Sstevel@tonic-gate# This program is distributed in the hope that it will be useful, 90Sstevel@tonic-gate# but WITHOUT ANY WARRANTY; without even the implied warranty of 100Sstevel@tonic-gate# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 110Sstevel@tonic-gate# GNU General Public License for more details. 120Sstevel@tonic-gate# 130Sstevel@tonic-gate# You should have received a copy of the GNU General Public License 140Sstevel@tonic-gate# along with this program. If not, see <http://www.gnu.org/licenses/>. 150Sstevel@tonic-gate 160Sstevel@tonic-gate# This file is part of the GDB testsuite. 170Sstevel@tonic-gate# It tests the objfile support in Guile. 180Sstevel@tonic-gate 190Sstevel@tonic-gateload_lib gdb-guile.exp 200Sstevel@tonic-gate 210Sstevel@tonic-gatestandard_testfile 220Sstevel@tonic-gate 230Sstevel@tonic-gateif { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { 240Sstevel@tonic-gate return 250Sstevel@tonic-gate} 260Sstevel@tonic-gate 270Sstevel@tonic-gate# Skip all tests if Guile scripting is not enabled. 280Sstevel@tonic-gateif { [skip_guile_tests] } { continue } 290Sstevel@tonic-gate 300Sstevel@tonic-gateif ![gdb_guile_runto_main] { 310Sstevel@tonic-gate return 320Sstevel@tonic-gate} 330Sstevel@tonic-gate 340Sstevel@tonic-gategdb_scm_test_silent_cmd "gu (define sym (lookup-symbol \"some_var\"))" \ 350Sstevel@tonic-gate "Find a symbol in objfile" 360Sstevel@tonic-gategdb_scm_test_silent_cmd "gu (define objfile (symtab-objfile (symbol-symtab (car sym))))" \ 370Sstevel@tonic-gate "Get backing object file" 380Sstevel@tonic-gate 390Sstevel@tonic-gategdb_test "gu (print (objfile-filename objfile))" \ 400Sstevel@tonic-gate ".*scm-objfile.*" "Get objfile filename" 410Sstevel@tonic-gategdb_test "gu (print (objfile-valid? objfile))" \ 420Sstevel@tonic-gate "#t" "Get objfile validity" 430Sstevel@tonic-gate 440Sstevel@tonic-gategdb_test "gu (print (->bool (or-map (lambda (o) (string-contains (objfile-filename o) \"scm-objfile\")) (objfiles))))" \ 450Sstevel@tonic-gate "= #t" "scm-objfile in objfile list" 460Sstevel@tonic-gate 470Sstevel@tonic-gategdb_test "gu (print (objfile-pretty-printers objfile))" \ 480Sstevel@tonic-gate "= \\(\\)" 490Sstevel@tonic-gate 500Sstevel@tonic-gategdb_test "gu (print (eq? (current-progspace) (objfile-progspace objfile)))" \ 510Sstevel@tonic-gate "= #t" 520Sstevel@tonic-gate 530Sstevel@tonic-gategdb_test "guile (set-objfile-pretty-printers! objfile 0)" \ 540Sstevel@tonic-gate "ERROR: .*: Wrong type argument in position 2 \\(expecting list\\): 0.*" 550Sstevel@tonic-gate 560Sstevel@tonic-gate# Do this last. 570Sstevel@tonic-gategdb_unload 580Sstevel@tonic-gategdb_test "gu (print (objfile-valid? objfile))" \ 590Sstevel@tonic-gate "#f" "Get objfile validity after unload" 600Sstevel@tonic-gate