home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / sun / misc / 5843 < prev    next >
Encoding:
Text File  |  1992-12-14  |  2.5 KB  |  60 lines

  1. Newsgroups: comp.sys.sun.misc
  2. Path: sparky!uunet!utcsri!newsflash.concordia.ca!mizar.cc.umanitoba.ca!thompsn
  3. From: thompsn@ccu.umanitoba.ca (Adam Thompson)
  4. Subject: Re: debugging programs compiled with pc
  5. Message-ID: <BzA7B0.Dpp@ccu.umanitoba.ca>
  6. Sender: news@ccu.umanitoba.ca
  7. Nntp-Posting-Host: ccu.umanitoba.ca
  8. Organization: University of Manitoba, Winnipeg, Canada
  9. References: <1992Dec9.231642.15897@ida.liu.se>
  10. Date: Tue, 15 Dec 1992 03:35:23 GMT
  11. Lines: 47
  12.  
  13. In <1992Dec9.231642.15897@ida.liu.se> davpa@ida.liu.se (David Partain) writes:
  14.  
  15. >I'm trying to help a student here who's having difficulty debugging
  16. >pascal.  The symptoms are very frustrating, and I haven't looked at
  17. >pascal in years, so I'm turning to y'all to see if you have seen the
  18. >problem before.
  19.  
  20. >Platform:
  21. >SunOS 4.1.2, Sparcs, using PC-2.1
  22.  
  23. >Symptoms:
  24. >Bunches of .o files, compiled with -g as they should be.
  25. >Some functions seem to have symbols, some don't.  I start up the
  26. >debugger (doesn't matter whether I use gdb, dbx, or ups), and try to
  27. >break in a function.  Guess what? It doesn't know about that function.
  28. >Of course, the function from which it was called it DOES know about, and
  29. >it's in the same supposedly debuggable executable.  dbx can't even list
  30. >the function, whereas gdb can.  this seems to be a result of being a
  31. >function called by a function called by the main program, but I don't
  32. >know.  Have any of you seen anything like this before?  Can anyone tell
  33. >me what needs to be done so that we can debug pascal?
  34.  
  35. (sorry about the extensive quoting...)
  36.  
  37. The solution is a bit obscure -- ld(1) appears to generate a symbol
  38. table that contains only identifiers declared at the 'main' level.
  39. I think it is referenced as 'Program' instead of 'main'.  A systematic
  40. fix is to have your main file consist of:
  41.  
  42.     #include <external_defs.h>
  43.  
  44.     begin
  45.       mainline;
  46.     end.
  47. and have the file external_defs.h (or .p or whatever you feel like!)
  48. contain 'external' definitions of all functions.  That main file should
  49. be compiled separately, and linked with mainline.o.  This should allow
  50. dbx, at least to figure things out correctly.  If you use gdb
  51. extensively, you should be aware that it works a *lot* better if you
  52. specify the modula-2 as the language instead of C.
  53.  
  54. -Adam Thompson
  55.  thompsn@ccu.umanitoba.ca
  56. -- 
  57. +----------------------------------------------------------------------+
  58. | Adam Thompson        University of Manitoba        Computer Services |
  59. | thompsn@ccu.umanitoba.ca                    OLC Project - Unix Group |
  60.