Make print_float_info() multi-arch pure. Add ui_file and frame parameters.
[deliverable/binutils-gdb.git] / gdb / memattr.c
index 10637fc60763ac74138bce6690140ad4cb2e5f95..8c46d7eb168ec78a07239c7a320b7793adc0d83d 100644 (file)
@@ -1,5 +1,6 @@
 /* Memory attributes support, for GDB.
-   Copyright 2001 Free Software Foundation, Inc.
+
+   Copyright 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #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 */
   MEM_WIDTH_UNSPECIFIED,
-  false,                       /* hwbreak */
-  false,                       /* cache */
-  false                                /* verify */
+  0,                           /* hwbreak */
+  0,                           /* cache */
+  0                            /* verify */
 };
 
 static struct mem_region *mem_region_chain = NULL;
@@ -55,9 +46,10 @@ create_mem_region (CORE_ADDR lo, CORE_ADDR hi,
 {
   struct mem_region *n, *new;
 
-  if (lo > hi)
+  /* lo == hi is a useless empty region */
+  if (lo >= hi)
     {
-      printf_unfiltered ("invalid memory region\n");
+      printf_unfiltered ("invalid memory region: low >= high\n");
       return NULL;
     }
 
@@ -65,8 +57,8 @@ create_mem_region (CORE_ADDR lo, CORE_ADDR hi,
   while (n)
     {
       /* overlapping node */
-      if ((lo >= n->lo && lo <= n->hi) ||
-         (hi >= n->lo && hi <= n->hi))
+      if ((lo >= n->lo && lo < n->hi) ||
+         (hi > n->lo && hi <= n->hi))
        {
          printf_unfiltered ("overlapping memory region\n");
          return NULL;
@@ -78,7 +70,7 @@ create_mem_region (CORE_ADDR lo, CORE_ADDR hi,
   new->lo = lo;
   new->hi = hi;
   new->number = ++mem_number;
-  new->status = enabled;
+  new->enabled_p = 1;
   new->attrib = *attrib;
 
   /* link in new node */
@@ -117,7 +109,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;
@@ -192,21 +184,21 @@ mem_command (char *args, int from_tty)
 
 #if 0
       else if (strcmp (tok, "hwbreak") == 0)
-       attrib.hwbreak = true;
+       attrib.hwbreak = 1;
       else if (strcmp (tok, "swbreak") == 0)
-       attrib.hwbreak = false;
+       attrib.hwbreak = 0;
 #endif
 
       else if (strcmp (tok, "cache") == 0)
-       attrib.cache = true;
+       attrib.cache = 1;
       else if (strcmp (tok, "nocache") == 0)
-       attrib.cache = false;
+       attrib.cache = 0;
 
 #if 0
       else if (strcmp (tok, "verify") == 0)
-       attrib.verify = true;
+       attrib.verify = 1;
       else if (strcmp (tok, "noverify") == 0)
-       attrib.verify = false;
+       attrib.verify = 0;
 #endif
 
       else
@@ -245,18 +237,18 @@ mem_info_command (char *args, int from_tty)
       char *tmp;
       printf_filtered ("%-3d %-3c\t",
                       m->number,
-                      m->status ? 'y' : 'n');
+                      m->enabled_p ? 'y' : 'n');
       if (TARGET_ADDR_BIT <= 32)
-       tmp = longest_local_hex_string_custom ((unsigned long) m->lo, "08l");
+       tmp = local_hex_string_custom ((unsigned long) m->lo, "08l");
       else
-       tmp = longest_local_hex_string_custom ((unsigned long) m->lo, "016l");
+       tmp = 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");
+       tmp = local_hex_string_custom ((unsigned long) m->hi, "08l");
       else
-       tmp = longest_local_hex_string_custom ((unsigned long) m->hi, "016l");
+       tmp = local_hex_string_custom ((unsigned long) m->hi, "016l");
       
       printf_filtered ("%s ", tmp);
 
@@ -340,7 +332,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);
@@ -359,7 +351,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)
@@ -390,7 +382,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);
@@ -409,7 +401,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)
@@ -516,7 +508,10 @@ _initialize_mem ()
 {
   add_com ("mem", class_vars, mem_command,
           "Define attributes for memory region.\n\
-Usage: mem <lo addr> <hi addr> [<mode> <width> <cache>]");
+Usage: mem <lo addr> <hi addr> [<mode> <width> <cache>], \n\
+where <mode>  may be rw (read/write), ro (read-only) or wo (write-only), \n\
+      <width> may be 8, 16, 32, or 64, and \n\
+      <cache> may be cache or nocache");
 
   add_cmd ("mem", class_vars, mem_enable_command,
           "Enable memory region.\n\
This page took 0.025969 seconds and 4 git commands to generate.