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]

[RFC] Extend gdb.parse_and_eval to accept a format string.


Hi,

Attached is a patch which extends gdb.parse_and_eval to accept a
format string. The idea was roughly put down by Doug here:
https://sourceware.org/ml/gdb-patches/2013-12/msg00709.html

My patch does not do exactly the same as what Doug did in his example;
Instead of using %V, I used ${N} syntax. If the string argument to
gdb.parse_and_eval is a format string, then a variable number of args
of type gdb.Value can follow. The number of gdb.Value args to be
passed is determined by the format string. The Nth gdb.Value arg is
referenced by "${N}" in the format string. The value of N starts at 0.

I have not made any docs or NEWS changes as I am not sure if the idea
in the patch is acceptable at all. I have however added tests.

        * parse.c (write_dollar_variable): Pass 0 for the "true_alias"
        arg of create_internalvar.
        * value.c (struct internalvar): New field "true_alias".
        (create_internalvar): New arg 'true_alias'.
        (create_internalvar_type_lazy): Pass 0 for the "true_alias" arg
        of create_internalvar.
        (value_of_internalvar): Do not set VALUE_LVAL to lval_internalvar
        if "true_alias" field of internalvar is set.
        * value.h (create_internalvar): Change prototype.
        * python/python.c (get_python_internalvar_name): New function.
        (validate_expression): New function.
        (parse_args_for_parse_and_eval): New function.
        (gdbpy_parse_and_eval): Use parse_args_for_parse_and_eval.

        testsuite/
        * gdb.python/py-value.exp: Add new tests.

Attachment: parse_and_eval_patch_v1.txt
Description: Text document


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