[PATCH 1/2] use zuinteger_unlimited for some remote commands

Yao Qi yao@codesourcery.com
Mon Mar 4 14:38:00 GMT 2013


On 03/04/2013 09:19 PM, Pedro Alves wrote:
> On 02/15/2013 01:27 PM, Yao Qi wrote:
>> -int remote_hw_watchpoint_limit = -1;
>> -int remote_hw_watchpoint_length_limit = -1;
>> -int remote_hw_breakpoint_limit = -1;
>> +static unsigned int remote_hw_watchpoint_limit = UINT_MAX;
>> +static unsigned int remote_hw_watchpoint_length_limit = UINT_MAX;
>> +static unsigned int remote_hw_breakpoint_limit = UINT_MAX;
>
> ...
>
>> @@ -8259,7 +8255,7 @@ remote_check_watch_resources (int type, int cnt, int ot)
>>       {
>>         if (remote_hw_watchpoint_limit == 0)
>>   	return 0;
>> -      else if (remote_hw_watchpoint_limit < 0)
>> +      else if (remote_hw_watchpoint_limit == UINT_MAX)
>
> This made me notice something with var_zuinteger_unlimited.
>
> What's the point of making it work with unsigned variables,
> and UINT_MAX, if the contents of the variable are actually
> treated as int everywhere in cli-setshow.c? (and val is
> still cut at INT_MAX).  Vis, e.g.,
>

Yes, in cli-setshow.c, the val is treated as signed integer, because -1 
stands for unlimited.  Outside of cli, var_zuinteger_unlimited is about 
a unsigned integer with a unlimited state.  That is reason I change type 
of "remote_hw_watchpoint_limit" from signed to unsigned.  Their default 
value is unlimited (-1), so I initialize them to UINT_MAX.  Originally I 
used "(unsigned int) -1", but UINT_MAX is better as "unlimited" here.

-- 
Yao (齐尧)



More information about the Gdb-patches mailing list