From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32724 invoked by alias); 13 Sep 2007 14:47:55 -0000 Received: (qmail 32712 invoked by uid 22791); 13 Sep 2007 14:47:54 -0000 X-Spam-Check-By: sourceware.org Received: from igw2.br.ibm.com (HELO igw2.br.ibm.com) (32.104.18.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 13 Sep 2007 14:47:42 +0000 Received: from mailhub1.br.ibm.com (mailhub1 [9.18.232.109]) by igw2.br.ibm.com (Postfix) with ESMTP id 35BB317F441 for ; Thu, 13 Sep 2007 11:45:51 -0300 (BRT) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.18.232.46]) by mailhub1.br.ibm.com (8.13.8/8.13.8/NCO v8.5) with ESMTP id l8DElcwY3215490 for ; Thu, 13 Sep 2007 11:47:38 -0300 Received: from d24av01.br.ibm.com (loopback [127.0.0.1]) by d24av01.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l8DElc23009462 for ; Thu, 13 Sep 2007 11:47:38 -0300 Received: from [9.18.238.24] ([9.18.238.24]) by d24av01.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l8DElYmG009385; Thu, 13 Sep 2007 11:47:36 -0300 Subject: Re: [patch] Backtrace prints wrong argument value From: Luis Machado Reply-To: luisgpm@linux.vnet.ibm.com To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com In-Reply-To: <20070516144250.GD24682@caradoc.them.org> References: <1177527233.12599.42.camel@localhost> <20070425191304.GA1283@caradoc.them.org> <1179293640.4323.16.camel@localhost> <20070516144250.GD24682@caradoc.them.org> Content-Type: multipart/mixed; boundary="=-KRRXXZM5sY+Y7IsyF1LC" Date: Thu, 13 Sep 2007 14:47:00 -0000 Message-Id: <1189694765.4564.5.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 X-IsSubscribed: yes 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-09/txt/msg00172.txt.bz2 --=-KRRXXZM5sY+Y7IsyF1LC Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1290 :ADDPATCH PowerPC-64: Hi, Bringing back this topic, i've written a patch to address this issue on ppc's side, providing a function to specify call-clobbered registers based on the ABI, similar to the S390's. Looking forward to suggestions/corrections. Best regards > There is simply not enough information in the debug info to handle > this correctly. Let me give you another example: > > move var to r3 > test something > if true, branch to Lfoo > call abort, which clobbers r3 > Lfoo: > do something with r3 > > At every instruction after the move, the debug info should say that > var is in r3. Right? No matter which location we pick here, while > backtracing from abort, we'll print the wrong value for var and > there's no point where the debug info will say it is undefined. > > If you want us to get this right using DWARF info, I believe your only > choice is to approach the DWARF working group about it. > > Now, in GDB we may have other options. We might be able to get the > list of call clobbered registers based on the ABI. Compare with s390, > which already does this (dwarf2_frame_set_init_reg). Does adding > this to PowerPC help your example any? > -- Luis Machado IBM Linux Technology Center e-mail: luisgpm@linux.vnet.ibm.com --=-KRRXXZM5sY+Y7IsyF1LC Content-Disposition: attachment; filename=call-clobbered-registers.diff Content-Type: text/x-patch; name=call-clobbered-registers.diff; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 3177 2007-09-13 Luis Machado * rs6000-tdep.c (ppc_dwarf2_frame_init_reg): New function. (rs6000_gdbarch_init): Install ppc_dwarf2_frame_init_reg as default dwarf2_frame_set_init_reg function. Index: gdb/rs6000-tdep.c =================================================================== --- gdb.orig/rs6000-tdep.c 2007-09-13 07:26:12.000000000 -0700 +++ gdb/rs6000-tdep.c 2007-09-13 07:41:10.000000000 -0700 @@ -3468,6 +3468,68 @@ return &rs6000_frame_base; } +/* DWARF-2 frame support. Used to handle the detection of + clobbered registers during function calls. */ + + static void +ppc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, + struct dwarf2_frame_state_reg *reg, + struct frame_info *next_frame) +{ + + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + /* PPC32 and PPC64 ABI's are the same regarding volatile and + non-volatile registers. We will use the same code for both. */ + + /* Call-saved GP registers. */ + if ((regnum >= (tdep->ppc_gp0_regnum + 14) + && regnum <= (tdep->ppc_gp0_regnum + 31)) + || (regnum == (tdep->ppc_gp0_regnum + 1))) + reg->how = DWARF2_FRAME_REG_SAME_VALUE; + + /* Call-clobbered GP registers. */ + if ((regnum >= (tdep->ppc_gp0_regnum + 3) + && regnum <= (tdep->ppc_gp0_regnum + 12)) + || (regnum == tdep->ppc_gp0_regnum)) + reg->how = DWARF2_FRAME_REG_UNDEFINED; + + /* Deal with FP registers, if supported. */ + if (tdep->ppc_fp0_regnum >= 0) + { + /* Call-saved FP registers. */ + if ((regnum >= (tdep->ppc_fp0_regnum + 14) + && regnum <= (tdep->ppc_fp0_regnum + 31))) + reg->how = DWARF2_FRAME_REG_SAME_VALUE; + + /* Call-clobbered FP registers. */ + if ((regnum >= (tdep->ppc_fp0_regnum) + && regnum <= (tdep->ppc_fp0_regnum + 13))) + reg->how = DWARF2_FRAME_REG_UNDEFINED; + } + + /* Deal with ALTIVEC registers, if supported. */ + if (tdep->ppc_vr0_regnum > 0 && tdep->ppc_vrsave_regnum > 0) + { + /* Call-saved Altivec registers. */ + if ((regnum >= (tdep->ppc_vr0_regnum + 20) + && regnum <= (tdep->ppc_vr0_regnum + 31)) + || regnum == tdep->ppc_vrsave_regnum) + reg->how = DWARF2_FRAME_REG_SAME_VALUE; + + /* Call-clobbered Altivec registers. */ + if ((regnum >= (tdep->ppc_vr0_regnum) + && regnum <= (tdep->ppc_vr0_regnum + 19))) + reg->how = DWARF2_FRAME_REG_UNDEFINED; + } + + if (regnum == gdbarch_pc_regnum (current_gdbarch)) + reg->how = DWARF2_FRAME_REG_RA; + else if (regnum == gdbarch_sp_regnum (current_gdbarch)) + reg->how = DWARF2_FRAME_REG_CFA; +} + + /* Initialize the current architecture based on INFO. If possible, re-use an architecture from ARCHES, which is a list of architectures already created during this debugging session. @@ -3790,6 +3852,10 @@ tdep->ppc_vr0_regnum = 71; tdep->ppc_vrsave_regnum = 104; } + + /* Frame handling. */ + dwarf2_frame_set_init_reg (gdbarch, ppc_dwarf2_frame_init_reg); + /* Fall Thru */ case GDB_OSABI_NETBSD_AOUT: case GDB_OSABI_NETBSD_ELF: --=-KRRXXZM5sY+Y7IsyF1LC--