* PATCH: new "void" memory region attribute
@ 2002-02-13 16:25 Greg McGary
2002-02-13 17:42 ` Michael Snyder
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Greg McGary @ 2002-02-13 16:25 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: new "void" memory region attribute
2002-02-13 16:25 PATCH: new "void" memory region attribute Greg McGary
@ 2002-02-13 17:42 ` Michael Snyder
2002-02-13 18:06 ` Greg McGary
2002-02-13 19:23 ` Andrew Cagney
2002-02-14 2:24 ` Eli Zaretskii
2 siblings, 1 reply; 7+ messages in thread
From: Michael Snyder @ 2002-02-13 17:42 UTC (permalink / raw)
To: Greg McGary; +Cc: gdb-patches
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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: new "void" memory region attribute
2002-02-13 17:42 ` Michael Snyder
@ 2002-02-13 18:06 ` Greg McGary
0 siblings, 0 replies; 7+ messages in thread
From: Greg McGary @ 2002-02-13 18:06 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael Snyder <msnyder@redhat.com> writes:
> 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?
Surely. Thanks for the invite. Having never hacked the gdb testsuite
before, I look forward to sleuthing it out. 8^)
I'll post diffs for the test case, then commit the whole wad when
that's approved.
Greg
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: new "void" memory region attribute
2002-02-13 16:25 PATCH: new "void" memory region attribute Greg McGary
2002-02-13 17:42 ` Michael Snyder
@ 2002-02-13 19:23 ` Andrew Cagney
2002-02-13 19:29 ` Michael Snyder
2002-02-14 2:24 ` Eli Zaretskii
2 siblings, 1 reply; 7+ messages in thread
From: Andrew Cagney @ 2002-02-13 19:23 UTC (permalink / raw)
To: Greg McGary; +Cc: gdb-patches
> 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,
> };
>
Greg, I'm just wondering why this part change? Wouldn't just adding a
MEM_VOID entry have been easier?
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: new "void" memory region attribute
2002-02-13 19:23 ` Andrew Cagney
@ 2002-02-13 19:29 ` Michael Snyder
2002-02-13 20:10 ` Andrew Cagney
0 siblings, 1 reply; 7+ messages in thread
From: Michael Snyder @ 2002-02-13 19:29 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Greg McGary, gdb-patches
Andrew Cagney wrote:
>
> > 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,
> > };
> >
>
> Greg, I'm just wondering why this part change? Wouldn't just adding a
> MEM_VOID entry have been easier?
No, it's because (attr != MEM_RO) is no longer a sufficient test
to see if a section is writeable. There are now two modes that are
not writeable -- MEM_RO and MEM_VOID. He could have made the tests
more complex, he simply chose to do it this way instead.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: new "void" memory region attribute
2002-02-13 19:29 ` Michael Snyder
@ 2002-02-13 20:10 ` Andrew Cagney
0 siblings, 0 replies; 7+ messages in thread
From: Andrew Cagney @ 2002-02-13 20:10 UTC (permalink / raw)
To: Michael Snyder; +Cc: Greg McGary, gdb-patches
> Andrew Cagney wrote:
>
>>
>
>> > 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,
>> > };
>> >
>
>>
>> Greg, I'm just wondering why this part change? Wouldn't just adding a
>> MEM_VOID entry have been easier?
>
>
> No, it's because (attr != MEM_RO) is no longer a sufficient test
> to see if a section is writeable. There are now two modes that are
> not writeable -- MEM_RO and MEM_VOID. He could have made the tests
> more complex, he simply chose to do it this way instead.
Ah, ok. I see why I'm confused. The command set is an enumeration:
void ro ro rw
but the internal representation is now:
r, w
Greg, might as well go the whole hog, make it a set: rwx (don't wan't a
programmer trying to jump into a device :-)
Otherwize ok.
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PATCH: new "void" memory region attribute
2002-02-13 16:25 PATCH: new "void" memory region attribute Greg McGary
2002-02-13 17:42 ` Michael Snyder
2002-02-13 19:23 ` Andrew Cagney
@ 2002-02-14 2:24 ` Eli Zaretskii
2 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2002-02-14 2:24 UTC (permalink / raw)
To: gkm; +Cc: gdb-patches
> From: Greg McGary <gkm@kayak.mcgary.org>
> Date: 13 Feb 2002 17:25:52 -0700
>
> --- 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
This part of the patch is approved, but please add a sentence to
explain what would be the effect of declaring a region `void' on GDB's
operation, from the user's point of view. It strikes me that this
text, from the beginning of your message:
> 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.
is exactly what would make this attribute's effect crystal-clear ;-)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-02-14 10:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-13 16:25 PATCH: new "void" memory region attribute Greg McGary
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox