iraf-v216 · Code · Issues (50) · Pull requests (81)
iraf.net pull request #98
Fix linenumber generation with xpp -x (rpp and spp)
olebole merged 3 commits to iraf-community/iraf
olebole commented on 2017-09-20
Currently, the line number calculation of xc is wrong:
File hello.x
(line numbers added):
1 # HELLO -- Sample program introducing SPP.
2 task hello = t_hello_world
3 procedure t_hello_world ()
4 begin
5 call printf ("Hello,world!\n")
6 end
Source code line 5 ends up marked as line 7 in the Fortran file:
$ xc -x -f hello.x
sys_runtask:
t_hello_world:
$ tail -22 hello.f|head -11
subroutine thelld ()
integer*2 st0001(14)
save
integer iyy
data (st0001(iyy),iyy= 1, 8) / 72,101,108,108,111, 44,119,111/
data (st0001(iyy),iyy= 9,14) /114,108,100, 33, 10, 0/
#line 7 "hello.x"
call xprinf(st0001)
100 call zzepro
return
end
First, when begin
is parsed, the end of line \n
is not eaten up. In fact, there may be code following after begin
on the same line; this is placed after xpp in the line after begin
. If nothing follows the begin
statement on the same line, an empty line is added. This means, that linenum
must not increase here; it is increased when the \n
of this line is found.
Similar argument for parsing a task
line; linenum
must not increase here as well.
Also, when processing include files, an additional ‘\n’ is included, which is later counted. To revert this effect, linenum
has to be decreased here as well.
When parsing .help
… .endhelp
however, one linenum
increase was missing, which is added now.
Another problem is that the resulting intermediate file (output of spp; input for rpp) may contain content from include files, f.e. lib/sysruk.x
. The line number protocol between spp and rpp does not allow to specify filenames, and spp suppresses the line number output of include files. However, rpp then interprets these lines as coming from the original file name and this way assigns wrong line numbers. Since files are included (explicitly or implicitly) in the beginning of the source file, this is pragmatically solved by supressing the output of line numbers before an explicit line number has been set by spp.
This (re-) enables the possibility to directly debug SPP code (note that the flag to enable debugging in xc is -x
, not -g
):
$ xc -x hello.x
sys_runtask:
t_hello_world:
$ gdb ./hello.e
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
[...]
Reading symbols from ./hello.e...done.
(gdb) b thelld_
Breakpoint 1 at 0x38e7: file hello.x, line 5.
(gdb) r
Starting program: ./hello.e
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> hello
Breakpoint 1, thelld_ () at hello.x:5
5 call printf ("Hello,world!\n")
(gdb) n
Hello,world!
6 end
(gdb)
Connected to this, the wrong debug flag given in irafuser.sh
is corrected as well.
I also added a test for the proper line number generation to #36.
Commits
- Fix linenum calculation in xpp [7325b359]
- Fix XC debug flag [c999fc4b]
- Dont output line numbers before they were set first [db81ba67]
Last updated on 2017-10-06