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

perldebguts.pod description of scalar ${"_<$filename"} doesnt match code #14776

Open
p5pRT opened this issue Jun 26, 2015 · 3 comments
Open

perldebguts.pod description of scalar ${"_<$filename"} doesnt match code #14776

p5pRT opened this issue Jun 26, 2015 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 26, 2015

Migrated from rt.perl.org#125492 (status was 'open')

Searchable as RT125492$

@p5pRT
Copy link
Author

p5pRT commented Jun 26, 2015

From @bulk88

Created by @bulk88

This ticket is related to
https://rt.perl.org/Public/Bug/Display.html?id=125296

perldebguts says

---------------------------------------------------
=item *

Each scalar C<${"_<$filename"}> contains C<"_<$filename">. This is
also the case for evaluated strings that contain subroutines, or
which are currently being executed. The $filename for C<eval>ed
strings looks like C<(eval 34)>.
---------------------------------------------------

This is not true.

---------------------------------------------------
BEGIN {$^P |=2;}
use warnings;
use Data​::Dumper;
use Devel​::Peek 'Dump';
$Data​::Dumper​::Sortkeys = 1;

print Dumper(${'​::_<Peek.c'});
print Dumper(${'​::_<C​:/perl521/srcnewb4opt/lib/Data/Dumper.pm'});
eval q|
print Dumper(${'​::_<(eval 3)'});|;
---------------------------------------------------
$VAR1 = 'Peek.c';
$VAR1 = 'C​:/perl521/srcnewb4opt/lib/Data/Dumper.pm';
$VAR1 = '(eval 3)';
---------------------------------------------------

That perldebguts item came from commit
http​://perl5.git.perl.org/perl.git/commitdiff/36477c247f3c188fb8cc7e276c87b739d3e6ab7c
"[inseparable changes from patch from perl5.003_10 to perl5.003_11]" and
specifically "10+ debugger patch" . I think that POD was based off a
comment in
http​://perl5.git.perl.org/perl.git/commitdiff/55497cffdd24c959994f9a8ddd56db8ce85e1c5b
  "[inseparable changes from patch from perl5.003_07 to perl5.003_08]"
specifically "Major '..' and debugger patches".

The actual C code that determines {SCALAR} contains a normal path and
not a "_<" path came from day 1 of gv_fetchfile in "perl 5.0 alpha 2"
http​://perl5.git.perl.org/perl.git/commitdiff/79072805bf63abe5b5978b5928ab00d360ea3e7f
which came from a function called fstab which is a near clone of
gv_fetchfile. fstab came from "perl 3.0 patch #34 patch #29, continued"
http​://perl5.git.perl.org/perl.git/commitdiff/0a12ae7dee71b6eb0609c35185096ab75c95b2da
. fstab was first used 1 commit ahead in at
http​://perl5.git.perl.org/perl.git/commitdiff/395c379347344a50494d2458b3a5e38ebdeac851
.

Most shocking is changing gv_fetchfile to store the "_<" path in SCALAR,
does not cause any tests to fail on a harness run.

------------------------BEFORE----------------------------------
GV *
Perl_gv_fetchfile_flags(pTHX_ const char *const name, const STRLEN namelen,
  const U32 flags)
{
  char smallbuf[128];
  char *tmpbuf;
  const STRLEN tmplen = namelen + 2;
  GV *gv;

  PERL_ARGS_ASSERT_GV_FETCHFILE_FLAGS;
  PERL_UNUSED_ARG(flags);

  if (!PL_defstash)
  return NULL;

  if (tmplen <= sizeof smallbuf)
  tmpbuf = smallbuf;
  else
  Newx(tmpbuf, tmplen, char);
  /* This is where the debugger's %{"​::_<$filename"} hash is created */
  tmpbuf[0] = '_';
  tmpbuf[1] = '<';
  memcpy(tmpbuf + 2, name, namelen);
  gv = *(GV**)hv_fetch(PL_defstash, tmpbuf, tmplen, TRUE);
  if (!isGV(gv)) {
  gv_init(gv, PL_defstash, tmpbuf, tmplen, FALSE);
#ifdef PERL_DONT_CREATE_GVSV
  GvSV(gv) = newSVpvn(name, namelen);
#else
  sv_setpvn(GvSV(gv), name, namelen);
#endif

------------------------AFTER----------------------------------
GV *
Perl_gv_fetchfile_flags(pTHX_ const char *const name, const STRLEN namelen,
  const U32 flags)
{
  char smallbuf[128];
  char *tmpbuf;
  const STRLEN tmplen = namelen + 2;
  GV *gv;

  PERL_ARGS_ASSERT_GV_FETCHFILE_FLAGS;
  PERL_UNUSED_ARG(flags);

  if (!PL_defstash)
  return NULL;

  if (tmplen <= sizeof smallbuf)
  tmpbuf = smallbuf;
  else
  Newx(tmpbuf, tmplen, char);
  /* This is where the debugger's %{"​::_<$filename"} hash is created */
  tmpbuf[0] = '_';
  tmpbuf[1] = '<';
  memcpy(tmpbuf + 2, name, namelen);
  gv = *(GV**)hv_fetch(PL_defstash, tmpbuf, tmplen, TRUE);
  if (!isGV(gv)) {
  gv_init(gv, PL_defstash, tmpbuf, tmplen, FALSE);
#ifdef PERL_DONT_CREATE_GVSV
  GvSV(gv) = newSVpvn(tmpbuf, tmplen);
#else
  sv_setpvn(GvSV(gv), tmpbuf, tmplen);
#endif
  }
----------------------------------------------------------

So it seems either the SCALAR part of the "_<" glob is unused by core
(maybe it should be deleted to save memory leaving only the hash and
array parts of the "_<" glob?), or is never used during a harness run
(perl5db.pl has no tests).

So my question is, fix the POD to match the code, or fix the code to
match the POD, or delete the code/feature entirely since its been unused
for 22 years?

Perl Info
---	
Flags:
                 category=core
                 severity=low

Site configuration information for perl 5.21.4:

Configured by Owner at Thu Sep 18 12:08:58 2014.

Summary of my perl5 (revision 5 version 21 subversion 4) configuration:
               Derived from: 7d2b2edb94ab56333b9049a3e26d15ea18445512
               Ancestor: 19be3be6968e2337bcdfe480693fff795ecd1304
               Platform:
                 osname=MSWin32, osvers=5.1,
archname=MSWin32-x86-multi-thread
                 uname=''
                 config_args='undef'
                 hint=recommended, useposix=true, d_sigaction=undef
                 useithreads=define, usemultiplicity=define
                 use64bitint=undef, use64bitall=undef, uselongdouble=undef
                 usemymalloc=n, bincompat5005=undef
               Compiler:
                 cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG
-DWIN32
-D_CONSOLE -DNO_STRICT  -DPERL_TEXTMODE_SCRIPTS
-DPERL_HASH_FUNC_ONE_AT_A_TIME -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T',
                 optimize='-O1 -MD -Zi -DNDEBUG',
                 cppflags='-DWIN32'
                 ccversion='12.00.8168', gccversion='', gccosandvers=''
                 intsize=4, longsize=4, ptrsize=4, doublesize=8,
byteorder=1234
                 d_longlong=undef, longlongsize=8, d_longdbl=define,
longdblsize=8,
longdblkind=0
                 ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='__int64',
lseeksize=8
                 alignbytes=8, prototype=define
               Linker and Libraries:
                 ld='link', ldflags ='-nologo -nodefaultlib -debug
-opt:ref,icf
-libpath:"c:\perl521\lib\CORE"  -machine:x86'
                 libpth=C:\PROGRA~1\MIAF9D~1\VC98\lib
                 libs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
                 perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
                 libc=msvcrt.lib, so=dll, useshrplib=true,
libperl=perl521.lib
                 gnulibc_version=''
               Dynamic Linking:
                 dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef,
ccdlflags=' '
                 cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib
-debug
-opt:ref,icf  -libpath:"c:\perl521\lib\CORE"  -machine:x86'

Locally applied patches:
                 uncommitted-changes
                 a0fe7a7e75de29e59f1da0d6822dc06e5be658fe
                 a261faffee83d0145642ab5d1d046c9f813bc497
                 6506ab86ad1602a9ca720fcd30446dce1461d23d
                 7d2b2edb94ab56333b9049a3e26d15ea18445512


@INC for perl 5.21.4:
                 lib
                 C:/perl521/srcnew/lib
                 .


Environment for perl 5.21.4:
                 HOME (unset)
                 LANG (unset)
                 LANGUAGE (unset)
                 LD_LIBRARY_PATH (unset)
                 LOGDIR (unset)
                 PATH=
                 PERL_BADLANG (unset)
                 PERL_JSON_BACKEND=Cpanel::JSON::XS
                 PERL_YAML_BACKEND=YAML
                 SHELL (unset)


@p5pRT
Copy link
Author

p5pRT commented Jun 27, 2015

From @rjbs

* bulk88 <perlbug-followup@​perl.org> [2015-06-26T18​:40​:56]

So it seems either the SCALAR part of the "_<" glob is unused by core
(maybe it should be deleted to save memory leaving only the hash and
array parts of the "_<" glob?), or is never used during a harness run
(perl5db.pl has no tests).

Shooting from the hip​: fix the docs to match the code. The current behavior
seems more useful.

Oh, and add a test. :-)

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Jun 27, 2015

The RT System itself - Status changed from 'new' to 'open'

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