Mail Archives: djgpp/2001/04/08/17:51:54
> 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 -