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 v2] Extend gdb.parse_and_eval to accept a format string


Hi,

Attached is the v2 of the 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

For reference, the posting for the v1 of this patch is here:
https://sourceware.org/ml/gdb-patches/2013-12/msg00985.html

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.

The idea here is that the format string argument will be parsed and
evaluated as an expression after the "${N}" occurances in it are
replaced with an internal variable having the same value as encapsulated
by the Nth gdb.Value arg.

As with the v1, I still do not have 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. The difference between v2 and v1 is the way in which the
internalvar is created and set. Though I am really not sure which
approach is best, I am slightly inclined towards the approach in v2.

2014-02-02  Siva Chandra Reddy  <sivachandra@google.com>

        * parse.c (write_dollar_variable): Pass 0 for the "true_alias"
        arg of create_internalvar.
        * value.c (struct internalvar): New field "true_alias".
        (set_internalvar_true_alias): New function.
        (value_of_internalvar): Do not set VALUE_LVAL to lval_internalvar
        if "true_alias" field of internalvar is set.
        * value.h (set_internalvar_true_alias): Declaration of the new
        function.
        * 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_v2.txt
Description: Text document


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