This is the mail archive of the gdb-patches@sources.redhat.com 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: new "void" memory region attribute


Greg McGary wrote:
> 
> Add "void" attribute, which disallows both read & write access.  This
> useful for guarding holes in a target's address space that cause the
> system to hang when read/written.
> 
> OK to commit?

I like it.  Would you consider adding a test to the testsuite?


> 
> gdb:
> 
> 2002-02-13  Greg McGary  <greg@mcgary.org>
> 
>         * memattr.h (enum mem_access_mode): s/MEM_RO/MEM_READ/
>         s/MEM_WO/MEM_WRITE/. New member MEM_VOID.
>         * memattr.c (mem_command, mem_info_command): Handle MEM_VOID.
>         * target.c (target_xfer_memory, target_xfer_memory_partial):
>         Check read/write validity with bit test.
>         * dcache.c (dcache_write_line, dcache_read_line): Likewise.
> 
> doc:
> 
> 2002-02-13  Greg McGary  <greg@mcgary.org>
> 
>         * gdb.texinfo (Memory Region Attributes): Describe `void' attribute.
> 
> Index: dcache.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dcache.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 dcache.c
> --- dcache.c    2001/04/06 22:43:55     1.15
> +++ dcache.c    2002/02/14 00:17:25
> @@ -1,5 +1,5 @@
>  /* Caching code.
> -   Copyright 1992, 1993, 1995, 1996, 1998, 1999, 2000, 2001
> +   Copyright 1992, 1993, 1995, 1996, 1998, 1999, 2000, 2001, 2002
>     Free Software Foundation, Inc.
> 
>     This file is part of GDB.
> @@ -267,7 +267,7 @@ dcache_write_line (DCACHE *dcache, regis
>        else
>         reg_len = region->hi - memaddr;
> 
> -      if (!region->attrib.cache || region->attrib.mode == MEM_RO)
> +      if (!region->attrib.cache || !(region->attrib.mode == MEM_WRITE))
>         {
>           memaddr += reg_len;
>           myaddr  += reg_len;
> @@ -349,7 +349,7 @@ dcache_read_line (DCACHE *dcache, struct
>        else
>         reg_len = region->hi - memaddr;
> 
> -      if (!region->attrib.cache || region->attrib.mode == MEM_WO)
> +      if (!region->attrib.cache || !(region->attrib.mode & MEM_READ))
>         {
>           memaddr += reg_len;
>           myaddr  += reg_len;
> Index: memattr.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/memattr.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 memattr.c
> --- memattr.c   2002/02/13 19:00:47     1.9
> +++ memattr.c   2002/02/14 00:17:25
> @@ -1,5 +1,5 @@
>  /* Memory attributes support, for GDB.
> -   Copyright 2001 Free Software Foundation, Inc.
> +   Copyright 2001, 2002 Free Software Foundation, Inc.
> 
>     This file is part of GDB.
> 
> @@ -156,9 +156,11 @@ mem_command (char *args, int from_tty)
>        if (strcmp (tok, "rw") == 0)
>         attrib.mode = MEM_RW;
>        else if (strcmp (tok, "ro") == 0)
> -       attrib.mode = MEM_RO;
> +       attrib.mode = MEM_READ;
>        else if (strcmp (tok, "wo") == 0)
> -       attrib.mode = MEM_WO;
> +       attrib.mode = MEM_WRITE;
> +      else if (strcmp (tok, "void") == 0)
> +       attrib.mode = MEM_VOID;
> 
>        else if (strcmp (tok, "8") == 0)
>         attrib.width = MEM_WIDTH_8;
> @@ -266,13 +268,16 @@ mem_info_command (char *args, int from_t
>        attrib = &m->attrib;
>        switch (attrib->mode)
>         {
> +       case MEM_VOID:
> +         printf_filtered ("void ");
> +         break;
>         case MEM_RW:
>           printf_filtered ("rw ");
>           break;
> -       case MEM_RO:
> +       case MEM_READ:
>           printf_filtered ("ro ");
>           break;
> -       case MEM_WO:
> +       case MEM_WRITE:
>           printf_filtered ("wo ");
>           break;
>         }
> Index: memattr.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/memattr.h,v
> retrieving revision 1.4
> diff -u -p -r1.4 memattr.h
> --- memattr.h   2001/08/02 11:58:29     1.4
> +++ memattr.h   2002/02/14 00:17:25
> @@ -1,5 +1,5 @@
>  /* Memory attributes support, for GDB.
> -   Copyright 2001 Free Software Foundation, Inc.
> +   Copyright 2001, 2002 Free Software Foundation, Inc.
> 
>     This file is part of GDB.
> 
> @@ -23,9 +23,10 @@
> 
>  enum mem_access_mode
>  {
> -  MEM_RW,                      /* read/write */
> -  MEM_RO,                      /* read only */
> -  MEM_WO                       /* write only */
> +  MEM_VOID = 0,
> +  MEM_READ = 1,
> +  MEM_WRITE = 2,
> +  MEM_RW = MEM_READ | MEM_WRITE,
>  };
> 
>  enum mem_access_width
> Index: target.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/target.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 target.c
> --- target.c    2002/02/01 01:01:21     1.33
> +++ target.c    2002/02/14 00:17:25
> @@ -933,18 +933,10 @@ target_xfer_memory (CORE_ADDR memaddr, c
>        else
>         reg_len = region->hi - memaddr;
> 
> -      switch (region->attrib.mode)
> -       {
> -       case MEM_RO:
> -         if (write)
> -           return EIO;
> -         break;
> -
> -       case MEM_WO:
> -         if (!write)
> -           return EIO;
> -         break;
> -       }
> +      if (write
> +         ? !(region->attrib.mode & MEM_WRITE)
> +         : !(region->attrib.mode & MEM_READ))
> +       return EIO;
> 
>        while (reg_len > 0)
>         {
> @@ -1004,23 +996,12 @@ target_xfer_memory_partial (CORE_ADDR me
>    else
>      reg_len = region->hi - memaddr;
> 
> -  switch (region->attrib.mode)
> +  if (write_p
> +      ? !(region->attrib.mode & MEM_WRITE)
> +      : !(region->attrib.mode & MEM_READ))
>      {
> -    case MEM_RO:
> -      if (write_p)
> -       {
> -         *err = EIO;
> -         return -1;
> -       }
> -      break;
> -
> -    case MEM_WO:
> -      if (write_p)
> -       {
> -         *err = EIO;
> -         return -1;
> -       }
> -      break;
> +      *err = EIO;
> +      return -1;
>      }
> 
>    if (region->attrib.cache)
> Index: doc/gdb.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
> retrieving revision 1.89
> diff -u -p -r1.89 gdb.texinfo
> --- gdb.texinfo 2002/02/08 00:39:45     1.89
> +++ gdb.texinfo 2002/02/14 00:17:32
> @@ -5642,6 +5642,8 @@ Memory is read only.
>  Memory is write only.
>  @item rw
>  Memory is read/write.  This is the default.
> +@item void
> +Memory is inaccessible.
>  @end table
> 
>  @subsubsection Memory Access Size
>


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