reading the expanded C for "hello, world\n"

32 views
Skip to first unread message

Raoul Duke

unread,
Dec 14, 2014, 3:53:36 AM12/14/14
to ats-lang-users
is, well, kind of scary. (I have similar feelings of scaryness when I
use haxe to generate other languages as back-end output.)

Do people really have success using GDB on the resulting C to debug
their original ATS program? I'd be a little more comfortable with the
whole "just shut your eyes and pretend C is assembly that you
hopefully will never have to look at as if your life depended on it"
if there were a debugger at the ATS source level.

(I realize that many functional languages often lack a source level
debugger. Though, even Haskell got some debugging work from Neil
Mitchell I think. ML has either PolyML's debugger, or the Ocaml or F#
route. JVM-targeted languages tend to have debuggers I guess.)

thanks.

Brandon Barker

unread,
Dec 14, 2014, 8:18:48 AM12/14/14
to ats-lang-users
I think debugging is rare in ATS; I also worried about this, but never actually ended up needing to use one. Of course, I spent a lot of time dealing with the typechecking, but once that was fixed, the only problems I had were able to be dealt with without a debugger.

Maybe in the future a debugger based on a checkpoint/restart solution could be used if ATS gets an interpreter.


--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAJ7XQb6ZLOWp966nm-NueNN-x8kKca4EFPprmyFQ3Dg5jScw5Q%40mail.gmail.com.


--
Brandon Barker
brandon...@gmail.com

Artyom Shalkhakov

unread,
Dec 14, 2014, 11:29:36 AM12/14/14
to ats-lan...@googlegroups.com

I debugged ATS1 compiler once, using GDB. It was quite unproductive, mainly because GDB was to be dealt with.

Debugging ATS can be useful. For instance, it can be helpful to quickly narrow down on some relevant parts of the program by observing its behaviour at run-time (especially if such a program is large, and the time constraints are tight).

I have some code for dealing with JS sourcemaps (mainly VLQ/Base64 encoding at this point) -- beware, I have not run it, only made sure it type-checks. The end goal is to be able to debug atscc2js-compiled programs using off the shelf JS tools. If anybody is interested in picking it up, I'll create a repo or a gist.

Does anybody know of anything similar to JS sourcemaps for C?

thanks.

gmhwxi

unread,
Dec 14, 2014, 2:21:56 PM12/14/14
to ats-lan...@googlegroups.com
Part of the reason is that you saw a lot of macros in the C output.
Following is the JS output converted from the C output for the Hello example.
A lot less scary, right :)

/*
**
** The JavaScript code is generated by atscc2js
** The starting compilation time is: 2014-12-14: 14h:17m
**
*/


function
hello
()
{
//
// knd = 0
//
 
// __patsflab_hello
  ats2jspre_print_string
("Hello, world!");
 
return/*_void*/;
} // end-of-function

// dynloadflag_init
var _057_tmp_057_patsopt_ccats_OLjWLU__dynloadflag = 0;

function
_057_tmp_057_patsopt_ccats_OLjWLU__dynload
()
{
//
// knd = 0
//
 
// ATSdynload()
 
// ATSdynloadflag_sta(_057_tmp_057_patsopt_ccats_OLjWLU__dynloadflag(14))
 
if(ATSCKiseqz(_057_tmp_057_patsopt_ccats_OLjWLU__dynloadflag)) {
    _057_tmp_057_patsopt_ccats_OLjWLU__dynloadflag
= 1 ; // flag is set
    hello
();
 
} // endif
 
return/*_void*/;
} // end-of-function


function
my_dynload
()
{
//
// knd = 0
//
  _057_tmp_057_patsopt_ccats_OLjWLU__dynload
();
 
return/*_void*/;
} // end-of-function


/* ATSextcode_beg() */
// COMMENT_line

ats2jspre_the_print_store_clear
();
my_dynload
();
alert
(ats2jspre_the_print_store_join());
// COMMENT_line

/* ATSextcode_end() */

/* ****** ****** */

/* end-of-compilation-unit */

gmhwxi

unread,
Dec 14, 2014, 2:57:08 PM12/14/14
to ats-lan...@googlegroups.com
Due to very heavy use of templates in ATS2, using GDB on the C code
generated from ATS2 source can be incredibly challenging. This is a place
where an IDE can help a lot. Without a proper tool, I find it so difficult trying
to figure out how the code for a particular instance is generated.
Reply all
Reply to author
Forward
0 new messages