old-cross-binutils/gdb/testsuite/gdb.guile/scm-breakpoint.exp
Doug Evans ed3ef33944 Add Guile as an extension language.
* NEWS: Mention Guile scripting.
	* Makefile.in (SUBDIR_GUILE_OBS): New variable.
	(SUBDIR_GUILE_SRCS, SUBDIR_GUILE_DEPS): New variables
	(SUBDIR_GUILE_LDFLAGS, SUBDIR_GUILE_CFLAGS): New variables.
	(INTERNAL_CPPFLAGS): Add GUILE_CPPFLAGS.
	(CLIBS): Add GUILE_LIBS.
	(install-guile): New rule.
	(guile.o): New rule.
	(scm-arch.o, scm-auto-load.o, scm-block.o): New rules.
	(scm-breakpoint.o, scm-disasm.o, scm-exception.o): New rules.
	(scm-frame.o, scm-iterator.o, scm-lazy-string.o): New rules.
	(scm-math.o, scm-objfile.o, scm-ports.o): New rules.
	(scm-pretty-print.o, scm-safe-call.o, scm-gsmob.o): New rules.
	(scm-string.o, scm-symbol.o, scm-symtab.o): New rules.
	(scm-type.o, scm-utils.o, scm-value.o): New rules.
	* configure.ac: New option --with-guile.
	* configure: Regenerate.
	* config.in: Regenerate.
	* auto-load.c: Remove #include "python/python.h".  Add #include
	"gdb/section-scripts.h".
	(source_section_scripts): Handle Guile scripts.
	(_initialize_auto_load): Add name of Guile objfile script to
	scripts-directory help text.
	* breakpoint.c (condition_command): Tweak comment to include Scheme.
	* breakpoint.h (gdbscm_breakpoint_object): Add forward decl.
	(struct breakpoint): New member scm_bp_object.
	* defs.h (enum command_control_type): New value guile_control.
	* cli/cli-cmds.c: Remove #include "python/python.h".  Add #include
	"extension.h".
	(show_user): Update comment.
	(_initialize_cli_cmds): Update help text for "show user".  Update help
	text for max-user-call-depth.
	* cli/cli-script.c: Remove #include "python/python.h".  Add #include
	"extension.h".
	(multi_line_command_p): Add guile_control.
	(print_command_lines): Handle guile_control.
	(execute_control_command, recurse_read_control_structure): Ditto.
	(process_next_line): Recognize "guile" commands.
	* disasm.c (gdb_disassemble_info): Make non-static.
	* disasm.h: #include "dis-asm.h".
	(struct gdbarch): Add forward decl.
	(gdb_disassemble_info): Declare.
	* extension.c: #include "guile/guile.h".
	(extension_languages): Add guile.
	(get_ext_lang_defn): Handle EXT_LANG_GDB.
	* extension.h (enum extension_language): New value EXT_LANG_GUILE.
	* gdbtypes.c (get_unsigned_type_max): New function.
	(get_signed_type_minmax): New function.
	* gdbtypes.h (get_unsigned_type_max): Declare.
	(get_signed_type_minmax): Declare.
	* guile/README: New file.
	* guile/guile-internal.h: New file.
	* guile/guile.c: New file.
	* guile/guile.h: New file.
	* guile/scm-arch.c: New file.
	* guile/scm-auto-load.c: New file.
	* guile/scm-block.c: New file.
	* guile/scm-breakpoint.c: New file.
	* guile/scm-disasm.c: New file.
	* guile/scm-exception.c: New file.
	* guile/scm-frame.c: New file.
	* guile/scm-gsmob.c: New file.
	* guile/scm-iterator.c: New file.
	* guile/scm-lazy-string.c: New file.
	* guile/scm-math.c: New file.
	* guile/scm-objfile.c: New file.
	* guile/scm-ports.c: New file.
	* guile/scm-pretty-print.c: New file.
	* guile/scm-safe-call.c: New file.
	* guile/scm-string.c: New file.
	* guile/scm-symbol.c: New file.
	* guile/scm-symtab.c: New file.
	* guile/scm-type.c: New file.
	* guile/scm-utils.c: New file.
	* guile/scm-value.c: New file.
	* guile/lib/gdb.scm: New file.
	* guile/lib/gdb/boot.scm: New file.
	* guile/lib/gdb/experimental.scm: New file.
	* guile/lib/gdb/init.scm: New file.
	* guile/lib/gdb/iterator.scm: New file.
	* guile/lib/gdb/printing.scm: New file.
	* guile/lib/gdb/types.scm: New file.
	* data-directory/Makefile.in (GUILE_SRCDIR): New variable.
	(VPATH): Add $(GUILE_SRCDIR).
	(GUILE_DIR): New variable.
	(GUILE_INSTALL_DIR, GUILE_FILES): New variables.
	(all): Add stamp-guile dependency.
	(stamp-guile): New rule.
	(clean-guile, install-guile, uninstall-guile): New rules.
	(install-only): Add install-guile dependency.
	(uninstall): Add uninstall-guile dependency.
	(clean): Add clean-guile dependency.

	doc/
	* Makefile.in (GDB_DOC_FILES): Add guile.texi.
	* gdb.texinfo (Auto-loading): Add set/show auto-load guile-scripts.
	(Extending GDB): New menu entries Guile, Multiple Extension Languages.
	(Guile docs): Include guile.texi.
	(objfile-gdbdotext file): Add objfile-gdb.scm.
	(dotdebug_gdb_scripts section): Mention Guile scripts.
	(Multiple Extension Languages): New node.
	* guile.texi: New file.

	testsuite/
	* configure.ac (AC_OUTPUT): Add gdb.guile.
	* configure: Regenerate.
	* lib/gdb-guile.exp: New file.
	* lib/gdb.exp (get_target_charset): New function.
	* gdb.base/help.exp: Update expected output from "apropos apropos".
	* gdb.guile/Makefile.in: New file.
	* gdb.guile/guile.exp: New file.
	* gdb.guile/scm-arch.c: New file.
	* gdb.guile/scm-arch.exp: New file.
	* gdb.guile/scm-block.c: New file.
	* gdb.guile/scm-block.exp: New file.
	* gdb.guile/scm-breakpoint.c: New file.
	* gdb.guile/scm-breakpoint.exp: New file.
	* gdb.guile/scm-disasm.c: New file.
	* gdb.guile/scm-disasm.exp: New file.
	* gdb.guile/scm-equal.c: New file.
	* gdb.guile/scm-equal.exp: New file.
	* gdb.guile/scm-error.exp: New file.
	* gdb.guile/scm-error.scm: New file.
	* gdb.guile/scm-frame-args.c: New file.
	* gdb.guile/scm-frame-args.exp: New file.
	* gdb.guile/scm-frame-args.scm: New file.
	* gdb.guile/scm-frame-inline.c: New file.
	* gdb.guile/scm-frame-inline.exp: New file.
	* gdb.guile/scm-frame.c: New file.
	* gdb.guile/scm-frame.exp: New file.
	* gdb.guile/scm-generics.exp: New file.
	* gdb.guile/scm-gsmob.exp: New file.
	* gdb.guile/scm-iterator.c: New file.
	* gdb.guile/scm-iterator.exp: New file.
	* gdb.guile/scm-math.c: New file.
	* gdb.guile/scm-math.exp: New file.
	* gdb.guile/scm-objfile-script-gdb.in: New file.
	* gdb.guile/scm-objfile-script.c: New file.
	* gdb.guile/scm-objfile-script.exp: New file.
	* gdb.guile/scm-objfile.c: New file.
	* gdb.guile/scm-objfile.exp: New file.
	* gdb.guile/scm-ports.exp: New file.
	* gdb.guile/scm-pretty-print.c: New file.
	* gdb.guile/scm-pretty-print.exp: New file.
	* gdb.guile/scm-pretty-print.scm: New file.
	* gdb.guile/scm-section-script.c: New file.
	* gdb.guile/scm-section-script.exp: New file.
	* gdb.guile/scm-section-script.scm: New file.
	* gdb.guile/scm-symbol.c: New file.
	* gdb.guile/scm-symbol.exp: New file.
	* gdb.guile/scm-symtab-2.c: New file.
	* gdb.guile/scm-symtab.c: New file.
	* gdb.guile/scm-symtab.exp: New file.
	* gdb.guile/scm-type.c: New file.
	* gdb.guile/scm-type.exp: New file.
	* gdb.guile/scm-value-cc.cc: New file.
	* gdb.guile/scm-value-cc.exp: New file.
	* gdb.guile/scm-value.c: New file.
	* gdb.guile/scm-value.exp: New file.
	* gdb.guile/source2.scm: New file.
	* gdb.guile/types-module.cc: New file.
	* gdb.guile/types-module.exp: New file.
2014-02-09 19:40:01 -08:00

438 lines
16 KiB
Text

# Copyright (C) 2010-2014 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file is part of the GDB testsuite.
# It tests the mechanism exposing breakpoints to Guile.
load_lib gdb-guile.exp
standard_testfile
if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
return -1
}
# Skip all tests if Guile scripting is not enabled.
if { [skip_guile_tests] } { continue }
proc test_bkpt_basic { } {
global srcfile testfile hex decimal
with_test_prefix "test_bkpt_basic" {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![gdb_guile_runto_main] {
return
}
# Initially there should be one breakpoint: main.
gdb_scm_test_silent_cmd "guile (define blist (breakpoints))" \
"get breakpoint list 1"
gdb_test "guile (print (car blist))" \
"<gdb:breakpoint #1 BP_BREAKPOINT enabled noisy hit:1 ignore:0 @main>" \
"check main breakpoint"
gdb_test "guile (print (breakpoint-location (car blist)))" \
"main" "check main breakpoint location"
set mult_line [gdb_get_line_number "Break at multiply."]
gdb_breakpoint ${mult_line}
gdb_continue_to_breakpoint "Break at multiply."
# Check that the Guile breakpoint code noted the addition of a
# breakpoint "behind the scenes".
gdb_scm_test_silent_cmd "guile (define blist (breakpoints))" \
"get breakpoint list 2"
gdb_scm_test_silent_cmd "guile (define mult-bkpt (cadr blist))" \
"get multiply breakpoint"
gdb_test "guile (print (length blist))" \
"= 2" "check for two breakpoints"
gdb_test "guile (print mult-bkpt)" \
"= #<gdb:breakpoint #2 BP_BREAKPOINT enabled noisy hit:1 ignore:0 @.*scm-breakpoint.c:$mult_line>" \
"check multiply breakpoint"
gdb_test "guile (print (breakpoint-location mult-bkpt))" \
"scm-breakpoint\.c:${mult_line}*" \
"check multiply breakpoint location"
# Check hit and ignore counts.
gdb_test "guile (print (breakpoint-hit-count mult-bkpt))" \
"= 1" "check multiply breakpoint hit count"
gdb_scm_test_silent_cmd "guile (set-breakpoint-ignore-count! mult-bkpt 4)" \
"set multiply breakpoint ignore count"
gdb_continue_to_breakpoint "Break at multiply."
gdb_test "guile (print (breakpoint-hit-count mult-bkpt))" \
"= 6" "check multiply breakpoint hit count 2"
gdb_test "print result" \
" = 545" "check expected variable result after 6 iterations"
# Test breakpoint is enabled and disabled correctly.
gdb_breakpoint [gdb_get_line_number "Break at add."]
gdb_continue_to_breakpoint "Break at add."
gdb_test "guile (print (breakpoint-enabled? mult-bkpt))" \
"= #t" "check multiply breakpoint enabled"
gdb_scm_test_silent_cmd "guile (set-breakpoint-enabled! mult-bkpt #f)" \
"set multiply breakpoint disabled"
gdb_continue_to_breakpoint "Break at add."
gdb_scm_test_silent_cmd "guile (set-breakpoint-enabled! mult-bkpt #t)" \
"set multiply breakpoint enabled"
gdb_continue_to_breakpoint "Break at multiply."
# Test other getters and setters.
gdb_scm_test_silent_cmd "guile (define blist (breakpoints))" \
"get breakpoint list 3"
gdb_test "guile (print (breakpoint-thread mult-bkpt))" \
"= #f" "check breakpoint thread"
gdb_test "guile (print (= (breakpoint-type mult-bkpt) BP_BREAKPOINT))" \
"= #t" "check breakpoint type"
gdb_test "guile (print (map breakpoint-number blist))" \
"= \\(1 2 3\\)" "check breakpoint numbers"
}
}
proc test_bkpt_deletion { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_deletion {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![gdb_guile_runto_main] {
return
}
# Test breakpoints are deleted correctly.
set deltst_location [gdb_get_line_number "Break at multiply."]
set end_location [gdb_get_line_number "Break at end."]
gdb_scm_test_silent_cmd "guile (define dp1 (create-breakpoint! \"$deltst_location\"))" \
"create deltst breakpoint"
gdb_breakpoint [gdb_get_line_number "Break at end."]
gdb_scm_test_silent_cmd "guile (define del-list (breakpoints))" \
"get breakpoint list 4"
gdb_test "guile (print (length del-list))" \
"= 3" "number of breakpoints before delete"
gdb_continue_to_breakpoint "Break at multiply." \
".*/$srcfile:$deltst_location.*"
gdb_scm_test_silent_cmd "guile (breakpoint-delete! dp1)" \
"delete breakpoint"
gdb_test "guile (print (breakpoint-number dp1))" \
"ERROR: .*: Invalid object: <gdb:breakpoint> in position 1: #<gdb:breakpoint #2>.*" \
"check breakpoint invalidated"
gdb_scm_test_silent_cmd "guile (set! del-list (breakpoints))" \
"get breakpoint list 5"
gdb_test "guile (print (length del-list))" \
"= 2" "number of breakpoints after delete"
gdb_continue_to_breakpoint "Break at end." ".*/$srcfile:$end_location.*"
}
}
proc test_bkpt_cond_and_cmds { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_cond_and_cmds {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![gdb_guile_runto_main] {
return
}
# Test conditional setting.
set bp_location1 [gdb_get_line_number "Break at multiply."]
gdb_scm_test_silent_cmd "guile (define bp1 (create-breakpoint! \"$bp_location1\"))" \
"create multiply breakpoint"
gdb_continue_to_breakpoint "Break at multiply."
gdb_scm_test_silent_cmd "guile (set-breakpoint-condition! bp1 \"i == 5\")" \
"set condition"
gdb_test "guile (print (breakpoint-condition bp1))" \
"= i == 5" "test condition has been set"
gdb_continue_to_breakpoint "Break at multiply."
gdb_test "print i" \
"5" "test conditional breakpoint stopped after five iterations"
gdb_scm_test_silent_cmd "guile (set-breakpoint-condition! bp1 #f)" \
"clear condition"
gdb_test "guile (print (breakpoint-condition bp1))" \
"= #f" "test condition has been removed"
gdb_continue_to_breakpoint "Break at multiply."
gdb_test "print i" "6" "test breakpoint stopped after six iterations"
# Test commands.
gdb_breakpoint [gdb_get_line_number "Break at add."]
set test {commands $bpnum}
gdb_test_multiple $test $test { -re "\r\n>$" { pass $test } }
set test {print "Command for breakpoint has been executed."}
gdb_test_multiple $test $test { -re "\r\n>$" { pass $test } }
set test {print result}
gdb_test_multiple $test $test { -re "\r\n>$" { pass $test } }
gdb_test "end"
gdb_scm_test_silent_cmd "guile (define blist (breakpoints))" \
"get breakpoint list 6"
gdb_test "guile (print (breakpoint-commands (list-ref blist (- (length blist) 1))))" \
"print \"Command for breakpoint has been executed.\".*print result"
}
}
proc test_bkpt_invisible { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_invisible {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![gdb_guile_runto_main] {
return
}
# Test invisible breakpoints.
delete_breakpoints
set ibp_location [gdb_get_line_number "Break at multiply."]
gdb_scm_test_silent_cmd "guile (define vbp (create-breakpoint! \"$ibp_location\" #:internal #f))" \
"create visible breakpoint"
gdb_scm_test_silent_cmd "guile (define vbp (car (breakpoints)))" \
"get visible breakpoint"
gdb_test "guile (print vbp)" \
"= #<gdb:breakpoint #2 BP_BREAKPOINT enabled noisy hit:0 ignore:0 @.*scm-breakpoint.c:$ibp_location>" \
"check visible bp obj exists"
gdb_test "guile (print (breakpoint-location vbp))" \
"scm-breakpoint\.c:$ibp_location*" "check visible breakpoint location"
gdb_test "guile (print (breakpoint-visible? vbp))" \
"= #t" "check breakpoint visibility"
gdb_test "info breakpoints" \
"scm-breakpoint\.c:$ibp_location.*" \
"check info breakpoints shows visible breakpoints"
delete_breakpoints
gdb_scm_test_silent_cmd "guile (define ibp (create-breakpoint! \"$ibp_location\" #:internal #t))" \
"create invisible breakpoint"
gdb_test "guile (print ibp)" \
"= #<gdb:breakpoint #-$decimal BP_BREAKPOINT enabled noisy hit:0 ignore:0 @.*scm-breakpoint.c:$ibp_location>" \
"check invisible bp obj exists"
gdb_test "guile (print (breakpoint-location ibp))" \
"scm-breakpoint\.c:$ibp_location*" "check invisible breakpoint location"
gdb_test "guile (print (breakpoint-visible? ibp))" \
"= #f" "check breakpoint invisibility"
gdb_test "info breakpoints" \
"No breakpoints or watchpoints.*" \
"check info breakpoints does not show invisible breakpoints"
gdb_test "maint info breakpoints" \
"scm-breakpoint\.c:$ibp_location.*" \
"check maint info breakpoints shows invisible breakpoints"
}
}
proc test_watchpoints { } {
global srcfile testfile hex decimal
with_test_prefix test_watchpoints {
# Start with a fresh gdb.
clean_restart ${testfile}
# Disable hardware watchpoints if necessary.
if [target_info exists gdb,no_hardware_watchpoints] {
gdb_test_no_output "set can-use-hw-watchpoints 0" ""
}
if ![gdb_guile_runto_main] {
return
}
gdb_scm_test_silent_cmd "guile (define wp1 (create-breakpoint! \"result\" #:type BP_WATCHPOINT #:wp-class WP_WRITE))" \
"create watchpoint"
gdb_test "continue" \
".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*main.*" \
"test watchpoint write"
}
}
proc test_bkpt_internal { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_internal {
# Start with a fresh gdb.
clean_restart ${testfile}
# Disable hardware watchpoints if necessary.
if [target_info exists gdb,no_hardware_watchpoints] {
gdb_test_no_output "set can-use-hw-watchpoints 0" ""
}
if ![gdb_guile_runto_main] {
return
}
delete_breakpoints
gdb_scm_test_silent_cmd "guile (define wp1 (create-breakpoint! \"result\" #:type BP_WATCHPOINT #:wp-class WP_WRITE #:internal #t))" \
"create invisible watchpoint"
gdb_test "info breakpoints" \
"No breakpoints or watchpoints.*" \
"check info breakpoints does not show invisible watchpoint"
gdb_test "maint info breakpoints" \
".*watchpoint.*result.*" \
"check maint info breakpoints shows invisible watchpoint"
gdb_test "continue" \
".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*" \
"test invisible watchpoint write"
}
}
proc test_bkpt_eval_funcs { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_eval_funcs {
# Start with a fresh gdb.
clean_restart ${testfile}
# Disable hardware watchpoints if necessary.
if [target_info exists gdb,no_hardware_watchpoints] {
gdb_test_no_output "set can-use-hw-watchpoints 0" ""
}
if ![gdb_guile_runto_main] {
return
}
delete_breakpoints
gdb_test_multiline "data collection breakpoint 1" \
"guile" "" \
"(define (make-bp-data) (cons 0 0))" "" \
"(define bp-data-count car)" "" \
"(define set-bp-data-count! set-car!)" "" \
"(define bp-data-inf-i cdr)" "" \
"(define set-bp-data-inf-i! set-cdr!)" "" \
"(define (bp-eval-count bkpt) (bp-data-count (gsmob-property bkpt 'bp-data)))" "" \
"(define (bp-eval-inf-i bkpt) (bp-data-inf-i (gsmob-property bkpt 'bp-data)))" "" \
"(define (make-bp-eval location)" "" \
" (let ((bp (create-breakpoint! location)))" "" \
" (set-gsmob-property! bp 'bp-data (make-bp-data))" "" \
" (set-breakpoint-stop! bp" "" \
" (lambda (bkpt)" "" \
" (let ((data (gsmob-property bkpt 'bp-data))" "" \
" (inf-i (parse-and-eval \"i\")))" "" \
" (set-bp-data-count! data (+ (bp-data-count data) 1))" "" \
" (set-bp-data-inf-i! data inf-i)" "" \
" (value=? inf-i 3))))" "" \
" bp))" "" \
"end" ""
gdb_test_multiline "data collection breakpoint 2" \
"guile" "" \
"(define (make-bp-also-eval location)" "" \
" (let ((bp (create-breakpoint! location)))" "" \
" (set-gsmob-property! bp 'bp-data (make-bp-data))" "" \
" (set-breakpoint-stop! bp" "" \
" (lambda (bkpt)" "" \
" (let* ((data (gsmob-property bkpt 'bp-data))" "" \
" (count (+ (bp-data-count data) 1)))" "" \
" (set-bp-data-count! data count)" "" \
" (= count 9))))" "" \
" bp))" "" \
"end" ""
gdb_test_multiline "data collection breakpoint 3" \
"guile" "" \
"(define (make-bp-basic location)" "" \
" (let ((bp (create-breakpoint! location)))" "" \
" (set-gsmob-property! bp 'bp-data (make-bp-data))" "" \
" bp))" "" \
"end" ""
set bp_location2 [gdb_get_line_number "Break at multiply."]
set end_location [gdb_get_line_number "Break at end."]
gdb_scm_test_silent_cmd "guile (define eval-bp1 (make-bp-eval \"$bp_location2\"))" \
"create eval-bp1 breakpoint"
gdb_scm_test_silent_cmd "guile (define also-eval-bp1 (make-bp-also-eval \"$bp_location2\"))" \
"create also-eval-bp1 breakpoint"
gdb_scm_test_silent_cmd "guile (define never-eval-bp1 (make-bp-also-eval \"$end_location\"))" \
"create never-eval-bp1 breakpoint"
gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$bp_location2.*"
gdb_test "print i" "3" "check inferior value matches guile accounting"
gdb_test "guile (print (bp-eval-inf-i eval-bp1))" \
"= 3" "check guile accounting matches inferior"
gdb_test "guile (print (bp-eval-count also-eval-bp1))" \
"= 4" \
"check non firing same-location breakpoint eval function was also called at each stop 1"
gdb_test "guile (print (bp-eval-count eval-bp1))" \
"= 4" \
"check non firing same-location breakpoint eval function was also called at each stop 2"
# Check we cannot assign a condition to a breakpoint with a stop-func,
# and cannot assign a stop-func to a breakpoint with a condition.
delete_breakpoints
set cond_bp [gdb_get_line_number "Break at multiply."]
gdb_scm_test_silent_cmd "guile (define eval-bp1 (make-bp-eval \"$cond_bp\"))" \
"create eval-bp1 breakpoint 2"
set test_cond {cond $bpnum}
gdb_test "$test_cond \"foo==3\"" \
"Only one stop condition allowed.*"
gdb_scm_test_silent_cmd "guile (define eval-bp2 (make-bp-basic \"$cond_bp\"))" \
"create basic breakpoint"
gdb_scm_test_silent_cmd "guile (set-breakpoint-condition! eval-bp2 \"1==1\")" \
"set a condition"
gdb_test_multiline "construct an eval function" \
"guile" "" \
"(define (stop-func bkpt)" "" \
" return #t)" "" \
"end" ""
gdb_test "guile (set-breakpoint-stop! eval-bp2 stop-func)" \
"Only one stop condition allowed.*"
# Check that stop-func is run when location has normal bp.
delete_breakpoints
gdb_breakpoint [gdb_get_line_number "Break at multiply."]
gdb_scm_test_silent_cmd "guile (define check-eval (make-bp-eval \"$bp_location2\"))" \
"create check-eval breakpoint"
gdb_test "guile (print (bp-eval-count check-eval))" \
"= 0" \
"test that evaluate function has not been yet executed (ie count = 0)"
gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$bp_location2.*"
gdb_test "guile (print (bp-eval-count check-eval))" \
"= 1" \
"test that evaluate function is run when location also has normal bp"
# Test watchpoints with stop-func.
gdb_test_multiline "watchpoint stop func" \
"guile" "" \
"(define (make-wp-eval location)" "" \
" (let ((wp (create-breakpoint! location #:type BP_WATCHPOINT #:wp-class WP_WRITE)))" "" \
" (set-breakpoint-stop! wp" "" \
" (lambda (bkpt)" "" \
" (let ((result (parse-and-eval \"result\")))" "" \
" (value=? result 788))))" "" \
" wp))" "" \
"end" ""
delete_breakpoints
gdb_scm_test_silent_cmd "guile (define wp1 (make-wp-eval \"result\"))" \
"create watchpoint"
gdb_test "continue" ".*\[Ww\]atchpoint.*result.*Old value =.*New value = 788.*" \
"test watchpoint write"
# Misc final tests.
gdb_test "guile (print (bp-eval-count never-eval-bp1))" \
"= 0" \
"check that this unrelated breakpoints eval function was never called"
}
}
test_bkpt_basic
test_bkpt_deletion
test_bkpt_cond_and_cmds
test_bkpt_invisible
test_watchpoints
test_bkpt_internal
test_bkpt_eval_funcs