Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [patch] Fix internal error on DW_OP_bregx(-1)
Date: Mon, 19 Oct 2015 16:41:00 -0000	[thread overview]
Message-ID: <56251D4F.4020300@redhat.com> (raw)
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  <jan.kratochvil@redhat.com>
> 
> 	* findvar.c (address_from_register): Check REGNUM validity.
> 
> gdb/testsuite/ChangeLog
> 2015-10-12  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* 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:

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 {} {


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:
<http://www.gnu.org/software/gdb/bugs/>.


> +
> +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


  reply	other threads:[~2015-10-19 16:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12 19:25 Jan Kratochvil
2015-10-19 16:41 ` Pedro Alves [this message]
2015-10-21  9:28   ` [patchv2] " Jan Kratochvil
2015-10-21  9:49     ` Pedro Alves
2015-10-21  9:56       ` [commit] " Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56251D4F.4020300@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox