Re: [PATCH] dynamic printf

Tom Tromey
2012-03-14T15:24:21Z

>>>>> "Stan" == Stan Shebs <stanshebs@earthlink.net> writes:

Tom> I think you have to have a comma after the location. That is the only
Tom> reliable linespec terminator.

Stan> Hmmm. The format is a string though; would linespec parsing attempt
Stan> to proceed into that? How is "break <location> if foo" working these
Stan> days?

It is handled in multiple spots -- linespec.c:keep_name_info, but also
every language expression parser.

Probably linespec could be changed to make this syntax work, but I don't
see how the parsers could. E.g., the C parser will lex the printf
format string as a string token, then proceed to fail to parse, throwing
an exception.

That is, the case that breaks this is: dprintf *main "format".
This works, though, due to the fact that linespec uses
parse_to_comma_and_eval: dprintf *main, "format"

Stan> + struct agent_expr *cmd_bytecode;

Tom> Needs a comment.
Tom> Perhaps subclassing bp_location is also doable?

Stan> I'm not sure what you mean by this?

I thought it was possible to make a subclass of bp_location, arranging
for your breakpoint ops to override the appropriate allocation method.
Then only dprintf breakpoint locations would have the extra field.

I'm not totally sure, I haven't tried it.

Tom