This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Remove MAX_REGISTER_SIZE from record-full.c


Alan Hayward <Alan.Hayward@arm.com> writes:

> Cannot avoid using buffer in record_full_exec_insn because it is doing an
> in place swap.

Your patch does change something other than record_full_exec_insn.  Need
more descriptions about them.

> @@ -792,15 +792,17 @@ static void
>  record_full_core_open_1 (const char *name, int from_tty)
>  {
>    struct regcache *regcache = get_current_regcache ();
> -  int regnum = gdbarch_num_regs (get_regcache_arch (regcache));
> +  struct gdbarch *gdbarch = get_regcache_arch (regcache);
> +  int regnum = gdbarch_num_regs (gdbarch);
> +  int regmaxsize = max_register_size (gdbarch);
>    int i;
>
>    /* Get record_full_core_regbuf.  */
>    target_fetch_registers (regcache, -1);
> -  record_full_core_regbuf = (gdb_byte *) xmalloc (MAX_REGISTER_SIZE * regnum);

We can see record_full_core_regbuf is allocated in target open, and
released on target close, used in fetch registers and store registers.
Can we replace it with a regcache?  In target open, copy
get_current_regcache () to it, and release it on target close.  In
target fetch/store registers, use it as well.

> @@ -2263,25 +2271,6 @@ init_record_full_core_ops (void)
>  }
>
>  /* Record log save-file format
> -   Version 1 (never released)
> -
> -   Header:
> -     4 bytes: magic number htonl(0x20090829).
> -       NOTE: be sure to change whenever this file format changes!
> -
> -   Records:
> -     record_full_end:
> -       1 byte:  record type (record_full_end, see enum record_full_type).
> -     record_full_reg:
> -       1 byte:  record type (record_full_reg, see enum record_full_type).
> -       8 bytes: register id (network byte order).
> -       MAX_REGISTER_SIZE bytes: register value.
> -     record_full_mem:
> -       1 byte:  record type (record_full_mem, see enum record_full_type).
> -       8 bytes: memory length (network byte order).
> -       8 bytes: memory address (network byte order).
> -       n bytes: memory value (n == memory length).
> -

Although format V1 is never released, and is not being used, we can't
simply remove it without any justifications.  They were added in
https://sourceware.org/ml/gdb-patches/2009-10/msg00380.html but nobody
raised the question why do we need this v1 format.

Hui, do you recall any reason that we keep v1 format in comment?  If
not, do you think we can remove these comments?  The comments go into
Alan's radar because MAX_REGISTER_SIZE is used in the comments and he
wants to remove MAX_REGISTER_SIZE.

-- 
Yao (齐尧)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]