Mail Archives: djgpp/2001/04/08/21:15:27
Eli Zaretskii wrote:
[...]
> 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.
Here is a much smaller program that also demonstrates
a terrible slowdown under gdb. That is, the program
below takes much more than 10 times as long to run under gdb.
----------------------------------
#include <iostream>
int count = 0;
int i, j, k;
unsigned long ii, jj, mm;
class Paths {
public:
static void car7()
{
for( i=0; i<10; i++) {
cout << "car7, i=" << i << '\n';
ii = i;
for( j=0; j<100; j++) {
jj = j | ii;
for( k=0; k<10000; k++) {
mm = jj | k;
if ( mm == 127)
if ( ++count < 5)
cout << "car7: " << (i*100+j)*10000+k << '\n';
}
}
}
}
};
int main()
{
cout << "Calling car7\n";
Paths::car7();
cout << "all done.\n";
}
-----------------------------------
I compile the program with:
gxx -g -Os -Wall test.cpp -o test.exe
Then I run it from the command line like this:
test
It completes in less than 1/2 second.
It writes 16 short lines.
Then I run it under gdb like this:
gdb test.exe
break main
run
n
After 20 seconds it has only produced 3 lines of output.
The program does not allocate any memory in the
function car7.
Clearly there is something wrong somewhere.
Can anyone tell me how to fix this?
Dennis Yelle
--
I am a computer programmer and I am looking for a job.
There is a link to my resume here:
http://table.jps.net/~vert/
- Raw text -