* sparcnbsd-tdep.c: Include "gdb_string.h".
[deliverable/binutils-gdb.git] / gdb / memattr.c
index 7387e8d830df1b41b10e4fbb942a50ce8dde6f79..05ad413cc0afb63486d3f12660bc9809568f3033 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.
 
@@ -46,7 +47,7 @@ create_mem_region (CORE_ADDR lo, CORE_ADDR hi,
   struct mem_region *n, *new;
 
   /* lo == hi is a useless empty region */
-  if (lo >= hi)
+  if (lo >= hi && hi != 0)
     {
       printf_unfiltered ("invalid memory region: low >= high\n");
       return NULL;
@@ -56,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;
@@ -110,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)
@@ -238,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.
@@ -503,7 +515,7 @@ mem_delete_command (char *args, int from_tty)
 }
 \f
 void
-_initialize_mem ()
+_initialize_mem (void)
 {
   add_com ("mem", class_vars, mem_command,
           "Define attributes for memory region.\n\
This page took 0.027218 seconds and 4 git commands to generate.