Laziness

David Lecomber
2005-10-10T20:46:15Z

Hi Folks,

Take a simple code with a big array...

#include <stdio.h>
int main()
{
double x[1000][1000];
printf("hello mum");
}

and ask gdb to "set print elements 1", then break at the printf, and say
"output x".

It takes a while.. (not as much as it used to on Linux thanks to
the /proc memory reading recently committed) but on other platforms it
literally sucks.

The busy bit of the stack is here:

#6 0x0807f37b in target_read_memory (memaddr=3207201336,
myaddr=0xb5e49048 "", len=8000000) at target.c:1000
#7 0x08084a5a in read_memory (memaddr=3207201336, myaddr=0xb5e49048 "",
len=8000000) at corefile.c:239
#8 0x080e2509 in value_fetch_lazy (val=0xb5e49008) at valops.c:515
#9 0x080dc4fb in value_contents_all (value=0xb5e49008) at value.c:331
#10 0x08167551 in c_value_print (val=0xb5e49008, stream=0x91ea940,
format=0, pretty=Val_pretty_default)
at c-valprint.c:596
#11 0x080eb0f4 in print_formatted (val=0xb5e49008, format=0, size=0,
stream=0x91ea940) at .././gdb/printcmd.c:335
#12 0x080eb776 in output_command (exp=0x91ea9a7 "x", from_tty=1)
at .././gdb/printcmd.c:985

Should we really really be reading all that memory, just to print the
first element? I mean, not only is that slow, but it imposes a memory
overhead in the GDB too!

Should we be using a better method?

Cheers
David

--
David Lecomber <david@lecomber.net>