Skip to content
Snippets Groups Projects
  • Maciej W. Rozycki's avatar
    7aeb03e2
    GDB: Allow arbitrary keywords in integer set commands · 7aeb03e2
    Maciej W. Rozycki authored
    
    Rather than just `unlimited' allow the integer set commands (or command
    options) to define arbitrary keywords for the user to use, removing
    hardcoded arrangements for the `unlimited' keyword.
    
    Remove the confusingly named `var_zinteger', `var_zuinteger' and
    `var_zuinteger_unlimited' `set'/`show' command variable types redefining
    them in terms of `var_uinteger', `var_integer' and `var_pinteger', which
    have the range of [0;UINT_MAX], [INT_MIN;INT_MAX], and [0;INT_MAX] each.
    
    Following existing practice `var_pinteger' allows extra negative values
    to be used, however unlike `var_zuinteger_unlimited' any number of such
    values can be defined rather than just `-1'.
    
    The "p" in `var_pinteger' stands for "positive", for the lack of a more
    appropriate unambiguous letter, even though 0 obviously is not positive;
    "n" would be confusing as to whether it stands for "non-negative" or
    "negative".
    
    Add a new structure, `literal_def', the entries of which define extra
    keywords allowed for a command and numerical values they correspond to.
    Those values are not verified against the basic range supported by the
    underlying variable type, allowing extra values to be allowed outside
    that range, which may or may not be individually made visible to the
    user.  An optional value translation is possible with the structure to
    follow the existing practice for some commands where user-entered 0 is
    internally translated to UINT_MAX or INT_MAX.  Such translation can now
    be arbitrary.  Literals defined by this structure are automatically used
    for completion as necessary.
    
    So for example:
    
    const literal_def integer_unlimited_literals[] =
      {
        { "unlimited", INT_MAX, 0 },
        { nullptr }
      };
    
    defines an extra `unlimited' keyword and a user-visible 0 value, both of
    which get translated to INT_MAX for the setting to be used with.
    
    Similarly:
    
    const literal_def zuinteger_unlimited_literals[] =
      {
        { "unlimited", -1, -1 },
        { nullptr }
      };
    
    defines the same keyword and a corresponding user-visible -1 value that
    is used for the requested setting.  If the last member were omitted (or
    set to `{}') here, then only the keyword would be allowed for the user
    to enter and while -1 would still be used internally trying to enter it
    as a part of a command would result in an "integer -1 out of range"
    error.
    
    Use said error message in all cases (citing the invalid value requested)
    replacing "only -1 is allowed to set as unlimited" previously used for
    `var_zuinteger_unlimited' settings only rather than propagating it to
    `var_pinteger' type.  It could only be used for the specific case where
    a single extra `unlimited' keyword was defined standing for -1 and the
    use of numeric equivalents is discouraged anyway as it is for historical
    reasons only that they expose GDB internals, confusingly different
    across variable types.  Similarly update the "must be >= -1" Guile error
    message.
    
    Redefine Guile and Python parameter types in terms of the new variable
    types and interpret extra keywords as Scheme keywords and Python strings
    used to communicate corresponding parameter values.  Do not add a new
    PARAM_INTEGER Guile parameter type, however do handle the `var_integer'
    variable type now, permitting existing parameters defined by GDB proper,
    such as `listsize', to be accessed from Scheme code.
    
    With these changes in place it should be trivial for a Scheme or Python
    programmer to expand the syntax of the `make-parameter' command and the
    `gdb.Parameter' class initializer to have arbitrary extra literals along
    with their internal representation supplied.
    
    Update the testsuite accordingly.
    
    Approved-By: default avatarSimon Marchi <simon.marchi@efficios.com>
    7aeb03e2
    History
    GDB: Allow arbitrary keywords in integer set commands
    Maciej W. Rozycki authored
    
    Rather than just `unlimited' allow the integer set commands (or command
    options) to define arbitrary keywords for the user to use, removing
    hardcoded arrangements for the `unlimited' keyword.
    
    Remove the confusingly named `var_zinteger', `var_zuinteger' and
    `var_zuinteger_unlimited' `set'/`show' command variable types redefining
    them in terms of `var_uinteger', `var_integer' and `var_pinteger', which
    have the range of [0;UINT_MAX], [INT_MIN;INT_MAX], and [0;INT_MAX] each.
    
    Following existing practice `var_pinteger' allows extra negative values
    to be used, however unlike `var_zuinteger_unlimited' any number of such
    values can be defined rather than just `-1'.
    
    The "p" in `var_pinteger' stands for "positive", for the lack of a more
    appropriate unambiguous letter, even though 0 obviously is not positive;
    "n" would be confusing as to whether it stands for "non-negative" or
    "negative".
    
    Add a new structure, `literal_def', the entries of which define extra
    keywords allowed for a command and numerical values they correspond to.
    Those values are not verified against the basic range supported by the
    underlying variable type, allowing extra values to be allowed outside
    that range, which may or may not be individually made visible to the
    user.  An optional value translation is possible with the structure to
    follow the existing practice for some commands where user-entered 0 is
    internally translated to UINT_MAX or INT_MAX.  Such translation can now
    be arbitrary.  Literals defined by this structure are automatically used
    for completion as necessary.
    
    So for example:
    
    const literal_def integer_unlimited_literals[] =
      {
        { "unlimited", INT_MAX, 0 },
        { nullptr }
      };
    
    defines an extra `unlimited' keyword and a user-visible 0 value, both of
    which get translated to INT_MAX for the setting to be used with.
    
    Similarly:
    
    const literal_def zuinteger_unlimited_literals[] =
      {
        { "unlimited", -1, -1 },
        { nullptr }
      };
    
    defines the same keyword and a corresponding user-visible -1 value that
    is used for the requested setting.  If the last member were omitted (or
    set to `{}') here, then only the keyword would be allowed for the user
    to enter and while -1 would still be used internally trying to enter it
    as a part of a command would result in an "integer -1 out of range"
    error.
    
    Use said error message in all cases (citing the invalid value requested)
    replacing "only -1 is allowed to set as unlimited" previously used for
    `var_zuinteger_unlimited' settings only rather than propagating it to
    `var_pinteger' type.  It could only be used for the specific case where
    a single extra `unlimited' keyword was defined standing for -1 and the
    use of numeric equivalents is discouraged anyway as it is for historical
    reasons only that they expose GDB internals, confusingly different
    across variable types.  Similarly update the "must be >= -1" Guile error
    message.
    
    Redefine Guile and Python parameter types in terms of the new variable
    types and interpret extra keywords as Scheme keywords and Python strings
    used to communicate corresponding parameter values.  Do not add a new
    PARAM_INTEGER Guile parameter type, however do handle the `var_integer'
    variable type now, permitting existing parameters defined by GDB proper,
    such as `listsize', to be accessed from Scheme code.
    
    With these changes in place it should be trivial for a Scheme or Python
    programmer to expand the syntax of the `make-parameter' command and the
    `gdb.Parameter' class initializer to have arbitrary extra literals along
    with their internal representation supplied.
    
    Update the testsuite accordingly.
    
    Approved-By: default avatarSimon Marchi <simon.marchi@efficios.com>
py-param.c 26.00 KiB