This is the mail archive of the
mailing list for the GDB project.
Re: "maint print registers" crash
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: drow at false dot org (Daniel Jacobowitz)
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 20 Jun 2007 22:26:29 +0200 (CEST)
- Subject: Re: "maint print registers" crash
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?
* 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);
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);
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE