From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Tracking down where GPFs occur . How? (DJGPP+Allegro) Date: Tue, 04 Nov 1997 12:07:58 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 44 Message-ID: <345F101E.674@cs.com> References: <63m4mh$qjl$1 AT news DOT interlog DOT com> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp225.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Gautam N. Lad wrote: > > Hi, > Is there any way to determine where a program is causing a GPF? > I get all the code like General Protection Fault at eip=(whatever). > and some other (unknown to me) stuff. > > Could this be used to pinpoint where in a program's source (hopefully a .CPP/.C > or .HPP/.H) it's happening? The DJGPP FAQ has a whole chapter devoted to debugging (chapter 12). The first thing you learn is what all that "garbage" on the screen really means. It's a complete register dump and stack traceback of your program at the moment of the crash. With the proper tools, you can use this information to localize the crash and determine why it happened. Basic instructions: - READ THE FAQ!!!! - Make sure to compile your program with the '-g' switch to add full debugging information. - When the crash traceback is on the screen, type 'symify myprog.exe', where myprog.exe is the name of your program's executable. - Symify will display on the screen the functions and line numbers of the points indicated on the stack traceback. The topmost line tells you where the crash occurred. - Look in your code at that line to see what the problem is. Fix it. - If you can't tell from looking at your code, try running it under a debugger. RHIDE has an integrated debugger, or you can download v2gnu/gdb416b.zip, which contains a standalone debugger. Instructions can be found online. (debugging Allegro programs is more difficult; look in the Allegro docs for instructions) - If all else fails, distill your code to the smallest compilable fragment that causes the crash and post it here. hth -- --------------------------------------------------------------------- | John M. Aldrich | "Autocracy is based on the assumption| | aka Fighteer I | that one man is wiser than a million | | mailto:fighteer AT cs DOT com | men. Let's play that over again, | | http://www.cs.com/fighteer | too. Who decides?" - Lazarus Long | ---------------------------------------------------------------------