public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-jankratochvil-entryval: +@entry
@ 2011-07-07 20:32 jkratoch
  0 siblings, 0 replies; only message in thread
From: jkratoch @ 2011-07-07 20:32 UTC (permalink / raw)
  To: archer-commits

The branch, archer-jankratochvil-entryval has been updated
       via  5338cf4fd4d6743ec1f5dff3ef4cdcc5a5f3ce22 (commit)
       via  d47f228302cb92e2c8d2567779eacaef39d47eb4 (commit)
      from  f6f20ca5307e4b2e25aaeae6629e12b59d7c9e37 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 5338cf4fd4d6743ec1f5dff3ef4cdcc5a5f3ce22
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Jul 7 22:32:26 2011 +0200

    +@entry

commit d47f228302cb92e2c8d2567779eacaef39d47eb4
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Jul 7 15:18:15 2011 +0200

    entry resolving

-----------------------------------------------------------------------

Summary of changes:
 gdb/c-exp.y          |   22 ++++++++++++++++++++++
 gdb/doc/gdb.texinfo  |   28 +++++++++++++++++++++++++++-
 gdb/dwarf2loc.c      |   17 ++++++++++++++++-
 gdb/eval.c           |   35 +++++++++++++++++++++++++++++++++++
 gdb/expprint.c       |   17 +++++++++++++++++
 gdb/parse.c          |    1 +
 gdb/printcmd.c       |    3 +--
 gdb/std-operator.def |    6 ++++++
 8 files changed, 125 insertions(+), 4 deletions(-)

First 500 lines of diff:
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 94d0737..0c0a53b 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -186,6 +186,7 @@ static struct stoken operator_stoken (const char *);
 %token <tsval> STRING
 %token <tsval> CHAR
 %token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */
+%token <ssym> ENTRY
 %token <ssym> UNKNOWN_CPP_NAME
 %token <voidval> COMPLETE
 %token <tsym> TYPENAME
@@ -756,6 +757,21 @@ block	:	block COLONCOLON name
 			  $$ = SYMBOL_BLOCK_VALUE (tem); }
 	;
 
+variable:	name_not_typename '@' ENTRY
+			{ struct symbol *sym = $1.sym;
+
+			  if (sym == NULL || !SYMBOL_IS_ARGUMENT (sym)
+			      || !symbol_read_needs_frame (sym))
+			    error (_("@entry can be used only for function "
+				     "parameters, not for %s"),
+				   copy_name ($1.stoken));
+
+			  write_exp_elt_opcode (OP_VAR_ENTRY_VALUE);
+			  write_exp_elt_sym (sym);
+			  write_exp_elt_opcode (OP_VAR_ENTRY_VALUE);
+			}
+	;
+
 variable:	block COLONCOLON name
 			{ struct symbol *sym;
 			  sym = lookup_symbol (copy_name ($3), $1,
@@ -1317,11 +1333,13 @@ name	:	NAME { $$ = $1.stoken; }
 	|	TYPENAME { $$ = $1.stoken; }
 	|	NAME_OR_INT  { $$ = $1.stoken; }
 	|	UNKNOWN_CPP_NAME  { $$ = $1.stoken; }
+	|	ENTRY { $$ = $1.stoken; }
 	|	operator { $$ = $1; }
 	;
 
 name_not_typename :	NAME
 	|	BLOCKNAME
+	|	ENTRY
 /* These would be useful if name_not_typename was useful, but it is just
    a fake for "variable", so these cause reduce/reduce conflicts because
    the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable,
@@ -2525,6 +2543,10 @@ yylex (void)
   current.token = lex_one_token ();
   if (current.token == NAME)
     current.token = classify_name (expression_context_block);
+  if (current.token == NAME && yylval.sval.length == strlen ("entry")
+      && strncmp (yylval.sval.ptr, "entry", strlen ("entry")) == 0)
+    current.token = ENTRY;
+
   if (parse_language->la_language != language_cplus
       || (current.token != TYPENAME && current.token != COLONCOLON))
     return current.token;
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 129a46b..152b3ab 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -5947,7 +5947,13 @@ Similar, but print only the outermost @var{n} frames.
 @itemx bt full
 @itemx bt full @var{n}
 @itemx bt full -@var{n}
-Print the values of the local variables also.  @var{n} specifies the
+Print the values of the local variables also.
+
+Names with appended @code{@@entry} show values of function parameters at the
+time the function got called.  The @code{@@entry} parameter line is not shown
+when the entry value is not available.
+
+@var{n} specifies the
 number of frames to print, as described above.
 @end table
 
@@ -6223,6 +6229,10 @@ architectures) that you specify in the @code{frame} command.
 @item info args
 Print the arguments of the selected frame, each on a separate line.
 
+Names with appended @code{@@entry} show values of function parameters at the
+time the function got called.  The @code{@@entry} parameter line is not shown
+when the entry value is not available.
+
 @item info locals
 @kindex info locals
 Print the local variables of the selected frame, each on a separate
@@ -7277,6 +7287,22 @@ If you ask to print an object whose contents are unknown to
 by the debug information, @value{GDBN} will say @samp{<incomplete
 type>}.  @xref{Symbols, incomplete type}, for more about this.
 
+If you append @code{@@entry} string to a function parameter name you get its
+value at the time the function got called.  If the value is not available an
+error message is printed.  Entry values are available only since @value{NGCC}
+version 4.7.
+
+@smallexample
+Breakpoint 1, d (i=30) at gdb.base/entry-value.c:29
+29	  i++;
+(gdb) next
+30	  e (i);
+(gdb) print i
+$1 = 31
+(gdb) print i@@entry
+$2 = 30
+@end smallexample
+
 Strings are identified as arrays of @code{char} values without specified
 signedness.  Arrays of either @code{signed char} or @code{unsigned char} get
 printed as arrays of 1 byte sized integers.  @code{-fsigned-char} or
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index f074866..0ddf00e 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -119,6 +119,21 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton,
       length = extract_unsigned_integer (loc_ptr, 2, byte_order);
       loc_ptr += 2;
 
+      if (low == high && pc == low)
+	{
+	  struct block *pc_block = block_for_pc (pc);
+	  struct symbol *pc_func = NULL;
+
+	  if (pc_block)
+	    pc_func = block_linkage_function (pc_block);
+
+	  if (pc_func && pc == BLOCK_START (SYMBOL_BLOCK_VALUE (pc_func)))
+	    {
+	      *locexpr_length = length;
+	      return loc_ptr;
+	    }
+	}
+
       if (pc >= low && pc < high)
 	{
 	  *locexpr_length = length;
@@ -3321,7 +3336,7 @@ locexpr_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
    evaluator.  */
 const struct symbol_computed_ops dwarf2_locexpr_funcs = {
   locexpr_read_variable,
-  locexpr_read_variable,	/* read_variable_at_entry */
+  NULL,				/* read_variable_at_entry */
   locexpr_read_needs_frame,
   locexpr_describe_location,
   locexpr_tracepoint_var_ref
diff --git a/gdb/eval.c b/gdb/eval.c
index 57a871f..870003e 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -860,6 +860,41 @@ evaluate_subexp_standard (struct type *expect_type,
 	return ret;
       }
 
+    case OP_VAR_ENTRY_VALUE:
+      (*pos) += 2;
+      if (noside == EVAL_SKIP)
+	goto nosideret;
+
+      {
+	struct symbol *sym = exp->elts[pc + 1].symbol;
+	volatile struct gdb_exception except;
+	struct value *ret = NULL;
+
+	TRY_CATCH (except, RETURN_MASK_ERROR)
+	  {
+	    struct frame_info *frame;
+
+	    if (SYMBOL_CLASS (sym) != LOC_COMPUTED
+		|| SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry == NULL)
+	      error (_("Symbol \"%s\" does not have any specific entry value"),
+		     SYMBOL_PRINT_NAME (sym));
+
+	    frame = get_selected_frame (NULL);
+	    ret = SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry (sym,
+								     frame);
+	  }
+
+	if (except.reason < 0)
+	  {
+	    if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	      ret = value_zero (SYMBOL_TYPE (sym), not_lval);
+	    else
+	      throw_exception (except);
+	  }
+
+	return ret;
+      }
+
     case OP_LAST:
       (*pos) += 2;
       return
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 2b6e416..0e0f1c3 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -135,6 +135,16 @@ print_subexp_standard (struct expression *exp, int *pos,
       }
       return;
 
+    case OP_VAR_ENTRY_VALUE:
+      {
+	struct block *b;
+
+	(*pos) += 2;
+	fprintf_filtered (stream, "%s@entry",
+			  SYMBOL_PRINT_NAME (exp->elts[pc + 1].symbol));
+      }
+      return;
+
     case OP_LAST:
       (*pos) += 2;
       fprintf_filtered (stream, "$%d",
@@ -853,6 +863,13 @@ dump_subexp_body_standard (struct expression *exp,
 			SYMBOL_PRINT_NAME (exp->elts[elt + 1].symbol));
       elt += 3;
       break;
+    case OP_VAR_ENTRY_VALUE:
+      fprintf_filtered (stream, "Entry value of symbol @");
+      gdb_print_host_address (exp->elts[elt].symbol, stream);
+      fprintf_filtered (stream, " (%s)",
+			SYMBOL_PRINT_NAME (exp->elts[elt].symbol));
+      elt += 2;
+      break;
     case OP_LAST:
       fprintf_filtered (stream, "History element %ld",
 			(long) exp->elts[elt].longconst);
diff --git a/gdb/parse.c b/gdb/parse.c
index a8523e6..e4f79d3 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -853,6 +853,7 @@ operator_length_standard (const struct expression *expr, int endpos,
     case OP_BOOL:
     case OP_LAST:
     case OP_INTERNALVAR:
+    case OP_VAR_ENTRY_VALUE:
       oplen = 3;
       break;
 
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 90e9bde..0529df0 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1962,8 +1962,7 @@ print_variable_and_value (const char *name, struct symbol *var,
 
       if (print_argument != PVAVD_IS_NOT_ARGUMENT
 	  && SYMBOL_CLASS (var) == LOC_COMPUTED
-	  && (SYMBOL_COMPUTED_OPS (var)->read_variable_at_entry
-	      != SYMBOL_COMPUTED_OPS (var)->read_variable))
+	  && SYMBOL_COMPUTED_OPS (var)->read_variable_at_entry != NULL)
 	{
 	  const struct symbol_computed_ops *ops;
 	  unsigned len = TYPE_LENGTH (value_type (val));
diff --git a/gdb/std-operator.def b/gdb/std-operator.def
index 2c77141..3b6b0ae 100644
--- a/gdb/std-operator.def
+++ b/gdb/std-operator.def
@@ -139,6 +139,12 @@ OP (OP_DOUBLE)
    use the selected frame.  */
 OP (OP_VAR_VALUE)
 
+/* OP_VAR_ENTRY_VALUE takes one struct symbol * in the following element,
+   followed by another OP_VAR_ENTRY_VALUE, making three exp_elements.
+   somename@entry may mean parameter value as present at the entry of the
+   current function.  Implemented via DW_OP_GNU_entry_value.  */
+OP (OP_VAR_ENTRY_VALUE)
+
 /* OP_LAST is followed by an integer in the next exp_element.
    The integer is zero for the last value printed,
    or it is the absolute number of a history element.


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-07-07 20:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-07 20:32 [SCM] archer-jankratochvil-entryval: +@entry jkratoch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).