Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: fix PR c++/14999
Date: Sat, 19 Jan 2013 15:54:00 -0000	[thread overview]
Message-ID: <20130119155435.GA5215@adacore.com> (raw)
In-Reply-To: <87mwwj38hm.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1936 bytes --]

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

[-- Attachment #2: 0001-Rework-GDB-PR-c-14999.patch --]
[-- Type: text/x-diff, Size: 1610 bytes --]

From 6ec232c4c61e5840042109ac119b8f284ff3f7b4 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Sat, 19 Jan 2013 19:13:14 +0400
Subject: [PATCH] Rework GDB PR c++/14999

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.
---
 gdb/dwarf2loc.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 2282feb..b540ef5 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -2765,6 +2765,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
 	  dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_regx");
 	  loc->u.reg = translate_register (arch, op - DW_OP_reg0);
 	  loc->kind = axs_lvalue_register;
+	  ax_reg (expr, loc->u.reg);
 	  break;
 
 	case DW_OP_regx:
@@ -2772,6 +2773,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
 	  dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_regx");
 	  loc->u.reg = translate_register (arch, reg);
 	  loc->kind = axs_lvalue_register;
+	  ax_reg (expr, loc->u.reg);
 	  break;
 
 	case DW_OP_implicit_value:
@@ -2878,7 +2880,6 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
 	    op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
 	    dwarf2_compile_expr_to_ax (expr, loc, arch, addr_size, datastart,
 				       datastart + datalen, per_cu);
-	    require_rvalue (expr, loc);
 
 	    if (offset != 0)
 	      {
-- 
1.7.10.4


  parent reply	other threads:[~2013-01-19 15:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 17:11 Tom Tromey
2013-01-18 18:25 ` Tom Tromey
2013-01-19 15:54 ` Joel Brobecker [this message]
2013-01-19 19:34   ` Tom Tromey
2013-01-21 16:04   ` Tom Tromey
2013-01-22  2:55     ` Joel Brobecker
2013-01-22 15:57       ` Tom Tromey

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=20130119155435.GA5215@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@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