Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org, Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: [unavailable values part 1, 16/17] don't merge almost but not quite adjacent memory ranges to collect
Date: Wed, 16 Feb 2011 18:03:00 -0000	[thread overview]
Message-ID: <201102161759.59317.pedro@codesourcery.com> (raw)
In-Reply-To: <m3k4gz6i21.fsf@fleche.redhat.com>

On Wednesday 16 February 2011 16:49:26, Tom Tromey wrote:
> >>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:
> 
> Pedro> While writting the test in the patch below I tripped
> Pedro> on an internal error:
> >> collect {int [4]}globalarr2
> Pedro>  ../../src/gdb/ax-gdb.c:2053: internal-error: gen_expr: OP_MEMVAL operand isn't an rvalue???
> Pedro>  A problem internal to GDB has been detected,
> Pedro>  further debugging may prove unreliable.
> Pedro> ... bah.
> 
> I think that code is just confused.  Even the comment says so :-)
> 
> Could you try the appended?  I'm not totally sure about it; maybe for
> the axs_lvalue_memory case we should be calling gen_address_of.

Thanks!  Looks, works and test fine.

We get the same ax, whether we take the
address of the address expression or not:

 (gdb) maintenance agent {int [4]} globalarr3 
 Scope: 0x40091d
 Reg mask: 00
   0  const32 6299952
   5  const8 16
   7  trace
   8  end
 (gdb) maintenance agent {int [4]} &globalarr3
 Scope: 0x40091d
 Reg mask: 00
   0  const32 6299952
   5  const8 16
   7  trace
   8  end

Which is the same behavior of printing:

 (gdb) p {int [4]} &globalarr3
 $1 = {3, 2, 1, 0}
 (gdb) p {int [4]} globalarr3 
 $2 = {3, 2, 1, 0}

The ax also looks fine with registers ax values:

 (gdb) maintenance agent {int [4]} $rip
 Scope: 0x40091d
 Reg mask: 00 00 01
   0  reg 16
   3  zero_ext 64
   5  const8 16
   7  trace
   8  end

> I can't really test it here, since newer versions of GCC confuse AX
> generation :-(.  That is, I get this a lot when running collection.exp:
> 
> DWARF operator DW_OP_call_frame_cfa cannot be translated to an agent expression

> 
> This seems pretty important to fix.

Bummer.  Yeah.

I've added a simple testcase.  I didn't try cooking up
a variant for the axs_lval_register path.

I also wrote a ChangeLog entry.  Shall I go ahead and
commit this?

-- 
Pedro Alves

2011-02-16  Tom Tromey  <tromey@redhat.com>

	gdb/
	* ax-gdb.c.c (gen_expr) <UNOP_MEMVAL>: Handle value kinds other
	than axs_rvalue.

2011-02-16  Pedro Alves  <pedro@codesourcery.com>

	gdb/testsuite/
	* collection.c (globalarr3): New global.
	(main): Initialize it before collecting, and and clear it
	afterwards.
	* collection.exp (gdb_collect_globals_test): Test collecting with
	'{type} addr', where the addr expression is not an rvalue.

---
 gdb/ax-gdb.c                           |   15 +++++++--------
 gdb/testsuite/gdb.trace/collection.c   |    6 ++++++
 gdb/testsuite/gdb.trace/collection.exp |   11 ++++++++++-
 3 files changed, 23 insertions(+), 9 deletions(-)

Index: src/gdb/ax-gdb.c
===================================================================
--- src.orig/gdb/ax-gdb.c	2011-01-13 15:07:17.386075004 +0000
+++ src/gdb/ax-gdb.c	2011-02-16 17:05:25.816002008 +0000
@@ -2044,14 +2044,13 @@ gen_expr (struct expression *exp, union
 
 	(*pc) += 3;
 	gen_expr (exp, pc, ax, value);
-	/* I'm not sure I understand UNOP_MEMVAL entirely.  I think
-	   it's just a hack for dealing with minsyms; you take some
-	   integer constant, pretend it's the address of an lvalue of
-	   the given type, and dereference it.  */
-	if (value->kind != axs_rvalue)
-	  /* This would be weird.  */
-	  internal_error (__FILE__, __LINE__,
-			  _("gen_expr: OP_MEMVAL operand isn't an rvalue???"));
+
+	/* If we have an axs_rvalue or an axs_lvalue_memory, then we
+	   already have the right value on the stack.  For
+	   axs_lvalue_register, we must convert.  */
+	if (value->kind == axs_lvalue_register)
+	  require_rvalue (ax, value);
+
 	value->type = type;
 	value->kind = axs_lvalue_memory;
       }
Index: src/gdb/testsuite/gdb.trace/collection.c
===================================================================
--- src.orig/gdb/testsuite/gdb.trace/collection.c	2011-02-16 12:49:02.000000000 +0000
+++ src/gdb/testsuite/gdb.trace/collection.c	2011-02-16 17:41:25.426002003 +0000
@@ -27,6 +27,7 @@ test_struct  globalstruct;
 test_struct *globalp;
 int          globalarr[16];
 int          globalarr2[4];
+int          globalarr3[4];
 
 struct global_pieces {
   unsigned int a;
@@ -241,6 +242,9 @@ main (argc, argv, envp)
   for (i = 0; i < 4; i++)
     globalarr2[i] = i;
 
+  for (i = 0; i < 4; i++)
+    globalarr3[3 - i] = i;
+
   mystruct.memberc = 101;
   mystruct.memberi = 102;
   mystruct.memberf = 103.3;
@@ -289,6 +293,8 @@ main (argc, argv, envp)
     globalarr[i] = 0;
   for (i = 0; i < 4; i++)
     globalarr2[i] = 0;
+  for (i = 0; i < 4; i++)
+    globalarr3[i] = 0;
 
   end ();
   return 0;
Index: src/gdb/testsuite/gdb.trace/collection.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.trace/collection.exp	2011-02-16 12:49:02.000000000 +0000
+++ src/gdb/testsuite/gdb.trace/collection.exp	2011-02-16 17:49:45.276001996 +0000
@@ -479,7 +479,8 @@ proc gdb_collect_globals_test { } {
 	    "collect globalc, globali, globalf, globald" "^$" \
 	    "collect globalstruct, globalp, globalarr" "^$" \
 	    "collect \{int \[4\]\}$globalarr2_addr" "^$" \
-	    "collect \{int \[2\]\}$globalarr2_addr" "^$"
+	    "collect \{int \[2\]\}$globalarr2_addr" "^$" \
+	    "collect \{int \[4\]\}globalarr3" "^$"
 
     # Begin the test.
     run_trace_experiment "globals" globals_test_func
@@ -530,6 +531,14 @@ proc gdb_collect_globals_test { } {
 	"\\$\[0-9\]+ = \\{0, 1, 2, 3\\}$cr" \
 	"collect globals: collected global array 2"
 
+    # GDB would internal error collecting UNOP_MEMVAL's whose address
+    # expression wasn't an rvalue (that's regtested in the
+    # corresponding 'collect' action above).  This just double checks
+    # we actually did collect what we wanted.
+    gdb_test "print globalarr3" \
+	"\\$\[0-9\]+ = \\{3, 2, 1, 0\\}$cr" \
+	"collect globals: collected global array 3"
+
     gdb_test "tfind none" \
 	    "#0  end .*" \
 	    "collect globals: cease trace debugging"


  reply	other threads:[~2011-02-16 18:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07 14:35 Pedro Alves
2011-02-14 12:01 ` Jan Kratochvil
2011-02-16 13:10   ` Pedro Alves
2011-02-16 18:00     ` Tom Tromey
2011-02-16 18:03       ` Pedro Alves [this message]
2011-02-16 18:07         ` Tom Tromey
2011-02-16 18:09           ` Pedro Alves
2011-02-16 18:09       ` Tom Tromey
2011-02-16 21:01         ` FYI: handle DW_OP_call_frame_cfa in AX compiler (Was: [unavailable values part 1, 16/17] don't merge almost but not quite adjacent memory ranges to collect) Tom Tromey
2011-02-16 21:31           ` FYI: handle DW_OP_call_frame_cfa in AX compiler Pedro Alves
2011-02-16 21:40             ` Tom Tromey
2011-02-16 23:27               ` Pedro Alves
2011-02-17 16:24                 ` 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=201102161759.59317.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --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