cin and read(*,*) not waiting for kbd input in gdb

Rockefeller, Harry Harry.Rockefeller@flightsafety.com
Thu Jan 16 21:03:00 GMT 2020


Both the Fortran and cpp used to work correctly when run in gdb.
FWIW, Both Fortran and cpp work correctly, stopping for keyboard input, when run outside of gdb.

But now, code simply doesn't stop to take keyboard input inside gdb.

I've tried simplifying cpp problem with simple code.
e.g.
#include <iostream> // to enable terminal printout
#include <cmath>    // pow function
int main() {
  float request_time_to_run(void);
  float a=0.0f;
  a = request_time_to_run();
  printf ("a is %f\n", a);
}
float request_time_to_run() {
  float tm = 0.0;        // Time duration (sec)
  std::string ans = "";  // interactive answer for time duration
  std::cout << "Supply the equivalent of runtime in seconds. \n";
  std::cout << "Note: time=0 will stop main. \n";
  std::cin >> ans;
  if ( (int)(ans[0]) < 48 || (int)(ans[0] > 57) ) {
    tm = 1.0;
  } else {
    int i;
    int j = 0;
    tm = 0.0;
    for (i=ans.length() - 1; i>=0; i--) {
      tm += ((int)(ans[i]) - 48) * pow( 10, j++);
    }
  }
  return tm;
}

But, simple stuff does run correctly in gdb stopping for terminal input at
  std::cin >> ans;
FWIW, for simple cpp above neither the cout nor the cin works directly (not running in gdb).

But with complicated code using gdb step by step into this line eventually shows this:
"/wip/cygport-git/gdb/gdb-8.2.1-1.x86_64/src/gdb-8.2.1/gdb/infrun.c:2723: internal-error: void resume_1(gdb_signal): Assertion `pc_in_thread_step_range (pc, tp)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable."

Where the gdb line-of-code pointer is here:
      virtual std::streamsize
      xsputn(const char_type* __s, std::streamsize __n);

      virtual int
      sync()
 >     { return std::fflush(_M_file); }

      virtual std::streampos
      seekoff(std::streamoff __off, std::ios_base::seekdir __dir,
      std::ios_base::openmode = std::ios_base::in | std::ios_base::out)
      {

When I run the fortran software and do gdb step by step into the line having the read(*,*)
There seems to be an infinite loop.  So when I just send the gdb continue
it fails with this info:
At line 40 of file jhx.f (unit = 5, file = 'stdin')
Fortran runtime error: End of file

Error termination. Backtrace:
#0  0xffffffffffffffff in ???
#1  0xffffffffffffffff in ???
#2  0xffffffffffffffff in ???
#3  0xffffffffffffffff in ???
#4  0xffffffffffffffff in ???
#5  0xffffffffffffffff in ???
#6  0xffffffffffffffff in ???
#7  0xffffffffffffffff in ???
#8  0xffffffffffffffff in ???
#9  0xffffffffffffffff in ???
#10  0xffffffffffffffff in ???
#11  0xffffffffffffffff in ???
#12  0xffffffffffffffff in ???
[Thread 7872.0x1e20 exited with code 2]
[Thread 7872.0x20f0 exited with code 2]
[Thread 7872.0x1b80 exited with code 2]
[Thread 7872.0x3e8 exited with code 2]
[Inferior 1 (process 7872) exited with code 02]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 130689 bytes
Desc: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20200116/b7eba161/attachment.obj>
-------------- next part --------------

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list