From: Greg McGary <gkm@kayak.mcgary.org>
To: gdb-patches@sources.redhat.com
Subject: PATCH: new "void" memory region attribute
Date: Wed, 13 Feb 2002 16:25:00 -0000 [thread overview]
Message-ID: <msg044zz73.fsf@mcgary.org> (raw)
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?
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
next reply other threads:[~2002-02-14 0:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-13 16:25 Greg McGary [this message]
2002-02-13 17:42 ` Michael Snyder
2002-02-13 18:06 ` Greg McGary
2002-02-13 19:23 ` Andrew Cagney
2002-02-13 19:29 ` Michael Snyder
2002-02-13 20:10 ` Andrew Cagney
2002-02-14 2:24 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=msg044zz73.fsf@mcgary.org \
--to=gkm@kayak.mcgary.org \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox