simpleodbc upgrade

2017-02-15
4 days ago
  • steve williams

    steve williams - 2017-02-15

    I'm trying to upgrade simpleodbc to work with the latest compiler.

    The simpleodbc preprocessor generates COBOL to COBOL calls that look like the following:

            >>SOURCE FORMAT IS FREE
    identification division.
    program-id. TestCall.
    procedure division.
    start-testcall.
        call 'TestCall1' using by reference 'abc' by value 1.
        stop run.
    identification division.
    program-id. TestCall1.
    data division.
    linkage section.
    01  stringparm any length.
    01  numparm pic 999 binary-long.
    procedure division using by reference stringparm by value numparm.
    start-testcall1.
       display stringparm
       display numparm
       goback
       .
    end program TestCall1.
    end program TestCall.
    

    test

    This doesn't work

    I could generate code to move the parameters to a common area and then pass the common area to the subroutine.

    What should I do?

    Steve Williams

    ---
    Mod edit for colour listing

     
    Last edit: Brian Tiffin 2017-02-16
    • David Wall

      David Wall - 2017-02-16

      It works for me - I did the following.
      1. Moved the >>source format to start in column 8.
      2. Removed the pic 999.

      I get the following results:

      abc
      +0000000001

      What do you get ??

       
  • steve williams

    steve williams - 2017-02-16

    David,

    You're right, that does work.

    Thanks for your reply.

    Steve Williams

     
  • steve williams

    steve williams - 4 days ago

    The shell script in the attached directory terminates with a compile failure.

     
    • Brian Tiffin

      Brian Tiffin - 4 days ago

      Move

      01  length-value binary-long.
      

      to the linkage section, Steve, and it'll compile.

      By spec 14.2

      PROCEDURE DIVISION [ using-phrase ] [ RETURNING data-name-2 ]
      

      14.2.2 5)

      Data-name-2 shall be defined as a level 01 entry or
      level 77 entry in the linkage section.
      

      And it can't be the same identifier as any of the USING parameters, 14.2.2 6).

      Cheers,
      Brian

       
  • steve williams

    steve williams - 4 days ago

    Thank you Brian.

     
  • steve williams

    steve williams - 4 days ago

    Unfortunately, no joy:

    working-storage section.
    copy SODBCWS.
    01 x binary-short.
    01 Column-Id.
    03 Column-Pointer pointer.
    linkage section.
    copy SODBCCA.
    01 Column-Value any length.
    01 length-value binary-long.

    procedure division using
    by reference odbc-control
    by reference Column-Value
    returning length-value
    .

    steve@steve-Lenovo-Z50-75:~/Desktop/cobol/Simpleodbc2/Compile$ ./SODBCTest.sh
    SODBCTest.cob: 3659: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 248: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 670: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 671: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 672: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 673: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 674: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 762: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 763: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 764: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 919: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed

    attempt to reference unallocated memory (signal SIGSEGV)

    cobc: aborting compile of SODBC.cbl at line 1059
    steve@steve-Lenovo-Z50-75:~/Desktop/cobol/Simpleodbc2/Compile$

     
    • Brian Tiffin

      Brian Tiffin - 4 days ago

      Hrrm, I don't get that result here. (I've added -w to drop the warnings)

      prompt$ cobc -w SODBCTest.cob SODBC.cbl -x
      
      prompt$ ls -l
      -rwxrwxr-x  1 btiffin btiffin 375416 Feb 24 13:26 SODBCTest
      
      prompt$ $ ./SODBCTest
      
      start SODBCTest
      
      test driver =============================
      libcob: cannot find module 'SQLAllocHandle'
      

      (Not having the rest of the suite compiled, the Test fails, but loads and runs).

      I was on -rc3 rev 1427, just compiled to rev 1428 and it still works here.

      Sorry, Steve, it might be time for some digging. And these types of errors might require some gdb and a debug build of cobc

      prompt$ ./configure --enable-debug
      prompt$ make; make check
      prompt$ sudo make install
      prompt$ sudo ldconfig
      

      (That ldconfig is important after source builds, otherwise ld.so cache is in an indeterminant state and you can end up executing who knows what code, including misaligned machine instructions)

      Then the fun begins

      prompt$ gdb -q cobc
      Reading symbols from cobc...done.
      (gdb) start -x SODBCTest.cob SODBC.cbl -w
      Temporary breakpoint 1 at 0x4114bc: file cobc.c, line 6622.
      Starting program: /usr/local/bin/cobc -x SODBCTest.cob SODBC.cbl -w
      
      Temporary breakpoint 1, main (argc=5, argv=0x7fffffffdbd8) at cobc.c:6622
      6622    {
      (gdb) cont
      Continuing.
      [Inferior 1 (process 5245) exited normally]
      

      gdb pass (the -q just avoids the gdb banner)

      Of course, I can't show you what the backtrace will look like, as this didn't crash so ...

      (gdb) bt
      No stack.
      

      backtrace

      In short, start with prompt$ gdb cobc then inside gdb do start (args passed to cobc)

      When the code halts on the default breakpoint of main type, cont in gdb to continue the compile. When it borks, there should be a better clue as to where your local install of cobc is failing, and bt can be used to get a backtrace. And then Simon, Ed, Ron, or I can dig in on a fix. Assuming it isn't a local config issue that you can fix at your end.

      Start with a clean checkout and rebuild first though, as that SODBTest code compiles here.

      Cheers,
      Brian

       
      Last edit: Brian Tiffin 4 days ago
  • steve williams

    steve williams - 4 days ago
    steve@steve-Lenovo-Z50-75:~/Desktop/cobol/Simpleodbc2/Compile$ gdb -q cobc
    Reading symbols from cobc...done.
    (gdb) start -x SODBCTest.cob SODBC.cbl -w
    Temporary breakpoint 1 at 0x246e2: file cobc.c, line 5810.
    Starting program: /usr/local/bin/cobc -x SODBCTest.cob SODBC.cbl -w
    warning: the debug information found in "/lib64/ld-2.24.so" does not match "/lib64/ld-linux-x86-64.so.2" (CRC mismatch).
    
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    
    Temporary breakpoint 1, main (argc=5, argv=0x7fffffffded8) at cobc.c:5810
    5810    {
    (gdb) cont
    Continuing.
    SODBCTest.cob: 3659: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 248: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 670: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 671: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 672: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 673: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 674: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 762: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 763: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 764: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    SODBC.cbl: 919: warning: handling of parameters passed BY VALUE is unfinished; implementation is likely to be changed
    
    Program received signal SIGSEGV, Segmentation fault.
    0x00005555555b3f64 in lookup_attr ()
    (gdb) bt
    #0  0x00005555555b3f64 in lookup_attr ()
    #1  0x00005555555b6bfb in output_attr ()
    #2  0x00005555555bb72d in output_param ()
    #3  0x00005555555be00d in output_funcall ()
    #4  0x00005555555b9825 in output_stmt ()
    #5  0x00005555555b97f9 in output_stmt ()
    #6  0x00005555555b923a in output_stmt ()
    #7  0x00005555555c3749 in output_internal_function ()
    #8  0x00005555555c5b03 in codegen ()
    #9  0x00005555555c621d in codegen ()
    #10 0x00005555555c621d in codegen ()
    #11 0x00005555555c621d in codegen ()
    #12 0x00005555555c621d in codegen ()
    #13 0x00005555555c621d in codegen ()
    #14 0x00005555555c621d in codegen ()
    #15 0x00005555555c621d in codegen ()
    #16 0x00005555555c621d in codegen ()
    #17 0x00005555555c621d in codegen ()
    #18 0x00005555555c621d in codegen ()
    #19 0x00005555555c621d in codegen ()
    #20 0x00005555555c621d in codegen ()
    #21 0x00005555555c621d in codegen ()
    #22 0x00005555555c621d in codegen ()
    ---Type <return> to continue, or q <return> to quit---
    #23 0x00005555555c621d in codegen ()
    #24 0x00005555555c621d in codegen ()
    #25 0x0000555555577852 in process_translate (fn=0x555555835578) at cobc.c:5200
    #26 0x0000555555579555 in main (argc=5, argv=0x7fffffffded8) at cobc.c:6265
    (gdb) 
    (gdb) q
    A debugging session is active.
    
        Inferior 1 [process 6680] will be killed.
    
    Quit anyway? (y or n) y
    steve@steve-Lenovo-Z50-75:~/Desktop/cobol/Simpleodbc2/Compile$ cobc -V
    cobc (GnuCOBOL) 2.0.0
    Copyright (C) 2016 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
    Built     Feb 24 2017 19:22:51
    Packaged  Nov 06 2016 22:36:19 UTC
    C version "6.2.0 20161005"
    

    ---
    Mod edit for formatting

     
    Last edit: Brian Tiffin 4 days ago
    • Brian Tiffin

      Brian Tiffin - 3 days ago

      Thanks, Steve.

      Awesome debugging.

      (The CRC mismatch is likely unrelated, and is a sign that you have an out of synch libc6 and libc6-dbg, which just means some symbol names may not line up with addresses, so that is not likely a problem here, but you may want to take a look at libc6 and libc6-dbg synch, just because).

      Now, can I ask you to try a later version, pulled out of SVN? Your code compiles fine here, so this problem may already be fixed.

      I'm not up on all the recent changes, so we might have to wait for Edward and/or Simon and Ron to notice this thread. That backtrace is really good info. In the meanwhile, if you are stuck, I'd suggest a new svn update and rebuild to see if that lets you continue with the port to 2.0 (which will be 2.2 shortly, there will be a version bump when 2.0-rc3 goes to final).

      Cheers,
      Brian

       
      Last edit: Brian Tiffin 3 days ago
  • steve williams

    steve williams - 3 days ago

    Brian,

    I've never installed the comipler from source. Here's what I get from make test:

    Comparing total test results
    diff ./summary.txt summary.log
    4,14c4,14
    < NC 95 95 0 0 4393 0 4 1 4398
    < SM 17 17 0 0 291 0 2 1 294
    < IC 25 25 0 0 246 0 4 0 250
    < SQ 85 85 0 0 518 0 0 89 607
    < RL 35 35 0 0 1827 0 5 0 1832
    < IX 42 42 0 0 507 0 1 0 508
    < ST 40 40 0 0 288 0 0 0 288
    < SG 13 13 0 0 310 0 0 0 310
    < OB 7 7 0 0 39 0 0 0 39
    < IF 45 45 0 0 733 0 0 0 733
    < DB 16 16 0 0 418 0 4 27 449


    NC 95 95 0 0 2 0 0 0 2
    SM 17 17 0 0 0 0 0 0 0
    IC 25 25 0 0 0 0 0 0 0
    SQ 85 85 0 0 0 0 0 0 0
    RL 35 35 0 0 0 0 0 0 0
    IX 42 42 0 0 0 0 0 0 0
    ST 40 40 0 0 10 0 0 0 10
    SG 13 13 0 0 0 0 0 0 0
    OB 7 7 0 0 1 0 0 0 1
    IF 45 45 0 0 1 0 0 0 1
    DB 16 16 0 0 4 0 0 0 4
    16c16
    < Total 420 420 0 0 9570 0 20 118 9708


    Total 420 420 0 0 18 0 0 0 18
    Makefile:523: recipe for target 'test' failed
    make[2]: [test] Error 1
    make[2]: Leaving directory '/home/steve/Desktop/cobol/Simpleodbc2/Compile/open-cobol-code-1428-branches-gnu-cobol-2.0/tests/cobol85'
    Makefile:739: recipe for target 'test' failed
    make[1]:
    [test] Error 2
    make[1]: Leaving directory '/home/steve/Desktop/cobol/Simpleodbc2/Compile/open-cobol-code-1428-branches-gnu-cobol-2.0/tests'
    Makefile:1021: recipe for target 'test-only' failed
    make: *** [test-only] Error 2
    steve@steve-Lenovo-Z50-75:~/Desktop/cobol/Simpleodbc2/Compile/open-cobol-code-1428-branches-gnu-cobol-2.0$

     
  • steve williams

    steve williams - 2 days ago

    Brian,

    In the SODBC.cbl source, program-id SODBCTable, call 'SQLTables' statement, the variable table-length was not defined.

    Correcting this error removed the compiler abort.

    Thank you for your help.

    Steve Williams

    ~~~~cobol
    call 'SQLTables' using by value hStmt
    by reference catalog
    by value catalog-length
    by reference schema
    by value schema-length
    by reference table-name
    by value TABLE-LENGTH
    by reference table-type
    *> TABLE, VIEW, SYSTEM TABLE, ALIAS or SYNONYM
    by value table-type-length
    end-call
    ~~~~text

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks