What about add new commands "maintenance agent-breakpoint id expression" and "maintenance agent-eval-breakpoint id expression"

Yao Qi yao@codesourcery.com
Tue Jun 12 13:15:00 GMT 2012

On 06/12/2012 07:41 PM, Hui Zhu wrote:
>> > Agent expression evaluation makes sense in the context of "current
>> > scope" or "current frame".  We can't switch to a frame at any arbitrary
>> > address, because the frame maybe does not exist.
>> >
> What your worry about is line "expr = parse_expression (exp);" cannot
> work, right?
> It can be change to function "parse_exp_1" to handle this issue.
> BTW if agent generate need current scope or current frame, how this
> code generate when breakpoint or tracepoint use it? :)

My reply was on the context of "maint agent"/"maint agent-expr" which
you asked about.  My full reply should be "In 'maint agent'/'maint
agent-expr', agent expression evaluation makes in ....".

I am not worried about parse_expression, but

  struct frame_info *fi = get_current_frame ();	/* need current scope */
  agent = gen_eval_for_expr (get_frame_pc (fi), expr);

gives me the feeling that we need a correct frame here.

When using variable in condition or actions in breakpoint or tracepoint,
the variable should be *visible* under a certain frame (not current
frame that we are setting breakpoint/tracepoint, as I observed).

> It have too much limit.  For example, it will not work when we want
> collect an local var inside of a function.

It is odd.  I can collect a local variable ii in function foo.

(gdb) target remote :1234
(gdb) b end
Breakpoint 1 at 0x80483c9: file 1.c, line 10.
(gdb) trace foo:label
Tracepoint 2 at 0x80483c1: file 1.c, line 5.
(gdb) actions
Enter actions for tracepoint 2, one per line.
End with a line saying just "end".
>collect ii
(gdb) tstart
(gdb) c

Breakpoint 1, end () at 1.c:10
10	void end () {}
(gdb) tstop
(gdb) tfind
Found trace frame 0, tracepoint 2
#0  foo () at 1.c:6
6	  return ii;
(gdb) tdump
Data collected at tracepoint 2, trace frame 0:
ii = 0

---- 1.c ----
int foo (void)
  int ii = 0;

  return ii;

void end () {}

int main (void)
  int i = foo ();

  end ();
  return 0;
Yao (齐尧)

More information about the Gdb mailing list