diff options
Diffstat (limited to 'gdb/testsuite/gdb.guile')
-rw-r--r-- | gdb/testsuite/gdb.guile/scm-section-script.c | 38 | ||||
-rw-r--r-- | gdb/testsuite/gdb.guile/scm-section-script.exp | 45 |
2 files changed, 78 insertions, 5 deletions
diff --git a/gdb/testsuite/gdb.guile/scm-section-script.c b/gdb/testsuite/gdb.guile/scm-section-script.c index e668a4942c4..cbff69882be 100644 --- a/gdb/testsuite/gdb.guile/scm-section-script.c +++ b/gdb/testsuite/gdb.guile/scm-section-script.c @@ -19,18 +19,52 @@ #include "gdb/section-scripts.h" /* Put the path to the pretty-printer script in .debug_gdb_scripts so - gdb will automagically loaded it. */ + gdb will automagically loaded it. + Normally "MS" would appear here, as in + .pushsection ".debug_gdb_scripts", "MS",@progbits,1 + but we remove it to test files appearing twice in the section. */ #define DEFINE_GDB_SCRIPT(script_name) \ asm("\ -.pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n\ +.pushsection \".debug_gdb_scripts\", \"S\",@progbits\n\ .byte " XSTRING (SECTION_SCRIPT_ID_SCHEME_FILE) "\n\ .asciz \"" script_name "\"\n\ .popsection \n\ "); +#ifndef SCRIPT_FILE +#error "SCRIPT_FILE not defined" +#endif + +/* Specify it twice to verify the file is only loaded once. */ +DEFINE_GDB_SCRIPT (SCRIPT_FILE) DEFINE_GDB_SCRIPT (SCRIPT_FILE) +/* Inlined scripts are harder to create in the same way as + DEFINE_GDB_SCRIPT_FILE. Keep things simple and just define it here. + Normally "MS" would appear here, as in + .pushsection ".debug_gdb_scripts", "MS",@progbits,1 + but we remove it to test scripts appearing twice in the section. */ + +#define DEFINE_GDB_SCRIPT_TEXT \ +asm( \ +".pushsection \".debug_gdb_scripts\", \"S\",@progbits\n" \ +".byte " XSTRING (SECTION_SCRIPT_ID_SCHEME_TEXT) "\n" \ +".ascii \"gdb.inlined-script\\n\"\n" \ +".ascii \"(define test-cmd\\n\"\n" \ +".ascii \" (make-command \\\"test-cmd\\\"\\n\"\n" \ +".ascii \" #:command-class COMMAND_OBSCURE\\n\"\n" \ +".ascii \" #:invoke (lambda (self arg from-tty)\\n\"\n" \ +".ascii \" (display (format #f \\\"test-cmd output, arg = ~a\\n\\\" arg)))))\\n\"\n" \ +".ascii \"(register-command! test-cmd)\\n\"\n" \ +".byte 0\n" \ +".popsection\n" \ +); + +/* Specify it twice to verify the script is only executed once. */ +DEFINE_GDB_SCRIPT_TEXT +DEFINE_GDB_SCRIPT_TEXT + struct ss { int a; diff --git a/gdb/testsuite/gdb.guile/scm-section-script.exp b/gdb/testsuite/gdb.guile/scm-section-script.exp index 93a10a0d462..8c04ac80b79 100644 --- a/gdb/testsuite/gdb.guile/scm-section-script.exp +++ b/gdb/testsuite/gdb.guile/scm-section-script.exp @@ -53,14 +53,51 @@ gdb_start if { [skip_guile_tests] } { continue } gdb_reinitialize_dir $srcdir/$subdir -gdb_test_no_output "set auto-load safe-path ${remote_guile_file}" \ + +# Try first with a restrictive safe-path. + +gdb_test_no_output "set auto-load safe-path /restricted" \ + "set restricted auto-load safe-path" +gdb_load ${binfile} + +# Verify gdb did not load the scripts. +set test_name "verify scripts not loaded" +gdb_test_multiple "info auto-load guile-scripts" "$test_name" { + -re "Yes.*${testfile}.scm.*Yes.*inlined-script.*$gdb_prompt $" { + fail "$test_name" + } + -re "No.*${testfile}.scm.*No.*inlined-script.*$gdb_prompt $" { + pass "$test_name" + } +} + +# Try again with a working safe-path. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +gdb_test_no_output "set auto-load safe-path ${remote_guile_file}:${binfile}" \ "set auto-load safe-path" gdb_load ${binfile} -# Verify gdb loaded the script. -gdb_test "info auto-load guile-scripts" "Yes.*${testfile}.scm.*" +# Verify gdb loaded each script and they appear once in the list. +set test_name "verify scripts loaded" +gdb_test_multiple "info auto-load guile-scripts" "$test_name" { + -re "${testfile}.scm.*${testfile}.scm.*$gdb_prompt $" { + fail "$test_name" + } + -re "inlined-script.*inlined-script.*$gdb_prompt $" { + fail "$test_name" + } + -re "Yes.*${testfile}.scm.*Yes.*inlined-script.*$gdb_prompt $" { + pass "$test_name" + } +} + # Again, with a regexp this time. gdb_test "info auto-load guile-scripts ${testfile}" "Yes.*${testfile}.scm.*" + # Again, with a regexp that matches no scripts. gdb_test "info auto-load guile-scripts no-script-matches-this" \ "No auto-load scripts matching no-script-matches-this." @@ -74,3 +111,5 @@ gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \ gdb_test "continue" ".*Breakpoint.*" gdb_test "print ss" " = a=<1> b=<2>" + +gdb_test "test-cmd 1 2 3" "test-cmd output, arg = 1 2 3" |