* gas/mips/macro-warn-[1234].[sdl]: New tests.
[deliverable/binutils-gdb.git] / gdb / memattr.c
index 9dd3dd5065c7758f393e0cf9a4b051b94a6b7122..4ab5dbf10091f6c0957f8348b4b2ad8e3184e711 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.
 
@@ -31,9 +32,9 @@ 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;
@@ -45,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 && hi != 0)
     {
-      printf_unfiltered ("invalid memory region\n");
+      printf_unfiltered ("invalid memory region: low >= high\n");
       return NULL;
     }
 
@@ -55,8 +57,9 @@ 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 || n->hi == 0)) 
+         || (hi > n->lo && (hi <= n->hi || n->hi == 0))
+         || (lo <= n->lo && (hi >= n->hi || hi == 0)))
        {
          printf_unfiltered ("overlapping memory region\n");
          return NULL;
@@ -109,7 +112,7 @@ lookup_mem_region (CORE_ADDR addr)
     {
       if (m->enabled_p == 1)
        {
-         if (addr >= m->lo && addr < m->hi)
+         if (addr >= m->lo && (addr < m->hi || m->hi == 0))
            return m;
 
          if (addr >= m->hi && lo < m->hi)
@@ -182,21 +185,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
@@ -237,17 +240,27 @@ mem_info_command (char *args, int from_tty)
                       m->number,
                       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");
+       {
+       if (m->hi == 0)
+         tmp = "0x100000000";
+       else
+         tmp = local_hex_string_custom ((unsigned long) m->hi, "08l");
+       }
       else
-       tmp = longest_local_hex_string_custom ((unsigned long) m->hi, "016l");
-      
+       {
+       if (m->hi == 0)
+         tmp = "0x10000000000000000";
+       else
+         tmp = local_hex_string_custom ((unsigned long) m->hi, "016l");
+       }
+
       printf_filtered ("%s ", tmp);
 
       /* Print a token for each attribute.
@@ -501,12 +514,17 @@ mem_delete_command (char *args, int from_tty)
   dont_repeat ();
 }
 \f
+extern initialize_file_ftype _initialize_mem; /* -Wmissing-prototype */
+
 void
-_initialize_mem ()
+_initialize_mem (void)
 {
   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.026163 seconds and 4 git commands to generate.