]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2011-04-20 Pedro Alves <pedro@codesourcery.com>
authorPedro Alves <palves@redhat.com>
Wed, 20 Apr 2011 17:04:32 +0000 (17:04 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 20 Apr 2011 17:04:32 +0000 (17:04 +0000)
gdb/
* regcache.c (get_thread_arch_regcache): If creating a regcache for
null_ptid, assume and allow a NULL address space, instead of
asking the target for the ptid's address space.
* infrun.c (ptid_is_pid): Remove assertion.

gdb/testsuite/
* gdb.base/maint.exp: Test that "maint print registers" works
without a running program.

gdb/ChangeLog
gdb/infrun.c
gdb/regcache.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/maint.exp

index 9f442d7101a5eca6bc0fdf071682a5b3eca680b4..7c32329a9c41cc2c0f0ef1b790bd1ad099b32a39 100644 (file)
@@ -1,3 +1,10 @@
+2011-04-20  Pedro Alves  <pedro@codesourcery.com>
+
+       * regcache.c (get_thread_arch_regcache): If creating a regcache for
+       null_ptid, assume and allow a NULL address space, instead of
+       asking the target for the ptid's address space.
+       * infrun.c (ptid_is_pid): Remove assertion.
+
 2011-04-19  Marc Khouzam  <marc.khouzam@ericsson.com>
 
        * thread.c (any_live_thread_of_process): Prioritize threads
index 7cee7c87aa9ccc6278d5554d768aab2677b932b7..867d4122686831905482855da0a8cd94a0795bb3 100644 (file)
@@ -6696,11 +6696,6 @@ ptid_is_pid (ptid_t ptid)
 int
 ptid_match (ptid_t ptid, ptid_t filter)
 {
-  /* Since both parameters have the same type, prevent easy mistakes
-     from happening.  */
-  gdb_assert (!ptid_equal (ptid, minus_one_ptid)
-             && !ptid_equal (ptid, null_ptid));
-
   if (ptid_equal (filter, minus_one_ptid))
     return 1;
   if (ptid_is_pid (filter)
index fbdecccbb164309abf68175efab0472a2b0fd087..8b4d77ccc0c81b7444e772ed7d3d6373e5c621e2 100644 (file)
@@ -453,16 +453,25 @@ get_thread_arch_regcache (ptid_t ptid, struct gdbarch *gdbarch)
 {
   struct regcache_list *list;
   struct regcache *new_regcache;
+  struct address_space *aspace;
 
   for (list = current_regcache; list; list = list->next)
     if (ptid_equal (list->regcache->ptid, ptid)
        && get_regcache_arch (list->regcache) == gdbarch)
       return list->regcache;
 
-  new_regcache = regcache_xmalloc_1 (gdbarch,
-                                    target_thread_address_space (ptid), 0);
+  /* For the benefit of "maint print registers" & co when debugging an
+     executable, allow dumping the regcache even when there is no
+     thread selected (target_thread_address_space internal-errors if
+     no address space is found).  Note that normal user commands will
+     fail higher up on the call stack due to no
+     target_has_registers.  */
+  aspace = (ptid_equal (null_ptid, ptid)
+           ? NULL
+           : target_thread_address_space (ptid));
+
+  new_regcache = regcache_xmalloc_1 (gdbarch, aspace, 0);
   new_regcache->ptid = ptid;
-  gdb_assert (new_regcache->aspace != NULL);
 
   list = xmalloc (sizeof (struct regcache_list));
   list->regcache = new_regcache;
index 145f097d6a02c2555e3eb6af58a1db4af35d9a31..a74a9400c68ed0ba2e8e30eb0e29da57adb3db70 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-20  Pedro Alves  <pedro@codesourcery.com>
+
+       * gdb.base/maint.exp: Test that "maint print registers" works
+       without a running program.
+
 2011-04-15  Thiago Jung Bauermann  <bauerman@br.ibm.com>
 
        * gdb.base/watchpoint.exp (test_inaccessible_watchpoint): Don't
index 843391a2a5e972fef017bc1890f68e9c299ef2ce..61ad43925e99e43dce639cc707163c7cc9cbeb43 100644 (file)
@@ -54,10 +54,6 @@ if $tracelevel then {
 
 global usestubs
 
-#
-# test running programs
-#
-
 set testfile "break"
 set srcfile ${testfile}.c
 set srcfile1 ${testfile}1.c
@@ -82,6 +78,21 @@ if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug
 gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
+
+# The commands we test here produce many lines of output; disable "press
+# <return> to continue" prompts.
+gdb_test_no_output "set height 0"
+
+# Tests that require that no program is running
+
+gdb_file_cmd ${binfile}
+
+# Test for a regression where this command would internal-error if the
+# program wasn't running.
+gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
+
+# Tests that can or should be done with a running program
+
 gdb_load ${binfile}
 
 if ![runto_main] then {
@@ -89,11 +100,6 @@ if ![runto_main] then {
 }
 
 
-# The commands we test here produce many lines of output; disable "press 
-# <return> to continue" prompts.
-gdb_test_no_output "set height 0"
-
-
 #
 # this command does not produce any output
 # unless there is some problem with the symtabs and psymtabs