From 261cbad16f5ed8a975d5b2d76eaa064b19452e70 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Tue, 10 Sep 2013 16:39:13 +1000 Subject: [PATCH] test and briefly document DB::goto --- MANIFEST | 1 + pod/perldebguts.pod | 7 +++++++ t/lib/Devel/switchd_goto.pm | 6 ++++++ t/run/switchd.t | 13 ++++++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 t/lib/Devel/switchd_goto.pm diff --git a/MANIFEST b/MANIFEST index 895d263..c040aa2 100644 --- a/MANIFEST +++ b/MANIFEST @@ -5034,6 +5034,7 @@ t/lib/deprecate/Optionally.pm Optionally deprecated module to test deprecate.pm t/lib/deprecate.t Test deprecate.pm t/lib/Devel/nodb.pm Module for t/run/switchd.t t/lib/Devel/switchd_empty.pm Module for t/run/switchd.t +t/lib/Devel/switchd_goto.pm Module for t/run/switchd.t t/lib/Devel/switchd.pm Module for t/run/switchd.t t/lib/feature/bundle Tests for feature bundles t/lib/feature/implicit Tests for implicit loading of feature.pm diff --git a/pod/perldebguts.pod b/pod/perldebguts.pod index ff9f97b..4c684d2 100644 --- a/pod/perldebguts.pod +++ b/pod/perldebguts.pod @@ -98,6 +98,13 @@ C<&DB::sub>(I) is made instead, with C<$DB::sub> holding the name of the called subroutine. (This doesn't happen if the subroutine was compiled in the C package.) +=item * + +When execution of the program uses C to enter a non-XS +subroutine and the 0x80 bit is set in C<$^P>, a call to C<&DB::goto> +is made, with C<$DB::sub> holding the name of the subroutine being +entered. + =back Note that if C<&DB::sub> needs external data for it to work, no diff --git a/t/lib/Devel/switchd_goto.pm b/t/lib/Devel/switchd_goto.pm new file mode 100644 index 0000000..d9df2e2 --- /dev/null +++ b/t/lib/Devel/switchd_goto.pm @@ -0,0 +1,6 @@ +package Devel::switchd_goto; +package DB; +sub DB { $^P |= 0x80; } +sub goto { print "goto<$DB::sub>;" } +1; + diff --git a/t/run/switchd.t b/t/run/switchd.t index b3a7364..e71de68 100644 --- a/t/run/switchd.t +++ b/t/run/switchd.t @@ -9,7 +9,7 @@ BEGIN { require "./test.pl"; } # This test depends on t/lib/Devel/switchd*.pm. -plan(tests => 13); +plan(tests => 14); my $r; @@ -200,3 +200,14 @@ like( 'PERL5DB with embedded newlines', ); } + +# test that DB::goto works +is( + runperl( + switches => [ '-Ilib', '-d:switchd_goto' ], + prog => 'sub baz { print qq|hello;| } sub foo { goto &baz } foo()', + stderr => 1, + ), + "goto;hello;", + "DB::goto" +); -- 1.8.3.1