This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Handle OP_THIS in tracepoints
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Stan Shebs <stan at codesourcery dot com>
- Date: Thu, 24 Dec 2009 16:34:54 +0000
- Subject: Re: [PATCH] Handle OP_THIS in tracepoints
- References: <4B32C4ED.6050904@codesourcery.com>
On Thursday 24 December 2009 01:33:33, Stan Shebs wrote:
> This one comes up pretty quickly when doing tracepoints in C++; members
> in expressions use OP_THIS, which amounts to shorthand for a reference
> to the implicit argument "this". Handling is uncomplicated, mimics
> expression evaluation.
>
> + case OP_THIS:
> + {
> + char *name;
> + struct frame_info *frame;
> + struct symbol *func, *sym;
> + struct block *b;
> +
> + name = current_language->la_name_of_this;
> + if (!name)
> + error (_("no `this' in current language"));
> +
> + frame = get_selected_frame (_("no frame selected"));
> +
> + func = get_frame_function (frame);
> + if (!func)
> + error (_("no `%s' in nameless context"), name);
> +
> + b = SYMBOL_BLOCK_VALUE (func);
> + if (dict_empty (BLOCK_DICT (b)))
> + error (_("no args, no `%s' in block"), name);
> +
> + /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
> + symbol instead of the LOC_ARG one (if both exist). */
> + sym = lookup_block_symbol (b, name, NULL, VAR_DOMAIN);
> + if (!sym)
> + error (_("no `%s' found"), name);
> +
> + gen_var_ref (exp->gdbarch, ax, value, sym);
> + (*pc) += 2;
> + }
> + break;
> +
> case OP_TYPE:
> error (_("Attempt to use a type name as an expression."));
>
This is busted, and was later fixed in our internal
tree. :-) The selected frame, and the current language
don't have anything to do with the context in which
the tracepoint runs. E.g.:
(gdb) trace 'Foo::Bar()'
(gdb) actions
(gdb) collect foo_field
Here, the `this' for foo_field needs to be
looked up in the context of Foo::Bar, not of whatever
context/frame the user had selected when she issued
the 'actions' command.
(Note that `maint agent(-eval)' always works in the context
of the selected frame, so testing with that alone can
mask out these issues.)
--
Pedro Alves