This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] record.c - save some memory in record log.
Hui Zhu wrote:
Thanks Michael, This patch is very cool.
+struct record_reg_entry
+{
+ unsigned short num;
+ unsigned short len;
+ union
+ {
+ gdb_byte *ptr;
+ gdb_byte buf[2 * sizeof (gdb_byte *)];
Why this part use "2 * sizeof (gdb_byte *)"?
Oh, no strong reason. I just noticed that mem_entry is larger
than reg_entry, and since it is used in a union, that space is
otherwise going to waste.
I do not assume that a target general register is the same size
as a host pointer -- only that the larger we make this buf, the
less likely that we have to use malloc.
+ rec->u.reg.u.ptr = (gdb_byte *) xmalloc (MAX_REGISTER_SIZE);
I suggest change MAX_REGISTER_SIZE to rec->u.reg.len.
Ah, good idea, thanks. I'll make that change.
Any other comments?