RFC: fix PR c++/14999

Joel Brobecker brobecker@adacore.com
Sat Jan 19 15:54:00 GMT 2013


Hi Tom,

> The problem here is that setting a tracepoint and collecting a certain
> local variable will cause a crash, if the source code was compiled with
> clang.
>
> The bug is just a missing call to require_rvalue when handling
> DW_OP_fbreg in the DWARF->AX translator.
[...]
>     	PR c++/14999:
>     	* dwarf2loc.c (dwarf2_compile_expr_to_ax) <DW_OP_fbreg>:
>     	Call require_rvalue.
>     
>     	* gdb.dwarf2/trace-crash.s: New file.
>     	* gdb.dwarf2/trace-crash.exp: New file.

Unfortunately, this patch causes a number of regressions which do
appear with the testsuite if you run it with gdbserver.

At the heart of the regression is the fact that the dwarf-to-ax
compiler, for a variable whose location looks like this:

    (gdb) info address i
    Symbol "i" is a variable at frame base reg $rbp offset 16+-44.

will now generate:

    (gdb) maintenance agent-eval i
    Scope: 0x404953
    Reg mask: 40
      0  reg 6
      3  const8 16
      5  add
      6  ref32    <<<<<-----  Unwanted dereference
      7  ext 32   <<<<<-----
      9  const8 212
     11  ext 8
     13  add
     14  ref32
     15  ext 32
     17  end

This affects conditional breakpoints when running with a gdbserver,
because gdbserver now evaluates incorrectly the condition on the
gdbserver side.

I looked at the PR, and it seems to me that the problem comes
from the fact that the ax stack was missing the "reg 7" operation.
I don't really understand the code well enough to be sure about
my fix, in particular what the "loc" parameter is about, but
the attached patch seems to restore the origin behavior while
still keeping your new testcase happy.

gdb/ChangeLog:

        PR c++/14999:
        * dwarf2_compile_expr_to_ax (dwarf2_compile_expr_to_ax):
        Add a call to ax_reg for DW_OP_reg* opcodes.
        <DW_OP_fbreg>: Remove call to require_rvalue.

Tested on x86_64-linux with gdbserver, fixes about 125 failures.

-- 
Joel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Rework-GDB-PR-c-14999.patch
Type: text/x-diff
Size: 1611 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20130119/9090b8df/attachment.bin>


More information about the Gdb-patches mailing list