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

Debugger loses record of last input filehandle #649

Closed
p5pRT opened this issue Sep 21, 1999 · 2 comments
Closed

Debugger loses record of last input filehandle #649

p5pRT opened this issue Sep 21, 1999 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 21, 1999

Migrated from rt.perl.org#1522 (status was 'resolved')

Searchable as RT1522$

@p5pRT
Copy link
Author

p5pRT commented Sep 21, 1999

From Richard@waveney.demon.co.uk

This is a fault when using the debugger. Using eof to test the end file of
the current input, works at full speed, but not when stepping through using
the debugger. It attempts to read from the terminal when it encounters the
eof. It is never eof on the terminal, and the CR is then buffered for the
next debugger command. I suspect the fault would affect other things that
depend on the notion of "Current input filehandle".

ILLUSTRATION​:

*type BugTest
open (IN,"BugTest");
while (<IN>) { print "Lines $.\n" if eof }

*perl BugTest
Lines 2

*perl -d BugTest

Loading DB routines from perl5db.pl version 1.0402
Emacs support available.

Enter h or `h h' for help.

main​::(BugTest​:1)​: open (IN,"BugTest");
  DB<1> s
main​::(BugTest​:2)​: while (<IN>) { print "Lines $.\n" if eof }
  DB<1>
  main​::(BugTest​:2)​: while (<IN>) { print "Lines $.\n" if eof }
  DB<1>

  main​::(BugTest​:2)​: while (<IN>) { print "Lines $.\n" if eof }
  DB<1> main​::(BugTest​:2)​: while (<IN>) { print "Lines $.\n" if eof }
  DB<1>

  main​::(BugTest​:2)​: while (<IN>) { print "Lines $.\n" if eof }
  DB<1> Debugged program terminated. Use q to quit or R to restart,
  use O inhibit_exit to avoid stopping after program termination,
  h q, h R or h O to get additional info.
  DB<1> q
 
*

REASON

The record of the last input filehandle is overridden, when the debugger
gets the next command.

PROBLEM / SOLUTION

The output file handle can be found and restored by using select. There
appears to be no direct equivalent method for the input filehandle.

However according to the perlvar if "$." is localised this has the effect of
localising perls notion of "last read file handle". Therefore the solution
may be adding a "local $." at an appropriate point. I can't work out where,
(I tried a few places with no apparent affect) nor am I sure that this will
fix the bug.

Ilya?

*perl -V
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration​:
  Platform​:
  osname=riscos, osvers=3.7, archname=arm-riscos
  uname='riscos bagpuss.unfortu.net 3.7 ROMPatches2.04 arc arm StrongARM,riscpc'
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  Compiler​:
  cc='gcc', optimize='-O2', gccversion=2.7.2
  cppflags=''
  ccflags ='-O2 -mthrowback -munixlib -IUnix​: -I. -ILib​:Zlib -DCONSERVATIVE
  -DDEBUGGING -DNICK_SIG_HACK -DREQUIRE_CAN_UNZIP'
  stdchar='unsigned char', d_stdstdio=undef, usevfork=true
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
  alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries​:
  ld='drlink', ldflags ='-o $@​ -rescan'
  libpth=
  libs=
  libc=, so=no, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=ro, d_dlsymun=undef, ccdlflags=''
  cccdlflags='', lddlflags=''

Characteristics of this binary (from libperl)​:
  Compile-time options​: DEBUGGING
  Built under riscos
  Compiled at Apr 17 1999 16​:32​:47
  @​INC​:
  /PerlPrivLib​:zip
  /PerlArchLib​:
  /PerlPrivLib​:
  /PerlSiteArchLib​:
  /PerlSiteLib​:
  .

--

Richard@​waveney.demon.co.uk

1 similar comment
@p5pRT
Copy link
Author

p5pRT commented Sep 21, 1999

From Richard@waveney.demon.co.uk

This is a fault when using the debugger. Using eof to test the end file of
the current input, works at full speed, but not when stepping through using
the debugger. It attempts to read from the terminal when it encounters the
eof. It is never eof on the terminal, and the CR is then buffered for the
next debugger command. I suspect the fault would affect other things that
depend on the notion of "Current input filehandle".

ILLUSTRATION​:

*type BugTest
open (IN,"BugTest");
while (<IN>) { print "Lines $.\n" if eof }

*perl BugTest
Lines 2

*perl -d BugTest

Loading DB routines from perl5db.pl version 1.0402
Emacs support available.

Enter h or `h h' for help.

main​::(BugTest​:1)​: open (IN,"BugTest");
  DB<1> s
main​::(BugTest​:2)​: while (<IN>) { print "Lines $.\n" if eof }
  DB<1>
  main​::(BugTest​:2)​: while (<IN>) { print "Lines $.\n" if eof }
  DB<1>

  main​::(BugTest​:2)​: while (<IN>) { print "Lines $.\n" if eof }
  DB<1> main​::(BugTest​:2)​: while (<IN>) { print "Lines $.\n" if eof }
  DB<1>

  main​::(BugTest​:2)​: while (<IN>) { print "Lines $.\n" if eof }
  DB<1> Debugged program terminated. Use q to quit or R to restart,
  use O inhibit_exit to avoid stopping after program termination,
  h q, h R or h O to get additional info.
  DB<1> q
 
*

REASON

The record of the last input filehandle is overridden, when the debugger
gets the next command.

PROBLEM / SOLUTION

The output file handle can be found and restored by using select. There
appears to be no direct equivalent method for the input filehandle.

However according to the perlvar if "$." is localised this has the effect of
localising perls notion of "last read file handle". Therefore the solution
may be adding a "local $." at an appropriate point. I can't work out where,
(I tried a few places with no apparent affect) nor am I sure that this will
fix the bug.

Ilya?

*perl -V
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration​:
  Platform​:
  osname=riscos, osvers=3.7, archname=arm-riscos
  uname='riscos bagpuss.unfortu.net 3.7 ROMPatches2.04 arc arm StrongARM,riscpc'
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  Compiler​:
  cc='gcc', optimize='-O2', gccversion=2.7.2
  cppflags=''
  ccflags ='-O2 -mthrowback -munixlib -IUnix​: -I. -ILib​:Zlib -DCONSERVATIVE
  -DDEBUGGING -DNICK_SIG_HACK -DREQUIRE_CAN_UNZIP'
  stdchar='unsigned char', d_stdstdio=undef, usevfork=true
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
  alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries​:
  ld='drlink', ldflags ='-o $@​ -rescan'
  libpth=
  libs=
  libc=, so=no, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=ro, d_dlsymun=undef, ccdlflags=''
  cccdlflags='', lddlflags=''

Characteristics of this binary (from libperl)​:
  Compile-time options​: DEBUGGING
  Built under riscos
  Compiled at Apr 17 1999 16​:32​:47
  @​INC​:
  /PerlPrivLib​:zip
  /PerlArchLib​:
  /PerlPrivLib​:
  /PerlSiteArchLib​:
  /PerlSiteLib​:
  .

--

Richard@​waveney.demon.co.uk

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

1 participant