This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix internal error on DW_OP_bregx(-1)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]