Cleanups. Now passes!
[deliverable/binutils-gdb.git] / gdb / memattr.c
index b1b4a781b164633f9696243819448b39256473ee..9dd3dd5065c7758f393e0cf9a4b051b94a6b7122 100644 (file)
@@ -1,4 +1,23 @@
-/* memattr.c */
+/* Memory attributes support, for GDB.
+   Copyright 2001 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
 #include "defs.h"
 #include "command.h"
 #include "gdbcmd.h"
@@ -8,16 +27,6 @@
 #include "language.h"
 #include "gdb_string.h"
 
-/* FIXME: While this conflicts with the enum defined in breakpoint.h,
-   I used them to be consistant with how breakpoints, tracepoints, and
-   displays are implemented.  It doesn't lose now because breakpoint.h
-   is not included.  */
-enum enable
-{
-  disabled,
-  enabled
-};
-
 const struct mem_attrib default_mem_attrib =
 {
   MEM_RW,                      /* mode */
@@ -52,13 +61,14 @@ create_mem_region (CORE_ADDR lo, CORE_ADDR hi,
          printf_unfiltered ("overlapping memory region\n");
          return NULL;
        }
+      n = n->next;
     }
 
   new = xmalloc (sizeof (struct mem_region));
   new->lo = lo;
   new->hi = hi;
   new->number = ++mem_number;
-  new->status = enabled;
+  new->enabled_p = 1;
   new->attrib = *attrib;
 
   /* link in new node */
@@ -97,7 +107,7 @@ lookup_mem_region (CORE_ADDR addr)
 
   for (m = mem_region_chain; m; m = m->next)
     {
-      if (m->status == enabled)
+      if (m->enabled_p == 1)
        {
          if (addr >= m->lo && addr < m->hi)
            return m;
@@ -209,16 +219,36 @@ mem_info_command (char *args, int from_tty)
       return;
     }
 
-  printf_filtered ("Memory regions now in effect:\n");
+  printf_filtered ("Num ");
+  printf_filtered ("Enb ");
+  printf_filtered ("Low Addr   ");
+  if (TARGET_ADDR_BIT > 32)
+    printf_filtered ("        ");
+  printf_filtered ("High Addr  ");
+  if (TARGET_ADDR_BIT > 32)
+    printf_filtered ("        ");
+  printf_filtered ("Attrs ");
+  printf_filtered ("\n");
+
   for (m = mem_region_chain; m; m = m->next)
     {
-      printf_filtered ("%d: %c\t",
+      char *tmp;
+      printf_filtered ("%-3d %-3c\t",
                       m->number,
-                      m->status ? 'y' : 'n');
-      printf_filtered ("%s - ",
-                   local_hex_string_custom ((unsigned long) m->lo, "08l"));
-      printf_filtered ("%s\t",
-                   local_hex_string_custom ((unsigned long) m->hi, "08l"));
+                      m->enabled_p ? 'y' : 'n');
+      if (TARGET_ADDR_BIT <= 32)
+       tmp = longest_local_hex_string_custom ((unsigned long) m->lo, "08l");
+      else
+       tmp = longest_local_hex_string_custom ((unsigned long) m->lo, "016l");
+      
+      printf_filtered ("%s ", tmp);
+      
+      if (TARGET_ADDR_BIT <= 32)
+       tmp = longest_local_hex_string_custom ((unsigned long) m->hi, "08l");
+      else
+       tmp = longest_local_hex_string_custom ((unsigned long) m->hi, "016l");
+      
+      printf_filtered ("%s ", tmp);
 
       /* Print a token for each attribute.
 
@@ -300,7 +330,7 @@ mem_enable (int num)
   for (m = mem_region_chain; m; m = m->next)
     if (m->number == num)
       {
-       m->status = enabled;
+       m->enabled_p = 1;
        return;
       }
   printf_unfiltered ("No memory region number %d.\n", num);
@@ -319,7 +349,7 @@ mem_enable_command (char *args, int from_tty)
   if (p == 0)
     {
       for (m = mem_region_chain; m; m = m->next)
-       m->status = enabled;
+       m->enabled_p = 1;
     }
   else
     while (*p)
@@ -350,7 +380,7 @@ mem_disable (int num)
   for (m = mem_region_chain; m; m = m->next)
     if (m->number == num)
       {
-       m->status = disabled;
+       m->enabled_p = 0;
        return;
       }
   printf_unfiltered ("No memory region number %d.\n", num);
@@ -369,7 +399,7 @@ mem_disable_command (char *args, int from_tty)
   if (p == 0)
     {
       for (m = mem_region_chain; m; m = m->next)
-       m->status = disabled;
+       m->enabled_p = 0;
     }
   else
     while (*p)
@@ -475,21 +505,25 @@ void
 _initialize_mem ()
 {
   add_com ("mem", class_vars, mem_command,
-          "Define attributes for memory region.");
+          "Define attributes for memory region.\n\
+Usage: mem <lo addr> <hi addr> [<mode> <width> <cache>]");
 
   add_cmd ("mem", class_vars, mem_enable_command,
           "Enable memory region.\n\
 Arguments are the code numbers of the memory regions to enable.\n\
+Usage: enable mem <code number>\n\
 Do \"info mem\" to see current list of code numbers.", &enablelist);
 
   add_cmd ("mem", class_vars, mem_disable_command,
           "Disable memory region.\n\
 Arguments are the code numbers of the memory regions to disable.\n\
+Usage: disable mem <code number>\n\
 Do \"info mem\" to see current list of code numbers.", &disablelist);
 
   add_cmd ("mem", class_vars, mem_delete_command,
           "Delete memory region.\n\
 Arguments are the code numbers of the memory regions to delete.\n\
+Usage: delete mem <code number>\n\
 Do \"info mem\" to see current list of code numbers.", &deletelist);
 
   add_info ("mem", mem_info_command,
This page took 0.025151 seconds and 4 git commands to generate.