From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31243 invoked by alias); 24 Oct 2007 16:00:05 -0000 Received: (qmail 31232 invoked by uid 22791); 24 Oct 2007 16:00:05 -0000 X-Spam-Check-By: sourceware.org Received: from dmz.mips-uk.com (HELO dmz.mips-uk.com) (194.74.144.194) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 24 Oct 2007 15:59:59 +0000 Received: from internal-mx1 ([192.168.192.240] helo=ukservices1.mips.com) by dmz.mips-uk.com with esmtp (Exim 3.35 #1 (Debian)) id 1IkieC-0005GO-00; Wed, 24 Oct 2007 16:59:56 +0100 Received: from perivale.mips.com ([192.168.192.200]) by ukservices1.mips.com with esmtp (Exim 3.36 #1 (Debian)) id 1Ikie3-0005uW-00; Wed, 24 Oct 2007 16:59:47 +0100 Received: from macro (helo=localhost) by perivale.mips.com with local-esmtp (Exim 4.63) (envelope-from ) id 1Ikie3-0001fo-Gf; Wed, 24 Oct 2007 16:59:47 +0100 Date: Wed, 24 Oct 2007 16:22:00 -0000 From: "Maciej W. Rozycki" To: gdb-patches@sourceware.org cc: David Ung , "Maciej W. Rozycki" Subject: infcmd.c: Output user registers correctly Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MIPS-Technologies-UK-MailScanner: Found to be clean X-MIPS-Technologies-UK-MailScanner-From: macro@mips.com Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-10/txt/msg00585.txt.bz2 Hello, We have a problem, seen at least for the MIPS target, with user registers. If one is requested with "info registers", an assertion failure happens. For example (with GNU sim): (gdb) info registers zero at v0 v1 a0 a1 a2 a3 R0 00000000 00000000 ffffffff ffffffff 00000000 807fffe0 807fffe8 00000000 t0 t1 t2 t3 t4 t5 t6 t7 R8 800287a4 80000000 aaaa5555 00000000 ff0055aa 00000000 00000000 00000000 s0 s1 s2 s3 s4 s5 s6 s7 R16 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 t8 t9 k0 k1 gp sp s8 ra R24 00000000 00000000 00000000 00000000 80030e80 807fffa0 807fffa0 80020164 sr lo hi bad cause pc 20000000 00000000 00000000 00000000 00000000 80020284 fsr fir 00000000 00000000 (gdb) info registers $ta0 /n/bank/raid/macro/src7-mdi/combined/gdb/regcache.c:164: internal-error: register_type: Assertion `regnum >= 0 && regnum < descr->nr_cooked_registers' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) n /n/bank/raid/macro/src7-mdi/combined/gdb/regcache.c:164: internal-error: register_type: Assertion `regnum >= 0 && regnum < descr->nr_cooked_registers' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) n (gdb) The "ta0" register is an alias for the "t4" register. With the fix below I get: (gdb) info registers $ta0 ta0: 0xff0055aa (gdb) Tested using the mipsisa32-sde-elf target, with the mips-sim-sde32/-EB and mips-sim-sde32/-EL boards with no regressions. 2007-10-24 David Ung Maciej W. Rozycki * infcmd.c (registers_info): Check for a user register before calling target's gdbarch_print_registers_info(). If found to be so, extract the implicit value of user register and call print_scalar_formatted(). * value.h (value_of_user_reg): Add prototype. OK to apply? Maciej 12659.diff Index: binutils-quilt/src/gdb/infcmd.c =================================================================== --- binutils-quilt.orig/src/gdb/infcmd.c 2007-10-24 14:20:01.000000000 +0100 +++ binutils-quilt/src/gdb/infcmd.c 2007-10-24 16:16:09.000000000 +0100 @@ -1705,21 +1705,35 @@ while ((*addr_exp) != '\0' && !isspace ((*addr_exp))) addr_exp++; end = addr_exp; - + /* Figure out what we've found and display it. */ /* A register name? */ { - int regnum = frame_map_name_to_regnum (frame, - start, end - start); + int regnum = frame_map_name_to_regnum (frame, start, end - start); if (regnum >= 0) { - gdbarch_print_registers_info (gdbarch, gdb_stdout, - frame, regnum, fpregs); + /* User registers lie completely outside of the range of + normal registers. Catch them early so that the target + never sees them. */ + if (regnum >= gdbarch_num_regs (gdbarch) + + gdbarch_num_pseudo_regs (gdbarch)) + { + struct value *val = value_of_user_reg (regnum, frame); + + printf_filtered ("%s: ", start); + print_scalar_formatted (value_contents (val), + check_typedef (value_type (val)), + 'x', 0, gdb_stdout); + printf_filtered ("\n"); + } + else + gdbarch_print_registers_info (gdbarch, gdb_stdout, + frame, regnum, fpregs); continue; } } - + /* A register number? (how portable is this one?). */ { char *endptr; Index: binutils-quilt/src/gdb/value.h =================================================================== --- binutils-quilt.orig/src/gdb/value.h 2007-10-24 14:20:01.000000000 +0100 +++ binutils-quilt/src/gdb/value.h 2007-10-24 16:16:54.000000000 +0100 @@ -299,6 +299,8 @@ extern struct value *value_of_register (int regnum, struct frame_info *frame); +extern struct value *value_of_user_reg (int regnum, struct frame_info *frame); + extern int symbol_read_needs_frame (struct symbol *); extern struct value *read_var_value (struct symbol *var,