From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,16e3a8dd4f3ab3f3 X-Google-Attributes: gid103376,public From: Laurent.Guerby@enst-bretagne.fr (Laurent Guerby) Subject: IO in Pure packages, debugging Date: 1996/03/26 Message-ID: <4xivfrimzk.fsf_-_@leibniz.enst-bretagne.fr>#1/1 X-Deja-AN: 144358928 distribution: world sender: guerby@leibniz.enst-bretagne.fr references: <314829CD.4FA9@lfwc.lockheed.com> content-type: text/plain; charset=US-ASCII organization: Telecom Bretagne mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-03-26T00:00:00+00:00 List-Id: [subject changed] Robert A Duff writes : : In article <4xspevde88.fsf@leibniz.enst-bretagne.fr>, : Laurent Guerby wrote: : > Here is a simple solution to this kind of problem : : > : >package Pure_IO is : > pragma Pure; : > : > procedure Debug (Msg : in String); : > pragma Import (C, Debug); : > : >end Pure_IO; : > : > Then do the dirty work (body) in Ada (convention C) or C. : : Excellent idea! Thanks. : : Does it really work? I mean you're sort of cheating here. That's more that cheating, I play a "pervert" game here ;-) : You've declared that the thing is Pure, but you've lied. So the optimizer : might play nasty tricks, like eliminating calls to Debug, if the only : effect of Debug is its "side effect". : I guess it's OK to cheat like that, since it's "merely" debugging code. : But one has to be careful, in case one's optimizer is smarter that one : is ;-). Just put "in out" instead of "in" to avoid this kind of optimization (but then you havve to declare the messages as variables somewhere, no big deal). : > It's true that the current GDB-GNAT has some weakpoints, but if you : >add to your code (instead of plenty ugly "with Text_IO; Put_Line ...") : >some "extra" procedures to set up complex data structures and to print : >them (just like in the GNAT code anyway) it works quite well : : Yes, I do add all kinds of printing routines, and call them from gdb : when necessary. My version of gdb, which might not be the latest, : doesn't even know how to print strings. It prints a pair of addresses, : instead of the characters of the string. Just update it (20 minutes of compilation ;-). The current version is quite efficient, the only problem is for tagged types, but if you have written some dump routines there's no problem at all (worked for me for tagged + tasking + multiple partitions). [deleted] : Thanks for the help. : : - Bob -- -- Laurent Guerby, student at Telecom Bretagne (France), Team Ada -- "Use the Source, Luke. The Source will be with you, always (GPL)" -- http://www-eleves.enst-bretagne.fr/~guerby/ (GATO Project) -- Try GNAT, the GNU Ada 95 compiler (ftp://cs.nyu.edu/pub/gnat)