Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!unixhub!ditka!comeau From: comeau@ditka.Chicago.COM (Greg Comeau) Newsgroups: comp.sys.amiga.programmer Subject: Re: Debugging C++ Message-ID: <38579@ditka.Chicago.COM> Date: 10 May 91 14:30:19 GMT References: <1991May5.222328.16225@csis.dit.csiro.au> <616@lysator.liu.se> <38542@ditka.Chicago.COM> Sender: comeau@ditka.Chicago.COM (Greg Comeau) Reply-To: comeau@csanta.attmail.com (Greg Comeau) Organization: Comeau Computing Lines: 80 Previous "debugging C++" thread have been expired from this machine (which is unfortunate since I wanted to address some specific points some of you made/asked about). Nevertheless, it's created enough interest that I've felt y'all need an answer. So. Given: #include int a = -3; main() { printf("hello, world\n"); printf("a=%d\n", a); } we generate output like: #line 1 "c.c" /* <> */ /* < c.c > */ #line 1 "c.c" char *__vec_new (); #line 1 "c.c" char __vec_delete (); typedef int (*__vptp)(); struct __mptr {short d; short i; __vptp f; }; #line 1 "c.c" #line 6 "work:aztec/include/stdarg.h" typedef char *va_list ; #line 10 "work:aztec/include/stdio.h" typedef unsigned long size_t ; #line 34 "work:aztec/include/stdio.h" typedef long fpos_t ; #line 45 "work:aztec/include/stdio.h" typedef struct __stdio FILE ; #line 36 "work:aztec/include/stdio.h" struct __stdio { /* sizeof __stdio == 24 */ unsigned char *_bp__7__stdio ; unsigned char *_bend__7__stdio ; unsigned char *_buff__7__stdio ; unsigned short _flags__7__stdio ; char _unit__7__stdio ; unsigned char _bytbuf__7__stdio ; size_t _buflen__7__stdio ; unsigned short _tmpnum__7__stdio ; }; extern struct __stdio _iob []; #line 3 "c.c" int a = -3; extern struct __mptr* __ptbl_vec__c_c_a_[]; #line 76 "work:aztec/include/stdio.h" extern int printf (); #line 5 "c.c" int main (){ _ConStrucT(); #line 6 "c.c" { #line 7 "c.c" printf ( (char *)"hello, world\n") ; printf ( (char *)"a=%d\n", a ) ; } } #line 9 "c.c" /* the end */ With the prodding that's been visible here, I went and did a quicky compile of c.c with como (our command line driver) both with a SAS C back-end and with as still in-house not released Manx C back-end (surprise!) with debugging turned on. In the Manx sdb case, it worked like a champ. In the SAS CPR case it displayed the proper file but appears the the debugging information contained line number relative to the top of the generated C file and did not pick up the #line line numbers. Most likely I did not use the right SAS C debugging switch as I've yet to see this technique fail yet (and I'm convinced that I did this before we released the SAS back end one). - Greg -- Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418 Producers of Comeau C++ 2.1 Here:attmail.com!csanta!comeau / BIX:comeau / CIS:72331,3421 Voice:718-945-0009 / Fax:718-441-2310