This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Fix breakpoint condition that use member variables.


Eli's raised a valid concern, but I think it's unrelated to this
change, so I will review this patch independently of it.

On Sat, Mar 22, 2008 at 12:40:15PM +0300, Vladimir Prus wrote:
> -    /* If this is non-NULL, lookup_symbol will do the 'field_of_this'
> -       check, using this function to find the value of this.  */
> +    /* If this is non-NULL, specifies the name that of the implicit
> +       local variable that refers to the current object instance.  */

Drop "that" in the first line.

> diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
> index 6b51fd5..400338e 100644
> --- a/gdb/m2-lang.c
> +++ b/gdb/m2-lang.c
> @@ -375,7 +375,7 @@ const struct language_defn m2_language_defn =
>    m2_val_print,			/* Print a value using appropriate syntax */
>    c_value_print,		/* Print a top-level value */
>    NULL,				/* Language specific skip_trampoline */
> -  value_of_this,		/* value_of_this */
> +  "this",		        /* name_of_this */
>    basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
>    basic_lookup_transparent_type,/* lookup_transparent_type */
>    NULL,				/* Language specific symbol demangler */

This can be NULL.

> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index ddd2310..7d9b4ea 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -1198,17 +1198,34 @@ lookup_symbol_aux (const char *name, const char 
> *linkage_name,
>  
>    langdef = language_def (language);
>  
> -  if (langdef->la_value_of_this != NULL
> -      && is_a_field_of_this != NULL)
> +  if (langdef->la_name_of_this != NULL && is_a_field_of_this != NULL
> +      && block != NULL && !dict_empty (BLOCK_DICT (block)))
>      {
> -      struct value *v = langdef->la_value_of_this (0);
> -
> -      if (v && check_field (v, name))
> +      struct symbol *sym = lookup_block_symbol (block, 
> langdef->la_name_of_this,
> +						NULL, VAR_DOMAIN);

value_of_local always gets the function block.  This might have an
inner block that does not correspond to the function.  I think you
need to find the enclosing function before checking dict_empty or
calling lookup_block_symbol.  You could use block_function to get
the symbol and then SYMBOL_BLOCK_VALUE to get the containing
block, or just walk up BLOCK_SUPERBLOCK looking for BLOCK_FUNCTION.

> @@ -2773,10 +2739,7 @@ value_of_local (const char *name, int complain)
>  struct value *
>  value_of_this (int complain)
>  {
> -  if (current_language->la_language == language_objc)
> -    return value_of_local ("self", complain);
> -  else
> -    return value_of_local ("this", complain);
> +  return value_of_local (current_language->la_name_of_this, complain);
>  }
>  
>  /* Create a slice (sub-string, sub-array) of ARRAY, that is LENGTH

Is this going to crash if we get here for a language where it is NULL?

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]