From patchwork Mon Oct 19 16:41:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 9227 Received: (qmail 39255 invoked by alias); 19 Oct 2015 16:41:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 39246 invoked by uid 89); 19 Oct 2015 16:41:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 19 Oct 2015 16:41:57 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 51A7FA8E for ; Mon, 19 Oct 2015 16:41:56 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9JGfquq000656; Mon, 19 Oct 2015 12:41:55 -0400 Message-ID: <56251D4F.4020300@redhat.com> Date: Mon, 19 Oct 2015 17:41:51 +0100 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Jan Kratochvil , gdb-patches@sourceware.org Subject: Re: [patch] Fix internal error on DW_OP_bregx(-1) References: <20151012192552.GA18998@host1.jankratochvil.net> In-Reply-To: <20151012192552.GA18998@host1.jankratochvil.net> On 10/12/2015 08:25 PM, Jan Kratochvil wrote: > but in i386 case it does: > /* This will hopefully provoke a warning. */ > return gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); > and the default implementation is a nop, leaving whatever register number > the DWARF specified. (Yeah, I think Doug had patches around this area.) > gdb/ChangeLog > 2015-10-12 Jan Kratochvil > > * findvar.c (address_from_register): Check REGNUM validity. > > gdb/testsuite/ChangeLog > 2015-10-12 Jan Kratochvil > > * gdb.dwarf2/dw2-regno-invalid.S: New file. > * gdb.dwarf2/dw2-regno-invalid.exp: New file. Please write this using the Dwarf assembler. I think we just need to teach it about DW_OP_bregx, like so: and: $ ./gdb -readnow ./testsuite/gdb.dwarf2/symtab-producer ... (gdb) start Temporary breakpoint 1 at 0x400594 Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.dwarf2/symtab-producer Temporary breakpoint 1, 0x0000000000400594 in main () (gdb) p bregx warning: Unmapped DWARF Register #-1 encountered. /home/pedro/gdb/mygit/build/../src/gdb/regcache.c:177: internal-error: register_size: Assertion `regnum >= 0 && regnum < (gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch))' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) n This is a bug, please report it. For instructions, see: . > + > +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile2}" \ > + "${binfile}" executable {}] != "" } { > + return -1 > +} > + > +clean_restart ${binfile} > +runto_main > + Please use prepare_for_testing. > +gdb_test "p variable" > Please add comments mentioning what is being tested, including intro comment at the top of the .exp file. Thanks, Pedro Alves diff --git c/gdb/testsuite/lib/dwarf.exp w/gdb/testsuite/lib/dwarf.exp index 515334e..888ba94 100644 --- c/gdb/testsuite/lib/dwarf.exp +++ w/gdb/testsuite/lib/dwarf.exp @@ -901,6 +901,11 @@ namespace eval Dwarf { _op .byte [lindex $line 1] } + DW_OP_bregx { + _op .uleb128 [lindex $line 1] + _op .sleb128 [lindex $line 2] + } + default { if {[llength $line] > 1} { error "Unimplemented: operands in location for $opcode" To make sure this works, I tested with: diff --git c/gdb/testsuite/gdb.dwarf2/symtab-producer.exp w/gdb/testsuite/gdb.dwarf2/symtab-producer.exp index abae89a..2ba39ae 100644 --- c/gdb/testsuite/gdb.dwarf2/symtab-producer.exp +++ w/gdb/testsuite/gdb.dwarf2/symtab-producer.exp @@ -50,6 +50,14 @@ Dwarf::assemble $asm_file { {DW_AT_external 1 flag} {DW_AT_const_value 42 DW_FORM_sdata} } + DW_TAG_variable { + {DW_AT_name bregx} + {DW_AT_type :$integer_label} + {DW_AT_external 1 flag} + {DW_AT_location { + DW_OP_bregx 0xffffffff 0 + } SPECIAL_expr} + } } } cu {} {