www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/08/17:51:54

Date: Sun, 08 Apr 2001 23:49:08 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: Dennis Yelle <dennis51 AT jps DOT net>
Message-Id: <4634-Sun08Apr2001234906+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: djgpp AT delorie DOT com
In-reply-to: <3AD0B992.44D0D3C3@jps.net> (message from Dennis Yelle on Sun, 08
Apr 2001 12:18:42 -0700)
Subject: Re: gdb still doesn't work for me
References: <3AD0B992 DOT 44D0D3C3 AT jps DOT net>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: Dennis Yelle <dennis51 AT jps DOT net>
> Newsgroups: comp.os.msdos.djgpp
> Date: Sun, 08 Apr 2001 12:18:42 -0700
> 
> I ran the program, like this:
>     test > z
> It finished in less than 1 second.
> 
> I ran gdb like this:
>   gdb test.exe
>   break main
>   n
>   n
>   n
>   n
>   n
>   n
>   n
> At this point, the program produces about 64 lines of
> output to the screen, but I noticed a significant pause
> every 4th line.
> The total of all of the pauses was far more than 1 second.
> So, it seems to me that the program is running significantly slower
> under gdb than when run alone.

No, GDB doesn't slow down programs, unless the program does something
very special, such as issues a lot of DPMI function calls, or
generates lots of SIGFPE exceptions.

Normal programs don't do that.  But your program, especially its car5
function, allocates lots of memory in very small chunks (because it
creates lots of temporary Bset objects), which forces the library to
requests lots of small allocations from the DPMI server.  Each such
allocation gets caught by GDB, because it needs to be aware of all
memory allocated by the program being debugged, to be able to
deallocate that memory if the program is restarted without exiting the
debugger.  This causes a huge overhead, which is why you see this
terrible slowdown.

> Is it a known problem that programs run very slowly when
> run under gdb?

Not normally, no.

>    Does gdb have problems with programs that are more than 
>    512 lines long?

I'm routinely debugging programs that have hundreds of thousands of
source lines, and I have yet to see any problems.

> 2. I removed the -Os from the compile line.
>    The problem went away.
>    Does gdb have problems with -Os ?

No.  But it's possible that code generated under -Os tends to allocate
memory in a different pattern, so that the number of memory
allocations is different.  Looking at the assembly generated by the
compiler (using the -S option to GCC) might reveal the differences in
the code with and without -Os.

- Raw text -


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