www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/04/07:00:57

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Tracking down where GPFs occur . How? (DJGPP+Allegro)
Date: Tue, 04 Nov 1997 12:09:58 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 48
Message-ID: <345F1096.3B47@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
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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

P.S.:  A quick piece of advice:  first, use lowercase to describe your
filenames; .CPP and .HPP are not valid C or C++ filename extensions. 
Second, putting actual code in header files is a BAD THING (tm).

-- 
---------------------------------------------------------------------
|      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 |
---------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019