Skip to content
Kiwamu Okabe edited this page May 28, 2019 · 2 revisions

As default, binary compiled by ATS2 has C language's debugging data:

$ cd ~/src/ATS-Postiats/doc/BOOK/INT2PROGINATS/CODE/CHAP_POLYMORPH
$ patscc -g -DATS_MEMALLOC_LIBC mergesort.dats
$ gdb a.out
(gdb) l
8609    #ifndef _ATS_CCOMP_RUNTIME_TRYWITH_NONE_
8610    #include "pats_ccomp_runtime_trywith.c"
8611    #endif /* _ATS_CCOMP_RUNTIME_TRYWITH_NONE_ */
8612    #endif // end of [_ATS_CCOMP_EXCEPTION_NONE_]
8613    #endif /* _ATS_CCOMP_RUNTIME_NONE_ */
8614
8615    /*
8616    ** the [main] implementation
8617    */
8618    int

But, if compile it with --gline option, the binary has ATS language's debugging data:

$ patscc --gline -g -DATS_MEMALLOC_LIBC mergesort.dats
$ gdb a.out
(gdb) l
323     *)
324     implement
325     {a}(*tmp*)
326     fprint_listlist_sep
327       (out, xss, sep1, sep2) = let
328     //
329     implement
330     fprint_val<List0_(a)>
331       (out, xs) = let
332       val xs = $UN.cast{List0(a)}(xs)
(gdb) b mergesort.dats:114
Breakpoint 1 at 0x1be4: mergesort.dats:114. (2 locations)
(gdb) i b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   <MULTIPLE>         
1.1                         y     0x0000000000001be4 in split_3__3__1 at /home/kiwamu/src/ATS-Postiats/doc/BOOK/INT2PROGINATS/CODE/CHAP_POLYMORPH/mergesort.dats:114
1.2                         y     0x000000000000279f in split_3__3__2 at /home/kiwamu/src/ATS-Postiats/doc/BOOK/INT2PROGINATS/CODE/CHAP_POLYMORPH/mergesort.dats:114
(gdb) run
Starting program: /home/kiwamu/src/ATS-Postiats/doc/BOOK/INT2PROGINATS/CODE/CHAP_POLYMORPH/a.out 
input:  219, 656, 828, 348, 70, 506, 923, 578, 736, 315

Breakpoint 1, split_3__3__1 (arg0=0x55555555c260, arg1=10, arg2=0x555555555f92 <__patsfun_70>, arg3=5, arg4=0x0)
    at /home/kiwamu/src/ATS-Postiats/doc/BOOK/INT2PROGINATS/CODE/CHAP_POLYMORPH/mergesort.dats:114
114       val xsf = list0_reverse<a> (xsf) // make sorting stable!
(gdb) l
109       val-cons0 (x, xs) = xs
110     in
111       split (xs, n, lte, i-1, cons0{a}(x, xsf))
112     end // end of [then]
113     else let
114       val xsf = list0_reverse<a> (xsf) // make sorting stable!
115       val xsf = msort (xsf, n/2, lte) and xs = msort (xs, n-n/2, lte)
116     in
117       merge<a> (xsf, xs, lte)
118     end // end of [else]
(gdb) bt
#0  split_3__3__1 (arg0=0x55555555c260, arg1=10, arg2=0x555555555f92 <__patsfun_70>, arg3=5, arg4=0x0)
    at /home/kiwamu/src/ATS-Postiats/doc/BOOK/INT2PROGINATS/CODE/CHAP_POLYMORPH/mergesort.dats:114
#1  0x0000555555555b08 in msort_2__2__1 (arg0=0x55555555c260, arg1=10, arg2=0x555555555f92 <__patsfun_70>)
    at /home/kiwamu/src/ATS-Postiats/doc/BOOK/INT2PROGINATS/CODE/CHAP_POLYMORPH/mergesort.dats:99
#2  0x00005555555559f7 in mergesort_1__1__1 (arg0=0x55555555c260, arg1=0x555555555f92 <__patsfun_70>)
    at /home/kiwamu/src/ATS-Postiats/doc/BOOK/INT2PROGINATS/CODE/CHAP_POLYMORPH/mergesort.dats:123
#3  0x0000555555555555 in mainats_0_void () at /home/kiwamu/src/ATS-Postiats/doc/BOOK/INT2PROGINATS/CODE/CHAP_POLYMORPH/mergesort.dats:189
#4  0x0000555555557176 in main (argc=1, argv=0x7fffffffd548, envp=0x7fffffffd558) at /home/kiwamu/src/ATS-Postiats/prelude/DATS/list.dats:339
Clone this wiki locally