Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* "maint print registers" crash
@ 2007-06-20 19:47 Daniel Jacobowitz
  2007-06-20 20:26 ` Ulrich Weigand
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-06-20 19:47 UTC (permalink / raw)
  To: gdb-patches, Ulrich Weigand

Hi Ulrich,

I used to be able to start GDB and print out the current register
layout without needing a target, by "maint print registers".  Now that
crashes GDB, because current_regcache is NULL.  What do you think -
refuse to dump values and use the gdbarch_descr in that case?

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "maint print registers" crash
  2007-06-20 19:47 "maint print registers" crash Daniel Jacobowitz
@ 2007-06-20 20:26 ` Ulrich Weigand
  2007-06-20 20:34   ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Weigand @ 2007-06-20 20:26 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel Jacobowitz wrote:
> I used to be able to start GDB and print out the current register
> layout without needing a target, by "maint print registers".  Now that
> crashes GDB, because current_regcache is NULL.  What do you think -
> refuse to dump values and use the gdbarch_descr in that case?

Ah, that usage of current_regcache is a bug anyway; I must have 
overlooked it.  current_regcache can now be NULL at other times
as well (always after registers_changed () for example); no code
should simply use that variable any more.

The following patch changes it to use get_current_regcache ()
instead, which currently always succeeds allocating a register
cache (even if we don't have an inferior yet).

That gets "maint print registers" immediately after startup
working for me.  Does this solve your problem?

Bye,
Ulrich


ChangeLog:

	* regcache.c (regcache_print): Use get_current_regcache ()
	instead of current_regcache.

diff -urNp gdb-orig/gdb/regcache.c gdb-head/gdb/regcache.c
--- gdb-orig/gdb/regcache.c	2007-06-19 19:12:17.000000000 +0200
+++ gdb-head/gdb/regcache.c	2007-06-20 22:17:39.205744658 +0200
@@ -1114,13 +1114,13 @@ static void
 regcache_print (char *args, enum regcache_dump_what what_to_dump)
 {
   if (args == NULL)
-    regcache_dump (current_regcache, gdb_stdout, what_to_dump);
+    regcache_dump (get_current_regcache (), gdb_stdout, what_to_dump);
   else
     {
       struct ui_file *file = gdb_fopen (args, "w");
       if (file == NULL)
 	perror_with_name (_("maintenance print architecture"));
-      regcache_dump (current_regcache, file, what_to_dump);    
+      regcache_dump (get_current_regcache (), file, what_to_dump);
       ui_file_delete (file);
     }
 }

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "maint print registers" crash
  2007-06-20 20:26 ` Ulrich Weigand
@ 2007-06-20 20:34   ` Daniel Jacobowitz
  2007-06-20 20:52     ` Ulrich Weigand
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-06-20 20:34 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: gdb-patches

On Wed, Jun 20, 2007 at 10:26:29PM +0200, Ulrich Weigand wrote:
> Daniel Jacobowitz wrote:
> > I used to be able to start GDB and print out the current register
> > layout without needing a target, by "maint print registers".  Now that
> > crashes GDB, because current_regcache is NULL.  What do you think -
> > refuse to dump values and use the gdbarch_descr in that case?
> 
> Ah, that usage of current_regcache is a bug anyway; I must have 
> overlooked it.  current_regcache can now be NULL at other times
> as well (always after registers_changed () for example); no code
> should simply use that variable any more.
> 
> The following patch changes it to use get_current_regcache ()
> instead, which currently always succeeds allocating a register
> cache (even if we don't have an inferior yet).
> 
> That gets "maint print registers" immediately after startup
> working for me.  Does this solve your problem?

Yes, this works great - thanks!

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "maint print registers" crash
  2007-06-20 20:34   ` Daniel Jacobowitz
@ 2007-06-20 20:52     ` Ulrich Weigand
  0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Weigand @ 2007-06-20 20:52 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel Jacobowitz wrote:
> On Wed, Jun 20, 2007 at 10:26:29PM +0200, Ulrich Weigand wrote:
> > That gets "maint print registers" immediately after startup
> > working for me.  Does this solve your problem?
> 
> Yes, this works great - thanks!

OK, I've checked this is.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-20 20:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-20 19:47 "maint print registers" crash Daniel Jacobowitz
2007-06-20 20:26 ` Ulrich Weigand
2007-06-20 20:34   ` Daniel Jacobowitz
2007-06-20 20:52     ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox