Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perl5db.pl: handling of undefined watch_expressions in _DB__handle_watch_expressions() #22207

Open
hexcoder- opened this issue May 10, 2024 · 1 comment

Comments

@hexcoder-
Copy link

(This is just an observation, not necessarily a bug.)

perl5db.pl as of commit c60ffc1

Module: perl5db.pl

Description

Reviewing the code for _DB__handle_watch_expressions()

sub _DB__handle_watch_expressions

I found that using join here
my ($val) = join( "', '", DB::eval(@_) );

makes $val always defined, since join always returns a (possibly empty) defined string.

Then in the following line

$val = ( ( defined $val ) ? "'$val'" : 'undef' );

the false branch is never applied.

So maybe watchpoint expressions with result "undefined" are not reported correctly.

======================
My main motivation for looking here, was the behavior of watchpoints with regard to package scope changes.

In my application I had
my %hash;
along with some imported modules.

When my hash was populated completely (and should be constant afterwards), I wanted to see where and when $hash{'myEntry'} changed unexpectedly. But using a watchpoint w $hash{'myEntry'} in the debugger led to a lot of unwanted breaks: each time the package/module scope changed the visibility of %hash changed also, of course.

How these visibility changes can be ignored in watchpoint breaks, I do not not know yet (should this be another bug report?).

@hexcoder- hexcoder- changed the title perl5db.pl: handling of undefined _DB__handle_watch_expressions() perl5db.pl: handling of undefined watch_expressions in_DB__handle_watch_expressions() May 10, 2024
@hexcoder- hexcoder- changed the title perl5db.pl: handling of undefined watch_expressions in_DB__handle_watch_expressions() perl5db.pl: handling of undefined watch_expressions in _DB__handle_watch_expressions() May 10, 2024
@tonycoz
Copy link
Contributor

tonycoz commented May 21, 2024

The visibility thing sound like a separate problem.

So maybe watchpoint expressions with result "undefined" are not reported correctly.

That looks like a regression introduced with the debugger refactor around 2012.

This changed the code from:

	my ($val) = &eval;	# Fix context (&eval is doing array)?
	$val = ( (defined $val) ? "'$val'" : 'undef' );

to what it is now:

            my ($val) = join( "', '", DB::eval(@_) );
            $val = ( ( defined $val ) ? "'$val'" : 'undef' );

I expect the fix is something like:

            my $val = join( ", ", map { defined ? "'$_'" : "undef" } DB::eval(@_) );           

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants