I have update branch. Do some fix and create testcase.
Now you can run
/perl/lib $ PERL5DB='BEGIN{ require "./perl5db.pl" }' perl -Iperl5db/t -d
perl5db/t/apply_users_pragma_when_eval
ACTUAL RESULTS:
Loading DB routines from perl5db.pl version 1.49_03
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(perl5db/t/apply_users_pragma_when_eval:5):
5: my $l = MyMaths->new(1.2);
DB<1> n
main::(perl5db/t/apply_users_pragma_when_eval:6):
6: my $r = MyMaths->new(3.4);
DB<1> n
main::(perl5db/t/apply_users_pragma_when_eval:7):
7: print "A: ", $l + $r, "\n";
DB<1> n
A: 4.6
main::(perl5db/t/apply_users_pragma_when_eval:9):
9: print "B: ", $l + $r, "\n";
10: {
DB<1> n
B: 4 <<<<<<<<<<< NOTICE HERE
main::(perl5db/t/apply_users_pragma_when_eval:11):
11: no myint;
DB<1> print "B: ", $l + $r, "\n";
B: 4.6
BUT EXPECTED:
B: 4
http://perldoc.perl.org/perlpragma.html
A: 4.6
B: 4
C: 4.6
D: 4
E: 4.6
28.03.2016, 14:38, "Shlomi Fish" <[email protected]>:
> Hi KES,
>
> First of all, note that you should not E-mail me at [email protected].
> E-mail
> me only at [email protected] . Where did you find the @iglu.org.il
> address?
>
> See below for the rest of my reply.
>
> On Mon, 28 Mar 2016 11:21:10 +0300
> KES <[email protected]> wrote:
>
>> Hi.
>>
>> When from debugger we evaluate some expression the user's context pragma is
>> not applyed.
>>
>> This patch fixes that:
>> https://github.com/KES777/perl/tree/apply_users_context_pragma
>
> I'm not sure I understand. Can you also include new test assertions (see
> lib/perl5db.t and lib/perl5db/t/ in the Perl distribution) that will fail
> before the changes to the production code and will pass after applying them?
> See:
>
> * https://en.wikipedia.org/wiki/Test-driven_development
>
> * http://perl-begin.org/uses/qa/
>
>> Need help with one problem, can not watch variables when the debugging
>> script.pl has 'use strict' in effect.
>>
>> Variable "$x" is not imported at (eval 10)[./perl5db.pl:740] line 1.
>> at (eval 10)[./perl5db.pl:740] line 1.
>> eval 'BEGIN{ ( $^H, ${^WARNING_BITS} ) = @DB::saved[7,8]; }($@, $!,
>> $^E, $,, $/, $\\, $^W) = @DB::saved;package main; $x; ' called
>> at ./perl5db.pl line 740 DB::eval called at ./perl5db.pl line 6051
>> DB::_add_watch_expr("\$x") called at ./perl5db.pl line 6071
>> DB::cmd_w("w", "\$x", 6) called at ./perl5db.pl line 4488
>> DB::cmd_wrapper("w", "\$x", 6) called at ./perl5db.pl line 3999
>> DB::Obj::_handle_cmd_wrapper_commands(DB::Obj=HASH(0x26593c0))
>> called
>> at ./perl5db.pl line 2881 DB::DB called at /home/kes/tmp/t3.pl line 6
>> Global symbol "$x" requires explicit package name (did you forget to
>> declare
>> "my $x"?) at (eval 10)[./perl5db.pl:740] line 1.
>
> I don't understand.
>
>> But here the design problem because of next:
>> An eval '' executed within a subroutine defined in the DB package doesn't
>> see
>> the usual surrounding lexical scope, but rather the scope of the first
>> non-DB
>> piece of code that called it
>>
>> As we can see from stacktrace the 'first non-DB piece of code' is
>> DB::Obj::_handle_cmd_wrapper_commands(DB::Obj=HASH(0x26593c0))
>> called
>> at ./perl5db.pl line 2881
>>
>> So if we want $x be evaled at user's context the DB::DB *SHOULD NOT* call
>> to
>> DB::Obj namespace.
>
> Not sure I understand (again). Can you provide a test case?
>
> Regards,
>
> Shlomi Fish
>
> --
> -----------------------------------------------------------------
> Shlomi Fish
>
> “Stop reinventing wheels, start building space rockets.”
> — The motto of the Comprehensive Perl Archive Network