Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* expressions with C preprocessor macro info
@ 2008-05-03 20:38 Pedro Alves
  2008-05-03 20:40 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2008-05-03 20:38 UTC (permalink / raw)
  To: gdb-patches

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

Hi,

I noticed while doing something else in parse.c, something suspicous.
It happens that after preprocessor macros support went
in, parse.c:parse_exp_in_context got changed in a form that
introduced a bug here:

static struct expression *
parse_exp_in_context (char **stringptr, struct block *block, int comma, 
		      int void_context_p)
{
...
  if (!block)
    block = get_selected_block (&expression_context_pc);

   ^^^ if this returns a block, expression_context_pc contains
       an accurate pc.

  /* Fall back to using the current source static context, if any. */

  if (!block)
    {
      struct symtab_and_line cursal = get_current_source_symtab_and_line ();
      if (cursal.symtab)
	block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK);
    }

  /* Save the context, if specified by caller, or found above. */

  if (block)
    {
      expression_context_block = block;
      expression_context_pc = BLOCK_START (block);

      ^^^ but here we're always overriding it with BLOCK_START.

    }

Talking about this with Jim Blandy, he explained it like so:

 "We want the exact PC because macros are scoped from one line to the
 next, not by block.  For example, we could have:

    {
      int foo;

      f ();
#define M slurgh;
      g ();
#undef M
      h ();
    }

 In this case, there will be only one lexical block covering the
 declaration of foo and all three statements, but we'd like to see the
 definition of M when we're stopped at the call to g, and not when
 we're stopped at the calls to f or h.  So we need to take a PC, find
 the source line and file, and then use that to decide whether any
 given macro is in scope."

Currently, "print M" when stopped at the g (); call above prints:
(gdb) print M
No symbol "M" in current context.

The attached patch fixes the issue, and adds a test to ensure
we don't regress again.

Tested on x86_64-unknown-linux-pc.

OK?

-- 
Pedro Alves

[-- Attachment #2: expression_context_pc.diff --]
[-- Type: text/x-diff, Size: 3918 bytes --]

2008-05-03  Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* parse.c (parse_exp_in_context): Don't override
	expression_context_pc if get_selected_block returned a valid block.

	gdb/testsuite/
	* gdb.base/macscp.exp, gdb.base/macscp1.c: Add test for printing
	expressions with macros.

---
 gdb/parse.c                       |   26 ++++++++++++--------------
 gdb/testsuite/gdb.base/macscp.exp |   23 +++++++++++++++++++++++
 gdb/testsuite/gdb.base/macscp1.c  |   13 +++++++++++++
 3 files changed, 48 insertions(+), 14 deletions(-)

Index: src/gdb/parse.c
===================================================================
--- src.orig/gdb/parse.c	2008-05-03 20:32:38.000000000 +0100
+++ src/gdb/parse.c	2008-05-03 20:43:01.000000000 +0100
@@ -961,26 +961,24 @@ parse_exp_in_context (char **stringptr, 
   old_chain = make_cleanup (free_funcalls, 0 /*ignore*/);
   funcall_chain = 0;
 
-  /* If no context specified, try using the current frame, if any. */
+  expression_context_block = block;
 
-  if (!block)
-    block = get_selected_block (&expression_context_pc);
+  /* If no context specified, try using the current frame, if any.  */
+  if (!expression_context_block)
+    expression_context_block = get_selected_block (&expression_context_pc);
+  else
+    expression_context_pc = BLOCK_START (expression_context_block);
 
-  /* Fall back to using the current source static context, if any. */
+  /* Fall back to using the current source static context, if any.  */
 
-  if (!block)
+  if (!expression_context_block)
     {
       struct symtab_and_line cursal = get_current_source_symtab_and_line ();
       if (cursal.symtab)
-	block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK);
-    }
-
-  /* Save the context, if specified by caller, or found above. */
-
-  if (block)
-    {
-      expression_context_block = block;
-      expression_context_pc = BLOCK_START (block);
+	expression_context_block
+	  = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK);
+      if (expression_context_block)
+	expression_context_pc = BLOCK_START (expression_context_block);
     }
 
   expout_size = 10;
Index: src/gdb/testsuite/gdb.base/macscp.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/macscp.exp	2008-05-03 20:32:39.000000000 +0100
+++ src/gdb/testsuite/gdb.base/macscp.exp	2008-05-03 20:37:56.000000000 +0100
@@ -24,6 +24,7 @@ if $tracelevel then {
 set prms_id 0
 set bug_id 0
 
+set srcfile macscp1.c
 set testfile "macscp"
 set binfile ${objdir}/${subdir}/${testfile}
 
@@ -405,3 +406,25 @@ for {set i 0} {$i < [llength $funcs]} {i
         }
     }
 }
+
+gdb_test "break [gdb_get_line_number "set breakpoint here"]" \
+    "Breakpoint.*at.* file .*, line.*" \
+    "breakpoint macscp_expr"
+
+gdb_test "continue" "foo = 0;.*" "continue to macsp_expr"
+
+gdb_test "print M" \
+    "No symbol \"M\" in current context\." \
+    "print expression with macro before define."
+
+gdb_test "next" "foo = 1;" "next to definition"
+
+gdb_test "print M" \
+    " = 0" \
+    "print expression with macro in scope."
+
+gdb_test "next" "foo = 2;" "next to definition"
+
+gdb_test "print M" \
+    "No symbol \"M\" in current context\." \
+    "print expression with macro after undef."
Index: src/gdb/testsuite/gdb.base/macscp1.c
===================================================================
--- src.orig/gdb/testsuite/gdb.base/macscp1.c	2008-05-03 20:32:39.000000000 +0100
+++ src/gdb/testsuite/gdb.base/macscp1.c	2008-05-03 20:37:56.000000000 +0100
@@ -63,6 +63,18 @@ macscp1_3 ()
   puts ("macscp1_3");
 }
 
+void
+macscp_expr (void)
+{
+  int foo = -1;
+
+  foo = 0;  /* set breakpoint here */
+#define M foo
+  foo = 1;
+#undef M
+  foo = 2;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -77,4 +89,5 @@ main (int argc, char **argv)
   macscp4_2_from_macscp3 ();
   macscp3_2 ();
   macscp1_3 ();
+  macscp_expr ();
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: expressions with C preprocessor macro info
  2008-05-03 20:38 expressions with C preprocessor macro info Pedro Alves
@ 2008-05-03 20:40 ` Daniel Jacobowitz
  2008-05-03 23:27   ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-05-03 20:40 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Sat, May 03, 2008 at 09:19:27PM +0100, Pedro Alves wrote:
> 2008-05-03  Pedro Alves  <pedro@codesourcery.com>
> 
> 	gdb/
> 	* parse.c (parse_exp_in_context): Don't override
> 	expression_context_pc if get_selected_block returned a valid block.
> 
> 	gdb/testsuite/
> 	* gdb.base/macscp.exp, gdb.base/macscp1.c: Add test for printing
> 	expressions with macros.

This patch is OK since it's clearly progress.  But doesn't this mean
that we should be passing a PC to parse_exp_1, not a block?  Otherwise
macros will not be correct in e.g. breakpoint conditions:

                loc->cond =
                  parse_exp_1 (&arg, block_for_pc (loc->address), 0);

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: expressions with C preprocessor macro info
  2008-05-03 20:40 ` Daniel Jacobowitz
@ 2008-05-03 23:27   ` Pedro Alves
  2008-06-05 16:27     ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2008-05-03 23:27 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

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

A Saturday 03 May 2008 21:27:44, Daniel Jacobowitz wrote:
> On Sat, May 03, 2008 at 09:19:27PM +0100, Pedro Alves wrote:
> > 2008-05-03  Pedro Alves  <pedro@codesourcery.com>
> >
> > 	gdb/
> > 	* parse.c (parse_exp_in_context): Don't override
> > 	expression_context_pc if get_selected_block returned a valid block.
> >
> > 	gdb/testsuite/
> > 	* gdb.base/macscp.exp, gdb.base/macscp1.c: Add test for printing
> > 	expressions with macros.
>
> This patch is OK since it's clearly progress.  

Thanks, I installed it -- better keep this regression fix separate
from follow up improvements.

> But doesn't this mean 
> that we should be passing a PC to parse_exp_1, not a block?  Otherwise
> macros will not be correct in e.g. breakpoint conditions:
>
>                 loc->cond =
>                   parse_exp_1 (&arg, block_for_pc (loc->address), 0);

Yes, looks like it.  At some point, it may even be better to get rid
of expression_context_block in the language parsers, in favor of 
expression_context_pc for variables declared midblock, I guess:

 {
    a = 1;
    f ();
    B b;
    g ();
 }

I'll submit a patch to the insight side if the attached is OK.  Tested
on x86_64-unknown-linux-gnu.

-- 
Pedro Alves

[-- Attachment #2: parse_exp_1_context_pc.diff --]
[-- Type: text/x-diff, Size: 14177 bytes --]

2008-05-03  Pedro Alves  <pedro@codesourcery.com>

	* expression.h (parse_exp_1): Take a context PC instead of a
	context block.

	* parse.c (parse_exp_1): Adjust.
	(parse_exp_in_context): Take a context PC instead of a context
	block.  If valid PC is passed, get the context block from it.
	(parse_expression): Adjust to the new signature of parse_exp_1.
	* ada-lang.c (ada_parse_catchpoint_condition): Likewise.
	* breakpoint.c (condition_command, update_watchpoint): Likewise.
	* eval.c (parse_and_eval_address_1, parse_to_comma_and_eval):
	Likewise.
	* tracepoint.c (validate_actionline, encode_actions): Likewise.
	* varobj.c (varobj_create, varobj_set_value): Likewise.

	* wrapper.h (gdb_parse_exp_1): Take a context PC instead of a
	context block.
	* wrapper.c (gdb_parse_exp_1): Adjust to the new signature of
	parse_exp_1.

---
 gdb/ada-lang.c   |    2 +-
 gdb/breakpoint.c |   24 +++++++++++++++---------
 gdb/eval.c       |    4 ++--
 gdb/expression.h |    2 +-
 gdb/parse.c      |   49 +++++++++++++++++++++++++------------------------
 gdb/tracepoint.c |    5 ++---
 gdb/varobj.c     |   11 ++++++-----
 gdb/wrapper.c    |    4 ++--
 gdb/wrapper.h    |    2 +-
 9 files changed, 55 insertions(+), 48 deletions(-)

Index: src/gdb/expression.h
===================================================================
--- src.orig/gdb/expression.h	2008-05-03 23:17:27.000000000 +0100
+++ src/gdb/expression.h	2008-05-03 23:23:41.000000000 +0100
@@ -389,7 +389,7 @@ struct expression
 
 extern struct expression *parse_expression (char *);
 
-extern struct expression *parse_exp_1 (char **, struct block *, int);
+extern struct expression *parse_exp_1 (char **, CORE_ADDR, int);
 
 /* The innermost context required by the stack and register variables
    we've encountered so far.  To use this, set it to NULL, then call
Index: src/gdb/parse.c
===================================================================
--- src.orig/gdb/parse.c	2008-05-03 23:23:39.000000000 +0100
+++ src/gdb/parse.c	2008-05-03 23:23:41.000000000 +0100
@@ -105,8 +105,7 @@ static void prefixify_expression (struct
 static void prefixify_subexp (struct expression *, struct expression *, int,
 			      int);
 
-static struct expression *parse_exp_in_context (char **, struct block *, int, 
-						int);
+static struct expression *parse_exp_in_context (char **, CORE_ADDR, int, int);
 
 void _initialize_parse (void);
 
@@ -924,8 +923,8 @@ prefixify_subexp (struct expression *ine
 
 /* Read an expression from the string *STRINGPTR points to,
    parse it, and return a pointer to a  struct expression  that we malloc.
-   Use block BLOCK as the lexical context for variable names;
-   if BLOCK is zero, use the block of the selected stack frame.
+   Use CONTEXT_PC to get the lexical context for variable names;
+   if CONTEXT_PC is -1, use the block of the selected stack frame.
    Meanwhile, advance *STRINGPTR to point after the expression,
    at the first nonwhite character that is not part of the expression
    (possibly a null character).
@@ -933,16 +932,16 @@ prefixify_subexp (struct expression *ine
    If COMMA is nonzero, stop if a comma is reached.  */
 
 struct expression *
-parse_exp_1 (char **stringptr, struct block *block, int comma)
+parse_exp_1 (char **stringptr, CORE_ADDR context_pc, int comma)
 {
-  return parse_exp_in_context (stringptr, block, comma, 0);
+  return parse_exp_in_context (stringptr, context_pc, comma, 0);
 }
 
 /* As for parse_exp_1, except that if VOID_CONTEXT_P, then
    no value is expected from the expression.  */
 
 static struct expression *
-parse_exp_in_context (char **stringptr, struct block *block, int comma, 
+parse_exp_in_context (char **stringptr, CORE_ADDR context_pc, int comma,
 		      int void_context_p)
 {
   struct cleanup *old_chain;
@@ -961,24 +960,26 @@ parse_exp_in_context (char **stringptr, 
   old_chain = make_cleanup (free_funcalls, 0 /*ignore*/);
   funcall_chain = 0;
 
-  expression_context_block = block;
-
-  /* If no context specified, try using the current frame, if any.  */
-  if (!expression_context_block)
-    expression_context_block = get_selected_block (&expression_context_pc);
+  if (context_pc != ~(CORE_ADDR) 0)
+    {
+      expression_context_block = block_for_pc (context_pc);
+      expression_context_pc = context_pc;
+    }
   else
-    expression_context_pc = BLOCK_START (expression_context_block);
-
-  /* Fall back to using the current source static context, if any.  */
-
-  if (!expression_context_block)
     {
-      struct symtab_and_line cursal = get_current_source_symtab_and_line ();
-      if (cursal.symtab)
-	expression_context_block
-	  = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK);
-      if (expression_context_block)
-	expression_context_pc = BLOCK_START (expression_context_block);
+      /* If no context specified, try using the current frame, if any.  */
+      expression_context_block = get_selected_block (&expression_context_pc);
+
+      /* Fall back to using the current source static context, if any.  */
+      if (!expression_context_block)
+	{
+	  struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+	  if (cursal.symtab)
+	    expression_context_block
+	      = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK);
+	  if (expression_context_block)
+	    expression_context_pc = BLOCK_START (expression_context_block);
+	}
     }
 
   expout_size = 10;
@@ -1027,7 +1028,7 @@ struct expression *
 parse_expression (char *string)
 {
   struct expression *exp;
-  exp = parse_exp_1 (&string, 0, 0);
+  exp = parse_exp_1 (&string, ~(CORE_ADDR) 0, 0);
   if (*string)
     error (_("Junk after end of expression."));
   return exp;
Index: src/gdb/ada-lang.c
===================================================================
--- src.orig/gdb/ada-lang.c	2008-05-03 23:17:27.000000000 +0100
+++ src/gdb/ada-lang.c	2008-05-03 23:23:41.000000000 +0100
@@ -10402,7 +10402,7 @@ static struct expression *
 ada_parse_catchpoint_condition (char *cond_string,
                                 struct symtab_and_line sal)
 {
-  return (parse_exp_1 (&cond_string, block_for_pc (sal.pc), 0));
+  return (parse_exp_1 (&cond_string, sal.pc, 0));
 }
 
 /* Return the symtab_and_line that should be used to insert an exception
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c	2008-05-03 23:23:15.000000000 +0100
+++ src/gdb/breakpoint.c	2008-05-03 23:23:41.000000000 +0100
@@ -617,7 +617,7 @@ condition_command (char *arg, int from_t
 	      {
 		arg = p;
 		loc->cond =
-		  parse_exp_1 (&arg, block_for_pc (loc->address), 0);
+		  parse_exp_1 (&arg, loc->address, 0);
 		if (*arg)
 		  error (_("Junk at end of expression"));
 	      }
@@ -910,13 +910,17 @@ update_watchpoint (struct breakpoint *b,
   if (within_current_scope && reparse)
     {
       char *s;
+      CORE_ADDR context_pc = ~(CORE_ADDR) 0;
+
       if (b->exp)
 	{
 	  xfree (b->exp);
 	  b->exp = NULL;
 	}
       s = b->exp_string;
-      b->exp = parse_exp_1 (&s, b->exp_valid_block, 0);
+      if (b->exp_valid_block)
+	context_pc = BLOCK_START (b->exp_valid_block);
+      b->exp = parse_exp_1 (&s, context_pc, 0);
       /* If the meaning of expression itself changed, the old value is
 	 no longer relevant.  We don't want to report a watchpoint hit
 	 to the user when the old value and the new value may actually
@@ -1001,7 +1005,10 @@ update_watchpoint (struct breakpoint *b,
       if (b->cond_string != NULL)
 	{
 	  char *s = b->cond_string;
-	  b->loc->cond = parse_exp_1 (&s, b->exp_valid_block, 0);
+	  CORE_ADDR context_pc = ~(CORE_ADDR) 0;
+	  if (b->exp_valid_block)
+	    context_pc = BLOCK_START (b->exp_valid_block);
+	  b->loc->cond = parse_exp_1 (&s, context_pc, 0);
 	}
     }
   else if (!within_current_scope)
@@ -5111,7 +5118,7 @@ create_breakpoint (struct symtabs_and_li
       if (b->cond_string)
 	{
 	  char *arg = b->cond_string;
-	  loc->cond = parse_exp_1 (&arg, block_for_pc (loc->address), 0);
+	  loc->cond = parse_exp_1 (&arg, loc->address, 0);
 	  if (*arg)
               error (_("Garbage %s follows condition"), arg);
 	}
@@ -5410,7 +5417,7 @@ find_condition_and_thread (char *tok, CO
       if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
 	{
 	  tok = cond_start = end_tok + 1;
-	  parse_exp_1 (&tok, block_for_pc (pc), 0);
+	  parse_exp_1 (&tok, pc, 0);
 	  cond_end = tok;
 	  *cond_string = savestring (cond_start, 
 				     cond_end - cond_start);
@@ -5916,7 +5923,7 @@ watch_command_1 (char *arg, int accessfl
   /* Parse the rest of the arguments.  */
   innermost_block = NULL;
   exp_start = arg;
-  exp = parse_exp_1 (&arg, 0, 0);
+  exp = parse_exp_1 (&arg, ~(CORE_ADDR) 0, 0);
   exp_end = arg;
   exp_valid_block = innermost_block;
   mark = value_mark ();
@@ -5936,7 +5943,7 @@ watch_command_1 (char *arg, int accessfl
   if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
     {
       tok = cond_start = end_tok + 1;
-      cond = parse_exp_1 (&tok, 0, 0);
+      cond = parse_exp_1 (&tok, ~(CORE_ADDR) 0, 0);
       cond_end = tok;
     }
   if (*tok)
@@ -7326,8 +7333,7 @@ update_breakpoint_locations (struct brea
 	  s = b->cond_string;
 	  TRY_CATCH (e, RETURN_MASK_ERROR)
 	    {
-	      new_loc->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 
-					   0);
+	      new_loc->cond = parse_exp_1 (&s, sals.sals[i].pc, 0);
 	    }
 	  if (e.reason < 0)
 	    {
Index: src/gdb/eval.c
===================================================================
--- src.orig/gdb/eval.c	2008-05-03 23:17:27.000000000 +0100
+++ src/gdb/eval.c	2008-05-03 23:23:41.000000000 +0100
@@ -98,7 +98,7 @@ parse_and_eval_address (char *exp)
 CORE_ADDR
 parse_and_eval_address_1 (char **expptr)
 {
-  struct expression *expr = parse_exp_1 (expptr, (struct block *) 0, 0);
+  struct expression *expr = parse_exp_1 (expptr, ~(CORE_ADDR) 0, 0);
   CORE_ADDR addr;
   struct cleanup *old_chain =
     make_cleanup (free_current_contents, &expr);
@@ -143,7 +143,7 @@ parse_and_eval (char *exp)
 struct value *
 parse_to_comma_and_eval (char **expp)
 {
-  struct expression *expr = parse_exp_1 (expp, (struct block *) 0, 1);
+  struct expression *expr = parse_exp_1 (expp, ~(CORE_ADDR) 0, 1);
   struct value *val;
   struct cleanup *old_chain =
     make_cleanup (free_current_contents, &expr);
Index: src/gdb/tracepoint.c
===================================================================
--- src.orig/gdb/tracepoint.c	2008-05-03 23:17:27.000000000 +0100
+++ src/gdb/tracepoint.c	2008-05-03 23:23:41.000000000 +0100
@@ -973,7 +973,7 @@ validate_actionline (char **line, struct
 		}
 	      /* else fall thru, treat p as an expression and parse it!  */
 	    }
-	  exp = parse_exp_1 (&p, block_for_pc (t->address), 1);
+	  exp = parse_exp_1 (&p, t->address, 1);
 	  old_chain = make_cleanup (free_current_contents, &exp);
 
 	  if (exp->elts[0].opcode == OP_VAR_VALUE)
@@ -1600,8 +1600,7 @@ encode_actions (struct tracepoint *t, ch
 		  struct cleanup *old_chain1 = NULL;
 		  struct agent_reqs areqs;
 
-		  exp = parse_exp_1 (&action_exp, 
-				     block_for_pc (t->address), 1);
+		  exp = parse_exp_1 (&action_exp, t->address, 1);
 		  old_chain = make_cleanup (free_current_contents, &exp);
 
 		  switch (exp->elts[0].opcode)
Index: src/gdb/varobj.c
===================================================================
--- src.orig/gdb/varobj.c	2008-05-03 23:17:27.000000000 +0100
+++ src/gdb/varobj.c	2008-05-03 23:23:41.000000000 +0100
@@ -447,7 +447,6 @@ varobj_create (char *objname,
   struct varobj *var;
   struct frame_info *fi;
   struct frame_info *old_fi = NULL;
-  struct block *block;
   struct cleanup *old_chain;
 
   /* Fill out a varobj structure for the (root) variable being constructed. */
@@ -460,6 +459,7 @@ varobj_create (char *objname,
       enum varobj_languages lang;
       struct value *value = NULL;
       int expr_len;
+      CORE_ADDR context_pc;
 
       /* Parse and evaluate the expression, filling in as much
          of the variable's data as possible */
@@ -480,15 +480,16 @@ varobj_create (char *objname,
       if (type == USE_SELECTED_FRAME)
 	var->root->floating = 1;
 
-      block = NULL;
       if (fi != NULL)
-	block = get_frame_block (fi, 0);
+	context_pc = get_frame_pc (fi);
+      else
+	context_pc = ~(CORE_ADDR) 0;
 
       p = expression;
       innermost_block = NULL;
       /* Wrap the call to parse expression, so we can 
          return a sensible error. */
-      if (!gdb_parse_exp_1 (&p, block, 0, &var->root->exp))
+      if (!gdb_parse_exp_1 (&p, context_pc, 0, &var->root->exp))
 	{
 	  return NULL;
 	}
@@ -898,7 +899,7 @@ varobj_set_value (struct varobj *var, ch
   gdb_assert (varobj_editable_p (var));
 
   input_radix = 10;		/* ALWAYS reset to decimal temporarily */
-  exp = parse_exp_1 (&s, 0, 0);
+  exp = parse_exp_1 (&s, ~(CORE_ADDR) 0, 0);
   if (!gdb_evaluate_expression (exp, &value))
     {
       /* We cannot proceed without a valid expression. */
Index: src/gdb/wrapper.h
===================================================================
--- src.orig/gdb/wrapper.h	2008-05-03 23:17:27.000000000 +0100
+++ src/gdb/wrapper.h	2008-05-03 23:23:41.000000000 +0100
@@ -24,7 +24,7 @@ struct value;
 struct expression;
 struct block;
 
-extern int gdb_parse_exp_1 (char **, struct block *,
+extern int gdb_parse_exp_1 (char **, CORE_ADDR,
 			    int, struct expression **);
 
 extern int gdb_evaluate_expression (struct expression *, struct value **);
Index: src/gdb/wrapper.c
===================================================================
--- src.orig/gdb/wrapper.c	2008-05-03 23:17:27.000000000 +0100
+++ src/gdb/wrapper.c	2008-05-03 23:23:41.000000000 +0100
@@ -22,14 +22,14 @@
 #include "ui-out.h"
 
 int
-gdb_parse_exp_1 (char **stringptr, struct block *block, int comma,
+gdb_parse_exp_1 (char **stringptr, CORE_ADDR context_pc, int comma,
 		 struct expression **expression)
 {
   volatile struct gdb_exception except;
 
   TRY_CATCH (except, RETURN_MASK_ERROR)
     {
-      *expression = parse_exp_1 (stringptr, block, comma);
+      *expression = parse_exp_1 (stringptr, context_pc, comma);
     }
 
   if (except.reason < 0)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: expressions with C preprocessor macro info
  2008-05-03 23:27   ` Pedro Alves
@ 2008-06-05 16:27     ` Daniel Jacobowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2008-06-05 16:27 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Sat, May 03, 2008 at 11:32:31PM +0100, Pedro Alves wrote:
> 	* expression.h (parse_exp_1): Take a context PC instead of a
> 	context block.

I'm thinking out loud here, but I think we should pass the PC _and_
the block.  Suppose we have inlined function support, which I'm still
hoping to submit soon.  Then there will be multiple relevant blocks
with different source locations at the same PC: the innermost
instruction, its "call site", and so forth.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-06-05 16:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-03 20:38 expressions with C preprocessor macro info Pedro Alves
2008-05-03 20:40 ` Daniel Jacobowitz
2008-05-03 23:27   ` Pedro Alves
2008-06-05 16:27     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox